From 0dae02030302c1a2eb1ecf299d92a8c8a92fcdaf Mon Sep 17 00:00:00 2001 From: Dominic Szablewski Date: Sun, 12 May 2024 21:52:34 +0200 Subject: [PATCH] Load music and intro movie from the platform's asset path --- src/platform.h | 1 + src/platform_sdl.c | 5 +++++ src/platform_sokol.c | 5 +++++ src/wipeout/intro.c | 9 ++++++++- src/wipeout/sfx.c | 4 ++-- 5 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/platform.h b/src/platform.h index 9e93904..3219269 100644 --- a/src/platform.h +++ b/src/platform.h @@ -10,6 +10,7 @@ bool platform_get_fullscreen(void); void platform_set_fullscreen(bool fullscreen); void platform_set_audio_mix_cb(void (*cb)(float *buffer, uint32_t len)); +FILE *platform_open_asset(const char *name, const char *mode); uint8_t *platform_load_asset(const char *name, uint32_t *bytes_read); uint8_t *platform_load_userdata(const char *name, uint32_t *bytes_read); uint32_t platform_store_userdata(const char *name, void *bytes, int32_t len); diff --git a/src/platform_sdl.c b/src/platform_sdl.c index 31e1ee0..1e68328 100755 --- a/src/platform_sdl.c +++ b/src/platform_sdl.c @@ -228,6 +228,11 @@ void platform_set_audio_mix_cb(void (*cb)(float *buffer, uint32_t len)) { } +FILE *platform_open_asset(const char *name, const char *mode) { + char *path = strcat(strcpy(temp_path, path_assets), name); + return fopen(path, mode); +} + uint8_t *platform_load_asset(const char *name, uint32_t *bytes_read) { char *path = strcat(strcpy(temp_path, path_assets), name); return file_load(path, bytes_read); diff --git a/src/platform_sokol.c b/src/platform_sokol.c index e06a332..710c875 100644 --- a/src/platform_sokol.c +++ b/src/platform_sokol.c @@ -264,6 +264,11 @@ void platform_set_audio_mix_cb(void (*cb)(float *buffer, uint32_t len)) { audio_callback = cb; } +FILE *platform_open_asset(const char *name, const char *mode) { + char *path = strcat(strcpy(temp_path, path_assets), name); + return fopen(path, mode); +} + uint8_t *platform_load_asset(const char *name, uint32_t *bytes_read) { char *path = strcat(strcpy(temp_path, path_assets), name); return file_load(path, bytes_read); diff --git a/src/wipeout/intro.c b/src/wipeout/intro.c index c252b49..0de5c98 100644 --- a/src/wipeout/intro.c +++ b/src/wipeout/intro.c @@ -3,6 +3,7 @@ #include "../utils.h" #include "../types.h" #include "../mem.h" +#include "../platform.h" #include "intro.h" #include "ui.h" @@ -36,7 +37,13 @@ static void audio_mix(float *samples, uint32_t len); static void intro_end(void); void intro_init(void) { - plm = plm_create_with_filename("wipeout/intro.mpeg"); + FILE *file = platform_open_asset("wipeout/intro.mpeg", "rb"); + if (!file) { + intro_end(); + return; + } + + plm = plm_create_with_file(file, true); if (!plm) { intro_end(); return; diff --git a/src/wipeout/sfx.c b/src/wipeout/sfx.c index a7a33a1..2d4d319 100644 --- a/src/wipeout/sfx.c +++ b/src/wipeout/sfx.c @@ -251,8 +251,8 @@ void sfx_music_open(char *path) { fclose(music->file); music->file = NULL; } - - FILE *file = fopen(path, "rb"); + + FILE *file = platform_open_asset(path, "rb"); if (!file) { return; }