Prev: 57442 Up: Map Next: 57578
57487: 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 57487 LD A,(52823) The map position.
57490 LD B,A B=A.
57491 LD HL,0 HL=0.
57494 LD DE,23990 The column table.
57497 AND A Jump to LoadMapObjects_Column if A is zero.
57498 JR Z,LoadMapObjects_Column
LoadMapObjects_Count 57500 LD A,(DE) Read DE.
57501 CALL AddAToHL Call AddAToHL.
57504 INC DE Advance DE.
57505 DJNZ LoadMapObjects_Count Decrease B and jump to LoadMapObjects_Count until none remain.
LoadMapObjects_Column 57507 LD (52794),HL The column of the map objects.
57510 ADD HL,HL Double HL.
57511 EX DE,HL Swap DE and HL.
57512 LD A,(HL) Read HL.
57513 LD (56821),A Update the column counts.
57516 INC HL Advance HL.
57517 LD A,(HL) Read HL.
57518 LD (56822),A The object count of the next column.
57521 LD IX,24087 The terrain data.
57525 ADD IX,DE IX gains DE.
57527 LD DE,23700 The map table.
57530 LD HL,(52794) Fetch the word at ScratchValues into HL.
57533 ADD HL,DE HL gains DE.
57534 LD A,(52823) The map position.
57537 LD C,A C=A.
57538 LD A,(56821) The column counts.
57541 LD B,A B=A.
57542 CALL AddMapObjects Call AddMapObjects.
57545 LD A,(56823) The next column.
57548 AND A Jump to LoadMapObjects_Second if A is not zero.
57549 JR NZ,LoadMapObjects_Second
57551 LD HL,0 HL=0.
57554 LD (52794),HL The column of the map objects.
57557 LD HL,23700 The map table.
57560 LD IX,24087 The terrain data.
LoadMapObjects_Second 57564 LD C,A C=A.
57565 LD A,(56822) The object count of the next column.
57568 LD B,A B=A.
57569 CALL AddMapObjects Call AddMapObjects.
57572 LD B,4 B=4.
57574 LD IX,43019 The map object slots.
Continue on to ClearFreeSlotFlags.
Prev: 57442 Up: Map Next: 57578