;====================================================================== ; Control Character Routines (12_Nov_84) ;======================================= ; ; Copyright 1984 ; Morrow Designs, Inc. ; San Leandro, Ca. ; Written by David Block and Jim Kearney (September 1983) ; ;---------------------------------------------------------------------- ; Index (9_Nov_84) ;----------------- ; ; CONTROL Control Character Decoding ; BELL Bell Code ; BS BackSpace ; TAB Tab ; LF Line Feed ; US Up Space ; FS ForeSpace ; CR Carriage Return ; CLRSCR Clear Screen ; ESC Escape ; HOME Home ; NEWLIN NewLine (Carriage Return Line Feed) PAGE ;---------------------------------------------------------------------- ; Control Character Decoding ;--------------------------- ; 1) if monitor mode, print the character otherwise do the action ; CONTROL:BIT MONITOR ; see if monitor mode enabled BPL DOCON ; if (monitor mode) enabled LDY #0 ; last char wasn't escape, is this???? CMP #$1B BNE SETRCVD ; if ( not escape ), then set escrcvd to 0 LDY #$FF ; else, set for escrcvd true SETRCVD:STY ESCRCVD OMON: LDY ESCRCVD ; see if last char was escape BEQ NOTCLR ; if escrcvd = 0, then last char not escape CMP #'X' ; else, see if this is a CLRMON command BNE NOTCLR ; if (not CLRMON) then branch, else LDA #0 ; clear escrcvd STA ESCRCVD JMP CLRMON ; clear monitor mode, and return NOTCLR: JSR OUTCHR ; put character on screen JMP SETPOS ; update cursor location, and return DOCON: AND #%11111 ; else, perform control code operation ASL A ; compute an index into control code vector table TAX LDA CTRLTAB,X ; set up vector for indirect jump STA CODE LDA CTRLTAB+1,X STA CODE+1 JMP (CODE) ; and execute control code RTN: RTS OUTC: LDX NSEQ ; are we getting a sequence? BEQ NORMCH ; if not, then normal character handling STA SQNC-1,X ; else, store character for sequence DEX ; update number of characters left in sequence STX NSEQ BNE RTN ; if ( entire sequence not received) then return JMP (CODE) ; else, sequence ready to process, so do it ; normal character input comes here. On entry, A reg = character NORMCH: LDX ATTRIB ; get the current atribute setting CMP #' ' ; if ( rcv'd character) < 20h BCC CONTROL ; then use control handler LDY GRAPHMD ; check if graphics enabled BEQ NOTGRAF ; if (graphics enabled) CMP #'?' ; see if char in range of 'A' to 'P' BCC NOTGRAF ORA #$80 ; convert to graphics char if 'A' to 'P' NOTGRAF:JMP OMON ; else, put character on screen, and update cursor PAGE ;---------------------------------------------------------------------- ; Ring the 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 KBRDOUT ;---------------------------------------------------------------------- ; BackSpace ;---------- ; BS: LDX COLMN LDY ROW ;get the current row DEX BPL BSSK1 ;if on same line, branch LDX #79 ;else, set last column of line above DEY BPL BSSK1 LDY #0 LDX #0 BSSK1: STX COLMN STY ROW JMP SETCUR ;---------------------------------------------------------------------- ; 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 PAGE ;---------------------------------------------------------------------- ; Line Feed ;---------- ; 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 JMP CLRLIN ;---------------------------------------------------------------------- ; UpSpace ;-------- ; US: DEC ROW ;Up a line BPL USSK1 LDA #0 STA ROW USSK1: JMP SETCUR PAGE ;---------------------------------------------------------------------- ; ForeSpace ;---------- ; FS: LDX COLMN ;forespace LDY ROW INX CPX #80 BCC FSSK1 LDX #0 INY CPY #24 BCC FSSK1 LDY #23 LDX #79 FSSK1: STX COLMN STY ROW JMP SETCUR ;---------------------------------------------------------------------- ; Carriage Return ;---------------- ; CR: LDA #0 ;Carriage return STA COLMN JMP SETPOS PAGE ;---------------------------------------------------------------------- ; Clear Screen (9_Nov_84) ;------------------------ ; CLRSCR: LDA #HIGH CRAM ;init start of ARAM and CRAM STA LB+1 LDA #HIGH ARAM STA AB+1 LDY #0 STY LB STY AB LDX #8 ;X:= Page Counter LDA CLRCHAR ;A:= Character to clear CRAM to CLCLP1: STA (LB),Y ;Repeat Repeat Clear a Location INY ; Increment the Index BNE CLCLP1 ; Until (Index wraps around) INC LB+1 ; Increment the Page Pointer DEX ;Until (8 pages are cleared) BNE CLCLP1 LDX #8 ;set to clear 8 pages of ARAM LDY #0 LDA ATTTAB+0 ;A:= Character to clear ARAM to (normal video) CLCLP2: STA (AB),Y ;Repeat Repeat Clear a location INY ; Increment the Index BNE CLCLP2 ; Until (Index wraps around) INC AB+1 ; Increment the Page Pointer DEX ;Until (8 pages have been cleared) BNE CLCLP2 JMP HOME ;Home the Cursor ;---------------------------------------------------------------------- ; Escape Recieved ;---------------- ; ESC: 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 PAGE ;---------------------------------------------------------------------- ; Home the Cursor ;---------------- ; HOME: LDA #0 ;put cursor in home position STA ROW ;ROW = COLMN = 0 STA COLMN JMP SETCUR ;set new cursor position ;---------------------------------------------------------------------- ; Print a Carriage Return followed by a Line Feed ;------------------------------------------------ ; NEWLIN: JSR CR ;carriage return line feed JMP LF ;---------------------------------------------------------------------- ; Keyboard Lock/UnLock ;--------------------- ; ;UNLOCK:LDA #$0 ; STA LOCKMD ; re-enable keyboard interrupts ; LDA #LOCKOFF ; turn off keyboard lock LED ; JMP KBRDOUT ; ;LOCK: LDA #$FF ; STA LOCKMD ; set keyboard lock mode ; LDA #LOCKON ; turn on keyboard lock LED ; JMP KBRDOUT PAGE END