Add missing changes
Jeffrey Pfau jeffrey@endrift.com
Wed, 02 Oct 2013 02:45:41 -0700
4 files changed,
28 insertions(+),
6 deletions(-)
M
src/sdl/sdl-events.c
→
src/sdl/sdl-events.c
@@ -4,16 +4,17 @@ #include "debugger.h"
#include "gba-io.h" #include "gba-video.h" -int GBASDLInitEvents() { +int GBASDLInitEvents(struct GBASDLEvents* context) { if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) < 0) { return 0; } SDL_JoystickEventState(SDL_ENABLE); - SDL_JoystickOpen(0); + context->joystick = SDL_JoystickOpen(0); return 1; } -void GBASDLDeinitEvents() { +void GBASDLDeinitEvents(struct GBASDLEvents* context) { + SDL_JoystickClose(context->joystick); SDL_QuitSubSystem(SDL_INIT_JOYSTICK); }
M
src/sdl/sdl-events.h
→
src/sdl/sdl-events.h
@@ -5,8 +5,12 @@ #include "gba-thread.h"
#include <SDL.h> -int GBASDLInitEvents(void); -void GBASDLDeinitEvents(void); +struct GBASDLEvents { + SDL_Joystick* joystick; +}; + +int GBASDLInitEvents(struct GBASDLEvents*); +void GBASDLDeinitEvents(struct GBASDLEvents*); void GBASDLHandleEvent(struct GBAThread* context, const union SDL_Event* event);
M
src/util/circle-buffer.c
→
src/util/circle-buffer.c
@@ -42,8 +42,24 @@ }
return 1; } +int CircleBufferRead8(struct CircleBuffer* buffer, int8_t* value) { + int8_t* data = buffer->readPtr; + if (buffer->readPtr == buffer->writePtr) { + return 0; + } + *value = *data; + ++data; + ptrdiff_t size = (int8_t*) data - (int8_t*) buffer->data; + if (size < buffer->capacity) { + buffer->readPtr = data; + } else { + buffer->readPtr = buffer->data; + } + return 1; +} + int CircleBufferRead32(struct CircleBuffer* buffer, int32_t* value) { - uint32_t* data = buffer->readPtr; + int32_t* data = buffer->readPtr; if (buffer->readPtr == buffer->writePtr) { return 0; }
M
src/util/circle-buffer.h
→
src/util/circle-buffer.h
@@ -14,6 +14,7 @@ void CircleBufferInit(struct CircleBuffer* buffer, unsigned capacity);
void CircleBufferDeinit(struct CircleBuffer* buffer); unsigned CircleBufferSize(const struct CircleBuffer* buffer); int CircleBufferWrite32(struct CircleBuffer* buffer, int32_t value); +int CircleBufferRead8(struct CircleBuffer* buffer, int8_t* value); int CircleBufferRead32(struct CircleBuffer* buffer, int32_t* value); #endif