Skip to content

Commit

Permalink
- Add 2-disc support for block devices.
Browse files Browse the repository at this point in the history
- Always treat games as potentially reloading with read patches.
  • Loading branch information
Extrems committed Oct 11, 2019
1 parent a0a3768 commit a1f0d1c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
17 changes: 17 additions & 0 deletions cube/patches/alt/blockdevice.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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();
}
}
}
10 changes: 8 additions & 2 deletions cube/patches/alt/emulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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();
}
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion cube/swiss/source/gcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a1f0d1c

Please sign in to comment.