Code: Select all
typedef struct
{
uint32_t region_free; // 0 - off, 1 - on (patch bios region protection)
uint32_t force_vga; // 0 - off, 1 - on (patch vga flag bios check)
uint32_t IGR; // 0 - off, 1 - on (In-Game Reset)
uint32_t boot_intro; // 0 - skip, 1 - show (boot animation)
uint32_t sega_license; // 0 - skip, 1 - show (IP.BIN license screen)
uint32_t game_region; // 0 - J, 1 - U, 2 - E
uint32_t disc_type; // 0 - CD, 1 - GD
uint32_t need_game_fix; // 0 - no, 1 - yes
} ldr_params_t;
ldr_params_t run_params;
void run_game(void)
{
FILE *fd;
uint32_t file_size;
fd = fs_open("/rd/loader.bin", "rb");
fseek(fd, 0, SEEK_END);
file_size = ftell(fd);
fseek(fd, 0, SEEK_SET);
fread((void *) 0x8CD00000, 1, file_size, fd);
fclose(fd);
run_params.game_region = get_game_region();
run_params.disc_type = is_GD_disc();
run_params.need_game_fix = need_game_fix();
memcpy((void *) 0xACCFFF00, (void *) &run_params, 0x20);
arch_exec(0x8CD00000, file_size);
}
uint32_t get_game_region(void)
{
/* this function check region in IP.BIN */
/* need adaptation for open menu, but logic simple */
if (NTSC-J)
{
return 0;
}
else if (NTSC-U)
{
return 1;
}
else if (PAL)
{
return 2;
}
/* if is region free, then get region from system variables */
uint8_t *sys_region = (uint8_t *) 0x8C000072;
return (uint32_t) (sys_region[0] & 7);
}
uint32_t is_GD_disc(void)
{
uint32_t status, disc_type;
status = disc_type = 0;
cdrom_get_status(&status, &disc_type);
return disc_type == 0x80;
}
uint32_t need_game_fix()
{
/* this function check game name from IP.BIN */
/* need adaptation for open menu, but logic simple */
if (strncmp(name, "PSO VER.2", 9) == 0 ||
strncmp(name, "SONIC ADVENTURE 2", 17) == 0)
{
return 1;
}
return 0;
}
2) the first 5 items of the ldr_params_t structure must be filled in when loading the menu