From f87dedce581787fb38bba57b2f4a22ab235d816f Mon Sep 17 00:00:00 2001 From: Extrems Date: Thu, 12 Sep 2019 18:54:47 -0400 Subject: [PATCH] - Fix patches on Serial Port 2 for other devices. - Fix patches on byte addressing SD for other devices. --- cube/swiss/include/swiss.h | 1 - .../source/devices/dvd/deviceHandler-DVD.c | 6 +++--- .../source/devices/fat/deviceHandler-FAT.c | 20 +++++-------------- .../source/devices/fsp/deviceHandler-FSP.c | 6 +++--- .../devices/usbgecko/deviceHandler-usbgecko.c | 6 +++--- .../wiikeyfusion/deviceHandler-wiikeyfusion.c | 6 +++--- cube/swiss/source/swiss.c | 9 ++++++--- 7 files changed, 23 insertions(+), 31 deletions(-) diff --git a/cube/swiss/include/swiss.h b/cube/swiss/include/swiss.h index ae8d1589..8ad944a8 100644 --- a/cube/swiss/include/swiss.h +++ b/cube/swiss/include/swiss.h @@ -33,7 +33,6 @@ extern int curMenuLocation; extern char* _menu_array[]; extern file_handle curFile; extern file_handle curDir; -extern u32 SDHCCard; extern char IPLInfo[256] __attribute__((aligned(32))); extern u8 driveVersion[8]; extern DiskHeader GCMDisk; diff --git a/cube/swiss/source/devices/dvd/deviceHandler-DVD.c b/cube/swiss/source/devices/dvd/deviceHandler-DVD.c index 39f9fb18..aba7bb90 100644 --- a/cube/swiss/source/devices/dvd/deviceHandler-DVD.c +++ b/cube/swiss/source/devices/dvd/deviceHandler-DVD.c @@ -467,11 +467,11 @@ s32 deviceHandler_DVD_setupFile(file_handle* file, file_handle* file2) { // Currently selected disk base sector *(vu32*)VAR_CUR_DISC_LBA = fragList[2]; // Card Type - *(vu8*)VAR_SD_SHIFT = (u8)(9 * sdgecko_getAddressingType(((devices[DEVICE_PATCHES]->location == LOC_MEMCARD_SLOT_A) ? 0:1))); + *(vu8*)VAR_SD_SHIFT = (u8)(sdgecko_getAddressingType(devices[DEVICE_PATCHES] == &__device_sd_a ? EXI_CHANNEL_0:(devices[DEVICE_PATCHES] == &__device_sd_b ? EXI_CHANNEL_1:EXI_CHANNEL_2)) ? 9:0); // Copy the actual freq - *(vu8*)VAR_EXI_FREQ = (u8)(EXI_SPEED16MHZ); // play it safe + *(vu8*)VAR_EXI_FREQ = (u8)(swissSettings.exiSpeed ? EXI_SPEED32MHZ:EXI_SPEED16MHZ); // Device slot (0 or 1) - *(vu8*)VAR_EXI_SLOT = (u8)((devices[DEVICE_PATCHES]->location == LOC_MEMCARD_SLOT_A) ? EXI_CHANNEL_0:EXI_CHANNEL_1); + *(vu8*)VAR_EXI_SLOT = (u8)(devices[DEVICE_PATCHES] == &__device_sd_a ? EXI_CHANNEL_0:(devices[DEVICE_PATCHES] == &__device_sd_b ? EXI_CHANNEL_1:EXI_CHANNEL_2)); } return 1; diff --git a/cube/swiss/source/devices/fat/deviceHandler-FAT.c b/cube/swiss/source/devices/fat/deviceHandler-FAT.c index abb96427..8ae0bfca 100644 --- a/cube/swiss/source/devices/fat/deviceHandler-FAT.c +++ b/cube/swiss/source/devices/fat/deviceHandler-FAT.c @@ -164,17 +164,7 @@ s32 deviceHandler_FAT_readDir(file_handle* ffile, file_handle** dir, u32 type) { f_closedir(dp); free(dp); - if(IS_SDCARD(ffile->name)) { - int slot = GET_SLOT(ffile->name); - // Set the card type (either block addressed (0) or byte addressed (1)) - SDHCCard = sdgecko_getAddressingType(slot); - // set the page size to 512 bytes - if(sdgecko_setPageSize(slot, 512)!=0) { - return -1; - } - } - - return num_entries; + return num_entries; } s32 deviceHandler_FAT_seekFile(file_handle* file, u32 where, u32 type){ @@ -400,13 +390,13 @@ s32 deviceHandler_FAT_setupFile(file_handle* file, file_handle* file2) { *(vu32*)VAR_SECTOR_CUR = 0; *(vu32*)VAR_SD_LBA = 0; // Card Type - *(vu8*)VAR_SD_SHIFT = (u8)(9 * SDHCCard); + *(vu8*)VAR_SD_SHIFT = (u8)(sdgecko_getAddressingType(devices[DEVICE_CUR] == &__device_sd_a ? EXI_CHANNEL_0:(devices[DEVICE_CUR] == &__device_sd_b ? EXI_CHANNEL_1:EXI_CHANNEL_2)) ? 9:0); // Copy the actual freq - *(vu8*)VAR_EXI_FREQ = (u8)(!swissSettings.exiSpeed ? EXI_SPEED16MHZ:EXI_SPEED32MHZ); + *(vu8*)VAR_EXI_FREQ = (u8)(swissSettings.exiSpeed ? EXI_SPEED32MHZ:EXI_SPEED16MHZ); // Device slot (0, 1 or 2) - *(vu8*)VAR_EXI_SLOT = (u8)(devices[DEVICE_CUR]->location == LOC_SERIAL_PORT_2 ? 2:((devices[DEVICE_CUR]->location == LOC_MEMCARD_SLOT_A)? 0:1)); + *(vu8*)VAR_EXI_SLOT = (u8)(devices[DEVICE_CUR] == &__device_sd_a ? EXI_CHANNEL_0:(devices[DEVICE_CUR] == &__device_sd_b ? EXI_CHANNEL_1:EXI_CHANNEL_2)); // IDE-EXI only settings - if((devices[DEVICE_CUR] == &__device_ide_a) || (devices[DEVICE_CUR] == &__device_ide_b)) { + if(devices[DEVICE_CUR] == &__device_ide_a || devices[DEVICE_CUR] == &__device_ide_b) { // Is the HDD in use a 48 bit LBA supported HDD? *(vu8*)VAR_ATA_LBA48 = ataDriveInfo.lba48Support; } diff --git a/cube/swiss/source/devices/fsp/deviceHandler-FSP.c b/cube/swiss/source/devices/fsp/deviceHandler-FSP.c index 785f9d4a..c568f780 100644 --- a/cube/swiss/source/devices/fsp/deviceHandler-FSP.c +++ b/cube/swiss/source/devices/fsp/deviceHandler-FSP.c @@ -177,11 +177,11 @@ s32 deviceHandler_FSP_setupFile(file_handle* file, file_handle* file2) { } } // Card Type - *(vu8*)VAR_SD_SHIFT = (u8)(9 * sdgecko_getAddressingType(((devices[DEVICE_PATCHES]->location == LOC_MEMCARD_SLOT_A) ? 0:1))); + *(vu8*)VAR_SD_SHIFT = (u8)(sdgecko_getAddressingType(devices[DEVICE_PATCHES] == &__device_sd_a ? EXI_CHANNEL_0:(devices[DEVICE_PATCHES] == &__device_sd_b ? EXI_CHANNEL_1:EXI_CHANNEL_2)) ? 9:0); // Copy the actual freq - *(vu8*)VAR_EXI_FREQ = (u8)(EXI_SPEED16MHZ); // play it safe + *(vu8*)VAR_EXI_FREQ = (u8)(swissSettings.exiSpeed ? EXI_SPEED32MHZ:EXI_SPEED16MHZ); // Device slot (0 or 1) - *(vu8*)VAR_EXI_SLOT = (u8)((devices[DEVICE_PATCHES]->location == LOC_MEMCARD_SLOT_A) ? EXI_CHANNEL_0:EXI_CHANNEL_1); + *(vu8*)VAR_EXI_SLOT = (u8)(devices[DEVICE_PATCHES] == &__device_sd_a ? EXI_CHANNEL_0:(devices[DEVICE_PATCHES] == &__device_sd_b ? EXI_CHANNEL_1:EXI_CHANNEL_2)); } print_frag_list(0); diff --git a/cube/swiss/source/devices/usbgecko/deviceHandler-usbgecko.c b/cube/swiss/source/devices/usbgecko/deviceHandler-usbgecko.c index 8901d986..69ba98cd 100644 --- a/cube/swiss/source/devices/usbgecko/deviceHandler-usbgecko.c +++ b/cube/swiss/source/devices/usbgecko/deviceHandler-usbgecko.c @@ -155,11 +155,11 @@ s32 deviceHandler_USBGecko_setupFile(file_handle* file, file_handle* file2) { } } // Card Type - *(vu8*)VAR_SD_SHIFT = (u8)(9 * sdgecko_getAddressingType(((devices[DEVICE_PATCHES]->location == LOC_MEMCARD_SLOT_A) ? 0:1))); + *(vu8*)VAR_SD_SHIFT = (u8)(sdgecko_getAddressingType(devices[DEVICE_PATCHES] == &__device_sd_a ? EXI_CHANNEL_0:(devices[DEVICE_PATCHES] == &__device_sd_b ? EXI_CHANNEL_1:EXI_CHANNEL_2)) ? 9:0); // Copy the actual freq - *(vu8*)VAR_EXI_FREQ = (u8)(EXI_SPEED16MHZ); // play it safe + *(vu8*)VAR_EXI_FREQ = (u8)(swissSettings.exiSpeed ? EXI_SPEED32MHZ:EXI_SPEED16MHZ); // Device slot (0 or 1) - *(vu8*)VAR_EXI_SLOT = (u8)((devices[DEVICE_PATCHES]->location == LOC_MEMCARD_SLOT_A) ? EXI_CHANNEL_0:EXI_CHANNEL_1); + *(vu8*)VAR_EXI_SLOT = (u8)(devices[DEVICE_PATCHES] == &__device_sd_a ? EXI_CHANNEL_0:(devices[DEVICE_PATCHES] == &__device_sd_b ? EXI_CHANNEL_1:EXI_CHANNEL_2)); } print_frag_list(0); diff --git a/cube/swiss/source/devices/wiikeyfusion/deviceHandler-wiikeyfusion.c b/cube/swiss/source/devices/wiikeyfusion/deviceHandler-wiikeyfusion.c index 09b54a48..25c33368 100644 --- a/cube/swiss/source/devices/wiikeyfusion/deviceHandler-wiikeyfusion.c +++ b/cube/swiss/source/devices/wiikeyfusion/deviceHandler-wiikeyfusion.c @@ -121,11 +121,11 @@ s32 deviceHandler_WKF_setupFile(file_handle* file, file_handle* file2) { } } // Card Type - *(vu8*)VAR_SD_SHIFT = (u8)(9 * sdgecko_getAddressingType(((devices[DEVICE_PATCHES]->location == LOC_MEMCARD_SLOT_A) ? 0:1))); + *(vu8*)VAR_SD_SHIFT = (u8)(sdgecko_getAddressingType(devices[DEVICE_PATCHES] == &__device_sd_a ? EXI_CHANNEL_0:(devices[DEVICE_PATCHES] == &__device_sd_b ? EXI_CHANNEL_1:EXI_CHANNEL_2)) ? 9:0); // Copy the actual freq - *(vu8*)VAR_EXI_FREQ = (u8)(EXI_SPEED16MHZ); // play it safe + *(vu8*)VAR_EXI_FREQ = (u8)(swissSettings.exiSpeed ? EXI_SPEED32MHZ:EXI_SPEED16MHZ); // Device slot (0 or 1) - *(vu8*)VAR_EXI_SLOT = (u8)((devices[DEVICE_PATCHES]->location == LOC_MEMCARD_SLOT_A) ? EXI_CHANNEL_0:EXI_CHANNEL_1); + *(vu8*)VAR_EXI_SLOT = (u8)(devices[DEVICE_PATCHES] == &__device_sd_a ? EXI_CHANNEL_0:(devices[DEVICE_PATCHES] == &__device_sd_b ? EXI_CHANNEL_1:EXI_CHANNEL_2)); } diff --git a/cube/swiss/source/swiss.c b/cube/swiss/source/swiss.c index 8b72235b..94b89372 100644 --- a/cube/swiss/source/swiss.c +++ b/cube/swiss/source/swiss.c @@ -51,7 +51,6 @@ GXRModeObj *newmode = NULL; char txtbuffer[2048]; //temporary text buffer file_handle curFile; //filedescriptor for current file file_handle curDir; //filedescriptor for current directory -u32 SDHCCard = 0; //0 == SDHC, 1 == normal SD extern int execdpatch_bin_size; extern u8 execdpatch_bin[]; @@ -879,9 +878,13 @@ unsigned int load_app(int multiDol, ExecutableFile *filesToPatch, int noASRequir wkfWriteOffset(*(vu32*)VAR_DISC_1_LBA); } print_gecko("libogc shutdown and boot game!\r\n"); - if((devices[DEVICE_CUR] == &__device_sd_a) || (devices[DEVICE_CUR] == &__device_sd_b) || (devices[DEVICE_CUR] == &__device_sd_c)) { + if(devices[DEVICE_CUR] == &__device_sd_a || devices[DEVICE_CUR] == &__device_sd_b || devices[DEVICE_CUR] == &__device_sd_c) { print_gecko("set size\r\n"); - sdgecko_setPageSize(devices[DEVICE_CUR]->location == LOC_SERIAL_PORT_2 ? 2:((devices[DEVICE_CUR]->location == LOC_MEMCARD_SLOT_A)? 0:1), 512); + sdgecko_setPageSize(devices[DEVICE_CUR] == &__device_sd_a ? EXI_CHANNEL_0:(devices[DEVICE_CUR] == &__device_sd_b ? EXI_CHANNEL_1:EXI_CHANNEL_2), 512); + } + else if(devices[DEVICE_PATCHES] == &__device_sd_a || devices[DEVICE_PATCHES] == &__device_sd_b || devices[DEVICE_PATCHES] == &__device_sd_c) { + print_gecko("set size\r\n"); + sdgecko_setPageSize(devices[DEVICE_PATCHES] == &__device_sd_a ? EXI_CHANNEL_0:(devices[DEVICE_PATCHES] == &__device_sd_b ? EXI_CHANNEL_1:EXI_CHANNEL_2), 512); } DOLtoARAM(main_dol_buffer, 0, NULL); return 0;