Prev: 99E5 Up: Map Next: 9A50
9A0A: Draw Graphic Rotated Left
The handler of DrawGraphic for a graphic that is turned a quarter turn anti-clockwise. Each row of the screen is made from a column of the graphic, from the right-hand side to the left-hand side. The bits for each byte come from eight rows of the graphic, which are gathered up in H' using the mask in L'.
DrawGraphic_RotatedLeft 9A0A POP BC Restore the attribute and graphic ID from the stack.
9A0B CALL GetBlendInstruction Call GetBlendInstruction to get the instruction to mix the graphic with the screen.
9A0E LD ($9A36),A Write it over the instruction at 9A36.
9A11 CALL GetGraphicDetails Call GetGraphicDetails to get the details of the graphic.
9A14 LD A,B Fetch the width.
9A15 EXX Switch to the shadow registers.
9A16 LD L,$01 L'=01 (the mask for the first column).
9A18 LD B,A Keep the number of columns in B'.
9A19 EXX Switch back to the main registers.
9A1A CALL AddWidthToAddress Call AddWidthToAddress to move DE on to the second row.
9A1D DEC DE Move DE back to the last byte of the first row.
DrawGraphic_RotatedLeft_Row 9A1E PUSH BC Stash the width and height on the stack.
9A1F PUSH DE Stash the position in the graphic on the stack.
9A20 PUSH HL Stash the screen address on the stack.
DrawGraphic_RotatedLeft_Bit 9A21 LD A,(DE) Fetch the byte of the graphic.
9A22 EXX Switch to the shadow registers.
9A23 AND L Mask the column.
9A24 JR Z,DrawGraphic_RotatedLeft_Shift Jump to DrawGraphic_RotatedLeft_Shift if the bit is not set.
9A26 SCF Set the carry flag.
DrawGraphic_RotatedLeft_Shift 9A27 RL H Shift the bit into H'.
9A29 EXX Switch back to the main registers.
9A2A CALL AddWidthToAddress Call AddWidthToAddress to move down to the next row of the graphic.
9A2D DEC C Decrease the height by one.
9A2E LD A,C Fetch the number of rows left.
9A2F AND %00000111 Keep only bits 0-2.
9A31 JR NZ,DrawGraphic_RotatedLeft_Bit Jump to DrawGraphic_RotatedLeft_Bit until eight bits have been gathered.
9A33 EXX Switch to the shadow registers.
9A34 LD A,H Fetch the byte that was built from the column.
9A35 EXX Switch back to the main registers.
9A36 NOP This is replaced by an instruction that mixes A with the screen.
9A37 LD (HL),A Write A to the screen.
9A38 INC L Move HL on to the next byte.
9A39 LD A,C Fetch the number of rows left.
9A3A AND A Jump to DrawGraphic_RotatedLeft_Bit if there are more bytes in this row of the screen.
9A3B JR NZ,DrawGraphic_RotatedLeft_Bit
9A3D POP HL Restore the screen address from the stack.
9A3E CALL ScreenPosition1PixelAbove Call ScreenPosition1PixelAbove to move up a line.
9A41 POP DE Restore the position in the graphic from the stack.
9A42 POP BC Restore the width and height from the stack.
9A43 EXX Switch to the shadow registers.
9A44 RLC L Move the mask on to the next column.
9A46 EXX Switch back to the main registers.
9A47 JR NC,DrawGraphic_RotatedLeft_Row Jump to DrawGraphic_RotatedLeft_Row if there are more columns in this byte.
9A49 EXX Switch to the shadow registers.
9A4A DEC B Decrease the number of columns by one.
9A4B EXX Switch back to the main registers.
9A4C RET Z Return if all of the columns have been drawn.
9A4D DEC DE Move DE back to the previous byte.
9A4E JR DrawGraphic_RotatedLeft_Row Jump back to DrawGraphic_RotatedLeft_Row to draw the next row of the graphic.
Prev: 99E5 Up: Map Next: 9A50