![]() |
CHGame 0.3.0
Libraries for the CHGame handheld
|
The global chgame object: the frame clock and the eight buttons. More...
Classes | |
| class | CHGame |
| The board's buttons and frame clock. There is one, chgame. More... | |
Macros | |
| #define | A_BUTTON (1u << 0) |
| The A button (PB1). | |
| #define | B_BUTTON (1u << 1) |
| The B button (PB6). | |
| #define | UP_BUTTON (1u << 2) |
| D-pad up (PB4). | |
| #define | DOWN_BUTTON (1u << 3) |
| D-pad down (PC14). | |
| #define | LEFT_BUTTON (1u << 4) |
| D-pad left (PB3). | |
| #define | RIGHT_BUTTON (1u << 5) |
| D-pad right (PC15). | |
| #define | START_BUTTON (1u << 6) |
| START (PB8). Held 3 s, it leaves for the menu (CHGame::startExits). | |
| #define | SELECT_BUTTON (1u << 7) |
| SELECT (PB7). | |
Functions | |
| uint8_t | chgame_readButtons () |
| Read the buttons straight from the hardware. | |
| void | chgame_exitToMenu () |
| Leave the game for the bootloader's game menu. | |
Variables | |
| CHGame | chgame |
| The one instance: chgame.boot(), chgame.pressed() ... | |
The global chgame object: the frame clock and the eight buttons.
Call chgame.boot() once in setup(), then in loop():
The button names and the calls are the Arduboy2 library's, so code written for it reads the same here.
| #define A_BUTTON (1u << 0) |
The A button (PB1).
| #define B_BUTTON (1u << 1) |
The B button (PB6).
| #define UP_BUTTON (1u << 2) |
D-pad up (PB4).
| #define DOWN_BUTTON (1u << 3) |
D-pad down (PC14).
| #define LEFT_BUTTON (1u << 4) |
D-pad left (PB3).
| #define RIGHT_BUTTON (1u << 5) |
D-pad right (PC15).
| #define START_BUTTON (1u << 6) |
START (PB8). Held 3 s, it leaves for the menu (CHGame::startExits).
| #define SELECT_BUTTON (1u << 7) |
SELECT (PB7).
| uint8_t chgame_readButtons | ( | ) |
Read the buttons straight from the hardware.
A_BUTTON ... SELECT_BUTTON ORed together.Implemented per platform (device: GPIO registers; simulator: the scripted input). A game normally uses CHGame::pollButtons() and the queries instead, which also see injected input.
| void chgame_exitToMenu | ( | ) |
Leave the game for the bootloader's game menu.
Never returns.
A plain reset, with no boot request (platform/bootloader/shared/chgame_bootreq.h). Under a bootloader without the menu (0.2.4) the game simply starts again. In the simulator it prints a line and ends the run.
|
extern |
The one instance: chgame.boot(), chgame.pressed() ...