Probably fixed rare bug:

the pseudo-random routine pseudo-randomly generated X,Y for new piece of food
that corresponded to immediately next snake head position.
This X,Y resulted empty when checked in the routine, but suddenly after it
is overwritten with snake head, so food simply disappears.
This leads to impossible game play, because no new pieces of food are
generated if no food is previously eaten, but there is no food to eat, so...
Hope to have fixed.
This commit is contained in:
giomba 2017-12-22 12:30:42 +01:00
parent 53b3e700ca
commit 61a1c140f4
2 changed files with 11 additions and 2 deletions

1
BUGS
View File

@ -1,2 +1 @@
- Fix random-eaten food that prevents from playng
- Search for proper SID song - Search for proper SID song

View File

@ -342,11 +342,21 @@ genFood:
sec ; if value is > 18, then subtract 18; now it sec ; if value is > 18, then subtract 18; now it
sbc #18 ; surely is less than 18 sbc #18 ; surely is less than 18
foodNoMod: foodNoMod:
cmp #0
bne foodNoLow ; if it is 0, then set 1 (avoid first line) bne foodNoLow ; if it is 0, then set 1 (avoid first line)
lda #1 lda #1
foodNoLow: foodNoLow:
sta calcTileY ; use this new value as tile Y-coordinate sta calcTileY ; use this new value as tile Y-coordinate
jsr calcTileMem ; calc its address in memory ; Now I have X and Y coordinate for food stored in calcTileX, calcTileY
; and I must check it is not the location that I am going to overwrite
; with the head in draw snake head...
cmp snakeY
bne foodOK
lda snakeX
cmp snakeX
beq genFood
foodOK:
jsr calcTileMem ; calc food address in memory
lda (tileMem),y ; check if memory is empty lda (tileMem),y ; check if memory is empty
cmp #$20 ; is there a space? cmp #$20 ; is there a space?
bne genFood ; if not, must generate another number bne genFood ; if not, must generate another number