extend mmap wrapper functionality
[libpicofe.git] / common / emu.h
1 // (c) Copyright 2006-2007 notaz, All rights reserved.
2 // Free for non-commercial use.
3
4 // For commercial use, separate licencing terms must be obtained.
5
6 #include "port_config.h"
7
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11
12 #define array_size(x) (sizeof(x) / sizeof(x[0]))
13
14 extern void *g_screen_ptr;
15
16 #if SCREEN_SIZE_FIXED
17 #define g_screen_width  SCREEN_WIDTH
18 #define g_screen_height SCREEN_HEIGHT
19 #else
20 extern int g_screen_width;
21 extern int g_screen_height;
22 #endif
23
24
25 #define EOPT_EN_SRAM      (1<<0)
26 #define EOPT_SHOW_FPS     (1<<1)
27 #define EOPT_EN_SOUND     (1<<2)
28 #define EOPT_GZIP_SAVES   (1<<3)
29 #define EOPT_MMUHACK      (1<<4)
30 #define EOPT_NO_AUTOSVCFG (1<<5)
31 #define EOPT_16BPP        (1<<7)  // depreceted for .renderer
32 #define EOPT_RAM_TIMINGS  (1<<8)
33 #define EOPT_EN_CD_LEDS   (1<<10)
34 #define EOPT_A_SN_GAMMA   (1<<12)
35 #define EOPT_VSYNC        (1<<13)
36 #define EOPT_GIZ_SCANLN   (1<<14)
37 #define EOPT_GIZ_DBLBUF   (1<<15)
38 #define EOPT_VSYNC_MODE   (1<<16)
39 #define EOPT_SHOW_RTC     (1<<17)
40 #define EOPT_NO_FRMLIMIT  (1<<18)
41 #define EOPT_WIZ_TEAR_FIX (1<<19)
42 #define EOPT_EXT_FRMLIMIT (1<<20) // no internal frame limiter (limited by snd, etc)
43
44 enum {
45         EOPT_SCALE_NONE = 0,
46         EOPT_SCALE_SW,
47         EOPT_SCALE_HW,
48 };
49
50 enum {
51         EOPT_CONFIRM_NONE = 0,
52         EOPT_CONFIRM_SAVE = 1,
53         EOPT_CONFIRM_LOAD = 2,
54         EOPT_CONFIRM_BOTH = 3,
55 };
56
57 typedef struct _currentConfig_t {
58         int EmuOpt;
59         int s_PicoOpt;
60         int s_PsndRate;
61         int s_PicoRegion;
62         int s_PicoAutoRgnOrder;
63         int s_PicoCDBuffers;
64         int Frameskip;
65         int confirm_save;
66         int CPUclock;
67         int volume;
68         int gamma;
69         int scaling;  // gp2x: EOPT_SCALE_*; psp: bilinear filtering
70         int vscaling;
71         int rotation; // for UIQ
72         float scale; // psp: screen scale
73         float hscale32, hscale40; // psp: horizontal scale
74         int gamma2;  // psp: black level
75         int turbo_rate;
76         int renderer;
77         int renderer32x;
78         int filter; // pandora
79         int analog_deadzone;
80 } currentConfig_t;
81
82 extern currentConfig_t currentConfig, defaultConfig;
83 extern char *PicoConfigFile;
84 extern int rom_loaded;
85 extern int state_slot;
86 extern int config_slot, config_slot_current;
87 extern unsigned char *movie_data;
88 extern int reset_timing;
89
90 #define PICO_PEN_ADJUST_X 4
91 #define PICO_PEN_ADJUST_Y 2
92 extern int pico_pen_x, pico_pen_y;
93 extern int pico_inp_mode;
94
95 extern char rom_fname_reload[512];              // ROM to try loading on next PGS_ReloadRom
96 extern char rom_fname_loaded[512];              // currently loaded ROM filename
97
98 // engine states
99 extern int engineState;
100 enum TPicoGameState {
101         PGS_Paused = 1,
102         PGS_Running,
103         PGS_Quit,
104         PGS_KeyConfig,
105         PGS_ReloadRom,
106         PGS_Menu,
107         PGS_TrayMenu,
108         PGS_RestartRun,
109         PGS_Suspending,         /* PSP */
110         PGS_SuspendWake,        /* PSP */
111 };
112
113 // media types
114 enum {
115         PM_BAD = 0,
116         PM_MD_CART,     /* also 32x */
117         PM_MARK3,
118         PM_CD,
119 };
120
121 void  emu_init(void);
122 void  emu_finish(void);
123 void  emu_loop(void);
124
125 int   emu_reload_rom(char *rom_fname);
126 int   emu_swap_cd(const char *fname);
127 int   emu_save_load_game(int load, int sram);
128 void  emu_reset_game(void);
129
130 void  emu_prep_defconfig(void);
131 void  emu_set_defconfig(void);
132 int   emu_read_config(const char *rom_fname, int no_defaults);
133 int   emu_write_config(int game);
134
135 char *emu_get_save_fname(int load, int is_sram, int slot);
136 int   emu_check_save_file(int slot, int *time);
137
138 void  emu_text_out8 (int x, int y, const char *text);
139 void  emu_text_out16(int x, int y, const char *text);
140 void  emu_text_out8_rot (int x, int y, const char *text);
141 void  emu_text_out16_rot(int x, int y, const char *text);
142
143 void  emu_make_path(char *buff, const char *end, int size);
144 void  emu_update_input(void);
145 void  emu_get_game_name(char *str150);
146 void  emu_set_fastforward(int set_on);
147 void  emu_status_msg(const char *format, ...);
148
149 /* used by some (but not all) platforms */
150 void  emu_cmn_forced_frame(int no_scale, int do_emu);
151
152 #ifdef __cplusplus
153 } // extern "C"
154 #endif
155