Added the GB_run_frame API; closes #5.
This commit is contained in:
parent
22d3510dde
commit
b858f17425
20
Core/gb.c
20
Core/gb.c
@ -416,6 +416,26 @@ void GB_run(GB_gameboy_t *gb)
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t GB_run_frame(GB_gameboy_t *gb)
|
||||
{
|
||||
/* Configure turbo temporarily, the user wants to handle FPS capping manually. */
|
||||
bool old_turbo = gb->turbo;
|
||||
bool old_dont_skip = gb->turbo_dont_skip;
|
||||
gb->turbo = true;
|
||||
gb->turbo_dont_skip = true;
|
||||
|
||||
gb->cycles_since_last_sync = 0;
|
||||
while (true) {
|
||||
GB_run(gb);
|
||||
if (gb->vblank_just_occured) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
gb->turbo = old_turbo;
|
||||
gb->turbo_dont_skip = old_dont_skip;
|
||||
return gb->cycles_since_last_sync * FRAME_LENGTH * LCDC_PERIOD;
|
||||
}
|
||||
|
||||
void GB_set_pixels_output(GB_gameboy_t *gb, uint32_t *output)
|
||||
{
|
||||
gb->screen = output;
|
||||
|
@ -491,6 +491,8 @@ void GB_free(GB_gameboy_t *gb);
|
||||
void GB_reset(GB_gameboy_t *gb);
|
||||
void GB_switch_model_and_reset(GB_gameboy_t *gb, bool is_cgb);
|
||||
void GB_run(GB_gameboy_t *gb);
|
||||
/* Returns the time passed since the last frame, in nanoseconds */
|
||||
uint64_t GB_run_frame(GB_gameboy_t *gb);
|
||||
|
||||
typedef enum {
|
||||
GB_DIRECT_ACCESS_ROM,
|
||||
|
Loading…
Reference in New Issue
Block a user