Prev: C12B Up: Map Next: C172
C141: Pick up a charm
Used by the routine at try_pickup_loop.
Copies the charm into the staging slot at $5BD8 -- type, flags, and the address of its entry in special_objs_tbl, whose type byte is then zeroed so the charm will not be put back in its room when the player leaves. The record becomes type 1 and is wiped from the screen.
If three charms are already carried, the oldest is dropped where the new one was, using the same record: picking up swaps.
A carried slot is four bytes: +0 the type ($60 to $66), +1 the flags byte from +$07, +2 and +3 the address of the charm's entry in the special-object table.
Input
IY the charm's record
pickup_object C141 LD HL,$5BD8
C144 XOR A clear $5BC0
C145 LD ($5BC0),A
C148 LD A,(IY+$00) type, flags and table pointer into slot 0; zero the table entry's type
C14B LD (HL),A
C14C INC HL
C14D LD A,(IY+$07)
C150 LD (HL),A
C151 INC HL
C152 LD E,(IY+$10)
C155 LD D,(IY+$11)
C158 XOR A
C159 LD (DE),A
C15A LD (HL),E
C15B INC HL
C15C LD (HL),D
C15D CALL set_wipe_and_draw_IY
C160 LD (IY+$00),$01
C164 LD HL,$5BE4 carrying fewer than three: just shift the slots
C167 LD A,(HL)
C168 INC HL
C169 AND A
C16A JR Z,adjust_carried
C16C LD (IY+$00),A otherwise the oldest takes the new one's place
C16F PUSH HL
C170 JR drop_object
Prev: C12B Up: Map Next: C172