]> Shamusworld >> Repos - apple2/commitdiff
Fixed log hangup on exit, added paddle buttons 0 & 1.
authorShamus Hammons <jlhamm@acm.org>
Tue, 10 Sep 2013 03:22:49 +0000 (22:22 -0500)
committerShamus Hammons <jlhamm@acm.org>
Tue, 10 Sep 2013 03:22:49 +0000 (22:22 -0500)
.gitignore
src/apple2.cpp
src/log.cpp

index a11e4d0e942b12845f56caca10bf3881de10852e..a7dd4bf0d65ff349c2b7046829efc001ddec014d 100644 (file)
@@ -3,3 +3,5 @@ apple2.log
 disks/
 gmon.out
 obj/
+bugs/
+reference/
index 1999e7651422af354dacbbe9495e87145f209549..0c6880f4ebd13ca6ee6299603fca9882dd8ec67a 100755 (executable)
@@ -75,6 +75,8 @@ FloppyDrive floppyDrive;
 
 static uint8_t lastKeyPressed = 0;
 static bool keyDown = false;
+static bool openAppleDown = false;
+static bool closedAppleDown = false;
 
 //static FloppyDrive floppyDrive;
 
@@ -322,6 +324,16 @@ deltaT to zero. In the sound IRQ, if deltaT > buffer size, then subtract buffer
        {
                hiRes = true;
        }
+       else if (addr == 0xC061)                                // Read $C061
+       {
+               // Open Apple key (or push button 0)
+               return (openAppleDown ? 0x80 : 0x00);
+       }
+       else if (addr == 0xC062)                                // Read $C062
+       {
+               // Open Apple key (or push button 0)
+               return (closedAppleDown ? 0x80 : 0x00);
+       }
 
 //Note that this is a kludge: The $D000-$DFFF 4K space is shared (since $C000-$CFFF is
 //memory mapped) between TWO banks, and that that $E000-$FFFF RAM space is a single bank.
@@ -459,9 +471,6 @@ WriteLog("LC(R): $C08B 49291 OECG RR Read/Write RAM bank 1\n");
        else if (addr == 0xC0EC)
        {
                return floppyDrive.ReadWrite();
-//Hm, some stuff is looking at the return value. Dunno what it *should* be...
-// OK, it's from the ReadWrite routine...
-//return 0xFF;
        }
        else if (addr == 0xC0ED)
        {
@@ -1155,21 +1164,30 @@ static void FrameCallback(void)
                                lastKeyPressed = 0x08, keyDown = true;
                        else if (event.key.keysym.sym == SDLK_RETURN)
                                lastKeyPressed = 0x0D, keyDown = true;
+                       else if (event.key.keysym.sym == SDLK_ESCAPE)
+                               lastKeyPressed = 0x1B, 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;
+                                       keyDown = true;
 //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;
 
+                       // Paddle buttons 0 & 1
+                       if (event.key.keysym.sym == SDLK_INSERT)
+                               openAppleDown = true;
+                       if (event.key.keysym.sym == SDLK_PAGEUP)
+                               closedAppleDown = true;
+
                        if (event.key.keysym.sym == SDLK_F11)
                                dumpDis = !dumpDis;                             // Toggle the disassembly process
 //                     else if (event.key.keysym.sym == SDLK_F11)
@@ -1232,6 +1250,15 @@ else if (event.key.keysym.sym == SDLK_F10)
                        if (event.key.keysym.sym == SDLK_F12)
                                fullscreenDebounce = false;
 
+                       // Paddle buttons 0 & 1
+                       if (event.key.keysym.sym == SDLK_INSERT)
+                               openAppleDown = false;
+                       if (event.key.keysym.sym == SDLK_PAGEUP)
+                               closedAppleDown = false;
+
+//                     if (event.key.keysym.sym >= SDLK_a && event.key.keysym.sym <= SDLK_z)
+//                             keyDown = false;
+
                        break;
                case SDL_QUIT:
                        running = false;
index e56a55727157c78628253035d4f1812972eab708..4a01f8001153f0fb3868382ec3483a2f921043c5 100755 (executable)
@@ -57,15 +57,15 @@ void WriteLog(const char * text, ...)
 
        va_start(arg, text);
        logSize += vfprintf(log_stream, text, arg);
+       va_end(arg);
+
+       fflush(log_stream);                                     // Make sure that text is written!
 
        if (logSize > MAX_LOG_SIZE)
        {
-               fflush(log_stream);
                fclose(log_stream);
+               log_stream = NULL;
                logDone = true;
        }
-
-       va_end(arg);
-       fflush(log_stream);                                     // Make sure that text is written!
 }