cleanup sprite_new_functions, label sprite ram values

This commit is contained in:
scawful
2024-06-27 20:17:27 -04:00
parent c3017570bb
commit 136d108358

View File

@@ -4,16 +4,14 @@
Sprite_CheckActive: Sprite_CheckActive:
{ {
; Deactivates the sprite in certain situations ; Deactivates the sprite in certain situations
LDA $0DD0, X : CMP.b #$09 : BNE .inactive LDA.w SprState, X : CMP.b #$09 : BNE .inactive
LDA $0FC1 : BNE .inactive LDA.w SprFreeze : BNE .inactive
LDA $11 : BNE .inactive LDA $11 : BNE .inactive
LDA $0CAA, X : BMI .active LDA.w SprDefl, X : BMI .active
LDA $0F00, X : BEQ .active LDA.w SprPause, X : BEQ .active
.inactive .inactive
CLC CLC
RTL RTL
.active .active
SEC SEC
RTL RTL
@@ -26,7 +24,7 @@ Sprite_MoveHoriz:
{ {
LDA.w SprXSpeed, X : BEQ .no_velocity LDA.w SprXSpeed, X : BEQ .no_velocity
ASL : ASL : ASL : ASL ASL : ASL : ASL : ASL
CLC : ADC.w $0D70, X : STA.w $0D70, X CLC : ADC.w SprXRound, X : STA.w SprXRound, X
LDY.b #$00 LDY.b #$00
LDA.w SprXSpeed, X LDA.w SprXSpeed, X
@@ -36,8 +34,8 @@ Sprite_MoveHoriz:
ORA.b #$F0 ORA.b #$F0
DEY DEY
++ ADC.w $0D10, X : STA.w $0D10, X ++ ADC.w SprX, X : STA.w SprX, X
TYA : ADC.w $0D30, X : STA.w $0D30, X TYA : ADC.w SprXH, X : STA.w SprXH, X
.no_velocity .no_velocity
RTL RTL
@@ -69,8 +67,8 @@ Sprite_MoveVert:
ORA.b #$F0 ORA.b #$F0
DEY DEY
++ ADC.w $0D00,X : STA.w $0D00,X ++ ADC.w SprY,X : STA.w SprY,X
TYA : ADC.w $0D20,X : STA.w $0D20,X TYA : ADC.w SprYH,X : STA.w SprYH,X
.no_velocity .no_velocity
RTL RTL
@@ -82,51 +80,39 @@ Sprite_MoveVert:
Sprite_MoveZ: Sprite_MoveZ:
Sprite_MoveAltitude: Sprite_MoveAltitude:
{ {
LDA.w $0F80, X : ASL : ASL : ASL : ASL LDA.w SprTimerF, X : ASL : ASL : ASL : ASL
CLC : ADC.w $0F90, X : STA.w $0F90, X CLC : ADC.w $0F90, X : STA.w $0F90, X
LDA.w $0F80, X : PHP LDA.w SprTimerF, X : PHP
LSR : LSR : LSR : LSR LSR : LSR : LSR : LSR
PLP : BPL .positive PLP : BPL .positive
ORA.b #$F0 ORA.b #$F0
.positive .positive
ADC.w $0F70,X : STA.w $0F70,X ADC.w SprHeight,X : STA.w SprHeight,X
RTL RTL
} }
; ========================================================= ; =========================================================
; make the sprite bounce toward player (like vitreous) ; make the sprite bounce toward player
; Movement, Collision are handled by this function (height:20 = vitreous) ; movement, collision are handled by this function
; $09 = speed, $08 = max height ; $09 = speed, $08 = max height ( e.g. height:20 = vitreous)
Sprite_BounceTowardPlayer: Sprite_BounceTowardPlayer:
{ {
JSL Sprite_MoveAltitude JSL Sprite_MoveAltitude
DEC.w SprTimerF, X : DEC.w SprTimerF, X
DEC.w $0F80,X : DEC.w $0F80,X LDA.w SprHeight, X : BPL .aloft
STZ.w SprHeight, X
LDA.w $0F70, X : BPL .aloft LDA.b $08 : STA.w SprTimerF, X ; set height from 08
LDA.b $09 : JSL Sprite_ApplySpeedTowardsPlayer
STZ.w $0F70, X ; LDA.b #$21 : JSL Sound_SetSfx2PanLong
.aloft
LDA.b $08 : STA.w $0F80, X ; set height from 08 LDA.w SprHeight, X : BEQ .dontmove
JSL Sprite_Move
;LDA.b $09 .dontmove
LDA.b #$20
JSL Sprite_ApplySpeedTowardsPlayer
; LDA.b #$21 : JSL Sound_SetSfx2PanLong
.aloft
LDA.w $0F70, X : BEQ .dontmove
JSL Sprite_Move
.dontmove
RTL RTL
} }
@@ -168,7 +154,7 @@ Sprite_BounceFromTileCollision:
LDA.w SprXSpeed, X : EOR.b #$FF : INC : STA.w SprXSpeed, X LDA.w SprXSpeed, X : EOR.b #$FF : INC : STA.w SprXSpeed, X
INC.w $0ED0, X INC.w $0ED0, X
++ LDA.w $0E70, X : AND.b #$0C : BEQ ++ ++ LDA.w SprCollision, X : AND.b #$0C : BEQ ++
LDA.w SprYSpeed, X : EOR.b #$FF : INC : STA.w SprYSpeed, X LDA.w SprYSpeed, X : EOR.b #$FF : INC : STA.w SprYSpeed, X
INC.w $0ED0, X INC.w $0ED0, X
@@ -178,14 +164,14 @@ Sprite_BounceFromTileCollision:
; ========================================================= ; =========================================================
Sprite_BounceOffWall: Sprite_BounceOffWall:
LDA.w $0E70,X LDA.w SprCollision, X
AND.b #$03 AND.b #$03
BEQ .no_horizontal_collision BEQ .no_horizontal_collision
JSR Sprite_InvertSpeed_X JSR Sprite_InvertSpeed_X
.no_horizontal_collision .no_horizontal_collision
LDA.w $0E70,X LDA.w SprCollision, X
AND.b #$0C AND.b #$0C
BEQ .no_vertical_collision BEQ .no_vertical_collision
@@ -202,20 +188,20 @@ Sprite_InvertSpeed_XY:
; ========================================================= ; =========================================================
Sprite_InvertSpeed_X: Sprite_InvertSpeed_X:
LDA.w $0D50,X LDA.w SprXSpeed, X
EOR.b #$FF EOR.b #$FF
INC A INC A
STA.w $0D50,X STA.w SprXSpeed, X
RTS RTS
; ========================================================= ; =========================================================
Sprite_InvertSpeed_Y: Sprite_InvertSpeed_Y:
LDA.w $0D40,X LDA.w SprYSpeed,X
EOR.b #$FF EOR.b #$FF
INC A INC A
STA.w $0D40,X STA.w SprYSpeed,X
RTS RTS
@@ -223,76 +209,62 @@ Sprite_InvertSpeed_Y:
Sprite_SelectNewDirection: Sprite_SelectNewDirection:
{ {
JSL GetRandomInt JSL GetRandomInt : AND.b #$07 : TAY
AND.b #$07 LDA.w .speed_x, Y : STA.w SprXSpeed, X
TAY LDA.w .speed_y, Y : STA.w SprYSpeed, X
LDA.w .timers, Y : STA.w SprTimerA, X
LDA.w .speed_x,Y
STA.w $0D50,X
LDA.w .speed_y,Y
STA.w $0D40,X
LDA.w .timers,Y
STA.w $0DF0,X
RTL RTL
.speed_x .speed_x
db 8, 6, -6, 8, -6, 6, 0, 0 db 8, 6, -6, 8, -6, 6, 0, 0
.speed_y .speed_y
db 0, 6, 6, 0, -6, -6, 0, 0 db 0, 6, 6, 0, -6, -6, 0, 0
.timers .timers
db 48, 48, 48, 48, 48, 48, 64, 64 db 48, 48, 48, 48, 48, 48, 64, 64
} }
; ========================================================= ; =========================================================
; Parameters: Y index contains direction to drag player
; 0 = up, 1 = down, 2 = left, 3 = right
DragYL = $0B7C DragYL = $0B7C
DragYH = $0B7D DragYH = $0B7D
DragXL = $0B7E
DragXH = $0B7F
; Parameters: Y index contains direction to drag player
DragPlayer: DragPlayer:
{ {
LDA.w .drag_x_low, Y : CLC : ADC.w DragYL : STA.w DragYL LDA.w .drag_x_low, Y : CLC : ADC.w DragYL : STA.w DragYL
LDA.w .drag_x_high, Y : ADC.w DragYH : STA DragYH LDA.w .drag_x_high, Y : ADC.w DragYH : STA DragYH
LDA.w .drag_y_low, Y : CLC : ADC.w $0B7E : STA.w $0B7E LDA.w .drag_y_low, Y : CLC : ADC.w DragXL : STA.w DragXL
LDA.w .drag_y_high, Y : ADC.w $0B7F : STA.w $0B7F LDA.w .drag_y_high, Y : ADC.w DragXH : STA.w DragXH
.SomariaPlatform_DragLink .SomariaPlatform_DragLink
REP #$20 REP #$20
LDA $0FD8 : SEC : SBC.w #$0002
CMP $22 : BEQ .x_done : BPL .x_too_low
DEC $0B7C
BRA .x_done
.x_too_low LDA SprCachedX : SEC : SBC.w #$0002
CMP $22 : BEQ .x_done : BPL .x_too_low
INC $0B7C DEC.w DragYL
BRA .x_done
.x_too_low
INC.w DragYL
.x_done .x_done
; Changing the modifier adjusts links position in the cart ; Changing the modifier adjusts links position in the cart
LDA $0FDA : SEC : SBC.w #$0008 LDA SprCachedY : SEC : SBC.w #$0008
CMP $20 : BEQ .y_done : BPL .y_too_low CMP $20 : BEQ .y_done : BPL .y_too_low
DEC.w DragXL
DEC $0B7E BRA .y_done
.y_too_low
BRA .y_done INC.w DragXL
.y_too_low
INC $0B7E
.y_done .y_done
SEP #$30 SEP #$30
RTL
RTL
.drag_x_high .drag_x_high
db 0, 0, -1, 0 db 0, 0, -1, 0
@@ -353,6 +325,8 @@ Intro_Dungeon_Main:
JML $0AFD0C ;FloorIndicator ; $57D0C IN ROM. Handles HUD floor indicator JML $0AFD0C ;FloorIndicator ; $57D0C IN ROM. Handles HUD floor indicator
} }
; =========================================================
;uses $00 as the Y coordinate and $02 as the X ;uses $00 as the Y coordinate and $02 as the X
MoveCamera: MoveCamera:
{ {
@@ -400,6 +374,8 @@ MoveCamera:
RTS RTS
} }
; =========================================================
MovieEffectTimer = $7EF500 ;0x01 MovieEffectTimer = $7EF500 ;0x01
;these need to be the same as the next set ;these need to be the same as the next set
@@ -516,33 +492,32 @@ Link_SetupHitBox:
RTL RTL
} }
; =========================================================
Sprite_SetupHitBox: Sprite_SetupHitBox:
{ {
PHB : PHK : PLB PHB : PHK : PLB
LDA.w $0F70, X : BMI .too_high LDA.w SprHeight, X : BMI .too_high
PHY
PHY
LDA.w $0F60, X : AND.b #$1F : TAY LDA.w $0F60, X : AND.b #$1F : TAY
LDA.w $0D10, X : CLC : ADC.w .offset_x_low, Y : STA.b $04 LDA.w SprX, X : CLC : ADC.w .offset_x_low, Y : STA.b $04
LDA.w $0D30, X : ADC.w .offset_x_high, Y : STA.b $0A LDA.w SprXH, X : ADC.w .offset_x_high, Y : STA.b $0A
LDA.w $0D00, X : CLC : ADC.w .offset_y_low, Y LDA.w SprY, X : CLC : ADC.w .offset_y_low, Y
PHP PHP
SEC : SBC.w $0F70, X : STA.b $05 SEC : SBC.w SprHeight, X : STA.b $05
LDA.w $0D20, X : SBC.b #$00 LDA.w SprYH, X : SBC.b #$00
PLP PLP
ADC.w .offset_y_high, Y : STA.b $0B ADC.w .offset_y_high, Y : STA.b $0B
LDA.w .width, Y : STA.b $06 LDA.w .width, Y : STA.b $06
LDA.w .height, Y : STA.b $07 LDA.w .height, Y : STA.b $07
PLY PLY
PLB PLB
RTL RTL
.too_high .too_high
LDA.b #$80 : STA.b $0A LDA.b #$80 : STA.b $0A