X-Git-Url: https://deadsoftware.ru/gitweb?p=flatwaifu.git;a=blobdiff_plain;f=src%2Fgame.c;h=e952a6c319a042ab3bd5d5bc39ba38296da26e4c;hp=8d14674c22ac3f1ebf2c88b1263c4ec4dfe5a8ad;hb=4a99fe51561ca331df54512eb25c502d0fcd2b55;hpb=2bb81ea2565c3627c954b5c37326db89b0048472 diff --git a/src/game.c b/src/game.c index 8d14674..e952a6c 100644 --- a/src/game.c +++ b/src/game.c @@ -26,7 +26,6 @@ #include #include "files.h" #include "memory.h" -#include "keyb.h" #include "sound.h" #include "view.h" #include "bmap.h" @@ -47,8 +46,9 @@ #include "music.h" #include "a8.h" #include "error.h" +#include "input.h" -#include +#include "save.h" #define LT_DELAY 8 #define LT_HITTIME 6 @@ -67,6 +67,7 @@ int dm_pnum; int dm_pl1p; int dm_pl2p; pos_t dm_pos[100]; +byte cheat; static void *telepsnd; @@ -94,62 +95,8 @@ static void set_trans(int st) { g_trans=1;g_transt=0; } -void G_savegame (FILE* h) { - myfwrite8(_2pl, h); - myfwrite8(g_dm, h); - myfwrite8(g_exit, h); - myfwrite8(g_map, h); - myfwrite32(g_time, h); - myfwrite32(dm_pl1p, h); - myfwrite32(dm_pl2p, h); - myfwrite32(dm_pnum, h); - int i = 0; - while (i < dm_pnum) { - myfwrite32(dm_pos[i].x, h); - myfwrite32(dm_pos[i].y, h); - myfwrite8(dm_pos[i].d, h); - i += 1; - } - myfwrite8(cheat, h); - myfwrite(g_music, 8, 1, h); -} - -void G_loadgame (FILE* h) { - _2pl = myfread8(h); - g_dm = myfread8(h); - g_exit = myfread8(h); - g_map = myfread8(h); - g_time = myfread32(h); - dm_pl1p = myfread32(h); - dm_pl2p = myfread32(h); - dm_pnum = myfread32(h); - int i = 0; - while (i < dm_pnum) { - dm_pos[i].x = myfread32(h); - dm_pos[i].y = myfread32(h); - dm_pos[i].d = myfread8(h); - i += 1; - } - cheat = myfread8(h); - myfread(g_music, 8, 1, h); - F_loadmus(g_music); -} - -int G_load (FILE *h) { - switch (blk.t) { - case MB_MUSIC: - myfread(g_music, 8, 1, h); - if (music_random) { - F_randmus(g_music); - } - F_loadmus(g_music); - return 1; - } - return 0; -} - void load_game (int n) { - F_freemus(); + MUS_free(); W_init(); F_loadgame(n); set_trans(GS_GAME); @@ -160,13 +107,13 @@ void load_game (int n) { BM_mark(&pl1.o,BM_PLR1); if(_2pl) BM_mark(&pl2.o,BM_PLR2); MN_mark(); - S_startmusic(music_time); + //MUS_start(music_time); + MUS_start(0); } void G_start (void) { char s[8]; - - F_freemus(); + MUS_free(); sprintf(s,"MAP%02u",(word)g_map); F_loadmap(s); set_trans(GS_GAME); @@ -184,7 +131,8 @@ void G_start (void) { BM_mark(&pl1.o,BM_PLR1); if(_2pl) BM_mark(&pl2.o,BM_PLR2); MN_mark(); - S_startmusic(music_time); + //MUS_start(music_time); + MUS_start(0); } #define GGAS_TOTAL (MN__LAST-MN_DEMON+16+10) @@ -273,8 +221,8 @@ void G_act (void) { if(g_st==GS_BVIDEO || g_st==GS_EVIDEO) { - if(!A8_nextframe() || lastkey==SDLK_ESCAPE) { - if(lastkey==SDLK_ESCAPE) lastkey=0; + if (!A8_nextframe() || lastkey == KEY_ESCAPE) { + if (lastkey == KEY_ESCAPE) lastkey = KEY_UNKNOWN; A8_close(); if(g_st==GS_BVIDEO) G_start(); else goto inter; @@ -311,10 +259,14 @@ void G_act (void) { set_trans(GS_TITLE); } #else - if(keys[SDLK_SPACE] || keys[SDLK_RETURN] || keys[SDLK_KP_ENTER])//if(keys[0x39] || keys[0x1C] || keys[0x9C]) - if(!G_beg_video()) G_start(); else { - g_st=GS_BVIDEO;F_freemus(); + if (I_pressed(KEY_SPACE) || I_pressed(KEY_RETURN) || I_pressed(KEY_KP_ENTER)) { + if (!G_beg_video()) { + G_start(); + } else { + g_st = GS_BVIDEO; + MUS_free(); } + } #endif return; } @@ -368,7 +320,7 @@ void G_act (void) { if(g_exit==1) { if(G_end_video()) { - F_freemus(); + MUS_free(); g_st=GS_EVIDEO; return; } @@ -379,20 +331,23 @@ inter: case 31: case 32: g_map=16;set_trans(GS_INTER);break; default: ++g_map;set_trans(GS_INTER);break; } - F_freemus(); - if(g_st==GS_INTER) { - F_loadmus("INTERMUS"); - }else {F_loadmus("\x8a\x8e\x8d\x85\x96\x0");if(mus_vol>0) {S_volumemusic(128);} } - S_startmusic(0); + MUS_free(); + if (g_st == GS_INTER) { + MUS_load("INTERMUS"); + } else { + MUS_load("\x8a\x8e\x8d\x85\x96\x0"); + MUS_volume(128); + } + MUS_start(0); }else if(g_exit==2) { switch(g_map) { case 31: g_map=32;set_trans(GS_INTER);break; case 32: g_map=16;set_trans(GS_INTER);break; default: g_map=31;set_trans(GS_INTER);break; } - F_freemus(); - F_loadmus("INTERMUS"); - S_startmusic(0); + MUS_free(); + MUS_load("INTERMUS"); + MUS_start(0); } #ifdef DEMO