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
|
|
|
|
;
|
2023-06-26 01:43:07 +00:00
|
|
|
; Y = Player index to update for
|
2023-06-22 03:07:30 +00:00
|
|
|
; Trashes SCRATCHL, PARAML0, PARAML1
|
|
|
|
;
|
|
|
|
updateCrosshair:
|
2023-06-26 01:43:07 +00:00
|
|
|
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
|
2023-06-24 22:25:08 +00:00
|
|
|
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
|
2023-06-24 22:25:08 +00:00
|
|
|
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
|
2023-06-24 22:25:08 +00:00
|
|
|
lda playerData+GO_POSY,y
|
2023-06-22 03:07:30 +00:00
|
|
|
adc SCRATCHL
|
|
|
|
sta crosshairGameObject+GO_POSY
|
|
|
|
|
|
|
|
updateCrosshairDone:
|
|
|
|
|
2023-06-26 01:43:07 +00:00
|
|
|
RESTORE_AXY
|
2023-06-22 03:07:30 +00:00
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; renderCrosshair
|
|
|
|
;
|
2023-06-26 01:43:07 +00:00
|
|
|
; Y = Player index to render for
|
|
|
|
; Trashes Y,PARAML0,SCRATCHL
|
2023-06-22 03:07:30 +00:00
|
|
|
;
|
|
|
|
renderCrosshair:
|
2023-06-24 22:25:08 +00:00
|
|
|
pha
|
2023-06-26 01:43:07 +00:00
|
|
|
PLAYERPTR_Y
|
|
|
|
|
2023-06-22 03:07:30 +00:00
|
|
|
lda #crosshairGameObject
|
|
|
|
sta PARAML0
|
2023-06-26 01:43:07 +00:00
|
|
|
|
|
|
|
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:
|
2023-06-24 22:25:08 +00:00
|
|
|
pla
|
2023-06-22 03:07:30 +00:00
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; unrenderCrosshair
|
|
|
|
;
|
2023-06-26 01:43:07 +00:00
|
|
|
; Trashes PARAML0
|
2023-06-22 03:07:30 +00:00
|
|
|
;
|
|
|
|
unrenderCrosshair:
|
|
|
|
pha
|
|
|
|
|
|
|
|
lda #crosshairGameObject
|
|
|
|
sta PARAML0
|
|
|
|
jsr unrenderGameObject
|
|
|
|
|
|
|
|
unrenderCrosshairDone:
|
|
|
|
pla
|
|
|
|
rts
|