Skip to content

Commit

Permalink
Expand self-tests around catalog data
Browse files Browse the repository at this point in the history
  • Loading branch information
joeyparrish committed Nov 15, 2024
1 parent dfd1a99 commit cb9a65a
Showing 1 changed file with 88 additions and 51 deletions.
139 changes: 88 additions & 51 deletions software/hardware-test/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <genesis.h>

#include "menu_font.h"
#include "segavideo_format.h"
#include "segavideo_menu.h"
#include "segavideo_player.h"

Expand All @@ -35,6 +36,9 @@
#define PAL_WHITE PAL2
#define PAL_YELLOW PAL3

// Maximum number of entries in a video catalog file.
#define MAX_CATALOG_SIZE 127

// Macros to complete sram_march_test in sram-common.h
char march_error_1[256];
char march_error_2[256];
Expand Down Expand Up @@ -259,57 +263,7 @@ int main(bool hardReset) {
}


// 13. Perform various intensive memory tests through the firmware.
// There are many different passes of this, with different patterns to verify.
line++; // blank line
int memory_test_pass_line = line;
line += 2;
int memory_test_error_line = line;
line += 2;

VDP_setTextPalette(PAL_WHITE);
// 0 1
// 012345678901234567
VDP_drawText("SRAM test pass 00", 0, memory_test_pass_line);
VDP_drawText("......................", 1, memory_test_pass_line + 1);

for (int pass = 0; pass < SRAM_MARCH_TEST_NUM_PASSES; ++pass) {
waitMs(1);
*KINETOSCOPE_PORT_COMMAND = CMD_MARCH_TEST;
*KINETOSCOPE_PORT_ARG = pass;
waitMs(1);
*KINETOSCOPE_PORT_TOKEN = 1;

VDP_setTextPalette(PAL_WHITE);
char counter[3] = {
'0' + ((pass / 10) % 10),
'0' + (pass % 10),
'\0',
};
VDP_drawText(counter, 15, memory_test_pass_line);
// "!": indicates that the uC is filling the SRAM with data.
VDP_drawText("!", pass + 1, memory_test_pass_line + 1);

if (!waitForToken(/* timeout_seconds= */ 30)) {
VDP_setTextPalette(PAL_YELLOW);
VDP_drawText("SRAM test command timed out.", 1, line++);
break;
}
// "?": indicates that the Sega is reading the SRAM.
VDP_drawText("?", pass + 1, memory_test_pass_line + 1);

bool ok = sram_march_test(pass);
VDP_setTextPalette(ok ? PAL_WHITE : PAL_YELLOW);
VDP_drawText(ok ? "P" : "F", pass + 1, memory_test_pass_line + 1);
if (!ok) {
VDP_drawText(march_error_1, 0, memory_test_error_line);
VDP_drawText(march_error_2, 0, memory_test_error_line + 1);
waitMs(10 * 1000);
}
}


// 14. Test network connectivity and writing data to SRAM.
// 13. Test network connectivity and writing data to SRAM.
do {
*KINETOSCOPE_PORT_ERROR = 0;
*KINETOSCOPE_PORT_COMMAND = CMD_CONNECT_NET;
Expand Down Expand Up @@ -347,7 +301,38 @@ int main(bool hardReset) {
VDP_setTextPalette(PAL_WHITE);
VDP_drawText("Catalog header validated.", 1, line++);
}
} while (false);


// 14. Count the size of the catalog.
const SegaVideoHeader* header = (const SegaVideoHeader*)KINETOSCOPE_DATA;
int num_videos = 0;
while (header->magic[0]) {
num_videos++;
header++;

if (num_videos > MAX_CATALOG_SIZE) {
VDP_clearTextArea(0, line, 32, 1);
VDP_setTextPalette(PAL_YELLOW);
VDP_drawText("Video catalog overflow!", 1, line++);
break;
}

VDP_clearTextArea(0, line, 32, 1);
VDP_setTextPalette(PAL_WHITE);
VDP_drawText(header->title, 0, line);
}
char catalog_count_buf[32];
// 0 1 2 3
// 0123456789012345678901234567890
// 12345678901
sprintf(catalog_count_buf, "Catalog size: %d", num_videos);
VDP_setTextPalette(PAL_WHITE);
VDP_drawText(catalog_count_buf, 0, line++);


// 15. Attempt to start streaming a video.
do {
*KINETOSCOPE_PORT_COMMAND = CMD_START_VIDEO;
*KINETOSCOPE_PORT_ARG = 0;
*KINETOSCOPE_PORT_TOKEN = 1;
Expand All @@ -371,6 +356,58 @@ int main(bool hardReset) {
}
} while (false);


// 16. Perform various intensive memory tests through the firmware.
// There are many different passes of this, with different patterns to verify.
line++; // blank line
int memory_test_pass_line = line;
line += 2;
int memory_test_error_line = line;
line += 2;

VDP_setTextPalette(PAL_WHITE);
// 0 1
// 012345678901234567
VDP_drawText("SRAM test pass 00", 0, memory_test_pass_line);
VDP_drawText("......................", 1, memory_test_pass_line + 1);

for (int pass = 0; pass < SRAM_MARCH_TEST_NUM_PASSES; ++pass) {
waitMs(1);
*KINETOSCOPE_PORT_COMMAND = CMD_MARCH_TEST;
*KINETOSCOPE_PORT_ARG = pass;
waitMs(1);
*KINETOSCOPE_PORT_TOKEN = 1;

VDP_setTextPalette(PAL_WHITE);
char counter[3] = {
'0' + ((pass / 10) % 10),
'0' + (pass % 10),
'\0',
};
VDP_drawText(counter, 15, memory_test_pass_line);
// "!": indicates that the uC is filling the SRAM with data.
VDP_drawText("!", pass + 1, memory_test_pass_line + 1);

if (!waitForToken(/* timeout_seconds= */ 30)) {
VDP_setTextPalette(PAL_YELLOW);
VDP_drawText("SRAM test command timed out.", 1, line++);
break;
}
// "?": indicates that the Sega is reading the SRAM.
VDP_drawText("?", pass + 1, memory_test_pass_line + 1);

bool ok = sram_march_test(pass);
VDP_setTextPalette(ok ? PAL_WHITE : PAL_YELLOW);
VDP_drawText(ok ? "P" : "F", pass + 1, memory_test_pass_line + 1);
if (!ok) {
VDP_drawText(march_error_1, 0, memory_test_error_line);
VDP_drawText(march_error_2, 0, memory_test_error_line + 1);
waitMs(10 * 1000);
}
}


// 16. Done!
line++; // blank line
VDP_drawText("Testing complete!", 0, line++);
while (true) {
Expand Down

0 comments on commit cb9a65a

Please sign in to comment.