From c48ed86a3644361b1951fef4045b62bafed9426d Mon Sep 17 00:00:00 2001 From: Shamus Hammons Date: Mon, 9 Sep 2013 07:59:51 -0500 Subject: [PATCH] Prevent aborting when the log file fills up; added CTRL key support. --- apple2.cfg | 31 ++++++++++++------------------- src/apple2.cpp | 19 +++++++++++++++---- src/log.cpp | 14 ++++++++++---- 3 files changed, 37 insertions(+), 27 deletions(-) diff --git a/apple2.cfg b/apple2.cfg index f843a17..f672918 100755 --- a/apple2.cfg +++ b/apple2.cfg @@ -50,7 +50,7 @@ autoSaveState = 1 #floppyImage1 = ./disks/MoebiusIIA.dsk #floppyImage2 = ./disks/MoebiusIIB.dsk # Yes -floppyImage1 = ./disks/wind_walker_1.dsk +#floppyImage1 = ./disks/wind_walker_1.dsk # Yes #floppyImage1 = ./disks/dino_eggs.dsk # ??? 1, yes; 2, no @@ -64,12 +64,19 @@ floppyImage1 = ./disks/wind_walker_1.dsk #floppyImage2 = ./disks/u2player-jlh.dsk # Yes #floppyImage1 = ./disks/TheHeist.dsk +# Yes +#floppyImage1 = ./disks/ult31snd.dsk +#floppyImage2 = ./disks/ult32snd.dsk +# Yes (key repeat is too high) +#floppyImage1 = ./disks/bandits.dsk +# Yes +#floppyImage1 = ./disks/SpareChange.dsk +# Yes +#floppyImage1 = ./disks/lode_runner.dsk +# Yes +floppyImage1 = ./disks/championship_lode_runner.dsk -# OpenGL options: 1 - use OpenGL rendering, 0 - use old style rendering - -useOpenGL = 1 - # OpenGL filtering type: 1 - blurry, 0 - sharp glFilterType = 0 @@ -78,20 +85,6 @@ glFilterType = 0 fullscreen = 0 -# Backend renderer (OpenGL dependent): 0 - regular, 1 - "TV" style - -#renderType = 0 - -# NTSC/PAL options: 1 - NTSC, 0 - PAL - -hardwareTypeNTSC = 1 - -# Framskip options: 0 - no skip, 1-N - draw every Nth frame -# Note: Skipping frames may cause strange visual side effects--don't bother -# reporting these unless they occur with a frameskip value of 0! - -frameSkip = 0 - # Joystick options: 1 - use joystick, 0 - don't use useJoystick = 0 diff --git a/src/apple2.cpp b/src/apple2.cpp index 0e65183..1999e76 100755 --- a/src/apple2.cpp +++ b/src/apple2.cpp @@ -908,8 +908,10 @@ int main(int /*argc*/, char * /*argv*/[]) //Kill the DOS ROM in slot 6 for now... //not memcpy(rom + 0xC600, diskROM, 0x100); +// memcpy(rom + 0xC700, diskROM, 0x100); // Slot 7??? WriteLog("About to initialize video...\n"); + if (!InitVideo()) { std::cout << "Aborting!" << std::endl; @@ -1121,21 +1123,20 @@ static void FrameCallback(void) switch (event.type) { case SDL_TEXTINPUT: -// if (event.key.keysym.unicode != 0) -// { //Need to do some key translation here, and screen out non-apple keys as well... +//(really, could do it all in SDL_KEYDOWN, would just have to get symbols & +// everything else done separately. this is slightly easier. :-P) // if (event.key.keysym.sym == SDLK_TAB) // Prelim key screening... if (event.edit.text[0] == '\t') // Prelim key screening... break; -// lastKeyPressed = event.key.keysym.unicode; lastKeyPressed = event.edit.text[0]; keyDown = true; + //kludge: should have a caps lock thingy here... //or all uppercase for ][+... if (lastKeyPressed >= 'a' && lastKeyPressed <='z') lastKeyPressed &= 0xDF; // Convert to upper case... -// } break; case SDL_KEYDOWN: @@ -1155,6 +1156,16 @@ static void FrameCallback(void) else if (event.key.keysym.sym == SDLK_RETURN) lastKeyPressed = 0x0D, keyDown = true; + // Fix CTRL+key combo... + if (event.key.keysym.mod & KMOD_CTRL) + { + if (event.key.keysym.sym >= SDLK_a && event.key.keysym.sym <= SDLK_z) +// { + lastKeyPressed = (event.key.keysym.sym - SDLK_a) + 1; +//printf("Key combo pressed: CTRL+%c\n", lastKeyPressed + 0x40); +// } + } + // Use ALT+Q to exit, as well as the usual window decoration method if (event.key.keysym.sym == SDLK_q && (event.key.keysym.mod & KMOD_ALT)) running = false; diff --git a/src/log.cpp b/src/log.cpp index ebf2535..e56a557 100755 --- a/src/log.cpp +++ b/src/log.cpp @@ -18,10 +18,13 @@ #include #include -#define MAX_LOG_SIZE 10000000 // Maximum size of log file (10 MB) +// Maximum size of log file (10 MB ought to be enough for anybody) +#define MAX_LOG_SIZE 10000000 static FILE * log_stream = NULL; static uint32_t logSize = 0; +static bool logDone = false; + bool InitLog(const char * path) { @@ -33,19 +36,21 @@ bool InitLog(const char * path) return true; } + void LogDone(void) { if (log_stream) fclose(log_stream); } + // // This logger is used mainly to ensure that text gets written to the log file // even if the program crashes. The performance hit is acceptable in this case! // void WriteLog(const char * text, ...) { - if (!log_stream) + if (!log_stream || logDone) return; va_list arg; @@ -57,9 +62,10 @@ void WriteLog(const char * text, ...) { fflush(log_stream); fclose(log_stream); - exit(1); - }//*/ + logDone = true; + } va_end(arg); fflush(log_stream); // Make sure that text is written! } + -- 2.37.2