Changed layout for GBA save type db.

This commit is contained in:
profi200 2020-08-04 17:00:33 +02:00
parent acbd4d0370
commit 83f8a2d1e7
No known key found for this signature in database
GPG Key ID: 17B42AE5911139F3
3 changed files with 80 additions and 50 deletions

View File

@ -0,0 +1,73 @@
#pragma once
#include <assert.h>
#include "types.h"
// Temporary define for all incomplete entries.
#define UNSPECIFIED 0xFF
typedef struct
{
char gameCode[3]; // Without the region letter.
u8 type;
} SaveTypeLut;
static_assert(offsetof(SaveTypeLut, type) == 3, "Error: Member 'type' of SaveTypeLut is not at offset 3!");
/*
* 0x0 = 16 MiB or smaller ROM + EEPROM 4k/8k (512/1024 bytes)
* 0x1 = 32 MiB ROM + EEPROM 4k/8k (512/1024 bytes)
* 0x2 = 16 MiB or smaller ROM + EEPROM 64k (8 KiB)
* 0x3 = 32 MiB ROM + EEPROM 64k (8 KiB)
* 0x4 = Flash 512k (64 KiB) with RTC, ID=0x3D1F, Atmel
* 0x5 = Flash 512k (64 KiB) without RTC, ID=0x3D1F, Atmel
* 0x6 = Flash 512k (64 KiB) with RTC, ID=0xD4BF, SST
* 0x7 = Flash 512k (64 KiB) without RTC, ID=0xD4BF, SST
* 0x8 = Flash 512k (64 KiB) with RTC, ID=0x1B32, Panasonic
* 0x9 = Flash 512k (64 KiB) without RTC, ID=0x1B32, Panasonic
* 0xA = Flash 1M (128 KiB) with RTC, ID=0x09C2, Macronix
* 0xB = Flash 1M (128 KiB) without RTC, ID=0x09C2, Macronix
* 0xC = Flash 1M (128 KiB) with RTC, ID=0x1362, Sanyo
* 0xD = Flash 1M (128 KiB) without RTC, ID=0x1362, Sanyo
* 0xE = SRAM/FRAM/FeRAM 256k (32 KiB)
* 0xF = No save chip
*/
/*
* [] = Optional
* <> = Required
*
* Format:
* // [SDK save string if any]
* // <no-intro game release names sepearated by newlines>
* {"<game code without region (last letter)>", <save type>},
*
* All entries ordered by release number.
*/
alignas(4) static const SaveTypeLut saveTypeLut[] =
{
// EEPROM_V120
// 0002 - Super Mario Advance - Super Mario USA + Mario Brothers (Japan)
// 0049 - Super Mario Advance (USA, Europe)
// 1570 - Chaoji Maliou 2 (China)
// x116 - Super Mario Advance (USA, Europe) (Wii U Virtual Console)
{"AMA", 0x0},
// EEPROM_V122
// 0237 - Super Mario Advance 2 - Super Mario World + Mario Brothers (Japan)
// 0288 - Super Mario Advance 2 - Super Mario World (USA, Australia)
// 0389 - Super Mario Advance 2 - Super Mario World (Europe) (En,Fr,De,Es)
// 2328 - Chaoji Maliou Shijie (China)
{"AA2", 0x2},
// EEPROM_V122
// 0578 - Super Mario Advance 3 - Yoshi's Island (USA)
// 0580 - Super Mario Advance 3 - Yoshi's Island + Mario Brothers (Japan)
// 0608 - Super Mario Advance 3 - Yoshi's Island (Europe) (En,Fr,De,Es,It)
// 2299 - Yaoxi Dao (China)
// x115 - Super Mario Advance 3 - Yoshi's Island (USA) (Wii U Virtual Console)
// x161 - Super Mario Advance 3 - Yoshi's Island (Europe) (En,Fr,De,Es,It) (Wii U Virtual Console)
{"A3A", 0x2},
};

View File

@ -1,37 +0,0 @@
#pragma once
#include "types.h"
typedef struct
{
char gameCode[3]; // Without the region letter.
u8 type;
} SaveTypeLut;
static_assert(offsetof(SaveTypeLut, type) == 3, "Error: Member type of SaveTypeLut is not at offset 3!");
/*
* 0x0 = EEPROM 4k/8k (512/1024 bytes)
* 0x2 = EEPROM 64k (8 KiB)
* 0x4 = Flash 512k (64 KiB) with RTC, ID=0x3D1F, Atmel
* 0x5 = Flash 512k (64 KiB) without RTC, ID=0x3D1F, Atmel
* 0x6 = Flash 512k (64 KiB) with RTC, ID=0xD4BF, SST
* 0x7 = Flash 512k (64 KiB) without RTC, ID=0xD4BF, SST
* 0x8 = Flash 512k (64 KiB) with RTC, ID=0x1B32, Panasonic
* 0x9 = Flash 512k (64 KiB) without RTC, ID=0x1B32, Panasonic
* 0xA = Flash 1M (128 KiB) with RTC, ID=0x09C2, Macronix
* 0xB = Flash 1M (128 KiB) without RTC, ID=0x09C2, Macronix
* 0xC = Flash 1M (128 KiB) with RTC, ID=0x1362, Sanyo
* 0xD = Flash 1M (128 KiB) without RTC, ID=0x1362, Sanyo
* 0xE = SRAM/FRAM/FeRAM 256k (32 KiB)
* 0xF = No save chip
*/
// TODO: Decide how each entry should look like.
alignas(4) static const SaveTypeLut saveTypeLut[] =
{
{"AMA", 0x0}, // EEPROM_V120 Super Mario Advance
{"AA2", 0x2}, // EEPROM_V122 Super Mario Advance 2 - Super Mario World
{"A3A", 0x2}, // EEPROM_V122 Super Mario Advance 3 - Yoshi's Island
};

View File

@ -11,7 +11,7 @@
#include "arm11/hardware/mcu.h"
#include "arm11/hardware/lgyfb.h"
#include "arm11/fmt.h"
//#include "arm11/gba_save_type_table.h"
//#include "arm11/gba_save_type_db.h"
#define LGY_REGS_BASE (IO_MEM_ARM9_ARM11 + 0x41100)
@ -188,29 +188,23 @@ saveTypeFound:
return saveType;
}
/*static u16 getSaveTypeFromTable(u32 romSize)
/*static u16 getSaveTypeFromTable(void)
{
const u32 gameCode = *(u32*)(ROM_LOC + 0xAC);
const u32 gameCode = *(u32*)(ROM_LOC + 0xAC) & ~0xFF000000u;
u16 saveType = SAVE_TYPE_NONE;
for(u32 i = 0; i < sizeof(saveTypeLut) / sizeof(*saveTypeLut); i++)
{
// Save type in last byte.
const u32 entry = *((u32*)saveTypeLut[i].gameCode);
if((entry & 0xFFFFFFu) == (gameCode & 0xFFFFFFu))
const u32 entry = *((u32*)&saveTypeLut[i]);
if((entry & ~0xFF000000u) == gameCode)
{
saveType = entry>>24;
break;
}
}
if(saveType == SAVE_TYPE_EEPROM_8k || saveType == SAVE_TYPE_EEPROM_64k)
{
// If ROM bigger than 16 MiB --> SAVE_TYPE_EEPROM_8k_2 or SAVE_TYPE_EEPROM_64k_2.
if(romSize > 0x1000000) saveType++;
}
debug_printf("Using save type %" PRIX16 ".\n", saveType);
debug_printf("Using save type 0x%" PRIX16 ".\n", saveType);
return saveType;
}*/
@ -236,7 +230,7 @@ Result LGY_prepareGbaMode(bool biosIntro, char *const romPath)
// Try to detect the save type.
const u16 saveType = tryDetectSaveType(romSize);
//const u16 saveType = getSaveTypeFromTable(romSize);
//const u16 saveType = getSaveTypeFromTable();
// Prepare ARM9 for GBA mode + settings and save loading.
const u32 romPathLen = strlen(romPath);