]> Shamusworld >> Repos - apple2/commitdiff
Fixed stupid bug that caused LC RAM bank #1 to get clobbered when writing
authorShamus Hammons <jlhamm@acm.org>
Wed, 28 Jan 2009 06:10:42 +0000 (06:10 +0000)
committerShamus Hammons <jlhamm@acm.org>
Wed, 28 Jan 2009 06:10:42 +0000 (06:10 +0000)
to I/O block $C000-$CFFF.

src/apple2.cpp
src/floppy.cpp
src/timing.cpp
src/v65c02.cpp

index 8365ef4a58ce12d9d27eff88d0e20332d376212a..1021f2096356b9bc2a67f1fe6cd67f81d364c25d 100755 (executable)
@@ -256,7 +256,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 +371,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;
 }
@@ -648,6 +701,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)
index 091467966c8aee4cf1858f922e3a39f3f61f6b86..942ffd9b088a245b59639f26e8aab8056099a83f 100755 (executable)
@@ -566,3 +566,38 @@ void FloppyDrive::SetWriteMode(void)
        // $C0EF
        ioMode = IO_MODE_WRITE;
 }
+
+/*
+PRODOS 8 MLI ERROR CODES
+
+$00:    No error
+$01:    Bad system call number
+$04:    Bad system call parameter count
+$25:    Interrupt table full
+$27:    I/O error
+$28:    No device connected
+$2B:    Disk write protected
+$2E:    Disk switched
+$40:    Invalid pathname
+$42:    Maximum number of files open
+$43:    Invalid reference number
+$44:    Directory not found
+$45:    Volume not found
+$46:    File not found
+$47:    Duplicate filename
+$48:    Volume full
+$49:    Volume directory full
+$4A:    Incompatible file format, also a ProDOS directory
+$4B:    Unsupported storage_type
+$4C:    End of file encountered
+$4D:    Position out of range
+$4E:    File access error, also file locked
+$50:    File is open
+$51:    Directory structure damaged
+$52:    Not a ProDOS volume
+$53:    Invalid system call parameter
+$55:    Volume Control Block table full
+$56:    Bad buffer address
+$57:    Duplicate volume
+$5A:    File structure damaged
+*/
index 2bf07091173a20fcd3c391d02328e8f330d6a751..eafaa21f236edf8342ce4870592086751c9b11f5 100755 (executable)
@@ -63,7 +63,7 @@ void SetCallbackTime(void (* callback)(void), double time)
         }
     }
 
-    WriteLog("SetCallbackTime() failed to find an empty slot in the list!\n");
+    WriteLog("TIMING: SetCallbackTime() failed to find an empty slot in the list!\n");
 }
 
 void RemoveCallback(void (* callback)(void))
@@ -94,6 +94,10 @@ void AdjustCallbackTime(void (* callback)(void), double time)
 
 double GetTimeToNextEvent(void)
 {
+       // Find the next event. Since the events are not necessarily in order of
+       // increasing time, we have to search through the list for the lowest one.
+
+//ALSO: There's a bug here--nextEvent is getting a bogus value/getting clobbered...
     double time = 0;
     bool firstTime = true;
 
@@ -102,15 +106,25 @@ double GetTimeToNextEvent(void)
         if (eventList[i].valid)
         {
             if (firstTime)
-                time = eventList[i].eventTime, nextEvent = i, firstTime = false;
+                       {
+                time = eventList[i].eventTime;
+                               nextEvent = i;
+                               firstTime = false;
+                       }
             else
             {
                 if (eventList[i].eventTime < time)
-                    time = eventList[i].eventTime, nextEvent = i;
+                               {
+                    time = eventList[i].eventTime;
+                                       nextEvent = i;
+                               }
             }
         }
     }
 
+       if (time == 0)
+               WriteLog("TIMING: GetTimeToNextEvent() failed to find next event!\n");
+
     return time;
 }
 
index b5c8716747e02fb22da6cf94b934d4d3629afae0..59cc4157f03c716ef4e1e6155e97e87207e7a9c6 100755 (executable)
@@ -1700,6 +1700,9 @@ RTI       Implied         RTI                     40      1       6
 static void Op40(void)                                                 // RTI
 {
        regs.cc = regs.RdMem(0x0100 + ++regs.sp);
+//clear I (seems to be the case, either that or clear it in the IRQ setup...)
+//I can't find *any* verification that this is the case.
+//     regs.cc &= ~FLAG_I;
        regs.pc = regs.RdMem(0x0100 + ++regs.sp);
        regs.pc |= (uint16)(regs.RdMem(0x0100 + ++regs.sp)) << 8;
 }
@@ -2296,6 +2299,11 @@ if (regs.pc == 0xFDED)
        dumpDis = false;
 }
 #endif
+#if 0
+// ProDOS debugging
+if (regs.pc == 0x2000)
+       dumpDis = true;
+#endif
 
 #ifdef __DEBUG__
 if (dumpDis)