menu.c
7.7 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
/*======================================================================*/
/* NuSYS 64GBPak test sample */
/* menu.c */
/* */
/* Copyright (C) 1997, NINTENDO Co,Ltd. */
/*======================================================================*/
#include <nusys.h>
#include "localdef.h"
extern Gfx* gfxListPtr;
extern Gfx* gfxListStartPtr;
extern void gfxListBufferChange(void);
extern void gfxClearCfb(u32 size);
extern NUContData contData[4];
extern void funccheck(s32 funcNo);
/*----------------------------------------------------------------------*/
/* MENU用の文字列定義 */
/*----------------------------------------------------------------------*/
struct st_menuList;
typedef struct st_menuLink {
struct st_menuList **list;
} MenuLink;
typedef struct st_menuList {
u8* title;
struct st_menuList* next;
s32 flag;
} MenuList;
MenuList funcTestPowerList[] = {
{"64GBPack Power OFF", NULL, MENU_FUNCPOWER},
{"64GBPack Power ON", NULL, MENU_FUNCPOWER},
{NULL, NULL, 0}
};
MenuList funcTestList[] = {
{"nuContGBPakOpen()", NULL, MENU_FUNCTEST},
{"nuContGBPakGetStatus()", NULL, MENU_FUNCTEST},
{"nuContGBPakPower()", funcTestPowerList, MENU_MODE},
{"nuContGBPakReadID()", NULL, MENU_FUNCTEST},
{"nuContGBPakRead()", NULL, MENU_FUNCTEST},
{"nuContGBPakWrite()", NULL, MENU_FUNCTEST},
{"nuContGBPakCheckConnector()", NULL, MENU_FUNCTEST},
{"nuContGBPakFread()", NULL, MENU_FUNCTEST},
{"nuContGBPakFwrite()", NULL, MENU_FUNCTEST},
{"nuContGBPakRegWrite()", NULL, MENU_FUNCTEST},
{NULL, NULL, 0}
};
MenuList* menuListPtr = funcTestList; /* 表示するメニューリスト */
MenuList* menuListPrev[4]; /* 選択したメニューの履歴 */
u8 menuSel[8];
u8 menuDeps; /* メニュー階層の深度 */
s32 menuFlag; /* メニュー表示制御用のフラグ */
s32 dispFlag; /* 表示用のフラグ */
NUContPakFile file[MAXCONTROLLERS];
s32 contNo = 0;
u8 gbpakInit[MAXCONTROLLERS] = {0, 0, 0, 0};
OSGbpakId gbpakId[MAXCONTROLLERS];
u8 gbData[0x10000];
/*----------------------------------------------------------------------*/
/* dispFrame - 画面の枠の表示 */
/* 画面の枠を表示する。といってもテキスト文字で。 */
/* IN: 無し */
/* RET: 無し */
/*----------------------------------------------------------------------*/
void dispFrame(void)
{
s32 cnt;
nuDebConTextColor(NU_DEB_CON_WINDOW0, NU_DEB_CON_TEXT_LIGHTBLUE);
nuDebConTextPos(NU_DEB_CON_WINDOW0, 1, 1);
nuDebConCPuts(NU_DEB_CON_WINDOW0, " ==================================== ");
nuDebConTextPos(NU_DEB_CON_WINDOW0, 12, 1);
nuDebConCPuts(NU_DEB_CON_WINDOW0, "64GB Pack Test");
for(cnt = 0; cnt < 26; cnt++){
nuDebConTextPos(NU_DEB_CON_WINDOW0, 1, 2 + cnt);
nuDebConCPuts(NU_DEB_CON_WINDOW0, "#");
nuDebConTextPos(NU_DEB_CON_WINDOW0, 38, 2 + cnt);
nuDebConCPuts(NU_DEB_CON_WINDOW0, "#");
}
nuDebConTextPos(NU_DEB_CON_WINDOW0, 1, 28);
nuDebConCPuts(NU_DEB_CON_WINDOW0, " ==================================== ");
nuDebConTextColor(NU_DEB_CON_WINDOW0, NU_DEB_CON_TEXT_WHITE);
}
/*----------------------------------------------------------------------*/
/* dispMenu - メニューの表示 */
/* メニュー階層のうち、指定されているメニューのリストを表示する */
/* IN: 無し */
/* RET: 無し */
/*----------------------------------------------------------------------*/
void dispMenu(void)
{
s32 cnt;
for(cnt = 0; menuListPtr[cnt].title != NULL; cnt++){
if(cnt == menuSel[menuDeps]){
nuDebConTextColor(NU_DEB_CON_WINDOW0, NU_DEB_CON_TEXT_RED);
nuDebConTextPos(NU_DEB_CON_WINDOW0, 3, 3 + menuSel[menuDeps] * 2);
nuDebConCPuts(NU_DEB_CON_WINDOW0, ">");
} else {
nuDebConTextColor(NU_DEB_CON_WINDOW0, NU_DEB_CON_TEXT_WHITE);
}
nuDebConTextPos(NU_DEB_CON_WINDOW0, 4, 3 + cnt * 2);
nuDebConCPuts(NU_DEB_CON_WINDOW0, menuListPtr[cnt].title);
}
}
/*----------------------------------------------------------------------*/
/* dispFuncTest - 選択した関数をサブタイトルとして表示する */
/* 選択した関数の関数名をサブタイトル位置に,センタリングして表示する*/
/* IN: 無し */
/* RET: 無し */
/*----------------------------------------------------------------------*/
void dispFuncTest(void)
{
s32 len;
nuDebConTextColor(NU_DEB_CON_WINDOW0, NU_DEB_CON_TEXT_GREEN);
for(len = 0; menuListPtr[menuSel[menuDeps]].title[len] != '\0'; len++)
;
nuDebConTextPos(NU_DEB_CON_WINDOW0, 20-len/2, 3);
nuDebConCPuts(NU_DEB_CON_WINDOW0, menuListPtr[menuSel[menuDeps]].title);
nuDebConTextColor(NU_DEB_CON_WINDOW0, NU_DEB_CON_TEXT_WHITE);
}
/*----------------------------------------------------------------------*/
/* dispConsole - 画面表示の制御 */
/* 現在の画面表示状態を認識して文字出力の制御をおこなう */
/* IN: 無し */
/* RET: 無し */
/*----------------------------------------------------------------------*/
void dispConsole(u32 taskNum)
{
gfxListBufferChange();
gfxClearCfb(0);
/* end top-level display list */
gDPFullSync(gfxListPtr++);
gSPEndDisplayList(gfxListPtr++);
nuGfxTaskStart(gfxListStartPtr, gfxListPtr - gfxListStartPtr,
NU_GFX_UCODE_S2DEX,NU_SC_NOSWAPBUFFER);
nuDebConDisp(NU_SC_SWAPBUFFER);
nuDebConClear(NU_DEB_CON_WINDOW0);
dispFrame();
switch(dispFlag){
case DISP_MENU:
dispMenu();
break;
case DISP_FUNCTEST:
dispFuncTest();
break;
case DISP_FUNCPOWER:
nuDebConTextColor(NU_DEB_CON_WINDOW0, NU_DEB_CON_TEXT_GREEN);
nuDebConTextPos(NU_DEB_CON_WINDOW0, 10, 3);
nuDebConCPuts(NU_DEB_CON_WINDOW0, "nuContGBPakPower");
break;
case DISP_FUNCREADWRITE:
break;
case DISP_FUNCINPUTADDR:
dispFuncTest();
break;
}
}
/*----------------------------------------------------------------------*/
/* mainMenu - 入力処理 */
/* パッド入力をチェックしてメニューリストの制御処理をおこなう */
/* IN: 無し */
/* RET: 無し */
/*----------------------------------------------------------------------*/
void mainMenu(void)
{
if(contData[0].trigger & D_JPAD){
if(menuListPtr[menuSel[menuDeps]+1].title != NULL){
menuSel[menuDeps]++;
}
}
if(contData[0].trigger & U_JPAD){
if(menuSel[menuDeps] > 0){
menuSel[menuDeps]--;
}
}
if(contData[0].trigger & A_BUTTON){
MenuList* nextListPtr;
nextListPtr = menuListPtr[menuSel[menuDeps]].next;
if(nextListPtr){
menuListPrev[menuDeps] = menuListPtr;
menuListPtr = nextListPtr;
menuDeps++;
menuSel[menuDeps] = 0;
} else {
menuFlag = menuListPtr[menuSel[menuDeps]].flag;
}
}
if(contData[0].trigger & B_BUTTON){
if(menuDeps){
menuDeps--;
menuListPtr = menuListPrev[menuDeps];
}
}
}
/*----------------------------------------------------------------------*/
/* メニュー操作の処理 */
/* IN: 特になし */
/* RET: 無し */
/*----------------------------------------------------------------------*/
void menu(void)
{
nuDebConScroll(NU_DEB_CON_WINDOW0, NU_DEB_CON_SCROLL_OFF);
nuDebConWindowShow(NU_DEB_CON_WINDOW1, NU_DEB_CON_WINDOW_OFF);
nuDebConWindowShow(NU_DEB_CON_WINDOW2, NU_DEB_CON_WINDOW_OFF);
nuDebConWindowShow(NU_DEB_CON_WINDOW3, NU_DEB_CON_WINDOW_OFF);
menuDeps = 0;
menuFlag = MENU_MODE;
dispFlag = DISP_MENU;
nuGfxDisplayOn();
nuGfxFuncSet(dispConsole);
while(1){
nuGfxRetraceWait(1);
/* コントローラデータの読み込み */
nuContDataGetExAll(contData);
switch(menuFlag){
case MENU_MODE:
dispFlag = DISP_MENU;
mainMenu();
break;
case MENU_FUNCTEST:
dispFlag = DISP_FUNCTEST;
funccheck(menuSel[menuDeps]);
menuFlag = MENU_MODE;
break;
case MENU_FUNCPOWER:
dispFlag = DISP_FUNCPOWER;
funccheck(menuSel[menuDeps-1]);
menuFlag = MENU_MODE;
menuDeps--;
menuListPtr = menuListPrev[menuDeps];
break;
}
}
}