Prev: 47930 Up: Map Next: 48031
47932: 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 47932 LD HL,(23737) Fetch the position of the cell.
47935 LD A,L Add the column of the cell to its row.
47936 ADD A,H
47937 LD (49062),A Patch it into 49062 as the depth of the objects.
Work out where the view starts, relative to the cell, and patch it into the drawing code.
47940 LD HL,32768 HL is 32768.
47943 LD DE,(23783) Fetch the vertical origin of the view.
47947 AND A Clear the carry flag.
47948 SBC HL,DE Take the origin away.
47950 LD (49082),HL Patch the result into 49082.
47953 LD HL,32831 HL is 32831.
47956 LD DE,(23790) Fetch the horizontal origin of the view.
47960 AND A Clear the carry flag.
47961 SBC HL,DE Take the origin away.
47963 LD (49249),HL Patch the result into 49249.
Read the header of the group.
47966 PUSH IY Put the address of the group onto the stack...
47968 POP IX ...and take it off into IX.
47970 LD A,(IX+0) Fetch the first byte of the group.
47973 AND %00011111 Keep the number of objects.
47975 LD B,A Keep it in B.
47976 LD H,(IX+1) Fetch the first byte of the flags.
47979 LD L,(IX+2) Fetch the second byte of the flags.
47982 INC IX Move past the first byte of the group...
47984 INC IX ...and the first byte of the flags.
47986 AND %00010000 Test whether the group has an extra byte of flags.
DrawGroupObjects_Header 47988 JR Z,DrawGroupObjects_Objects Jump to DrawGroupObjects_Objects if there is no extra byte, with A as zero.
47990 LD A,(IX+1) Fetch the extra byte of flags.
47993 INC IX Move past the extra byte.
DrawGroupObjects_Objects 47995 LD (48014),HL Patch the flags into the instructions that load them after each object...
47998 LD (48012),A ...including the extra byte.
Draw each object, and then move the row of flags along by one.
DrawGroupObjects_Loop 48001 INC IX Move onto the first byte of the object.
48003 PUSH BC Save the number of objects left.
48004 CALL DrawObject Draw the object.
48007 INC IX Move past the second byte of the object...
48009 INC IX ...and the third.
48011 LD A,0 Fetch the extra byte of flags, which is patched in.
48013 LD HL,0 Fetch the other two bytes of flags, which are patched in.
48016 RLA Shift the extra byte left...
48017 RL L ...then the second byte...
48019 RL H ...and then the first byte.
48021 LD (48012),A Patch the extra byte back in.
48024 LD (48014),HL Patch the other two bytes back in.
48027 POP BC Restore the number of objects left.
48028 DJNZ DrawGroupObjects_Loop Decrease the number of objects and loop back to DrawGroupObjects_Loop until all of them have been drawn.
48030 RET Return.
Prev: 47930 Up: Map Next: 48031