Prev: BB3A Up: Map Next: BB9F
BB3C: Draw Group Objects
Used by the routine at DrawLevelObjects.
Draws each of the objects of a group of a cell, using DrawObject. The group is at IY and the cell is at CellPosition. The first byte of a group has the number of objects in bits 0-4, and if bit 4 of it is set there is an extra byte, as described for GroupTable. The next two bytes and the extra byte make up a row of flags that is shifted left by one bit after each object, so that each object has a flag of its own.
Input
IY The address of the group
DrawGroupObjects BB3C LD HL,($5CB9) Fetch the position of the cell.
BB3F LD A,L Add the column of the cell to its row.
BB40 ADD A,H
BB41 LD ($BFA6),A Patch it into BFA6 as the depth of the objects.
Work out where the view starts, relative to the cell, and patch it into the drawing code.
BB44 LD HL,$8000 HL is 8000.
BB47 LD DE,($5CE7) Fetch the vertical origin of the view.
BB4B AND A Clear the carry flag.
BB4C SBC HL,DE Take the origin away.
BB4E LD ($BFBA),HL Patch the result into BFBA.
BB51 LD HL,$803F HL is 803F.
BB54 LD DE,($5CEE) Fetch the horizontal origin of the view.
BB58 AND A Clear the carry flag.
BB59 SBC HL,DE Take the origin away.
BB5B LD ($C061),HL Patch the result into C061.
Read the header of the group.
BB5E PUSH IY Put the address of the group onto the stack...
BB60 POP IX ...and take it off into IX.
BB62 LD A,(IX+$00) Fetch the first byte of the group.
BB65 AND %00011111 Keep the number of objects.
BB67 LD B,A Keep it in B.
BB68 LD H,(IX+$01) Fetch the first byte of the flags.
BB6B LD L,(IX+$02) Fetch the second byte of the flags.
BB6E INC IX Move past the first byte of the group...
BB70 INC IX ...and the first byte of the flags.
BB72 AND %00010000 Test whether the group has an extra byte of flags.
DrawGroupObjects_Header BB74 JR Z,DrawGroupObjects_Objects Jump to DrawGroupObjects_Objects if there is no extra byte, with A as zero.
BB76 LD A,(IX+$01) Fetch the extra byte of flags.
BB79 INC IX Move past the extra byte.
DrawGroupObjects_Objects BB7B LD ($BB8E),HL Patch the flags into the instructions that load them after each object...
BB7E LD ($BB8C),A ...including the extra byte.
Draw each object, and then move the row of flags along by one.
DrawGroupObjects_Loop BB81 INC IX Move onto the first byte of the object.
BB83 PUSH BC Save the number of objects left.
BB84 CALL DrawObject Draw the object.
BB87 INC IX Move past the second byte of the object...
BB89 INC IX ...and the third.
BB8B LD A,$00 Fetch the extra byte of flags, which is patched in.
BB8D LD HL,$0000 Fetch the other two bytes of flags, which are patched in.
BB90 RLA Shift the extra byte left...
BB91 RL L ...then the second byte...
BB93 RL H ...and then the first byte.
BB95 LD ($BB8C),A Patch the extra byte back in.
BB98 LD ($BB8E),HL Patch the other two bytes back in.
BB9B POP BC Restore the number of objects left.
BB9C DJNZ DrawGroupObjects_Loop Decrease the number of objects and loop back to DrawGroupObjects_Loop until all of them have been drawn.
BB9E RET Return.
Prev: BB3A Up: Map Next: BB9F