Added crater clipping to terrain edges

This commit is contained in:
blondie7575 2017-09-18 12:51:01 -07:00
parent 3a5f8594f2
commit 5d04f335e0
4 changed files with 16 additions and 17 deletions

View File

@ -22,21 +22,6 @@ beginGameplay:
; Generate, compile, and clip terrain
jsr generateTerrain
; lda #40
; sta PARAML0
; lda #30
; sta PARAML1
; ldy #12
; jsr craterTerrain
; lda #74
; sta PARAML0
; lda #30
; sta PARAML1
; ldy #16
; jsr craterTerrain
jsr compileTerrain
jsr clipTerrain

Binary file not shown.

View File

@ -30,7 +30,7 @@ GRAVITY = $ffff ; 8.8 fixed point
projectileTypes: ; Byte offsets into projectile type data structure
.word 50 ; Damage
.word 12 ; Crater radius
.word 40 ; Crater radius
.word 0,0 ; Padding
PT_DAMAGE = 0

View File

@ -66,7 +66,6 @@ craterTerrain:
sbc PARAML0
sty SCRATCHL ; Center width in bytes
sbc SCRATCHL
; sbc SCRATCHL
and #$fffe ; Force even
clc
adc #terrainData
@ -84,9 +83,18 @@ craterTerrainLoop:
dey
bmi craterTerrainDone
tya
clc
adc PARAML0 ; Clip to terrain edges
cmp #terrainData
bmi craterTerrainDone
cmp #terrainDataEnd
bpl craterTerrainLoop
lda (SCRATCHL),y ; Fetch circle Y value
clc
adc PARAML1 ; Convert to terrain-space
bmi craterTerrainZero
sta SCRATCHL2
lda (PARAML0),y
cmp SCRATCHL2
@ -96,6 +104,11 @@ craterTerrainLoop:
sta (PARAML0),y
bra craterTerrainLoop
craterTerrainZero: ; Circle went negative so clip to 0
lda #0
sta (PARAML0),y
bra craterTerrainLoop
craterTerrainDone:
lda #1
sta terrainDirty
@ -408,6 +421,7 @@ terrainData:
.repeat TERRAINWIDTH/2
.word 0
.endrepeat
terrainDataEnd:
compiledTerrain:
.repeat COMPILEDTERRAINROW * MAXTERRAINHEIGHT