Prev: 03545 Up: Map Next: 03652
03582: THE 'SCROLLING' SUBROUTINE
Used by the routine at PO_SCR.
The number of lines of the display that are to be scrolled has to be held on entry to the main subroutine in the B register.
CL_SC_ALL 03582 LD B,23 The entry point after 'scroll?'
This entry point is used by the routine at PO_SCR.
The main entry point - from above and when scrolling for INPUT...AT.
CL_SCROLL 03584 CALL CL_ADDR Find the starting address of the line.
03587 LD C,8 There are eight pixel lines to a complete line.
Now enter the main scrolling loop. The B register holds the number of the top line to be scrolled, the HL register pair the starting address in the display area of this line and the C register the pixel line counter.
CL_SCR_1 03589 PUSH BC Save both counters.
03590 PUSH HL Save the starting address.
03591 LD A,B Jump forward unless dealing at the present moment with a 'third' of the display.
03592 AND 7
03594 LD A,B
03595 JR NZ,CL_SCR_3
The pixel lines of the top lines of the 'thirds' of the display have to be moved across the 2K boundaries. (Each 'third' is 2K.)
CL_SCR_2 03597 EX DE,HL The result of this manipulation is to leave HL unchanged and DE pointing to the required destination.
03598 LD HL,63712
03601 ADD HL,DE
03602 EX DE,HL
03603 LD BC,32 There are 32 characters.
03606 DEC A Decrease the counter as one line is being dealt with.
03607 LDIR Now move the thirty two bytes.
The pixel lines within the 'thirds' can now be scrolled. The A register holds, on the first pass, 1 to 7, 9 to 15, or 17 to 23.
CL_SCR_3 03609 EX DE,HL Again DE is made to point to the required destination, this time only thirty two locations away.
03610 LD HL,65504
03613 ADD HL,DE
03614 EX DE,HL
03615 LD B,A Save the line number in B.
03616 AND 7 Now find how many characters there are remaining in the 'third'.
03618 RRCA
03619 RRCA
03620 RRCA
03621 LD C,A Pass the 'character total' to the C register.
03622 LD A,B Fetch the line number.
03623 LD B,0 BC holds the 'character total' and a pixel line from each of the characters is 'scrolled'.
03625 LDIR
03627 LD B,7 Now prepare to increment the address to jump across a 'third' boundary.
03629 ADD HL,BC Increase HL by 1792.
03630 AND 248 Jump back if there are any 'thirds' left to consider.
03632 JR NZ,CL_SCR_2
Now find if the loop has been used eight times - once for each pixel line.
03634 POP HL Fetch the original address.
03635 INC H Address the next pixel line.
03636 POP BC Fetch the counters.
03637 DEC C Decrease the pixel line counter and jump back unless eight lines have been moved.
03638 JR NZ,CL_SCR_1
Next the attribute bytes are scrolled. Note that the B register still holds the number of lines to be scrolled and the C register holds zero.
03640 CALL CL_ATTR The required address in the attribute area and the number of characters in B lines are found.
03643 LD HL,65504 The displacement for all the attribute bytes is thirty two locations away.
03646 ADD HL,DE
03647 EX DE,HL
03648 LDIR The attribute bytes are 'scrolled'.
It remains now to clear the bottom line of the display.
03650 LD B,1 The B register is loaded with 1 and CL_LINE is entered.
Prev: 03545 Up: Map Next: 03652