mirror of
https://github.com/TomHarte/CLK.git
synced 2024-09-07 12:54:34 +00:00
Added something of the ball counter, but without yet a working HMOVE it's prone to error.
This commit is contained in:
parent
7d3cf76576
commit
6a961c4d28
@ -80,21 +80,26 @@ Machine::~Machine()
|
|||||||
|
|
||||||
void Machine::update_upcoming_event()
|
void Machine::update_upcoming_event()
|
||||||
{
|
{
|
||||||
|
unsigned int upcomingEventsPointerPlus4 = (_upcomingEventsPointer + 4)%number_of_upcoming_events;
|
||||||
|
|
||||||
// grab the background now, for display in four clocks
|
// grab the background now, for display in four clocks
|
||||||
if(!(_horizontalTimer&3))
|
if(!(_horizontalTimer&3))
|
||||||
{
|
{
|
||||||
unsigned int offset = 4 + _horizontalTimer - (horizontalTimerPeriod - 160);
|
unsigned int offset = 4 + _horizontalTimer - (horizontalTimerPeriod - 160);
|
||||||
_upcomingEvents[(_upcomingEventsPointer + 4)%number_of_upcoming_events].updates |= Event::Action::Playfield;
|
_upcomingEvents[upcomingEventsPointerPlus4].updates |= Event::Action::Playfield;
|
||||||
_upcomingEvents[(_upcomingEventsPointer + 4)%number_of_upcoming_events].playfieldOutput = _playfield[(offset >> 2)%40];
|
_upcomingEvents[upcomingEventsPointerPlus4].playfieldOutput = _playfield[(offset >> 2)%40];
|
||||||
}
|
}
|
||||||
|
|
||||||
// the ball becomes visible whenever it hits zero, regardless of whether its status
|
// the ball becomes visible whenever it hits zero, regardless of whether its status
|
||||||
// is the result of a counter rollover or a programmatic reset
|
// is the result of a counter rollover or a programmatic reset
|
||||||
if(!_objectCounter[4] && _ballGraphicsEnable&2)
|
if(!_objectCounter[4])
|
||||||
{
|
{
|
||||||
|
_upcomingEvents[upcomingEventsPointerPlus4].updates |= Event::Action::Ball;
|
||||||
}
|
}
|
||||||
|
_objectCounter[4] = (_objectCounter[4] + 1)%160;
|
||||||
|
|
||||||
// the players and missles become visible only upon overflow to zero
|
// the players and missles become visible only upon overflow to zero, so schedule for
|
||||||
|
// 5/6 clocks ahead from 159
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t Machine::get_output_pixel()
|
uint8_t Machine::get_output_pixel()
|
||||||
@ -105,12 +110,12 @@ uint8_t Machine::get_output_pixel()
|
|||||||
uint8_t playfieldColour = ((_playfieldControl&6) == 2) ? _playerColour[offset / 80] : _playfieldColour;
|
uint8_t playfieldColour = ((_playfieldControl&6) == 2) ? _playerColour[offset / 80] : _playfieldColour;
|
||||||
|
|
||||||
// get the ball proposed colour
|
// get the ball proposed colour
|
||||||
// uint8_t ballPixel = 0;
|
uint8_t ballPixel = 0;
|
||||||
// if(_ballGraphicsEnable&2) {
|
if(_ballGraphicsEnable&2) {
|
||||||
// int ballIndex = _objectCounter[4];
|
int ballSize = 1 << ((_playfieldControl >> 4)&3);
|
||||||
// int ballSize = 1 << ((_playfieldControl >> 4)&3);
|
ballPixel = (_pixelCounters.ball < ballSize) ? 1 : 0;
|
||||||
// ballPixel = (ballIndex >= 0 && ballIndex < ballSize) ? 1 : 0;
|
}
|
||||||
// }
|
_pixelCounters.ball ++;
|
||||||
|
|
||||||
// get player and missile proposed pixels
|
// get player and missile proposed pixels
|
||||||
/* uint8_t playerPixels[2] = {0, 0}, missilePixels[2] = {0, 0};
|
/* uint8_t playerPixels[2] = {0, 0}, missilePixels[2] = {0, 0};
|
||||||
@ -196,7 +201,7 @@ uint8_t Machine::get_output_pixel()
|
|||||||
}*/
|
}*/
|
||||||
|
|
||||||
// return colour
|
// return colour
|
||||||
return _playfieldOutput ? playfieldColour : _backgroundColour;
|
return (_playfieldOutput | ballPixel) ? playfieldColour : _backgroundColour;
|
||||||
}
|
}
|
||||||
|
|
||||||
// in imputing the knowledge that all we're dealing with is the rollover from 159 to 0,
|
// in imputing the knowledge that all we're dealing with is the rollover from 159 to 0,
|
||||||
@ -236,9 +241,9 @@ void Machine::output_pixels(unsigned int count)
|
|||||||
|
|
||||||
// apply any queued changes and flush the record
|
// apply any queued changes and flush the record
|
||||||
if(_upcomingEvents[_upcomingEventsPointer].updates & Event::Action::Playfield)
|
if(_upcomingEvents[_upcomingEventsPointer].updates & Event::Action::Playfield)
|
||||||
{
|
|
||||||
_playfieldOutput = _upcomingEvents[_upcomingEventsPointer].playfieldOutput;
|
_playfieldOutput = _upcomingEvents[_upcomingEventsPointer].playfieldOutput;
|
||||||
}
|
if(_upcomingEvents[_upcomingEventsPointer].updates & Event::Action::Ball)
|
||||||
|
_pixelCounters.ball = 0;
|
||||||
_upcomingEvents[_upcomingEventsPointer].updates = 0;
|
_upcomingEvents[_upcomingEventsPointer].updates = 0;
|
||||||
|
|
||||||
// read that state
|
// read that state
|
||||||
|
@ -60,8 +60,8 @@ class Machine: public CPU6502::Processor<Machine> {
|
|||||||
|
|
||||||
struct Event {
|
struct Event {
|
||||||
enum Action {
|
enum Action {
|
||||||
OutputSate = 1 << 0,
|
Playfield = 1 << 0,
|
||||||
Playfield = 1 << 1,
|
Ball = 1 << 1
|
||||||
};
|
};
|
||||||
unsigned int updates;
|
unsigned int updates;
|
||||||
uint8_t playfieldOutput;
|
uint8_t playfieldOutput;
|
||||||
@ -70,6 +70,9 @@ class Machine: public CPU6502::Processor<Machine> {
|
|||||||
unsigned int _upcomingEventsPointer;
|
unsigned int _upcomingEventsPointer;
|
||||||
|
|
||||||
uint8_t _playfieldOutput;
|
uint8_t _playfieldOutput;
|
||||||
|
struct {
|
||||||
|
uint8_t ball;
|
||||||
|
} _pixelCounters;
|
||||||
|
|
||||||
// player registers
|
// player registers
|
||||||
uint8_t _playerColour[2];
|
uint8_t _playerColour[2];
|
||||||
|
Loading…
Reference in New Issue
Block a user