2017-10-04 09:43:31 +00:00
|
|
|
#ifndef gui_h
|
|
|
|
#define gui_h
|
|
|
|
|
|
|
|
#include <SDL2/SDL.h>
|
2017-10-14 11:10:26 +00:00
|
|
|
#include <Core/gb.h>
|
2018-05-27 16:30:23 +00:00
|
|
|
#include <stdbool.h>
|
2017-12-23 15:29:42 +00:00
|
|
|
#include "shader.h"
|
2017-10-04 09:43:31 +00:00
|
|
|
|
2018-06-26 16:36:14 +00:00
|
|
|
#define JOYSTICK_HIGH 0x4000
|
|
|
|
#define JOYSTICK_LOW 0x3800
|
|
|
|
|
2018-06-22 21:10:28 +00:00
|
|
|
extern GB_gameboy_t gb;
|
2018-05-27 16:30:23 +00:00
|
|
|
|
2017-10-04 09:43:31 +00:00
|
|
|
extern SDL_Window *window;
|
|
|
|
extern SDL_Renderer *renderer;
|
|
|
|
extern SDL_Texture *texture;
|
|
|
|
extern SDL_PixelFormat *pixel_format;
|
2017-12-23 15:29:42 +00:00
|
|
|
extern shader_t shader;
|
2017-10-04 09:43:31 +00: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-13 22:41:51 +00: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 11:10:26 +00:00
|
|
|
GB_SDL_QUIT_COMMAND,
|
2017-10-13 22:41:51 +00:00
|
|
|
};
|
|
|
|
|
2018-06-23 19:27:05 +00:00
|
|
|
|
2017-10-13 22:41:51 +00:00
|
|
|
extern enum pending_command pending_command;
|
|
|
|
extern unsigned command_parameter;
|
2018-06-23 19:27:05 +00:00
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
JOYPAD_BUTTON_LEFT,
|
|
|
|
JOYPAD_BUTTON_RIGHT,
|
|
|
|
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 20:25:53 +00:00
|
|
|
typedef struct {
|
|
|
|
SDL_Scancode keys[9];
|
|
|
|
GB_color_correction_mode_t color_correction_mode;
|
|
|
|
enum scaling_mode scaling_mode;
|
2017-12-23 15:41:47 +00:00
|
|
|
bool blend_frames;
|
2017-12-22 22:39:04 +00:00
|
|
|
|
2017-12-23 19:11:44 +00:00
|
|
|
GB_highpass_mode_t highpass_mode;
|
|
|
|
|
2018-06-23 19:27:05 +00:00
|
|
|
bool _deprecated_div_joystick;
|
|
|
|
bool _deprecated_flip_joystick_bit_1;
|
|
|
|
bool _deprecated_swap_joysticks_bits_1_and_2;
|
2017-12-23 15:29:42 +00:00
|
|
|
|
|
|
|
char filter[32];
|
2018-01-13 11:49:20 +00:00
|
|
|
enum {
|
|
|
|
MODEL_DMG,
|
|
|
|
MODEL_CGB,
|
|
|
|
MODEL_AGB,
|
|
|
|
MODEL_MAX,
|
|
|
|
} model;
|
2018-06-22 21:10:28 +00:00
|
|
|
|
|
|
|
/* v0.11 */
|
|
|
|
uint32_t rewind_length;
|
2018-06-23 19:27:05 +00: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];
|
2017-12-22 20:25:53 +00:00
|
|
|
} configuration_t;
|
|
|
|
|
|
|
|
extern configuration_t configuration;
|
2017-10-13 22:41:51 +00:00
|
|
|
|
2017-10-04 09:43:31 +00:00
|
|
|
void update_viewport(void);
|
2017-10-13 22:41:51 +00:00
|
|
|
void run_gui(bool is_running);
|
2017-12-23 15:29:42 +00:00
|
|
|
void render_texture(void *pixels, void *previous);
|
2017-12-22 22:39:04 +00:00
|
|
|
|
2018-06-23 19:27:05 +00:00
|
|
|
joypad_button_t get_joypad_button(uint8_t physical_button);
|
|
|
|
joypad_axis_t get_joypad_axis(uint8_t physical_axis);
|
|
|
|
|
2017-10-04 09:43:31 +00:00
|
|
|
#endif
|