Pursuing Tom Ram

Game available in Itch.io.

Soruce code in Github.

Programming adventures in VIC-20.


Objects player can take and objects she cannot

I only have one vector for names. This vector includes the objects a player can take and carry and other names that are not objects.


; Objects: CHandelier (43 48), GLasses, REvolver (52 45), LEaf (4C, 45), IDol (49 44), DOll (44, 4f)
; No Objs: DIary (44 49), BEd (42 45), MIrror (4D 49), TOm (54 4f), MOnster (4D, 4f), TRapdoor (54, 52)
; GOrdon (47 4f)
name_tokens     BYTE $43, $48, $47, $4C, $52, $45, $4C, $45, $49, $44, $44, $4f
                BYTE $44, $49, $42, $45, $4d, $49, $54, $4f, $4d, $4f, $54, $52, $0 


So, how knows the game that a doll is something he player may take but the bed must stay in its loc? You have the answer in the code.

First names are objects you can carry. I use this constant: OBJECTS_NUMER = $7.

If the name token number is lower than this contact, then is an object the player may takes. It other cases, take command will fail. Take a look at the Take command..


Take_CMD
        ; Name is an item
        jsr Name_Is_Item
        bcs Take_P_Useless 


The first thing this command does is to see if name is a object player may take. Here you have the full code of the subroutine.

 

;---
Name_Is_Item
        lda name_index
        tax        
        ; If name is bigger than the cosntant, 
        ; then the player cannot take ir
        sec
        sbc #OBJECTS_NUMER 
        rts


  

Remember. I have to decrement index because $0 means an invalid name, but the first name is index 0. I fixed this inconsistence in my next game, Desert.

If you want to introduce a new objet player may take, you have to remember to add it after the last one and increase the constant. However, if you add an object that player cannot take, you have to add it at the end of the vector and constant remains the same.