libretro: update for core changes
[picodrive.git] / pico / pico.h
... / ...
CommitLineData
1/*\r
2 * PicoDrive\r
3 * (c) Copyright Dave, 2004\r
4 * (C) notaz, 2006-2010\r
5 *\r
6 * This work is licensed under the terms of MAME license.\r
7 * See COPYING file in the top-level directory.\r
8 */\r
9\r
10#ifndef PICO_H\r
11#define PICO_H\r
12\r
13#include <stdlib.h> // size_t\r
14\r
15#ifdef __cplusplus\r
16extern "C" {\r
17#endif\r
18\r
19// message log\r
20extern void lprintf(const char *fmt, ...);\r
21\r
22// external funcs for Sega/Mega CD\r
23extern int mp3_get_bitrate(void *f, int size);\r
24extern void mp3_start_play(void *f, int pos);\r
25extern void mp3_update(int *buffer, int length, int stereo);\r
26\r
27// this function should write-back d-cache and invalidate i-cache\r
28// on a mem region [start_addr, end_addr)\r
29// used by dynarecs\r
30extern void cache_flush_d_inval_i(void *start_addr, void *end_addr);\r
31\r
32// attempt to alloc mem at specified address.\r
33// alloc anywhere else if that fails (callers should handle that)\r
34extern void *plat_mmap(unsigned long addr, size_t size, int need_exec, int is_fixed);\r
35extern void *plat_mremap(void *ptr, size_t oldsize, size_t newsize);\r
36extern void plat_munmap(void *ptr, size_t size);\r
37extern int plat_mem_set_exec(void *ptr, size_t size);\r
38\r
39// this one should handle display mode changes\r
40extern void emu_video_mode_change(int start_line, int line_count, int is_32cols);\r
41\r
42// this must switch to 16bpp mode\r
43extern void emu_32x_startup(void);\r
44\r
45// optional 32X BIOS, should be left NULL if not used\r
46// must be 256, 2048, 1024 bytes\r
47extern void *p32x_bios_g, *p32x_bios_m, *p32x_bios_s;\r
48\r
49// Pico.c\r
50#define POPT_EN_FM (1<< 0) // 00 000x\r
51#define POPT_EN_PSG (1<< 1)\r
52#define POPT_EN_Z80 (1<< 2)\r
53#define POPT_EN_STEREO (1<< 3)\r
54#define POPT_ALT_RENDERER (1<< 4) // 00 00x0\r
55// unused (1<< 5)\r
56// unused (1<< 6)\r
57#define POPT_ACC_SPRITES (1<< 7)\r
58#define POPT_DIS_32C_BORDER (1<< 8) // 00 0x00\r
59#define POPT_EXT_FM (1<< 9)\r
60#define POPT_EN_MCD_PCM (1<<10)\r
61#define POPT_EN_MCD_CDDA (1<<11)\r
62#define POPT_EN_MCD_GFX (1<<12) // 00 x000\r
63// unused (1<<13)\r
64#define POPT_EN_SOFTSCALE (1<<14)\r
65#define POPT_EN_MCD_RAMCART (1<<15)\r
66#define POPT_DIS_VDP_FIFO (1<<16) // 0x 0000\r
67#define POPT_EN_DRC (1<<17)\r
68#define POPT_DIS_SPRITE_LIM (1<<18)\r
69#define POPT_DIS_IDLE_DET (1<<19)\r
70#define POPT_EN_32X (1<<20)\r
71#define POPT_EN_PWM (1<<21)\r
72extern int PicoOpt; // bitfield\r
73\r
74#define PAHW_MCD (1<<0)\r
75#define PAHW_32X (1<<1)\r
76#define PAHW_SVP (1<<2)\r
77#define PAHW_PICO (1<<3)\r
78#define PAHW_SMS (1<<4)\r
79extern int PicoAHW; // Pico active hw\r
80\r
81#define PQUIRK_FORCE_6BTN (1<<0)\r
82extern int PicoQuirks;\r
83\r
84extern int PicoSkipFrame; // skip rendering frame, but still do sound (if enabled) and emulation stuff\r
85extern int PicoRegionOverride; // override the region detection 0: auto, 1: Japan NTSC, 2: Japan PAL, 4: US, 8: Europe\r
86extern int PicoAutoRgnOrder; // packed priority list of regions, for example 0x148 means this detection order: EUR, USA, JAP\r
87extern int PicoSVPCycles;\r
88void PicoInit(void);\r
89void PicoExit(void);\r
90void PicoPower(void);\r
91int PicoReset(void);\r
92void PicoLoopPrepare(void);\r
93void PicoFrame(void);\r
94void PicoFrameDrawOnly(void);\r
95extern int PicoPad[2]; // Joypads, format is MXYZ SACB RLDU\r
96extern void (*PicoWriteSound)(int bytes); // called once per frame at the best time to send sound buffer (PsndOut) to hardware\r
97extern void (*PicoMessage)(const char *msg); // callback to output text message from emu\r
98typedef enum { PI_ROM, PI_ISPAL, PI_IS40_CELL, PI_IS240_LINES } pint_t;\r
99typedef union { int vint; void *vptr; } pint_ret_t;\r
100void PicoGetInternal(pint_t which, pint_ret_t *ret);\r
101\r
102struct PicoEState;\r
103\r
104// cd/mcd.c\r
105extern void (*PicoMCDopenTray)(void);\r
106extern void (*PicoMCDcloseTray)(void);\r
107\r
108// pico.c\r
109#define XPCM_BUFFER_SIZE (320+160)\r
110typedef struct\r
111{\r
112 int pen_pos[2];\r
113 int page;\r
114 // internal\r
115 int fifo_bytes; // bytes in FIFO\r
116 int fifo_bytes_prev;\r
117 int fifo_line_bytes; // float part, << 16\r
118 int line_counter;\r
119 unsigned short r1, r12;\r
120 unsigned char xpcm_buffer[XPCM_BUFFER_SIZE+4];\r
121 unsigned char *xpcm_ptr;\r
122} picohw_state;\r
123extern picohw_state PicoPicohw;\r
124\r
125// area.c\r
126int PicoState(const char *fname, int is_save);\r
127int PicoStateLoadGfx(const char *fname);\r
128void *PicoTmpStateSave(void);\r
129void PicoTmpStateRestore(void *data);\r
130extern void (*PicoStateProgressCB)(const char *str);\r
131\r
132// cd/cdd.c\r
133int cdd_load(const char *filename, int type);\r
134int cdd_unload(void);\r
135\r
136// Cart.c\r
137typedef enum\r
138{\r
139 PMT_UNCOMPRESSED = 0,\r
140 PMT_ZIP,\r
141 PMT_CSO\r
142} pm_type;\r
143typedef struct\r
144{\r
145 void *file; /* file handle */\r
146 void *param; /* additional file related field */\r
147 unsigned int size; /* size */\r
148 pm_type type;\r
149 char ext[4];\r
150} pm_file;\r
151pm_file *pm_open(const char *path);\r
152size_t pm_read(void *ptr, size_t bytes, pm_file *stream);\r
153int pm_seek(pm_file *stream, long offset, int whence);\r
154int pm_close(pm_file *fp);\r
155int PicoCartLoad(pm_file *f,unsigned char **prom,unsigned int *psize,int is_sms);\r
156int PicoCartInsert(unsigned char *rom, unsigned int romsize, const char *carthw_cfg);\r
157void PicoCartUnload(void);\r
158extern void (*PicoCartLoadProgressCB)(int percent);\r
159extern void (*PicoCDLoadProgressCB)(const char *fname, int percent);\r
160extern int PicoGameLoaded;\r
161\r
162// Draw.c\r
163// for line-based renderer, set conversion\r
164// from internal 8 bit representation in 'HighCol' to:\r
165typedef 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
171void PicoDrawSetOutFormat(pdso_t which, int use_32x_line_mode);\r
172void PicoDrawSetOutBuf(void *dest, int increment);\r
173void PicoDrawSetCallbacks(int (*begin)(unsigned int num), int (*end)(unsigned int num));\r
174// utility\r
175#ifdef _ASM_DRAW_C\r
176void vidConvCpyRGB565(void *to, void *from, int pixels);\r
177#endif\r
178void PicoDoHighPal555(int sh, int line, struct PicoEState *est);\r
179// internals\r
180#define PDRAW_SPRITES_MOVED (1<<0) // (asm)\r
181#define PDRAW_WND_DIFF_PRIO (1<<1) // not all window tiles use same priority\r
182#define PDRAW_SPR_LO_ON_HI (1<<2) // seen sprites without layer pri bit ontop spr. with that bit\r
183#define PDRAW_INTERLACE (1<<3)\r
184#define PDRAW_DIRTY_SPRITES (1<<4) // (asm)\r
185#define PDRAW_SONIC_MODE (1<<5) // mid-frame palette changes for 8bit renderer\r
186#define PDRAW_PLANE_HI_PRIO (1<<6) // have layer with all hi prio tiles (mk3)\r
187#define PDRAW_SHHI_DONE (1<<7) // layer sh/hi already processed\r
188#define PDRAW_32_COLS (1<<8) // 32 column mode\r
189extern int rendstatus_old;\r
190extern int rendlines;\r
191\r
192// draw.c\r
193void PicoDrawUpdateHighPal(void);\r
194void PicoDrawSetInternalBuf(void *dest, int line_increment);\r
195\r
196// draw2.c\r
197// stuff below is optional\r
198extern unsigned short *PicoCramHigh; // pointer to CRAM buff (0x40 shorts), converted to native device color (works only with 16bit for now)\r
199extern void (*PicoPrepareCram)(); // prepares PicoCramHigh for renderer to use\r
200\r
201// pico.c (32x)\r
202#ifndef NO_32X\r
203\r
204void Pico32xSetClocks(int msh2_hz, int ssh2_hz);\r
205\r
206#else\r
207\r
208#define Pico32xSetClocks(msh2_khz, ssh2_khz)\r
209\r
210#endif\r
211\r
212// normally 68k clock (7670442) * 3, in reality but much lower\r
213// because of high memory latencies\r
214#define PICO_MSH2_HZ ((int)(7670442.0 * 2.4))\r
215#define PICO_SSH2_HZ ((int)(7670442.0 * 2.4))\r
216\r
217// sound.c\r
218extern int PsndRate,PsndLen;\r
219extern short *PsndOut;\r
220extern void (*PsndMix_32_to_16l)(short *dest, int *src, int count);\r
221void PsndRerate(int preserve_state);\r
222\r
223// media.c\r
224enum media_type_e {\r
225 PM_BAD_DETECT = -1,\r
226 PM_ERROR = -2,\r
227 PM_BAD_CD = -3,\r
228 PM_BAD_CD_NO_BIOS = -4,\r
229 PM_MD_CART = 1, /* also 32x */\r
230 PM_MARK3,\r
231 PM_CD,\r
232};\r
233\r
234enum cd_img_type\r
235{\r
236 CIT_NOT_CD = 0,\r
237 CIT_ISO,\r
238 CIT_BIN,\r
239 CIT_CUE\r
240};\r
241\r
242enum media_type_e PicoLoadMedia(const char *filename,\r
243 const char *carthw_cfg_fname,\r
244 const char *(*get_bios_filename)(int *region, const char *cd_fname),\r
245 void (*do_region_override)(const char *media_filename));\r
246int PicoCdCheck(const char *fname_in, int *pregion);\r
247\r
248extern unsigned char media_id_header[0x100];\r
249\r
250// memory.c\r
251enum input_device {\r
252 PICO_INPUT_NOTHING,\r
253 PICO_INPUT_PAD_3BTN,\r
254 PICO_INPUT_PAD_6BTN,\r
255};\r
256void PicoSetInputDevice(int port, enum input_device device);\r
257\r
258#ifdef __cplusplus\r
259} // End of extern "C"\r
260#endif\r
261\r
262#endif // PICO_H\r