Prev: 40168 Up: Map Next: 40217
40178: Draw Top Left Corner Picture
Used by the routine at Draw_Special_Room_Parts.
Draws a picture of a corner of the frame of a special room at x position 0 and y position 16 which is the top left corner. The picture is three bytes wide and 32 lines high, and starts with its attributes (see Room_Graphics).
The entries at Draw_Top_Right_Corner_Picture, Draw_Bottom_Left_Corner_Picture and Draw_Bottom_Right_Corner_Picture draw the other three corners, using the shared code from Draw_Corner_Picture onwards.
Input
DE Address of the picture
Draw_Top_Left_Corner_Picture 40178 LD HL,4096 Set the x position to 0 and the y position to 16 (4096).
Copy the attributes of the picture, four rows of three cells.
Draw_Corner_Picture 40181 PUSH HL Stash the position on the stack.
40182 CALL AttributeAddress Convert the position into an attribute buffer address.
40185 LD C,4 Set the number of rows to 4.
Draw_Top_Left_Corner_Picture_Row_Loop 40187 PUSH HL Stash the address of the start of the row on the stack.
40188 LD B,3 Set the number of cells in a row to 3.
Draw_Top_Left_Corner_Picture_Cell_Loop 40190 LD A,(DE) Fetch an attribute from the picture.
40191 LD (HL),A Write it to the cell.
40192 INC DE Move on to the next attribute of the picture.
40193 INC L Move on to the next cell.
40194 DJNZ Draw_Top_Left_Corner_Picture_Cell_Loop Decrease the cell counter and loop back until the row is copied.
40196 POP HL Restore the address of the start of the row.
40197 LD A,L Fetch the low byte of the address.
40198 ADD A,32 Add the size of a row of cells.
40200 LD L,A Store the low byte of the address.
40201 LD A,H Fetch the high byte of the address.
40202 ADC A,0 Add the carry.
40204 LD H,A Store the high byte of the address.
40205 DEC C Decrease the row counter and loop back until all of the rows of attributes are copied.
40206 JR NZ,Draw_Top_Left_Corner_Picture_Row_Loop
40208 POP HL Restore the position from the stack.
40209 CALL ScreenAddress Convert the position into a screen address.
40212 LD C,32 Set the number of lines to 32.
40214 JP Draw_Three_Byte_Lines Jump to Draw_Three_Byte_Lines to copy the pixels.
Prev: 40168 Up: Map Next: 40217