forked from 0xGlitchbyte/TinyNightmare64
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nuboot.c
97 lines (75 loc) · 3.27 KB
/
nuboot.c
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
/*======================================================================*/
/* NuSYS */
/* nuboot.c */
/* */
/* Copyright (C) 1997, NINTENDO Co,Ltd. */
/* */
/*----------------------------------------------------------------------*/
/* Ver 1.0 97/10/9 Created by Kensaku Ohki(SLANP) */
/*======================================================================*/
#include <nusys.h>
static OSThread IdleThread; /* Idle thread */
static OSThread MainThread; /* main thread */
/*****************************************************************************/
/* The stack for the boot becomes reuseable when the first thread activates. */
/* Thus, it has been reused for the main thread. */
/*****************************************************************************/
u64 nuMainStack[NU_MAIN_STACK_SIZE/sizeof(u64)];/* boot/main thread stack */
static u64 IdleStack[NU_IDLE_STACK_SIZE/sizeof(u64)];/* Idle thread stack */
void (*nuIdleFunc)(void); /* Idle loop callback function */
/*--------------------------------------*/
/* Static Function */
/*--------------------------------------*/
static void idle(void *arg); /* idle function */
/*--------------------------------------*/
/* Extern Function */
/*--------------------------------------*/
extern void mainproc(void *arg); /* game main function */
/*----------------------------------------------------------------------*/
/* Initialize and activate NuSYS */
/* IN: The pointer for the main function */
/* RET: None */
/*----------------------------------------------------------------------*/
void nuBoot(void)
{
__osInitialize_common(); /* Initialize N64OS */
/* Create and execute the Idle thread */
osCreateThread(&IdleThread,NU_IDLE_THREAD_ID, idle, 0,
(IdleStack + NU_IDLE_STACK_SIZE/8), 10);
osStartThread(&IdleThread);
}
/*----------------------------------------------------------------------*/
/* IDLE */
/* IN: None */
/* RET: None */
/*----------------------------------------------------------------------*/
static void idle(void *arg)
{
/* Initialize the CALLBACK function */
nuIdleFunc = NULL;
nuPiInit();
/* Activate the scheduler */
/* Setting of VI is NTSC/ANTIALIASING/NON-INTERLACE/16bitPixel*/
/* Possible to change by osViSetMode. */
nuScCreateScheduler(OS_VI_NTSC_LAN1, 1);
/* Setting of the VI interface */
/* Specify OS_VI_DITHER_FILTER_ON and */
/* use the DITHER filter (Default is OFF). */
osViSetSpecialFeatures(OS_VI_DITHER_FILTER_ON
| OS_VI_GAMMA_OFF
| OS_VI_GAMMA_DITHER_OFF
| OS_VI_DIVOT_ON);
/* Create th main thread for the application. */
osCreateThread(&MainThread, NU_MAIN_THREAD_ID, mainproc, (void*)NULL,
(nuMainStack + NU_MAIN_STACK_SIZE/sizeof(u64)), NU_MAIN_THREAD_PRI);
osStartThread(&MainThread);
/* Lower priority of the IDLE thread and give the process to the main thread */
osSetThreadPri(&IdleThread, NU_IDLE_THREAD_PRI);
/* Idle loop */
while(1){
if((volatile)nuIdleFunc != NULL){
/* Execute the idle function */
(*nuIdleFunc)();
}
}
}