mirror of
https://github.com/badvision/lawless-legends.git
synced 2025-08-12 17:25:06 +00:00
Actually started debugging the sprite math.
This commit is contained in:
@@ -625,7 +625,9 @@ spriteCalc: !zone
|
||||
sbc #>W_LOG_256 ; subtract wLog256
|
||||
sta wLogCosT+1 ; store hi byte
|
||||
|
||||
; Calculate wDx = spriteX - playerX, as abs value and a sign bit
|
||||
!if DEBUG { jsr .debug1 }
|
||||
|
||||
; Calculate wLogDx = log2_w_w(spriteX - playerX), as abs value and a sign bit
|
||||
lda spriteX ; calculate spriteX - playerX
|
||||
sec
|
||||
sbc playerX
|
||||
@@ -641,7 +643,7 @@ spriteCalc: !zone
|
||||
sta wLogDx
|
||||
stx wLogDx+1
|
||||
|
||||
; Calculate wDy = spriteY - playerY, as abs value and a sign bit
|
||||
; Calculate wLogDy = log2_w_w(spriteY - playerY), as abs value and a sign bit
|
||||
lda spriteY ; calculate spriteX - playerX
|
||||
sec
|
||||
sbc playerY
|
||||
@@ -657,6 +659,8 @@ spriteCalc: !zone
|
||||
sta wLogDy
|
||||
stx wLogDy+1
|
||||
|
||||
!if DEBUG { jsr .debug2 }
|
||||
|
||||
; Calculate wRx = bSgnDx*bSgnCosT*pow2_w_w(wLogDx + wLogCosT) -
|
||||
; bSgnDy*bSgnSinT*pow2_w_w(wLogDy + wLogSinT)
|
||||
lda wLogDx ; start with lo byte
|
||||
@@ -696,6 +700,8 @@ spriteCalc: !zone
|
||||
adc wRx+1 ; also hi byte
|
||||
sta wRx+1
|
||||
|
||||
!if DEBUG { jsr .debug3 }
|
||||
|
||||
; if wRx is negative, it means sprite is behind viewer... we get out of school early.
|
||||
bpl +
|
||||
!if DEBUG { +prStr : !text "Sprite is behind viewer.",0 }
|
||||
@@ -833,6 +839,8 @@ spriteCalc: !zone
|
||||
inx ; bump hi byte
|
||||
+ stx wSpriteTop+1 ; save hi byte
|
||||
|
||||
!if DEBUG { jsr .debug4 }
|
||||
|
||||
; Need X position on screen.
|
||||
; The constant below is cheesy and based on empirical observation rather than understanding.
|
||||
; Sorry :/
|
||||
@@ -855,6 +863,8 @@ spriteCalc: !zone
|
||||
jsr pow2_w_w ; back to normal space (in: Y=lo,X=hi, out: A=lo,X=hi)
|
||||
; don't need to actually store wX -- it's only needed for spriteLeft below
|
||||
|
||||
!if DEBUG { jsr .debug5 }
|
||||
|
||||
; Calculate wSpriteLeft = wx + wSpriteTop
|
||||
clc ; lo byte already in A from code above
|
||||
adc wSpriteTop ; add to spriteTop (which if you think about it, is a function of dist just like spriteLeft)
|
||||
@@ -935,6 +945,8 @@ spriteCalc: !zone
|
||||
lsr
|
||||
ror depth
|
||||
|
||||
!if DEBUG { jsr .debug6 }
|
||||
|
||||
.draw ; Okay, I think we're all done with calculations for this sprite.
|
||||
brk ; would draw sprite here
|
||||
|
||||
@@ -950,6 +962,62 @@ spriteCalc: !zone
|
||||
inx
|
||||
+ rts
|
||||
|
||||
; Code for debugging sprite math
|
||||
!if DEBUG {
|
||||
.debug1 +prStr : !text "bSgnSinT=",0
|
||||
+prByte bSgnSinT
|
||||
+prStr : !text "wLogSinT=",0
|
||||
+prWord wLogSinT
|
||||
+prStr : !text "bSgnCosT=",0
|
||||
+prByte bSgnCosT
|
||||
+prStr : !text "wLogCosT=",0
|
||||
+prWord wLogCosT
|
||||
+crout
|
||||
rts
|
||||
.debug2 +prStr : !text "bSgnDx=",0
|
||||
+prByte bSgnDx
|
||||
+prStr : !text "wLogDx=",0
|
||||
+prWord wLogDx
|
||||
+prStr : !text "bSgnDy=",0
|
||||
+prByte bSgnDy
|
||||
+prStr : !text "wLogDy=",0
|
||||
+prWord wLogDy
|
||||
+crout
|
||||
rts
|
||||
.debug3 +prStr : !text "wRx=",0
|
||||
+prWord wRx
|
||||
+crout
|
||||
rts
|
||||
.debug4 +prStr : !text "wRy=",0
|
||||
+prWord wRy
|
||||
+prStr : !text "wLogSqRx=",0
|
||||
+prWord wLogSqRx
|
||||
+prStr : !text "wLogSqRy=",0
|
||||
+prWord wLogSqRy
|
||||
+prStr : !text "wSqDist=",0
|
||||
+prWord wSqDist
|
||||
+prStr : !text "wLogSize=",0
|
||||
+prWord wLogSize
|
||||
+prStr : !text "wSize=",0
|
||||
+prWord wSize
|
||||
+prStr : !text "wSpriteTop=",0
|
||||
+prWord wSpriteTop
|
||||
+crout
|
||||
rts
|
||||
.debug5 +prStr : !text "wX=",0
|
||||
+prX
|
||||
+prA
|
||||
+crout
|
||||
rts
|
||||
.debug6 +prStr : !text "bStartTx=",0
|
||||
+prByte bStartTx
|
||||
+prStr : !text "wTxColBump=",0
|
||||
+prWord wTxColBump
|
||||
+prStr : !text "depth=",0
|
||||
+prByte depth
|
||||
rts
|
||||
}
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user