Prev: 47710 Up: Map Next: 47887
47728: Draw Level Objects
Used by the routines at BuildView, ScrollViewLeft and ScrollViewRight.
Draws the objects of the level that are near the player. The nine cells around the position of the player are tried in turn, and the objects of the group in each cell are drawn with DrawGroupObjects. There are two entry points, which choose between two versions of the drawing code that is patched at 50136.
DrawLevelObjects 47728 LD DE,50586 Draw each row with DrawBlockRow.
47731 JR DrawLevelObjects_Start
This entry point is used by the routines at ScrollViewDown and ScrollViewUp.
DrawLevelObjects_Second 47733 LD DE,50967 Test each row with TestBlockRow instead.
This entry point is used by the routine at CollectBottle.
DrawLevelObjects_Start 47736 LD (50136),DE Give that routine to the shape drawer.
47740 LD (49375),HL Remember where DrawObject should return.
Records at ObjectRecords whose fifth byte is set are copied, seven bytes each, into the table at CopiedRecords.
47743 LD A,(48499) There is nothing to copy when the count is zero.
47746 AND A
47747 JR Z,DrawLevelObjects_0
47749 LD B,A Start with none kept.
47750 LD C,0
47752 LD IY,48500 Start at the first record.
47756 LD DE,48571 The copies go into CopiedRecords.
DrawLevelObjects_Loop 47759 PUSH BC Remember how many records remain.
47760 LD A,(IY+5) Copy a record whose fifth byte is set.
47763 AND A
47764 JR Z,DrawLevelObjects_Empty
47766 PUSH IY Take the seven bytes.
47768 POP HL
47769 LD BC,7
47772 LDIR Copy them.
47774 PUSH HL Move on to the next source record.
47775 POP IY
47777 POP BC Count the copy.
47778 INC C
47779 JR DrawLevelObjects_Copied
DrawLevelObjects_Empty 47781 LD BC,7 Skip an empty record.
47784 ADD IY,BC
47786 POP BC Bring the counts back.
DrawLevelObjects_Copied 47787 DJNZ DrawLevelObjects_Loop Repeat for the remaining records.
47789 LD A,C Remember how many records were copied.
47790 LD (48570),A
DrawLevelObjects_0 47793 LD HL,(23783) Remember the horizontal view origin.
47796 LD (45418),HL
47799 LD HL,48119 The next item record is the first one.
47802 LD (45569),HL
47805 LD HL,48500 The object records start at ObjectRecords.
47808 LD (48962),HL
47811 LD A,205 Draw the block bytes with a call.
47813 LD (51037),A
47816 LD HL,51053 The call draws the block bytes.
47819 LD (51038),HL
47822 LD HL,65510 Restore the shape index so that it masks nothing.
47825 LD (49568),HL
47828 LD A,26 The row step-back is 26.
47830 LD (46384),A
47833 XOR A Clear the item count and the record count.
47834 LD (48118),A
47837 LD (48499),A
47840 PUSH IX Remember the entity.
47842 LD C,0 Start at the first cell.
DrawLevelObjects_1 47844 PUSH BC Remember the cell number.
47845 CALL GetCellPosition Find the cell around the player.
47848 CALL SetCarry Accept the cell.
47851 JR NC,DrawLevelObjects_Next Leave the cell when it is not accepted.
47853 LD HL,(23737) Find the cell position for the group.
47856 CALL ClearCarry
47859 JR C,DrawLevelObjects_Next Leave the cell when it is rejected.
47861 LD HL,(23737) Find the group at that cell.
47864 CALL FindGroup
47867 JR C,DrawLevelObjects_Next Leave the cell when there is no group.
47869 LD (23772),DE Remember the group.
47873 CALL DrawGroupObjects Draw the objects of the group.
DrawLevelObjects_Next 47876 POP BC Bring the cell number back.
47877 INC C Step on by two cells.
47878 INC C
47879 LD A,C Repeat for the nine cells.
47880 CP 18
47882 JR NZ,DrawLevelObjects_1
47884 POP IX Restore the entity.
47886 RET Return.
Prev: 47710 Up: Map Next: 47887