2017-10-04 12:43:31 +03:00
|
|
|
#ifndef gui_h
|
|
|
|
#define gui_h
|
|
|
|
|
2019-06-25 21:01:54 -06:00
|
|
|
#include <SDL.h>
|
2017-10-14 14:10:26 +03:00
|
|
|
#include <Core/gb.h>
|
2018-05-27 19:30:23 +03:00
|
|
|
#include <stdbool.h>
|
2017-12-23 17:29:42 +02:00
|
|
|
#include "shader.h"
|
2017-10-04 12:43:31 +03:00
|
|
|
|
2018-06-26 19:36:14 +03:00
|
|
|
#define JOYSTICK_HIGH 0x4000
|
|
|
|
#define JOYSTICK_LOW 0x3800
|
|
|
|
|
2019-06-01 14:29:46 +03:00
|
|
|
#ifdef __APPLE__
|
|
|
|
#define MODIFIER KMOD_GUI
|
|
|
|
#else
|
|
|
|
#define MODIFIER KMOD_CTRL
|
|
|
|
#endif
|
|
|
|
|
2018-06-23 00:10:28 +03:00
|
|
|
extern GB_gameboy_t gb;
|
2018-05-27 19:30:23 +03:00
|
|
|
|
2017-10-04 12:43:31 +03:00
|
|
|
extern SDL_Window *window;
|
|
|
|
extern SDL_Renderer *renderer;
|
|
|
|
extern SDL_Texture *texture;
|
|
|
|
extern SDL_PixelFormat *pixel_format;
|
2020-05-24 23:04:36 +03:00
|
|
|
extern SDL_Haptic *haptic;
|
2017-12-23 17:29:42 +02:00
|
|
|
extern shader_t shader;
|
2017-10-04 12:43:31 +03:00
|
|
|
|
|
|
|
enum scaling_mode {
|
|
|
|
GB_SDL_SCALING_ENTIRE_WINDOW,
|
|
|
|
GB_SDL_SCALING_KEEP_RATIO,
|
|
|
|
GB_SDL_SCALING_INTEGER_FACTOR,
|
|
|
|
GB_SDL_SCALING_MAX,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2017-10-14 01:41:51 +03:00
|
|
|
enum pending_command {
|
|
|
|
GB_SDL_NO_COMMAND,
|
|
|
|
GB_SDL_SAVE_STATE_COMMAND,
|
|
|
|
GB_SDL_LOAD_STATE_COMMAND,
|
|
|
|
GB_SDL_RESET_COMMAND,
|
|
|
|
GB_SDL_NEW_FILE_COMMAND,
|
2017-10-14 14:10:26 +03:00
|
|
|
GB_SDL_QUIT_COMMAND,
|
2021-04-14 15:20:01 +03:00
|
|
|
GB_SDL_LOAD_STATE_FROM_FILE_COMMAND,
|
2017-10-14 01:41:51 +03:00
|
|
|
};
|
|
|
|
|
2020-08-06 03:08:19 +02:00
|
|
|
#define GB_SDL_DEFAULT_SCALE_MAX 8
|
2018-06-23 22:27:05 +03:00
|
|
|
|
2017-10-14 01:41:51 +03:00
|
|
|
extern enum pending_command pending_command;
|
|
|
|
extern unsigned command_parameter;
|
2021-04-14 15:20:01 +03:00
|
|
|
extern char *dropped_state_file;
|
2018-06-23 22:27:05 +03:00
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
JOYPAD_BUTTON_RIGHT,
|
2021-10-09 15:27:18 +03:00
|
|
|
JOYPAD_BUTTON_LEFT,
|
2018-06-23 22:27:05 +03:00
|
|
|
JOYPAD_BUTTON_UP,
|
|
|
|
JOYPAD_BUTTON_DOWN,
|
|
|
|
JOYPAD_BUTTON_A,
|
|
|
|
JOYPAD_BUTTON_B,
|
|
|
|
JOYPAD_BUTTON_SELECT,
|
|
|
|
JOYPAD_BUTTON_START,
|
|
|
|
JOYPAD_BUTTON_MENU,
|
|
|
|
JOYPAD_BUTTON_TURBO,
|
|
|
|
JOYPAD_BUTTON_REWIND,
|
|
|
|
JOYPAD_BUTTON_SLOW_MOTION,
|
|
|
|
JOYPAD_BUTTONS_MAX
|
|
|
|
} joypad_button_t;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
JOYPAD_AXISES_X,
|
|
|
|
JOYPAD_AXISES_Y,
|
|
|
|
JOYPAD_AXISES_MAX
|
|
|
|
} joypad_axis_t;
|
|
|
|
|
2017-12-22 22:25:53 +02:00
|
|
|
typedef struct {
|
|
|
|
SDL_Scancode keys[9];
|
|
|
|
GB_color_correction_mode_t color_correction_mode;
|
|
|
|
enum scaling_mode scaling_mode;
|
2020-03-26 20:54:18 +02:00
|
|
|
uint8_t blending_mode;
|
2017-12-23 00:39:04 +02:00
|
|
|
|
2017-12-23 21:11:44 +02:00
|
|
|
GB_highpass_mode_t highpass_mode;
|
|
|
|
|
2018-06-23 22:27:05 +03:00
|
|
|
bool _deprecated_div_joystick;
|
|
|
|
bool _deprecated_flip_joystick_bit_1;
|
|
|
|
bool _deprecated_swap_joysticks_bits_1_and_2;
|
2017-12-23 17:29:42 +02:00
|
|
|
|
|
|
|
char filter[32];
|
2018-01-13 13:49:20 +02:00
|
|
|
enum {
|
|
|
|
MODEL_DMG,
|
|
|
|
MODEL_CGB,
|
|
|
|
MODEL_AGB,
|
2019-05-18 18:45:31 +03:00
|
|
|
MODEL_SGB,
|
2021-10-23 23:28:54 +03:00
|
|
|
MODEL_MGB,
|
2018-01-13 13:49:20 +02:00
|
|
|
MODEL_MAX,
|
|
|
|
} model;
|
2018-06-23 00:10:28 +03:00
|
|
|
|
|
|
|
/* v0.11 */
|
|
|
|
uint32_t rewind_length;
|
2018-06-23 22:27:05 +03:00
|
|
|
SDL_Scancode keys_2[32]; /* Rewind and underclock, + padding for the future */
|
|
|
|
uint8_t joypad_configuration[32]; /* 12 Keys + padding for the future*/;
|
|
|
|
uint8_t joypad_axises[JOYPAD_AXISES_MAX];
|
2019-05-18 20:37:41 +03:00
|
|
|
|
|
|
|
/* v0.12 */
|
|
|
|
enum {
|
|
|
|
SGB_NTSC,
|
|
|
|
SGB_PAL,
|
|
|
|
SGB_2,
|
|
|
|
SGB_MAX
|
|
|
|
} sgb_revision;
|
2020-01-29 15:36:19 +02:00
|
|
|
|
|
|
|
/* v0.13 */
|
|
|
|
uint8_t dmg_palette;
|
2020-02-08 13:28:46 +02:00
|
|
|
GB_border_mode_t border_mode;
|
2020-03-27 19:10:42 +03:00
|
|
|
uint8_t volume;
|
2020-05-24 23:04:36 +03:00
|
|
|
GB_rumble_mode_t rumble_mode;
|
2020-08-06 03:08:19 +02:00
|
|
|
|
|
|
|
uint8_t default_scale;
|
2020-12-25 14:14:17 +02:00
|
|
|
|
|
|
|
/* v0.14 */
|
|
|
|
unsigned padding;
|
|
|
|
uint8_t color_temperature;
|
2020-12-26 15:10:11 +02:00
|
|
|
char bootrom_path[4096];
|
2020-12-31 00:06:36 +02:00
|
|
|
uint8_t interference_volume;
|
2021-02-26 01:04:24 +02:00
|
|
|
GB_rtc_mode_t rtc_mode;
|
2021-05-30 23:39:59 +03:00
|
|
|
|
|
|
|
/* v0.14.4 */
|
|
|
|
bool osd;
|
2022-07-02 18:11:55 +03:00
|
|
|
|
|
|
|
struct __attribute__((packed, aligned(4))) {
|
|
|
|
|
2022-06-10 23:51:06 +03:00
|
|
|
/* v0.15 */
|
|
|
|
bool allow_mouse_controls;
|
2022-07-02 18:11:55 +03:00
|
|
|
uint8_t cgb_revision;
|
|
|
|
|
|
|
|
};
|
2017-12-22 22:25:53 +02:00
|
|
|
} configuration_t;
|
|
|
|
|
|
|
|
extern configuration_t configuration;
|
2017-10-14 01:41:51 +03:00
|
|
|
|
2017-10-04 12:43:31 +03:00
|
|
|
void update_viewport(void);
|
2017-10-14 01:41:51 +03:00
|
|
|
void run_gui(bool is_running);
|
2017-12-23 17:29:42 +02:00
|
|
|
void render_texture(void *pixels, void *previous);
|
2018-11-10 19:39:57 +02:00
|
|
|
void connect_joypad(void);
|
2017-12-23 00:39:04 +02:00
|
|
|
|
2018-06-23 22:27:05 +03:00
|
|
|
joypad_button_t get_joypad_button(uint8_t physical_button);
|
|
|
|
joypad_axis_t get_joypad_axis(uint8_t physical_axis);
|
|
|
|
|
2020-12-23 23:50:19 +02:00
|
|
|
static SDL_Scancode event_hotkey_code(SDL_Event *event)
|
|
|
|
{
|
|
|
|
if (event->key.keysym.sym >= SDLK_a && event->key.keysym.sym < SDLK_z) {
|
|
|
|
return SDL_SCANCODE_A + event->key.keysym.sym - SDLK_a;
|
|
|
|
}
|
|
|
|
|
|
|
|
return event->key.keysym.scancode;
|
|
|
|
}
|
|
|
|
|
2021-05-30 23:39:59 +03:00
|
|
|
void draw_text(uint32_t *buffer, unsigned width, unsigned height, unsigned x, signed y, const char *string, uint32_t color, uint32_t border, bool is_osd);
|
|
|
|
void show_osd_text(const char *text);
|
|
|
|
extern const char *osd_text;
|
|
|
|
extern unsigned osd_countdown;
|
|
|
|
extern unsigned osd_text_lines;
|
2022-06-10 23:51:06 +03:00
|
|
|
void convert_mouse_coordinates(signed *x, signed *y);
|
2021-05-30 23:39:59 +03:00
|
|
|
|
2017-10-04 12:43:31 +03:00
|
|
|
#endif
|