Prev: 0C41 Up: Map Next: 0D4D
0C55: THE 'TEST FOR SCROLL' SUBROUTINE
Used by the routines at PO_ENTER, PO_TV_2 and PO_ANY.
This subroutine is called whenever there might be the need to scroll the display. This occurs on three occasions:
  • when handling a 'carriage return' character
  • when using AT in an INPUT line
  • when the current line is full and the next line has to be used
Input
B Current line number
Output
PO_SCR 0C55 BIT 1,(IY+$01) Return immediately if the printer is being used (bit 1 of FLAGS set).
0C59 RET NZ
0C5A LD DE,$0DD9 Pre-load the machine stack with the address of CL_SET.
0C5D PUSH DE
0C5E LD A,B Transfer the line number.
0C5F BIT 0,(IY+$02) Jump forward if considering 'INPUT ... AT ...' (bit 0 of TV-FLAG set).
0C63 JP NZ,PO_SCR_4
0C66 CP (IY+$31) Return, via CL_SET, if the line number is greater than the value of DF-SZ; give report 5 if it is less; otherwise continue.
0C69 JR C,REPORT_5
0C6B RET NZ
0C6C BIT 4,(IY+$02) Jump forward unless dealing with an 'automatic listing' (bit 4 of TV-FLAG set).
0C70 JR Z,PO_SCR_2
0C72 LD E,(IY+$2D) Fetch the line counter from BREG.
0C75 DEC E Decrease this counter.
0C76 JR Z,PO_SCR_3 Jump forward if the listing is to be scrolled.
0C78 LD A,$00 Otherwise open channel 'K', restore the stack pointer, flag that the automatic listing has finished (reset bit 4 of TV-FLAG) and return via CL_SET.
0C7A CALL CHAN_OPEN
0C7D LD SP,($5C3F)
0C81 RES 4,(IY+$02)
0C85 RET
This entry point is used by the routine at PO_TV_2.
Report 5 - Out of screen.
REPORT_5 0C86 RST $08 Call the error handling routine.
0C87 DEFB $04
Now consider if the prompt 'scroll?' is required.
PO_SCR_2 0C88 DEC (IY+$52) Decrease the scroll counter (SCR-CT) and proceed to give the prompt only if it becomes zero.
0C8B JR NZ,PO_SCR_3
Proceed to give the prompt message.
0C8D LD A,$18 The scroll counter (SCR-CT) is reset.
0C8F SUB B
0C90 LD ($5C8C),A
0C93 LD HL,($5C8F) The current values of ATTR-T and MASK-T are saved.
0C96 PUSH HL
0C97 LD A,($5C91) The current value of P-FLAG is saved.
0C9A PUSH AF
0C9B LD A,$FD Channel 'K' is opened.
0C9D CALL CHAN_OPEN
0CA0 XOR A The message 'scroll?' is message '0'. This message is now printed.
0CA1 LD DE,$0CF8
0CA4 CALL PO_MSG
0CA7 SET 5,(IY+$02) Signal 'clear the lower screen after a keystroke' (set bit 5 of TV-FLAG).
0CAB LD HL,$5C3B This is FLAGS.
0CAE SET 3,(HL) Signal 'L mode'.
0CB0 RES 5,(HL) Signal 'no key yet'.
0CB2 EXX Note: DE should be pushed also.
0CB3 CALL WAIT_KEY Fetch a single key code.
0CB6 EXX Restore the registers.
0CB7 CP " " There is a jump forward to REPORT_D - 'BREAK - CONT repeats' - if the keystroke was 'BREAK', 'STOP', 'N' or 'n'; otherwise accept the keystroke as indicating the need to scroll the display.
0CB9 JR Z,REPORT_D
0CBB CP $E2
0CBD JR Z,REPORT_D
0CBF OR $20
0CC1 CP "n"
0CC3 JR Z,REPORT_D
0CC5 LD A,$FE Open channel 'S'.
0CC7 CALL CHAN_OPEN
0CCA POP AF Restore the value of P-FLAG.
0CCB LD ($5C91),A
0CCE POP HL Restore the values of ATTR-T and MASK-T.
0CCF LD ($5C8F),HL
The display is now scrolled.
PO_SCR_3 0CD2 CALL CL_SC_ALL The whole display is scrolled.
0CD5 LD B,(IY+$31) The line (DF-SZ) and column numbers for the start of the line above the lower part of the display are found and saved.
0CD8 INC B
0CD9 LD C,$21
0CDB PUSH BC
0CDC CALL CL_ADDR The corresponding attribute byte for this character area is then found. The HL register pair holds the address of the byte.
0CDF LD A,H
0CE0 RRCA
0CE1 RRCA
0CE2 RRCA
0CE3 AND $03
0CE5 OR $58
0CE7 LD H,A
The line in question will have 'lower part' attribute values and the new line at the bottom of the display may have 'ATTR-P' values so the attribute values are exchanged.
0CE8 LD DE,$5AE0 DE points to the first attribute byte of the bottom line.
0CEB LD A,(DE) The value is fetched.
0CEC LD C,(HL) The 'lower part' value.
0CED LD B,$20 There are thirty two bytes.
0CEF EX DE,HL Exchange the pointers.
PO_SCR_3A 0CF0 LD (DE),A Make the first exchange and then proceed to use the same values for the thirty two attribute bytes of the two lines being handled.
0CF1 LD (HL),C
0CF2 INC DE
0CF3 INC HL
0CF4 DJNZ PO_SCR_3A
0CF6 POP BC The line and column numbers of the bottom line of the 'upper part' are fetched before returning.
0CF7 RET
The 'scroll?' message.
SCROLL 0CF8 DEFB $80 Initial marker - stepped over.
0CF9 DEFM "scroll"
0CFF DEFM "?"+$80 The '?' is inverted.
Report D - BREAK - CONT repeats.
REPORT_D 0D00 RST $08 Call the error handling routine.
0D01 DEFB $0C
The lower part of the display is handled as follows:
PO_SCR_4 0D02 CP $02 The 'out of screen' error is given if the lower part is going to be 'too large' (see DF-SZ) and a return made if scrolling is unnecessary.
0D04 JR C,REPORT_5
0D06 ADD A,(IY+$31)
0D09 SUB $19
0D0B RET NC
0D0C NEG The A register will now hold 'the number of scrolls to be made'.
0D0E PUSH BC The line and column numbers are now saved.
0D0F LD B,A The 'scroll number', ATTR-T, MASK-T and P-FLAG are all saved.
0D10 LD HL,($5C8F)
0D13 PUSH HL
0D14 LD HL,($5C91)
0D17 PUSH HL
0D18 CALL TEMPS The 'permanent' colour items are to be used.
0D1B LD A,B The 'scroll number' is fetched.
The lower part of the screen is now scrolled A number of times.
PO_SCR_4A 0D1C PUSH AF Save the 'number'.
0D1D LD HL,$5C6B This is DF-SZ.
0D20 LD B,(HL) The value in DF-SZ is incremented; the B register set to hold the former value and the A register the new value.
0D21 LD A,B
0D22 INC A
0D23 LD (HL),A
0D24 LD HL,$5C89 This is S-POSN-hi.
0D27 CP (HL) The jump is taken if only the lower part of the display is to be scrolled (B=old DF-SZ).
0D28 JR C,PO_SCR_4B
0D2A INC (HL) Otherwise S-POSN-hi is incremented and the whole display scrolled (B=+18).
0D2B LD B,$18
PO_SCR_4B 0D2D CALL CL_SCROLL Scroll B lines.
0D30 POP AF Fetch and decrement the 'scroll number'.
0D31 DEC A
0D32 JR NZ,PO_SCR_4A Jump back until finished.
0D34 POP HL Restore the value of P-FLAG.
0D35 LD (IY+$57),L
0D38 POP HL Restore the values of ATTR-T and MASK-T.
0D39 LD ($5C8F),HL
0D3C LD BC,($5C88) In case S-POSN has been changed CL_SET is called to give a matching value to DF-CC (after resetting bit 0 of TV-FLAG).
0D40 RES 0,(IY+$02)
0D44 CALL CL_SET
0D47 SET 0,(IY+$02) Set bit 0 of TV-FLAG to indicate that the lower screen is being handled, fetch the line and column numbers, and then return.
0D4B POP BC
0D4C RET
Prev: 0C41 Up: Map Next: 0D4D