Skip to content

Commit

Permalink
- Fix patches on Serial Port 2 for other devices.
Browse files Browse the repository at this point in the history
- Fix patches on byte addressing SD for other devices.
  • Loading branch information
Extrems committed Sep 12, 2019
1 parent 0823b57 commit f87dedc
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 31 deletions.
1 change: 0 additions & 1 deletion cube/swiss/include/swiss.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions cube/swiss/source/devices/dvd/deviceHandler-DVD.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
20 changes: 5 additions & 15 deletions cube/swiss/source/devices/fat/deviceHandler-FAT.c
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down Expand Up @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions cube/swiss/source/devices/fsp/deviceHandler-FSP.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions cube/swiss/source/devices/usbgecko/deviceHandler-usbgecko.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}


Expand Down
9 changes: 6 additions & 3 deletions cube/swiss/source/swiss.c
Original file line number Diff line number Diff line change
Expand Up @@ -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[];

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit f87dedc

Please sign in to comment.