Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; Code for making shop items solid, and for detecting if player is in range to purchase the item
- ; Note, when starting the below fragment
- ; X should be the shopkeeper sprite index
- ; Y should be applicable offset .item_offsets
- ;check if player link is on same layer as shopkeeper
- LDA $00EE : CMP $0F20, X; BNE .no_interaction
- JSR Setup_LinksHitbox
- JSR Setup_ShopItemCollisionHitbox
- JSL Utility_CheckIfHitBoxesOverlapLong
- BCC .no_contact
- JSR Sprite_HaltSpecialPlayerMovementCopied
- .no_contact
- JSR Setup_ShopItemInteractionHitbox
- JSL Utility_CheckIfHitBoxesOverlapLong
- BCC .no_interaction
- ;TODO Check if player is pressing A Button (by checking $F6). If so try to buy item
- .no_interaction
- ;--------------------
- Setup_ShopItemCollisionHitbox:
- ;The complications with XBA are to handle the fact that nintendo likes to store
- ;high and low bytes of 16 bit postion values seperately :-(
- ; load shopkeeper X (16 bit)
- LDA $0D30, X : XBA : LDA $0D10, X
- REP #$20 ; set 16-bit accumulator
- !ADD .item_offsets, Y
- !ADD.w #$0002 ; a small negative margin
- ; TODO: add 4 for a narrow item
- SEP #20 ; set 8-bit accumulator
- ; store hitbox X
- STA $04 : XBA : STA $0A
- ;load shopkeeper Y (16 bit)
- LDA $0D20, X : XBA : LDA $0D00, X
- REP #$20 ; set 16-bit accumulator
- !ADD .item_offsets+2, Y
- SEP #20 ; set 8-bit accumulator
- ; store hitbox Y Low: $05, High $0B
- STA $05 : XBA : STA $0B
- LDA.b #12: STA $06 ; Hitbox width, always 12 for existing (wide) shop items
- ; TODO: for narrow sprite store make width 4 (i.e. 8 pixels smaller)
- LDA.b #14: STA $07 ; Hitbox height, always 14
- RTS
- ; Adjusts the already set up collision hitbox to be a suitable interaction hitbox
- Setup_ShopItemInteractionHitbox:
- ; collision hitbox has left margin of -2, we want margin of 8 so we subtract 10
- LDA $04; !SUB.b #$0A; STA $04
- LDA $0A; SBC.b #$00; STA $0A ; Apply borrow
- ; collision hitbox has 0 top margin, we want a margin of 8 so we subtract 8
- LDA $05; !SUB.b #$08; STA $05
- LDA $0B; SBC.b #$00; STA $0B ; Apply borrow
- ; We want a width of 32 for wide or 24 for narrow, so we add 20
- LDA $06: !ADD.b #20: STA $06 ; Hitbox width
- LDA.b #40: STA $07 ; Hitbox height, always 40
- RTS
- ; Following is a copy of procedure $3770A (Bank06.asm Line 6273)
- ; because there is no long version available
- Setup_LinksHitbox:
- LDA.b #$08 : STA $02
- STA $03
- LDA $22 : ADD.b #$04 : STA $00
- LDA $23 : ADC.b #$00 : STA $08
- LDA $20 : ADC.b #$08 : STA $01
- LDA $21 : ADC.b #$00 : STA $09
- RTS
- ; The following is a copy of procedure Sprite_HaltSpecialPlayerMovement (Bank1E.asm line 255)
- ; because there is no long version available
- Sprite_HaltSpecialPlayerMovementCopied:
- PHX
- JSL Sprite_NullifyHookshotDrag
- STZ $5E ; Set Link's speed to zero...
- JSL Player_HaltDashAttackLong
- PLX
- RTS
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement