diff options
author | Franklin Wei <git@fwei.tk> | 2018-02-11 15:34:30 -0500 |
---|---|---|
committer | Franklin Wei <git@fwei.tk> | 2019-07-19 22:37:40 -0400 |
commit | 5d05b9d3e920a6aa5fcb553758e98ed0da8c91e4 (patch) | |
tree | 84406e21639529a185556a33e5de7f43cffc277b /apps/plugins/sdl/src | |
parent | b70fecf21ddc21877ec1ae7888d9c18a979e37ad (diff) | |
download | rockbox-5d05b9d3e920a6aa5fcb553758e98ed0da8c91e4.tar.gz rockbox-5d05b9d3e920a6aa5fcb553758e98ed0da8c91e4.zip |
Quake!
This ports id Software's Quake to run on the SDL plugin runtime. The
source code originated from id under the GPLv2 license. I used
https://github.com/ahefner/sdlquake as the base of my port.
Performance is, unsurprisingly, not on par with what you're probably
used to on PC. I average about 10FPS on ipod6g, but it's still
playable.
Sound works well enough, but in-game music is not supported. I've
written ARM assembly routines for the inner sound loop. Make sure you
turn the "brightness" all the way down, or colors will look funky.
To run, extract Quake's data files to /.rockbox/quake. Have fun!
Change-Id: I4285036e967d7f0722802d43cf2096c808ca5799
Diffstat (limited to 'apps/plugins/sdl/src')
5 files changed, 23 insertions, 4 deletions
diff --git a/apps/plugins/sdl/src/audio/SDL_audio.c b/apps/plugins/sdl/src/audio/SDL_audio.c index 9c0feeddfc..f2a2e59323 100644 --- a/apps/plugins/sdl/src/audio/SDL_audio.c +++ b/apps/plugins/sdl/src/audio/SDL_audio.c | |||
@@ -204,6 +204,7 @@ int SDLCALL SDL_RunAudio(void *audiop) | |||
204 | 204 | ||
205 | /* Convert the audio if necessary */ | 205 | /* Convert the audio if necessary */ |
206 | if ( audio->convert.needed ) { | 206 | if ( audio->convert.needed ) { |
207 | LOGF("RB AUDIO: converting audio. Will be slow!"); | ||
207 | SDL_ConvertAudio(&audio->convert); | 208 | SDL_ConvertAudio(&audio->convert); |
208 | stream = audio->GetAudioBuf(audio); | 209 | stream = audio->GetAudioBuf(audio); |
209 | if ( stream == NULL ) { | 210 | if ( stream == NULL ) { |
diff --git a/apps/plugins/sdl/src/audio/rockbox/SDL_rockboxaudio.c b/apps/plugins/sdl/src/audio/rockbox/SDL_rockboxaudio.c index 78334303af..cb72687d48 100644 --- a/apps/plugins/sdl/src/audio/rockbox/SDL_rockboxaudio.c +++ b/apps/plugins/sdl/src/audio/rockbox/SDL_rockboxaudio.c | |||
@@ -225,12 +225,29 @@ static void ROCKBOXAUD_CloseAudio(_THIS) | |||
225 | rb->pcm_set_frequency(HW_SAMPR_DEFAULT); | 225 | rb->pcm_set_frequency(HW_SAMPR_DEFAULT); |
226 | } | 226 | } |
227 | 227 | ||
228 | static bool freq_ok(unsigned int freq) | ||
229 | { | ||
230 | for(int i = 0; i < SAMPR_NUM_FREQ; i++) | ||
231 | { | ||
232 | if(rb->hw_freq_sampr[i] == freq) | ||
233 | return true; | ||
234 | } | ||
235 | return false; | ||
236 | } | ||
237 | |||
228 | static int ROCKBOXAUD_OpenAudio(_THIS, SDL_AudioSpec *spec) | 238 | static int ROCKBOXAUD_OpenAudio(_THIS, SDL_AudioSpec *spec) |
229 | { | 239 | { |
230 | /* change to our format */ | 240 | /* change to our format */ |
231 | spec->format = AUDIO_S16SYS; | 241 | spec->format = AUDIO_S16SYS; |
232 | spec->channels = 2; | 242 | spec->channels = 2; |
233 | spec->freq = RB_SAMPR; | 243 | |
244 | if(!freq_ok(spec->freq)) | ||
245 | { | ||
246 | rb->splashf(HZ, "Warning: Unsupported audio rate. Defaulting to %d Hz", RB_SAMPR); | ||
247 | |||
248 | // switch to default | ||
249 | spec->freq = RB_SAMPR; | ||
250 | } | ||
234 | 251 | ||
235 | /* we've changed it */ | 252 | /* we've changed it */ |
236 | SDL_CalculateAudioSpec(spec); | 253 | SDL_CalculateAudioSpec(spec); |
diff --git a/apps/plugins/sdl/src/thread/rockbox/SDL_systhread.c b/apps/plugins/sdl/src/thread/rockbox/SDL_systhread.c index f9dc877815..b9bd8735d3 100644 --- a/apps/plugins/sdl/src/thread/rockbox/SDL_systhread.c +++ b/apps/plugins/sdl/src/thread/rockbox/SDL_systhread.c | |||
@@ -51,13 +51,13 @@ int SDL_SYS_CreateThread(SDL_Thread *thread, void *args) | |||
51 | static int threadnum = 0; | 51 | static int threadnum = 0; |
52 | snprintf(names[threadnum], 16, "sdl_%d", threadnum); | 52 | snprintf(names[threadnum], 16, "sdl_%d", threadnum); |
53 | 53 | ||
54 | while(global_args) rb->yield(); /* busy wait */ | 54 | while(global_args) rb->yield(); /* busy wait, pray that this works */ |
55 | 55 | ||
56 | global_args = args; | 56 | global_args = args; |
57 | 57 | ||
58 | thread->handle = rb->create_thread(rbsdl_runthread, stacks[threadnum], DEFAULT_STACK_SIZE, | 58 | thread->handle = rb->create_thread(rbsdl_runthread, stacks[threadnum], DEFAULT_STACK_SIZE, |
59 | 0, names[threadnum] /* collisions allowed? */ | 59 | 0, names[threadnum] /* collisions allowed? */ |
60 | IF_PRIO(, PRIORITY_USER_INTERFACE) | 60 | IF_PRIO(, PRIORITY_BUFFERING) // this is used for sound mixing |
61 | IF_COP(, CPU)); | 61 | IF_COP(, CPU)); |
62 | 62 | ||
63 | threadnum++; | 63 | threadnum++; |
diff --git a/apps/plugins/sdl/src/timer/rockbox/SDL_systimer.c b/apps/plugins/sdl/src/timer/rockbox/SDL_systimer.c index f4e886260c..8da84552c5 100644 --- a/apps/plugins/sdl/src/timer/rockbox/SDL_systimer.c +++ b/apps/plugins/sdl/src/timer/rockbox/SDL_systimer.c | |||
@@ -28,6 +28,7 @@ | |||
28 | 28 | ||
29 | #include "plugin.h" | 29 | #include "plugin.h" |
30 | 30 | ||
31 | /* color because greylib will use timer otherwise */ | ||
31 | #if defined(HAVE_LCD_COLOR) && !defined(SIMULATOR) && !defined(RB_PROFILE) | 32 | #if defined(HAVE_LCD_COLOR) && !defined(SIMULATOR) && !defined(RB_PROFILE) |
32 | #define USE_TIMER | 33 | #define USE_TIMER |
33 | #endif | 34 | #endif |
diff --git a/apps/plugins/sdl/src/video/rockbox/SDL_rockboxvideo.c b/apps/plugins/sdl/src/video/rockbox/SDL_rockboxvideo.c index 58de15754d..3a12d984b8 100644 --- a/apps/plugins/sdl/src/video/rockbox/SDL_rockboxvideo.c +++ b/apps/plugins/sdl/src/video/rockbox/SDL_rockboxvideo.c | |||
@@ -769,8 +769,8 @@ static void ROCKBOX_UpdateRects(_THIS, int numrects, SDL_Rect *rects) | |||
769 | /* FIXME: this won't work for rotated screen or overlapping rects */ | 769 | /* FIXME: this won't work for rotated screen or overlapping rects */ |
770 | flip_pixels(rects[i].x, rects[i].y, rects[i].w, rects[i].h); | 770 | flip_pixels(rects[i].x, rects[i].y, rects[i].w, rects[i].h); |
771 | #endif | 771 | #endif |
772 | rb->lcd_update_rect(rects[i].x, rects[i].y, rects[i].w, rects[i].h); | ||
772 | } /* for */ | 773 | } /* for */ |
773 | rb->lcd_update(); | ||
774 | } /* if */ | 774 | } /* if */ |
775 | } | 775 | } |
776 | 776 | ||