SBTTL 'Control Character Routines (28_Dec_84)' PAGE ;====================================================================== ; ; Copyright 1984 ; Morrow Designs, Inc. ; San Leandro, Ca. ; ; ; Module Description: ;-------------------- ; This Module contains all of the code for executing control ; characters. These codes are involked by the PROCESS routine in the ; main module (VBxx). ; ;---------------------------------------------------------------------- ; Index (27_Dec_84) ;------------------ ; ; READCR 05 - Read the Current Cursor Position ; BELL 07 - Bell Code ; HOME 08 - Home the Cursor ; TAB 09 - Tab ; NEWLIN 0A - NewLine (Carriage Return Line Feed) ; CLREOL 0B - Clear to the End of the Line ; CLRSCR 0C - Clear Screen ; SCURS 10 - Set the Cursor Position ; UNLON 14 - Underline On ; UNLOFF 15 - Underline Off ; US 17 - Up Space ; FS 18 - Fore Space ; BS 19 - Back Space ; DS 1A - Down Space ; LOINT 1C - Dim Video On ; HIINT 1D - Dim Video Off ; EXTND 1E - Extended Code Sequence ; ; LF xx - Line Feed ; CR xx - Carriage Return ; ESC xx - Escape ; HOME xx - Home PAGE ;---------------------------------------------------------------------- ; (5) Read the Cursor's Position (28_Dec_84) ;------------------------------------------- ; READCR: LDA COLMN ;A:= Column JSR SNDINS ;Insert the Column into the Send Buffer LDA ROW ;A:= Current Row JSR SNDINS ;Insert the Row into the Send Buffer RTS ;Return ;---------------------------------------------------------------------- ; (7) Bell ;--------- ; BELL: LDX BAUD BPL BLSK1 ;nothing from keyboard, so beep. JSR GETKEY ;else, get the key from keyboard before beeping JMP BELL ;wait for settle BLSK1: LDA #BEEP ;BEEP! BEEP! JMP PUTKEY ;---------------------------------------------------------------------- ; (8) Home the Cursor ;-------------------- ; HOME: LDA #0 ;put cursor in home position STA ROW ;ROW = COLMN = 0 STA COLMN JMP SETCUR ;set new cursor position ;---------------------------------------------------------------------- ; (9) Tab ;-------- ; TAB: LDA COLMN ;tab over 8 spaces AND #$F8 CLC ADC #8 CMP #80 BNE TABSK1 LDA #0 STA COLMN JMP LF TABSK1: STA COLMN JMP SETCUR ;---------------------------------------------------------------------- ; (A) Carriage Return - Line Feed ;-------------------------------- ; NEWLIN: JSR CR ;carriage return line feed JMP LF ;---------------------------------------------------------------------- ; (B) Clear to the End of the Line ;---------------------------------- ; CLREOL: LDA COLMN ; clear to end of line JMP CLEOLA ;---------------------------------------------------------------------- ; (C) Clear Screen (26_Nov_84) ;----------------------------- ; CLRSCR: LDA #HIGH CRAM ;init start of ARAM and CRAM STA CHARD+1 LDA #HIGH ARAM STA ATTRD+1 LDY #0 STY CHARD STY ATTRD LDX #8 ;X:= Page Counter CLCLP1: LDA CLRCHAR ;Repeat A:= Character to clear CRAM to CLCLP2: STA (CHARD),Y ; Repeat Clear a Location INY ; Increment the Index BNE CLCLP2 ; Until (Index wraps around) LDA ATTTAB+0 ; A:= Normal Video Attribute CLCLP3: STA (ATTRD),Y ; Repeat Clear a location INY ; Increment the Index BNE CLCLP3 ; Until (Index wraps around) INC CHARD+1 ; Increment the Page Pointer INC ATTRD+1 ; Increment the Page Pointer DEX ;Until (8 pages have been cleared) BNE CLCLP1 JMP HOME ;Home the Cursor ;---------------------------------------------------------------------- ; (10) Set the Cursor Position (28_Dec_84) ;----------------------------------------- ; SCURS: LDA #2 STA NSEQ ;Nseq:= Additional Parameters (Row Column) LDA #LOW GOTOXY STA CODE LDA #HIGH GOTOXY STA CODE+1 ;Vector:= Cursor Routine RTS ;Return ;---------------------------------------------------------------------- ; (14) Turn ON Underlining (28_Dec_84) ;------------------------------------- ; UNLON: LDA ATTRIB ;A:= Current Attribute Setting ORA #%00000001 ;Add in the Underline Attribute STA ATTRIB ;Update the Attribute Setting RTS ;Return ;---------------------------------------------------------------------- ; (15) Turn OFF Underlining (28_Dec_84) ;-------------------------------------- ; UNLOFF: LDA ATTRIB ;A:= Current Attribute Setting AND #%11111110 ;Remove the Underline Attribute STA ATTRIB ;Update the Attribute Setting RTS ;Return ;---------------------------------------------------------------------- ; (17) UpSpace (28_Dec_84) ;------------------------- ; US: DEC ROW ;Row:= Row - 1 BPL USSK1 ;If (We've just wrapped around) LDA #23 STA ROW ; Row:= Bottom Line of Screen USSK1: JMP SETCUR ;Update the Cursor Position ;---------------------------------------------------------------------- ; (18) ForeSpace (28_Dec_84) ;--------------------------- ; FS: LDX COLMN ;X:= Column LDY ROW ;Y:= Row INX ;Column:= Column + 1 CPX #80 ;If (We've gone past the last column) BCC FSSK1 LDX #0 ; Column:= 0 INY ; Row:= Row + 1 CPY #24 ; If (We've gone past the last Row) BCC FSSK1 JSR CR ; Carriage Return JSR LF ; Line Feed RTS ; Return FSSK1: STX COLMN ;Update the Column STY ROW ;Update the Row JSR SETCUR ;Update the Cursor Position RTS ;Return ;---------------------------------------------------------------------- ; (19) BackSpace (28_Dec_84) ;--------------------------- ; BS: LDX COLMN ;X:= Column LDY ROW ;Y:= Row DEX ;Column:= Column - 1 BPL BSSK1 ;If (We've gone past the beginning of the line) LDX #79 ; Column:= Last Column DEY ; Row:= Row - 1 BPL BSSK1 ; If (We've gone past the beginning row) LDY #23 ; Row:= Last Row BSSK1: STX COLMN ;Update the Column STY ROW ;Update the Row JMP SETCUR ;Update the Cursor ;---------------------------------------------------------------------- ; (1A) Move the Cursor Down One Line (27_Dec_84) ;----------------------------------------------- ; DS: LDX ROW ;X:= Row INX ;Row:= Row + 1 CPX #24 ;If (We've gone past the bottom of the screen) BCC DSSK1 LDX #0 ; Row:= 0 DSSK1: STX ROW ;Update the Row JSR SETCUR ;Update the Cursor RTS ;Return ;---------------------------------------------------------------------- ; (1B) Turn OFF Low Intensity (28_Dec_84) ;---------------------------------------- ; HIINT: LDA ATTRIB ;A:= Current Attribute Setting AND #%11111101 ;Remove the Low Intensity Bit STA ATTRIB ;Update the Attribute Byte RTS ;Return ;---------------------------------------------------------------------- ; (1C) Turn ON Low Intensity (28_Dec_84) ;--------------------------------------- ; LOINT: LDA ATTRIB ;A:= Current Attribute Setting ORA #%00000010 ;Add in the Low Intensity Bit STA ATTRIB ;Update the Attribute Byte RTS ;Return ;---------------------------------------------------------------------- ; (1E) Begin Extended Function ;----------------------------- ; EXTND: LDA #1 ;escape handler STA NSEQ ;set up to save next char LDA #LOW ESCHAND ;routine to handle next char STA CODE LDA #HIGH ESCHAND STA CODE+1 RTS ;---------------------------------------------------------------------- ; (xx) Line Feed (28_Nov_84) ;--------------------------- ; LF: LDA ROW ;Line feed CMP #23 ;check if scroll req'd BEQ LFSK1 ;if yes, then scroll INC ROW ;else, just set new row JMP SETCUR ;and put the cursor there LFSK1: SEI ;Scroll screen LDA SCBASE CLC ADC #80 STA SCBASE LDA SCBASE+1 ;new scbase = old scbase + 80 ADC #0 AND #%111 ;wrap it around STA SCBASE+1 JSR SETCUR ;set cursor register of CRTC LDX #13 LDA SCBASE ;set starting reg of CRTC STX CRTC STA CRTC+1 DEX LDA SCBASE+1 STX CRTC STA CRTC+1 CLI LDX #80 ;Set the Number of Characters to Clear Counter JMP CLR79 ;Clear the Line ;---------------------------------------------------------------------- ; (xx) Carriage Return ;--------------------- ; CR: LDA #0 ;Carriage return STA COLMN JMP SETPOS END