2017-03-18 22:03:48 +00:00
|
|
|
//
|
|
|
|
// CartridgeActivisionStack.h
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 18/03/2017.
|
2018-05-13 19:19:52 +00:00
|
|
|
// Copyright 2017 Thomas Harte. All rights reserved.
|
2017-03-18 22:03:48 +00:00
|
|
|
//
|
|
|
|
|
2024-01-17 04:34:46 +00:00
|
|
|
#pragma once
|
2017-03-18 22:03:48 +00:00
|
|
|
|
2023-05-10 21:02:18 +00:00
|
|
|
namespace Atari2600::Cartridge {
|
2017-03-18 22:03:48 +00:00
|
|
|
|
2017-08-16 16:39:15 +00:00
|
|
|
class ActivisionStack: public BusExtender {
|
2017-03-18 22:03:48 +00:00
|
|
|
public:
|
2017-11-11 20:28:40 +00:00
|
|
|
ActivisionStack(uint8_t *rom_base, std::size_t rom_size) :
|
2017-08-16 16:39:15 +00:00
|
|
|
BusExtender(rom_base, rom_size),
|
|
|
|
rom_ptr_(rom_base),
|
|
|
|
last_opcode_(0x00) {}
|
2017-03-18 22:03:48 +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 22:03:48 +00:00
|
|
|
if(!(address & 0x1000)) return;
|
|
|
|
|
2017-03-19 01:01:58 +00:00
|
|
|
// This is a bit of a hack; a real cartridge can't see either the sync or read lines, and can't see
|
|
|
|
// address line 13. Instead it looks for a pattern in recent address accesses that would imply an
|
|
|
|
// RST or JSR.
|
2017-05-15 02:08:15 +00:00
|
|
|
if(operation == CPU::MOS6502::BusOperation::ReadOpcode && (last_opcode_ == 0x20 || last_opcode_ == 0x60)) {
|
2017-03-18 22:03:48 +00:00
|
|
|
if(address & 0x2000) {
|
2017-08-16 16:39:15 +00:00
|
|
|
rom_ptr_ = rom_base_;
|
2017-03-18 22:03:48 +00:00
|
|
|
} else {
|
2017-08-16 16:39:15 +00:00
|
|
|
rom_ptr_ = rom_base_ + 4096;
|
2017-03-18 22:03:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(isReadOperation(operation)) {
|
|
|
|
*value = rom_ptr_[address & 4095];
|
|
|
|
}
|
|
|
|
|
2017-05-15 02:08:15 +00:00
|
|
|
if(operation == CPU::MOS6502::BusOperation::ReadOpcode) last_opcode_ = *value;
|
2017-03-18 22:03:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
uint8_t *rom_ptr_;
|
|
|
|
uint8_t last_opcode_;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|