S-C DocuMentor — Applesoft

               SAVE S.F1D5
               1010 *--------------------------------
               1020 *      "CALL" STATEMENT
               1030 *
               1040 *      EFFECTIVELY PERFORMS A "JSR" TO THE SPECIFIED
               1050 *      ADDRESS, WITH THE FOLLOWING REGISTER CONTENTS:
               1060 *           (A,Y) = CALL ADDRESS
               1070 *           (X)   = $9D
               1080 *
               1090 *      THE CALLED ROUTINE CAN RETURN WITH "RTS",
               1100 *      AND APPLESOFT WILL CONTINUE WITH THE NEXT
               1110 *      STATEMENT.
               1120 *--------------------------------
F1D5- 20 67 DD 1130 CALL   JSR FRMNUM   EVALUATE EXPRESSION FOR CALL ADDRESS
F1D8- 20 52 E7 1140        JSR GETADR   CONVERT EXPRESSION TO 16-BIT INTEGER
F1DB- 6C 50 00 1150        JMP (LINNUM)     IN LINNUM, AND JUMP THERE.
               1160 *--------------------------------
               1170 *      "IN#" STATEMENT
               1180 *
               1190 *      NOTE:  NO CHECK FOR VALID SLOT #, AS LONG
               1200 *      AS VALUE IS < 256 IT IS ACCEPTED.
               1210 *      MONITOR MASKS VALUE TO 4 BITS (0-15).
               1220 *--------------------------------
               1230 IN.NUMBER
F1DE- 20 F8 E6 1240        JSR GETBYT   GET SLOT NUMBER IN X-REG
F1E1- 8A       1250        TXA          MONITOR WILL INSTALL IN VECTOR
F1E2- 4C 8B FE 1260        JMP MON.INPORT    AT $38,39.
               1270 *--------------------------------
               1280 *      "PR#" STATEMENT
               1290 *
               1300 *      NOTE:  NO CHECK FOR VALID SLOT #, AS LONG
               1310 *      AS VALUE IS < 256 IT IS ACCEPTED.
               1320 *      MONITOR MASKS VALUE TO 4 BITS (0-15).
               1330 *--------------------------------
               1340 PR.NUMBER
F1E5- 20 F8 E6 1350        JSR GETBYT   GET SLOT NUMBER IN X-REG
F1E8- 8A       1360        TXA          MONITOR WILL INSTALL IN VECTOR
F1E9- 4C 95 FE 1370        JMP MON.OUTPORT   AT $36,37
               1380 *--------------------------------
               1390 *      GET TWO VALUES < 48, WITH COMMA SEPARATOR
               1400 *
               1410 *      CALLED FOR "PLOT X,Y" 
               1420 *             AND "HLIN A,B AT Y"
               1430 *             AND "VLIN A,B AT X"
               1440 *
               1450 *--------------------------------
               1460 PLOTFNS
F1EC- 20 F8 E6 1470        JSR GETBYT   GET FIRST VALUE IN X-REG
F1EF- E0 30    1480        CPX #48      MUST BE < 48
F1F1- B0 13    1490        BCS GOERR    TOO LARGE
F1F3- 86 F0    1500        STX FIRST    SAVE FIRST VALUE
F1F5- A9 2C    1510        LDA #','     MUST HAVE A COMMA
F1F7- 20 C0 DE 1520        JSR SYNCHR
F1FA- 20 F8 E6 1530        JSR GETBYT   GET SECOND VALUE IN X-REG
F1FD- E0 30    1540        CPX #48      MUST BE < 48
F1FF- B0 05    1550        BCS GOERR    TOO LARGE
F201- 86 2C    1560        STX MON.H2   SAVE SECOND VALUE
F203- 86 2D    1570        STX MON.V2
F205- 60       1580        RTS          SECOND VALUE STILL IN X-REG
               1590 *--------------------------------
F206- 4C 99 E1 1600 GOERR  JMP IQERR    ILLEGAL QUANTITY ERROR
               1610 *--------------------------------
               1620 *      GET "A,B AT C" VALUES FOR "HLIN" AND "VLIN"
               1630 *
               1640 *      PUT SMALLER OF (A,B) IN FIRST,
               1650 *      AND LARGER  OF (A,B) IN H2 AND V2.
               1660 *      RETURN WITH (X) = C-VALUE.
               1670 *--------------------------------
               1680 LINCOOR
F209- 20 EC F1 1690        JSR PLOTFNS  GET A,B VALUES
F20C- E4 F0    1700        CPX FIRST    IS A < B?
F20E- B0 08    1710        BCS .1       YES, IN RIGHT ORDER
F210- A5 F0    1720        LDA FIRST    NO, INTERCHANGE THEM
F212- 85 2C    1730        STA MON.H2
F214- 85 2D    1740        STA MON.V2
F216- 86 F0    1750        STX FIRST
F218- A9 C5    1760 .1     LDA #TOKEN.AT     MUST HAVE "AT" NEXT
F21A- 20 C0 DE 1770        JSR SYNCHR
F21D- 20 F8 E6 1780        JSR GETBYT   GET C-VALUE IN X-REG
F220- E0 30    1790        CPX #48      MUST BE < 48
F222- B0 E2    1800        BCS GOERR    TOO LARGE
F224- 60       1810        RTS          C-VALUE IN X-REG
               1820 *--------------------------------
               1830 *      "PLOT" STATEMENT
               1840 *--------------------------------
F225- 20 EC F1 1850 PLOT   JSR PLOTFNS  GET X,Y VALUES
F228- 8A       1860        TXA          Y-COORD TO A-REG FOR MONITOR
F229- A4 F0    1870        LDY FIRST    X-COORD TO Y-YEG FOR MONITOR
F22B- C0 28    1880        CPY #40      X-COORD MUST BE < 40
F22D- B0 D7    1890        BCS GOERR    X-COORD IS TOO LARGE
F22F- 4C 00 F8 1900        JMP MON.PLOT      PLOT!
               1910 *--------------------------------
               1920 *      "HLIN" STATEMENT
               1930 *--------------------------------
F232- 20 09 F2 1940 HLIN   JSR LINCOOR  GET "A,B AT C"
F235- 8A       1950        TXA          Y-COORD IN A-REG
F236- A4 2C    1960        LDY MON.H2   RIGHT END OF LINE
F238- C0 28    1970        CPY #40      MUST BE < 40
F23A- B0 CA    1980        BCS GOERR    TOO LARGE
F23C- A4 F0    1990        LDY FIRST    LEFT END OF LINE IN Y-REG
F23E- 4C 19 F8 2000        JMP MON.HLINE     LET MONITOR DRAW LINE
               2010 *--------------------------------
               2020 *      "VLIN" STATEMENT
               2030 *--------------------------------
F241- 20 09 F2 2040 VLIN  JSR LINCOOR   GET "A,B AT C"
F244- 8A       2050        TXA          X-COORD IN Y-REG
F245- A8       2060        TAY
F246- C0 28    2070        CPY #40      X-COORD MUST BE < 40
F248- B0 BC    2080        BCS GOERR    TOO LARGE
F24A- A5 F0    2090        LDA FIRST    TOP END OF LINE IN A-REG
F24C- 4C 28 F8 2100        JMP MON.VLINE     LET MONITOR DRAW LINE
               2110 *--------------------------------
               2120 *      "COLOR=" STATEMENT
               2130 *--------------------------------
F24F- 20 F8 E6 2140 COLOR  JSR GETBYT   GET COLOR VALUE IN X-REG
F252- 8A       2150        TXA
F253- 4C 64 F8 2160        JMP MON.SETCOL    LET MONITOR STORE COLOR
               2170 *--------------------------------
               2180 *      "VTAB" STATEMENT
               2190 *--------------------------------
F256- 20 F8 E6 2200 VTAB   JSR GETBYT   GET LINE # IN X-REG
F259- CA       2210        DEX          CONVERT TO ZERO BASE
F25A- 8A       2220        TXA
F25B- C9 18    2230        CMP #24      MUST BE 0-23
F25D- B0 A7    2240        BCS GOERR    TOO LARGE, OR WAS "VTAB 0"
F25F- 4C 5B FB 2250        JMP MON.TABV      LET MONITOR COMPUTE BASE
               2260 *--------------------------------
               2270 *      "SPEED=" STATEMENT
               2280 *--------------------------------
F262- 20 F8 E6 2290 SPEED  JSR GETBYT   GET SPEED SETTING IN X-REG
F265- 8A       2300        TXA          SPEEDZ = $100-SPEED
F266- 49 FF    2310        EOR #$FF     SO "SPEED=255" IS FASTEST
F268- AA       2320        TAX
F269- E8       2330        INX
F26A- 86 F1    2340        STX SPEEDZ
F26C- 60       2350        RTS
               2360 *--------------------------------
               2370 *      "TRACE" STATEMENT
               2380 *      SET SIGN BIT IN TRCFLG
               2390 *--------------------------------
F26D- 38       2400 TRACE SEC
F26E- 90       2410        .HS 90       FAKE BCC TO SKIP NEXT OPCODE
               2420 *--------------------------------
               2430 *      "NOTRACE" STATEMENT
               2440 *      CLEAR SIGN BIT IN TRCFLG
               2450 *--------------------------------
               2460 NOTRACE
F26F- 18       2470        CLC
F270- 66 F2    2480        ROR TRCFLG   SHIFT CARRY INTO TRCFLG
F272- 60       2490        RTS
               2500 *--------------------------------
               2510 *      "NORMAL" STATEMENT
               2520 *--------------------------------
F273- A9 FF    2530 NORMAL LDA #$FF     SET INVFLG = $FF
F275- D0 02    2540        BNE N.I.     AND FLASH.BIT = $00
               2550 *--------------------------------
               2560 *      "INVERSE" STATEMENT
               2570 *--------------------------------
               2580 INVERSE
F277- A9 3F    2590        LDA #$3F     SET INVFLG = $3F
F279- A2 00    2600 N.I.   LDX #0       AND FLASH.BIT = $00
F27B- 85 32    2610 N.I.F. STA MON.INVFLG
F27D- 86 F3    2620        STX FLASH.BIT
F27F- 60       2630        RTS
               2640 *--------------------------------
               2650 *      "FLASH" STATEMENT
               2660 *--------------------------------
F280- A9 7F    2670 FLASH  LDA #$7F     SET INVFLG = $7F
F282- A2 40    2680        LDX #$40     AND FLASH.BIT = $40
F284- D0 F5    2690        BNE N.I.F.   ...ALWAYS
               2700 *--------------------------------
               2710 *      "HIMEM:" STATEMENT
               2720 *--------------------------------
F286- 20 67 DD 2730 HIMEM  JSR FRMNUM   GET VALUE SPECIFIED FOR HIMEM
F289- 20 52 E7 2740        JSR GETADR   AS 16-BIT INTEGER
F28C- A5 50    2750        LDA LINNUM   MUST BE ABOVE VARIABLES AND ARRAYS
F28E- C5 6D    2760        CMP STREND
F290- A5 51    2770        LDA LINNUM+1
F292- E5 6E    2780        SBC STREND+1
F294- B0 03    2790        BCS SETHI    IT IS ABOVE THEM
F296- 4C 10 D4 2800 JMM    JMP MEMERR   NOT ENOUGH MEMORY
F299- A5 50    2810 SETHI  LDA LINNUM   STORE NEW HIMEM: VALUE
F29B- 85 73    2820        STA MEMSIZ
F29D- 85 6F    2830        STA FRETOP   <<<NOTE THAT "HIMEM:" DOES NOT>>>
F29F- A5 51    2840        LDA LINNUM+1 <<<CLEAR STRING VARIABLES.    >>>
F2A1- 85 74    2850        STA MEMSIZ+1 <<<THIS COULD BE DISASTROUS.  >>>
F2A3- 85 70    2860        STA FRETOP+1
F2A5- 60       2870        RTS
               2880 *--------------------------------
               2890 *      "LOMEM:" STATEMENT
               2900 *--------------------------------
F2A6- 20 67 DD 2910 LOMEM  JSR FRMNUM   GET VALUE SPECIFIED FOR LOMEM
F2A9- 20 52 E7 2920        JSR GETADR   AS 16-BIT INTEGER IN LINNUM
F2AC- A5 50    2930        LDA LINNUM   MUST BE BELOW HIMEM
F2AE- C5 73    2940        CMP MEMSIZ
F2B0- A5 51    2950        LDA LINNUM+1
F2B2- E5 74    2960        SBC MEMSIZ+1
F2B4- B0 E0    2970        BCS JMM      ABOVE HIMEM, MEMORY ERROR
F2B6- A5 50    2980        LDA LINNUM   MUST BE ABOVE PROGRAM
F2B8- C5 69    2990        CMP VARTAB
F2BA- A5 51    3000        LDA LINNUM+1
F2BC- E5 6A    3010        SBC VARTAB+1
F2BE- 90 D6    3020        BCC JMM      NOT ABOVE PROGRAM, ERROR
F2C0- A5 50    3030        LDA LINNUM   STORE NEW LOMEM VALUE
F2C2- 85 69    3040        STA VARTAB
F2C4- A5 51    3050        LDA LINNUM+1
F2C6- 85 6A    3060        STA VARTAB+1
F2C8- 4C 6C D6 3070        JMP CLEARC   LOMEM CLEARS VARIABLES AND ARRAYS
               3080 *--------------------------------
               3090 *      "ON ERR GO TO" STATEMENT
               3100 *--------------------------------
F2CB- A9 AB    3110 ONERR  LDA #TOKEN.GOTO   MUST BE "GOTO" NEXT
F2CD- 20 C0 DE 3120        JSR SYNCHR
F2D0- A5 B8    3130        LDA TXTPTR   SAVE TXTPTR FOR HANDLERR
F2D2- 85 F4    3140        STA TXTPSV
F2D4- A5 B9    3150        LDA TXTPTR+1
F2D6- 85 F5    3160        STA TXTPSV+1
F2D8- 38       3170        SEC          SET SIGN BIT OF ERRFLG
F2D9- 66 D8    3180        ROR ERRFLG
F2DB- A5 75    3190        LDA CURLIN   SAVE LINE # OF CURRENT LINE
F2DD- 85 F6    3200        STA CURLSV
F2DF- A5 76    3210        LDA CURLIN+1
F2E1- 85 F7    3220        STA CURLSV+1
F2E3- 20 A6 D9 3230        JSR REMN     IGNORE REST OF LINE <<<WHY?>>>
F2E6- 4C 98 D9 3240        JMP ADDON    CONTINUE PROGRAM
               3250 *--------------------------------
               3260 *      ROUTINE TO HANDLE ERRORS IF ONERR GOTO ACTIVE
               3270 *--------------------------------
               3280 HANDLERR
F2E9- 86 DE    3290        STX ERRNUM   SAVE ERROR CODE NUMBER
F2EB- A6 F8    3300        LDX REMSTK   GET STACK PNTR SAVED AT NEWSTT
F2ED- 86 DF    3310        STX ERRSTK   REMEMBER IT
               3320 *                   <<<COULD ALSO HAVE DONE TXS  >>>
               3330 *                   <<<HERE; SEE ONERR CORRECTION>>>
               3340 *                   <<<IN APPLESOFT MANUAL.      >>>
F2EF- A5 75    3350        LDA CURLIN   GET LINE # OF OFFENDING STATEMENT
F2F1- 85 DA    3360        STA ERRLIN   SO USER CAN SEE IT IF DESIRED
F2F3- A5 76    3370        LDA CURLIN+1
F2F5- 85 DB    3380        STA ERRLIN+1
F2F7- A5 79    3390        LDA OLDTEXT  ALSO THE POSITION IN THE LINE
F2F9- 85 DC    3400        STA ERRPOS   IN CASE USER WANTS TO "RESUME"
F2FB- A5 7A    3410        LDA OLDTEXT+1
F2FD- 85 DD    3420        STA ERRPOS+1
F2FF- A5 F4    3430        LDA TXTPSV   SET UP TXTPTR TO READ TARGET LINE #
F301- 85 B8    3440        STA TXTPTR   IN "ON ERR GO TO XXXX"
F303- A5 F5    3450        LDA TXTPSV+1
F305- 85 B9    3460        STA TXTPTR+1
F307- A5 F6    3470        LDA CURLSV
F309- 85 75    3480        STA CURLIN   LINE # OF "ON ERR" STATEMENT
F30B- A5 F7    3490        LDA CURLSV+1
F30D- 85 76    3500        STA CURLIN+1
F30F- 20 B7 00 3510        JSR CHRGOT   START CONVERSION
F312- 20 3E D9 3520        JSR GOTO     GOTO SPECIFIED ONERR LINE
F315- 4C D2 D7 3530        JMP NEWSTT
               3540 *--------------------------------
               3550 *      "RESUME" STATEMENT
               3560 *--------------------------------
F318- A5 DA    3570 RESUME LDA ERRLIN   RESTORE LINE # AND TXTPTR
F31A- 85 75    3580        STA CURLIN   TO RE-TRY OFFENDING LINE
F31C- A5 DB    3590        LDA ERRLIN+1
F31E- 85 76    3600        STA CURLIN+1
F320- A5 DC    3610        LDA ERRPOS
F322- 85 B8    3620        STA TXTPTR
F324- A5 DD    3630        LDA ERRPOS+1
F326- 85 B9    3640        STA TXTPTR+1
               3650 *  <<< ONERR CORRECTION IN MANUAL IS EASILY >>>
               3660 *  <<< BY "CALL -3288", WHICH IS $F328 HERE >>>
F328- A6 DF    3670        LDX ERRSTK   RETRIEVE STACK PNTR AS IT WAS
F32A- 9A       3680        TXS          BEFORE STATEMENT SCANNED
F32B- 4C D2 D7 3690        JMP NEWSTT   DO STATEMENT AGAIN
               3700 *--------------------------------
F32E- 4C C9 DE 3710 JSYN   JMP SYNERR
               3720 *--------------------------------
               3730 *      "DEL" STATEMENT
               3740 *--------------------------------
F331- B0 FB    3750 DEL    BCS JSYN     ERROR IF # NOT SPECIFIED
F333- A6 AF    3760        LDX PRGEND
F335- 86 69    3770        STX VARTAB
F337- A6 B0    3780        LDX PRGEND+1
F339- 86 6A    3790        STX VARTAB+1
F33B- 20 0C DA 3800        JSR LINGET   GET BEGINNING OF RANGE
F33E- 20 1A D6 3810        JSR FNDLIN   FIND THIS LINE OR NEXT
F341- A5 9B    3820        LDA LOWTR    UPPER PORTION OF PROGRAM WILL
F343- 85 60    3830        STA DEST     BE MOVED DOWN TO HERE
F345- A5 9C    3840        LDA LOWTR+1
F347- 85 61    3850        STA DEST+1
F349- A9 2C    3860        LDA #','     MUST HAVE A COMMA NEXT
F34B- 20 C0 DE 3870        JSR SYNCHR
F34E- 20 0C DA 3880        JSR LINGET   GET END RANGE
               3890 *                   (DOES NOTHING IF END RANGE
               3900 *                   IS NOT SPECIFIED)
F351- E6 50    3910        INC LINNUM   POINT ONE PAST IT
F353- D0 02    3920        BNE .1
F355- E6 51    3930        INC LINNUM+1
F357- 20 1A D6 3940 .1     JSR FNDLIN   FIND START LINE AFTER SPECIFIED LINE
F35A- A5 9B    3950        LDA LOWTR    WHICH IS BEGINNING OF PORTION
F35C- C5 60    3960        CMP DEST     TO BE MOVED DOWN
F35E- A5 9C    3970        LDA LOWTR+1  IT MUST BE ABOVE THE TARGET
F360- E5 61    3980        SBC DEST+1
F362- B0 01    3990        BCS .2       IT IS OKAY
F364- 60       4000        RTS          NOTHING TO DELETE
F365- A0 00    4010 .2     LDY #0       MOVE UPPER PORTION DOWN NOW
F367- B1 9B    4020 .3     LDA (LOWTR),Y     SOURCE . . .
F369- 91 60    4030        STA (DEST),Y      ...TO DESTINATION
F36B- E6 9B    4040        INC LOWTR         BUMP SOURCE PNTR
F36D- D0 02    4050        BNE .4
F36F- E6 9C    4060        INC LOWTR+1
F371- E6 60    4070 .4     INC DEST          BUMP DESTINATION PNTR
F373- D0 02    4080        BNE .5
F375- E6 61    4090        INC DEST+1
F377- A5 69    4100 .5     LDA VARTAB        REACHED END OF PROGRAM YET?
F379- C5 9B    4110        CMP LOWTR
F37B- A5 6A    4120        LDA VARTAB+1
F37D- E5 9C    4130        SBC LOWTR+1
F37F- B0 E6    4140        BCS .3            NO, KEEP MOVING
F381- A6 61    4150        LDX DEST+1        STORE NEW END OF PROGRAM
F383- A4 60    4160        LDY DEST          MUST SUBTRACT 1 FIRST
F385- D0 01    4170        BNE .6
F387- CA       4180        DEX
F388- 88       4190 .6     DEY
F389- 86 6A    4200        STX VARTAB+1
F38B- 84 69    4210        STY VARTAB
F38D- 4C F2 D4 4220        JMP FIX.LINKS  RESET LINKS AFTER A DELETE
               4230 *--------------------------------
               4240 *      "GR" STATEMENT
               4250 *--------------------------------
F390- AD 56 C0 4260 GR     LDA SW.LORES
F393- AD 53 C0 4270        LDA SW.MIXSET
F396- 4C 40 FB 4280        JMP MON.SETGR
               4290 *--------------------------------
               4300 *      "TEXT" STATEMENT
               4310 *--------------------------------
F399- AD 54 C0 4320 TEXT   LDA SW.LOWSCR     JMP $FB36 WOULD HAVE
F39C- 4C 39 FB 4330        JMP MON.SETTXT    DONE BOTH OF THESE
               4340 * <<<       BETTER CODE WOULD BE:   >>>
               4350 * <<<  LDA SW.MIXSET                >>>
               4360 * <<<  JMP $FB33                    >>>
               4370 *--------------------------------
               4380 *      "STORE" STATEMENT
               4390 *--------------------------------
F39F- 20 D9 F7 4400 STORE  JSR GETARYPT GET ADDRESS OF ARRAY TO BE SAVED
F3A2- A0 03    4410        LDY #3       FORWARD OFFSET - 1 IS SIZE OF
F3A4- B1 9B    4420        LDA (LOWTR),Y     THIS ARRAY
F3A6- AA       4430        TAX
F3A7- 88       4440        DEY
F3A8- B1 9B    4450        LDA (LOWTR),Y
F3AA- E9 01    4460        SBC #1
F3AC- B0 01    4470        BCS .1
F3AE- CA       4480        DEX
F3AF- 85 50    4490 .1     STA LINNUM
F3B1- 86 51    4500        STX LINNUM+1
F3B3- 20 CD FE 4510        JSR MON.WRITE
F3B6- 20 BC F7 4520        JSR TAPEPNT
F3B9- 4C CD FE 4530        JMP MON.WRITE
               4540 *--------------------------------
               4550 *      "RECALL" STATEMENT
               4560 *--------------------------------
F3BC- 20 D9 F7 4570 RECALL JSR GETARYPT   FIND ARRAY IN MEMORY
F3BF- 20 FD FE 4580        JSR MON.READ      READ HEADER
F3C2- A0 02    4590        LDY #2         MAKE SURE THE NEW DATA FITS
F3C4- B1 9B    4600        LDA (LOWTR),Y
F3C6- C5 50    4610        CMP LINNUM
F3C8- C8       4620        INY
F3C9- B1 9B    4630        LDA (LOWTR),Y
F3CB- E5 51    4640        SBC LINNUM+1
F3CD- B0 03    4650        BCS .1         IT FITS
F3CF- 4C 10 D4 4660        JMP MEMERR     DOESN'T FIT
F3D2- 20 BC F7 4670 .1     JSR TAPEPNT    READ THE DATA
F3D5- 4C FD FE 4680        JMP MON.READ