1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-10-04 01:57:54 +00:00

Formalised read bus value guarantee from the 6502, fixed missing clock signal wiring on the Atari cartridge class, reintroduced CommaVid support.

This commit is contained in:
Thomas Harte 2017-03-18 14:46:46 -04:00
parent 7958459db9
commit 36b58d03b7
4 changed files with 55 additions and 4 deletions

View File

@ -11,6 +11,7 @@
#include <stdio.h>
#include "CartridgeUnpaged.hpp"
#include "CartridgeCommaVid.h"
using namespace Atari2600;
namespace {
@ -72,7 +73,15 @@ void Machine::set_switch_is_enabled(Atari2600Switch input, bool state) {
}
void Machine::configure_as_target(const StaticAnalyser::Target &target) {
bus_.reset(new CartridgeUnpaged(target.cartridges.front()->get_segments().front().data));
switch(target.atari.paging_model) {
case StaticAnalyser::Atari2600PagingModel::None:
bus_.reset(new CartridgeUnpaged(target.cartridges.front()->get_segments().front().data));
break;
case StaticAnalyser::Atari2600PagingModel::CommaVid:
bus_.reset(new CartridgeCommaVid(target.cartridges.front()->get_segments().front().data));
break;
}
/* if(!target.cartridges.front()->get_segments().size()) return;
Storage::Cartridge::Cartridge::Segment segment = target.cartridges.front()->get_segments().front();
size_t length = segment.data.size();

View File

@ -60,7 +60,7 @@ template<class T> class Cartridge:
public Bus {
public:
void run_for_cycles(int number_of_cycles) {}
void run_for_cycles(int number_of_cycles) { CPU6502::Processor<Cartridge<T>>::run_for_cycles(number_of_cycles); }
// to satisfy CPU6502::Processor
unsigned int perform_bus_operation(CPU6502::BusOperation operation, uint16_t address, uint8_t *value) {
@ -79,8 +79,6 @@ template<class T> class Cartridge:
cycles_since_6532_update_ += (cycles_run_for / 3);
if(operation != CPU6502::BusOperation::Ready) {
// uint16_t masked_address = address & 0x1fff;
// give the cartridge a chance to respond to the bus access
static_cast<T *>(this)->perform_bus_operation(operation, address, value);

View File

@ -0,0 +1,43 @@
//
// CartridgeCommaVid.h
// Clock Signal
//
// Created by Thomas Harte on 18/03/2017.
// Copyright © 2017 Thomas Harte. All rights reserved.
//
#ifndef Atari2600_CartridgeCommaVid_hpp
#define Atari2600_CartridgeCommaVid_hpp
namespace Atari2600 {
class CartridgeCommaVid: public Cartridge<CartridgeCommaVid> {
public:
CartridgeCommaVid(const std::vector<uint8_t> &rom) :
rom_(rom) {}
void perform_bus_operation(CPU6502::BusOperation operation, uint16_t address, uint8_t *value) {
if(!(address & 0x1000)) return;
address &= 0x1fff;
if(address < 0x1400) {
if(isReadOperation(operation)) *value = ram_[address & 1023];
return;
}
if(address < 0x1800) {
ram_[address & 1023] = *value;
return;
}
if(isReadOperation(operation)) *value = rom_[address & 2047];
}
private:
std::vector<uint8_t> rom_;
uint8_t ram_[1024];
};
}
#endif /* Atari2600_CartridgeCommaVid_hpp */

View File

@ -568,6 +568,7 @@ template <class T> class Processor {
@discussion Subclasses must implement @c perform_bus_operation(BusOperation operation, uint16_t address, uint8_t *value) .
The 6502 will call that method for all bus accesses. The 6502 is guaranteed to perform one bus operation call per cycle.
If it is a read operation then @c value will be seeded with the value 0xff.
@param number_of_cycles The number of cycles to run the 6502 for.
*/