33
|
1 #include "Test.h"
|
|
2 #include "SgoexCerium.h"
|
|
3 #include <stdio.h>
|
|
4 #include <stdlib.h>
|
|
5 #include <string.h>
|
|
6 #include <ctype.h>
|
|
7 #include <math.h>
|
|
8 #include <time.h>
|
|
9 #include <SDL.h>
|
|
10 #include "SDL_opengl.h"
|
|
11 #include "object.h"
|
|
12 #include "tree_controll.h"
|
|
13 #include "xml.h"
|
|
14 #include "profile.h"
|
|
15 #include "syokika.h"
|
|
16 #include "sankaku.h"
|
|
17 #include "sgoex.h"
|
|
18 #include "sound.h"
|
|
19 #include "bool.h"
|
|
20 #include "bom.h"
|
|
21 #include "count2.h"
|
|
22 #include "tokuten.h"
|
|
23 #include "schedule.h"
|
|
24 #include "tama.h"
|
|
25 #include "debug.h"
|
|
26 #include "trace.h"
|
|
27 #include "LoadSprite.h"
|
|
28 #include <SDL_mixer.h>
|
|
29 #include "error.h"
|
|
30 #include "matrix_calc.h"
|
|
31
|
|
32 #include "Character.h"
|
|
33 #include "Character_state.h"
|
|
34
|
|
35 static int use_keybord = 0;
|
|
36
|
|
37 static int i;
|
|
38
|
|
39 static int test_mode = 0;
|
|
40 static const char *test_object = "" ;
|
|
41
|
|
42 //static SDL_Surface *screen;
|
|
43 // static Uint32 background;
|
|
44 // static char *pad_trace_file;
|
|
45
|
|
46 extern void schedule();
|
|
47 extern void tokuten();
|
|
48 extern void Pad();
|
|
49 extern void keybord();
|
|
50 static int gamesyokika(int gamef);
|
|
51 //static char *pad_trace_file;
|
|
52
|
|
53 /**
|
|
54 * runmode:
|
|
55 * 0 - normal game
|
|
56 * 1 - capture mode
|
|
57 * program will capture all pad traces on a play and
|
|
58 * dump it into a file
|
|
59 * 2 - trace mode
|
|
60 * program will run with a trace file which is generated
|
|
61 * by capture-mode
|
|
62 */
|
|
63 int runmode;
|
|
64
|
|
65 SDL_Joystick *joy;
|
|
66
|
|
67
|
|
68
|
|
69 const char *usr_help_str = "Usage: ./twice [-length data_length] [-count task_num]\n\
|
|
70 -length Number of data (default DATA_NUM (Func.h))\n\
|
|
71 -count Number of task (default 1)\n";
|
|
72
|
|
73 Viewer *droot;
|
|
74
|
|
75 static int screen_w;
|
|
76 static int screen_h;
|
|
77
|
|
78 MainLoopPtr
|
|
79 Test::init(Viewer *sgroot_, int w, int h)
|
|
80 {
|
|
81 screen_w = w;
|
|
82 screen_h = h;
|
|
83 droot = sgroot_;
|
|
84 return droot;
|
|
85 }
|
|
86
|
|
87 Application *
|
|
88 application() {
|
|
89 return new Test();
|
|
90 }
|
|
91
|
|
92
|
|
93 static int opening(int gamef);
|
|
94 static int dandy_closing(int gamef);
|
|
95 static int dandy_main_loop(int gamef);
|
|
96 static int dandy_main_init(int gamef);
|
|
97 extern int init(TaskManager *manager, int argc, char *argv[]);
|
|
98 extern void task_initialize();
|
|
99 static void TMend(TaskManager *manager);
|
|
100
|
|
101 bool
|
|
102 Test::app_loop(Viewer *viewer){
|
|
103 // don't use allExecute
|
|
104 return 0;
|
|
105 };
|
|
106
|
|
107 static int gamef = 0;
|
|
108
|
|
109 HTaskPtr
|
|
110 Test::application_task(HTaskPtr next, Viewer* viewer){
|
|
111 // printf("gamef = %d\n",gamef);
|
|
112 switch (gamef) {
|
|
113 case 0: gamef= dandy_main_init(gamef); break;
|
|
114 case 1: gamef= gamesyokika(gamef); break;
|
|
115 case 2: gamef= opening(gamef); break;
|
|
116 case 3: gamef= dandy_main_loop(gamef); break;
|
|
117 case 4: gamef= dandy_closing(gamef); break;
|
|
118 }
|
|
119 return next;
|
|
120 };
|
|
121
|
|
122
|
|
123
|
|
124
|
|
125 int
|
|
126 TMmain(TaskManager *manager,int argc, char *argv[])
|
|
127 {
|
|
128 for(int i = 1; i<argc ; i++) {
|
|
129 if (strcmp(argv[i],"-t")) {
|
|
130 test_mode=1;
|
|
131 if (i+1<argc && argv[i+1]) {
|
|
132 i++;
|
|
133 test_object=argv[i];
|
|
134 }
|
|
135 }
|
|
136 }
|
|
137
|
|
138 task_initialize();
|
|
139 manager->set_TMend(TMend);
|
|
140
|
|
141 return init(manager,argc, argv);
|
|
142 }
|
|
143
|
|
144 void
|
|
145 TMend(TaskManager *manager)
|
|
146 {
|
|
147 printf("game end\n");
|
|
148 }
|
|
149
|
|
150 static int light_sysswitch = 0;
|
|
151 static int light_num = 4;
|
|
152
|
|
153 static void
|
|
154 LightSysSwitch(Viewer *sgroot) {
|
|
155 if (light_sysswitch == 1) {
|
|
156 sgroot->OnLightSysSwitch();
|
|
157 for (int i = 0; i < light_num; i++) {
|
|
158 SceneGraphPtr light = sgroot->getLight(i);
|
|
159 sgroot->OnLightSwitch(i);
|
|
160 light->xyz[0] = screen_w / 2;
|
|
161 light->xyz[1] = screen_h / 2;
|
|
162 light->xyz[2] = -100;
|
|
163 }
|
|
164 } else if (light_sysswitch == 0) {
|
|
165 sgroot->OffLightSysSwitch();
|
|
166 }
|
|
167 }
|
|
168
|
|
169
|
|
170 static int
|
|
171 dandy_main_init(int gamef)
|
|
172 {
|
|
173 //Timeprof timeprof_move;
|
|
174 //timeprof_move = timeprof_new();
|
|
175 dbg_init("/dev/stdout");
|
|
176
|
|
177 /**
|
|
178 * timeprof があるんだけどね
|
|
179 */
|
|
180
|
|
181 droot->createFromXMLfile("xml/character.xml");
|
|
182 droot->createFromXMLfile("xml/font.xml");
|
|
183 droot->createFromXMLfile("xml/effect.xml");
|
|
184 droot->createFromXMLfile("xml/boss.xml");
|
|
185
|
|
186 LightSysSwitch(droot);
|
|
187
|
|
188
|
|
189 init_sprite(0,0,0,0);
|
|
190
|
|
191 __debug("syokikaが呼びだされました\n");
|
|
192 joy=SDL_JoystickOpen(0);
|
|
193 if(!joy) {
|
|
194 fprintf(stderr,"failed to open joystick 0\n");
|
|
195 use_keybord = 1;
|
|
196 }
|
|
197
|
|
198 /**
|
|
199 * sound.c に移しました
|
|
200 * 代わりに InitSdlMixer(void); を使います。
|
|
201 * まあ中身一緒なんだけどね
|
|
202 */
|
|
203 /**
|
|
204 if (Mix_OpenAudio(MIX_DEFAULT_FREQUENCY,MIX_DEFAULT_FORMAT,2,1024) < 0) {
|
|
205 fprintf(stderr,"failed to initialize SDL_mixer.\n");
|
|
206 SDL_Quit();
|
|
207 exit(-1);
|
|
208 }
|
|
209 */
|
|
210
|
|
211 // SDL_mixer とかいろいろ初期化
|
|
212 // もし Init に失敗したら
|
|
213 // 以後の Mixer 関連の関数を呼び出しても
|
|
214 // 中では何も行われないとかいう小細工を入れました。
|
|
215 InitSdlMixer();
|
|
216
|
|
217 // 音楽ファイルの読み込み
|
|
218 LoadSdlMixer();
|
|
219
|
|
220 // ボリューム調整
|
|
221 InitVolume();
|
|
222
|
|
223 // 音出しテスト
|
|
224 PlaySdlMixer(-1, BGM);
|
|
225
|
|
226 if(!(init_chara_list(1024))){
|
|
227 __debug("failed to init_chara_list\n");
|
|
228 }
|
|
229
|
|
230 __debug("finished init_chara_list\n");
|
|
231
|
|
232 return 1;
|
|
233 }
|
|
234
|
|
235
|
|
236 static int
|
|
237 dandy_main_loop(int gamef)
|
|
238 {
|
|
239
|
|
240
|
|
241 if ((pad[0].l1 != 0) && (pad[0].r1 != 0) &&
|
|
242 (pad[0].l2 != 0) && (pad[0].r2 != 0)) {
|
|
243 gamef = gamesyokika(gamef);
|
|
244 }
|
|
245
|
|
246 if (pad[0].quit != 0) {
|
|
247 gamef = 4;
|
|
248 }
|
|
249 flip();
|
|
250
|
|
251 //SDL_FillRect(screen, NULL, background);
|
|
252
|
|
253 enemyfaste = count;
|
|
254
|
|
255 // timeprof_begin(timeprof_move);
|
|
256 //Move(); //enemy move
|
|
257 // timeprof_end(timeprof_move);
|
|
258 asteroidi = 0;
|
|
259 //charpatern();
|
|
260 //bosguage();
|
|
261
|
|
262 count++;
|
|
263 PutSprite(count++, jiki.x, jiki.y,PLAYER_LEFTMOVE );
|
|
264 PutSprite(count++, jiki.x, jiki.y,PLAYER_TURNTOLEFT );
|
|
265 PutSprite(count++, jiki.x, jiki.y,PLAYER_IDLE);
|
|
266 PutSprite(count++, jiki.x, jiki.y,PLAYER_TURNTORIGHT );
|
|
267 PutSprite(count++, jiki.x, jiki.y,PLAYER_RIGHTMOVE);
|
|
268
|
|
269
|
|
270 tokuten();
|
|
271
|
|
272 count++;
|
|
273 //PutSprite(count, 0, 960 - 96, 10);
|
|
274 /*インフレゲージ */
|
|
275 count++;
|
|
276 //PutSprite(count, 0, 0, 48);
|
|
277
|
|
278 obj_draw();
|
|
279
|
|
280 if (use_keybord) {
|
|
281 keybord();
|
|
282 } else {
|
|
283 Pad(joy);
|
|
284 }
|
|
285 filpcount++;
|
|
286 count = 0;
|
|
287
|
|
288 return gamef;
|
|
289 }
|
|
290
|
|
291 static int
|
|
292 dandy_closing(int gamef)
|
|
293 {
|
|
294
|
|
295 //_______________________________________________
|
|
296 // SDL_mixerの後始末
|
|
297 Mix_CloseAudio();
|
|
298 Mix_HaltMusic();
|
|
299 FreeSdlMixer() ;
|
|
300 //_______________________________________________
|
|
301 return 0;
|
|
302 }
|
|
303
|
|
304
|
|
305 static int
|
|
306 gamesyokika(int gamef)
|
|
307 {
|
|
308 laser_lv3[0].r = 62;
|
|
309 laser_lv3[0].r = 62;
|
|
310 for (i = 0; i < 3; i++) {
|
|
311 tlv3[i].y = -1;
|
|
312 }
|
|
313 filpcount = 0;
|
|
314 stage = 0;
|
|
315 //for (i = 0; i < 300; i++)
|
|
316 //enemy[i].f = FALSE;
|
|
317 jiki.zanki = 3;
|
|
318 jiki.x = 60;
|
|
319 jiki.y = 200;
|
|
320 jiki.ch = 3;
|
|
321 jiki.point = 0;
|
|
322 jiki.bf = FALSE;
|
|
323 jiki.muteki = 120;
|
|
324 enemycount = 0;
|
|
325 lg.stg = 4096;
|
|
326 pg.stg = 4096;
|
|
327 infg.stg = 0;
|
|
328 infg_level = 0;
|
|
329 //kyeenemyno = -1;
|
|
330 fastebos = 0;
|
|
331 jiki.ccount = 99;
|
|
332 p_extend = 200000;
|
|
333 pad[0].up=0;
|
|
334 pad[0].down=0;
|
|
335 pad[0].right=0;
|
|
336 pad[0].left=0;
|
|
337 pad[0].st=0;
|
|
338 pad[0].se=0;
|
|
339
|
|
340 SoundStop();
|
|
341 SoundPlay(7);
|
|
342 gamef = 2;
|
|
343 flip();
|
|
344 return gamef;
|
|
345 }
|
|
346
|
|
347 static int
|
|
348 opening(int gamef)
|
|
349 {
|
|
350 if(use_keybord == 1) {
|
|
351 keybord();
|
|
352 } else {
|
|
353 Pad(joy);
|
|
354 }
|
|
355
|
|
356 count = 1;
|
|
357
|
|
358 PutSprite(count, 700, 480, 53); // put `push start' string on screen.
|
|
359 count++;
|
|
360 PutSprite(count, 224, 776, 119); // put `super dandy'
|
|
361 count++;
|
|
362 // PutSprite(count, 200, 64, 190);
|
|
363 // PutSpriteEx(count, 8192, 8192, 0);
|
|
364 PutSpriteEx(190, 800, 264, 2, 2, 5);
|
|
365 count++;
|
|
366 PutSprite(count, 396, 432, 191);
|
|
367 //PutSpriteEx(count, 8192, 8192, 0);
|
|
368 count++;
|
|
369 PutSprite(count, 640, 640, 192);
|
|
370 //PutSpriteEx(count, 8192, 8192, 0);
|
|
371
|
|
372 if (pad[0].st > 1) {
|
|
373 jiki.bf = TRUE;
|
|
374
|
|
375 //CdPlay(1,&cdp[0],0);
|
|
376 SoundStop();
|
|
377 SoundPlay(0);
|
|
378
|
|
379 gamef = 3;
|
|
380 pad[0].st = 1;
|
|
381 } else if ((pad[0].se > 0) && (pad[0].st > 0)) {
|
|
382 gamef = 2;
|
|
383 }
|
|
384 flip();
|
|
385 return gamef;
|
|
386 }
|
|
387
|
|
388
|
|
389
|
|
390
|
|
391 /* end */
|