move all the discordrpc stuff to pc_main.c

that means it will now work in D3D11 and D3D12

also 'normalized' the sdl2 main loop
This commit is contained in:
fgsfds 2020-06-13 04:21:47 +03:00
parent b673f38516
commit 208bfdcbf3
3 changed files with 21 additions and 29 deletions

View File

@ -23,10 +23,6 @@
#include "gfx_dimensions.h"
#ifdef DISCORDRPC
#include "pc/discord/discordrpc.h"
#endif
struct SpawnInfo gPlayerSpawnInfos[1];
struct GraphNode *D_8033A160[0x100];
struct Area gAreaData[8];
@ -425,8 +421,4 @@ void render_game(void) {
D_8032CE74 = NULL;
D_8032CE78 = 0;
#ifdef DISCORDRPC
discord_update_rich_presence();
#endif
}

View File

@ -34,10 +34,6 @@
#include "src/pc/controller/controller_keyboard.h"
#ifdef DISCORDRPC
#include "pc/discord/discordrpc.h"
#endif
// TODO: figure out if this shit even works
#ifdef VERSION_EU
# define FRAMERATE 25
@ -50,7 +46,6 @@ static const Uint32 FRAME_TIME = 1000 / FRAMERATE;
static SDL_Window *wnd;
static SDL_GLContext ctx = NULL;
static int inverted_scancode_table[512];
static Uint32 frame_start = 0;
static kb_callback_t kb_key_down = NULL;
static kb_callback_t kb_key_up = NULL;
@ -189,17 +184,11 @@ static void gfx_sdl_init(const char *window_title) {
}
static void gfx_sdl_main_loop(void (*run_one_game_iter)(void)) {
Uint32 t;
#ifdef DISCORDRPC
discord_init();
#endif
while (1) {
t = SDL_GetTicks();
run_one_game_iter();
t = SDL_GetTicks() - t;
if (t < FRAME_TIME && configWindow.vsync <= 1)
SDL_Delay(FRAME_TIME - t);
}
Uint32 t = SDL_GetTicks();
run_one_game_iter();
t = SDL_GetTicks() - t;
if (t < FRAME_TIME && configWindow.vsync <= 1)
SDL_Delay(FRAME_TIME - t);
}
static void gfx_sdl_get_dimensions(uint32_t *width, uint32_t *height) {
@ -261,9 +250,6 @@ static void gfx_sdl_handle_events(void) {
}
break;
case SDL_QUIT:
#ifdef DISCORDRPC
discord_shutdown();
#endif
game_exit();
break;
}
@ -283,7 +269,6 @@ static void gfx_sdl_set_keyboard_callbacks(kb_callback_t on_key_down, kb_callbac
}
static bool gfx_sdl_start_frame(void) {
frame_start = SDL_GetTicks();
return true;
}

View File

@ -32,6 +32,10 @@
#include "game/main.h"
#include "game/thread6.h"
#ifdef DISCORDRPC
#include "pc/discord/discordrpc.h"
#endif
OSMesg D_80339BEC;
OSMesgQueue gSIEventMesgQueue;
@ -106,6 +110,9 @@ void audio_shutdown(void) {
}
void game_deinit(void) {
#ifdef DISCORDRPC
discord_shutdown();
#endif
configfile_save(configfile_name());
controller_shutdown();
audio_shutdown();
@ -228,12 +235,20 @@ void main_func(void) {
}
#endif
#ifdef DISCORDRPC
discord_init();
#endif
#ifdef TARGET_WEB
emscripten_set_main_loop(em_main_loop, 0, 0);
request_anim_frame(on_anim_frame);
#else
while (true)
while (true) {
wm_api->main_loop(produce_one_frame);
#ifdef DISCORDRPC
discord_update_rich_presence();
#endif
}
#endif
}