mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-06 07:38:05 -04:00
region detection, cd states wip, fixes, stuff
git-svn-id: file:///home/notaz/opt/svn/PicoDrive@25 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
parent
cb0316e4c5
commit
51a902ae25
26 changed files with 520 additions and 291 deletions
151
Pico/cd/Area.c
Normal file
151
Pico/cd/Area.c
Normal file
|
@ -0,0 +1,151 @@
|
|||
// This is part of Pico Library
|
||||
|
||||
// (c) Copyright 2006 notaz, All rights reserved.
|
||||
// Free for non-commercial use.
|
||||
|
||||
// For commercial use, separate licencing terms must be obtained.
|
||||
|
||||
|
||||
#include "../PicoInt.h"
|
||||
|
||||
// ym2612
|
||||
#include "../sound/ym2612.h"
|
||||
|
||||
// sn76496
|
||||
extern int *sn76496_regs;
|
||||
|
||||
|
||||
typedef enum {
|
||||
CHUNK_M68K = 1,
|
||||
CHUNK_RAM,
|
||||
CHUNK_VRAM,
|
||||
CHUNK_ZRAM,
|
||||
CHUNK_CRAM,
|
||||
CHUNK_VSRAM,
|
||||
CHUNK_MISC,
|
||||
CHUNK_VIDEO,
|
||||
CHUNK_Z80,
|
||||
CHUNK_PSG,
|
||||
CHUNK_FM,
|
||||
// CD stuff
|
||||
} chunk_name_e;
|
||||
|
||||
|
||||
static int write_chunk(chunk_name_e name, int len, void *data, void *file)
|
||||
{
|
||||
size_t bwritten = 0;
|
||||
bwritten += areaWrite(&name, 1, 1, file);
|
||||
bwritten += areaWrite(&len, 1, 4, file);
|
||||
bwritten += areaWrite(data, 1, len, file);
|
||||
|
||||
return (bwritten == len + 4 + 1);
|
||||
}
|
||||
|
||||
|
||||
#define CHECKED_WRITE(name,len,data) \
|
||||
if (!write_chunk(name, len, data, file)) return 1;
|
||||
|
||||
#define CHECKED_WRITE_BUFF(name,buff) \
|
||||
if (!write_chunk(name, sizeof(buff), &buff, file)) return 1;
|
||||
|
||||
int PicoCdSaveState(void *file)
|
||||
{
|
||||
unsigned char buff[0x60];
|
||||
void *ym2612_regs = YM2612GetRegs();
|
||||
|
||||
areaWrite("PicoSMCD", 1, 8, file);
|
||||
areaWrite(&PicoVer, 1, 4, file);
|
||||
|
||||
memset(buff, 0, sizeof(buff));
|
||||
PicoAreaPackCpu(buff, 0);
|
||||
CHECKED_WRITE_BUFF(CHUNK_M68K, buff);
|
||||
CHECKED_WRITE_BUFF(CHUNK_RAM, Pico.ram);
|
||||
CHECKED_WRITE_BUFF(CHUNK_VRAM, Pico.vram);
|
||||
CHECKED_WRITE_BUFF(CHUNK_ZRAM, Pico.zram);
|
||||
CHECKED_WRITE_BUFF(CHUNK_CRAM, Pico.cram);
|
||||
CHECKED_WRITE_BUFF(CHUNK_VSRAM, Pico.vsram);
|
||||
CHECKED_WRITE_BUFF(CHUNK_MISC, Pico.m);
|
||||
CHECKED_WRITE_BUFF(CHUNK_VIDEO, Pico.video);
|
||||
if(PicoOpt&7) {
|
||||
memset(buff, 0, sizeof(buff));
|
||||
z80_pack(buff);
|
||||
CHECKED_WRITE_BUFF(CHUNK_Z80, buff);
|
||||
}
|
||||
if(PicoOpt&3)
|
||||
CHECKED_WRITE(CHUNK_PSG, 28*4, sn76496_regs);
|
||||
if(PicoOpt&1)
|
||||
CHECKED_WRITE(CHUNK_FM, 0x200+4, ym2612_regs);
|
||||
|
||||
// TODO: cd stuff
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int g_read_offs = 0;
|
||||
|
||||
#define CHECKED_READ(len,data) \
|
||||
if (areaRead(data, 1, len, file) != len) { \
|
||||
g_read_offs += len; \
|
||||
printf("areaRead: premature EOF\n"); \
|
||||
return 0; \
|
||||
}
|
||||
|
||||
#define R_ERROR_RETURN(error) \
|
||||
{ \
|
||||
printf("PicoCdLoadState @ %x: " error "\n", g_read_offs); \
|
||||
return 1; \
|
||||
}
|
||||
|
||||
#define CHECKED_READ2(len2,data) \
|
||||
if (len2 != len) R_ERROR_RETURN("unexpected len, wanted " #len2); \
|
||||
CHECKED_READ(len2, data)
|
||||
|
||||
#define CHECKED_READ_BUFF(buff) CHECKED_READ2(sizeof(buff), &buff);
|
||||
|
||||
int PicoCdLoadState(void *file)
|
||||
{
|
||||
unsigned char buff[0x60];
|
||||
int ver, len;
|
||||
void *ym2612_regs = YM2612GetRegs();
|
||||
|
||||
g_read_offs = 0;
|
||||
CHECKED_READ(8, buff);
|
||||
if (strncmp((char *)buff, "PicoSMCD", 8)) R_ERROR_RETURN("bad header");
|
||||
CHECKED_READ(4, &ver);
|
||||
|
||||
while (!areaEof(file))
|
||||
{
|
||||
CHECKED_READ(1, buff);
|
||||
CHECKED_READ(4, &len);
|
||||
if (len < 0 || len > 1024*256) R_ERROR_RETURN("bad length");
|
||||
|
||||
switch (buff[0])
|
||||
{
|
||||
case CHUNK_M68K:
|
||||
CHECKED_READ_BUFF(buff);
|
||||
PicoAreaUnpackCpu(buff, 0);
|
||||
break;
|
||||
|
||||
case CHUNK_Z80:
|
||||
CHECKED_READ_BUFF(buff);
|
||||
z80_unpack(buff);
|
||||
break;
|
||||
|
||||
case CHUNK_RAM: CHECKED_READ_BUFF(Pico.ram); break;
|
||||
case CHUNK_VRAM: CHECKED_READ_BUFF(Pico.vram); break;
|
||||
case CHUNK_ZRAM: CHECKED_READ_BUFF(Pico.zram); break;
|
||||
case CHUNK_CRAM: CHECKED_READ_BUFF(Pico.cram); break;
|
||||
case CHUNK_VSRAM: CHECKED_READ_BUFF(Pico.vsram); break;
|
||||
case CHUNK_MISC: CHECKED_READ_BUFF(Pico.m); break;
|
||||
case CHUNK_VIDEO: CHECKED_READ_BUFF(Pico.video); break;
|
||||
case CHUNK_PSG: CHECKED_READ2(28*4, sn76496_regs); break;
|
||||
case CHUNK_FM:
|
||||
CHECKED_READ2(0x200+4, ym2612_regs);
|
||||
YM2612PicoStateLoad();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -15,8 +15,6 @@
|
|||
|
||||
#define CDC_DMA_SPEED 256
|
||||
|
||||
int CDC_Decode_Reg_Read; // 2 context?
|
||||
|
||||
|
||||
static void CDD_Reset(void)
|
||||
{
|
||||
|
@ -55,7 +53,7 @@ static void CDC_Reset(void)
|
|||
Pico_mcd->cdc.IFCTRL = 0;
|
||||
Pico_mcd->cdc.CTRL.N = 0;
|
||||
|
||||
CDC_Decode_Reg_Read = 0;
|
||||
Pico_mcd->cdd.CDC_Decode_Reg_Read = 0;
|
||||
Pico_mcd->scd.Status_CDC &= ~0x08;
|
||||
}
|
||||
|
||||
|
@ -259,7 +257,7 @@ unsigned char CDC_Read_Reg(void)
|
|||
case 0x1: // IFSTAT
|
||||
cdprintf("CDC read reg 01 = %.2X", Pico_mcd->cdc.IFSTAT);
|
||||
|
||||
CDC_Decode_Reg_Read |= (1 << 1); // Reg 1 (decoding)
|
||||
Pico_mcd->cdd.CDC_Decode_Reg_Read |= (1 << 1); // Reg 1 (decoding)
|
||||
Pico_mcd->s68k_regs[5] = 0x2;
|
||||
return Pico_mcd->cdc.IFSTAT;
|
||||
|
||||
|
@ -278,42 +276,42 @@ unsigned char CDC_Read_Reg(void)
|
|||
case 0x4: // HEAD0
|
||||
cdprintf("CDC read reg 04 = %.2X", Pico_mcd->cdc.HEAD.B.B0);
|
||||
|
||||
CDC_Decode_Reg_Read |= (1 << 4); // Reg 4 (decoding)
|
||||
Pico_mcd->cdd.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("CDC read reg 05 = %.2X", Pico_mcd->cdc.HEAD.B.B1);
|
||||
|
||||
CDC_Decode_Reg_Read |= (1 << 5); // Reg 5 (decoding)
|
||||
Pico_mcd->cdd.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("CDC read reg 06 = %.2X", Pico_mcd->cdc.HEAD.B.B2);
|
||||
|
||||
CDC_Decode_Reg_Read |= (1 << 6); // Reg 6 (decoding)
|
||||
Pico_mcd->cdd.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("CDC read reg 07 = %.2X", Pico_mcd->cdc.HEAD.B.B3);
|
||||
|
||||
CDC_Decode_Reg_Read |= (1 << 7); // Reg 7 (decoding)
|
||||
Pico_mcd->cdd.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("CDC read reg 08 = %.2X", Pico_mcd->cdc.PT.B.L);
|
||||
|
||||
CDC_Decode_Reg_Read |= (1 << 8); // Reg 8 (decoding)
|
||||
Pico_mcd->cdd.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("CDC read reg 09 = %.2X", Pico_mcd->cdc.PT.B.H);
|
||||
|
||||
CDC_Decode_Reg_Read |= (1 << 9); // Reg 9 (decoding)
|
||||
Pico_mcd->cdd.CDC_Decode_Reg_Read |= (1 << 9); // Reg 9 (decoding)
|
||||
Pico_mcd->s68k_regs[5] = 0xA;
|
||||
return Pico_mcd->cdc.PT.B.H;
|
||||
|
||||
|
@ -332,21 +330,21 @@ unsigned char CDC_Read_Reg(void)
|
|||
case 0xC: // STAT0
|
||||
cdprintf("CDC read reg 12 = %.2X", Pico_mcd->cdc.STAT.B.B0);
|
||||
|
||||
CDC_Decode_Reg_Read |= (1 << 12); // Reg 12 (decoding)
|
||||
Pico_mcd->cdd.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("CDC read reg 13 = %.2X", Pico_mcd->cdc.STAT.B.B1);
|
||||
|
||||
CDC_Decode_Reg_Read |= (1 << 13); // Reg 13 (decoding)
|
||||
Pico_mcd->cdd.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("CDC read reg 14 = %.2X", Pico_mcd->cdc.STAT.B.B2);
|
||||
|
||||
CDC_Decode_Reg_Read |= (1 << 14); // Reg 14 (decoding)
|
||||
Pico_mcd->cdd.CDC_Decode_Reg_Read |= (1 << 14); // Reg 14 (decoding)
|
||||
Pico_mcd->s68k_regs[5] = 0xF;
|
||||
return Pico_mcd->cdc.STAT.B.B2;
|
||||
|
||||
|
@ -357,7 +355,7 @@ unsigned char CDC_Read_Reg(void)
|
|||
Pico_mcd->cdc.IFSTAT |= 0x20; // decoding interrupt flag cleared
|
||||
if ((Pico_mcd->cdc.CTRL.B.B0 & 0x80) && (Pico_mcd->cdc.IFCTRL & 0x20))
|
||||
{
|
||||
if ((CDC_Decode_Reg_Read & 0x73F2) == 0x73F2)
|
||||
if ((Pico_mcd->cdd.CDC_Decode_Reg_Read & 0x73F2) == 0x73F2)
|
||||
Pico_mcd->cdc.STAT.B.B3 = 0x80;
|
||||
}
|
||||
return ret;
|
||||
|
|
|
@ -88,6 +88,7 @@ typedef struct
|
|||
} B;
|
||||
unsigned int N;
|
||||
} CTRL;
|
||||
unsigned int CDC_Decode_Reg_Read;
|
||||
} CDC;
|
||||
|
||||
typedef struct
|
||||
|
@ -105,9 +106,6 @@ typedef struct
|
|||
} CDD;
|
||||
|
||||
|
||||
extern int CDC_Decode_Reg_Read;
|
||||
|
||||
|
||||
void LC89510_Reset(void);
|
||||
unsigned short Read_CDC_Host(int is_sub);
|
||||
void Update_CDC_TRansfer(int which);
|
||||
|
|
|
@ -31,8 +31,6 @@ typedef unsigned int u32;
|
|||
|
||||
// extern m68ki_cpu_core m68ki_cpu;
|
||||
|
||||
extern int counter75hz;
|
||||
|
||||
|
||||
static u32 m68k_reg_read16(u32 a)
|
||||
{
|
||||
|
@ -91,12 +89,12 @@ static void m68k_reg_write8(u32 a, u32 d)
|
|||
return;
|
||||
case 1:
|
||||
d &= 3;
|
||||
if (!(d&1)) PicoMCD |= 2; // reset pending, needed to be sure we fetch the right vectors on reset
|
||||
if (!(d&1)) Pico_mcd->m.state_flags |= 1; // reset pending, needed to be sure we fetch the right vectors on reset
|
||||
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) {
|
||||
if ((Pico_mcd->m.state_flags&1) && (d&3)==1) {
|
||||
SekResetS68k(); // S68k comes out of RESET or BRQ state
|
||||
PicoMCD&=~2;
|
||||
Pico_mcd->m.state_flags&=~1;
|
||||
dprintf("m68k: resetting s68k, cycles=%i", SekCyclesLeft);
|
||||
}
|
||||
Pico_mcd->m.busreq = d;
|
||||
|
@ -225,7 +223,6 @@ static void s68k_reg_write8(u32 a, u32 d)
|
|||
dprintf("s68k irq mask: %02x", d);
|
||||
if ((d&(1<<4)) && (Pico_mcd->s68k_regs[0x37]&4) && !(Pico_mcd->s68k_regs[0x33]&(1<<4))) {
|
||||
CDD_Export_Status();
|
||||
// counter75hz = 0; // ???
|
||||
}
|
||||
break;
|
||||
case 0x34: // fader
|
||||
|
@ -238,7 +235,6 @@ static void s68k_reg_write8(u32 a, u32 d)
|
|||
Pico_mcd->s68k_regs[0x37] = d&7;
|
||||
if ((d&4) && !(d_old&4)) {
|
||||
CDD_Export_Status();
|
||||
// counter75hz = 0; // ???
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
16
Pico/cd/Misc.c
Normal file
16
Pico/cd/Misc.c
Normal file
|
@ -0,0 +1,16 @@
|
|||
|
||||
|
||||
unsigned char formatted_bram[8*0x10] =
|
||||
{
|
||||
0x00, 0xd4, 0x63, 0x00, 0x00, 0x03, 0x03, 0x00, 0x03, 0x03, 0x03, 0x00, 0x03, 0x00, 0x00, 0x03,
|
||||
0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x53, 0xd2, 0xf5, 0x3a, 0x48, 0x50, 0x35, 0x0f,
|
||||
0x47, 0x14, 0xf5, 0x7e, 0x5c, 0xd4, 0xf3, 0x03, 0x00, 0x03, 0x12, 0x00, 0x0a, 0xff, 0xca, 0xa6,
|
||||
0xf5, 0x27, 0xed, 0x22, 0x47, 0xfa, 0x22, 0x96, 0x6c, 0xa5, 0x88, 0x14, 0x48, 0x48, 0x0a, 0xbb,
|
||||
0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x00, 0x00, 0x00, 0x00, 0x40,
|
||||
0x00, 0x7d, 0x00, 0x7d, 0x00, 0x7d, 0x00, 0x7d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x53, 0x45, 0x47, 0x41, 0x5f, 0x43, 0x44, 0x5f, 0x52, 0x4f, 0x4d, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||
0x52, 0x41, 0x4d, 0x5f, 0x43, 0x41, 0x52, 0x54, 0x52, 0x49, 0x44, 0x47, 0x45, 0x5f, 0x5f, 0x5f,
|
||||
// SEGA_CD_ROM.....RAM_CART
|
||||
};
|
||||
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
#include "../sound/sound.h"
|
||||
|
||||
|
||||
static int counter75hz = 0; // TODO: move 2 context
|
||||
extern unsigned char formatted_bram[8*0x10];
|
||||
|
||||
|
||||
int PicoInitMCD(void)
|
||||
|
@ -30,15 +30,22 @@ void PicoExitMCD(void)
|
|||
|
||||
int PicoResetMCD(int hard)
|
||||
{
|
||||
// clear everything except BIOS
|
||||
memset(Pico_mcd->prg_ram, 0, sizeof(mcd_state) - sizeof(Pico_mcd->bios));
|
||||
memset(Pico_mcd->prg_ram, 0, sizeof(Pico_mcd->prg_ram));
|
||||
memset(Pico_mcd->word_ram, 0, sizeof(Pico_mcd->word_ram));
|
||||
if (hard) {
|
||||
memset(Pico_mcd->bram, 0, sizeof(Pico_mcd->bram));
|
||||
memcpy(Pico_mcd->bram + sizeof(Pico_mcd->bram) - 8*0x10, formatted_bram, 8*0x10);
|
||||
}
|
||||
memset(Pico_mcd->s68k_regs, 0, sizeof(Pico_mcd->s68k_regs));
|
||||
|
||||
*(unsigned int *)(Pico_mcd->bios + 0x70) = 0xffffffff; // reset hint vector (simplest way to implement reg6)
|
||||
PicoMCD |= 2; // s68k reset pending. TODO: move
|
||||
Pico_mcd->m.state_flags |= 2; // s68k reset pending
|
||||
Pico_mcd->s68k_regs[3] = 1; // 2M word RAM mode with m68k access after reset
|
||||
counter75hz = 0;
|
||||
Pico_mcd->m.counter75hz = 0;
|
||||
|
||||
LC89510_Reset();
|
||||
Reset_CD();
|
||||
gfx_cd_reset();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -235,8 +242,8 @@ static int PicoFrameHintsMCD(void)
|
|||
total_z80+=z80_run(z80CycleAim-total_z80);
|
||||
}
|
||||
|
||||
if ((counter75hz+=10) >= counter75hz_lim) {
|
||||
counter75hz -= counter75hz_lim;
|
||||
if ((Pico_mcd->m.counter75hz+=10) >= counter75hz_lim) {
|
||||
Pico_mcd->m.counter75hz -= counter75hz_lim;
|
||||
Check_CD_Command();
|
||||
}
|
||||
|
||||
|
|
|
@ -23,20 +23,21 @@ struct Cyclone PicoCpuS68k;
|
|||
m68ki_cpu_core PicoS68kCPU; // Mega CD's CPU
|
||||
#endif
|
||||
|
||||
static int irqs = 0; // TODO: 2 context
|
||||
static int new_irq_level(int level)
|
||||
{
|
||||
int level_new = 0, irqs;
|
||||
Pico_mcd->m.s68k_pend_ints &= ~(1 << level);
|
||||
irqs = Pico_mcd->m.s68k_pend_ints;
|
||||
irqs &= Pico_mcd->s68k_regs[0x33];
|
||||
while ((irqs >>= 1)) level_new++;
|
||||
|
||||
return level_new;
|
||||
}
|
||||
|
||||
#ifdef EMU_M68K
|
||||
static int SekIntAckS68k(int level)
|
||||
{
|
||||
int level_new = 0;
|
||||
irqs &= ~(1 << level);
|
||||
irqs &= Pico_mcd->s68k_regs[0x33];
|
||||
if (irqs) {
|
||||
level_new = 6;
|
||||
while (level_new > 0) { if (irqs & (1 << level_new)) break; level_new--; }
|
||||
}
|
||||
|
||||
int level_new = new_irq_level(level);
|
||||
dprintf("s68kACK %i -> %i", level, level_new);
|
||||
CPU_INT_LEVEL = level_new << 8;
|
||||
return M68K_INT_ACK_AUTOVECTOR;
|
||||
|
@ -45,15 +46,9 @@ static int SekIntAckS68k(int level)
|
|||
|
||||
#ifdef EMU_C68K
|
||||
// interrupt acknowledgment
|
||||
static void SekIntAck(int level)
|
||||
static void SekIntAckS68k(int level)
|
||||
{
|
||||
int level_new = 0;
|
||||
irqs &= ~(1 << level);
|
||||
irqs &= Pico_mcd->s68k_regs[0x33];
|
||||
if (irqs) {
|
||||
level_new = 6;
|
||||
while (level_new > 0) { if (irqs & (1 << level_new)) break; level_new--; }
|
||||
}
|
||||
int level_new = new_irq_level(level);
|
||||
|
||||
dprintf("s68kACK %i -> %i", level, level_new);
|
||||
PicoCpuS68k.irq = level_new;
|
||||
|
@ -82,7 +77,7 @@ int SekInitS68k()
|
|||
#ifdef EMU_C68K
|
||||
// CycloneInit();
|
||||
memset(&PicoCpuS68k,0,sizeof(PicoCpuS68k));
|
||||
PicoCpuS68k.IrqCallback=SekIntAck;
|
||||
PicoCpuS68k.IrqCallback=SekIntAckS68k;
|
||||
PicoCpuS68k.ResetCallback=SekResetAck;
|
||||
PicoCpuS68k.UnrecognizedCallback=SekUnrecognizedOpcode;
|
||||
#endif
|
||||
|
@ -132,14 +127,18 @@ int SekResetS68k()
|
|||
|
||||
int SekInterruptS68k(int irq)
|
||||
{
|
||||
irqs |= 1 << irq;
|
||||
int irqs, real_irq = 1;
|
||||
Pico_mcd->m.s68k_pend_ints |= 1 << irq;
|
||||
irqs = Pico_mcd->m.s68k_pend_ints >> 1;
|
||||
while ((irqs >>= 1)) real_irq++; // this is probably only needed for Cyclone
|
||||
|
||||
#ifdef EMU_C68K
|
||||
PicoCpuS68k.irq=irq;
|
||||
PicoCpuS68k.irq=real_irq;
|
||||
#endif
|
||||
#ifdef EMU_M68K
|
||||
void *oldcontext = m68ki_cpu_p;
|
||||
m68k_set_context(&PicoS68kCPU);
|
||||
m68k_set_irq(irq); // raise irq (gets lowered after taken or must be done in ack)
|
||||
m68k_set_irq(real_irq); // raise irq (gets lowered after taken or must be done in ack)
|
||||
m68k_set_context(oldcontext);
|
||||
#endif
|
||||
return 0;
|
||||
|
|
|
@ -1,20 +1,3 @@
|
|||
/*
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#if defined(__WIN__)
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include "port.h"
|
||||
#endif
|
||||
#include "cd_sys.h"
|
||||
#include "cd_file.h"
|
||||
#include "lc89510.h"
|
||||
#include "cdda_mp3.h"
|
||||
#include "star_68k.h"
|
||||
#include "rom.h"
|
||||
#include "mem_s68k.h"
|
||||
*/
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include "cd_file.h"
|
||||
|
||||
|
@ -24,6 +7,7 @@
|
|||
//#define cdprintf(x...)
|
||||
#define DEBUG_CD
|
||||
|
||||
// TODO: check refs, move 2 context
|
||||
struct _file_track Tracks[100];
|
||||
char Track_Played;
|
||||
|
||||
|
@ -53,6 +37,7 @@ int Load_ISO(const char *iso_name, int is_bin)
|
|||
static char *exts[] = {
|
||||
"%02d.mp3", " %02d.mp3", "-%02d.mp3", "_%02d.mp3", " - %02d.mp3",
|
||||
"%d.mp3", " %d.mp3", "-%d.mp3", "_%d.mp3", " - %d.mp3",
|
||||
"%02d.MP3", " %02d.MP3", "-%02d.MP3", "_%02d.MP3", " - %02d.MP3",
|
||||
/* "%02d.wav", " %02d.wav", "-%02d.wav", "_%02d.wav", " - %02d.wav",
|
||||
"%d.wav", " %d.wav", "-%d.wav", "_%d.wav", " - %2d.wav" */
|
||||
};
|
||||
|
@ -103,8 +88,6 @@ int Load_ISO(const char *iso_name, int is_bin)
|
|||
|
||||
for (num_track = 2, i = 0; i < 100; i++)
|
||||
{
|
||||
if (sizeof(exts)/sizeof(char *) != 10) { printf("eee"); exit(1); }
|
||||
|
||||
for(j = 0; j < sizeof(exts)/sizeof(char *); j++)
|
||||
{
|
||||
int ext_len;
|
||||
|
|
|
@ -28,11 +28,7 @@ int CD_Audio_Starting;
|
|||
*/
|
||||
|
||||
static int CD_Present = 0;
|
||||
int CD_Timer_Counter = 0; // TODO: check refs
|
||||
|
||||
static int CDD_Complete;
|
||||
|
||||
static int File_Add_Delay = 0;
|
||||
// int CD_Timer_Counter = 0; // TODO: check refs
|
||||
|
||||
|
||||
|
||||
|
@ -46,7 +42,7 @@ if (Pico_mcd->scd.Status_CDD == TRAY_OPEN) \
|
|||
Pico_mcd->cdd.Frame = 0; \
|
||||
Pico_mcd->cdd.Ext = 0; \
|
||||
\
|
||||
CDD_Complete = 1; \
|
||||
Pico_mcd->scd.CDD_Complete = 1; \
|
||||
\
|
||||
return 2; \
|
||||
}
|
||||
|
@ -63,7 +59,7 @@ if (!CD_Present) \
|
|||
Pico_mcd->cdd.Frame = 0; \
|
||||
Pico_mcd->cdd.Ext = 0; \
|
||||
\
|
||||
CDD_Complete = 1; \
|
||||
Pico_mcd->scd.CDD_Complete = 1; \
|
||||
\
|
||||
return 3; \
|
||||
}
|
||||
|
@ -158,9 +154,9 @@ void Check_CD_Command(void)
|
|||
|
||||
// Check CDD
|
||||
|
||||
if (CDD_Complete)
|
||||
if (Pico_mcd->scd.CDD_Complete)
|
||||
{
|
||||
CDD_Complete = 0;
|
||||
Pico_mcd->scd.CDD_Complete = 0;
|
||||
|
||||
CDD_Export_Status();
|
||||
}
|
||||
|
@ -176,11 +172,11 @@ void Check_CD_Command(void)
|
|||
Pico_mcd->s68k_regs[0x36] |= 0x01;
|
||||
else Pico_mcd->s68k_regs[0x36] &= ~0x01; // AUDIO
|
||||
|
||||
if (File_Add_Delay == 0)
|
||||
if (Pico_mcd->scd.File_Add_Delay == 0)
|
||||
{
|
||||
FILE_Read_One_LBA_CDC();
|
||||
}
|
||||
else File_Add_Delay--;
|
||||
else Pico_mcd->scd.File_Add_Delay--;
|
||||
}
|
||||
|
||||
if (Pico_mcd->scd.Status_CDD == FAST_FOW)
|
||||
|
@ -217,7 +213,7 @@ void Reset_CD(void)
|
|||
Pico_mcd->scd.Cur_Track = 0;
|
||||
Pico_mcd->scd.Cur_LBA = -150;
|
||||
Pico_mcd->scd.Status_CDD = READY;
|
||||
CDD_Complete = 0;
|
||||
Pico_mcd->scd.CDD_Complete = 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -267,7 +263,7 @@ int Get_Status_CDD_c0(void)
|
|||
else if ((Pico_mcd->cdd.Status & 0x0F00) == 0x0E00)
|
||||
Pico_mcd->cdd.Status = (Pico_mcd->scd.Status_CDD & 0xFF00) | (Pico_mcd->cdd.Status & 0x00FF);
|
||||
|
||||
CDD_Complete = 1;
|
||||
Pico_mcd->scd.CDD_Complete = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -290,7 +286,7 @@ int Stop_CDD_c1(void)
|
|||
Pico_mcd->cdd.Frame = 0;
|
||||
Pico_mcd->cdd.Ext = 0;
|
||||
|
||||
CDD_Complete = 1;
|
||||
Pico_mcd->scd.CDD_Complete = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -322,7 +318,7 @@ int Get_Pos_CDD_c20(void)
|
|||
Pico_mcd->cdd.Frame = INT_TO_BCDW(MSF.F);
|
||||
Pico_mcd->cdd.Ext = 0;
|
||||
|
||||
CDD_Complete = 1;
|
||||
Pico_mcd->scd.CDD_Complete = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -356,7 +352,7 @@ int Get_Track_Pos_CDD_c21(void)
|
|||
Pico_mcd->cdd.Frame = INT_TO_BCDW(MSF.F);
|
||||
Pico_mcd->cdd.Ext = 0;
|
||||
|
||||
CDD_Complete = 1;
|
||||
Pico_mcd->scd.CDD_Complete = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -385,7 +381,7 @@ int Get_Current_Track_CDD_c22(void)
|
|||
Pico_mcd->cdd.Frame = 0;
|
||||
Pico_mcd->cdd.Ext = 0;
|
||||
|
||||
CDD_Complete = 1;
|
||||
Pico_mcd->scd.CDD_Complete = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -415,7 +411,7 @@ int Get_Total_Lenght_CDD_c23(void)
|
|||
// FIXME: remove
|
||||
//Pico_mcd->cdd.Seconde = 2;
|
||||
|
||||
CDD_Complete = 1;
|
||||
Pico_mcd->scd.CDD_Complete = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -441,7 +437,7 @@ int Get_First_Last_Track_CDD_c24(void)
|
|||
// FIXME: remove
|
||||
//Pico_mcd->cdd.Minute = Pico_mcd->cdd.Seconde = 1;
|
||||
|
||||
CDD_Complete = 1;
|
||||
Pico_mcd->scd.CDD_Complete = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -476,7 +472,7 @@ int Get_Track_Adr_CDD_c25(void)
|
|||
|
||||
if (Pico_mcd->scd.TOC.Tracks[track_number - Pico_mcd->scd.TOC.First_Track].Type) Pico_mcd->cdd.Frame |= 0x0800;
|
||||
|
||||
CDD_Complete = 1;
|
||||
Pico_mcd->scd.CDD_Complete = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -513,7 +509,7 @@ int Play_CDD_c3(void)
|
|||
Pico_mcd->cdd.Status = 0x0102;
|
||||
// Pico_mcd->cdd.Status = COMM_OK;
|
||||
|
||||
if (File_Add_Delay == 0) File_Add_Delay = delay;
|
||||
if (Pico_mcd->scd.File_Add_Delay == 0) Pico_mcd->scd.File_Add_Delay = delay;
|
||||
|
||||
if (Pico_mcd->scd.TOC.Tracks[Pico_mcd->scd.Cur_Track - Pico_mcd->scd.TOC.First_Track].Type)
|
||||
{
|
||||
|
@ -534,7 +530,7 @@ int Play_CDD_c3(void)
|
|||
|
||||
Pico_mcd->scd.Status_CDC |= 1; // Read data with CDC
|
||||
|
||||
CDD_Complete = 1;
|
||||
Pico_mcd->scd.CDD_Complete = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -571,7 +567,7 @@ int Seek_CDD_c4(void)
|
|||
Pico_mcd->cdd.Frame = 0;
|
||||
Pico_mcd->cdd.Ext = 0;
|
||||
|
||||
CDD_Complete = 1;
|
||||
Pico_mcd->scd.CDD_Complete = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -594,7 +590,7 @@ int Pause_CDD_c6(void)
|
|||
Pico_mcd->cdd.Frame = 0;
|
||||
Pico_mcd->cdd.Ext = 0;
|
||||
|
||||
CDD_Complete = 1;
|
||||
Pico_mcd->scd.CDD_Complete = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -637,7 +633,7 @@ int Resume_CDD_c7(void)
|
|||
|
||||
Pico_mcd->scd.Status_CDC |= 1; // Read data with CDC
|
||||
|
||||
CDD_Complete = 1;
|
||||
Pico_mcd->scd.CDD_Complete = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -657,7 +653,7 @@ int Fast_Foward_CDD_c8(void)
|
|||
Pico_mcd->cdd.Frame = 0;
|
||||
Pico_mcd->cdd.Ext = 0;
|
||||
|
||||
CDD_Complete = 1;
|
||||
Pico_mcd->scd.CDD_Complete = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -678,7 +674,7 @@ int Fast_Rewind_CDD_c9(void)
|
|||
Pico_mcd->cdd.Frame = 0;
|
||||
Pico_mcd->cdd.Ext = 0;
|
||||
|
||||
CDD_Complete = 1;
|
||||
Pico_mcd->scd.CDD_Complete = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -712,7 +708,7 @@ int Close_Tray_CDD_cC(void)
|
|||
Pico_mcd->cdd.Ext = 0;
|
||||
}
|
||||
|
||||
CDD_Complete = 1;
|
||||
Pico_mcd->scd.CDD_Complete = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -735,7 +731,7 @@ int Open_Tray_CDD_cD(void)
|
|||
Pico_mcd->cdd.Frame = 0;
|
||||
Pico_mcd->cdd.Ext = 0;
|
||||
|
||||
CDD_Complete = 1;
|
||||
Pico_mcd->scd.CDD_Complete = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -756,7 +752,7 @@ int CDD_cA(void)
|
|||
Pico_mcd->cdd.Frame = INT_TO_BCDW(1);
|
||||
Pico_mcd->cdd.Ext = 0;
|
||||
|
||||
CDD_Complete = 1;
|
||||
Pico_mcd->scd.CDD_Complete = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -46,12 +46,11 @@ typedef struct {
|
|||
_scd_toc TOC;
|
||||
int Cur_LBA;
|
||||
unsigned int Cur_Track;
|
||||
int File_Add_Delay;
|
||||
char CDD_Complete;
|
||||
} _scd;
|
||||
|
||||
|
||||
extern int CD_Timer_Counter;
|
||||
|
||||
|
||||
void LBA_to_MSF(int lba, _msf *MSF);
|
||||
int Track_to_LBA(int track);
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// TODO...
|
||||
|
||||
// #include <string.h>
|
||||
#include "../PicoInt.h"
|
||||
|
||||
#define rot_comp Pico_mcd->rot_comp
|
||||
|
@ -197,3 +198,8 @@ void gfx_cd_write(unsigned int a, unsigned int d)
|
|||
}
|
||||
|
||||
|
||||
void gfx_cd_reset(void)
|
||||
{
|
||||
memset(&rot_comp.Reg_58, 0, 0/*sizeof(Pico_mcd->rot_comp)*/);
|
||||
}
|
||||
|
||||
|
|
|
@ -36,5 +36,7 @@ void gfx_cd_update(void);
|
|||
unsigned int gfx_cd_read(unsigned int a);
|
||||
void gfx_cd_write(unsigned int a, unsigned int d);
|
||||
|
||||
void gfx_cd_reset(void);
|
||||
|
||||
#endif // _GFX_CD_H
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue