Fixed CD-ROM image mounting crashes and, hopefully, Linux compiles.

This commit is contained in:
OBattler
2025-01-28 18:39:26 +01:00
parent 90e1190c92
commit 7c6f45b4cd
5 changed files with 10 additions and 8 deletions

View File

@@ -22,6 +22,7 @@ endif()
add_executable(86Box
86box.c
all_devices.c
config.c
log.c
random.c

View File

@@ -22,6 +22,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <wchar.h>
#include <86box/86box.h>
#include <86box/device.h>
#include <86box/config.h>
@@ -1522,14 +1523,14 @@ cdrom_audio_play_toshiba(cdrom_t *dev, const uint32_t pos, const int type)
case 0x00:
dev->cd_end = pos2;
break;
case 0x40:
case 0x40: {
const int m = bcd2bin((pos >> 24) & 0xff);
const int s = bcd2bin((pos >> 16) & 0xff);
const int f = bcd2bin((pos >> 8) & 0xff);
pos2 = MSFtoLBA(m, s, f) - 150;
dev->cd_end = pos2;
break;
case 0x80:
} case 0x80:
dev->cd_end = (pos2 >> 24) & 0xff;
break;
case 0xc0:
@@ -1572,7 +1573,7 @@ cdrom_audio_scan(cdrom_t *dev, const uint32_t pos, const int type)
}
dev->seek_pos = pos2;
break;
case 0x40:
case 0x40: {
const int m = bcd2bin((pos >> 24) & 0xff);
const int s = bcd2bin((pos >> 16) & 0xff);
const int f = bcd2bin((pos >> 8) & 0xff);
@@ -1584,7 +1585,7 @@ cdrom_audio_scan(cdrom_t *dev, const uint32_t pos, const int type)
dev->seek_pos = pos2;
break;
case 0x80:
} case 0x80:
dev->seek_pos = (pos >> 24) & 0xff;
break;
default:

View File

@@ -2006,6 +2006,8 @@ image_open(cdrom_t *dev, const char *path)
int ret;
const int is_cue = ((ext == 4) && !stricmp(path + strlen(path) - ext + 1, "CUE"));
img->dev = dev;
if (is_cue) {
ret = image_load_cue(img, path);
@@ -2029,8 +2031,6 @@ image_open(cdrom_t *dev, const char *path)
sprintf(n, "CD-ROM %i Image", dev->id + 1);
img->log = log_open(n);
img->dev = dev;
dev->ops = &image_ops;
}
}

View File

@@ -30,7 +30,7 @@
#include <86box/cdrom.h>
#include <86box/log.h>
#include <86box/plat_unused.h>
#include <86box/plat_cdrom.h>
#include <86box/plat_cdrom_ioctl.h>
/* The addresses sent from the guest are absolute, ie. a LBA of 0 corresponds to a MSF of 00:00:00. Otherwise, the counter displayed by the guest is wrong:
there is a seeming 2 seconds in which audio plays but counter does not move, while a data track before audio jumps to 2 seconds before the actual start

View File

@@ -30,7 +30,7 @@
#include <86box/cdrom.h>
#include <86box/log.h>
#include <86box/plat_unused.h>
#include <86box/plat_cdrom.h>
#include <86box/plat_cdrom_ioctl.h>
/* The addresses sent from the guest are absolute, ie. a LBA of 0 corresponds to a MSF of 00:00:00. Otherwise, the counter displayed by the guest is wrong:
there is a seeming 2 seconds in which audio plays but counter does not move, while a data track before audio jumps to 2 seconds before the actual start