Prev: 7D49 Up: Map Next: 7E90
7DC5: Pick up.
Used by the routine at Vectors.
ObjectPickUp 7DC5 LD A,(ManData_InventoryCount_DFC9) Can't carry more than four objects
7DC8 CP $04
7DCA RET NC
7DCB LD HL,(CurrentPathPtr)
7DCE LD C,(HL)
7DCF INC HL
7DD0 LD B,(HL)
7DD1 LD IX,(AreaDataCurrent_ObjectsPtr) Get pointer holding address of first object laying around in area.
7DD5 LD DE,$FFFC Offset so we get the value from the address.
7DD8 ADD IX,DE
ObjectPickUp_0 7DDA LD L,(IX+$04) Get pointer to next object in link list.
7DDD LD H,(IX+$05)
7DE0 LD A,L Zero is end of link list.
7DE1 OR H
7DE2 RET Z
7DE3 LD ( s0),IX Remember current object.
7DE7 PUSH HL Get pointer to next object.
7DE8 POP IX
7DEA LD DE,(ManData_PosSecondary_dfc5) See if hero is standing close enough to pick up.
7DEE LD L,(IX+$01)
7DF1 LD H,$00
7DF3 ADD HL,HL
7DF4 EXX
7DF5 LD DE,(ManData_PosPrimary_dfc3)
7DF9 LD L,(IX+$00)
7DFC LD H,$00
7DFE ADD HL,HL
7DFF LD A,(CamDirection_DFD2)
7E02 BIT 0,A
7E04 JR Z,ObjectPickUp_1
7E06 EXX
ObjectPickUp_1 7E07 LD A,$02
7E09 LD BC,$0004
ObjectPickUp_2 7E0C EX AF,AF'
7E0D CALL Vector_ABS(hl_minus_de)
7E10 AND A
7E11 SBC HL,BC
7E13 JR NC,ObjectPickUp_0 Not close enough move onto next object in list.
7E15 EXX
7E16 LD BC,$0003
7E19 EX AF,AF'
7E1A DEC A
7E1B JR NZ,ObjectPickUp_2
7E1D LD E,(IX+$04) Get pointer to next object in list.
7E20 LD D,(IX+$05)
7E23 PUSH IX
7E25 LD A,(IX+$02)
7E28 CP $6F
7E2A JR NZ,ObjectPickUp_6
7E2C LD IX,ManData_PosPrimary_dfc3
ObjectPickUp_3 7E30 LD L,(IX+$04)
7E33 LD H,(IX+$05)
7E36 LD A,L
7E37 OR H
7E38 JR Z,ObjectPickUp_5
7E3A PUSH HL
7E3B EX (SP),IX
7E3D LD A,(IX+$02)
7E40 CP $6F
7E42 JR Z,ObjectPickUp_4
7E44 POP HL
7E45 JR ObjectPickUp_3
ObjectPickUp_4 7E47 LD L,(IX+$04)
7E4A LD H,(IX+$05)
7E4D POP IX
7E4F LD (IX+$04),L
7E52 LD (IX+$05),H
7E55 LD HL,ManData_InventoryCount_DFC9
7E58 DEC (HL)
7E59 LD IX,$7DBA
7E5D JR ObjectPickUp_6
ObjectPickUp_5 7E5F POP IX
7E61 PUSH IX
ObjectPickUp_6 7E63 LD HL,(ManData_FirstObjectCarried) Add object to top of inventory linked list.
7E66 LD (IX+$04),L
7E69 LD (IX+$05),H
7E6C LD (ManData_FirstObjectCarried),IX
7E70 LD IX,( s0) Make next object in area list become the first.
7E74 LD (IX+$04),E
7E77 LD (IX+$05),D
7E7A LD HL,ManData_InventoryCount_DFC9 Increase number of objects carried.
7E7D INC (HL)
7E7E XOR A
7E7F LD (ManData_SelectIndex_DFCA),A
7E82 LD DE,$0005
7E85 LD HL,$0320
7E88 CALL $03B5 Beep
7E8B POP IX
7E8D JP $7D49
Prev: 7D49 Up: Map Next: 7E90