diff --git a/cube/patches/alt/blockdevice.c b/cube/patches/alt/blockdevice.c index 45c02b08..6b94394f 100644 --- a/cube/patches/alt/blockdevice.c +++ b/cube/patches/alt/blockdevice.c @@ -17,6 +17,7 @@ bool exi_trylock(int32_t chan, uint32_t dev, EXIControl *exi) return true; } +void di_update_interrupts(void); void di_complete_transfer(void); void perform_read(uint32_t offset, uint32_t length, uint32_t address) @@ -44,5 +45,21 @@ void trickle_read(void) *(uint8_t **)VAR_TMP1 = data + data_size; if (!remainder) di_complete_transfer(); + } else if (*(uint32_t *)VAR_DISC_CHANGING) { + tb_t end; + mftb(&end); + + if (tb_diff_usec(&end, (tb_t *)VAR_TIMER_START) > 1000000) { + if (*(uint32_t *)VAR_CUR_DISC_LBA == *(uint32_t *)VAR_DISC_1_LBA) + *(uint32_t *)VAR_CUR_DISC_LBA = *(uint32_t *)VAR_DISC_2_LBA; + else + *(uint32_t *)VAR_CUR_DISC_LBA = *(uint32_t *)VAR_DISC_1_LBA; + + *(uint32_t *)VAR_DISC_CHANGING = 0; + + (*DI_EMU)[1] &= ~0b001; + (*DI_EMU)[1] |= 0b100; + di_update_interrupts(); + } } } diff --git a/cube/patches/alt/emulator.c b/cube/patches/alt/emulator.c index 86cb90ab..952d75e4 100644 --- a/cube/patches/alt/emulator.c +++ b/cube/patches/alt/emulator.c @@ -26,7 +26,7 @@ void di_complete_transfer(void) uint32_t address = (*DI_EMU)[5] + OS_BASE_CACHED; uint32_t length = (*DI_EMU)[6]; - (*DI_EMU)[0] |= 0b0010000; + (*DI_EMU)[0] |= 0b0010000; (*DI_EMU)[7] &= ~0b001; if ((*DI_EMU)[7] & 0b010) { @@ -51,7 +51,7 @@ static void di_execute_command(void) perform_read(offset, length, address); } else { - (*DI_EMU)[0] |= 0b0000100; + (*DI_EMU)[0] |= 0b0000100; (*DI_EMU)[7] &= ~0b001; di_update_interrupts(); } @@ -63,6 +63,12 @@ static void di_execute_command(void) result = 0x01023A00; break; } + case 0xE3: + { + (*DI_EMU)[1] |= 0b001; + mftb((tb_t *)VAR_TIMER_START); + *(uint32_t *)VAR_DISC_CHANGING = 1; + } } (*DI_EMU)[8] = result; diff --git a/cube/swiss/source/gcm.c b/cube/swiss/source/gcm.c index 2120d891..513e0744 100644 --- a/cube/swiss/source/gcm.c +++ b/cube/swiss/source/gcm.c @@ -188,7 +188,7 @@ int parse_gcm(file_handle *file, ExecutableFile *filesToPatch) { free(FST); // Multi-DOL games may re-load the main DOL, so make sure we patch it too. - if((devices[DEVICE_CUR]->features & FEAT_CAN_HOLD_PATCHES) || numFiles > 0) { + if((devices[DEVICE_CUR]->features & FEAT_REPLACES_DVD_FUNCS) || numFiles > 0) { DOLHEADER dolhdr; u32 main_dol_size = 0; // Calc size