# if the item buffer is nonzero, spawn the item at link and reset the buffer. # var INTERAC_MULTI_BYTE is used to signal the destination player number, and # var 71 is set to override normal collect/player properties lookup. 05//checkNetItemBuffer: | push bc push de push hl ld a,(wMenuDisabled) and a jr nz,@done ld a,(wLinkGrabState) and a jr nz,@done ld hl,wNetTreasureIn ldi a,(hl) or a jr z,@done cp $ff jr nz,@notDeathlink ; If item in buffer is 0xFF, it's a deathlink signal so make Link die ld a,$fe ld (wLinkDeathTrigger),a jr @done @notDeathlink: ld b,a ld c,(hl) call spawnTreasureOnLink jr nz,@done ld l,$71 ld (hl),$02 ld hl,wNetCountInL inc (hl) ld a,(hl) or a jr nz,@noOverflow ld hl,wNetCountInH inc (hl) @noOverflow: ld hl,wNetTreasureIn xor a ldi (hl),a ld (hl),a @done: pop hl pop de pop bc call linkInteractWithAButtonSensitiveObjects ret 05/5526/: call checkNetItemBuffer # run treasure state 1 code immediately following treasure state 0 code, so # that link can pick up items on the same frame they're spawned. this avoids # issues for treasures spawning on the frame before link gets warped, like # after subrosian dancing and when failing poe skip. maku seed visuals don't # quite work right this way, so don't do this for maku seed. 09//treasureCollideImmediately: | call objectSetVisiblec2 ld e,$70 ld a,(de) cp TREASURE_MAKU_SEED ret z jp $4000 ; interactionCode60 09/49a6/: jp treasureCollideImmediately # if var 71 is already nonzero, use that as the collect mode instead of # whatever this is. 16//keepNonzeroCollectMode: | ld e,$71 ld a,(de) and a jr nz,@next ld a,b @next: ld b,a swap a and $07 ld (de),a ret 16/453e/: call keepNonzeroCollectMode