Skip to content

Commit

Permalink
Better error message about unsupported mechacons.
Browse files Browse the repository at this point in the history
  • Loading branch information
balika011 committed Apr 2, 2021
1 parent 1b3436e commit 01a2452
Showing 1 changed file with 40 additions and 27 deletions.
67 changes: 40 additions & 27 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,40 +51,15 @@ char unlockNVM()
gsKit_clear(gsGlobal, Black);

uint8_t version[3];
if (!getMechaVersion(version))
{
//scr_printf("Failed to read the version!\n");
//scr_printf("Do you have an SPC MechaCon?\n");
SleepThread();
return 0;
}
getMechaVersion(version);

uint8_t build_date[5];
if (!getMechaBuildDate(build_date))
{
//scr_printf("Failed to read build date!\n");
//scr_printf("Do you have an SPC MechaCon?\n");
SleepThread();
return 0;
}
getMechaBuildDate(build_date);

struct GSTEXTURE_holder *versionTextures = ui_printf(10, 100, 42, 0xFFFFFF, "Mecha version: %d.%02d\n", version[1], version[2]);
struct GSTEXTURE_holder *buildTextures = ui_printf(10, 150, 42, 0xFFFFFF, "Mecha build date: 20%02x/%02x/%02x %02x:%02x\n", build_date[0], build_date[1], build_date[2], build_date[3], build_date[4]);

const uint8_t *patch = getPatch(build_date);
if (patch == 0)
{
struct GSTEXTURE_holder *errorTextures = draw_text(10, 200, 42, 0xFFFFFF, "This MechaCon isn't supported!\n");

drawFrame();

freeGSTEXTURE_holder(versionTextures);
freeGSTEXTURE_holder(buildTextures);
freeGSTEXTURE_holder(errorTextures);

SleepThread();
return 0;
}

struct GSTEXTURE_holder *exploitTextures = draw_text(10, 200, 42, 0xFFFFFF, "Press O exploit.\n");
struct GSTEXTURE_holder *exitTextures = draw_text(10, 250, 42, 0xFFFFFF, "Press X to exit.\n");
Expand Down Expand Up @@ -822,6 +797,42 @@ uint8_t *getPowerTexture()
return &pwr50k;
}

void checkUnsupportedVersion()
{
uint8_t version[3];
uint8_t build_date[5];
if (!getMechaVersion(version) || !getMechaBuildDate(build_date))
{
struct GSTEXTURE_holder *errorTextures = draw_text(10, 200, 42, 0xFFFFFF, "This MechaCon isn't supported!\n");

drawFrame();

freeGSTEXTURE_holder(errorTextures);

SleepThread();
return 0;
}


struct GSTEXTURE_holder *versionTextures = ui_printf(10, 100, 42, 0xFFFFFF, "Mecha version: %d.%02d\n", version[1], version[2]);
struct GSTEXTURE_holder *buildTextures = ui_printf(10, 150, 42, 0xFFFFFF, "Mecha build date: 20%02x/%02x/%02x %02x:%02x\n", build_date[0], build_date[1], build_date[2], build_date[3], build_date[4]);

const uint8_t *patch = getPatch(build_date);
if (patch == 0)
{
struct GSTEXTURE_holder *errorTextures = draw_text(10, 200, 42, 0xFFFFFF, "This MechaCon isn't supported!\n");

drawFrame();

freeGSTEXTURE_holder(versionTextures);
freeGSTEXTURE_holder(buildTextures);
freeGSTEXTURE_holder(errorTextures);

SleepThread();
return 0;
}
}

int main()
{
init_ui();
Expand Down Expand Up @@ -862,6 +873,8 @@ int main()

drawLogo();

checkUnsupportedVersion();

if (!IsNVMUnlocked())
{
if (backupNVM())
Expand Down

0 comments on commit 01a2452

Please sign in to comment.