eeprom crash fix, PacMan2 hack
[picodrive.git] / Pico / Pico.h
... / ...
CommitLineData
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
7// (c) Copyright 2006-2008 notaz, All rights reserved.\r
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
15#include <stdio.h>\r
16\r
17// port-specific compile-time settings\r
18#include <port_config.h>\r
19\r
20#ifdef __cplusplus\r
21extern "C" {\r
22#endif\r
23\r
24// external funcs for Sega/Mega CD\r
25int mp3_get_bitrate(FILE *f, int size);\r
26void mp3_start_play(FILE *f, int pos);\r
27int mp3_get_offset(void); // 0-1023\r
28void mp3_update(int *buffer, int length, int stereo);\r
29\r
30\r
31// Pico.c\r
32#define POPT_EN_FM (1<< 0) // 00 000x\r
33#define POPT_EN_PSG (1<< 1)\r
34#define POPT_EN_Z80 (1<< 2)\r
35#define POPT_EN_STEREO (1<< 3)\r
36#define POPT_ALT_RENDERER (1<< 4) // 00 00x0\r
37#define POPT_6BTN_PAD (1<< 5)\r
38#define POPT_ACC_TIMING (1<< 6)\r
39#define POPT_ACC_SPRITES (1<< 7)\r
40#define POPT_DIS_32C_BORDER (1<< 8) // 00 0x00\r
41#define POPT_EXT_FM (1<< 9)\r
42#define POPT_EN_MCD_PCM (1<<10)\r
43#define POPT_EN_MCD_CDDA (1<<11)\r
44#define POPT_EN_MCD_GFX (1<<12) // 00 x000\r
45#define POPT_EN_MCD_PSYNC (1<<13)\r
46#define POPT_EN_SOFTSCALE (1<<14)\r
47#define POPT_EN_MCD_RAMCART (1<<15)\r
48#define POPT_DIS_VDP_FIFO (1<<16) // 0x 0000\r
49#define POPT_EN_SVP_DRC (1<<17)\r
50#define POPT_DIS_SPRITE_LIM (1<<18)\r
51extern int PicoOpt; // bitfield\r
52extern int PicoVer;\r
53extern int PicoSkipFrame; // skip rendering frame, but still do sound (if enabled) and emulation stuff\r
54extern int PicoRegionOverride; // override the region detection 0: auto, 1: Japan NTSC, 2: Japan PAL, 4: US, 8: Europe\r
55extern int PicoAutoRgnOrder; // packed priority list of regions, for example 0x148 means this detection order: EUR, USA, JAP\r
56extern int PicoSVPCycles;\r
57int PicoInit(void);\r
58void PicoExit(void);\r
59void PicoPower(void);\r
60int PicoReset(void);\r
61int PicoFrame(void);\r
62void PicoFrameDrawOnly(void);\r
63extern int PicoPad[2]; // Joypads, format is MXYZ SACB RLDU\r
64extern void (*PicoWriteSound)(int len); // called once per frame at the best time to send sound buffer (PsndOut) to hardware\r
65extern void (*PicoMessage)(const char *msg); // callback to output text message from emu\r
66typedef enum { PS_PAL, PS_40_CELL, PS_240_LINES } pstat_t;\r
67int PicoGetStat(pstat_t which);\r
68\r
69// cd/Pico.c\r
70extern void (*PicoMCDopenTray)(void);\r
71extern int (*PicoMCDcloseTray)(void);\r
72extern int PicoCDBuffers;\r
73\r
74// Area.c\r
75typedef size_t (arearw)(void *p, size_t _size, size_t _n, void *file);\r
76typedef size_t (areaeof)(void *file);\r
77typedef int (areaseek)(void *file, long offset, int whence);\r
78typedef int (areaclose)(void *file);\r
79// Save or load the state from PmovFile:\r
80int PmovState(int PmovAction, void *PmovFile); // &1=for reading &2=for writing &4=volatile &8=non-volatile\r
81extern arearw *areaRead; // external read and write function pointers for\r
82extern arearw *areaWrite; // gzip save state ability\r
83extern areaeof *areaEof;\r
84extern areaseek *areaSeek;\r
85extern areaclose *areaClose;\r
86extern void (*PicoStateProgressCB)(const char *str);\r
87\r
88// cd/Area.c\r
89int PicoCdLoadStateGfx(void *file);\r
90\r
91// cd/buffering.c\r
92void PicoCDBufferInit(void);\r
93void PicoCDBufferFree(void);\r
94\r
95// cd/cd_sys.c\r
96int Insert_CD(char *iso_name, int is_bin);\r
97void Stop_CD(void); // releases all resources taken when CD game was started.\r
98\r
99// Cart.c\r
100typedef enum\r
101{\r
102 PMT_UNCOMPRESSED = 0,\r
103 PMT_ZIP,\r
104 PMT_CSO\r
105} pm_type;\r
106typedef struct\r
107{\r
108 void *file; /* file handle */\r
109 void *param; /* additional file related field */\r
110 unsigned int size; /* size */\r
111 pm_type type;\r
112} pm_file;\r
113pm_file *pm_open(const char *path);\r
114size_t pm_read(void *ptr, size_t bytes, pm_file *stream);\r
115int pm_seek(pm_file *stream, long offset, int whence);\r
116int pm_close(pm_file *fp);\r
117int PicoCartLoad(pm_file *f,unsigned char **prom,unsigned int *psize);\r
118int PicoCartInsert(unsigned char *rom,unsigned int romsize);\r
119void Byteswap(unsigned char *data,int len);\r
120int PicoCartUnload(void);\r
121extern void (*PicoCartLoadProgressCB)(int percent);\r
122extern void (*PicoCDLoadProgressCB)(int percent);\r
123\r
124// Draw.c\r
125void PicoDrawSetColorFormat(int which); // 0=BGR444, 1=RGB555, 2=8bit(HighPal pal)\r
126extern void *DrawLineDest;\r
127#if OVERRIDE_HIGHCOL\r
128extern unsigned char *HighCol;\r
129#endif\r
130extern int (*PicoScanBegin)(unsigned int num);\r
131extern int (*PicoScanEnd)(unsigned int num);\r
132// utility\r
133#ifdef _ASM_DRAW_C\r
134void vidConvCpyRGB565(void *to, void *from, int pixels);\r
135#endif\r
136// internals\r
137#define PDRAW_SPRITES_MOVED (1<<0)\r
138#define PDRAW_WND_DIFF_PRIO (1<<1) // not all window tiles use same priority\r
139#define PDRAW_ACC_SPRITES (1<<2) // accurate sprites (copied from PicoOpt)\r
140#define PDRAW_INTERLACE (1<<3) // \r
141#define PDRAW_DIRTY_SPRITES (1<<4)\r
142#define PDRAW_SONIC_MODE (1<<5) // mid-frame palette changes for 8bit renderer\r
143#define PDRAW_PLANE_HI_PRIO (1<<6) // have layer with all hi prio tiles (mk3)\r
144#define PDRAW_SHHI_DONE (1<<7) // layer sh/hi already processed\r
145#define PDRAW_EARLY_BLANK (1<<8) // blanking enabled at the start of prev line\r
146extern int rendstatus;\r
147extern unsigned short HighPal[0x100];\r
148\r
149// Draw2.c\r
150// stuff below is optional\r
151extern unsigned char *PicoDraw2FB; // buffer for fast renderer in format (8+320)x(8+224+8) (eights for borders)\r
152extern unsigned short *PicoCramHigh; // pointer to CRAM buff (0x40 shorts), converted to native device color (works only with 16bit for now)\r
153extern void (*PicoPrepareCram)(); // prepares PicoCramHigh for renderer to use\r
154\r
155// sound.c\r
156extern int PsndRate,PsndLen;\r
157extern short *PsndOut;\r
158extern void (*PsndMix_32_to_16l)(short *dest, int *src, int count);\r
159void PsndRerate(int preserve_state);\r
160\r
161// Utils.c\r
162extern int PicuAnd;\r
163int PicuQuick(unsigned short *dest,unsigned short *src);\r
164int PicuShrink(unsigned short *dest,int destLen,unsigned short *src,int srcLen);\r
165int PicuShrinkReverse(unsigned short *dest,int destLen,unsigned short *src,int srcLen);\r
166int PicuMerge(unsigned short *dest,int destLen,unsigned short *src,int srcLen);\r
167\r
168#ifdef __cplusplus\r
169} // End of extern "C"\r
170#endif\r
171\r
172#endif // PICO_H\r