cscg22-gearboy

CSCG 2022 Challenge 'Gearboy'
git clone https://git.sinitax.com/sinitax/cscg22-gearboy
Log | Files | Refs | sfeed.txt

MBC3MemoryRule.h (2319B)


      1/*
      2 * Gearboy - Nintendo Game Boy Emulator
      3 * Copyright (C) 2012  Ignacio Sanchez
      4
      5 * This program is free software: you can redistribute it and/or modify
      6 * it under the terms of the GNU General Public License as published by
      7 * the Free Software Foundation, either version 3 of the License, or
      8 * any later version.
      9
     10 * This program is distributed in the hope that it will be useful,
     11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
     13 * GNU General Public License for more details.
     14
     15 * You should have received a copy of the GNU General Public License
     16 * along with this program.  If not, see http://www.gnu.org/licenses/
     17 *
     18 */
     19
     20#ifndef MBC3MEMORYRULE_H
     21#define	MBC3MEMORYRULE_H
     22
     23#include "MemoryRule.h"
     24
     25struct RTC_Registers
     26{
     27    s32 Seconds;
     28    s32 Minutes;
     29    s32 Hours;
     30    s32 Days;
     31    s32 Control;
     32    s32 LatchedSeconds;
     33    s32 LatchedMinutes;
     34    s32 LatchedHours;
     35    s32 LatchedDays;
     36    s32 LatchedControl;
     37    s32 LastTime;
     38    s32 padding;
     39};
     40
     41class MBC3MemoryRule : public MemoryRule
     42{
     43public:
     44    MBC3MemoryRule(Processor* pProcessor, Memory* pMemory,
     45            Video* pVideo, Input* pInput, Cartridge* pCartridge, Audio* pAudio);
     46    virtual ~MBC3MemoryRule();
     47    virtual u8 PerformRead(u16 address);
     48    virtual void PerformWrite(u16 address, u8 value);
     49    virtual void Reset(bool bCGB);
     50    virtual void SaveRam(std::ostream &file);
     51    virtual bool LoadRam(std::istream &file, s32 fileSize);
     52    virtual size_t GetRamSize();
     53    virtual size_t GetRTCSize();
     54    virtual u8* GetRamBanks();
     55    virtual u8* GetCurrentRamBank();
     56    virtual int GetCurrentRamBankIndex();
     57    virtual u8* GetRomBank0();
     58    virtual int GetCurrentRomBank0Index();
     59    virtual u8* GetCurrentRomBank1();
     60    virtual int GetCurrentRomBank1Index();
     61    virtual u8* GetRTCMemory();
     62    virtual void SaveState(std::ostream& stream);
     63    virtual void LoadState(std::istream& stream);
     64
     65private:
     66    void UpdateRTC();
     67
     68private:
     69    int m_iCurrentRAMBank;
     70    int m_iCurrentROMBank;
     71    bool m_bRamEnabled;
     72    bool m_bRTCEnabled;
     73    u8* m_pRAMBanks;
     74    s32 m_iRTCLatch;
     75    u8 m_RTCRegister;
     76    s32 m_RTCLastTimeCache;
     77    int m_CurrentROMAddress;
     78    int m_CurrentRAMAddress;
     79    RTC_Registers m_RTC;
     80};
     81
     82#endif	/* MBC3MEMORYRULE_H */