mirror of
https://github.com/cc65/cc65.git
synced 2025-01-30 12:33:15 +00:00
Merge pull request #467 from pmjdebruijn/joy
joy: refactor generic joy_masks array indices and macros
This commit is contained in:
commit
ef17e65c1b
@ -75,6 +75,13 @@
|
||||
|
||||
|
||||
|
||||
/* Expanding upon joystick.h */
|
||||
#define JOY_FIRE_IDX 4
|
||||
|
||||
#define JOY_FIRE(v) ((v) & joy_masks[JOY_FIRE_IDX])
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Variables */
|
||||
/*****************************************************************************/
|
||||
|
@ -80,17 +80,6 @@
|
||||
bit 3:
|
||||
*/
|
||||
|
||||
#define JOY_DATA 0x4400
|
||||
|
||||
#define JOY_DATA_UP 0x01
|
||||
#define JOY_DATA_DOWN 0x02
|
||||
#define JOY_DATA_LEFT 0x04
|
||||
#define JOY_DATA_RIGHT 0x08
|
||||
#define JOY_DATA_FIRE_A 0x10
|
||||
#define JOY_DATA_FIRE_B 0x20
|
||||
#define JOY_DATA_START 0x40
|
||||
#define JOY_DATA_SELECT 0x80
|
||||
|
||||
/* LCD
|
||||
|
||||
resolution 160x152 in 4 greys/greens
|
||||
@ -181,13 +170,20 @@
|
||||
/* No support for dynamically loadable drivers */
|
||||
#define DYN_DRV 0
|
||||
|
||||
/* Expanding upon joystick.h */
|
||||
#define JOY_BTN_A_IDX 4
|
||||
#define JOY_BTN_B_IDX 5
|
||||
#define JOY_START_IDX 6
|
||||
#define JOY_SELECT_IDX 7
|
||||
|
||||
#define JOY_BTN_A(v) ((v) & joy_masks[JOY_BTN_A_IDX])
|
||||
#define JOY_BTN_B(v) ((v) & joy_masks[JOY_BTN_B_IDX])
|
||||
#define JOY_START(v) ((v) & joy_masks[JOY_START_IDX])
|
||||
#define JOY_SELECT(v) ((v) & joy_masks[JOY_SELECT_IDX])
|
||||
|
||||
/* The addresses of the static drivers */
|
||||
extern void gamate_stdjoy_joy[]; /* Referred to by joy_static_stddrv[] */
|
||||
|
||||
#define JOY_FIRE_B 5
|
||||
#define JOY_START 6
|
||||
#define JOY_SELECT 7
|
||||
|
||||
void waitvsync (void);
|
||||
/* Wait for start of next frame */
|
||||
|
||||
|
@ -52,27 +52,31 @@
|
||||
#define JOY_ERR_NO_DEVICE 4 /* Device (hardware) not found */
|
||||
|
||||
/* Argument for the joy_read function */
|
||||
#define JOY_1 0
|
||||
#define JOY_2 1
|
||||
#define JOY_1 0
|
||||
#define JOY_2 1
|
||||
|
||||
/* The following codes are *indices* into the joy_masks array */
|
||||
#define JOY_UP 0
|
||||
#define JOY_DOWN 1
|
||||
#define JOY_LEFT 2
|
||||
#define JOY_RIGHT 3
|
||||
#define JOY_FIRE 4
|
||||
#define JOY_FIRE2 5 /* Second fire button if available */
|
||||
#define JOY_UP_IDX 0
|
||||
#define JOY_DOWN_IDX 1
|
||||
#define JOY_LEFT_IDX 2
|
||||
#define JOY_RIGHT_IDX 3
|
||||
#define JOY_BTN_1_IDX 4 /* Universally available */
|
||||
#define JOY_BTN_2_IDX 5 /* Second fire button if available */
|
||||
#define JOY_BTN_3_IDX 6 /* Third fire button if available */
|
||||
#define JOY_BTN_4_IDX 7 /* Fourth fire button if available */
|
||||
|
||||
/* Array of masks used to check the return value of joy_read for a state */
|
||||
extern const unsigned char joy_masks[8];
|
||||
|
||||
/* Macros that evaluate the return code of joy_read */
|
||||
#define JOY_BTN_UP(v) ((v) & joy_masks[JOY_UP])
|
||||
#define JOY_BTN_DOWN(v) ((v) & joy_masks[JOY_DOWN])
|
||||
#define JOY_BTN_LEFT(v) ((v) & joy_masks[JOY_LEFT])
|
||||
#define JOY_BTN_RIGHT(v) ((v) & joy_masks[JOY_RIGHT])
|
||||
#define JOY_BTN_FIRE(v) ((v) & joy_masks[JOY_FIRE])
|
||||
#define JOY_BTN_FIRE2(v) ((v) & joy_masks[JOY_FIRE2])
|
||||
#define JOY_UP(v) ((v) & joy_masks[JOY_UP_IDX])
|
||||
#define JOY_DOWN(v) ((v) & joy_masks[JOY_DOWN_IDX])
|
||||
#define JOY_LEFT(v) ((v) & joy_masks[JOY_LEFT_IDX])
|
||||
#define JOY_RIGHT(v) ((v) & joy_masks[JOY_RIGHT_IDX])
|
||||
#define JOY_BTN_1(v) ((v) & joy_masks[JOY_BTN_1_IDX])
|
||||
#define JOY_BTN_2(v) ((v) & joy_masks[JOY_BTN_2_IDX])
|
||||
#define JOY_BTN_3(v) ((v) & joy_masks[JOY_BTN_3_IDX])
|
||||
#define JOY_BTN_4(v) ((v) & joy_masks[JOY_BTN_4_IDX])
|
||||
|
||||
/* The name of the standard joystick driver for a platform */
|
||||
extern const char joy_stddrv[];
|
||||
|
@ -92,6 +92,15 @@
|
||||
|
||||
|
||||
|
||||
/* Expanding upon joystick.h */
|
||||
#define JOY_BTN_A_IDX 4
|
||||
#define JOY_BTN_B_IDX 5
|
||||
|
||||
#define JOY_BTN_A(v) ((v) & joy_masks[JOY_BTN_A_IDX])
|
||||
#define JOY_BTN_B(v) ((v) & joy_masks[JOY_BTN_B_IDX])
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Variables */
|
||||
/*****************************************************************************/
|
||||
|
@ -91,15 +91,15 @@
|
||||
#define DYN_DRV 0
|
||||
|
||||
/* Expanding upon joystick.h */
|
||||
#define JOY_A 4
|
||||
#define JOY_B 5
|
||||
#define JOY_SELECT 6
|
||||
#define JOY_START 7
|
||||
#define JOY_BTN_A_IDX 4
|
||||
#define JOY_BTN_B_IDX 5
|
||||
#define JOY_SELECT_IDX 6
|
||||
#define JOY_START_IDX 7
|
||||
|
||||
#define JOY_BTN_A(v) ((v) & joy_masks[JOY_A])
|
||||
#define JOY_BTN_B(v) ((v) & joy_masks[JOY_B])
|
||||
#define JOY_BTN_SELECT(v) ((v) & joy_masks[JOY_SELECT])
|
||||
#define JOY_BTN_START(v) ((v) & joy_masks[JOY_START])
|
||||
#define JOY_BTN_A(v) ((v) & joy_masks[JOY_BTN_A_IDX])
|
||||
#define JOY_BTN_B(v) ((v) & joy_masks[JOY_BTN_B_IDX])
|
||||
#define JOY_SELECT(v) ((v) & joy_masks[JOY_SELECT_IDX])
|
||||
#define JOY_START(v) ((v) & joy_masks[JOY_START_IDX])
|
||||
|
||||
/* Define hardware */
|
||||
|
||||
|
@ -77,23 +77,19 @@
|
||||
#define DYN_DRV 0
|
||||
|
||||
/* Expanding upon joystick.h */
|
||||
#define JOY_I 4
|
||||
#define JOY_II 5
|
||||
#define JOY_SELECT 6
|
||||
#define JOY_RUN 7
|
||||
#define JOY_BTN_I_IDX 4
|
||||
#define JOY_BTN_II_IDX 5
|
||||
#define JOY_SELECT_IDX 6
|
||||
#define JOY_RUN_IDX 7
|
||||
|
||||
#define JOY_BTN_I(v) ((v) & joy_masks[JOY_I])
|
||||
#define JOY_BTN_II(v) ((v) & joy_masks[JOY_II])
|
||||
#define JOY_BTN_SELECT(v) ((v) & joy_masks[JOY_SELECT])
|
||||
#define JOY_BTN_RUN(v) ((v) & joy_masks[JOY_RUN])
|
||||
#define JOY_BTN_I(v) ((v) & joy_masks[JOY_BTN_I_IDX])
|
||||
#define JOY_BTN_II(v) ((v) & joy_masks[JOY_BTN_II_IDX])
|
||||
#define JOY_SELECT(v) ((v) & joy_masks[JOY_SELECT_IDX])
|
||||
#define JOY_RUN(v) ((v) & joy_masks[JOY_RUN_IDX])
|
||||
|
||||
/* The addresses of the static drivers */
|
||||
extern void pce_stdjoy_joy[]; /* Referred to by joy_static_stddrv[] */
|
||||
|
||||
#define JOY_FIRE_B 5
|
||||
#define JOY_SELECT 6
|
||||
#define JOY_RUN 7
|
||||
|
||||
void waitvsync (void);
|
||||
/* Wait for start of the next frame */
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user