Fix emulator build script, UI rendering, and clean up repo
This commit is contained in:
33
basic1.cpp
33
basic1.cpp
@@ -573,10 +573,11 @@ int main()
|
||||
uint32_t last_frame_time = 0;
|
||||
|
||||
bool needs_refresh = false; // Track if screen needs redraw
|
||||
bool dirty_rect_opt_state = (display->get_type() == DISPLAY_TYPE_ST7796);
|
||||
|
||||
while (1) {
|
||||
// 0. Process serial uploads (for rapid game iteration)
|
||||
serial_uploader.process();
|
||||
serial_uploader.process(is_refresh_in_progress());
|
||||
|
||||
// If serial uploader wants to launch a game, wait until it's safe (no display refresh)
|
||||
if (serial_uploader.wants_to_launch_game() && !is_refresh_in_progress()) {
|
||||
@@ -645,7 +646,7 @@ int main()
|
||||
launcher.reset();
|
||||
needs_refresh = true;
|
||||
// Force full clear for clean transition
|
||||
display->clear(false);
|
||||
// display->clear(false); // Unsafe while Core 1 might be busy
|
||||
if (display->get_type() == DISPLAY_TYPE_EPAPER) {
|
||||
LowLevelDisplayEPaper* epaper = static_cast<LowLevelDisplayEPaper*>(display);
|
||||
epaper->full_refresh();
|
||||
@@ -667,7 +668,7 @@ int main()
|
||||
launcher.reset();
|
||||
needs_refresh = true;
|
||||
// Force full clear for clean transition
|
||||
display->clear(false);
|
||||
// display->clear(false); // Unsafe while Core 1 might be busy
|
||||
if (display->get_type() == DISPLAY_TYPE_EPAPER) {
|
||||
LowLevelDisplayEPaper* epaper = static_cast<LowLevelDisplayEPaper*>(display);
|
||||
epaper->full_refresh();
|
||||
@@ -677,12 +678,19 @@ int main()
|
||||
}
|
||||
} else {
|
||||
// In launcher mode - process menu input
|
||||
|
||||
// Wait for any active display refresh to finish before potentially loading a game (SD Card I/O)
|
||||
// This prevents SPI bus conflicts between Core 0 (SD Card) and Core 1 (Display)
|
||||
while (is_refresh_in_progress()) {
|
||||
sleep_us(100);
|
||||
}
|
||||
|
||||
bool game_selected = launcher.update(input);
|
||||
if (game_selected) {
|
||||
printf("Game launched successfully\n");
|
||||
game_start_time = 0;
|
||||
// Force full clear for clean transition to game
|
||||
display->clear(false);
|
||||
// display->clear(false); // Unsafe while Core 1 might be busy
|
||||
// if (display->get_type() == DISPLAY_TYPE_EPAPER) {
|
||||
// LowLevelDisplayEPaper* epaper = static_cast<LowLevelDisplayEPaper*>(display);
|
||||
// epaper->full_refresh();
|
||||
@@ -714,6 +722,23 @@ int main()
|
||||
if (time_since_last_frame >= TARGET_FRAME_TIME_MS) {
|
||||
// Only draw if Core 1 is finished with the buffer
|
||||
if (!is_refresh_in_progress()) {
|
||||
// Update dirty rectangle optimization based on continuous updates
|
||||
if (display->get_type() == DISPLAY_TYPE_ST7796) {
|
||||
bool wants_opt = false;
|
||||
if (launcher.is_game_selected()) {
|
||||
Game* g = launcher.get_selected_game();
|
||||
if (g && g->wants_frame_updates()) {
|
||||
wants_opt = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (dirty_rect_opt_state != wants_opt) {
|
||||
LowLevelDisplayST7796* st7796_display = static_cast<LowLevelDisplayST7796*>(display);
|
||||
st7796_display->enable_dirty_rect(wants_opt);
|
||||
dirty_rect_opt_state = wants_opt;
|
||||
}
|
||||
}
|
||||
|
||||
// Clear buffer and redraw entire UI with updated state
|
||||
memset(bit_buffer, 0, V_WIDTH * V_HEIGHT / 8);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user