mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-26 23:52:26 +00:00
Sought to reintroduce the Atari 8k paging scheme, at the same time deciding to do away with the copy and paste of holding on to ROM data.
This commit is contained in:
parent
36b58d03b7
commit
bb3daaa99b
@ -11,7 +11,8 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "CartridgeUnpaged.hpp"
|
||||
#include "CartridgeCommaVid.h"
|
||||
#include "CartridgeCommaVid.hpp"
|
||||
#include "CartridgeAtari8k.hpp"
|
||||
|
||||
using namespace Atari2600;
|
||||
namespace {
|
||||
@ -80,6 +81,13 @@ void Machine::configure_as_target(const StaticAnalyser::Target &target) {
|
||||
case StaticAnalyser::Atari2600PagingModel::CommaVid:
|
||||
bus_.reset(new CartridgeCommaVid(target.cartridges.front()->get_segments().front().data));
|
||||
break;
|
||||
case StaticAnalyser::Atari2600PagingModel::Atari8k:
|
||||
if(target.atari.uses_superchip) {
|
||||
bus_.reset(new CartridgeAtari8kSuperChip(target.cartridges.front()->get_segments().front().data));
|
||||
} else {
|
||||
bus_.reset(new CartridgeAtari8k(target.cartridges.front()->get_segments().front().data));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* if(!target.cartridges.front()->get_segments().size()) return;
|
||||
|
@ -60,6 +60,9 @@ template<class T> class Cartridge:
|
||||
public Bus {
|
||||
|
||||
public:
|
||||
Cartridge(const std::vector<uint8_t> &rom) :
|
||||
rom_(rom) {}
|
||||
|
||||
void run_for_cycles(int number_of_cycles) { CPU6502::Processor<Cartridge<T>>::run_for_cycles(number_of_cycles); }
|
||||
|
||||
// to satisfy CPU6502::Processor
|
||||
@ -201,6 +204,9 @@ template<class T> class Cartridge:
|
||||
update_video();
|
||||
speaker_->flush();
|
||||
}
|
||||
|
||||
protected:
|
||||
std::vector<uint8_t> rom_;
|
||||
};
|
||||
|
||||
}
|
||||
|
68
Machines/Atari2600/CartridgeAtari8k.hpp
Normal file
68
Machines/Atari2600/CartridgeAtari8k.hpp
Normal file
@ -0,0 +1,68 @@
|
||||
//
|
||||
// CartridgeAtari8k.h
|
||||
// Clock Signal
|
||||
//
|
||||
// Created by Thomas Harte on 18/03/2017.
|
||||
// Copyright © 2017 Thomas Harte. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef CartridgeAtari8k_h
|
||||
#define CartridgeAtari8k_h
|
||||
|
||||
#include "Cartridge.hpp"
|
||||
|
||||
namespace Atari2600 {
|
||||
|
||||
class CartridgeAtari8k: public Cartridge<CartridgeUnpaged> {
|
||||
public:
|
||||
CartridgeAtari8k(const std::vector<uint8_t> &rom) :
|
||||
Cartridge(rom) {
|
||||
rom_ptr_ = rom_.data();
|
||||
}
|
||||
|
||||
void perform_bus_operation(CPU6502::BusOperation operation, uint16_t address, uint8_t *value) {
|
||||
address &= 0x1fff;
|
||||
if(!(address & 0x1000)) return;
|
||||
|
||||
if(address == 0x1ff8) rom_ptr_ = rom_.data();
|
||||
else if(address == 0x1ff9) rom_ptr_ = rom_.data() + 4096;
|
||||
|
||||
if(isReadOperation(operation)) {
|
||||
*value = rom_ptr_[address & 4095];
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
uint8_t *rom_ptr_;
|
||||
};
|
||||
|
||||
class CartridgeAtari8kSuperChip: public Cartridge<CartridgeUnpaged> {
|
||||
public:
|
||||
CartridgeAtari8kSuperChip(const std::vector<uint8_t> &rom) :
|
||||
Cartridge(rom) {
|
||||
rom_ptr_ = rom_.data();
|
||||
}
|
||||
|
||||
void perform_bus_operation(CPU6502::BusOperation operation, uint16_t address, uint8_t *value) {
|
||||
address &= 0x1fff;
|
||||
if(!(address & 0x1000)) return;
|
||||
|
||||
if(address == 0x1ff8) rom_ptr_ = rom_.data();
|
||||
if(address == 0x1ff9) rom_ptr_ = rom_.data() + 4096;
|
||||
|
||||
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];
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* CartridgeAtari8k_h */
|
@ -14,7 +14,7 @@ namespace Atari2600 {
|
||||
class CartridgeCommaVid: public Cartridge<CartridgeCommaVid> {
|
||||
public:
|
||||
CartridgeCommaVid(const std::vector<uint8_t> &rom) :
|
||||
rom_(rom) {}
|
||||
Cartridge(rom) {}
|
||||
|
||||
void perform_bus_operation(CPU6502::BusOperation operation, uint16_t address, uint8_t *value) {
|
||||
if(!(address & 0x1000)) return;
|
||||
@ -34,7 +34,6 @@ class CartridgeCommaVid: public Cartridge<CartridgeCommaVid> {
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<uint8_t> rom_;
|
||||
uint8_t ram_[1024];
|
||||
};
|
||||
|
@ -16,16 +16,13 @@ namespace Atari2600 {
|
||||
class CartridgeUnpaged: public Cartridge<CartridgeUnpaged> {
|
||||
public:
|
||||
CartridgeUnpaged(const std::vector<uint8_t> &rom) :
|
||||
rom_(rom) {}
|
||||
Cartridge(rom) {}
|
||||
|
||||
void perform_bus_operation(CPU6502::BusOperation operation, uint16_t address, uint8_t *value) {
|
||||
if(isReadOperation(operation) && (address & 0x1000)) {
|
||||
*value = rom_[address & (rom_.size() - 1)];
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<uint8_t> rom_;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -582,6 +582,8 @@
|
||||
4B9CCDA21DA27C3F0098B625 /* CSJoystickMachine.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CSJoystickMachine.h; sourceTree = "<group>"; };
|
||||
4BA22B051D8817CE0008C640 /* Disk.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Disk.cpp; path = ../../StaticAnalyser/Commodore/Disk.cpp; sourceTree = "<group>"; };
|
||||
4BA22B061D8817CE0008C640 /* Disk.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = Disk.hpp; path = ../../StaticAnalyser/Commodore/Disk.hpp; sourceTree = "<group>"; };
|
||||
4BA443E71E7DB54700C86749 /* CartridgeCommaVid.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = CartridgeCommaVid.hpp; sourceTree = "<group>"; };
|
||||
4BA443E81E7DB8F900C86749 /* CartridgeAtari8k.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = CartridgeAtari8k.hpp; sourceTree = "<group>"; };
|
||||
4BA61EAE1D91515900B3C876 /* NSData+StdVector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSData+StdVector.h"; sourceTree = "<group>"; };
|
||||
4BA61EAF1D91515900B3C876 /* NSData+StdVector.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "NSData+StdVector.mm"; sourceTree = "<group>"; };
|
||||
4BA799931D8B656E0045123D /* StaticAnalyser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StaticAnalyser.cpp; path = ../../StaticAnalyser/Atari/StaticAnalyser.cpp; sourceTree = "<group>"; };
|
||||
@ -1114,6 +1116,8 @@
|
||||
4BE7C9171E3D397100A5496D /* TIA.hpp */,
|
||||
4BE069991E7C942C00DD379F /* Cartridge.hpp */,
|
||||
4BE0699A1E7C9C5A00DD379F /* CartridgeUnpaged.hpp */,
|
||||
4BA443E71E7DB54700C86749 /* CartridgeCommaVid.hpp */,
|
||||
4BA443E81E7DB8F900C86749 /* CartridgeAtari8k.hpp */,
|
||||
);
|
||||
path = Atari2600;
|
||||
sourceTree = "<group>";
|
||||
|
Loading…
Reference in New Issue
Block a user