When you make an intback call, what it does is fetch SMPC status and/or peripheral data(depending on what you set in IREG0 and IREG1 - IREG2 should be set to 0xF0).
|IREG0 setting||What it does|
|0x00||Don't fetch SMPC status data|
|0x01||Fetch SMPC status data|
Whenever intback finishes, it automatically sends out an SMPC interrupt through the SCU, and then clears the SF register(in that exact order). This can be verified by reading SF immediately in an smpc interrupt handler.
Now depending on what you've all setup intback to fetch, and what peripherals you may have connected, the data the OREG's get set to may be different. Let's say you're only getting peripherals, the OREG's will be set like follows:
OREG0 = Port 1 connection type
OREG1 = If a peripheral is connected, the peripheral id.
OREG2-OREGX = Peripheral data. The number of registers it occupies depending on the peripheral type.
OREGX = Port 2 connection type, etc.
You can usually figure out how to parse the data based on what the port connection type is set to and by the peripheral id.
So say for example the port connection type was set to 0xF1. The lower 4 bits of 0xF1 are the number of peripherals connected to that port(in this case, '1'). The higher 4 bits tell you what kind of connection it is. Refer to the following chart:
|Port connection upper 4 bits||What kind of connection is it?|
|0xF||Direct connection(uses this even if there's no peripherals connected)|
Anything else is considered invalid.
As for peripheral id's, you can figure out the type of peripheral from the upper 4 bits, and the amount of oreg's the peripheral data is taking up from the lower 4 bits. So for example if the peripheral type is 0x02, 0x0 is the type for a standard pad, and 0x2 means there's 2 oreg's worth of data. Refer to the following chart:
|Peripheral ID||What kind of peripheral is it?||Data size|
|0xE1||Mega Drive(3 button)||1|
|0xE2||Mega Drive(6 button)||2|
One thing of note with multi-tap's, you'll get a 0xFF for the peripheral type for each port that's unconnected. For example:
OREG0 = 0x16 (6 player multi-tap connected to port 1)
OREG1 = 0x02 (standard pad connected to port 1a)
OREG2 = 0xFF (pad data 1)
OREG3 = 0xFF (pad data 2)
OREG4 = 0xFF (no pad connected to port 1b)
OREG5 = 0xFF (no pad connected to port 1c)
OREG6 = 0xFF (no pad connected to port 1d)
OREG7 = 0xFF (no pad connected to port 1e)
OREG8 = 0x02 (standard pad connected to port 1f)
OREG9 = 0xFF (pad data 1)
OREG10 = 0xFF (pad data 2)
OREG11 = 0xF0 (Nothing connected to port 2)
As you can see, there are standard pads connected to port 1a and 1f, but nothing in between.
Special Notes: There may be times when there's too much peripheral data collected than what the oreg's can hold. You should be checking the PDE bit of the SR register after each intback command to make sure that you've got everything(if there's more peripheral data, this bit will be set). To retrieve more data after an intback command, write 0x80 to IREG0. IREG0 appears to be polled since you can write 0x81 to IREG0 before issuing an INTBACK command and it'll retrieve the second set of data automatically.