// Loosely following the structure in z26/2600core.c::ScanFrame() void simulate_single_frame(const uint8_t* byte_code, size_t size, uint8_t* output_picture) { struct z26_state* s = init_z26_state(output_picture); s->ROM_data = byte_code; s->ROM_size = size; // Simulate frame. while (s->Frame == 0) { nTIALineTo(s); ++s->ScanLine; s->RClock -= CYCLESPERSCANLINE; } // Clean up. free(s); }
void ScanFrame() { /* Reset display pointer */ ScreenBuffer = DisplayPointer; do { /* Generate a raster line */ nTIALineTo(); ScanLine++; /* adjust RClock for next line */ RClock -= 76; /* if charging capacitors... */ if( !(VBlank & 0x80) ) /* and if not fully charged... */ if(ChargeCounter < 0x80000000) /* add some charge. */ ChargeCounter++; if( ScanLine >= OurBailoutLine) { BailoutLine = OurBailoutLine; PrevLinesInFrame = LinesInFrame; LinesInFrame = ScanLine-1; Frame++; ScanLine = 1; } } while (Frame == PrevFrame); /* Frame gets updated by tiawrite.asm */ /* Done with frame. Blank rest of screen buffer, update PrevFrame, and return to caller. */ BlankBufferEnd(); Frame = PrevFrame; }