lorom ;Item finder by Black Falcon ;If there is any item in the room that hasn't been picked up yet, you'll get notified in the HUD org $A0868F ;main hijack point JSR $FFB0 org $A0FFB0 ; push stuff in case it's needed later PHA PHX JSL CHECKPLM PLX PLA LDA $1840 ;pull stuff after the routine is run and do what the hijack jump overwrote RTS org $90F640 !item = #$1475 ;tile to display if an item is present !noitem = #$1477 ;ditto if no item is present in the room ITEMFINDER: SEP #$20 : LDA #$8F PHA : PLB : REP #$20 LDA !noitem : STA $18 ;assumes that there is no item in the room before the check LDX $07BB : LDA $8F0014, X : STA $12 ;reads out current PLM pointer LOOP: LDA ($12) : BEQ NOMOREITEMS ;loads value stored at the pointer, ie detects header, if no header is found, no item is found CMP #$DF7D : BMI INCREASE ;checks items CMP #$F0A0 : BPL NOMOREITEMS ;checks custom PLMS LDA $12 : CLC : ADC #$0004 ;we want to read out LO STA $14 LDA ($14) : AND #$00FF JSL ITEMCHECKROUTINE : BCS INCREASE ;SEC if item has been picked up, CLC if not LDA !item : STA $18 : BRA NOMOREITEMS ;if even just one is found, you can jump out right here INCREASE: LDA $12 : CLC : ADC #$0006 STA $12 : BRA LOOP NOMOREITEMS: LDA $18 : STA $7EC616 : RTL ITEMCHECKROUTINE: PHX : PHY : PHP : REP #$30 JSR $80818E LDA $7ED870,x : AND $05E7 : BNE SET ;checks item bit PLP : PLY : PLX : CLC : RTL SET: PLP : PLY : PLX : SEC : RTL