diff --git a/src/emucore/Cart.cxx b/src/emucore/Cart.cxx index e2a8f1ffb..b8ef48961 100644 --- a/src/emucore/Cart.cxx +++ b/src/emucore/Cart.cxx @@ -496,6 +496,40 @@ bool Cartridge::isProbablySC(const uInt8* image, uInt32 size) return true; } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool Cartridge::isProbably0840(const uInt8* image, uInt32 size) +{ + // 0840 cart bankswitching is triggered by accessing addresses 0x0800 + // or 0x0840 + uInt8 signature1[2][3] = { + { 0xAD, 0x00, 0x08 }, // LDA $0800 + { 0xAD, 0x40, 0x08 } // LDA $0840 + }; + for(uInt32 i = 0; i < 2; ++i) + if(searchForBytes(image, size, signature1[i], 3, 1)) + return true; + + uInt8 signature2[2][4] = { + { 0x0C, 0x00, 0x08, 0x4C }, // NOP $0800; JMP ... + { 0x0C, 0xFF, 0x0F, 0x4C } // NOP $0FFF; JMP ... + }; + for(uInt32 i = 0; i < 2; ++i) + if(searchForBytes(image, size, signature2[i], 4, 1)) + return true; + + return false; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool Cartridge::isProbably3E(const uInt8* image, uInt32 size) +{ + // 3E cart bankswitching is triggered by storing the bank number + // in address 3E using 'STA $3E', commonly followed by an + // immediate mode LDA + uInt8 signature[] = { 0x85, 0x3E, 0xA9, 0x00 }; // STA $3E; LDA #$00 + return searchForBytes(image, size, signature, 4, 1); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool Cartridge::isProbably3F(const uInt8* image, uInt32 size) { @@ -508,13 +542,28 @@ bool Cartridge::isProbably3F(const uInt8* image, uInt32 size) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool Cartridge::isProbably3E(const uInt8* image, uInt32 size) +bool Cartridge::isProbably4A50(const uInt8* image, uInt32 size) { - // 3E cart bankswitching is triggered by storing the bank number - // in address 3E using 'STA $3E', commonly followed by an - // immediate mode LDA - uInt8 signature[] = { 0x85, 0x3E, 0xA9, 0x00 }; // STA $3E; LDA #$00 - return searchForBytes(image, size, signature, 4, 1); + // 4A50 carts store address $4A50 at the NMI vector, which + // in this scheme is always in the last page of ROM at + // $1FFA - $1FFB (at least this is true in rev 1 of the format) + int idx = size - 6; // $1FFA + return (image[idx] == 0x50 && image[idx+1] == 0x4A); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool Cartridge::isProbablyCV(const uInt8* image, uInt32 size) +{ + // CV RAM access occurs at addresses $f3ff and $f400 + // These signatures are attributed to the MESS project + uInt8 signature[2][3] = { + { 0x9D, 0xFF, 0xF3 }, // STA $F3FF + { 0x99, 0x00, 0xF4 } // STA $F400 + }; + if(searchForBytes(image, size, signature[0], 3, 1)) + return true; + else + return searchForBytes(image, size, signature[1], 3, 1); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -560,14 +609,16 @@ bool Cartridge::isProbablyE7(const uInt8* image, uInt32 size) // search for only certain known signatures // Thanks to "stella@casperkitty.com" for this advice // These signatures are attributed to the MESS project - uInt8 signature[5][3] = { + uInt8 signature[7][3] = { + { 0xAD, 0xE2, 0xFF }, // LDA $FFE2 { 0xAD, 0xE5, 0xFF }, // LDA $FFE5 { 0xAD, 0xE5, 0x1F }, // LDA $1FE5 + { 0xAD, 0xE7, 0x1F }, // LDA $1FE7 { 0x0C, 0xE7, 0x1F }, // NOP $1FE7 { 0x8D, 0xE7, 0xFF }, // STA $FFE7 { 0x8D, 0xE7, 0x1F } // STA $1FE7 }; - for(uInt32 i = 0; i < 5; ++i) + for(uInt32 i = 0; i < 7; ++i) if(searchForBytes(image, size, signature[i], 3, 1)) return true; @@ -591,32 +642,24 @@ bool Cartridge::isProbablyEF(const uInt8* image, uInt32 size) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool Cartridge::isProbablyUA(const uInt8* image, uInt32 size) +bool Cartridge::isProbablyFE(const uInt8* image, uInt32 size) { - // UA cart bankswitching switches to bank 1 by accessing address 0x240 - // using 'STA $240' or 'LDA $240' - uInt8 signature[3][3] = { - { 0x8D, 0x40, 0x02 }, // STA $240 - { 0xAD, 0x40, 0x02 }, // LDA $240 - { 0xBD, 0x1F, 0x02 } // LDA $21F,X + // FE bankswitching is very weird, but always seems to include a + // 'JSR $xxxx' + // These signatures are attributed to the MESS project + uInt8 signature[4][5] = { + { 0x20, 0x00, 0xD0, 0xC6, 0xC5 }, // JSR $D000; DEC $C5 + { 0x20, 0xC3, 0xF8, 0xA5, 0x82 }, // JSR $F8C3; LDA $82 + { 0xD0, 0xFB, 0x20, 0x73, 0xFE }, // BNE $FB; JSR $FE73 + { 0x20, 0x00, 0xF0, 0x84, 0xD6 } // JSR $F000; STY $D6 }; - for(uInt32 i = 0; i < 3; ++i) - if(searchForBytes(image, size, signature[i], 3, 1)) + for(uInt32 i = 0; i < 4; ++i) + if(searchForBytes(image, size, signature[i], 5, 1)) return true; return false; } -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool Cartridge::isProbably4A50(const uInt8* image, uInt32 size) -{ - // 4A50 carts store address $4A50 at the NMI vector, which - // in this scheme is always in the last page of ROM at - // $1FFA - $1FFB (at least this is true in rev 1 of the format) - int idx = size - 6; // $1FFA - return (image[idx] == 0x50 && image[idx+1] == 0x4A); -} - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool Cartridge::isProbablySB(const uInt8* image, uInt32 size) { @@ -632,58 +675,17 @@ bool Cartridge::isProbablySB(const uInt8* image, uInt32 size) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool Cartridge::isProbably0840(const uInt8* image, uInt32 size) +bool Cartridge::isProbablyUA(const uInt8* image, uInt32 size) { - // 0840 cart bankswitching is triggered by accessing addresses 0x0800 - // or 0x0840 - uInt8 signature1[2][3] = { - { 0xAD, 0x00, 0x08 }, // LDA $0800 - { 0xAD, 0x40, 0x08 } // LDA $0840 + // UA cart bankswitching switches to bank 1 by accessing address 0x240 + // using 'STA $240' or 'LDA $240' + uInt8 signature[3][3] = { + { 0x8D, 0x40, 0x02 }, // STA $240 + { 0xAD, 0x40, 0x02 }, // LDA $240 + { 0xBD, 0x1F, 0x02 } // LDA $21F,X }; - for(uInt32 i = 0; i < 2; ++i) - if(searchForBytes(image, size, signature1[i], 3, 1)) - return true; - - uInt8 signature2[2][4] = { - { 0x0C, 0x00, 0x08, 0x4C }, // NOP $0800; JMP ... - { 0x0C, 0xFF, 0x0F, 0x4C } // NOP $0FFF; JMP ... - }; - for(uInt32 i = 0; i < 2; ++i) - if(searchForBytes(image, size, signature2[i], 4, 1)) - return true; - - return false; -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool Cartridge::isProbablyCV(const uInt8* image, uInt32 size) -{ - // CV RAM access occurs at addresses $f3ff and $f400 - // These signatures are attributed to the MESS project - uInt8 signature[2][3] = { - { 0x9D, 0xFF, 0xF3 }, // STA $F3FF - { 0x99, 0x00, 0xF4 } // STA $F400 - }; - if(searchForBytes(image, size, signature[0], 3, 1)) - return true; - else - return searchForBytes(image, size, signature[1], 3, 1); -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool Cartridge::isProbablyFE(const uInt8* image, uInt32 size) -{ - // FE bankswitching is very weird, but always seems to include a - // 'JSR $xxxx' - // These signatures are attributed to the MESS project - uInt8 signature[4][5] = { - { 0x20, 0x00, 0xD0, 0xC6, 0xC5 }, // JSR $D000; DEC $C5 - { 0x20, 0xC3, 0xF8, 0xA5, 0x82 }, // JSR $F8C3; LDA $82 - { 0xD0, 0xFB, 0x20, 0x73, 0xFE }, // BNE $FB; JSR $FE73 - { 0x20, 0x00, 0xF0, 0x84, 0xD6 } // JSR $F000; STY $D6 - }; - for(uInt32 i = 0; i < 4; ++i) - if(searchForBytes(image, size, signature[i], 5, 1)) + for(uInt32 i = 0; i < 3; ++i) + if(searchForBytes(image, size, signature[i], 3, 1)) return true; return false; diff --git a/src/emucore/Cart.hxx b/src/emucore/Cart.hxx index ae1551cbe..65d0a7099 100644 --- a/src/emucore/Cart.hxx +++ b/src/emucore/Cart.hxx @@ -251,15 +251,30 @@ class Cartridge : public Device static bool isProbablySC(const uInt8* image, uInt32 size); /** - Returns true if the image is probably a 3F bankswitching cartridge + Returns true if the image is probably a 0840 bankswitching cartridge */ - static bool isProbably3F(const uInt8* image, uInt32 size); + static bool isProbably0840(const uInt8* image, uInt32 size); /** Returns true if the image is probably a 3E bankswitching cartridge */ static bool isProbably3E(const uInt8* image, uInt32 size); - + + /** + Returns true if the image is probably a 3F bankswitching cartridge + */ + static bool isProbably3F(const uInt8* image, uInt32 size); + + /** + Returns true if the image is probably a 4A50 bankswitching cartridge + */ + static bool isProbably4A50(const uInt8* image, uInt32 size); + + /** + Returns true if the image is probably a CV bankswitching cartridge + */ + static bool isProbablyCV(const uInt8* image, uInt32 size); + /** Returns true if the image is probably a DPC+ bankswitching cartridge */ @@ -281,14 +296,14 @@ class Cartridge : public Device static bool isProbablyEF(const uInt8* image, uInt32 size); /** - Returns true if the image is probably a UA bankswitching cartridge + Returns true if the image is probably an F6 bankswitching cartridge */ - static bool isProbablyUA(const uInt8* image, uInt32 size); + static bool isProbablyF6(const uInt8* image, uInt32 size); /** - Returns true if the image is probably a 4A50 bankswitching cartridge + Returns true if the image is probably an FE bankswitching cartridge */ - static bool isProbably4A50(const uInt8* image, uInt32 size); + static bool isProbablyFE(const uInt8* image, uInt32 size); /** Returns true if the image is probably a SB bankswitching cartridge @@ -296,19 +311,9 @@ class Cartridge : public Device static bool isProbablySB(const uInt8* image, uInt32 size); /** - Returns true if the image is probably a 0840 bankswitching cartridge + Returns true if the image is probably a UA bankswitching cartridge */ - static bool isProbably0840(const uInt8* image, uInt32 size); - - /** - Returns true if the image is probably a CV bankswitching cartridge - */ - static bool isProbablyCV(const uInt8* image, uInt32 size); - - /** - Returns true if the image is probably an FE bankswitching cartridge - */ - static bool isProbablyFE(const uInt8* image, uInt32 size); + static bool isProbablyUA(const uInt8* image, uInt32 size); /** Returns true if the image is probably an X07 bankswitching cartridge diff --git a/src/emucore/Cart0840.cxx b/src/emucore/Cart0840.cxx index 969c0a547..b95332537 100644 --- a/src/emucore/Cart0840.cxx +++ b/src/emucore/Cart0840.cxx @@ -199,11 +199,9 @@ const uInt8* Cartridge0840::getImage(int& size) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool Cartridge0840::save(Serializer& out) const { - const string& cart = name(); - try { - out.putString(cart); + out.putString(name()); out.putInt(myCurrentBank); } catch(const char* msg) @@ -218,11 +216,9 @@ bool Cartridge0840::save(Serializer& out) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool Cartridge0840::load(Serializer& in) { - const string& cart = name(); - try { - if(in.getString() != cart) + if(in.getString() != name()) return false; myCurrentBank = (uInt16)in.getInt(); diff --git a/src/emucore/Cart2K.cxx b/src/emucore/Cart2K.cxx index 6f1485355..994938fc1 100644 --- a/src/emucore/Cart2K.cxx +++ b/src/emucore/Cart2K.cxx @@ -136,11 +136,9 @@ const uInt8* Cartridge2K::getImage(int& size) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool Cartridge2K::save(Serializer& out) const { - const string& cart = name(); - try { - out.putString(cart); + out.putString(name()); } catch(const char* msg) { @@ -154,11 +152,9 @@ bool Cartridge2K::save(Serializer& out) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool Cartridge2K::load(Serializer& in) { - const string& cart = name(); - try { - if(in.getString() != cart) + if(in.getString() != name()) return false; } catch(const char* msg) diff --git a/src/emucore/Cart3E.cxx b/src/emucore/Cart3E.cxx index 71d905d56..463415bd9 100644 --- a/src/emucore/Cart3E.cxx +++ b/src/emucore/Cart3E.cxx @@ -273,11 +273,9 @@ const uInt8* Cartridge3E::getImage(int& size) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool Cartridge3E::save(Serializer& out) const { - const string& cart = name(); - try { - out.putString(cart); + out.putString(name()); out.putInt(myCurrentBank); // Output RAM @@ -297,11 +295,9 @@ bool Cartridge3E::save(Serializer& out) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool Cartridge3E::load(Serializer& in) { - const string& cart = name(); - try { - if(in.getString() != cart) + if(in.getString() != name()) return false; myCurrentBank = (uInt16) in.getInt(); diff --git a/src/emucore/Cart3F.cxx b/src/emucore/Cart3F.cxx index 8a89d3471..f5e32b663 100644 --- a/src/emucore/Cart3F.cxx +++ b/src/emucore/Cart3F.cxx @@ -192,11 +192,9 @@ const uInt8* Cartridge3F::getImage(int& size) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool Cartridge3F::save(Serializer& out) const { - const string& cart = name(); - try { - out.putString(cart); + out.putString(name()); out.putInt(myCurrentBank); } catch(const char* msg) @@ -211,11 +209,9 @@ bool Cartridge3F::save(Serializer& out) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool Cartridge3F::load(Serializer& in) { - const string& cart = name(); - try { - if(in.getString() != cart) + if(in.getString() != name()) return false; myCurrentBank = (uInt16) in.getInt(); diff --git a/src/emucore/Cart4A50.cxx b/src/emucore/Cart4A50.cxx index b478e7f1f..6119f18f5 100644 --- a/src/emucore/Cart4A50.cxx +++ b/src/emucore/Cart4A50.cxx @@ -373,11 +373,9 @@ const uInt8* Cartridge4A50::getImage(int& size) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool Cartridge4A50::save(Serializer& out) const { - const string& cart = name(); - try { - out.putString(cart); + out.putString(name()); // The 32K bytes of RAM out.putInt(32768); @@ -410,11 +408,9 @@ bool Cartridge4A50::save(Serializer& out) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool Cartridge4A50::load(Serializer& in) { - const string& cart = name(); - try { - if(in.getString() != cart) + if(in.getString() != name()) return false; uInt32 limit = (uInt32) in.getInt(); diff --git a/src/emucore/Cart4K.cxx b/src/emucore/Cart4K.cxx index fc53c6719..5d9bf1fda 100644 --- a/src/emucore/Cart4K.cxx +++ b/src/emucore/Cart4K.cxx @@ -113,11 +113,9 @@ const uInt8* Cartridge4K::getImage(int& size) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool Cartridge4K::save(Serializer& out) const { - const string& cart = name(); - try { - out.putString(cart); + out.putString(name()); } catch(const char* msg) { @@ -131,11 +129,9 @@ bool Cartridge4K::save(Serializer& out) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool Cartridge4K::load(Serializer& in) { - const string& cart = name(); - try { - if(in.getString() != cart) + if(in.getString() != name()) return false; } catch(const char* msg) diff --git a/src/emucore/CartAR.cxx b/src/emucore/CartAR.cxx index 50b9e3d13..0335269b9 100644 --- a/src/emucore/CartAR.cxx +++ b/src/emucore/CartAR.cxx @@ -444,13 +444,11 @@ const uInt8* CartridgeAR::getImage(int& size) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool CartridgeAR::save(Serializer& out) const { - const string& cart = name(); - try { uInt32 i; - out.putString(cart); + out.putString(name()); // Indicates the offest within the image for the corresponding bank out.putInt(2); @@ -506,11 +504,9 @@ bool CartridgeAR::save(Serializer& out) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool CartridgeAR::load(Serializer& in) { - const string& cart = name(); - try { - if(in.getString() != cart) + if(in.getString() != name()) return false; uInt32 i, limit; diff --git a/src/emucore/CartCV.cxx b/src/emucore/CartCV.cxx index 2a77dfa77..1ca54b68b 100644 --- a/src/emucore/CartCV.cxx +++ b/src/emucore/CartCV.cxx @@ -196,11 +196,9 @@ const uInt8* CartridgeCV::getImage(int& size) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool CartridgeCV::save(Serializer& out) const { - const string& cart = name(); - try { - out.putString(cart); + out.putString(name()); // Output RAM out.putInt(1024); @@ -219,11 +217,9 @@ bool CartridgeCV::save(Serializer& out) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool CartridgeCV::load(Serializer& in) { - const string& cart = name(); - try { - if(in.getString() != cart) + if(in.getString() != name()) return false; // Input RAM diff --git a/src/emucore/CartDPC.cxx b/src/emucore/CartDPC.cxx index 4ad9d6990..5c4dc77d5 100644 --- a/src/emucore/CartDPC.cxx +++ b/src/emucore/CartDPC.cxx @@ -479,13 +479,11 @@ const uInt8* CartridgeDPC::getImage(int& size) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool CartridgeDPC::save(Serializer& out) const { - const string& cart = name(); - try { uInt32 i; - out.putString(cart); + out.putString(name()); // Indicates which bank is currently active out.putInt(myCurrentBank); @@ -533,11 +531,9 @@ bool CartridgeDPC::save(Serializer& out) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool CartridgeDPC::load(Serializer& in) { - const string& cart = name(); - try { - if(in.getString() != cart) + if(in.getString() != name()) return false; uInt32 i, limit; diff --git a/src/emucore/CartDPCPlus.cxx b/src/emucore/CartDPCPlus.cxx index 09cc5bc57..85dc7e52a 100644 --- a/src/emucore/CartDPCPlus.cxx +++ b/src/emucore/CartDPCPlus.cxx @@ -599,13 +599,11 @@ const uInt8* CartridgeDPCPlus::getImage(int& size) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool CartridgeDPCPlus::save(Serializer& out) const { - const string& cart = name(); - try { uInt32 i; - out.putString(cart); + out.putString(name()); // Indicates which bank is currently active out.putInt(myCurrentBank); @@ -680,11 +678,9 @@ bool CartridgeDPCPlus::save(Serializer& out) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool CartridgeDPCPlus::load(Serializer& in) { - const string& cart = name(); - try { - if(in.getString() != cart) + if(in.getString() != name()) return false; uInt32 i, limit; diff --git a/src/emucore/CartE0.cxx b/src/emucore/CartE0.cxx index 47285085b..2789ed4d0 100644 --- a/src/emucore/CartE0.cxx +++ b/src/emucore/CartE0.cxx @@ -238,11 +238,9 @@ const uInt8* CartridgeE0::getImage(int& size) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool CartridgeE0::save(Serializer& out) const { - const string& cart = name(); - try { - out.putString(cart); + out.putString(name()); out.putInt(4); for(uInt32 i = 0; i < 4; ++i) @@ -260,11 +258,9 @@ bool CartridgeE0::save(Serializer& out) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool CartridgeE0::load(Serializer& in) { - const string& cart = name(); - try { - if(in.getString() != cart) + if(in.getString() != name()) return false; uInt32 limit = (uInt32) in.getInt(); diff --git a/src/emucore/CartE7.cxx b/src/emucore/CartE7.cxx index 352a379f3..f202e74d6 100644 --- a/src/emucore/CartE7.cxx +++ b/src/emucore/CartE7.cxx @@ -300,13 +300,11 @@ const uInt8* CartridgeE7::getImage(int& size) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool CartridgeE7::save(Serializer& out) const { - const string& cart = name(); - try { uInt32 i; - out.putString(cart); + out.putString(name()); out.putInt(2); for(i = 0; i < 2; ++i) @@ -331,11 +329,9 @@ bool CartridgeE7::save(Serializer& out) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool CartridgeE7::load(Serializer& in) { - const string& cart = name(); - try { - if(in.getString() != cart) + if(in.getString() != name()) return false; uInt32 i, limit; diff --git a/src/emucore/CartEF.cxx b/src/emucore/CartEF.cxx index f1f445723..da3a6c734 100644 --- a/src/emucore/CartEF.cxx +++ b/src/emucore/CartEF.cxx @@ -150,12 +150,9 @@ const uInt8* CartridgeEF::getImage(int& size) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool CartridgeEF::save(Serializer& out) const { - const string& cart = name(); - try { - out.putString(cart); - + out.putString(name()); out.putInt(myCurrentBank); } catch(const char* msg) @@ -170,11 +167,9 @@ bool CartridgeEF::save(Serializer& out) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool CartridgeEF::load(Serializer& in) { - const string& cart = name(); - try { - if(in.getString() != cart) + if(in.getString() != name()) return false; myCurrentBank = (uInt16) in.getInt(); diff --git a/src/emucore/CartEFSC.cxx b/src/emucore/CartEFSC.cxx index 0dbf2cf91..452dda7f1 100644 --- a/src/emucore/CartEFSC.cxx +++ b/src/emucore/CartEFSC.cxx @@ -205,12 +205,9 @@ const uInt8* CartridgeEFSC::getImage(int& size) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool CartridgeEFSC::save(Serializer& out) const { - const string& cart = name(); - try { - out.putString(cart); - + out.putString(name()); out.putInt(myCurrentBank); } catch(const char* msg) @@ -225,11 +222,9 @@ bool CartridgeEFSC::save(Serializer& out) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool CartridgeEFSC::load(Serializer& in) { - const string& cart = name(); - try { - if(in.getString() != cart) + if(in.getString() != name()) return false; myCurrentBank = (uInt16) in.getInt(); diff --git a/src/emucore/CartF0.cxx b/src/emucore/CartF0.cxx index f3feffce5..12f03ea65 100644 --- a/src/emucore/CartF0.cxx +++ b/src/emucore/CartF0.cxx @@ -161,12 +161,9 @@ const uInt8* CartridgeF0::getImage(int& size) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool CartridgeF0::save(Serializer& out) const { - const string& cart = name(); - try { - out.putString(cart); - + out.putString(name()); out.putInt(myCurrentBank); } catch(const char* msg) @@ -181,11 +178,9 @@ bool CartridgeF0::save(Serializer& out) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool CartridgeF0::load(Serializer& in) { - const string& cart = name(); - try { - if(in.getString() != cart) + if(in.getString() != name()) return false; myCurrentBank = (uInt16) in.getInt(); diff --git a/src/emucore/CartF4.cxx b/src/emucore/CartF4.cxx index 6c6a48059..043c887a3 100644 --- a/src/emucore/CartF4.cxx +++ b/src/emucore/CartF4.cxx @@ -154,11 +154,9 @@ const uInt8* CartridgeF4::getImage(int& size) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool CartridgeF4::save(Serializer& out) const { - const string& cart = name(); - try { - out.putString(cart); + out.putString(name()); out.putInt(myCurrentBank); } catch(const char* msg) @@ -173,14 +171,10 @@ bool CartridgeF4::save(Serializer& out) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool CartridgeF4::load(Serializer& in) { - const string& cart = name(); - try { - if(in.getString() != cart) - { + if(in.getString() != name()) return false; - } myCurrentBank = (uInt16)in.getInt(); } diff --git a/src/emucore/CartF4SC.cxx b/src/emucore/CartF4SC.cxx index c03d75379..e3934a3a6 100644 --- a/src/emucore/CartF4SC.cxx +++ b/src/emucore/CartF4SC.cxx @@ -208,12 +208,9 @@ const uInt8* CartridgeF4SC::getImage(int& size) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool CartridgeF4SC::save(Serializer& out) const { - const string& cart = name(); - try { - out.putString(cart); - + out.putString(name()); out.putInt(myCurrentBank); // The 128 bytes of RAM @@ -233,11 +230,9 @@ bool CartridgeF4SC::save(Serializer& out) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool CartridgeF4SC::load(Serializer& in) { - const string& cart = name(); - try { - if(in.getString() != cart) + if(in.getString() != name()) return false; myCurrentBank = (uInt16) in.getInt(); diff --git a/src/emucore/CartF6.cxx b/src/emucore/CartF6.cxx index eae28907e..831537c67 100644 --- a/src/emucore/CartF6.cxx +++ b/src/emucore/CartF6.cxx @@ -194,12 +194,9 @@ const uInt8* CartridgeF6::getImage(int& size) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool CartridgeF6::save(Serializer& out) const { - const string& cart = name(); - try { - out.putString(cart); - + out.putString(name()); out.putInt(myCurrentBank); } catch(const char* msg) @@ -214,11 +211,9 @@ bool CartridgeF6::save(Serializer& out) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool CartridgeF6::load(Serializer& in) { - const string& cart = name(); - try { - if(in.getString() != cart) + if(in.getString() != name()) return false; myCurrentBank = (uInt16) in.getInt(); diff --git a/src/emucore/CartF6SC.cxx b/src/emucore/CartF6SC.cxx index 8245f47f7..f10b0b5b9 100644 --- a/src/emucore/CartF6SC.cxx +++ b/src/emucore/CartF6SC.cxx @@ -251,12 +251,9 @@ const uInt8* CartridgeF6SC::getImage(int& size) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool CartridgeF6SC::save(Serializer& out) const { - const string& cart = name(); - try { - out.putString(cart); - + out.putString(name()); out.putInt(myCurrentBank); // The 128 bytes of RAM @@ -277,11 +274,9 @@ bool CartridgeF6SC::save(Serializer& out) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool CartridgeF6SC::load(Serializer& in) { - const string& cart = name(); - try { - if(in.getString() != cart) + if(in.getString() != name()) return false; myCurrentBank = (uInt16) in.getInt(); diff --git a/src/emucore/CartF8.cxx b/src/emucore/CartF8.cxx index ea927cfe6..d342fbcee 100644 --- a/src/emucore/CartF8.cxx +++ b/src/emucore/CartF8.cxx @@ -175,12 +175,9 @@ const uInt8* CartridgeF8::getImage(int& size) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool CartridgeF8::save(Serializer& out) const { - const string& cart = name(); - try { - out.putString(cart); - + out.putString(name()); out.putInt(myCurrentBank); } catch(const char* msg) @@ -195,11 +192,9 @@ bool CartridgeF8::save(Serializer& out) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool CartridgeF8::load(Serializer& in) { - const string& cart = name(); - try { - if(in.getString() != cart) + if(in.getString() != name()) return false; myCurrentBank = (uInt16) in.getInt(); diff --git a/src/emucore/CartF8SC.cxx b/src/emucore/CartF8SC.cxx index 5f4dc0184..d4f5eb388 100644 --- a/src/emucore/CartF8SC.cxx +++ b/src/emucore/CartF8SC.cxx @@ -231,12 +231,9 @@ const uInt8* CartridgeF8SC::getImage(int& size) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool CartridgeF8SC::save(Serializer& out) const { - const string& cart = name(); - try { - out.putString(cart); - + out.putString(name()); out.putInt(myCurrentBank); // The 128 bytes of RAM @@ -256,11 +253,9 @@ bool CartridgeF8SC::save(Serializer& out) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool CartridgeF8SC::load(Serializer& in) { - const string& cart = name(); - try { - if(in.getString() != cart) + if(in.getString() != name()) return false; myCurrentBank = (uInt16) in.getInt(); diff --git a/src/emucore/CartFA.cxx b/src/emucore/CartFA.cxx index 97fa0faad..d24c94fd2 100644 --- a/src/emucore/CartFA.cxx +++ b/src/emucore/CartFA.cxx @@ -241,12 +241,9 @@ const uInt8* CartridgeFA::getImage(int& size) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool CartridgeFA::save(Serializer& out) const { - const string& cart = name(); - try { - out.putString(cart); - + out.putString(name()); out.putInt(myCurrentBank); // The 256 bytes of RAM @@ -266,11 +263,9 @@ bool CartridgeFA::save(Serializer& out) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool CartridgeFA::load(Serializer& in) { - const string& cart = name(); - try { - if(in.getString() != cart) + if(in.getString() != name()) return false; myCurrentBank = (uInt16) in.getInt(); diff --git a/src/emucore/CartFE.cxx b/src/emucore/CartFE.cxx index 8176507bb..8831678ef 100644 --- a/src/emucore/CartFE.cxx +++ b/src/emucore/CartFE.cxx @@ -139,11 +139,9 @@ const uInt8* CartridgeFE::getImage(int& size) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool CartridgeFE::save(Serializer& out) const { - const string& cart = name(); - try { - out.putString(cart); + out.putString(name()); out.putInt(myLastAddress1); out.putInt(myLastAddress2); } @@ -159,11 +157,9 @@ bool CartridgeFE::save(Serializer& out) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool CartridgeFE::load(Serializer& in) { - const string& cart = name(); - try { - if(in.getString() != cart) + if(in.getString() != name()) return false; myLastAddress1 = (uInt16)in.getInt(); diff --git a/src/emucore/CartMC.cxx b/src/emucore/CartMC.cxx index 5ea20b9e4..eeb8c4ab9 100644 --- a/src/emucore/CartMC.cxx +++ b/src/emucore/CartMC.cxx @@ -246,12 +246,10 @@ const uInt8* CartridgeMC::getImage(int& size) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool CartridgeMC::save(Serializer& out) const { - uInt32 i; - const string& cart = name(); - try { - out.putString(cart); + uInt32 i; + out.putString(name()); // The currentBlock array out.putInt(4); @@ -275,14 +273,11 @@ bool CartridgeMC::save(Serializer& out) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool CartridgeMC::load(Serializer& in) { - uInt32 i; - const string& cart = name(); - try { - uInt32 limit; + uInt32 i, limit; - if(in.getString() != cart) + if(in.getString() != name()) return false; // The currentBlock array diff --git a/src/emucore/CartSB.cxx b/src/emucore/CartSB.cxx index f9b0dcb37..b9d4fbbfd 100644 --- a/src/emucore/CartSB.cxx +++ b/src/emucore/CartSB.cxx @@ -178,11 +178,9 @@ const uInt8* CartridgeSB::getImage(int& size) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool CartridgeSB::save(Serializer& out) const { - const string& cart = name(); - try { - out.putString(cart); + out.putString(name()); out.putInt(myCurrentBank); } catch(const char* msg) @@ -197,11 +195,9 @@ bool CartridgeSB::save(Serializer& out) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool CartridgeSB::load(Serializer& in) { - const string& cart = name(); - try { - if(in.getString() != cart) + if(in.getString() != name()) return false; myCurrentBank = (uInt16)in.getInt(); diff --git a/src/emucore/CartUA.cxx b/src/emucore/CartUA.cxx index ca2403855..1be139672 100644 --- a/src/emucore/CartUA.cxx +++ b/src/emucore/CartUA.cxx @@ -187,12 +187,9 @@ const uInt8* CartridgeUA::getImage(int& size) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool CartridgeUA::save(Serializer& out) const { - const string& cart = name(); - try { - out.putString(cart); - + out.putString(name()); out.putInt(myCurrentBank); } catch(const char* msg) @@ -207,11 +204,9 @@ bool CartridgeUA::save(Serializer& out) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool CartridgeUA::load(Serializer& in) { - const string& cart = name(); - try { - if(in.getString() != cart) + if(in.getString() != name()) return false; myCurrentBank = (uInt16)in.getInt(); diff --git a/src/emucore/CartX07.cxx b/src/emucore/CartX07.cxx index 2851aeb1e..0318022c9 100644 --- a/src/emucore/CartX07.cxx +++ b/src/emucore/CartX07.cxx @@ -171,11 +171,9 @@ const uInt8* CartridgeX07::getImage(int& size) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool CartridgeX07::save(Serializer& out) const { - const string& cart = name(); - try { - out.putString(cart); + out.putString(name()); out.putInt(myCurrentBank); } catch(const char* msg) @@ -190,11 +188,9 @@ bool CartridgeX07::save(Serializer& out) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool CartridgeX07::load(Serializer& in) { - const string& cart = name(); - try { - if(in.getString() != cart) + if(in.getString() != name()) return false; myCurrentBank = (uInt16)in.getInt();