Pursuing Tom Ram

Game available in Itch.io.

Soruce code in Github.

Programming adventures in VIC-20.


Understanding input I. Break into pieces.

The simplest input a text adventure should manage is a VERB and a NAME, for example, GO NORTH, TAKE KEY or EXAMINE TREE. So I program a subroutine that process a verb and a carriage return or a verb, an space, a name and a carriage return.

So, after an input, I will search for an space and Split the input into two parts, first one will be the verb and the other one (if any) will be the name.

Some verbs does not need a name (INVENTORY, NORTH, etc.), So it will be ok if name is empty. If VERB needs a name I will check if there is a valid NAME.

  
;---------------
ProcessInput

        ldx #0
        ldy #0

        ; Cleans verb and name
        stx verb+1 
        stx name
        stx name+1

N_C     lda INPUT_BUFFER,X
        cmp #RETURN
        beq @End
        CMP #SPACE 
        beq @Reset
        cpy #$4
        beq @Next
        sta verb,y
        iny
        cpy #$2
        beq @Disable

@Next    
        inx
        jmp N_C

@Disable
        ldy #$4
        jmp @Next

@Reset
        ldy #$2
        jmp @Next

@End    
        lda #RETURN
        jsr CHROUT 
        rts

  

Text adventures does not use all characters in the input. They select a number of characters from VERB and INPUT and discard the rest.

Pursuing Tom Ram uses two characters only for VERB and NAME, So EXAMINE and EX are the same input.

I store both string (4 bytes in total). Maybe I could process VERB first and then NAME.