]> Shamusworld >> Repos - apple2/blobdiff - src/apple2.cpp
Added infrastructure to handle write protecting floppy disks
[apple2] / src / apple2.cpp
index 8365ef4a58ce12d9d27eff88d0e20332d376212a..fa7323a6d217adb2a8ddfb32a6a87b32c0432409 100755 (executable)
@@ -62,13 +62,14 @@ uint8 ram[0x10000], rom[0x10000];                           // RAM & ROM spaces
 uint8 diskRom[0x100];                                                  // Disk ROM space
 V65C02REGS mainCPU;
 uint8 appleType = APPLE_TYPE_II;
+FloppyDrive floppyDrive;
 
 // Local variables
 
 static uint8 lastKeyPressed = 0;
 static bool keyDown = false;
 
-static FloppyDrive floppyDrive;
+//static FloppyDrive floppyDrive;
 
 enum { LC_BANK_1, LC_BANK_2 };
 
@@ -256,7 +257,7 @@ deltaT to zero. In the sound IRQ, if deltaT > buffer size, then subtract buffer
 A = PEEK($C082)
 */
 
-#define DEBUG_LC
+//#define DEBUG_LC
        else if ((addr & 0xFFFB) == 0xC080)
        {
 #ifdef DEBUG_LC
@@ -371,23 +372,76 @@ WriteLog("LC(R): $C08B 49291 OECG RR Read/Write RAM bank 1\n");
                floppyDrive.SetWriteMode();
        }
 
+//#define LC_DEBUGGING
+#ifdef LC_DEBUGGING
+bool showpath = false;
+if (addr >= 0xD000 && addr <= 0xD00F)
+       showpath = true;
+#endif
 //This sux...
        if (addr >= 0xC100 && addr <= 0xCFFF)   // The $C000-$CFFF block is *never* RAM
+#ifdef LC_DEBUGGING
+       {
+#endif
                b = rom[addr];
+#ifdef LC_DEBUGGING
+if (showpath)
+       WriteLog("b is from $C100-$CFFF block...\n");
+       }
+#endif
        else if (addr >= 0xD000)
        {
                if (readRAM)
                {
                        if (addr <= 0xDFFF && visibleBank == LC_BANK_1)
+#ifdef LC_DEBUGGING
+       {
+#endif
                                b = ram[addr - 0x1000];
+#ifdef LC_DEBUGGING
+if (showpath)
+       WriteLog("b is from LC bank #1 (ram[addr - 0x1000])...\n");
+       }
+#endif
                        else
+#ifdef LC_DEBUGGING
+       {
+#endif
                                b = ram[addr];
+#ifdef LC_DEBUGGING
+if (showpath)
+       WriteLog("b is from LC bank #2 (ram[addr])...\n");
+       }
+#endif
                }
                else
+#ifdef LC_DEBUGGING
+       {
+#endif
                        b = rom[addr];
+#ifdef LC_DEBUGGING
+if (showpath)
+       WriteLog("b is from LC ROM (rom[addr])...\n");
+       }
+#endif
        }
        else
+#ifdef LC_DEBUGGING
+       {
+#endif
                b = ram[addr];
+#ifdef LC_DEBUGGING
+if (showpath)
+       WriteLog("b is from ram[addr]...\n");
+       }
+#endif
+
+#ifdef LC_DEBUGGING
+if (addr >= 0xD000 && addr <= 0xD00F)
+{
+       WriteLog("*** Read from $%04X: $%02X (readRAM=%s, PC=%04X, ram$D000=%02X)\n", addr, b, (readRAM ? "T" : "F"), mainCPU.pc, ram[0xC000]);
+}
+#endif
 
        return b;
 }
@@ -502,7 +556,8 @@ SETALTCH = $C00F ;use alt char set- norm inverse, LC; no Flash (WR-only)
        {
 //Actually, according to the A2 ref, this should do nothing since a write
 //is immediately preceded by a read leaving it in the same state it was...
-//             keyDown = false;
+//But leaving this out seems to fuck up the key handling of some games...
+               keyDown = false;
        }
        else if (addr == 0xC050)
        {
@@ -648,6 +703,16 @@ WriteLog("LC(R): $C08B 49291 OECG RR Read/Write RAM bank 1\n");
        }
 //Still need to add missing I/O switches here...
 
+//DEEE: BD 10 BF       LDA   $BF10,X    [PC=DEF1, SP=01F4, CC=--.B-IZ-, A=00, X=0C, Y=07]
+#if 0
+if (addr >= 0xD000 && addr <= 0xD00F)
+{
+       WriteLog("*** Write to $%04X: $%02X (writeRAM=%s, PC=%04X, ram$D000=%02X)\n", addr, b, (writeRAM ? "T" : "F"), mainCPU.pc, ram[0xC000]);
+}
+#endif
+       if (addr >= 0xC000 && addr <= 0xCFFF)
+               return; // Protect LC bank #1 from being written to!
+
        if (addr >= 0xD000)
        {
                if (writeRAM)
@@ -724,7 +789,7 @@ int main(int /*argc*/, char * /*argv*/[])
 
 //Load up disk image from config file (for now)...
        floppyDrive.LoadImage(settings.diskImagePath1, 0);
-//     floppyDrive.LoadImage(settings.diskImagePath2, 1);
+       floppyDrive.LoadImage(settings.diskImagePath2, 1);
 //     floppyDrive.LoadImage("./disks/temp.nib", 1);   // Load temp .nib file into second drive...
 
 //Kill the DOS ROM in slot 6 for now...
@@ -785,12 +850,15 @@ memcpy(ram + 0xD000, ram + 0xC000, 0x1000);
        SoundInit();
        SDL_EnableUNICODE(1);                                           // Needed to do key translation shit
 
-       gui = new GUI(surface);                                         // Set up the GUI system object...
+//     gui = new GUI(surface);                                         // Set up the GUI system object...
+       gui = new GUI(mainSurface);                                     // Set up the GUI system object...
+#if 0
        gui->AddMenuTitle("Apple2");
        gui->AddMenuItem("Test!", TestWindow/*, hotkey*/);
        gui->AddMenuItem("");
        gui->AddMenuItem("Quit", QuitEmulator, SDLK_q);
        gui->CommitItemsToMenu();
+#endif
 
        SetupBlurTable();                                                       // Set up the color TV emulation blur table
        running = true;                                                         // Set running status...