![]() |
Routines |
| Prev: 9398 | Up: Map | Next: 93E3 |
|
Returns one byte for all three control methods, in Kempston's bit order: bit 0 right, bit 1 left, bit 2 down, bit 3 up, bit 4 fire. A bit is 0 when that direction is being asked for.
Kempston reads the other way round, so its byte is inverted; the keyboard needs no inversion but does need its bits shuffled, because Q and W sit in the opposite order to left and right. That swap is the whole reason this routine looks fiddly -- it is what lets the movement code downstream be written once instead of three times.
This is what pins down the key map: the half-row selected is $FBFE, which is Q W E R T, and after the swap Q lands on the "left" bit and W on the "right" bit. So the keyboard controls are Q left, W right, E down, R up, T fire. Confirmed live -- holding W drives the player's x up to the room's right-hand limit and E drives y down to the bottom one.
|
||||||||
| READ_CONTROLS | 93BE | LD A,($5E00) | The control method chosen on the title screen, kept in $5E00. | |||||
| 93C1 | AND $06 | |||||||
| 93C3 | JR Z,READ_CONTROLS_0 | 0 is keyboard, 4 is the cursor keys, anything else Kempston. | ||||||
| 93C5 | CP $04 | |||||||
| 93C7 | JR Z,READ_CURSOR_KEYS | |||||||
| 93C9 | IN A,($1F) | Kempston is active high, so invert it to match the other two. | ||||||
| 93CB | CPL | |||||||
| 93CC | RET | |||||||
| READ_CONTROLS_0 | 93CD | LD A,$FB | Select the half-row holding Q, W, E, R and T. | |||||
| 93CF | OUT ($FD),A | |||||||
| 93D1 | IN A,($FE) | Bits 0-4 are Q, W, E, R, T in that order. | ||||||
| 93D3 | LD C,A | |||||||
| 93D4 | RRA | Exchange bits 0 and 1, so that W becomes "right" and Q "left". | ||||||
| 93D5 | AND $01 | |||||||
| 93D7 | LD E,A | |||||||
| 93D8 | LD A,C | |||||||
| 93D9 | RLA | |||||||
| 93DA | AND $02 | |||||||
| 93DC | OR E | |||||||
| 93DD | LD E,A | |||||||
| 93DE | LD A,C | E, R and T are already in the right places for down, up and fire. | ||||||
| 93DF | AND $1C | |||||||
| 93E1 | OR E | |||||||
| 93E2 | RET | |||||||
| Prev: 9398 | Up: Map | Next: 93E3 |