2017-03-18 19:04:01 +00:00
|
|
|
//
|
|
|
|
// CartridgeAtari8k.h
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 18/03/2017.
|
|
|
|
// Copyright © 2017 Thomas Harte. All rights reserved.
|
|
|
|
//
|
|
|
|
|
2017-03-18 21:34:34 +00:00
|
|
|
#ifndef Atari2600_CartridgeAtari8k_hpp
|
|
|
|
#define Atari2600_CartridgeAtari8k_hpp
|
2017-03-18 19:04:01 +00:00
|
|
|
|
|
|
|
#include "Cartridge.hpp"
|
|
|
|
|
|
|
|
namespace Atari2600 {
|
2017-08-16 15:56:52 +00:00
|
|
|
namespace Cartridge {
|
2017-03-18 19:04:01 +00:00
|
|
|
|
2017-08-16 16:39:15 +00:00
|
|
|
class Atari8k: public BusExtender {
|
2017-03-18 19:04:01 +00:00
|
|
|
public:
|
2017-11-11 20:28:40 +00:00
|
|
|
Atari8k(uint8_t *rom_base, std::size_t rom_size) : BusExtender(rom_base, rom_size), rom_ptr_(rom_base) {}
|
2017-03-18 19:04:01 +00:00
|
|
|
|
2017-05-15 02:08:15 +00:00
|
|
|
void perform_bus_operation(CPU::MOS6502::BusOperation operation, uint16_t address, uint8_t *value) {
|
2017-03-18 19:04:01 +00:00
|
|
|
address &= 0x1fff;
|
|
|
|
if(!(address & 0x1000)) return;
|
|
|
|
|
2017-08-16 16:39:15 +00:00
|
|
|
if(address == 0x1ff8) rom_ptr_ = rom_base_;
|
|
|
|
else if(address == 0x1ff9) rom_ptr_ = rom_base_ + 4096;
|
2017-03-18 19:04:01 +00:00
|
|
|
|
|
|
|
if(isReadOperation(operation)) {
|
|
|
|
*value = rom_ptr_[address & 4095];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
uint8_t *rom_ptr_;
|
|
|
|
};
|
|
|
|
|
2017-08-16 16:39:15 +00:00
|
|
|
class Atari8kSuperChip: public BusExtender {
|
2017-03-18 19:04:01 +00:00
|
|
|
public:
|
2017-11-11 20:28:40 +00:00
|
|
|
Atari8kSuperChip(uint8_t *rom_base, std::size_t rom_size) : BusExtender(rom_base, rom_size), rom_ptr_(rom_base) {}
|
2017-03-18 19:04:01 +00:00
|
|
|
|
2017-05-15 02:08:15 +00:00
|
|
|
void perform_bus_operation(CPU::MOS6502::BusOperation operation, uint16_t address, uint8_t *value) {
|
2017-03-18 19:04:01 +00:00
|
|
|
address &= 0x1fff;
|
|
|
|
if(!(address & 0x1000)) return;
|
|
|
|
|
2017-08-16 16:39:15 +00:00
|
|
|
if(address == 0x1ff8) rom_ptr_ = rom_base_;
|
|
|
|
if(address == 0x1ff9) rom_ptr_ = rom_base_ + 4096;
|
2017-03-18 19:04:01 +00:00
|
|
|
|
|
|
|
if(isReadOperation(operation)) {
|
|
|
|
*value = rom_ptr_[address & 4095];
|
|
|
|
}
|
|
|
|
|
|
|
|
if(address < 0x1080) ram_[address & 0x7f] = *value;
|
|
|
|
else if(address < 0x1100 && isReadOperation(operation)) *value = ram_[address & 0x7f];
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
uint8_t *rom_ptr_;
|
|
|
|
uint8_t ram_[128];
|
|
|
|
};
|
|
|
|
|
2017-08-16 15:56:52 +00:00
|
|
|
}
|
2017-03-18 19:04:01 +00:00
|
|
|
}
|
|
|
|
|
2017-03-18 21:34:34 +00:00
|
|
|
#endif /* Atari2600_CartridgeAtari8k_hpp */
|