Prev: 56247 Up: Map Next: 56391
56317: 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 63744 (B is set to 249). 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 56317 EXX Switch to the alternate registers.
56318 LD B,A B=A.
56319 EXX Switch to the alternate registers.
56320 LD A,L A=L.
56321 INC A Advance A.
56322 INC A Advance A.
56323 AND %11100000 Keep the bits of A that are set in 224.
56325 INC A Advance A.
56326 LD L,A L=A.
56327 LD B,249 B=249.
56329 EXX Switch to the alternate registers.
56330 INC SP Advance SP.
DrawMirroredRowsFromEdge_PatchFirst 56331 JR DrawMirroredRowsFromEdge_PatchFirst Skip ahead by the displacement at 56332.
56333 INC SP Advance SP.
DrawMirroredRowsFromEdge_Loop 56334 EXX Switch to the alternate registers.
56335 POP DE Bring DE back off the stack.
56336 LD C,E C=E.
56337 LD A,(BC) Read BC.
56338 LD (HL),A Write A where HL points.
DrawMirroredRowsFromEdge_PatchSecond 56339 JR DrawMirroredRowsFromEdge_PatchSecond Skip ahead by the displacement at 56340.
56341 INC L Advance L.
56342 LD C,D C=D.
56343 LD A,(BC) Read BC.
56344 LD (HL),A Write A where HL points.
56345 DEC H Step H back.
56346 POP DE Bring DE back off the stack.
56347 LD C,E C=E.
56348 LD A,(BC) Read BC.
56349 LD (HL),A Write A where HL points.
56350 DEC L Step L back.
DrawMirroredRowsFromEdge_Second 56351 LD C,D C=D.
56352 LD A,(BC) Read BC.
56353 LD (HL),A Write A where HL points.
DrawMirroredRowsFromEdge_PopWord 56354 POP DE Bring DE back off the stack.
56355 DEC H Step H back.
56356 LD A,H A=H.
56357 INC A Advance A.
56358 AND %00000111 Keep the bits of A that are set in 7.
56360 JR NZ,DrawMirroredRowsFromEdge_Next Jump to DrawMirroredRowsFromEdge_Next if the zero flag is clear.
56362 LD A,L A=L.
56363 SUB 32 Subtract 32 from A.
56365 LD L,A L=A.
56366 JR C,DrawMirroredRowsFromEdge_Next Jump to DrawMirroredRowsFromEdge_Next if the carry flag is set.
56368 LD A,H A=H.
56369 ADD A,8 Add 8 to A.
56371 LD H,A H=A.
DrawMirroredRowsFromEdge_Next 56372 EXX Switch to the alternate registers.
56373 DJNZ DrawMirroredRowsFromEdge_Loop Decrease B and jump to DrawMirroredRowsFromEdge_Loop until none remain.
56375 EXX Switch to the alternate registers.
56376 JP FinishStep Jump to FinishStep.
56379 DEC H Step H back.
56380 JP DrawMirroredRowsFromEdge_Second Jump to DrawMirroredRowsFromEdge_Second.
56383 DEC H Step H back.
56384 LD C,D C=D.
56385 LD A,(BC) Read BC.
56386 LD (HL),A Write A where HL points.
56387 POP DE Bring DE back off the stack.
56388 JP DrawMirroredRowsFromEdge_PopWord Jump to DrawMirroredRowsFromEdge_PopWord.
Prev: 56247 Up: Map Next: 56391