X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=pico%2Fpico_int.h;h=4367a6e8050c0f0868cf16f191a8eca4af4fd10e;hb=be20816c4c487c4b114aa444b1a5819d5785b118;hp=cb12bc10c1fdbf84cf9eaf8560735aa15532e45b;hpb=45f2f245f51ef0c0d37df3c998595c132bfcaffa;p=picodrive.git diff --git a/pico/pico_int.h b/pico/pico_int.h index cb12bc1..4367a6e 100644 --- a/pico/pico_int.h +++ b/pico/pico_int.h @@ -1,7 +1,7 @@ // Pico Library - Internal Header File // (c) Copyright 2004 Dave, All rights reserved. -// (c) Copyright 2006-2008 Grazvydas "notaz" Ignotas, all rights reserved. +// (c) Copyright 2006-2009 Grazvydas "notaz" Ignotas, all rights reserved. // Free for non-commercial use. // For commercial use, separate licencing terms must be obtained. @@ -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_end_run(after) sh2_icount = after +#define ash2_cycles_done() (10000 - sh2_icount) // HACK + +#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 @@ -257,15 +271,15 @@ struct PicoMisc unsigned char pal; // 08 1=PAL 0=NTSC 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 pad0; - 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 cycle number unsigned char eeprom_slave; // EEPROM slave word for X24C02 and better SRAMs unsigned char eeprom_status; - unsigned char pad1; + unsigned char pad2; unsigned short dma_xfers; // 18 unsigned char eeprom_wb[2]; // EEPROM latch/write buffer unsigned int frame_count; // 1c for movies and idle det @@ -385,8 +399,76 @@ 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) // DREQ FIFO full +#define P32XS_68S (1<< 2) +#define P32XS_DMA (1<< 1) +#define P32XS_RV (1<< 0) + +#define P32XV_nPAL (1<<15) // VDP +#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 P32XP_FULL (1<<15) // PWM +#define P32XP_EMPTY (1<<14) + +#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) +#define PWM_BUFF_LEN 1024 // in one channel samples + +struct Pico32x +{ + unsigned short regs[0x20]; + unsigned short vdp_regs[0x10]; + unsigned short sh2_regs[3]; + unsigned char pending_fb; + unsigned char dirty_pal; + 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; + unsigned int pwm_irq_sample_cnt; +}; + +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 data_array[2][0x1000]; // cache in SH2s (can be used as RAM) + 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 + signed short pwm[2*PWM_BUFF_LEN]; // PWM buffer for current frame +}; // area.c PICO_INTERNAL void PicoAreaPackCpu(unsigned char *cpu, int is_sub); @@ -427,7 +509,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]; @@ -442,8 +524,6 @@ 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); unsigned int PicoRead8_io(unsigned int a); unsigned int PicoRead16_io(unsigned int a); @@ -455,14 +535,14 @@ 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; extern struct PicoSRAM SRam; extern int PicoPadInt[2]; extern int emustatus; +extern int scanlines_total; extern void (*PicoResetHook)(void); extern void (*PicoLineHook)(void); PICO_INTERNAL int CheckDMA(void); @@ -576,6 +656,37 @@ 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 cpu_mask, int is_vdp); + +// 32x/draw.c +void FinalizeLine32xRGB555(int sh, int line); + +// 32x/pwm.c +unsigned int p32x_pwm_read16(unsigned int a); +void p32x_pwm_write16(unsigned int a, unsigned int d); +void p32x_pwm_refresh(void); +void p32x_pwm_irq_check(int new_line); +void p32x_pwm_update(int *buf32, int length, int stereo); +extern int pwm_frame_smp_cnt; + /* avoid dependency on newer glibc */ static __inline int isspace_(int c) { @@ -606,6 +717,7 @@ static __inline int isspace_(int c) #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) */ @@ -635,6 +747,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