--- BasiliskII/src/cdrom.cpp 2001/07/15 14:19:06 1.15 +++ BasiliskII/src/cdrom.cpp 2004/01/12 15:29:21 1.20 @@ -1,7 +1,7 @@ /* * cdrom.cpp - CD-ROM driver * - * Basilisk II (C) 1997-2001 Christian Bauer + * Basilisk II (C) 1997-2004 Christian Bauer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -180,11 +180,13 @@ static void find_hfs_partition(cdrom_dri { info.start_byte = 0; uint8 *map = new uint8[512]; + D(bug("Looking for HFS partitions on CD-ROM...\n")); // Search first 64 blocks for HFS partition for (int i=0; i<64; i++) { if (Sys_read(info.fh, map, i * 512, 512) != 512) break; + D(bug(" block %d, signature '%c%c' (%02x%02x)\n", i, map[0], map[1], map[0], map[1])); // Not a partition map block? Then look at next block uint16 sig = (map[0] << 8) | map[1]; @@ -193,8 +195,9 @@ static void find_hfs_partition(cdrom_dri // Partition map block found, Apple HFS partition? if (strcmp((char *)(map + 48), "Apple_HFS") == 0) { - info.start_byte = ntohl(((uint32 *)map)[2]) << 9; - D(bug(" HFS partition found at %d, %d blocks\n", info.start_byte, ntohl(((uint32 *)map)[3]))); + info.start_byte = (loff_t)((map[8] << 24) | (map[9] << 16) | (map[10] << 8) | map[11]) << 9; + uint32 num_blocks = (map[12] << 24) | (map[13] << 16) | (map[14] << 8) | map[15]; + D(bug(" HFS partition found at %d, %d blocks\n", info.start_byte, num_blocks)); break; } } @@ -211,7 +214,18 @@ static void read_toc(cdrom_drive_info &i // Read TOC memset(info.toc, 0, sizeof(info.toc)); SysCDReadTOC(info.fh, info.toc); - D(bug(" TOC: %08lx %08lx\n", ntohl(((uint32 *)info.toc)[0]), ntohl(((uint32 *)info.toc)[1]))); + +#if DEBUG + // Dump TOC for debugging + D(bug(" TOC:\n %02x%02x%02x%02x : %d bytes, first track = %d, last track = %d\n", info.toc[0], info.toc[1], info.toc[2], info.toc[3], (info.toc[0] << 8) | info.toc[1], info.toc[2], info.toc[3])); + for (int i=4; i<804; i+=8) { + D(bug(" %02x%02x%02x%02x%02x%02x%02x%02x: ", info.toc[i+0], info.toc[i+1], info.toc[i+2], info.toc[i+3], info.toc[i+4], info.toc[i+5], info.toc[i+6], info.toc[i+7])); + const char *type = (info.toc[i+2] == 0xaa ? "lead-out" : (info.toc[i+1] & 0x04 ? "data" : "audio")); + D(bug("track %d (%s), addr/ctrl 0x%02x, M %d S %d F %d\n", info.toc[i+2], type, info.toc[i+1], info.toc[i+5], info.toc[i+6], info.toc[i+7])); + if (info.toc[i+2] == 0xaa) + break; + } +#endif // Find lead-out track info.lead_out[0] = 0;