DEADSOFTWARE

map: move map loading to separate file
[flatwaifu.git] / src / game.c
index 8d14674c22ac3f1ebf2c88b1263c4ec4dfe5a8ad..85108333d617a5508dba067bebb48510e2ad34a5 100644 (file)
@@ -26,7 +26,6 @@
 #include <string.h>
 #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 <SDL_keysym.h>
+#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,60 +95,6 @@ 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();
   W_init();
@@ -273,8 +220,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 +258,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;
+        F_freemus();
            }
+    }
 #endif
          return;
   }