From: notaz Date: Sat, 13 Jan 2007 21:57:26 +0000 (+0000) Subject: Sonic CD shows Sega logo X-Git-Tag: v1.85~769 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cb4a513a96b173624619686ca21360d556557ec3;p=picodrive.git Sonic CD shows Sega logo git-svn-id: file:///home/notaz/opt/svn/PicoDrive@18 be3aeb3a-fb24-0410-a615-afba39da0efa --- diff --git a/Pico/cd/LC89510.c b/Pico/cd/LC89510.c index de11f90e..a6503ca6 100644 --- a/Pico/cd/LC89510.c +++ b/Pico/cd/LC89510.c @@ -65,15 +65,14 @@ void LC89510_Reset(void) CDD_Reset(); CDC_Reset(); - Pico_mcd->cdc.Host_Data = 0; - Pico_mcd->cdc.DMA_Adr = 0; - Pico_mcd->cdc.Stop_Watch = 0; + // clear DMA_Adr & Stop_Watch + memset(Pico_mcd->s68k_regs + 0xA, 0, 4); } void Update_CDC_TRansfer(int which) { - unsigned int dep, length, len; + unsigned int DMA_Adr, dep, length, len; unsigned short *dest; unsigned char *src; @@ -101,17 +100,17 @@ void Update_CDC_TRansfer(int which) // TODO: dst bounds checking? DAC.N alignment? src = Pico_mcd->cdc.Buffer + Pico_mcd->cdc.DAC.N; - + DMA_Adr = (Pico_mcd->s68k_regs[0xA]<<8) | Pico_mcd->s68k_regs[0xB]; if (which == 7) // WORD RAM { if (Pico_mcd->s68k_regs[3] & 4) { - dep = ((Pico_mcd->cdc.DMA_Adr & 0x3FFF) << 3); + dep = ((DMA_Adr & 0x3FFF) << 3); cdprintf("CD DMA # %04x -> word_ram1M # %06x, len=%i", Pico_mcd->cdc.DAC.N, dep, length); - dep = ((Pico_mcd->cdc.DMA_Adr & 0x3FFF) << 4); + dep = ((DMA_Adr & 0x3FFF) << 4); if (!(Pico_mcd->s68k_regs[3]&1)) dep += 2; dest = (unsigned short *) (Pico_mcd->word_ram + dep); @@ -120,7 +119,7 @@ void Update_CDC_TRansfer(int which) } else { - dep = ((Pico_mcd->cdc.DMA_Adr & 0x7FFF) << 3); + dep = ((DMA_Adr & 0x7FFF) << 3); cdprintf("CD DMA # %04x -> word_ram2M # %06x, len=%i", Pico_mcd->cdc.DAC.N, dep, length); dest = (unsigned short *) (Pico_mcd->word_ram + dep); @@ -133,14 +132,14 @@ void Update_CDC_TRansfer(int which) { #if 0 dest = (unsigned char *) Ram_PCM; - dep = ((Pico_mcd->cdc.DMA_Adr & 0x03FF) << 2) + PCM_Chip.Bank; + dep = ((DMA_Adr & 0x03FF) << 2) + PCM_Chip.Bank; #else - cdprintf("TODO: PCM Dma"); + cdprintf("CD DMA # %04x -> PCD TODO", Pico_mcd->cdc.DAC.N); #endif } else if (which == 5) // PRG RAM { - dep = (Pico_mcd->cdc.DMA_Adr & 0xFFFF) << 3; + dep = DMA_Adr << 3; dest = (unsigned short *) (Pico_mcd->prg_ram + dep); cdprintf("CD DMA # %04x -> prg_ram # %06x, len=%i", Pico_mcd->cdc.DAC.N, dep, length); @@ -425,7 +424,7 @@ void CDC_Write_Reg(unsigned char Data) cdprintf("************** Starting Data Transfer ***********"); cdprintf("RS0 = %.4X DAC = %.4X DBC = %.4X DMA adr = %.4X\n\n", Pico_mcd->s68k_regs[4]<<8, - Pico_mcd->cdc.DAC.N, Pico_mcd->cdc.DBC.N, Pico_mcd->cdc.DMA_Adr); + Pico_mcd->cdc.DAC.N, Pico_mcd->cdc.DBC.N, (Pico_mcd->s68k_regs[0xA]<<8) | Pico_mcd->s68k_regs[0xB]); } break; diff --git a/Pico/cd/LC89510.h b/Pico/cd/LC89510.h index 11001491..7acfe8ac 100644 --- a/Pico/cd/LC89510.h +++ b/Pico/cd/LC89510.h @@ -8,9 +8,9 @@ extern "C" { typedef struct { unsigned char Buffer[(32 * 1024 * 2) + 2352]; - unsigned int Host_Data; - unsigned int DMA_Adr; - unsigned int Stop_Watch; +// unsigned int Host_Data; // unused +// unsigned int DMA_Adr; // 0A +// unsigned int Stop_Watch; // 0C unsigned int COMIN; unsigned int IFSTAT; union diff --git a/Pico/cd/Memory.c b/Pico/cd/Memory.c index 0113d7f8..739f3bf8 100644 --- a/Pico/cd/Memory.c +++ b/Pico/cd/Memory.c @@ -16,13 +16,16 @@ #include "../sound/ym2612.h" #include "../sound/sn76496.h" +#include "gfx_cd.h" + typedef unsigned char u8; typedef unsigned short u16; typedef unsigned int u32; //#define __debug_io //#define __debug_io2 -#define rdprintf dprintf +//#define rdprintf dprintf +#define rdprintf(...) // ----------------------------------------------------------------- @@ -31,7 +34,7 @@ typedef unsigned int u32; extern int counter75hz; -static u32 m68k_reg_read16(u32 a, int realsize) +static u32 m68k_reg_read16(u32 a) { u32 d=0; a &= 0x3e; @@ -52,7 +55,6 @@ static u32 m68k_reg_read16(u32 a, int realsize) d = Pico_mcd->m.hint_vector; goto end; case 8: - dprintf("m68k host data read"); d = Read_CDC_Host(0); goto end; case 0xA: @@ -77,7 +79,7 @@ end: return d; } -static void m68k_reg_write8(u32 a, u32 d, int realsize) +static void m68k_reg_write8(u32 a, u32 d) { a &= 0x3f; // dprintf("m68k_regs w%2i: [%02x] %02x @%06x", realsize, a, d, SekPc); @@ -139,16 +141,15 @@ static void m68k_reg_write8(u32 a, u32 d, int realsize) -static u32 s68k_reg_read16(u32 a, int realsize) +static u32 s68k_reg_read16(u32 a) { u32 d=0; - a &= 0x1fe; // dprintf("s68k_regs r%2i: [%02x] @ %06x", realsize&~1, a+(realsize&1), SekPcS68k); switch (a) { case 0: - d = 1; // ver = 0, not in reset state + d = ((Pico_mcd->s68k_regs[0]&3)<<8) | 1; // ver = 0, not in reset state goto end; case 2: d = (Pico_mcd->s68k_regs[a]<<8) | (Pico_mcd->s68k_regs[a+1]&0x1f); @@ -158,8 +159,7 @@ static u32 s68k_reg_read16(u32 a, int realsize) d = CDC_Read_Reg(); goto end; case 8: - dprintf("s68k host data read"); - d = Read_CDC_Host(1); + d = Read_CDC_Host(1); // Gens returns 0 here on byte reads goto end; case 0xC: dprintf("s68k stopwatch read"); @@ -178,9 +178,8 @@ end: return d; } -static void s68k_reg_write8(u32 a, u32 d, int realsize) +static void s68k_reg_write8(u32 a, u32 d) { - a &= 0x1ff; //dprintf("s68k_regs w%2i: [%02x] %02x @ %06x", realsize, a, d, SekPcS68k); // TODO: review against Gens @@ -349,7 +348,7 @@ static u32 OtherRead16(u32 a, int realsize) if ((a&0xe700e0)==0xc00000) { d=PicoVideoRead(a); goto end; } if ((a&0xffffc0)==0xa12000) { - d=m68k_reg_read16(a, realsize); + d=m68k_reg_read16(a); goto end; } @@ -411,7 +410,7 @@ static void OtherWrite8(u32 a,u32 d,int realsize) if ((a&0xe700e0)==0xc00000) { PicoVideoWrite(a,(u16)(d|(d<<8))); return; } // Byte access gets mirrored - if ((a&0xffffc0)==0xa12000) { m68k_reg_write8(a, d, realsize); return; } + if ((a&0xffffc0)==0xa12000) { m68k_reg_write8(a, d); return; } dprintf("strange w%i: %06x, %08x @%06x", realsize, a&0xffffff, d, SekPc); } @@ -767,8 +766,12 @@ u8 PicoReadS68k8(u32 a) // regs if ((a&0xfffe00) == 0xff8000) { - rdprintf("s68k_regs r8: [%02x] @ %06x", a&0x1ff, SekPcS68k); - d = s68k_reg_read16(a&~1, 8|(a&1)); if ((a&1)==0) d>>=8; + a &= 0x1ff; + rdprintf("s68k_regs r8: [%02x] @ %06x", a, SekPcS68k); + if (a >= 0x50 && a < 0x68) + d = gfx_cd_read(a&~1); + else d = s68k_reg_read16(a&~1); + if ((a&1)==0) d>>=8; rdprintf("ret = %02x", (u8)d); goto end; } @@ -821,8 +824,11 @@ u16 PicoReadS68k16(u32 a) // regs if ((a&0xfffe00) == 0xff8000) { - rdprintf("s68k_regs r16: [%02x] @ %06x", a&0x1fe, SekPcS68k); - d = s68k_reg_read16(a, 16); + a &= 0x1fe; + rdprintf("s68k_regs r16: [%02x] @ %06x", a, SekPcS68k); + if (a >= 0x50 && a < 0x68) + d = gfx_cd_read(a); + else d = s68k_reg_read16(a); rdprintf("ret = %04x", d); goto end; } @@ -876,8 +882,11 @@ u32 PicoReadS68k32(u32 a) // regs if ((a&0xfffe00) == 0xff8000) { - rdprintf("s68k_regs r32: [%02x] @ %06x", a&0x1fe, SekPcS68k); - d = (s68k_reg_read16(a, 32)<<16)|s68k_reg_read16(a+2, 32); + a &= 0x1fe; + rdprintf("s68k_regs r32: [%02x] @ %06x", a, SekPcS68k); + if (a >= 0x50 && a < 0x68) + d = (gfx_cd_read(a)<<16)|gfx_cd_read(a+2); + else d = (s68k_reg_read16(a)<<16)|s68k_reg_read16(a+2); rdprintf("ret = %08x", d); goto end; } @@ -940,8 +949,11 @@ void PicoWriteS68k8(u32 a,u8 d) // regs if ((a&0xfffe00) == 0xff8000) { - rdprintf("s68k_regs w8: [%02x] %02x @ %06x", a&0x1ff, d, SekPcS68k); - s68k_reg_write8(a,d,8); + a &= 0x1ff; + rdprintf("s68k_regs w8: [%02x] %02x @ %06x", a, d, SekPcS68k); + if (a >= 0x50 && a < 0x68) + gfx_cd_write(a&~1, (d<<8)|d); + else s68k_reg_write8(a,d); return; } @@ -987,9 +999,14 @@ void PicoWriteS68k16(u32 a,u16 d) // regs if ((a&0xfffe00) == 0xff8000) { - rdprintf("s68k_regs w16: [%02x] %04x @ %06x", a&0x1ff, d, SekPcS68k); - s68k_reg_write8(a, d>>8, 16); - s68k_reg_write8(a+1,d&0xff, 16); + a &= 0x1fe; + rdprintf("s68k_regs w16: [%02x] %04x @ %06x", a, d, SekPcS68k); + if (a >= 0x50 && a < 0x68) + gfx_cd_write(a, d); + else { + s68k_reg_write8(a, d>>8); + s68k_reg_write8(a+1,d&0xff); + } return; } @@ -1036,11 +1053,17 @@ void PicoWriteS68k32(u32 a,u32 d) // regs if ((a&0xfffe00) == 0xff8000) { - rdprintf("s68k_regs w32: [%02x] %08x @ %06x", a&0x1ff, d, SekPcS68k); - s68k_reg_write8(a, d>>24, 32); - s68k_reg_write8(a+1,(d>>16)&0xff, 32); - s68k_reg_write8(a+2,(d>>8) &0xff, 32); - s68k_reg_write8(a+3, d &0xff, 32); + a &= 0x1fe; + rdprintf("s68k_regs w32: [%02x] %08x @ %06x", a, d, SekPcS68k); + if (a >= 0x50 && a < 0x68) { + gfx_cd_write(a, d>>16); + gfx_cd_write(a+2, d&0xffff); + } else { + s68k_reg_write8(a, d>>24); + s68k_reg_write8(a+1,(d>>16)&0xff); + s68k_reg_write8(a+2,(d>>8) &0xff); + s68k_reg_write8(a+3, d &0xff); + } return; } diff --git a/Pico/cd/gfx_cd.c b/Pico/cd/gfx_cd.c new file mode 100644 index 00000000..f104f69f --- /dev/null +++ b/Pico/cd/gfx_cd.c @@ -0,0 +1,42 @@ +// TODO... + +#include "../PicoInt.h" + + +static void gfx_cd_start(void) +{ + dprintf("gfx_cd_start()"); + if (Pico_mcd->s68k_regs[0x33] & (1<<1)) + { + dprintf("gfx_cd irq 1"); + SekInterruptS68k(1); + } +} + +void gfx_cd_update(void) +{ +} + + +unsigned int gfx_cd_read(unsigned int a) +{ + dprintf("gfx_cd_read(%x)", a); + +// switch (a) { +// case 2: +// return; + return 0; +} + +void gfx_cd_write(unsigned int a, unsigned int d) +{ + dprintf("gfx_cd_write(%x, %04x)", a, d); + + switch (a) { + case 0x66: + if (Pico_mcd->s68k_regs[3]&4) return; // can't do tanformations in 1M mode + gfx_cd_start(); + return; + } +} + diff --git a/Pico/cd/gfx_cd.h b/Pico/cd/gfx_cd.h new file mode 100644 index 00000000..848fd040 --- /dev/null +++ b/Pico/cd/gfx_cd.h @@ -0,0 +1,7 @@ + + +void gfx_cd_update(void); + +unsigned int gfx_cd_read(unsigned int a); +void gfx_cd_write(unsigned int a, unsigned int d); + diff --git a/platform/linux/Makefile b/platform/linux/Makefile index e4d54802..cd369371 100644 --- a/platform/linux/Makefile +++ b/platform/linux/Makefile @@ -30,7 +30,7 @@ OBJS += ../../Pico/Area.o ../../Pico/Cart.o ../../Pico/Utils.o ../../Pico/Memory ../../Pico/Pico.o ../../Pico/Sek.o ../../Pico/VideoPort.o ../../Pico/Draw2.o ../../Pico/Draw.o # Pico - CD OBJS += ../../Pico/cd/Pico.o ../../Pico/cd/Memory.o ../../Pico/cd/Sek.o ../../Pico/cd/LC89510.o \ - ../../Pico/cd/cd_sys.o ../../Pico/cd/cd_file.o + ../../Pico/cd/cd_sys.o ../../Pico/cd/cd_file.o ../../Pico/cd/gfx_cd.o # Pico - sound OBJS += ../../Pico/sound/sound.o ../../Pico/sound/sn76496.o ../../Pico/sound/ym2612.o # zlib