"Fossies" - the Fresh Open Source Software Archive

Member "stella-6.0.2/src/emucore/CartCV.hxx" (11 Oct 2019, 4548 Bytes) of package /linux/privat/stella-6.0.2-src.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "CartCV.hxx" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 6.0.1_vs_6.0.2.

    1 //============================================================================
    2 //
    3 //   SSSS    tt          lll  lll
    4 //  SS  SS   tt           ll   ll
    5 //  SS     tttttt  eeee   ll   ll   aaaa
    6 //   SSSS    tt   ee  ee  ll   ll      aa
    7 //      SS   tt   eeeeee  ll   ll   aaaaa  --  "An Atari 2600 VCS Emulator"
    8 //  SS  SS   tt   ee      ll   ll  aa  aa
    9 //   SSSS     ttt  eeeee llll llll  aaaaa
   10 //
   11 // Copyright (c) 1995-2019 by Bradford W. Mott, Stephen Anthony
   12 // and the Stella Team
   13 //
   14 // See the file "License.txt" for information on usage and redistribution of
   15 // this file, and for a DISCLAIMER OF ALL WARRANTIES.
   16 //============================================================================
   17 
   18 #ifndef CARTRIDGECV_HXX
   19 #define CARTRIDGECV_HXX
   20 
   21 class System;
   22 
   23 #include "bspf.hxx"
   24 #include "Cart.hxx"
   25 #ifdef DEBUGGER_SUPPORT
   26   #include "CartCVWidget.hxx"
   27 #endif
   28 
   29 /**
   30   Cartridge class used for Commavid's extra-RAM games.
   31 
   32   $F000-$F3FF read from RAM
   33   $F400-$F7FF write to RAM
   34   $F800-$FFFF ROM
   35 
   36   @author  Eckhard Stolberg
   37 */
   38 class CartridgeCV : public Cartridge
   39 {
   40   friend class CartridgeCVWidget;
   41 
   42   public:
   43     /**
   44       Create a new cartridge using the specified image
   45 
   46       @param image     Pointer to the ROM image
   47       @param size      The size of the ROM image
   48       @param md5       The md5sum of the ROM image
   49       @param settings  A reference to the various settings (read-only)
   50     */
   51     CartridgeCV(const BytePtr& image, uInt32 size, const string& md5,
   52                 const Settings& settings);
   53     virtual ~CartridgeCV() = default;
   54 
   55   public:
   56     /**
   57       Reset cartridge to its power-on state
   58     */
   59     void reset() override;
   60 
   61     /**
   62       Install cartridge in the specified system.  Invoked by the system
   63       when the cartridge is attached to it.
   64 
   65       @param system The system the device should install itself in
   66     */
   67     void install(System& system) override;
   68 
   69     /**
   70       Patch the cartridge ROM.
   71 
   72       @param address  The ROM address to patch
   73       @param value    The value to place into the address
   74       @return    Success or failure of the patch operation
   75     */
   76     bool patch(uInt16 address, uInt8 value) override;
   77 
   78     /**
   79       Access the internal ROM image for this cartridge.
   80 
   81       @param size  Set to the size of the internal ROM image data
   82       @return  A pointer to the internal ROM image data
   83     */
   84     const uInt8* getImage(uInt32& size) const override;
   85 
   86     /**
   87       Save the current state of this cart to the given Serializer.
   88 
   89       @param out  The Serializer object to use
   90       @return  False on any errors, else true
   91     */
   92     bool save(Serializer& out) const override;
   93 
   94     /**
   95       Load the current state of this cart from the given Serializer.
   96 
   97       @param in  The Serializer object to use
   98       @return  False on any errors, else true
   99     */
  100     bool load(Serializer& in) override;
  101 
  102     /**
  103       Get a descriptor for the device name (used in error checking).
  104 
  105       @return The name of the object
  106     */
  107     string name() const override { return "CartridgeCV"; }
  108 
  109   #ifdef DEBUGGER_SUPPORT
  110     /**
  111       Get debugger widget responsible for accessing the inner workings
  112       of the cart.
  113     */
  114     CartDebugWidget* debugWidget(GuiObject* boss, const GUI::Font& lfont,
  115         const GUI::Font& nfont, int x, int y, int w, int h) override
  116     {
  117       return new CartridgeCVWidget(boss, lfont, nfont, x, y, w, h, *this);
  118     }
  119   #endif
  120 
  121   public:
  122     /**
  123       Get the byte at the specified address
  124 
  125       @return The byte at the specified address
  126     */
  127     uInt8 peek(uInt16 address) override;
  128 
  129     /**
  130       Change the byte at the specified address to the given value
  131 
  132       @param address The address where the value should be stored
  133       @param value The value to be stored at the address
  134       @return  True if the poke changed the device address space, else false
  135     */
  136     bool poke(uInt16 address, uInt8 value) override;
  137 
  138   private:
  139     // Pointer to the initial RAM data from the cart
  140     // This doesn't always exist, so we don't pre-allocate it
  141     BytePtr myInitialRAM;
  142 
  143     // Initial size of the cart data
  144     uInt32 mySize;
  145 
  146     // The 2k ROM image for the cartridge
  147     uInt8 myImage[2048];
  148 
  149     // The 1024 bytes of RAM
  150     uInt8 myRAM[1024];
  151 
  152   private:
  153     // Following constructors and assignment operators not supported
  154     CartridgeCV() = delete;
  155     CartridgeCV(const CartridgeCV&) = delete;
  156     CartridgeCV(CartridgeCV&&) = delete;
  157     CartridgeCV& operator=(const CartridgeCV&) = delete;
  158     CartridgeCV& operator=(CartridgeCV&&) = delete;
  159 };
  160 
  161 #endif