From 58d00f8ff54697b6f30cb6e12321ebc5a2377331 Mon Sep 17 00:00:00 2001 From: Bad Diode Date: Wed, 21 Apr 2021 14:43:04 +0200 Subject: Cleanup sprite animation code in gba-buttons --- src/gba-buttons.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) (limited to 'src/gba-buttons.c') diff --git a/src/gba-buttons.c b/src/gba-buttons.c index ee6458d..de62212 100644 --- a/src/gba-buttons.c +++ b/src/gba-buttons.c @@ -228,26 +228,23 @@ u32 gba_btn_b_data[112][8] = { {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, }; -typedef enum {GBA_BTN_STATE_IDLE, GBA_BTN_STATE_PRESSED} GbaBtnState; typedef struct SpriteAnimation { size_t *tile_offsets; size_t n_frames; } SpriteAnimation; -static size_t gba_btn_state_idle[] = {0}; -static size_t gba_btn_state_pressed[] = {0, 16, 16, 32, 32, 48, 48, 64, 64, 80, 96}; +typedef enum {BTN_STATE_IDLE, BTN_STATE_PRESSED} BtnState; -SpriteAnimation anim_idle = { - .tile_offsets = &gba_btn_state_idle, - .n_frames = sizeof(gba_btn_state_idle) / sizeof(size_t), -}; - -SpriteAnimation anim_pressed = { - .tile_offsets = &gba_btn_state_pressed, - .n_frames = sizeof(gba_btn_state_pressed) / sizeof(size_t), -}; +static size_t btn_state_idle[] = {0}; +static size_t btn_state_pressed[] = {16, 16, 32, 32, 48, 48, 64, 64, 80, 96}; -SpriteAnimation *animation_states[] = { - &anim_idle, - &anim_pressed, +static SpriteAnimation *animation_states[] = { + &(SpriteAnimation){ + .tile_offsets = &btn_state_idle, + .n_frames = sizeof(btn_state_idle) / sizeof(size_t), + }, + &(SpriteAnimation){ + .tile_offsets = &btn_state_pressed, + .n_frames = sizeof(btn_state_pressed) / sizeof(size_t), + }, }; -- cgit v1.2.1