mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 15:27:46 -04:00
ISO loading, menus, LEDs
git-svn-id: file:///home/notaz/opt/svn/PicoDrive@16 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
parent
d0d47c5be3
commit
bf098bc532
15 changed files with 914 additions and 295 deletions
38
Pico/Cart.c
38
Pico/Cart.c
|
@ -57,18 +57,21 @@ static int DecodeSmd(unsigned char *data,int len)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static unsigned char *cd_realloc(void *old, int filesize)
|
||||
{
|
||||
unsigned char *rom;
|
||||
dprintf("sizeof(mcd_state): %i", sizeof(mcd_state));
|
||||
rom=realloc(old, sizeof(mcd_state));
|
||||
if (rom) memset(rom+0x20000, 0, sizeof(mcd_state)-0x20000);
|
||||
return rom;
|
||||
}
|
||||
|
||||
static unsigned char *PicoCartAlloc(int filesize)
|
||||
{
|
||||
int alloc_size;
|
||||
unsigned char *rom;
|
||||
|
||||
if (PicoMCD & 1) {
|
||||
dprintf("sizeof(mcd_state): %i", sizeof(mcd_state));
|
||||
if (filesize > 0x20000) return NULL; // invalid BIOS
|
||||
rom=(unsigned char *)malloc(sizeof(mcd_state));
|
||||
if (rom) memset(rom, 0, sizeof(mcd_state));
|
||||
return rom;
|
||||
}
|
||||
if (PicoMCD & 1) return cd_realloc(NULL, filesize);
|
||||
|
||||
alloc_size=filesize+0x7ffff;
|
||||
if((filesize&0x3fff)==0x200) alloc_size-=0x200;
|
||||
|
@ -90,19 +93,19 @@ int PicoCartLoad(FILE *f,unsigned char **prom,unsigned int *psize)
|
|||
|
||||
fseek(f,0,SEEK_END); size=ftell(f); fseek(f,0,SEEK_SET);
|
||||
if (size <= 0) return 1;
|
||||
if (PicoMCD & 1) {
|
||||
if (size > 0x20000) return 1; // invalid BIOS
|
||||
size = 0xe0000;
|
||||
} else {
|
||||
size=(size+3)&~3; // Round up to a multiple of 4
|
||||
}
|
||||
size=(size+3)&~3; // Round up to a multiple of 4
|
||||
|
||||
// Allocate space for the rom plus padding
|
||||
rom=PicoCartAlloc(size);
|
||||
if (rom==NULL) return 1; // { fclose(f); return 1; }
|
||||
|
||||
fread(rom,1,size,f); // Load up the rom
|
||||
// fclose(f); // this is confusing. From now on, caller should close it, because it opened this.
|
||||
|
||||
// maybe we are loading MegaCD BIOS?
|
||||
if (!(PicoMCD&1) && size == 0x20000 && (!strncmp((char *)rom+0x124, "BOOT", 4) || !strncmp((char *)rom+0x128, "BOOT", 4))) {
|
||||
PicoMCD |= 1;
|
||||
rom = cd_realloc(rom, size);
|
||||
}
|
||||
|
||||
// Check for SMD:
|
||||
if ((size&0x3fff)==0x200) { DecodeSmd(rom,size); size-=0x200; } // Decode and byteswap SMD
|
||||
|
@ -184,6 +187,13 @@ int CartLoadZip(const char *fname, unsigned char **prom, unsigned int *psize)
|
|||
|
||||
closezip(zipfile);
|
||||
|
||||
// maybe we are loading MegaCD BIOS?
|
||||
if (!(PicoMCD&1) && size == 0x20000 &&
|
||||
(!strncmp((char *)rom+0x124, "BOOT", 4) || !strncmp((char *)rom+0x128, "BOOT", 4))) {
|
||||
PicoMCD |= 1;
|
||||
rom = cd_realloc(rom, size);
|
||||
}
|
||||
|
||||
// Check for SMD:
|
||||
if ((size&0x3fff)==0x200) { DecodeSmd(rom,size); size-=0x200; } // Decode and byteswap SMD
|
||||
else Byteswap(rom,size); // Just byteswap
|
||||
|
|
|
@ -22,8 +22,8 @@ void (*PicoWriteSound)(void) = 0; // called once per frame at the best time to s
|
|||
struct PicoSRAM SRam;
|
||||
int z80startCycle = 0, z80stopCycle = 0; // in 68k cycles
|
||||
//int z80ExtraCycles = 0;
|
||||
int PicoPad[2]; // Joypads, format is SACB RLDU
|
||||
int PicoMCD = 1; // mega CD status: scd_started
|
||||
int PicoPad[2]; // Joypads, format is SACB RLDU
|
||||
int PicoMCD = 0; // mega CD status: scd_started, reset_pending
|
||||
|
||||
// to be called once on emu init
|
||||
int PicoInit(void)
|
||||
|
|
|
@ -359,7 +359,7 @@ unsigned int PicoVideoRead(unsigned int a)
|
|||
if(Pico.m.rotate++&8) d|=0x0100; else d|=0x0200; // Toggle fifo full empty (who uses that stuff?)
|
||||
if(!(Pico.video.reg[1]&0x40)) d|=0x0008; // set V-Blank if display is disabled
|
||||
if(SekCyclesLeft < 84+4) d|=0x0004; // H-Blank (Sonic3 vs)
|
||||
dprintf("sr_read %04x @ %06x [%i|%i]", d, SekPc, Pico.m.scanline, SekCyclesDone());
|
||||
// dprintf("sr_read %04x @ %06x [%i|%i]", d, SekPc, Pico.m.scanline, SekCyclesDone());
|
||||
|
||||
Pico.video.pending=0; // ctrl port reads clear write-pending flag (Charles MacDonald)
|
||||
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
#if 0
|
||||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
#include "misc.h"
|
||||
#include "lc89510.h"
|
||||
#include "cd_aspi.h"
|
||||
#include "Star_68k.h"
|
||||
#include "mem_S68k.h"
|
||||
#include "pcm.h"
|
||||
#endif
|
||||
/***********************************************************
|
||||
* *
|
||||
* This source is taken from the Gens project *
|
||||
* Written by Stéphane Dallongeville *
|
||||
* Copyright (c) 2002 by Stéphane Dallongeville *
|
||||
* Modified/adapted for Picodrive by notaz, 2007 *
|
||||
* *
|
||||
***********************************************************/
|
||||
|
||||
#include "../PicoInt.h"
|
||||
|
||||
|
@ -18,7 +16,7 @@
|
|||
#define CDC_DMA_SPEED 256
|
||||
|
||||
int CDC_Decode_Reg_Read;
|
||||
static int Status_CDC; // internal status
|
||||
static int Status_CDC; // internal status (TODO: 2 context?)
|
||||
|
||||
|
||||
static void CDD_Reset(void)
|
||||
|
@ -73,129 +71,90 @@ void LC89510_Reset(void)
|
|||
Pico_mcd->cdc.Stop_Watch = 0;
|
||||
}
|
||||
|
||||
#if 0 // TODO
|
||||
void Update_CDC_TRansfer(void)
|
||||
|
||||
void Update_CDC_TRansfer(int which)
|
||||
{
|
||||
unsigned int i, dep, lenght, add_dest;
|
||||
unsigned char *dest;
|
||||
|
||||
if ((Status_CDC & 0x08) == 0) return;
|
||||
|
||||
switch(Pico_mcd->s68k_regs[4] & 7)
|
||||
{
|
||||
case 0x0200: // MAIN CPU
|
||||
case 0x0300: // SUB CPU
|
||||
Pico_mcd->s68k_regs[4] |= 0x40; // Data ready in host port
|
||||
return;
|
||||
|
||||
case 0x0400: // PCM RAM
|
||||
dest = (unsigned char *) Ram_PCM;
|
||||
dep = ((Pico_mcd->cdc.DMA_Adr & 0x03FF) << 2) + PCM_Chip.Bank;
|
||||
add_dest = 2;
|
||||
break;
|
||||
|
||||
case 0x0500: // PRG RAM
|
||||
dest = (unsigned char *) Ram_Prg;
|
||||
dep = (Pico_mcd->cdc.DMA_Adr & 0xFFFF) << 3;
|
||||
add_dest = 2;
|
||||
// cdprintf("DMA transfer PRG RAM : adr = %.8X ", dep);
|
||||
break;
|
||||
|
||||
case 0x0700: // WORD RAM
|
||||
if (Ram_Word_State >= 2)
|
||||
{
|
||||
dest = (unsigned char *) Ram_Word_1M;
|
||||
add_dest = 2;
|
||||
if (Ram_Word_State & 1) dep = ((Pico_mcd->cdc.DMA_Adr & 0x3FFF) << 3);
|
||||
else dep = ((Pico_mcd->cdc.DMA_Adr & 0x3FFF) << 3) + 0x20000;
|
||||
}
|
||||
else
|
||||
{
|
||||
dest = (unsigned char *) Ram_Word_2M;
|
||||
dep = ((Pico_mcd->cdc.DMA_Adr & 0x7FFF) << 3);
|
||||
add_dest = 2;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
unsigned int dep, length, len;
|
||||
unsigned short *dest;
|
||||
unsigned char *src;
|
||||
|
||||
if (Pico_mcd->cdc.DBC.N <= (CDC_DMA_SPEED * 2))
|
||||
{
|
||||
lenght = (Pico_mcd->cdc.DBC.N + 1) >> 1;
|
||||
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
|
||||
length = (Pico_mcd->cdc.DBC.N + 1) >> 1;
|
||||
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
|
||||
|
||||
if (Pico_mcd->cdc.IFCTRL & 0x40) // DTEIEN = Data Trasnfer End Interrupt Enable ?
|
||||
if (Pico_mcd->cdc.IFCTRL & 0x40) // DTEIEN = Data Trasnfer End Interrupt Enable ?
|
||||
{
|
||||
Pico_mcd->cdc.IFSTAT &= ~0x40;
|
||||
|
||||
if (Int_Mask_S68K & 0x20) sub68k_interrupt(5, -1);
|
||||
|
||||
cdprintf("CDC - DTE interrupt\n");
|
||||
if (Pico_mcd->s68k_regs[0x33] & (1<<5))
|
||||
{
|
||||
dprintf("cdc DTE irq 5");
|
||||
SekInterruptS68k(5);
|
||||
}
|
||||
}
|
||||
}
|
||||
else lenght = CDC_DMA_SPEED;
|
||||
|
||||
// cdprintf("DMA lenght = %.4X\n", lenght);
|
||||
else length = CDC_DMA_SPEED;
|
||||
|
||||
|
||||
if ((Pico_mcd->s68k_regs[4] & 7) == 4) // PCM DMA
|
||||
// TODO: dst bounds checking? DAC.N alignment?
|
||||
src = Pico_mcd->cdc.Buffer + Pico_mcd->cdc.DAC.N;
|
||||
|
||||
|
||||
if (which == 7) // WORD RAM
|
||||
{
|
||||
__asm
|
||||
if (Pico_mcd->s68k_regs[3] & 4)
|
||||
{
|
||||
mov ecx, lenght
|
||||
mov edi, dest
|
||||
lea esi, Pico_mcd->cdc.Buffer
|
||||
add edi, dep
|
||||
add esi, Pico_mcd->cdc.DAC.N
|
||||
mov ebx, add_dest
|
||||
dep = ((Pico_mcd->cdc.DMA_Adr & 0x3FFF) << 3);
|
||||
cdprintf("CD DMA # %04x -> word_ram1M # %06x, len=%i",
|
||||
Pico_mcd->cdc.DAC.N, dep, length);
|
||||
|
||||
Loop_DMA_PCM:
|
||||
mov ax, [esi]
|
||||
add esi, 2
|
||||
mov [edi], ax
|
||||
add edi, ebx
|
||||
dec ecx
|
||||
jnz Loop_DMA_PCM
|
||||
dep = ((Pico_mcd->cdc.DMA_Adr & 0x3FFF) << 4);
|
||||
if (!(Pico_mcd->s68k_regs[3]&1)) dep += 2;
|
||||
dest = (unsigned short *) (Pico_mcd->word_ram + dep);
|
||||
|
||||
for (len = length; len > 0; len--, src+=2, dest+=2)
|
||||
*dest = (src[0]<<8) | src[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
dep = ((Pico_mcd->cdc.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);
|
||||
|
||||
lenght <<= 1;
|
||||
Pico_mcd->cdc.DMA_Adr += lenght >> 2;
|
||||
for (len = length; len > 0; len--, src+=2, dest++)
|
||||
*dest = (src[0]<<8) | src[1];
|
||||
}
|
||||
}
|
||||
else // OTHER DMA
|
||||
else if (which == 4) // PCM RAM
|
||||
{
|
||||
__asm
|
||||
{
|
||||
mov ecx, lenght
|
||||
mov edi, dest
|
||||
lea esi, Pico_mcd->cdc.Buffer
|
||||
add edi, dep
|
||||
add esi, Pico_mcd->cdc.DAC.N
|
||||
mov ebx, add_dest
|
||||
#if 0
|
||||
dest = (unsigned char *) Ram_PCM;
|
||||
dep = ((Pico_mcd->cdc.DMA_Adr & 0x03FF) << 2) + PCM_Chip.Bank;
|
||||
#else
|
||||
cdprintf("TODO: PCM Dma");
|
||||
#endif
|
||||
}
|
||||
else if (which == 5) // PRG RAM
|
||||
{
|
||||
dep = (Pico_mcd->cdc.DMA_Adr & 0xFFFF) << 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);
|
||||
|
||||
Loop_DMA:
|
||||
mov ax, [esi]
|
||||
add esi, 2
|
||||
rol ax, 8
|
||||
mov [edi], ax
|
||||
add edi, ebx
|
||||
dec ecx
|
||||
jnz Loop_DMA
|
||||
}
|
||||
|
||||
lenght <<= 1;
|
||||
Pico_mcd->cdc.DMA_Adr += lenght >> 3;
|
||||
for (len = length; len > 0; len--, src+=2, dest++)
|
||||
*dest = (src[0]<<8) | src[1];
|
||||
}
|
||||
|
||||
Pico_mcd->cdc.DAC.N = (Pico_mcd->cdc.DAC.N + lenght) & 0xFFFF;
|
||||
if (Status_CDC & 0x08) Pico_mcd->cdc.DBC.N -= lenght;
|
||||
length <<= 1;
|
||||
Pico_mcd->cdc.DAC.N = (Pico_mcd->cdc.DAC.N + length) & 0xFFFF;
|
||||
if (Status_CDC & 0x08) Pico_mcd->cdc.DBC.N -= length;
|
||||
else Pico_mcd->cdc.DBC.N = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
unsigned short Read_CDC_Host(int is_sub)
|
||||
|
@ -592,7 +551,7 @@ void CDD_Import_Command(void)
|
|||
Get_Current_Track_CDD_c22();
|
||||
break;
|
||||
|
||||
case 0x3: // get total lenght (MSF format)
|
||||
case 0x3: // get total length (MSF format)
|
||||
Pico_mcd->cdd.Status = (Pico_mcd->cdd.Status & 0xFF00) | 3;
|
||||
Get_Total_Lenght_CDD_c23();
|
||||
break;
|
||||
|
|
|
@ -7,6 +7,7 @@ extern "C" {
|
|||
|
||||
typedef struct
|
||||
{
|
||||
unsigned char Buffer[(32 * 1024 * 2) + 2352];
|
||||
unsigned int Host_Data;
|
||||
unsigned int DMA_Adr;
|
||||
unsigned int Stop_Watch;
|
||||
|
@ -87,7 +88,6 @@ typedef struct
|
|||
} B;
|
||||
unsigned int N;
|
||||
} CTRL;
|
||||
unsigned char Buffer[(32 * 1024 * 2) + 2352];
|
||||
} CDC;
|
||||
|
||||
typedef struct
|
||||
|
@ -110,7 +110,7 @@ extern int CDC_Decode_Reg_Read;
|
|||
|
||||
void LC89510_Reset(void);
|
||||
unsigned short Read_CDC_Host(int is_sub);
|
||||
void Update_CDC_TRansfer(void);
|
||||
void Update_CDC_TRansfer(int which);
|
||||
void CDC_Update_Header(void);
|
||||
|
||||
unsigned char CDC_Read_Reg(void);
|
||||
|
@ -119,9 +119,6 @@ void CDC_Write_Reg(unsigned char Data);
|
|||
void CDD_Export_Status(void);
|
||||
void CDD_Import_Command(void);
|
||||
|
||||
unsigned char SCD_Read_Byte(unsigned int Adr);
|
||||
unsigned short SCD_Read_Word(unsigned int Adr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
|
151
Pico/cd/Memory.c
151
Pico/cd/Memory.c
|
@ -42,6 +42,7 @@ static u32 m68k_reg_read16(u32 a, int realsize)
|
|||
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 8:
|
||||
dprintf("m68k host data read");
|
||||
|
@ -96,6 +97,7 @@ static void m68k_reg_write8(u32 a, u32 d, int realsize)
|
|||
Pico_mcd->s68k_regs[2] = d; // really use s68k side register
|
||||
return;
|
||||
case 3:
|
||||
dprintf("m68k_regs w3: %02x @%06x", (u8)d, SekPc);
|
||||
d &= 0xc2;
|
||||
if ((Pico_mcd->s68k_regs[3]>>6) != ((d>>6)&3))
|
||||
dprintf("m68k: prg bank: %i -> %i", (Pico_mcd->s68k_regs[a]>>6), ((d>>6)&3));
|
||||
|
@ -143,6 +145,7 @@ static u32 s68k_reg_read16(u32 a, int realsize)
|
|||
d = 1; goto end; // ver = 0, not in reset state
|
||||
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);
|
||||
goto end;
|
||||
case 6:
|
||||
d = CDC_Read_Reg();
|
||||
|
@ -178,6 +181,7 @@ static void s68k_reg_write8(u32 a, u32 d, int realsize)
|
|||
case 2:
|
||||
return; // only m68k can change WP
|
||||
case 3:
|
||||
dprintf("s68k_regs w3: %02x @%06x", (u8)d, SekPc);
|
||||
d &= 0x1d;
|
||||
if (d&4) {
|
||||
d |= Pico_mcd->s68k_regs[3]&0xc2;
|
||||
|
@ -457,7 +461,13 @@ u8 PicoReadM68k8(u32 a)
|
|||
if ((a&0xfc0000)==0x200000) {
|
||||
dprintf("m68k_wram r8: [%06x] @%06x", a, SekPc);
|
||||
if (Pico_mcd->s68k_regs[3]&4) { // 1M mode?
|
||||
// TODO
|
||||
if (a >= 0x220000) {
|
||||
dprintf("cell");
|
||||
} else {
|
||||
a=((a&0x1fffe)<<1)|(a&1);
|
||||
if (Pico_mcd->s68k_regs[3]&1) a+=2;
|
||||
d = Pico_mcd->word_ram[a^1];
|
||||
}
|
||||
} else {
|
||||
// allow access in any mode, like Gens does
|
||||
d = Pico_mcd->word_ram[(a^1)&0x3ffff];
|
||||
|
@ -468,13 +478,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)
|
||||
// dprintf("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)
|
||||
// dprintf("ret = %02x", (u8)d);
|
||||
|
||||
end:
|
||||
|
||||
|
@ -505,7 +515,13 @@ u16 PicoReadM68k16(u32 a)
|
|||
if ((a&0xfc0000)==0x200000) {
|
||||
dprintf("m68k_wram r16: [%06x] @%06x", a, SekPc);
|
||||
if (Pico_mcd->s68k_regs[3]&4) { // 1M mode?
|
||||
// TODO
|
||||
if (a >= 0x220000) {
|
||||
dprintf("cell");
|
||||
} else {
|
||||
a=((a&0x1fffe)<<1);
|
||||
if (Pico_mcd->s68k_regs[3]&1) a+=2;
|
||||
d = *(u16 *)(Pico_mcd->word_ram+a);
|
||||
}
|
||||
} else {
|
||||
// allow access in any mode, like Gens does
|
||||
d = *(u16 *)(Pico_mcd->word_ram+(a&0x3fffe));
|
||||
|
@ -514,13 +530,13 @@ u16 PicoReadM68k16(u32 a)
|
|||
goto end;
|
||||
}
|
||||
|
||||
if ((a&0xffffc0)==0xa12000)
|
||||
dprintf("m68k_regs r16: [%02x] @%06x", a&0x3f, SekPc);
|
||||
//if ((a&0xffffc0)==0xa12000)
|
||||
// dprintf("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)
|
||||
// dprintf("ret = %04x", d);
|
||||
|
||||
end:
|
||||
|
||||
|
@ -552,7 +568,15 @@ u32 PicoReadM68k32(u32 a)
|
|||
if ((a&0xfc0000)==0x200000) {
|
||||
dprintf("m68k_wram r32: [%06x] @%06x", a, SekPc);
|
||||
if (Pico_mcd->s68k_regs[3]&4) { // 1M mode?
|
||||
// TODO
|
||||
if (a >= 0x220000) {
|
||||
dprintf("cell");
|
||||
} else {
|
||||
u16 *pm;
|
||||
a=((a&0x1fffe)<<1);
|
||||
if (Pico_mcd->s68k_regs[3]&1) a+=2;
|
||||
pm=(u16 *)(Pico_mcd->word_ram+a);
|
||||
d = (pm[0]<<16)|pm[1];
|
||||
}
|
||||
} else {
|
||||
// allow access in any mode, like Gens does
|
||||
u16 *pm=(u16 *)(Pico_mcd->word_ram+(a&0x3fffe)); d = (pm[0]<<16)|pm[1];
|
||||
|
@ -561,13 +585,13 @@ u32 PicoReadM68k32(u32 a)
|
|||
goto end;
|
||||
}
|
||||
|
||||
if ((a&0xffffc0)==0xa12000)
|
||||
dprintf("m68k_regs r32: [%02x] @%06x", a&0x3f, SekPc);
|
||||
//if ((a&0xffffc0)==0xa12000)
|
||||
// dprintf("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)
|
||||
// dprintf("ret = %08x", d);
|
||||
|
||||
end:
|
||||
#ifdef __debug_io
|
||||
|
@ -595,8 +619,7 @@ void PicoWriteM68k8(u32 a,u8 d)
|
|||
// prg RAM
|
||||
if ((a&0xfe0000)==0x020000) {
|
||||
u8 *prg_bank = Pico_mcd->prg_ram_b[Pico_mcd->s68k_regs[3]>>6];
|
||||
u8 *pm=(u8 *)(prg_bank+((a^1)&0x1ffff));
|
||||
*pm=d;
|
||||
*(u8 *)(prg_bank+((a^1)&0x1ffff))=d;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -604,17 +627,22 @@ void PicoWriteM68k8(u32 a,u8 d)
|
|||
if ((a&0xfc0000)==0x200000) {
|
||||
dprintf("m68k_wram w8: [%06x] %02x @%06x", a, d, SekPc);
|
||||
if (Pico_mcd->s68k_regs[3]&4) { // 1M mode?
|
||||
// TODO
|
||||
if (a >= 0x220000) {
|
||||
dprintf("cell");
|
||||
} else {
|
||||
a=((a&0x1fffe)<<1)|(a&1);
|
||||
if (Pico_mcd->s68k_regs[3]&1) a+=2;
|
||||
*(u8 *)(Pico_mcd->word_ram+(a^1))=d;
|
||||
}
|
||||
} else {
|
||||
// allow access in any mode, like Gens does
|
||||
u8 *pm=(u8 *)(Pico_mcd->word_ram+((a^1)&0x3ffff));
|
||||
*pm=d;
|
||||
*(u8 *)(Pico_mcd->word_ram+((a^1)&0x3ffff))=d;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if ((a&0xffffc0)==0xa12000)
|
||||
dprintf("m68k_regs w8: [%02x] %02x @%06x", a&0x3f, d, SekPc);
|
||||
//if ((a&0xffffc0)==0xa12000)
|
||||
// dprintf("m68k_regs w8: [%02x] %02x @%06x", a&0x3f, d, SekPc);
|
||||
|
||||
OtherWrite8(a,d,8);
|
||||
}
|
||||
|
@ -624,7 +652,6 @@ void PicoWriteM68k16(u32 a,u16 d)
|
|||
#ifdef __debug_io
|
||||
dprintf("w16: %06x, %04x", a&0xffffff, d);
|
||||
#endif
|
||||
//if ((a&0xe0ffff)==0xe0AF0E+0x69c||(a&0xe0ffff)==0xe0A9A8+0x69c||(a&0xe0ffff)==0xe0A9AA+0x69c||(a&0xe0ffff)==0xe0A9AC+0x69c)
|
||||
// dprintf("w16: %06x, %04x @%06x", a&0xffffff, d, SekPc);
|
||||
|
||||
if ((a&0xe00000)==0xe00000) { *(u16 *)(Pico.ram+(a&0xfffe))=d; return; } // Ram
|
||||
|
@ -642,7 +669,13 @@ void PicoWriteM68k16(u32 a,u16 d)
|
|||
if ((a&0xfc0000)==0x200000) {
|
||||
dprintf("m68k_wram w16: [%06x] %04x @%06x", a, d, SekPc);
|
||||
if (Pico_mcd->s68k_regs[3]&4) { // 1M mode?
|
||||
// TODO
|
||||
if (a >= 0x220000) {
|
||||
dprintf("cell");
|
||||
} else {
|
||||
a=((a&0x1fffe)<<1);
|
||||
if (Pico_mcd->s68k_regs[3]&1) a+=2;
|
||||
*(u16 *)(Pico_mcd->word_ram+a)=d;
|
||||
}
|
||||
} else {
|
||||
// allow access in any mode, like Gens does
|
||||
*(u16 *)(Pico_mcd->word_ram+(a&0x3fffe))=d;
|
||||
|
@ -650,8 +683,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)
|
||||
// dprintf("m68k_regs w16: [%02x] %04x @%06x", a&0x3f, d, SekPc);
|
||||
|
||||
OtherWrite16(a,d);
|
||||
}
|
||||
|
@ -685,7 +718,15 @@ void PicoWriteM68k32(u32 a,u32 d)
|
|||
if (d != 0) // don't log clears
|
||||
dprintf("m68k_wram w32: [%06x] %08x @%06x", a, d, SekPc);
|
||||
if (Pico_mcd->s68k_regs[3]&4) { // 1M mode?
|
||||
// TODO
|
||||
if (a >= 0x220000) {
|
||||
dprintf("cell");
|
||||
} else {
|
||||
u16 *pm;
|
||||
a=((a&0x1fffe)<<1);
|
||||
if (Pico_mcd->s68k_regs[3]&1) a+=2;
|
||||
pm=(u16 *)(Pico_mcd->word_ram+a);
|
||||
pm[0]=(u16)(d>>16); pm[1]=(u16)d;
|
||||
}
|
||||
} else {
|
||||
// allow access in any mode, like Gens does
|
||||
u16 *pm=(u16 *)(Pico_mcd->word_ram+(a&0x3fffe));
|
||||
|
@ -694,8 +735,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)
|
||||
// dprintf("m68k_regs w32: [%02x] %08x @%06x", a&0x3f, d, SekPc);
|
||||
|
||||
OtherWrite16(a, (u16)(d>>16));
|
||||
OtherWrite16(a+2,(u16)d);
|
||||
|
@ -719,9 +760,9 @@ u8 PicoReadS68k8(u32 a)
|
|||
|
||||
// regs
|
||||
if ((a&0xfffe00) == 0xff8000) {
|
||||
dprintf("s68k_regs r8: [%02x] @ %06x", a&0x1ff, SekPcS68k);
|
||||
//dprintf("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);
|
||||
//dprintf("ret = %02x", (u8)d);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -742,7 +783,10 @@ u8 PicoReadS68k8(u32 a)
|
|||
// word RAM (1M area)
|
||||
if ((a&0xfe0000)==0x0c0000 && (Pico_mcd->s68k_regs[3]&4)) { // 0c0000-0dffff
|
||||
dprintf("s68k_wram1M r8: [%06x] @%06x", a, SekPc);
|
||||
// TODO
|
||||
a=((a&0x1fffe)<<1)|(a&1);
|
||||
if (!(Pico_mcd->s68k_regs[3]&1)) a+=2;
|
||||
d = Pico_mcd->word_ram[a^1];
|
||||
dprintf("ret = %02x", (u8)d);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -770,9 +814,9 @@ u16 PicoReadS68k16(u32 a)
|
|||
|
||||
// regs
|
||||
if ((a&0xfffe00) == 0xff8000) {
|
||||
dprintf("s68k_regs r16: [%02x] @ %06x", a&0x1fe, SekPcS68k);
|
||||
//dprintf("s68k_regs r16: [%02x] @ %06x", a&0x1fe, SekPcS68k);
|
||||
d = s68k_reg_read16(a, 16);
|
||||
dprintf("ret = %04x", d);
|
||||
//dprintf("ret = %04x", d);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -793,7 +837,10 @@ u16 PicoReadS68k16(u32 a)
|
|||
// word RAM (1M area)
|
||||
if ((a&0xfe0000)==0x0c0000 && (Pico_mcd->s68k_regs[3]&4)) { // 0c0000-0dffff
|
||||
dprintf("s68k_wram1M r16: [%06x] @%06x", a, SekPc);
|
||||
// TODO
|
||||
a=((a&0x1fffe)<<1);
|
||||
if (!(Pico_mcd->s68k_regs[3]&1)) a+=2;
|
||||
d = *(u16 *)(Pico_mcd->word_ram+a);
|
||||
dprintf("ret = %04x", (u8)d);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -822,9 +869,9 @@ u32 PicoReadS68k32(u32 a)
|
|||
|
||||
// regs
|
||||
if ((a&0xfffe00) == 0xff8000) {
|
||||
dprintf("s68k_regs r32: [%02x] @ %06x", a&0x1fe, SekPcS68k);
|
||||
//dprintf("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);
|
||||
//dprintf("ret = %08x", d);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -844,8 +891,13 @@ u32 PicoReadS68k32(u32 a)
|
|||
|
||||
// word RAM (1M area)
|
||||
if ((a&0xfe0000)==0x0c0000 && (Pico_mcd->s68k_regs[3]&4)) { // 0c0000-0dffff
|
||||
u16 *pm;
|
||||
dprintf("s68k_wram1M 32: [%06x] @%06x", a, SekPc);
|
||||
// TODO
|
||||
a=((a&0x1fffe)<<1);
|
||||
if (!(Pico_mcd->s68k_regs[3]&1)) a+=2;
|
||||
pm=(u16 *)(Pico_mcd->word_ram+a);
|
||||
d = (pm[0]<<16)|pm[1];
|
||||
dprintf("ret = %08x", (u8)d);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -881,7 +933,7 @@ void PicoWriteS68k8(u32 a,u8 d)
|
|||
|
||||
// regs
|
||||
if ((a&0xfffe00) == 0xff8000) {
|
||||
dprintf("s68k_regs w8: [%02x] %02x @ %06x", a&0x1ff, d, SekPcS68k);
|
||||
//dprintf("s68k_regs w8: [%02x] %02x @ %06x", a&0x1ff, d, SekPcS68k);
|
||||
s68k_reg_write8(a,d,8);
|
||||
return;
|
||||
}
|
||||
|
@ -894,8 +946,7 @@ void PicoWriteS68k8(u32 a,u8 d)
|
|||
dprintf("(decode)");
|
||||
} else {
|
||||
// allow access in any mode, like Gens does
|
||||
u8 *pm=(u8 *)(Pico_mcd->word_ram+((a^1)&0x3ffff));
|
||||
*pm=d;
|
||||
*(u8 *)(Pico_mcd->word_ram+((a^1)&0x3ffff))=d;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -904,7 +955,9 @@ void PicoWriteS68k8(u32 a,u8 d)
|
|||
if ((a&0xfe0000)==0x0c0000 && (Pico_mcd->s68k_regs[3]&4)) { // 0c0000-0dffff
|
||||
if (d)
|
||||
dprintf("s68k_wram1M w8: [%06x] %02x @%06x", a, d, SekPc);
|
||||
// TODO
|
||||
a=((a&0x1fffe)<<1)|(a&1);
|
||||
if (!(Pico_mcd->s68k_regs[3]&1)) a+=2;
|
||||
*(u8 *)(Pico_mcd->word_ram+(a^1))=d;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -927,7 +980,7 @@ void PicoWriteS68k16(u32 a,u16 d)
|
|||
|
||||
// regs
|
||||
if ((a&0xfffe00) == 0xff8000) {
|
||||
dprintf("s68k_regs w16: [%02x] %04x @ %06x", a&0x1ff, d, SekPcS68k);
|
||||
//dprintf("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;
|
||||
|
@ -950,7 +1003,9 @@ void PicoWriteS68k16(u32 a,u16 d)
|
|||
if ((a&0xfe0000)==0x0c0000 && (Pico_mcd->s68k_regs[3]&4)) { // 0c0000-0dffff
|
||||
if (d)
|
||||
dprintf("s68k_wram1M w16: [%06x] %04x @%06x", a, d, SekPc);
|
||||
// TODO
|
||||
a=((a&0x1fffe)<<1);
|
||||
if (!(Pico_mcd->s68k_regs[3]&1)) a+=2;
|
||||
*(u16 *)(Pico_mcd->word_ram+a)=d;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -974,7 +1029,7 @@ void PicoWriteS68k32(u32 a,u32 d)
|
|||
|
||||
// regs
|
||||
if ((a&0xfffe00) == 0xff8000) {
|
||||
dprintf("s68k_regs w32: [%02x] %08x @ %06x", a&0x1ff, d, SekPcS68k);
|
||||
//dprintf("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);
|
||||
|
@ -998,9 +1053,13 @@ void PicoWriteS68k32(u32 a,u32 d)
|
|||
|
||||
// word RAM (1M area)
|
||||
if ((a&0xfe0000)==0x0c0000 && (Pico_mcd->s68k_regs[3]&4)) { // 0c0000-0dffff
|
||||
u16 *pm;
|
||||
if (d)
|
||||
dprintf("s68k_wram1M w32: [%06x] %08x @%06x", a, d, SekPc);
|
||||
// TODO
|
||||
a=((a&0x1fffe)<<1);
|
||||
if (!(Pico_mcd->s68k_regs[3]&1)) a+=2;
|
||||
pm=(u16 *)(Pico_mcd->word_ram+a);
|
||||
pm[0]=(u16)(d>>16); pm[1]=(u16)d;
|
||||
return;
|
||||
}
|
||||
dprintf("s68k w32: %06x, %08x @%06x", a&0xffffff, d, SekPcS68k);
|
||||
|
|
|
@ -64,9 +64,22 @@ static __inline void SekRunS68k(int cyc)
|
|||
#endif
|
||||
}
|
||||
|
||||
// TODO: tidy
|
||||
extern unsigned char m68k_regs[0x40];
|
||||
extern unsigned char s68k_regs[0x200];
|
||||
static int Status_CDC;
|
||||
|
||||
static __inline void check_cd_dma(void)
|
||||
{
|
||||
int ddx;
|
||||
|
||||
if (!(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 == 6) return; // invalid
|
||||
|
||||
Update_CDC_TRansfer(ddx); // now go and do the actual transfer
|
||||
}
|
||||
|
||||
|
||||
// Accurate but slower frame which does hints
|
||||
static int PicoFrameHintsMCD(void)
|
||||
|
@ -115,6 +128,8 @@ static int PicoFrameHintsMCD(void)
|
|||
if(Pico.m.padDelay[1]++ > 25) Pico.m.padTHPhase[1]=0;
|
||||
}
|
||||
|
||||
check_cd_dma();
|
||||
|
||||
// H-Interrupts:
|
||||
if(y <= lines_vis && --hint < 0) // y <= lines_vis: Comix Zone, Golden Axe
|
||||
{
|
||||
|
|
326
Pico/cd/cd_file.c
Normal file
326
Pico/cd/cd_file.c
Normal file
|
@ -0,0 +1,326 @@
|
|||
/*
|
||||
#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"
|
||||
|
||||
#include "../PicoInt.h"
|
||||
|
||||
#define cdprintf printf
|
||||
//#define cdprintf(x...)
|
||||
|
||||
struct _file_track Tracks[100];
|
||||
char Track_Played;
|
||||
|
||||
|
||||
int FILE_Init(void)
|
||||
{
|
||||
// MP3_Init(); // TODO
|
||||
Unload_ISO();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void FILE_End(void)
|
||||
{
|
||||
Unload_ISO();
|
||||
}
|
||||
|
||||
|
||||
int Load_ISO(const char *iso_name, int is_bin)
|
||||
{
|
||||
struct stat file_stat;
|
||||
int i, j, num_track, Cur_LBA, index, ret;
|
||||
_scd_track *SCD_TOC_Tracks = Pico_mcd->scd.TOC.Tracks;
|
||||
FILE *tmp_file;
|
||||
char tmp_name[1024], tmp_ext[10];
|
||||
static char *exts[] = {
|
||||
"%02d.mp3", " %02d.mp3", "-%02d.mp3", "_%02d.mp3", " - %02d.mp3",
|
||||
"%d.mp3", " %d.mp3", "-%d.mp3", "_%d.mp3", " - %d.mp3",
|
||||
/* "%02d.wav", " %02d.wav", "-%02d.wav", "_%02d.wav", " - %02d.wav",
|
||||
"%d.wav", " %d.wav", "-%d.wav", "_%d.wav", " - %2d.wav" */
|
||||
};
|
||||
|
||||
Unload_ISO();
|
||||
|
||||
Tracks[0].Type = is_bin ? TYPE_BIN : TYPE_ISO;
|
||||
|
||||
ret = stat(iso_name, &file_stat);
|
||||
if (ret != 0) return -1;
|
||||
|
||||
Tracks[0].Lenght = file_stat.st_size;
|
||||
|
||||
if (Tracks[0].Type == TYPE_ISO) Tracks[0].Lenght >>= 11; // size in sectors
|
||||
else Tracks[0].Lenght /= 2352; // size in sectors
|
||||
|
||||
|
||||
Tracks[0].F = fopen(iso_name, "rb");
|
||||
if (Tracks[0].F == NULL)
|
||||
{
|
||||
Tracks[0].Type = 0;
|
||||
Tracks[0].Lenght = 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (Tracks[0].Type == TYPE_ISO) fseek(Tracks[0].F, 0x100, SEEK_SET);
|
||||
else fseek(Tracks[0].F, 0x110, SEEK_SET);
|
||||
|
||||
// fread(buf, 1, 0x200, Tracks[0].F);
|
||||
fseek(Tracks[0].F, 0, SEEK_SET);
|
||||
|
||||
Pico_mcd->scd.TOC.First_Track = 1;
|
||||
|
||||
SCD_TOC_Tracks[0].Num = 1;
|
||||
SCD_TOC_Tracks[0].Type = 1; // DATA
|
||||
|
||||
SCD_TOC_Tracks[0].MSF.M = 0;
|
||||
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,
|
||||
SCD_TOC_Tracks[0].Type ? "DATA" : "AUDIO");
|
||||
|
||||
Cur_LBA = Tracks[0].Lenght; // Size in sectors
|
||||
|
||||
strcpy(tmp_name, iso_name);
|
||||
|
||||
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++)
|
||||
{
|
||||
tmp_name[strlen(iso_name) - 4] = 0;
|
||||
sprintf(tmp_ext, exts[j], i);
|
||||
strcat(tmp_name, tmp_ext);
|
||||
|
||||
tmp_file = fopen(tmp_name, "rb");
|
||||
|
||||
if (tmp_file)
|
||||
{
|
||||
float fs;
|
||||
index = num_track - Pico_mcd->scd.TOC.First_Track;
|
||||
|
||||
stat(tmp_name, &file_stat);
|
||||
|
||||
fs = (float) file_stat.st_size; // used to calculate lenght
|
||||
|
||||
Tracks[index].F = tmp_file;
|
||||
|
||||
SCD_TOC_Tracks[index].Num = num_track;
|
||||
SCD_TOC_Tracks[index].Type = 0; // AUDIO
|
||||
|
||||
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,
|
||||
SCD_TOC_Tracks[index].MSF.S, SCD_TOC_Tracks[index].MSF.F,
|
||||
SCD_TOC_Tracks[index].Type ? "DATA" : "AUDIO");
|
||||
|
||||
// MP3 File
|
||||
Tracks[index].Type = TYPE_MP3;
|
||||
fs /= (128>>3); // (float) (MP3_Get_Bitrate(Tracks[num_track - 1].F) >> 3);
|
||||
fs *= 75;
|
||||
Tracks[index].Lenght = (int) fs;
|
||||
Cur_LBA += Tracks[index].Lenght;
|
||||
|
||||
num_track++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Pico_mcd->scd.TOC.Last_Track = num_track - 1;
|
||||
|
||||
index = num_track - Pico_mcd->scd.TOC.First_Track;
|
||||
SCD_TOC_Tracks[index].Num = num_track;
|
||||
SCD_TOC_Tracks[index].Type = 0;
|
||||
|
||||
LBA_to_MSF(Cur_LBA, &(SCD_TOC_Tracks[index].MSF));
|
||||
|
||||
cdprintf("End CD - %02d:%02d:%02d\n\n", SCD_TOC_Tracks[index].MSF.M,
|
||||
SCD_TOC_Tracks[index].MSF.S, SCD_TOC_Tracks[index].MSF.F);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void Unload_ISO(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
Track_Played = 99;
|
||||
|
||||
for(i = 0; i < 100; i++)
|
||||
{
|
||||
if (Tracks[i].F) fclose(Tracks[i].F);
|
||||
Tracks[i].F = NULL;
|
||||
Tracks[i].Lenght = 0;
|
||||
Tracks[i].Type = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int FILE_Read_One_LBA_CDC(void)
|
||||
{
|
||||
int where_read;
|
||||
static char cp_buf[2560];
|
||||
|
||||
if (Pico_mcd->s68k_regs[0x36] & 1) // DATA
|
||||
{
|
||||
if (Tracks[0].F == NULL) return -1;
|
||||
|
||||
if (Pico_mcd->scd.Cur_LBA < 0) where_read = 0;
|
||||
else if (Pico_mcd->scd.Cur_LBA >= Tracks[0].Lenght) where_read = Tracks[0].Lenght - 1;
|
||||
else where_read = Pico_mcd->scd.Cur_LBA;
|
||||
|
||||
if (Tracks[0].Type == TYPE_ISO) where_read <<= 11;
|
||||
else where_read = (where_read * 2352 + 16);
|
||||
|
||||
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");
|
||||
}
|
||||
else // AUDIO
|
||||
{
|
||||
// int rate, channel;
|
||||
|
||||
if (Tracks[Pico_mcd->scd.Cur_Track - Pico_mcd->scd.TOC.First_Track].Type == TYPE_MP3)
|
||||
{
|
||||
// TODO
|
||||
// MP3_Update(cp_buf, &rate, &channel, 0);
|
||||
// Write_CD_Audio((short *) cp_buf, rate, channel, 588);
|
||||
}
|
||||
|
||||
cdprintf("\n\nRead file CDC 1 audio sector :\n");
|
||||
}
|
||||
|
||||
// Update CDC stuff
|
||||
|
||||
CDC_Update_Header();
|
||||
|
||||
if (Pico_mcd->s68k_regs[0x36] & 1) // DATA track
|
||||
{
|
||||
if (Pico_mcd->cdc.CTRL.B.B0 & 0x80) // DECEN = decoding enable
|
||||
{
|
||||
if (Pico_mcd->cdc.CTRL.B.B0 & 0x04) // WRRQ : this bit enable write to buffer
|
||||
{
|
||||
// CAUTION : lookahead bit not implemented
|
||||
|
||||
Pico_mcd->scd.Cur_LBA++;
|
||||
|
||||
Pico_mcd->cdc.WA.N = (Pico_mcd->cdc.WA.N + 2352) & 0x7FFF; // add one sector to WA
|
||||
Pico_mcd->cdc.PT.N = (Pico_mcd->cdc.PT.N + 2352) & 0x7FFF;
|
||||
|
||||
memcpy(&Pico_mcd->cdc.Buffer[Pico_mcd->cdc.PT.N + 4], cp_buf, 2048);
|
||||
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,
|
||||
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],
|
||||
Pico_mcd->cdc.Buffer[(Pico_mcd->cdc.PT.N + 1) & 0x3FFF],
|
||||
Pico_mcd->cdc.Buffer[(Pico_mcd->cdc.PT.N + 2) & 0x3FFF],
|
||||
Pico_mcd->cdc.Buffer[(Pico_mcd->cdc.PT.N + 3) & 0x3FFF],
|
||||
Pico_mcd->cdc.Buffer[(Pico_mcd->cdc.PT.N + 4) & 0x3FFF],
|
||||
Pico_mcd->cdc.Buffer[(Pico_mcd->cdc.PT.N + 5) & 0x3FFF]);
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else // music track
|
||||
{
|
||||
Pico_mcd->scd.Cur_LBA++;
|
||||
|
||||
Pico_mcd->cdc.WA.N = (Pico_mcd->cdc.WA.N + 2352) & 0x7FFF; // add one sector to WA
|
||||
Pico_mcd->cdc.PT.N = (Pico_mcd->cdc.PT.N + 2352) & 0x7FFF;
|
||||
|
||||
if (Pico_mcd->cdc.CTRL.B.B0 & 0x80) // DECEN = decoding enable
|
||||
{
|
||||
if (Pico_mcd->cdc.CTRL.B.B0 & 0x04) // WRRQ : this bit enable write to buffer
|
||||
{
|
||||
// CAUTION : lookahead bit not implemented
|
||||
|
||||
memcpy(&Pico_mcd->cdc.Buffer[Pico_mcd->cdc.PT.N], cp_buf, 2352);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Pico_mcd->cdc.CTRL.B.B0 & 0x80) // DECEN = decoding enable
|
||||
{
|
||||
Pico_mcd->cdc.STAT.B.B0 = 0x80;
|
||||
|
||||
if (Pico_mcd->cdc.CTRL.B.B0 & 0x10) // determine form bit form sub header ?
|
||||
{
|
||||
Pico_mcd->cdc.STAT.B.B2 = Pico_mcd->cdc.CTRL.B.B1 & 0x08;
|
||||
}
|
||||
else
|
||||
{
|
||||
Pico_mcd->cdc.STAT.B.B2 = Pico_mcd->cdc.CTRL.B.B1 & 0x0C;
|
||||
}
|
||||
|
||||
if (Pico_mcd->cdc.CTRL.B.B0 & 0x02) Pico_mcd->cdc.STAT.B.B3 = 0x20; // ECC done
|
||||
else Pico_mcd->cdc.STAT.B.B3 = 0x00; // ECC not done
|
||||
|
||||
if (Pico_mcd->cdc.IFCTRL & 0x20)
|
||||
{
|
||||
if (Pico_mcd->s68k_regs[0x33] & (1<<5))
|
||||
{
|
||||
dprintf("cdc dec irq 5");
|
||||
SekInterruptS68k(5);
|
||||
}
|
||||
|
||||
Pico_mcd->cdc.IFSTAT &= ~0x20; // DEC interrupt happen
|
||||
CDC_Decode_Reg_Read = 0; // Reset read after DEC int
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int FILE_Play_CD_LBA(void)
|
||||
{
|
||||
int index = Pico_mcd->scd.Cur_Track - Pico_mcd->scd.TOC.First_Track;
|
||||
|
||||
cdprintf("Play FILE Comp\n");
|
||||
|
||||
if (Tracks[index].F == NULL)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (Tracks[index].Type == TYPE_MP3)
|
||||
{
|
||||
int Track_LBA_Pos = Pico_mcd->scd.Cur_LBA - Track_to_LBA(Pico_mcd->scd.Cur_Track);
|
||||
if (Track_LBA_Pos < 0) Track_LBA_Pos = 0;
|
||||
|
||||
// MP3_Play(index, Track_LBA_Pos); // TODO
|
||||
}
|
||||
else
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
38
Pico/cd/cd_file.h
Normal file
38
Pico/cd/cd_file.h
Normal file
|
@ -0,0 +1,38 @@
|
|||
#ifndef _CD_FILE_H
|
||||
#define _CD_FILE_H
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define TYPE_ISO 1
|
||||
#define TYPE_BIN 2
|
||||
#define TYPE_MP3 3
|
||||
//#define TYPE_WAV 4
|
||||
|
||||
|
||||
struct _file_track {
|
||||
FILE *F;
|
||||
int Lenght;
|
||||
int Type;
|
||||
};
|
||||
|
||||
extern struct _file_track Tracks[100];
|
||||
extern char Track_Played;
|
||||
|
||||
|
||||
int FILE_Init(void);
|
||||
void FILE_End(void);
|
||||
int Load_ISO(const char *iso_name, int is_bin);
|
||||
void Unload_ISO(void);
|
||||
int FILE_Read_One_LBA_CDC(void);
|
||||
int FILE_Play_CD_LBA(void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -1,6 +1,6 @@
|
|||
#include <stdio.h>
|
||||
#include "cd_sys.h"
|
||||
//#include "cd_file.h"
|
||||
#include "cd_file.h"
|
||||
|
||||
#include "../PicoInt.h"
|
||||
|
||||
|
@ -15,18 +15,6 @@
|
|||
#define FAST_REV 0x10300 // FAST REVERSE track CDD status
|
||||
#define PLAYING 0x0100 // PLAYING audio track CDD status
|
||||
|
||||
/*
|
||||
#include "gens.h"
|
||||
#include "G_dsound.h"
|
||||
#include "cdda_mp3.h"
|
||||
#include "lc89510.h"
|
||||
#include "Star_68k.h"
|
||||
#include "Mem_M68K.h"
|
||||
#include "Mem_S68K.h"
|
||||
#include "save.h"
|
||||
#include "misc.h"
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
int CDDA_Enable;
|
||||
|
@ -45,8 +33,6 @@ static int CDD_Complete;
|
|||
|
||||
static int File_Add_Delay = 0;
|
||||
|
||||
//_scd SCD;
|
||||
|
||||
|
||||
|
||||
#define CHECK_TRAY_OPEN \
|
||||
|
@ -191,9 +177,7 @@ void Check_CD_Command(void)
|
|||
|
||||
if (File_Add_Delay == 0)
|
||||
{
|
||||
#if 0 // TODO
|
||||
FILE_Read_One_LBA_CDC();
|
||||
#endif
|
||||
}
|
||||
else File_Add_Delay--;
|
||||
}
|
||||
|
@ -215,9 +199,7 @@ void Check_CD_Command(void)
|
|||
|
||||
int Init_CD_Driver(void)
|
||||
{
|
||||
#if 0 // TODO
|
||||
FILE_Init();
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -225,9 +207,7 @@ int Init_CD_Driver(void)
|
|||
|
||||
void End_CD_Driver(void)
|
||||
{
|
||||
#if 0 // TODO
|
||||
FILE_End();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -240,33 +220,29 @@ void Reset_CD(void)
|
|||
}
|
||||
|
||||
|
||||
int Insert_CD(char *buf, char *iso_name)
|
||||
int Insert_CD(char *iso_name, int is_bin)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
// memset(CD_Audio_Buffer_L, 0, 4096 * 4);
|
||||
// memset(CD_Audio_Buffer_R, 0, 4096 * 4);
|
||||
|
||||
if (iso_name == NULL)
|
||||
CD_Present = 0;
|
||||
|
||||
if (iso_name != NULL)
|
||||
{
|
||||
CD_Present = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
#if 0 // TODO
|
||||
Load_ISO(buf, iso_name);
|
||||
CD_Present = 1;
|
||||
#endif
|
||||
return 0;
|
||||
ret = Load_ISO(iso_name, is_bin);
|
||||
if (ret == 0)
|
||||
CD_Present = 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void Stop_CD(void)
|
||||
{
|
||||
#if 0 // TODO
|
||||
Unload_ISO();
|
||||
#endif
|
||||
CD_Present = 0;
|
||||
}
|
||||
|
||||
|
@ -436,7 +412,7 @@ int Get_Total_Lenght_CDD_c23(void)
|
|||
Pico_mcd->cdd.Ext = 0;
|
||||
|
||||
// FIXME: remove
|
||||
Pico_mcd->cdd.Seconde = 2;
|
||||
//Pico_mcd->cdd.Seconde = 2;
|
||||
|
||||
CDD_Complete = 1;
|
||||
|
||||
|
@ -462,7 +438,7 @@ int Get_First_Last_Track_CDD_c24(void)
|
|||
Pico_mcd->cdd.Ext = 0;
|
||||
|
||||
// FIXME: remove
|
||||
Pico_mcd->cdd.Minute = Pico_mcd->cdd.Seconde = 1;
|
||||
//Pico_mcd->cdd.Minute = Pico_mcd->cdd.Seconde = 1;
|
||||
|
||||
CDD_Complete = 1;
|
||||
|
||||
|
@ -546,9 +522,7 @@ int Play_CDD_c3(void)
|
|||
{
|
||||
Pico_mcd->s68k_regs[0x36] &= ~0x01; // AUDIO
|
||||
//CD_Audio_Starting = 1;
|
||||
#if 0 // TODO
|
||||
FILE_Play_CD_LBA();
|
||||
#endif
|
||||
}
|
||||
|
||||
if (Pico_mcd->scd.Cur_Track == 100) Pico_mcd->cdd.Minute = 0x0A02;
|
||||
|
@ -651,9 +625,7 @@ int Resume_CDD_c7(void)
|
|||
{
|
||||
Pico_mcd->s68k_regs[0x36] &= ~0x01; // AUDIO
|
||||
//CD_Audio_Starting = 1;
|
||||
#if 0 // TODO
|
||||
FILE_Play_CD_LBA();
|
||||
#endif
|
||||
}
|
||||
|
||||
if (Pico_mcd->scd.Cur_Track == 100) Pico_mcd->cdd.Minute = 0x0A02;
|
||||
|
@ -669,7 +641,7 @@ int Resume_CDD_c7(void)
|
|||
}
|
||||
|
||||
|
||||
int Fast_Foward_CDD_c8(void)
|
||||
int Fast_Foward_CDD_c8(void)
|
||||
{
|
||||
CHECK_TRAY_OPEN
|
||||
CHECK_CD_PRESENT
|
||||
|
@ -690,7 +662,7 @@ int Fast_Foward_CDD_c8(void)
|
|||
}
|
||||
|
||||
|
||||
int Fast_Rewind_CDD_c9(void)
|
||||
int Fast_Rewind_CDD_c9(void)
|
||||
{
|
||||
CHECK_TRAY_OPEN
|
||||
CHECK_CD_PRESENT
|
||||
|
@ -751,9 +723,7 @@ int Open_Tray_CDD_cD(void)
|
|||
|
||||
Pico_mcd->scd.Status_CDC &= ~1; // Stop CDC read
|
||||
|
||||
#if 0 // TODO
|
||||
Unload_ISO();
|
||||
#endif
|
||||
CD_Present = 0;
|
||||
|
||||
Pico_mcd->scd.Status_CDD = TRAY_OPEN;
|
||||
|
|
|
@ -60,7 +60,7 @@ void Check_CD_Command(void);
|
|||
|
||||
int Init_CD_Driver(void);
|
||||
void End_CD_Driver(void);
|
||||
int Insert_CD(char *buf, char *iso_name);
|
||||
int Insert_CD(char *iso_name, int is_bin);
|
||||
void Stop_CD(void);
|
||||
void Change_CD(void);
|
||||
void Reset_CD(void);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue