mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-06 07:38:05 -04:00
lowercasing filenames, part3
git-svn-id: file:///home/notaz/opt/svn/PicoDrive@576 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
parent
d158df697d
commit
1cfc5cc4ce
71 changed files with 0 additions and 0 deletions
275
pico/pico/memory.c
Normal file
275
pico/pico/memory.c
Normal file
|
@ -0,0 +1,275 @@
|
|||
#include "../pico_int.h"
|
||||
#include "../sound/sn76496.h"
|
||||
|
||||
#ifndef UTYPES_DEFINED
|
||||
typedef unsigned char u8;
|
||||
typedef unsigned short u16;
|
||||
typedef unsigned int u32;
|
||||
#define UTYPES_DEFINED
|
||||
#endif
|
||||
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
// Read Rom and read Ram
|
||||
|
||||
static u32 PicoReadPico8(u32 a)
|
||||
{
|
||||
u32 d=0;
|
||||
|
||||
if ((a&0xe00000)==0xe00000) { d = *(u8 *)(Pico.ram+((a^1)&0xffff)); goto end; } // Ram
|
||||
if (a<Pico.romsize) { d = *(u8 *)(Pico.rom+(a^1)); goto end; } // Rom
|
||||
|
||||
a&=0xffffff;
|
||||
|
||||
if ((a&0xfffff0)==0xc00000) { // VDP
|
||||
d=PicoVideoRead8(a);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if ((a&0xffffe0)==0x800000) // Pico I/O
|
||||
{
|
||||
switch (a & 0x1f)
|
||||
{
|
||||
case 0x01: d = PicoPicohw.r1; break;
|
||||
case 0x03:
|
||||
d = PicoPad[0]&0x1f; // d-pad
|
||||
d |= (PicoPad[0]&0x20) << 2; // pen push -> C
|
||||
d = ~d;
|
||||
break;
|
||||
|
||||
case 0x05: d = (PicoPicohw.pen_pos[0] >> 8); break; // what is MS bit for? Games read it..
|
||||
case 0x07: d = PicoPicohw.pen_pos[0] & 0xff; break;
|
||||
case 0x09: d = (PicoPicohw.pen_pos[1] >> 8); break;
|
||||
case 0x0b: d = PicoPicohw.pen_pos[1] & 0xff; break;
|
||||
case 0x0d: d = (1 << (PicoPicohw.page & 7)) - 1; break;
|
||||
case 0x12: d = PicoPicohw.fifo_bytes == 0 ? 0x80 : 0; break; // guess
|
||||
default:
|
||||
elprintf(EL_UIO, "r8 : %06x, %02x @%06x", a&0xffffff, (u8)d, SekPc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//elprintf(EL_UIO, "r8 : %06x, %02x @%06x", a&0xffffff, (u8)d, SekPc);
|
||||
|
||||
end:
|
||||
elprintf(EL_IO, "r8 : %06x, %02x @%06x", a&0xffffff, (u8)d, SekPc);
|
||||
return d;
|
||||
}
|
||||
|
||||
static u32 PicoReadPico16(u32 a)
|
||||
{
|
||||
u32 d=0;
|
||||
|
||||
if ((a&0xe00000)==0xe00000) { d=*(u16 *)(Pico.ram+(a&0xfffe)); goto end; } // Ram
|
||||
|
||||
a&=0xfffffe;
|
||||
|
||||
if (a<Pico.romsize) { d = *(u16 *)(Pico.rom+a); goto end; } // Rom
|
||||
|
||||
if ((a&0xfffff0)==0xc00000) {
|
||||
d = PicoVideoRead(a);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (a == 0x800010)
|
||||
d = (PicoPicohw.fifo_bytes > 0x3f) ? 0 : (0x3f - PicoPicohw.fifo_bytes);
|
||||
else if (a == 0x800012)
|
||||
d = PicoPicohw.fifo_bytes == 0 ? 0x8000 : 0; // guess
|
||||
else
|
||||
elprintf(EL_UIO, "r16: %06x, %04x @%06x", a&0xffffff, d, SekPc);
|
||||
|
||||
//elprintf(EL_UIO, "r16: %06x, %04x @%06x", a&0xffffff, d, SekPc);
|
||||
|
||||
end:
|
||||
elprintf(EL_IO, "r16: %06x, %04x @%06x", a&0xffffff, d, SekPc);
|
||||
return d;
|
||||
}
|
||||
|
||||
static u32 PicoReadPico32(u32 a)
|
||||
{
|
||||
u32 d=0;
|
||||
|
||||
if ((a&0xe00000)==0xe00000) { u16 *pm=(u16 *)(Pico.ram+(a&0xfffe)); d = (pm[0]<<16)|pm[1]; goto end; } // Ram
|
||||
|
||||
a&=0xfffffe;
|
||||
|
||||
if (a<Pico.romsize) { u16 *pm=(u16 *)(Pico.rom+a); d = (pm[0]<<16)|pm[1]; goto end; } // Rom
|
||||
|
||||
if ((a&0xfffff0)==0xc00000) {
|
||||
d = (PicoVideoRead(a)<<16)|PicoVideoRead(a+2);
|
||||
goto end;
|
||||
}
|
||||
|
||||
elprintf(EL_UIO, "r32: %06x, %08x @%06x", a&0xffffff, d, SekPc);
|
||||
|
||||
end:
|
||||
elprintf(EL_IO, "r32: %06x, %08x @%06x", a&0xffffff, d, SekPc);
|
||||
return d;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
// Write Ram
|
||||
/*
|
||||
void dump(u16 w)
|
||||
{
|
||||
static FILE *f[0x10] = { NULL, };
|
||||
char fname[32];
|
||||
int num = PicoPicohw.r12 & 0xf;
|
||||
|
||||
w = (w << 8) | (w >> 8);
|
||||
sprintf(fname, "ldump%i.bin", num);
|
||||
if (f[num] == NULL)
|
||||
f[num] = fopen(fname, "wb");
|
||||
fwrite(&w, 1, 2, f[num]);
|
||||
//fclose(f);
|
||||
}
|
||||
*/
|
||||
|
||||
static void PicoWritePico8(u32 a,u8 d)
|
||||
{
|
||||
elprintf(EL_IO, "w8 : %06x, %02x @%06x", a&0xffffff, d, SekPc);
|
||||
|
||||
if ((a&0xe00000)==0xe00000) { *(u8 *)(Pico.ram+((a^1)&0xffff))=d; return; } // Ram
|
||||
|
||||
a&=0xffffff;
|
||||
if ((a&0xfffff9)==0xc00011) { if (PicoOpt&2) SN76496Write(d); return; } // PSG Sound
|
||||
|
||||
if ((a&0xfffff0)==0xc00000) { // VDP
|
||||
d&=0xff;
|
||||
PicoVideoWrite(a,(u16)(d|(d<<8))); // Byte access gets mirrored
|
||||
return;
|
||||
}
|
||||
|
||||
switch (a & 0x1f) {
|
||||
case 0x19: case 0x1b: case 0x1d: case 0x1f: break; // 'S' 'E' 'G' 'A'
|
||||
default:
|
||||
elprintf(EL_UIO, "w8 : %06x, %02x @%06x", a&0xffffff, d, SekPc);
|
||||
break;
|
||||
}
|
||||
//elprintf(EL_UIO, "w8 : %06x, %02x @%06x", a&0xffffff, d, SekPc);
|
||||
}
|
||||
|
||||
static void PicoWritePico16(u32 a,u16 d)
|
||||
{
|
||||
elprintf(EL_IO, "w16: %06x, %04x", a&0xffffff, d);
|
||||
|
||||
if ((a&0xe00000)==0xe00000) { *(u16 *)(Pico.ram+(a&0xfffe))=d; return; } // Ram
|
||||
|
||||
a&=0xfffffe;
|
||||
if ((a&0xfffff0)==0xc00000) { PicoVideoWrite(a,(u16)d); return; } // VDP
|
||||
|
||||
//if (a == 0x800010) dump(d);
|
||||
if (a == 0x800010)
|
||||
{
|
||||
PicoPicohw.fifo_bytes += 2;
|
||||
|
||||
if (PicoPicohw.xpcm_ptr < PicoPicohw.xpcm_buffer + XPCM_BUFFER_SIZE) {
|
||||
*PicoPicohw.xpcm_ptr++ = d >> 8;
|
||||
*PicoPicohw.xpcm_ptr++ = d;
|
||||
}
|
||||
else if (PicoPicohw.xpcm_ptr == PicoPicohw.xpcm_buffer + XPCM_BUFFER_SIZE) {
|
||||
elprintf(EL_ANOMALY|EL_PICOHW, "xpcm_buffer overflow!");
|
||||
PicoPicohw.xpcm_ptr++;
|
||||
}
|
||||
}
|
||||
else if (a == 0x800012) {
|
||||
int r12_old = PicoPicohw.r12;
|
||||
PicoPicohw.r12 = d;
|
||||
if (r12_old != d)
|
||||
PicoReratePico();
|
||||
}
|
||||
else
|
||||
elprintf(EL_UIO, "w16: %06x, %04x", a&0xffffff, d);
|
||||
|
||||
//elprintf(EL_UIO, "w16: %06x, %04x", a&0xffffff, d);
|
||||
}
|
||||
|
||||
static void PicoWritePico32(u32 a,u32 d)
|
||||
{
|
||||
elprintf(EL_IO, "w32: %06x, %08x", a&0xffffff, d);
|
||||
|
||||
if ((a&0xe00000)==0xe00000)
|
||||
{
|
||||
// Ram:
|
||||
u16 *pm=(u16 *)(Pico.ram+(a&0xfffe));
|
||||
pm[0]=(u16)(d>>16); pm[1]=(u16)d;
|
||||
return;
|
||||
}
|
||||
|
||||
a&=0xfffffe;
|
||||
if ((a&0xfffff0)==0xc00000)
|
||||
{
|
||||
// VDP:
|
||||
PicoVideoWrite(a, (u16)(d>>16));
|
||||
PicoVideoWrite(a+2,(u16)d);
|
||||
return;
|
||||
}
|
||||
|
||||
elprintf(EL_UIO, "w32: %06x, %08x", a&0xffffff, d);
|
||||
}
|
||||
|
||||
#ifdef EMU_M68K
|
||||
extern unsigned int (*pm68k_read_memory_8) (unsigned int address);
|
||||
extern unsigned int (*pm68k_read_memory_16)(unsigned int address);
|
||||
extern unsigned int (*pm68k_read_memory_32)(unsigned int address);
|
||||
extern void (*pm68k_write_memory_8) (unsigned int address, unsigned char value);
|
||||
extern void (*pm68k_write_memory_16)(unsigned int address, unsigned short value);
|
||||
extern void (*pm68k_write_memory_32)(unsigned int address, unsigned int value);
|
||||
extern unsigned int (*pm68k_read_memory_pcr_8) (unsigned int address);
|
||||
extern unsigned int (*pm68k_read_memory_pcr_16)(unsigned int address);
|
||||
extern unsigned int (*pm68k_read_memory_pcr_32)(unsigned int address);
|
||||
|
||||
static unsigned int m68k_read_memory_pcrp_8(unsigned int a)
|
||||
{
|
||||
if((a&0xe00000)==0xe00000) return *(u8 *)(Pico.ram+((a^1)&0xffff)); // Ram
|
||||
return 0;
|
||||
}
|
||||
|
||||
static unsigned int m68k_read_memory_pcrp_16(unsigned int a)
|
||||
{
|
||||
if((a&0xe00000)==0xe00000) return *(u16 *)(Pico.ram+(a&0xfffe)); // Ram
|
||||
return 0;
|
||||
}
|
||||
|
||||
static unsigned int m68k_read_memory_pcrp_32(unsigned int a)
|
||||
{
|
||||
if((a&0xe00000)==0xe00000) { u16 *pm=(u16 *)(Pico.ram+(a&0xfffe)); return (pm[0]<<16)|pm[1]; } // Ram
|
||||
return 0;
|
||||
}
|
||||
#endif // EMU_M68K
|
||||
|
||||
|
||||
PICO_INTERNAL void PicoMemSetupPico(void)
|
||||
{
|
||||
#ifdef EMU_C68K
|
||||
PicoCpuCM68k.checkpc=PicoCheckPc;
|
||||
PicoCpuCM68k.fetch8 =PicoCpuCM68k.read8 =PicoReadPico8;
|
||||
PicoCpuCM68k.fetch16=PicoCpuCM68k.read16=PicoReadPico16;
|
||||
PicoCpuCM68k.fetch32=PicoCpuCM68k.read32=PicoReadPico32;
|
||||
PicoCpuCM68k.write8 =PicoWritePico8;
|
||||
PicoCpuCM68k.write16=PicoWritePico16;
|
||||
PicoCpuCM68k.write32=PicoWritePico32;
|
||||
#endif
|
||||
#ifdef EMU_M68K
|
||||
pm68k_read_memory_8 = PicoReadPico8;
|
||||
pm68k_read_memory_16 = PicoReadPico16;
|
||||
pm68k_read_memory_32 = PicoReadPico32;
|
||||
pm68k_write_memory_8 = PicoWritePico8;
|
||||
pm68k_write_memory_16 = PicoWritePico16;
|
||||
pm68k_write_memory_32 = PicoWritePico32;
|
||||
pm68k_read_memory_pcr_8 = m68k_read_memory_pcrp_8;
|
||||
pm68k_read_memory_pcr_16 = m68k_read_memory_pcrp_16;
|
||||
pm68k_read_memory_pcr_32 = m68k_read_memory_pcrp_32;
|
||||
#endif
|
||||
#ifdef EMU_F68K
|
||||
// use standard setup, only override handlers
|
||||
PicoMemSetup();
|
||||
PicoCpuFM68k.read_byte =PicoReadPico8;
|
||||
PicoCpuFM68k.read_word =PicoReadPico16;
|
||||
PicoCpuFM68k.read_long =PicoReadPico32;
|
||||
PicoCpuFM68k.write_byte=PicoWritePico8;
|
||||
PicoCpuFM68k.write_word=PicoWritePico16;
|
||||
PicoCpuFM68k.write_long=PicoWritePico32;
|
||||
#endif
|
||||
}
|
||||
|
97
pico/pico/pico.c
Normal file
97
pico/pico/pico.c
Normal file
|
@ -0,0 +1,97 @@
|
|||
#include "../pico_int.h"
|
||||
|
||||
// x: 0x03c - 0x19d
|
||||
// y: 0x1fc - 0x2f7
|
||||
// 0x2f8 - 0x3f3
|
||||
picohw_state PicoPicohw;
|
||||
|
||||
static int prev_line_cnt_irq3 = 0, prev_line_cnt_irq5 = 0;
|
||||
static int fifo_bytes_line = (16000<<16)/60/262/2;
|
||||
|
||||
static const int guessed_rates[] = { 8000, 14000, 12000, 14000, 16000, 18000, 16000, 16000 }; // ?
|
||||
|
||||
#define PICOHW_FIFO_IRQ_THRESHOLD 12
|
||||
|
||||
PICO_INTERNAL void PicoReratePico(void)
|
||||
{
|
||||
int rate = guessed_rates[PicoPicohw.r12 & 7];
|
||||
if (Pico.m.pal)
|
||||
fifo_bytes_line = (rate<<16)/50/312/2;
|
||||
else fifo_bytes_line = (rate<<16)/60/262/2;
|
||||
PicoPicoPCMRerate(rate);
|
||||
}
|
||||
|
||||
static void PicoLinePico(void)
|
||||
{
|
||||
PicoPicohw.line_counter++;
|
||||
|
||||
#if 1
|
||||
if ((PicoPicohw.r12 & 0x4003) && PicoPicohw.line_counter - prev_line_cnt_irq3 > 200) {
|
||||
prev_line_cnt_irq3 = PicoPicohw.line_counter;
|
||||
// just a guess/hack, allows 101 Dalmantians to boot
|
||||
elprintf(EL_PICOHW, "irq3");
|
||||
SekInterrupt(3);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (PicoPicohw.fifo_bytes > 0)
|
||||
{
|
||||
PicoPicohw.fifo_line_bytes += fifo_bytes_line;
|
||||
if (PicoPicohw.fifo_line_bytes >= (1<<16)) {
|
||||
PicoPicohw.fifo_bytes -= PicoPicohw.fifo_line_bytes >> 16;
|
||||
PicoPicohw.fifo_line_bytes &= 0xffff;
|
||||
if (PicoPicohw.fifo_bytes < 0)
|
||||
PicoPicohw.fifo_bytes = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
PicoPicohw.fifo_line_bytes = 0;
|
||||
|
||||
#if 1
|
||||
if (PicoPicohw.fifo_bytes_prev >= PICOHW_FIFO_IRQ_THRESHOLD &&
|
||||
PicoPicohw.fifo_bytes < PICOHW_FIFO_IRQ_THRESHOLD) {
|
||||
prev_line_cnt_irq3 = PicoPicohw.line_counter; // ?
|
||||
elprintf(EL_PICOHW, "irq3, fb=%i", PicoPicohw.fifo_bytes);
|
||||
SekInterrupt(3);
|
||||
}
|
||||
PicoPicohw.fifo_bytes_prev = PicoPicohw.fifo_bytes;
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
if (PicoPicohw.line_counter - prev_line_cnt_irq5 > 512) {
|
||||
prev_line_cnt_irq5 = PicoPicohw.line_counter;
|
||||
elprintf(EL_PICOHW, "irq5");
|
||||
SekInterrupt(5);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void PicoResetPico(void)
|
||||
{
|
||||
PicoPicoPCMReset();
|
||||
PicoPicohw.xpcm_ptr = PicoPicohw.xpcm_buffer;
|
||||
}
|
||||
|
||||
PICO_INTERNAL void PicoInitPico(void)
|
||||
{
|
||||
elprintf(EL_STATUS, "Pico detected");
|
||||
PicoLineHook = PicoLinePico;
|
||||
PicoResetHook = PicoResetPico;
|
||||
|
||||
PicoAHW = PAHW_PICO;
|
||||
memset(&PicoPicohw, 0, sizeof(PicoPicohw));
|
||||
PicoPicohw.pen_pos[0] = 0x03c + 320/2;
|
||||
PicoPicohw.pen_pos[1] = 0x200 + 240/2;
|
||||
prev_line_cnt_irq3 = prev_line_cnt_irq5 = 0;
|
||||
|
||||
// map version register
|
||||
PicoDetectRegion();
|
||||
switch (Pico.m.hardware >> 6) {
|
||||
case 0: PicoPicohw.r1 = 0x00; break;
|
||||
case 1: PicoPicohw.r1 = 0x00; break;
|
||||
case 2: PicoPicohw.r1 = 0x40; break;
|
||||
case 3: PicoPicohw.r1 = 0x20; break;
|
||||
}
|
||||
}
|
||||
|
114
pico/pico/xpcm.c
Normal file
114
pico/pico/xpcm.c
Normal file
|
@ -0,0 +1,114 @@
|
|||
/*
|
||||
* The following ADPCM algorithm was stolen from MAME aica driver.
|
||||
* I'm quite sure it's not the right one, but it's the
|
||||
* best sounding of the ones that I tried.
|
||||
*/
|
||||
|
||||
#include "../pico_int.h"
|
||||
|
||||
#define ADPCMSHIFT 8
|
||||
#define ADFIX(f) (int) ((double)f * (double)(1<<ADPCMSHIFT))
|
||||
|
||||
/* limitter */
|
||||
#define Limit(val, max, min) { \
|
||||
if ( val > max ) val = max; \
|
||||
else if ( val < min ) val = min; \
|
||||
}
|
||||
|
||||
static const int TableQuant[8] =
|
||||
{
|
||||
ADFIX(0.8984375),
|
||||
ADFIX(0.8984375),
|
||||
ADFIX(0.8984375),
|
||||
ADFIX(0.8984375),
|
||||
ADFIX(1.19921875),
|
||||
ADFIX(1.59765625),
|
||||
ADFIX(2.0),
|
||||
ADFIX(2.3984375)
|
||||
};
|
||||
|
||||
// changed using trial and error..
|
||||
//static const int quant_mul[16] = { 1, 3, 5, 7, 9, 11, 13, 15, -1, -3, -5, -7, -9, -11, -13, -15 };
|
||||
static const int quant_mul[16] = { 1, 3, 5, 7, 9, 11, 13, -1, -1, -3, -5, -7, -9, -11, -13, -15 };
|
||||
|
||||
static int sample = 0, quant = 0, sgn = 0;
|
||||
static int stepsamples = (44100<<10)/16000;
|
||||
|
||||
|
||||
PICO_INTERNAL void PicoPicoPCMReset(void)
|
||||
{
|
||||
sample = sgn = 0;
|
||||
quant = 0x7f;
|
||||
memset(PicoPicohw.xpcm_buffer, 0, sizeof(PicoPicohw.xpcm_buffer));
|
||||
}
|
||||
|
||||
PICO_INTERNAL void PicoPicoPCMRerate(int xpcm_rate)
|
||||
{
|
||||
stepsamples = (PsndRate<<10)/xpcm_rate;
|
||||
}
|
||||
|
||||
#define XSHIFT 6
|
||||
|
||||
#define do_sample() \
|
||||
{ \
|
||||
int delta = quant * quant_mul[srcval] >> XSHIFT; \
|
||||
sample += delta - (delta >> 2); /* 3/4 */ \
|
||||
quant = (quant * TableQuant[srcval&7]) >> ADPCMSHIFT; \
|
||||
Limit(quant, 0x6000, 0x7f); \
|
||||
Limit(sample, 32767*3/4, -32768*3/4); \
|
||||
}
|
||||
|
||||
PICO_INTERNAL void PicoPicoPCMUpdate(short *buffer, int length, int stereo)
|
||||
{
|
||||
unsigned char *src = PicoPicohw.xpcm_buffer;
|
||||
unsigned char *lim = PicoPicohw.xpcm_ptr;
|
||||
int srcval, needsamples = 0;
|
||||
|
||||
if (src == lim) goto end;
|
||||
|
||||
for (; length > 0 && src < lim; src++)
|
||||
{
|
||||
srcval = *src >> 4;
|
||||
do_sample();
|
||||
|
||||
for (needsamples += stepsamples; needsamples > (1<<10) && length > 0; needsamples -= (1<<10), length--) {
|
||||
*buffer++ += sample;
|
||||
if (stereo) { buffer[0] = buffer[-1]; buffer++; }
|
||||
}
|
||||
|
||||
srcval = *src & 0xf;
|
||||
do_sample();
|
||||
|
||||
for (needsamples += stepsamples; needsamples > (1<<10) && length > 0; needsamples -= (1<<10), length--) {
|
||||
*buffer++ += sample;
|
||||
if (stereo) { buffer[0] = buffer[-1]; buffer++; }
|
||||
}
|
||||
|
||||
// lame normalization stuff, needed due to wrong adpcm algo
|
||||
sgn += (sample < 0) ? -1 : 1;
|
||||
if (sgn < -16 || sgn > 16) sample -= sample >> 5;
|
||||
}
|
||||
|
||||
if (src < lim) {
|
||||
int di = lim - src;
|
||||
memmove(PicoPicohw.xpcm_buffer, src, di);
|
||||
PicoPicohw.xpcm_ptr = PicoPicohw.xpcm_buffer + di;
|
||||
elprintf(EL_PICOHW, "xpcm update: over %i", di);
|
||||
// adjust fifo
|
||||
PicoPicohw.fifo_bytes = di;
|
||||
return;
|
||||
}
|
||||
|
||||
elprintf(EL_PICOHW, "xpcm update: under %i", length);
|
||||
PicoPicohw.xpcm_ptr = PicoPicohw.xpcm_buffer;
|
||||
|
||||
end:
|
||||
if (stereo)
|
||||
// still must expand SN76496 to stereo
|
||||
for (; length > 0; buffer+=2, length--)
|
||||
buffer[1] = buffer[0];
|
||||
|
||||
sample = sgn = 0;
|
||||
quant = 0x7f;
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue