main.c 1.98 KB
/*============================================================================

		NINTENDO64 TECHNICAL SUPPORT CENTER 
		
		    NINTENDO64 SAMPLE PROGRAM 1

		Copyright (C) 1997, NINTENDO Co,Ltd.

============================================================================*/

#include <ultra64.h>
#include <PR/ramrom.h>
#include <assert.h>

#include "def.h"
#include "vram.h"
#include "segment.h"
#include "message.h"
#include "nnsched.h"
#include "main.h"
#include "controller.h"
#include "audio.h"
#include "graphic.h"


NNSched sched;
int main_no;

/* 外部関数宣言 */
extern int main00(NNSched* );
extern int main01(NNSched* );

/*------------------------
	mainproc
--------------------------*/
void mainproc(void* arg)
{

  /* initialize audio */
  auAudioInit();

  /* initialize sequence player */
  auSeqPlayerInit(_midibankSegmentRomStart, _midibankSegmentRomEnd,
		  _seqSegmentRomStart, _seqSegmentRomEnd,
		  _miditableSegmentRomStart);

  /* initialize sound player */
  auSndPlayerInit(_sfxbankSegmentRomStart, _sfxbankSegmentRomEnd,
		  _sfxtableSegmentRomStart);


  /* create scheduler thread */
  nnScCreateScheduler(&sched, OS_VI_NTSC_LAN1, 1);

  /* create audio thread */
  auCreateAudioThread(&sched);

  /* graphic library の初期化 */
  gfxInit(_gfxdlistSegmentStart);

  /* craete graphic thread */
  gfxCreateGraphicThread(&sched);

  /*
     VIインターフェイスの設定
     OS_VI_DITHER_FILTER_ONを指定することでDITHERフィルターを使用できるように
     する。
  */
  osViSetSpecialFeatures(OS_VI_DITHER_FILTER_ON | OS_VI_GAMMA_OFF | OS_VI_GAMMA_DITHER_OFF);

  /* initialize controller (use max 4 controller)*/
  controllerInit(4);
  controllerThreadMake(&sched);

  main_no = MAIN_01;

  /* game main loop */
  while(1){
    switch(main_no){
    case MAIN_00:   /* main 00 */
      main_no = main00(&sched);
      break;
    case MAIN_01:   /* main 01 */
      main_no = main01(&sched);
      break;
    case MAIN_02:
    case MAIN_03:
    case MAIN_04:
      break;
   }
  }  /* end of while */
}