Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Volgarr stuck at the end of IP.BIN #70

Open
Senryoku opened this issue Jan 6, 2025 · 0 comments
Open

Volgarr stuck at the end of IP.BIN #70

Senryoku opened this issue Jan 6, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@Senryoku
Copy link
Owner

Senryoku commented Jan 6, 2025

For some reason, the GDROM DMA data queue isn't completely emptied, preventing Volgarr from reaching the menu.

DCA3 has the same issue.

Both use KallistiOS.
All CDIs seem to have the same issue actually! Most likely an issue with MIL-CDs.

Previous hack:

Deecy/src/dreamcast.zig

Lines 622 to 639 in 870b8b2

// FIXME: Volgarr/DCA3 Hack (stays stuck on IP.BIN with data stuck in the queue)
// AFAIK the buffer is filled with the requested amount of sectors. The program leaves it with less than a sector of data left.
// It then spins forever in the Boot ROM checking for GDROM Alternate Status (5F7018), checking drq and bsy.
if (len == 0x20) {
if (self.gdrom.disc) |disc| {
const product_name = disc.get_product_name().?;
const product_id = disc.get_product_id().?;
// std.debug.print("GDROM: Product Name: '{any}', Product ID: '{any}'\n", .{ product_name, product_id });
if (self.gdrom.dma_data_queue.count == 0x2E0 - 0x20 and std.mem.startsWith(u8, product_name, "VOLGARR") and std.mem.startsWith(u8, product_id, "T0000 V1.000")) {
// Volgarr
dc_log.err(termcolor.red("Volgarr Hack: discarding remaining data from gdrom dma data queue."), .{});
self.gdrom.dma_data_queue.discard(self.gdrom.dma_data_queue.count);
} else if (self.gdrom.dma_data_queue.count == 0x1A0 - 0x20 and std.mem.eql(u8, product_name, &([_]u8{0} ** 16)) and std.mem.eql(u8, product_id, &([_]u8{0} ** 16))) {
// DCA3
dc_log.err(termcolor.red("DCA3 Hack: discarding remaining data from gdrom dma data queue."), .{});
self.gdrom.dma_data_queue.discard(self.gdrom.dma_data_queue.count);
}
}

Moved to:

Deecy/src/gdrom.zig

Lines 371 to 385 in bdeef8f

// FIXME: CDI Hack - See issue #70
// IP.BIN (using boot ROM syscalls) is stuck waiting for the GD drive with data in DMA queue.
const static = struct {
var consecutive_busy_reads: u64 = 0;
var last_dma_data_queue_count: u64 = 0;
};
if (self.status_register.bsy == 1 and self.dma_data_queue.count == static.last_dma_data_queue_count) {
static.consecutive_busy_reads += 1;
if (static.consecutive_busy_reads >= 10_000) {
gdrom_log.err(termcolor.red("CDI Hack: Stuck with data in dma queue, discarding."), .{});
self.dma_data_queue.discard(self.dma_data_queue.count);
self.status_register.bsy = 0;
}
} else static.consecutive_busy_reads = 0;
static.last_dma_data_queue_count = self.dma_data_queue.count;

Spend more time on this and tested on other emulators: Everything seems correct. The CD_READ command, the huge amount of 32-bytes DMAs and stopping before the end, all of it matches the behaviour in other emulators. I still have no idea what's different (I see no interrupts, no interaction with the gd drive except reads to AltStatus).
The boot ROM should abort the read command (by sending a NOP command), but I don't understand what triggers it.

@Senryoku Senryoku added the bug Something isn't working label Jan 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant