NEW
  AUTO 3,1
*--------------------------------------
				.PH $A800
*--------------------------------
*   I/O VECTORS -- 3 BYTES EACH
*--------------------------------
				JMP IIE.INIT
				JMP IIE.WARM
				JMP IIE.RDKEY
				JMP S.GET.HORIZ.POSN
				JMP MON.HOME
				JMP MON.CLREOL
				JMP MON.CLREOP
				JMP MON.UP
				JMP MON.LF
				JMP IIE.LEFT
				JMP IIE.RIGHT
				JMP IIE.COUT
				JMP IIE.PICK.SCREEN
				JMP IIE.HTABX
				JMP IIE.HTAB
				JMP IIE.VTAB
*---Case Toggle MUST go here-----
				RTS
*--------------------------------
*      VARIABLE LENGTH ROUTINES
*--------------------------------
IIE.INIT
       LDA $BF98
       AND #2
       BEQ IO.HOME
       LDA #$99     CTRL-Y
       JMP $C300
*--------------------------------
IIE.HTABX
       PHA
       TXA
       JSR IIE.HTAB
       PLA
       RTS
*--------------------------------
IIE.HTAB
       BIT $C01F
       BPL .1
       STA $57B
       RTS
.1     STA CH
       RTS
*--------------------------------
S.GET.HORIZ.POSN
       LDA $57B
       BIT $C01F
       BMI .1
       LDA CH
.1     RTS
*--------------------------------
IIE.WARM
       CLD
       LDX CV       SAVE CV
       JSR MON.INIT
       TXA          GET CV, FALL INTO VTAB
IIE.VTAB
       STA CV
       JMP MON.VTAB
*--------------------------------
IIE.RDKEY
       LDA #40
       BIT $C01F
       BPL .1
       ASL
.1     STA SCREEN.WIDTH
       JSR MON.RDKEY
       CMP #$FF
       BNE .2
       LDA #$88
.2     ASL $C061    SET CARRY IF "OPEN APPLE" PRESSED
       ORA #$80
       RTS
*--------------------------------
IIE.COUT
       CMP #$80     NORMAL OR INVERSE?
       BCS .2       ...NORMAL
       BIT $C01F    ...INVERSE; 40- OR 80-COLUMNS?
       BPL .2       ...40-COLUMN
       PHA          ...80-COLUMN
       LDA #$8F     SELECT INVERSE DISPLAY
       JSR MON.COUT
       PLA
       CMP #$20     CONTROL CHAR?
       BCS .1       ...NO
       ORA #$40     MAKE PRINTABLE CHARACTER
.1     ORA #$80
       JSR MON.COUT
       LDA #$8E     SELECT NORMAL DISPLAY
.2     JMP MON.COUT
*--------------------------------
IIE.PICK.SCREEN
       BIT $C01F
       BMI .1
       LDA (BASL),Y
       RTS
.1     TYA
       LSR
       TAY
       PHP
       SEI
       LDA $C055
       BCC .2
       LDA $C054
.2     LDA (BASL),Y
       BIT $C054
       PLP
       PHA          SAVE CHAR FROM SCREEN
       TYA          RESTORE Y-REG
       ROL
       TAY
       PLA
       RTS
*--------------------------------
IIE.RIGHT
       BIT $C01F    IN 80-COLUMN MODE?
       BMI .1       ...YES
       JMP MON.ADVANC
.1     LDA #$9C     FORWARD SPACE
       .HS 2C       SKIP TWO BYTES
*--------------------------------
IIE.LEFT
       LDA #$88     BACKSPACE
       JMP MON.COUT
*--------------------------------------
				.EP
*--------------------------------------
MAN
SAVE usr/src/scmasm.31/io.s.iie
LOAD usr/src/scmasm.31/scmasm.s
ASM
