1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-26 08:49:37 +00:00

Fixed runaway frame generator.

This commit is contained in:
Thomas Harte 2016-01-10 23:32:57 -05:00
parent 93f7df04a0
commit ce916ebd6a
2 changed files with 18 additions and 4 deletions

View File

@ -170,6 +170,7 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin
{ {
update_display(); update_display();
_frameCycles = 0; _frameCycles = 0;
_outputPosition = 0;
} }
if(_frameCycles == 128*128) signal_interrupt(InterruptRealTimeClock); if(_frameCycles == 128*128) signal_interrupt(InterruptRealTimeClock);
if(_frameCycles == 284*128) signal_interrupt(InterruptDisplayEnd); if(_frameCycles == 284*128) signal_interrupt(InterruptDisplayEnd);
@ -249,7 +250,7 @@ inline void Machine::update_display()
if(line_position == 9) if(line_position == 9)
{ {
_crt->output_blank(119 * crt_cycles_multiplier); _crt->output_blank(119 * crt_cycles_multiplier);
_outputPosition = (_outputPosition + 119) % cycles_per_frame;; _outputPosition += 119;
} }
} }
else else
@ -290,8 +291,7 @@ inline void Machine::update_display()
if(line_position == 104) if(line_position == 104)
{ {
if(!((current_line - 27)%8)) if(!((current_line - 27)&7))
// if(!((current_line - 27)&7))
{ {
_startLineAddress += 40*8 - 7; _startLineAddress += 40*8 - 7;
} }
@ -314,7 +314,7 @@ const char *Machine::get_signal_decoder()
return return
"vec4 sample(vec2 coordinate)\n" "vec4 sample(vec2 coordinate)\n"
"{\n" "{\n"
"float texValue = texture(texID, srcCoordinatesVarying).r;" // step(mod(texValue, 4.0), 2.0) "float texValue = texture(texID, srcCoordinatesVarying).r;\n"
"return vec4( step(mod(texValue, 8.0/256.0), 4.0/256.0), step(mod(texValue, 4.0/256.0), 2.0/256.0), step(mod(texValue, 2.0/256.0), 1.0/256.0), 1.0);\n" "return vec4( step(mod(texValue, 8.0/256.0), 4.0/256.0), step(mod(texValue, 4.0/256.0), 2.0/256.0), step(mod(texValue, 2.0/256.0), 1.0/256.0), 1.0);\n"
"}"; "}";
} }

View File

@ -26,6 +26,9 @@ typedef NS_ENUM(NSInteger, CSAtari2600RunningState) {
dispatch_queue_t _serialDispatchQueue; dispatch_queue_t _serialDispatchQueue;
NSConditionLock *_runningLock; NSConditionLock *_runningLock;
int _frameCount;
NSTimeInterval _firstFrame;
} }
- (void)perform:(dispatch_block_t)action { - (void)perform:(dispatch_block_t)action {
@ -34,6 +37,17 @@ typedef NS_ENUM(NSInteger, CSAtari2600RunningState) {
- (void)crt:(Outputs::CRT *)crt didEndFrame:(CRTFrame *)frame didDetectVSync:(BOOL)didDetectVSync { - (void)crt:(Outputs::CRT *)crt didEndFrame:(CRTFrame *)frame didDetectVSync:(BOOL)didDetectVSync {
if([self.view pushFrame:frame]) crt->return_frame(); if([self.view pushFrame:frame]) crt->return_frame();
if(!_frameCount) _firstFrame = [NSDate timeIntervalSinceReferenceDate];
_frameCount++;
// NSLog(@"!-!");
if(!(_frameCount%50))
{
NSTimeInterval timeSinceFirstFrame = [NSDate timeIntervalSinceReferenceDate] - _firstFrame;
NSLog(@"%d in %0.2f: %0.2f", _frameCount, timeSinceFirstFrame, (double)_frameCount / timeSinceFirstFrame);
}
} }
- (void)runForNumberOfCycles:(int)cycles { - (void)runForNumberOfCycles:(int)cycles {