cscg22-gearboy

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

Cartridge.h (2669B)


      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 CARTRIDGE_H
     21#define	CARTRIDGE_H
     22
     23#include <list>
     24#include "definitions.h"
     25
     26class Cartridge
     27{
     28public:
     29    enum CartridgeTypes
     30    {
     31        CartridgeNoMBC,
     32        CartridgeMBC1,
     33        CartridgeMBC2,
     34        CartridgeMBC3,
     35        CartridgeMBC5,
     36        CartridgeMBC1Multi,
     37        CartridgeNotSupported
     38    };
     39
     40    struct GameGenieCode
     41    {
     42        int address;
     43        u8 old_value;
     44    };
     45
     46public:
     47    Cartridge();
     48    ~Cartridge();
     49    void Init();
     50    void Reset();
     51    bool IsValidROM() const;
     52    bool IsLoadedROM() const;
     53    CartridgeTypes GetType() const;
     54    int GetRAMSize() const;
     55    int GetROMSize() const;
     56    int GetROMBankCount() const;
     57    int GetRAMBankCount() const;
     58    const char* GetName() const;
     59    const char* GetFilePath() const;
     60    const char* GetFileName() const;
     61    int GetTotalSize() const;
     62    bool HasBattery() const;
     63    u8* GetTheROM() const;
     64    bool LoadFromFile(const char* path);
     65    bool LoadFromBuffer(const u8* buffer, int size);
     66    int GetVersion() const;
     67    bool IsSGB() const;
     68    bool IsCGB() const;
     69    void UpdateCurrentRTC();
     70    time_t GetCurrentRTC();
     71    bool IsRTCPresent() const;
     72    bool IsRumblePresent() const;
     73    void SetGameGenieCheat(const char* szCheat);
     74    void ClearGameGenieCheats();
     75
     76private:
     77    unsigned int Pow2Ceil(unsigned int n);
     78    bool GatherMetadata();
     79    bool LoadFromZipFile(const u8* buffer, int size);
     80    void CheckCartridgeType(int type);
     81
     82private:
     83    u8* m_pTheROM;
     84    int m_iTotalSize;
     85    char m_szName[16];
     86    int m_iROMSize;
     87    int m_iRAMSize;
     88    CartridgeTypes m_Type;
     89    bool m_bValidROM;
     90    bool m_bCGB;
     91    bool m_bSGB;
     92    int m_iVersion;
     93    bool m_bLoaded;
     94    time_t m_RTCCurrentTime;
     95    bool m_bBattery;
     96    char m_szFilePath[512];
     97    char m_szFileName[512];
     98    bool m_bRTCPresent;
     99    bool m_bRumblePresent;
    100    int m_iRAMBankCount;
    101    int m_iROMBankCount;
    102    std::list<GameGenieCode> m_GameGenieList;
    103};
    104
    105#endif	/* CARTRIDGE_H */