some minor fixes

This commit is contained in:
tic 2018-02-15 18:54:49 +03:00
parent fd3f316b1d
commit 17ac8d2ab2
2 changed files with 21 additions and 22 deletions

View File

@ -27,20 +27,12 @@ static struct
struct struct
{ {
SDL_AudioSpec spec; SDL_Joystick* ports[TIC_GAMEPADS];
SDL_AudioDeviceID device; SDL_Texture* texture;
SDL_AudioCVT cvt;
} audio;
SDL_Joystick* joysticks[TIC_GAMEPADS];
struct
{
tic80_gamepads touch; tic80_gamepads touch;
tic80_gamepads joystick; tic80_gamepads joystick;
SDL_Texture* texture;
bool show; bool show;
s32 counter; s32 counter;
s32 alpha; s32 alpha;
@ -66,6 +58,13 @@ static struct
bool missedFrame; bool missedFrame;
bool fullscreen; bool fullscreen;
struct
{
SDL_AudioSpec spec;
SDL_AudioDeviceID device;
SDL_AudioCVT cvt;
} audio;
} platform; } platform;
static void initSound() static void initSound()
@ -436,9 +435,9 @@ static void processJoysticks()
platform.gamepad.joystick.data = 0; platform.gamepad.joystick.data = 0;
s32 index = 0; s32 index = 0;
for(s32 i = 0; i < COUNT_OF(platform.joysticks); i++) for(s32 i = 0; i < COUNT_OF(platform.gamepad.ports); i++)
{ {
SDL_Joystick* joystick = platform.joysticks[i]; SDL_Joystick* joystick = platform.gamepad.ports[i];
if(joystick && SDL_JoystickGetAttached(joystick)) if(joystick && SDL_JoystickGetAttached(joystick))
{ {
@ -520,7 +519,7 @@ static void pollEvent()
input->mouse.btns = 0; input->mouse.btns = 0;
} }
static SDL_Event event; SDL_Event event;
while(SDL_PollEvent(&event)) while(SDL_PollEvent(&event))
{ {
@ -538,10 +537,10 @@ static void pollEvent()
if (id < TIC_GAMEPADS) if (id < TIC_GAMEPADS)
{ {
if(platform.joysticks[id]) if(platform.gamepad.ports[id])
SDL_JoystickClose(platform.joysticks[id]); SDL_JoystickClose(platform.gamepad.ports[id]);
platform.joysticks[id] = SDL_JoystickOpen(id); platform.gamepad.ports[id] = SDL_JoystickOpen(id);
} }
} }
break; break;
@ -550,10 +549,10 @@ static void pollEvent()
{ {
s32 id = event.jdevice.which; s32 id = event.jdevice.which;
if (id < TIC_GAMEPADS && platform.joysticks[id]) if (id < TIC_GAMEPADS && platform.gamepad.ports[id])
{ {
SDL_JoystickClose(platform.joysticks[id]); SDL_JoystickClose(platform.gamepad.ports[id]);
platform.joysticks[id] = NULL; platform.gamepad.ports[id] = NULL;
} }
} }
break; break;
@ -635,7 +634,7 @@ static void blitSound()
tic_mem* tic = platform.studio->tic; tic_mem* tic = platform.studio->tic;
SDL_PauseAudioDevice(platform.audio.device, 0); SDL_PauseAudioDevice(platform.audio.device, 0);
if(platform.audio.cvt.needed) if(platform.audio.cvt.needed)
{ {
SDL_memcpy(platform.audio.cvt.buf, tic->samples.buffer, tic->samples.size); SDL_memcpy(platform.audio.cvt.buf, tic->samples.buffer, tic->samples.size);

View File

@ -27,8 +27,8 @@
#include "defines.h" #include "defines.h"
#define TIC_VERSION_MAJOR 0 #define TIC_VERSION_MAJOR 0
#define TIC_VERSION_MINOR 60 #define TIC_VERSION_MINOR 70
#define TIC_VERSION_PATCH 3 #define TIC_VERSION_PATCH 0
#define TIC_VERSION_STATUS " dev" #define TIC_VERSION_STATUS " dev"
#if defined(TIC80_PRO) #if defined(TIC80_PRO)