1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-08-15 14:27:29 +00:00

Various bits of caveman debugging appearing and disappearing, switched to latching ball behaviour.

This commit is contained in:
Thomas Harte
2016-05-22 14:26:02 -04:00
parent 5e220562e4
commit 0242924fb4
3 changed files with 68 additions and 28 deletions

View File

@@ -79,6 +79,8 @@ Machine::~Machine()
void Machine::update_timers(int mask) void Machine::update_timers(int mask)
{ {
// if(_vBlankExtend) printf(".");
// unsigned int upcomingEventsPointerPlus1 = (_upcomingEventsPointer + 1)%number_of_upcoming_events; // unsigned int upcomingEventsPointerPlus1 = (_upcomingEventsPointer + 1)%number_of_upcoming_events;
unsigned int upcomingEventsPointerPlus2 = (_upcomingEventsPointer + 4)%number_of_upcoming_events; unsigned int upcomingEventsPointerPlus2 = (_upcomingEventsPointer + 4)%number_of_upcoming_events;
unsigned int upcomingEventsPointerPlus3 = (_upcomingEventsPointer + 5)%number_of_upcoming_events; unsigned int upcomingEventsPointerPlus3 = (_upcomingEventsPointer + 5)%number_of_upcoming_events;
@@ -153,15 +155,9 @@ void Machine::update_timers(int mask)
uint8_t repeatMask = _playerAndMissileSize[c] & 7; uint8_t repeatMask = _playerAndMissileSize[c] & 7;
switch(repeatMask) switch(repeatMask)
{ {
default: default: _pixelCounter[c] += 4; break;
_pixelCounter[c] += 4; case 5: _pixelCounter[c] += 2; break;
break; case 7: _pixelCounter[c] += 1; break;
case 5:
_pixelCounter[c] += 2;
break;
case 7:
_pixelCounter[c] += 1;
break;
} }
_objectCounter[c] = (_objectCounter[c] + 1)%160; _objectCounter[c] = (_objectCounter[c] + 1)%160;
} }
@@ -183,7 +179,7 @@ uint8_t Machine::get_output_pixel()
// get the ball proposed state // get the ball proposed state
uint8_t ballPixel = 0; uint8_t ballPixel = 0;
if(_ballGraphicsEnable&2) { if(_ballGraphicsEnable[_ballGraphicsSelector]&2) {
int ballSize = 1 << ((_playfieldControl >> 4)&3); int ballSize = 1 << ((_playfieldControl >> 4)&3);
ballPixel = (_pixelCounter[4] < ballSize) ? 1 : 0; ballPixel = (_pixelCounter[4] < ballSize) ? 1 : 0;
} }
@@ -231,10 +227,10 @@ uint8_t Machine::get_output_pixel()
uint8_t outputColour = playfieldPixel ? playfieldColour : _backgroundColour; uint8_t outputColour = playfieldPixel ? playfieldColour : _backgroundColour;
if(!(_playfieldControl&0x04) || !playfieldPixel) { if(!(_playfieldControl&0x04) || !playfieldPixel) {
if(missilePixels[1]) outputColour = _playerColour[1]; // if(missilePixels[1]) outputColour = _playerColour[1];
if(missilePixels[0]) outputColour = _playerColour[0]; // if(missilePixels[0]) outputColour = _playerColour[0];
// if(playerPixels[1] || missilePixels[1]) outputColour = _playerColour[1]; if(playerPixels[1] || missilePixels[1]) outputColour = _playerColour[1];
// if(playerPixels[0] || missilePixels[0]) outputColour = _playerColour[0]; if(playerPixels[0] || missilePixels[0]) outputColour = _playerColour[0];
} }
// return colour // return colour
@@ -263,6 +259,10 @@ void Machine::output_pixels(unsigned int count)
case 16: case 17: state = _vBlankExtend ? OutputState::Blank : OutputState::Pixel; break; case 16: case 17: state = _vBlankExtend ? OutputState::Blank : OutputState::Pixel; break;
default: state = OutputState::Pixel; break; default: state = OutputState::Pixel; break;
} }
// if(!(_horizontalTimer&3) && _vBlankExtend)
// {
// printf("%c", 'a' + state);
// }
// grab background colour and schedule pixel counter resets // grab background colour and schedule pixel counter resets
if(state == OutputState::Pixel) if(state == OutputState::Pixel)
@@ -305,11 +305,20 @@ void Machine::output_pixels(unsigned int count)
_upcomingEvents[(_upcomingEventsPointer+4)%number_of_upcoming_events].updates |= Event::Action::HMoveCompare; _upcomingEvents[(_upcomingEventsPointer+4)%number_of_upcoming_events].updates |= Event::Action::HMoveCompare;
_upcomingEvents[(_upcomingEventsPointer+2)%number_of_upcoming_events].updates |= Event::Action::HMoveDecrement; _upcomingEvents[(_upcomingEventsPointer+2)%number_of_upcoming_events].updates |= Event::Action::HMoveDecrement;
} }
// else
// {
// _vBlankExtend = false;
// }
} }
if(_upcomingEvents[_upcomingEventsPointer].updates & Event::Action::HMoveDecrement) if(_upcomingEvents[_upcomingEventsPointer].updates & Event::Action::HMoveDecrement)
{ {
update_timers(_hMoveFlags); update_timers(_hMoveFlags);
// for(int c = 0; c < 5; c++)
// {
// printf("%c", _hMoveFlags & (1 << c) ? 'X' : '-');
// }
// printf(" ");
} }
_upcomingEvents[_upcomingEventsPointer].updates = 0; _upcomingEvents[_upcomingEventsPointer].updates = 0;
@@ -383,6 +392,8 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin
output_pixels(cycles_run_for * 3); output_pixels(cycles_run_for * 3);
// printf("/%d/", _horizontalTimer);
if(operation != CPU6502::BusOperation::Ready) { if(operation != CPU6502::BusOperation::Ready) {
// check for a paging access // check for a paging access
@@ -458,10 +469,12 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin
case 0x02: case 0x02:
// printf("%d\n", _horizontalTimer); // printf("%d\n", _horizontalTimer);
// printf("W");
if(_horizontalTimer) set_ready_line(true); if(_horizontalTimer) set_ready_line(true);
break; break;
case 0x03: case 0x03:
_horizontalTimer = 0; _horizontalTimer = 0; // TODO: this should be delayed by four cycles, affecting phase;
// need to fix wait logic.
break; break;
case 0x04: case 0x04:
@@ -539,7 +552,7 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin
break; break;
case 0x1c: case 0x1c:
_ballGraphicsEnable = _ballGraphicsEnableLatch; _ballGraphicsEnable[1] = _ballGraphicsEnable[0];
case 0x1b: { case 0x1b: {
int index = decodedAddress - 0x1b; int index = decodedAddress - 0x1b;
_playerGraphics[0][index] = *value; _playerGraphics[0][index] = *value;
@@ -548,9 +561,7 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin
case 0x1d: _missileGraphicsEnable[0] = *value; break; case 0x1d: _missileGraphicsEnable[0] = *value; break;
case 0x1e: _missileGraphicsEnable[1] = *value; break; case 0x1e: _missileGraphicsEnable[1] = *value; break;
case 0x1f: case 0x1f:
_ballGraphicsEnableLatch = *value; _ballGraphicsEnable[0] = *value;
if(!(_ballGraphicsEnableDelay&1))
_ballGraphicsEnable = _ballGraphicsEnableLatch;
break; break;
case 0x20: case 0x20:
@@ -561,9 +572,9 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin
_objectMotion[decodedAddress - 0x20] = *value; _objectMotion[decodedAddress - 0x20] = *value;
break; break;
case 0x25: _playerGraphicsSelector[0] = (*value)&1; break; case 0x25: _playerGraphicsSelector[0] = (*value)&1; break;
case 0x26: _playerGraphicsSelector[1] = (*value)&1; break; case 0x26: _playerGraphicsSelector[1] = (*value)&1; break;
case 0x27: _ballGraphicsEnableDelay = *value; break; case 0x27: _ballGraphicsSelector = (*value)&1; break;
case 0x28: case 0x28:
case 0x29: case 0x29:
@@ -588,6 +599,31 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin
_hMoveFlags = 0x1f; _hMoveFlags = 0x1f;
_hMoveCounter = 15; _hMoveCounter = 15;
// static int lc = 0;
// lc++;
// if(lc == 2813)
// printf("{%d}", lc);
// printf("/%d/", _horizontalTimer);
// printf("%d [", _horizontalTimer);
// for(int c = 0; c < 5; c++)
// {
// printf("%d ", _objectMotion[c] >> 4);
// }
// printf("]");
// printf("[");
// for(int c = 0; c < 5; c++)
// {
// printf("%d ", _objectCounter[c]);
// }
// printf("]\n");
// for(int c = 0; c < 5; c++)
// {
// if(_objectMotion[c] >> 4)
// printf("!");
// }
// justification for +5: "we need to wait at least 71 [clocks] before the HMOVE operation is complete"; // justification for +5: "we need to wait at least 71 [clocks] before the HMOVE operation is complete";
// which will take 16*4 + 2 = 66 cycles from the first compare, implying the first compare must be // which will take 16*4 + 2 = 66 cycles from the first compare, implying the first compare must be
// in five cycles from now // in five cycles from now
@@ -622,6 +658,7 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin
case 0x01: case 0x01:
case 0x03: case 0x03:
// TODO: port DDR // TODO: port DDR
printf("!!!DDR!!!");
break; break;
case 0x04: case 0x04:
returnValue &= _piaTimerValue >> _piaTimerShift; returnValue &= _piaTimerValue >> _piaTimerShift;

View File

@@ -61,14 +61,16 @@ class Machine: public CPU6502::Processor<Machine> {
struct Event { struct Event {
enum Action { enum Action {
Playfield = 1 << 0, Playfield = 1 << 0,
ResetPixelCounter = 1 << 1,
HMoveCompare = 1 << 2, ResetPixelCounter = 1 << 3,
HMoveDecrement = 1 << 3,
HMoveCompare = 1 << 4,
HMoveDecrement = 1 << 5,
}; };
int updates; int updates;
int pixelCounterMask; int pixelCounterMask;
uint8_t playfieldOutput; uint8_t playfieldOutput, player0Output, player1Output;
OutputState state; OutputState state;
Event() : updates(0), pixelCounterMask(0) {} Event() : updates(0), pixelCounterMask(0) {}
@@ -91,8 +93,8 @@ class Machine: public CPU6502::Processor<Machine> {
uint8_t _missileGraphicsEnable[2], _missileGraphicsReset[2]; uint8_t _missileGraphicsEnable[2], _missileGraphicsReset[2];
// ball registers // ball registers
uint8_t _ballGraphicsEnable, _ballGraphicsEnableLatch; uint8_t _ballGraphicsEnable[2];
uint8_t _ballGraphicsEnableDelay; uint8_t _ballGraphicsSelector;
// graphics output // graphics output
unsigned int _horizontalTimer; unsigned int _horizontalTimer;

View File

@@ -597,6 +597,7 @@ template <class T> class Processor {
case CycleFetchOperation: { case CycleFetchOperation: {
_lastOperationPC = _pc; _lastOperationPC = _pc;
// printf("%04x\n", _pc.full);
_pc.full++; _pc.full++;
read_op(_operation, _lastOperationPC.full); read_op(_operation, _lastOperationPC.full);