From 8e45768c29dd20018217bd16b4d9fbcaf892b5b7 Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Fri, 25 Apr 2014 03:31:26 +0200 Subject: [PATCH] Fix the keyboard handling. Reset the mixed mode flag when changing video mode. Better path building for savestates. --- source/input.c | 2 +- source/state.c | 14 ++++++++++++-- source/video.c | 4 ++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/source/input.c b/source/input.c index 89d85e0..fad6141 100644 --- a/source/input.c +++ b/source/input.c @@ -39,7 +39,7 @@ void update_input () kbd_key = keyboardUpdate(); if (kbd_key > 0) { - switch (keybd_latch) { + switch (kbd_key) { case DVK_ENTER: keybd_latch = 0x8d; return; diff --git a/source/state.c b/source/state.c index 84dc187..c642667 100644 --- a/source/state.c +++ b/source/state.c @@ -11,12 +11,22 @@ typedef struct state_hdr_t { #define STATE_MAGIC (0x47525033) +char *build_path (int slot) +{ + static char tmp[1024]; + if (basename) + snprintf(tmp, sizeof(tmp), "%s.%03i", basename, slot); + else + snprintf(tmp, sizeof(tmp), "grape.%03i", slot); + return tmp; +} + int state_save (int slot) { FILE *f; state_hdr_t h; - f = fopen("game.sav", "w+"); + f = fopen(build_path(slot), "w+"); if (f) return 0; @@ -51,7 +61,7 @@ int state_load (int slot) FILE *f; state_hdr_t h; - f = fopen("game.sav", "w+"); + f = fopen(build_path(slot), "w+"); if (f) return 0; diff --git a/source/video.c b/source/video.c index 1b4b919..8916fce 100644 --- a/source/video.c +++ b/source/video.c @@ -112,9 +112,11 @@ u8 video_io_read (u16 addr) switch (addr&0xf) { case 0x0: text_mode = 0; + mixed_mode = 0; break; case 0x1: text_mode = 1; + mixed_mode = 0; break; case 0x2: mixed_mode = 0; @@ -130,9 +132,11 @@ u8 video_io_read (u16 addr) break; case 0x6: hires = 0; + mixed_mode = 0; break; case 0x7: hires = 1; + mixed_mode = 0; break; // Annunciators case 0x8: