From c459aefdad169c97b6fb93a20c1219a76aa07505 Mon Sep 17 00:00:00 2001 From: notaz Date: Thu, 11 Jan 2007 22:21:34 +0000 Subject: [PATCH] shows: press start button git-svn-id: file:///home/notaz/opt/svn/PicoDrive@17 be3aeb3a-fb24-0410-a615-afba39da0efa --- Pico/PicoInt.h | 10 ++++- Pico/cd/LC89510.c | 73 ++++++++++++++++---------------- Pico/cd/Memory.c | 103 +++++++++++++++++++++++++--------------------- Pico/cd/Pico.c | 11 ++--- Pico/cd/cd_file.c | 17 ++++---- Pico/cd/cd_sys.c | 21 +++++----- 6 files changed, 128 insertions(+), 107 deletions(-) diff --git a/Pico/PicoInt.h b/Pico/PicoInt.h index dd1d417f..8f328ea8 100644 --- a/Pico/PicoInt.h +++ b/Pico/PicoInt.h @@ -162,6 +162,14 @@ struct PicoSRAM #include "cd/cd_sys.h" #include "cd/LC89510.h" +struct mcd_misc +{ + unsigned short hint_vector; + unsigned char busreq; + unsigned char pad0; + +}; + typedef struct { unsigned char bios[0x20000]; @@ -171,10 +179,10 @@ typedef struct }; unsigned char word_ram[0x40000]; unsigned char s68k_regs[0x200]; - unsigned char m68k_regs[0x10]; CDD cdd; CDC cdc; _scd scd; + struct mcd_misc m; } mcd_state; #define Pico_mcd ((mcd_state *)Pico.rom) diff --git a/Pico/cd/LC89510.c b/Pico/cd/LC89510.c index 91b44442..de11f90e 100644 --- a/Pico/cd/LC89510.c +++ b/Pico/cd/LC89510.c @@ -9,14 +9,13 @@ #include "../PicoInt.h" -#define cdprintf printf +#define cdprintf dprintf //#define cdprintf(x...) #define CDC_DMA_SPEED 256 -int CDC_Decode_Reg_Read; -static int Status_CDC; // internal status (TODO: 2 context?) +int CDC_Decode_Reg_Read; // 2 context? static void CDD_Reset(void) @@ -57,7 +56,7 @@ static void CDC_Reset(void) Pico_mcd->cdc.CTRL.N = 0; CDC_Decode_Reg_Read = 0; - Status_CDC = 0; + Pico_mcd->scd.Status_CDC &= ~0x08; } @@ -81,7 +80,7 @@ void Update_CDC_TRansfer(int which) if (Pico_mcd->cdc.DBC.N <= (CDC_DMA_SPEED * 2)) { length = (Pico_mcd->cdc.DBC.N + 1) >> 1; - Status_CDC &= ~0x08; // Last transfer + Pico_mcd->scd.Status_CDC &= ~0x08; // Last transfer Pico_mcd->s68k_regs[4] |= 0x80; // End data transfer Pico_mcd->s68k_regs[4] &= ~0x40; // no more data ready Pico_mcd->cdc.IFSTAT |= 0x08; // No more data transfer in progress @@ -152,7 +151,7 @@ void Update_CDC_TRansfer(int which) length <<= 1; Pico_mcd->cdc.DAC.N = (Pico_mcd->cdc.DAC.N + length) & 0xFFFF; - if (Status_CDC & 0x08) Pico_mcd->cdc.DBC.N -= length; + if (Pico_mcd->scd.Status_CDC & 0x08) Pico_mcd->cdc.DBC.N -= length; else Pico_mcd->cdc.DBC.N = 0; } @@ -161,9 +160,10 @@ unsigned short Read_CDC_Host(int is_sub) { int addr; - if (!(Status_CDC & 0x08)) + if (!(Pico_mcd->scd.Status_CDC & 0x08)) { // Transfer data disabled + cdprintf("Read_CDC_Host: Transfer data disabled"); return 0; } @@ -171,6 +171,7 @@ unsigned short Read_CDC_Host(int is_sub) (!is_sub && (Pico_mcd->s68k_regs[4] & 7) != 2)) { // Wrong setting + cdprintf("Read_CDC_Host: Wrong setting"); return 0; } @@ -179,7 +180,7 @@ unsigned short Read_CDC_Host(int is_sub) if (Pico_mcd->cdc.DBC.N <= 0) { Pico_mcd->cdc.DBC.N = 0; - Status_CDC &= ~0x08; // Last transfer + Pico_mcd->scd.Status_CDC &= ~0x08; // Last transfer Pico_mcd->s68k_regs[4] |= 0x80; // End data transfer Pico_mcd->s68k_regs[4] &= ~0x40; // no more data ready Pico_mcd->cdc.IFSTAT |= 0x08; // No more data transfer in progress @@ -193,12 +194,16 @@ unsigned short Read_CDC_Host(int is_sub) SekInterruptS68k(5); } - cdprintf("CDC - DTE interrupt\n"); + cdprintf("CDC - DTE interrupt"); } } addr = Pico_mcd->cdc.DAC.N; Pico_mcd->cdc.DAC.N += 2; + + cdprintf("Read_CDC_Host sub=%i d=%04x dac=%04x dbc=%04x", is_sub, + (Pico_mcd->cdc.Buffer[addr]<<8) | Pico_mcd->cdc.Buffer[addr+1], Pico_mcd->cdc.DAC.N, Pico_mcd->cdc.DBC.N); + return (Pico_mcd->cdc.Buffer[addr]<<8) | Pico_mcd->cdc.Buffer[addr+1]; #if 0 @@ -244,112 +249,110 @@ unsigned char CDC_Read_Reg(void) { unsigned char ret; - cdprintf("CDC read reg %.2d = ", Pico_mcd->s68k_regs[5] & 0xF); - switch(Pico_mcd->s68k_regs[5] & 0xF) { case 0x0: // COMIN - cdprintf("%.2X\n", Pico_mcd->cdc.COMIN); + cdprintf("CDC read reg 00 = %.2X", Pico_mcd->cdc.COMIN); Pico_mcd->s68k_regs[5] = 0x1; return Pico_mcd->cdc.COMIN; case 0x1: // IFSTAT - cdprintf("%.2X\n", Pico_mcd->cdc.IFSTAT); + cdprintf("CDC read reg 01 = %.2X", Pico_mcd->cdc.IFSTAT); CDC_Decode_Reg_Read |= (1 << 1); // Reg 1 (decoding) Pico_mcd->s68k_regs[5] = 0x2; return Pico_mcd->cdc.IFSTAT; case 0x2: // DBCL - cdprintf("%.2X\n", Pico_mcd->cdc.DBC.B.L); + cdprintf("CDC read reg 02 = %.2X", Pico_mcd->cdc.DBC.B.L); Pico_mcd->s68k_regs[5] = 0x3; return Pico_mcd->cdc.DBC.B.L; case 0x3: // DBCH - cdprintf("%.2X\n", Pico_mcd->cdc.DBC.B.H); + cdprintf("CDC read reg 03 = %.2X", Pico_mcd->cdc.DBC.B.H); Pico_mcd->s68k_regs[5] = 0x4; return Pico_mcd->cdc.DBC.B.H; case 0x4: // HEAD0 - cdprintf("%.2X\n", Pico_mcd->cdc.HEAD.B.B0); + cdprintf("CDC read reg 04 = %.2X", Pico_mcd->cdc.HEAD.B.B0); CDC_Decode_Reg_Read |= (1 << 4); // Reg 4 (decoding) Pico_mcd->s68k_regs[5] = 0x5; return Pico_mcd->cdc.HEAD.B.B0; case 0x5: // HEAD1 - cdprintf("%.2X\n", Pico_mcd->cdc.HEAD.B.B1); + cdprintf("CDC read reg 05 = %.2X", Pico_mcd->cdc.HEAD.B.B1); CDC_Decode_Reg_Read |= (1 << 5); // Reg 5 (decoding) Pico_mcd->s68k_regs[5] = 0x6; return Pico_mcd->cdc.HEAD.B.B1; case 0x6: // HEAD2 - cdprintf("%.2X\n", Pico_mcd->cdc.HEAD.B.B2); + cdprintf("CDC read reg 06 = %.2X", Pico_mcd->cdc.HEAD.B.B2); CDC_Decode_Reg_Read |= (1 << 6); // Reg 6 (decoding) Pico_mcd->s68k_regs[5] = 0x7; return Pico_mcd->cdc.HEAD.B.B2; case 0x7: // HEAD3 - cdprintf("%.2X\n", Pico_mcd->cdc.HEAD.B.B3); + cdprintf("CDC read reg 07 = %.2X", Pico_mcd->cdc.HEAD.B.B3); CDC_Decode_Reg_Read |= (1 << 7); // Reg 7 (decoding) Pico_mcd->s68k_regs[5] = 0x8; return Pico_mcd->cdc.HEAD.B.B3; case 0x8: // PTL - cdprintf("%.2X\n", Pico_mcd->cdc.PT.B.L); + cdprintf("CDC read reg 08 = %.2X", Pico_mcd->cdc.PT.B.L); CDC_Decode_Reg_Read |= (1 << 8); // Reg 8 (decoding) Pico_mcd->s68k_regs[5] = 0x9; return Pico_mcd->cdc.PT.B.L; case 0x9: // PTH - cdprintf("%.2X\n", Pico_mcd->cdc.PT.B.H); + cdprintf("CDC read reg 09 = %.2X", Pico_mcd->cdc.PT.B.H); CDC_Decode_Reg_Read |= (1 << 9); // Reg 9 (decoding) Pico_mcd->s68k_regs[5] = 0xA; return Pico_mcd->cdc.PT.B.H; case 0xA: // WAL - cdprintf("%.2X\n", Pico_mcd->cdc.WA.B.L); + cdprintf("CDC read reg 10 = %.2X", Pico_mcd->cdc.WA.B.L); Pico_mcd->s68k_regs[5] = 0xB; return Pico_mcd->cdc.WA.B.L; case 0xB: // WAH - cdprintf("%.2X\n", Pico_mcd->cdc.WA.B.H); + cdprintf("CDC read reg 11 = %.2X", Pico_mcd->cdc.WA.B.H); Pico_mcd->s68k_regs[5] = 0xC; return Pico_mcd->cdc.WA.B.H; case 0xC: // STAT0 - cdprintf("%.2X\n", Pico_mcd->cdc.STAT.B.B0); + cdprintf("CDC read reg 12 = %.2X", Pico_mcd->cdc.STAT.B.B0); CDC_Decode_Reg_Read |= (1 << 12); // Reg 12 (decoding) Pico_mcd->s68k_regs[5] = 0xD; return Pico_mcd->cdc.STAT.B.B0; case 0xD: // STAT1 - cdprintf("%.2X\n", Pico_mcd->cdc.STAT.B.B1); + cdprintf("CDC read reg 13 = %.2X", Pico_mcd->cdc.STAT.B.B1); CDC_Decode_Reg_Read |= (1 << 13); // Reg 13 (decoding) Pico_mcd->s68k_regs[5] = 0xE; return Pico_mcd->cdc.STAT.B.B1; case 0xE: // STAT2 - cdprintf("%.2X\n", Pico_mcd->cdc.STAT.B.B2); + cdprintf("CDC read reg 14 = %.2X", Pico_mcd->cdc.STAT.B.B2); CDC_Decode_Reg_Read |= (1 << 14); // Reg 14 (decoding) Pico_mcd->s68k_regs[5] = 0xF; return Pico_mcd->cdc.STAT.B.B2; case 0xF: // STAT3 - cdprintf("%.2X\n", Pico_mcd->cdc.STAT.B.B3); + cdprintf("CDC read reg 15 = %.2X", Pico_mcd->cdc.STAT.B.B3); ret = Pico_mcd->cdc.STAT.B.B3; Pico_mcd->cdc.IFSTAT |= 0x20; // decoding interrupt flag cleared @@ -367,7 +370,7 @@ unsigned char CDC_Read_Reg(void) void CDC_Write_Reg(unsigned char Data) { - cdprintf("CDC write reg%d = %.2X\n", Pico_mcd->s68k_regs[5] & 0xF, Data); + cdprintf("CDC write reg%02d = %.2X", Pico_mcd->s68k_regs[5] & 0xF, Data); switch (Pico_mcd->s68k_regs[5] & 0xF) { @@ -384,7 +387,7 @@ void CDC_Write_Reg(unsigned char Data) if ((Pico_mcd->cdc.IFCTRL & 0x02) == 0) // Stop data transfer { Pico_mcd->cdc.DBC.N = 0; - Status_CDC &= ~0x08; + Pico_mcd->scd.Status_CDC &= ~0x08; Pico_mcd->cdc.IFSTAT |= 0x08; // No more data transfer in progress } break; @@ -417,10 +420,10 @@ void CDC_Write_Reg(unsigned char Data) if (Pico_mcd->cdc.IFCTRL & 0x02) // Data transfer enable ? { Pico_mcd->cdc.IFSTAT &= ~0x08; // Data transfer in progress - Status_CDC |= 0x08; // Data transfer in progress + Pico_mcd->scd.Status_CDC |= 0x08; // Data transfer in progress Pico_mcd->s68k_regs[4] &= 0x7F; // A data transfer start - cdprintf("\n************** Starting Data Transfer ***********\n"); + 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); } @@ -503,8 +506,8 @@ void CDD_Export_Status(void) SekInterruptS68k(4); } - cdprintf("CDD exported status\n"); - cdprintf("Status =%.4X, Minute=%.4X, Second=%.4X, Frame=%.4X Checksum=%.4X\n", +// cdprintf("CDD exported status\n"); + cdprintf("out: Status=%.4X, Minute=%.4X, Second=%.4X, Frame=%.4X Checksum=%.4X", (Pico_mcd->s68k_regs[0x38+0] << 8) | Pico_mcd->s68k_regs[0x38+1], (Pico_mcd->s68k_regs[0x38+2] << 8) | Pico_mcd->s68k_regs[0x38+3], (Pico_mcd->s68k_regs[0x38+4] << 8) | Pico_mcd->s68k_regs[0x38+5], @@ -515,8 +518,8 @@ void CDD_Export_Status(void) void CDD_Import_Command(void) { - cdprintf("CDD importing command\n"); - cdprintf("Command=%.4X, Minute=%.4X, Second=%.4X, Frame=%.4X Checksum=%.4X\n", +// cdprintf("CDD importing command\n"); + cdprintf("in: Command=%.4X, Minute=%.4X, Second=%.4X, Frame=%.4X Checksum=%.4X", (Pico_mcd->s68k_regs[0x38+10+0] << 8) | Pico_mcd->s68k_regs[0x38+10+1], (Pico_mcd->s68k_regs[0x38+10+2] << 8) | Pico_mcd->s68k_regs[0x38+10+3], (Pico_mcd->s68k_regs[0x38+10+4] << 8) | Pico_mcd->s68k_regs[0x38+10+5], diff --git a/Pico/cd/Memory.c b/Pico/cd/Memory.c index 78602144..0113d7f8 100644 --- a/Pico/cd/Memory.c +++ b/Pico/cd/Memory.c @@ -22,6 +22,7 @@ typedef unsigned int u32; //#define __debug_io //#define __debug_io2 +#define rdprintf dprintf // ----------------------------------------------------------------- @@ -38,26 +39,30 @@ static u32 m68k_reg_read16(u32 a, int realsize) switch (a) { case 0: - d = ((Pico_mcd->s68k_regs[0x33]<<13)&0x8000) | Pico_mcd->m68k_regs[1]; // here IFL2 is always 0, just like in Gens + d = ((Pico_mcd->s68k_regs[0x33]<<13)&0x8000) | Pico_mcd->m.busreq; // here IFL2 is always 0, just like in Gens goto end; case 2: d = (Pico_mcd->s68k_regs[a]<<8) | (Pico_mcd->s68k_regs[a+1]&0xc7); dprintf("m68k_regs r3: %02x @%06x", (u8)d, SekPc); goto end; + case 4: + d = Pico_mcd->s68k_regs[4]<<8; + goto end; + case 6: + d = Pico_mcd->m.hint_vector; + goto end; case 8: dprintf("m68k host data read"); d = Read_CDC_Host(0); goto end; + case 0xA: + dprintf("m68k reserved read"); + goto end; case 0xC: dprintf("m68k stopwatch read"); break; } - if (a < 0xE) { - d = (Pico_mcd->m68k_regs[a]<<8) | Pico_mcd->m68k_regs[a+1]; - goto end; - } - if (a < 0x30) { // comm flag/cmd/status (0xE-0x2F) d = (Pico_mcd->s68k_regs[a]<<8) | Pico_mcd->s68k_regs[a+1]; @@ -81,18 +86,19 @@ static void m68k_reg_write8(u32 a, u32 d, int realsize) case 0: d &= 1; if ((d&1) && (Pico_mcd->s68k_regs[0x33]&(1<<2))) { dprintf("m68k: s68k irq 2"); SekInterruptS68k(2); } - break; + return; case 1: d &= 3; if (!(d&1)) PicoMCD |= 2; // reset pending, needed to be sure we fetch the right vectors on reset - if ( (Pico_mcd->m68k_regs[1]&1) != (d&1)) dprintf("m68k: s68k reset %i", !(d&1)); - if ( (Pico_mcd->m68k_regs[1]&2) != (d&2)) dprintf("m68k: s68k brq %i", (d&2)>>1); - if (/*!(Pico_mcd->m68k_regs[1]&1) &&*/ (PicoMCD&2) && (d&3)==1) { + if ( (Pico_mcd->m.busreq&1) != (d&1)) dprintf("m68k: s68k reset %i", !(d&1)); + if ( (Pico_mcd->m.busreq&2) != (d&2)) dprintf("m68k: s68k brq %i", (d&2)>>1); + if ((PicoMCD&2) && (d&3)==1) { SekResetS68k(); // S68k comes out of RESET or BRQ state PicoMCD&=~2; dprintf("m68k: resetting s68k, cycles=%i", SekCyclesLeft); } - break; + Pico_mcd->m.busreq = d; + return; case 2: Pico_mcd->s68k_regs[2] = d; // really use s68k side register return; @@ -108,18 +114,19 @@ static void m68k_reg_write8(u32 a, u32 d, int realsize) if (!(d & 4) && (d & 2)) d &= ~1; // return word RAM to s68k in 2M mode Pico_mcd->s68k_regs[3] = d; // really use s68k side register return; + case 6: + *((char *)&Pico_mcd->m.hint_vector+1) = d; + return; + case 7: + *(char *)&Pico_mcd->m.hint_vector = d; + return; case 0xe: //dprintf("m68k: comm flag: %02x", d); //dprintf("s68k @ %06x", SekPcS68k); Pico_mcd->s68k_regs[0xe] = d; - break; - } - - if (a < 0x10) { - Pico_mcd->m68k_regs[a] = (u8) d; - return; + return; } if ((a&0xf0) == 0x10) { @@ -127,8 +134,7 @@ static void m68k_reg_write8(u32 a, u32 d, int realsize) return; } - if (a >= 0x20 || (a >= 0xa && a <= 0xd) || a == 0x0f) - dprintf("m68k: invalid write?"); + dprintf("m68k: invalid write? [%02x] %02x", a, d); } @@ -142,7 +148,8 @@ static u32 s68k_reg_read16(u32 a, int realsize) switch (a) { case 0: - d = 1; goto end; // ver = 0, not in reset state + d = 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); dprintf("s68k_regs r3: %02x @%06x", (u8)d, SekPc); @@ -196,7 +203,7 @@ static void s68k_reg_write8(u32 a, u32 d, int realsize) Pico_mcd->s68k_regs[4] = (Pico_mcd->s68k_regs[4]&0xC0) | (d&7); // CDC mode return; case 5: - dprintf("s68k CDC reg addr: %x", d&0xf); + //dprintf("s68k CDC reg addr: %x", d&0xf); break; case 7: CDC_Write_Reg(d); @@ -478,13 +485,13 @@ u8 PicoReadM68k8(u32 a) if ((a&0xff4000)==0xa00000) { d=z80Read8(a); goto end; } // Z80 Ram - //if ((a&0xffffc0)==0xa12000) - // dprintf("m68k_regs r8: [%02x] @%06x", a&0x3f, SekPc); + if ((a&0xffffc0)==0xa12000) + rdprintf("m68k_regs r8: [%02x] @%06x", a&0x3f, SekPc); d=OtherRead16(a&~1, 8|(a&1)); if ((a&1)==0) d>>=8; - //if ((a&0xffffc0)==0xa12000) - // dprintf("ret = %02x", (u8)d); + if ((a&0xffffc0)==0xa12000) + rdprintf("ret = %02x", (u8)d); end: @@ -530,13 +537,13 @@ u16 PicoReadM68k16(u32 a) goto end; } - //if ((a&0xffffc0)==0xa12000) - // dprintf("m68k_regs r16: [%02x] @%06x", a&0x3f, SekPc); + if ((a&0xffffc0)==0xa12000) + rdprintf("m68k_regs r16: [%02x] @%06x", a&0x3f, SekPc); d = (u16)OtherRead16(a, 16); - //if ((a&0xffffc0)==0xa12000) - // dprintf("ret = %04x", d); + if ((a&0xffffc0)==0xa12000) + rdprintf("ret = %04x", d); end: @@ -585,13 +592,13 @@ u32 PicoReadM68k32(u32 a) goto end; } - //if ((a&0xffffc0)==0xa12000) - // dprintf("m68k_regs r32: [%02x] @%06x", a&0x3f, SekPc); + if ((a&0xffffc0)==0xa12000) + rdprintf("m68k_regs r32: [%02x] @%06x", a&0x3f, SekPc); d = (OtherRead16(a, 32)<<16)|OtherRead16(a+2, 32); - //if ((a&0xffffc0)==0xa12000) - // dprintf("ret = %08x", d); + if ((a&0xffffc0)==0xa12000) + rdprintf("ret = %08x", d); end: #ifdef __debug_io @@ -641,8 +648,8 @@ void PicoWriteM68k8(u32 a,u8 d) return; } - //if ((a&0xffffc0)==0xa12000) - // dprintf("m68k_regs w8: [%02x] %02x @%06x", a&0x3f, d, SekPc); + if ((a&0xffffc0)==0xa12000) + rdprintf("m68k_regs w8: [%02x] %02x @%06x", a&0x3f, d, SekPc); OtherWrite8(a,d,8); } @@ -683,8 +690,8 @@ void PicoWriteM68k16(u32 a,u16 d) return; } - //if ((a&0xffffc0)==0xa12000) - // dprintf("m68k_regs w16: [%02x] %04x @%06x", a&0x3f, d, SekPc); + if ((a&0xffffc0)==0xa12000) + rdprintf("m68k_regs w16: [%02x] %04x @%06x", a&0x3f, d, SekPc); OtherWrite16(a,d); } @@ -735,8 +742,8 @@ void PicoWriteM68k32(u32 a,u32 d) return; } - //if ((a&0xffffc0)==0xa12000) - // dprintf("m68k_regs w32: [%02x] %08x @%06x", a&0x3f, d, SekPc); + if ((a&0xffffc0)==0xa12000) + rdprintf("m68k_regs w32: [%02x] %08x @%06x", a&0x3f, d, SekPc); OtherWrite16(a, (u16)(d>>16)); OtherWrite16(a+2,(u16)d); @@ -760,9 +767,9 @@ u8 PicoReadS68k8(u32 a) // regs if ((a&0xfffe00) == 0xff8000) { - //dprintf("s68k_regs r8: [%02x] @ %06x", a&0x1ff, SekPcS68k); + rdprintf("s68k_regs r8: [%02x] @ %06x", a&0x1ff, SekPcS68k); d = s68k_reg_read16(a&~1, 8|(a&1)); if ((a&1)==0) d>>=8; - //dprintf("ret = %02x", (u8)d); + rdprintf("ret = %02x", (u8)d); goto end; } @@ -814,9 +821,9 @@ u16 PicoReadS68k16(u32 a) // regs if ((a&0xfffe00) == 0xff8000) { - //dprintf("s68k_regs r16: [%02x] @ %06x", a&0x1fe, SekPcS68k); + rdprintf("s68k_regs r16: [%02x] @ %06x", a&0x1fe, SekPcS68k); d = s68k_reg_read16(a, 16); - //dprintf("ret = %04x", d); + rdprintf("ret = %04x", d); goto end; } @@ -869,9 +876,9 @@ u32 PicoReadS68k32(u32 a) // regs if ((a&0xfffe00) == 0xff8000) { - //dprintf("s68k_regs r32: [%02x] @ %06x", a&0x1fe, SekPcS68k); + rdprintf("s68k_regs r32: [%02x] @ %06x", a&0x1fe, SekPcS68k); d = (s68k_reg_read16(a, 32)<<16)|s68k_reg_read16(a+2, 32); - //dprintf("ret = %08x", d); + rdprintf("ret = %08x", d); goto end; } @@ -933,7 +940,7 @@ void PicoWriteS68k8(u32 a,u8 d) // regs if ((a&0xfffe00) == 0xff8000) { - //dprintf("s68k_regs w8: [%02x] %02x @ %06x", a&0x1ff, d, SekPcS68k); + rdprintf("s68k_regs w8: [%02x] %02x @ %06x", a&0x1ff, d, SekPcS68k); s68k_reg_write8(a,d,8); return; } @@ -980,7 +987,7 @@ void PicoWriteS68k16(u32 a,u16 d) // regs if ((a&0xfffe00) == 0xff8000) { - //dprintf("s68k_regs w16: [%02x] %04x @ %06x", a&0x1ff, d, SekPcS68k); + 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); return; @@ -1029,7 +1036,7 @@ void PicoWriteS68k32(u32 a,u32 d) // regs if ((a&0xfffe00) == 0xff8000) { - //dprintf("s68k_regs w32: [%02x] %08x @ %06x", a&0x1ff, d, SekPcS68k); + 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); diff --git a/Pico/cd/Pico.c b/Pico/cd/Pico.c index 013340cc..573322cd 100644 --- a/Pico/cd/Pico.c +++ b/Pico/cd/Pico.c @@ -64,17 +64,18 @@ static __inline void SekRunS68k(int cyc) #endif } -static int Status_CDC; - static __inline void check_cd_dma(void) { int ddx; - if (!(Status_CDC & 0x08)) return; + if (!(Pico_mcd->scd.Status_CDC & 0x08)) return; ddx = Pico_mcd->s68k_regs[4] & 7; if (ddx < 2) return; // invalid - if (ddx < 4) Pico_mcd->s68k_regs[4] |= 0x40; // Data set ready in host port + if (ddx < 4) { + Pico_mcd->s68k_regs[4] |= 0x40; // Data set ready in host port + return; + } if (ddx == 6) return; // invalid Update_CDC_TRansfer(ddx); // now go and do the actual transfer @@ -180,7 +181,7 @@ static int PicoFrameHintsMCD(void) //dprintf("m68k starting exec @ %06x", SekPc); if(Pico.m.dma_bytes) SekCycleCnt+=CheckDMA(); SekRun(cycles_68k); - if ((Pico_mcd->m68k_regs[1]&3) == 1) { // no busreq/no reset + if ((Pico_mcd->m.busreq&3) == 1) { // no busreq/no reset #if 0 int i; FILE *f = fopen("prg_ram.bin", "wb"); diff --git a/Pico/cd/cd_file.c b/Pico/cd/cd_file.c index 1f634744..4f11ba57 100644 --- a/Pico/cd/cd_file.c +++ b/Pico/cd/cd_file.c @@ -20,8 +20,9 @@ #include "../PicoInt.h" -#define cdprintf printf +#define cdprintf dprintf //#define cdprintf(x...) +#define DEBUG_CD struct _file_track Tracks[100]; char Track_Played; @@ -92,7 +93,7 @@ int Load_ISO(const char *iso_name, int is_bin) SCD_TOC_Tracks[0].MSF.S = 2; SCD_TOC_Tracks[0].MSF.F = 0; - cdprintf("\nTrack 0 - %02d:%02d:%02d %s\n", SCD_TOC_Tracks[0].MSF.M, SCD_TOC_Tracks[0].MSF.S, SCD_TOC_Tracks[0].MSF.F, + cdprintf("Track 0 - %02d:%02d:%02d %s", SCD_TOC_Tracks[0].MSF.M, SCD_TOC_Tracks[0].MSF.S, SCD_TOC_Tracks[0].MSF.F, SCD_TOC_Tracks[0].Type ? "DATA" : "AUDIO"); Cur_LBA = Tracks[0].Lenght; // Size in sectors @@ -127,7 +128,7 @@ int Load_ISO(const char *iso_name, int is_bin) LBA_to_MSF(Cur_LBA, &(SCD_TOC_Tracks[index].MSF)); - cdprintf("\nTrack %i - %02d:%02d:%02d %s\n", index, SCD_TOC_Tracks[index].MSF.M, + cdprintf("Track %i - %02d:%02d:%02d %s", index, SCD_TOC_Tracks[index].MSF.M, SCD_TOC_Tracks[index].MSF.S, SCD_TOC_Tracks[index].MSF.F, SCD_TOC_Tracks[index].Type ? "DATA" : "AUDIO"); @@ -194,7 +195,7 @@ int FILE_Read_One_LBA_CDC(void) fseek(Tracks[0].F, where_read, SEEK_SET); fread(cp_buf, 1, 2048, Tracks[0].F); - cdprintf("\n\nRead file CDC 1 data sector :\n"); + cdprintf("Read file CDC 1 data sector :\n"); } else // AUDIO { @@ -207,7 +208,7 @@ int FILE_Read_One_LBA_CDC(void) // Write_CD_Audio((short *) cp_buf, rate, channel, 588); } - cdprintf("\n\nRead file CDC 1 audio sector :\n"); + cdprintf("Read file CDC 1 audio sector :\n"); } // Update CDC stuff @@ -231,8 +232,8 @@ int FILE_Read_One_LBA_CDC(void) memcpy(&Pico_mcd->cdc.Buffer[Pico_mcd->cdc.PT.N], &Pico_mcd->cdc.HEAD, 4); #ifdef DEBUG_CD - cdprintf("\nRead -> WA = %d Buffer[%d] =\n", Pico_mcd->cdc.WA.N, Pico_mcd->cdc.PT.N & 0x3FFF); - cdprintf("Header 1 = %.2X %.2X %.2X %.2X\n", Pico_mcd->cdc.HEAD.B.B0, + cdprintf("Read -> WA = %d Buffer[%d] =", Pico_mcd->cdc.WA.N, Pico_mcd->cdc.PT.N & 0x3FFF); + cdprintf("Header 1 = %.2X %.2X %.2X %.2X", Pico_mcd->cdc.HEAD.B.B0, Pico_mcd->cdc.HEAD.B.B1, Pico_mcd->cdc.HEAD.B.B2, Pico_mcd->cdc.HEAD.B.B3); cdprintf("Header 2 = %.2X %.2X %.2X %.2X --- %.2X %.2X\n\n", Pico_mcd->cdc.Buffer[(Pico_mcd->cdc.PT.N + 0) & 0x3FFF], @@ -302,7 +303,7 @@ int FILE_Play_CD_LBA(void) { int index = Pico_mcd->scd.Cur_Track - Pico_mcd->scd.TOC.First_Track; - cdprintf("Play FILE Comp\n"); + cdprintf("Play FILE Comp"); if (Tracks[index].F == NULL) { diff --git a/Pico/cd/cd_sys.c b/Pico/cd/cd_sys.c index 833680b1..2c70ea26 100644 --- a/Pico/cd/cd_sys.c +++ b/Pico/cd/cd_sys.c @@ -4,8 +4,9 @@ #include "../PicoInt.h" -#define cdprintf printf +#define cdprintf dprintf //#define cdprintf(x...) +#define DEBUG_CD #define TRAY_OPEN 0x0500 // TRAY OPEN CDD status #define NOCD 0x0000 // CD removed CDD status @@ -153,7 +154,7 @@ int Track_to_LBA(int track) void Check_CD_Command(void) { - cdprintf("CHECK CD COMMAND\n"); + cdprintf("CHECK CD COMMAND"); // Check CDD @@ -168,7 +169,7 @@ void Check_CD_Command(void) if (Pico_mcd->scd.Status_CDC & 1) // CDC is reading data ... { - cdprintf("Sending a read command\n"); + cdprintf("Got a read command"); // DATA ? if (Pico_mcd->scd.TOC.Tracks[Pico_mcd->scd.Cur_Track - Pico_mcd->scd.TOC.First_Track].Type) @@ -256,7 +257,7 @@ void Change_CD(void) int Get_Status_CDD_c0(void) { - cdprintf("Status command : Cur LBA = %d\n", Pico_mcd->scd.Cur_LBA); + cdprintf("Status command : Cur LBA = %d", Pico_mcd->scd.Cur_LBA); // Clear immediat status if ((Pico_mcd->cdd.Status & 0x0F00) == 0x0200) @@ -299,7 +300,7 @@ int Get_Pos_CDD_c20(void) { _msf MSF; - cdprintf("command 200 : Cur LBA = %d\n", Pico_mcd->scd.Cur_LBA); + cdprintf("command 200 : Cur LBA = %d", Pico_mcd->scd.Cur_LBA); CHECK_TRAY_OPEN @@ -312,7 +313,7 @@ int Get_Pos_CDD_c20(void) // else if (!(CDC.CTRL.B.B0 & 0x80)) Pico_mcd->cdd.Status |= Pico_mcd->scd.Status_CDD; Pico_mcd->cdd.Status |= Pico_mcd->scd.Status_CDD; - cdprintf("Status CDD = %.4X Status = %.4X\n", Pico_mcd->scd.Status_CDD, Pico_mcd->cdd.Status); + cdprintf("Status CDD = %.4X Status = %.4X", Pico_mcd->scd.Status_CDD, Pico_mcd->cdd.Status); LBA_to_MSF(Pico_mcd->scd.Cur_LBA, &MSF); @@ -348,7 +349,7 @@ int Get_Track_Pos_CDD_c21(void) elapsed_time = Pico_mcd->scd.Cur_LBA - Track_to_LBA(LBA_to_Track(Pico_mcd->scd.Cur_LBA)); LBA_to_MSF(elapsed_time - 150, &MSF); - cdprintf(" elapsed = %d\n", elapsed_time); + cdprintf(" elapsed = %d", elapsed_time); Pico_mcd->cdd.Minute = INT_TO_BCDW(MSF.M); Pico_mcd->cdd.Seconde = INT_TO_BCDW(MSF.S); @@ -363,7 +364,7 @@ int Get_Track_Pos_CDD_c21(void) int Get_Current_Track_CDD_c22(void) { - cdprintf("Status CDD = %.4X Status = %.4X\n", Pico_mcd->scd.Status_CDD, Pico_mcd->cdd.Status); + cdprintf("Status CDD = %.4X Status = %.4X", Pico_mcd->scd.Status_CDD, Pico_mcd->cdd.Status); CHECK_TRAY_OPEN @@ -504,7 +505,7 @@ int Play_CDD_c3(void) Pico_mcd->scd.Cur_LBA = new_lba; CDC_Update_Header(); - cdprintf("Read : Cur LBA = %d, M=%d, S=%d, F=%d\n", Pico_mcd->scd.Cur_LBA, MSF.M, MSF.S, MSF.F); + cdprintf("Read : Cur LBA = %d, M=%d, S=%d, F=%d", Pico_mcd->scd.Cur_LBA, MSF.M, MSF.S, MSF.F); if (Pico_mcd->scd.Status_CDD != PLAYING) delay += 20; @@ -610,7 +611,7 @@ int Resume_CDD_c7(void) { _msf MSF; LBA_to_MSF(Pico_mcd->scd.Cur_LBA, &MSF); - cdprintf("Resume read : Cur LBA = %d, M=%d, S=%d, F=%d\n", Pico_mcd->scd.Cur_LBA, MSF.M, MSF.S, MSF.F); + cdprintf("Resume read : Cur LBA = %d, M=%d, S=%d, F=%d", Pico_mcd->scd.Cur_LBA, MSF.M, MSF.S, MSF.F); } #endif -- 2.39.5