
 1000  *--------------------------------
 1010  *      FIELD INPUT SUBROUTINE
 1020  *      ----------------------
 1030  *      BY ROBERT W. POTTS
 1040  *      BANK OF LOUISVILLE
 1050  *      P. O. BOX 1101
 1060  *      LOUISVILLE, KY 40201
 1070  *
 1080  *      MODIFIED BY BOB SANDER-CEDERLOF
 1090  *      FOR THE "APPLE ASSEMBLY LINE"
 1100  *---------------------------------
 1110         .OR $300
 1120  *--------------------------------
 1130  MON.CH     .EQ $24      MONITOR HORIZONTAL
 1140  MON.BASL   .EQ $28
 1150  SPC.PNTR   .EQ $71,72
 1160  STR.PNTR   .EQ $83,84
 1170  *---------------------------------
 1180  CT         .EQ $E1      CHARACTER COUNT
 1190  FL         .EQ $E7      FIELD LENGTH  (SET BY "SCALE=FL")
 1200  FLDCOD     .EQ $F9      FIELD CODE    (SET BY "ROT=FC")
 1210  EXITCODE   .EQ $E0      PEEK (224) TO SEE EXIT CODE
 1220  *---------------------------------
 1230  INPUT.BUFFER .EQ $0200
 1240  AMPER.VECTOR .EQ $03F5
 1250  *---------------------------------
 1260  MON.RDKEY  .EQ $FD0C    MONITOR CHAR INPUT
 1270  MON.COUT   .EQ $FDED
 1280  MON.BS     .EQ $FC10    MONITOR BACKSPACE
 1290  *---------------------------------
 1300  AS.CHKSTR  .EQ $DD6C
 1310  AS.SYNCHR  .EQ $DEC0
 1320  AS.PTRGET  .EQ $DFE3
 1330  AS.GETSPA  .EQ $E452
 1340  AS.MOVSTR  .EQ $E5E2
 1350  *---------------------------------
 1360  *  SET UP AMPERSAND VECTOR
 1370  *--------------------------------
 1380  SETUP  LDA #$4C     JMP OPCODE
 1390         STA AMPER.VECTOR
 1400         LDA #INPUT.FIELD
 1410         STA AMPER.VECTOR+1
 1420         LDA /INPUT.FIELD
 1430         STA AMPER.VECTOR+2
 1440         RTS
 1450  *---------------------------------
 1460  INPUT.FIELD
 1470         LDA #$84     "INPUT" TOKEN
 1480         JSR AS.SYNCHR  REQUIRE "INPUT" OR SYNTAX ERROR
 1490         JSR AS.PTRGET  GET STRING VARIABLE
 1500         JSR AS.CHKSTR  REQUIRE STRING OR MISMATCH
 1510  *---------------------------------
 1520         LDA #0       ZERO OUT CHARACTER COUNT
 1530         STA CT
 1540  .1     JSR MON.RDKEY    GET CHARACTER
 1550  .2     AND #$7F     APPLESOFT STYLE
 1560         CMP #$06     CONTROL-F?
 1570         BEQ .3       YES
 1580         CMP #$08     BACKSPACE?
 1590         BEQ .4       YES
 1600         CMP #$0D     RETURN?
 1610         BEQ .7       YES, END OF FIELD
 1620         CMP #$15     RIGHT ARROW?
 1630         BEQ .5       YES
 1640         CMP #$1B     ESCAPE?
 1650         BEQ .6       YES
 1660         CMP #$20     SOME OTHER CONTROL CHARACTER?
 1670         BCC .1       YES, IGNORE IT
 1680         CMP #$5B     ACCEPTABLE PRINTING CHARACTER?
 1690         BCS .1       NO, IGNORE IT
 1700  *--------------------------------
 1710  *  GOT PRINTING CHARACTER - STORE IT
 1720  *--------------------------------
 1730         LDY CT       CHARACTER COUNTER   
 1740         STA INPUT.BUFFER,Y  STORE IN STRING
 1750         ORA #$80     TURN ON HIGH BIT
 1760         JSR MON.COUT PRINT CHARACTER
 1770         INC CT       INCREMENT CHARACTER COUNT
 1780         LDA CT
 1790         CMP FL       IS FIELD FILLED UP?
 1800         BNE .1       NO, GET ANOTHER CHARACTER
 1810         BEQ .7       ...ALWAYS
 1820  *---------------------------------
 1830  *  HANDLE CONTROL-F
 1840  *---------------------------------
 1850  .3     LDA CT       ON FIRST CHARACTER?
 1860         BNE .1       NO, GET ANOTHER CHARACTER  
 1870         LDA #2       EXIT CODE = 2
 1880         BNE .8       ...ALWAYS
 1890  *---------------------------------
 1900  *  HANDLE BACKSPACE
 1910  *---------------------------------
 1920  .4     LDA #3       EXIT CODE = 3 IF IN 1ST CHAR
 1930         DEC CT       DECREMENT CHARACTER COUNTER 
 1940         BMI .8       ON FIRST POSITION
 1950         JSR MON.BS   BACKSPACE
 1960         LDA #$DF     UNDERLINE
 1970         JSR MON.COUT PRINT IT
 1980         JSR MON.BS   BACKSPACE AGAIN
 1990         JMP .1       DO AGAIN
 2000  *---------------------------------
 2010  *  HANDLE RIGHT ARROW
 2020  *---------------------------------
 2030  .5     LDY MON.CH   YES, GET NEXT CHARACTER FROM SCREEN
 2040         LDA (MON.BASL),Y
 2050         JMP .2
 2060  *---------------------------------
 2070  *  HANDLE ESCAPE
 2080  *---------------------------------
 2090  .6     LDA FLDCOD   FIELD CODE = 0?
 2100         BEQ .1       YES, GET ANOTHER CHARACTER 
 2110         LDA CT       
 2120         BNE .1       NO, GET ANOTHER CHARACTER  
 2130         LDA #1       EXIT CODE = 1
 2140         BNE .8       ...ALWAYS
 2150  *--------------------------------
 2160  *  STORE THE INPUT DATA IN THE STRING
 2170  *--------------------------------
 2180  .7     LDA CT       STRING LENGTH
 2190         JSR AS.GETSPA  GET SPACE IN STRING AREA
 2200         LDY #0       MOVE DATA INTO VARIABLE
 2210         STA (STR.PNTR),Y  LENGTH
 2220         LDA SPC.PNTR
 2230         INY
 2240         STA (STR.PNTR),Y  LO-BYTE OF ADDRESS
 2250         LDA SPC.PNTR+1
 2260         INY
 2270         STA (STR.PNTR),Y  HI-BYTE OF ADDRESS
 2280         LDX #INPUT.BUFFER
 2290         LDY /INPUT.BUFFER
 2300         LDA CT       LENGTH
 2310         JSR AS.MOVSTR
 2320         LDA #0       EXIT CODE = 0
 2330  .8     STA EXITCODE
 2340         RTS

