Created
October 16, 2011 00:51
-
-
Save inactive123/1290374 to your computer and use it in GitHub Desktop.
diff patch libsnes gba
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/trunk/platform/libgba/Makefile b/trunk/platform/libgba/Makefile | |
index 15bb917..28c4387 100644 | |
--- a/trunk/platform/libgba/Makefile | |
+++ b/trunk/platform/libgba/Makefile | |
@@ -13,8 +13,8 @@ OBJS := $(VBA_COBJ) $(VBA_CXXOBJ) libsnes.o | |
VBA_DEFINES := -D__LIBGBA__ | |
-CFLAGS += -O3 -g -std=gnu99 -fPIC $(VBA_DEFINES) | |
-CXXFLAGS += -O3 -g -fPIC $(VBA_DEFINES) | |
+CFLAGS += -O0 -g -std=gnu99 -fPIC $(VBA_DEFINES) | |
+CXXFLAGS += -O0 -g -fPIC $(VBA_DEFINES) | |
LDFLAGS += -Wl,-no-undefined | |
INCDIRS := -I$(VBA_DIR) | |
diff --git a/trunk/platform/libgba/libsnes.cpp b/trunk/platform/libgba/libsnes.cpp | |
index 657b289..ae14d10 100644 | |
--- a/trunk/platform/libgba/libsnes.cpp | |
+++ b/trunk/platform/libgba/libsnes.cpp | |
@@ -1,3 +1,4 @@ | |
+#include <stdint.h> | |
#include "libsnes.hpp" | |
#include "../vba/Util.h" | |
@@ -219,7 +220,7 @@ void systemOnSoundShutdown() | |
void systemSoundNonblock(bool) | |
{} | |
-void systemSoundSetThrottle(u16) | |
+void systemSoundSetThrottle(uint16_t) | |
{} | |
bool systemSoundInitDriver(long) | |
@@ -258,9 +259,9 @@ void systemDrawScreen() | |
} | |
// Stubs | |
-u16 systemColorMap16[0x10000]; | |
-u32 systemColorMap32[0x10000]; | |
-u16 systemGbPalette[24]; | |
+uint16_t systemColorMap16[0x10000]; | |
+uint32_t systemColorMap32[0x10000]; | |
+uint16_t systemGbPalette[24]; | |
int systemColorDepth = 32; | |
int systemDebug = 0; | |
int systemVerbose = 0; | |
@@ -274,11 +275,11 @@ int systemBlueShift = 0; | |
void systemMessage(int, const char*, ...) | |
{} | |
-u32 systemReadJoypad(int) | |
+uint32_t systemReadJoypad(int) | |
{ | |
poll_cb(); | |
- u32 J = 0; | |
+ uint32_t J = 0; | |
static const unsigned binds[] = { | |
SNES_DEVICE_ID_JOYPAD_A, | |
diff --git a/trunk/src/vba/System.h b/trunk/src/vba/System.h | |
index a2a8a21..50871e5 100644 | |
--- a/trunk/src/vba/System.h | |
+++ b/trunk/src/vba/System.h | |
@@ -1,6 +1,7 @@ | |
#ifndef SYSTEM_H | |
#define SYSTEM_H | |
+#include <stdint.h> | |
#ifdef __CELLOS_LV2__ | |
#include "../../platform/common/utils/zlib/zlib.h" | |
#else | |
@@ -32,7 +33,11 @@ extern void systemDrawScreen(); | |
extern bool systemReadJoypads(); | |
// return information about the given joystick, -1 for default joystick | |
+#ifdef __LIBGBA__ | |
+extern uint32_t systemReadJoypad(int); | |
+#else | |
extern void systemReadJoypad(int); | |
+#endif | |
extern uint32_t systemGetClock(); | |
extern void systemMessage(int, const char *, ...); | |
diff --git a/trunk/src/vba/apu/Sound_Buffer.cpp b/trunk/src/vba/apu/Sound_Buffer.cpp | |
index 4647bae..a389782 100644 | |
--- a/trunk/src/vba/apu/Sound_Buffer.cpp | |
+++ b/trunk/src/vba/apu/Sound_Buffer.cpp | |
@@ -421,10 +421,12 @@ Effects_Buffer::~Effects_Buffer() | |
// avoid using new [] | |
int32_t Effects_Buffer::new_bufs( int size ) | |
{ | |
- bufs_buffer = (buf_t*) __builtin_malloc( size * sizeof(*bufs_buffer)); | |
+ bufs_buffer = (buf_t*)malloc( size * sizeof(*bufs_buffer)); | |
CHECK_ALLOC( bufs_buffer ); | |
+ #if 0 | |
for ( int i = 0; i < size; i++ ) | |
new (bufs_buffer + i) buf_t; | |
+ #endif | |
bufs_size = size; | |
return 0; // success | |
} | |
diff --git a/trunk/src/vba/apu/Sound_Buffer.h b/trunk/src/vba/apu/Sound_Buffer.h | |
index 335a38f..6a17f2a 100644 | |
--- a/trunk/src/vba/apu/Sound_Buffer.h | |
+++ b/trunk/src/vba/apu/Sound_Buffer.h | |
@@ -114,10 +114,9 @@ class Blip_Buffer | |
// Range specifies the greatest expected change in amplitude. Calculate it | |
// by finding the difference between the maximum and minimum expected | |
// amplitudes (max - min). | |
-typedef struct Blip_Synth | |
-{ | |
+typedef struct { | |
int32_t delta_factor; | |
-}; | |
+} Blip_Synth; | |
// Optimized reading from Blip_Buffer, for use in custom sample output | |
@@ -200,11 +199,11 @@ inline void Blip_Buffer::clock_rate(int32_t cps ) | |
#define MIXED_TYPE WAVE_TYPE | NOISE_TYPE | |
#define TYPE_INDEX_MASK 0xFF | |
-typedef struct channel_t { | |
+typedef struct { | |
Blip_Buffer* center; | |
Blip_Buffer* left; | |
Blip_Buffer* right; | |
-}; | |
+} channel_t; | |
#define BUFFERS_SIZE 3 | |
@@ -241,19 +240,14 @@ class Stereo_Buffer { | |
int const* channel_types_; | |
}; | |
-typedef struct pan_vol_t | |
+typedef struct | |
{ | |
float vol; // 0.0 = silent, 0.5 = half volume, 1.0 = normal | |
float pan; // -1.0 = left, 0.0 = center, +1.0 = right | |
-}; | |
+} pan_vol_t; | |
// See Simple_Effects_Buffer (below) for a simpler interface | |
-typedef struct buf_t : Blip_Buffer | |
-{ | |
- int32_t vol[STEREO]; | |
- bool echo; | |
-}; | |
class Effects_Buffer { | |
public: | |
@@ -321,6 +315,11 @@ class Effects_Buffer { | |
}; | |
blargg_vector<chan_t> chans; | |
+ struct buf_t : Blip_Buffer | |
+ { | |
+ int32_t vol[STEREO]; | |
+ bool echo; | |
+ }; | |
buf_t* bufs_buffer; | |
int bufs_size; | |
int bufs_max; // bufs_size <= bufs_max, to limit memory usage | |
diff --git a/trunk/src/vba/gb/gbGlobals.cpp b/trunk/src/vba/gb/gbGlobals.cpp | |
index bebc678..f7dfe26 100644 | |
--- a/trunk/src/vba/gb/gbGlobals.cpp | |
+++ b/trunk/src/vba/gb/gbGlobals.cpp | |
@@ -1,3 +1,4 @@ | |
+#include <stdint.h> | |
#include <cstdlib> | |
uint8_t *gbMemoryMap[16]; | |
diff --git a/trunk/src/vba/gb/gbSound.cpp b/trunk/src/vba/gb/gbSound.cpp | |
index c51b9dd..2f12dfb 100644 | |
--- a/trunk/src/vba/gb/gbSound.cpp | |
+++ b/trunk/src/vba/gb/gbSound.cpp | |
@@ -1,3 +1,4 @@ | |
+#include <stdint.h> | |
#include <string.h> | |
#include "../gba/Sound.h" | |
diff --git a/trunk/src/vba/gba/GBA.cpp b/trunk/src/vba/gba/GBA.cpp | |
index 08c0e72..c02d1bc 100644 | |
--- a/trunk/src/vba/gba/GBA.cpp | |
+++ b/trunk/src/vba/gba/GBA.cpp | |
@@ -1,6 +1,7 @@ | |
-#include <zlib.h> | |
+#include <stdint.h> | |
#include <stdlib.h> | |
#include <math.h> | |
+#include <zlib.h> | |
#ifdef __LIBGBA__ | |
#include <stddef.h> | |
diff --git a/trunk/src/vba/gba/Sound_.h b/trunk/src/vba/gba/Sound_.h | |
index a90f6b4..225c763 100644 | |
--- a/trunk/src/vba/gba/Sound_.h | |
+++ b/trunk/src/vba/gba/Sound_.h | |
@@ -52,19 +52,19 @@ static const int32_t table [0x40] = | |
0xFF38,0xFF39,0xFF3A,0xFF3B,0xFF3C,0xFF3D,0xFF3E,0xFF3F, | |
}; | |
-typedef struct gba_pcm_struct | |
+typedef struct | |
{ | |
Blip_Buffer* output; | |
int32_t last_time; | |
int32_t last_amp; | |
int32_t shift; | |
-}; | |
+} gba_pcm_struct; | |
class Gba_Pcm_Fifo | |
{ | |
public: | |
uint32_t which; | |
- struct gba_pcm_struct pcm_s; | |
+ gba_pcm_struct pcm_s; | |
void write_control( int data ); | |
void write_fifo( int data ); | |
@@ -85,7 +85,7 @@ static Gba_Pcm_Fifo pcm[2]; | |
static Gb_Apu* gb_apu; | |
static Stereo_Buffer* stereo_buffer; | |
-static struct Blip_Synth pcm_synth; | |
+static Blip_Synth pcm_synth; | |
#define INIT_GBA_PCM(pcm_s) \ | |
pcm_s.output = 0; \ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment