64dd.c 2.98 KB
/* 64DD プロローグ */
/* copyright Nintendo co.,ltd. 1996 Mar. */
/* programed by S.Kato RD3 */
/*---------------------------------------------------------------------*/
/* パラメータ定義  */
#include <ultra64.h>
#include "64dd.h"
#define GAMMA_CORRECTION 1

/*-----------------------------------*/
/*   DESTINY AREA                    */
/*-----------------------------------*/
#define JAPAN                   0xe848d316
#define USA                     0x2263ee56
#define EUROPE                  0xffffffff  /* not defined */
#define ASIA                    0xffffffff  /* not defined */
#define DEVELOPER               0x00000000


#ifdef CJAPAN
#define CCODE   JAPAN
#else
#define CCODE   DEVELOPER
#endif

/*---------------------------------------------------------------------*/

extern void start(void);

global u64 bootStack[BOOT_STACKSIZE/sizeof(u64)];
static u64 idleStack[IDLE_STACKSIZE/sizeof(u64)];
static u64 mainStack[MAIN_STACKSIZE/sizeof(u64)];

/*---------------------------------------------------------------------*/
/* (3) main thread メイン・スレッド */
extern u32 LEO_country_code;
static OSMesgQueue mq;
static OSIoMesg mb;
static OSMesg msg[1];

static OSThread mainThread;

static void main(void *arg)
{
   osCreateViManager((OSPri)OS_PRIORITY_VIMGR);
   osViBlack(1);
   osViSetMode(&osViModeTable[OS_VI_NTSC_LAF1]);
   #if GAMMA_CORRECTION==0
     osViSetSpecialFeatures(OS_VI_GAMMA_OFF);
   #endif

   *(u8*)OS_PHYSICAL_TO_K1(0x00000010) = (((u32)CCODE & 0xff000000) >> 24); /* Save country_code */
   *(u8*)OS_PHYSICAL_TO_K1(0x00000090) = (((u32)CCODE & 0x00ff0000) >> 16);
   *(u8*)OS_PHYSICAL_TO_K1(0x00000110) = (((u32)CCODE & 0x0000ff00) >>  8);
   *(u8*)OS_PHYSICAL_TO_K1(0x00000190) = ( (u32)CCODE & 0x000000ff       );

   start();
}
/*---------------------------------------------------------------------*/
/* (2) rmon thread RMONスレッド */
#if RMON
  static OSThread rmonThread;
#endif
/*---------------------------------------------------------------------*/
/* (1) idle thread アイドル・スレッド */
static OSMesgQueue PiMesgQueue;
static OSMesg PiMesgs[NUM_PI_MSGS];
static OSThread idleThread;

static void idle(void *arg)
{
  osCreatePiManager((OSPri)OS_PRIORITY_PIMGR,&PiMesgQueue,PiMesgs,NUM_PI_MSGS);
  #if RMON
    osCreateThread(&rmonThread,(OSId)2,rmonMain,(void*)0,
	rmonStack+RMON_STACKSIZE/sizeof(u64),(OSPri)OS_PRIORITY_RMON);
    osStartThread(&rmonThread);
  #endif
  osCreateThread(&mainThread,(OSId)3,main,(void*)0,
	mainStack+MAIN_STACKSIZE/sizeof(u64),(OSPri)OS_PRIORITY_MAIN);
  osStartThread(&mainThread);

  osSetThreadPri((OSThread*)NULL,(OSPri)OS_PRIORITY_IDLE);
  while(1)osYieldThread();
}
/*---------------------------------------------------------------------*/
/* boot program ブートプログラム */

global void boot(void)
{
#ifdef PARTNER
extern void ptstart(void);
  osInitialize();
  ptstart();
#else
  osInitialize();
#endif
  osCreateThread(&idleThread,(OSId)1,idle,(void*)0,
	idleStack+IDLE_STACKSIZE/sizeof(u64),(OSPri)OS_PRIORITY_HIGH);
  osStartThread(&idleThread);
}