Desert

Game available in Itch.io.

Soruce code in Github.

Programming grid games in assembly for VIC-20.


Variables and page 0

You already know what page 0 is about (if you do not, read that section of Pursing Tom Ram).

In this game, I store more information, so I use more positions from page 0. In the source code, you have the addresses I use and their original mission.

  
; $3-$4, ADRAY1, vector to flating point / integer routine (INTIDX)
; Never used by basic
player_x = $3
player_y = $4

; $5-$6, ADRAY2, vector to flating point to integer (MAKFP)
; Never used by basic
water = $5
life = $6

; $/ Search-character for basic
; $8 Scan-quotes flag
;verb = $7 ; Uses $7 and $8
; No funciona, puede que las rutinas de inpt loc mabien

; $9 Column cursor before TAB
; $A Byte to LOAD
verb = $9

; $B  used as an index into the BASIC input text

; $C flag for array routines
verb_index = $C

; $D Type of variable: string / numeric
; no funciona

; $e
current_loc_type = $e

; Empty page 0 psotiton 
tmp_a = $fb
tmp_b = $fc

  

Due I call BASIC subroutines I have to be careful not to use any positions on page 0 that use those BASIC routines. For that reason, I have left some gaps.

I also use the string buffer at the top of page 3 (address $200).

Map of desert

Map is 16x16. Desert has 256 locations in total. I use this value because I have to now the loc the player is the biggest value I can store in a byte is 256.

How do I store the content of a location?

You could store a name per location. For example, if the number of the loc is 0 it means there is nothing there, a 1 means an enemy, a 2 an oases, etc.

I am going to do it in this way but with a Little change. A number uses (al least) 1 byte and I I store a number per loc I will use 256 bytes. It nos not too mucho but I would like to save

I use 4 bits per loc, so the map uses 128 bytes in memory. The drawback is I can only have 16 different locations, but there are some tricks to sue if I need more locations.

This is the final map of the Student Edition.

  
; 0001 - Birds in the sky
OASIS_LOC = $2; 0010 - Oasis
;OASIS_TO_EAST = $3 ; 0011
; Enemy 1: Ruk 0100
IDOL_LOC = $5 ; Object 1: Idol 0101
; Vibration 0110
FLASK_LOC = $7 ; Object 2: Flask 0111
; Enemy 2: Scorpion 1000
COMPASS_LOC = $9  ; Object 3: Compass 1001
TEMPLE_LOC = $a ; Temple 1010
ANKH_LOC = $b ; Object 4: Ankh 1011
FINAL_LOC = $c ; End of game 1100
; Vision of an enemy 1101

row00 BYTE EMPTY,     EMPTY,     %00000110, %01000110, EMPTY,     EMPTY,     EMPTY, EMPTY
row01 BYTE %00000111, EMPTY,     EMPTY,     %01100000, EMPTY,     %00001001, EMPTY, %00100001
row02 BYTE EMPTY,     EMPTY,     EMPTY,     EMPTY,     EMPTY,     EMPTY,     EMPTY, %01100000
row03 BYTE %00010000, EMPTY,     EMPTY,     EMPTY,     EMPTY,     %00000101, %00000110, %01000110
row04 BYTE %00100000, EMPTY,     %00000001, EMPTY,     EMPTY,     %01100000, EMPTY, %01100000
row05 BYTE %00000110, EMPTY,     %00000010, EMPTY,     %00000110, %10000110, EMPTY, EMPTY
row06 BYTE %01101000, %01100000, %00000001, EMPTY,     EMPTY,     %01100000, EMPTY, %01110000
row07 BYTE %00000110, EMPTY,     EMPTY,     EMPTY,     EMPTY,     %00000010,EMPTY, EMPTY
row08 BYTE EMPTY,     EMPTY,     EMPTY,     EMPTY,     EMPTY,     EMPTY,EMPTY, EMPTY
row09 BYTE EMPTY,     %01110000, EMPTY,     EMPTY,     EMPTY,     %11010110, EMPTY,     EMPTY
row10 BYTE EMPTY,     EMPTY,     %00110011, %00001010, EMPTY,     %01100100, %01100000, %00000110
row11 BYTE %00001011, EMPTY,     EMPTY,     EMPTY,     %01100000, %00000110,EMPTY, %01100100
row12 BYTE EMPTY,     EMPTY,     EMPTY,     %00000110, %10000110, EMPTY,%00001100, %00000110
row13 BYTE %00000010, %00010001, EMPTY,     EMPTY,     %00000110, EMPTY, EMPTY, EMPTY
row14 BYTE EMPTY,     EMPTY,     EMPTY,     EMPTY,     EMPTY, EMPTY,%00010001, %00100000 ; 119
row15 BYTE EMPTY,     EMPTY,     EMPTY,     EMPTY,     EMPTY, EMPTY,EMPTY, EMPTY
  

You read about techniques for working with the half of a byte and even with individual bits in the guide about Pursuing Tom Ram. If you do not remember that part of the guide or you skipped it, here you will find some ideas.