make the smpc intback interrupt do something
This commit is contained in:
parent
fe51d016df
commit
fa41d47e1f
22
main.c
22
main.c
@ -44,7 +44,7 @@ void oci_int(void)
|
|||||||
|
|
||||||
smpc.reg.IREG0 = INTBACK__IREG0__STATUS_DISABLE;
|
smpc.reg.IREG0 = INTBACK__IREG0__STATUS_DISABLE;
|
||||||
smpc.reg.IREG1 = ( INTBACK__IREG1__PERIPHERAL_DATA_ENABLE
|
smpc.reg.IREG1 = ( INTBACK__IREG1__PERIPHERAL_DATA_ENABLE
|
||||||
| INTBACK__IREG1__PORT2_15BYTE
|
| INTBACK__IREG1__PORT2_0BYTE
|
||||||
| INTBACK__IREG1__PORT1_15BYTE
|
| INTBACK__IREG1__PORT1_15BYTE
|
||||||
);
|
);
|
||||||
smpc.reg.IREG2 = INTBACK__IREG2__MAGIC;
|
smpc.reg.IREG2 = INTBACK__IREG2__MAGIC;
|
||||||
@ -60,6 +60,26 @@ void smpc_int(void)
|
|||||||
{
|
{
|
||||||
scu.reg.IST &= ~(IST__SMPC);
|
scu.reg.IST &= ~(IST__SMPC);
|
||||||
|
|
||||||
|
if (smpc.reg.SR & SR__PDL) {
|
||||||
|
// to get all controller data, one should check SR__NPE and send CONTINUE
|
||||||
|
// requests as needed
|
||||||
|
|
||||||
|
// assuming SR__PDL is set and SR__P1MD is not 0-byte-mode:
|
||||||
|
// smpc.reg.OREG0 (port 1 status)
|
||||||
|
// smpc.reg.OREG1 (peripheral 1 data[0] {type,size})
|
||||||
|
// smpc.reg.OREG2 (peripheral 1 data[1])
|
||||||
|
|
||||||
|
if ((smpc.reg.OREG2 & DIGITAL__1__C) == 0) {
|
||||||
|
// if C is pressed, swap the color palette
|
||||||
|
vdp2.cram.u16[1] = (0x31 << 10); // blue
|
||||||
|
vdp2.cram.u16[2] = (0x31 << 5); // green
|
||||||
|
} else {
|
||||||
|
// if C is not pressed, restore the original palette
|
||||||
|
vdp2.cram.u16[1] = (0x31 << 5); // green
|
||||||
|
vdp2.cram.u16[2] = (0x31 << 10); // blue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
smpc.reg.IREG0 = INTBACK__IREG0__BREAK;
|
smpc.reg.IREG0 = INTBACK__IREG0__BREAK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
34
smpc.h
34
smpc.h
@ -180,3 +180,37 @@ enum intback_ireg_bit {
|
|||||||
|
|
||||||
INTBACK__IREG2__MAGIC = (0xF0),
|
INTBACK__IREG2__MAGIC = (0xF0),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum sr_bit {
|
||||||
|
SR__PDL = (1 << 6),
|
||||||
|
SR__NPE = (1 << 5),
|
||||||
|
SR__RESB = (1 << 4),
|
||||||
|
SR__P2MD1 = (1 << 3),
|
||||||
|
SR__P2MD0 = (1 << 2),
|
||||||
|
SR__P1MD1 = (1 << 1),
|
||||||
|
SR__P1MD0 = (1 << 0),
|
||||||
|
#define SR__P2MD__15BYTE(sr) (((sr & 0b00001100)) == (0b00 << 2))
|
||||||
|
#define SR__P2MD__255BYTE(sr) (((sr & 0b00001100)) == (0b01 << 2))
|
||||||
|
#define SR__P2MD__0BYTE(sr) (((sr & 0b00001100)) == (0b11 << 2))
|
||||||
|
|
||||||
|
#define SR__P1MD__15BYTE(sr) (((sr & 0b00000011)) == (0b00 << 0))
|
||||||
|
#define SR__P1MD__255BYTE(sr) (((sr & 0b00000011)) == (0b01 << 0))
|
||||||
|
#define SR__P1MD__0BYTE(sr) (((sr & 0b00000011)) == (0b11 << 0))
|
||||||
|
};
|
||||||
|
|
||||||
|
enum digital_bit {
|
||||||
|
DIGITAL__1__RIGHT = (1 << 7),
|
||||||
|
DIGITAL__1__LEFT = (1 << 6),
|
||||||
|
DIGITAL__1__DOWN = (1 << 5),
|
||||||
|
DIGITAL__1__UP = (1 << 4),
|
||||||
|
DIGITAL__1__START = (1 << 3),
|
||||||
|
DIGITAL__1__A = (1 << 2),
|
||||||
|
DIGITAL__1__C = (1 << 1),
|
||||||
|
DIGITAL__1__B = (1 << 0),
|
||||||
|
|
||||||
|
DIGITAL__2__R = (1 << 7),
|
||||||
|
DIGITAL__2__X = (1 << 6),
|
||||||
|
DIGITAL__2__Y = (1 << 5),
|
||||||
|
DIGITAL__2__Z = (1 << 4),
|
||||||
|
DIGITAL__2__L = (1 << 3),
|
||||||
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user