modify joyprocess's HoldCoin<N, T = UINT8> for UINT16(&etc) happytime

This commit is contained in:
dinkc64 2024-05-25 01:06:37 -04:00
parent b588fb6d7b
commit 71162f4450

View File

@ -69,10 +69,10 @@ struct ButtonToggle {
};
// E-Z HoldCoin logic (see pgm_run.cpp, d_discoboy.cpp)
template <int N>
template <int N, typename T = UINT8>
struct HoldCoin {
UINT8 prev[N];
UINT8 counter[N];
T prev[N];
T counter[N];
void reset() {
memset(&prev, 0, sizeof(prev));
@ -84,7 +84,7 @@ struct HoldCoin {
SCAN_VAR(counter);
}
void check(UINT8 num, UINT8 &inp, UINT8 bit, UINT8 hold_count) {
void check(UINT8 num, T &inp, T bit, UINT8 hold_count) {
if ((prev[num] & bit) != (inp & bit) && (inp & bit) && !counter[num]) {
counter[num] = hold_count + 1;
}
@ -98,7 +98,7 @@ struct HoldCoin {
}
}
void checklow(UINT8 num, UINT8 &inp, UINT8 bit, UINT8 hold_count) {
void checklow(UINT8 num, T &inp, T bit, UINT8 hold_count) {
if ((prev[num] & bit) != (inp & bit) && (~inp & bit) && !counter[num]) {
counter[num] = hold_count + 1;
}