X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=pico%2Fpico_int.h;h=afcc838ee88ea99b6e2daed00d7dd067d6930ca6;hb=4ea707e1e38b7ca204a5012f617018d0ea5eced2;hp=8c72bba2229b4c565b95533b7c48fde027b42d09;hpb=af37bca858874b5cbd5ab126eaba1fad6ff7ab72;p=picodrive.git diff --git a/pico/pico_int.h b/pico/pico_int.h index 8c72bba..afcc838 100644 --- a/pico/pico_int.h +++ b/pico/pico_int.h @@ -226,6 +226,20 @@ extern unsigned long z80_write_map[0x10000 >> Z80_MEM_SHIFT]; typedef unsigned char (z80_read_f)(unsigned short a); typedef void (z80_write_f)(unsigned int a, unsigned char data); +// ----------------------- SH2 CPU ----------------------- + +#include "cpu/sh2mame/sh2.h" + +SH2 msh2, ssh2; +#define ash2_pc() msh2.ppc +#define ash2_end_run(after) sh2_icount = after + +#define sh2_pc(c) (c) ? ssh2.ppc : msh2.ppc +#define sh2_reg(c, x) (c) ? ssh2.r[x] : msh2.r[x] +#define sh2_gbr(c) (c) ? ssh2.gbr : msh2.gbr +#define sh2_vbr(c) (c) ? ssh2.vbr : msh2.vbr +#define sh2_sr(c) (c) ? ssh2.sr : msh2.sr + // --------------------------------------------------------- // main oscillator clock which controls timing @@ -255,18 +269,19 @@ struct PicoMisc 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_status; // 09 SRAM status. See SRS_* below + unsigned char sram_reg; // 09 SRAM reg. See SRR_* below unsigned short z80_bank68k; // 0a - unsigned short z80_lastaddr; // this is for Z80 faking - unsigned char z80_fakeval; - unsigned char z80_reset; // z80 reset held + unsigned short pad0; + unsigned char pad1; + unsigned char z80_reset; // 0f z80 reset held 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_cycle; // EEPROM cycle number unsigned char eeprom_slave; // EEPROM slave word for X24C02 and better SRAMs - unsigned char prot_bytes[2]; // simple protection faking + unsigned char eeprom_status; + unsigned char pad2; unsigned short dma_xfers; // 18 - unsigned char pad[2]; + unsigned char eeprom_wb[2]; // EEPROM latch/write buffer unsigned int frame_count; // 1c for movies and idle det }; @@ -293,24 +308,26 @@ struct Pico }; // sram -#define SRS_MAPPED (1 << 0) -#define SRS_READONLY (1 << 1) -#define SRS_EEPROM (1 << 2) -#define SRS_DETECTED (1 << 4) +#define SRR_MAPPED (1 << 0) +#define SRR_READONLY (1 << 1) + +#define SRF_ENABLED (1 << 0) +#define SRF_EEPROM (1 << 1) struct PicoSRAM { unsigned char *data; // actual data unsigned int start; // start address in 68k address space unsigned int end; - unsigned char unused1; // 0c: unused + unsigned char flags; // 0c: SRF_* unsigned char unused2; unsigned char changed; - 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_type; // eeprom type: 0: 7bit (24C01), 2: 2 addr words (X24C02+), 3: 3 addr words + unsigned char unused3; 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 + unsigned int size; }; // MCD @@ -382,8 +399,68 @@ typedef struct Rot_Comp rot_comp; } mcd_state; +// XXX: this will need to be reworked for cart+cd support. #define Pico_mcd ((mcd_state *)Pico.rom) +// 32X +#define P32XS_FM (1<<15) +#define P32XS2_ADEN (1<< 9) +#define P32XS_FULL (1<< 7) +#define P32XS_68S (1<< 2) +#define P32XS_RV (1<< 0) + +#define P32XV_nPAL (1<<15) +#define P32XV_PRI (1<< 7) +#define P32XV_Mx (3<< 0) // display mode mask + +#define P32XV_VBLK (1<<15) +#define P32XV_HBLK (1<<14) +#define P32XV_PEN (1<<13) +#define P32XV_nFEN (1<< 1) +#define P32XV_FS (1<< 0) + +#define P32XF_68KPOLL (1 << 0) +#define P32XF_MSH2POLL (1 << 1) +#define P32XF_SSH2POLL (1 << 2) +#define P32XF_68KVPOLL (1 << 3) +#define P32XF_MSH2VPOLL (1 << 4) +#define P32XF_SSH2VPOLL (1 << 5) + +#define P32XI_VRES (1 << 14/2) // IRL/2 +#define P32XI_VINT (1 << 12/2) +#define P32XI_HINT (1 << 10/2) +#define P32XI_CMD (1 << 8/2) +#define P32XI_PWM (1 << 6/2) + +// real one is 4*2, but we use more because we don't lockstep +#define DMAC_FIFO_LEN (4*4) + +struct Pico32x +{ + unsigned short regs[0x20]; + unsigned short vdp_regs[0x10]; + unsigned char pending_fb; + unsigned char dirty_pal; + unsigned char pad[2]; + unsigned int emu_flags; + unsigned char sh2irq_mask[2]; + unsigned char sh2irqi[2]; // individual + unsigned int sh2irqs; // common irqs + unsigned short dmac_fifo[DMAC_FIFO_LEN]; + unsigned int dmac_ptr; +}; + +struct Pico32xMem +{ + unsigned char sdram[0x40000]; + unsigned short dram[2][0x20000/2]; // AKA fb + unsigned char m68k_rom[0x10000]; // 0x100; using M68K_BANK_SIZE + unsigned char sh2_rom_m[0x800]; + unsigned char sh2_rom_s[0x400]; + unsigned short pal[0x100]; + unsigned short pal_native[0x100]; // converted to native (for renderer) + unsigned int sh2_peri_regs[2][0x200/4]; // periphereal regs of SH2s +}; // area.c PICO_INTERNAL void PicoAreaPackCpu(unsigned char *cpu, int is_sub); @@ -414,6 +491,7 @@ extern areaseek *areaSeek; extern areaclose *areaClose; // cart.c +extern void (*PicoCartMemSetup)(void); extern void (*PicoCartUnloadHook)(void); // debug.c @@ -423,7 +501,7 @@ int CM_compareRun(int cyc, int is_sub); PICO_INTERNAL void PicoFrameStart(void); void PicoDrawSync(int to, int blank_last_line); void BackFill(int reg7, int sh); -void FinalizeLineRGB555(int sh); +void FinalizeLineRGB555(int sh, int line); extern int DrawScanline; #define MAX_LINE_SPRITES 29 extern unsigned char HighLnSpr[240][3 + MAX_LINE_SPRITES]; @@ -438,13 +516,7 @@ void PicoDoHighPal555M4(void); void PicoDrawSetColorFormatMode4(int which); // memory.c -PICO_INTERNAL void PicoInitPc(unsigned int pc); -PICO_INTERNAL unsigned int PicoCheckPc(unsigned int pc); PICO_INTERNAL void PicoMemSetup(void); -PICO_INTERNAL void PicoMemResetHooks(void); -extern unsigned int (*PicoRead16Hook)(unsigned int a, int realsize); -extern void (*PicoWrite8Hook) (unsigned int a,unsigned int d,int realsize); -extern void (*PicoWrite16Hook)(unsigned int a,unsigned int d,int realsize); unsigned int PicoRead8_io(unsigned int a); unsigned int PicoRead16_io(unsigned int a); void PicoWrite8_io(unsigned int a, unsigned int d); @@ -455,8 +527,7 @@ PICO_INTERNAL void PicoMemSetupPico(void); // cd/memory.c PICO_INTERNAL void PicoMemSetupCD(void); -PICO_INTERNAL_ASM void PicoMemRemapCD(int r3); -PICO_INTERNAL_ASM void PicoMemResetCDdecode(int r3); +void PicoMemStateLoaded(void); // pico.c extern struct Pico Pico; @@ -537,14 +608,16 @@ PICO_INTERNAL_ASM unsigned int PicoVideoRead8(unsigned int a); extern int (*PicoDmaHook)(unsigned int source, int len, unsigned short **srcp, unsigned short **limitp); // misc.c -PICO_INTERNAL void EEPROM_write(unsigned int d); -PICO_INTERNAL void EEPROM_upd_pending(unsigned int a, unsigned int d); -PICO_INTERNAL_ASM unsigned int EEPROM_read(void); PICO_INTERNAL_ASM void memcpy16(unsigned short *dest, unsigned short *src, int count); PICO_INTERNAL_ASM void memcpy16bswap(unsigned short *dest, void *src, int count); PICO_INTERNAL_ASM void memcpy32(int *dest, int *src, int count); // 32bit word count PICO_INTERNAL_ASM void memset32(int *dest, int c, int count); +// eeprom.c +void EEPROM_write8(unsigned int a, unsigned int d); +void EEPROM_write16(unsigned int d); +unsigned int EEPROM_read(void); + // z80 functionality wrappers PICO_INTERNAL void z80_init(void); PICO_INTERNAL void z80_pack(unsigned char *data); @@ -574,6 +647,35 @@ void PicoMemSetupMS(void); void PicoFrameMS(void); void PicoFrameDrawOnlyMS(void); +// 32x/32x.c +extern struct Pico32x Pico32x; +void Pico32xInit(void); +void PicoPower32x(void); +void PicoReset32x(void); +void Pico32xStartup(void); +void PicoUnload32x(void); +void PicoFrame32x(void); +void p32x_update_irls(void); + +// 32x/memory.c +struct Pico32xMem *Pico32xMem; +unsigned int PicoRead8_32x(unsigned int a); +unsigned int PicoRead16_32x(unsigned int a); +void PicoWrite8_32x(unsigned int a, unsigned int d); +void PicoWrite16_32x(unsigned int a, unsigned int d); +void PicoMemSetup32x(void); +void Pico32xSwapDRAM(int b); +void p32x_poll_event(int is_vdp); + +// 32x/draw.c +void FinalizeLine32xRGB555(int sh, int line); + +/* avoid dependency on newer glibc */ +static __inline int isspace_(int c) +{ + return (0x09 <= c && c <= 0x0d) || c == ' '; +} + // emulation event logging #ifndef EL_LOGMASK #define EL_LOGMASK 0 @@ -598,6 +700,7 @@ void PicoFrameDrawOnlyMS(void); #define EL_IDLE 0x00010000 /* idle loop det. */ #define EL_CDREGS 0x00020000 /* MCD: register access */ #define EL_CDREG3 0x00040000 /* MCD: register 3 only */ +#define EL_32X 0x00080000 #define EL_STATUS 0x40000000 /* status messages */ #define EL_ANOMALY 0x80000000 /* some unexpected conditions (during emulation) */ @@ -627,6 +730,12 @@ extern void lprintf(const char *fmt, ...); #define MEMH_FUNC #endif +#ifdef __GNUC__ +#define NOINLINE __attribute__((noinline)) +#else +#define NOINLINE +#endif + #ifdef __cplusplus } // End of extern "C" #endif