From: <ste...@us...> - 2010-03-30 20:36:20
|
Revision: 1980 http://stella.svn.sourceforge.net/stella/?rev=1980&view=rev Author: stephena Date: 2010-03-30 20:36:13 +0000 (Tue, 30 Mar 2010) Log Message: ----------- Added debugger patch support for bankswitch schemes CV, DPC, DPC+ and E7. DPC and DPC+ currently do not modify the DPC address space on a patch; more research is required to figure out how to handle this. Modified Paths: -------------- trunk/src/emucore/CartCV.cxx trunk/src/emucore/CartDPC.cxx trunk/src/emucore/CartDPCPlus.cxx trunk/src/emucore/CartE7.cxx trunk/src/emucore/CartEFSC.cxx trunk/src/emucore/CartF4SC.cxx trunk/src/emucore/CartF6SC.cxx trunk/src/emucore/CartF8SC.cxx trunk/src/emucore/CartFA.cxx Modified: trunk/src/emucore/CartCV.cxx =================================================================== --- trunk/src/emucore/CartCV.cxx 2010-03-29 02:21:32 UTC (rev 1979) +++ trunk/src/emucore/CartCV.cxx 2010-03-30 20:36:13 UTC (rev 1980) @@ -72,6 +72,8 @@ for(uInt32 i = 0; i < 1024; ++i) myRAM[i] = mySystem->randGenerator().next(); } + + myBankChanged = true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -139,7 +141,9 @@ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool CartridgeCV::poke(uInt16, uInt8) { - // This is ROM so poking has no effect :-) + // NOTE: This does not handle accessing RAM, however, this function + // should never be called for RAM because of the way page accessing + // has been setup return false; } @@ -165,9 +169,20 @@ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool CartridgeCV::patch(uInt16 address, uInt8 value) { - // TODO - ROM vs RAM in patching - myImage[address & 0x07FF] = value; - return true; + address &= 0x0FFF; + + if(address < 0x0800) + { + // Normally, a write to the read port won't do anything + // However, the patch command is special in that ignores such + // cart restrictions + // The following will work for both reads and writes + myRAM[address & 0x03FF] = value; + } + else + myImage[address & 0x07FF] = value; + + return myBankChanged = true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Modified: trunk/src/emucore/CartDPC.cxx =================================================================== --- trunk/src/emucore/CartDPC.cxx 2010-03-29 02:21:32 UTC (rev 1979) +++ trunk/src/emucore/CartDPC.cxx 2010-03-30 20:36:13 UTC (rev 1980) @@ -346,14 +346,14 @@ { if((index >= 5) && myMusicMode[index - 5]) { - // Data fecther is in music mode so its low counter value + // Data fetcher is in music mode so its low counter value // should be loaded from the top register not the poked value myCounters[index] = (myCounters[index] & 0x0700) | (uInt16)myTops[index]; } else { - // Data fecther is either not a music mode data fecther or it + // Data fetcher is either not a music mode data fetcher or it // isn't in music mode so it's low counter value should be loaded // with the poked value myCounters[index] = (myCounters[index] & 0x0700) | (uInt16)value; @@ -421,7 +421,7 @@ // Remember what bank we're in myCurrentBank = bank; - uInt16 offset = myCurrentBank * 4096; + uInt16 offset = myCurrentBank << 12; uInt16 shift = mySystem->pageShift(); uInt16 mask = mySystem->pageMask(); @@ -455,8 +455,16 @@ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool CartridgeDPC::patch(uInt16 address, uInt8 value) { - myProgramImage[(myCurrentBank << 12) + (address & 0x0FFF)] = value; - return true; + address &= 0x0FFF; + + // For now, we ignore attempts to patch the DPC address space + if(address >= 0x0080) + { + myProgramImage[(myCurrentBank << 12) + (address & 0x0FFF)] = value; + return myBankChanged = true; + } + else + return false; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Modified: trunk/src/emucore/CartDPCPlus.cxx =================================================================== --- trunk/src/emucore/CartDPCPlus.cxx 2010-03-29 02:21:32 UTC (rev 1979) +++ trunk/src/emucore/CartDPCPlus.cxx 2010-03-30 20:36:13 UTC (rev 1980) @@ -315,7 +315,7 @@ default: break; } - return myProgramImage[myCurrentBank * 4096 + address]; + return myProgramImage[(myCurrentBank << 12) + address]; } } @@ -501,7 +501,7 @@ // Remember what bank we're in myCurrentBank = bank; - uInt16 offset = myCurrentBank * 4096; + uInt16 offset = myCurrentBank << 12; uInt16 shift = mySystem->pageShift(); uInt16 mask = mySystem->pageMask(); @@ -535,8 +535,16 @@ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool CartridgeDPCPlus::patch(uInt16 address, uInt8 value) { - myProgramImage[(myCurrentBank << 12) + (address & 0x0FFF)] = value; - return myBankChanged = true; + address &= 0x0FFF; + + // For now, we ignore attempts to patch the DPC address space + if(address >= 0x0080) + { + myProgramImage[(myCurrentBank << 12) + (address & 0x0FFF)] = value; + return myBankChanged = true; + } + else + return false; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Modified: trunk/src/emucore/CartE7.cxx =================================================================== --- trunk/src/emucore/CartE7.cxx 2010-03-29 02:21:32 UTC (rev 1979) +++ trunk/src/emucore/CartE7.cxx 2010-03-30 20:36:13 UTC (rev 1980) @@ -258,8 +258,30 @@ bool CartridgeE7::patch(uInt16 address, uInt8 value) { address = address & 0x0FFF; - myImage[(myCurrentSlice[address >> 11] << 11) + (address & 0x07FF)] = value; - return true; + + if(address < 0x0800) + { + if(myCurrentSlice[0] == 7) + { + // Normally, a write to the read port won't do anything + // However, the patch command is special in that ignores such + // cart restrictions + myRAM[address & 0x03FF] = value; + } + else + myImage[(myCurrentSlice[0] << 11) + (address & 0x07FF)] = value; + } + else if(address < 0x0900) + { + // Normally, a write to the read port won't do anything + // However, the patch command is special in that ignores such + // cart restrictions + myRAM[1024 + (myCurrentRAM << 8) + (address & 0x00FF)] = value; + } + else + myImage[(myCurrentSlice[address >> 11] << 11) + (address & 0x07FF)] = value; + + return myBankChanged = true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Modified: trunk/src/emucore/CartEFSC.cxx =================================================================== --- trunk/src/emucore/CartEFSC.cxx 2010-03-29 02:21:32 UTC (rev 1979) +++ trunk/src/emucore/CartEFSC.cxx 2010-03-30 20:36:13 UTC (rev 1980) @@ -178,16 +178,12 @@ { address &= 0x0FFF; - if(address < 0x0080) + if(address < 0x0100) { - myRAM[address] = value; - } - else if(address < 0x0100) - { // Normally, a write to the read port won't do anything // However, the patch command is special in that ignores such // cart restrictions - myRAM[address - 0x80] = value; + myRAM[address & 0x007F] = value; } else myImage[(myCurrentBank << 12) + address] = value; Modified: trunk/src/emucore/CartF4SC.cxx =================================================================== --- trunk/src/emucore/CartF4SC.cxx 2010-03-29 02:21:32 UTC (rev 1979) +++ trunk/src/emucore/CartF4SC.cxx 2010-03-30 20:36:13 UTC (rev 1980) @@ -181,16 +181,12 @@ { address &= 0x0FFF; - if(address < 0x0080) + if(address < 0x0100) { - myRAM[address] = value; - } - else if(address < 0x0100) - { // Normally, a write to the read port won't do anything // However, the patch command is special in that ignores such // cart restrictions - myRAM[address - 0x80] = value; + myRAM[address & 0x007F] = value; } else myImage[(myCurrentBank << 12) + address] = value; Modified: trunk/src/emucore/CartF6SC.cxx =================================================================== --- trunk/src/emucore/CartF6SC.cxx 2010-03-29 02:21:32 UTC (rev 1979) +++ trunk/src/emucore/CartF6SC.cxx 2010-03-30 20:36:13 UTC (rev 1980) @@ -224,16 +224,12 @@ { address &= 0x0FFF; - if(address < 0x0080) + if(address < 0x0100) { - myRAM[address] = value; - } - else if(address < 0x0100) - { // Normally, a write to the read port won't do anything // However, the patch command is special in that ignores such // cart restrictions - myRAM[address - 0x80] = value; + myRAM[address & 0x007F] = value; } else myImage[(myCurrentBank << 12) + address] = value; Modified: trunk/src/emucore/CartF8SC.cxx =================================================================== --- trunk/src/emucore/CartF8SC.cxx 2010-03-29 02:21:32 UTC (rev 1979) +++ trunk/src/emucore/CartF8SC.cxx 2010-03-30 20:36:13 UTC (rev 1980) @@ -204,16 +204,12 @@ { address &= 0x0FFF; - if(address < 0x0080) + if(address < 0x0100) { - myRAM[address] = value; - } - else if(address < 0x0100) - { // Normally, a write to the read port won't do anything // However, the patch command is special in that ignores such // cart restrictions - myRAM[address - 0x80] = value; + myRAM[address & 0x007F] = value; } else myImage[(myCurrentBank << 12) + address] = value; Modified: trunk/src/emucore/CartFA.cxx =================================================================== --- trunk/src/emucore/CartFA.cxx 2010-03-29 02:21:32 UTC (rev 1979) +++ trunk/src/emucore/CartFA.cxx 2010-03-30 20:36:13 UTC (rev 1980) @@ -214,16 +214,12 @@ { address &= 0x0FFF; - if(address < 0x0100) + if(address < 0x0200) { - myRAM[address] = value; - } - else if(address < 0x0200) - { // Normally, a write to the read port won't do anything // However, the patch command is special in that ignores such // cart restrictions - myRAM[address - 0x100] = value; + myRAM[address & 0x00FF] = value; } else myImage[(myCurrentBank << 12) + address] = value; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |