Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: return to frontend after certain number of CPU cycles #89

Open
deltabeard opened this issue May 26, 2023 · 1 comment
Open

core: return to frontend after certain number of CPU cycles #89

deltabeard opened this issue May 26, 2023 · 1 comment
Labels
diff: complex A difficult issue; may require significant planning. enhancement New feature or request
Milestone

Comments

@deltabeard
Copy link
Owner

Currently, Peanut-GB uses gb_run_frame() to emulate the Game Boy and returns after a frame is drawn. If the LCD is set to off, then this function would not return until the game turns the LCD back on again. On a real Game Boy, this would result in a delay (typically small). But Peanut-GB skips this delay.

Peanut-GB should return to the frontend after a certain number of CPU cycles (eg. the number of cycles that it would take for a frame to be drawn).

@deltabeard deltabeard added enhancement New feature or request diff: complex A difficult issue; may require significant planning. labels May 26, 2023
@deltabeard deltabeard added this to the v3 milestone May 26, 2023
@deltabeard
Copy link
Owner Author

When checking whether the LCD is switched on/off using if(!(gb->hram_io[IO_LCDC] & LCDC_ENABLE)), an internal variable should be incremented to keep track of the duration of time that the LCD is switched off (including the number of LCD ticks before it was switched off before HBlank). When this internal variable reaches the same amount of time as a single frame, then Peanut-GB should set gb->gb_frame and return as if a new frame has been drawn.

This internal variable should not be cleared when the LCD is switched on, since the time the LCD is switched off might be less than a frame. In this case, this delay should be propagated until the "frame skip" occurs when the LCD has been switched off for long enough to be equal to a single frame.

@deltabeard deltabeard modified the milestones: v3, v1.4.0 Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
diff: complex A difficult issue; may require significant planning. enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant