2 // -------------------- Pico Library --------------------
\r
4 // Pico Library - Header File
\r
6 // (c) Copyright 2004 Dave, All rights reserved.
\r
7 // (c) Copyright 2006-2009 notaz, All rights reserved.
\r
8 // Free for non-commercial use.
\r
10 // For commercial use, separate licencing terms must be obtained.
\r
17 // port-specific compile-time settings
\r
18 #include <port_config.h>
\r
24 // external funcs for Sega/Mega CD
\r
25 extern int mp3_get_bitrate(FILE *f, int size);
\r
26 extern void mp3_start_play(FILE *f, int pos);
\r
27 extern void mp3_update(int *buffer, int length, int stereo);
\r
29 // this function should write-back d-cache and invalidate i-cache
\r
30 // on a mem region [start_addr, end_addr)
\r
32 extern void cache_flush_d_inval_i(const void *start_addr, const void *end_addr);
\r
34 // attempt to alloc mem at specified address.
\r
35 // alloc anywhere else if that fails (callers should handle that)
\r
36 extern void *plat_mmap(unsigned long addr, size_t size);
\r
37 extern void *plat_mremap(void *ptr, size_t oldsize, size_t newsize);
\r
38 extern void plat_munmap(void *ptr, size_t size);
\r
40 // this one should handle display mode changes
\r
41 extern void emu_video_mode_change(int start_line, int line_count, int is_32cols);
\r
43 // this must switch to 16bpp mode
\r
44 extern void emu_32x_startup(void);
\r
46 // optional 32X BIOS, should be left NULL if not used
\r
47 // must be 256, 2048, 1024 bytes
\r
48 extern void *p32x_bios_g, *p32x_bios_m, *p32x_bios_s;
\r
51 #define POPT_EN_FM (1<< 0) // 00 000x
\r
52 #define POPT_EN_PSG (1<< 1)
\r
53 #define POPT_EN_Z80 (1<< 2)
\r
54 #define POPT_EN_STEREO (1<< 3)
\r
55 #define POPT_ALT_RENDERER (1<< 4) // 00 00x0
\r
56 #define POPT_6BTN_PAD (1<< 5)
\r
58 #define POPT_ACC_SPRITES (1<< 7)
\r
59 #define POPT_DIS_32C_BORDER (1<< 8) // 00 0x00
\r
60 #define POPT_EXT_FM (1<< 9)
\r
61 #define POPT_EN_MCD_PCM (1<<10)
\r
62 #define POPT_EN_MCD_CDDA (1<<11)
\r
63 #define POPT_EN_MCD_GFX (1<<12) // 00 x000
\r
64 #define POPT_EN_MCD_PSYNC (1<<13)
\r
65 #define POPT_EN_SOFTSCALE (1<<14)
\r
66 #define POPT_EN_MCD_RAMCART (1<<15)
\r
67 #define POPT_DIS_VDP_FIFO (1<<16) // 0x 0000
\r
68 #define POPT_EN_SVP_DRC (1<<17)
\r
69 #define POPT_DIS_SPRITE_LIM (1<<18)
\r
70 #define POPT_DIS_IDLE_DET (1<<19)
\r
71 #define POPT_EN_32X (1<<20)
\r
72 #define POPT_EN_PWM (1<<21)
\r
73 extern int PicoOpt; // bitfield
\r
75 #define PAHW_MCD (1<<0)
\r
76 #define PAHW_32X (1<<1)
\r
77 #define PAHW_SVP (1<<2)
\r
78 #define PAHW_PICO (1<<3)
\r
79 #define PAHW_SMS (1<<4)
\r
80 extern int PicoAHW; // Pico active hw
\r
81 extern int PicoSkipFrame; // skip rendering frame, but still do sound (if enabled) and emulation stuff
\r
82 extern int PicoRegionOverride; // override the region detection 0: auto, 1: Japan NTSC, 2: Japan PAL, 4: US, 8: Europe
\r
83 extern int PicoAutoRgnOrder; // packed priority list of regions, for example 0x148 means this detection order: EUR, USA, JAP
\r
84 extern int PicoSVPCycles;
\r
85 void PicoInit(void);
\r
86 void PicoExit(void);
\r
87 void PicoPower(void);
\r
88 int PicoReset(void);
\r
89 void PicoLoopPrepare(void);
\r
90 void PicoFrame(void);
\r
91 void PicoFrameDrawOnly(void);
\r
92 extern int PicoPad[2]; // Joypads, format is MXYZ SACB RLDU
\r
93 extern void (*PicoWriteSound)(int len); // called once per frame at the best time to send sound buffer (PsndOut) to hardware
\r
94 extern void (*PicoMessage)(const char *msg); // callback to output text message from emu
\r
95 typedef enum { PI_ROM, PI_ISPAL, PI_IS40_CELL, PI_IS240_LINES } pint_t;
\r
96 typedef union { int vint; void *vptr; } pint_ret_t;
\r
97 void PicoGetInternal(pint_t which, pint_ret_t *ret);
\r
100 extern void (*PicoMCDopenTray)(void);
\r
101 extern void (*PicoMCDcloseTray)(void);
\r
102 extern int PicoCDBuffers;
\r
105 #define XPCM_BUFFER_SIZE (320+160)
\r
111 int fifo_bytes; // bytes in FIFO
\r
112 int fifo_bytes_prev;
\r
113 int fifo_line_bytes; // float part, << 16
\r
115 unsigned short r1, r12;
\r
116 unsigned char xpcm_buffer[XPCM_BUFFER_SIZE+4];
\r
117 unsigned char *xpcm_ptr;
\r
119 extern picohw_state PicoPicohw;
\r
122 int PicoState(const char *fname, int is_save);
\r
123 int PicoStateLoadGfx(const char *fname);
\r
124 void *PicoTmpStateSave(void);
\r
125 void PicoTmpStateRestore(void *data);
\r
126 extern void (*PicoStateProgressCB)(const char *str);
\r
129 void PicoCDBufferInit(void);
\r
130 void PicoCDBufferFree(void);
\r
131 void PicoCDBufferFlush(void);
\r
134 int Insert_CD(const char *cdimg_name, int type);
\r
135 void Stop_CD(void); // releases all resources taken when CD game was started.
\r
140 PMT_UNCOMPRESSED = 0,
\r
146 void *file; /* file handle */
\r
147 void *param; /* additional file related field */
\r
148 unsigned int size; /* size */
\r
152 pm_file *pm_open(const char *path);
\r
153 size_t pm_read(void *ptr, size_t bytes, pm_file *stream);
\r
154 int pm_seek(pm_file *stream, long offset, int whence);
\r
155 int pm_close(pm_file *fp);
\r
156 int PicoCartLoad(pm_file *f,unsigned char **prom,unsigned int *psize,int is_sms);
\r
157 int PicoCartInsert(unsigned char *rom, unsigned int romsize, const char *carthw_cfg);
\r
158 void PicoCartUnload(void);
\r
159 extern void (*PicoCartLoadProgressCB)(int percent);
\r
160 extern void (*PicoCDLoadProgressCB)(const char *fname, int percent);
\r
163 // for line-based renderer, set conversion
\r
164 // from internal 8 bit representation in 'HighCol' to:
\r
167 PDF_NONE = 0, // no conversion
\r
168 PDF_RGB555, // RGB/BGR output, depends on compile options
\r
169 PDF_8BIT, // 8-bit out (handles shadow/hilight mode, sonic water)
\r
171 void PicoDrawSetOutFormat(pdso_t which, int allow_32x);
\r
172 void PicoDrawSetOutBuf(void *dest, int increment);
\r
173 extern void *DrawLineDest;
\r
174 extern unsigned char *HighCol;
\r
175 extern int (*PicoScanBegin)(unsigned int num);
\r
176 extern int (*PicoScanEnd)(unsigned int num);
\r
179 void vidConvCpyRGB565(void *to, void *from, int pixels);
\r
181 void PicoDoHighPal555(int sh);
\r
182 extern int PicoDrawMask;
\r
183 #define PDRAW_LAYERB_ON (1<<2)
\r
184 #define PDRAW_LAYERA_ON (1<<3)
\r
185 #define PDRAW_SPRITES_LOW_ON (1<<4)
\r
186 #define PDRAW_SPRITES_HI_ON (1<<7)
\r
187 #define PDRAW_32X_ON (1<<8)
\r
189 #define PDRAW_SPRITES_MOVED (1<<0) // (asm)
\r
190 #define PDRAW_WND_DIFF_PRIO (1<<1) // not all window tiles use same priority
\r
191 #define PDRAW_SPR_LO_ON_HI (1<<2) // seen sprites without layer pri bit ontop spr. with that bit
\r
192 #define PDRAW_INTERLACE (1<<3)
\r
193 #define PDRAW_DIRTY_SPRITES (1<<4) // (asm)
\r
194 #define PDRAW_SONIC_MODE (1<<5) // mid-frame palette changes for 8bit renderer
\r
195 #define PDRAW_PLANE_HI_PRIO (1<<6) // have layer with all hi prio tiles (mk3)
\r
196 #define PDRAW_SHHI_DONE (1<<7) // layer sh/hi already processed
\r
197 #define PDRAW_32_COLS (1<<8) // 32 column mode
\r
198 extern int rendstatus, rendstatus_old;
\r
199 extern int rendlines;
\r
200 extern unsigned short HighPal[0x100];
\r
203 void PicoDrawUpdateHighPal(void);
\r
204 void PicoDrawSetInternalBuf(void *dest, int line_increment);
\r
207 // stuff below is optional
\r
208 extern unsigned char *PicoDraw2FB; // buffer for fast renderer in format (8+320)x(8+224+8) (eights for borders)
\r
209 extern unsigned short *PicoCramHigh; // pointer to CRAM buff (0x40 shorts), converted to native device color (works only with 16bit for now)
\r
210 extern void (*PicoPrepareCram)(); // prepares PicoCramHigh for renderer to use
\r
213 // multipliers against 68k clock
\r
214 extern int p32x_msh2_multiplier;
\r
215 extern int p32x_ssh2_multiplier;
\r
216 #define SH2_MULTI_SHIFT 10
\r
217 #define MSH2_MULTI_DEFAULT ((1 << SH2_MULTI_SHIFT) * 3 / 2)
\r
218 #define SSH2_MULTI_DEFAULT ((1 << SH2_MULTI_SHIFT) * 3 / 2)
\r
221 void PicoDraw32xSetFrameMode(int is_on, int only_32x);
\r
222 extern int (*PicoScan32xBegin)(unsigned int num);
\r
223 extern int (*PicoScan32xEnd)(unsigned int num);
\r
226 extern int PsndRate,PsndLen;
\r
227 extern short *PsndOut;
\r
228 extern void (*PsndMix_32_to_16l)(short *dest, int *src, int count);
\r
229 void PsndRerate(int preserve_state);
\r
232 extern int PicuAnd;
\r
233 int PicuQuick(unsigned short *dest,unsigned short *src);
\r
234 int PicuShrink(unsigned short *dest,int destLen,unsigned short *src,int srcLen);
\r
235 int PicuShrinkReverse(unsigned short *dest,int destLen,unsigned short *src,int srcLen);
\r
236 int PicuMerge(unsigned short *dest,int destLen,unsigned short *src,int srcLen);
\r
239 } // End of extern "C"
\r