diff --git a/src/menu.c b/src/menu.c index 746ecf8..4a66d64 100644 --- a/src/menu.c +++ b/src/menu.c @@ -224,10 +224,9 @@ static void drawPlayerButtons(Menu* menu, s32 x, s32 y) static void drawGamepadSetupTabs(Menu* menu, s32 x, s32 y) { - enum{Width = 90, Height = 41, Tabs = 2}; + enum{Width = 90, Height = 41, Tabs = TIC_GAMEPADS, TabWidth = 16}; tic_mem* tic = menu->tic; - tic->api.rect(tic, x, y, Width, Height, (tic_color_white)); tic->api.pixel(tic, x, y, (tic_color_blue)); tic->api.pixel(tic, x+Width-1, y, (tic_color_blue)); @@ -236,12 +235,7 @@ static void drawGamepadSetupTabs(Menu* menu, s32 x, s32 y) tic->api.rect(tic, x+1, y+Height, Width-2 , 1, (tic_color_black)); for(s32 i = 0; i < Tabs; i++) - { - if(menu->gamepad.tab == i) - drawTab(menu, x + 73 - i*17, y + 43, i); - else - drawTabDisabled(menu, x + 73 - i*17, y + 43, i); - } + (menu->gamepad.tab == i ? drawTab : drawTabDisabled)(menu, x + 73 - i*TabWidth, y + 43, i); drawPlayerButtons(menu, x + 3, y + 3); } diff --git a/src/studio.c b/src/studio.c index 3433e73..5bf8303 100644 --- a/src/studio.c +++ b/src/studio.c @@ -45,17 +45,11 @@ #include "ext/md5.h" #define STUDIO_UI_SCALE 3 - #define TEXTURE_SIZE (TIC80_FULLWIDTH) - -#define MAX_CONTROLLERS (sizeof(tic80_gamepads)) #define STUDIO_PIXEL_FORMAT SDL_PIXELFORMAT_ARGB8888 - #define FRAME_SIZE (TIC80_FULLWIDTH * TIC80_FULLHEIGHT * sizeof(u32)) - #define OFFSET_LEFT ((TIC80_FULLWIDTH-TIC80_WIDTH)/2) #define OFFSET_TOP ((TIC80_FULLHEIGHT-TIC80_HEIGHT)/2) - #define POPUP_DUR (TIC_FRAMERATE*2) #if defined(TIC80_PRO) @@ -110,7 +104,7 @@ static struct SDL_AudioCVT cvt; } audio; - SDL_Joystick* joysticks[MAX_CONTROLLERS]; + SDL_Joystick* joysticks[TIC_GAMEPADS]; EditorMode mode; EditorMode prevMode; @@ -1936,7 +1930,7 @@ SDL_Event* pollEvent() { s32 id = event.jdevice.which; - if (id < MAX_CONTROLLERS) + if (id < TIC_GAMEPADS) { if(studio.joysticks[id]) SDL_JoystickClose(studio.joysticks[id]); @@ -1950,7 +1944,7 @@ SDL_Event* pollEvent() { s32 id = event.jdevice.which; - if (id < MAX_CONTROLLERS && studio.joysticks[id]) + if (id < TIC_GAMEPADS && studio.joysticks[id]) { SDL_JoystickClose(studio.joysticks[id]); studio.joysticks[id] = NULL; diff --git a/src/tic.h b/src/tic.h index 23a97b3..4c94c13 100644 --- a/src/tic.h +++ b/src/tic.h @@ -108,6 +108,7 @@ #define TIC_BANK_BITS 3 #define TIC_BANKS (1 << TIC_BANK_BITS) +#define TIC_GAMEPADS (sizeof(tic80_gamepads) / sizeof(tic80_gamepad)) #define SFX_NOTES {"C-", "C#", "D-", "D#", "E-", "F-", "F#", "G-", "G#", "A-", "A#", "B-"} #define TIC_FONT_CHARS 128