diff --git a/Machines/Atari2600/Atari2600.cpp b/Machines/Atari2600/Atari2600.cpp index 3c049ba55..cdd9eef6e 100644 --- a/Machines/Atari2600/Atari2600.cpp +++ b/Machines/Atari2600/Atari2600.cpp @@ -10,11 +10,12 @@ #include #include -#include "CartridgeUnpaged.hpp" -#include "CartridgeCommaVid.hpp" #include "CartridgeAtari8k.hpp" #include "CartridgeAtari16k.hpp" #include "CartridgeAtari32k.hpp" +#include "CartridgeActivisionStack.hpp" +#include "CartridgeCommaVid.hpp" +#include "CartridgeUnpaged.hpp" using namespace Atari2600; namespace { @@ -104,6 +105,9 @@ void Machine::configure_as_target(const StaticAnalyser::Target &target) { bus_.reset(new CartridgeAtari32k(target.cartridges.front()->get_segments().front().data)); } break; + case StaticAnalyser::Atari2600PagingModel::ActivisionStack: + bus_.reset(new CartridgeActivisionStack(target.cartridges.front()->get_segments().front().data)); + break; } /* if(!target.cartridges.front()->get_segments().size()) return; diff --git a/Machines/Atari2600/CartridgeActivisionStack.hpp b/Machines/Atari2600/CartridgeActivisionStack.hpp new file mode 100644 index 000000000..8cf8a2713 --- /dev/null +++ b/Machines/Atari2600/CartridgeActivisionStack.hpp @@ -0,0 +1,47 @@ +// +// CartridgeActivisionStack.h +// Clock Signal +// +// Created by Thomas Harte on 18/03/2017. +// Copyright © 2017 Thomas Harte. All rights reserved. +// + +#ifndef Atari2600_CartridgeActivisionStack_hpp +#define Atari2600_CartridgeActivisionStack_hpp + +namespace Atari2600 { + +class CartridgeActivisionStack: public Cartridge { + public: + CartridgeActivisionStack(const std::vector &rom) : + Cartridge(rom), + last_opcode_(0x00) { + rom_ptr_ = rom_.data(); + } + + void perform_bus_operation(CPU6502::BusOperation operation, uint16_t address, uint8_t *value) { + if(!(address & 0x1000)) return; + + if(operation == CPU6502::BusOperation::ReadOpcode && (last_opcode_ == 0x20 || last_opcode_ == 0x60)) { + if(address & 0x2000) { + rom_ptr_ = rom_.data(); + } else { + rom_ptr_ = rom_.data() + 4096; + } + } + + if(isReadOperation(operation)) { + *value = rom_ptr_[address & 4095]; + } + + if(operation == CPU6502::BusOperation::ReadOpcode) last_opcode_ = *value; + } + + private: + uint8_t *rom_ptr_; + uint8_t last_opcode_; +}; + +} + +#endif /* Atari2600_CartridgeActivisionStack_hpp */ diff --git a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj index 9d8046b66..c734eb154 100644 --- a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj +++ b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj @@ -944,6 +944,9 @@ 4BEA52641DF3472B007E74F2 /* Speaker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Speaker.cpp; sourceTree = ""; }; 4BEA52651DF3472B007E74F2 /* Speaker.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Speaker.hpp; sourceTree = ""; }; 4BEA52671DF34909007E74F2 /* PIA.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = PIA.hpp; sourceTree = ""; }; + 4BEAC0781E7DD86E00EE56B2 /* CartridgeAtari16k.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = CartridgeAtari16k.hpp; sourceTree = ""; }; + 4BEAC0791E7DD86E00EE56B2 /* CartridgeAtari32k.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = CartridgeAtari32k.hpp; sourceTree = ""; }; + 4BEAC07A1E7DDFDA00EE56B2 /* CartridgeActivisionStack.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = CartridgeActivisionStack.hpp; sourceTree = ""; }; 4BEE0A6A1D72496600532C7B /* Cartridge.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Cartridge.cpp; sourceTree = ""; }; 4BEE0A6B1D72496600532C7B /* Cartridge.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Cartridge.hpp; sourceTree = ""; }; 4BEE0A6D1D72496600532C7B /* PRG.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PRG.cpp; sourceTree = ""; }; @@ -1111,13 +1114,16 @@ 4BE7C9161E3D397100A5496D /* TIA.cpp */, 4B2E2D991C3A06EC00138695 /* Atari2600Inputs.h */, 4B2E2D981C3A06EC00138695 /* Atari2600.hpp */, + 4BE069991E7C942C00DD379F /* Cartridge.hpp */, + 4BEAC07A1E7DDFDA00EE56B2 /* CartridgeActivisionStack.hpp */, + 4BA443E81E7DB8F900C86749 /* CartridgeAtari8k.hpp */, + 4BEAC0781E7DD86E00EE56B2 /* CartridgeAtari16k.hpp */, + 4BEAC0791E7DD86E00EE56B2 /* CartridgeAtari32k.hpp */, + 4BA443E71E7DB54700C86749 /* CartridgeCommaVid.hpp */, + 4BE0699A1E7C9C5A00DD379F /* CartridgeUnpaged.hpp */, 4BEA52671DF34909007E74F2 /* PIA.hpp */, 4BEA52651DF3472B007E74F2 /* Speaker.hpp */, 4BE7C9171E3D397100A5496D /* TIA.hpp */, - 4BE069991E7C942C00DD379F /* Cartridge.hpp */, - 4BE0699A1E7C9C5A00DD379F /* CartridgeUnpaged.hpp */, - 4BA443E71E7DB54700C86749 /* CartridgeCommaVid.hpp */, - 4BA443E81E7DB8F900C86749 /* CartridgeAtari8k.hpp */, ); path = Atari2600; sourceTree = "";