Prev: E10E Up: Map Next: E205
E114: Bring the objects of one map column into free ground-object slots
Used by the routine at spawn_column_objects.
For each of B objects: skip it if gone (bit 7 of its kind byte, or bit 6 for player 2: play patches the BIT), if its map row is not one of the window's two, or if a slot at ground_objects already holds it; otherwise take the first free of the first three slots (the fourth if none is), set it up (free_object) and fill it in from the object's two position bytes -- bits 7-2 of the first are the y (less one), bits 1-0 of it and bits 7-5 of the second the x, bits 4-0 of the second the map row -- with graphic $0D, kind (+$13), its colours from object_kind_bytes (+$0D), the flags from object_kind_flags (+$18) and the object's index (+$18 low bits, +$19) so it can be marked gone later.
Input
A Number of objects (none if 0)
B Same
C Map column
HL Object's kind byte (in map_object_kinds)
IX Object's position bytes (in map_object_places)
spawn_objects_from_list E114 AND A Gone, or in neither row of the window: next.
E115 RET Z
spawn_objects_from_list_0 E116 PUSH BC
E117 BIT 7,(HL)
E119 JP NZ,spawn_objects_from_list_7
E11C LD A,(IX+$01)
E11F AND $1F
E121 LD E,A
E122 LD A,(view_row)
E125 CP E
E126 JR Z,spawn_objects_from_list_1
E128 INC A
E129 CP E
E12A JP NZ,spawn_objects_from_list_7
spawn_objects_from_list_1 E12D LD IY,ground_objects Already in a slot: next.
E131 LD B,$04
spawn_objects_from_list_2 E133 LD A,(IY+$00)
E136 INC A
E137 JR Z,spawn_objects_from_list_3
E139 LD A,(IY+$01)
E13C CP C
E13D JR NZ,spawn_objects_from_list_3
E13F LD A,(IY+$04)
E142 CP E
E143 JP Z,spawn_objects_from_list_7
spawn_objects_from_list_3 E146 LD A,E
E147 LD DE,$001A
E14A ADD IY,DE
E14C LD E,A
E14D DJNZ spawn_objects_from_list_2
E14F LD IY,ground_objects The first free slot.
E153 LD B,$03
spawn_objects_from_list_4 E155 LD A,(IY+$00)
E158 INC A
E159 JR Z,spawn_objects_from_list_5
E15B LD A,E
E15C LD DE,$001A
E15F ADD IY,DE
E161 LD E,A
E162 DJNZ spawn_objects_from_list_4
spawn_objects_from_list_5 E164 PUSH IX Set it up.
E166 PUSH IY
E168 POP IX
E16A POP IY
E16C CALL free_object
E16F PUSH IX
E171 PUSH IY
E173 POP IX
E175 POP IY
E177 LD (IY+$04),E Row, graphic $0D, kind, the colours from object_kind_bytes.
E17A LD (IY+$00),$0D
E17E LD A,(HL)
E17F AND $3F
E181 LD (IY+$13),A
E184 PUSH HL
E185 LD HL,object_kind_bytes
E188 CALL add_a_to_hl
E18B LD A,(HL)
E18C LD (IY+$0D),A
E18F LD HL,object_kind_flags Flags from object_kind_flags.
E192 LD A,(IY+$13)
E195 CALL add_a_to_hl
E198 LD A,(HL)
E199 AND $E0
E19B SRL A
E19D SRL A
E19F SRL A
E1A1 SRL A
E1A3 LD (IY+$18),A
E1A6 BIT 4,(HL) An animated object: graphic $1B, its frame byte and range (object_part_pairs).
E1A8 JR Z,spawn_objects_from_list_6
E1AA LD A,(HL)
E1AB AND $0F
E1AD LD HL,object_part_pairs
E1B0 CALL add_a_to_hl
E1B3 LD A,(HL)
E1B4 LD (IY+$13),A
E1B7 INC HL
E1B8 LD A,(HL)
E1B9 LD (IY+$14),A
E1BC LD (IY+$15),$80
E1C0 LD (IY+$00),$1B
spawn_objects_from_list_6 E1C4 POP HL The object's index.
E1C5 LD DE,(box_x)
E1C9 LD A,D
E1CA OR (IY+$18)
E1CD LD (IY+$18),A
E1D0 LD (IY+$19),E
E1D3 LD (IY+$01),C Column, y, x.
E1D6 LD A,(IX+$00)
E1D9 AND $FC
E1DB DEC A
E1DC LD (IY+$05),A
E1DF LD A,(IX+$00)
E1E2 AND $03
E1E4 ADD A,A
E1E5 ADD A,A
E1E6 ADD A,A
E1E7 LD E,A
E1E8 LD A,(IX+$01)
E1EB AND $E0
E1ED OR E
E1EE LD (IY+$02),A
spawn_objects_from_list_7 E1F1 INC IX Next object.
E1F3 INC IX
E1F5 INC HL
E1F6 LD DE,(box_x)
E1FA INC DE
E1FB LD (box_x),DE
E1FF POP BC
E200 DEC B
E201 JP NZ,spawn_objects_from_list_0
E204 RET
Prev: E10E Up: Map Next: E205