pcecd: fix multifile CD, adjust default menu position.
This commit is contained in:
@@ -69,7 +69,7 @@ void pcecd_poll()
|
||||
data_mode = spi_w(0);
|
||||
DisableIO();
|
||||
|
||||
|
||||
|
||||
switch (data_mode & 0xFF)
|
||||
{
|
||||
case 0:
|
||||
@@ -120,6 +120,11 @@ static void notify_mount(int load)
|
||||
}
|
||||
}
|
||||
|
||||
int pcecd_using_cd()
|
||||
{
|
||||
return pcecdd.loaded;
|
||||
}
|
||||
|
||||
void pcecd_set_image(int num, const char *filename)
|
||||
{
|
||||
(void)num;
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#define PCECD_STATUS_CHECK_COND 1
|
||||
#define PCECD_STATUS_CONDITION_MET 2
|
||||
#define PCECD_STATUS_BUSY 4
|
||||
#define PCECD_STATUS_INTERMEDIATE 8
|
||||
#define PCECD_STATUS_INTERMEDIATE 8
|
||||
|
||||
#define SENSEKEY_NO_SENSE 0x0
|
||||
#define SENSEKEY_NOT_READY 0x2
|
||||
@@ -30,7 +30,7 @@
|
||||
#define SENSEKEY_HARDWARE_ERROR 0x4
|
||||
#define SENSEKEY_ILLEGAL_REQUEST 0x5
|
||||
#define SENSEKEY_UNIT_ATTENTION 0x6
|
||||
#define SENSEKEY_ABORTED_COMMAND 0xB
|
||||
#define SENSEKEY_ABORTED_COMMAND 0xB
|
||||
|
||||
#define NSE_NO_DISC 0x0B
|
||||
#define NSE_TRAY_OPEN 0x0D
|
||||
@@ -44,7 +44,7 @@
|
||||
#define NSE_END_OF_VOLUME 0x25
|
||||
#define NSE_INVALID_REQUEST_IN_CDB 0x27
|
||||
#define NSE_DISC_CHANGED 0x28
|
||||
#define NSE_AUDIO_NOT_PLAYING 0x2C
|
||||
#define NSE_AUDIO_NOT_PLAYING 0x2C
|
||||
|
||||
|
||||
#include "../../cd.h"
|
||||
@@ -84,7 +84,6 @@ private:
|
||||
int index;
|
||||
int lba;
|
||||
int cnt;
|
||||
uint16_t sectorSize;
|
||||
int scanOffset;
|
||||
int audioLength;
|
||||
int audioOffset;
|
||||
@@ -123,5 +122,6 @@ void pcecd_poll();
|
||||
void pcecd_set_image(int num, const char *filename);
|
||||
int pcecd_send_data(uint8_t* buf, int len, uint8_t index);
|
||||
void pcecd_reset();
|
||||
int pcecd_using_cd();
|
||||
|
||||
#endif
|
||||
|
||||
@@ -141,19 +141,19 @@ int pcecdd_t::LoadCUE(const char* filename) {
|
||||
{
|
||||
if (strstr(lptr, "MODE1/2048"))
|
||||
{
|
||||
this->sectorSize = 2048;
|
||||
this->toc.tracks[this->toc.last].sector_size = 2048;
|
||||
this->toc.tracks[this->toc.last].type = 1;
|
||||
}
|
||||
else if (strstr(lptr, "MODE1/2352"))
|
||||
{
|
||||
this->sectorSize = 2352;
|
||||
this->toc.tracks[this->toc.last].sector_size = 2352;
|
||||
this->toc.tracks[this->toc.last].type = 1;
|
||||
|
||||
FileSeek(&this->toc.tracks[this->toc.last].f, 0x10, SEEK_SET);
|
||||
}
|
||||
else if (strstr(lptr, "AUDIO"))
|
||||
{
|
||||
this->sectorSize = 2352;
|
||||
this->toc.tracks[this->toc.last].sector_size = 2352;
|
||||
this->toc.tracks[this->toc.last].type = 0;
|
||||
|
||||
FileSeek(&this->toc.tracks[this->toc.last].f, 0, SEEK_SET);
|
||||
@@ -195,7 +195,7 @@ int pcecdd_t::LoadCUE(const char* filename) {
|
||||
else if ((sscanf(lptr, "INDEX 01 %02d:%02d:%02d", &mm, &ss, &bb) == 3) ||
|
||||
(sscanf(lptr, "INDEX 1 %02d:%02d:%02d", &mm, &ss, &bb) == 3))
|
||||
{
|
||||
this->toc.tracks[this->toc.last].offset += pregap * 2352;
|
||||
this->toc.tracks[this->toc.last].offset = pregap * this->toc.tracks[this->toc.last].sector_size;
|
||||
|
||||
if (!this->toc.tracks[this->toc.last].f.opened())
|
||||
{
|
||||
@@ -211,11 +211,8 @@ int pcecdd_t::LoadCUE(const char* filename) {
|
||||
FileSeek(&this->toc.tracks[this->toc.last].f, 0, SEEK_SET);
|
||||
|
||||
this->toc.tracks[this->toc.last].start = this->toc.end + pregap;
|
||||
this->toc.tracks[this->toc.last].offset += this->toc.end * 2352;
|
||||
|
||||
int sectorSize = 2352;
|
||||
if (this->toc.tracks[this->toc.last].type) sectorSize = this->sectorSize;
|
||||
this->toc.tracks[this->toc.last].end = this->toc.tracks[this->toc.last].start + ((this->toc.tracks[this->toc.last].f.size + sectorSize - 1) / sectorSize);
|
||||
this->toc.tracks[this->toc.last].offset += this->toc.tracks[this->toc.last].start * this->toc.tracks[this->toc.last].sector_size;
|
||||
this->toc.tracks[this->toc.last].end = this->toc.tracks[this->toc.last].start + ((this->toc.tracks[this->toc.last].f.size + this->toc.tracks[this->toc.last].sector_size - 1) / this->toc.tracks[this->toc.last].sector_size);
|
||||
|
||||
this->toc.tracks[this->toc.last].start += (bb + ss * 75 + mm * 60 * 75);
|
||||
this->toc.end = this->toc.tracks[this->toc.last].end;
|
||||
@@ -243,46 +240,13 @@ int pcecdd_t::LoadCUE(const char* filename) {
|
||||
|
||||
int pcecdd_t::Load(const char *filename)
|
||||
{
|
||||
//char fname[1024 + 10];
|
||||
static char header[1024];
|
||||
fileTYPE *fd_img;
|
||||
|
||||
Unload();
|
||||
|
||||
if (LoadCUE(filename)) {
|
||||
return (-1);
|
||||
}
|
||||
|
||||
fd_img = &this->toc.tracks[0].f;
|
||||
|
||||
FileSeek(fd_img, 0, SEEK_SET);
|
||||
FileReadAdv(fd_img, header, 0x10);
|
||||
|
||||
if (!memcmp("SEGADISCSYSTEM", header, 14))
|
||||
{
|
||||
this->sectorSize = 2048;
|
||||
}
|
||||
else
|
||||
{
|
||||
FileReadAdv(fd_img, header, 0x10);
|
||||
if (!memcmp("SEGADISCSYSTEM", header, 14))
|
||||
{
|
||||
this->sectorSize = 2352;
|
||||
}
|
||||
}
|
||||
|
||||
if (this->sectorSize)
|
||||
{
|
||||
FileReadAdv(fd_img, header + 0x10, 0x200);
|
||||
FileSeek(fd_img, 0, SEEK_SET);
|
||||
}
|
||||
else
|
||||
{
|
||||
FileClose(fd_img);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
printf("\x1b[32mPCECD: Sector size = %u, Track 0 end = %u\n\x1b[0m", this->sectorSize, this->toc.tracks[0].end);
|
||||
printf("\x1b[32mPCECD: Tr0 Sector size = %u, Tr0 end = %u\n\x1b[0m", this->toc.tracks[0].sector_size, this->toc.tracks[0].end);
|
||||
|
||||
if (this->toc.last)
|
||||
{
|
||||
@@ -315,7 +279,6 @@ void pcecdd_t::Unload()
|
||||
}
|
||||
|
||||
memset(&this->toc, 0x00, sizeof(this->toc));
|
||||
this->sectorSize = 0;
|
||||
}
|
||||
|
||||
void pcecdd_t::Reset() {
|
||||
@@ -551,13 +514,10 @@ void pcecdd_t::CommandExec() {
|
||||
lba_ = this->toc.tracks[index].start;
|
||||
}
|
||||
|
||||
if (this->toc.tracks[index].type)
|
||||
if (this->toc.tracks[index].f.opened())
|
||||
{
|
||||
FileSeek(&this->toc.tracks[0].f, lba_ * this->sectorSize, SEEK_SET);
|
||||
}
|
||||
else if (this->toc.tracks[index].f.opened())
|
||||
{
|
||||
FileSeek(&this->toc.tracks[index].f, (lba_ * 2352) - this->toc.tracks[index].offset, SEEK_SET);
|
||||
int offset = (lba_ * this->toc.tracks[index].sector_size) - this->toc.tracks[index].offset;
|
||||
FileSeek(&this->toc.tracks[index].f, offset, SEEK_SET);
|
||||
}
|
||||
|
||||
this->audioOffset = 0;
|
||||
@@ -760,16 +720,16 @@ void pcecdd_t::ReadData(uint8_t *buf)
|
||||
{
|
||||
if (this->toc.tracks[this->index].type && (this->lba >= 0))
|
||||
{
|
||||
if (this->sectorSize == 2048)
|
||||
if (this->toc.tracks[this->index].sector_size == 2048)
|
||||
{
|
||||
FileSeek(&this->toc.tracks[0].f, this->lba * 2048, SEEK_SET);
|
||||
FileSeek(&this->toc.tracks[this->index].f, this->lba * 2048 - this->toc.tracks[this->index].offset, SEEK_SET);
|
||||
}
|
||||
else
|
||||
{
|
||||
FileSeek(&this->toc.tracks[0].f, this->lba * 2352 + 16, SEEK_SET);
|
||||
FileSeek(&this->toc.tracks[this->index].f, this->lba * 2352 + 16 - this->toc.tracks[this->index].offset, SEEK_SET);
|
||||
}
|
||||
|
||||
FileReadAdv(&this->toc.tracks[0].f, buf, 2048);
|
||||
FileReadAdv(&this->toc.tracks[this->index].f, buf, 2048);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user