Path: blob/a-new-beginning/Cherry/Core/include/StandardMapper.h
2 views
/*1* Gearcoleco - ColecoVision Emulator2* Copyright (C) 2021 Ignacio Sanchez34* This program is free software: you can redistribute it and/or modify5* it under the terms of the GNU General Public License as published by6* the Free Software Foundation, either version 3 of the License, or7* any later version.89* This program is distributed in the hope that it will be useful,10* but WITHOUT ANY WARRANTY; without even the implied warranty of11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12* GNU General Public License for more details.1314* You should have received a copy of the GNU General Public License15* along with this program. If not, see http://www.gnu.org/licenses/16*17*/1819#ifndef STANDARDMAPPER_H20#define STANDARDMAPPER_H2122#include "Mapper.h"23#include "Cartridge.h"2425class StandardMapper : public Mapper26{27public:28StandardMapper(Cartridge* pCartridge);29virtual ~StandardMapper();3031virtual void Reset();32virtual u8 Read(u16 address);33virtual void Write(u16 address, u8 value);34virtual void SaveState(std::ostream& stream);35virtual void LoadState(std::istream& stream);36};3738inline StandardMapper::StandardMapper(Cartridge* pCartridge) : Mapper(pCartridge)39{40}4142inline StandardMapper::~StandardMapper()43{44}4546inline void StandardMapper::Reset()47{48}4950inline u8 StandardMapper::Read(u16 address)51{52u8* pRom = m_pCartridge->GetROM();53int romSize = m_pCartridge->GetROMSize();5455if (address >= (romSize + 0x8000))56{57Debug("--> ** Attempting to read from outer ROM: %X. ROM Size: %X", address, romSize);58return 0xFF;59}6061return pRom[address & 0x7FFF];62}6364inline void StandardMapper::Write(u16 address, u8 value)65{66if (m_pCartridge->HasSRAM() && (address >= 0xE000) && (address < 0xE800))67{68u8* pRom = m_pCartridge->GetROM();69pRom[(address + 0x800) & 0x7FFF] = value;70}71else72{73Debug("--> ** Attempting to write on ROM: %X %X", address, value);74}75}7677inline void StandardMapper::SaveState(std::ostream& stream)78{79(void)stream;80}8182inline void StandardMapper::LoadState(std::istream& stream)83{84(void)stream;85}8687#endif /* STANDARDMAPPER_H */888990