Fixed for DVD-related stuff, DVD images should now be better readable on 86Box.

This commit is contained in:
OBattler
2020-01-17 03:02:12 +01:00
parent cf31b00d34
commit 2d02d941f8
4 changed files with 71 additions and 36 deletions

View File

@@ -21,6 +21,7 @@
#define __USE_LARGEFILE64 #define __USE_LARGEFILE64
#define _LARGEFILE_SOURCE #define _LARGEFILE_SOURCE
#define _LARGEFILE64_SOURCE #define _LARGEFILE64_SOURCE
#include <inttypes.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <stdint.h> #include <stdint.h>
@@ -113,18 +114,15 @@ image_get_capacity(cdrom_t *dev)
int first_track, last_track; int first_track, last_track;
int number, c; int number, c;
unsigned char attr; unsigned char attr;
TMSF tmsf; uint32_t address = 0, lb = 0;
uint32_t lb = 0;
uint32_t address;
if (!img) if (!img)
return 0; return 0;
cdi_get_audio_tracks(img, &first_track, &last_track, &tmsf); cdi_get_audio_tracks_lba(img, &first_track, &last_track, &lb);
for (c = 0; c <= last_track; c++) { for (c = 0; c <= last_track; c++) {
cdi_get_audio_track_info(img, 0, c + 1, &number, &tmsf, &attr); cdi_get_audio_track_info_lba(img, 0, c + 1, &number, &address, &attr);
address = MSFtoLBA(tmsf.min, tmsf.sec, tmsf.fr) - 150; /* Do the - 150 here as well. */
if (address > lb) if (address > lb)
lb = address; lb = address;
} }
@@ -280,7 +278,7 @@ cdrom_image_open(cdrom_t *dev, const wchar_t *fn)
dev->seek_pos = 0; dev->seek_pos = 0;
dev->cd_buflen = 0; dev->cd_buflen = 0;
dev->cdrom_capacity = image_get_capacity(dev); dev->cdrom_capacity = image_get_capacity(dev);
cdrom_image_log("CD-ROM capacity: %i sectors (%i bytes)\n", dev->cdrom_capacity, dev->cdrom_capacity << 11); cdrom_image_log("CD-ROM capacity: %i sectors (%" PRIi64 " bytes)\n", dev->cdrom_capacity, ((uint64_t) dev->cdrom_capacity) << 11ULL);
/* Attach this handler to the drive. */ /* Attach this handler to the drive. */
dev->ops = &cdrom_image_ops; dev->ops = &cdrom_image_ops;

View File

@@ -9,7 +9,7 @@
* CD-ROM image file handling module, translated to C from * CD-ROM image file handling module, translated to C from
* cdrom_dosbox.cpp. * cdrom_dosbox.cpp.
* *
* Version: @(#)cdrom_image_backend.c 1.0.4 2020/01/13 * Version: @(#)cdrom_image_backend.c 1.0.5 2020/01/17
* *
* Authors: Miran Grca, <mgrca8@gmail.com> * Authors: Miran Grca, <mgrca8@gmail.com>
* Fred N. van Kempen, <decwiz@yahoo.com> * Fred N. van Kempen, <decwiz@yahoo.com>
@@ -257,6 +257,17 @@ cdi_get_audio_tracks(cd_img_t *cdi, int *st_track, int *end, TMSF *lead_out)
} }
int
cdi_get_audio_tracks_lba(cd_img_t *cdi, int *st_track, int *end, uint32_t *lead_out)
{
*st_track = 1;
*end = cdi->tracks_num - 1;
*lead_out = cdi->tracks[*end].start;
return 1;
}
/* This replaces both Info and EndInfo, they are specified by a variable. */ /* This replaces both Info and EndInfo, they are specified by a variable. */
int int
cdi_get_audio_track_info(cd_img_t *cdi, int end, int track, int *track_num, TMSF *start, uint8_t *attr) cdi_get_audio_track_info(cd_img_t *cdi, int end, int track, int *track_num, TMSF *start, uint8_t *attr)
@@ -270,6 +281,24 @@ cdi_get_audio_track_info(cd_img_t *cdi, int end, int track, int *track_num, TMSF
pos = trk->start + 150; pos = trk->start + 150;
FRAMES_TO_MSF(pos, &start->min, &start->sec, &start->fr); FRAMES_TO_MSF(pos, &start->min, &start->sec, &start->fr);
*track_num = trk->track_number;
*attr = trk->attr;
return 1;
}
int
cdi_get_audio_track_info_lba(cd_img_t *cdi, int end, int track, int *track_num, uint32_t *start, uint8_t *attr)
{
track_t *trk = &cdi->tracks[track - 1];
if ((track < 1) || (track > cdi->tracks_num))
return 0;
*start = (uint32_t) trk->start;
*track_num = trk->track_number; *track_num = trk->track_number;
*attr = trk->attr; *attr = trk->attr;
@@ -556,6 +585,7 @@ cdi_load_iso(cd_img_t *cdi, const wchar_t *filename)
} }
trk.length = trk.file->get_length(trk.file) / trk.sector_size; trk.length = trk.file->get_length(trk.file) / trk.sector_size;
cdrom_image_backend_log("ISO: Data track: length = %" PRIu64 ", sector_size = %i\n", trk.length, trk.sector_size);
cdi_track_push_back(cdi, &trk); cdi_track_push_back(cdi, &trk);
/* Lead out track. */ /* Lead out track. */

View File

@@ -9,15 +9,15 @@
* CD-ROM image file handling module header , translated to C * CD-ROM image file handling module header , translated to C
* from cdrom_dosbox.h. * from cdrom_dosbox.h.
* *
* Version: @(#)cdrom_image_backend.h 1.0.1 2019/12/21 * Version: @(#)cdrom_image_backend.h 1.0.2 2020/01/17
* *
* Authors: Miran Grca, <mgrca8@gmail.com> * Authors: Miran Grca, <mgrca8@gmail.com>
* Fred N. van Kempen, <decwiz@yahoo.com> * Fred N. van Kempen, <decwiz@yahoo.com>
* The DOSBox Team, <unknown> * The DOSBox Team, <unknown>
* *
* Copyright 2016-2019 Miran Grca. * Copyright 2016-2020 Miran Grca.
* Copyright 2017-2019 Fred N. van Kempen. * Copyright 2017-2020 Fred N. van Kempen.
* Copyright 2002-2019 The DOSBox Team. * Copyright 2002-2020 The DOSBox Team.
*/ */
#ifndef CDROM_IMAGE_BACKEND_H #ifndef CDROM_IMAGE_BACKEND_H
#define CDROM_IMAGE_BACKEND_H #define CDROM_IMAGE_BACKEND_H
@@ -41,7 +41,7 @@
typedef struct SMSF { typedef struct SMSF {
uint8_t min; uint16_t min;
uint8_t sec; uint8_t sec;
uint8_t fr; uint8_t fr;
} TMSF; } TMSF;
@@ -74,7 +74,9 @@ typedef struct {
extern void cdi_close(cd_img_t *cdi); extern void cdi_close(cd_img_t *cdi);
extern int cdi_set_device(cd_img_t *cdi, const wchar_t *path); extern int cdi_set_device(cd_img_t *cdi, const wchar_t *path);
extern int cdi_get_audio_tracks(cd_img_t *cdi, int *st_track, int *end, TMSF *lead_out); extern int cdi_get_audio_tracks(cd_img_t *cdi, int *st_track, int *end, TMSF *lead_out);
extern int cdi_get_audio_tracks_lba(cd_img_t *cdi, int *st_track, int *end, uint32_t *lead_out);
extern int cdi_get_audio_track_info(cd_img_t *cdi, int end, int track, int *track_num, TMSF *start, uint8_t *attr); extern int cdi_get_audio_track_info(cd_img_t *cdi, int end, int track, int *track_num, TMSF *start, uint8_t *attr);
extern int cdi_get_audio_track_info_lba(cd_img_t *cdi, int end, int track, int *track_num, uint32_t *start, uint8_t *attr);
extern int cdi_get_track(cd_img_t *cdi, uint32_t sector); extern int cdi_get_track(cd_img_t *cdi, uint32_t sector);
extern int cdi_get_audio_sub(cd_img_t *cdi, uint32_t sector, uint8_t *attr, uint8_t *track, uint8_t *index, TMSF *rel_pos, TMSF *abs_pos); extern int cdi_get_audio_sub(cd_img_t *cdi, uint32_t sector, uint8_t *attr, uint8_t *track, uint8_t *index, TMSF *rel_pos, TMSF *abs_pos);
extern int cdi_read_sector(cd_img_t *cdi, uint8_t *buffer, int raw, uint32_t sector); extern int cdi_read_sector(cd_img_t *cdi, uint8_t *buffer, int raw, uint32_t sector);

View File

@@ -9,11 +9,11 @@
* Implementation of the CD-ROM drive with SCSI(-like) * Implementation of the CD-ROM drive with SCSI(-like)
* commands, for both ATAPI and SCSI usage. * commands, for both ATAPI and SCSI usage.
* *
* Version: @(#)scsi_cdrom.c 1.0.73 2019/12/13 * Version: @(#)scsi_cdrom.c 1.0.74 2020/01/17
* *
* Author: Miran Grca, <mgrca8@gmail.com> * Author: Miran Grca, <mgrca8@gmail.com>
* *
* Copyright 2016-2019 Miran Grca. * Copyright 2016-2020 Miran Grca.
*/ */
#include <inttypes.h> #include <inttypes.h>
#include <stdarg.h> #include <stdarg.h>
@@ -1080,29 +1080,31 @@ scsi_cdrom_read_dvd_structure(scsi_cdrom_t *dev, int format, const uint8_t *pack
return 0; return 0;
} }
buf[4] = 1; /* DVD-ROM, part version 1 */ buf[4] = 18; /* Length of Layer Information */
buf[5] = 0xf; /* 120mm disc, minimum rate unspecified */ buf[5] = 0;
buf[6] = 1; /* one layer, read-only (per MMC-2 spec) */
buf[7] = 0; /* default densities */ buf[6] = 1; /* DVD-ROM, part version 1 */
buf[7] = 0xf; /* 120mm disc, minimum rate unspecified */
buf[8] = 1; /* one layer, read-only (per MMC-2 spec) */
buf[9] = 0; /* default densities */
/* FIXME: 0x30000 per spec? */ /* FIXME: 0x30000 per spec? */
buf[8] = buf[9] = buf[10] = buf[11] = 0; /* start sector */ buf[10] = 0x00;
buf[12] = (total_sectors >> 24) & 0xff; /* end sector */ buf[11] = 0x03;
buf[13] = (total_sectors >> 16) & 0xff; buf[12] = buf[13] = 0; /* start sector */
buf[14] = (total_sectors >> 8) & 0xff;
buf[15] = total_sectors & 0xff;
buf[16] = (total_sectors >> 24) & 0xff; /* l0 end sector */ buf[14] = 0x00;
buf[17] = (total_sectors >> 16) & 0xff; buf[15] = (total_sectors >> 16) & 0xff; /* end sector */
buf[18] = (total_sectors >> 8) & 0xff; buf[16] = (total_sectors >> 8) & 0xff;
buf[19] = total_sectors & 0xff; buf[17] = total_sectors & 0xff;
/* Size of buffer, not including 2 byte size field */ buf[18] = 0x00;
buf[0] = ((2048 +2 ) >> 8) & 0xff; buf[19] = (total_sectors >> 16) & 0xff; /* l0 end sector */
buf[1] = (2048 + 2) & 0xff; buf[20] = (total_sectors >> 8) & 0xff;
buf[21] = total_sectors & 0xff;
/* 2k data + 4 byte header */ /* 20 bytes of data + 4 byte header */
return (2048 + 4); return (20 + 4);
case 0x01: /* DVD copyright information */ case 0x01: /* DVD copyright information */
buf[4] = 0; /* no copyright data */ buf[4] = 0; /* no copyright data */
@@ -1135,8 +1137,8 @@ scsi_cdrom_read_dvd_structure(scsi_cdrom_t *dev, int format, const uint8_t *pack
buf[4] = 0x00; /* Physical format */ buf[4] = 0x00; /* Physical format */
buf[5] = 0x40; /* Not writable, is readable */ buf[5] = 0x40; /* Not writable, is readable */
buf[6] = ((2048 + 4) >> 8) & 0xff; buf[6] = ((20 + 4) >> 8) & 0xff;
buf[7] = (2048 + 4) & 0xff; buf[7] = (20 + 4) & 0xff;
buf[8] = 0x01; /* Copyright info */ buf[8] = 0x01; /* Copyright info */
buf[9] = 0x40; /* Not writable, is readable */ buf[9] = 0x40; /* Not writable, is readable */
@@ -2130,7 +2132,10 @@ scsi_cdrom_command(scsi_common_t *sc, uint8_t *cdb)
if ((cdb[7] <= 0x7f) || (cdb[7] == 0xff)) { if ((cdb[7] <= 0x7f) || (cdb[7] == 0xff)) {
if (cdb[1] == 0) { if (cdb[1] == 0) {
ret = scsi_cdrom_read_dvd_structure(dev, format, cdb, dev->buffer); ret = scsi_cdrom_read_dvd_structure(dev, format, cdb, dev->buffer);
if (ret) { dev->buffer[0] = (ret >> 8);
dev->buffer[1] = (ret & 0xff);
dev->buffer[2] = dev->buffer[3] = 0x00;
if (ret) {
scsi_cdrom_set_buf_len(dev, BufLen, &alloc_length); scsi_cdrom_set_buf_len(dev, BufLen, &alloc_length);
scsi_cdrom_data_command_finish(dev, alloc_length, alloc_length, scsi_cdrom_data_command_finish(dev, alloc_length, alloc_length,
alloc_length, 0); alloc_length, 0);