smpc: add oreg/intback macros

This commit is contained in:
Zack Buhman 2023-05-04 14:33:46 -07:00
parent d58f0a9e32
commit dcdcd7749a

12
smpc.h
View File

@ -133,6 +133,7 @@ typedef struct smpc_reg {
static_assert((sizeof (struct smpc_reg)) == 0x80); static_assert((sizeof (struct smpc_reg)) == 0x80);
static_assert((offsetof (struct smpc_reg, OREG0)) == 0x21); static_assert((offsetof (struct smpc_reg, OREG0)) == 0x21);
static_assert((offsetof (struct smpc_reg, OREG1)) == 0x23);
static_assert((offsetof (struct smpc_reg, SF)) == 0x63); static_assert((offsetof (struct smpc_reg, SF)) == 0x63);
struct smpc { struct smpc {
@ -198,6 +199,17 @@ enum sr_bit {
#define SR__P1MD__0BYTE(sr) (((sr & 0b00000011)) == (0b11 << 0)) #define SR__P1MD__0BYTE(sr) (((sr & 0b00000011)) == (0b11 << 0))
}; };
//enum port_status {
#define PORT_STATUS__CONNECTORS(oreg) ((oreg >> 0) & 0b1111)
#define PORT_STATUS__MULTITAP_ID(oreg) ((oreg >> 4) & 0b1111)
//}
//enum peripheral_id {
#define PERIPHERAL_ID__DATA_SIZE(oreg) ((oreg >> 0) & 0b1111)
#define PERIPHERAL_ID__IS_DIGITAL_PAD(oreg) (((oreg >> 4) & 0b1111) == 0b0000)
//}
enum digital_bit { enum digital_bit {
DIGITAL__1__RIGHT = (1 << 7), DIGITAL__1__RIGHT = (1 << 7),
DIGITAL__1__LEFT = (1 << 6), DIGITAL__1__LEFT = (1 << 6),