@@ -226,6 +226,10 @@ struct disc_state* disc_open(const char* path) {
226226 return NULL ;
227227}
228228
229+ #define CD_EXTRA_SIZE 800000000
230+ #define CDX_MAX_SIZE 734003200
231+ #define CD_MAX_SIZE 681574400
232+
229233int disc_detect_media (struct disc_state * disc ) {
230234 uint64_t size = disc_get_size (disc );
231235
@@ -235,13 +239,13 @@ int disc_detect_media(struct disc_state* disc) {
235239 uint64_t volume_size = * (uint32_t * )& disc -> pvd [0x50 ];
236240 uint64_t path_table_lba = * (uint32_t * )& disc -> pvd [0x8c ];
237241
238- // printf("sector_size=%lx volume_size=%lx (%ld) in bytes=%lx (%ld) path_table_lba=%lx (%ld) size=%lx (%ld)\n",
239- // sector_size,
240- // volume_size, volume_size,
241- // volume_size * sector_size, volume_size * sector_size,
242- // path_table_lba, path_table_lba,
243- // size, size
244- // );
242+ printf ("sector_size=%lx volume_size=%lx (%ld) in bytes=%lx (%ld) path_table_lba=%lx (%ld) size=%lx (%ld)\n" ,
243+ sector_size ,
244+ volume_size , volume_size ,
245+ volume_size * sector_size , volume_size * sector_size ,
246+ path_table_lba , path_table_lba ,
247+ size , size
248+ );
245249
246250 // DVD is dual-layer
247251 if ((volume_size * sector_size ) < size ) {
@@ -250,7 +254,7 @@ int disc_detect_media(struct disc_state* disc) {
250254 return DISC_MEDIA_DVD ;
251255 }
252256
253- if ((volume_size * sector_size ) <= 681574400 || path_table_lba != 257 ) {
257+ if ((( volume_size * sector_size ) <= CD_EXTRA_SIZE ) && ( path_table_lba != 257 ) ) {
254258 return DISC_MEDIA_CD ;
255259 }
256260
@@ -601,7 +605,7 @@ char* disc_read_boot_elf(struct disc_state* disc, char* buf, int s) {
601605
602606 // Reverse search for a path separator
603607 while (* ptr != '/' && * ptr != '\\' && * ptr != ':' ) {
604- if (* ptr == boot_path )
608+ if (ptr == boot_path )
605609 break ;
606610
607611 -- ptr ;
0 commit comments