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