Add GBC Link, update Masks directory
This commit is contained in:
351
Sprites/ZSpriteLib/sprite_functions_hooks.asm
Normal file
351
Sprites/ZSpriteLib/sprite_functions_hooks.asm
Normal file
@@ -0,0 +1,351 @@
|
||||
SprAction = $0D80
|
||||
SprFrame = $0D90 ; This is also used to do various things in different sprites
|
||||
SprMiscA = $0DA0 ; This can be used to do anything in sprite
|
||||
SprMiscB = $0DB0 ; This can be used to do anything in sprite
|
||||
SprMiscC = $0DE0 ; This can be used to do anything in sprite (Mainly used for sprite direction)
|
||||
SprMiscD = $0E90 ; This can be used to do anything in sprite
|
||||
SprMiscE = $0EB0 ; This can be used to do anything in sprite
|
||||
SprMiscF = $0EC0 ; This can be used to do anything in sprite
|
||||
SprMiscG = $0ED0 ; This can be used to do anything in sprite
|
||||
|
||||
SprStunTimer = $0B58
|
||||
|
||||
SprTimerA = $0DF0 ; This address value is decreased by one every frames
|
||||
SprTimerB = $0E00 ; This address value is decreased by one every frames
|
||||
SprTimerC = $0E10 ; This address value is decreased by one every frames
|
||||
SprTimerD = $0EE0 ; This address value is decreased by one every frames
|
||||
SprTimerE = $0F10 ; This address value is decreased by one every frames
|
||||
SprTimerF = $0F80 ; This address value is decreased by 2 every frames is also used by the gravity routine
|
||||
|
||||
SprPause = $0F00 ; Can probably be used for anything
|
||||
SprFloor = $0F20
|
||||
SprType = $0E20 ; This contains the ID of the sprite 00 = raven, 01 = vulture, etc...
|
||||
SprSubtype = $0E30 ; This contains the Sub ID of the sprite
|
||||
SprState = $0DD0 ; This tells if the sprite is alive, dead, frozen, etc...
|
||||
|
||||
SprNbrOAM = $0E40 ; Bits 0-4: define the number of OAM slots used by the sprite
|
||||
SprHealth = $0E50
|
||||
SprGfxProps = $0E60
|
||||
SprCollision = $0E70 ; When a sprite hit a wall, this gets set to the direction in which the collision occurred.
|
||||
SprDelay = $0E80 ; Used in sprite state 0x03 (falling in water), used as delay in most of the sprites
|
||||
SprRecoil = $0EA0 ; Recoil Timer
|
||||
SprDeath = $0EF0
|
||||
|
||||
SprProps = $0F50 ; DIWS UUUU - [D boss death][I Impervious to all attacks][W Water slash] [S Draw Shadow] [U Unused]
|
||||
SprHitbox = $0F60 ; ISPH HHHH - [I ignore collisions][S Statis (not alive eg beamos)][P Persist code still run outside of camera][H Hitbox]
|
||||
SprHeight = $0F70 ; Distance from the shadow
|
||||
SprHeightS = $0F90 ; Distance from the shadow subpixel
|
||||
|
||||
SprYRecoil = $0F30
|
||||
SprXRecoil = $0F40
|
||||
|
||||
SprGfx = $0DC0 ; Determine the GFX used for the sprite
|
||||
OAMPtr = $90
|
||||
OAMPtrH = $92
|
||||
|
||||
SprY = $0D00
|
||||
SprX = $0D10
|
||||
SprYH = $0D20
|
||||
SprXH = $0D30
|
||||
|
||||
SprYSpeed = $0D40
|
||||
SprXSpeed = $0D50
|
||||
|
||||
SprYRound = $0D60
|
||||
SprXRound = $0D70
|
||||
|
||||
SprCachedX = $0FD8 ; This doesn't need to be indexed with X it contains the 16bit position of the sprite
|
||||
SprCachedY = $0FDA ; This doesn't need to be indexed with X it contains the 16bit position of the sprite
|
||||
|
||||
|
||||
|
||||
org $09AE64
|
||||
Sprite_SetSpawnedCoords:
|
||||
|
||||
;=================================================================
|
||||
;Sprite_PrepOamCoord LONG
|
||||
;set the oam coordinate for the sprite draw
|
||||
org $06E416
|
||||
Sprite_PrepOamCoord:
|
||||
|
||||
;=================================================================
|
||||
;Sprite_CheckDamageFromPlayer LONG
|
||||
;check if the sprite is getting damage from player or items
|
||||
org $06F2AA
|
||||
Sprite_CheckDamageFromPlayer:
|
||||
|
||||
;=================================================================
|
||||
;Sprite_CheckDamageToPlayer LONG
|
||||
;check if the sprite is touching the player to damage
|
||||
org $06F121
|
||||
Sprite_CheckDamageToPlayer:
|
||||
|
||||
;=================================================================
|
||||
;Sprite_AttemptDamageToPlayerPlusRecoil LONG
|
||||
;damage the player everywhere on screen?
|
||||
org $06F41F
|
||||
Sprite_AttemptDamageToPlayerPlusRecoil:
|
||||
|
||||
;=================================================================
|
||||
;Sprite_OAM_AllocateDeferToPlayer LONG
|
||||
;Draw the sprite depending of the position of the player (if he has to be over or under link)
|
||||
org $06F864
|
||||
Sprite_OAM_AllocateDeferToPlayer:
|
||||
|
||||
org $0DBA80
|
||||
OAM_AllocateFromRegionA:
|
||||
org $0DBA84
|
||||
OAM_AllocateFromRegionB:
|
||||
org $0DBA88
|
||||
OAM_AllocateFromRegionC:
|
||||
org $0DBA8C
|
||||
OAM_AllocateFromRegionD:
|
||||
org $0DBA90
|
||||
OAM_AllocateFromRegionE:
|
||||
org $0DBA94
|
||||
OAM_AllocateFromRegionF:
|
||||
|
||||
org $05DF70
|
||||
Sprite_DrawMultiple_quantity_preset:
|
||||
;=================================================================
|
||||
;ApplyRumbleToSprites LONG
|
||||
;makes all the sprites on screen shaking?
|
||||
org $0680FA
|
||||
ApplyRumbleToSprites:
|
||||
|
||||
|
||||
;=================================================================
|
||||
;CheckIfHitBoxesOverlap LONG
|
||||
;args :
|
||||
;!pos1_low = $00
|
||||
;!pos1_size = $02
|
||||
;!pos2_low = $04
|
||||
;!pos2_size = $06
|
||||
;!pos1_high = $08
|
||||
;!pos2_high = $0A
|
||||
;!ans_low = $0F
|
||||
;!ans_high = $0C
|
||||
;returns carry clear if there was no overlap
|
||||
org $0683E6
|
||||
CheckIfHitBoxesOverlap:
|
||||
|
||||
;=================================================================
|
||||
;Sprite_Get_16_bit_Coords LONG
|
||||
;$0FD8 = sprite's X coordinate, $0FDA = sprite's Y coordinate
|
||||
org $0684BD
|
||||
Sprite_Get_16_bit_Coords:
|
||||
|
||||
;=================================================================
|
||||
;Sprite_PrepAndDrawSingleLarge LONG
|
||||
;load / draw a 16x16 sprite
|
||||
org $06DBF0
|
||||
Sprite_PrepAndDrawSingleLarge:
|
||||
|
||||
;=================================================================
|
||||
;Sprite_PrepAndDrawSingleSmall LONG
|
||||
;load / draw a 8x8 sprite
|
||||
org $06DBF8
|
||||
Sprite_PrepAndDrawSingleSmall:
|
||||
|
||||
;=================================================================
|
||||
;Sprite_DrawShadow LONG
|
||||
;draw shadow
|
||||
org $06DC54
|
||||
Sprite_DrawShadow:
|
||||
|
||||
;=================================================================
|
||||
;Sprite_CheckTileCollision LONG
|
||||
;check if the sprite is colliding with a solid tile set $0E70, X
|
||||
;----udlr , u = up, d = down, l = left, r = right
|
||||
org $06E496
|
||||
Sprite_CheckTileCollision:
|
||||
|
||||
;=================================================================
|
||||
;Sprite_GetTileAttr LONG
|
||||
; $00[0x02] - Entity Y coordinate
|
||||
; $02[0x03?] - Entity X coordinate
|
||||
;$0FA5
|
||||
org $06E87B
|
||||
Sprite_GetTileAttr:
|
||||
|
||||
;=================================================================
|
||||
;Sprite_CheckSlopedTileCollision LONG
|
||||
;check if the sprite is colliding with a solid sloped tile
|
||||
org $06E8FD
|
||||
Sprite_CheckSlopedTileCollision:
|
||||
|
||||
;=================================================================
|
||||
;Sprite_ApplySpeedTowardsPlayer LONG
|
||||
;set the velocity x,y towards the player (A = speed)
|
||||
org $06EA12
|
||||
Sprite_ApplySpeedTowardsPlayer:
|
||||
|
||||
;=================================================================
|
||||
;Sprite_DirectionToFacePlayer LONG
|
||||
; \return $0E is low byte of player_y_pos - sprite_y_pos
|
||||
; \return $0F is low byte of player_x_pos - sprite_x_pos
|
||||
org $06EAA0
|
||||
Sprite_DirectionToFacePlayer:
|
||||
|
||||
;=================================================================
|
||||
;Sprite_IsToRightOfPlayer LONG
|
||||
;if Link is to the left of the sprite, Y = 1, otherwise Y = 0.
|
||||
org $06EACD
|
||||
Sprite_IsToRightOfPlayer:
|
||||
|
||||
;=================================================================
|
||||
;Sprite_IsBelowPlayer LONG
|
||||
;return Y=1 sprite is below player, otherwise Y = 0
|
||||
org $06EAE4
|
||||
Sprite_IsBelowPlayer:
|
||||
|
||||
;=================================================================
|
||||
;Sprite_CheckDamageToPlayerSameLayer LONG
|
||||
;check damage done to player if they collide and if they are on same layer
|
||||
org $06F129
|
||||
Sprite_CheckDamageToPlayerSameLayer:
|
||||
|
||||
;=================================================================
|
||||
;Sprite_CheckDamageToPlayerIgnoreLayer LONG
|
||||
;check damage done to player if they collide even if they are not on same layer
|
||||
org $06F131
|
||||
Sprite_CheckDamageToPlayerIgnoreLayer:
|
||||
|
||||
;=================================================================
|
||||
;Sound_SetSfx2PanLong LONG
|
||||
;play a sound loaded in A
|
||||
org $0DBB6E
|
||||
Sound_SetSfx1PanLong:
|
||||
|
||||
org $0DBB7C
|
||||
Sound_SetSfx2PanLong:
|
||||
|
||||
org $0DBB8A
|
||||
Sound_SetSfx3PanLong:
|
||||
|
||||
;=================================================================
|
||||
;Sprite_SpawnDynamically LONG
|
||||
;spawn a new sprite on screen, A = sprite id
|
||||
;when using this function you have to set the position yourself
|
||||
;these values belong to the sprite who used that function not the new one
|
||||
;$00 low x, $01 high x
|
||||
;$02 low y, $03 high y
|
||||
;$04 height, $05 low x (overlord)
|
||||
;$06 high x (overlord), $07 low y (overlord)
|
||||
;$08 high y (overlord)
|
||||
org $1DF65D
|
||||
Sprite_SpawnDynamically:
|
||||
|
||||
org $07F1A3
|
||||
Player_ResetState:
|
||||
;=================================================================
|
||||
;Sprite_ApplyConveyorAdjustment LONG
|
||||
;move the sprite if he stand on a conveyor belt
|
||||
org $1D8010
|
||||
Sprite_ApplyConveyorAdjustment:
|
||||
|
||||
;=================================================================
|
||||
;SetupHitBox LONG
|
||||
;set the hitbox of the player (i think)
|
||||
;org $0683EA
|
||||
;Sprite_SetupHitBoxLong:
|
||||
|
||||
;=================================================================
|
||||
;Dungeon_SpriteInducedTilemapUpdate LONG
|
||||
;set tile of dungeon
|
||||
org $01E7A9
|
||||
Dungeon_SpriteInducedTilemapUpdate:
|
||||
;=================================================================
|
||||
;Get random INT LONG
|
||||
;GetRandomInt
|
||||
org $0DBA71
|
||||
GetRandomInt:
|
||||
|
||||
;=================================================================
|
||||
;Sprite_PlayerCantPassThrough
|
||||
;player can't pass through the sprite
|
||||
org $1EF4F3
|
||||
Sprite_PlayerCantPassThrough:
|
||||
|
||||
;=================================================================
|
||||
;Sprite_NullifyHookshotDrag
|
||||
;player can't hookshot to that sprite
|
||||
org $0FF540
|
||||
Sprite_NullifyHookshotDrag:
|
||||
|
||||
;=================================================================
|
||||
;Player_HaltDashAttack
|
||||
;stop the dash attack of the player
|
||||
org $0791B9
|
||||
Player_HaltDashAttack:
|
||||
|
||||
;=================================================================
|
||||
;Sprite_ShowMessageUnconditional
|
||||
;show a message box without any condition
|
||||
; A = low byte of message ID to use.
|
||||
; Y = high byte of message ID to use.
|
||||
org $05E219
|
||||
Sprite_ShowMessageUnconditional:
|
||||
|
||||
;=================================================================
|
||||
;Link_ReceiveItem
|
||||
;Y = item id
|
||||
org $0799AD
|
||||
Link_ReceiveItem:
|
||||
|
||||
;=================================================================
|
||||
;Sprite_ShowSolicitedMessageIfPlayerFacing
|
||||
;show a message if we press A and face the sprite
|
||||
; A = low byte of message ID to use.
|
||||
; Y = high byte of message ID to use.
|
||||
org $05E1A7
|
||||
Sprite_ShowSolicitedMessageIfPlayerFacing:
|
||||
|
||||
;=================================================================
|
||||
;Sprite_ShowMessageFromPlayerContact
|
||||
;show a message if we touch the sprite should be used with Sprite_PlayerCantPassThrough
|
||||
; A = low byte of message ID to use.
|
||||
; Y = high byte of message ID to use.
|
||||
org $05E1F0
|
||||
Sprite_ShowMessageFromPlayerContact:
|
||||
|
||||
; Parameters: Stack, A
|
||||
org $008781
|
||||
UseImplicitRegIndexedLocalJumpTable:
|
||||
|
||||
org $00893D
|
||||
EnableForceBlank:
|
||||
|
||||
|
||||
;=================================================================
|
||||
;Sprite_ProjectSpeedTowardsEntityLong
|
||||
;04 = X
|
||||
;05 = HighX
|
||||
;06 = Y
|
||||
;07 = HighY
|
||||
;A = Speed
|
||||
|
||||
;Return $00 - Y Velocity
|
||||
;Return $01 - X Velocity
|
||||
|
||||
org $06EA22
|
||||
Sprite_ProjectSpeedTowardsEntityLong:
|
||||
|
||||
org $0DDA06
|
||||
Sprite_SpawnFireball:
|
||||
|
||||
org $1D808C
|
||||
Sprite_MoveLong:
|
||||
|
||||
org $1EFF8D
|
||||
Sprite_DrawRippleIfInWater:
|
||||
|
||||
org $058008
|
||||
Sprite_SpawnSparkleGarnish:
|
||||
|
||||
|
||||
org $06EA1A
|
||||
Sprite_ProjectSpeedTowardsPlayer:
|
||||
|
||||
org $06F2AA
|
||||
Sprite_CheckDamageFromPlayerLong:
|
||||
208
Sprites/ZSpriteLib/sprite_macros.asm
Normal file
208
Sprites/ZSpriteLib/sprite_macros.asm
Normal file
@@ -0,0 +1,208 @@
|
||||
; Write Sprite Properties in the rom MACRO
|
||||
macro Set_Sprite_Properties(SprPrep, SprMain)
|
||||
|
||||
pushpc ; Save writing Position for the sprite
|
||||
org $0DB080+!SPRID ; Oam Harmless ($0E40)
|
||||
db ((!Harmless<<7)|(!HVelocity<<6)|!NbrTiles)
|
||||
|
||||
org $0DB173+!SPRID ; Sprite HP ($0E50)
|
||||
db !Health
|
||||
|
||||
org $0DB266+!SPRID ; Sprite Damage ($0CD2)
|
||||
db !Damage
|
||||
|
||||
org $0DB359+!SPRID ; Sprite Data ($0E60 / $0F50)
|
||||
db ((!DeathAnimation<<7)|(!ImperviousAll<<6)|(!SmallShadow<<5)|(!Shadow<<4)|(!Palette<<1))
|
||||
|
||||
org $0DB44C+!SPRID ; Sprite Hitbox ($0F60)
|
||||
db ((!CollisionLayer<<7)|(!Statis<<6)|(!Persist<<5)|(!Hitbox))
|
||||
|
||||
org $0DB53F+!SPRID ; Sprite Fall ($0B6B)
|
||||
db ((!DeflectArrow<<3)|(!Boss<<1)|!CanFall)
|
||||
|
||||
org $0DB632+!SPRID ; Sprite Prize ($0BE0)
|
||||
db ((!Interaction<<7)|(!WaterSprite<<6)|(!Blockable<<5)|(!Sound<<4)|!Prize)
|
||||
|
||||
org $0DB725+!SPRID ; Sprite ($0CAA)
|
||||
db ($40|(!Statue<<5)|(!DeflectProjectiles<<4)|(!ImpervSwordHammer<<2)|(!ImperviousArrow<<1))
|
||||
|
||||
org $069283+(!SPRID*2) ; Vanilla Sprite Main Pointer
|
||||
dw NewMainSprFunction
|
||||
|
||||
org $06865B+(!SPRID*2) ; Vanilla Sprite Prep Pointer
|
||||
dw NewSprPrepFunction
|
||||
|
||||
org NewSprRoutinesLong+(!SPRID*3) ; New Long Sprite Pointer
|
||||
dl <SprMain>
|
||||
|
||||
org NewSprPrepRoutinesLong+(!SPRID*3) ; New Long Sprite Pointer
|
||||
dl <SprPrep>
|
||||
pullpc ; Get back the writing position for the sprite
|
||||
|
||||
endmacro
|
||||
|
||||
; Go to the action specified ID can be Hex or Decimal
|
||||
macro GotoAction(action)
|
||||
LDA.b #<action> : STA.w SprAction, X
|
||||
endmacro
|
||||
|
||||
|
||||
; Increase the sprite frame every (frames_wait) frames
|
||||
; reset to (frame_start) when reaching (frame_end)
|
||||
; This is using SprTimerB
|
||||
macro PlayAnimation(frame_start, frame_end, frame_wait)
|
||||
LDA.w SprTimerB, X : BNE +
|
||||
LDA.w SprFrame, X : INC : STA.w SprFrame, X : CMP.b #<frame_end>+1 : BCC .noframereset
|
||||
LDA.b #<frame_start> : STA.w SprFrame, X
|
||||
.noframereset
|
||||
LDA.b #<frame_wait> : STA.w SprTimerB, X
|
||||
+
|
||||
endmacro
|
||||
|
||||
macro StartOnFrame(frame)
|
||||
LDA.w SprFrame, x : CMP.b #<frame> : BCS +
|
||||
LDA.b #<frame> : STA.w SprFrame, x
|
||||
+
|
||||
endmacro
|
||||
|
||||
|
||||
; Show message if the player is facing toward sprite and pressing A
|
||||
; Return Carry Set if message is displayed
|
||||
; can use BCC .label <> .label to see if message have been displayed
|
||||
macro ShowSolicitedMessage(message_id)
|
||||
LDY.b #(<message_id>)>>8
|
||||
LDA.b #<message_id>
|
||||
JSL Sprite_ShowSolicitedMessageIfPlayerFacing
|
||||
endmacro
|
||||
|
||||
; Show message no matter what (should not be used without code condition)
|
||||
macro ShowUnconditionalMessage(message_id)
|
||||
LDY.b #(<message_id>)>>8
|
||||
LDA.b #<message_id>
|
||||
JSL Sprite_ShowMessageUnconditional
|
||||
endmacro
|
||||
|
||||
; Make the sprite move towards the player at a speed of (speed)
|
||||
macro MoveTowardPlayer(speed)
|
||||
LDA.b #<speed>
|
||||
JSL Sprite_ApplySpeedTowardsPlayer
|
||||
JSL Sprite_MoveLong
|
||||
endmacro
|
||||
|
||||
; Prevent the player from passing through sprite hitbox
|
||||
macro PlayerCantPassThrough()
|
||||
JSL Sprite_PlayerCantPassThrough
|
||||
endmacro
|
||||
|
||||
; Do damage to player on contact if sprite is on same layer as player
|
||||
macro DoDamageToPlayerSameLayerOnContact()
|
||||
JSL Sprite_CheckDamageToPlayerSameLayer
|
||||
endmacro
|
||||
|
||||
; Set harmless flag, 0 = harmful, 1 = harmless
|
||||
macro SetHarmless(value)
|
||||
LDA.w SprNbrOAM, X
|
||||
AND #$7F
|
||||
if <value> != 0
|
||||
ORA.b #(<value>)<<7
|
||||
endif
|
||||
STA.w SprNbrOAM, X
|
||||
endmacro
|
||||
|
||||
; Set Room Flag (Chest 6)
|
||||
; Do not use if you have more than 5 chests or a small key under a pot
|
||||
; in that room unless you want it to be already opened/taken
|
||||
macro SetRoomFlag(value)
|
||||
if <value> != 0
|
||||
LDA $0403 : ORA #$20 : STA $0403
|
||||
else
|
||||
LDA $0403 : AND #$DF : STA $0403
|
||||
endif
|
||||
endmacro
|
||||
|
||||
; Will prevent the player from moving or opening his menu
|
||||
macro PreventPlayerMovement()
|
||||
LDA #$01 : STA $02E4
|
||||
endmacro
|
||||
|
||||
; Will allow the player to move or open his menu
|
||||
macro AllowPlayerMovement()
|
||||
STZ.w $02E4
|
||||
endmacro
|
||||
|
||||
; Enter 16bit mode
|
||||
macro Set16bitmode()
|
||||
REP #$30
|
||||
endmacro
|
||||
|
||||
; Enter 8bit mode
|
||||
macro Set8bitmode()
|
||||
SEP #$30
|
||||
endmacro
|
||||
|
||||
; This is a 16 bit will load A with current rupee count
|
||||
; to use with instructions CMP and BCC/BCS
|
||||
macro GetPlayerRupees()
|
||||
LDA $7EF360
|
||||
endmacro
|
||||
|
||||
; Set the velocity Y of the sprite at (speed) value
|
||||
; this require the use of the function JSL Sprite_MoveLong
|
||||
macro SetSpriteSpeedY(speed)
|
||||
LDA.b #<speed> : STA.w SprYSpeed, x
|
||||
endmacro
|
||||
|
||||
; Set the velocity X of the sprite at (speed) value
|
||||
; this require the use of the function JSL Sprite_MoveLong
|
||||
macro SetSpriteSpeedX(speed)
|
||||
LDA.b #<speed> : STA.w SprXSpeed, x
|
||||
endmacro
|
||||
|
||||
; Will play a sound SFX 1 See Zelda_3_RAM.log for more informations
|
||||
macro PlaySFX1(sfxid)
|
||||
LDA.b #<sfxid> : STA $012E
|
||||
endmacro
|
||||
|
||||
; Will play a sound SFX 2 See Zelda_3_RAM.log for more informations
|
||||
macro PlaySFX2(sfxid)
|
||||
LDA.b #<sfxid> : STA $012F
|
||||
endmacro
|
||||
|
||||
; Will play a music See Zelda_3_RAM.log for more informations
|
||||
macro PlayMusic(musicid)
|
||||
LDA.b #<musicid> : STA $012C
|
||||
endmacro
|
||||
|
||||
; Will set the timer A to wait (length) amount of frames
|
||||
macro SetTimerA(length)
|
||||
LDA.b #<length> : STA.w SprTimerA, X
|
||||
endmacro
|
||||
|
||||
; Will set the timer B to wait (length) amount of frames
|
||||
macro SetTimerB(length)
|
||||
LDA.b #<length> : STA.w SprTimerB, X
|
||||
endmacro
|
||||
|
||||
; Will set the timer C to wait (length) amount of frames
|
||||
macro SetTimerC(length)
|
||||
LDA.b #<length> : STA.w SprTimerC, X
|
||||
endmacro
|
||||
|
||||
; Will set the timer D to wait (length) amount of frames
|
||||
macro SetTimerD(length)
|
||||
LDA.b #<length> : STA.w SprTimerD, X
|
||||
endmacro
|
||||
|
||||
; Will set the timer E to wait (length) amount of frames
|
||||
macro SetTimerE(length)
|
||||
LDA.b #<length> : STA.w SprTimerE, X
|
||||
endmacro
|
||||
|
||||
; Will set the timer F to wait (length) amount of frames
|
||||
macro SetTimerF(length)
|
||||
LDA.b #<length> : STA.w SprTimerF, X
|
||||
endmacro
|
||||
|
||||
macro NextAction()
|
||||
INC $0D80, X
|
||||
endmacro
|
||||
231
Sprites/ZSpriteLib/sprite_new_functions.asm
Normal file
231
Sprites/ZSpriteLib/sprite_new_functions.asm
Normal file
@@ -0,0 +1,231 @@
|
||||
;=================================================================
|
||||
;Long function, return Carry Set if Active
|
||||
;=================================================================
|
||||
Sprite_CheckActive:
|
||||
{
|
||||
; Deactivates the sprite in certain situations
|
||||
|
||||
LDA $0DD0, X : CMP.b #$09 : BNE .inactive
|
||||
|
||||
LDA $0FC1 : BNE .inactive
|
||||
|
||||
LDA $11 : BNE .inactive
|
||||
|
||||
LDA $0CAA, X : BMI .active
|
||||
|
||||
LDA $0F00, X : BEQ .active
|
||||
|
||||
.inactive
|
||||
CLC
|
||||
RTL
|
||||
|
||||
.active
|
||||
SEC
|
||||
RTL
|
||||
}
|
||||
|
||||
|
||||
; make the sprite move X axis
|
||||
;===================================================================================================
|
||||
Sprite_MoveHoriz:
|
||||
LDA.w $0D50,X : BEQ .no_velocity
|
||||
ASL : ASL : ASL : ASL
|
||||
CLC : ADC.w $0D70,X : STA.w $0D70,X
|
||||
|
||||
LDY.b #$00
|
||||
LDA.w $0D50,X
|
||||
PHP : LSR : LSR : LSR : LSR : PLP
|
||||
BPL ++
|
||||
|
||||
ORA.b #$F0
|
||||
DEY
|
||||
|
||||
++ ADC.w $0D10,X : STA.w $0D10,X
|
||||
TYA : ADC.w $0D30,X : STA.w $0D30,X
|
||||
|
||||
.no_velocity
|
||||
RTL
|
||||
|
||||
;===================================================================================================
|
||||
; make the sprite move both directions (also height)
|
||||
;===================================================================================================
|
||||
Sprite_MoveXyz:
|
||||
JSL Sprite_MoveAltitude
|
||||
Sprite_Move:
|
||||
JSL Sprite_MoveHoriz
|
||||
; no RTL, just continue into Sprite_MoveVert
|
||||
|
||||
;===================================================================================================
|
||||
; make the sprite move Y axis
|
||||
;===================================================================================================
|
||||
Sprite_MoveVert:
|
||||
LDA.w $0D40,X : BEQ .no_velocity
|
||||
ASL : ASL : ASL : ASL
|
||||
CLC : ADC.w $0D60,X : STA.w $0D60,X
|
||||
|
||||
LDY.b #$00
|
||||
LDA.w $0D40,X
|
||||
PHP : LSR : LSR : LSR : LSR : PLP
|
||||
BPL ++
|
||||
|
||||
ORA.b #$F0
|
||||
DEY
|
||||
|
||||
++ ADC.w $0D00,X : STA.w $0D00,X
|
||||
TYA : ADC.w $0D20,X : STA.w $0D20,X
|
||||
|
||||
.no_velocity
|
||||
RTL
|
||||
|
||||
;===================================================================================================
|
||||
; make the sprite move Z axis (height)
|
||||
;===================================================================================================
|
||||
Sprite_MoveZ:
|
||||
Sprite_MoveAltitude:
|
||||
LDA.w $0F80,X : ASL : ASL : ASL : ASL
|
||||
CLC : ADC.w $0F90,X : STA.w $0F90,X
|
||||
|
||||
LDA.w $0F80,X : PHP
|
||||
LSR : LSR : LSR : LSR
|
||||
PLP : BPL .positive
|
||||
|
||||
ORA.b #$F0
|
||||
|
||||
.positive
|
||||
ADC.w $0F70,X : STA.w $0F70,X
|
||||
|
||||
RTL
|
||||
|
||||
|
||||
;===================================================================================================
|
||||
; make the sprite bounce toward player (like vitreous)
|
||||
; Movement, Collision are handled by this function (height:20 = vitreous)
|
||||
; $09 = speed, $08 = max height
|
||||
;===================================================================================================
|
||||
Sprite_BounceTowardPlayer:
|
||||
JSL Sprite_MoveAltitude
|
||||
|
||||
DEC.w $0F80,X : DEC.w $0F80,X
|
||||
|
||||
LDA.w $0F70,X : BPL .aloft
|
||||
|
||||
STZ.w $0F70,X
|
||||
|
||||
LDA.b $08 : STA.w $0F80,X ; set height from 08
|
||||
|
||||
;LDA.b $09
|
||||
LDA.b #$20
|
||||
|
||||
JSL Sprite_ApplySpeedTowardsPlayer
|
||||
|
||||
LDA.b #$21 : JSL Sound_SetSfx2PanLong
|
||||
|
||||
.aloft
|
||||
LDA.w $0F70,X : BEQ .dontmove
|
||||
|
||||
JSL Sprite_Move
|
||||
|
||||
.dontmove
|
||||
RTL
|
||||
|
||||
Sprite_BounceFromTileCollision:
|
||||
JSL Sprite_CheckTileCollision : AND.b #$03 : BEQ ++
|
||||
LDA.w $0D50,X : EOR.b #$FF : INC : STA.w $0D50,X
|
||||
INC.w $0ED0,X
|
||||
|
||||
++ LDA.w $0E70,X : AND.b #$0C : BEQ ++
|
||||
LDA.w $0D40,X : EOR.b #$FF : INC : STA.w $0D40,X
|
||||
INC.w $0ED0,X
|
||||
|
||||
++ RTL
|
||||
|
||||
; ==============================================================================
|
||||
|
||||
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
|
||||
}
|
||||
79
Sprites/ZSpriteLib/sprite_new_table.asm
Normal file
79
Sprites/ZSpriteLib/sprite_new_table.asm
Normal file
@@ -0,0 +1,79 @@
|
||||
pushpc
|
||||
org $06FFF8 ; New Jumptable for sprites
|
||||
NewMainSprFunction:
|
||||
JSL SpriteActiveExp_MainLong
|
||||
RTS
|
||||
|
||||
org $068EB9
|
||||
NewSprPrepFunction:
|
||||
JSL Sprite_PrepExp_Long
|
||||
RTS
|
||||
pullpc
|
||||
|
||||
|
||||
|
||||
SpriteActiveExp_MainLong:
|
||||
{
|
||||
PHB : PHK : PLB
|
||||
|
||||
JSL NewSprTable
|
||||
|
||||
PLB
|
||||
|
||||
RTL
|
||||
}
|
||||
|
||||
NewSprTable:
|
||||
LDA $0E20, X ; Load Sprite ID
|
||||
REP #$30
|
||||
AND.w #$00FF
|
||||
STA $06
|
||||
ASL A ; *2
|
||||
CLC : ADC $06 ; *3
|
||||
TAY
|
||||
|
||||
LDA NewSprRoutinesLong, Y ; Load sprite Address
|
||||
STA $06
|
||||
SEP #$20 ; Previously SEP #$30 -_- (that's fine for sprites below ~0x40 over that it will crash)
|
||||
LDA NewSprRoutinesLong+2, Y
|
||||
STA $08
|
||||
SEP #$30
|
||||
JMP [$0006]
|
||||
|
||||
;do a JML and sprite will RTL back to previous code
|
||||
|
||||
Sprite_PrepExp_Long:
|
||||
{
|
||||
PHB : PHK : PLB
|
||||
|
||||
JSL NewSprPrepTable
|
||||
|
||||
PLB
|
||||
|
||||
RTL
|
||||
}
|
||||
|
||||
NewSprPrepTable:
|
||||
LDA $0E20, X ; Load Sprite ID
|
||||
REP #$30
|
||||
AND.w #$00FF
|
||||
STA $06
|
||||
ASL A ; *2
|
||||
CLC : ADC $06 ; *3
|
||||
TAY
|
||||
|
||||
LDA NewSprPrepRoutinesLong, Y ; Load sprite Address
|
||||
STA $06
|
||||
SEP #$20 ; Previously SEP #$30 -_- (that's fine for sprites below ~0x40 over that it will crash)
|
||||
LDA NewSprPrepRoutinesLong+2, Y
|
||||
STA $08
|
||||
SEP #$30
|
||||
JMP [$0006]
|
||||
|
||||
NewSprRoutinesLong:
|
||||
fillbyte $00
|
||||
fill $2FD
|
||||
|
||||
NewSprPrepRoutinesLong:
|
||||
fillbyte $00
|
||||
fill $2FD
|
||||
Reference in New Issue
Block a user