X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=Pico%2FPicoInt.h;h=1fd7422e0d9c29b52dfd8e62705624a91dc996ec;hb=7d4906bfc93ced40a544534f433f06b00add52b0;hp=d98a900d8f12534600090d003ac2c259c06abcb3;hpb=e5f426aa2e86d56357b8af2795e73cc0c9b17e8f;p=picodrive.git diff --git a/Pico/PicoInt.h b/Pico/PicoInt.h index d98a900..1fd7422 100644 --- a/Pico/PicoInt.h +++ b/Pico/PicoInt.h @@ -101,7 +101,11 @@ extern int SekCycleCnt; // cycles done in this frame extern int SekCycleAim; // cycle aim extern unsigned int SekCycleCntT; // total cycle counter, updated once per frame -#define SekCyclesReset() {SekCycleCntT+=SekCycleCnt;SekCycleCnt=SekCycleAim=0;} +#define SekCyclesReset() { \ + SekCycleCntT+=SekCycleAim; \ + SekCycleCnt-=SekCycleAim; \ + SekCycleAim=0; \ +} #define SekCyclesBurn(c) SekCycleCnt+=c #define SekCyclesDone() (SekCycleAim-SekCyclesLeft) // nuber of cycles done in this frame (can be checked anywhere) #define SekCyclesDoneT() (SekCycleCntT+SekCyclesDone()) // total nuber of cycles done for this rom @@ -115,7 +119,10 @@ extern unsigned int SekCycleCntT; // total cycle counter, updated once per frame extern int SekCycleCntS68k; extern int SekCycleAimS68k; -#define SekCyclesResetS68k() {SekCycleCntS68k=SekCycleAimS68k=0;} +#define SekCyclesResetS68k() { \ + SekCycleCntS68k-=SekCycleAimS68k; \ + SekCycleAimS68k=0; \ +} #define SekCyclesDoneS68k() (SekCycleAimS68k-SekCyclesLeftS68k) // debug cyclone @@ -136,40 +143,42 @@ extern int PicoMCD; // main oscillator clock which controls timing #define OSC_NTSC 53693100 -#define OSC_PAL 53203424 // not accurate +// seems to be accurate, see scans from http://www.hot.ee/tmeeco/ +#define OSC_PAL 53203424 struct PicoVideo { unsigned char reg[0x20]; - unsigned int command; // 32-bit Command - unsigned char pending; // 1 if waiting for second half of 32-bit command - unsigned char type; // Command type (v/c/vsram read/write) - unsigned short addr; // Read/Write address - int status; // Status bits + unsigned int command; // 32-bit Command + unsigned char pending; // 1 if waiting for second half of 32-bit command + unsigned char type; // Command type (v/c/vsram read/write) + unsigned short addr; // Read/Write address + int status; // Status bits unsigned char pending_ints; // pending interrupts: ??VH???? - unsigned char pad[0x13]; + signed char lwrite_cnt; // VDP write count during active display line + unsigned char pad[0x12]; }; struct PicoMisc { unsigned char rotate; unsigned char z80Run; - unsigned char padTHPhase[2]; // phase of gamepad TH switches - short scanline; // 0 to 261||311; -1 in fast mode - char dirtyPal; // Is the palette dirty (1 - change @ this frame, 2 - some time before) - unsigned char hardware; // Hardware value for country - unsigned char pal; // 1=PAL 0=NTSC - unsigned char sram_reg; // SRAM mode register. bit0: allow read? bit1: deny write? bit2: EEPROM? bit4: detected? (header or by access) - unsigned short z80_bank68k; + unsigned char padTHPhase[2]; // 02 phase of gamepad TH switches + short scanline; // 04 0 to 261||311; -1 in fast mode + char dirtyPal; // 06 Is the palette dirty (1 - change @ this frame, 2 - some time before) + unsigned char hardware; // 07 Hardware value for country + unsigned char pal; // 08 1=PAL 0=NTSC + unsigned char sram_reg; // SRAM mode register. bit0: allow read? bit1: deny write? bit2: EEPROM? bit4: detected? (header or by access) + unsigned short z80_bank68k; // 0a unsigned short z80_lastaddr; // this is for Z80 faking unsigned char z80_fakeval; unsigned char pad0; - unsigned char padDelay[2]; // gamepad phase time outs, so we count a delay - unsigned short sram_addr; // EEPROM address register - unsigned char sram_cycle; // EEPROM SRAM cycle number - unsigned char sram_slave; // EEPROM slave word for X24C02 and better SRAMs + unsigned char padDelay[2]; // 10 gamepad phase time outs, so we count a delay + unsigned short eeprom_addr; // EEPROM address register + unsigned char eeprom_cycle; // EEPROM SRAM cycle number + unsigned char eeprom_slave; // EEPROM slave word for X24C02 and better SRAMs unsigned char prot_bytes[2]; // simple protection faking - unsigned short dma_bytes; // + unsigned short dma_xfers; unsigned char pad[2]; unsigned int frame_count; // mainly for movies }; @@ -198,10 +207,14 @@ struct PicoSRAM unsigned char *data; // actual data unsigned int start; // start address in 68k address space unsigned int end; - unsigned char resize; // 0c: 1=SRAM size changed and needs to be reallocated on PicoReset - unsigned char reg_back; // copy of Pico.m.sram_reg to set after reset + unsigned char unused1; // 0c: unused + unsigned char unused2; unsigned char changed; - unsigned char pad; + unsigned char eeprom_type; // eeprom type: 0: 7bit (24C01), 2: device with 2 addr words (X24C02+), 3: dev with 3 addr words + unsigned char eeprom_abits; // eeprom access must be odd addr for: bit0 ~ cl, bit1 ~ out + unsigned char eeprom_bit_cl; // bit number for cl + unsigned char eeprom_bit_in; // bit number for in + unsigned char eeprom_bit_out; // bit number for out }; // MCD @@ -285,6 +298,9 @@ PICO_INTERNAL int PicoAreaUnpackCpu(unsigned char *cpu, int is_sub); PICO_INTERNAL int PicoCdSaveState(void *file); PICO_INTERNAL int PicoCdLoadState(void *file); +// Cart.c +PICO_INTERNAL void PicoCartDetect(void); + // Draw.c PICO_INTERNAL int PicoLine(int scan); PICO_INTERNAL void PicoFrameStart(void); @@ -297,6 +313,7 @@ PICO_INTERNAL int PicoInitPc(unsigned int pc); PICO_INTERNAL_ASM unsigned int CPU_CALL PicoRead32(unsigned int a); PICO_INTERNAL void PicoMemSetup(void); PICO_INTERNAL_ASM void PicoMemReset(void); +PICO_INTERNAL int PadRead(int i); PICO_INTERNAL unsigned char z80_read(unsigned short a); PICO_INTERNAL unsigned short z80_read16(unsigned short a); PICO_INTERNAL_ASM void z80_write(unsigned char data, unsigned short a); @@ -376,5 +393,37 @@ PICO_INTERNAL void z80_exit(void); } // End of extern "C" #endif +// emulation event logging +#ifndef EL_LOGMASK +#define EL_LOGMASK 0 +#endif + +#define EL_HVCNT 0x0001 /* hv counter reads */ +#define EL_SR 0x0002 /* SR reads */ +#define EL_INTS 0x0004 /* ints and acks */ +#define EL_YM2612R 0x0008 /* 68k ym2612 reads */ +#define EL_INTSW 0x0010 /* log irq switching on/off */ +#define EL_ASVDP 0x0020 /* VDP accesses during active scan */ +#define EL_VDPDMA 0x0040 /* VDP DMA transfers and their timing */ +#define EL_BUSREQ 0x0080 /* z80 busreq r/w or reset w */ +#define EL_Z80BNK 0x0100 /* z80 i/o through bank area */ +#define EL_SRAMIO 0x0200 /* sram i/o */ +#define EL_EEPROM 0x0400 /* eeprom debug */ +#define EL_UIO 0x0800 /* unmapped i/o */ +#define EL_IO 0x1000 /* all i/o (TODO) */ + +#define EL_STATUS 0x4000 /* status messages */ +#define EL_ANOMALY 0x8000 /* some unexpected conditions */ + +#if EL_LOGMASK +#define elprintf(w,f,...) \ +{ \ + if ((w) & EL_LOGMASK) \ + printf("%05i:%03i: " f "\n",Pico.m.frame_count,Pico.m.scanline,##__VA_ARGS__); \ +} +#else +#define elprintf(w,f,...) +#endif + #endif // PICO_INTERNAL_INCLUDED