vdp1: improve point access

This adds a new union to the vdp1 command list.
This commit is contained in:
Zack Buhman 2023-07-01 04:13:16 +00:00
parent 9ef2884cbc
commit 912c67e2e6
2 changed files with 39 additions and 23 deletions

12
scsp.h
View File

@ -297,10 +297,10 @@ enum dma_bits {
// timer bits // timer bits
//enum tima_bits { //enum tima_bits {
#define TIMA__TACTL(n) ((n & 0b111) << 8) #define TIMA__TACTL(n) (((n) & 0b111) << 8)
#define TIMB__TBCTL(n) ((n & 0b111) << 8) #define TIMB__TBCTL(n) (((n) & 0b111) << 8)
#define TIMC__TCCTL(n) ((n & 0b111) << 8) #define TIMC__TCCTL(n) (((n) & 0b111) << 8)
#define TIMA__TIMA(n) ((n & 0xff) << 0) #define TIMA__TIMA(n) (((n) & 0xff) << 0)
#define TIMB__TIMB(n) ((n & 0xff) << 0) #define TIMB__TIMB(n) (((n) & 0xff) << 0)
#define TIMC__TIMC(n) ((n & 0xff) << 0) #define TIMC__TIMC(n) (((n) & 0xff) << 0)
//}; //};

32
vdp1.h
View File

@ -4,6 +4,11 @@
/* command table */ /* command table */
typedef struct cmd_point {
s16 X;
s16 Y;
} cmd_point;
typedef struct vdp1_cmd { typedef struct vdp1_cmd {
u16 CTRL; u16 CTRL;
u16 LINK; u16 LINK;
@ -11,6 +16,8 @@ typedef struct vdp1_cmd {
u16 COLR; u16 COLR;
u16 SRCA; u16 SRCA;
u16 SIZE; u16 SIZE;
union {
struct {
s16 XA; s16 XA;
s16 YA; s16 YA;
s16 XB; s16 XB;
@ -19,6 +26,15 @@ typedef struct vdp1_cmd {
s16 YC; s16 YC;
s16 XD; s16 XD;
s16 YD; s16 YD;
};
struct {
cmd_point A;
cmd_point B;
cmd_point C;
cmd_point D;
};
cmd_point point[4];
};
u16 GDRA; u16 GDRA;
u16 _dummy; u16 _dummy;
} vdp1_cmd; } vdp1_cmd;
@ -87,7 +103,7 @@ enum pmod_bit {
enum colr_bit { enum colr_bit {
COLR__RGB = (1 << 15) COLR__RGB = (1 << 15)
#define COLR__ADDRESS(n) (n >> 3) #define COLR__ADDRESS(n) ((n) >> 3)
}; };
//enum srca_bit { //enum srca_bit {
@ -102,23 +118,23 @@ enum colr_bit {
/* memory offsets */ /* memory offsets */
typedef union vdp1_vram { typedef union vdp1_vram {
unsigned char u8[0x080000 / 1]; uint8_t u8[0x080000 / 1];
unsigned short u16[0x080000 / 2]; uint16_t u16[0x080000 / 2];
unsigned long u32[0x080000 / 4]; uint32_t u32[0x080000 / 4];
vdp1_cmd cmd[0x080000 / 0x20]; vdp1_cmd cmd[0x080000 / 0x20];
} vdp1_vram; } vdp1_vram;
static_assert((sizeof (union vdp1_vram)) == 0x080000); static_assert((sizeof (union vdp1_vram)) == 0x080000);
typedef union vdp1_framebuffer { typedef union vdp1_framebuffer {
unsigned char u8[0x040000 / 1]; uint8_t u8[0x040000 / 1];
unsigned short u16[0x040000 / 2]; uint16_t u16[0x040000 / 2];
unsigned long u32[0x040000 / 4]; uint32_t u32[0x040000 / 4];
} vdp1_framebuffer; } vdp1_framebuffer;
static_assert((sizeof (union vdp1_framebuffer)) == 0x040000); static_assert((sizeof (union vdp1_framebuffer)) == 0x040000);
typedef unsigned char vdp1_res0[0x040000]; typedef u8 vdp1_res0[0x040000];
typedef struct vdp1_reg { typedef struct vdp1_reg {
reg16 TVMR; /* TV MODE SELECTION */ reg16 TVMR; /* TV MODE SELECTION */