From e969ce7fad00d75bd8b17268a8342fd3eb0aa0b0 Mon Sep 17 00:00:00 2001 From: tmbinc Date: Fri, 4 Sep 2009 02:45:14 +0000 Subject: [PATCH] xbox 360 port: use full cpu speed, sleep unused cpu cores, add sound (which isn't that great yet) --- source/xenon/main.cpp | 50 +++++++++++++++++++++++++++++++++++++ source/xenon/s9xsupport.cpp | 6 ++++- 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/source/xenon/main.cpp b/source/xenon/main.cpp index ff12a74..d354ef0 100644 --- a/source/xenon/main.cpp +++ b/source/xenon/main.cpp @@ -20,6 +20,8 @@ #include #include #include +#include +#include //#include "smc.h" @@ -48,6 +50,11 @@ extern "C" { }; +static inline uint32_t bswap_32(uint32_t t) +{ + return ((t & 0xFF) << 24) | ((t & 0xFF00) << 8) | ((t & 0xFF0000) >> 8) | ((t & 0xFF000000) >> 24); +} + void emulate () { @@ -90,6 +97,40 @@ emulate () ConfigRequested = 0; break; } + + + /* this all isn't that great... */ + int sample_rate = 48000 * 2; + int samples_per_frame = Settings.PAL ? sample_rate / 50 : sample_rate / 60; + + int samples_guard = 16384; + + if (xenon_sound_get_unplayed() < samples_guard) + { + so.samples_mixed_so_far = so.play_position = 0; + + unsigned char buffer[2048]; + unsigned char out[2048]; + +#if 0 + int req_samples = xenon_sound_get_unplayed(); + if ((req_samples + samples_per_frame) < samples_guard) + req_samples = samples_guard + samples_per_frame; + else + req_samples = samples_per_frame; +#endif + int req_samples = samples_per_frame; + + S9xMixSamples(buffer, req_samples); + + int i; + for (i = 0; i < req_samples * 2; i += 4) + *(int*)(buffer + i) = bswap_32(*(int*)(buffer + i)); + xenon_sound_submit(buffer, req_samples * 2); + + } + + } // main loop } @@ -210,6 +251,15 @@ int main(void) extern void xenos_init(); xenos_init(); console_init(); + + xenon_thread_startup(); + xenon_make_it_faster(XENON_SPEED_FULL); + xenon_sleep_thread(1); + xenon_sleep_thread(2); + xenon_sleep_thread(3); + xenon_sleep_thread(4); + xenon_sleep_thread(5); + printf("SNES9x GX\n"); kmem_init(); diff --git a/source/xenon/s9xsupport.cpp b/source/xenon/s9xsupport.cpp index d93b269..0e5fe64 100644 --- a/source/xenon/s9xsupport.cpp +++ b/source/xenon/s9xsupport.cpp @@ -16,6 +16,7 @@ #include