mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 07:17:45 -04:00
mcd, preparations for msu support
This commit is contained in:
parent
178a9b683c
commit
02ff025479
15 changed files with 153 additions and 170 deletions
|
@ -726,11 +726,6 @@ static unsigned char *PicoCartAlloc(int filesize, int is_sms)
|
||||||
rom_alloc_size = 0x10000;
|
rom_alloc_size = 0x10000;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// make alloc size at least sizeof(mcd_state),
|
|
||||||
// in case we want to switch to CD mode
|
|
||||||
if (filesize < sizeof(mcd_state))
|
|
||||||
filesize = sizeof(mcd_state);
|
|
||||||
|
|
||||||
// align to 512K for memhandlers
|
// align to 512K for memhandlers
|
||||||
rom_alloc_size = (filesize + 0x7ffff) & ~0x7ffff;
|
rom_alloc_size = (filesize + 0x7ffff) & ~0x7ffff;
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,6 +49,7 @@ static int handle_mp3(const char *fname, int index)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
track->type = CT_AUDIO;
|
||||||
track->fd = tmp_file;
|
track->fd = tmp_file;
|
||||||
track->offset = 0;
|
track->offset = 0;
|
||||||
|
|
||||||
|
@ -114,10 +115,11 @@ int load_cd_image(const char *cd_img_name, int *type)
|
||||||
}
|
}
|
||||||
tracks[0].fd = pmf;
|
tracks[0].fd = pmf;
|
||||||
tracks[0].fname = strdup(cd_img_name);
|
tracks[0].fname = strdup(cd_img_name);
|
||||||
|
tracks[0].type = *type & CT_AUDIO;
|
||||||
|
|
||||||
if (*type == CT_ISO)
|
if (*type == CT_ISO)
|
||||||
cd_img_sectors = pmf->size >>= 11; // size in sectors
|
cd_img_sectors = pmf->size >> 11; // size in sectors
|
||||||
else cd_img_sectors = pmf->size /= 2352;
|
else cd_img_sectors = pmf->size / 2352;
|
||||||
|
|
||||||
// cdd.c operates with lba - 150
|
// cdd.c operates with lba - 150
|
||||||
tracks[0].start = 0;
|
tracks[0].start = 0;
|
||||||
|
@ -125,8 +127,8 @@ int load_cd_image(const char *cd_img_name, int *type)
|
||||||
tracks[0].offset = 0;
|
tracks[0].offset = 0;
|
||||||
|
|
||||||
sprintf_lba(tmp_ext, sizeof(tmp_ext), 0);
|
sprintf_lba(tmp_ext, sizeof(tmp_ext), 0);
|
||||||
elprintf(EL_STATUS, "Track 1: %s %9i DATA %s",
|
elprintf(EL_STATUS, "Track 1: %s %9i %s %s",
|
||||||
tmp_ext, tracks[0].end, cd_img_name);
|
tmp_ext, tracks[0].end, tracks[0].type ? "AUDIO" : "DATA ", cd_img_name);
|
||||||
|
|
||||||
lba = cd_img_sectors;
|
lba = cd_img_sectors;
|
||||||
|
|
||||||
|
@ -185,13 +187,15 @@ int load_cd_image(const char *cd_img_name, int *type)
|
||||||
length = cue_data->tracks[n].sector_xlength;
|
length = cue_data->tracks[n].sector_xlength;
|
||||||
|
|
||||||
Pico_mcd->cdda_type = cue_data->tracks[n].type;
|
Pico_mcd->cdda_type = cue_data->tracks[n].type;
|
||||||
|
tracks[index].type = cue_data->tracks[n].type & CT_AUDIO;
|
||||||
|
|
||||||
tracks[index].start = lba;
|
tracks[index].start = lba;
|
||||||
lba += length;
|
lba += length;
|
||||||
tracks[index].end = lba;
|
tracks[index].end = lba;
|
||||||
|
|
||||||
sprintf_lba(tmp_ext, sizeof(tmp_ext), tracks[index].start);
|
sprintf_lba(tmp_ext, sizeof(tmp_ext), tracks[index].start);
|
||||||
elprintf(EL_STATUS, "Track %2i: %s %9i AUDIO %s", n, tmp_ext, length,
|
elprintf(EL_STATUS, "Track %2i: %s %9i %s %s", n, tmp_ext, length,
|
||||||
|
tracks[index].type ? "AUDIO" : "DATA ",
|
||||||
cue_data->tracks[n].fname ? cue_data->tracks[n].fname : "");
|
cue_data->tracks[n].fname ? cue_data->tracks[n].fname : "");
|
||||||
}
|
}
|
||||||
goto finish;
|
goto finish;
|
||||||
|
@ -246,6 +250,7 @@ int load_cd_image(const char *cd_img_name, int *type)
|
||||||
tracks[index].end = lba;
|
tracks[index].end = lba;
|
||||||
|
|
||||||
Pico_mcd->cdda_type = CT_MP3;
|
Pico_mcd->cdda_type = CT_MP3;
|
||||||
|
tracks[index].type = CT_AUDIO;
|
||||||
|
|
||||||
sprintf_lba(tmp_ext, sizeof(tmp_ext), tracks[index].start);
|
sprintf_lba(tmp_ext, sizeof(tmp_ext), tracks[index].start);
|
||||||
elprintf(EL_STATUS, "Track %2i: %s %9i AUDIO - %s",
|
elprintf(EL_STATUS, "Track %2i: %s %9i AUDIO - %s",
|
||||||
|
|
|
@ -172,19 +172,15 @@ cd_data_t *chd_parse(const char *fname)
|
||||||
}
|
}
|
||||||
memset(&data->tracks[count], 0, sizeof(data->tracks[0]));
|
memset(&data->tracks[count], 0, sizeof(data->tracks[0]));
|
||||||
|
|
||||||
if (count == 1) { // binary code
|
|
||||||
data->tracks[count].fname = strdup(fname);
|
data->tracks[count].fname = strdup(fname);
|
||||||
if (!strcmp(type, "MODE1_RAW") || !strcmp(type, "MODE2_RAW")) {
|
if (!strcmp(type, "MODE1_RAW") || !strcmp(type, "MODE2_RAW")) {
|
||||||
data->tracks[count].type = CT_BIN;
|
data->tracks[count].type = CT_BIN;
|
||||||
} else if (!strcmp(type, "MODE1") || !strcmp(type, "MODE2_FORM1")) {
|
} else if (!strcmp(type, "MODE1") || !strcmp(type, "MODE2_FORM1")) {
|
||||||
data->tracks[count].type = CT_ISO;
|
data->tracks[count].type = CT_ISO;
|
||||||
|
} else if (!strcmp(type, "AUDIO")) {
|
||||||
|
data->tracks[count].type = CT_CHD;
|
||||||
} else
|
} else
|
||||||
break;
|
break;
|
||||||
} else { // audio
|
|
||||||
if (strcmp(type, "AUDIO"))
|
|
||||||
break;
|
|
||||||
data->tracks[count].type = CT_CHD;
|
|
||||||
}
|
|
||||||
|
|
||||||
data->tracks[count].pregap = pregap;
|
data->tracks[count].pregap = pregap;
|
||||||
if (pgtype[0] != 'V') // VAUDIO includes pregap in file
|
if (pgtype[0] != 'V') // VAUDIO includes pregap in file
|
||||||
|
@ -344,17 +340,22 @@ file_ok:
|
||||||
else if (strcasecmp(ext, "wav") == 0)
|
else if (strcasecmp(ext, "wav") == 0)
|
||||||
data->tracks[count].type = CT_WAV;
|
data->tracks[count].type = CT_WAV;
|
||||||
else if (strcasecmp(ext, "bin") == 0)
|
else if (strcasecmp(ext, "bin") == 0)
|
||||||
data->tracks[count].type = CT_BIN;
|
data->tracks[count].type = CT_RAW;
|
||||||
else {
|
else {
|
||||||
elprintf(EL_STATUS, "unhandled audio format: \"%s\"",
|
elprintf(EL_STATUS, "unhandled audio format: \"%s\"",
|
||||||
data->tracks[count].fname);
|
data->tracks[count].fname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else if (data->tracks[count-1].type & CT_AUDIO)
|
||||||
{
|
{
|
||||||
// propagate previous
|
// propagate previous
|
||||||
data->tracks[count].type = data->tracks[count-1].type;
|
data->tracks[count].type = data->tracks[count-1].type;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// assume raw binary data
|
||||||
|
data->tracks[count].type = CT_RAW;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
elprintf(EL_STATUS, "unhandled track type: \"%s\"", buff2);
|
elprintf(EL_STATUS, "unhandled track type: \"%s\"", buff2);
|
||||||
|
|
|
@ -704,7 +704,6 @@ void cdc_reg_w(unsigned char data)
|
||||||
|
|
||||||
case 0x0f: /* RESET */
|
case 0x0f: /* RESET */
|
||||||
cdc_reset();
|
cdc_reset();
|
||||||
Pico_mcd->s68k_regs[0x04+1] = 0x10;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: /* by default, SBOUT is not used */
|
default: /* by default, SBOUT is not used */
|
||||||
|
@ -715,7 +714,7 @@ void cdc_reg_w(unsigned char data)
|
||||||
|
|
||||||
unsigned char cdc_reg_r(void)
|
unsigned char cdc_reg_r(void)
|
||||||
{
|
{
|
||||||
switch (Pico_mcd->s68k_regs[0x04+1] & 0x01F)
|
switch (Pico_mcd->s68k_regs[0x04+1] & 0x1F)
|
||||||
{
|
{
|
||||||
case 0x00:
|
case 0x00:
|
||||||
return 0xff;
|
return 0xff;
|
||||||
|
@ -835,7 +834,9 @@ unsigned short cdc_host_r(void)
|
||||||
|
|
||||||
/* clear DSR bit & set EDT bit (SCD register $04) */
|
/* clear DSR bit & set EDT bit (SCD register $04) */
|
||||||
Pico_mcd->s68k_regs[0x04+0] = (Pico_mcd->s68k_regs[0x04+0] & 0x07) | 0x80;
|
Pico_mcd->s68k_regs[0x04+0] = (Pico_mcd->s68k_regs[0x04+0] & 0x07) | 0x80;
|
||||||
} else if ((int16)cdc.dbc <= 2) {
|
|
||||||
|
} else if ((int16)cdc.dbc <= 2)
|
||||||
|
{
|
||||||
if (cdc.ifstat & BIT_DTEI) {
|
if (cdc.ifstat & BIT_DTEI) {
|
||||||
/* pending Data Transfer End interrupt */
|
/* pending Data Transfer End interrupt */
|
||||||
cdc.ifstat &= ~BIT_DTEI;
|
cdc.ifstat &= ~BIT_DTEI;
|
||||||
|
|
|
@ -49,6 +49,9 @@
|
||||||
|
|
||||||
cdd_t cdd;
|
cdd_t cdd;
|
||||||
|
|
||||||
|
#define is_audio(index) \
|
||||||
|
(cdd.toc.tracks[index].type & CT_AUDIO)
|
||||||
|
|
||||||
/* BCD conversion lookup tables */
|
/* BCD conversion lookup tables */
|
||||||
static const uint8 lut_BCD_8[100] =
|
static const uint8 lut_BCD_8[100] =
|
||||||
{
|
{
|
||||||
|
@ -239,12 +242,12 @@ int cdd_context_load(uint8 *state)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* seek to current track position */
|
/* seek to current track position */
|
||||||
if (!cdd.index)
|
if (!is_audio(cdd.index))
|
||||||
{
|
{
|
||||||
/* DATA track */
|
/* DATA track */
|
||||||
if (cdd.toc.tracks[0].fd)
|
if (cdd.toc.tracks[cdd.index].fd)
|
||||||
{
|
{
|
||||||
pm_seek(cdd.toc.tracks[0].fd, lba * cdd.sectorSize, SEEK_SET);
|
pm_seek(cdd.toc.tracks[cdd.index].fd, lba * cdd.sectorSize, SEEK_SET);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef USE_LIBTREMOR
|
#ifdef USE_LIBTREMOR
|
||||||
|
@ -318,7 +321,7 @@ int cdd_load(const char *filename, int type)
|
||||||
cdd.sectorSize = 2048;
|
cdd.sectorSize = 2048;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = (type == CT_BIN) ? 2352 : 2048;
|
ret = (type == CT_ISO ? 2048 : 2352);
|
||||||
if (ret != cdd.sectorSize)
|
if (ret != cdd.sectorSize)
|
||||||
elprintf(EL_STATUS|EL_ANOMALY, "cd: type detection mismatch");
|
elprintf(EL_STATUS|EL_ANOMALY, "cd: type detection mismatch");
|
||||||
pm_sectorsize(cdd.sectorSize, cdd.toc.tracks[0].fd);
|
pm_sectorsize(cdd.sectorSize, cdd.toc.tracks[0].fd);
|
||||||
|
@ -507,17 +510,17 @@ int cdd_unload(void)
|
||||||
void cdd_read_data(uint8 *dst)
|
void cdd_read_data(uint8 *dst)
|
||||||
{
|
{
|
||||||
/* only read DATA track sectors */
|
/* only read DATA track sectors */
|
||||||
if ((cdd.lba >= 0) && (cdd.lba < cdd.toc.tracks[0].end))
|
if ((cdd.lba >= 0) && (cdd.lba < cdd.toc.tracks[cdd.index].end))
|
||||||
{
|
{
|
||||||
/* BIN format ? */
|
/* BIN format ? */
|
||||||
if (cdd.sectorSize == 2352)
|
if (cdd.sectorSize == 2352)
|
||||||
{
|
{
|
||||||
/* skip 16-byte header */
|
/* skip 16-byte header */
|
||||||
pm_seek(cdd.toc.tracks[0].fd, cdd.lba * 2352 + 16, SEEK_SET);
|
pm_seek(cdd.toc.tracks[cdd.index].fd, cdd.lba * 2352 + 16, SEEK_SET);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* read sector data (Mode 1 = 2048 bytes) */
|
/* read sector data (Mode 1 = 2048 bytes) */
|
||||||
pm_read(dst, 2048, cdd.toc.tracks[0].fd);
|
pm_read(dst, 2048, cdd.toc.tracks[cdd.index].fd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -698,7 +701,7 @@ void cdd_update(void)
|
||||||
if (cdd.status == CD_PLAY)
|
if (cdd.status == CD_PLAY)
|
||||||
{
|
{
|
||||||
/* track type */
|
/* track type */
|
||||||
if (!cdd.index)
|
if (!is_audio(cdd.index))
|
||||||
{
|
{
|
||||||
/* DATA sector header (CD-ROM Mode 1) */
|
/* DATA sector header (CD-ROM Mode 1) */
|
||||||
uint8 header[4];
|
uint8 header[4];
|
||||||
|
@ -846,13 +849,13 @@ void cdd_update(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* seek to current block */
|
/* seek to current block */
|
||||||
if (!cdd.index)
|
if (!is_audio(cdd.index))
|
||||||
{
|
{
|
||||||
/* no AUDIO track playing */
|
/* no AUDIO track playing */
|
||||||
Pico_mcd->s68k_regs[0x36+0] = 0x01;
|
Pico_mcd->s68k_regs[0x36+0] = 0x01;
|
||||||
|
|
||||||
/* DATA track */
|
/* DATA track */
|
||||||
pm_seek(cdd.toc.tracks[0].fd, cdd.lba * cdd.sectorSize, SEEK_SET);
|
pm_seek(cdd.toc.tracks[cdd.index].fd, cdd.lba * cdd.sectorSize, SEEK_SET);
|
||||||
}
|
}
|
||||||
#ifdef USE_LIBTREMOR
|
#ifdef USE_LIBTREMOR
|
||||||
else if (cdd.toc.tracks[cdd.index].vf.seekable)
|
else if (cdd.toc.tracks[cdd.index].vf.seekable)
|
||||||
|
@ -914,7 +917,7 @@ void cdd_process(void)
|
||||||
set_reg16(0x3a, lut_BCD_16[(lba/75)/60]);
|
set_reg16(0x3a, lut_BCD_16[(lba/75)/60]);
|
||||||
set_reg16(0x3c, lut_BCD_16[(lba/75)%60]);
|
set_reg16(0x3c, lut_BCD_16[(lba/75)%60]);
|
||||||
set_reg16(0x3e, lut_BCD_16[(lba%75)]);
|
set_reg16(0x3e, lut_BCD_16[(lba%75)]);
|
||||||
Pico_mcd->s68k_regs[0x40+0] = cdd.index ? 0x00 : 0x04;
|
Pico_mcd->s68k_regs[0x40+0] = is_audio(cdd.index) ? 0x00 : 0x04;
|
||||||
} else if (Pico_mcd->s68k_regs[0x38+1] == 0x02) {
|
} else if (Pico_mcd->s68k_regs[0x38+1] == 0x02) {
|
||||||
/* then return valid track infos, e.g current track number in RS2-RS3 (fixes Lunar - The Silver Star) */
|
/* then return valid track infos, e.g current track number in RS2-RS3 (fixes Lunar - The Silver Star) */
|
||||||
Pico_mcd->s68k_regs[0x38+1] = 0x02;
|
Pico_mcd->s68k_regs[0x38+1] = 0x02;
|
||||||
|
@ -957,7 +960,7 @@ void cdd_process(void)
|
||||||
set_reg16(0x3a, lut_BCD_16[(lba/75)/60]);
|
set_reg16(0x3a, lut_BCD_16[(lba/75)/60]);
|
||||||
set_reg16(0x3c, lut_BCD_16[(lba/75)%60]);
|
set_reg16(0x3c, lut_BCD_16[(lba/75)%60]);
|
||||||
set_reg16(0x3e, lut_BCD_16[(lba%75)]);
|
set_reg16(0x3e, lut_BCD_16[(lba%75)]);
|
||||||
Pico_mcd->s68k_regs[0x40+0] = cdd.index ? 0x00 : 0x04; /* Current block flags in RS8 (bit0 = mute status, bit1: pre-emphasis status, bit2: track type) */
|
Pico_mcd->s68k_regs[0x40+0] = is_audio(cdd.index) ? 0x00 : 0x04; /* Current block flags in RS8 (bit0 = mute status, bit1: pre-emphasis status, bit2: track type) */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -969,7 +972,7 @@ void cdd_process(void)
|
||||||
set_reg16(0x3a, lut_BCD_16[(lba/75)/60]);
|
set_reg16(0x3a, lut_BCD_16[(lba/75)/60]);
|
||||||
set_reg16(0x3c, lut_BCD_16[(lba/75)%60]);
|
set_reg16(0x3c, lut_BCD_16[(lba/75)%60]);
|
||||||
set_reg16(0x3e, lut_BCD_16[(lba%75)]);
|
set_reg16(0x3e, lut_BCD_16[(lba%75)]);
|
||||||
Pico_mcd->s68k_regs[0x40+0] = cdd.index ? 0x00 : 0x04; /* Current block flags in RS8 (bit0 = mute status, bit1: pre-emphasis status, bit2: track type) */
|
Pico_mcd->s68k_regs[0x40+0] = is_audio(cdd.index) ? 0x00 : 0x04; /* Current block flags in RS8 (bit0 = mute status, bit1: pre-emphasis status, bit2: track type) */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1113,10 +1116,10 @@ void cdd_process(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* seek to current block */
|
/* seek to current block */
|
||||||
if (!index)
|
if (!is_audio(cdd.index))
|
||||||
{
|
{
|
||||||
/* DATA track */
|
/* DATA track */
|
||||||
pm_seek(cdd.toc.tracks[0].fd, lba * cdd.sectorSize, SEEK_SET);
|
pm_seek(cdd.toc.tracks[cdd.index].fd, lba * cdd.sectorSize, SEEK_SET);
|
||||||
}
|
}
|
||||||
#ifdef USE_LIBTREMOR
|
#ifdef USE_LIBTREMOR
|
||||||
else if (cdd.toc.tracks[index].vf.seekable)
|
else if (cdd.toc.tracks[index].vf.seekable)
|
||||||
|
@ -1212,10 +1215,10 @@ void cdd_process(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* seek to current block */
|
/* seek to current block */
|
||||||
if (!index)
|
if (!is_audio(cdd.index))
|
||||||
{
|
{
|
||||||
/* DATA track */
|
/* DATA track */
|
||||||
pm_seek(cdd.toc.tracks[0].fd, lba * cdd.sectorSize, SEEK_SET);
|
pm_seek(cdd.toc.tracks[cdd.index].fd, lba * cdd.sectorSize, SEEK_SET);
|
||||||
}
|
}
|
||||||
#ifdef USE_LIBTREMOR
|
#ifdef USE_LIBTREMOR
|
||||||
else if (cdd.toc.tracks[index].vf.seekable)
|
else if (cdd.toc.tracks[index].vf.seekable)
|
||||||
|
|
|
@ -60,6 +60,7 @@
|
||||||
/* CD track */
|
/* CD track */
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
int type;
|
||||||
char *fname;
|
char *fname;
|
||||||
void *fd;
|
void *fd;
|
||||||
#ifdef USE_LIBTREMOR
|
#ifdef USE_LIBTREMOR
|
||||||
|
|
|
@ -16,6 +16,7 @@ static unsigned int mcd_s68k_cycle_mult;
|
||||||
static unsigned int mcd_m68k_cycle_base;
|
static unsigned int mcd_m68k_cycle_base;
|
||||||
static unsigned int mcd_s68k_cycle_base;
|
static unsigned int mcd_s68k_cycle_base;
|
||||||
|
|
||||||
|
mcd_state *Pico_mcd;
|
||||||
|
|
||||||
PICO_INTERNAL void PicoInitMCD(void)
|
PICO_INTERNAL void PicoInitMCD(void)
|
||||||
{
|
{
|
||||||
|
@ -25,6 +26,10 @@ PICO_INTERNAL void PicoInitMCD(void)
|
||||||
PICO_INTERNAL void PicoExitMCD(void)
|
PICO_INTERNAL void PicoExitMCD(void)
|
||||||
{
|
{
|
||||||
cdd_unload();
|
cdd_unload();
|
||||||
|
if (Pico_mcd) {
|
||||||
|
plat_munmap(Pico_mcd, sizeof(mcd_state));
|
||||||
|
Pico_mcd = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PICO_INTERNAL void PicoPowerMCD(void)
|
PICO_INTERNAL void PicoPowerMCD(void)
|
||||||
|
@ -52,7 +57,8 @@ PICO_INTERNAL void PicoPowerMCD(void)
|
||||||
Pico_mcd->m.state_flags = PCD_ST_S68K_RST;
|
Pico_mcd->m.state_flags = PCD_ST_S68K_RST;
|
||||||
Pico_mcd->m.busreq = 2; // busreq on, s68k in reset
|
Pico_mcd->m.busreq = 2; // busreq on, s68k in reset
|
||||||
Pico_mcd->s68k_regs[3] = 1; // 2M word RAM mode, m68k access
|
Pico_mcd->s68k_regs[3] = 1; // 2M word RAM mode, m68k access
|
||||||
memset(Pico_mcd->bios + 0x70, 0xff, 4);
|
if (Pico.romsize <= 0x20000)
|
||||||
|
memset(Pico.rom + 0x70, 0xff, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pcd_soft_reset(void)
|
void pcd_soft_reset(void)
|
||||||
|
|
113
pico/cd/memory.c
113
pico/cd/memory.c
|
@ -23,6 +23,9 @@ MAKE_68K_WRITE16(s68k_write16, s68k_write16_map)
|
||||||
MAKE_68K_WRITE32(s68k_write32, s68k_write16_map)
|
MAKE_68K_WRITE32(s68k_write32, s68k_write16_map)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
u32 pcd_base_address;
|
||||||
|
#define BASE pcd_base_address
|
||||||
|
|
||||||
// -----------------------------------------------------------------
|
// -----------------------------------------------------------------
|
||||||
|
|
||||||
// provided by ASM code:
|
// provided by ASM code:
|
||||||
|
@ -113,7 +116,7 @@ static u32 m68k_reg_read16(u32 a)
|
||||||
d = Pico_mcd->s68k_regs[4]<<8;
|
d = Pico_mcd->s68k_regs[4]<<8;
|
||||||
goto end;
|
goto end;
|
||||||
case 6:
|
case 6:
|
||||||
d = *(u16 *)(Pico_mcd->bios + 0x72);
|
d = *(u16 *)(Pico.rom + 0x72);
|
||||||
goto end;
|
goto end;
|
||||||
case 8:
|
case 8:
|
||||||
d = cdc_host_r();
|
d = cdc_host_r();
|
||||||
|
@ -169,8 +172,8 @@ void m68k_reg_write8(u32 a, u32 d)
|
||||||
case 1:
|
case 1:
|
||||||
d &= 3;
|
d &= 3;
|
||||||
dold = Pico_mcd->m.busreq;
|
dold = Pico_mcd->m.busreq;
|
||||||
if (!(d & 1))
|
// if (!(d & 1))
|
||||||
d |= 2; // verified: can't release bus on reset
|
// d |= 2; // verified: can't release bus on reset
|
||||||
if (dold == d)
|
if (dold == d)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -185,7 +188,7 @@ void m68k_reg_write8(u32 a, u32 d)
|
||||||
elprintf(EL_CDREGS, "m68k: resetting s68k");
|
elprintf(EL_CDREGS, "m68k: resetting s68k");
|
||||||
SekResetS68k();
|
SekResetS68k();
|
||||||
}
|
}
|
||||||
if ((dold ^ d) & 2) {
|
if (((dold & 3) == 1) != ((d & 3) == 1)) {
|
||||||
elprintf(EL_INTSW, "m68k: s68k brq %i", d >> 1);
|
elprintf(EL_INTSW, "m68k: s68k brq %i", d >> 1);
|
||||||
remap_prg_window(d, Pico_mcd->s68k_regs[3]);
|
remap_prg_window(d, Pico_mcd->s68k_regs[3]);
|
||||||
}
|
}
|
||||||
|
@ -218,12 +221,12 @@ void m68k_reg_write8(u32 a, u32 d)
|
||||||
remap_word_ram(d);
|
remap_word_ram(d);
|
||||||
goto write_comm;
|
goto write_comm;
|
||||||
case 6:
|
case 6:
|
||||||
Pico_mcd->bios[MEM_BE2(0x72)] = d; // simple hint vector changer
|
Pico.rom[MEM_BE2(0x72)] = d; // simple hint vector changer
|
||||||
return;
|
return;
|
||||||
case 7:
|
case 7:
|
||||||
Pico_mcd->bios[MEM_BE2(0x73)] = d;
|
Pico.rom[MEM_BE2(0x73)] = d;
|
||||||
elprintf(EL_CDREGS, "hint vector set to %04x%04x",
|
elprintf(EL_CDREGS, "hint vector set to %04x%04x",
|
||||||
((u16 *)Pico_mcd->bios)[0x70/2], ((u16 *)Pico_mcd->bios)[0x72/2]);
|
((u16 *)Pico.rom)[0x70/2], ((u16 *)Pico.rom)[0x72/2]);
|
||||||
return;
|
return;
|
||||||
case 8:
|
case 8:
|
||||||
(void) cdc_host_r(); // acts same as reading
|
(void) cdc_host_r(); // acts same as reading
|
||||||
|
@ -659,7 +662,7 @@ static void PicoWriteM68k16_cell1(u32 a, u32 d)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// RAM cart (40000 - 7fffff, optional)
|
// RAM cart (400000 - 7fffff, optional)
|
||||||
static u32 PicoReadM68k8_ramc(u32 a)
|
static u32 PicoReadM68k8_ramc(u32 a)
|
||||||
{
|
{
|
||||||
u32 d = 0;
|
u32 d = 0;
|
||||||
|
@ -685,6 +688,8 @@ static u32 PicoReadM68k8_ramc(u32 a)
|
||||||
static u32 PicoReadM68k16_ramc(u32 a)
|
static u32 PicoReadM68k16_ramc(u32 a)
|
||||||
{
|
{
|
||||||
elprintf(EL_ANOMALY, "ramcart r16: [%06x] @%06x", a, SekPcS68k);
|
elprintf(EL_ANOMALY, "ramcart r16: [%06x] @%06x", a, SekPcS68k);
|
||||||
|
if ((a & 0xfffffc) == BASE+0x100) // CD detection by MSU
|
||||||
|
return (~a & 2) ? 0x5345 : 0x4741; // "SEGA"
|
||||||
return PicoReadM68k8_ramc(a + 1);
|
return PicoReadM68k8_ramc(a + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1093,13 +1098,12 @@ static const void *s68k_dec_write16[2][4] = {
|
||||||
|
|
||||||
static void remap_prg_window(u32 r1, u32 r3)
|
static void remap_prg_window(u32 r1, u32 r3)
|
||||||
{
|
{
|
||||||
// PRG RAM
|
// PRG RAM, mapped to main CPU if sub is not running
|
||||||
if (r1 & 2) {
|
if ((r1 & 3) != 1) {
|
||||||
void *bank = Pico_mcd->prg_ram_b[(r3 >> 6) & 3];
|
void *bank = Pico_mcd->prg_ram_b[(r3 >> 6) & 3];
|
||||||
cpu68k_map_all_ram(0x020000, 0x03ffff, bank, 0);
|
cpu68k_map_all_ram(BASE+0x020000, BASE+0x03ffff, bank, 0);
|
||||||
}
|
} else {
|
||||||
else {
|
m68k_map_unmap(BASE+0x020000, BASE+0x03ffff);
|
||||||
m68k_map_unmap(0x020000, 0x03ffff);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1145,14 +1149,14 @@ static void remap_word_ram(u32 r3)
|
||||||
// 2M mode.
|
// 2M mode.
|
||||||
bank = Pico_mcd->word_ram2M;
|
bank = Pico_mcd->word_ram2M;
|
||||||
if (r3 & 1) {
|
if (r3 & 1) {
|
||||||
cpu68k_map_all_ram(0x200000, 0x23ffff, bank, 0);
|
cpu68k_map_all_ram(BASE+0x200000, BASE+0x23ffff, bank, 0);
|
||||||
cpu68k_map_all_funcs(0x80000, 0xbffff,
|
cpu68k_map_all_funcs(0x80000, 0xbffff,
|
||||||
s68k_wordram_main_read8, s68k_wordram_main_read16,
|
s68k_wordram_main_read8, s68k_wordram_main_read16,
|
||||||
s68k_wordram_main_write8, s68k_wordram_main_write16, 1);
|
s68k_wordram_main_write8, s68k_wordram_main_write16, 1);
|
||||||
} else {
|
} else {
|
||||||
Pico_mcd->m.state_flags &= ~PCD_ST_S68K_SLEEP;
|
Pico_mcd->m.state_flags &= ~PCD_ST_S68K_SLEEP;
|
||||||
cpu68k_map_all_ram(0x080000, 0x0bffff, bank, 1);
|
cpu68k_map_all_ram(0x080000, 0x0bffff, bank, 1);
|
||||||
m68k_map_unmap(0x200000, 0x23ffff);
|
m68k_map_unmap(BASE+0x200000, BASE+0x23ffff);
|
||||||
}
|
}
|
||||||
// TODO: handle 0x0c0000
|
// TODO: handle 0x0c0000
|
||||||
}
|
}
|
||||||
|
@ -1161,11 +1165,11 @@ static void remap_word_ram(u32 r3)
|
||||||
int m = (r3 & 0x18) >> 3;
|
int m = (r3 & 0x18) >> 3;
|
||||||
Pico_mcd->m.state_flags &= ~PCD_ST_S68K_SLEEP;
|
Pico_mcd->m.state_flags &= ~PCD_ST_S68K_SLEEP;
|
||||||
bank = Pico_mcd->word_ram1M[b0];
|
bank = Pico_mcd->word_ram1M[b0];
|
||||||
cpu68k_map_all_ram(0x200000, 0x21ffff, bank, 0);
|
cpu68k_map_all_ram(BASE+0x200000, BASE+0x21ffff, bank, 0);
|
||||||
bank = Pico_mcd->word_ram1M[b0 ^ 1];
|
bank = Pico_mcd->word_ram1M[b0 ^ 1];
|
||||||
cpu68k_map_all_ram(0x0c0000, 0x0effff, bank, 1);
|
cpu68k_map_all_ram(0x0c0000, 0x0effff, bank, 1);
|
||||||
// "cell arrange" on m68k
|
// "cell arrange" on m68k
|
||||||
cpu68k_map_all_funcs(0x220000, 0x23ffff,
|
cpu68k_map_all_funcs(BASE+0x220000, BASE+0x23ffff,
|
||||||
m68k_cell_read8[b0], m68k_cell_read16[b0],
|
m68k_cell_read8[b0], m68k_cell_read16[b0],
|
||||||
m68k_cell_write8[b0], m68k_cell_write16[b0], 0);
|
m68k_cell_write8[b0], m68k_cell_write16[b0], 0);
|
||||||
// "decode format" on s68k
|
// "decode format" on s68k
|
||||||
|
@ -1187,7 +1191,7 @@ void pcd_state_loaded_mem(void)
|
||||||
Pico_mcd->m.dmna_ret_2m &= 3;
|
Pico_mcd->m.dmna_ret_2m &= 3;
|
||||||
|
|
||||||
// restore hint vector
|
// restore hint vector
|
||||||
*(u16 *)(Pico_mcd->bios + 0x72) = Pico_mcd->m.hint_vector;
|
*(u16 *)(Pico.rom + 0x72) = Pico_mcd->m.hint_vector;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef EMU_M68K
|
#ifdef EMU_M68K
|
||||||
|
@ -1196,6 +1200,10 @@ static void m68k_mem_setup_cd(void);
|
||||||
|
|
||||||
PICO_INTERNAL void PicoMemSetupCD(void)
|
PICO_INTERNAL void PicoMemSetupCD(void)
|
||||||
{
|
{
|
||||||
|
if (!Pico_mcd)
|
||||||
|
Pico_mcd = plat_mmap(0x05000000, sizeof(mcd_state), 0, 0);
|
||||||
|
pcd_base_address = (Pico.romsize > 0x20000 ? 0x400000 : 0x000000);
|
||||||
|
|
||||||
// setup default main68k map
|
// setup default main68k map
|
||||||
PicoMemSetup();
|
PicoMemSetup();
|
||||||
|
|
||||||
|
@ -1215,30 +1223,30 @@ PICO_INTERNAL void PicoMemSetupCD(void)
|
||||||
cpu68k_map_set(m68k_write16_map, 0xa10000, 0xa1ffff, PicoWrite16_mcd_io, 1);
|
cpu68k_map_set(m68k_write16_map, 0xa10000, 0xa1ffff, PicoWrite16_mcd_io, 1);
|
||||||
|
|
||||||
// sub68k map
|
// sub68k map
|
||||||
cpu68k_map_set(s68k_read8_map, 0x000000, 0xffffff, s68k_unmapped_read8, 1);
|
cpu68k_map_set(s68k_read8_map, 0x000000, 0xffffff, s68k_unmapped_read8, 3);
|
||||||
cpu68k_map_set(s68k_read16_map, 0x000000, 0xffffff, s68k_unmapped_read16, 1);
|
cpu68k_map_set(s68k_read16_map, 0x000000, 0xffffff, s68k_unmapped_read16, 3);
|
||||||
cpu68k_map_set(s68k_write8_map, 0x000000, 0xffffff, s68k_unmapped_write8, 1);
|
cpu68k_map_set(s68k_write8_map, 0x000000, 0xffffff, s68k_unmapped_write8, 3);
|
||||||
cpu68k_map_set(s68k_write16_map, 0x000000, 0xffffff, s68k_unmapped_write16, 1);
|
cpu68k_map_set(s68k_write16_map, 0x000000, 0xffffff, s68k_unmapped_write16, 3);
|
||||||
|
|
||||||
// PRG RAM
|
// PRG RAM
|
||||||
cpu68k_map_set(s68k_read8_map, 0x000000, 0x07ffff, Pico_mcd->prg_ram, 0);
|
cpu68k_map_set(s68k_read8_map, 0x000000, 0x07ffff, Pico_mcd->prg_ram, 2);
|
||||||
cpu68k_map_set(s68k_read16_map, 0x000000, 0x07ffff, Pico_mcd->prg_ram, 0);
|
cpu68k_map_set(s68k_read16_map, 0x000000, 0x07ffff, Pico_mcd->prg_ram, 2);
|
||||||
cpu68k_map_set(s68k_write8_map, 0x000000, 0x07ffff, Pico_mcd->prg_ram, 0);
|
cpu68k_map_set(s68k_write8_map, 0x000000, 0x07ffff, Pico_mcd->prg_ram, 2);
|
||||||
cpu68k_map_set(s68k_write16_map, 0x000000, 0x07ffff, Pico_mcd->prg_ram, 0);
|
cpu68k_map_set(s68k_write16_map, 0x000000, 0x07ffff, Pico_mcd->prg_ram, 2);
|
||||||
cpu68k_map_set(s68k_write8_map, 0x000000, 0x01ffff, PicoWriteS68k8_prgwp, 1);
|
cpu68k_map_set(s68k_write8_map, 0x000000, 0x01ffff, PicoWriteS68k8_prgwp, 3);
|
||||||
cpu68k_map_set(s68k_write16_map, 0x000000, 0x01ffff, PicoWriteS68k16_prgwp, 1);
|
cpu68k_map_set(s68k_write16_map, 0x000000, 0x01ffff, PicoWriteS68k16_prgwp, 3);
|
||||||
|
|
||||||
// BRAM
|
// BRAM
|
||||||
cpu68k_map_set(s68k_read8_map, 0xfe0000, 0xfeffff, PicoReadS68k8_bram, 1);
|
cpu68k_map_set(s68k_read8_map, 0xfe0000, 0xfeffff, PicoReadS68k8_bram, 3);
|
||||||
cpu68k_map_set(s68k_read16_map, 0xfe0000, 0xfeffff, PicoReadS68k16_bram, 1);
|
cpu68k_map_set(s68k_read16_map, 0xfe0000, 0xfeffff, PicoReadS68k16_bram, 3);
|
||||||
cpu68k_map_set(s68k_write8_map, 0xfe0000, 0xfeffff, PicoWriteS68k8_bram, 1);
|
cpu68k_map_set(s68k_write8_map, 0xfe0000, 0xfeffff, PicoWriteS68k8_bram, 3);
|
||||||
cpu68k_map_set(s68k_write16_map, 0xfe0000, 0xfeffff, PicoWriteS68k16_bram, 1);
|
cpu68k_map_set(s68k_write16_map, 0xfe0000, 0xfeffff, PicoWriteS68k16_bram, 3);
|
||||||
|
|
||||||
// PCM, regs
|
// PCM, regs
|
||||||
cpu68k_map_set(s68k_read8_map, 0xff0000, 0xffffff, PicoReadS68k8_pr, 1);
|
cpu68k_map_set(s68k_read8_map, 0xff0000, 0xffffff, PicoReadS68k8_pr, 3);
|
||||||
cpu68k_map_set(s68k_read16_map, 0xff0000, 0xffffff, PicoReadS68k16_pr, 1);
|
cpu68k_map_set(s68k_read16_map, 0xff0000, 0xffffff, PicoReadS68k16_pr, 3);
|
||||||
cpu68k_map_set(s68k_write8_map, 0xff0000, 0xffffff, PicoWriteS68k8_pr, 1);
|
cpu68k_map_set(s68k_write8_map, 0xff0000, 0xffffff, PicoWriteS68k8_pr, 3);
|
||||||
cpu68k_map_set(s68k_write16_map, 0xff0000, 0xffffff, PicoWriteS68k16_pr, 1);
|
cpu68k_map_set(s68k_write16_map, 0xff0000, 0xffffff, PicoWriteS68k16_pr, 3);
|
||||||
|
|
||||||
// RAMs
|
// RAMs
|
||||||
remap_prg_window(2,1);
|
remap_prg_window(2,1);
|
||||||
|
@ -1265,37 +1273,6 @@ PICO_INTERNAL void PicoMemSetupCD(void)
|
||||||
PicoCpuFS68k.write_byte = (void *)s68k_write8;
|
PicoCpuFS68k.write_byte = (void *)s68k_write8;
|
||||||
PicoCpuFS68k.write_word = (void *)s68k_write16;
|
PicoCpuFS68k.write_word = (void *)s68k_write16;
|
||||||
PicoCpuFS68k.write_long = (void *)s68k_write32;
|
PicoCpuFS68k.write_long = (void *)s68k_write32;
|
||||||
|
|
||||||
// setup FAME fetchmap
|
|
||||||
{
|
|
||||||
#if defined __clang__ || defined HW_WUP
|
|
||||||
volatile // prevent strange relocs from clang
|
|
||||||
#endif
|
|
||||||
uptr ptr_ram = (uptr)PicoMem.ram;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
// M68k
|
|
||||||
// by default, point everything to fitst 64k of ROM (BIOS)
|
|
||||||
for (i = 0; i < M68K_FETCHBANK1; i++)
|
|
||||||
PicoCpuFM68k.Fetch[i] = (uptr)Pico.rom - (i<<(24-FAMEC_FETCHBITS));
|
|
||||||
// now real ROM (BIOS)
|
|
||||||
for (i = 0; i < M68K_FETCHBANK1 && (i<<(24-FAMEC_FETCHBITS)) < Pico.romsize; i++)
|
|
||||||
PicoCpuFM68k.Fetch[i] = (uptr)Pico.rom;
|
|
||||||
// .. and RAM
|
|
||||||
for (i = M68K_FETCHBANK1*14/16; i < M68K_FETCHBANK1; i++)
|
|
||||||
PicoCpuFM68k.Fetch[i] = ptr_ram - (i<<(24-FAMEC_FETCHBITS));
|
|
||||||
// S68k
|
|
||||||
// PRG RAM is default
|
|
||||||
for (i = 0; i < M68K_FETCHBANK1; i++)
|
|
||||||
PicoCpuFS68k.Fetch[i] = (uptr)Pico_mcd->prg_ram - (i<<(24-FAMEC_FETCHBITS));
|
|
||||||
// real PRG RAM
|
|
||||||
for (i = 0; i < M68K_FETCHBANK1 && (i<<(24-FAMEC_FETCHBITS)) < 0x80000; i++)
|
|
||||||
PicoCpuFS68k.Fetch[i] = (uptr)Pico_mcd->prg_ram;
|
|
||||||
// WORD RAM 2M area
|
|
||||||
for (i = M68K_FETCHBANK1*0x08/0x100; i < M68K_FETCHBANK1 && (i<<(24-FAMEC_FETCHBITS)) < 0xc0000; i++)
|
|
||||||
PicoCpuFS68k.Fetch[i] = (uptr)Pico_mcd->word_ram2M - 0x80000;
|
|
||||||
// remap_word_ram() will setup word ram for both
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef EMU_M68K
|
#ifdef EMU_M68K
|
||||||
m68k_mem_setup_cd();
|
m68k_mem_setup_cd();
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
.global PicoWriteS68k16_dec_m2b1
|
.global PicoWriteS68k16_dec_m2b1
|
||||||
|
|
||||||
@ externs, just for reference
|
@ externs, just for reference
|
||||||
.extern Pico
|
.extern Pico_mcd
|
||||||
.extern cdc_host_r
|
.extern cdc_host_r
|
||||||
.extern m68k_reg_write8
|
.extern m68k_reg_write8
|
||||||
.extern s68k_reg_read16
|
.extern s68k_reg_read16
|
||||||
|
@ -130,9 +130,9 @@ PicoReadM68k8_cell1: @ 0x220000 - 0x23ffff, cell arranged
|
||||||
mov r3, #0x0e0000
|
mov r3, #0x0e0000
|
||||||
0:
|
0:
|
||||||
cell_map
|
cell_map
|
||||||
PIC_LDR(r1, r2, Pico)
|
PIC_LDR(r1, r2, Pico_mcd)
|
||||||
add r0, r0, r3
|
add r0, r0, r3
|
||||||
ldr r1, [r1, #OFS_Pico_rom] @ Pico.mcd (used everywhere)
|
ldr r1, [r1] @ Pico.mcd (used everywhere)
|
||||||
eor r0, r0, #1
|
eor r0, r0, #1
|
||||||
ldrb r0, [r1, r0]
|
ldrb r0, [r1, r0]
|
||||||
bx lr
|
bx lr
|
||||||
|
@ -143,9 +143,9 @@ PicoRead8_mcd_io:
|
||||||
cmp r1, #0x2000 @ a120xx?
|
cmp r1, #0x2000 @ a120xx?
|
||||||
bne PicoRead8_io
|
bne PicoRead8_io
|
||||||
|
|
||||||
PIC_LDR(r1, r2, Pico)
|
PIC_LDR(r1, r2, Pico_mcd)
|
||||||
and r0, r0, #0x3f
|
and r0, r0, #0x3f
|
||||||
ldr r1, [r1, #OFS_Pico_rom] @ Pico.mcd
|
ldr r1, [r1] @ Pico.mcd
|
||||||
cmp r0, #0x0e
|
cmp r0, #0x0e
|
||||||
PIC_XB(lt ,r0, lsl #2)
|
PIC_XB(lt ,r0, lsl #2)
|
||||||
b m_m68k_read8_hi
|
b m_m68k_read8_hi
|
||||||
|
@ -242,9 +242,9 @@ PicoReadM68k16_cell1: @ 0x220000 - 0x23ffff, cell arranged
|
||||||
mov r3, #0x0e0000
|
mov r3, #0x0e0000
|
||||||
0:
|
0:
|
||||||
cell_map
|
cell_map
|
||||||
PIC_LDR(r1, r2, Pico)
|
PIC_LDR(r1, r2, Pico_mcd)
|
||||||
add r0, r0, r3
|
add r0, r0, r3
|
||||||
ldr r1, [r1, #OFS_Pico_rom] @ Pico.mcd
|
ldr r1, [r1] @ Pico.mcd
|
||||||
bic r0, r0, #1
|
bic r0, r0, #1
|
||||||
ldrh r0, [r1, r0]
|
ldrh r0, [r1, r0]
|
||||||
bx lr
|
bx lr
|
||||||
|
@ -256,9 +256,9 @@ PicoRead16_mcd_io:
|
||||||
bne PicoRead16_io
|
bne PicoRead16_io
|
||||||
|
|
||||||
m_m68k_read16_m68k_regs:
|
m_m68k_read16_m68k_regs:
|
||||||
PIC_LDR(r1, r2, Pico)
|
PIC_LDR(r1, r2, Pico_mcd)
|
||||||
and r0, r0, #0x3e
|
and r0, r0, #0x3e
|
||||||
ldr r1, [r1, #OFS_Pico_rom] @ Pico.mcd
|
ldr r1, [r1, @ Pico.mcd
|
||||||
cmp r0, #0x0e
|
cmp r0, #0x0e
|
||||||
PIC_XB(lt ,r0, lsl #1)
|
PIC_XB(lt ,r0, lsl #1)
|
||||||
b m_m68k_read16_hi
|
b m_m68k_read16_hi
|
||||||
|
@ -333,9 +333,9 @@ PicoWriteM68k8_cell1: @ 0x220000 - 0x23ffff, cell arranged
|
||||||
0:
|
0:
|
||||||
mov r3, r1
|
mov r3, r1
|
||||||
cell_map
|
cell_map
|
||||||
PIC_LDR(r2, r1, Pico)
|
PIC_LDR(r2, r1, Pico_mcd)
|
||||||
add r0, r0, r12
|
add r0, r0, r12
|
||||||
ldr r2, [r2, #OFS_Pico_rom] @ Pico.mcd
|
ldr r2, [r2] @ Pico.mcd
|
||||||
ldr r2, [r2]
|
ldr r2, [r2]
|
||||||
eor r0, r0, #1
|
eor r0, r0, #1
|
||||||
strb r3, [r2, r0]
|
strb r3, [r2, r0]
|
||||||
|
@ -361,9 +361,9 @@ PicoWriteM68k16_cell1: @ 0x220000 - 0x23ffff, cell arranged
|
||||||
0:
|
0:
|
||||||
mov r3, r1
|
mov r3, r1
|
||||||
cell_map
|
cell_map
|
||||||
PIC_LDR(r1, r2, Pico)
|
PIC_LDR(r1, r2, Pico_mcd)
|
||||||
add r0, r0, r12
|
add r0, r0, r12
|
||||||
ldr r1, [r1, #OFS_Pico_rom] @ Pico.mcd
|
ldr r1, [r1] @ Pico.mcd
|
||||||
bic r0, r0, #1
|
bic r0, r0, #1
|
||||||
strh r3, [r1, r0]
|
strh r3, [r1, r0]
|
||||||
bx lr
|
bx lr
|
||||||
|
@ -403,9 +403,9 @@ PicoReadS68k8_dec0: @ 0x080000 - 0x0bffff
|
||||||
PicoReadS68k8_dec1:
|
PicoReadS68k8_dec1:
|
||||||
mov r3, #0x0a0000 @ + ^ / 2
|
mov r3, #0x0a0000 @ + ^ / 2
|
||||||
0:
|
0:
|
||||||
PIC_LDR(r2, r1, Pico)
|
PIC_LDR(r2, r1, Pico_mcd)
|
||||||
eor r0, r0, #2
|
eor r0, r0, #2
|
||||||
ldr r2, [r2, #OFS_Pico_rom] @ Pico.mcd
|
ldr r2, [r2] @ Pico.mcd
|
||||||
movs r0, r0, lsr #1 @ +4-6 <<16
|
movs r0, r0, lsr #1 @ +4-6 <<16
|
||||||
add r2, r2, r3 @ map to our address
|
add r2, r2, r3 @ map to our address
|
||||||
ldrb r0, [r2, r0]
|
ldrb r0, [r2, r0]
|
||||||
|
@ -435,8 +435,8 @@ m_s68k_read8_regs:
|
||||||
bx lr
|
bx lr
|
||||||
|
|
||||||
m_s68k_read8_comm:
|
m_s68k_read8_comm:
|
||||||
PIC_LDR(r1, r2, Pico)
|
PIC_LDR(r1, r2, Pico_mcd)
|
||||||
ldr r1, [r1, #OFS_Pico_rom] @ Pico.mcd
|
ldr r1, [r1] @ Pico.mcd
|
||||||
add r1, r1, #0x110000
|
add r1, r1, #0x110000
|
||||||
ldrb r1, [r1, r0]
|
ldrb r1, [r1, r0]
|
||||||
bic r0, r0, #1
|
bic r0, r0, #1
|
||||||
|
@ -448,9 +448,9 @@ m_s68k_read8_pcm:
|
||||||
bne m_read_null
|
bne m_read_null
|
||||||
|
|
||||||
@ must not trash r3 and r12
|
@ must not trash r3 and r12
|
||||||
PIC_LDR(r1, r2, Pico)
|
PIC_LDR(r1, r2, Pico_mcd)
|
||||||
bic r0, r0, #0xff0000
|
bic r0, r0, #0xff0000
|
||||||
ldr r1, [r1, #OFS_Pico_rom] @ Pico.mcd
|
ldr r1, [r1] @ Pico.mcd
|
||||||
mov r2, #0x110000
|
mov r2, #0x110000
|
||||||
orr r2, r2, #0x002200
|
orr r2, r2, #0x002200
|
||||||
cmp r0, #0x2000
|
cmp r0, #0x2000
|
||||||
|
@ -483,9 +483,9 @@ PicoReadS68k16_dec0: @ 0x080000 - 0x0bffff
|
||||||
PicoReadS68k16_dec1:
|
PicoReadS68k16_dec1:
|
||||||
mov r3, #0x0a0000 @ + ^ / 2
|
mov r3, #0x0a0000 @ + ^ / 2
|
||||||
0:
|
0:
|
||||||
PIC_LDR(r2, r1, Pico)
|
PIC_LDR(r2, r1, Pico_mcd)
|
||||||
eor r0, r0, #2
|
eor r0, r0, #2
|
||||||
ldr r2, [r2, #OFS_Pico_rom] @ Pico.mcd
|
ldr r2, [r2] @ Pico.mcd
|
||||||
mov r0, r0, lsr #1 @ +4-6 <<16
|
mov r0, r0, lsr #1 @ +4-6 <<16
|
||||||
add r2, r2, r3 @ map to our address
|
add r2, r2, r3 @ map to our address
|
||||||
ldrb r0, [r2, r0]
|
ldrb r0, [r2, r0]
|
||||||
|
@ -513,9 +513,9 @@ m_s68k_read16_regs:
|
||||||
|
|
||||||
|
|
||||||
.macro m_s68k_write8_2M_decode
|
.macro m_s68k_write8_2M_decode
|
||||||
PIC_LDR(r2, ip, Pico)
|
PIC_LDR(r2, ip, Pico_mcd)
|
||||||
eor r0, r0, #2
|
eor r0, r0, #2
|
||||||
ldr r2, [r2, #OFS_Pico_rom] @ Pico.mcd
|
ldr r2, [r2] @ Pico.mcd
|
||||||
movs r0, r0, lsr #1 @ +4-6 <<16
|
movs r0, r0, lsr #1 @ +4-6 <<16
|
||||||
add r2, r2, r3 @ map to our address
|
add r2, r2, r3 @ map to our address
|
||||||
.endm
|
.endm
|
||||||
|
@ -597,9 +597,9 @@ m_s68k_write8_pcm:
|
||||||
bxlt lr
|
bxlt lr
|
||||||
|
|
||||||
m_s68k_write8_pcm_ram:
|
m_s68k_write8_pcm_ram:
|
||||||
PIC_LDR(r3, r2, Pico)
|
PIC_LDR(r3, r2, Pico_mcd)
|
||||||
bic r0, r0, #0x00e000
|
bic r0, r0, #0x00e000
|
||||||
ldr r3, [r3, #OFS_Pico_rom] @ Pico.mcd
|
ldr r3, [r3] @ Pico.mcd
|
||||||
mov r0, r0, lsr #1
|
mov r0, r0, lsr #1
|
||||||
add r2, r3, #0x110000
|
add r2, r3, #0x110000
|
||||||
add r2, r2, #0x002200
|
add r2, r2, #0x002200
|
||||||
|
@ -615,9 +615,9 @@ m_s68k_write8_pcm_ram:
|
||||||
|
|
||||||
|
|
||||||
.macro m_s68k_write16_2M_decode
|
.macro m_s68k_write16_2M_decode
|
||||||
PIC_LDR(r2, ip, Pico)
|
PIC_LDR(r2, ip, Pico_mcd)
|
||||||
eor r0, r0, #2
|
eor r0, r0, #2
|
||||||
ldr r2, [r2, #OFS_Pico_rom] @ Pico.mcd
|
ldr r2, [r2] @ Pico.mcd
|
||||||
mov r0, r0, lsr #1 @ +4-6 <<16
|
mov r0, r0, lsr #1 @ +4-6 <<16
|
||||||
add r2, r2, r3 @ map to our address
|
add r2, r2, r3 @ map to our address
|
||||||
.endm
|
.endm
|
||||||
|
@ -696,9 +696,9 @@ m_s68k_write16_regs:
|
||||||
bne s68k_reg_write16
|
bne s68k_reg_write16
|
||||||
|
|
||||||
m_s68k_write16_regs_spec: @ special case
|
m_s68k_write16_regs_spec: @ special case
|
||||||
PIC_LDR(r2, r0, Pico)
|
PIC_LDR(r2, r0, Pico_mcd)
|
||||||
mov r0, #0x110000
|
mov r0, #0x110000
|
||||||
ldr r2, [r2, #OFS_Pico_rom] @ Pico.mcd
|
ldr r2, [r2] @ Pico.mcd
|
||||||
add r0, r0, #0x00000f
|
add r0, r0, #0x00000f
|
||||||
strb r1, [r2, r0] @ if (a == 0xe) s68k_regs[0xf] = d;
|
strb r1, [r2, r0] @ if (a == 0xe) s68k_regs[0xf] = d;
|
||||||
bx lr
|
bx lr
|
||||||
|
|
|
@ -66,16 +66,17 @@ void z80_map_set(uptr *map, u16 start_addr, u16 end_addr,
|
||||||
void cpu68k_map_set(uptr *map, u32 start_addr, u32 end_addr,
|
void cpu68k_map_set(uptr *map, u32 start_addr, u32 end_addr,
|
||||||
const void *func_or_mh, int is_func)
|
const void *func_or_mh, int is_func)
|
||||||
{
|
{
|
||||||
xmap_set(map, M68K_MEM_SHIFT, start_addr, end_addr, func_or_mh, is_func);
|
xmap_set(map, M68K_MEM_SHIFT, start_addr, end_addr, func_or_mh, is_func & 1);
|
||||||
#ifdef EMU_F68K
|
#ifdef EMU_F68K
|
||||||
// setup FAME fetchmap
|
// setup FAME fetchmap
|
||||||
if (!is_func)
|
if (!(is_func & 1))
|
||||||
{
|
{
|
||||||
|
M68K_CONTEXT *ctx = is_func & 2 ? &PicoCpuFS68k : &PicoCpuFM68k;
|
||||||
int shiftout = 24 - FAMEC_FETCHBITS;
|
int shiftout = 24 - FAMEC_FETCHBITS;
|
||||||
int i = start_addr >> shiftout;
|
int i = start_addr >> shiftout;
|
||||||
uptr base = (uptr)func_or_mh - (i << shiftout);
|
uptr base = (uptr)func_or_mh - (i << shiftout);
|
||||||
for (; i <= (end_addr >> shiftout); i++)
|
for (; i <= (end_addr >> shiftout); i++)
|
||||||
PicoCpuFM68k.Fetch[i] = base;
|
ctx->Fetch[i] = base;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -997,18 +998,6 @@ PICO_INTERNAL void PicoMemSetup(void)
|
||||||
PicoCpuFM68k.write_byte = (void *)m68k_write8;
|
PicoCpuFM68k.write_byte = (void *)m68k_write8;
|
||||||
PicoCpuFM68k.write_word = (void *)m68k_write16;
|
PicoCpuFM68k.write_word = (void *)m68k_write16;
|
||||||
PicoCpuFM68k.write_long = (void *)m68k_write32;
|
PicoCpuFM68k.write_long = (void *)m68k_write32;
|
||||||
|
|
||||||
// setup FAME fetchmap
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
// by default, point everything to first 64k of ROM
|
|
||||||
for (i = 0; i < M68K_FETCHBANK1 * 0xe0 / 0x100; i++)
|
|
||||||
PicoCpuFM68k.Fetch[i] = (uptr)Pico.rom - (i<<(24-FAMEC_FETCHBITS));
|
|
||||||
// now real ROM
|
|
||||||
for (i = 0; i < M68K_FETCHBANK1 && (i<<(24-FAMEC_FETCHBITS)) < Pico.romsize; i++)
|
|
||||||
PicoCpuFM68k.Fetch[i] = (uptr)Pico.rom;
|
|
||||||
// RAM already set
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef EMU_M68K
|
#ifdef EMU_M68K
|
||||||
m68k_mem_setup();
|
m68k_mem_setup();
|
||||||
|
|
|
@ -146,7 +146,9 @@ PICO_INTERNAL void PicoDetectRegion(void)
|
||||||
else if (support&1) hw=0x00; // Japan NTSC
|
else if (support&1) hw=0x00; // Japan NTSC
|
||||||
else hw=0x80; // USA
|
else hw=0x80; // USA
|
||||||
|
|
||||||
Pico.m.hardware=(unsigned char)(hw|0x20); // No disk attached
|
if (!(PicoIn.AHW & PAHW_MCD)) hw |= 0x20; // No disk attached
|
||||||
|
|
||||||
|
Pico.m.hardware=(unsigned char)hw;
|
||||||
Pico.m.pal=pal;
|
Pico.m.pal=pal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -289,9 +289,11 @@ enum cd_track_type
|
||||||
CT_ISO = 1, /* 2048 B/sector */
|
CT_ISO = 1, /* 2048 B/sector */
|
||||||
CT_BIN = 2, /* 2352 B/sector */
|
CT_BIN = 2, /* 2352 B/sector */
|
||||||
// audio tracks
|
// audio tracks
|
||||||
CT_MP3 = 3,
|
CT_AUDIO = 8,
|
||||||
CT_WAV = 4,
|
CT_RAW = CT_AUDIO | 1,
|
||||||
CT_CHD = 5,
|
CT_CHD = CT_AUDIO | 2,
|
||||||
|
CT_MP3 = CT_AUDIO | 3,
|
||||||
|
CT_WAV = CT_AUDIO | 4,
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
|
|
@ -566,9 +566,6 @@ typedef struct
|
||||||
char pcm_regs_dirty;
|
char pcm_regs_dirty;
|
||||||
} mcd_state;
|
} mcd_state;
|
||||||
|
|
||||||
// XXX: this will need to be reworked for cart+cd support.
|
|
||||||
#define Pico_mcd ((mcd_state *)Pico.rom)
|
|
||||||
|
|
||||||
// 32X
|
// 32X
|
||||||
#define P32XS_FM (1<<15)
|
#define P32XS_FM (1<<15)
|
||||||
#define P32XS_nCART (1<< 8)
|
#define P32XS_nCART (1<< 8)
|
||||||
|
@ -773,6 +770,7 @@ int gfx_context_load(const unsigned char *state);
|
||||||
void DmaSlowCell(u32 source, u32 a, int len, unsigned char inc);
|
void DmaSlowCell(u32 source, u32 a, int len, unsigned char inc);
|
||||||
|
|
||||||
// cd/memory.c
|
// cd/memory.c
|
||||||
|
extern unsigned int pcd_base_address;
|
||||||
PICO_INTERNAL void PicoMemSetupCD(void);
|
PICO_INTERNAL void PicoMemSetupCD(void);
|
||||||
u32 PicoRead8_mcd_io(u32 a);
|
u32 PicoRead8_mcd_io(u32 a);
|
||||||
u32 PicoRead16_mcd_io(u32 a);
|
u32 PicoRead16_mcd_io(u32 a);
|
||||||
|
@ -797,6 +795,8 @@ PICO_INTERNAL void PicoSyncZ80(unsigned int m68k_cycles_done);
|
||||||
#define PCDS_IEN5 (1<<5)
|
#define PCDS_IEN5 (1<<5)
|
||||||
#define PCDS_IEN6 (1<<6)
|
#define PCDS_IEN6 (1<<6)
|
||||||
|
|
||||||
|
extern mcd_state *Pico_mcd;
|
||||||
|
|
||||||
PICO_INTERNAL void PicoInitMCD(void);
|
PICO_INTERNAL void PicoInitMCD(void);
|
||||||
PICO_INTERNAL void PicoExitMCD(void);
|
PICO_INTERNAL void PicoExitMCD(void);
|
||||||
PICO_INTERNAL void PicoPowerMCD(void);
|
PICO_INTERNAL void PicoPowerMCD(void);
|
||||||
|
@ -811,6 +811,7 @@ enum pcd_event {
|
||||||
PCD_EVENT_COUNT,
|
PCD_EVENT_COUNT,
|
||||||
};
|
};
|
||||||
extern unsigned int pcd_event_times[PCD_EVENT_COUNT];
|
extern unsigned int pcd_event_times[PCD_EVENT_COUNT];
|
||||||
|
|
||||||
void pcd_event_schedule(unsigned int now, enum pcd_event event, int after);
|
void pcd_event_schedule(unsigned int now, enum pcd_event event, int after);
|
||||||
void pcd_event_schedule_s68k(enum pcd_event event, int after);
|
void pcd_event_schedule_s68k(enum pcd_event event, int after);
|
||||||
void pcd_prepare_frame(void);
|
void pcd_prepare_frame(void);
|
||||||
|
|
|
@ -278,7 +278,7 @@ static int state_save(void *file)
|
||||||
SekPackCpu(buff, 1);
|
SekPackCpu(buff, 1);
|
||||||
if (Pico_mcd->s68k_regs[3] & 4) // 1M mode?
|
if (Pico_mcd->s68k_regs[3] & 4) // 1M mode?
|
||||||
wram_1M_to_2M(Pico_mcd->word_ram2M);
|
wram_1M_to_2M(Pico_mcd->word_ram2M);
|
||||||
memcpy(&Pico_mcd->m.hint_vector, Pico_mcd->bios + 0x72,
|
memcpy(&Pico_mcd->m.hint_vector, Pico.rom + 0x72,
|
||||||
sizeof(Pico_mcd->m.hint_vector));
|
sizeof(Pico_mcd->m.hint_vector));
|
||||||
|
|
||||||
CHECKED_WRITE_BUFF(CHUNK_S68K, buff);
|
CHECKED_WRITE_BUFF(CHUNK_S68K, buff);
|
||||||
|
|
|
@ -533,13 +533,13 @@ static void DmaSlow(int len, u32 source)
|
||||||
{
|
{
|
||||||
u8 r3 = Pico_mcd->s68k_regs[3];
|
u8 r3 = Pico_mcd->s68k_regs[3];
|
||||||
elprintf(EL_VDPDMA, "DmaSlow CD, r3=%02x", r3);
|
elprintf(EL_VDPDMA, "DmaSlow CD, r3=%02x", r3);
|
||||||
if (source < 0x20000) { // Bios area
|
if (source < Pico.romsize /*0x20000*/) { // Bios area
|
||||||
base = (u16 *)Pico_mcd->bios;
|
base = (u16 *)(Pico.rom + (source & 0xfe0000));
|
||||||
} else if ((source & 0xfc0000) == 0x200000) { // Word Ram
|
} else if ((source & 0xfc0000) == pcd_base_address+0x200000) { // Word Ram
|
||||||
if (!(r3 & 4)) { // 2M mode
|
if (!(r3 & 4)) { // 2M mode
|
||||||
base = (u16 *)(Pico_mcd->word_ram2M + (source & 0x20000));
|
base = (u16 *)(Pico_mcd->word_ram2M + (source & 0x20000));
|
||||||
} else {
|
} else {
|
||||||
if (source < 0x220000) { // 1M mode
|
if ((source & 0xfe0000) < pcd_base_address+0x220000) { // 1M mode
|
||||||
int bank = r3 & 1;
|
int bank = r3 & 1;
|
||||||
base = (u16 *)(Pico_mcd->word_ram1M[bank]);
|
base = (u16 *)(Pico_mcd->word_ram1M[bank]);
|
||||||
} else {
|
} else {
|
||||||
|
@ -548,7 +548,7 @@ static void DmaSlow(int len, u32 source)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
source -= 2;
|
source -= 2;
|
||||||
} else if ((source & 0xfe0000) == 0x020000) { // Prg Ram
|
} else if ((source & 0xfe0000) == pcd_base_address+0x020000) { // Prg Ram
|
||||||
base = (u16 *)Pico_mcd->prg_ram_b[r3 >> 6];
|
base = (u16 *)Pico_mcd->prg_ram_b[r3 >> 6];
|
||||||
source -= 2; // XXX: test
|
source -= 2; // XXX: test
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue