Skip to content

Commit

Permalink
Merge pull request #5 from fhoedemakers/develop
Browse files Browse the repository at this point in the history
#4 proper refresh rate and vsync
  • Loading branch information
fhoedemakers authored Mar 23, 2023
2 parents 832b204 + 18042d3 commit d075830
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
13 changes: 3 additions & 10 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,6 @@ void InfoNES_PadState(DWORD *pdwPad1, DWORD *pdwPad2, DWORD *pdwSystem)

if (pushed & X)
{
printf("PrevButtons: %d\n", prevButtons);
printf("Pushed: %d\n", pushed) ;
printf("%d\n", fps);
}

Expand Down Expand Up @@ -451,17 +449,12 @@ int InfoNES_LoadFrame()
{

auto count = frame++;
auto onOff = hw_divider_s32_quotient_inlined(count, 60) & 1;
#ifdef LED_ENABLED
auto onOff = hw_divider_s32_quotient_inlined(count, 60) & 1;
gpio_put(LED_PIN, onOff);
#endif
// Not sure if i'm doing the right thing here...
// _wait_vsync() makes it run at 41 fps which is too slow for the emulator
// picosystem::_wait_vsync();
// not waiting for vsync goes to 80 frames per second.
// Delay 4 milliseconds (4000 microseconds) in order to reach a 60 fps cap.
// sleep_ms() does not work.
busy_wait_us_32(4000);
// Wait for vsync to pace emulator at 60fps as suggested by shuichitakano in issue #4, thanks!
picosystem::_wait_vsync();
uint32_t tick_us = picosystem::time_us() - start_tick_us;
// calculate fps and round to nearest value (instead of truncating/floor)
fps = (1000000 - 1) / tick_us + 1;
Expand Down
2 changes: 1 addition & 1 deletion picosystem/hardware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ namespace picosystem {
_screen_command(VRHS, 1, "\x12");
_screen_command(VDVS, 1, "\x20");
_screen_command(PWRCTRL1, 2, "\xA4\xA1");
_screen_command(FRCTRL2, 1, "\x1E");
_screen_command(FRCTRL2, 1, "\x0F"); // 60 FPS as Suggested by shuichitakano in issue #4, thanks!
_screen_command(GMCTRP1, 14, "\xD0\x04\x0D\x11\x13\x2B\x3F\x54\x4C\x18\x0D\x0B\x1F\x23");
_screen_command(GMCTRN1, 14, "\xD0\x04\x0C\x11\x13\x2C\x3F\x44\x51\x2F\x1F\x1F\x20\x23");
_screen_command(INVON);
Expand Down

0 comments on commit d075830

Please sign in to comment.