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 |
602133e1 |
7 | // (c) Copyright 2006-2008 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 |
eff55556 |
15 | #include <stdio.h>\r |
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 |
84100c0f |
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 |
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 |
31 | // used by SVP dynarec\r |
32 | extern void cache_flush_d_inval_i(const void *start_addr, const void *end_addr);\r |
cb0316e4 |
33 | \r |
cc68a136 |
34 | // Pico.c\r |
602133e1 |
35 | #define POPT_EN_FM (1<< 0) // 00 000x\r |
36 | #define POPT_EN_PSG (1<< 1)\r |
37 | #define POPT_EN_Z80 (1<< 2)\r |
38 | #define POPT_EN_STEREO (1<< 3)\r |
39 | #define POPT_ALT_RENDERER (1<< 4) // 00 00x0\r |
40 | #define POPT_6BTN_PAD (1<< 5)\r |
2aa27095 |
41 | // unused (1<< 6)\r |
602133e1 |
42 | #define POPT_ACC_SPRITES (1<< 7)\r |
43 | #define POPT_DIS_32C_BORDER (1<< 8) // 00 0x00\r |
44 | #define POPT_EXT_FM (1<< 9)\r |
45 | #define POPT_EN_MCD_PCM (1<<10)\r |
46 | #define POPT_EN_MCD_CDDA (1<<11)\r |
47 | #define POPT_EN_MCD_GFX (1<<12) // 00 x000\r |
48 | #define POPT_EN_MCD_PSYNC (1<<13)\r |
49 | #define POPT_EN_SOFTSCALE (1<<14)\r |
50 | #define POPT_EN_MCD_RAMCART (1<<15)\r |
51 | #define POPT_DIS_VDP_FIFO (1<<16) // 0x 0000\r |
52 | #define POPT_EN_SVP_DRC (1<<17)\r |
381eea9b |
53 | #define POPT_DIS_SPRITE_LIM (1<<18)\r |
053fd9b4 |
54 | #define POPT_DIS_IDLE_DET (1<<19)\r |
602133e1 |
55 | extern int PicoOpt; // bitfield\r |
fa22af4c |
56 | #define PAHW_MCD (1<<0)\r |
57 | #define PAHW_32X (1<<1)\r |
58 | #define PAHW_SVP (1<<2)\r |
59 | #define PAHW_PICO (1<<3)\r |
60 | extern int PicoAHW; // Pico active hw\r |
cc68a136 |
61 | extern int PicoVer;\r |
fa22af4c |
62 | extern int PicoSkipFrame; // skip rendering frame, but still do sound (if enabled) and emulation stuff\r |
cc68a136 |
63 | extern int PicoRegionOverride; // override the region detection 0: auto, 1: Japan NTSC, 2: Japan PAL, 4: US, 8: Europe\r |
fa22af4c |
64 | extern int PicoAutoRgnOrder; // packed priority list of regions, for example 0x148 means this detection order: EUR, USA, JAP\r |
0ffefdb8 |
65 | extern int PicoSVPCycles;\r |
2aa27095 |
66 | void PicoInit(void);\r |
cc68a136 |
67 | void PicoExit(void);\r |
1cb1584b |
68 | void PicoPower(void);\r |
69 | int PicoReset(void);\r |
2aa27095 |
70 | void PicoFrame(void);\r |
a12e0116 |
71 | void PicoFrameDrawOnly(void);\r |
cc68a136 |
72 | extern int PicoPad[2]; // Joypads, format is MXYZ SACB RLDU\r |
7a93adeb |
73 | extern void (*PicoWriteSound)(int len); // called once per frame at the best time to send sound buffer (PsndOut) to hardware\r |
66fdc0f0 |
74 | extern void (*PicoMessage)(const char *msg); // callback to output text message from emu\r |
4609d0cd |
75 | typedef enum { PI_ROM, PI_ISPAL, PI_IS40_CELL, PI_IS240_LINES } pint_t;\r |
76 | typedef union { int vint; void *vptr; } pint_ret_t;\r |
77 | void PicoGetInternal(pint_t which, pint_ret_t *ret);\r |
cc68a136 |
78 | \r |
721cd396 |
79 | // cd/Pico.c\r |
721cd396 |
80 | extern void (*PicoMCDopenTray)(void);\r |
81 | extern int (*PicoMCDcloseTray)(void);\r |
0a051f55 |
82 | extern int PicoCDBuffers;\r |
83 | \r |
406c96c5 |
84 | // Pico/Pico.c\r |
ed367a3f |
85 | #define XPCM_BUFFER_SIZE (320+160)\r |
d49b10c2 |
86 | typedef struct\r |
87 | {\r |
88 | int pen_pos[2];\r |
89 | int page;\r |
90 | // internal\r |
fa22af4c |
91 | int fifo_bytes; // bytes in FIFO\r |
92 | int fifo_bytes_prev;\r |
ef4eb506 |
93 | int fifo_line_bytes; // float part, << 16\r |
d49b10c2 |
94 | int line_counter;\r |
ef4eb506 |
95 | unsigned short r1, r12;\r |
96 | unsigned char xpcm_buffer[XPCM_BUFFER_SIZE+4];\r |
97 | unsigned char *xpcm_ptr;\r |
d49b10c2 |
98 | } picohw_state;\r |
99 | extern picohw_state PicoPicohw;\r |
406c96c5 |
100 | \r |
cc68a136 |
101 | // Area.c\r |
102 | typedef size_t (arearw)(void *p, size_t _size, size_t _n, void *file);\r |
51a902ae |
103 | typedef size_t (areaeof)(void *file);\r |
75736070 |
104 | typedef int (areaseek)(void *file, long offset, int whence);\r |
860c6322 |
105 | typedef int (areaclose)(void *file);\r |
cc68a136 |
106 | // Save or load the state from PmovFile:\r |
107 | int PmovState(int PmovAction, void *PmovFile); // &1=for reading &2=for writing &4=volatile &8=non-volatile\r |
51a902ae |
108 | extern arearw *areaRead; // external read and write function pointers for\r |
109 | extern arearw *areaWrite; // gzip save state ability\r |
110 | extern areaeof *areaEof;\r |
75736070 |
111 | extern areaseek *areaSeek;\r |
860c6322 |
112 | extern areaclose *areaClose;\r |
76276b0b |
113 | extern void (*PicoStateProgressCB)(const char *str);\r |
cc68a136 |
114 | \r |
eff55556 |
115 | // cd/Area.c\r |
2aa27095 |
116 | int PicoCdLoadStateGfx(void *file);\r |
eff55556 |
117 | \r |
0a051f55 |
118 | // cd/buffering.c\r |
119 | void PicoCDBufferInit(void);\r |
120 | void PicoCDBufferFree(void);\r |
c9e1affc |
121 | void PicoCDBufferFlush(void);\r |
0a051f55 |
122 | \r |
eff55556 |
123 | // cd/cd_sys.c\r |
b923ecbe |
124 | int Insert_CD(char *cdimg_name, int type);\r |
eff55556 |
125 | void Stop_CD(void); // releases all resources taken when CD game was started.\r |
126 | \r |
cc68a136 |
127 | // Cart.c\r |
83bd0b76 |
128 | typedef enum\r |
129 | {\r |
130 | PMT_UNCOMPRESSED = 0,\r |
71de3cd9 |
131 | PMT_ZIP,\r |
132 | PMT_CSO\r |
83bd0b76 |
133 | } pm_type;\r |
134 | typedef struct\r |
135 | {\r |
136 | void *file; /* file handle */\r |
137 | void *param; /* additional file related field */\r |
138 | unsigned int size; /* size */\r |
139 | pm_type type;\r |
140 | } pm_file;\r |
141 | pm_file *pm_open(const char *path);\r |
142 | size_t pm_read(void *ptr, size_t bytes, pm_file *stream);\r |
143 | int pm_seek(pm_file *stream, long offset, int whence);\r |
144 | int pm_close(pm_file *fp);\r |
145 | int PicoCartLoad(pm_file *f,unsigned char **prom,unsigned int *psize);\r |
cc68a136 |
146 | int PicoCartInsert(unsigned char *rom,unsigned int romsize);\r |
cc68a136 |
147 | void Byteswap(unsigned char *data,int len);\r |
2aa27095 |
148 | void PicoCartUnload(void);\r |
a9b3ffd3 |
149 | extern void (*PicoCartLoadProgressCB)(int percent);\r |
4b167c12 |
150 | extern void (*PicoCDLoadProgressCB)(int percent);\r |
cc68a136 |
151 | \r |
152 | // Draw.c\r |
153 | void PicoDrawSetColorFormat(int which); // 0=BGR444, 1=RGB555, 2=8bit(HighPal pal)\r |
154 | extern void *DrawLineDest;\r |
ea8c405f |
155 | #if OVERRIDE_HIGHCOL\r |
156 | extern unsigned char *HighCol;\r |
e55f0cbb |
157 | #else\r |
158 | extern unsigned char HighCol[8+320+8];\r |
ea8c405f |
159 | #endif\r |
602133e1 |
160 | extern int (*PicoScanBegin)(unsigned int num);\r |
161 | extern int (*PicoScanEnd)(unsigned int num);\r |
cc68a136 |
162 | // utility\r |
163 | #ifdef _ASM_DRAW_C\r |
ea8c405f |
164 | void vidConvCpyRGB565(void *to, void *from, int pixels);\r |
cc68a136 |
165 | #endif\r |
e55f0cbb |
166 | void PicoDoHighPal555(int sh);\r |
fbc65db7 |
167 | extern int PicoDrawMask;\r |
168 | #define PDRAW_LAYERB_ON (1<<2)\r |
169 | #define PDRAW_LAYERA_ON (1<<3)\r |
170 | #define PDRAW_SPRITES_LOW_ON (1<<4)\r |
171 | #define PDRAW_SPRITES_HI_ON (1<<7)\r |
602133e1 |
172 | // internals\r |
947fb5f9 |
173 | #define PDRAW_SPRITES_MOVED (1<<0) // (asm)\r |
602133e1 |
174 | #define PDRAW_WND_DIFF_PRIO (1<<1) // not all window tiles use same priority\r |
f8af9634 |
175 | #define PDRAW_SPR_LO_ON_HI (1<<2) // seen sprites without layer pri bit ontop spr. with that bit\r |
947fb5f9 |
176 | #define PDRAW_INTERLACE (1<<3)\r |
177 | #define PDRAW_DIRTY_SPRITES (1<<4) // (asm)\r |
602133e1 |
178 | #define PDRAW_SONIC_MODE (1<<5) // mid-frame palette changes for 8bit renderer\r |
179 | #define PDRAW_PLANE_HI_PRIO (1<<6) // have layer with all hi prio tiles (mk3)\r |
180 | #define PDRAW_SHHI_DONE (1<<7) // layer sh/hi already processed\r |
602133e1 |
181 | extern int rendstatus;\r |
182 | extern unsigned short HighPal[0x100];\r |
cc68a136 |
183 | \r |
184 | // Draw2.c\r |
185 | // stuff below is optional\r |
8e5427a0 |
186 | extern unsigned char *PicoDraw2FB; // buffer for fast renderer in format (8+320)x(8+224+8) (eights for borders)\r |
cc68a136 |
187 | extern unsigned short *PicoCramHigh; // pointer to CRAM buff (0x40 shorts), converted to native device color (works only with 16bit for now)\r |
188 | extern void (*PicoPrepareCram)(); // prepares PicoCramHigh for renderer to use\r |
189 | \r |
190 | // sound.c\r |
191 | extern int PsndRate,PsndLen;\r |
192 | extern short *PsndOut;\r |
4a32f01f |
193 | extern void (*PsndMix_32_to_16l)(short *dest, int *src, int count);\r |
9d917eea |
194 | void PsndRerate(int preserve_state);\r |
cc68a136 |
195 | \r |
196 | // Utils.c\r |
197 | extern int PicuAnd;\r |
198 | int PicuQuick(unsigned short *dest,unsigned short *src);\r |
199 | int PicuShrink(unsigned short *dest,int destLen,unsigned short *src,int srcLen);\r |
200 | int PicuShrinkReverse(unsigned short *dest,int destLen,unsigned short *src,int srcLen);\r |
201 | int PicuMerge(unsigned short *dest,int destLen,unsigned short *src,int srcLen);\r |
202 | \r |
203 | #ifdef __cplusplus\r |
204 | } // End of extern "C"\r |
205 | #endif\r |
206 | \r |
207 | #endif // PICO_H\r |