game.c
2.9 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
102
103
104
105
106
107
108
109
/**************************************************************************
* *
* Copyright (C) 1995, Silicon Graphics, Inc. *
* *
* These coded instructions, statements, and computer programs contain *
* unpublished proprietary information of Silicon Graphics, Inc., and *
* are protected by Federal copyright law. They may not be disclosed *
* to third parties or copied or duplicated in any form, in whole or *
* in part, without the prior written consent of Silicon Graphics, Inc. *
* *
*************************************************************************/
/*---------------------------------------------------------------------*
Copyright (C) 1997,1998 Nintendo. (Originated by SGI)
$RCSfile: game.c,v $
$Revision: 1.1.1.1 $
$Date: 2002/05/02 03:27:32 $
*---------------------------------------------------------------------*/
#include "hostio.h"
#include <ultra64.h>
u64 bootStack[STACKSIZE/sizeof(u64)];
static void idle(void *);
static void mainproc(void *);
static OSThread idleThread;
static u64 idleThreadStack[STACKSIZE/sizeof(u64)];
static OSThread mainThread;
static u64 mainThreadStack[STACKSIZE/sizeof(u64)];
#define RDB_SEND_BUF_SIZE 2000
u8 rdbSendBuf[RDB_SEND_BUF_SIZE];
void
boot(void)
{
osInitialize();
osCreateThread(&idleThread, 1, idle, (void *)0,
idleThreadStack+STACKSIZE/sizeof(u64), 10);
osStartThread(&idleThread);
/* never reached */
}
static void
idle(void *arg)
{
osCreateViManager(OS_PRIORITY_VIMGR);
osViSetMode(&osViModeTable[OS_VI_NTSC_LAN1]);
osInitRdb(rdbSendBuf, RDB_SEND_BUF_SIZE);
/*
* Create main thread
*/
osCreateThread(&mainThread, 3, mainproc, arg,
mainThreadStack+STACKSIZE/sizeof(u64), 10);
osStartThread(&mainThread);
/*
* Become the idle thread
*/
osSetThreadPri(0, 0);
for (;;);
}
u8 SendBlockBuf[MY_MAX_BLOCK_SIZE];
u8 ReadBlockBuf[MY_MAX_BLOCK_SIZE];
/*
* This is the main routine of the app. We block waiting for the indy
* to send us a command block. Once we get that command we do something,
* like print an answer, get a block of data, or send a block of data.
*/
static void
mainproc(void *arg)
{
cmdBlk cb;
while(1)
{
osReadHost(&cb, sizeof(cmdBlk));
switch(cb.command)
{
case CMD_PRINT_SOMETHING:
osSyncPrintf("N64: Something\n");
break;
case CMD_WRITE_HOST:
osWriteHost(SendBlockBuf, cb.blkSize);
osSyncPrintf("N64: osWriteHost completed on %d bytes\n", cb.blkSize);
break;
case CMD_READ_HOST:
osReadHost(ReadBlockBuf, cb.blkSize);
osSyncPrintf("N64: osReadHost completed on %d bytes\n", cb.blkSize);
break;
}
}
}