Very old digger bug fixed!

This commit is contained in:
Pecusx
2023-06-14 22:55:34 +02:00
parent 85cac04328
commit 4e6b29add7
4 changed files with 34 additions and 16 deletions
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+34 -16
View File
@@ -443,7 +443,7 @@ WriteToBranches
sta digtabyH,x sta digtabyH,x
dex dex
bpl WriteToBranches bpl WriteToBranches
jsr DiggerCharacter ; start character ;jsr DiggerCharacter ; start character
adw xdraw #4 adw xdraw #4
lda DigLong lda DigLong
@@ -479,24 +479,18 @@ DigRight ; odd go right (everytime 4 pixels)
sta digtabxH,x sta digtabxH,x
DigRandomize DigRandomize
lda random lda random
and #$87 ;and #$87
bmi DigUp bmi DigUp
DigDown DigDown
and #$07 and #$07
clc clc
adc digtabyL,x adc digtabyL,x
sta digtabyL,x sta digtabyL,x
lda digtabyH,x bcc @+
adc #$00 inc digtabyH,x
sta digtabyH,x ; adc #$00
;crashing bug here - if too much added to digtaby, it gets over screenheight and starts writing over random areas @ ; sta digtabyH,x
;WARNING! fix for 1 byte screenheight. TODO jmp DigCalculateNext
lda digtabyL,x
cmp #screenheight
bcc @+ ; branch if less
lda #screenheight-1
sta digtabyL,x
@ jmp DigCalculateNext
DigUp DigUp
and #$07 and #$07
sta temp sta temp
@@ -504,10 +498,34 @@ DigUp
lda digtabyL,x lda digtabyL,x
sbc temp sbc temp
sta digtabyL,x sta digtabyL,x
lda digtabyH,x bcs @+
sbc #$00 dec digtabyH,x
sta digtabyH,x ; sbc #$00
@ ; sta digtabyH,x
DigCalculateNext DigCalculateNext
;second crashing bug here :) - if too much subtracted from digtaby, it gets under 8 (char height) and starts writing over random areas
lda digtabyH,x
bmi ToHigh
; cmp #0 ; necessary only if screenheight > 255
; bne @+
lda digtabyL,x
cmp #7
;@
bcs CheckLow
ToHigh
lda #0
sta digtabyH,x
lda #7
sta digtabyL,x
CheckLow
;crashing bug here - if too much added to digtaby, it gets over screenheight and starts writing over random areas
;WARNING! fix for 1 byte screenheight. TODO
lda digtabyL,x
cmp #screenheight
bcc @+ ; branch if less
lda #screenheight-1
sta digtabyL,x
@
dex dex
bpl CalculateBranches bpl CalculateBranches
; here we draw... ; here we draw...