Prev: E062 Up: Map Next: E0EA
E08F: Load Map Objects
Used by the routine at MakeTiles.
Puts the objects of the map for the two columns that are on the screen into the slots for the map objects. The objects of a column are found by adding up the numbers of the objects in the columns before it, from the table at ColumnTable, to get the place in the tables at MapTable and TerrainData. If the second column wraps round to column zero its objects are the first in the tables. The slots of any objects that are free have their flags cleared.
LoadMapObjects E08F LD A,($CE57) The map position.
E092 LD B,A B=A.
E093 LD HL,$0000 HL=00.
E096 LD DE,$5DB6 The column table.
E099 AND A Jump to LoadMapObjects_Column if A is zero.
E09A JR Z,LoadMapObjects_Column
LoadMapObjects_Count E09C LD A,(DE) Read DE.
E09D CALL AddAToHL Call AddAToHL.
E0A0 INC DE Advance DE.
E0A1 DJNZ LoadMapObjects_Count Decrease B and jump to LoadMapObjects_Count until none remain.
LoadMapObjects_Column E0A3 LD ($CE3A),HL The column of the map objects.
E0A6 ADD HL,HL Double HL.
E0A7 EX DE,HL Swap DE and HL.
E0A8 LD A,(HL) Read HL.
E0A9 LD ($DDF5),A Update the column counts.
E0AC INC HL Advance HL.
E0AD LD A,(HL) Read HL.
E0AE LD ($DDF6),A The object count of the next column.
E0B1 LD IX,$5E17 The terrain data.
E0B5 ADD IX,DE IX gains DE.
E0B7 LD DE,$5C94 The map table.
E0BA LD HL,($CE3A) Fetch the word at ScratchValues into HL.
E0BD ADD HL,DE HL gains DE.
E0BE LD A,($CE57) The map position.
E0C1 LD C,A C=A.
E0C2 LD A,($DDF5) The column counts.
E0C5 LD B,A B=A.
E0C6 CALL AddMapObjects Call AddMapObjects.
E0C9 LD A,($DDF7) The next column.
E0CC AND A Jump to LoadMapObjects_Second if A is not zero.
E0CD JR NZ,LoadMapObjects_Second
E0CF LD HL,$0000 HL=00.
E0D2 LD ($CE3A),HL The column of the map objects.
E0D5 LD HL,$5C94 The map table.
E0D8 LD IX,$5E17 The terrain data.
LoadMapObjects_Second E0DC LD C,A C=A.
E0DD LD A,($DDF6) The object count of the next column.
E0E0 LD B,A B=A.
E0E1 CALL AddMapObjects Call AddMapObjects.
E0E4 LD B,$04 B=04.
E0E6 LD IX,$A80B The map object slots.
Continue on to ClearFreeSlotFlags.
Prev: E062 Up: Map Next: E0EA