CDD_Reset();\r
CDC_Reset();\r
\r
- Pico_mcd->cdc.Host_Data = 0;\r
- Pico_mcd->cdc.DMA_Adr = 0;\r
- Pico_mcd->cdc.Stop_Watch = 0;\r
+ // clear DMA_Adr & Stop_Watch\r
+ memset(Pico_mcd->s68k_regs + 0xA, 0, 4);\r
}\r
\r
\r
void Update_CDC_TRansfer(int which)\r
{\r
- unsigned int dep, length, len;\r
+ unsigned int DMA_Adr, dep, length, len;\r
unsigned short *dest;\r
unsigned char *src;\r
\r
\r
// TODO: dst bounds checking? DAC.N alignment?\r
src = Pico_mcd->cdc.Buffer + Pico_mcd->cdc.DAC.N;\r
-\r
+ DMA_Adr = (Pico_mcd->s68k_regs[0xA]<<8) | Pico_mcd->s68k_regs[0xB];\r
\r
if (which == 7) // WORD RAM\r
{\r
if (Pico_mcd->s68k_regs[3] & 4)\r
{\r
- dep = ((Pico_mcd->cdc.DMA_Adr & 0x3FFF) << 3);\r
+ dep = ((DMA_Adr & 0x3FFF) << 3);\r
cdprintf("CD DMA # %04x -> word_ram1M # %06x, len=%i",\r
Pico_mcd->cdc.DAC.N, dep, length);\r
\r
- dep = ((Pico_mcd->cdc.DMA_Adr & 0x3FFF) << 4);\r
+ dep = ((DMA_Adr & 0x3FFF) << 4);\r
if (!(Pico_mcd->s68k_regs[3]&1)) dep += 2;\r
dest = (unsigned short *) (Pico_mcd->word_ram + dep);\r
\r
}\r
else\r
{\r
- dep = ((Pico_mcd->cdc.DMA_Adr & 0x7FFF) << 3);\r
+ dep = ((DMA_Adr & 0x7FFF) << 3);\r
cdprintf("CD DMA # %04x -> word_ram2M # %06x, len=%i",\r
Pico_mcd->cdc.DAC.N, dep, length);\r
dest = (unsigned short *) (Pico_mcd->word_ram + dep);\r
{\r
#if 0\r
dest = (unsigned char *) Ram_PCM;\r
- dep = ((Pico_mcd->cdc.DMA_Adr & 0x03FF) << 2) + PCM_Chip.Bank;\r
+ dep = ((DMA_Adr & 0x03FF) << 2) + PCM_Chip.Bank;\r
#else\r
- cdprintf("TODO: PCM Dma");\r
+ cdprintf("CD DMA # %04x -> PCD TODO", Pico_mcd->cdc.DAC.N);\r
#endif\r
}\r
else if (which == 5) // PRG RAM\r
{\r
- dep = (Pico_mcd->cdc.DMA_Adr & 0xFFFF) << 3;\r
+ dep = DMA_Adr << 3;\r
dest = (unsigned short *) (Pico_mcd->prg_ram + dep);\r
cdprintf("CD DMA # %04x -> prg_ram # %06x, len=%i",\r
Pico_mcd->cdc.DAC.N, dep, length);\r
\r
cdprintf("************** Starting Data Transfer ***********");\r
cdprintf("RS0 = %.4X DAC = %.4X DBC = %.4X DMA adr = %.4X\n\n", Pico_mcd->s68k_regs[4]<<8,\r
- Pico_mcd->cdc.DAC.N, Pico_mcd->cdc.DBC.N, Pico_mcd->cdc.DMA_Adr);\r
+ Pico_mcd->cdc.DAC.N, Pico_mcd->cdc.DBC.N, (Pico_mcd->s68k_regs[0xA]<<8) | Pico_mcd->s68k_regs[0xB]);\r
}\r
break;\r
\r
#include "../sound/ym2612.h"\r
#include "../sound/sn76496.h"\r
\r
+#include "gfx_cd.h"\r
+\r
typedef unsigned char u8;\r
typedef unsigned short u16;\r
typedef unsigned int u32;\r
\r
//#define __debug_io\r
//#define __debug_io2\r
-#define rdprintf dprintf\r
+//#define rdprintf dprintf\r
+#define rdprintf(...)\r
\r
// -----------------------------------------------------------------\r
\r
extern int counter75hz;\r
\r
\r
-static u32 m68k_reg_read16(u32 a, int realsize)\r
+static u32 m68k_reg_read16(u32 a)\r
{\r
u32 d=0;\r
a &= 0x3e;\r
d = Pico_mcd->m.hint_vector;\r
goto end;\r
case 8:\r
- dprintf("m68k host data read");\r
d = Read_CDC_Host(0);\r
goto end;\r
case 0xA:\r
return d;\r
}\r
\r
-static void m68k_reg_write8(u32 a, u32 d, int realsize)\r
+static void m68k_reg_write8(u32 a, u32 d)\r
{\r
a &= 0x3f;\r
// dprintf("m68k_regs w%2i: [%02x] %02x @%06x", realsize, a, d, SekPc);\r
\r
\r
\r
-static u32 s68k_reg_read16(u32 a, int realsize)\r
+static u32 s68k_reg_read16(u32 a)\r
{\r
u32 d=0;\r
- a &= 0x1fe;\r
\r
// dprintf("s68k_regs r%2i: [%02x] @ %06x", realsize&~1, a+(realsize&1), SekPcS68k);\r
\r
switch (a) {\r
case 0:\r
- d = 1; // ver = 0, not in reset state\r
+ d = ((Pico_mcd->s68k_regs[0]&3)<<8) | 1; // ver = 0, not in reset state\r
goto end;\r
case 2:\r
d = (Pico_mcd->s68k_regs[a]<<8) | (Pico_mcd->s68k_regs[a+1]&0x1f);\r
d = CDC_Read_Reg();\r
goto end;\r
case 8:\r
- dprintf("s68k host data read");\r
- d = Read_CDC_Host(1);\r
+ d = Read_CDC_Host(1); // Gens returns 0 here on byte reads\r
goto end;\r
case 0xC:\r
dprintf("s68k stopwatch read");\r
return d;\r
}\r
\r
-static void s68k_reg_write8(u32 a, u32 d, int realsize)\r
+static void s68k_reg_write8(u32 a, u32 d)\r
{\r
- a &= 0x1ff;\r
//dprintf("s68k_regs w%2i: [%02x] %02x @ %06x", realsize, a, d, SekPcS68k);\r
\r
// TODO: review against Gens\r
if ((a&0xe700e0)==0xc00000) { d=PicoVideoRead(a); goto end; }\r
\r
if ((a&0xffffc0)==0xa12000) {\r
- d=m68k_reg_read16(a, realsize);\r
+ d=m68k_reg_read16(a);\r
goto end;\r
}\r
\r
\r
if ((a&0xe700e0)==0xc00000) { PicoVideoWrite(a,(u16)(d|(d<<8))); return; } // Byte access gets mirrored\r
\r
- if ((a&0xffffc0)==0xa12000) { m68k_reg_write8(a, d, realsize); return; }\r
+ if ((a&0xffffc0)==0xa12000) { m68k_reg_write8(a, d); return; }\r
\r
dprintf("strange w%i: %06x, %08x @%06x", realsize, a&0xffffff, d, SekPc);\r
}\r
\r
// regs\r
if ((a&0xfffe00) == 0xff8000) {\r
- rdprintf("s68k_regs r8: [%02x] @ %06x", a&0x1ff, SekPcS68k);\r
- d = s68k_reg_read16(a&~1, 8|(a&1)); if ((a&1)==0) d>>=8;\r
+ a &= 0x1ff;\r
+ rdprintf("s68k_regs r8: [%02x] @ %06x", a, SekPcS68k);\r
+ if (a >= 0x50 && a < 0x68)\r
+ d = gfx_cd_read(a&~1);\r
+ else d = s68k_reg_read16(a&~1);\r
+ if ((a&1)==0) d>>=8;\r
rdprintf("ret = %02x", (u8)d);\r
goto end;\r
}\r
\r
// regs\r
if ((a&0xfffe00) == 0xff8000) {\r
- rdprintf("s68k_regs r16: [%02x] @ %06x", a&0x1fe, SekPcS68k);\r
- d = s68k_reg_read16(a, 16);\r
+ a &= 0x1fe;\r
+ rdprintf("s68k_regs r16: [%02x] @ %06x", a, SekPcS68k);\r
+ if (a >= 0x50 && a < 0x68)\r
+ d = gfx_cd_read(a);\r
+ else d = s68k_reg_read16(a);\r
rdprintf("ret = %04x", d);\r
goto end;\r
}\r
\r
// regs\r
if ((a&0xfffe00) == 0xff8000) {\r
- rdprintf("s68k_regs r32: [%02x] @ %06x", a&0x1fe, SekPcS68k);\r
- d = (s68k_reg_read16(a, 32)<<16)|s68k_reg_read16(a+2, 32);\r
+ a &= 0x1fe;\r
+ rdprintf("s68k_regs r32: [%02x] @ %06x", a, SekPcS68k);\r
+ if (a >= 0x50 && a < 0x68)\r
+ d = (gfx_cd_read(a)<<16)|gfx_cd_read(a+2);\r
+ else d = (s68k_reg_read16(a)<<16)|s68k_reg_read16(a+2);\r
rdprintf("ret = %08x", d);\r
goto end;\r
}\r
\r
// regs\r
if ((a&0xfffe00) == 0xff8000) {\r
- rdprintf("s68k_regs w8: [%02x] %02x @ %06x", a&0x1ff, d, SekPcS68k);\r
- s68k_reg_write8(a,d,8);\r
+ a &= 0x1ff;\r
+ rdprintf("s68k_regs w8: [%02x] %02x @ %06x", a, d, SekPcS68k);\r
+ if (a >= 0x50 && a < 0x68)\r
+ gfx_cd_write(a&~1, (d<<8)|d);\r
+ else s68k_reg_write8(a,d);\r
return;\r
}\r
\r
\r
// regs\r
if ((a&0xfffe00) == 0xff8000) {\r
- rdprintf("s68k_regs w16: [%02x] %04x @ %06x", a&0x1ff, d, SekPcS68k);\r
- s68k_reg_write8(a, d>>8, 16);\r
- s68k_reg_write8(a+1,d&0xff, 16);\r
+ a &= 0x1fe;\r
+ rdprintf("s68k_regs w16: [%02x] %04x @ %06x", a, d, SekPcS68k);\r
+ if (a >= 0x50 && a < 0x68)\r
+ gfx_cd_write(a, d);\r
+ else {\r
+ s68k_reg_write8(a, d>>8);\r
+ s68k_reg_write8(a+1,d&0xff);\r
+ }\r
return;\r
}\r
\r
\r
// regs\r
if ((a&0xfffe00) == 0xff8000) {\r
- rdprintf("s68k_regs w32: [%02x] %08x @ %06x", a&0x1ff, d, SekPcS68k);\r
- s68k_reg_write8(a, d>>24, 32);\r
- s68k_reg_write8(a+1,(d>>16)&0xff, 32);\r
- s68k_reg_write8(a+2,(d>>8) &0xff, 32);\r
- s68k_reg_write8(a+3, d &0xff, 32);\r
+ a &= 0x1fe;\r
+ rdprintf("s68k_regs w32: [%02x] %08x @ %06x", a, d, SekPcS68k);\r
+ if (a >= 0x50 && a < 0x68) {\r
+ gfx_cd_write(a, d>>16);\r
+ gfx_cd_write(a+2, d&0xffff);\r
+ } else {\r
+ s68k_reg_write8(a, d>>24);\r
+ s68k_reg_write8(a+1,(d>>16)&0xff);\r
+ s68k_reg_write8(a+2,(d>>8) &0xff);\r
+ s68k_reg_write8(a+3, d &0xff);\r
+ }\r
return;\r
}\r
\r