mirror of
https://github.com/blondie7575/GSCats.git
synced 2025-01-10 10:29:25 +00:00
Added shot power & fixed point multiply
This commit is contained in:
parent
dec9f3e2c8
commit
4525010273
BIN
gscats.2mg
BIN
gscats.2mg
Binary file not shown.
6
player.s
6
player.s
@ -13,7 +13,7 @@ playerData:
|
||||
.word 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ; Saved background
|
||||
|
||||
.word 45 ; Angle in degrees from +X
|
||||
.word 50 ; Power
|
||||
.word 2 ; Power
|
||||
.word 100 ; Anger
|
||||
.byte 8,"SPROCKET " ; Name
|
||||
.word 0,0,0,0,0,0 ;Padding
|
||||
@ -23,8 +23,8 @@ playerData:
|
||||
.word 0 ; 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
|
||||
|
||||
.word 45 ; Angle in degrees from +X
|
||||
.word 50 ; Power
|
||||
.word 135 ; Angle in degrees from +X
|
||||
.word 3 ; Power
|
||||
.word 100 ; Anger
|
||||
.byte 8,"TINKER " ; Name
|
||||
.word 0,0,0,0,0,0 ;Padding
|
||||
|
24
projectile.s
24
projectile.s
@ -90,16 +90,36 @@ fireProjectile:
|
||||
asl
|
||||
sta projectileData+JD_PRECISEY,y
|
||||
|
||||
lda projectileParams+6 ; Convert power to 8.8
|
||||
asl
|
||||
asl
|
||||
asl
|
||||
asl
|
||||
asl
|
||||
asl
|
||||
asl
|
||||
asl
|
||||
sta projectileParams+6
|
||||
|
||||
lda projectileParams+4 ; Convert angle to vector
|
||||
asl
|
||||
tax
|
||||
lda angleToVectorX,x ; Velocity X
|
||||
lda angleToVectorX,x ; Velocity X (unit vector)
|
||||
|
||||
sta PARAML1
|
||||
lda projectileParams+6 ; Scale by power
|
||||
sta PARAML0
|
||||
jsr mult88
|
||||
sta projectileData+JD_VX,y
|
||||
|
||||
lda projectileParams+4 ; Convert angle to vector
|
||||
asl
|
||||
tax
|
||||
lda angleToVectorY,x ; Velocity Y
|
||||
lda angleToVectorY,x ; Velocity Y (unit vector)
|
||||
sta PARAML1
|
||||
lda projectileParams+6 ; Scale by power
|
||||
sta PARAML0
|
||||
jsr mult88
|
||||
sta projectileData+JD_VY,y
|
||||
|
||||
RESTORE_AXY
|
||||
|
58
utility.s
58
utility.s
@ -61,6 +61,8 @@ intToStringSkipSingle:
|
||||
sta intToStringResult,y
|
||||
iny
|
||||
inx
|
||||
cpx #3
|
||||
beq intToStringFinish ; Single digit number so we're done
|
||||
|
||||
intToStringFullDigitsLoop:
|
||||
; Remaining bytes all contain two digits
|
||||
@ -83,6 +85,7 @@ intToStringFullDigitsLoop:
|
||||
cpx #3
|
||||
bne intToStringFullDigitsLoop
|
||||
|
||||
intToStringFinish:
|
||||
; Store final length and we're done
|
||||
dey
|
||||
sty intToStringResult
|
||||
@ -94,3 +97,58 @@ intToStringDone:
|
||||
|
||||
intToStringBCD: .byte 0,0,0
|
||||
intToStringResult: .byte 0,0,0,0,0,0
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; mult16
|
||||
;
|
||||
; PARAML0 = Operand 1 (16 bits)
|
||||
; PARAML1 = Operand 2 (16 bits)
|
||||
; A => Op1 * Op2 (16 bits)
|
||||
; Algorithm from https://apple2.gs/downloads/Programmanual.pdf
|
||||
; Trashes X
|
||||
;
|
||||
mult16:
|
||||
lda #0 ; Initialize result
|
||||
|
||||
mult16L1:
|
||||
ldx PARAML0 ; Get operand 1
|
||||
beq mult16Done ; If operand is zero, we're done
|
||||
lsr PARAML0 ; Get low bit
|
||||
bcc mult16L2 ; If clear, no additions to previous products
|
||||
clc ; Otherwise add oeprand 2 to partial result
|
||||
adc PARAML1
|
||||
|
||||
mult16L2:
|
||||
asl PARAML1 ; Now shift operand 2 left for possible add next time
|
||||
bra mult16L1
|
||||
|
||||
mult16Done:
|
||||
rts
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; mult88
|
||||
;
|
||||
; PARAML0 = Operand 1 (8.8 fixed point)
|
||||
; PARAML1 = Operand 2 (8.8 fixed point)
|
||||
; A => Op1 * Op2 (8.8 fixed point)
|
||||
; Substantial precision loss occurs here, but it's usually good enough
|
||||
;
|
||||
mult88:
|
||||
lda PARAML0 ; Convert operands to 12.4
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
sta PARAML0
|
||||
|
||||
lda PARAML1
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
sta PARAML1
|
||||
|
||||
jsr mult16 ; Result is 8.8
|
||||
rts
|
||||
|
Loading…
x
Reference in New Issue
Block a user