]> git.sur5r.net Git - cc65/blobdiff - include/gamate.h
joy: refactor generic joy_masks array indices and macros
[cc65] / include / gamate.h
index 96c70c9bcdeb1e12fb80742d0429e9ef5d5cccc8..7355ede84da6d8eb679653fe6b855baa29662d0d 100644 (file)
  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
 /* 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 */