This adds an example of how to use the SNES controllers on Commander X16. This is a breaking change due to cx16_k_joystick_get() signature change. This is likely not a big issue as it has most likely not been used much in the wild, considering the incomplete bitmasks for buttons, see below.
[x] Change signature of cx16_k_joystick_get() to return a three-byte struct, JoyState instead of a four-byte integer. This has the advantage of (1) being formally one byte shorter and (2) enables easy byte-wise bit masking (16 bit also exposed via union). The last byte is for checking if the joystick is attached and is cast to a bool which is cleaner than checking for -1. Finally this approach avoids duplication of Y.
[x] Fix a bitmask bug cx16.h (Button B).
[x] Add bitmask defines for missing buttons and change to explicitly typed enum.
[x] Remove unused macros relevant only to cc65's general joystick support.
[x] If on C++, enable inlined member functions. Illustrated in C++ example, testing all buttons.
[x] cx16_k_joystick_get() now uses inline assembly for better optimization of register usage.
[ ] Added common/include/stdbool.h from clang to allow use of bools in C code.
This adds an example of how to use the SNES controllers on Commander X16. This is a breaking change due to
cx16_k_joystick_get()
signature change. This is likely not a big issue as it has most likely not been used much in the wild, considering the incomplete bitmasks for buttons, see below.cx16_k_joystick_get()
to return a three-byte struct,JoyState
instead of a four-byte integer. This has the advantage of (1) being formally one byte shorter and (2) enables easy byte-wise bit masking (16 bit also exposed via union). The last byte is for checking if the joystick is attached and is cast to a bool which is cleaner than checking for -1. Finally this approach avoids duplication of Y.cx16.h
(Button B).cx16_k_joystick_get()
now uses inline assembly for better optimization of register usage.Addedcommon/include/stdbool.h
from clang to allow use of bools in C code.