4255e3717b4e172c4f36bbcffd4d2b455923266c
[picodrive.git] / platform / common / emu.h
1 /*
2  * PicoDrive
3  * (C) notaz, 2006-2010
4  *
5  * This work is licensed under the terms of MAME license.
6  * See COPYING file in the top-level directory.
7  */
8
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12
13 #define array_size(x) (sizeof(x) / sizeof(x[0]))
14
15 extern void *g_screen_ptr;
16
17 extern int g_screen_width;
18 extern int g_screen_height;
19 extern int g_screen_ppitch; // pitch in pixels
20
21 #define EOPT_EN_SRAM      (1<<0)
22 #define EOPT_SHOW_FPS     (1<<1)
23 #define EOPT_EN_SOUND     (1<<2)
24 #define EOPT_GZIP_SAVES   (1<<3)
25 #define EOPT_NO_AUTOSVCFG (1<<5)
26 #define EOPT_16BPP        (1<<7)  // depreceted for .renderer
27 #define EOPT_EN_CD_LEDS   (1<<10)
28 #define EOPT_A_SN_GAMMA   (1<<12)
29 #define EOPT_VSYNC        (1<<13)
30 #define EOPT_GIZ_SCANLN   (1<<14)
31 #define EOPT_GIZ_DBLBUF   (1<<15)
32 #define EOPT_VSYNC_MODE   (1<<16)
33 #define EOPT_SHOW_RTC     (1<<17)
34 #define EOPT_NO_FRMLIMIT  (1<<18)
35 #define EOPT_WIZ_TEAR_FIX (1<<19)
36 #define EOPT_EXT_FRMLIMIT (1<<20) // no internal frame limiter (limited by snd, etc)
37 #define EOPT_PICO_PEN     (1<<21)
38
39 enum {
40         EOPT_SCALE_NONE = 0,
41         // linux, GP2X:
42         EOPT_SCALE_SW = 1,
43         EOPT_SCALE_HW,
44         // PSP horiz:
45         EOPT_SCALE_43 = 1,      // 4:3 screen
46         EOPT_SCALE_STRETCH,     // stretched to between _43 and _WIDE
47         EOPT_SCALE_WIDE,        // stretched to match display width
48         // PSP vert:
49         EOPT_VSCALE_FULL = 1,   // TV height scaled to screen height
50         EOPT_VSCALE_NOBORDER,   // VDP area scaled to screen height
51 };
52
53 enum {
54         EOPT_FILTER_NONE = 0,
55         // PSP texture filtering
56         EOPT_FILTER_BILINEAR = 1,
57         // software scalers
58         EOPT_FILTER_SMOOTHER = 1,
59         EOPT_FILTER_BILINEAR1,
60         EOPT_FILTER_BILINEAR2,
61 };
62
63 enum {
64         EOPT_CONFIRM_NONE = 0,
65         EOPT_CONFIRM_SAVE = 1,
66         EOPT_CONFIRM_LOAD = 2,
67         EOPT_CONFIRM_BOTH = 3,
68 };
69
70 typedef struct _currentConfig_t {
71         int EmuOpt;
72         int s_PicoOpt;
73         int s_PsndRate;
74         int s_PicoRegion;
75         int s_PicoAutoRgnOrder;
76         int s_hwSelect;
77         int s_PicoCDBuffers;
78         int s_PicoSndFilterAlpha;
79         int Frameskip;
80         int input_dev0;
81         int input_dev1;
82         int confirm_save;
83         int CPUclock;
84         int volume;
85         int gamma;
86         int scaling;  // EOPT_SCALE_*
87         int vscaling;
88         int rotation; // for UIQ
89         int gamma2;  // psp: black level
90         int turbo_rate;
91         int renderer;
92         int renderer32x;
93         int filter;  // EOPT_FILTER_* video filter
94         int ghosting;
95         int analog_deadzone;
96         int keyboard;
97         int msh2_khz;
98         int ssh2_khz;
99         int overclock_68k;
100         int max_skip;
101 } currentConfig_t;
102
103 extern currentConfig_t currentConfig, defaultConfig;
104 extern const char *PicoConfigFile;
105 extern int state_slot;
106 extern int config_slot, config_slot_current;
107 extern unsigned char *movie_data;
108 extern int reset_timing;
109 extern int flip_after_sync;
110 extern int kbd_mode;
111 extern struct vkbd *vkbd;
112
113 #define PICO_PEN_ADJUST_X 1
114 #define PICO_PEN_ADJUST_Y 1
115 extern int pico_pen_x, pico_pen_y;
116 extern int pico_inp_mode;
117
118 extern const char *rom_fname_reload;            // ROM to try loading on next PGS_ReloadRom
119 extern char rom_fname_loaded[512];              // currently loaded ROM filename
120
121 // engine states
122 extern int engineState;
123 enum TPicoGameState {
124         PGS_Paused = 1,
125         PGS_Running,
126         PGS_Quit,
127         PGS_KeyConfig,
128         PGS_ReloadRom,
129         PGS_Menu,
130         PGS_TrayMenu,
131         PGS_RestartRun,
132         PGS_Suspending,         /* PSP */
133         PGS_SuspendWake,        /* PSP */
134 };
135
136 void  emu_init(void);
137 void  emu_finish(void);
138 void  emu_loop(void);
139
140 int   emu_reload_rom(const char *rom_fname_in);
141 int   emu_swap_cd(const char *fname);
142 int   emu_play_tape(const char *fname);
143 int   emu_record_tape(const char *ext);
144 int   emu_save_load_game(int load, int sram);
145 void  emu_reset_game(void);
146
147 void  emu_prep_defconfig(void);
148 void  emu_set_defconfig(void);
149 int   emu_read_config(const char *rom_fname, int no_defaults);
150 int   emu_write_config(int game);
151
152 char *emu_get_save_fname(int load, int is_sram, int slot, int *time);
153 int   emu_check_save_file(int slot, int *time);
154
155 void  emu_text_out8 (int x, int y, const char *text);
156 void  emu_text_out16(int x, int y, const char *text);
157 void  emu_text_out8_rot (int x, int y, const char *text);
158 void  emu_text_out16_rot(int x, int y, const char *text);
159
160 void  emu_osd_text16(int x, int y, const char *text);
161
162 void  emu_make_path(char *buff, const char *end, int size);
163 void  emu_update_input(void);
164 void  emu_get_game_name(char *str150);
165 void  emu_set_fastforward(int set_on);
166 void  emu_status_msg(const char *format, ...);
167
168 void  emu_pico_overlay(unsigned short *pd, int w, int h, int pitch);
169
170 /* default sound code */
171 void  emu_sound_start(void);
172 void  emu_sound_stop(void);
173 void  emu_sound_wait(void);
174
175 /* used by some (but not all) platforms */
176 void  emu_cmn_forced_frame(int no_scale, int do_emu, void *buf);
177
178 /* stuff to be implemented by platform code */
179 extern const char *renderer_names[];
180 extern const char *renderer_names32x[];
181
182 void pemu_prep_defconfig(void);
183 void pemu_validate_config(void);
184 void pemu_loop_prep(void);
185 void pemu_loop_end(void);
186 void pemu_forced_frame(int no_scale, int do_emu); // ..to g_menubg_src_ptr
187 void pemu_finalize_frame(const char *fps, const char *notice_msg);
188
189 void pemu_sound_start(void);
190
191 int plat_parse_arg(int argc, char *argv[], int *x);
192 void plat_early_init(void);
193 void plat_init(void);
194 void plat_finish(void);
195
196 void plat_show_cursor(int on);
197 int plat_grab_cursor(int on);
198 int plat_has_wm(void);
199
200 /* used before things blocking for a while (these funcs redraw on return) */
201 void plat_status_msg_busy_first(const char *msg);
202 void plat_status_msg_busy_next(const char *msg);
203 void plat_status_msg_busy_done(void);
204 void plat_status_msg_clear(void);
205
206 void plat_video_toggle_renderer(int change, int menu_call);
207 void plat_video_loop_prepare(void);
208 void plat_video_set_buffer(void *);
209
210 void plat_update_volume(int has_changed, int is_up);
211
212 /* should be in libpicofe/plat.h */
213 void plat_video_clear_status(void);
214 void plat_video_clear_buffers(void);
215 void plat_video_set_size(int w, int h);
216 void plat_video_set_shadow(int w, int h);
217
218 #ifdef __cplusplus
219 } // extern "C"
220 #endif
221