cc68a136 |
1 | \r |
2 | // -------------------- Pico Library --------------------\r |
3 | \r |
4 | // Pico Library - Header File\r |
5 | \r |
6 | // (c) Copyright 2004 Dave, All rights reserved.\r |
19954be1 |
7 | // (c) Copyright 2006-2009 notaz, All rights reserved.\r |
cc68a136 |
8 | // Free for non-commercial use.\r |
9 | \r |
10 | // For commercial use, separate licencing terms must be obtained.\r |
11 | \r |
12 | #ifndef PICO_H\r |
13 | #define PICO_H\r |
14 | \r |
21ebcfd3 |
15 | #include <stdlib.h> // size_t\r |
eff55556 |
16 | \r |
cc68a136 |
17 | // port-specific compile-time settings\r |
18 | #include <port_config.h>\r |
19 | \r |
20 | #ifdef __cplusplus\r |
21 | extern "C" {\r |
22 | #endif\r |
23 | \r |
75736070 |
24 | // external funcs for Sega/Mega CD\r |
7c18e34a |
25 | extern int mp3_get_bitrate(void *f, int size);\r |
26 | extern void mp3_start_play(void *f, int pos);\r |
84100c0f |
27 | extern void mp3_update(int *buffer, int length, int stereo);\r |
28 | \r |
29 | // this function should write-back d-cache and invalidate i-cache\r |
30 | // on a mem region [start_addr, end_addr)\r |
b081408f |
31 | // used by dynarecs\r |
84100c0f |
32 | extern void cache_flush_d_inval_i(const void *start_addr, const void *end_addr);\r |
cb0316e4 |
33 | \r |
b081408f |
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 |
b4db550e |
37 | extern void *plat_mremap(void *ptr, size_t oldsize, size_t newsize);\r |
b081408f |
38 | extern void plat_munmap(void *ptr, size_t size);\r |
39 | \r |
19954be1 |
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 |
42 | \r |
ae87bffa |
43 | // this must switch to 16bpp mode\r |
974fdb5b |
44 | extern void emu_32x_startup(void);\r |
45 | \r |
83ff19ec |
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 |
49 | \r |
cc68a136 |
50 | // Pico.c\r |
602133e1 |
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 |
2aa27095 |
57 | // unused (1<< 6)\r |
602133e1 |
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 |
381eea9b |
69 | #define POPT_DIS_SPRITE_LIM (1<<18)\r |
053fd9b4 |
70 | #define POPT_DIS_IDLE_DET (1<<19)\r |
db1d3564 |
71 | #define POPT_EN_32X (1<<20)\r |
72 | #define POPT_EN_PWM (1<<21)\r |
602133e1 |
73 | extern int PicoOpt; // bitfield\r |
be2c4208 |
74 | \r |
fa22af4c |
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 |
3e49ffd0 |
79 | #define PAHW_SMS (1<<4)\r |
fa22af4c |
80 | extern int PicoAHW; // Pico active hw\r |
fa22af4c |
81 | extern int PicoSkipFrame; // skip rendering frame, but still do sound (if enabled) and emulation stuff\r |
cc68a136 |
82 | extern int PicoRegionOverride; // override the region detection 0: auto, 1: Japan NTSC, 2: Japan PAL, 4: US, 8: Europe\r |
fa22af4c |
83 | extern int PicoAutoRgnOrder; // packed priority list of regions, for example 0x148 means this detection order: EUR, USA, JAP\r |
0ffefdb8 |
84 | extern int PicoSVPCycles;\r |
2aa27095 |
85 | void PicoInit(void);\r |
cc68a136 |
86 | void PicoExit(void);\r |
1cb1584b |
87 | void PicoPower(void);\r |
88 | int PicoReset(void);\r |
5e128c6d |
89 | void PicoLoopPrepare(void);\r |
2aa27095 |
90 | void PicoFrame(void);\r |
a12e0116 |
91 | void PicoFrameDrawOnly(void);\r |
cc68a136 |
92 | extern int PicoPad[2]; // Joypads, format is MXYZ SACB RLDU\r |
a4edca53 |
93 | extern void (*PicoWriteSound)(int bytes); // called once per frame at the best time to send sound buffer (PsndOut) to hardware\r |
66fdc0f0 |
94 | extern void (*PicoMessage)(const char *msg); // callback to output text message from emu\r |
4609d0cd |
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 |
cc68a136 |
98 | \r |
721cd396 |
99 | // cd/Pico.c\r |
721cd396 |
100 | extern void (*PicoMCDopenTray)(void);\r |
d687ef50 |
101 | extern void (*PicoMCDcloseTray)(void);\r |
0a051f55 |
102 | extern int PicoCDBuffers;\r |
103 | \r |
f3a57b2d |
104 | // pico.c\r |
ed367a3f |
105 | #define XPCM_BUFFER_SIZE (320+160)\r |
d49b10c2 |
106 | typedef struct\r |
107 | {\r |
108 | int pen_pos[2];\r |
109 | int page;\r |
110 | // internal\r |
fa22af4c |
111 | int fifo_bytes; // bytes in FIFO\r |
112 | int fifo_bytes_prev;\r |
ef4eb506 |
113 | int fifo_line_bytes; // float part, << 16\r |
d49b10c2 |
114 | int line_counter;\r |
ef4eb506 |
115 | unsigned short r1, r12;\r |
116 | unsigned char xpcm_buffer[XPCM_BUFFER_SIZE+4];\r |
117 | unsigned char *xpcm_ptr;\r |
d49b10c2 |
118 | } picohw_state;\r |
119 | extern picohw_state PicoPicohw;\r |
406c96c5 |
120 | \r |
bcc9eda0 |
121 | // area.c\r |
122 | int PicoState(const char *fname, int is_save);\r |
b4db550e |
123 | int PicoStateLoadGfx(const char *fname);\r |
124 | void *PicoTmpStateSave(void);\r |
125 | void PicoTmpStateRestore(void *data);\r |
76276b0b |
126 | extern void (*PicoStateProgressCB)(const char *str);\r |
cc68a136 |
127 | \r |
0a051f55 |
128 | // cd/buffering.c\r |
129 | void PicoCDBufferInit(void);\r |
130 | void PicoCDBufferFree(void);\r |
c9e1affc |
131 | void PicoCDBufferFlush(void);\r |
0a051f55 |
132 | \r |
eff55556 |
133 | // cd/cd_sys.c\r |
35e3031a |
134 | int Insert_CD(const char *cdimg_name, int type);\r |
eff55556 |
135 | void Stop_CD(void); // releases all resources taken when CD game was started.\r |
136 | \r |
cc68a136 |
137 | // Cart.c\r |
83bd0b76 |
138 | typedef enum\r |
139 | {\r |
140 | PMT_UNCOMPRESSED = 0,\r |
71de3cd9 |
141 | PMT_ZIP,\r |
142 | PMT_CSO\r |
83bd0b76 |
143 | } pm_type;\r |
144 | typedef struct\r |
145 | {\r |
146 | void *file; /* file handle */\r |
147 | void *param; /* additional file related field */\r |
148 | unsigned int size; /* size */\r |
149 | pm_type type;\r |
87b0845f |
150 | char ext[4];\r |
83bd0b76 |
151 | } pm_file;\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 |
3e49ffd0 |
156 | int PicoCartLoad(pm_file *f,unsigned char **prom,unsigned int *psize,int is_sms);\r |
ae87bffa |
157 | int PicoCartInsert(unsigned char *rom, unsigned int romsize, const char *carthw_cfg);\r |
2aa27095 |
158 | void PicoCartUnload(void);\r |
a9b3ffd3 |
159 | extern void (*PicoCartLoadProgressCB)(int percent);\r |
b2451ac6 |
160 | extern void (*PicoCDLoadProgressCB)(const char *fname, int percent);\r |
cc68a136 |
161 | \r |
162 | // Draw.c\r |
5a681086 |
163 | // for line-based renderer, set conversion\r |
164 | // from internal 8 bit representation in 'HighCol' to:\r |
165 | typedef enum\r |
166 | {\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 |
170 | } pdso_t;\r |
171 | void PicoDrawSetOutFormat(pdso_t which, int allow_32x);\r |
172 | void PicoDrawSetOutBuf(void *dest, int increment);\r |
f4750ee0 |
173 | void PicoDrawSetCallbacks(int (*begin)(unsigned int num), int (*end)(unsigned int num));\r |
cc68a136 |
174 | extern void *DrawLineDest;\r |
ea8c405f |
175 | extern unsigned char *HighCol;\r |
cc68a136 |
176 | // utility\r |
177 | #ifdef _ASM_DRAW_C\r |
ea8c405f |
178 | void vidConvCpyRGB565(void *to, void *from, int pixels);\r |
cc68a136 |
179 | #endif\r |
e55f0cbb |
180 | void PicoDoHighPal555(int sh);\r |
fbc65db7 |
181 | extern int PicoDrawMask;\r |
182 | #define PDRAW_LAYERB_ON (1<<2)\r |
183 | #define PDRAW_LAYERA_ON (1<<3)\r |
184 | #define PDRAW_SPRITES_LOW_ON (1<<4)\r |
185 | #define PDRAW_SPRITES_HI_ON (1<<7)\r |
5e49c3a8 |
186 | #define PDRAW_32X_ON (1<<8)\r |
602133e1 |
187 | // internals\r |
947fb5f9 |
188 | #define PDRAW_SPRITES_MOVED (1<<0) // (asm)\r |
602133e1 |
189 | #define PDRAW_WND_DIFF_PRIO (1<<1) // not all window tiles use same priority\r |
f8af9634 |
190 | #define PDRAW_SPR_LO_ON_HI (1<<2) // seen sprites without layer pri bit ontop spr. with that bit\r |
947fb5f9 |
191 | #define PDRAW_INTERLACE (1<<3)\r |
192 | #define PDRAW_DIRTY_SPRITES (1<<4) // (asm)\r |
602133e1 |
193 | #define PDRAW_SONIC_MODE (1<<5) // mid-frame palette changes for 8bit renderer\r |
194 | #define PDRAW_PLANE_HI_PRIO (1<<6) // have layer with all hi prio tiles (mk3)\r |
195 | #define PDRAW_SHHI_DONE (1<<7) // layer sh/hi already processed\r |
ae87bffa |
196 | #define PDRAW_32_COLS (1<<8) // 32 column mode\r |
19954be1 |
197 | extern int rendstatus, rendstatus_old;\r |
ae87bffa |
198 | extern int rendlines;\r |
602133e1 |
199 | extern unsigned short HighPal[0x100];\r |
cc68a136 |
200 | \r |
5a681086 |
201 | // draw.c\r |
202 | void PicoDrawUpdateHighPal(void);\r |
203 | void PicoDrawSetInternalBuf(void *dest, int line_increment);\r |
204 | \r |
205 | // draw2.c\r |
cc68a136 |
206 | // stuff below is optional\r |
8e5427a0 |
207 | extern unsigned char *PicoDraw2FB; // buffer for fast renderer in format (8+320)x(8+224+8) (eights for borders)\r |
cc68a136 |
208 | extern unsigned short *PicoCramHigh; // pointer to CRAM buff (0x40 shorts), converted to native device color (works only with 16bit for now)\r |
209 | extern void (*PicoPrepareCram)(); // prepares PicoCramHigh for renderer to use\r |
210 | \r |
f3a57b2d |
211 | // pico.c (32x)\r |
fcdefcf6 |
212 | // multipliers against 68k clock\r |
213 | extern int p32x_msh2_multiplier;\r |
214 | extern int p32x_ssh2_multiplier;\r |
215 | #define SH2_MULTI_SHIFT 10\r |
216 | #define MSH2_MULTI_DEFAULT ((1 << SH2_MULTI_SHIFT) * 3 / 2)\r |
217 | #define SSH2_MULTI_DEFAULT ((1 << SH2_MULTI_SHIFT) * 3 / 2)\r |
218 | \r |
5a681086 |
219 | // 32x/draw.c\r |
220 | void PicoDraw32xSetFrameMode(int is_on, int only_32x);\r |
5a681086 |
221 | \r |
cc68a136 |
222 | // sound.c\r |
223 | extern int PsndRate,PsndLen;\r |
224 | extern short *PsndOut;\r |
4a32f01f |
225 | extern void (*PsndMix_32_to_16l)(short *dest, int *src, int count);\r |
9d917eea |
226 | void PsndRerate(int preserve_state);\r |
cc68a136 |
227 | \r |
228 | // Utils.c\r |
229 | extern int PicuAnd;\r |
230 | int PicuQuick(unsigned short *dest,unsigned short *src);\r |
231 | int PicuShrink(unsigned short *dest,int destLen,unsigned short *src,int srcLen);\r |
232 | int PicuShrinkReverse(unsigned short *dest,int destLen,unsigned short *src,int srcLen);\r |
233 | int PicuMerge(unsigned short *dest,int destLen,unsigned short *src,int srcLen);\r |
234 | \r |
235 | #ifdef __cplusplus\r |
236 | } // End of extern "C"\r |
237 | #endif\r |
238 | \r |
239 | #endif // PICO_H\r |