S-C DocuMentor — Applesoft

               SAVE S.DEF9
               1010 *--------------------------------
               1020 *      "SCRN(" FUNCTION
               1030 *--------------------------------
DEF9- 20 B1 00 1040 SCREEN JSR CHRGET
DEFC- 20 EC F1 1050        JSR PLOTFNS  GET COLUMN AND ROW
DEFF- 8A       1060        TXA          ROW
DF00- A4 F0    1070        LDY FIRST    COLUMN
DF02- 20 71 F8 1080        JSR MON.SCRN GET 4-BIT COLOR THERE
DF05- A8       1090        TAY
DF06- 20 01 E3 1100        JSR SNGFLT   CONVERT (Y) TO REAL IN FAC
DF09- 4C B8 DE 1110        JMP CHKCLS   REQUIRE ")"
               1120 *--------------------------------
               1130 *      PROCESS UNARY OPERATORS (FUNCTIONS)
               1140 *--------------------------------
DF0C- C9 D7    1150 UNARY  CMP #TOKEN.SCRN     NOT UNARY, DO SPECIAL
DF0E- F0 E9    1160        BEQ SCREEN
DF10- 0A       1170        ASL          DOUBLE TOKEN TO GET INDEX
DF11- 48       1180        PHA
DF12- AA       1190        TAX
DF13- 20 B1 00 1200        JSR CHRGET
DF16- E0 CF    1210        CPX #TOKEN.LEFTSTR*2-1   LEFT$, RIGHT$, AND MID$
DF18- 90 20    1220        BCC .1       NOT ONE OF THE STRING FUNCTIONS
DF1A- 20 BB DE 1230        JSR CHKOPN   STRING FUNCTION, NEED "("
DF1D- 20 7B DD 1240        JSR FRMEVL   EVALUATE EXPRESSION FOR STRING
DF20- 20 BE DE 1250        JSR CHKCOM   REQUIRE A COMMA
DF23- 20 6C DD 1260        JSR CHKSTR   MAKE SURE EXPRESSION IS A STRING
DF26- 68       1270        PLA
DF27- AA       1280        TAX          RETRIEVE ROUTINE POINTER
DF28- A5 A1    1290        LDA VPNT+1   STACK ADDRESS OF STRING
DF2A- 48       1300        PHA
DF2B- A5 A0    1310        LDA VPNT
DF2D- 48       1320        PHA
DF2E- 8A       1330        TXA
DF2F- 48       1340        PHA          STACK DOUBLED TOKEN
DF30- 20 F8 E6 1350        JSR GETBYT   CONVERT NEXT EXPRESSION TO BYTE IN X-REG
DF33- 68       1360        PLA          GET DOUBLED TOKEN OFF STACK
DF34- A8       1370        TAY          USE AS INDEX TO BRANCH 
DF35- 8A       1380        TXA          VALUE OF SECOND PARAMETER
DF36- 48       1390        PHA          PUSH 2ND PARAM
DF37- 4C 3F DF 1400        JMP .2       JOIN UNARY FUNCTIONS
DF3A- 20 B2 DE 1410 .1     JSR PARCHK   REQUIRE "(EXPRESSION)"
DF3D- 68       1420        PLA
DF3E- A8       1430        TAY          INDEX INTO FUNCTION ADDRESS TABLE
DF3F- B9 DC CF 1440 .2     LDA UNFNC-TOKEN.SGN-TOKEN.SGN+$100,Y
DF42- 85 91    1450        STA JMPADRS+1  PREPARE TO JSR TO ADDRESS
DF44- B9 DD CF 1460        LDA UNFNC-TOKEN.SGN-TOKEN.SGN+$101,Y
DF47- 85 92    1470        STA JMPADRS+2
DF49- 20 90 00 1480        JSR JMPADRS  DOES NOT RETURN FOR
               1490 *                   CHR$, LEFT$, RIGHT$, OR MID$
DF4C- 4C 6A DD 1500        JMP CHKNUM   REQUIRE NUMERIC RESULT
               1510 *--------------------------------
DF4F- A5 A5    1520 OR     LDA ARG      "OR" OPERATOR
DF51- 05 9D    1530        ORA FAC      IF RESULT NONZERO, IT IS TRUE
DF53- D0 0B    1540        BNE TRUE
               1550 *--------------------------------
DF55- A5 A5    1560 AND    LDA ARG      "AND" OPERATOR
DF57- F0 04    1570        BEQ FALSE    IF EITHER IS ZERO, RESULT IS FALSE
DF59- A5 9D    1580        LDA FAC
DF5B- D0 03    1590        BNE TRUE
               1600 *--------------------------------
DF5D- A0 00    1610 FALSE  LDY #0       RETURN FAC=0
DF5F- 2C       1620        .HS 2C       TRICK
               1630 *--------------------------------
DF60- A0 01    1640 TRUE   LDY #1       RETURN FAC=1
DF62- 4C 01 E3 1650        JMP SNGFLT
               1660 *--------------------------------
               1670 *      PERFORM RELATIONAL OPERATIONS
               1680 *--------------------------------
DF65- 20 6D DD 1690 RELOPS JSR CHKVAL   MAKE SURE FAC IS CORRECT TYPE
DF68- B0 13    1700        BCS STRCMP   TYPE MATCHES, BRANCH IF STRINGS
DF6A- A5 AA    1710        LDA ARG.SIGN   NUMERIC COMPARISON
DF6C- 09 7F    1720        ORA #$7F     RE-PACK VALUE IN ARG FOR FCOMP
DF6E- 25 A6    1730        AND ARG+1
DF70- 85 A6    1740        STA ARG+1
DF72- A9 A5    1750        LDA #ARG
DF74- A0 00    1760        LDY /ARG
DF76- 20 B2 EB 1770        JSR FCOMP    RETURN A-REG = -1,0,1
DF79- AA       1780        TAX           AS ARG <,=,> FAC
DF7A- 4C B0 DF 1790        JMP NUMCMP
               1800 *--------------------------------
               1810 *      STRING COMPARISON
               1820 *--------------------------------
DF7D- A9 00    1830 STRCMP LDA #0       SET RESULT TYPE TO NUMERIC
DF7F- 85 11    1840        STA VALTYP
DF81- C6 89    1850        DEC CPRTYP   MAKE CPRTYP 0000<=>0
DF83- 20 00 E6 1860        JSR FREFAC
DF86- 85 9D    1870        STA FAC      STRING LENGTH
DF88- 86 9E    1880        STX FAC+1
DF8A- 84 9F    1890        STY FAC+2
DF8C- A5 A8    1900        LDA ARG+3
DF8E- A4 A9    1910        LDY ARG+4
DF90- 20 04 E6 1920        JSR FRETMP
DF93- 86 A8    1930        STX ARG+3
DF95- 84 A9    1940        STY ARG+4
DF97- AA       1950        TAX          LEN (ARG) STRING
DF98- 38       1960        SEC
DF99- E5 9D    1970        SBC FAC      SET X TO SMALLER LEN
DF9B- F0 08    1980        BEQ .1
DF9D- A9 01    1990        LDA #1
DF9F- 90 04    2000        BCC .1
DFA1- A6 9D    2010        LDX FAC
DFA3- A9 FF    2020        LDA #$FF
DFA5- 85 A2    2030 .1     STA FAC.SIGN      FLAG WHICH SHORTER
DFA7- A0 FF    2040        LDY #$FF
DFA9- E8       2050        INX
               2060 STRCMP.1
DFAA- C8       2070        INY
DFAB- CA       2080        DEX
DFAC- D0 07    2090        BNE STRCMP.2      MORE CHARS IN BOTH STRINGS
DFAE- A6 A2    2100        LDX FAC.SIGN   IF = SO FAR, DECIDE BY LENGTH
               2110 *--------------------------------
DFB0- 30 0F    2120 NUMCMP BMI CMPDONE
DFB2- 18       2130        CLC
DFB3- 90 0C    2140        BCC CMPDONE  ...ALWAYS
               2150 *--------------------------------
               2160 STRCMP.2
DFB5- B1 A8    2170        LDA (ARG+3),Y
DFB7- D1 9E    2180        CMP (FAC+1),Y
DFB9- F0 EF    2190        BEQ STRCMP.1      SAME, KEEP COMPARING
DFBB- A2 FF    2200        LDX #$FF          IN CASE ARG GREATER
DFBD- B0 02    2210        BCS CMPDONE       IT IS
DFBF- A2 01    2220        LDX #1            FAC GREATER
               2230 *--------------------------------
               2240 CMPDONE
DFC1- E8       2250        INX          CONVERT FF,0,1 TO 0,1,2
DFC2- 8A       2260        TXA
DFC3- 2A       2270        ROL          AND TO 0,2,4 IF C=0, ELSE 1,2,5
DFC4- 25 16    2280        AND CPRMASK  00000<=>
DFC6- F0 02    2290        BEQ .1       IF NO MATCH: FALSE
DFC8- A9 01    2300        LDA #1       AT LEAST ONE MATCH: TRUE
DFCA- 4C 93 EB 2310 .1     JMP FLOAT
               2320 *--------------------------------
               2330 *      "PDL" FUNCTION
               2340 *      <<< NOTE: ARG<4 IS NOT CHECKED >>>
               2350 *--------------------------------
DFCD- 20 FB E6 2360 PDL    JSR CONINT       GET # IN X
DFD0- 20 1E FB 2370        JSR MON.PREAD    READ PADDLE
DFD3- 4C 01 E3 2380        JMP SNGFLT       FLOAT RESULT
               2390 *--------------------------------
               2400 *      "DIM" STATEMENT
               2410 *--------------------------------
DFD6- 20 BE DE 2420 NXDIM  JSR CHKCOM   SEPARATED BY COMMAS
DFD9- AA       2430 DIM    TAX          NON-ZERO, FLAGS PTRGET DIM CALLED
DFDA- 20 E8 DF 2440        JSR PTRGET2  ALLOCATE THE ARRAY
DFDD- 20 B7 00 2450        JSR CHRGOT   NEXT CHAR
DFE0- D0 F4    2460        BNE NXDIM    NOT END OF STATEMENT
DFE2- 60       2470        RTS