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