]> Shamusworld >> Repos - apple2/blobdiff - src/mmu.cpp
Miscellaneous bugfixes.
[apple2] / src / mmu.cpp
index 77578d42271c63c2803da523275ebfeaf9ef6f6b..326451091748a04c4aa44407b7751ee51a15832a 100644 (file)
@@ -829,7 +829,9 @@ void WriteKeyStrobe(uint16_t, uint8_t)
 uint8_t ReadSpeaker(uint16_t)
 {
        ToggleSpeaker();
-       return 0;
+//     return 0;
+       // Seems this is needed for some things...
+       return ReadFloatingBus(0);
 }
 
 void WriteSpeaker(uint16_t, uint8_t)
@@ -841,7 +843,9 @@ uint8_t SwitchLCR(uint16_t address)
 {
        lcState = address & 0x0B;
        SwitchLC();
-       return 0;
+//     return 0;
+       // Seems this is needed for some things...
+       return ReadFloatingBus(0);
 }
 
 void SwitchLCW(uint16_t address, uint8_t)
@@ -929,7 +933,9 @@ uint8_t SwitchTEXTR(uint16_t address)
 {
 WriteLog("Setting TEXT to %s...\n", (address & 0x01 ? "ON" : "off"));
        textMode = (bool)(address & 0x01);
-       return 0;
+//     return 0;
+       // Seems this is needed for some things...
+       return ReadFloatingBus(0);
 }
 
 void SwitchTEXTW(uint16_t address, uint8_t)
@@ -942,7 +948,9 @@ uint8_t SwitchMIXEDR(uint16_t address)
 {
 WriteLog("Setting MIXED to %s...\n", (address & 0x01 ? "ON" : "off"));
        mixedMode = (bool)(address & 0x01);
-       return 0;
+//     return 0;
+       // Seems this is needed for some things...
+       return ReadFloatingBus(0);
 }
 
 void SwitchMIXEDW(uint16_t address, uint8_t)
@@ -951,6 +959,9 @@ WriteLog("Setting MIXED to %s...\n", (address & 0x01 ? "ON" : "off"));
        mixedMode = (bool)(address & 0x01);
 }
 
+/*
+80STORE, PAGE2, and HIRES bank switch the primary display pages, $400--$7FF and $2000--$3FFF, between motherboard RAM and auxiliary card RAM.  If 80STORE is set and HIRES is reset, then PAGE2 switches between motherboard RAM and auxiliary card RAM for reading and writing in the $400--$7FF range.  If 80STORE is set and HIRES is set, then PAGE2 switches between motherboard RAM and auxiliary card RAM for reading and writing in the $400--$7FF and $2000--$3FFF ranges.  PAGE2 set selects auxiliary card RAM, and PAGE2 reset selects motherboard RAM.  If 80STORE is reset, then RAMRD and RAMWRT will bank switch the $400-$7FF and $2000--$3FFF ranges along with the rest of the $200--$BFFF range.
+*/
 uint8_t SwitchPAGE2R(uint16_t address)
 {
 WriteLog("Setting PAGE2 to %s...\n", (address & 0x01 ? "ON" : "off"));
@@ -960,11 +971,16 @@ WriteLog("Setting PAGE2 to %s...\n", (address & 0x01 ? "ON" : "off"));
        {
                mainMemoryTextR = (displayPage2 ? &ram2[0x0400] : &ram[0x0400]);
                mainMemoryTextW = (displayPage2 ? &ram2[0x0400] : &ram[0x0400]);
-               mainMemoryHGRR = (displayPage2 ? &ram2[0x2000] : &ram[0x2000]);
-               mainMemoryHGRW = (displayPage2 ? &ram2[0x2000] : &ram[0x2000]);
+
+               if (hiRes)
+               {
+                       mainMemoryHGRR = (displayPage2 ? &ram2[0x2000] : &ram[0x2000]);
+                       mainMemoryHGRW = (displayPage2 ? &ram2[0x2000] : &ram[0x2000]);
+               }
        }
 
-       return 0;
+       // Seems this is needed for some things...
+       return ReadFloatingBus(0);
 }
 
 void SwitchPAGE2W(uint16_t address, uint8_t)
@@ -976,8 +992,12 @@ WriteLog("Setting PAGE2 to %s...\n", (address & 0x01 ? "ON" : "off"));
        {
                mainMemoryTextR = (displayPage2 ? &ram2[0x0400] : &ram[0x0400]);
                mainMemoryTextW = (displayPage2 ? &ram2[0x0400] : &ram[0x0400]);
-               mainMemoryHGRR = (displayPage2 ? &ram2[0x2000] : &ram[0x2000]);
-               mainMemoryHGRW = (displayPage2 ? &ram2[0x2000] : &ram[0x2000]);
+
+               if (hiRes)
+               {
+                       mainMemoryHGRR = (displayPage2 ? &ram2[0x2000] : &ram[0x2000]);
+                       mainMemoryHGRW = (displayPage2 ? &ram2[0x2000] : &ram[0x2000]);
+               }
        }
 }
 
@@ -985,7 +1005,9 @@ uint8_t SwitchHIRESR(uint16_t address)
 {
 WriteLog("Setting HIRES to %s...\n", (address & 0x01 ? "ON" : "off"));
        hiRes = (bool)(address & 0x01);
-       return 0;
+//     return 0;
+       // Seems this is needed for some things...
+       return ReadFloatingBus(0);
 }
 
 void SwitchHIRESW(uint16_t address, uint8_t)
@@ -1001,7 +1023,9 @@ WriteLog("Setting DHIRES to %s (ioudis = %s)...\n", ((address & 0x01) ^ 0x01 ? "
        if (ioudis)
                dhires = !((bool)(address & 0x01));
 
-       return 0;
+//     return 0;
+       // Seems this is needed for some things...
+       return ReadFloatingBus(0);
 }
 
 void SwitchDHIRESW(uint16_t address, uint8_t)