dd_summon.c
3.14 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
/*---------------------------------------------------------------------*
Copyright (C) 1998 Nintendo.
$RCSfile: dd_summon.c,v $
$Revision: 1.1.1.1 $
$Date: 2002/05/02 03:27:33 $
*---------------------------------------------------------------------*/
#include "hmenu.h"
#include "herr.h"
/* declarerations */
#define ITEM_H 16
#define BTILE_NUM 3
#define LABEL_NUM 12
#define MES_NUM 7
static TStringBar _label[LABEL_NUM];
static TStringBar _mes[MES_NUM];
static TBackTile _btile[BTILE_NUM];
static s32 _step = 0;
static TMessage4dd _ddmsg = {0};
/* functions */
static void _print(void);
static s32 _init(void);
/* implementation */
static void
_print(void)
{
s32 i,j,mes_num=0,max_width=0;
FORI(MES_NUM) _mes[i].visible = false;
_btile[0].visible = false;
switch(_step)
{
case 2:
case 3:
case 4:
sprintf( _mes[mes_num++].str ,"被起動ゲームをロード") ;
sprintf( _mes[mes_num++].str ,"しています……") ;
break;
}
if(mes_num) _btile[0].visible = true;
/* 表示位置の調整 */
FORI(mes_num)
{
j = sbar_getWidth(&_mes[i]);
max_width = (j>max_width) ? j : max_width;
_mes[i].visible = true;
}
_btile[0].w = max_width + 10;
j = ( SCREEN_WD - max_width ) / 2 ;
FORI(mes_num) _mes[i].x = j;
_btile[0].x = j - 5;
_btile[0].h = mes_num * 16;
/* 表示 */
FORI(BTILE_NUM) btile_show(&_btile[i]);
FORI(MES_NUM) sbar_show(&_mes[i]);
FORI(LABEL_NUM) sbar_show(&_label[i]);
}
void
scr_summon(void)
{
static s32 cnt=0,_first=1;
static LEODiskID _id;
if(_first)
{
--_first;
_init();
_step = 0;
}
_print();
if( dd_checkGate(&_ddmsg) )
{
switch(_step)
{
case 0: /* ディスクの確認 */
_ddmsg.command = LEOCMD_GETID;
_ddmsg.param.hi = (s32)&_id;
_ddmsg.param.lo = 0;
dd_exec( &_ddmsg );
++_step;
break;
case 1: /* 指定領域サイズの取得 */
if( _ddmsg.retVal )
{
if(!bcmp(_id.gameName,"REBT",4))
{
_ddmsg.command = LEOCMD_LBAREAD;
_ddmsg.param.hi = 49;
_ddmsg.param.lo = 1;
dd_exec( &_ddmsg );
++_step;
}
else
err_set(1);
break;
}
_step = 0;
break;
case 2: /* 被起動ゲームのロード */
if( _ddmsg.retVal )
{
_ddmsg.command = LEOCMD_LBAREAD;
_ddmsg.param.hi = *((s32 *)_ddmsg.param.rw);
_ddmsg.param.lo = *((s32 *)_ddmsg.param.rw + 1);
_ddmsg.param.rw = (u32)0x80400000;
dd_exec( &_ddmsg );
++_step;
}
else
_step = 0;
break;
case 3:
if( _ddmsg.retVal )
++_step;
else
_step = 0;
break;
case 4:
if ( ++cnt < 0 * 180 ) return;
osViBlack(1);
cnt = 0;
++_step;
break;
case 5:
#ifdef DEBUG
osSyncPrintf("load end\n");
osAppNMIBuffer[5] = 0x12345678;
osSyncPrintf("buffer is 0x%08x\n", osAppNMIBuffer[5]);
#endif
LeoBootGame((void *)0x80400000);
break;
default:
break;
}
}
}
static s32
_init(void)
{
s32 xpos,ypos,i;
xpos = 20;
ypos = 20;
FORI(MES_NUM) sbar_create(&_mes[i],"*" ,45 ,50 + i * 16 );
btile_create(&_btile[0] ,70 ,50 ,240 ,100 ,RGBA_BLUEALPHA );
_ddmsg.retQ = &myQ;
return -1;
}