Implement EEPROM save override.

Disabled SRAM/FLASH when EEPROM saves have been attempted. Allows to
override games via gba_over too
This commit is contained in:
David Guillen Fandos 2023-09-23 18:13:18 +02:00
parent ae048beb9c
commit 9632dedf90
3 changed files with 72 additions and 11 deletions

View File

@ -381,10 +381,8 @@ RFILE *gamepak_file_large = NULL;
// If the GBC audio waveform is modified:
u32 gbc_sound_wave_update = 0;
// Keep it 32KB until the upper 64KB is accessed, then make it 64KB.
u32 backup_type = BACKUP_NONE;
u32 backup_type = BACKUP_UNKN;
u32 backup_type_reset = BACKUP_UNKN;
u32 flash_mode = FLASH_BASE_MODE;
u32 flash_command_position = 0;
u32 flash_bank_num; // 0 or 1
@ -424,7 +422,10 @@ u8 read_backup(u32 address)
{
u8 value = 0;
if(backup_type == BACKUP_NONE)
if(backup_type == BACKUP_EEPROM)
return 0xff;
if(backup_type == BACKUP_UNKN)
backup_type = BACKUP_SRAM;
if(backup_type == BACKUP_SRAM)
@ -1028,7 +1029,10 @@ void function_cc write_backup(u32 address, u32 value)
{
value &= 0xFF;
if(backup_type == BACKUP_NONE)
if(backup_type == BACKUP_EEPROM)
return;
if(backup_type == BACKUP_UNKN)
backup_type = BACKUP_SRAM;
// gamepak SRAM or Flash ROM
@ -1545,6 +1549,7 @@ typedef struct
#define FLAGS_FLASH_128KB 0x0001
#define FLAGS_RUMBLE 0x0002
#define FLAGS_RTC 0x0004
#define FLAGS_EEPROM 0x0010
#include "gba_over.h"
@ -1582,6 +1587,9 @@ static void load_game_config_over(gamepak_info_t *gpinfo)
if (gbaover[i].flags & FLAGS_RUMBLE)
rumble_enabled = true;
if (gbaover[i].flags & FLAGS_EEPROM)
backup_type_reset = BACKUP_EEPROM;
if (gbaover[i].translation_gate_target_1 != 0)
{
translation_gate_target_pc[translation_gate_targets] = gbaover[i].translation_gate_target_1;
@ -2255,10 +2263,7 @@ void init_memory(void)
reload_timing_info();
backup_type = BACKUP_NONE;
//flash_size = FLASH_SIZE_64KB;
backup_type = backup_type_reset;
flash_bank_num = 0;
flash_command_position = 0;
eeprom_size = EEPROM_512_BYTE;
@ -2528,6 +2533,7 @@ u32 load_gamepak(const struct retro_game_info* info, const char *name,
flash_bank_cnt = FLASH_SIZE_64KB;
rtc_enabled = false;
rumble_enabled = false;
backup_type_reset = BACKUP_UNKN;
load_game_config_over(&gpinfo);

View File

@ -275,7 +275,7 @@ extern u32 reg[64];
#define BACKUP_SRAM 0
#define BACKUP_FLASH 1
#define BACKUP_EEPROM 2
#define BACKUP_NONE 3
#define BACKUP_UNKN 3
#define SRAM_SIZE_32KB 1
#define SRAM_SIZE_64KB 2

View File

@ -296,6 +296,61 @@ static const ini_t gbaover[] = {
0, /* translation_gate_target_2 */
0, /* translation_gate_target_3 */
},
{
// Dragon Ball Z - The Legacy of Goku (E)
"DRAGONBALL Z", /* gamepak_title */
"ALGP", /* gamepak_code */
"70", /* gamepak_maker */
FLAGS_EEPROM, /* flags */
0, /* idle_loop_target_pc */
0, /* translation_gate_target_1 */
0, /* translation_gate_target_2 */
0, /* translation_gate_target_3 */
},
{
// Dragon Ball Z - The Legacy of Goku II (U)
"DBZLGCYGOKU2", /* gamepak_title */
"ALFE", /* gamepak_code */
"70", /* gamepak_maker */
FLAGS_EEPROM, /* flags */
0, /* idle_loop_target_pc */
0, /* translation_gate_target_1 */
0, /* translation_gate_target_2 */
0, /* translation_gate_target_3 */
},
{
// Dragon Ball Z - The Legacy of Goku II (E)
"DBZLGCYGOKU2", /* gamepak_title */
"ALFP", /* gamepak_code */
"70", /* gamepak_maker */
FLAGS_EEPROM, /* flags */
0, /* idle_loop_target_pc */
0, /* translation_gate_target_1 */
0, /* translation_gate_target_2 */
0, /* translation_gate_target_3 */
},
{
// Dragon Ball Z - Taiketsu (U)
"DBZ TAIKETSU", /* gamepak_title */
"BDBE", /* gamepak_code */
"70", /* gamepak_maker */
FLAGS_EEPROM, /* flags */
0, /* idle_loop_target_pc */
0, /* translation_gate_target_1 */
0, /* translation_gate_target_2 */
0, /* translation_gate_target_3 */
},
{
// Dragon Ball Z - Taiketsu (E)
"DBZ TAIKETSU", /* gamepak_title */
"BDBP", /* gamepak_code */
"70", /* gamepak_maker */
FLAGS_EEPROM, /* flags */
0, /* idle_loop_target_pc */
0, /* translation_gate_target_1 */
0, /* translation_gate_target_2 */
0, /* translation_gate_target_3 */
},
{
// Drill Dozer (U)
"DRILL DOZER", /* gamepak_title */