GSCats/crosshair.s

115 lines
1.9 KiB
ArmAsm
Raw Normal View History

2023-06-22 03:07:30 +00:00
;
; crosshair
; Code and data structures related to the aiming crosshair
;
; Created by Quinn Dunki on 2/13/21
;
crosshairGameObject:
.word 100 ; X pos in pixels (from right terrain edge)
.word 100 ; Y pos in pixels (from bottom terrain edge)
.word 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ; Saved background 128 bytes
.word 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.word 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.word 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; updateCrosshair
;
; Y = Player index to update for
2023-06-22 03:07:30 +00:00
; Trashes SCRATCHL, PARAML0, PARAML1
;
updateCrosshair:
SAVE_AXY
2023-06-22 03:07:30 +00:00
PLAYERPTR_Y
; Calculate X offset
lda playerData+PD_ANGLE,y
asl
tax
lda pixelCircle45X,x
bmi updateCrosshairNegX
; Compute screenspace X
sta SCRATCHL
clc
lda playerData+GO_POSX,y
2023-06-22 03:07:30 +00:00
adc SCRATCHL
sta crosshairGameObject+GO_POSX
bra updateCrosshairCalcY
updateCrosshairNegX:
eor #$FFFF
inc
; Compute screenspace X
sta SCRATCHL
sec
lda playerData+GO_POSX,y
2023-06-22 03:07:30 +00:00
sbc SCRATCHL
sta crosshairGameObject+GO_POSX
updateCrosshairCalcY:
; Calculate Y offset
lda playerData+PD_ANGLE,y
asl
tax
lda pixelCircle45Y,x
sta SCRATCHL
; Compute screenspace Y
clc
lda playerData+GO_POSY,y
2023-06-22 03:07:30 +00:00
adc SCRATCHL
sta crosshairGameObject+GO_POSY
updateCrosshairDone:
RESTORE_AXY
2023-06-22 03:07:30 +00:00
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; renderCrosshair
;
; Y = Player index to render for
; Trashes Y,PARAML0,SCRATCHL
2023-06-22 03:07:30 +00:00
;
renderCrosshair:
pha
PLAYERPTR_Y
2023-06-22 03:07:30 +00:00
lda #crosshairGameObject
sta PARAML0
lda playerData+PD_POWER,y ; Choose reticle size for power level
sta SCRATCHL
lda #14
clc
adc SCRATCHL
2023-06-22 03:07:30 +00:00
jsr renderGameObject
renderCrosshairDone:
pla
2023-06-22 03:07:30 +00:00
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; unrenderCrosshair
;
; Trashes PARAML0
2023-06-22 03:07:30 +00:00
;
unrenderCrosshair:
pha
lda #crosshairGameObject
sta PARAML0
jsr unrenderGameObject
unrenderCrosshairDone:
pla
rts