segatools/idacio/shifter.c

33 lines
612 B
C
Raw Normal View History

2023-04-23 14:13:51 +00:00
#include <stdbool.h>
#include <stdint.h>
#include "idzio/shifter.h"
static bool idac_shifter_shifting;
static uint8_t idac_shifter_gear;
void idac_shifter_reset(void)
{
idac_shifter_gear = 0;
}
void idac_shifter_update(bool shift_dn, bool shift_up)
{
if (!idac_shifter_shifting) {
if (shift_dn && idac_shifter_gear > 0) {
idac_shifter_gear--;
}
if (shift_up && idac_shifter_gear < 6) {
idac_shifter_gear++;
}
}
idac_shifter_shifting = shift_dn || shift_up;
}
uint8_t idac_shifter_current_gear(void)
{
return idac_shifter_gear;
}