Skip to content

Commit 36b7dee

Browse files
PARTIAL COMMIT - DO NOT MERGE TO MASTER
gdrom: don't raise an error for out-of-bounds GD-ROM reads. 2K sports games are doing 32767-sector reads that go past the end of the final track. I'm still not sure if this is the correct behavior or if there is some other error which is causing it to issue the abnormal read commands. with this commit, NBA 2K is now in-game. NFL 2K is not in-game yet because it hangs at a blank screen. see issue #97 on github.
1 parent 1142f76 commit 36b7dee

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

src/libwashdc/hw/gdrom/gdrom.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -739,22 +739,14 @@ static void gdrom_input_read_packet(struct gdrom_ctxt *gdrom) {
739739
unsigned fad_offs = 0;
740740
while (trans_len--) {
741741
struct gdrom_bufq_node *node =
742-
(struct gdrom_bufq_node*)malloc(sizeof(struct gdrom_bufq_node));
742+
(struct gdrom_bufq_node*)calloc(1, sizeof(struct gdrom_bufq_node));
743743

744744
if (!node)
745745
RAISE_ERROR(ERROR_FAILED_ALLOC);
746746

747-
if (mount_read_sectors(node->dat, start_addr + fad_offs++, 1) < 0) {
747+
if (mount_read_sectors(node->dat, start_addr + fad_offs++, 1) < 0)
748748
GDROM_ERROR("GD-ROM failed to read fad %u\n", fad_offs);
749749

750-
free(node);
751-
752-
gdrom->error_reg.sense_key = SENSE_KEY_ILLEGAL_REQ;
753-
gdrom->stat_reg.check = true;
754-
gdrom_state_transition(gdrom, GDROM_STATE_NORM);
755-
return;
756-
}
757-
758750
node->idx = 0;
759751
node->len = CDROM_FRAME_DATA_SIZE;
760752

@@ -1420,8 +1412,10 @@ enum gdrom_disc_state gdrom_get_drive_state(void) {
14201412

14211413
void gdrom_start_dma(struct gdrom_ctxt *gdrom) {
14221414
if (gdrom->dma_start_reg) {
1423-
if (gdrom->state != GDROM_STATE_DMA_WAITING)
1415+
if (gdrom->state != GDROM_STATE_DMA_WAITING) {
1416+
GDROM_ERROR("current GD-ROM state is %d\n", gdrom->state);
14241417
RAISE_ERROR(ERROR_UNIMPLEMENTED);
1418+
}
14251419

14261420
gdrom->stat_reg.drq = false;
14271421
gdrom->stat_reg.bsy = true;

0 commit comments

Comments
 (0)