Prev: DBB7 Up: Map Next: DC47
DBFD: Draw Mirrored Rows From Edge
Used by the routine at JumpToDrawingRoutine.
Draws the rows of a piece of a slope back to front, two bytes wide, going up the screen two pixel rows at a time, starting from the second column of the row (see DrawSlopeRowsFromEdge). Each byte of the picture is reversed using the table at F900 (B is set to F9). The jumps at DrawMirroredRowsFromEdge_PatchFirst and DrawMirroredRowsFromEdge_PatchSecond are changed by SetUpPiece to skip bytes when only part of the piece is to be drawn.
Input
A Number of pairs of pixel rows to draw
HL Screen address
SP Address of the picture
DrawMirroredRowsFromEdge DBFD EXX Switch to the alternate registers.
DBFE LD B,A B=A.
DBFF EXX Switch to the alternate registers.
DC00 LD A,L A=L.
DC01 INC A Advance A.
DC02 INC A Advance A.
DC03 AND %11100000 Keep the bits of A that are set in E0.
DC05 INC A Advance A.
DC06 LD L,A L=A.
DC07 LD B,$F9 B=F9.
DC09 EXX Switch to the alternate registers.
DC0A INC SP Advance SP.
DrawMirroredRowsFromEdge_PatchFirst DC0B JR DrawMirroredRowsFromEdge_PatchFirst Skip ahead by the displacement at DC0C.
DC0D INC SP Advance SP.
DrawMirroredRowsFromEdge_Loop DC0E EXX Switch to the alternate registers.
DC0F POP DE Bring DE back off the stack.
DC10 LD C,E C=E.
DC11 LD A,(BC) Read BC.
DC12 LD (HL),A Write A where HL points.
DrawMirroredRowsFromEdge_PatchSecond DC13 JR DrawMirroredRowsFromEdge_PatchSecond Skip ahead by the displacement at DC14.
DC15 INC L Advance L.
DC16 LD C,D C=D.
DC17 LD A,(BC) Read BC.
DC18 LD (HL),A Write A where HL points.
DC19 DEC H Step H back.
DC1A POP DE Bring DE back off the stack.
DC1B LD C,E C=E.
DC1C LD A,(BC) Read BC.
DC1D LD (HL),A Write A where HL points.
DC1E DEC L Step L back.
DrawMirroredRowsFromEdge_Second DC1F LD C,D C=D.
DC20 LD A,(BC) Read BC.
DC21 LD (HL),A Write A where HL points.
DrawMirroredRowsFromEdge_PopWord DC22 POP DE Bring DE back off the stack.
DC23 DEC H Step H back.
DC24 LD A,H A=H.
DC25 INC A Advance A.
DC26 AND %00000111 Keep the bits of A that are set in 07.
DC28 JR NZ,DrawMirroredRowsFromEdge_Next Jump to DrawMirroredRowsFromEdge_Next if the zero flag is clear.
DC2A LD A,L A=L.
DC2B SUB $20 Subtract 20 from A.
DC2D LD L,A L=A.
DC2E JR C,DrawMirroredRowsFromEdge_Next Jump to DrawMirroredRowsFromEdge_Next if the carry flag is set.
DC30 LD A,H A=H.
DC31 ADD A,$08 Add 08 to A.
DC33 LD H,A H=A.
DrawMirroredRowsFromEdge_Next DC34 EXX Switch to the alternate registers.
DC35 DJNZ DrawMirroredRowsFromEdge_Loop Decrease B and jump to DrawMirroredRowsFromEdge_Loop until none remain.
DC37 EXX Switch to the alternate registers.
DC38 JP FinishStep Jump to FinishStep.
DC3B DEC H Step H back.
DC3C JP DrawMirroredRowsFromEdge_Second Jump to DrawMirroredRowsFromEdge_Second.
DC3F DEC H Step H back.
DC40 LD C,D C=D.
DC41 LD A,(BC) Read BC.
DC42 LD (HL),A Write A where HL points.
DC43 POP DE Bring DE back off the stack.
DC44 JP DrawMirroredRowsFromEdge_PopWord Jump to DrawMirroredRowsFromEdge_PopWord.
Prev: DBB7 Up: Map Next: DC47