SBTTL 'Escape Code Routines (12_Nov_84)' PAGE ;====================================================================== ; ; Copyright 1984 ; Morrow Designs, Inc. ; San Leandro, Ca. ; ;---------------------------------------------------------------------- ; Index (9_Nov_84) ;----------------- ; ; HICHAR Print a Character in Alternate Graphics Mode ; CURSRT Set the Cursor Type ; DISREV Display the Code Revision Message ; GRAFON Graphics Mode On ; GRAFOFF Graphics Mode Off ; INVOFF Dim Video On ; INVON Dim Video Off ; CLRSCR In the Control Module ; CLRSCR In the Control Module ; ALIGN Fill the Screen with the alignment pattern ; GOTOXY Direct Cursor Addressing ; READCR Read the Cursor Location ; SCRNDIS Enable/Disable Screen Saver ; INSLIN Insert a Line ; SETATT Set a Character's Attribute ; BACKTB Back-Tab ; SETCLK Enable/Disable the Keyclick ; SETREV Enable/Disable Reverse Video Screen ; RDLPEN Read the Light Pen ; RTRV22 Restore the Last Two Lines on the Screen ; INSCHR Insert a Character ; DELLIN Delete a Line ; SAVE22 Save the Last Two Characters on the Screen ; CLREOL Clear to the End of the Line ; SETMON Set the Mointor Mode ; DELCHR Delete a Character ; CLRMON Clear the Monitor Mode ; CLREOS Clear to the End of the Screen ; SETKPD Set the Applications KeyPad Mode ; CLRKPD Clear the Applications KeyPad Mode PAGE ;---------------------------------------------------------------------- ; Escape Handeler ;---------------- ; ESCHAND:AND #$7F ; mask 8th bit LDA SQNC ; process received char SEC SBC #' ' ; in $20-$5F ? BMI ESCSK1 CMP #64 ; see if valid escape code BCS ERTN ; return if invalid code TAY ; save char ASL A ; compute table index TAX LDA ESCTAB,X ; set up code address for function STA CODE LDA ESCTAB+1,X STA CODE+1 LDA ESCMOR,Y ; get number of parameters req'd ; by esc sequence STA NSEQ BNE ERTN ; wait if entire sequence not rcv'd JMP (CODE) ; no, execute it ESCSK1: LDX ATTRIB ; handle <0..31> as request to ADC #' ' ; print ASCII character JSR OUTCHR ; put char on screen JMP SETPOS ; update cursor position ERTN: RTS ;Error Return ;---------------------------------------------------------------------- ; Print a Character in Alternate Graphics Mode ;--------------------------------------------- ; HICHAR: LDA SQNC ; Get the character ORA #$80 ; set msb to select alternate character set LDX ATTRIB JSR OUTCHR ; and output the character JMP SETPOS PAGE ;---------------------------------------------------------------------- ; Set the Cursor Type ;-------------------- ; CURSRT: LDA SQNC ; set the cursor type ;Enter Here from Warm Start Code CURST2: AND #%111 ; enter here to set cursor as in A reg CMP #7 BEQ NOCSK1 STA DCURTYP ASL A TAX LDY #10 STY CRTC LDA CURTYPE,X STA CRTC+1 INY STY CRTC LDA CURTYPE+1,X STA CRTC+1 NOCSK1: RTS ;---------------------------------------------------------------------- ; Display Code Revision Message ;------------------------------ ; DISREV: LDA RVMESG ; set up for message to print STA MESG LDA RVMESG+1 STA MESG+1 JMP PRNTMSG ; print the message ;---------------------------------------------------------------------- ; Enable Graphics Mode ;--------------------- ; GRAFON: LDA #$FF STA GRAPHMD ; enable graphics mode RTS ;---------------------------------------------------------------------- ; Disable Graphics Mode ;---------------------- ; GRAFOFF:LDA #$0 STA GRAPHMD ; disable graphics mode RTS PAGE ;---------------------------------------------------------------------- ; set Normal video ;----------------- ; INVOFF: LDA ATTTAB+0 ; everything off STA ATTRIB RTS ;---------------------------------------------------------------------- ; turn DIM video on ;------------------ ; INVON: LDA ATTTAB+2 STA ATTRIB RTS ;---------------------------------------------------------------------- ; Put the Alignment Pattern on the Screen (9_Nov_84) ;--------------------------------------------------- ; ALIGN: LDA #'H' ; fill screen with "H" for alignment STA CLRCHAR JSR CLRSCR LDA #' ' STA CLRCHAR JMP SETREV PAGE ;---------------------------------------------------------------------- ; Direct Cursor Addressing ;------------------------- ; GOTOXY: LDA SQNC+1 ; Direct Cursor Addressing SEC ; Get Row, and subtract offset SBC #' ' CMP #24 ; see if out of range BCC GOTSK1 ; if not, then set new row LDA #23 ; else, set last row GOTSK1: STA ROW LDA SQNC ; get Column SEC ; subtract offset SBC #' ' CMP #80 ; check if out of range BCC GOTSK2 ; if not, then set new column LDA #79 ; else, set for last column GOTSK2: STA COLMN JMP SETCUR ; and put the cursor there ;---------------------------------------------------------------------- ; Read the Cursor's Position ;--------------------------- ; READCR: LDA ROW ; get row ORA #' ' ; add offset JSR SNDINS ; put in send buffer LDA COLMN ; get column CLC ADC #' ' ; add offset JMP SNDINS ; put in send buffer ;---------------------------------------------------------------------- ; Enable/Disable Screen Saver Function ;------------------------------------- ; SCRNDIS:LDA SQNC ; enable/disable screen saver function AND #1 ; see if enable or disable BEQ SCRSK1 ; if (disable) then LDA #$FF ; set screen saver disable flag SCRSK1: STA TIMEN ; else, clear screen saver disable flag RTS PAGE ;---------------------------------------------------------------------- ; Insert a Line (21_Nov_84) ;-------------------------- ; INSLIN: LDA #23 ; Calculate number of lines to move SEC SBC ROW BNE INSSK1 ; if (on bottom line) JMP DELL99 ; Clear the Last Line INSSK1: CLC LDA SCBASE ; calculate pointer to last line ADC #LOW(LASTLIN)+79 STA LB LDA SCBASE+1 ADC #HIGH(LASTLIN)+HIGH(CRAM) AND #$3F ;(Keep the move in bounds) STA LB+1 SEC ; LB = last line - 80 = source for move LDA LB SBC #80 STA LB2 LDA LB+1 SBC #0 STA LB2+1 LDA #0 ; setup source and dest. for attribute move JSR CALCATT2 LDA #0 JSR CALCATT LDA ROW ; calculate number of attributes to be moved ASL A ; compute index into line table TAX SEC ; # Attributes = 23 * 80 - (80 * ROW) LDA #LOW(LASTLIN) SBC LINES,X STA TRANSFR LDA #HIGH(LASTLIN) SBC LINES+1,X STA TRANSFR+1 JSR SETSD ; set source and destination pointers JSR INSMOVE ; move the characters and attributes LDA LB2 STA LB LDA LB2+1 STA LB+1 LDA ROW ; reset pointers, and then clear the line JSR LINBAS JSR DELL99 JMP SETCUR PAGE ;---------------------------------------------------------------------- ; Set a Character's Attribute ;---------------------------- ; SETATT: LDA SQNC ; get code for desired attribute AND #%111 ; lower 3 bits only TAX LDA ATTTAB,X ; get appropriate settings STA ATTRIB ; set as current attribute RTS ;---------------------------------------------------------------------- ; BackTab ;-------- ; BACKTB: LDA COLMN BEQ BAKSK1 SEC SBC #1 BMI BAKSK1 AND #$F8 STA COLMN BAKSK1: JMP SETCUR ;---------------------------------------------------------------------- ; Enable/Disable Keyclick ;------------------------ ; SETCLK: LDA SQNC ; turn keyclick on or off AND #$01 ; 0 => keyclick off 1 => keyclick on BEQ SECSK1 LDA #CLCKON JMP KBRDOUT ; send keyclick on to keyboard SECSK1: LDA #CLCKOFF JMP KBRDOUT ; send keyclick off to keyboard PAGE ;---------------------------------------------------------------------- ; Set Screen to Normal/Reverse Video ;----------------------------------- ; SETREV: LDA SQNC ; set reverse/normal video AND #$01 ; 0 => normal, 1 => reverse BEQ SERSK1 ; if 0, then turn off reverse video LDA BDREG ; else, turn reverse video on ORA #$20 STA BDREG STA BAUD RTS SERSK1: LDA BDREG ; turn reverse video off AND #$DF STA BDREG STA BAUD RTS ;---------------------------------------------------------------------- ; Read Lightpen ;-------------- ; RDLPEN: RTS ; Just in case!!!! ;---------------------------------------------------------------------- ; Restore Last Two Lines of the Screen ;------------------------------------- ; RTRV22: LDA #22 JSR LINBAS LDA #0 JSR CALCATT LDY #0 RTRLP1: LDA ATTLINE,Y ; get attribute of character STA (NEWAB),Y LDA CHRLINE,Y ; get the character STA (LB),Y INY CPY #160 BNE RTRLP1 LDA TMPROW STA ROW LDA TMPCLMN STA COLMN JMP SETCUR PAGE ;---------------------------------------------------------------------- ; Insert a Character ;------------------- ; INSCHR: LDA LB ; Move CRAM and ARAM over 1 space STA LB2 ; now, move the attributes, 1st init LB2 LDA LB+1 STA LB2+1 LDA #78 ; set up source for character moves JSR CALCS LDA #79 ; set up destination for character moves JSR CALCD SEC ; now, figure how many bytes to transfer LDA #79 ; number to move = 79 - COLMN SBC COLMN CMP #0 BEQ INCSK1 ; if no characters to move, just blank position STA TRANSFR LDA #0 STA TRANSFR+1 JSR INSMOVE ; move the characters and attributes INCSK1: LDY COLMN ; now, blank the character position JMP CLRIT PAGE ;---------------------------------------------------------------------- ; delete line- move lines below up and clear last line ;----------------------------------------------------- ; DELLIN: LDA #23 SEC SBC ROW BEQ DLLSK1 ; if on bottom line STA TEMP ; save # of rows to move CLC LDA LB ; calculate start of next line ADC #80 ; in both ARAM and CRAM STA LB2 LDA LB+1 ADC #0 STA LB2+1 JSR SETSD ; set source and destination pointers LDA #0 JSR CALCATT2 ; calculate source for attribute move LDA #0 JSR CALCATT ; calculate destination for attribute move LDA TEMP ; get number of rows to move up ASL A ; convert to table index TAX LDA LINES,X ; get number of bytes to transfer and set up for move STA TRANSFR LDA LINES+1,X STA TRANSFR+1 JSR DELMOVE ; move the characters CLC ; set to clear last line LDA #1 ADC CHARD ; set LB to point to 1st character of last line STA LB LDA #0 ADC CHARD+1 STA LB+1 DLLSK1: JSR DELL99 ; now, clear last line JMP SETCUR ; and put the cursor where it should be PAGE ;---------------------------------------------------------------------- ; save last 2 lines of screen ;---------------------------- ; SAVE22: LDA ROW STA TMPROW LDA COLMN STA TMPCLMN LDA #22 JSR LINBAS LDA #0 JSR CALCATT ; get starting location in ARAM of line 22 LDY #0 SAVLP1: LDA (LB),Y ; get next char from CRAM STA CHRLINE,Y ; put it in RAM LDA (NEWAB),Y ; get the attribute STA ATTLINE,Y ; put it into RAM LDA #$20 STA (LB),Y ; clear space just saved LDA ATTTAB+0 STA (NEWAB),Y INY CPY #160 BNE SAVLP1 LDA #0 STA COLMN LDA #22 STA ROW JMP SETCUR ; set cursor to beginning of line 22 ;---------------------------------------------------------------------- ; Clear to the End of the Line ;----------------------------- ; CLREOL: LDA COLMN ; clear to end of line JMP CLEOLA ;---------------------------------------------------------------------- ; Set Monitor Mode ;----------------- ; SETMON: LDA #$FF ; set monitor mode STA MONITOR RTS PAGE ;---------------------------------------------------------------------- ; Delete a Character (9_Nov_84) ;------------------------------ ; DELCHR: LDY COLMN ; delete character CPY #79 ; if last char on line, just blank it BEQ CLRIT INY ; else, get next character up the line, (SOURCE) LDA LB ; set up to calculate source and dest. for att move STA LB2 LDA LB+1 STA LB2+1 TYA JSR CALCS ; source = LB + COLMN + 1 LDA COLMN ; destination = LB + COLMN JSR CALCD SEC LDA #79 ; 80? SBC COLMN STA TRANSFR ; # to transfer = 79 - COLMN LDA #0 STA TRANSFR+1 JSR DELMOVE LDY #79 ; Clear the Last Character Position ;---------------------------------- ; 1) This code also used by the insert character routine (INSCHR) ; CLRIT: LDA ATTTAB+0 ; now, clear the space for the insert character JSR WRATT ; write the attribute LDA #' ' ; write a space STA (LB),Y RTS ;---------------------------------------------------------------------- ; Clear Monitor Mode ;------------------- ; CLRMON: LDA #0 ; clear monitor mode STA MONITOR RTS PAGE ;---------------------------------------------------------------------- ; Clear to the End of the Screen ;------------------------------- ; CLREOS: LDA COLMN ; clear to end of screen JSR CLEOLA SEC LDA #23 SBC ROW BEQ CLESK2 STA TEMP CLELP1: LDA LB CLC ADC #80 STA LB BCC CLESK1 INC LB+1 CLESK1: JSR CLRLIN DEC TEMP BNE CLELP1 CLESK2: JMP SETCUR ;---------------------------------------------------------------------- ; Set the Keypad Applications Mode ;--------------------------------- ; SETKPD: LDA #$FF ; set keypad applications mode STA KPAD LDA #OFLNON ; turn on keypad application LED JMP KBRDOUT ;---------------------------------------------------------------------- ; Clear the Keypad Applications Mode ;----------------------------------- ; CLRKPD: LDA #0 ; clear keypad applications mode STA KPAD LDA #OFLNOFF ; turn off keypad application LED JMP KBRDOUT END