Prev: AE42 Up: Map Next: AFDB
AEDA: Object, drop into a locker
Used by the routine at _87c9.
See lockers for types.
Obj_Drop AEDA LD A,(Hero_Select) Using selection index...
AEDD AND A
AEDE RET Z
AEDF LD L,A Calculate address of selected pocket.
AEE0 LD H,$00
AEE2 LD DE,$BD3A
AEE5 ADD HL,DE
AEE6 LD A,(HL) Get index of object being selected to drop.
AEE7 AND A Ignore if selected empty pocket.
AEE8 RET Z
AEE9 CP $3C Check the object aren't the plans.
AEEB JR NZ,Obj_Drop_0
AEED CALL Print_WarningCentered Tell user about the plans, end.
AEF0 DEFM "plans can't be dropped!",$5E
AF08 RET Scan the background for a locker...
Obj_Drop_0 AF09 EX DE,HL
AF0A XOR A
AF0B LD HL,$5E57
AF0E LD BC,$0002
AF11 CPDR
AF13 RET Z
AF14 CPDR
AF16 INC HL
AF17 INC HL
AF18 LD A,(HL) Get locker index from background info.
AF19 LD ($BD1E),A
AF1C LD C,A
AF1D LD B,$00
AF1F INC HL Get locker type from background info.
AF20 LD A,(HL)
AF21 LD HL,(Handle_Lockers) Calculate address of locker using index.
AF24 ADD HL,BC
AF25 LD C,A If locker is a supply, the ignore any drop.
AF26 AND $7F
AF28 CP $03
AF2A RET Z
AF2B CP C See if upper bit is not set.
AF2C JR Z,Obj_Drop_1
AF2E LD C,A
AF2F DEC HL
AF30 LD A,(HL)
AF31 DEC HL
AF32 CP (HL)
AF33 RET NZ
AF34 INC HL
AF35 INC HL
Refuse Gun Check
Obj_Drop_1 AF36 LD A,C Check if locker is a refuse.
AF37 CP $05
AF39 JR NZ,Obj_Drop_3
AF3B LD A,(DE) If it is check player is not trying to drop a gun.
AF3C CP $13
AF3E JR Z,Obj_Drop_2
AF40 CP $01
AF42 JR NZ,Obj_Drop_3
Obj_Drop_2 AF44 CALL Print_WarningCentered Warn user, they can;t drop a gun in the refuse.
AF47 DEFM "power weapons not accepted",$5E
AF62 RET
Locker Full Check
Obj_Drop_3 AF63 LD A,C Get locker type.
AF64 CP $02 Check for 'factor'
AF66 LD A,$FF Mask to check for item in the locker.
AF68 JR NZ,Obj_Drop_4 If not a factor then use the mask
AF6A LD A,$80 Else set mask to only check for a factor flag.
Obj_Drop_4 AF6C AND (HL) Use mask to see if locker is full.
AF6D JR Z,Obj_Drop_7
Locker Full
Obj_Drop_5 AF6F PUSH BC Display message...
AF70 CALL Print_WarningMessageAt6
AF73 DEFM "no room in ",$5E
AF7F POP BC
AF80 LD A,C Calculate which word to use to describe the locker.
AF81 ADD A,A
AF82 ADD A,C
AF83 ADD A,A
AF84 SUB $06
AF86 LD E,A
AF87 LD D,$00
AF89 LD HL,(Word_TableLen06)
AF8C ADD HL,DE
AF8D LD B,$06
Obj_Drop_6 AF8F LD A,(HL) and display the type.
AF90 CALL Print_Character
AF93 INC HL
AF94 DJNZ Obj_Drop_6
AF96 CALL Print_StringOnStack
AF99 DEFM " unit",$5E
AF9F RET
Locker available
Obj_Drop_7 AFA0 LD A,(HL) Confirm locker is empty
AFA1 AND A
AFA2 JR Z,Obj_Drop_8
AFA4 LD A,C Only apply to a factor.
AFA5 CP $02
AFA7 RET NZ
AFA8 LD BC,$0004 Check if end slot in factor is empty.
AFAB ADD HL,BC
AFAC LD A,(HL)
AFAD AND A
AFAE LD C,$02 If not all slot must be full. Force type to a factor and display message.
AFB0 JR NZ,Obj_Drop_5
AFB2 LD C,$04 Shift all of the objects in the factor slots along.
AFB4 PUSH DE
AFB5 LD E,L
AFB6 LD D,H
AFB7 DEC HL
AFB8 LDDR
AFBA EX DE,HL
AFBB INC HL
AFBC RES 7,(HL)
AFBE DEC HL
AFBF POP DE
Obj_Drop_8 AFC0 EX DE,HL Drop object into locker.
AFC1 LD A,(HL)
AFC2 LD (DE),A
AFC3 OR $80
AFC5 LD ($BD1D),A
AFC8 LD (HL),$00 Clear pocket.
AFCA LD A,$01 Reset selection to first pocket.
AFCC LD (Hero_Select),A
AFCF LD DE,$0005 Make a beep.
AFD2 LD HL,$0190
AFD5 CALL $03B5
AFD8 JP Pockets_UpdateInv Update inventory displayed.
Prev: AE42 Up: Map Next: AFDB