cleanup DarkLink

This commit is contained in:
scawful
2024-06-06 21:03:12 -04:00
parent aa6a39a7da
commit 38bb68ee72

View File

@@ -1,6 +1,6 @@
;==============================================================================
; Sprite Properties
;==============================================================================
; =========================================================
; Dark Link Boss
!SPRID = $C1 ; The sprite ID you are overwriting (HEX)
!NbrTiles = 4 ; Number of tiles used in a frame
!Harmless = 00 ; 00 = Sprite is Harmful, 01 = Sprite is Harmless
@@ -30,12 +30,8 @@
!Boss = 00 ; 00 = normal sprite, 01 = sprite is a boss
%Set_Sprite_Properties(Sprite_DarkLink_Prep, Sprite_DarkLink_Long);
;==============================================================================
; Sprite Long Hook for that sprite
; -----------------------------------------------------------------------------
; This code can be left unchanged
; handle the draw code and if the sprite is active and should move or not
;==============================================================================
; =========================================================
Sprite_DarkLink_Long:
{
PHB : PHK : PLB
@@ -91,15 +87,10 @@ Sprite_DarkLink_Long:
.SpriteIsNotActive
PLB ; Get back the databank we stored previously
RTL ; Go back to original code
}
;==============================================================================
; Sprite initialization
; -----------------------------------------------------------------------------
; this code only get called once perfect to initialize sprites substate or timers
; this code as soon as the room transitions/ overworld transition occurs
;==============================================================================
; =========================================================
Sprite_DarkLink_Prep:
{
PHB : PHK : PLB
@@ -135,12 +126,8 @@ Sprite_DarkLink_Prep:
dlinkPal:
dw #$7FFF, #$14A5, #$2108, #$294A, #$1CF5, #$7E4E, #$3DEF, #$6FF4
;==================================================================================================
; Sprite Main routines code
; --------------------------------------------------------------------------------------------------
; This is the main local code of your sprite
; This contains all the Subroutines of your sprites you can add more below
;==================================================================================================
; =========================================================
Sprite_DarkLink_Main:
{
LDA.w SprAction, X; Load the SprAction
@@ -560,6 +547,7 @@ Sprite_DarkLink_Main:
}
SwordSlash:
{
JSL Sprite_CheckDamageFromPlayer : BCC .nodamage
LDA.w SprTimerA, X : BNE .alreadytakingdamage
LDA.w $02B2 : CMP #$03 : BNE .notmoredamage
@@ -643,11 +631,11 @@ Sprite_DarkLink_Main:
%GotoAction(00)
+
RTS
}
JumpBack:
{
JSL Sprite_MoveXyz
DEC.w $0F80,X : DEC.w $0F80,X
@@ -663,8 +651,10 @@ Sprite_DarkLink_Main:
RTS
}
JumpAttackUp:
{
JSL Sprite_MoveXyz
LDA.w $0F80,X : BEQ +
DEC.w $0F80,X
@@ -712,17 +702,13 @@ Sprite_DarkLink_Main:
.toofar
SEP #$20
RTS
}
JumpAttackDown:
{
LDA.w SprTimerA, X : BNE .wait
JSL Sprite_MoveXyz
JSL Sprite_CheckDamageToPlayer
@@ -746,8 +732,10 @@ Sprite_DarkLink_Main:
.wait
RTS
}
JumpAttackPrep:
{
LDA #35 : STA.w SprFrame, X
LDA.w SprTimerA, X : BNE +
@@ -755,8 +743,10 @@ Sprite_DarkLink_Main:
+
RTS
}
JumpAttackShake:
{
PHX
JSL Sprite_CheckDamageToPlayer
@@ -803,10 +793,8 @@ Sprite_DarkLink_Main:
+
RTS
}
CrumbleSpr:
db $0C, $0D, $0E, $0F
@@ -818,7 +806,7 @@ Sprite_DarkLink_Main:
db $28, $28, $D8, $D8
WalkAction:
{
JSL Sprite_CheckDamageFromPlayer : BCC .nodamage
LDA.w SprTimerA, X : BNE .alreadytakingdamage
LDA.w $02B2 : CMP #$03 : BNE .notmoredamage
@@ -866,17 +854,17 @@ Sprite_DarkLink_Main:
JMP Handler_DoWalk
RTS
}
; right
speedTableX:
db 16, -16, 00, 00
speedTableY:
db 00, 00, 16, -16
Damaged:
{
JSL Sprite_MoveXyz
LDA.w SprYSpeed, X : BPL +
@@ -918,8 +906,10 @@ Sprite_DarkLink_Main:
RTS
}
RecoilSword:
{
JSL Sprite_MoveLong
LDA.w SprTimerC, X : BNE +
%SetTimerC(20)
@@ -929,10 +919,10 @@ Sprite_DarkLink_Main:
JSL Sprite_CheckTileCollision
RTS
}
SwordSubtype:
{
LDA.w SprTimerA, X : BNE +
STZ.w SprState, X ; kill the sprite
+
@@ -942,8 +932,10 @@ Sprite_DarkLink_Main:
RTS
}
DyingSpin:
{
STZ.w SprHeight, X
LDA.w SprTimerB, X : BNE ++
@@ -957,8 +949,6 @@ Sprite_DarkLink_Main:
++
LDA.w SprTimerA, X : BNE +
LDA.b #$60 : STA.w SprTimerA, X
LDA.b #$12 : STA.w SprTimerB, X
@@ -966,6 +956,7 @@ Sprite_DarkLink_Main:
%GotoAction(12)
+
RTS
}
dyingframes:
db $00, $02, $01, $03
@@ -1031,11 +1022,9 @@ Sprite_DarkLink_Main:
dlinkPalRed:
dw #$7FFF, #$14A5, #$2108, #$294A, #$1CF5, #$7E4E, #$001D, #$6FF4
}
;==================================================================================================
; Sprite Draw code
; --------------------------------------------------------------------------------------------------
; Draw the tiles on screen with the data provided by the sprite maker editor
;==================================================================================================
; =========================================================
Sprite_DarkLink_Draw:
{
JSL Sprite_PrepOamCoord
@@ -1292,12 +1281,8 @@ Sprite_DarkLink_Draw:
db $02, $02, $02
db $02, $02
; =========================================================
;==================================================================================================
; Sprite Draw Generated Data
; --------------------------------------------------------------------------------------------------
; This is where the generated Data for the sprite go
;==================================================================================================
.start_index
db $00, $02, $04, $06, $08, $0A, $0C, $0E, $10, $12, $14, $16, $18, $1A, $1C, $1E, $20, $22, $24, $26, $28, $2A, $2C, $2E, $30, $32, $34, $36, $38, $3A, $3C, $3E, $40, $42, $44, $45, $48, $4B, $4E, $50, $52, $54, $56, $58, $5A, $5C
.nbr_of_tiles
@@ -1539,14 +1524,12 @@ Sprite_DarkLink_Draw:
db $02, $02
}
; =========================================================
GanonInit:
{
LDA #$C1
JSL Sprite_SpawnDynamically
LDA #$C1
JSL Sprite_SpawnDynamically
LDA #$05 : STA.w SprSubtype, Y
LDA $00 : STA $0D10, Y
LDA $01 : STA.w $0D30, Y
@@ -1556,128 +1539,155 @@ JSL Sprite_SpawnDynamically
LDA.b #$30 : STA.w SprTimerA, Y
LDA #$1E : STA.w $012C
RTL
RTL
}
; =========================================================
Sprite_Ganon_Main:
LDA.w SprAction, X; Load the SprAction
JSL UseImplicitRegIndexedLocalJumpTable; Goto the SprAction we are currently in
dw Wait
dw ShowMessage
dw Fall
dw FellWait
dw FadingAwait
{
LDA.w SprAction, X; Load the SprAction
JSL UseImplicitRegIndexedLocalJumpTable; Goto the SprAction we are currently in
dw Wait
dw ShowMessage
dw Fall
dw FellWait
dw FadingAwait
Wait:
LDA.w SprTimerA, X : BNE .wait
LDA.b #$30 : STA.w SprTimerA, X
%ShowUnconditionalMessage($46)
%GotoAction(1)
.wait
Wait:
LDA.w SprTimerA, X : BNE .wait
LDA.b #$30 : STA.w SprTimerA, X
%ShowUnconditionalMessage($46)
%GotoAction(1)
.wait
RTS
RTS
ShowMessage:
LDA.w SprTimerA, X : BNE .wait
LDA.b #$90 : STA.w SprTimerA, X
%GotoAction(2)
.wait
ShowMessage:
LDA.w SprTimerA, X : BNE .wait
LDA.b #$90 : STA.w SprTimerA, X
%GotoAction(2)
.wait
RTS
RTS
Fall:
LDA.w SprTimerA, X : BNE .wait
LDA.b #$50 : STA.w SprTimerA, X
LDA #$01 : STA.w SprFrame, X
INC.w SprMiscA, X
%GotoAction(3)
.wait
Fall:
LDA.w SprTimerA, X : BNE .wait
LDA.b #$50 : STA.w SprTimerA, X
LDA #$01 : STA.w SprFrame, X
INC.w SprMiscA, X
%GotoAction(3)
.wait
RTS
RTS
FellWait:
LDA.w SprTimerA, X : BNE .wait
LDA.b #$30 : STA.w SprTimerA, X
%GotoAction(4)
.wait
FellWait:
LDA.w SprTimerA, X : BNE .wait
LDA.b #$30 : STA.w SprTimerA, X
%GotoAction(4)
.wait
RTS
RTS
FadingAwait:
LDA.w SprTimerA, X : BNE .wait
STZ.w SprState, X
.wait
FadingAwait:
LDA.w SprTimerA, X : BNE .wait
STZ.w SprState, X
.wait
RTS
RTS
}
; =========================================================
Sprite_Ganon_Draw:
LDA.w SprAction, X : CMP #$04 : BNE +
LDA.w SprTimerA, X : AND #$04 : BEQ +
RTS
{
LDA.w SprAction, X : CMP #$04 : BNE +
LDA.w SprTimerA, X : AND #$04 : BEQ +
RTS
+
JSL Sprite_PrepOamCoord
LDA #$18
JSL OAM_AllocateFromRegionB
+
JSL Sprite_PrepOamCoord
LDA #$18
JSL OAM_AllocateFromRegionB
LDA $0DC0, X : CLC : ADC $0D90, X : TAY;Animation Frame
LDA .start_index, Y : STA $06
LDA $0DC0, X : CLC : ADC $0D90, X : TAY;Animation Frame
LDA .start_index, Y : STA $06
PHX
LDX .nbr_of_tiles, Y ;amount of tiles -1
LDY.b #$00
.nextTile
PHX
LDX .nbr_of_tiles, Y ;amount of tiles -1
LDY.b #$00
.nextTile
PHX ; Save current Tile Index?
PHX ; Save current Tile Index?
TXA : CLC : ADC $06 ; Add Animation Index Offset
TXA : CLC : ADC $06 ; Add Animation Index Offset
PHA ; Keep the value with animation index offset?
PHA ; Keep the value with animation index offset?
ASL A : TAX
ASL A : TAX
REP #$20
REP #$20
LDA $00 : CLC : ADC .x_offsets, X : STA ($90), Y
AND.w #$0100 : STA $0E
INY
LDA $02 : CLC : ADC .y_offsets, X : STA ($90), Y
CLC : ADC #$0010 : CMP.w #$0100
SEP #$20
BCC .on_screen_y
LDA $00 : CLC : ADC .x_offsets, X : STA ($90), Y
AND.w #$0100 : STA $0E
INY
LDA $02 : CLC : ADC .y_offsets, X : STA ($90), Y
CLC : ADC #$0010 : CMP.w #$0100
SEP #$20
BCC .on_screen_y
LDA.b #$F0 : STA ($90), Y ;Put the sprite out of the way
STA $0E
.on_screen_y
LDA.b #$F0 : STA ($90), Y ;Put the sprite out of the way
STA $0E
.on_screen_y
PLX ; Pullback Animation Index Offset (without the *2 not 16bit anymore)
INY
LDA .chr, X : STA ($90), Y
INY
LDA .properties, X : STA ($90), Y
PLX ; Pullback Animation Index Offset (without the *2 not 16bit anymore)
INY
LDA .chr, X : STA ($90), Y
INY
LDA .properties, X : STA ($90), Y
PHY
PHY
TYA : LSR #2 : TAY
TYA : LSR #2 : TAY
LDA .sizes, X : ORA $0F : STA ($92), Y ; store size in oam buffer
LDA .sizes, X : ORA $0F : STA ($92), Y ; store size in oam buffer
PLY : INY
PLY : INY
PLX : DEX : BPL .nextTile
PLX : DEX : BPL .nextTile
PLX
PLX
RTS
RTS
.start_index
db $00, $0C
.nbr_of_tiles
db 11, 11
.x_offsets
dw 0, 16, 28, 28, 0, 0, 16, 16, 0, 16, -12, -12
dw 22, 22, -5, -5, -3, 18, 0, 16, 0, 16, 0, 16
.y_offsets
dw 7, 7, -9, 7, -16, 0, 0, -16, -19, -19, -9, 7
dw 10, 26, 11, 27, -21, -21, -11, -11, 5, 5, 10, 10
.chr
db $E0, $E0, $C4, $E4, $C2, $E2, $E2, $C2, $C0, $C0, $C4, $E4
db $C4, $E4, $C4, $E4, $E6, $E6, $C8, $C8, $E8, $E8, $C6, $C6
.properties
db $3D, $7D, $7D, $7D, $3B, $3B, $7B, $7B, $3D, $7D, $3D, $3D
db $7D, $7D, $3D, $3D, $3D, $7D, $3B, $7B, $3B, $7B, $3D, $7D
.sizes
db $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02
db $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02
}
; =========================================================
ApplyDarkLinkGraphics:
{