64dd.c
2.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/* 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);
}