"Fossies" - the Fresh Open Source Software Archive

Member "stella-6.0.2/src/emucore/CartBFSC.hxx" (11 Oct 2019, 4910 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 "CartBFSC.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 CARTRIDGEBFSC_HXX
   19 #define CARTRIDGEBFSC_HXX
   20 
   21 class System;
   22 
   23 #include "bspf.hxx"
   24 #include "Cart.hxx"
   25 #ifdef DEBUGGER_SUPPORT
   26   #include "CartBFSCWidget.hxx"
   27 #endif
   28 
   29 /**
   30   There are 64 4K banks (total of 256K ROM) with 128 bytes of RAM.
   31   Accessing $1F80 - $1FBF switches to each bank.
   32   RAM read port is $1080 - $10FF, write port is $1000 - $107F.
   33 
   34   @author  Stephen Anthony
   35 */
   36 class CartridgeBFSC : public Cartridge
   37 {
   38   friend class CartridgeBFSCWidget;
   39 
   40   public:
   41     /**
   42       Create a new cartridge using the specified image
   43 
   44       @param image     Pointer to the ROM image
   45       @param size      The size of the ROM image
   46       @param md5       The md5sum of the ROM image
   47       @param settings  A reference to the various settings (read-only)
   48     */
   49     CartridgeBFSC(const BytePtr& image, uInt32 size, const string& md5,
   50                   const Settings& settings);
   51     virtual ~CartridgeBFSC() = default;
   52 
   53   public:
   54     /**
   55       Reset device to its power-on state
   56     */
   57     void reset() override;
   58 
   59     /**
   60       Install cartridge in the specified system.  Invoked by the system
   61       when the cartridge is attached to it.
   62 
   63       @param system The system the device should install itself in
   64     */
   65     void install(System& system) override;
   66 
   67     /**
   68       Install pages for the specified bank in the system.
   69 
   70       @param bank The bank that should be installed in the system
   71     */
   72     bool bank(uInt16 bank) override;
   73 
   74     /**
   75       Get the current bank.
   76     */
   77     uInt16 getBank() const override;
   78 
   79     /**
   80       Query the number of banks supported by the cartridge.
   81     */
   82     uInt16 bankCount() const override;
   83 
   84     /**
   85       Patch the cartridge ROM.
   86 
   87       @param address  The ROM address to patch
   88       @param value    The value to place into the address
   89       @return    Success or failure of the patch operation
   90     */
   91     bool patch(uInt16 address, uInt8 value) override;
   92 
   93     /**
   94       Access the internal ROM image for this cartridge.
   95 
   96       @param size  Set to the size of the internal ROM image data
   97       @return  A pointer to the internal ROM image data
   98     */
   99     const uInt8* getImage(uInt32& size) const override;
  100 
  101     /**
  102       Save the current state of this cart to the given Serializer.
  103 
  104       @param out  The Serializer object to use
  105       @return  False on any errors, else true
  106     */
  107     bool save(Serializer& out) const override;
  108 
  109     /**
  110       Load the current state of this cart from the given Serializer.
  111 
  112       @param in  The Serializer object to use
  113       @return  False on any errors, else true
  114     */
  115     bool load(Serializer& in) override;
  116 
  117     /**
  118       Get a descriptor for the device name (used in error checking).
  119 
  120       @return The name of the object
  121     */
  122     string name() const override { return "CartridgeBFSC"; }
  123 
  124   #ifdef DEBUGGER_SUPPORT
  125     /**
  126       Get debugger widget responsible for accessing the inner workings
  127       of the cart.
  128     */
  129     CartDebugWidget* debugWidget(GuiObject* boss, const GUI::Font& lfont,
  130         const GUI::Font& nfont, int x, int y, int w, int h) override
  131     {
  132       return new CartridgeBFSCWidget(boss, lfont, nfont, x, y, w, h, *this);
  133     }
  134   #endif
  135 
  136   public:
  137     /**
  138       Get the byte at the specified address.
  139 
  140       @return The byte at the specified address
  141     */
  142     uInt8 peek(uInt16 address) override;
  143 
  144     /**
  145       Change the byte at the specified address to the given value
  146 
  147       @param address The address where the value should be stored
  148       @param value The value to be stored at the address
  149       @return  True if the poke changed the device address space, else false
  150     */
  151     bool poke(uInt16 address, uInt8 value) override;
  152 
  153   private:
  154     // The 256K ROM image of the cartridge
  155     uInt8 myImage[64 * 4096];
  156 
  157     // The 128 bytes of RAM
  158     uInt8 myRAM[128];
  159 
  160     // Indicates the offset into the ROM image (aligns to current bank)
  161     uInt32 myBankOffset;
  162 
  163   private:
  164     // Following constructors and assignment operators not supported
  165     CartridgeBFSC() = delete;
  166     CartridgeBFSC(const CartridgeBFSC&) = delete;
  167     CartridgeBFSC(CartridgeBFSC&&) = delete;
  168     CartridgeBFSC& operator=(const CartridgeBFSC&) = delete;
  169     CartridgeBFSC& operator=(CartridgeBFSC&&) = delete;
  170 };
  171 
  172 #endif