NEW
  AUTO 3,1
*--------------------------------------
				.PH $A800
*--------------------------------
STB.SCREEN.WIDTH .EQ $A5
*--------------------------------
STB.SLOT       .EQ 3
*--------------------------------
STB.HORIZ  .EQ $05F8+STB.SLOT
STB.ESCBYT .EQ $06F8+STB.SLOT
STB.FLAGS  .EQ $0778+STB.SLOT
*--------------------------------
STB.ENTRY  .EQ STB.SLOT*256+$C000
STB.RDKEY1  .EQ STB.SLOT*256+$C005
STB.COUT1  .EQ STB.SLOT*256+$C019
STB.SCREEN .EQ STB.SLOT*256+$C031
*--------------------------------
*   I/O VECTORS -- 3 BYTES EACH
*--------------------------------
				JMP STB.INIT
				JMP STB.WARM
				JMP STB.READ.KEY.WITH.CASE
				JMP STB.GET.HORIZ.POSN
				LDA #$8C     ^L--HOME
				.HS 2C
				LDA #$9D     ^]--CLREOL
				.HS 2C
				LDA #$8B     ^K--CLREOP
				.HS 2C
				LDA #$9F     ^_--UP 
				.HS 2C
				LDA #$8A     ^J--DOWN
				.HS 2C
				LDA #$88     ^H--LEFT
				.HS 2C
				LDA #$9C     ^\--RIGHT
				NOP
				JMP MON.COUT
				JMP STB.PICK.SCREEN
				JMP STB.HTABX
				JMP STB.HTAB
				JMP STB.VTAB
*---Case Change MUST go here-----
				LDA STB.FLAGS
				EOR #$40
				STA STB.FLAGS
				RTS
*--------------------------------
*      VARIABLE LENGTH ROUTINES
*--------------------------------
STB.HTABX
       PHA
       TXA
       JSR STB.HTAB
       PLA
       RTS
*--------------------------------
STB.GET.HORIZ.POSN
       LDA STB.HORIZ
       RTS
*--------------------------------
STB.VTAB
       STA CV
       LDA STB.HORIZ
STB.HTAB
       PHA          SAVE HORIZ POSN
       LDA #$9E
       JSR STB.COUT1
       PLA          GET HORIZ POSN
       JSR .1
       LDA CV

.1     CLC
       ADC #$A0
       JMP STB.COUT1
*--------------------------------
STB.INIT
       LDA #80
       STA STB.SCREEN.WIDTH
       LDA #$8C     CLEAR SCREEN AND START STB-80
       JSR STB.ENTRY
       LDA #0
       STA STB.ESCBYT     DISABLE ^A AND ESC-MODE
       LDA #2       DISABLE "HOME" SENSING
       STA STB.FLAGS
STB.INSTALL.VECTORS
       LDX #1
.1     LDA STB.VECTORS,X
       STA $36,X
       STA STB.SLOT*2+$BE10,X
       LDA STB.VECTORS+2,X
       BIT F.EXEC
       BMI .2
       STA $38,X
.2     STA STB.SLOT*2+$BE20,X
       DEX
       BPL .1
       RTS
*--------------------------------
STB.VECTORS    .DA STB.COUT
           .DA STB.RDKEY
*--------------------------------
STB.WARM
       CLD
       LDX CV
       JSR MON.INIT
       STX CV
       JMP STB.INSTALL.VECTORS
*--------------------------------
*      READ KEY WITH CASE CONTROL
*--------------------------------
STB.READ.KEY.WITH.CASE
       JSR MON.RDKEY
       ORA #$80     REQUIRED FOR EXEC FILES
       CLC          SIGNAL NO OPEN APPLE
       RTS
*--------------------------------
STB.RDKEY
       CLD
       LDA #$0A
       STA STB.SLOT*16+$C080
       LDA #$07     SOLID DBL LINE CURSOR
       STA STB.SLOT*16+$C081
       JSR STB.RDKEY1
       ORA #$80     Make sure it looks right
       PHA
       LDA #$0A
       STA STB.SLOT*16+$C080
       LDA #$20     CURSOR OFF
       STA STB.SLOT*16+$C081
       PLA
       RTS
*--------------------------------
STB.COUT
       CLD
       CMP #$80     NORMAL OR INVERSE?
       BCS .1       ...NORMAL
       PHA          ...80-COLUMN
       LDA #$8F     SELECT INVERSE DISPLAY
       JSR STB.COUT1
       PLA
       ORA #$80     MAKE PRINTABLE CHARACTER
       CMP #$A0
       BCS .2
       ORA #$40
.2     JSR STB.COUT1
       LDA #$8E     SELECT NORMAL DISPLAY
.1     JMP STB.COUT1
*--------------------------------
STB.PICK.SCREEN
       STX $481
       TYA
       STA $482
       JSR STB.HTAB
       JSR STB.SCREEN
       LDY $482
       LDX $481
       RTS
*--------------------------------------
				.EP
*--------------------------------------
MAN
SAVE usr/src/scmasm.30/io.s.stb80
LOAD usr/src/scmasm.30/scmasm.s
ASM
