3 * (c) Copyright Dave, 2004
\r
4 * (C) notaz, 2006-2010
\r
6 * This work is licensed under the terms of MAME license.
\r
7 * See COPYING file in the top-level directory.
\r
13 #include <stdlib.h> // size_t
\r
20 extern void lprintf(const char *fmt, ...);
\r
22 // external funcs for Sega/Mega CD
\r
23 extern int mp3_get_bitrate(void *f, int size);
\r
24 extern void mp3_start_play(void *f, int pos);
\r
25 extern void mp3_update(int *buffer, int length, int stereo);
\r
27 // this function should write-back d-cache and invalidate i-cache
\r
28 // on a mem region [start_addr, end_addr)
\r
30 extern void cache_flush_d_inval_i(void *start_addr, void *end_addr);
\r
32 // attempt to alloc mem at specified address.
\r
33 // alloc anywhere else if that fails (callers should handle that)
\r
34 extern void *plat_mmap(unsigned long addr, size_t size, int need_exec, int is_fixed);
\r
35 extern void *plat_mremap(void *ptr, size_t oldsize, size_t newsize);
\r
36 extern void plat_munmap(void *ptr, size_t size);
\r
37 extern int plat_mem_set_exec(void *ptr, size_t size);
\r
39 // this one should handle display mode changes
\r
40 extern void emu_video_mode_change(int start_line, int line_count, int is_32cols);
\r
42 // this must switch to 16bpp mode
\r
43 extern void emu_32x_startup(void);
\r
45 // optional 32X BIOS, should be left NULL if not used
\r
46 // must be 256, 2048, 1024 bytes
\r
47 extern void *p32x_bios_g, *p32x_bios_m, *p32x_bios_s;
\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 #define POPT_6BTN_PAD (1<< 5)
\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 #define POPT_EN_MCD_PSYNC (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_SVP_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
72 extern int PicoOpt; // bitfield
\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
79 extern int PicoAHW; // Pico active hw
\r
80 extern int PicoSkipFrame; // skip rendering frame, but still do sound (if enabled) and emulation stuff
\r
81 extern int PicoRegionOverride; // override the region detection 0: auto, 1: Japan NTSC, 2: Japan PAL, 4: US, 8: Europe
\r
82 extern int PicoAutoRgnOrder; // packed priority list of regions, for example 0x148 means this detection order: EUR, USA, JAP
\r
83 extern int PicoSVPCycles;
\r
84 void PicoInit(void);
\r
85 void PicoExit(void);
\r
86 void PicoPower(void);
\r
87 int PicoReset(void);
\r
88 void PicoLoopPrepare(void);
\r
89 void PicoFrame(void);
\r
90 void PicoFrameDrawOnly(void);
\r
91 extern int PicoPad[2]; // Joypads, format is MXYZ SACB RLDU
\r
92 extern void (*PicoWriteSound)(int bytes); // called once per frame at the best time to send sound buffer (PsndOut) to hardware
\r
93 extern void (*PicoMessage)(const char *msg); // callback to output text message from emu
\r
94 typedef enum { PI_ROM, PI_ISPAL, PI_IS40_CELL, PI_IS240_LINES } pint_t;
\r
95 typedef union { int vint; void *vptr; } pint_ret_t;
\r
96 void PicoGetInternal(pint_t which, pint_ret_t *ret);
\r
99 extern void (*PicoMCDopenTray)(void);
\r
100 extern void (*PicoMCDcloseTray)(void);
\r
101 extern int PicoCDBuffers;
\r
104 #define XPCM_BUFFER_SIZE (320+160)
\r
110 int fifo_bytes; // bytes in FIFO
\r
111 int fifo_bytes_prev;
\r
112 int fifo_line_bytes; // float part, << 16
\r
114 unsigned short r1, r12;
\r
115 unsigned char xpcm_buffer[XPCM_BUFFER_SIZE+4];
\r
116 unsigned char *xpcm_ptr;
\r
118 extern picohw_state PicoPicohw;
\r
121 int PicoState(const char *fname, int is_save);
\r
122 int PicoStateLoadGfx(const char *fname);
\r
123 void *PicoTmpStateSave(void);
\r
124 void PicoTmpStateRestore(void *data);
\r
125 extern void (*PicoStateProgressCB)(const char *str);
\r
128 void PicoCDBufferInit(void);
\r
129 void PicoCDBufferFree(void);
\r
130 void PicoCDBufferFlush(void);
\r
133 int Insert_CD(const char *cdimg_name, int type);
\r
134 void Stop_CD(void); // releases all resources taken when CD game was started.
\r
139 PMT_UNCOMPRESSED = 0,
\r
145 void *file; /* file handle */
\r
146 void *param; /* additional file related field */
\r
147 unsigned int size; /* size */
\r
151 pm_file *pm_open(const char *path);
\r
152 size_t pm_read(void *ptr, size_t bytes, pm_file *stream);
\r
153 int pm_seek(pm_file *stream, long offset, int whence);
\r
154 int pm_close(pm_file *fp);
\r
155 int PicoCartLoad(pm_file *f,unsigned char **prom,unsigned int *psize,int is_sms);
\r
156 int PicoCartInsert(unsigned char *rom, unsigned int romsize, const char *carthw_cfg);
\r
157 void PicoCartUnload(void);
\r
158 extern void (*PicoCartLoadProgressCB)(int percent);
\r
159 extern void (*PicoCDLoadProgressCB)(const char *fname, int percent);
\r
160 extern int PicoGameLoaded;
\r
163 // for line-based renderer, set conversion
\r
164 // from internal 8 bit representation in 'HighCol' to:
\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
171 void PicoDrawSetOutFormat(pdso_t which, int use_32x_line_mode);
\r
172 void PicoDrawSetOutBuf(void *dest, int increment);
\r
173 void PicoDrawSetCallbacks(int (*begin)(unsigned int num), int (*end)(unsigned int num));
\r
174 extern void *DrawLineDest;
\r
175 extern unsigned char *HighCol;
\r
178 void vidConvCpyRGB565(void *to, void *from, int pixels);
\r
180 void PicoDoHighPal555(int sh);
\r
181 extern int PicoDrawMask;
\r
182 #define PDRAW_LAYERB_ON (1<<2)
\r
183 #define PDRAW_LAYERA_ON (1<<3)
\r
184 #define PDRAW_SPRITES_LOW_ON (1<<4)
\r
185 #define PDRAW_SPRITES_HI_ON (1<<7)
\r
186 #define PDRAW_32X_ON (1<<8)
\r
188 #define PDRAW_SPRITES_MOVED (1<<0) // (asm)
\r
189 #define PDRAW_WND_DIFF_PRIO (1<<1) // not all window tiles use same priority
\r
190 #define PDRAW_SPR_LO_ON_HI (1<<2) // seen sprites without layer pri bit ontop spr. with that bit
\r
191 #define PDRAW_INTERLACE (1<<3)
\r
192 #define PDRAW_DIRTY_SPRITES (1<<4) // (asm)
\r
193 #define PDRAW_SONIC_MODE (1<<5) // mid-frame palette changes for 8bit renderer
\r
194 #define PDRAW_PLANE_HI_PRIO (1<<6) // have layer with all hi prio tiles (mk3)
\r
195 #define PDRAW_SHHI_DONE (1<<7) // layer sh/hi already processed
\r
196 #define PDRAW_32_COLS (1<<8) // 32 column mode
\r
197 extern int rendstatus, rendstatus_old;
\r
198 extern int rendlines;
\r
199 extern unsigned short HighPal[0x100];
\r
202 void PicoDrawUpdateHighPal(void);
\r
203 void PicoDrawSetInternalBuf(void *dest, int line_increment);
\r
206 // stuff below is optional
\r
207 extern unsigned char *PicoDraw2FB; // buffer for fast renderer in format (8+320)x(8+224+8) (eights for borders)
\r
208 extern unsigned short *PicoCramHigh; // pointer to CRAM buff (0x40 shorts), converted to native device color (works only with 16bit for now)
\r
209 extern void (*PicoPrepareCram)(); // prepares PicoCramHigh for renderer to use
\r
214 void Pico32xSetClocks(int msh2_hz, int ssh2_hz);
\r
218 #define Pico32xSetClocks(msh2_khz, ssh2_khz)
\r
222 // normally 68k clock (7670442) * 3, in reality but much lower
\r
223 // because of high memory latencies
\r
224 #define PICO_MSH2_HZ ((int)(7670442.0 * 2.4))
\r
225 #define PICO_SSH2_HZ ((int)(7670442.0 * 2.4))
\r
228 extern int PsndRate,PsndLen;
\r
229 extern short *PsndOut;
\r
230 extern void (*PsndMix_32_to_16l)(short *dest, int *src, int count);
\r
231 void PsndRerate(int preserve_state);
\r
234 enum media_type_e {
\r
235 PM_BAD_DETECT = -1,
\r
238 PM_BAD_CD_NO_BIOS = -4,
\r
239 PM_MD_CART = 1, /* also 32x */
\r
243 enum media_type_e PicoLoadMedia(const char *filename,
\r
244 const char *carthw_cfg_fname,
\r
245 const char *(*get_bios_filename)(int *region, const char *cd_fname),
\r
246 void (*do_region_override)(const char *media_filename));
\r
247 int PicoCdCheck(const char *fname_in, int *pregion);
\r
249 extern unsigned char media_id_header[0x100];
\r
252 } // End of extern "C"
\r