[Coco] Assembly code scans keyboard but doesn't repeat
William Astle
lost at l-w.ca
Mon Mar 6 17:37:25 EST 2017
You need a state table to keep track of keys that are pressed. Take a
look at POLCAT (or "KEYIN" in the color basic unravelled book) to see
how the Basic ROM does it, though that routine looks are any key press.
On 2017-03-06 03:28 PM, Glen Hewlett wrote:
> Hi All,
>
> Can anyone show me a little assembly code to scan the keyboard for key presses so they don’t repeat? The code below works for the Up and Down arrows but the keypresses repeat.
>
> Thanks,
> Glen
>
> ScanKeys:
> LDX #PIA0_Byte_0_KeyRow_Joy * PIA0
> ; Up Arrow
> LDA #%11110111 * Bit 3
> STA $02,X
> LDA ,X
> BITA #%00001000 * and bit 3 = Up Arrow pushed
> BNE > * If not, scan for another key
> LDA #1
> STA MovePointer
> BRA CheckedKeys
> ; Down Arrow
> ! LDA #%11101111 * Bit 4
> STA $02,X
> LDA ,X
> BITA #%00001000 * and bit 3 = Down Arrow pushed
> BNE > * If not, scan for another key
> LDA #2
> STA MovePointer
> BRA CheckedKeys
> !…
>
>
>
More information about the Coco
mailing list