![]() |
Routines |
| Prev: BA5E | Up: Map | Next: BB0F |
|
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 C3D8.
|
||||
| DrawLevelObjects | BA70 | LD DE,$C59A | Draw each row with DrawBlockRow. | |
| BA73 | JR DrawLevelObjects_Start | |||
|
This entry point is used by the routines at ScrollViewDown and ScrollViewUp.
|
||||
| DrawLevelObjects_Second | BA75 | LD DE,$C717 | Test each row with TestBlockRow instead. | |
|
This entry point is used by the routine at CollectBottle.
|
||||
| DrawLevelObjects_Start | BA78 | LD ($C3D8),DE | Give that routine to the shape drawer. | |
| BA7C | LD ($C0DF),HL | Remember where DrawObject should return. | ||
|
Records at ObjectRecords whose fifth byte is set are copied, seven bytes each, into the table at CopiedRecords.
|
||||
| BA7F | LD A,($BD73) | There is nothing to copy when the count is zero. | ||
| BA82 | AND A | |||
| BA83 | JR Z,DrawLevelObjects_0 | |||
| BA85 | LD B,A | Start with none kept. | ||
| BA86 | LD C,$00 | |||
| BA88 | LD IY,$BD74 | Start at the first record. | ||
| BA8C | LD DE,$BDBB | The copies go into CopiedRecords. | ||
| DrawLevelObjects_Loop | BA8F | PUSH BC | Remember how many records remain. | |
| BA90 | LD A,(IY+$05) | Copy a record whose fifth byte is set. | ||
| BA93 | AND A | |||
| BA94 | JR Z,DrawLevelObjects_Empty | |||
| BA96 | PUSH IY | Take the seven bytes. | ||
| BA98 | POP HL | |||
| BA99 | LD BC,$0007 | |||
| BA9C | LDIR | Copy them. | ||
| BA9E | PUSH HL | Move on to the next source record. | ||
| BA9F | POP IY | |||
| BAA1 | POP BC | Count the copy. | ||
| BAA2 | INC C | |||
| BAA3 | JR DrawLevelObjects_Copied | |||
| DrawLevelObjects_Empty | BAA5 | LD BC,$0007 | Skip an empty record. | |
| BAA8 | ADD IY,BC | |||
| BAAA | POP BC | Bring the counts back. | ||
| DrawLevelObjects_Copied | BAAB | DJNZ DrawLevelObjects_Loop | Repeat for the remaining records. | |
| BAAD | LD A,C | Remember how many records were copied. | ||
| BAAE | LD ($BDBA),A | |||
| DrawLevelObjects_0 | BAB1 | LD HL,($5CE7) | Remember the horizontal view origin. | |
| BAB4 | LD ($B16A),HL | |||
| BAB7 | LD HL,$BBF7 | The next item record is the first one. | ||
| BABA | LD ($B201),HL | |||
| BABD | LD HL,$BD74 | The object records start at ObjectRecords. | ||
| BAC0 | LD ($BF42),HL | |||
| BAC3 | LD A,$CD | Draw the block bytes with a call. | ||
| BAC5 | LD ($C75D),A | |||
| BAC8 | LD HL,$C76D | The call draws the block bytes. | ||
| BACB | LD ($C75E),HL | |||
| BACE | LD HL,$FFE6 | Restore the shape index so that it masks nothing. | ||
| BAD1 | LD ($C1A0),HL | |||
| BAD4 | LD A,$1A | The row step-back is 1A. | ||
| BAD6 | LD ($B530),A | |||
| BAD9 | XOR A | Clear the item count and the record count. | ||
| BADA | LD ($BBF6),A | |||
| BADD | LD ($BD73),A | |||
| BAE0 | PUSH IX | Remember the entity. | ||
| BAE2 | LD C,$00 | Start at the first cell. | ||
| DrawLevelObjects_1 | BAE4 | PUSH BC | Remember the cell number. | |
| BAE5 | CALL GetCellPosition | Find the cell around the player. | ||
| BAE8 | CALL SetCarry | Accept the cell. | ||
| BAEB | JR NC,DrawLevelObjects_Next | Leave the cell when it is not accepted. | ||
| BAED | LD HL,($5CB9) | Find the cell position for the group. | ||
| BAF0 | CALL ClearCarry | |||
| BAF3 | JR C,DrawLevelObjects_Next | Leave the cell when it is rejected. | ||
| BAF5 | LD HL,($5CB9) | Find the group at that cell. | ||
| BAF8 | CALL FindGroup | |||
| BAFB | JR C,DrawLevelObjects_Next | Leave the cell when there is no group. | ||
| BAFD | LD ($5CDC),DE | Remember the group. | ||
| BB01 | CALL DrawGroupObjects | Draw the objects of the group. | ||
| DrawLevelObjects_Next | BB04 | POP BC | Bring the cell number back. | |
| BB05 | INC C | Step on by two cells. | ||
| BB06 | INC C | |||
| BB07 | LD A,C | Repeat for the nine cells. | ||
| BB08 | CP $12 | |||
| BB0A | JR NZ,DrawLevelObjects_1 | |||
| BB0C | POP IX | Restore the entity. | ||
| BB0E | RET | Return. | ||
| Prev: BA5E | Up: Map | Next: BB0F |