cleanup sprite functions and macros

This commit is contained in:
scawful
2024-07-07 11:00:28 -04:00
parent 9e739c8891
commit 1f2bb46559
2 changed files with 226 additions and 222 deletions

View File

@@ -307,181 +307,6 @@ Sprite_Damage_Flash:
; =========================================================
Intro_Dungeon_Main:
{
LDA $0E20 : CMP.b #$92 : BNE .not_sprite_body_boss
LDA $0E30 : BEQ .not_sprite_body_boss
LDA $1C : AND.b #$FE : STA $1C ;turn off BG2 (Body)
; free ram used to check if the sprite ran this frame, if 0, it didn't run
LDA.b SpriteRanCheck : BEQ .didNotRun
LDA $1C : ORA.b #$01 : STA $1C ;turn on BG2 (Body)
.didNotRun
STZ.b SpriteRanCheck
.not_sprite_body_boss
REP #$21 : LDA.w DungeonMainCheck : BNE .intro ;<- load that free ram you are using if it's not zero then we're doing intro thing
LDA $E2 : RTL ;return to normal intro
.intro
PLA ;Pop 2byte from stack
;skip all the BGs codes
SEP #$20
PLA ;Pop 1 byte from the stack
JSL $07F0AC ; $3F0AC IN ROM. Handle the sprites of pushed blocks.
JSL $068328 ;Sprite_Main
JSL $0DA18E ;PlayerOam_Main
JSL $0DDB75 ;HUD.RefillLogicLong
JML $0AFD0C ;FloorIndicator ; $57D0C IN ROM. Handles HUD floor indicator
}
; =========================================================
;uses $00 as the Y coordinate and $02 as the X
MoveCamera:
{
REP #$20
;move the camera up or down until a point is reached
LDA $E8 : CMP $00 : BEQ .dontMoveY ;if equals that point, dont move y
BCS .CameraBelowPointY
;CameraAbovePoint
ADC.w #$0001 : STA $E8 : STA $E6 : STA $0122 : STA $0124 ;move the camera down by 1
BRA .dontMoveY
.CameraBelowPointY
SEC : SBC.w #$0001 : STA $E8 : STA $E6 : STA $0122 : STA $0124 ;move the camera up by 1
.dontMoveY
;move the camera right or left until a point is reached
LDA $E2 : CMP.w $02 : BEQ .dontMoveX ;if equals that point, dont move x
BCS .CameraBelowPointX ;left
;CameraAbovePoint ;right
ADC.w #$0001 : STA $E2 : STA $E0 : STA $011E : STA $0120 ;move the camera right by 1
BRA .dontMoveX
.CameraBelowPointX
SEC : SBC.w #$0001 : STA $E2 : STA $E0 : STA $011E : STA $0120 ;move the camera left by 1
.dontMoveX
;if link is outside of a certain range of the camera, make him dissapear so he doesnt appear on the other side
LDA $20 : SEC : SBC $E8 : CMP.w #$00E0 : BCS .MakeLinkInvisible
LDA $22 : SEC : SBC $E2 : CMP.w #$00E0 : BCS .MakeLinkInvisible
SEP #$20
LDA.b #$00 : STA $4B ;make link visible
RTS
.MakeLinkInvisible
SEP #$20
LDA.b #$0C : STA $4B ;make link invisible
RTS
}
; =========================================================
MovieEffectTimer = $7EF500 ;0x01
;these need to be the same as the next set
;used to do the HDMA
MovieEffectArray = $F900 ;0x0F
MovieEffectBank = $7E
;used to set the actual values
MovieEffect0 = $7EF900 ;0x01
MovieEffect1 = $7EF901 ;0x01
MovieEffect2 = $7EF902 ;0x01
MovieEffect3 = $7EF903 ;0x01
MovieEffect4 = $7EF904 ;0x01
MovieEffect5 = $7EF905 ;0x01
MovieEffect6 = $7EF906 ;0x01
MovieEffect7 = $7EF907 ;0x01
MovieEffect8 = $7EF908 ;0x01
MovieEffect9 = $7EF909 ;0x01
MovieEffectA = $7EF90A ;0x01
MovieEffectB = $7EF90B ;0x01
MovieEffectC = $7EF90C ;0x01
MovieEffectD = $7EF90D ;0x01
MovieEffectE = $7EF90E ;0x01
SetupMovieEffect:
{
;setup HDMA RAM
;Top Dark Row
LDA.b #$01 : STA.l MovieEffect0
LDA.b #$00 : STA.l MovieEffect1
;Top Dark Row Buffer
LDA.b #$1F : STA.l MovieEffect2
LDA.b #$0F : STA.l MovieEffect3
;Middle Unaffected Area
LDA.b #$50 : STA.l MovieEffect4
LDA.b #$0F : STA.l MovieEffect5
LDA.b #$50 : STA.l MovieEffect6
LDA.b #$0F : STA.l MovieEffect7
;Bottom Drak Row Buffer
LDA.b #$1F : STA.l MovieEffect8
LDA.b #$0F : STA.l MovieEffect9
;Bottom Dark Row
LDA.b #$01 : STA.l MovieEffectA
LDA.b #$00 : STA.l MovieEffectB
;Below screen
LDA.b #$20 : STA.l MovieEffectC
LDA.b #$0F : STA.l MovieEffectD
;End
LDA.b #$00 : STA.l MovieEffectE
;start timer
LDA.b #$01 : STA.l MovieEffectTimer
RTS
}
; =========================================================
MovieEffect:
{
REP #$20
LDX #$00 : STX $4350 ;Set the transfer mode into 1 byte to 1 register
LDX #$00 : STX $4351 ;Set register to 00 ($21 00)
LDA.w #MovieEffectArray : STA $4352 ;set address of the hdma table
LDX.b #MovieEffectBank : STX $4354 ;set the bank of HDMA table
SEP #$20
LDA.b #$20 : STA $9B ;Do the HDMA instead of $420C
; LDA $9B : ORA #$20 : STA $9B
; LDA.b #$02 : STA $13 ;controls the brightness of the screen
RTS
HDMATable: ;values cannot go above 80 or it will read as continuous mode
db $20, $00 ;for $20 line set screen brightness to 0
db $50, $0F ;for $A0 line set screen brightness to 15 full
db $50, $0F ;for $A0 line set screen brightness to 15 full
db $3F, $00 ;for $20 line set screen brightness to 0
db $00 ;end the HDMA
}
Link_CheckNewY_ButtonPress_Long:
{
BIT.b $3A : BVS .fail
@@ -495,6 +320,8 @@ Link_CheckNewY_ButtonPress_Long:
RTL
}
; =========================================================
Link_SetupHitBox:
{
LDA.b #$08 : STA $02 : STA $03
@@ -872,3 +699,180 @@ GetDistance8bit_Long:
CLC : ADC $00 : STA $00 ; distance total X, Y (ABS)
RTL
}
; =========================================================
Intro_Dungeon_Main:
{
LDA $0E20 : CMP.b #$92 : BNE .not_sprite_body_boss
LDA $0E30 : BEQ .not_sprite_body_boss
LDA $1C : AND.b #$FE : STA $1C ;turn off BG2 (Body)
; free ram used to check if the sprite ran this frame, if 0, it didn't run
LDA.b SpriteRanCheck : BEQ .didNotRun
LDA $1C : ORA.b #$01 : STA $1C ;turn on BG2 (Body)
.didNotRun
STZ.b SpriteRanCheck
.not_sprite_body_boss
REP #$21 : LDA.w DungeonMainCheck : BNE .intro ;<- load that free ram you are using if it's not zero then we're doing intro thing
LDA $E2 : RTL ;return to normal intro
.intro
PLA ;Pop 2byte from stack
;skip all the BGs codes
SEP #$20
PLA ;Pop 1 byte from the stack
JSL $07F0AC ; $3F0AC IN ROM. Handle the sprites of pushed blocks.
JSL $068328 ;Sprite_Main
JSL $0DA18E ;PlayerOam_Main
JSL $0DDB75 ;HUD.RefillLogicLong
JML $0AFD0C ;FloorIndicator ; $57D0C IN ROM. Handles HUD floor indicator
}
; =========================================================
;uses $00 as the Y coordinate and $02 as the X
MoveCamera:
{
REP #$20
;move the camera up or down until a point is reached
LDA $E8 : CMP $00 : BEQ .dontMoveY ;if equals that point, dont move y
BCS .CameraBelowPointY
;CameraAbovePoint
ADC.w #$0001 : STA $E8 : STA $E6 : STA $0122 : STA $0124 ;move the camera down by 1
BRA .dontMoveY
.CameraBelowPointY
SEC : SBC.w #$0001 : STA $E8 : STA $E6 : STA $0122 : STA $0124 ;move the camera up by 1
.dontMoveY
;move the camera right or left until a point is reached
LDA $E2 : CMP.w $02 : BEQ .dontMoveX ;if equals that point, dont move x
BCS .CameraBelowPointX ;left
;CameraAbovePoint ;right
ADC.w #$0001 : STA $E2 : STA $E0 : STA $011E : STA $0120 ;move the camera right by 1
BRA .dontMoveX
.CameraBelowPointX
SEC : SBC.w #$0001 : STA $E2 : STA $E0 : STA $011E : STA $0120 ;move the camera left by 1
.dontMoveX
;if link is outside of a certain range of the camera, make him dissapear so he doesnt appear on the other side
LDA $20 : SEC : SBC $E8 : CMP.w #$00E0 : BCS .MakeLinkInvisible
LDA $22 : SEC : SBC $E2 : CMP.w #$00E0 : BCS .MakeLinkInvisible
SEP #$20
LDA.b #$00 : STA $4B ;make link visible
RTS
.MakeLinkInvisible
SEP #$20
LDA.b #$0C : STA $4B ;make link invisible
RTS
}
; =========================================================
MovieEffectTimer = $7EF500 ;0x01
;these need to be the same as the next set
;used to do the HDMA
MovieEffectArray = $F900 ;0x0F
MovieEffectBank = $7E
;used to set the actual values
MovieEffect0 = $7EF900 ;0x01
MovieEffect1 = $7EF901 ;0x01
MovieEffect2 = $7EF902 ;0x01
MovieEffect3 = $7EF903 ;0x01
MovieEffect4 = $7EF904 ;0x01
MovieEffect5 = $7EF905 ;0x01
MovieEffect6 = $7EF906 ;0x01
MovieEffect7 = $7EF907 ;0x01
MovieEffect8 = $7EF908 ;0x01
MovieEffect9 = $7EF909 ;0x01
MovieEffectA = $7EF90A ;0x01
MovieEffectB = $7EF90B ;0x01
MovieEffectC = $7EF90C ;0x01
MovieEffectD = $7EF90D ;0x01
MovieEffectE = $7EF90E ;0x01
SetupMovieEffect:
{
;setup HDMA RAM
;Top Dark Row
LDA.b #$01 : STA.l MovieEffect0
LDA.b #$00 : STA.l MovieEffect1
;Top Dark Row Buffer
LDA.b #$1F : STA.l MovieEffect2
LDA.b #$0F : STA.l MovieEffect3
;Middle Unaffected Area
LDA.b #$50 : STA.l MovieEffect4
LDA.b #$0F : STA.l MovieEffect5
LDA.b #$50 : STA.l MovieEffect6
LDA.b #$0F : STA.l MovieEffect7
;Bottom Drak Row Buffer
LDA.b #$1F : STA.l MovieEffect8
LDA.b #$0F : STA.l MovieEffect9
;Bottom Dark Row
LDA.b #$01 : STA.l MovieEffectA
LDA.b #$00 : STA.l MovieEffectB
;Below screen
LDA.b #$20 : STA.l MovieEffectC
LDA.b #$0F : STA.l MovieEffectD
;End
LDA.b #$00 : STA.l MovieEffectE
;start timer
LDA.b #$01 : STA.l MovieEffectTimer
RTS
}
; =========================================================
MovieEffect:
{
REP #$20
LDX #$00 : STX $4350 ;Set the transfer mode into 1 byte to 1 register
LDX #$00 : STX $4351 ;Set register to 00 ($21 00)
LDA.w #MovieEffectArray : STA $4352 ;set address of the hdma table
LDX.b #MovieEffectBank : STX $4354 ;set the bank of HDMA table
SEP #$20
LDA.b #$20 : STA $9B ;Do the HDMA instead of $420C
; LDA $9B : ORA #$20 : STA $9B
; LDA.b #$02 : STA $13 ;controls the brightness of the screen
RTS
HDMATable: ;values cannot go above 80 or it will read as continuous mode
db $20, $00 ;for $20 line set screen brightness to 0
db $50, $0F ;for $A0 line set screen brightness to 15 full
db $50, $0F ;for $A0 line set screen brightness to 15 full
db $3F, $00 ;for $20 line set screen brightness to 0
db $00 ;end the HDMA
}