input: detect dead devices, always set keynames
[libpicofe.git] / common / emu.h
CommitLineData
f013066e 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
36f6fd5a 6#include "port_config.h"
7
8#ifdef __cplusplus
9extern "C" {
10#endif
11
2f3ca016 12#define array_size(x) (sizeof(x) / sizeof(x[0]))
13
e31266dd 14extern 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
20extern int g_screen_width;
21extern int g_screen_height;
22#endif
23
24
ee0f881e 25#define EOPT_EN_SRAM (1<<0)
36f6fd5a 26#define EOPT_SHOW_FPS (1<<1)
27#define EOPT_EN_SOUND (1<<2)
28#define EOPT_GZIP_SAVES (1<<3)
fa5e045b 29#define EOPT_MMUHACK (1<<4)
7f3b59cf 30#define EOPT_NO_AUTOSVCFG (1<<5)
662e622b 31#define EOPT_16BPP (1<<7) // depreceted for .renderer
fa5e045b 32#define EOPT_RAM_TIMINGS (1<<8)
388947f3 33#define EOPT_EN_CD_LEDS (1<<10)
fa8d1331 34#define EOPT_A_SN_GAMMA (1<<12)
f71361b5 35#define EOPT_VSYNC (1<<13)
b7911801 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)
6c026031 42#define EOPT_EXT_FRMLIMIT (1<<20) // no internal frame limiter (limited by snd, etc)
36f6fd5a 43
fa8d1331 44enum {
45 EOPT_SCALE_NONE = 0,
b6072c17 46 EOPT_SCALE_SW,
47 EOPT_SCALE_HW,
fa8d1331 48};
49
0c9ae592 50enum {
51 EOPT_CONFIRM_NONE = 0,
52 EOPT_CONFIRM_SAVE = 1,
53 EOPT_CONFIRM_LOAD = 2,
54 EOPT_CONFIRM_BOTH = 3,
55};
56
36f6fd5a 57typedef struct _currentConfig_t {
b7911801 58 int EmuOpt;
59 int s_PicoOpt;
0ae25549 60 int s_PsndRate;
61 int s_PicoRegion;
36f6fd5a 62 int s_PicoAutoRgnOrder;
63 int s_PicoCDBuffers;
f013066e 64 int Frameskip;
0c9ae592 65 int confirm_save;
f013066e 66 int CPUclock;
f013066e 67 int volume;
68 int gamma;
b6072c17 69 int scaling; // gp2x: EOPT_SCALE_*; psp: bilinear filtering
70 int vscaling;
36f6fd5a 71 int rotation; // for UIQ
6f748c47 72 float scale; // psp: screen scale
73 float hscale32, hscale40; // psp: horizontal scale
960a8e27 74 int gamma2; // psp: black level
6589c840 75 int turbo_rate;
662e622b 76 int renderer;
77 int renderer32x;
c66f49e6 78 int filter; // pandora
902972d1 79 int analog_deadzone;
f013066e 80} currentConfig_t;
81
0ae25549 82extern currentConfig_t currentConfig, defaultConfig;
f013066e 83extern char *PicoConfigFile;
144a28a0 84extern int rom_loaded;
f013066e 85extern int state_slot;
86extern int config_slot, config_slot_current;
87extern unsigned char *movie_data;
93c18cb4 88extern int reset_timing;
89
90#define PICO_PEN_ADJUST_X 4
91#define PICO_PEN_ADJUST_Y 2
92extern int pico_pen_x, pico_pen_y;
8a091e48 93extern int pico_inp_mode;
f013066e 94
049a6b3e 95extern char rom_fname_reload[512]; // ROM to try loading on next PGS_ReloadRom
96extern char rom_fname_loaded[512]; // currently loaded ROM filename
97
24b24674 98// engine states
049a6b3e 99extern int engineState;
24b24674 100enum TPicoGameState {
101 PGS_Paused = 1,
102 PGS_Running,
103 PGS_Quit,
104 PGS_KeyConfig,
105 PGS_ReloadRom,
106 PGS_Menu,
0f4090a9 107 PGS_TrayMenu,
24b24674 108 PGS_RestartRun,
109 PGS_Suspending, /* PSP */
110 PGS_SuspendWake, /* PSP */
111};
112
2f3ca016 113// media types
114enum {
115 PM_BAD = 0,
116 PM_MD_CART, /* also 32x */
117 PM_MARK3,
118 PM_CD,
119};
f013066e 120
93c18cb4 121void emu_init(void);
122void emu_finish(void);
b5bfb864 123void emu_loop(void);
93c18cb4 124
ee0f881e 125int emu_reload_rom(char *rom_fname);
6b8796e2 126int emu_swap_cd(const char *fname);
ee0f881e 127int emu_save_load_game(int load, int sram);
93c18cb4 128void emu_reset_game(void);
388947f3 129
d2f29611 130void emu_prep_defconfig(void);
9ecdd73a 131void emu_set_defconfig(void);
0c9ae592 132int emu_read_config(const char *rom_fname, int no_defaults);
ee0f881e 133int emu_write_config(int game);
388947f3 134
ee0f881e 135char *emu_get_save_fname(int load, int is_sram, int slot);
136int emu_check_save_file(int slot);
388947f3 137
b7911801 138void emu_text_out8 (int x, int y, const char *text);
139void emu_text_out16(int x, int y, const char *text);
140void emu_text_out8_rot (int x, int y, const char *text);
141void emu_text_out16_rot(int x, int y, const char *text);
142
45deb409 143void emu_make_path(char *buff, const char *end, int size);
388947f3 144void emu_update_input(void);
ee0f881e 145void emu_get_game_name(char *str150);
146void emu_set_fastforward(int set_on);
b5bfb864 147void emu_status_msg(const char *format, ...);
f013066e 148
a33164ff 149/* used by some (but not all) platforms */
150void emu_cmn_forced_frame(int no_scale, int do_emu);
151
36f6fd5a 152#ifdef __cplusplus
153} // extern "C"
154#endif
155