Prev: 869B Up: Map Next: 87C9
876B: Scroll Line
Used by the routine at 869B.
ScrollLine 876B PUSH AF Push AF, BC, HL and DE on the stack.
876C PUSH BC
876D PUSH HL
876E PUSH DE
Set up the initial values.
876F LD HL,$4020 HL=$4020 (source).
8772 LD DE,$4000 DE=$4000 (target).
8775 LD A,$11 A=$11 (number of lines to shift).
8777 LD B,$00 B=$00.
ScrollLine_Loop 8779 PUSH HL Stash HL and DE on the stack.
877A PUSH DE
877B LD C,$08 C=$08 (byte counter).
ScrollLine_Line 877D PUSH HL Stash HL, DE and BC on the stack.
877E PUSH DE
877F PUSH BC
8780 LD C,$20 C=$20 (column counter - i.e. one row).
8782 LDIR Copy the row up one.
8784 POP BC Restore BC, DE and HL from the stack.
8785 POP DE
8786 POP HL
8787 INC H Increment the MSB of HL and DE by one to point to the next line down.
8788 INC D
8789 DEC C Decrease our byte counter in C by one.
878A JR NZ,ScrollLine_Line Jump back to ScrollLine_Line unless the whole line is moved (i.e. C is now zero).
878C POP DE Restore DE and HL from the stack. They are now at their values prior to the line move ScrollLine_Loop.
878D POP HL
878E LD C,$20 DE=DE + $20 and HL=HL + $20.
8790 ADD HL,BC
8791 EX DE,HL
8792 ADD HL,BC
8793 EX DE,HL
8794 PUSH AF Stash AF on the stack.
8795 LD A,D A=D.
8796 AND %00000111 Keep only bits 0-2.
8798 JR Z,ScrollLine_SkipDE Skip to ScrollLine_SkipDE if zero.
Handle changing the target between each screen buffer area.
879A LD A,D D=D + $07.
879B ADD A,$07
879D LD D,A
ScrollLine_SkipDE 879E LD A,H A=H.
879F AND %00000111 Keep only bits 0-2.
87A1 JR Z,ScrollLine_SkipHL Skip to ScrollLine_SkipHL if zero.
Handle changing the source between each screen buffer area.
87A3 LD A,H H=H + $07.
87A4 ADD A,$07
87A6 LD H,A
ScrollLine_SkipHL 87A7 POP AF Restore AF containing the line counter from the stack.
87A8 DEC A Decrease A by one.
87A9 JR NZ,ScrollLine_Loop Loop back to ScrollLine_Loop until the line counter is zero.
Handle the attributes.
87AB LD HL,$5820 Move the attributes up one character block.
87AE LD DE,$5800
87B1 LD BC,$0220
87B4 LDIR
This creates the indent.
87B6 LD B,$2A Set a counter for $2A spaces.
87B8 LD HL,$5020 Set the target screen location to $5020.
87BB LD C,$01 C=$01 (bit offset).
87BD LD A,$20 A=ASCII "SPACE".
ScrollLine_Spacing 87BF CALL PrintPropChar Call PrintPropChar.
87C2 DJNZ ScrollLine_Spacing Decrease counter by one and loop back to ScrollLine_Spacing until counter is zero.
Housekeeping and return.
87C4 POP DE Restore DE, HL, BC and AF off the stack.
87C5 POP HL
87C6 POP BC
87C7 POP AF
87C8 RET Return.
Prev: 869B Up: Map Next: 87C9