mcd, preparations for msu support

This commit is contained in:
kub 2023-05-26 19:09:37 +00:00
parent 178a9b683c
commit 02ff025479
15 changed files with 153 additions and 170 deletions

View file

@ -49,6 +49,7 @@ static int handle_mp3(const char *fname, int index)
return -1;
}
track->type = CT_AUDIO;
track->fd = tmp_file;
track->offset = 0;
@ -114,10 +115,11 @@ int load_cd_image(const char *cd_img_name, int *type)
}
tracks[0].fd = pmf;
tracks[0].fname = strdup(cd_img_name);
tracks[0].type = *type & CT_AUDIO;
if (*type == CT_ISO)
cd_img_sectors = pmf->size >>= 11; // size in sectors
else cd_img_sectors = pmf->size /= 2352;
cd_img_sectors = pmf->size >> 11; // size in sectors
else cd_img_sectors = pmf->size / 2352;
// cdd.c operates with lba - 150
tracks[0].start = 0;
@ -125,8 +127,8 @@ int load_cd_image(const char *cd_img_name, int *type)
tracks[0].offset = 0;
sprintf_lba(tmp_ext, sizeof(tmp_ext), 0);
elprintf(EL_STATUS, "Track 1: %s %9i DATA %s",
tmp_ext, tracks[0].end, cd_img_name);
elprintf(EL_STATUS, "Track 1: %s %9i %s %s",
tmp_ext, tracks[0].end, tracks[0].type ? "AUDIO" : "DATA ", cd_img_name);
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;
Pico_mcd->cdda_type = cue_data->tracks[n].type;
tracks[index].type = cue_data->tracks[n].type & CT_AUDIO;
tracks[index].start = lba;
lba += length;
tracks[index].end = lba;
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 : "");
}
goto finish;
@ -246,6 +250,7 @@ int load_cd_image(const char *cd_img_name, int *type)
tracks[index].end = lba;
Pico_mcd->cdda_type = CT_MP3;
tracks[index].type = CT_AUDIO;
sprintf_lba(tmp_ext, sizeof(tmp_ext), tracks[index].start);
elprintf(EL_STATUS, "Track %2i: %s %9i AUDIO - %s",

View file

@ -172,19 +172,15 @@ cd_data_t *chd_parse(const char *fname)
}
memset(&data->tracks[count], 0, sizeof(data->tracks[0]));
if (count == 1) { // binary code
data->tracks[count].fname = strdup(fname);
if (!strcmp(type, "MODE1_RAW") || !strcmp(type, "MODE2_RAW")) {
data->tracks[count].type = CT_BIN;
} else if (!strcmp(type, "MODE1") || !strcmp(type, "MODE2_FORM1")) {
data->tracks[count].type = CT_ISO;
} else
break;
} else { // audio
if (strcmp(type, "AUDIO"))
break;
data->tracks[count].fname = strdup(fname);
if (!strcmp(type, "MODE1_RAW") || !strcmp(type, "MODE2_RAW")) {
data->tracks[count].type = CT_BIN;
} else if (!strcmp(type, "MODE1") || !strcmp(type, "MODE2_FORM1")) {
data->tracks[count].type = CT_ISO;
} else if (!strcmp(type, "AUDIO")) {
data->tracks[count].type = CT_CHD;
}
} else
break;
data->tracks[count].pregap = pregap;
if (pgtype[0] != 'V') // VAUDIO includes pregap in file
@ -344,17 +340,22 @@ file_ok:
else if (strcasecmp(ext, "wav") == 0)
data->tracks[count].type = CT_WAV;
else if (strcasecmp(ext, "bin") == 0)
data->tracks[count].type = CT_BIN;
data->tracks[count].type = CT_RAW;
else {
elprintf(EL_STATUS, "unhandled audio format: \"%s\"",
data->tracks[count].fname);
}
}
else
else if (data->tracks[count-1].type & CT_AUDIO)
{
// propagate previous
data->tracks[count].type = data->tracks[count-1].type;
}
else
{
// assume raw binary data
data->tracks[count].type = CT_RAW;
}
}
else {
elprintf(EL_STATUS, "unhandled track type: \"%s\"", buff2);

View file

@ -704,7 +704,6 @@ void cdc_reg_w(unsigned char data)
case 0x0f: /* RESET */
cdc_reset();
Pico_mcd->s68k_regs[0x04+1] = 0x10;
break;
default: /* by default, SBOUT is not used */
@ -715,7 +714,7 @@ void cdc_reg_w(unsigned char data)
unsigned char cdc_reg_r(void)
{
switch (Pico_mcd->s68k_regs[0x04+1] & 0x01F)
switch (Pico_mcd->s68k_regs[0x04+1] & 0x1F)
{
case 0x00:
return 0xff;
@ -835,7 +834,9 @@ unsigned short cdc_host_r(void)
/* clear DSR bit & set EDT bit (SCD register $04) */
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) {
/* pending Data Transfer End interrupt */
cdc.ifstat &= ~BIT_DTEI;

View file

@ -49,6 +49,9 @@
cdd_t cdd;
#define is_audio(index) \
(cdd.toc.tracks[index].type & CT_AUDIO)
/* BCD conversion lookup tables */
static const uint8 lut_BCD_8[100] =
{
@ -239,12 +242,12 @@ int cdd_context_load(uint8 *state)
}
/* seek to current track position */
if (!cdd.index)
if (!is_audio(cdd.index))
{
/* 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
@ -318,7 +321,7 @@ int cdd_load(const char *filename, int type)
cdd.sectorSize = 2048;
}
ret = (type == CT_BIN) ? 2352 : 2048;
ret = (type == CT_ISO ? 2048 : 2352);
if (ret != cdd.sectorSize)
elprintf(EL_STATUS|EL_ANOMALY, "cd: type detection mismatch");
pm_sectorsize(cdd.sectorSize, cdd.toc.tracks[0].fd);
@ -507,17 +510,17 @@ int cdd_unload(void)
void cdd_read_data(uint8 *dst)
{
/* 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 ? */
if (cdd.sectorSize == 2352)
{
/* 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) */
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)
{
/* track type */
if (!cdd.index)
if (!is_audio(cdd.index))
{
/* DATA sector header (CD-ROM Mode 1) */
uint8 header[4];
@ -846,13 +849,13 @@ void cdd_update(void)
}
/* seek to current block */
if (!cdd.index)
if (!is_audio(cdd.index))
{
/* no AUDIO track playing */
Pico_mcd->s68k_regs[0x36+0] = 0x01;
/* 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
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(0x3c, lut_BCD_16[(lba/75)%60]);
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) {
/* 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;
@ -957,7 +960,7 @@ void cdd_process(void)
set_reg16(0x3a, lut_BCD_16[(lba/75)/60]);
set_reg16(0x3c, lut_BCD_16[(lba/75)%60]);
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;
}
@ -969,7 +972,7 @@ void cdd_process(void)
set_reg16(0x3a, lut_BCD_16[(lba/75)/60]);
set_reg16(0x3c, lut_BCD_16[(lba/75)%60]);
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;
}
@ -1113,10 +1116,10 @@ void cdd_process(void)
}
/* seek to current block */
if (!index)
if (!is_audio(cdd.index))
{
/* 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
else if (cdd.toc.tracks[index].vf.seekable)
@ -1212,10 +1215,10 @@ void cdd_process(void)
}
/* seek to current block */
if (!index)
if (!is_audio(cdd.index))
{
/* 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
else if (cdd.toc.tracks[index].vf.seekable)

View file

@ -60,6 +60,7 @@
/* CD track */
typedef struct
{
int type;
char *fname;
void *fd;
#ifdef USE_LIBTREMOR

View file

@ -16,6 +16,7 @@ static unsigned int mcd_s68k_cycle_mult;
static unsigned int mcd_m68k_cycle_base;
static unsigned int mcd_s68k_cycle_base;
mcd_state *Pico_mcd;
PICO_INTERNAL void PicoInitMCD(void)
{
@ -25,6 +26,10 @@ PICO_INTERNAL void PicoInitMCD(void)
PICO_INTERNAL void PicoExitMCD(void)
{
cdd_unload();
if (Pico_mcd) {
plat_munmap(Pico_mcd, sizeof(mcd_state));
Pico_mcd = NULL;
}
}
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.busreq = 2; // busreq on, s68k in reset
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)

View file

@ -23,6 +23,9 @@ MAKE_68K_WRITE16(s68k_write16, s68k_write16_map)
MAKE_68K_WRITE32(s68k_write32, s68k_write16_map)
#endif
u32 pcd_base_address;
#define BASE pcd_base_address
// -----------------------------------------------------------------
// provided by ASM code:
@ -113,7 +116,7 @@ static u32 m68k_reg_read16(u32 a)
d = Pico_mcd->s68k_regs[4]<<8;
goto end;
case 6:
d = *(u16 *)(Pico_mcd->bios + 0x72);
d = *(u16 *)(Pico.rom + 0x72);
goto end;
case 8:
d = cdc_host_r();
@ -169,8 +172,8 @@ void m68k_reg_write8(u32 a, u32 d)
case 1:
d &= 3;
dold = Pico_mcd->m.busreq;
if (!(d & 1))
d |= 2; // verified: can't release bus on reset
// if (!(d & 1))
// d |= 2; // verified: can't release bus on reset
if (dold == d)
return;
@ -185,7 +188,7 @@ void m68k_reg_write8(u32 a, u32 d)
elprintf(EL_CDREGS, "m68k: resetting s68k");
SekResetS68k();
}
if ((dold ^ d) & 2) {
if (((dold & 3) == 1) != ((d & 3) == 1)) {
elprintf(EL_INTSW, "m68k: s68k brq %i", d >> 1);
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);
goto write_comm;
case 6:
Pico_mcd->bios[MEM_BE2(0x72)] = d; // simple hint vector changer
Pico.rom[MEM_BE2(0x72)] = d; // simple hint vector changer
return;
case 7:
Pico_mcd->bios[MEM_BE2(0x73)] = d;
Pico.rom[MEM_BE2(0x73)] = d;
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;
case 8:
(void) cdc_host_r(); // acts same as reading
@ -659,7 +662,7 @@ static void PicoWriteM68k16_cell1(u32 a, u32 d)
}
#endif
// RAM cart (40000 - 7fffff, optional)
// RAM cart (400000 - 7fffff, optional)
static u32 PicoReadM68k8_ramc(u32 a)
{
u32 d = 0;
@ -685,6 +688,8 @@ static u32 PicoReadM68k8_ramc(u32 a)
static u32 PicoReadM68k16_ramc(u32 a)
{
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);
}
@ -1093,13 +1098,12 @@ static const void *s68k_dec_write16[2][4] = {
static void remap_prg_window(u32 r1, u32 r3)
{
// PRG RAM
if (r1 & 2) {
// PRG RAM, mapped to main CPU if sub is not running
if ((r1 & 3) != 1) {
void *bank = Pico_mcd->prg_ram_b[(r3 >> 6) & 3];
cpu68k_map_all_ram(0x020000, 0x03ffff, bank, 0);
}
else {
m68k_map_unmap(0x020000, 0x03ffff);
cpu68k_map_all_ram(BASE+0x020000, BASE+0x03ffff, bank, 0);
} else {
m68k_map_unmap(BASE+0x020000, BASE+0x03ffff);
}
}
@ -1145,14 +1149,14 @@ static void remap_word_ram(u32 r3)
// 2M mode.
bank = Pico_mcd->word_ram2M;
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,
s68k_wordram_main_read8, s68k_wordram_main_read16,
s68k_wordram_main_write8, s68k_wordram_main_write16, 1);
} else {
Pico_mcd->m.state_flags &= ~PCD_ST_S68K_SLEEP;
cpu68k_map_all_ram(0x080000, 0x0bffff, bank, 1);
m68k_map_unmap(0x200000, 0x23ffff);
m68k_map_unmap(BASE+0x200000, BASE+0x23ffff);
}
// TODO: handle 0x0c0000
}
@ -1161,11 +1165,11 @@ static void remap_word_ram(u32 r3)
int m = (r3 & 0x18) >> 3;
Pico_mcd->m.state_flags &= ~PCD_ST_S68K_SLEEP;
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];
cpu68k_map_all_ram(0x0c0000, 0x0effff, bank, 1);
// "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_write8[b0], m68k_cell_write16[b0], 0);
// "decode format" on s68k
@ -1187,7 +1191,7 @@ void pcd_state_loaded_mem(void)
Pico_mcd->m.dmna_ret_2m &= 3;
// 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
@ -1196,6 +1200,10 @@ static void m68k_mem_setup_cd(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
PicoMemSetup();
@ -1215,30 +1223,30 @@ PICO_INTERNAL void PicoMemSetupCD(void)
cpu68k_map_set(m68k_write16_map, 0xa10000, 0xa1ffff, PicoWrite16_mcd_io, 1);
// sub68k map
cpu68k_map_set(s68k_read8_map, 0x000000, 0xffffff, s68k_unmapped_read8, 1);
cpu68k_map_set(s68k_read16_map, 0x000000, 0xffffff, s68k_unmapped_read16, 1);
cpu68k_map_set(s68k_write8_map, 0x000000, 0xffffff, s68k_unmapped_write8, 1);
cpu68k_map_set(s68k_write16_map, 0x000000, 0xffffff, s68k_unmapped_write16, 1);
cpu68k_map_set(s68k_read8_map, 0x000000, 0xffffff, s68k_unmapped_read8, 3);
cpu68k_map_set(s68k_read16_map, 0x000000, 0xffffff, s68k_unmapped_read16, 3);
cpu68k_map_set(s68k_write8_map, 0x000000, 0xffffff, s68k_unmapped_write8, 3);
cpu68k_map_set(s68k_write16_map, 0x000000, 0xffffff, s68k_unmapped_write16, 3);
// PRG RAM
cpu68k_map_set(s68k_read8_map, 0x000000, 0x07ffff, Pico_mcd->prg_ram, 0);
cpu68k_map_set(s68k_read16_map, 0x000000, 0x07ffff, Pico_mcd->prg_ram, 0);
cpu68k_map_set(s68k_write8_map, 0x000000, 0x07ffff, Pico_mcd->prg_ram, 0);
cpu68k_map_set(s68k_write16_map, 0x000000, 0x07ffff, Pico_mcd->prg_ram, 0);
cpu68k_map_set(s68k_write8_map, 0x000000, 0x01ffff, PicoWriteS68k8_prgwp, 1);
cpu68k_map_set(s68k_write16_map, 0x000000, 0x01ffff, PicoWriteS68k16_prgwp, 1);
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, 2);
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, 2);
cpu68k_map_set(s68k_write8_map, 0x000000, 0x01ffff, PicoWriteS68k8_prgwp, 3);
cpu68k_map_set(s68k_write16_map, 0x000000, 0x01ffff, PicoWriteS68k16_prgwp, 3);
// BRAM
cpu68k_map_set(s68k_read8_map, 0xfe0000, 0xfeffff, PicoReadS68k8_bram, 1);
cpu68k_map_set(s68k_read16_map, 0xfe0000, 0xfeffff, PicoReadS68k16_bram, 1);
cpu68k_map_set(s68k_write8_map, 0xfe0000, 0xfeffff, PicoWriteS68k8_bram, 1);
cpu68k_map_set(s68k_write16_map, 0xfe0000, 0xfeffff, PicoWriteS68k16_bram, 1);
cpu68k_map_set(s68k_read8_map, 0xfe0000, 0xfeffff, PicoReadS68k8_bram, 3);
cpu68k_map_set(s68k_read16_map, 0xfe0000, 0xfeffff, PicoReadS68k16_bram, 3);
cpu68k_map_set(s68k_write8_map, 0xfe0000, 0xfeffff, PicoWriteS68k8_bram, 3);
cpu68k_map_set(s68k_write16_map, 0xfe0000, 0xfeffff, PicoWriteS68k16_bram, 3);
// PCM, regs
cpu68k_map_set(s68k_read8_map, 0xff0000, 0xffffff, PicoReadS68k8_pr, 1);
cpu68k_map_set(s68k_read16_map, 0xff0000, 0xffffff, PicoReadS68k16_pr, 1);
cpu68k_map_set(s68k_write8_map, 0xff0000, 0xffffff, PicoWriteS68k8_pr, 1);
cpu68k_map_set(s68k_write16_map, 0xff0000, 0xffffff, PicoWriteS68k16_pr, 1);
cpu68k_map_set(s68k_read8_map, 0xff0000, 0xffffff, PicoReadS68k8_pr, 3);
cpu68k_map_set(s68k_read16_map, 0xff0000, 0xffffff, PicoReadS68k16_pr, 3);
cpu68k_map_set(s68k_write8_map, 0xff0000, 0xffffff, PicoWriteS68k8_pr, 3);
cpu68k_map_set(s68k_write16_map, 0xff0000, 0xffffff, PicoWriteS68k16_pr, 3);
// RAMs
remap_prg_window(2,1);
@ -1265,37 +1273,6 @@ PICO_INTERNAL void PicoMemSetupCD(void)
PicoCpuFS68k.write_byte = (void *)s68k_write8;
PicoCpuFS68k.write_word = (void *)s68k_write16;
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
#ifdef EMU_M68K
m68k_mem_setup_cd();

View file

@ -51,7 +51,7 @@
.global PicoWriteS68k16_dec_m2b1
@ externs, just for reference
.extern Pico
.extern Pico_mcd
.extern cdc_host_r
.extern m68k_reg_write8
.extern s68k_reg_read16
@ -130,9 +130,9 @@ PicoReadM68k8_cell1: @ 0x220000 - 0x23ffff, cell arranged
mov r3, #0x0e0000
0:
cell_map
PIC_LDR(r1, r2, Pico)
PIC_LDR(r1, r2, Pico_mcd)
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
ldrb r0, [r1, r0]
bx lr
@ -143,9 +143,9 @@ PicoRead8_mcd_io:
cmp r1, #0x2000 @ a120xx?
bne PicoRead8_io
PIC_LDR(r1, r2, Pico)
PIC_LDR(r1, r2, Pico_mcd)
and r0, r0, #0x3f
ldr r1, [r1, #OFS_Pico_rom] @ Pico.mcd
ldr r1, [r1] @ Pico.mcd
cmp r0, #0x0e
PIC_XB(lt ,r0, lsl #2)
b m_m68k_read8_hi
@ -242,9 +242,9 @@ PicoReadM68k16_cell1: @ 0x220000 - 0x23ffff, cell arranged
mov r3, #0x0e0000
0:
cell_map
PIC_LDR(r1, r2, Pico)
PIC_LDR(r1, r2, Pico_mcd)
add r0, r0, r3
ldr r1, [r1, #OFS_Pico_rom] @ Pico.mcd
ldr r1, [r1] @ Pico.mcd
bic r0, r0, #1
ldrh r0, [r1, r0]
bx lr
@ -256,9 +256,9 @@ PicoRead16_mcd_io:
bne PicoRead16_io
m_m68k_read16_m68k_regs:
PIC_LDR(r1, r2, Pico)
PIC_LDR(r1, r2, Pico_mcd)
and r0, r0, #0x3e
ldr r1, [r1, #OFS_Pico_rom] @ Pico.mcd
ldr r1, [r1, @ Pico.mcd
cmp r0, #0x0e
PIC_XB(lt ,r0, lsl #1)
b m_m68k_read16_hi
@ -333,9 +333,9 @@ PicoWriteM68k8_cell1: @ 0x220000 - 0x23ffff, cell arranged
0:
mov r3, r1
cell_map
PIC_LDR(r2, r1, Pico)
PIC_LDR(r2, r1, Pico_mcd)
add r0, r0, r12
ldr r2, [r2, #OFS_Pico_rom] @ Pico.mcd
ldr r2, [r2] @ Pico.mcd
ldr r2, [r2]
eor r0, r0, #1
strb r3, [r2, r0]
@ -361,9 +361,9 @@ PicoWriteM68k16_cell1: @ 0x220000 - 0x23ffff, cell arranged
0:
mov r3, r1
cell_map
PIC_LDR(r1, r2, Pico)
PIC_LDR(r1, r2, Pico_mcd)
add r0, r0, r12
ldr r1, [r1, #OFS_Pico_rom] @ Pico.mcd
ldr r1, [r1] @ Pico.mcd
bic r0, r0, #1
strh r3, [r1, r0]
bx lr
@ -403,9 +403,9 @@ PicoReadS68k8_dec0: @ 0x080000 - 0x0bffff
PicoReadS68k8_dec1:
mov r3, #0x0a0000 @ + ^ / 2
0:
PIC_LDR(r2, r1, Pico)
PIC_LDR(r2, r1, Pico_mcd)
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
add r2, r2, r3 @ map to our address
ldrb r0, [r2, r0]
@ -435,8 +435,8 @@ m_s68k_read8_regs:
bx lr
m_s68k_read8_comm:
PIC_LDR(r1, r2, Pico)
ldr r1, [r1, #OFS_Pico_rom] @ Pico.mcd
PIC_LDR(r1, r2, Pico_mcd)
ldr r1, [r1] @ Pico.mcd
add r1, r1, #0x110000
ldrb r1, [r1, r0]
bic r0, r0, #1
@ -448,9 +448,9 @@ m_s68k_read8_pcm:
bne m_read_null
@ must not trash r3 and r12
PIC_LDR(r1, r2, Pico)
PIC_LDR(r1, r2, Pico_mcd)
bic r0, r0, #0xff0000
ldr r1, [r1, #OFS_Pico_rom] @ Pico.mcd
ldr r1, [r1] @ Pico.mcd
mov r2, #0x110000
orr r2, r2, #0x002200
cmp r0, #0x2000
@ -483,9 +483,9 @@ PicoReadS68k16_dec0: @ 0x080000 - 0x0bffff
PicoReadS68k16_dec1:
mov r3, #0x0a0000 @ + ^ / 2
0:
PIC_LDR(r2, r1, Pico)
PIC_LDR(r2, r1, Pico_mcd)
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
add r2, r2, r3 @ map to our address
ldrb r0, [r2, r0]
@ -513,9 +513,9 @@ m_s68k_read16_regs:
.macro m_s68k_write8_2M_decode
PIC_LDR(r2, ip, Pico)
PIC_LDR(r2, ip, Pico_mcd)
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
add r2, r2, r3 @ map to our address
.endm
@ -597,9 +597,9 @@ m_s68k_write8_pcm:
bxlt lr
m_s68k_write8_pcm_ram:
PIC_LDR(r3, r2, Pico)
PIC_LDR(r3, r2, Pico_mcd)
bic r0, r0, #0x00e000
ldr r3, [r3, #OFS_Pico_rom] @ Pico.mcd
ldr r3, [r3] @ Pico.mcd
mov r0, r0, lsr #1
add r2, r3, #0x110000
add r2, r2, #0x002200
@ -615,9 +615,9 @@ m_s68k_write8_pcm_ram:
.macro m_s68k_write16_2M_decode
PIC_LDR(r2, ip, Pico)
PIC_LDR(r2, ip, Pico_mcd)
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
add r2, r2, r3 @ map to our address
.endm
@ -696,9 +696,9 @@ m_s68k_write16_regs:
bne s68k_reg_write16
m_s68k_write16_regs_spec: @ special case
PIC_LDR(r2, r0, Pico)
PIC_LDR(r2, r0, Pico_mcd)
mov r0, #0x110000
ldr r2, [r2, #OFS_Pico_rom] @ Pico.mcd
ldr r2, [r2] @ Pico.mcd
add r0, r0, #0x00000f
strb r1, [r2, r0] @ if (a == 0xe) s68k_regs[0xf] = d;
bx lr