Pursuing Tom Ram

Game available in Itch.io.

Soruce code in Github.

Programming adventures in VIC-20.


Input

There are two main subroutines for reading from keyboard: CHIN and GET.

CHIN is an Input. It captures all keys unit you press RETURN. On the other hand, GET waits a key and end.

GET is your routine if you want to create a specific input routine. However, I have not nought memory in the VIC-20, so I will use CHIN. CHIN is a routine from de Commodore Kernal well documented, so you should use it without problems.

VIC-20 documentation says: first time you call CHIN the computer asks the user a input ending in RETURN. Further calls returns characters one by one. So, you have to call CHIN one time for every character in input plus the first call.

  
;---------------
Input
        LDX #0

@Loop
        JSR CHIN
        STA INPUT_BUFFER,X ; $200
        INX
        CMP #RETURN 
        BNE @Loop
        rts


  

With the previous code, I copy the characters read by CHIN in INPUT_BUFFER memory address (which is $200)

How do I know when to stop calling CHIN? When CHIN returns a RETURN character