move emu loop to common; redo timing; add pollux timer
[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 extern void *g_screen_ptr;
13
14 #if SCREEN_SIZE_FIXED
15 #define g_screen_width  SCREEN_WIDTH
16 #define g_screen_height SCREEN_HEIGHT
17 #else
18 extern int g_screen_width;
19 extern int g_screen_height;
20 #endif
21
22
23 #define EOPT_EN_SRAM      (1<<0)
24 #define EOPT_SHOW_FPS     (1<<1)
25 #define EOPT_EN_SOUND     (1<<2)
26 #define EOPT_GZIP_SAVES   (1<<3)
27 #define EOPT_MMUHACK      (1<<4)
28 #define EOPT_NO_AUTOSVCFG (1<<5)
29 #define EOPT_16BPP        (1<<7)
30 #define EOPT_RAM_TIMINGS  (1<<8)
31 #define EOPT_CONFIRM_SAVE (1<<9)
32 #define EOPT_EN_CD_LEDS   (1<<10)
33 #define EOPT_CONFIRM_LOAD (1<<11)
34 #define EOPT_A_SN_GAMMA   (1<<12)
35 #define EOPT_PSYNC        (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
43 enum {
44         EOPT_SCALE_NONE = 0,
45         EOPT_SCALE_SW_H,
46         EOPT_SCALE_HW_H,
47         EOPT_SCALE_HW_HV,
48 };
49
50 typedef struct _currentConfig_t {
51         int EmuOpt;
52         int s_PicoOpt;
53         int s_PsndRate;
54         int s_PicoRegion;
55         int s_PicoAutoRgnOrder;
56         int s_PicoCDBuffers;
57         int Frameskip;
58         int CPUclock;
59         int volume;
60         int gamma;
61         int scaling;  // gp2x: 0=center, 1=hscale, 2=hvscale, 3=hsoftscale; psp: bilinear filtering
62         int rotation; // for UIQ
63         float scale; // psp: screen scale
64         float hscale32, hscale40; // psp: horizontal scale
65         int gamma2;  // psp: black level
66         int turbo_rate;
67 } currentConfig_t;
68
69 extern currentConfig_t currentConfig, defaultConfig;
70 extern char *PicoConfigFile;
71 extern int rom_loaded;
72 extern int state_slot;
73 extern int config_slot, config_slot_current;
74 extern unsigned char *movie_data;
75 extern int reset_timing;
76
77 #define PICO_PEN_ADJUST_X 4
78 #define PICO_PEN_ADJUST_Y 2
79 extern int pico_pen_x, pico_pen_y;
80 extern int pico_inp_mode;
81
82 extern char rom_fname_reload[512];              // ROM to try loading on next PGS_ReloadRom
83 extern char rom_fname_loaded[512];              // currently loaded ROM filename
84
85 // engine states
86 extern int engineState;
87 enum TPicoGameState {
88         PGS_Paused = 1,
89         PGS_Running,
90         PGS_Quit,
91         PGS_KeyConfig,
92         PGS_ReloadRom,
93         PGS_Menu,
94         PGS_RestartRun,
95         PGS_Suspending,         /* PSP */
96         PGS_SuspendWake,        /* PSP */
97 };
98
99
100 void  emu_init(void);
101 void  emu_finish(void);
102 void  emu_loop(void);
103
104 int   emu_reload_rom(char *rom_fname);
105 int   emu_save_load_game(int load, int sram);
106 void  emu_reset_game(void);
107
108 void  emu_set_defconfig(void);
109 int   emu_read_config(int game, int no_defaults);
110 int   emu_write_config(int game);
111
112 char *emu_get_save_fname(int load, int is_sram, int slot);
113 int   emu_check_save_file(int slot);
114 void  emu_setSaveStateCbs(int gz);
115
116 void  emu_text_out8 (int x, int y, const char *text);
117 void  emu_text_out16(int x, int y, const char *text);
118 void  emu_text_out8_rot (int x, int y, const char *text);
119 void  emu_text_out16_rot(int x, int y, const char *text);
120
121 void  emu_make_path(char *buff, const char *end, int size);
122 void  emu_update_input(void);
123 void  emu_get_game_name(char *str150);
124 void  emu_set_fastforward(int set_on);
125 int   emu_cd_check(int *pregion, char *fname_in);
126 void  emu_status_msg(const char *format, ...);
127
128 #ifdef __cplusplus
129 } // extern "C"
130 #endif
131