aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNebuleon Fumika2013-01-19 20:28:17 -0500
committerNebuleon Fumika2013-01-19 20:28:17 -0500
commit88135c52f8367549d6c864df193018f5a6cb2b35 (patch)
tree57ae06a89349f86544f00060adbf2cdc396a8374
parent2bb2ee8c0aee044998858ff8263be71cb908a663 (diff)
downloadsnes9x2005-88135c52f8367549d6c864df193018f5a6cb2b35.tar.gz
snes9x2005-88135c52f8367549d6c864df193018f5a6cb2b35.tar.bz2
snes9x2005-88135c52f8367549d6c864df193018f5a6cb2b35.zip
Remove unneeded volatility, enabling more optimisations. Sound volatility is #define'd away, GUI volatility is simply removed.
-rw-r--r--Makefile2
-rw-r--r--source/globals.cpp7
-rw-r--r--source/nds/draw.c6
-rw-r--r--source/nds/entry.cpp44
-rw-r--r--source/soundux.h7
5 files changed, 23 insertions, 43 deletions
diff --git a/Makefile b/Makefile
index 0d8faeb..e0732d3 100644
--- a/Makefile
+++ b/Makefile
@@ -70,7 +70,7 @@ DEFS := -DSPC700_C -DEXECUTE_SUPERFX_PER_LINE -DSDD1_DECOMP \
-DVAR_CYCLES -DCPU_SHUTDOWN -DSPC700_SHUTDOWN \
-DNO_INLINE_SET_GET -DNOASM -DHAVE_MKSTEMP '-DACCEPT_SIZE_T=size_t' \
-DUNZIP_SUPPORT -DFOREVER_16_BIT_SOUND -DFOREVER_STEREO \
- -DFOREVER_FORWARD_STEREO -DSYNC_JOYPAD_AT_HBLANK
+ -DFOREVER_FORWARD_STEREO -DNO_VOLATILE_SOUND -DSYNC_JOYPAD_AT_HBLANK
.PHONY: clean makedirs
.SUFFIXES: .elf .dat .plg
diff --git a/source/globals.cpp b/source/globals.cpp
index a4efb46..d24816b 100644
--- a/source/globals.cpp
+++ b/source/globals.cpp
@@ -216,7 +216,14 @@ uint32 current_graphic_format = RGB565;
struct SCheatData Cheat;
+// Define NO_VOLATILE_SOUND if you're always reading or writing sound from one
+// thread or one co-routine. If you're using interrupts or a thread, sound must
+// be volatile.
+#ifndef NO_VOLATILE_SOUND
volatile SoundStatus so;
+#else
+SoundStatus so;
+#endif
int Echo [24000];
int DummyEchoBuffer [SOUND_BUFFER_SIZE];
diff --git a/source/nds/draw.c b/source/nds/draw.c
index b6916a3..4eb45c2 100644
--- a/source/nds/draw.c
+++ b/source/nds/draw.c
@@ -142,7 +142,7 @@ void drawhline(void* screen_addr, u32 sx, u32 ex, u32 y, u32 color)
{
u32 x;
u32 width = (ex - sx) + 1;
- volatile u16 *dst = VRAM_POS(screen_addr, sx, y);
+ u16 *dst = VRAM_POS(screen_addr, sx, y);
for (x = 0; x < width; x++)
*dst++ = (u16)color;
@@ -155,7 +155,7 @@ void drawvline(void* screen_addr, u32 x, u32 sy, u32 ey, u32 color)
{
int y;
int height = (ey - sy) + 1;
- volatile u16 *dst = VRAM_POS(screen_addr, x, sy);
+ u16 *dst = VRAM_POS(screen_addr, x, sy);
for (y = 0; y < height; y++)
{
@@ -183,7 +183,7 @@ void drawboxfill(void* screen_addr, u32 sx, u32 sy, u32 ex, u32 ey, u32 color)
u32 x, y;
u32 width = (ex - sx) + 1;
u32 height = (ey - sy) + 1;
- volatile u16 *dst = VRAM_POS(screen_addr, sx, sy);
+ u16 *dst = VRAM_POS(screen_addr, sx, sy);
for (y = 0; y < height; y++)
{
diff --git a/source/nds/entry.cpp b/source/nds/entry.cpp
index 1fb5bd8..8cd5c06 100644
--- a/source/nds/entry.cpp
+++ b/source/nds/entry.cpp
@@ -34,10 +34,6 @@ static u8 Buf[MAX_BUFFER_SIZE];
#define FIXED_POINT_SHIFT 16
#define FIXED_POINT_REMAINDER 0xffff
-static volatile bool8 block_signal = FALSE;
-static volatile bool8 pending_signal = FALSE;
-static volatile bool8 DelayingForEarlyFrame = FALSE;
-
void S9xMessage (int /*type*/, int /*number*/, const char *message)
{
#if 1
@@ -677,12 +673,10 @@ void S9xSyncSpeed ()
else // Early
{
skip_rate = 0;
- DelayingForEarlyFrame = TRUE;
ds2_setCPUclocklevel(0);
if (syncdif > 0)
udelay(syncdif * 128 / 3 /* times 42 + 2/3 microseconds */);
set_cpu_clock(clock_speed_number);
- DelayingForEarlyFrame = FALSE;
S9xProcessSound (0);
IPPU.RenderThisFrame = TRUE;
@@ -712,11 +706,9 @@ void S9xSyncSpeed ()
syncdif = sync_next - syncnow;
if (syncdif > 0)
{
- DelayingForEarlyFrame = TRUE;
ds2_setCPUclocklevel(0);
udelay(syncdif * 128 / 3 /* times 42 + 2/3 microseconds */);
set_cpu_clock(clock_speed_number);
- DelayingForEarlyFrame = FALSE;
S9xProcessSound (0);
// After that little delay, what time is it?
syncnow = getSysTime();
@@ -846,8 +838,6 @@ bool8 S9xOpenSoundDevice (int mode, bool8 stereo, int buffer_size)
void S9xGenerateSound ()
{
- block_signal = TRUE;
-
#ifndef FOREVER_16_BIT_SOUND
int bytes_so_far = so.sixteen_bit ? (so.samples_mixed_so_far << 1) :
so.samples_mixed_so_far;
@@ -856,7 +846,7 @@ void S9xGenerateSound ()
#endif
if (bytes_so_far >= so.buffer_size)
- goto end;
+ return;
so.err_counter += so.err_rate;
if (so.err_counter >= FIXED_POINT)
@@ -909,37 +899,17 @@ void S9xGenerateSound ()
byte_offset = (byte_offset + bytes_this_run) & SOUND_BUFFER_SIZE_MASK;
} while (samples_to_write > 0);
}
-
-end:
-
- if (pending_signal)
- {
- block_signal = FALSE;
- pending_signal = FALSE;
- S9xProcessSound (0);
- }
- else
- block_signal = FALSE;
}
void S9xProcessSound (unsigned int)
{
- if (DelayingForEarlyFrame)
- set_cpu_clock(clock_speed_number);
-
- if (block_signal)
- {
- pending_signal = TRUE;
- goto end;
- }
-
unsigned short *audiobuff;
- if (Settings.Paused || so.mute_sound || !game_enable_audio)
- goto end;
+ if (so.mute_sound || !game_enable_audio)
+ return;
if(ds2_checkAudiobuff() > 4)
- goto end;
+ return;
/* Number of samples to generate now */
int sample_count;
@@ -959,7 +929,7 @@ void S9xProcessSound (unsigned int)
audiobuff = (unsigned short*)ds2_getAudiobuff();
if(NULL == audiobuff) //There are audio queue in sending or wait to send
{
- goto end;
+ return;
}
/* If we need more audio samples */
@@ -1075,10 +1045,6 @@ void S9xProcessSound (unsigned int)
}
so.samples_mixed_so_far -= sample_count;
-
-end:
- if (DelayingForEarlyFrame)
- ds2_setCPUclocklevel(0);
}
/*
diff --git a/source/soundux.h b/source/soundux.h
index ad8cba1..8fb8396 100644
--- a/source/soundux.h
+++ b/source/soundux.h
@@ -144,7 +144,14 @@ typedef struct {
uint32 err_rate;
} SoundStatus;
+// Define NO_VOLATILE_SOUND if you're always reading or writing sound from one
+// thread or one co-routine. If you're using interrupts or a thread, sound must
+// be volatile.
+#ifndef NO_VOLATILE_SOUND
EXTERN_C volatile SoundStatus so;
+#else
+EXTERN_C SoundStatus so;
+#endif
typedef struct {
int state;