mirror of
https://github.com/lesserkuma/GBA_MultiMenu.git
synced 2026-08-23 00:54:39 -05:00
0.3
This commit is contained in:
@@ -216,16 +216,20 @@ IWRAM_CODE u8 BootGame(ItemConfig config, FlashStatus status)
|
||||
return 1;
|
||||
|
||||
// Temporarily store SRAM values at mapper registers
|
||||
sram_register_backup[0] = *(vu8 *)MAPPER_CONFIG1;
|
||||
sram_register_backup[1] = *(vu8 *)MAPPER_CONFIG2;
|
||||
sram_register_backup[2] = *(vu8 *)MAPPER_CONFIG3;
|
||||
sram_register_backup[3] = *(vu8 *)MAPPER_CONFIG4;
|
||||
if (status.last_boot_save_type == SRAM_NONE)
|
||||
{
|
||||
sram_register_backup[0] = *(vu8 *)MAPPER_CONFIG1;
|
||||
sram_register_backup[1] = *(vu8 *)MAPPER_CONFIG2;
|
||||
sram_register_backup[2] = *(vu8 *)MAPPER_CONFIG3;
|
||||
sram_register_backup[3] = *(vu8 *)MAPPER_CONFIG4;
|
||||
}
|
||||
|
||||
// Enable SRAM access
|
||||
*(vu8 *)MAPPER_CONFIG4 = 1;
|
||||
|
||||
// Write previous SRAM to flash
|
||||
if (status.battery_present) {
|
||||
if (status.battery_present)
|
||||
{
|
||||
if (status.last_boot_save_type != SRAM_NONE)
|
||||
{
|
||||
for (int i = 0; i < SRAM_SIZE; i++)
|
||||
@@ -279,7 +283,7 @@ IWRAM_CODE u8 BootGame(ItemConfig config, FlashStatus status)
|
||||
*(vu8 *)MAPPER_CONFIG3 = 0x40 - config.rom_size; // accessible ROM size (in 512 KB blocks)
|
||||
|
||||
// Wait until menu ROM is no longer visible
|
||||
u16 timeout = 0xFFFF;
|
||||
u32 timeout = 0x2FFF;
|
||||
while (((vu16 *)AGB_ROM)[0x58] == 0x4B4C)
|
||||
{
|
||||
if (!timeout--)
|
||||
@@ -294,16 +298,20 @@ IWRAM_CODE u8 BootGame(ItemConfig config, FlashStatus status)
|
||||
// Lock mapper
|
||||
*(vu8 *)MAPPER_CONFIG2 |= 0x80;
|
||||
|
||||
// Restore SRAM values at mapper registers
|
||||
*(vu8 *)MAPPER_CONFIG1 = sram_register_backup[0];
|
||||
*(vu8 *)MAPPER_CONFIG2 = sram_register_backup[1];
|
||||
*(vu8 *)MAPPER_CONFIG3 = sram_register_backup[2];
|
||||
*(vu8 *)MAPPER_CONFIG4 = sram_register_backup[3];
|
||||
|
||||
// Write buffer to SRAM
|
||||
for (int i = 0; i < SRAM_SIZE; i++)
|
||||
if (config.save_type != SRAM_NONE)
|
||||
{
|
||||
((vu8 *)AGB_SRAM)[i] = data_buffer[i];
|
||||
for (int i = 0; i < SRAM_SIZE; i++)
|
||||
{
|
||||
((vu8 *)AGB_SRAM)[i] = data_buffer[i];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
*(vu8 *)MAPPER_CONFIG1 = sram_register_backup[0];
|
||||
*(vu8 *)MAPPER_CONFIG2 = sram_register_backup[1];
|
||||
*(vu8 *)MAPPER_CONFIG3 = sram_register_backup[2];
|
||||
*(vu8 *)MAPPER_CONFIG4 = sram_register_backup[3];
|
||||
}
|
||||
|
||||
// Clear palette
|
||||
@@ -313,7 +321,7 @@ IWRAM_CODE u8 BootGame(ItemConfig config, FlashStatus status)
|
||||
}
|
||||
REG_BLDY = 0;
|
||||
|
||||
// Soft Reset system call
|
||||
// Boot ROM
|
||||
__asm("swi 0"); // Soft reset
|
||||
|
||||
return 3;
|
||||
|
||||
@@ -14,6 +14,7 @@ Author: Lesserkuma (github.com/lesserkuma)
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "version.h"
|
||||
#include "main.h"
|
||||
#include "font.h"
|
||||
#include "flash.h"
|
||||
@@ -186,14 +187,10 @@ int main(void) {
|
||||
}
|
||||
} else if (show_credits) {
|
||||
LoadFont(0);
|
||||
#ifdef __TIMESTAMP_ISO__
|
||||
memset(temp_unicode, 0, sizeof(temp_unicode));
|
||||
snprintf(temp_ascii, 48, "Menu by LK - %s", __TIMESTAMP_ISO__);
|
||||
AsciiToUnicode(temp_ascii, temp_unicode);
|
||||
DrawText(6, SCREEN_HEIGHT - sFontSpecs.max_height - 3 - FontMarginBottom, ALIGN_LEFT, temp_unicode, 48, font, (void*)AGB_VRAM+0xA000, FALSE);
|
||||
#else
|
||||
DrawText(6, SCREEN_HEIGHT - sFontSpecs.max_height - 3 - FontMarginBottom, ALIGN_LEFT, u"Menu by LK", 48, font, (void*)AGB_VRAM+0xA000, FALSE);
|
||||
#endif
|
||||
memset(temp_unicode, 0, sizeof(temp_unicode));
|
||||
snprintf(temp_ascii, 48, "Menu by LK - %s", BUILDTIME);
|
||||
AsciiToUnicode(temp_ascii, temp_unicode);
|
||||
DrawText(6, SCREEN_HEIGHT - sFontSpecs.max_height - 3 - FontMarginBottom, ALIGN_LEFT, temp_unicode, 48, font, (void*)AGB_VRAM+0xA000, FALSE);
|
||||
} else if (show_debug) {
|
||||
LoadFont(0);
|
||||
u8 a = ((sItemConfig.rom_offset / 0x40) & 0xF) << 4;
|
||||
|
||||
15
source/version.h
Normal file
15
source/version.h
Normal file
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
GBA Multi Game Menu
|
||||
Author: Lesserkuma (github.com/lesserkuma)
|
||||
*/
|
||||
|
||||
#ifndef VERSION_H_
|
||||
#define VERSION_H_
|
||||
|
||||
#ifdef __TIMESTAMP_ISO__
|
||||
#define BUILDTIME __TIMESTAMP_ISO__
|
||||
#else
|
||||
#define BUILDTIME __TIMESTAMP__
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user