drc: support ms ABI
[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
38 enum {
39         EOPT_SCALE_NONE = 0,
40         EOPT_SCALE_SW,
41         EOPT_SCALE_HW,
42 };
43
44 enum {
45         EOPT_CONFIRM_NONE = 0,
46         EOPT_CONFIRM_SAVE = 1,
47         EOPT_CONFIRM_LOAD = 2,
48         EOPT_CONFIRM_BOTH = 3,
49 };
50
51 typedef struct _currentConfig_t {
52         int EmuOpt;
53         int s_PicoOpt;
54         int s_PsndRate;
55         int s_PicoRegion;
56         int s_PicoAutoRgnOrder;
57         int s_PicoCDBuffers;
58         int Frameskip;
59         int input_dev0;
60         int input_dev1;
61         int confirm_save;
62         int CPUclock;
63         int volume;
64         int gamma;
65         int scaling;  // gp2x: EOPT_SCALE_*; psp: bilinear filtering
66         int vscaling;
67         int rotation; // for UIQ
68         float scale; // psp: screen scale
69         float hscale32, hscale40; // psp: horizontal scale
70         int gamma2;  // psp: black level
71         int turbo_rate;
72         int renderer;
73         int renderer32x;
74         int filter; // pandora
75         int analog_deadzone;
76         int msh2_khz;
77         int ssh2_khz;
78         int overclock_68k;
79 } currentConfig_t;
80
81 extern currentConfig_t currentConfig, defaultConfig;
82 extern const char *PicoConfigFile;
83 extern int state_slot;
84 extern int config_slot, config_slot_current;
85 extern unsigned char *movie_data;
86 extern int reset_timing;
87 extern int flip_after_sync;
88
89 #define PICO_PEN_ADJUST_X 4
90 #define PICO_PEN_ADJUST_Y 2
91 extern int pico_pen_x, pico_pen_y;
92 extern int pico_inp_mode;
93
94 extern const char *rom_fname_reload;            // ROM to try loading on next PGS_ReloadRom
95 extern char rom_fname_loaded[512];              // currently loaded ROM filename
96
97 // engine states
98 extern int engineState;
99 enum TPicoGameState {
100         PGS_Paused = 1,
101         PGS_Running,
102         PGS_Quit,
103         PGS_KeyConfig,
104         PGS_ReloadRom,
105         PGS_Menu,
106         PGS_TrayMenu,
107         PGS_RestartRun,
108         PGS_Suspending,         /* PSP */
109         PGS_SuspendWake,        /* PSP */
110 };
111
112 void  emu_init(void);
113 void  emu_finish(void);
114 void  emu_loop(void);
115
116 int   emu_reload_rom(const char *rom_fname_in);
117 int   emu_swap_cd(const char *fname);
118 int   emu_save_load_game(int load, int sram);
119 void  emu_reset_game(void);
120
121 void  emu_prep_defconfig(void);
122 void  emu_set_defconfig(void);
123 int   emu_read_config(const char *rom_fname, int no_defaults);
124 int   emu_write_config(int game);
125
126 char *emu_get_save_fname(int load, int is_sram, int slot, int *time);
127 int   emu_check_save_file(int slot, int *time);
128
129 void  emu_text_out8 (int x, int y, const char *text);
130 void  emu_text_out16(int x, int y, const char *text);
131 void  emu_text_out8_rot (int x, int y, const char *text);
132 void  emu_text_out16_rot(int x, int y, const char *text);
133
134 void  emu_osd_text16(int x, int y, const char *text);
135
136 void  emu_make_path(char *buff, const char *end, int size);
137 void  emu_update_input(void);
138 void  emu_get_game_name(char *str150);
139 void  emu_set_fastforward(int set_on);
140 void  emu_status_msg(const char *format, ...);
141
142 /* default sound code */
143 void  emu_sound_start(void);
144 void  emu_sound_stop(void);
145 void  emu_sound_wait(void);
146
147 /* used by some (but not all) platforms */
148 void  emu_cmn_forced_frame(int no_scale, int do_emu);
149
150 /* stuff to be implemented by platform code */
151 extern const char *renderer_names[];
152 extern const char *renderer_names32x[];
153
154 void pemu_prep_defconfig(void);
155 void pemu_validate_config(void);
156 void pemu_loop_prep(void);
157 void pemu_loop_end(void);
158 void pemu_forced_frame(int no_scale, int do_emu); // ..to g_menubg_src_ptr
159 void pemu_finalize_frame(const char *fps, const char *notice_msg);
160
161 void pemu_sound_start(void);
162
163 void plat_early_init(void);
164 void plat_init(void);
165 void plat_finish(void);
166
167 /* used before things blocking for a while (these funcs redraw on return) */
168 void plat_status_msg_busy_first(const char *msg);
169 void plat_status_msg_busy_next(const char *msg);
170 void plat_status_msg_clear(void);
171
172 void plat_video_toggle_renderer(int change, int menu_call);
173 void plat_video_loop_prepare(void);
174
175 void plat_update_volume(int has_changed, int is_up);
176
177 #ifdef __cplusplus
178 } // extern "C"
179 #endif
180