/
init.c
343 lines (282 loc) · 8.83 KB
/
init.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
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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <SDL.h>
#include <unistd.h>
#include "define.h"
#include "extern.h"
#include "function.h"
#include "util_snd.h"
#include "scene.h"
#ifdef GP2X
#include <unistd.h>
#endif
#ifdef PSPUMODE
#include <pspkernel.h>
#endif
//#define MacOS
#ifdef HOME_PATH
char home_path[256];
#endif
void main_init( void );
void main_init_config( void );
void ExitProgram(void);
int main(int argc, char *argv[]);
///----------------------------------------------------------------------------
/// PSP Related Stuff
///----------------------------------------------------------------------------
#ifdef PSPUMODE
PSP_MODULE_INFO("Champyonshipp Kaiten Patissier", 0, 1, 1);
PSP_HEAP_SIZE_KB(21*1024);
int iDoRun;
// PSP things
/*
int psp_exit_callback(int arg1, int arg2, void *common)
{
iDoRun = 0;
//sceDisplayWaitVblankStart();
//sceKernelExitGame();
return 0;
}
int psp_callback_thread(SceSize args, void *argp)
{
int cbid;
cbid = sceKernelCreateCallback("Exit Callback", psp_exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
return 0;
}
int psp_setup_callbacks(void)
{
int thid = 0;
thid = sceKernelCreateThread("update_thread", psp_callback_thread, 0x11, 0xFA0, 0, 0);
if(thid >= 0)
sceKernelStartThread(thid, 0, 0);
return thid;
}
*/
#endif
int main(int argc, char *argv[])
{
SDL_Rect rect;
Uint32 flags;
SDL_Surface* tmp;
char AppPath[1024];
char AppPathw[1024];
char *char_work;
int strlen;
#ifdef PSPUMODE
// PSP things
//psp_setup_callbacks();
scePowerSetClockFrequency(333, 333, 166);
#endif
#ifdef HOME_PATH
char save_path[256];
char replay_path[256];
char replay_fold_path[3][256];
snprintf(home_path, sizeof(home_path), "%s/.kaiten", getenv("HOME"));
snprintf(save_path, sizeof(save_path), "%s/save", home_path);
snprintf(replay_path, sizeof(replay_path), "%s/replay", home_path);
snprintf(replay_fold_path[0], 256, "%s/replay/0", home_path);
snprintf(replay_fold_path[1], 256, "%s/replay/1", home_path);
snprintf(replay_fold_path[2], 256, "%s/replay/2", home_path);
mkdir(home_path, 0755);
mkdir(save_path, 0755);
mkdir(replay_path, 0755);
mkdir(replay_fold_path[0], 0755);
mkdir(replay_fold_path[1], 0755);
mkdir(replay_fold_path[2], 0755);
#endif
/* 初期化 */
memset( &AppPath[0], '\0', sizeof( AppPath ) );
memset( &AppPathw[0], '\0', sizeof( AppPath ) );
if (SDL_Init(SDL_INIT_VIDEO) < 0)
return 1;
#ifdef GP2X
#else
#ifdef MacOS
if ( argc > 0 ) // 起動に引数がある場合
{
snprintf( &AppPath[0], sizeof(AppPath), "%s", argv[0]);
// strcat( &AppPath[0], "/Contents/Recources/" );
char_work = strrchr( &AppPath[0], '/' );
// char_work = strrchr( &AppPath[0], '\\' );
strlen = char_work - &AppPath[0];
strncpy( &AppPathw[0], &AppPath[0], strlen );
chdir( &AppPathw[0] );
// LogFileWrite( "testlog.txt", &AppPathw[0] );
}
#else
#endif
#endif
/* 初期化画面サイズ */
#ifdef PSPUMODE
flags = SDL_HWSURFACE | SDL_FULLSCREEN | SDL_DOUBLEBUF | SDL_HWPALETTE;
#else
if ( argc > 1 ) // 起動に引数がある場合
{
flags = SDL_FULLSCREEN | SDL_SWSURFACE;
}
else
{
flags = SDL_SWSURFACE;
}
#endif
#ifdef PSPUMODE
flags = SDL_HWSURFACE | SDL_FULLSCREEN | SDL_DOUBLEBUF | SDL_HWPALETTE;
#endif
// g_screen = SDL_SetVideoMode(DISPLY_WIDTH, DISPLY_HEIGHT, 16, SDL_SWSURFACE);
g_screen = SDL_SetVideoMode(DISPLY_WIDTH, DISPLY_HEIGHT, 8, flags);
rect.x = 0;
rect.y = 0;
rect.w = DISPLY_WIDTH;
rect.h = DISPLY_HEIGHT;
// SDL_SetClipRect( g_screen, &rect );
tmp = SDL_LoadBMP("image/color.bmp"); //プレーンナンバー1にタイトル画面背景を読み込む
SetGscreenPalette( tmp );
SDL_FreeSurface(tmp);
printf("FUCK YEAH!!\n");
if (!g_screen)
{
fprintf(stderr, "Couldn't set video mode: %s\n", SDL_GetError());
return 1;
}
SDL_WM_SetCaption("RotateGear", "");
SDL_ShowCursor(SDL_DISABLE);
FunctionInit( );
// soundInitBuffer();
/* グローバル変数の初期化 */
main_init( );
scenemanager( );
ExitProgram( );
return 0;
}
void main_init( void )
{
g_scene = EN_SN_LOGO;
printf("FUCK NNN!!\n");
main_init_config( ); // 環境ファイルの読み込み
printf("I SUCK VANGINAS\n");
// ゲーム中の使用する音の読み込み
soundLoadBuffer(EN_BGM_GAME01, (Uint8 *)"sound/bgm/01.ogg", -1);
soundLoadBuffer(EN_BGM_GAME02, (Uint8 *)"sound/bgm/02.ogg", -1);
soundLoadBuffer(EN_BGM_GAME03, (Uint8 *)"sound/bgm/03.ogg", -1);
soundLoadBuffer(EN_BGM_GAME04, (Uint8 *)"sound/bgm/04.ogg", -1);
soundLoadBuffer(EN_BGM_GAME05, (Uint8 *)"sound/bgm/05.ogg", -1);
soundLoadBuffer(EN_BGM_GAME06, (Uint8 *)"sound/bgm/06.ogg", -1);
soundLoadBuffer(EN_BGM_GAME07, (Uint8 *)"sound/bgm/07.ogg", 0);
soundLoadBufferSE(EN_SE_ATK1 , (Uint8 *)"sound/se/atk1.wav" );
soundLoadBufferSE(EN_SE_DAMEGE , (Uint8 *)"sound/se/damage.wav" );
soundLoadBufferSE(EN_SE_L1 , (Uint8 *)"sound/se/l1.wav" );
soundLoadBufferSE(EN_SE_LANDING, (Uint8 *)"sound/se/landing.wav" );
soundLoadBufferSE(EN_SE_MSG , (Uint8 *)"sound/se/msg.wav" );
soundLoadBufferSE(EN_SE_SELECT , (Uint8 *)"sound/se/select.wav" );
soundLoadBufferSE(EN_SE_SW , (Uint8 *)"sound/se/sw.wav" );
soundLoadBufferSE(EN_SE_JUMP , (Uint8 *)"sound/se/jump.wav" );
soundLoadBufferSE(EN_SE_PAWA , (Uint8 *)"sound/se/puwa.wav" );
soundLoadBufferSE(EN_SE_CL1 , (Uint8 *)"sound/se/se01.wav" );
soundLoadBufferSE(EN_SE_CL2 , (Uint8 *)"sound/se/se02.wav" );
soundLoadBufferSE(EN_SE_CL3 , (Uint8 *)"sound/se/se03.wav" );
soundLoadBufferSE(EN_SE_CL4 , (Uint8 *)"sound/se/se04.wav" );
soundLoadBufferSE(EN_SE_CL5 , (Uint8 *)"sound/se/se05.wav" );
soundLoadBufferSE(EN_SE_CL21 , (Uint8 *)"sound/se/se06.wav" );
soundLoadBufferSE(EN_SE_CL22 , (Uint8 *)"sound/se/se07.wav" );
soundLoadBufferSE(EN_SE_CL23 , (Uint8 *)"sound/se/se08.wav" );
soundLoadBufferSE(EN_SE_CL24 , (Uint8 *)"sound/se/se09.wav" );
soundLoadBufferSE(EN_SE_CL25 , (Uint8 *)"sound/se/se10.wav" );
Set_Volume( gameflag[60] );
printf("FUCK YESS YES!!\n");
}
void ExitProgram(void)
{
soundStopBgm(0);
soundStopSeAll();
soundRelease();
SaveGameFlag("save/config");
closePAD();
// closeSDL();
SDL_Quit();
#ifdef GP2X
chdir("/usr/gp2x");
execl("/usr/gp2x/gp2xmenu", "/usr/gp2x/gp2xmenu", NULL);
#endif
#ifdef PSPUMODE
sceDisplayWaitVblankStart();
sceKernelExitGame();
#endif
}
void main_init_config( void )
{
int i;
i = 0;
gameflag[0]=GP2X_BUTTON_UP; //上 Up
gameflag[1]=GP2X_BUTTON_DOWN; //下 Down
gameflag[2]=GP2X_BUTTON_LEFT; //左 Left
gameflag[3]=GP2X_BUTTON_RIGHT; //右 Right
gameflag[4]=GP2X_BUTTON_A; //A Z
gameflag[5]=GP2X_BUTTON_X; //B X
gameflag[6]=GP2X_BUTTON_Y; //C C
gameflag[7]=GP2X_BUTTON_B; //D S
gameflag[8]=GP2X_BUTTON_L; //D S
gameflag[9]=GP2X_BUTTON_R; //D S
gameflag[10]=GP2X_BUTTON_START; //D S
gameflag[11]=GP2X_BUTTON_SELECT; //D S
if ( ! ( LoadGameFlag("save/config") == 0 ) )
{
/* ファイルが存在しない場合の初期値設定 */
ResetGameFlag();
gameflag[60] = 128; //音量
gameflag[70] = 1; //タイトル画面から来た
gameflag[71] = 1; //リトライを選択した
gameflag[100] = 0; //クリアフラグ
gameflag[107] = 0; //play time s
gameflag[108] = 0; //play time s
gameflag[109] = 0; //play time m
gameflag[110] = 0; //play time h
gameflag[111] = 59; //CLEAR time s
gameflag[112] = 59; //CLEAR time m
gameflag[113] = 99; //CLEAR time h
gameflag[120] = 1; //ステージセレクト
gameflag[121] = 1; //到達ステージ
gameflag[122] = 0; //キャラセレクト
gameflag[123] = -1; //リプレイ選択時のステージ
gameflag[124] = 0; //リプレイALL、ONE
gameflag[125] = 0; //リプレイjamp
gameflag[126] = 0; //裏面
gameflag[127] = 0; //トータルアタック
gameflag[128] = 0; //マップビュー
gameflag[129] = 0; //ステージセレクトから開始
gameflag[131] = 0; //言語
gameflag[132] = 0; //リプレイ
gameflag[133] = 1; //up key use
gameflag[134] = 0; //開始演出の有無
gameflag[135] = 0; //トータルアタック 時間 [130]>[135]
gameflag[136] = 0; //トータルアタック ミス [131]>[136]
gameflag[137] = 1595959; //トータルアタック クリア時間 [132]>[137]
gameflag[138] = 999; //トータルアタック クリアミス [133]>[138]
for ( i = 0; i <= 99; i++ )
{
gameflag[200 + i] = 1105959;
}
for ( i = 0; i <= 99; i++ )
{
gameflag[300 + i] = 99;
}
for ( i = 0; i <= 99; i++ )
{
gameflag[400 + i] = 0;
}
}
// for debug start
/*
for ( i = 0; i <= 99; i++ )
{
gameflag[400 + i] = 1;
}
*/
// for debug end
//gameflag[121] = 50; //到達ステージ
// gameflag[100] = 1; //到達ステージ
g_DebugDisp = GetConfig( CONFIGFILE_NAME , "DebugDisp" );
g_DebugStageProduction = GetConfig( CONFIGFILE_NAME , "DebugStageProduction" );
}