Prev: B82B Up: Map Next: B8C4
B84B: Draw a room graphic
Used by the routines at B3C3, B82B, B952, BA6E, BAB4, E3FD, E468 and EDF7.
Input
HL The address of the graphic to draw
D The y co-ordinate
E The x co-ordinate
B84B LD A,(HL) Get the next byte.
B84C INC HL Move to the next position in the buffer.
B84D CP $80 Is the byte less than 80?
B84F JR C,$B8BD Jump forward if so.
B851 CP $FF Is the byte the end marker FF?
B853 RET Z Return if so.
B854 CP $FE Is this a change attribute marker FE?
B856 JR NZ,$B85C Jump forward if not.
B858 LD C,(HL) Put the next byte in C.
B859 INC HL Move to the next position in the buffer.
B85A JR $B84B Jump back to look at the rest of the data.
B85C CP $A8 Is the byte less than A8?
B85E JR C,$B8BD Jump forward if so.
B860 CP $E8 Is the byte greater than E8?
B862 JR NC,$B86E Jump forward if so.
Move to a new position.
B864 SUB $C8 Subtract C8 to get the actual x co-ordinate.
B866 ADD A,E
B867 LD E,A
B868 LD A,D Add the next byte to the current y co-ordinate.
B869 ADD A,(HL)
B86A LD D,A
B86B INC HL Move to the next position in the buffer.
B86C JR $B84B Jump back to draw some more.
Check to see if this is an address marker.
B86E CP $FB Is the byte an address marker? (FB)
B870 JR NZ,$B87E Jump forward if not.
Change the base address.
B872 LD A,(HL) Get the low byte.
B873 LD ($B7E9),A Set this in the printing routine.
B876 INC HL Move to the next position in the buffer.
B877 LD A,(HL) Get the high byte.
B878 LD ($B7EA),A Set this in the printing routine.
B87B INC HL Move to the next position in the buffer.
B87C JR $B84B Jump back to draw some more.
Check some more control bytes.
B87E CP $F1 Is the a "move a column" marker? (F1)
B880 JR Z,$B8C0 Jump if so.
B882 CP $F3 Is this a "sub block" marker? (F3)
B884 JR NZ,$B88C Jump if not.
Chain to block data at another address.
B886 LD A,(HL) Put the new block marker in HL.
B887 INC HL
B888 LD H,(HL)
B889 LD L,A
B88A JR $B84B Jump back to draw some more.
Check some more control bytes.
B88C LD B,(HL) Get the number of rows or columns in B.
B88D INC HL Move to the next position in the buffer.
B88E CP $F0 Is this a "row repeat" instruction? (F0)
B890 JR NZ,$B89C Move forward if not.
Repeat this graphic for a number of rows.
B892 LD A,(HL) Get the next byte.
B893 INC HL Move to the next position in the buffer.
B894 CALL $B7BA Put the graphic on screen.
B897 INC D Move to the next row.
B898 DJNZ $B894 Repeat while there are more rows.
B89A JR $B84B Jump back to draw some more.
Check some more control bytes.
B89C CP $F2 Is this a "block column repeat" instruction? (F2)
B89E JR NZ,$B8B2 Jump foward if not.
Repeat this graphic for a number of pairs of columns.
B8A0 LD A,(HL) Get the next byte.
B8A1 INC HL Move to the next position in the buffer.
B8A2 CALL $B7BA Put the graphic on screen.
B8A5 LD A,(HL) Get the next byte.
B8A6 INC E Move to the next column.
B8A7 CALL $B7BA Put the graphic on screen.
B8AA INC E Move to the next column.
B8AB DEC HL Move back in the buffer.
B8AC DJNZ $B8A0 Repeat until all columns are drawn.
B8AE INC HL Move forward to the correct position in the buffer.
B8AF INC HL
B8B0 JR $B84B Jump back to draw some more.
Otherwise, the instruction must be "column repeat" (FD), so repeat this graphic for a number of columns.
B8B2 LD A,(HL) Get the next byte.
B8B3 INC HL Move to the next position in the buffer.
B8B4 CALL $B7BA Put the graphic on screen.
B8B7 INC E Move forward a column.
B8B8 DJNZ $B8B4 Loop while there is more to draw.
B8BA JP $B84B Otherwise jump back to draw some more.
Simple instruction - display a graphic
B8BD CALL $B7BA Put the graphic on screen.
B8C0 INC E Move forward a column.
B8C1 JP $B84B Jump back to draw some more.
Prev: B82B Up: Map Next: B8C4