X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=Pico%2FPico%2FMemory.c;h=8c4674b59651549f8cb5a1a357edd2921e01cbe0;hb=45a1ef7153910f005c01cba63d12f312071efef0;hp=f18edc4569c3022a9e93e03a6caf141d0ef1ce99;hpb=406c96c547a11046f63cb88bd0bc666003812608;p=picodrive.git diff --git a/Pico/Pico/Memory.c b/Pico/Pico/Memory.c index f18edc4..8c4674b 100644 --- a/Pico/Pico/Memory.c +++ b/Pico/Pico/Memory.c @@ -1,4 +1,5 @@ #include "../PicoInt.h" +#include "../sound/sn76496.h" #ifndef UTYPES_DEFINED typedef unsigned char u8; @@ -7,6 +8,7 @@ typedef unsigned int u32; #define UTYPES_DEFINED #endif + // ----------------------------------------------------------------- // Read Rom and read Ram @@ -19,7 +21,7 @@ static u32 PicoReadPico8(u32 a) a&=0xffffff; - if ((a&0xffffe0)==0xc00000) { // VDP + if ((a&0xfffff0)==0xc00000) { // VDP d=PicoVideoRead(a); if ((a&1)==0) d>>=8; goto end; @@ -29,26 +31,26 @@ static u32 PicoReadPico8(u32 a) { switch (a & 0x1f) { + case 0x01: d = PicoPicohw.r1; break; case 0x03: - d = PicoPad[0]&0x0f; // d-pad - d |= (PicoPad[0]&0x20) >> 1; // red button -> C - d |= (PicoPad[0]&0x40) << 1; // pen tap -> A + d = PicoPad[0]&0x1f; // d-pad + d |= (PicoPad[0]&0x20) << 2; // pen push -> C d = ~d; break; - case 0x05: d = (PicoPicoPenPos[0] >> 8) & 3; break; // what is MS bit for? Games read it.. - case 0x07: d = PicoPicoPenPos[0] & 0xff; break; - case 0x09: d = (PicoPicoPenPos[1] >> 8) & 3; break; - case 0x0b: d = PicoPicoPenPos[1] & 0xff; break; - case 0x0d: d = (1 << (PicoPicoPage & 7)) - 1;break; - case 0x12: d = 0x80; 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); + //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); @@ -65,14 +67,19 @@ static u32 PicoReadPico16(u32 a) if (a 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); + //elprintf(EL_UIO, "r16: %06x, %04x @%06x", a&0xffffff, d, SekPc); end: elprintf(EL_IO, "r16: %06x, %04x @%06x", a&0xffffff, d, SekPc); @@ -89,7 +96,7 @@ static u32 PicoReadPico32(u32 a) if (a> 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) { @@ -119,13 +133,21 @@ static void PicoWritePico8(u32 a,u8 d) if ((a&0xe00000)==0xe00000) { *(u8 *)(Pico.ram+((a^1)&0xffff))=d; return; } // Ram a&=0xffffff; - if ((a&0xffffe0)==0xc00000) { // VDP + 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; } - elprintf(EL_UIO, "w8 : %06x, %02x @%06x", a&0xffffff, d, SekPc); + 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) @@ -135,11 +157,32 @@ static void PicoWritePico16(u32 a,u16 d) if ((a&0xe00000)==0xe00000) { *(u16 *)(Pico.ram+(a&0xfffe))=d; return; } // Ram a&=0xfffffe; - if ((a&0xffffe0)==0xc00000) { PicoVideoWrite(a,(u16)d); return; } // VDP + if ((a&0xfffff0)==0xc00000) { PicoVideoWrite(a,(u16)d); return; } // VDP + + //if (a == 0x800010) dump(d); + if (a == 0x800010) + { + PicoPicohw.fifo_bytes += 2; -// if (a == 0x800010) dump(d); + 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); + //elprintf(EL_UIO, "w16: %06x, %04x", a&0xffffff, d); } static void PicoWritePico32(u32 a,u32 d) @@ -155,7 +198,7 @@ static void PicoWritePico32(u32 a,u32 d) } a&=0xfffffe; - if ((a&0xffffe0)==0xc00000) + if ((a&0xfffff0)==0xc00000) { // VDP: PicoVideoWrite(a, (u16)(d>>16)); @@ -219,5 +262,15 @@ PICO_INTERNAL void PicoMemSetupPico(void) 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 }