mirror of
https://github.com/cc65/cc65.git
synced 2026-04-25 06:17:58 +00:00
Removed joy_masks array.
So far the joy_masks array allowed several joystick drivers for a single target to each have different joy_read return values. However this meant that every call to joy_read implied an additional joy_masks lookup to post-process the return value. Given that almost all targets only come with a single joystick driver this seems an inappropriate overhead. Therefore now the target header files contain constants matching the return value of the joy_read of the joystick driver(s) on that target. If there indeed are several joystick drivers for a single target they must agree on a common return value for joy_read. In some cases this was alredy the case as there's a "natural" return value for joy_read. However a few joystick drivers need to be adjusted. This may cause some overhead inside the driver. But that is for sure smaller than the overhead introduced by the joy_masks lookup before. !!! ToDo !!! The following three joystick drivers become broken with this commit and need to be adjusted: - atrmj8.s - c64-numpad.s - vic20-stdjoy.s
This commit is contained in:
@@ -91,6 +91,14 @@
|
||||
#define CH_RTEE '+'
|
||||
#define CH_CROSS '+'
|
||||
|
||||
/* Masks for joy_read */
|
||||
#define JOY_UP_MASK 0x10
|
||||
#define JOY_DOWN_MASK 0x20
|
||||
#define JOY_LEFT_MASK 0x04
|
||||
#define JOY_RIGHT_MASK 0x08
|
||||
#define JOY_BTN_1_MASK 0x40
|
||||
#define JOY_BTN_2_MASK 0x80
|
||||
|
||||
/* Return codes for get_ostype */
|
||||
#define APPLE_UNKNOWN 0x00
|
||||
#define APPLE_II 0x10 /* Apple ][ */
|
||||
|
||||
+8
-1
@@ -149,6 +149,13 @@
|
||||
#define TGI_COLOR_LIGHTBLUE COLOR_LIGHTBLUE
|
||||
#define TGI_COLOR_GRAY3 COLOR_GRAY3
|
||||
|
||||
/* Masks for joy_read */
|
||||
#define JOY_UP_MASK 0x01
|
||||
#define JOY_DOWN_MASK 0x02
|
||||
#define JOY_LEFT_MASK 0x04
|
||||
#define JOY_RIGHT_MASK 0x08
|
||||
#define JOY_BTN_1_MASK 0x10
|
||||
|
||||
/* color register functions */
|
||||
extern void __fastcall__ _setcolor (unsigned char color_reg, unsigned char hue, unsigned char luminace);
|
||||
extern void __fastcall__ _setcolor_low (unsigned char color_reg, unsigned char color_value);
|
||||
@@ -346,4 +353,4 @@ struct __iocb {
|
||||
#define IOCB_FORMAT 0xFE /* format */
|
||||
|
||||
/* End of atari.h */
|
||||
#endif /* #ifndef _ATARI_H */
|
||||
#endif
|
||||
|
||||
+8
-1
@@ -87,6 +87,13 @@ extern void atr5200std_joy[]; /* referred to by joy_static_stddrv[] */
|
||||
#define COLOR_LIGHTBLUE _gtia_mkcolor(HUE_BLUE,6)
|
||||
#define COLOR_GRAY3 _gtia_mkcolor(HUE_GREY,5)
|
||||
|
||||
/* Masks for joy_read */
|
||||
#define JOY_UP_MASK 0x01
|
||||
#define JOY_DOWN_MASK 0x02
|
||||
#define JOY_LEFT_MASK 0x04
|
||||
#define JOY_RIGHT_MASK 0x08
|
||||
#define JOY_BTN_1_MASK 0x10
|
||||
|
||||
/* get_tv return values */
|
||||
#define AT_NTSC 0
|
||||
#define AT_PAL 1
|
||||
@@ -104,4 +111,4 @@ extern void atr5200std_joy[]; /* referred to by joy_static_stddrv[] */
|
||||
#define ANTIC (*(struct __antic*)0xD400)
|
||||
|
||||
/* End of atari5200.h */
|
||||
#endif /* #ifndef _ATARI5200_H */
|
||||
#endif
|
||||
|
||||
@@ -113,6 +113,15 @@
|
||||
|
||||
|
||||
|
||||
/* Masks for joy_read */
|
||||
#define JOY_UP_MASK 0x10
|
||||
#define JOY_DOWN_MASK 0x08
|
||||
#define JOY_LEFT_MASK 0x01
|
||||
#define JOY_RIGHT_MASK 0x02
|
||||
#define JOY_BTN_1_MASK 0x20
|
||||
|
||||
|
||||
|
||||
/* No support for dynamically loadable drivers */
|
||||
#define DYN_DRV 0
|
||||
|
||||
|
||||
@@ -91,6 +91,13 @@
|
||||
#define TGI_COLOR_LIGHTBLUE COLOR_LIGHTBLUE
|
||||
#define TGI_COLOR_GRAY3 COLOR_GRAY3
|
||||
|
||||
/* Masks for joy_read */
|
||||
#define JOY_UP_MASK 0x01
|
||||
#define JOY_DOWN_MASK 0x02
|
||||
#define JOY_LEFT_MASK 0x04
|
||||
#define JOY_RIGHT_MASK 0x08
|
||||
#define JOY_BTN_1_MASK 0x10
|
||||
|
||||
/* Video mode defines */
|
||||
#define VIDEOMODE_40x25 0x00
|
||||
#define VIDEOMODE_80x25 0x80
|
||||
|
||||
@@ -99,6 +99,13 @@
|
||||
#define TGI_COLOR_LIGHTBLUE COLOR_LIGHTBLUE
|
||||
#define TGI_COLOR_GRAY3 COLOR_GRAY3
|
||||
|
||||
/* Masks for joy_read */
|
||||
#define JOY_UP_MASK 0x01
|
||||
#define JOY_DOWN_MASK 0x02
|
||||
#define JOY_LEFT_MASK 0x04
|
||||
#define JOY_RIGHT_MASK 0x08
|
||||
#define JOY_BTN_1_MASK 0x10
|
||||
|
||||
/* Define hardware */
|
||||
#include <_vic2.h>
|
||||
#define VIC (*(struct __vic2*)0xD000)
|
||||
|
||||
+2
-4
@@ -75,10 +75,8 @@
|
||||
|
||||
|
||||
|
||||
/* Expanding upon joystick.h */
|
||||
#define JOY_FIRE_IDX 4
|
||||
|
||||
#define JOY_FIRE(v) ((v) & joy_masks[JOY_FIRE_IDX])
|
||||
#define JOY_FIRE_MASK JOY_BTN_1_MASK
|
||||
#define JOY_FIRE(v) ((v) & JOY_FIRE_MASK)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -112,6 +112,17 @@
|
||||
#define COLOR_LIGHTBLUE (BCOLOR_LIGHTBLUE | CATTR_LUMA7)
|
||||
#define COLOR_GRAY3 (BCOLOR_WHITE | CATTR_LUMA5)
|
||||
|
||||
|
||||
|
||||
/* Masks for joy_read */
|
||||
#define JOY_UP_MASK 0x01
|
||||
#define JOY_DOWN_MASK 0x02
|
||||
#define JOY_LEFT_MASK 0x04
|
||||
#define JOY_RIGHT_MASK 0x08
|
||||
#define JOY_BTN_1_MASK 0x80
|
||||
|
||||
|
||||
|
||||
/* Define hardware */
|
||||
#include <_ted.h>
|
||||
#define TED (*(struct __ted*)0xFF00)
|
||||
|
||||
@@ -92,6 +92,13 @@
|
||||
#define COLOR_LIGHTBLUE 0x0E
|
||||
#define COLOR_GRAY3 0x0F
|
||||
|
||||
/* Masks for joy_read */
|
||||
#define JOY_UP_MASK 0x01
|
||||
#define JOY_DOWN_MASK 0x02
|
||||
#define JOY_LEFT_MASK 0x04
|
||||
#define JOY_RIGHT_MASK 0x08
|
||||
#define JOY_BTN_1_MASK 0x10
|
||||
|
||||
/* Define hardware */
|
||||
#include <_vic2.h>
|
||||
#define VIC (*(struct __vic2*)0xD800)
|
||||
|
||||
@@ -40,6 +40,14 @@
|
||||
#define CH_LLCORNER 37
|
||||
#define CH_LRCORNER 38
|
||||
|
||||
/* Masks for joy_read */
|
||||
#define JOY_UP_MASK 0x10
|
||||
#define JOY_DOWN_MASK 0x04
|
||||
#define JOY_LEFT_MASK 0x20
|
||||
#define JOY_RIGHT_MASK 0x08
|
||||
#define JOY_BTN_1_MASK 0x01
|
||||
#define JOY_BTN_2_MASK 0x02
|
||||
|
||||
/* no support for dynamically loadable drivers */
|
||||
#define DYN_DRV 0
|
||||
|
||||
|
||||
@@ -52,6 +52,7 @@ typedef struct {
|
||||
/* Driver header */
|
||||
char id[3]; /* Contains 0x65, 0x6d, 0x64 ("emd") */
|
||||
unsigned char version; /* Interface version */
|
||||
void* /* Library reference */
|
||||
|
||||
/* Jump vectors. Note that these are not C callable */
|
||||
void* install; /* INSTALL routine */
|
||||
|
||||
+18
-9
@@ -170,16 +170,25 @@
|
||||
/* 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
|
||||
/* Masks for joy_read */
|
||||
#define JOY_UP_MASK 0x01
|
||||
#define JOY_DOWN_MASK 0x02
|
||||
#define JOY_LEFT_MASK 0x04
|
||||
#define JOY_RIGHT_MASK 0x08
|
||||
#define JOY_BTN_1_MASK 0x10
|
||||
#define JOY_BTN_2_MASK 0x20
|
||||
#define JOY_BTN_3_MASK 0x40
|
||||
#define JOY_BTN_4_MASK 0x80
|
||||
|
||||
#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])
|
||||
#define JOY_BTN_A_MASK JOY_BTN_1_MASK
|
||||
#define JOY_BTN_B_MASk JOY_BTN_2_MASK
|
||||
#define JOY_START_MASK JOY_BTN_3_MASK
|
||||
#define JOY_SELECT_MASK JOY_BTN_4_MASK
|
||||
|
||||
#define JOY_BTN_A(v) ((v) & JOY_BTN_A_MASK)
|
||||
#define JOY_BTN_B(v) ((v) & JOY_BTN_B_MASK)
|
||||
#define JOY_START(v) ((v) & JOY_START_MASK)
|
||||
#define JOY_SELECT(v) ((v) & JOY_SELECT_MASK)
|
||||
|
||||
/* The addresses of the static drivers */
|
||||
extern void gamate_stdjoy_joy[]; /* Referred to by joy_static_stddrv[] */
|
||||
|
||||
@@ -133,6 +133,12 @@
|
||||
#define TGI_COLOR_LIGHTBLUE COLOR_LIGHTBLUE
|
||||
#define TGI_COLOR_GRAY3 COLOR_GRAY3
|
||||
|
||||
#define JOY_UP_MASK 0x01
|
||||
#define JOY_DOWN_MASK 0x02
|
||||
#define JOY_LEFT_MASK 0x04
|
||||
#define JOY_RIGHT_MASK 0x08
|
||||
#define JOY_BTN_1_MASK 0x10
|
||||
|
||||
|
||||
/* End of geos.h */
|
||||
#endif
|
||||
|
||||
+8
-21
@@ -55,28 +55,15 @@
|
||||
#define JOY_1 0
|
||||
#define JOY_2 1
|
||||
|
||||
/* The following codes are *indices* into the joy_masks array */
|
||||
#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 button if available */
|
||||
#define JOY_BTN_3_IDX 6 /* Third button if available */
|
||||
#define JOY_BTN_4_IDX 7 /* Fourth 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_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])
|
||||
#define JOY_UP(v) ((v) & JOY_UP_MASK)
|
||||
#define JOY_DOWN(v) ((v) & JOY_DOWN_MASK)
|
||||
#define JOY_LEFT(v) ((v) & JOY_LEFT_MASK)
|
||||
#define JOY_RIGHT(v) ((v) & JOY_RIGHT_MASK)
|
||||
#define JOY_BTN_1(v) ((v) & JOY_BTN_1_MASK) /* Universally available */
|
||||
#define JOY_BTN_2(v) ((v) & JOY_BTN_2_MASK) /* Second button if available */
|
||||
#define JOY_BTN_3(v) ((v) & JOY_BTN_3_MASK) /* Third button if available */
|
||||
#define JOY_BTN_4(v) ((v) & JOY_BTN_4_MASK) /* Fourth button if available */
|
||||
|
||||
/* The name of the standard joystick driver for a platform */
|
||||
extern const char joy_stddrv[];
|
||||
|
||||
@@ -52,9 +52,7 @@ typedef struct {
|
||||
/* Driver header */
|
||||
char id[3]; /* Contains 0x6a, 0x6f, 0x79 ("joy") */
|
||||
unsigned char version; /* Interface version */
|
||||
|
||||
/* Bitmasks for the joystick states. See joystick.h for indices */
|
||||
unsigned char masks[8];
|
||||
void* /* Library reference */
|
||||
|
||||
/* Jump vectors. Note that these are not C callable */
|
||||
void* install; /* INSTALL routine */
|
||||
@@ -85,6 +83,3 @@ void joy_clear_ptr (void);
|
||||
|
||||
/* End of joy-kernel.h */
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
+14
-9
@@ -87,20 +87,25 @@
|
||||
#define TGI_COLOR_LIGHTBLUE COLOR_LIGHTBLUE
|
||||
#define TGI_COLOR_WHITE COLOR_WHITE
|
||||
|
||||
/* Masks for joy_read */
|
||||
#define JOY_UP_MASK 0x80
|
||||
#define JOY_DOWN_MASK 0x40
|
||||
#define JOY_LEFT_MASK 0x20
|
||||
#define JOY_RIGHT_MASK 0x10
|
||||
#define JOY_BTN_1_MASK 0x01
|
||||
#define JOY_BTN_2_MASK 0x02
|
||||
|
||||
#define JOY_BTN_A_MASK JOY_BTN_1_MASK
|
||||
#define JOY_BTN_B_MASK JOY_BTN_2_MASK
|
||||
|
||||
#define JOY_BTN_A(v) ((v) & JOY_BTN_A_MASK)
|
||||
#define JOY_BTN_B(v) ((v) & JOY_BTN_B_MASK)
|
||||
|
||||
/* 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_BTN_A(v) ((v) & joy_masks[JOY_BTN_A_IDX])
|
||||
#define JOY_BTN_B(v) ((v) & joy_masks[JOY_BTN_B_IDX])
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Variables */
|
||||
/*****************************************************************************/
|
||||
|
||||
+20
-11
@@ -82,6 +82,26 @@
|
||||
#define COLOR_LIGHTBLUE 0x0E
|
||||
#define COLOR_GRAY3 0x0F
|
||||
|
||||
/* Masks for joy_read */
|
||||
#define JOY_UP_MASK 0x10
|
||||
#define JOY_DOWN_MASK 0x20
|
||||
#define JOY_LEFT_MASK 0x40
|
||||
#define JOY_RIGHT_MASK 0x80
|
||||
#define JOY_BTN_1_MASK 0x01
|
||||
#define JOY_BTN_2_MASK 0x02
|
||||
#define JOY_BTN_3_MASK 0x04
|
||||
#define JOY_BTN_4_MASK 0x08
|
||||
|
||||
#define JOY_BTN_A_MASK JOY_BTN_1_MASK
|
||||
#define JOY_BTN_B_MASK JOY_BTN_2_MASK
|
||||
#define JOY_SELECT_MASK JOY_BTN_3_MASK
|
||||
#define JOY_START_MASK JOY_BTN_4_MASK
|
||||
|
||||
#define JOY_BTN_A(v) ((v) & JOY_BTN_A_MASK)
|
||||
#define JOY_BTN_B(v) ((v) & JOY_BTN_B_MASK)
|
||||
#define JOY_SELECT(v) ((v) & JOY_SELECT_MASK)
|
||||
#define JOY_START(v) ((v) & JOY_START_MASK)
|
||||
|
||||
/* Return codes of get_tv */
|
||||
#define TV_NTSC 0
|
||||
#define TV_PAL 1
|
||||
@@ -90,17 +110,6 @@
|
||||
/* 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_SELECT_IDX 6
|
||||
#define JOY_START_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_SELECT(v) ((v) & joy_masks[JOY_SELECT_IDX])
|
||||
#define JOY_START(v) ((v) & joy_masks[JOY_START_IDX])
|
||||
|
||||
/* Define hardware */
|
||||
|
||||
/* Picture Processing Unit */
|
||||
|
||||
+21
-12
@@ -73,19 +73,28 @@
|
||||
#define TV_PAL 1
|
||||
#define TV_OTHER 2
|
||||
|
||||
/* Masks for joy_read */
|
||||
#define JOY_UP_MASK 0x10
|
||||
#define JOY_DOWN_MASK 0x40
|
||||
#define JOY_LEFT_MASK 0x80
|
||||
#define JOY_RIGHT_MASK 0x20
|
||||
#define JOY_BTN_1_MASK 0x01
|
||||
#define JOY_BTN_2_MASK 0x02
|
||||
#define JOY_BTN_3_MASK 0x04
|
||||
#define JOY_BTN_4_MASK 0x08
|
||||
|
||||
#define JOY_BTN_I_MASK JOY_BTN_1_MASK
|
||||
#define JOY_BTN_II_MASK JOY_BTN_2_MASK
|
||||
#define JOY_SELECT_MASK JOY_BTN_3_MASK
|
||||
#define JOY_RUN_MASK JOY_BTN_4_MASK
|
||||
|
||||
#define JOY_BTN_I(v) ((v) & JOY_BTN_I_MASK)
|
||||
#define JOY_BTN_II(v) ((v) & JOY_BTN_II_MASK)
|
||||
#define JOY_SELECT(v) ((v) & JOY_SELECT_MASK)
|
||||
#define JOY_RUN(v) ((v) & JOY_RUN_MASK)
|
||||
|
||||
/* No support for dynamically loadable drivers */
|
||||
#define DYN_DRV 0
|
||||
|
||||
/* Expanding upon joystick.h */
|
||||
#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_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])
|
||||
#define DYN_DRV 0
|
||||
|
||||
/* The addresses of the static drivers */
|
||||
extern void pce_stdjoy_joy[]; /* Referred to by joy_static_stddrv[] */
|
||||
|
||||
@@ -55,6 +55,13 @@
|
||||
#define COLOR_BLACK 0x00
|
||||
#define COLOR_WHITE 0x01
|
||||
|
||||
/* Masks for joy_read */
|
||||
#define JOY_UP_MASK 0x01
|
||||
#define JOY_DOWN_MASK 0x02
|
||||
#define JOY_LEFT_MASK 0x04
|
||||
#define JOY_RIGHT_MASK 0x08
|
||||
#define JOY_BTN_1_MASK 0x10
|
||||
|
||||
/* Define hardware */
|
||||
#include <_pia.h>
|
||||
#define PIA1 (*(struct __pia*)0xE810)
|
||||
|
||||
@@ -77,6 +77,15 @@
|
||||
|
||||
|
||||
|
||||
/* Masks for joy_read */
|
||||
#define JOY_UP_MASK 0x01
|
||||
#define JOY_DOWN_MASK 0x02
|
||||
#define JOY_LEFT_MASK 0x04
|
||||
#define JOY_RIGHT_MASK 0x08
|
||||
#define JOY_BTN_1_MASK 0x10
|
||||
|
||||
|
||||
|
||||
/* Define hardware */
|
||||
#include <_vic.h>
|
||||
#define VIC (*(struct __vic*)0x9000)
|
||||
|
||||
Reference in New Issue
Block a user