Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revamp the protocol used between the GUI and the emulator. #51

Merged
merged 7 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
shell: msys2 {0}
steps:
- name: 'Sync source code'
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Install Dependencies
Expand All @@ -26,7 +26,7 @@ jobs:
run: |
./build/Hades.exe --help
- name: Collect Artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: hades-win64
path: build/Hades.exe
Expand All @@ -36,7 +36,7 @@ jobs:
runs-on: macos-latest
steps:
- name: 'Sync source code'
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Install Dependencies
Expand Down Expand Up @@ -121,7 +121,7 @@ jobs:
MACOS_APPLE_TEAMID: ${{ secrets.MACOS_APPLE_TEAMID }}

- name: Collect Artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: hades-macos
path: Hades-Installer.dmg
Expand All @@ -131,7 +131,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 'Sync source code'
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Install Dependencies
Expand All @@ -147,7 +147,7 @@ jobs:
run: |
./build/hades --help
- name: Collect Artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: hades-linux
path: build/hades
Expand Down
91 changes: 68 additions & 23 deletions include/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#define MAX_RECENT_ROMS 5
#define MAX_QUICKSAVES 5
#define POWER_SAVE_FRAME_DELAY 30
#define MAX_GFX_PROGRAMS 10

struct ImGuiIO;

Expand Down Expand Up @@ -88,11 +89,20 @@ extern char const * const binds_slug[];
struct app {
atomic_bool run;

struct args {
char const *rom_path;
char const *bios_path;
} args;

struct {
struct gba *gba;
struct launch_config *launch_config;
struct game_entry *game_entry;

FILE *backup_file;

bool started;
bool running;
bool is_started;
bool is_running;

// Current FPS
uint32_t fps;
Expand All @@ -105,18 +115,33 @@ struct app {
bool skip_bios;

// Backup storage
enum backup_storage_types backup_type;
struct {
bool autodetect;
enum backup_storage_types type;
} backup_storage;

// RTC
bool rtc_autodetect;
bool rtc_force_enabled;
struct {
bool autodetect;
bool enabled;
} rtc;

// The current quicksave request
struct {
bool enabled;
size_t idx;
} quicksave_request;

// The current quickload request
struct {
bool enabled;
void *data;
} quickload_request;
} emulation;

struct {
SDL_Window *window;
SDL_GLContext gl_context;
SDL_AudioDeviceID audio_device;
GLuint game_texture;

/* Game controller */
struct {
Expand All @@ -132,41 +157,48 @@ struct app {
} controller;
} sdl;

struct {
SDL_GLContext gl_context;

enum texture_filter_kind texture_filter;
GLuint game_texture_in;
GLuint game_texture_out;
GLuint fbo;
GLuint vao;
GLuint vbo;

GLuint program_color_correction;

GLuint active_programs[MAX_GFX_PROGRAMS];
size_t active_programs_length;
} gfx;

struct {
char *config_path;

char *bios_path;
char *game_path;
char *recent_roms[MAX_RECENT_ROMS];

char *backup_path;
FILE *backup_file;

struct {
char *path;
char *mtime;
bool exist;
} qsaves[MAX_QUICKSAVES];

bool flush_qsaves_cache;
bool flush_qsaves_cache; // Set to true if the `mtime` and `exist` field of `qsaves` needs to be refreshed.
} file;

struct {
uint32_t display_size;
enum aspect_ratio aspect_ratio;
bool vsync;
bool color_correction;

struct {
enum texture_filter_kind kind;
bool refresh;
} texture_filter;

} video;

struct {
bool mute;
float level;
uint32_t resample_frequency;
} audio;

struct {
Expand Down Expand Up @@ -244,6 +276,9 @@ struct app {

#if WITH_DEBUGGER
struct {
bool is_running;
bool is_started;

csh handle_arm; // Capstone handle for ARM mode
csh handle_thumb; // Capstone handle for Thumb mode

Expand All @@ -260,17 +295,27 @@ struct app {
};

/* common/game.c */
void app_game_reset(struct app *app);
void app_game_process_all_notifs(struct app *app);
bool app_game_configure(struct app *app, char const *rom_path);
void app_game_stop(struct app *app);
void app_game_run(struct app *app);
void app_game_pause(struct app *app);
void app_game_write_backup(struct app *app);
void app_game_reset(struct app *app);
void app_game_exit(struct app *app);
void app_game_key(struct app *app, enum keys key, bool pressed);
void app_game_speed(struct app *app, uint32_t);
void app_game_update_backup(struct app *app);
void app_game_screenshot(struct app *app);
void app_game_quicksave(struct app *, size_t);
void app_game_quickload(struct app *, size_t);
void app_game_quicksave(struct app *app, size_t idx);
void app_game_quickload(struct app *app, size_t idx);

#ifdef WITH_DEBUGGER

void app_game_frame(struct app *app);
void app_game_trace(struct app *app, size_t, void (*)(struct app *));
void app_game_step(struct app *app, bool over, size_t cnt);
void app_game_step_in(struct app *app, size_t cnt);
void app_game_step_over(struct app *app, size_t cnt);
void app_game_set_breakpoints_list(struct app *app, struct breakpoint *breakpoints, size_t len);
void app_game_set_watchpoints_list(struct app *app, struct watchpoint *watchpoints, size_t len);

#endif
44 changes: 44 additions & 0 deletions include/common/channel/channel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/******************************************************************************\
**
** This file is part of the Hades GBA Emulator, and is made available under
** the terms of the GNU General Public License version 2.
**
** Copyright (C) 2021-2023 - The Hades Authors
**
\******************************************************************************/

#pragma once

#include "hades.h"

struct event_header {
int32_t kind;
size_t size;
};

struct channel {
struct event_header *events; // An array of events.
size_t length; // The number of event in `events`
size_t size; // The sum of the size of all the events in `events`
size_t allocated_size; // The size of the allocation of `events`

pthread_mutex_t lock;
pthread_cond_t ready;
};

struct channels {
struct channel messages; // Sent by the frontned to the emulator
struct channel notifications; // Sent by the emulator to the frontend
#ifdef WITH_DEBUGGER
struct channel debug; // Sent by the emulator to the debugger
#endif
};

/* channel.c */
void channel_init(struct channel *channel);
void channel_lock(struct channel *channel);
void channel_release(struct channel *channel);
void channel_push(struct channel *channel, struct event_header const *event);
void channel_wait(struct channel *channel);
struct event_header const *channel_next(struct channel const *channel, struct event_header const *event);
void channel_clear(struct channel *channel);
Loading