mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-29 12:50:28 +00:00
My counter was going the wrong way.
This commit is contained in:
parent
a4e52cc4db
commit
3c27306a8e
@ -106,14 +106,14 @@ void Machine::get_output_pixel(uint8_t *pixel, int offset)
|
|||||||
playerPixels[c] = 0;
|
playerPixels[c] = 0;
|
||||||
|
|
||||||
// figure out missile colour
|
// figure out missile colour
|
||||||
int missileIndex = _missileCounter[c] - 4;
|
int missileIndex = _missileCounter[c];
|
||||||
int missileSize = 1 << ((_playerAndMissileSize[c] >> 4)&3);
|
int missileSize = 1 << ((_playerAndMissileSize[c] >> 4)&3);
|
||||||
missilePixels[c] = (missileIndex >= 0 && missileIndex < missileSize && (_missileGraphicsEnable[c]&2)) ? 1 : 0;
|
missilePixels[c] = (missileIndex >= 0 && missileIndex < missileSize && (_missileGraphicsEnable[c]&2)) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the ball proposed colour
|
// get the ball proposed colour
|
||||||
uint8_t ballPixel;
|
uint8_t ballPixel;
|
||||||
int ballIndex = _ballCounter;
|
int ballIndex = _ballCounter - 2;
|
||||||
int ballSize = 1 << ((_playfieldControl >> 4)&3);
|
int ballSize = 1 << ((_playfieldControl >> 4)&3);
|
||||||
ballPixel = (ballIndex >= 0 && ballIndex < ballSize && (_ballGraphicsEnable&2)) ? 1 : 0;
|
ballPixel = (ballIndex >= 0 && ballIndex < ballSize && (_ballGraphicsEnable&2)) ? 1 : 0;
|
||||||
|
|
||||||
@ -151,22 +151,14 @@ void Machine::output_pixels(int count)
|
|||||||
if (_hMoveFlags&8) _missileCounter[1] = (_missileCounter[1]+1)%160;
|
if (_hMoveFlags&8) _missileCounter[1] = (_missileCounter[1]+1)%160;
|
||||||
if (_hMoveFlags&16) _ballCounter = (_ballCounter+1)%160;
|
if (_hMoveFlags&16) _ballCounter = (_ballCounter+1)%160;
|
||||||
|
|
||||||
|
_hMoveCounter --;
|
||||||
|
|
||||||
if ((_hMoveCounter^8^(_playerMotion[0] >> 4)) == 0xf) _hMoveFlags &= ~1;
|
if ((_hMoveCounter^8^(_playerMotion[0] >> 4)) == 0xf) _hMoveFlags &= ~1;
|
||||||
if ((_hMoveCounter^8^(_playerMotion[1] >> 4)) == 0xf) _hMoveFlags &= ~2;
|
if ((_hMoveCounter^8^(_playerMotion[1] >> 4)) == 0xf) _hMoveFlags &= ~2;
|
||||||
if ((_hMoveCounter^8^(_missileMotion[0] >> 4)) == 0xf) _hMoveFlags &= ~4;
|
if ((_hMoveCounter^8^(_missileMotion[0] >> 4)) == 0xf) _hMoveFlags &= ~4;
|
||||||
if ((_hMoveCounter^8^(_missileMotion[1] >> 4)) == 0xf) _hMoveFlags &= ~8;
|
if ((_hMoveCounter^8^(_missileMotion[1] >> 4)) == 0xf) _hMoveFlags &= ~8;
|
||||||
if ((_hMoveCounter^8^(_ballMotion >> 4)) == 0xf) _hMoveFlags &= ~16;
|
if ((_hMoveCounter^8^(_ballMotion >> 4)) == 0xf) _hMoveFlags &= ~16;
|
||||||
|
}
|
||||||
_hMoveCounter ++;
|
|
||||||
|
|
||||||
// _playerCounter[0] = (_playerCounter[0] + 160 - 8^(_playerMotion[0] >> 4))%160;
|
|
||||||
// _playerCounter[1] = (_playerCounter[1] + 160 - 8^(_playerMotion[1] >> 4))%160;
|
|
||||||
// _missileCounter[0] = (_missileCounter[0] + 160 - 8^(_missileMotion[0] >> 4))%160;
|
|
||||||
// _missileCounter[1] = (_missileCounter[1] + 160 - 8^(_missileMotion[1] >> 4))%160;
|
|
||||||
// _ballCounter = (_ballCounter + 160 + 8^(_ballMotion >> 4))%160;
|
|
||||||
} /*else {
|
|
||||||
_hMoveCounter --;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
// logic: if in vsync, output that; otherwise if in vblank then output that;
|
// logic: if in vsync, output that; otherwise if in vblank then output that;
|
||||||
// otherwise output a pixel
|
// otherwise output a pixel
|
||||||
@ -233,8 +225,6 @@ void Machine::output_pixels(int count)
|
|||||||
_horizontalTimer--;
|
_horizontalTimer--;
|
||||||
const int32_t sign_extension = _horizontalTimer >> 31;
|
const int32_t sign_extension = _horizontalTimer >> 31;
|
||||||
_horizontalTimer = (_horizontalTimer&~sign_extension) | (sign_extension&horizontalTimerReload);
|
_horizontalTimer = (_horizontalTimer&~sign_extension) | (sign_extension&horizontalTimerReload);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,16 +232,16 @@ int Machine::perform_bus_operation(CPU6502::BusOperation operation, uint16_t add
|
|||||||
{
|
{
|
||||||
uint8_t returnValue = 0xff;
|
uint8_t returnValue = 0xff;
|
||||||
int cycles_run_for = 1;
|
int cycles_run_for = 1;
|
||||||
const int32_t ready_line_disable_time = horizontalTimerReload-3;
|
const int32_t ready_line_disable_time = horizontalTimerReload;
|
||||||
|
|
||||||
if(operation == CPU6502::BusOperation::Ready) {
|
if(operation == CPU6502::BusOperation::Ready) {
|
||||||
int32_t distance_to_end_of_ready = _horizontalTimer - ready_line_disable_time + horizontalTimerReload;
|
int32_t distance_to_end_of_ready = _horizontalTimer - ready_line_disable_time + horizontalTimerReload;
|
||||||
cycles_run_for += distance_to_end_of_ready / 3;
|
cycles_run_for = distance_to_end_of_ready / 3;
|
||||||
output_pixels(distance_to_end_of_ready);
|
output_pixels(distance_to_end_of_ready);
|
||||||
set_ready_line(false);
|
set_ready_line(false);
|
||||||
} else {
|
} else {
|
||||||
output_pixels(3);
|
output_pixels(3);
|
||||||
if(_horizontalTimer == horizontalTimerReload-3)
|
if(_horizontalTimer == ready_line_disable_time)
|
||||||
set_ready_line(false);
|
set_ready_line(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -347,7 +337,7 @@ int Machine::perform_bus_operation(CPU6502::BusOperation operation, uint16_t add
|
|||||||
|
|
||||||
case 0x2a:
|
case 0x2a:
|
||||||
_vBlankExtend = true;
|
_vBlankExtend = true;
|
||||||
_hMoveCounter = 0;
|
_hMoveCounter = 15;
|
||||||
_hMoveFlags = 0x1f;
|
_hMoveFlags = 0x1f;
|
||||||
break;
|
break;
|
||||||
case 0x2b: _playerMotion[0] = _playerMotion[1] = _missileMotion[0] = _missileMotion[1] = _ballMotion = 0; break;
|
case 0x2b: _playerMotion[0] = _playerMotion[1] = _missileMotion[0] = _missileMotion[1] = _ballMotion = 0; break;
|
||||||
|
Loading…
Reference in New Issue
Block a user