NEW
  AUTO 3,1
*--------------------------------
B.TMP1 .EQ VAR.BEG-1
B.TMP2 .EQ B.TMP1-1
B.TMP3 .EQ B.TMP2-1
B.TMP4 .EQ B.TMP3-1
  .DO B.TMP4<$300
  *** VARS<$300
  .FIN
*--------------------------------
* STANDARD VIDEO JUMP VECTORS
*  1. READ KEYBOARD KEY CODE
*       TURNS ON CURSOR
*       GETS KEY CODE
*       TURNS OFF CURSOR
*       REG-A HAS KEY CODE SIGN BIT ON.
*  2. HORIZONTAL TAB
*       REG-A HAS TAB 0-79
*  3. VERTICAL TAB
*       REG-A HAS TAB 0-23
*  4. CLEAR TO END OF LINE
*  5. CLEAR TO END OF SCREEN
*  6. CHARACTER OUTPUT ROUTINE
*       REG-A HAS CHAR TO OUTPUT.
*       MUST NOT SCROLL SCREEN OR
*       GO TO NEXT LINE WHEN LAST
*       CHARACTER IS PRINTED ON A LINE.
*--------------------------------
       JMP B.RD.KBD
       JMP B.MY.HTAB
       JMP B.MY.VTAB
       JMP B.MY.CLREOL
       JMP B.MY.CLREOP
       JMP B.MY.COUT
*--------------------------------
B.CN   .DA #$C3          SLOT + $C0 OF 80 COL BOARD
B.N0   .EQ $30           SLOT * 16 OF 80 COL BOARD
*--------------------------------
B.MY.CLP LDA CTR
       JSR B.MY.VTAB
B.MY.CLREOP JSR B.MY.CLREOL  CLEAR TO END OF LINE
       LDA #0
       JSR B.MY.HTAB     NEXT LINE BEGINS WITH COL 0
       INC CTR           BUMP CTR TO NEXT LINE
       LDA CTR
       CMP LAST.LINE     IS IT > LANT LINE
       BCC B.MY.CLP      < END
       BEQ B.MY.CLP      = END
       RTS               > END
*--------------------------------
B.MY.HTAB STX B.TMP1     SAVE X REG
       LDX B.CN
       STA B.CHORZ,X     SAVE HORIZONTAL POSN
       LDX B.TMP1        RESTORE X REG
       RTS
*--------------------------------
B.MY.VTAB STY B.TMP1     SAVE Y REG
       STX B.TMP2        SAVE X REG
       LDX B.CN
       STA CV            SET NEW VERT POSN
       STA B.CVERT,X     SAVE FOR VIDEX TOO
       JSR B.VTABZ       DO CALCULATION
       LDY B.TMP1        RESTORE Y REG
       LDX B.TMP2        RESTORE X REG
       RTS
*--------------------------------
B.MY.COUT STY B.TMP1     SAVE Y REG
       STX B.TMP2        SAVE X REG
       LDX B.CN
       LDY B.CHORZ,X     GET COLUMN POSN
       JSR B.CHRPUT      PUT CHAR ON SCREEN
       INC B.CHORZ,X     NEXT COLUMN
       LDY B.TMP1        RESTORE Y REG
       LDX B.TMP2        RESTORE X REG
       RTS
*--------------------------------
B.MY.CLREOL STY B.TMP3   SAVE Y REG
       STX B.TMP4        SAVE X REG
       LDX B.CN
       LDY B.CHORZ,X     GET COL POSN
.1     LDA #$A0          A REG = BLANK
       CPY SCREEN.WIDTH  END OF LINE YET?
       BCS .2            YES
       JSR B.MY.COUT     NO, PRINT A BLANK
       LDY B.CHORZ,X     GET COL POSN
       BNE .1            ...ALWAYS
.2     LDY B.TMP3        RESTORE Y REG
       LDX B.TMP4        RESTORE X REG
       RTS
*--------------------------------
* VIDEX IO ROUTINES
*--------------------------------
B.YSAVE  .EQ $35         SAVE Y REG
*
B.ASAV1  .EQ $4F8        SAVE A REG
B.XSAV1  .EQ $578        SAVE X REG
B.MSLOT  .EQ $7F8        SAVE SLOT NUMBER
*--------------------------------
B.BASEL  .EQ $478-$C0    COMPUTED BASE ADRS LOW
B.BASEH  .EQ $4F8-$C0    COMPUTED BASE ADRS HIGH
B.CHORZ  .EQ $578-$C0    TRUE HORIZONTAL POSN
B.CVERT  .EQ $5F8-$C0    TRUE VERTICAL POSN
B.START  .EQ $6F8-$C0    SCROLL LINE START
*--------------------------------
B.FLAGS  .EQ $7F8-$C0    FLAG BITS FOR VIDEX
*--------------------------------
B.DEV0   .EQ $C080       REGISTER SELECT
B.DEV1   .EQ $C081       REGISTER DATA
B.DISP0  .EQ $CC00       1ST PAGE OF BANK
B.DISP1  .EQ $CD00       2ND PAGE OF BANK
*--------------------------------
B.VTABZ  STA B.ASAV1     COMPUTE VIDEX BASE ADRS
       ASL
       ASL
       CLC
       ADC B.ASAV1       A*5 + START
       ADC B.START,X
       PHA
       LSR               * $10
       LSR
       LSR
       LSR
       STA B.BASEH,X
       PLA
       ASL
       ASL
       ASL
       ASL
       STA B.BASEL,X
       RTS
*--------------------------------
B.PSNCALC STX B.MSLOT    POSITION CALCULATION
       TYA
       CLC
       ADC B.BASEL,X
       STA B.XSAV1
       LDA #0
       ADC B.BASEH,X
       LSR               BIT 0 TO CARRY
       PHP               SAVE CARRY BIT
       AND #3            BIT 1,2 SPECIFY WHICH BANK
       ASL
       ASL
       ORA #B.N0
       STY B.YSAVE
       TAY
       LDA B.DEV0,Y      FLIP IN RIGHT 512 BANK
       LDY B.YSAVE
       PLP               CARRY SAYS WHICH 256 BYTE PAGE
       LDX B.XSAV1         TO USE
       RTS
*--------------------------------
B.CHRPUT ASL             KILL SIGN BIT
       PHA               SAVE CHAR
       LDA B.FLAGS,X     GET CHAR SET FLAG
       LSR               IN CARRY BIT
       PLA               RECOVER CHAR
       ROR               INSERT CHAR SET BIT
       PHA               SAVE CHAR
       JSR B.PSNCALC     COMPUTE POSN
       PLA               GET CHAR
       BCS .1            HIGH PAGE
       STA B.DISP0,X     LOW PAGE STORE CHAR
       BCC .2
.1     STA B.DISP1,X     HIGH PAGE STORE CHAR
.2     LDX B.MSLOT
       RTS
*--------------------------------
B.RD.KBD JSR B.CURSOR.ON TURN ON CURSOR
.1     LDA $C000         GET CHAR
       BPL .1
       BIT $C010         STROBE KBD TO KILL FLAG BIT
       PHA               SAVE CHAR
       JSR B.CURSOR.OFF  TURN OFF CURSOR
       PLA               CHAR IN A REG
       RTS
*--------------------------------
B.CURSOR.ON LDA POSV     POSITION VERTICVALLY
       JSR B.MY.VTAB
       LDA POSH
       SEC
       SBC LEFT.MARGIN
       CLC
       ADC RM.ADJUST
       JSR B.MY.HTAB     POSITION HORIZONTALLY
       LDY #B.N0
       LDA ESC.FLAG      CHK FOR EDIT OR SCROLL MODE
       BEQ .1            MUST BE SCROLL MODE.
       LDA #$67          EDIT MODE GETS LITTLE CURSOR
       BNE .2
.1     LDA #$C0          SCROLL MODE GETS NORMAL CURSOR
.2     PHA
       LDA #$0A
       STA B.DEV0,Y      SET CTRC = REG 10
       PLA
       STA B.DEV1,Y      SET CURSOR START DATA
B.WRIT LDX B.CN
       LDY #B.N0
       LDA #$0F
       STA B.DEV0,Y      CTRC = REG 15
       LDA B.CHORZ,X
       CLC
       ADC B.BASEL,X
       STA B.DEV1,Y      SET CURSOR HOIZONTAL POSN
       LDA #$0E
       STA B.DEV0,Y      CTRC = REG 14
       LDA #0
       ADC B.BASEH,X
       STA B.DEV1,Y      SET CURSOR VERTICAL POSN
       RTS
*--------------------------------
B.CURSOR.OFF LDA #24     GO TO LINE 24 (DOES NOT EXIST)
       JSR B.MY.VTAB
       JMP B.WRIT        PUT CURSOR THERE
*--------------------------------
MAN
SAVE usr/src/fse/fse.s.videx
LOAD usr/src/fse/fse.s
ASM
