Prev: AE26 Up: Map Next: AEDA
AE42: Take an object.
Used by the routine at _87c9.
Obj_Take AE42 XOR A Search background info for non-locker data.
AE43 LD HL,$5E57
AE46 LD BC,$0002
AE49 CPDR
AE4B RET Z Now search past info until zeroes found.
AE4C CPDR Keep searching to end.
AE4E INC HL Move up to first non zero slot.
AE4F INC HL
AE50 LD A,(HL) Get index of locker.
AE51 LD ($BD1E),A
AE54 LD E,A
AE55 LD D,$00
AE57 INC HL Get type of locker.
AE58 LD C,(HL)
AE59 LD HL,(Handle_Lockers) Calculate locker address from index.
AE5C ADD HL,DE
AE5D SLA C See if bit 7 is clear for locker type.
AE5F JR NC,Obj_Take_0
AE61 DEC HL
AE62 LD A,(HL)
AE63 DEC HL
AE64 CP (HL)
AE65 RET NZ
AE66 INC HL
AE67 INC HL
Obj_Take_0 AE68 SRL C Put locker type back to true value.
AE6A LD A,(HL) Do nothing if empty.
AE6B AND A
AE6C RET Z
AE6D LD A,(Hero_Pocket4) See if last pocket is empty.
AE70 AND A
AE71 JP Z,Obj_Take_1
AE74 CALL Print_WarningCentered Display warning if not.
AE77 DEFM "your hands are full",$5E
AE8B RET
Obj_Take_1 AE8C LD A,C Check for a factor.
AE8D CP $02
AE8F LD A,(HL) Get object index in locker.
AE90 JR NZ,Obj_Take_2 Not a factor.
AE92 LD E,L Factor have four slots, move everything along one.
AE93 LD D,H
AE94 INC HL
AE95 LD BC,$0004
AE98 LDIR
AE9A DEC HL
Obj_Take_2 AE9B AND $7F Empty locker.
AE9D LD (HL),$00
AE9F LD HL,Hero_Pocket3 Shuffle objects in pockets to make space.
AEA2 LD DE,Hero_Pocket4
AEA5 LD BC,$0003
AEA8 LDDR
AEAA LD ($BD1D),A Remember object index.
AEAD CP $3C Check the object aren't the plans.
AEAF JR NZ,Obj_Take_3
AEB1 LD HL,$0090 Set up the countdown.
AEB4 LD (Plans_CountDownTime),HL
AEB7 LD A,($5C78)
AEBA LD (Plans_CountDownFrames),A
AEBD LD HL,Str_FinalCoundown
AEC0 CALL Message_ClearIfNoPlans
Obj_Take_3 AEC3 LD A,($BD1D) Put object taken into pocket.
AEC6 LD (Hero_Pocket1),A
AEC9 LD A,$01 Reset pocket selection.
AECB LD (Hero_Select),A
AECE LD DE,$0005 Make a beep.
AED1 LD HL,$02EE
AED4 CALL $03B5
AED7 JP Pockets_UpdateInv Update inventory.
Prev: AE26 Up: Map Next: AEDA