Pursuing Tom Ram

Game available in Itch.io.

Soruce code in Github.

Programming adventures in VIC-20.


Movement Improved

I used four routines in the movement code. If you think so, yes there is many duplicated code. We can do it with just one routine.

If instead of subtracting, I add the number in two's complement, then the routine is the same. To find out which number to add, I create a new vector. If the direction is north, I add the first number, if it is south, I add the second (which is the two's complement of the rows to be subtracted), and so on.

If you do not know what a two's complement is, take a minute to look it up, it's easy to learn and use.

  
; Entry point
Move_CMD 
        jsr MovementCommands
        
        ; Caluclate mask
        lda #$3
        sec
        sbc verb_index

        tax
        tya

        and masks,x
        beq NoSalida ; No hay salida
        

        ldx verb_index

        lda loc
        clc
        adc offset,x
        sta loc

End     
        jmp PrintContent 

  

Remember, I stored the masks for the flags, I use again those masks

  
masks
        BYTE %00000001, %00000010, %00000100, %00001000
        BYTE %00010000, %00100000, %01000000, %10000000