Skip to content

Commit

Permalink
Clear error flag after hardware echo check
Browse files Browse the repository at this point in the history
  • Loading branch information
joeyparrish committed Sep 15, 2024
1 parent 05133d9 commit 668c0a4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
6 changes: 6 additions & 0 deletions software/player/inc/segavideo_menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,18 @@ void segavideo_menu_nextItem();
bool segavideo_menu_select(bool loop);

// Is there a pending error or an error already on screen?
// This is not valid until after segavideo_menu_checkHardware() has succeeded.
// Before that time, the state of the error flag is undefined.
bool segavideo_menu_hasError();

// Show the error.
// This is not valid until after segavideo_menu_checkHardware() has succeeded.
// Before that time, the state of the error flag is undefined.
void segavideo_menu_showError();

// Clear the error state and screen.
// The error is automatically cleared during a successful call to
// segavideo_menu_checkHardware().
void segavideo_menu_clearError();

#endif // _SEGAVIDEO_MENU_H
33 changes: 16 additions & 17 deletions software/player/src/segavideo_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,14 +270,25 @@ static void loadMenuColors() {
PAL_setColors(PAL_YELLOW * 16 + 1, &yellow, /* count= */ 1, CPU);
}

static void drawLogo() {
VDP_drawImageEx(
BG_B, &kinetoscope_logo,
TILE_ATTR_FULL(PAL_LOGO, FALSE, FALSE, FALSE, LOGO_TILE_INDEX),
LOGO_X, LOGO_Y,
/* load palette */ TRUE,
CPU);

// It's not clear to me what is overwriting these palettes, but reloading at
// this point fixes them.
loadMenuColors();
}

void segavideo_menu_init() {
kprintf("segavideo_menu_init\n");

// Clear the error flag, which may boot up in a random state.
clearPendingError();

// Load menu palettes.
loadMenuColors();
clearScreen();
drawLogo();

// Allocate menu line pointers.
menuLines = (char**)MEM_alloc(sizeof(char*) * MAX_CATALOG_SIZE);
Expand All @@ -293,19 +304,6 @@ void segavideo_menu_init() {
menuChanged = false;
}

static void drawLogo() {
VDP_drawImageEx(
BG_B, &kinetoscope_logo,
TILE_ATTR_FULL(PAL_LOGO, FALSE, FALSE, FALSE, LOGO_TILE_INDEX),
LOGO_X, LOGO_Y,
/* load palette */ TRUE,
CPU);

// It's not clear to me what is overwriting these palettes, but reloading at
// this point fixes them.
loadMenuColors();
}

static void drawInstructions() {
VDP_drawText("Choose a video", INSTRUCTIONS_X, INSTRUCTIONS_Y);
VDP_drawText(" Press start ", INSTRUCTIONS_X, INSTRUCTIONS_Y + 2);
Expand Down Expand Up @@ -357,6 +355,7 @@ bool segavideo_menu_checkHardware() {
statusMessage("Kinetoscope cartridge detected!");
#endif

clearPendingError();
waitMs(1000);
return true;
}
Expand Down

0 comments on commit 668c0a4

Please sign in to comment.