Prev: 9B14 Up: Map Next: 9BA2
9B5D: Draw Graphic Rotated Right
The handler of DrawGraphic for a graphic that is turned a quarter turn clockwise. This is the same as DrawGraphic_Transposed, except that it starts from the last row and works up using SubtractWidthFromAddress.
DrawGraphic_RotatedRight 9B5D POP BC Restore the attribute and graphic ID from the stack.
9B5E CALL GetBlendInstruction Call GetBlendInstruction to get the instruction to mix the graphic with the screen.
9B61 LD ($9B88),A Write it over the instruction at 9B88.
9B64 CALL GetGraphicDetails Call GetGraphicDetails to get the details of the graphic.
9B67 LD A,B Fetch the width.
9B68 EXX Switch to the shadow registers.
9B69 LD B,A Keep the number of columns in B'.
9B6A LD L,$80 L'=80 (the mask for the first column).
9B6C EXX Switch back to the main registers.
9B6D CALL FindLastRow Call FindLastRow to move on to the last row.
DrawGraphic_RotatedRight_Row 9B70 PUSH BC Stash the width and height on the stack.
9B71 PUSH DE Stash the position in the graphic on the stack.
9B72 PUSH HL Stash the screen address on the stack.
DrawGraphic_RotatedRight_Bit 9B73 LD A,(DE) Fetch the byte of the graphic.
9B74 EXX Switch to the shadow registers.
9B75 AND L Mask the column.
9B76 JR Z,DrawGraphic_RotatedRight_Shift Jump to DrawGraphic_RotatedRight_Shift if the bit is not set.
9B78 SCF Set the carry flag.
DrawGraphic_RotatedRight_Shift 9B79 RL H Shift the bit into H'.
9B7B EXX Switch back to the main registers.
9B7C CALL SubtractWidthFromAddress Call SubtractWidthFromAddress to move up to the previous row of the graphic.
9B7F DEC C Decrease the height by one.
9B80 LD A,C Fetch the number of rows left.
9B81 AND %00000111 Keep only bits 0-2.
9B83 JR NZ,DrawGraphic_RotatedRight_Bit Jump to DrawGraphic_RotatedRight_Bit until eight bits have been gathered.
9B85 EXX Switch to the shadow registers.
9B86 LD A,H Fetch the byte that was built from the column.
9B87 EXX Switch back to the main registers.
9B88 NOP This is replaced by an instruction that mixes A with the screen.
9B89 LD (HL),A Write A to the screen.
9B8A INC L Move HL on to the next byte.
9B8B LD A,C Fetch the number of rows left.
9B8C AND A Jump to DrawGraphic_RotatedRight_Bit if there are more bytes in this row of the screen.
9B8D JR NZ,DrawGraphic_RotatedRight_Bit
9B8F POP HL Restore the screen address from the stack.
9B90 CALL ScreenPosition1PixelAbove Call ScreenPosition1PixelAbove to move up a line.
9B93 POP DE Restore the position in the graphic from the stack.
9B94 POP BC Restore the width and height from the stack.
9B95 EXX Switch to the shadow registers.
9B96 RRC L Move the mask on to the next column.
9B98 EXX Switch back to the main registers.
9B99 JR NC,DrawGraphic_RotatedRight_Row Jump to DrawGraphic_RotatedRight_Row if there are more columns in this byte.
9B9B EXX Switch to the shadow registers.
9B9C DEC B Decrease the number of columns by one.
9B9D EXX Switch back to the main registers.
9B9E RET Z Return if all of the columns have been drawn.
9B9F INC DE Move DE on to the next byte.
9BA0 JR DrawGraphic_RotatedRight_Row Jump back to DrawGraphic_RotatedRight_Row to draw the next row of the graphic.
Prev: 9B14 Up: Map Next: 9BA2