cscg22-gearboy

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

GearboyCore.h (4170B)


      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 CORE_H
     21#define	CORE_H
     22
     23#include "definitions.h"
     24#include "Cartridge.h"
     25
     26class Memory;
     27class Processor;
     28class Video;
     29class Audio;
     30class Input;
     31class CommonMemoryRule;
     32class IORegistersMemoryRule;
     33class RomOnlyMemoryRule;
     34class MBC1MemoryRule;
     35class MBC2MemoryRule;
     36class MBC3MemoryRule;
     37class MBC5MemoryRule;
     38class MultiMBC1MemoryRule;
     39class MemoryRule;
     40
     41class GearboyCore
     42{
     43public:
     44    GearboyCore();
     45    ~GearboyCore();
     46    void Init(GB_Color_Format pixelFormat = GB_PIXEL_RGB565);
     47    bool RunToVBlank(u16* pFrameBuffer, s16* pSampleBuffer, int* pSampleCount, bool bDMGbuffer = false, bool step = false, bool stopOnBreakpoints = false);
     48    bool LoadROM(const char* szFilePath, bool forceDMG, Cartridge::CartridgeTypes forceType = Cartridge::CartridgeNotSupported, bool forceGBA = false);
     49    bool LoadROMFromBuffer(const u8* buffer, int size, bool forceDMG, Cartridge::CartridgeTypes forceType = Cartridge::CartridgeNotSupported, bool forceGBA = false);
     50    void SaveDisassembledROM();
     51    void SaveMemoryDump();
     52    void KeyPressed(Gameboy_Keys key);
     53    void KeyReleased(Gameboy_Keys key);
     54    void Pause(bool paused);
     55    bool IsPaused();
     56    void ResetROM(bool forceDMG, Cartridge::CartridgeTypes forceType = Cartridge::CartridgeNotSupported, bool forceGBA = false);
     57    void ResetROMPreservingRAM(bool forceDMG, Cartridge::CartridgeTypes forceType = Cartridge::CartridgeNotSupported, bool forceGBA = false);
     58    void ResetSound();
     59    void SetSoundSampleRate(int rate);
     60    void SetSoundVolume(float volume);
     61    void SetDMGPalette(GB_Color& color1, GB_Color& color2, GB_Color& color3, GB_Color& color4);
     62    u16* GetDMGInternalPalette();
     63    void SaveRam();
     64    void SaveRam(const char* szPath, bool fullPath = false);
     65    void LoadRam();
     66    void LoadRam(const char* szPath, bool fullPath = false);
     67    void SaveState(int index);
     68    void SaveState(const char* szPath, int index);
     69    bool SaveState(u8* buffer, size_t& size);
     70    bool SaveState(std::ostream& stream, size_t& size);
     71    void LoadState(int index);
     72    void LoadState(const char* szPath, int index);
     73    bool LoadState(const u8* buffer, size_t size);
     74    bool LoadState(std::istream& stream);
     75    void SetCheat(const char* szCheat);
     76    void ClearCheats();
     77    void SetRamModificationCallback(RamChangedCallback callback);
     78    bool IsCGB();
     79    bool IsGBA();
     80    Memory* GetMemory();
     81    Cartridge* GetCartridge();
     82    Processor* GetProcessor();
     83    Audio* GetAudio();
     84    Video* GetVideo();
     85
     86private:
     87    void RenderDMGFrame(u16* pFrameBuffer) const;
     88    void InitDMGPalette();
     89    void InitMemoryRules();
     90    bool AddMemoryRules(Cartridge::CartridgeTypes forceType = Cartridge::CartridgeNotSupported);
     91    void Reset(bool bCGB, bool bGBA);
     92
     93private:
     94    Memory* m_pMemory;
     95    Processor* m_pProcessor;
     96    Video* m_pVideo;
     97    Audio* m_pAudio;
     98    Input* m_pInput;
     99    Cartridge* m_pCartridge;
    100    CommonMemoryRule* m_pCommonMemoryRule;
    101    IORegistersMemoryRule* m_pIORegistersMemoryRule;
    102    RomOnlyMemoryRule* m_pRomOnlyMemoryRule;
    103    MBC1MemoryRule* m_pMBC1MemoryRule;
    104    MBC2MemoryRule* m_pMBC2MemoryRule;
    105    MBC3MemoryRule* m_pMBC3MemoryRule;
    106    MBC5MemoryRule* m_pMBC5MemoryRule;
    107    MultiMBC1MemoryRule* m_pMultiMBC1MemoryRule;
    108    bool m_bCGB;
    109    bool m_bGBA;
    110    bool m_bPaused;
    111    u16 m_DMGPalette[4];
    112    bool m_bForceDMG;
    113    int m_iRTCUpdateCount;
    114    RamChangedCallback m_pRamChangedCallback;
    115    GB_Color_Format m_pixelFormat;
    116};
    117
    118#endif	/* CORE_H */