X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=Pico%2FMemory.c;h=dc9c7386404bb0b8b0c54ad33a8b4e3d4d77d990;hb=fb9bec948efc6c7edca8f5463bc0c3522f96c165;hp=2b253d80e0322f141587eb77ea0458daae995c2c;hpb=0af33fe0ef24a3e3b65217ad0d7aa2db03d16fc1;p=picodrive.git diff --git a/Pico/Memory.c b/Pico/Memory.c index 2b253d8..dc9c738 100644 --- a/Pico/Memory.c +++ b/Pico/Memory.c @@ -11,19 +11,22 @@ #include "PicoInt.h" -#include "sound/sound.h" #include "sound/ym2612.h" #include "sound/sn76496.h" +#ifndef UTYPES_DEFINED typedef unsigned char u8; typedef unsigned short u16; typedef unsigned int u32; +#define UTYPES_DEFINED +#endif extern unsigned int lastSSRamWrite; // used by serial SRAM code #ifdef _ASM_MEMORY_C u32 PicoRead8(u32 a); u32 PicoRead16(u32 a); +void PicoWrite8(u32 a,u8 d); void PicoWriteRomHW_SSF2(u32 a,u32 d); void PicoWriteRomHW_in1 (u32 a,u32 d); #endif @@ -36,6 +39,12 @@ int lrp_cyc=0, lrp_mus=0, lwp_cyc=0, lwp_mus=0; extern unsigned int ppop; #endif +#ifdef IO_STATS +void log_io(unsigned int addr, int bits, int rw); +#else +#define log_io(...) +#endif + #if defined(EMU_C68K) || defined(EMU_A68K) static __inline int PicoMemBase(u32 pc) { @@ -88,20 +97,52 @@ static u32 CPU_CALL PicoCheckPc(u32 pc) } -int PicoInitPc(u32 pc) +PICO_INTERNAL int PicoInitPc(u32 pc) { PicoCheckPc(pc); return 0; } #ifndef _ASM_MEMORY_C -void PicoMemReset() +PICO_INTERNAL_ASM void PicoMemReset(void) { } #endif // ----------------------------------------------------------------- +int PadRead(int i) +{ + int pad,value,data_reg; + pad=~PicoPad[i]; // Get inverse of pad MXYZ SACB RLDU + data_reg=Pico.ioports[i+1]; + + // orr the bits, which are set as output + value = data_reg&(Pico.ioports[i+4]|0x80); + + if(PicoOpt & 0x20) { // 6 button gamepad enabled + int phase = Pico.m.padTHPhase[i]; + + if(phase == 2 && !(data_reg&0x40)) { // TH + value|=(pad&0xc0)>>2; // ?0SA 0000 + return value; + } else if(phase == 3) { + if(data_reg&0x40) + value|=(pad&0x30)|((pad>>8)&0xf); // ?1CB MXYZ + else + value|=((pad&0xc0)>>2)|0x0f; // ?0SA 1111 + return value; + } + } + + if(data_reg&0x40) // TH + value|=(pad&0x3f); // ?1CB RLDU + else value|=((pad&0xc0)>>2)|(pad&3); // ?0SA 00DU + + return value; // will mirror later +} + + #ifndef _ASM_MEMORY_C // address must already be checked static int SRAMRead(u32 a) @@ -266,7 +307,7 @@ static void OtherWrite8End(u32 a,u32 d,int realsize) // Read Rom and read Ram #ifndef _ASM_MEMORY_C -u32 CPU_CALL PicoRead8(u32 a) +PICO_INTERNAL_ASM u32 CPU_CALL PicoRead8(u32 a) { u32 d=0; @@ -292,6 +333,7 @@ u32 CPU_CALL PicoRead8(u32 a) #endif if (a>=8; @@ -317,7 +359,7 @@ u32 CPU_CALL PicoRead8(u32 a) return d; } -u32 CPU_CALL PicoRead16(u32 a) +PICO_INTERNAL_ASM u32 CPU_CALL PicoRead16(u32 a) { u32 d=0; @@ -334,6 +376,7 @@ u32 CPU_CALL PicoRead16(u32 a) #endif if (a>16); pm[1]=(u16)d; return; } + log_io(a, 32, 1); a&=0xfffffe; OtherWrite16(a, (u16)(d>>16)); @@ -446,7 +495,7 @@ static void CPU_CALL PicoWrite32(u32 a,u32 d) // ----------------------------------------------------------------- -void PicoMemSetup() +PICO_INTERNAL void PicoMemSetup(void) { #ifdef EMU_C68K // Setup memory callbacks: @@ -623,7 +672,7 @@ void m68k_write_memory_32(unsigned int address, unsigned int value) // ----------------------------------------------------------------- // z80 memhandlers -unsigned char z80_read(unsigned short a) +PICO_INTERNAL unsigned char z80_read(unsigned short a) { u8 ret = 0; @@ -651,14 +700,14 @@ end: return ret; } -unsigned short z80_read16(unsigned short a) +PICO_INTERNAL unsigned short z80_read16(unsigned short a) { //dprintf("z80_read16"); return (u16) ( (u16)z80_read(a) | ((u16)z80_read((u16)(a+1))<<8) ); } -void z80_write(unsigned char data, unsigned short a) +PICO_INTERNAL_ASM void z80_write(unsigned char data, unsigned short a) { //if (a<0x4000) // dprintf("z80 w8 : %06x, %02x @%04x", a, data, mz80GetRegisterValue(NULL, 0)); @@ -697,7 +746,7 @@ void z80_write(unsigned char data, unsigned short a) if (a<0x4000) { Pico.zram[a&0x1fff]=data; return; } } -void z80_write16(unsigned short data, unsigned short a) +PICO_INTERNAL void z80_write16(unsigned short data, unsigned short a) { //dprintf("z80_write16");