mirror of
https://github.com/TomHarte/CLK.git
synced 2025-02-19 23:29:05 +00:00
Switched on the appropriate compiler warnings re: signed comparisons and implicit conversions. Fixed all less-than-explicit calls.
This commit is contained in:
parent
1cc479affd
commit
a693c081f8
@ -166,7 +166,7 @@ void Machine::get_output_pixel(uint8_t *pixel, int offset)
|
|||||||
// this is faster than the straightforward +1)%160 per profiling
|
// this is faster than the straightforward +1)%160 per profiling
|
||||||
#define increment_object_counter(c) _objectCounter[c] = (_objectCounter[c]+1)&~((158-_objectCounter[c]) >> 8)
|
#define increment_object_counter(c) _objectCounter[c] = (_objectCounter[c]+1)&~((158-_objectCounter[c]) >> 8)
|
||||||
|
|
||||||
void Machine::output_pixels(int count)
|
void Machine::output_pixels(unsigned int count)
|
||||||
{
|
{
|
||||||
const int32_t start_of_sync = 214;
|
const int32_t start_of_sync = 214;
|
||||||
const int32_t end_of_sync = 198;
|
const int32_t end_of_sync = 198;
|
||||||
@ -264,16 +264,16 @@ void Machine::output_pixels(int count)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int Machine::perform_bus_operation(CPU6502::BusOperation operation, uint16_t address, uint8_t *value)
|
unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uint16_t address, uint8_t *value)
|
||||||
{
|
{
|
||||||
set_reset_line(false);
|
set_reset_line(false);
|
||||||
|
|
||||||
uint8_t returnValue = 0xff;
|
uint8_t returnValue = 0xff;
|
||||||
int cycles_run_for = 1;
|
unsigned int cycles_run_for = 1;
|
||||||
const int32_t ready_line_disable_time = 227;//horizontalTimerReload;
|
const int32_t ready_line_disable_time = 227;//horizontalTimerReload;
|
||||||
|
|
||||||
if(operation == CPU6502::BusOperation::Ready) {
|
if(operation == CPU6502::BusOperation::Ready) {
|
||||||
int32_t distance_to_end_of_ready = (_horizontalTimer - ready_line_disable_time + horizontalTimerReload + 1)%(horizontalTimerReload + 1);
|
unsigned int distance_to_end_of_ready = (_horizontalTimer - ready_line_disable_time + horizontalTimerReload + 1)%(horizontalTimerReload + 1);
|
||||||
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);
|
||||||
} else {
|
} else {
|
||||||
@ -295,7 +295,7 @@ int Machine::perform_bus_operation(CPU6502::BusOperation operation, uint16_t add
|
|||||||
// check for a paging access
|
// check for a paging access
|
||||||
if(_rom_size > 4096 && ((address & 0x1f00) == 0x1f00)) {
|
if(_rom_size > 4096 && ((address & 0x1f00) == 0x1f00)) {
|
||||||
uint8_t *base_ptr = _romPages[0];
|
uint8_t *base_ptr = _romPages[0];
|
||||||
uint8_t first_paging_register = 0xf8 - (_rom_size >> 14)*2;
|
uint8_t first_paging_register = (uint8_t)(0xf8 - (_rom_size >> 14)*2);
|
||||||
|
|
||||||
const uint8_t paging_register = address&0xff;
|
const uint8_t paging_register = address&0xff;
|
||||||
if(paging_register >= first_paging_register) {
|
if(paging_register >= first_paging_register) {
|
||||||
@ -530,11 +530,16 @@ int Machine::perform_bus_operation(CPU6502::BusOperation operation, uint16_t add
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
switch(address & 0x0f) {
|
const uint8_t decodedAddress = address & 0x0f;
|
||||||
case 0x04: _writtenPiaTimerShift = _piaTimerShift = 0; _piaTimerValue = *value << 0; _piaTimerStatus &= ~0xc0; break;
|
switch(decodedAddress) {
|
||||||
case 0x05: _writtenPiaTimerShift = _piaTimerShift = 3; _piaTimerValue = *value << 3; _piaTimerStatus &= ~0xc0; break;
|
case 0x04:
|
||||||
case 0x06: _writtenPiaTimerShift = _piaTimerShift = 6; _piaTimerValue = *value << 6; _piaTimerStatus &= ~0xc0; break;
|
case 0x05:
|
||||||
case 0x07: _writtenPiaTimerShift = _piaTimerShift = 10; _piaTimerValue = *value << 10; _piaTimerStatus &= ~0xc0; break;
|
case 0x06:
|
||||||
|
case 0x07:
|
||||||
|
_writtenPiaTimerShift = _piaTimerShift = (decodedAddress - 0x04) * 3 + (decodedAddress / 0x07);
|
||||||
|
_piaTimerValue = (unsigned int)(*value << _piaTimerShift);
|
||||||
|
_piaTimerStatus &= ~0xc0;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ class Machine: public CPU6502::Processor<Machine> {
|
|||||||
Machine();
|
Machine();
|
||||||
~Machine();
|
~Machine();
|
||||||
|
|
||||||
int perform_bus_operation(CPU6502::BusOperation operation, uint16_t address, uint8_t *value);
|
unsigned int perform_bus_operation(CPU6502::BusOperation operation, uint16_t address, uint8_t *value);
|
||||||
|
|
||||||
void set_rom(size_t length, const uint8_t *data);
|
void set_rom(size_t length, const uint8_t *data);
|
||||||
void switch_region();
|
void switch_region();
|
||||||
@ -81,12 +81,12 @@ class Machine: public CPU6502::Processor<Machine> {
|
|||||||
Pixel
|
Pixel
|
||||||
};
|
};
|
||||||
|
|
||||||
void output_pixels(int count);
|
void output_pixels(unsigned int count);
|
||||||
void get_output_pixel(uint8_t *pixel, int offset);
|
void get_output_pixel(uint8_t *pixel, int offset);
|
||||||
Outputs::CRT *_crt;
|
Outputs::CRT *_crt;
|
||||||
|
|
||||||
// latched output state
|
// latched output state
|
||||||
int _lastOutputStateDuration;
|
unsigned int _lastOutputStateDuration;
|
||||||
OutputState _lastOutputState;
|
OutputState _lastOutputState;
|
||||||
uint8_t *_outputBuffer;
|
uint8_t *_outputBuffer;
|
||||||
};
|
};
|
||||||
|
@ -1584,6 +1584,8 @@
|
|||||||
buildSettings = {
|
buildSettings = {
|
||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
CLANG_ENABLE_MODULES = YES;
|
CLANG_ENABLE_MODULES = YES;
|
||||||
|
CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES;
|
||||||
|
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
|
||||||
CODE_SIGN_ENTITLEMENTS = "Clock Signal/Clock Signal.entitlements";
|
CODE_SIGN_ENTITLEMENTS = "Clock Signal/Clock Signal.entitlements";
|
||||||
COMBINE_HIDPI_IMAGES = YES;
|
COMBINE_HIDPI_IMAGES = YES;
|
||||||
INFOPLIST_FILE = "Clock Signal/Info.plist";
|
INFOPLIST_FILE = "Clock Signal/Info.plist";
|
||||||
@ -1600,6 +1602,8 @@
|
|||||||
buildSettings = {
|
buildSettings = {
|
||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
CLANG_ENABLE_MODULES = YES;
|
CLANG_ENABLE_MODULES = YES;
|
||||||
|
CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES;
|
||||||
|
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
|
||||||
CODE_SIGN_ENTITLEMENTS = "Clock Signal/Clock Signal.entitlements";
|
CODE_SIGN_ENTITLEMENTS = "Clock Signal/Clock Signal.entitlements";
|
||||||
COMBINE_HIDPI_IMAGES = YES;
|
COMBINE_HIDPI_IMAGES = YES;
|
||||||
INFOPLIST_FILE = "Clock Signal/Info.plist";
|
INFOPLIST_FILE = "Clock Signal/Info.plist";
|
||||||
|
@ -95,7 +95,7 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
|
|||||||
|
|
||||||
NSPoint backingSize = {.x = self.bounds.size.width, .y = self.bounds.size.height};
|
NSPoint backingSize = {.x = self.bounds.size.width, .y = self.bounds.size.height};
|
||||||
NSPoint viewSize = [self convertPointToBacking:backingSize];
|
NSPoint viewSize = [self convertPointToBacking:backingSize];
|
||||||
glViewport(0, 0, viewSize.x, viewSize.y);
|
glViewport(0, 0, (GLsizei)viewSize.x, (GLsizei)viewSize.y);
|
||||||
|
|
||||||
CGLUnlockContext([[self openGLContext] CGLContextObj]);
|
CGLUnlockContext([[self openGLContext] CGLContextObj]);
|
||||||
}
|
}
|
||||||
@ -128,7 +128,7 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
|
|||||||
self.wantsBestResolutionOpenGLSurface = YES;
|
self.wantsBestResolutionOpenGLSurface = YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (GLint)formatForDepth:(int)depth
|
- (GLint)formatForDepth:(unsigned int)depth
|
||||||
{
|
{
|
||||||
switch(depth)
|
switch(depth)
|
||||||
{
|
{
|
||||||
@ -154,11 +154,11 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
|
|||||||
if(_textureSize.width != _crtFrame->size.width || _textureSize.height != _crtFrame->size.height)
|
if(_textureSize.width != _crtFrame->size.width || _textureSize.height != _crtFrame->size.height)
|
||||||
{
|
{
|
||||||
GLint format = [self formatForDepth:_crtFrame->buffers[0].depth];
|
GLint format = [self formatForDepth:_crtFrame->buffers[0].depth];
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, format, _crtFrame->size.width, _crtFrame->size.height, 0, format, GL_UNSIGNED_BYTE, _crtFrame->buffers[0].data);
|
glTexImage2D(GL_TEXTURE_2D, 0, format, _crtFrame->size.width, _crtFrame->size.height, 0, (GLenum)format, GL_UNSIGNED_BYTE, _crtFrame->buffers[0].data);
|
||||||
_textureSize = _crtFrame->size;
|
_textureSize = _crtFrame->size;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, _crtFrame->size.width, _crtFrame->dirty_size.height, [self formatForDepth:_crtFrame->buffers[0].depth], GL_UNSIGNED_BYTE, _crtFrame->buffers[0].data);
|
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, _crtFrame->size.width, _crtFrame->dirty_size.height, (GLenum)[self formatForDepth:_crtFrame->buffers[0].depth], GL_UNSIGNED_BYTE, _crtFrame->buffers[0].data);
|
||||||
|
|
||||||
[self drawView];
|
[self drawView];
|
||||||
|
|
||||||
@ -213,7 +213,7 @@ const char *fragmentShader =
|
|||||||
GLint logLength;
|
GLint logLength;
|
||||||
glGetShaderiv(object, GL_INFO_LOG_LENGTH, &logLength);
|
glGetShaderiv(object, GL_INFO_LOG_LENGTH, &logLength);
|
||||||
if (logLength > 0) {
|
if (logLength > 0) {
|
||||||
GLchar *log = (GLchar *)malloc(logLength);
|
GLchar *log = (GLchar *)malloc((size_t)logLength);
|
||||||
glGetShaderInfoLog(object, logLength, &logLength, log);
|
glGetShaderInfoLog(object, logLength, &logLength, log);
|
||||||
NSLog(@"Compile log:\n%s", log);
|
NSLog(@"Compile log:\n%s", log);
|
||||||
free(log);
|
free(log);
|
||||||
@ -262,14 +262,14 @@ const char *fragmentShader =
|
|||||||
_alphaUniform = glGetUniformLocation(_shaderProgram, "alpha");
|
_alphaUniform = glGetUniformLocation(_shaderProgram, "alpha");
|
||||||
_textureSizeUniform = glGetUniformLocation(_shaderProgram, "textureSize");
|
_textureSizeUniform = glGetUniformLocation(_shaderProgram, "textureSize");
|
||||||
|
|
||||||
glEnableVertexAttribArray(_positionAttribute);
|
glEnableVertexAttribArray((GLuint)_positionAttribute);
|
||||||
glEnableVertexAttribArray(_textureCoordinatesAttribute);
|
glEnableVertexAttribArray((GLuint)_textureCoordinatesAttribute);
|
||||||
glEnableVertexAttribArray(_lateralAttribute);
|
glEnableVertexAttribArray((GLuint)_lateralAttribute);
|
||||||
|
|
||||||
const GLsizei vertexStride = kCRTSizeOfVertex;
|
const GLsizei vertexStride = kCRTSizeOfVertex;
|
||||||
glVertexAttribPointer(_positionAttribute, 2, GL_UNSIGNED_SHORT, GL_TRUE, vertexStride, (void *)kCRTVertexOffsetOfPosition);
|
glVertexAttribPointer((GLuint)_positionAttribute, 2, GL_UNSIGNED_SHORT, GL_TRUE, vertexStride, (void *)kCRTVertexOffsetOfPosition);
|
||||||
glVertexAttribPointer(_textureCoordinatesAttribute, 2, GL_UNSIGNED_SHORT, GL_FALSE, vertexStride, (void *)kCRTVertexOffsetOfTexCoord);
|
glVertexAttribPointer((GLuint)_textureCoordinatesAttribute, 2, GL_UNSIGNED_SHORT, GL_FALSE, vertexStride, (void *)kCRTVertexOffsetOfTexCoord);
|
||||||
glVertexAttribPointer(_lateralAttribute, 1, GL_UNSIGNED_BYTE, GL_FALSE, vertexStride, (void *)kCRTVertexOffsetOfLateral);
|
glVertexAttribPointer((GLuint)_lateralAttribute, 1, GL_UNSIGNED_BYTE, GL_FALSE, vertexStride, (void *)kCRTVertexOffsetOfLateral);
|
||||||
|
|
||||||
glGenTextures(1, &_textureName);
|
glGenTextures(1, &_textureName);
|
||||||
glBindTexture(GL_TEXTURE_2D, _textureName);
|
glBindTexture(GL_TEXTURE_2D, _textureName);
|
||||||
@ -294,7 +294,7 @@ const char *fragmentShader =
|
|||||||
if (_crtFrame)
|
if (_crtFrame)
|
||||||
{
|
{
|
||||||
glUniform2f(_textureSizeUniform, _crtFrame->size.width, _crtFrame->size.height);
|
glUniform2f(_textureSizeUniform, _crtFrame->size.width, _crtFrame->size.height);
|
||||||
glDrawArrays(GL_TRIANGLES, 0, _crtFrame->number_of_runs*6);
|
glDrawArrays(GL_TRIANGLES, 0, (GLsizei)(_crtFrame->number_of_runs*6));
|
||||||
}
|
}
|
||||||
|
|
||||||
CGLFlushDrawable([[self openGLContext] CGLContextObj]);
|
CGLFlushDrawable([[self openGLContext] CGLContextObj]);
|
||||||
|
@ -18,11 +18,11 @@ static const uint32_t kCRTFixedPointOffset = 0x08000000;
|
|||||||
#define kRetraceXMask 0x01
|
#define kRetraceXMask 0x01
|
||||||
#define kRetraceYMask 0x02
|
#define kRetraceYMask 0x02
|
||||||
|
|
||||||
void CRT::set_new_timing(int cycles_per_line, int height_of_display)
|
void CRT::set_new_timing(unsigned int cycles_per_line, unsigned int height_of_display)
|
||||||
{
|
{
|
||||||
const int syncCapacityLineChargeThreshold = 3;
|
const unsigned int syncCapacityLineChargeThreshold = 3;
|
||||||
const int millisecondsHorizontalRetraceTime = 10; // source: Dictionary of Video and Television Technology, p. 234
|
const unsigned int millisecondsHorizontalRetraceTime = 10; // source: Dictionary of Video and Television Technology, p. 234
|
||||||
const int scanlinesVerticalRetraceTime = 7; // source: ibid
|
const unsigned int scanlinesVerticalRetraceTime = 7; // source: ibid
|
||||||
|
|
||||||
_time_multiplier = (1000 + cycles_per_line - 1) / cycles_per_line;
|
_time_multiplier = (1000 + cycles_per_line - 1) / cycles_per_line;
|
||||||
height_of_display += (height_of_display / 20); // this is the overrun area we'll use to
|
height_of_display += (height_of_display / 20); // this is the overrun area we'll use to
|
||||||
@ -36,7 +36,7 @@ void CRT::set_new_timing(int cycles_per_line, int height_of_display)
|
|||||||
|
|
||||||
_sync_capacitor_charge_threshold = ((syncCapacityLineChargeThreshold * _cycles_per_line) * 50) >> 7;
|
_sync_capacitor_charge_threshold = ((syncCapacityLineChargeThreshold * _cycles_per_line) * 50) >> 7;
|
||||||
_horizontal_retrace_time = (millisecondsHorizontalRetraceTime * _cycles_per_line) >> 6;
|
_horizontal_retrace_time = (millisecondsHorizontalRetraceTime * _cycles_per_line) >> 6;
|
||||||
const int vertical_retrace_time = scanlinesVerticalRetraceTime * _cycles_per_line;
|
const unsigned int vertical_retrace_time = scanlinesVerticalRetraceTime * _cycles_per_line;
|
||||||
const float halfLineWidth = (float)_height_of_display * 1.85f;
|
const float halfLineWidth = (float)_height_of_display * 1.85f;
|
||||||
|
|
||||||
for(int c = 0; c < 4; c++)
|
for(int c = 0; c < 4; c++)
|
||||||
@ -46,19 +46,19 @@ void CRT::set_new_timing(int cycles_per_line, int height_of_display)
|
|||||||
|
|
||||||
// width should be 1.0 / _height_of_display, rotated to match the direction
|
// width should be 1.0 / _height_of_display, rotated to match the direction
|
||||||
float angle = atan2f(_scanSpeed[c].y, _scanSpeed[c].x);
|
float angle = atan2f(_scanSpeed[c].y, _scanSpeed[c].x);
|
||||||
_beamWidth[c].x = (sinf(angle) / halfLineWidth) * kCRTFixedPointRange;
|
_beamWidth[c].x = (uint32_t)((sinf(angle) / halfLineWidth) * kCRTFixedPointRange);
|
||||||
_beamWidth[c].y = (cosf(angle) / halfLineWidth) * kCRTFixedPointRange;
|
_beamWidth[c].y = (uint32_t)((cosf(angle) / halfLineWidth) * kCRTFixedPointRange);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CRT::CRT(int cycles_per_line, int height_of_display, int number_of_buffers, ...)
|
CRT::CRT(unsigned int cycles_per_line, unsigned int height_of_display, unsigned int number_of_buffers, ...)
|
||||||
{
|
{
|
||||||
set_new_timing(cycles_per_line, height_of_display);
|
set_new_timing(cycles_per_line, height_of_display);
|
||||||
|
|
||||||
// generate buffers for signal storage as requested — format is
|
// generate buffers for signal storage as requested — format is
|
||||||
// number of buffers, size of buffer 1, size of buffer 2...
|
// number of buffers, size of buffer 1, size of buffer 2...
|
||||||
const int bufferWidth = 2048;
|
const uint16_t bufferWidth = 2048;
|
||||||
const int bufferHeight = 2048;
|
const uint16_t bufferHeight = 2048;
|
||||||
for(int frame = 0; frame < sizeof(_frame_builders) / sizeof(*_frame_builders); frame++)
|
for(int frame = 0; frame < sizeof(_frame_builders) / sizeof(*_frame_builders); frame++)
|
||||||
{
|
{
|
||||||
va_list va;
|
va_list va;
|
||||||
@ -96,14 +96,14 @@ CRT::~CRT()
|
|||||||
|
|
||||||
#pragma mark - Sync loop
|
#pragma mark - Sync loop
|
||||||
|
|
||||||
CRT::SyncEvent CRT::get_next_vertical_sync_event(bool vsync_is_requested, int cycles_to_run_for, int *cycles_advanced)
|
CRT::SyncEvent CRT::get_next_vertical_sync_event(bool vsync_is_requested, unsigned int cycles_to_run_for, unsigned int *cycles_advanced)
|
||||||
{
|
{
|
||||||
SyncEvent proposedEvent = SyncEvent::None;
|
SyncEvent proposedEvent = SyncEvent::None;
|
||||||
int proposedSyncTime = cycles_to_run_for;
|
unsigned int proposedSyncTime = cycles_to_run_for;
|
||||||
|
|
||||||
// will an acceptable vertical sync be triggered?
|
// will an acceptable vertical sync be triggered?
|
||||||
if (vsync_is_requested && !_is_in_vsync) {
|
if (vsync_is_requested && !_is_in_vsync) {
|
||||||
if (_sync_capacitor_charge_level >= _sync_capacitor_charge_threshold && _rasterPosition.y >= (kCRTFixedPointRange * 7) >> 3) {
|
if (_sync_capacitor_charge_level >= _sync_capacitor_charge_threshold){// && _rasterPosition.y >= (kCRTFixedPointRange * 7) >> 3) {
|
||||||
proposedSyncTime = 0;
|
proposedSyncTime = 0;
|
||||||
proposedEvent = SyncEvent::StartVSync;
|
proposedEvent = SyncEvent::StartVSync;
|
||||||
_did_detect_vsync = true;
|
_did_detect_vsync = true;
|
||||||
@ -112,14 +112,14 @@ CRT::SyncEvent CRT::get_next_vertical_sync_event(bool vsync_is_requested, int cy
|
|||||||
|
|
||||||
// have we overrun the maximum permitted number of horizontal syncs for this frame?
|
// have we overrun the maximum permitted number of horizontal syncs for this frame?
|
||||||
if (!_is_in_vsync) {
|
if (!_is_in_vsync) {
|
||||||
int time_until_end_of_frame = (kCRTFixedPointRange - _rasterPosition.y) / _scanSpeed[0].y;
|
unsigned int time_until_end_of_frame = (kCRTFixedPointRange - _rasterPosition.y) / _scanSpeed[0].y;
|
||||||
|
|
||||||
if(time_until_end_of_frame < proposedSyncTime) {
|
if(time_until_end_of_frame < proposedSyncTime) {
|
||||||
proposedSyncTime = time_until_end_of_frame;
|
proposedSyncTime = time_until_end_of_frame;
|
||||||
proposedEvent = SyncEvent::StartVSync;
|
proposedEvent = SyncEvent::StartVSync;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
uint32_t time_until_start_of_frame = _rasterPosition.y / (uint32_t)(-_scanSpeed[kRetraceYMask].y);
|
unsigned int time_until_start_of_frame = _rasterPosition.y / (uint32_t)(-_scanSpeed[kRetraceYMask].y);
|
||||||
|
|
||||||
if(time_until_start_of_frame < proposedSyncTime) {
|
if(time_until_start_of_frame < proposedSyncTime) {
|
||||||
proposedSyncTime = time_until_start_of_frame;
|
proposedSyncTime = time_until_start_of_frame;
|
||||||
@ -131,20 +131,20 @@ CRT::SyncEvent CRT::get_next_vertical_sync_event(bool vsync_is_requested, int cy
|
|||||||
return proposedEvent;
|
return proposedEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
CRT::SyncEvent CRT::get_next_horizontal_sync_event(bool hsync_is_requested, int cycles_to_run_for, int *cycles_advanced)
|
CRT::SyncEvent CRT::get_next_horizontal_sync_event(bool hsync_is_requested, unsigned int cycles_to_run_for, unsigned int *cycles_advanced)
|
||||||
{
|
{
|
||||||
// do we recognise this hsync, thereby adjusting future time expectations?
|
// do we recognise this hsync, thereby adjusting future time expectations?
|
||||||
if(hsync_is_requested) {
|
if(hsync_is_requested) {
|
||||||
if (_horizontal_counter < _hsync_error_window || _horizontal_counter >= _expected_next_hsync - _hsync_error_window) {
|
if (_horizontal_counter < _hsync_error_window || _horizontal_counter >= _expected_next_hsync - _hsync_error_window) {
|
||||||
_did_detect_hsync = true;
|
_did_detect_hsync = true;
|
||||||
|
|
||||||
int time_now = (_horizontal_counter < _hsync_error_window) ? _expected_next_hsync + _horizontal_counter : _horizontal_counter;
|
unsigned int time_now = (_horizontal_counter < _hsync_error_window) ? _expected_next_hsync + _horizontal_counter : _horizontal_counter;
|
||||||
_expected_next_hsync = (_expected_next_hsync + _expected_next_hsync + _expected_next_hsync + time_now) >> 2;
|
_expected_next_hsync = (_expected_next_hsync + _expected_next_hsync + _expected_next_hsync + time_now) >> 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SyncEvent proposedEvent = SyncEvent::None;
|
SyncEvent proposedEvent = SyncEvent::None;
|
||||||
int proposedSyncTime = cycles_to_run_for;
|
unsigned int proposedSyncTime = cycles_to_run_for;
|
||||||
|
|
||||||
// will we end an ongoing hsync?
|
// will we end an ongoing hsync?
|
||||||
if (_horizontal_counter < _horizontal_retrace_time && _horizontal_counter+proposedSyncTime >= _horizontal_retrace_time) {
|
if (_horizontal_counter < _horizontal_retrace_time && _horizontal_counter+proposedSyncTime >= _horizontal_retrace_time) {
|
||||||
@ -162,7 +162,7 @@ CRT::SyncEvent CRT::get_next_horizontal_sync_event(bool hsync_is_requested, int
|
|||||||
return proposedEvent;
|
return proposedEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CRT::advance_cycles(int number_of_cycles, bool hsync_requested, bool vsync_requested, const bool vsync_charging, const Type type, const char *data_type)
|
void CRT::advance_cycles(unsigned int number_of_cycles, bool hsync_requested, bool vsync_requested, const bool vsync_charging, const Type type, const char *data_type)
|
||||||
{
|
{
|
||||||
number_of_cycles *= _time_multiplier;
|
number_of_cycles *= _time_multiplier;
|
||||||
|
|
||||||
@ -177,13 +177,13 @@ void CRT::advance_cycles(int number_of_cycles, bool hsync_requested, bool vsync_
|
|||||||
|
|
||||||
while(number_of_cycles) {
|
while(number_of_cycles) {
|
||||||
|
|
||||||
int time_until_vertical_sync_event, time_until_horizontal_sync_event;
|
unsigned int time_until_vertical_sync_event, time_until_horizontal_sync_event;
|
||||||
SyncEvent next_vertical_sync_event = this->get_next_vertical_sync_event(vsync_requested, number_of_cycles, &time_until_vertical_sync_event);
|
SyncEvent next_vertical_sync_event = this->get_next_vertical_sync_event(vsync_requested, number_of_cycles, &time_until_vertical_sync_event);
|
||||||
SyncEvent next_horizontal_sync_event = this->get_next_horizontal_sync_event(hsync_requested, time_until_vertical_sync_event, &time_until_horizontal_sync_event);
|
SyncEvent next_horizontal_sync_event = this->get_next_horizontal_sync_event(hsync_requested, time_until_vertical_sync_event, &time_until_horizontal_sync_event);
|
||||||
|
|
||||||
// get the next sync event and its timing; hsync request is instantaneous (being edge triggered) so
|
// get the next sync event and its timing; hsync request is instantaneous (being edge triggered) so
|
||||||
// set it to false for the next run through this loop (if any)
|
// set it to false for the next run through this loop (if any)
|
||||||
int next_run_length = std::min(time_until_vertical_sync_event, time_until_horizontal_sync_event);
|
unsigned int next_run_length = std::min(time_until_vertical_sync_event, time_until_horizontal_sync_event);
|
||||||
|
|
||||||
hsync_requested = false;
|
hsync_requested = false;
|
||||||
vsync_requested = false;
|
vsync_requested = false;
|
||||||
@ -252,7 +252,7 @@ void CRT::advance_cycles(int number_of_cycles, bool hsync_requested, bool vsync_
|
|||||||
if (vsync_charging && !_is_in_vsync)
|
if (vsync_charging && !_is_in_vsync)
|
||||||
_sync_capacitor_charge_level += next_run_length;
|
_sync_capacitor_charge_level += next_run_length;
|
||||||
else
|
else
|
||||||
_sync_capacitor_charge_level = std::max(_sync_capacitor_charge_level - next_run_length, 0);
|
_sync_capacitor_charge_level = std::max(_sync_capacitor_charge_level - (int)next_run_length, 0);
|
||||||
|
|
||||||
// react to the incoming event...
|
// react to the incoming event...
|
||||||
if(next_run_length == time_until_horizontal_sync_event)
|
if(next_run_length == time_until_horizontal_sync_event)
|
||||||
@ -337,28 +337,28 @@ void CRT::set_delegate(CRTDelegate *delegate)
|
|||||||
/*
|
/*
|
||||||
These all merely channel into advance_cycles, supplying appropriate arguments
|
These all merely channel into advance_cycles, supplying appropriate arguments
|
||||||
*/
|
*/
|
||||||
void CRT::output_sync(int number_of_cycles)
|
void CRT::output_sync(unsigned int number_of_cycles)
|
||||||
{
|
{
|
||||||
bool _hsync_requested = !_is_receiving_sync; // ensure this really is edge triggered; someone calling output_sync twice in succession shouldn't trigger it twice
|
bool _hsync_requested = !_is_receiving_sync; // ensure this really is edge triggered; someone calling output_sync twice in succession shouldn't trigger it twice
|
||||||
_is_receiving_sync = true;
|
_is_receiving_sync = true;
|
||||||
advance_cycles(number_of_cycles, _hsync_requested, false, true, Type::Sync, nullptr);
|
advance_cycles(number_of_cycles, _hsync_requested, false, true, Type::Sync, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CRT::output_blank(int number_of_cycles)
|
void CRT::output_blank(unsigned int number_of_cycles)
|
||||||
{
|
{
|
||||||
bool _vsync_requested = _is_receiving_sync;
|
bool _vsync_requested = _is_receiving_sync;
|
||||||
_is_receiving_sync = false;
|
_is_receiving_sync = false;
|
||||||
advance_cycles(number_of_cycles, false, _vsync_requested, false, Type::Blank, nullptr);
|
advance_cycles(number_of_cycles, false, _vsync_requested, false, Type::Blank, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CRT::output_level(int number_of_cycles, const char *type)
|
void CRT::output_level(unsigned int number_of_cycles, const char *type)
|
||||||
{
|
{
|
||||||
bool _vsync_requested = _is_receiving_sync;
|
bool _vsync_requested = _is_receiving_sync;
|
||||||
_is_receiving_sync = false;
|
_is_receiving_sync = false;
|
||||||
advance_cycles(number_of_cycles, false, _vsync_requested, false, Type::Level, type);
|
advance_cycles(number_of_cycles, false, _vsync_requested, false, Type::Level, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CRT::output_data(int number_of_cycles, const char *type)
|
void CRT::output_data(unsigned int number_of_cycles, const char *type)
|
||||||
{
|
{
|
||||||
bool _vsync_requested = _is_receiving_sync;
|
bool _vsync_requested = _is_receiving_sync;
|
||||||
_is_receiving_sync = false;
|
_is_receiving_sync = false;
|
||||||
@ -380,7 +380,7 @@ uint8_t *CRT::get_write_target_for_buffer(int buffer)
|
|||||||
|
|
||||||
#pragma mark - CRTFrame
|
#pragma mark - CRTFrame
|
||||||
|
|
||||||
CRTFrameBuilder::CRTFrameBuilder(int width, int height, int number_of_buffers, va_list buffer_sizes)
|
CRTFrameBuilder::CRTFrameBuilder(uint16_t width, uint16_t height, unsigned int number_of_buffers, va_list buffer_sizes)
|
||||||
{
|
{
|
||||||
frame.size.width = width;
|
frame.size.width = width;
|
||||||
frame.size.height = height;
|
frame.size.height = height;
|
||||||
@ -389,7 +389,7 @@ CRTFrameBuilder::CRTFrameBuilder(int width, int height, int number_of_buffers, v
|
|||||||
|
|
||||||
for(int buffer = 0; buffer < number_of_buffers; buffer++)
|
for(int buffer = 0; buffer < number_of_buffers; buffer++)
|
||||||
{
|
{
|
||||||
frame.buffers[buffer].depth = va_arg(buffer_sizes, int);
|
frame.buffers[buffer].depth = va_arg(buffer_sizes, unsigned int);
|
||||||
frame.buffers[buffer].data = new uint8_t[width * height * frame.buffers[buffer].depth];
|
frame.buffers[buffer].data = new uint8_t[width * height * frame.buffers[buffer].depth];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ class CRT;
|
|||||||
struct CRTFrameBuilder {
|
struct CRTFrameBuilder {
|
||||||
CRTFrame frame;
|
CRTFrame frame;
|
||||||
|
|
||||||
CRTFrameBuilder(int width, int height, int number_of_buffers, va_list buffer_sizes);
|
CRTFrameBuilder(uint16_t width, uint16_t height, unsigned int number_of_buffers, va_list buffer_sizes);
|
||||||
~CRTFrameBuilder();
|
~CRTFrameBuilder();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -39,24 +39,24 @@ struct CRTFrameBuilder {
|
|||||||
|
|
||||||
// a pointer to the section of content buffer currently being
|
// a pointer to the section of content buffer currently being
|
||||||
// returned and to where the next section will begin
|
// returned and to where the next section will begin
|
||||||
int _next_write_x_position, _next_write_y_position;
|
uint16_t _next_write_x_position, _next_write_y_position;
|
||||||
int _write_x_position, _write_y_position;
|
uint16_t _write_x_position, _write_y_position;
|
||||||
int _write_target_pointer;
|
unsigned int _write_target_pointer;
|
||||||
};
|
};
|
||||||
|
|
||||||
static const int kCRTNumberOfFrames = 4;
|
static const int kCRTNumberOfFrames = 4;
|
||||||
|
|
||||||
class CRT {
|
class CRT {
|
||||||
public:
|
public:
|
||||||
CRT(int cycles_per_line, int height_of_display, int number_of_buffers, ...);
|
CRT(unsigned int cycles_per_line, unsigned int height_of_display, unsigned int number_of_buffers, ...);
|
||||||
~CRT();
|
~CRT();
|
||||||
|
|
||||||
void set_new_timing(int cycles_per_line, int height_of_display);
|
void set_new_timing(unsigned int cycles_per_line, unsigned int height_of_display);
|
||||||
|
|
||||||
void output_sync(int number_of_cycles);
|
void output_sync(unsigned int number_of_cycles);
|
||||||
void output_blank(int number_of_cycles);
|
void output_blank(unsigned int number_of_cycles);
|
||||||
void output_level(int number_of_cycles, const char *type);
|
void output_level(unsigned int number_of_cycles, const char *type);
|
||||||
void output_data(int number_of_cycles, const char *type);
|
void output_data(unsigned int number_of_cycles, const char *type);
|
||||||
|
|
||||||
class CRTDelegate {
|
class CRTDelegate {
|
||||||
public:
|
public:
|
||||||
@ -71,14 +71,14 @@ class CRT {
|
|||||||
private:
|
private:
|
||||||
// the incoming clock lengths will be multiplied by something to give at least 1000
|
// the incoming clock lengths will be multiplied by something to give at least 1000
|
||||||
// sample points per line
|
// sample points per line
|
||||||
int _time_multiplier;
|
unsigned int _time_multiplier;
|
||||||
|
|
||||||
// fundamental creator-specified properties
|
// fundamental creator-specified properties
|
||||||
int _cycles_per_line;
|
unsigned int _cycles_per_line;
|
||||||
int _height_of_display;
|
unsigned int _height_of_display;
|
||||||
|
|
||||||
// properties directly derived from there
|
// properties directly derived from there
|
||||||
int _hsync_error_window; // the permitted window around the expected sync position in which a sync pulse will be recognised; calculated once at init
|
unsigned int _hsync_error_window; // the permitted window around the expected sync position in which a sync pulse will be recognised; calculated once at init
|
||||||
|
|
||||||
// the current scanning position
|
// the current scanning position
|
||||||
struct Vector {
|
struct Vector {
|
||||||
@ -100,9 +100,9 @@ class CRT {
|
|||||||
int _is_in_vsync;
|
int _is_in_vsync;
|
||||||
|
|
||||||
// components of the flywheel sync
|
// components of the flywheel sync
|
||||||
int _horizontal_counter; // time run since the _start_ of the last horizontal sync
|
unsigned int _horizontal_counter; // time run since the _start_ of the last horizontal sync
|
||||||
int _expected_next_hsync; // our current expection of when the next horizontal sync will be encountered (which implies current flywheel velocity)
|
unsigned int _expected_next_hsync; // our current expection of when the next horizontal sync will be encountered (which implies current flywheel velocity)
|
||||||
int _horizontal_retrace_time;
|
unsigned int _horizontal_retrace_time;
|
||||||
bool _is_in_hsync; // true for the duration of a horizontal sync — used to determine beam running direction and speed
|
bool _is_in_hsync; // true for the duration of a horizontal sync — used to determine beam running direction and speed
|
||||||
bool _did_detect_vsync; // true if vertical sync was detected in the input stream rather than forced by emergency measure
|
bool _did_detect_vsync; // true if vertical sync was detected in the input stream rather than forced by emergency measure
|
||||||
|
|
||||||
@ -110,7 +110,7 @@ class CRT {
|
|||||||
enum Type {
|
enum Type {
|
||||||
Sync, Level, Data, Blank
|
Sync, Level, Data, Blank
|
||||||
} type;
|
} type;
|
||||||
void advance_cycles(int number_of_cycles, bool hsync_requested, bool vsync_requested, bool vsync_charging, Type type, const char *data_type);
|
void advance_cycles(unsigned int number_of_cycles, bool hsync_requested, bool vsync_requested, bool vsync_charging, Type type, const char *data_type);
|
||||||
|
|
||||||
// the inner entry point that determines whether and when the next sync event will occur within
|
// the inner entry point that determines whether and when the next sync event will occur within
|
||||||
// the current output window
|
// the current output window
|
||||||
@ -119,8 +119,8 @@ class CRT {
|
|||||||
StartHSync, EndHSync,
|
StartHSync, EndHSync,
|
||||||
StartVSync, EndVSync
|
StartVSync, EndVSync
|
||||||
};
|
};
|
||||||
SyncEvent get_next_vertical_sync_event(bool vsync_is_requested, int cycles_to_run_for, int *cycles_advanced);
|
SyncEvent get_next_vertical_sync_event(bool vsync_is_requested, unsigned int cycles_to_run_for, unsigned int *cycles_advanced);
|
||||||
SyncEvent get_next_horizontal_sync_event(bool hsync_is_requested, int cycles_to_run_for, int *cycles_advanced);
|
SyncEvent get_next_horizontal_sync_event(bool hsync_is_requested, unsigned int cycles_to_run_for, unsigned int *cycles_advanced);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,20 +15,20 @@ extern "C" {
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t *data;
|
uint8_t *data;
|
||||||
int depth;
|
unsigned int depth;
|
||||||
} CRTBuffer;
|
} CRTBuffer;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int width, height;
|
uint16_t width, height;
|
||||||
} CRTSize;
|
} CRTSize;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
CRTSize size, dirty_size;
|
CRTSize size, dirty_size;
|
||||||
|
|
||||||
int number_of_buffers;
|
unsigned int number_of_buffers;
|
||||||
CRTBuffer *buffers;
|
CRTBuffer *buffers;
|
||||||
|
|
||||||
int number_of_runs;
|
unsigned int number_of_runs;
|
||||||
uint8_t *runs;
|
uint8_t *runs;
|
||||||
} CRTFrame;
|
} CRTFrame;
|
||||||
|
|
||||||
|
@ -576,17 +576,17 @@ template <class T> class Processor {
|
|||||||
|
|
||||||
case OperationCMP: {
|
case OperationCMP: {
|
||||||
const uint16_t temp16 = _a - _operand;
|
const uint16_t temp16 = _a - _operand;
|
||||||
_negativeResult = _zeroResult = temp16;
|
_negativeResult = _zeroResult = (uint8_t)temp16;
|
||||||
_carryFlag = ((~temp16) >> 8)&1;
|
_carryFlag = ((~temp16) >> 8)&1;
|
||||||
} break;
|
} break;
|
||||||
case OperationCPX: {
|
case OperationCPX: {
|
||||||
const uint16_t temp16 = _x - _operand;
|
const uint16_t temp16 = _x - _operand;
|
||||||
_negativeResult = _zeroResult = temp16;
|
_negativeResult = _zeroResult = (uint8_t)temp16;
|
||||||
_carryFlag = ((~temp16) >> 8)&1;
|
_carryFlag = ((~temp16) >> 8)&1;
|
||||||
} break;
|
} break;
|
||||||
case OperationCPY: {
|
case OperationCPY: {
|
||||||
const uint16_t temp16 = _y - _operand;
|
const uint16_t temp16 = _y - _operand;
|
||||||
_negativeResult = _zeroResult = temp16;
|
_negativeResult = _zeroResult = (uint8_t)temp16;
|
||||||
_carryFlag = ((~temp16) >> 8)&1;
|
_carryFlag = ((~temp16) >> 8)&1;
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
@ -614,13 +614,13 @@ template <class T> class Processor {
|
|||||||
temp16 += (_a&0xf0) - (_operand&0xf0);
|
temp16 += (_a&0xf0) - (_operand&0xf0);
|
||||||
|
|
||||||
_overflowFlag = ( ( (decimalResult^_a)&(~decimalResult^_operand) )&0x80) >> 1;
|
_overflowFlag = ( ( (decimalResult^_a)&(~decimalResult^_operand) )&0x80) >> 1;
|
||||||
_negativeResult = temp16;
|
_negativeResult = (uint8_t)temp16;
|
||||||
_zeroResult = decimalResult;
|
_zeroResult = (uint8_t)decimalResult;
|
||||||
|
|
||||||
if(temp16 > 0xff) temp16 -= 0x60;
|
if(temp16 > 0xff) temp16 -= 0x60;
|
||||||
|
|
||||||
_carryFlag = (temp16 > 0xff) ? 0 : Flag::Carry;
|
_carryFlag = (temp16 > 0xff) ? 0 : Flag::Carry;
|
||||||
_a = temp16;
|
_a = (uint8_t)temp16;
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
_operand = ~_operand;
|
_operand = ~_operand;
|
||||||
@ -637,17 +637,17 @@ template <class T> class Processor {
|
|||||||
temp16 = (temp16&0x0f) + ((temp16 > 0x0f) ? 0x10 : 0x00) + (_a&0xf0) + (_operand&0xf0);
|
temp16 = (temp16&0x0f) + ((temp16 > 0x0f) ? 0x10 : 0x00) + (_a&0xf0) + (_operand&0xf0);
|
||||||
|
|
||||||
_overflowFlag = (( (decimalResult^_a)&(decimalResult^_operand) )&0x80) >> 1;
|
_overflowFlag = (( (decimalResult^_a)&(decimalResult^_operand) )&0x80) >> 1;
|
||||||
_negativeResult = temp16;
|
_negativeResult = (uint8_t)temp16;
|
||||||
_zeroResult = decimalResult;
|
_zeroResult = (uint8_t)decimalResult;
|
||||||
|
|
||||||
if(temp16 > 0x9f) temp16 += 0x60;
|
if(temp16 > 0x9f) temp16 += 0x60;
|
||||||
|
|
||||||
_carryFlag = (temp16 > 0xff) ? Flag::Carry : 0;
|
_carryFlag = (temp16 > 0xff) ? Flag::Carry : 0;
|
||||||
_a = temp16;
|
_a = (uint8_t)temp16;
|
||||||
} else {
|
} else {
|
||||||
const uint16_t decimalResult = (uint16_t)_a + (uint16_t)_operand + (uint16_t)_carryFlag;
|
const uint16_t decimalResult = (uint16_t)_a + (uint16_t)_operand + (uint16_t)_carryFlag;
|
||||||
_overflowFlag = (( (decimalResult^_a)&(decimalResult^_operand) )&0x80) >> 1;
|
_overflowFlag = (( (decimalResult^_a)&(decimalResult^_operand) )&0x80) >> 1;
|
||||||
_negativeResult = _zeroResult = _a = decimalResult;
|
_negativeResult = _zeroResult = _a = (uint8_t)decimalResult;
|
||||||
_carryFlag = (decimalResult >> 8)&1;
|
_carryFlag = (decimalResult >> 8)&1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -671,13 +671,13 @@ template <class T> class Processor {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case OperationROL: {
|
case OperationROL: {
|
||||||
const uint8_t temp8 = (_operand << 1) | _carryFlag;\
|
const uint8_t temp8 = (uint8_t)((_operand << 1) | _carryFlag);
|
||||||
_carryFlag = _operand >> 7;\
|
_carryFlag = _operand >> 7;
|
||||||
_operand = _negativeResult = _zeroResult = temp8;
|
_operand = _negativeResult = _zeroResult = temp8;
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case OperationRLA: {
|
case OperationRLA: {
|
||||||
const uint8_t temp8 = (_operand << 1) | _carryFlag;
|
const uint8_t temp8 = (uint8_t)((_operand << 1) | _carryFlag);
|
||||||
_carryFlag = _operand >> 7;
|
_carryFlag = _operand >> 7;
|
||||||
_operand = temp8;
|
_operand = temp8;
|
||||||
_a &= _operand;
|
_a &= _operand;
|
||||||
@ -705,13 +705,13 @@ template <class T> class Processor {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case OperationROR: {
|
case OperationROR: {
|
||||||
const uint8_t temp8 = (_operand >> 1) | (_carryFlag << 7);
|
const uint8_t temp8 = (uint8_t)((_operand >> 1) | (_carryFlag << 7));
|
||||||
_carryFlag = _operand & 1;
|
_carryFlag = _operand & 1;
|
||||||
_operand = _negativeResult = _zeroResult = temp8;
|
_operand = _negativeResult = _zeroResult = temp8;
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case OperationRRA: {
|
case OperationRRA: {
|
||||||
const uint8_t temp8 = (_operand >> 1) | (_carryFlag << 7);
|
const uint8_t temp8 = (uint8_t)((_operand >> 1) | (_carryFlag << 7));
|
||||||
_carryFlag = _operand & 1;
|
_carryFlag = _operand & 1;
|
||||||
_operand = temp8;
|
_operand = temp8;
|
||||||
} break;
|
} break;
|
||||||
@ -849,7 +849,7 @@ template <class T> class Processor {
|
|||||||
case OperationBEQ: BRA(!_zeroResult); break;
|
case OperationBEQ: BRA(!_zeroResult); break;
|
||||||
|
|
||||||
case CycleAddSignedOperandToPC:
|
case CycleAddSignedOperandToPC:
|
||||||
_nextAddress.full = _pc.full + (int8_t)_operand;
|
_nextAddress.full = (uint16_t)(_pc.full + (int8_t)_operand);
|
||||||
_pc.bytes.low = _nextAddress.bytes.low;
|
_pc.bytes.low = _nextAddress.bytes.low;
|
||||||
if(_nextAddress.bytes.high != _pc.bytes.high) {
|
if(_nextAddress.bytes.high != _pc.bytes.high) {
|
||||||
uint16_t halfUpdatedPc = _pc.full;
|
uint16_t halfUpdatedPc = _pc.full;
|
||||||
@ -873,7 +873,7 @@ template <class T> class Processor {
|
|||||||
if(_decimalFlag) {
|
if(_decimalFlag) {
|
||||||
_a &= _operand;
|
_a &= _operand;
|
||||||
uint8_t unshiftedA = _a;
|
uint8_t unshiftedA = _a;
|
||||||
_a = (_a >> 1) | (_carryFlag << 7);
|
_a = (uint8_t)((_a >> 1) | (_carryFlag << 7));
|
||||||
_zeroResult = _negativeResult = _a;
|
_zeroResult = _negativeResult = _a;
|
||||||
_overflowFlag = (_a^(_a << 1))&Flag::Overflow;
|
_overflowFlag = (_a^(_a << 1))&Flag::Overflow;
|
||||||
|
|
||||||
@ -884,7 +884,7 @@ template <class T> class Processor {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
_a &= _operand;
|
_a &= _operand;
|
||||||
_a = (_a >> 1) | (_carryFlag << 7);
|
_a = (uint8_t)((_a >> 1) | (_carryFlag << 7));
|
||||||
_negativeResult = _zeroResult = _a;
|
_negativeResult = _zeroResult = _a;
|
||||||
_carryFlag = (_a >> 6)&1;
|
_carryFlag = (_a >> 6)&1;
|
||||||
_overflowFlag = (_a^(_a << 1))&Flag::Overflow;
|
_overflowFlag = (_a^(_a << 1))&Flag::Overflow;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user