Routines |
Prev: FEA3 | Up: Map | Next: FEF4 |
This is the input routine for Sinclair joysticks. The Sinclair interface maps Up/Down/Left/Right/Fire to keys 9/8/6/7/0.
|
||||||||
inputroutine_sinclair | FECD | LD BC,$EFFE | Load BC with the port number of the keyboard half row for keys 6/7/8/9/0 | |||||
FED0 | IN A,(C) | Read that port. We'll receive xxx67890 | ||||||
FED2 | CPL | The keyboard is active low, so complement the value | ||||||
FED3 | LD BC,$0000 | Clear our left_right and up_down variables | ||||||
FED6 | RRCA | Rotate '0' out: 0xxx6789 | ||||||
Up
|
||||||||
FED7 | RRCA | Rotate '9' out: 90xxx678 | ||||||
FED8 | JR NC,inputroutine_sinclair_0 | If carry was set then '9' was pressed, otherwise skip | ||||||
FEDA | LD C,$01 | up_down = input_UP | ||||||
Down
|
||||||||
inputroutine_sinclair_0 | FEDC | RRCA | Rotate '8' out: 890xxx67 | |||||
FEDD | JR NC,inputroutine_sinclair_1 | If carry was set then '8' was pressed, otherwise skip | ||||||
FEDF | LD C,$02 | up_down = input_DOWN | ||||||
Right
|
||||||||
inputroutine_sinclair_1 | FEE1 | RRCA | Rotate '7' out: 7890xxx6 | |||||
FEE2 | JR NC,inputroutine_sinclair_2 | If carry was set then '7' was pressed, otherwise skip | ||||||
FEE4 | LD B,$06 | left_right = input_RIGHT | ||||||
Left
|
||||||||
inputroutine_sinclair_2 | FEE6 | RRCA | Rotate '6' out: 67890xxx | |||||
FEE7 | JR NC,inputroutine_sinclair_3 | If carry was set then '6' was pressed, otherwise skip | ||||||
FEE9 | LD B,$03 | left_right = input_LEFT | ||||||
Fire
|
||||||||
inputroutine_sinclair_3 | FEEB | AND $08 | Is '0' pressed? | |||||
FEED | JR Z,inputroutine_sinclair_4 | Jump forward if not | ||||||
FEEF | LD A,$09 | fire = input_FIRE | ||||||
inputroutine_sinclair_4 | FEF1 | ADD A,B | Combine the fire, up_down and left_right values | |||||
FEF2 | ADD A,C | |||||||
FEF3 | RET | Return |
Prev: FEA3 | Up: Map | Next: FEF4 |