1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-01-28 13:30:55 +00:00

Realised that registers appear also to be readable.

This commit is contained in:
Thomas Harte 2016-06-06 20:29:39 -04:00
parent e8cb674073
commit c7c55528e2
4 changed files with 16 additions and 2 deletions

View File

@ -50,6 +50,7 @@ MOS6560::MOS6560() :
void MOS6560::set_register(int address, uint8_t value) void MOS6560::set_register(int address, uint8_t value)
{ {
_registers[address] = value;
switch(address) switch(address)
{ {
case 0x0: case 0x0:
@ -99,6 +100,12 @@ void MOS6560::set_register(int address, uint8_t value)
} }
} }
uint8_t MOS6560::get_register(int address)
{
return _registers[address];
}
void MOS6560::output_border(unsigned int number_of_cycles) void MOS6560::output_border(unsigned int number_of_cycles)
{ {
uint8_t *colour_pointer = _crt->allocate_write_area(1); uint8_t *colour_pointer = _crt->allocate_write_area(1);

View File

@ -22,6 +22,7 @@ class MOS6560 {
void set_graphics_value(uint8_t value, uint8_t colour_value); void set_graphics_value(uint8_t value, uint8_t colour_value);
void set_register(int address, uint8_t value); void set_register(int address, uint8_t value);
uint8_t get_register(int address);
private: private:
std::unique_ptr<Outputs::CRT::CRT> _crt; std::unique_ptr<Outputs::CRT::CRT> _crt;
@ -47,6 +48,8 @@ class MOS6560 {
uint8_t *pixel_pointer; uint8_t *pixel_pointer;
uint8_t _registers[16];
void output_border(unsigned int number_of_cycles); void output_border(unsigned int number_of_cycles);
}; };

View File

@ -29,6 +29,10 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin
if(isReadOperation(operation)) if(isReadOperation(operation))
{ {
*value = read_memory(address); *value = read_memory(address);
if((address&0xfff0) == 0x9000)
{
*value = _mos6560->get_register(address - 0x9000);
}
} }
else else
{ {

View File

@ -46,12 +46,12 @@ class Machine: public CPU6502::Processor<Machine>, public CRTMachine::Machine {
uint8_t _userBASICMemory[0x0400]; uint8_t _userBASICMemory[0x0400];
uint8_t _screenMemory[0x1000]; uint8_t _screenMemory[0x1000];
uint8_t _colorMemory[0x0200]; uint8_t _colorMemory[0x0400];
inline uint8_t *ram_pointer(uint16_t address) { inline uint8_t *ram_pointer(uint16_t address) {
if(address < sizeof(_userBASICMemory)) return &_userBASICMemory[address]; if(address < sizeof(_userBASICMemory)) return &_userBASICMemory[address];
if(address >= 0x1000 && address < 0x2000) return &_screenMemory[address&0x0fff]; if(address >= 0x1000 && address < 0x2000) return &_screenMemory[address&0x0fff];
if(address >= 0x9400 && address < 0x9600) return &_colorMemory[0x01ff]; if(address >= 0x9400 && address < 0x9800) return &_colorMemory[0x03ff]; // TODO: make this 4-bit
return nullptr; return nullptr;
} }