From c033bad0b959b26f0be310d097d210ab729912bf Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sat, 18 Mar 2017 20:51:49 -0400 Subject: [PATCH] Here's MNetwork! --- Machines/Atari2600/Atari2600.cpp | 2 + Machines/Atari2600/CartridgeMNetwork.hpp | 68 +++++++++++++++++++ .../Clock Signal.xcodeproj/project.pbxproj | 2 + 3 files changed, 72 insertions(+) create mode 100644 Machines/Atari2600/CartridgeMNetwork.hpp diff --git a/Machines/Atari2600/Atari2600.cpp b/Machines/Atari2600/Atari2600.cpp index 40457ca7f..3d6bea78c 100644 --- a/Machines/Atari2600/Atari2600.cpp +++ b/Machines/Atari2600/Atari2600.cpp @@ -17,6 +17,7 @@ #include "CartridgeCBSRAMPlus.hpp" #include "CartridgeCommaVid.hpp" #include "CartridgeMegaBoy.hpp" +#include "CartridgeMNetwork.hpp" #include "CartridgeParkerBros.hpp" #include "CartridgeTigervision.hpp" #include "CartridgeUnpaged.hpp" @@ -88,6 +89,7 @@ void Machine::configure_as_target(const StaticAnalyser::Target &target) { case StaticAnalyser::Atari2600PagingModel::Tigervision: bus_.reset(new CartridgeTigervision(rom)); break; case StaticAnalyser::Atari2600PagingModel::CBSRamPlus: bus_.reset(new CartridgeCBSRAMPlus(rom)); break; case StaticAnalyser::Atari2600PagingModel::MegaBoy: bus_.reset(new CartridgeMegaBoy(rom)); break; + case StaticAnalyser::Atari2600PagingModel::MNetwork: bus_.reset(new CartridgeMNetwork(rom)); break; case StaticAnalyser::Atari2600PagingModel::Atari8k: if(target.atari.uses_superchip) { bus_.reset(new CartridgeAtari8kSuperChip(rom)); diff --git a/Machines/Atari2600/CartridgeMNetwork.hpp b/Machines/Atari2600/CartridgeMNetwork.hpp new file mode 100644 index 000000000..fcd392d36 --- /dev/null +++ b/Machines/Atari2600/CartridgeMNetwork.hpp @@ -0,0 +1,68 @@ +// +// CartridgeMNetwork.h +// Clock Signal +// +// Created by Thomas Harte on 18/03/2017. +// Copyright © 2017 Thomas Harte. All rights reserved. +// + +#ifndef Atari2600_CartridgeMNetwork_hpp +#define Atari2600_CartridgeMNetwork_hpp + +#include "Cartridge.hpp" + +namespace Atari2600 { + +class CartridgeMNetwork: public Cartridge { + public: + CartridgeMNetwork(const std::vector &rom) : + Cartridge(rom) { + rom_ptr_[0] = rom_.data() + rom_.size() - 4096; + rom_ptr_[1] = rom_ptr_[0] + 2048; + high_ram_ptr_ = high_ram_; + } + + void perform_bus_operation(CPU6502::BusOperation operation, uint16_t address, uint8_t *value) { + address &= 0x1fff; + if(!(address & 0x1000)) return; + + if(address >= 0x1fe0 && address <= 0x1fe6) { + rom_ptr_[0] = rom_.data() + (address - 0x1fe0) * 2048; + } else if(address == 0x1fe7) { + rom_ptr_[0] = nullptr; + } else if(address >= 0x1ff8 && address <= 0x1ffb) { + int offset = (address - 0x1ff8) * 256; + high_ram_ptr_ = &high_ram_[offset]; + } + + if(address & 0x800) { + if(address < 0x1900) { + high_ram_ptr_[address & 255] = *value; + } else if(address < 0x1a00) { + if(isReadOperation(operation)) *value = high_ram_ptr_[address & 255]; + } else { + if(isReadOperation(operation)) *value = rom_ptr_[1][address & 2047]; + } + } else { + if(rom_ptr_[0]) { + if(isReadOperation(operation)) *value = rom_ptr_[0][address & 2047]; + } else { + if(address < 0x1400) { + low_ram_[address & 1023] = *value; + } else { + if(isReadOperation(operation)) *value = low_ram_[address & 1023]; + } + } + } + + } + + private: + uint8_t *rom_ptr_[2]; + uint8_t *high_ram_ptr_; + uint8_t low_ram_[1024], high_ram_[1024]; +}; + +} + +#endif /* Atari2600_CartridgeMNetwork_hpp */ diff --git a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj index d4e620bc5..450d31b92 100644 --- a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj +++ b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj @@ -951,6 +951,7 @@ 4BEAC07C1E7DEA6B00EE56B2 /* CartridgeTigervision.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = CartridgeTigervision.hpp; sourceTree = ""; }; 4BEAC07D1E7DF13E00EE56B2 /* CartridgeCBSRAMPlus.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = CartridgeCBSRAMPlus.hpp; sourceTree = ""; }; 4BEAC07E1E7DF2D000EE56B2 /* CartridgeMegaBoy.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = CartridgeMegaBoy.hpp; sourceTree = ""; }; + 4BEAC07F1E7DF45900EE56B2 /* CartridgeMNetwork.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = CartridgeMNetwork.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 = ""; }; @@ -1132,6 +1133,7 @@ 4BEA52671DF34909007E74F2 /* PIA.hpp */, 4BEA52651DF3472B007E74F2 /* Speaker.hpp */, 4BE7C9171E3D397100A5496D /* TIA.hpp */, + 4BEAC07F1E7DF45900EE56B2 /* CartridgeMNetwork.hpp */, ); path = Atari2600; sourceTree = "";