mirror of
https://github.com/TomHarte/CLK.git
synced 2025-02-19 07:31:15 +00:00
Had a quick bash at timer overflow.
This commit is contained in:
parent
58908b60ac
commit
14adcd2096
@ -20,6 +20,7 @@ Machine::Machine()
|
|||||||
_lastOutputStateDuration = 0;
|
_lastOutputStateDuration = 0;
|
||||||
_lastOutputState = OutputState::Sync;
|
_lastOutputState = OutputState::Sync;
|
||||||
_crt = new Outputs::CRT(228, 256, 1, 4);
|
_crt = new Outputs::CRT(228, 256, 1, 4);
|
||||||
|
_piaTimerStatus = 0xff;
|
||||||
|
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
@ -272,15 +273,15 @@ int Machine::perform_bus_operation(CPU6502::BusOperation operation, uint16_t add
|
|||||||
if ((address&0x1280) == 0x280) {
|
if ((address&0x1280) == 0x280) {
|
||||||
if(isReadOperation(operation)) {
|
if(isReadOperation(operation)) {
|
||||||
switch(address & 0xf) {
|
switch(address & 0xf) {
|
||||||
// case 0x00:
|
case 0x04: returnValue &= _piaTimerValue >> _piaTimerShift; break;
|
||||||
case 0x04: returnValue &= _piaTimerValue >> _piaTimerShift; break;
|
case 0x05: returnValue &= _piaTimerStatus; _piaTimerStatus &= ~0x40; break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
switch(address & 0x0f) {
|
switch(address & 0x0f) {
|
||||||
case 0x04: _piaTimerShift = 0; _piaTimerValue = *value << 0; break;
|
case 0x04: _piaTimerShift = 0; _piaTimerValue = *value << 0; _piaTimerStatus &= ~0xc0; break;
|
||||||
case 0x05: _piaTimerShift = 3; _piaTimerValue = *value << 3; break;
|
case 0x05: _piaTimerShift = 3; _piaTimerValue = *value << 3; _piaTimerStatus &= ~0xc0; break;
|
||||||
case 0x06: _piaTimerShift = 6; _piaTimerValue = *value << 6; break;
|
case 0x06: _piaTimerShift = 6; _piaTimerValue = *value << 6; _piaTimerStatus &= ~0xc0; break;
|
||||||
case 0x07: _piaTimerShift = 10; _piaTimerValue = *value << 10; break;
|
case 0x07: _piaTimerShift = 10; _piaTimerValue = *value << 10; _piaTimerStatus &= ~0xc0; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// printf("Uncaught PIA %04x\n", address);
|
// printf("Uncaught PIA %04x\n", address);
|
||||||
@ -290,7 +291,13 @@ int Machine::perform_bus_operation(CPU6502::BusOperation operation, uint16_t add
|
|||||||
*value = returnValue;
|
*value = returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
_piaTimerValue -= cycle_count;
|
if(_piaTimerValue < cycle_count) {
|
||||||
|
_piaTimerValue = 0x100 - cycle_count + _piaTimerValue;
|
||||||
|
_piaTimerShift = 0;
|
||||||
|
_piaTimerStatus |= 0xc0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
_piaTimerValue -= cycle_count;
|
||||||
|
|
||||||
return cycle_count;
|
return cycle_count;
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,7 @@ class Machine: public CPU6502::Processor<Machine> {
|
|||||||
// the timer
|
// the timer
|
||||||
unsigned int _piaTimerValue;
|
unsigned int _piaTimerValue;
|
||||||
unsigned int _piaTimerShift;
|
unsigned int _piaTimerShift;
|
||||||
|
uint8_t _piaTimerStatus;
|
||||||
|
|
||||||
// graphics registers
|
// graphics registers
|
||||||
uint8_t _playfield[3], _playfieldControl;
|
uint8_t _playfield[3], _playfieldControl;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user