1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-29 12:50:28 +00:00
CLK/Machines/Atari/2600/Cartridges/CBSRAMPlus.hpp

39 lines
931 B
C++
Raw Normal View History

2017-03-18 22:56:20 +00:00
//
// CartridgeCBSRAMPlus.h
// Clock Signal
//
// Created by Thomas Harte on 18/03/2017.
// Copyright 2017 Thomas Harte. All rights reserved.
2017-03-18 22:56:20 +00:00
//
#pragma once
2017-03-18 22:56:20 +00:00
#include "Cartridge.hpp"
2023-05-10 21:02:18 +00:00
namespace Atari2600::Cartridge {
2017-03-18 22:56:20 +00:00
class CBSRAMPlus: public BusExtender {
2017-03-18 22:56:20 +00:00
public:
CBSRAMPlus(uint8_t *rom_base, std::size_t rom_size) : BusExtender(rom_base, rom_size), rom_ptr_(rom_base) {}
2017-03-18 22:56:20 +00:00
void perform_bus_operation(CPU::MOS6502::BusOperation operation, uint16_t address, uint8_t *value) {
2017-03-18 22:56:20 +00:00
address &= 0x1fff;
if(!(address & 0x1000)) return;
if(address >= 0x1ff8 && address <= 0x1ffa) rom_ptr_ = rom_base_ + (address - 0x1ff8) * 4096;
2017-03-18 22:56:20 +00:00
if(isReadOperation(operation)) {
*value = rom_ptr_[address & 4095];
}
if(address < 0x1100) ram_[address & 0xff] = *value;
else if(address < 0x1200 && isReadOperation(operation)) *value = ram_[address & 0xff];
}
private:
uint8_t *rom_ptr_;
uint8_t ram_[256];
};
}