From 3949101fb7ec4959367645904e21fd9186670e10 Mon Sep 17 00:00:00 2001 From: stephena Date: Mon, 3 Nov 2014 17:16:43 +0000 Subject: [PATCH] Some 'nullptr' updates to Cart classes. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@3036 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- src/emucore/AtariVox.cxx | 4 +--- src/emucore/AtariVox.hxx | 2 +- src/emucore/Cart2K.cxx | 3 ++- src/emucore/Cart3E.cxx | 1 + src/emucore/Cart3F.cxx | 1 + src/emucore/CartAR.cxx | 3 ++- src/emucore/CartBF.hxx | 8 ++++---- src/emucore/CartBFSC.hxx | 8 ++++---- src/emucore/CartCV.cxx | 2 +- src/emucore/CartDASH.cxx | 11 +++++++---- src/emucore/CartDF.hxx | 4 ++-- src/emucore/CartDFSC.hxx | 6 +++--- src/emucore/CartDPCPlus.cxx | 11 ++++------- src/emucore/CartDPCPlus.hxx | 2 +- src/emucore/CartFA2.cxx | 4 ---- src/emucore/CartFA2.hxx | 2 +- src/emucore/CartMDM.cxx | 4 ++-- src/emucore/CartSB.cxx | 1 + 18 files changed, 38 insertions(+), 39 deletions(-) diff --git a/src/emucore/AtariVox.cxx b/src/emucore/AtariVox.cxx index bba4c6d0a..d43cd9da3 100644 --- a/src/emucore/AtariVox.cxx +++ b/src/emucore/AtariVox.cxx @@ -28,7 +28,6 @@ AtariVox::AtariVox(Jack jack, const Event& event, const System& system, const string& eepromfile) : Controller(jack, event, system, Controller::AtariVox), mySerialPort((SerialPort&)port), - myEEPROM(NULL), myShiftCount(0), myShiftRegister(0), myLastDataWriteCycle(0) @@ -38,7 +37,7 @@ AtariVox::AtariVox(Jack jack, const Event& event, const System& system, else myAboutString = " (invalid serial port \'" + portname + "\')"; - myEEPROM = new MT24LC256(eepromfile, system); + myEEPROM = make_ptr(eepromfile, system); myDigitalPinState[One] = myDigitalPinState[Two] = myDigitalPinState[Three] = myDigitalPinState[Four] = true; @@ -50,7 +49,6 @@ AtariVox::AtariVox(Jack jack, const Event& event, const System& system, AtariVox::~AtariVox() { mySerialPort.closePort(); - delete myEEPROM; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/AtariVox.hxx b/src/emucore/AtariVox.hxx index dccb04e21..6814eb85b 100644 --- a/src/emucore/AtariVox.hxx +++ b/src/emucore/AtariVox.hxx @@ -106,7 +106,7 @@ class AtariVox : public Controller SerialPort& mySerialPort; // The EEPROM used in the AtariVox - MT24LC256* myEEPROM; + unique_ptr myEEPROM; // How many bits have been shifted into the shift register? uInt8 myShiftCount; diff --git a/src/emucore/Cart2K.cxx b/src/emucore/Cart2K.cxx index f5e93635b..9878c27a0 100644 --- a/src/emucore/Cart2K.cxx +++ b/src/emucore/Cart2K.cxx @@ -24,7 +24,8 @@ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Cartridge2K::Cartridge2K(const uInt8* image, uInt32 size, const Settings& settings) - : Cartridge(settings) + : Cartridge(settings), + myImage(nullptr) { // Size can be a maximum of 2K if(size > 2048) size = 2048; diff --git a/src/emucore/Cart3E.cxx b/src/emucore/Cart3E.cxx index 80b01aa61..dfc53d69b 100644 --- a/src/emucore/Cart3E.cxx +++ b/src/emucore/Cart3E.cxx @@ -27,6 +27,7 @@ Cartridge3E::Cartridge3E(const uInt8* image, uInt32 size, const Settings& settings) : Cartridge(settings), + myImage(nullptr), mySize(size) { // Allocate array for the ROM image diff --git a/src/emucore/Cart3F.cxx b/src/emucore/Cart3F.cxx index b0669d88f..4d343d8e3 100644 --- a/src/emucore/Cart3F.cxx +++ b/src/emucore/Cart3F.cxx @@ -27,6 +27,7 @@ Cartridge3F::Cartridge3F(const uInt8* image, uInt32 size, const Settings& settings) : Cartridge(settings), + myImage(nullptr), mySize(size) { // Allocate array for the ROM image diff --git a/src/emucore/CartAR.cxx b/src/emucore/CartAR.cxx index c0b5d91fd..1e1099b77 100644 --- a/src/emucore/CartAR.cxx +++ b/src/emucore/CartAR.cxx @@ -28,7 +28,8 @@ CartridgeAR::CartridgeAR(const uInt8* image, uInt32 size, const Settings& settings) : Cartridge(settings), my6502(0), - mySize(BSPF_max(size, 8448u)) + mySize(BSPF_max(size, 8448u)), + myLoadImages(nullptr) { // Create a load image buffer and copy the given image myLoadImages = new uInt8[mySize]; diff --git a/src/emucore/CartBF.hxx b/src/emucore/CartBF.hxx index 080cde369..8a8d60499 100644 --- a/src/emucore/CartBF.hxx +++ b/src/emucore/CartBF.hxx @@ -30,8 +30,8 @@ class System; /** Update of EF cartridge class used for Homestar Runner by Paul Slocum. - There are 32 4K banks (total of 128K ROM). - Accessing $1FC0 - $1FDF switches to each bank. + There are 64 4K banks (total of 256K ROM). + Accessing $1F80 - $1FBF switches to each bank. @author Mike Saarna @version $Id$ @@ -159,8 +159,8 @@ class CartridgeBF : public Cartridge // Indicates which bank is currently active uInt16 myCurrentBank; - // The 64K ROM image of the cartridge - uInt8 myImage[262144]; + // The 256K ROM image of the cartridge + uInt8 myImage[64 * 4096]; }; #endif diff --git a/src/emucore/CartBFSC.hxx b/src/emucore/CartBFSC.hxx index bca390452..e44cbe25b 100644 --- a/src/emucore/CartBFSC.hxx +++ b/src/emucore/CartBFSC.hxx @@ -29,8 +29,8 @@ class System; #endif /** - There are 32 4K banks (total of 128K ROM) with 128 bytes of RAM. - Accessing $1FD0 - $1FEF switches to each bank. + There are 64 4K banks (total of 256K ROM) with 128 bytes of RAM. + Accessing $1F80 - $1FBF switches to each bank. @author Stephen Anthony @version $Id$ @@ -158,8 +158,8 @@ class CartridgeBFSC : public Cartridge // Indicates which bank is currently active uInt16 myCurrentBank; - // The 64K ROM image of the cartridge - uInt8 myImage[131072*2]; + // The 256K ROM image of the cartridge + uInt8 myImage[64 * 4096]; // The 128 bytes of RAM uInt8 myRAM[128]; diff --git a/src/emucore/CartCV.cxx b/src/emucore/CartCV.cxx index 4e25a072d..f355db78d 100644 --- a/src/emucore/CartCV.cxx +++ b/src/emucore/CartCV.cxx @@ -26,7 +26,7 @@ CartridgeCV::CartridgeCV(const uInt8* image, uInt32 size, const Settings& settings) : Cartridge(settings), - myInitialRAM(0), + myInitialRAM(nullptr), mySize(size) { if(mySize == 2048) diff --git a/src/emucore/CartDASH.cxx b/src/emucore/CartDASH.cxx index 965bee2be..b37acd07f 100644 --- a/src/emucore/CartDASH.cxx +++ b/src/emucore/CartDASH.cxx @@ -24,9 +24,11 @@ #include "CartDASH.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -CartridgeDASH::CartridgeDASH(const uInt8* image, uInt32 size, const Settings& settings) : - Cartridge(settings), mySize(size) { - +CartridgeDASH::CartridgeDASH(const uInt8* image, uInt32 size, const Settings& settings) + : Cartridge(settings), + mySize(size), + myImage(nullptr) +{ // Allocate array for the ROM image myImage = new uInt8[mySize]; @@ -40,7 +42,8 @@ CartridgeDASH::CartridgeDASH(const uInt8* image, uInt32 size, const Settings& se } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -CartridgeDASH::~CartridgeDASH() { +CartridgeDASH::~CartridgeDASH() +{ delete[] myImage; } diff --git a/src/emucore/CartDF.hxx b/src/emucore/CartDF.hxx index 0e9f876ed..4c9f9783b 100644 --- a/src/emucore/CartDF.hxx +++ b/src/emucore/CartDF.hxx @@ -159,8 +159,8 @@ class CartridgeDF : public Cartridge // Indicates which bank is currently active uInt16 myCurrentBank; - // The 64K ROM image of the cartridge - uInt8 myImage[131072]; + // The 128K ROM image of the cartridge + uInt8 myImage[32 * 4096]; }; #endif diff --git a/src/emucore/CartDFSC.hxx b/src/emucore/CartDFSC.hxx index ede00daab..6dcf92330 100644 --- a/src/emucore/CartDFSC.hxx +++ b/src/emucore/CartDFSC.hxx @@ -30,7 +30,7 @@ class System; /** There are 32 4K banks (total of 128K ROM) with 128 bytes of RAM. - Accessing $1FD0 - $1FEF switches to each bank. + Accessing $1FC0 - $1FDF switches to each bank. @author Stephen Anthony @version $Id$ @@ -158,8 +158,8 @@ class CartridgeDFSC : public Cartridge // Indicates which bank is currently active uInt16 myCurrentBank; - // The 64K ROM image of the cartridge - uInt8 myImage[131072]; + // The 128K ROM image of the cartridge + uInt8 myImage[32 * 4096]; // The 128 bytes of RAM uInt8 myRAM[128]; diff --git a/src/emucore/CartDPCPlus.cxx b/src/emucore/CartDPCPlus.cxx index adaade59e..ce25b34a3 100644 --- a/src/emucore/CartDPCPlus.cxx +++ b/src/emucore/CartDPCPlus.cxx @@ -30,6 +30,7 @@ CartridgeDPCPlus::CartridgeDPCPlus(const uInt8* image, uInt32 size, const Settings& settings) : Cartridge(settings), + myImage(nullptr), myFastFetch(false), myLDAimmediate(false), myParameterPointer(0), @@ -59,9 +60,9 @@ CartridgeDPCPlus::CartridgeDPCPlus(const uInt8* image, uInt32 size, #ifdef THUMB_SUPPORT // Create Thumbulator ARM emulator - myThumbEmulator = new Thumbulator((uInt16*)(myProgramImage-0xC00), - (uInt16*)myDPCRAM, - settings.getBool("thumb.trapfatal")); + myThumbEmulator = make_ptr + ((uInt16*)(myProgramImage-0xC00), (uInt16*)myDPCRAM, + settings.getBool("thumb.trapfatal")); #endif setInitialState(); @@ -73,10 +74,6 @@ CartridgeDPCPlus::CartridgeDPCPlus(const uInt8* image, uInt32 size, CartridgeDPCPlus::~CartridgeDPCPlus() { delete[] myImage; - -#ifdef THUMB_SUPPORT - delete myThumbEmulator; -#endif } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/CartDPCPlus.hxx b/src/emucore/CartDPCPlus.hxx index 921473ceb..40081b95b 100644 --- a/src/emucore/CartDPCPlus.hxx +++ b/src/emucore/CartDPCPlus.hxx @@ -216,7 +216,7 @@ class CartridgeDPCPlus : public Cartridge #ifdef THUMB_SUPPORT // Pointer to the Thumb ARM emulator object - Thumbulator* myThumbEmulator; + unique_ptr myThumbEmulator; #endif // Pointer to the 1K frequency table diff --git a/src/emucore/CartFA2.cxx b/src/emucore/CartFA2.cxx index d4218a9d7..7d3b1d245 100644 --- a/src/emucore/CartFA2.cxx +++ b/src/emucore/CartFA2.cxx @@ -38,9 +38,6 @@ CartridgeFA2::CartridgeFA2(const uInt8* image, uInt32 size, const OSystem& osyst mySize = 28 * 1024; } - // Allocate array for the ROM image - myImage = new uInt8[mySize]; - // Copy the ROM image into my buffer memcpy(myImage, image, mySize); createCodeAccessBase(mySize); @@ -52,7 +49,6 @@ CartridgeFA2::CartridgeFA2(const uInt8* image, uInt32 size, const OSystem& osyst // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CartridgeFA2::~CartridgeFA2() { - delete[] myImage; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/CartFA2.hxx b/src/emucore/CartFA2.hxx index d63822ce6..25d9f416c 100644 --- a/src/emucore/CartFA2.hxx +++ b/src/emucore/CartFA2.hxx @@ -197,7 +197,7 @@ class CartridgeFA2 : public Cartridge uInt16 myCurrentBank; // The 24K/28K ROM image of the cartridge - uInt8* myImage; + uInt8 myImage[28 * 1024]; // The 256 bytes of RAM on the cartridge uInt8 myRAM[256]; diff --git a/src/emucore/CartMDM.cxx b/src/emucore/CartMDM.cxx index 75309e5c3..2b6c79b96 100644 --- a/src/emucore/CartMDM.cxx +++ b/src/emucore/CartMDM.cxx @@ -25,7 +25,7 @@ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CartridgeMDM::CartridgeMDM(const uInt8* image, uInt32 size, const Settings& settings) : Cartridge(settings), - myImage(NULL), + myImage(nullptr), mySize(size), myBankingDisabled(false) { @@ -43,7 +43,7 @@ CartridgeMDM::CartridgeMDM(const uInt8* image, uInt32 size, const Settings& sett // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CartridgeMDM::~CartridgeMDM() { - delete[] myImage; myImage = NULL; + delete[] myImage; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/CartSB.cxx b/src/emucore/CartSB.cxx index 28155605b..75bc09836 100644 --- a/src/emucore/CartSB.cxx +++ b/src/emucore/CartSB.cxx @@ -26,6 +26,7 @@ CartridgeSB::CartridgeSB(const uInt8* image, uInt32 size, const Settings& settings) : Cartridge(settings), + myImage(nullptr), mySize(size) { // Allocate array for the ROM image