NEW
  AUTO 3,1
*--------------------------------------
*   I/O VECTORS -- 3 BYTES EACH
*--------------------------------
IO.INIT               JMP S.IO.INIT
IO.WARM               JMP S.IO.WARM
READ.KEY.WITH.CASE    JMP S.READ.KEY.WITH.CASE
GET.HORIZ.POSN        LDA CH
                      RTS
IO.HOME               JMP MON.HOME
IO.CLREOL             JMP MON.CLREOL
IO.CLREOP             JMP MON.CLREOP
IO.UP                 JMP MON.UP
IO.DOWN               JMP MON.LF
IO.LEFT               JMP MON.BS
IO.RIGHT              JMP MON.ADVANC
IO.COUT               JMP MON.COUT
IO.PICK.SCREEN        LDA (BASL),Y
                      RTS
IO.HTABX              STX CH
                      RTS
IO.HTAB               STA CH
                      RTS
IO.VTAB               JMP S.IO.VTAB
IO.CASE.TOGGLE        LDA LC.MODE
                      EOR #$FF
                      STA LC.MODE
                      RTS
*--------------------------------
*      VARIABLE LENGTH ROUTINES
*          (ENTERED THROUGH VECTORS)
*--------------------------------
S.IO.VTAB
       STA CV
       JMP MON.VTAB
*--------------------------------
S.IO.INIT
       LDA #40
       STA SCREEN.WIDTH
       JSR MON.SETKBD
       JSR MON.SETVID
       JSR MON.INIT
       JMP MON.HOME
*--------------------------------
S.IO.WARM
       CLD
       LDX CV
       JSR MON.INIT
       STX CV
       STX LC.MODE  POSITIVE VALUE
       JSR MON.VTAB
       RTS
*--------------------------------
*      READ KEY WITH CASE CONTROL
*--------------------------------
S.READ.KEY.WITH.CASE
       LDA $BE43    See if "EXEC" in progress
       BMI .1       ...Yes, use straight input
       LDA LC.MODE
       BMI .2       Yes, use fancy translation
.1     JSR MON.RDKEY
       ORA #$80     Make sure it looks right
       CLC          SIGNAL "NO OPEN APPLE PRESSED"
       RTS
*--------------------------------
.2
       LDY CH       Set up cursor
       LDA (BASL),Y Char from screen
       PHA
       CMP #$E0     ELIMINATE CASE
       BCC .25
       AND #$DF
.25    AND #$3F     Make it flash
       ORA #$40
       STA (BASL),Y
       PLA
       JSR MON.READCH
       BIT $C063    Shift key down?
       BPL .4       Yes
       CMP #$C0     No, lower case if letter
       BCC .3
       ORA #$20
       CLC          SIGNAL "NO OPEN APPLE PRESSED"
.3     RTS
*--------------------------------
.4     CMP #$C0     Shift key down
       BCC .8       Not a letter key
       BEQ .7       Shift-P
       CMP #$DD     Shift-M
       BEQ .5       Yes
       CMP #$DE     Shift-N
       BNE .6       No
.5     AND #$EF     Make capital-M or -N
.6     CLC          SIGNAL "NO OPEN APPLE PRESSED"
       RTS
*--------------------------------
.7     LDA #$D0     Make capital-P
       CLC          SIGNAL "NO OPEN APPLE PRESSED"
       RTS
*--------------------------------
.8     CMP #$87     Look for control-shift-A thru -F
       BCS .10      No
       CMP #$81     Control-A
       BCC .10      No, control-P
       BNE .9       No, control-B thru -F
       LDA #$C0-$58-1    Control-shift-A = at-sign (@)
.9     ADC #$58
.10    CLC          SIGNAL "NO OPEN APPLE PRESSED"
       RTS
*--------------------------------------
MAN
SAVE usr/src/scmasm.30/scmasm.s.iostd
LOAD usr/src/scmasm.30/scmasm.s
ASM
