Skip to content

Commit

Permalink
fix chainloader using IPL code
Browse files Browse the repository at this point in the history
trevor403 committed Jun 22, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 0c91265 commit 700c109
Showing 2 changed files with 18 additions and 7 deletions.
24 changes: 17 additions & 7 deletions patches/source/boot.c
Original file line number Diff line number Diff line change
@@ -41,6 +41,7 @@ dol_info_t load_dol(char *path, bool flash) {
}

custom_OSReport("Copy done...\n");
dvd_custom_close(file_status->fd);

// Clear BSS
// TODO: check if this overlaps with IPL
@@ -59,20 +60,29 @@ void chainload_boot_game(char *boot_path) {
lowmem->a_version = 0x00000001;
lowmem->b_physical_memory_size = 0x01800000;

// open file
dvd_custom_open(boot_path, FILE_ENTRY_TYPE_FILE, 0);
file_status_t *file_status = dvd_custom_status();
if (file_status == NULL || file_status->result != 0) {
custom_OSReport("Failed to open file %s\n", boot_path);
return;
}

dvd_set_default_fd(file_status->fd);
dvd_read(&lowmem->b_disk_info, 0x20, 0, 0);

void *entrypoint = load_apploader();

struct gcm_disk_header_info *bi2 = lowmem->a_bi2;

OSReport("BI2: %08x\n", bi2);
OSReport("Country: %x\n", bi2->country_code);
custom_OSReport("BI2: %08x\n", bi2);
custom_OSReport("Country: %x\n", bi2->country_code);

// game id
OSReport("Game ID: %c%c%c%c\n", lowmem->b_disk_info.game_code[0], lowmem->b_disk_info.game_code[1], lowmem->b_disk_info.game_code[2], lowmem->b_disk_info.game_code[3]);
custom_OSReport("Game ID: %c%c%c%c\n", lowmem->b_disk_info.game_code[0], lowmem->b_disk_info.game_code[1], lowmem->b_disk_info.game_code[2], lowmem->b_disk_info.game_code[3]);

if (bi2->country_code == COUNTRY_EUR) {
OSReport("PAL game detected\n");
custom_OSReport("PAL game detected\n");
ogc__VIInit(VI_TVMODE_PAL_INT);

// set video mode PAL
@@ -83,7 +93,7 @@ void chainload_boot_game(char *boot_path) {
lowmem->tv_mode = 1;
}
} else {
OSReport("NTSC game detected\n");
custom_OSReport("NTSC game detected\n");
ogc__VIInit(VI_TVMODE_NTSC_INT);

lowmem->tv_mode = 0;
@@ -118,12 +128,12 @@ void* load_apploader() {
// start disc drive & read apploader
err = dvd_read(buffer,0x20,0x2440, 0);
if (err) {
OSReport("Could not load apploader header\n");
custom_OSReport("Could not load apploader header\n");
while(1);
}
err = dvd_read((void*)0x81200000,((*(unsigned long*)((u32)buffer+0x14)) + 31) &~31,0x2460, 0);
if (err) {
OSReport("Could not load apploader data\n");
custom_OSReport("Could not load apploader data\n");
while(1);
}

1 change: 1 addition & 0 deletions patches/source/main.c
Original file line number Diff line number Diff line change
@@ -441,6 +441,7 @@ __attribute_used__ void bs2start() {
lowmem->b_physical_memory_size = 0x01800000;

// TODO: use the filebrowser to get the game path
chainload_boot_game(boot_path);

// only load the apploader if the boot path is not a .dol file
extern int strncmpci(const char * str1, const char * str2, size_t num);

0 comments on commit 700c109

Please sign in to comment.