mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-28 21:49:27 +00:00
Collapsed two methods into one, to avoid redundant pixel copying.
This commit is contained in:
parent
828ae66a45
commit
164866d613
@ -70,40 +70,30 @@ void Machine::output_pixels(int count)
|
|||||||
{
|
{
|
||||||
while(count--)
|
while(count--)
|
||||||
{
|
{
|
||||||
|
OutputState state;
|
||||||
|
|
||||||
// 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
|
||||||
if(_vSyncEnabled) {
|
if(_vSyncEnabled) {
|
||||||
output_state(OutputState::Sync, nullptr);
|
state = OutputState::Sync;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// blank is decoded as 68 counts; sync and colour burst as 16 counts
|
// blank is decoded as 68 counts; sync and colour burst as 16 counts
|
||||||
|
|
||||||
// it'll be about 43 cycles from start of hsync to start of visible frame, so...
|
// it'll be about 43 cycles from start of hsync to start of visible frame, so...
|
||||||
// guesses, until I can find information: 26 cycles blank, 16 sync, 40 blank, 160 pixels
|
// guesses, until I can find information: 26 cycles blank, 16 sync, 40 blank, 160 pixels
|
||||||
if(_horizontalTimer > 214) output_state(OutputState::Blank, nullptr);
|
if(_horizontalTimer > 214) state = OutputState::Blank;
|
||||||
else if (_horizontalTimer > 188) output_state(OutputState::Sync, nullptr);
|
else if (_horizontalTimer > 188) state = OutputState::Sync;
|
||||||
else if (_horizontalTimer >= 160) output_state(OutputState::Blank, nullptr);
|
else if (_horizontalTimer >= 160) state = OutputState::Blank;
|
||||||
else {
|
else {
|
||||||
if(_vBlankEnabled) {
|
if(_vBlankEnabled) {
|
||||||
output_state(OutputState::Blank, nullptr);
|
state = OutputState::Blank;
|
||||||
} else {
|
} else {
|
||||||
uint8_t outputPixel[4];
|
state = OutputState::Pixel;
|
||||||
get_output_pixel(outputPixel, 159 - _horizontalTimer);
|
|
||||||
output_state(OutputState::Pixel, outputPixel);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// assumption here: signed shifts right; otherwise it's just
|
|
||||||
// an attempt to avoid both the % operator and a conditional
|
|
||||||
_horizontalTimer--;
|
|
||||||
const int32_t sign_extension = _horizontalTimer >> 31;
|
|
||||||
_horizontalTimer = (_horizontalTimer&~sign_extension) | (sign_extension&227);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Machine::output_state(OutputState state, uint8_t *pixel)
|
|
||||||
{
|
|
||||||
_lastOutputStateDuration++;
|
_lastOutputStateDuration++;
|
||||||
if(state != _lastOutputState)
|
if(state != _lastOutputState)
|
||||||
{
|
{
|
||||||
@ -124,11 +114,13 @@ void Machine::output_state(OutputState state, uint8_t *pixel)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(state == OutputState::Pixel && _outputBuffer)
|
if(state == OutputState::Pixel && _outputBuffer)
|
||||||
{
|
get_output_pixel(&_outputBuffer[_lastOutputStateDuration * 4], 159 - _horizontalTimer);
|
||||||
_outputBuffer[(_lastOutputStateDuration * 4) + 0] = pixel[0];
|
|
||||||
_outputBuffer[(_lastOutputStateDuration * 4) + 1] = pixel[1];
|
// assumption here: signed shifts right; otherwise it's just
|
||||||
_outputBuffer[(_lastOutputStateDuration * 4) + 2] = pixel[2];
|
// an attempt to avoid both the % operator and a conditional
|
||||||
_outputBuffer[(_lastOutputStateDuration * 4) + 3] = pixel[3];
|
_horizontalTimer--;
|
||||||
|
const int32_t sign_extension = _horizontalTimer >> 31;
|
||||||
|
_horizontalTimer = (_horizontalTimer&~sign_extension) | (sign_extension&227);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,6 +152,16 @@ int Machine::perform_bus_operation(CPU6502::BusOperation operation, uint16_t add
|
|||||||
// check for a TIA access
|
// check for a TIA access
|
||||||
if (!(address&0x1080)) {
|
if (!(address&0x1080)) {
|
||||||
if(isReadOperation(operation)) {
|
if(isReadOperation(operation)) {
|
||||||
|
switch(address & 0xf) {
|
||||||
|
case 0x00: *value = 0x3f; break;
|
||||||
|
case 0x01: *value = 0x3f; break;
|
||||||
|
case 0x02: *value = 0x3f; break;
|
||||||
|
case 0x03: *value = 0x3f; break;
|
||||||
|
case 0x04: *value = 0x3f; break;
|
||||||
|
case 0x05: *value = 0x3f; break;
|
||||||
|
case 0x06: *value = 0x7f; break;
|
||||||
|
case 0x07: *value = 0x3f; break;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
switch(address & 0x3f) {
|
switch(address & 0x3f) {
|
||||||
case 0: _vSyncEnabled = !!(*value & 0x02); break;
|
case 0: _vSyncEnabled = !!(*value & 0x02); break;
|
||||||
|
@ -57,7 +57,6 @@ class Machine: public CPU6502::Processor<Machine> {
|
|||||||
|
|
||||||
void output_pixels(int count);
|
void output_pixels(int count);
|
||||||
void get_output_pixel(uint8_t *pixel, int offset);
|
void get_output_pixel(uint8_t *pixel, int offset);
|
||||||
void output_state(OutputState state, uint8_t *pixel);
|
|
||||||
Outputs::CRT *_crt;
|
Outputs::CRT *_crt;
|
||||||
|
|
||||||
// latched output state
|
// latched output state
|
||||||
|
Loading…
Reference in New Issue
Block a user