
 1000  *---------------------------------
 1010  *      INSTALL EXTENSIONS TO LANGASM
 1020  *
 1030  *      AUTHOR:  DON TAYLOR
 1040  *        DATE:  2/6/82, 4:00 PM
 1050  *
 1060  *---------------------------------
 1070         .OR $D000
 1080         .TF LANGASM.1 EXTENSIONS
 1090  *---------------------------------
 1100  DOS.REENTRY             .EQ $03D0
 1110  MON.HOME                .EQ $FC58
 1120  SCA.LOAD.CMD            .EQ $E246
 1130  SCA.SAVE.CMD            .EQ $E26E
 1140  SCA.SLOW.CMD            .EQ $E273
 1150  *---------------------------------
 1160  INSTALL.MODIFICATIONS
 1170         LDY #2            MODIFY ASSEMBLER
 1180  .1     LDA HOME.TABLE,Y  COMMAND JUMP
 1190         STA SCA.SLOW.CMD,Y
 1200         DEY
 1210         BPL .1
 1220         LDA #MON.HOME-1
 1230         STA SCA.SLOW.CMD+3
 1240         LDA /MON.HOME-1
 1250         STA SCA.SLOW.CMD+4
 1260         LDY #2
 1270  .2     LDA COPY.TABLE,Y
 1280         STA SCA.LOAD.CMD,Y
 1290         DEY
 1300         BPL .2
 1310         LDA #COPY-1
 1320         STA SCA.LOAD.CMD+3
 1330         LDA /COPY-1
 1340         STA SCA.LOAD.CMD+4
 1350         LDY #2
 1360  .3     LDA EDIT.TABLE,Y
 1370         STA SCA.SAVE.CMD,Y
 1380         DEY
 1390         BPL .3
 1400         LDA #EDIT-1
 1410         STA SCA.SAVE.CMD+3
 1420         LDA /EDIT-1
 1430         STA SCA.SAVE.CMD+4
 1440         LDA #$60       PATCH NML TO
 1450         STA $E125      MAKE IT A
 1460         LDA #$4C       SUBROUTINE
 1470         STA NML
 1480         STA $E078
 1490         LDA #NEW.NML
 1500         STA NML+1
 1510         LDA /NEW.NML
 1520         STA NML+2
 1530         RTS
 1540  *---------------------------------
 1550  HOME.TABLE .AS ^HOM^
 1560  COPY.TABLE .AS ^COP^
 1570  EDIT.TABLE .AS ^EDI^
 1580  *---------------------------------
 1590  * COPY COMMAND FOR S-C ASSEMBLER
 1600  * VERSION 4.0
 1610  *
 1620  * SOURCE: BOB SANDER-CEDERLOF 12/80
 1630  *
 1640  *---------------------------------
 1650  *
 1660  *
 1670  * NOTE: COPY FUNCTION SOURCE IS 
 1680  *       ASSEMBLED HERE...
 1690         .LIST OFF
 1700  *
 1710  *      COPY FUNCTION <COPY L1,L2,L3>
 1720  *      L1= FIRST LINE OF RANGE TO COPY
 1730  *      L2= LAST LINE OF RANGE TO COPY
 1740  *      L3= LINE BEFORE WHICH TO INSERT COPY
 1750  *
 1760  *      ROUTINE BY BOB SANDER-CEDERLOF
 1770  *      APPLE ASSEMBLY LINE 12/80
 1780  *
 1790  *---------------------------------
 1800  SS     .EQ $00,01     START OF SOURCE BLOCK
 1810  SE     .EQ $02,03     END OF SOURCE BLOCK
 1820  SL     .EQ $04,05     LENGTH OF SOURCE BLOCK
 1830  NEWPP  .EQ $06,07     NEW PROGRAM POINTER
 1840  A0L    .EQ $3A,3B
 1850  A0H    .EQ $3B
 1860  A1L    .EQ $3C,3D
 1870  A1H    .EQ $3D
 1880  A2L    .EQ $3E
 1890  A2H    .EQ $3F
 1900  A4L    .EQ $42
 1910  A4H    .EQ $43
 1920  LOMEM  .EQ $4A,4B
 1930  PP     .EQ $CA,CB
 1940  *---------------------------------
 1950  SYNX   .EQ $E05E
 1960  MFER   .EQ $E128
 1970  SCND   .EQ $E12D
 1980  SERTXT .EQ $E4F6
 1990  MON.MOVE .EQ $FE2C
 2000  *---------------------------------
 2010  ERR1   JMP SYNX
 2020  ERR2   .EQ ERR1
 2030  ERR3   JMP MFER
 2040  ERR4   .EQ ERR1
 2050  *---------------------------------
 2060  COPY
 2070         JSR SCND       GET THIRD PARAMETER
 2080         CPX #6         BE SURE WE GOT THREE
 2090         BCC ERR1       NOT ENOUGH PARAMS
 2100         LDX #A0L       FIND BEGINNING OF SOURCE
 2110         JSR SERTXT
 2120         LDA $E4        SAVE POINTER
 2130         STA SS
 2140         LDA $E5
 2150         STA SS+1
 2160         LDX #A1L       FIND END OF SOURCE BLOCK
 2170         JSR SERTXT
 2180         SEC            SAVE POINTER AND COMPUTE
 2190         LDA $E6        LENGTH
 2200         STA SE
 2210         SBC SS
 2220         STA SL         SOURCE LENGTH
 2230         LDA $E7
 2240         STA SE+1
 2250         SBC SS+1
 2260         STA SL+1
 2270         BCC ERR2       RANGE BACKWARD
 2280         BNE .4
 2290         LDA SL
 2300         BEQ ERR2       NOTHING TO MOVE
 2310  *---------------------------------
 2320  .4     LDA PP         COMPUTE NEW PP POINTER
 2330         SBC SL
 2340         STA NEWPP
 2350         LDA PP+1
 2360         SBC SL+1
 2370         STA NEWPP+1
 2380  *---------------------------------
 2390         LDA NEWPP      SEE IF ROOM FOR THIS
 2400         CMP LOMEM
 2410         LDA NEWPP+1
 2420         SBC LOMEM+1
 2430         BCC ERR3       MEM FULL ERROR
 2440  *---------------------------------
 2450         LDX #A2L       FIND TARGET LOCATION
 2460         JSR SERTXT
 2470         LDA SS         BE SURE NOT INSIDE SOURCE
 2480         CMP $E4
 2490         LDA SS+1
 2500         SBC $E5
 2510         BCS .1         BELOW SOURCE BLOCK
 2520         LDA $E4
 2530         CMP SE
 2540         LDA $E5
 2550         SBC SE+1
 2560         BCC ERR4       INSIDE SOURCE BLOCK
 2570  *  TARGET IS ABOVE SOURCE BLOCK, SO WE HAVE TO
 2580  *  ADJUST SOURCE BLOCK POINTERS.
 2590         SEC
 2600         LDA SS
 2610         SBC SL         SS=SS-SL
 2620         STA SS
 2630         LDA SS+1
 2640         SBC SL+1
 2650         STA SS+1
 2660         SEC
 2670         LDA SE
 2680         SBC SL         SE=SE-SL
 2690         STA SE
 2700         LDA SE+1
 2710         SBC SL+1
 2720         STA SE+1
 2730  *---------------------------------
 2740  .1     LDA PP         SET UP MOVE TO MAKE HOLE
 2750         STA A1L
 2760         LDA PP+1
 2770         STA A1H
 2780         LDA NEWPP
 2790         STA PP
 2800         STA A4L
 2810         LDA NEWPP+1
 2820         STA PP+1
 2830         STA A4H
 2840         LDA $E5
 2850         STA A2H
 2860         LDA $E4
 2870         STA A2L
 2880         BNE .2
 2890         DEC A2H
 2900  .2     DEC A2L        A2=A2-1
 2910         LDY #0
 2920         LDA A2L
 2930         CMP A1L
 2940         LDA A2H
 2950         SBC A1H
 2960         BCC .5
 2970         JSR MON.MOVE   A4<A1.A2M
 2980  *---------------------------------
 2990  .5     LDA SS         MOVE IN SOURCE BLOCK
 3000         STA A1L        (MON.MOVE LEFT
 3010         LDA SS+1       A4 POINTING AT FIRST
 3020         STA A1H        BYTE OF THE HOLE)
 3030         LDA SE+1
 3040         STA A2H
 3050         LDA SE
 3060         STA A2L
 3070         BNE .3
 3080         DEC A2H        A2=A2-1
 3090  .3     DEC A2L
 3100         JSR MON.MOVE   A4<A1.A2
 3110         RTS
 3120         .LIST ON
 3130  *
 3140  *
 3150  * NOTE: EDIT FUNCTION SOURCE IS 
 3160  *       ASSEMBLED HERE...
 3170         .LIST OFF
 3180  *
 3190  *
 3200  *---------------------------------
 3210  * EDIT COMMAND FOR S-C ASSEMBLER
 3220  * VERSION 4.0
 3230  *
 3240  * SOURCE: MIKE LAUMER 12/6/80
 3250  *
 3260  *---------------------------------
 3270  *
 3280  *  SYSTEM EQUATES
 3290  *---------------------------------
 3300  MON.COUT     .EQ $FDED
 3310  MON.BELL     .EQ $FF3A
 3320  MON.RDKEY    .EQ $FD0C
 3330  MON.CLREOP   .EQ $FC42
 3340  MON.VTAB     .EQ $FC22
 3350  CH           .EQ $0024
 3360  CV           .EQ $0025
 3370  *---------------------------------
 3380  *  ASSEMBLER EQUATES
 3390  *---------------------------------
 3400  GNL    .EQ $E026
 3410  NML    .EQ $E063
 3420  PLNO   .EQ $E779
 3430  GNB    .EQ $E2C5
 3440  DOIT   .EQ $E874
 3450  SEARCH .EQ $E64B
 3460  SERNXT .EQ $E4FE
 3470  NTKN   .EQ $E2AF
 3480  SRCP   .EQ $DD,DE
 3490  WBUF   .EQ $0200
 3500  CURRENT.LINE.NUMBER .EQ $D3,D4
 3510  *---------------------------------
 3520  * PATCH ROUTINES FOR ASSEMBLER
 3530  *---------------------------------
 3540  NEW.NML JSR MY.NML
 3550         JMP GNL
 3560  MY.NML LDY #0
 3570         JSR $E28D
 3580         JSR $E14A
 3590         JMP $E066
 3600  *---------------------------------
 3610  * LOCAL VARIABLES FOR EDIT COMMAND
 3620  *---------------------------------
 3630  NEXT   .DA 0
 3640  END    .DA 0
 3650  CHAR   .DA #0
 3660  EDPTR  .DA #0
 3670  FKEY   .DA #0
 3680  *---------------------------------
 3690  EDIT   DEX
 3700         DEX
 3710         BMI .2         NO ARGUMENTS
 3720         BEQ .4         1 ARGUMENT
 3730         JSR .3         2 ARGUMENTS
 3740         LDX #A1L       FIND END PTR
 3750         JSR SERNXT
 3760         LDA $E6
 3770         STA END
 3780         LDA $E7
 3790         STA END+1
 3800  .1     LDA NEXT+1
 3810         STA SRCP+1
 3820         PHA
 3830         LDA NEXT
 3840         STA SRCP
 3850         CMP END
 3860         PLA
 3870         SBC END+1      PAST END LINE?
 3880         BCS .2         YES, EXIT
 3890         JSR E.LIST     NO, LIST AND EDIT
 3900         JMP .1         TRY FOR NEXT LINE
 3910  .3     LDX #A0L       FIND START PTR
 3920         JSR SERTXT
 3930         LDA $E4
 3940         STA SRCP
 3950         STA NEXT       SAVE NEXT LINE ADRS
 3960         LDA $E5
 3970         STA SRCP+1
 3980         STA NEXT+1
 3990  .2     RTS
 4000  .4     JSR .3         SEARCH FOR LINE
 4010         BCC .2         NOT FOUND EXIT
 4020  E.LIST JSR E.POSN     POSITION FOR EDIT
 4030         JSR MON.CLREOP  PREPARE DISPLAY
 4040         JSR GNB        GET LINE SIZE
 4050         CLC
 4060         ADC NEXT       COMPUTE NEXT LINE ADRS
 4070         STA NEXT
 4080         TYA
 4090         ADC NEXT+1
 4100         STA NEXT+1
 4110         JSR GNB        GET LINE # FOR DISPLAY
 4120         STA CURRENT.LINE.NUMBER
 4130         JSR GNB
 4140         STA CURRENT.LINE.NUMBER+1
 4150         SEC
 4160         ROR $F8        STUFF WBUF FLAG
 4170         JSR PLNO
 4180         LSR $F8        TURN OFF FLAG
 4190         LDA #$20       SPACE AFTER LINE #
 4200         LDX #0
 4210  .1     STX EDPTR
 4220         ORA #$80       FORCE VIDEO BIT
 4230         STA WBUF+4,X   STORE INTO INPUT BUFFER
 4240         CMP #$A0       TEST FOR CONTROL CHAR
 4250         BCS .2         OK, IF NOT
 4260         AND #$7F       OUTPUT INVERSE ALPHA
 4270  .2     JSR MON.COUT   PRINT CHAR
 4280         JSR NTKN       GET NEXT TOKEN
 4290         LDX EDPTR
 4300         INX
 4310         CMP #0         END TOKEN?
 4320         BNE .1         NO,PRINT IT
 4330         STA WBUF+4,X   YES,PUT IT IN TOO
 4340  E.LINE LDX #0
 4350  E.0    STX EDPTR 
 4360  E.1    JSR E.INPUT    GET INPUT CHAR
 4370  E.2    LDA #EDTB
 4380         STA $2
 4390         LDA /EDTB
 4400         STA $3
 4410         LDA #CHAR
 4420         STA $12
 4430         LDA /CHAR
 4440         STA $13
 4450         JSR SEARCH     SEARCH EDIT COMMAND TABLE
 4460         BNE .2         NOT IN TABLE
 4470         LDX EDPTR
 4480         JSR DOIT       EXECUTE COMMAND ROUTINE
 4490         BCC E.0        NO DISPLAY ON RETURN
 4500         BCS .5         DISPLAY ON RETURN
 4510  .2     LDX EDPTR      MUST BE TYPE OVER
 4520         LDA CHAR
 4530         CMP #$A0
 4540         BCS .4
 4550  .3     JSR MON.BELL   ERR IF CONTROL KEY
 4560         JMP E.1
 4570  .4     LDA WBUF+5,X   SEE IT END OF LINE
 4580         BNE .6         TYPE OVER IF NOT
 4590         STA WBUF+6,X   SHIFT OVER END OF LINE
 4600  .6     LDA CHAR       STUFF CHAR INTO BUFFER
 4610         STA WBUF+5,X
 4620         CPX #256-5-2   TEST BUFFER SIZE
 4630         BEQ .5         TYPE OVER LAST CHAR IN BUFFER
 4640         INX            INSTEAD OF BUFFER END
 4650  .5     JSR E.DISP     DISPLAY LINE
 4660         JMP E.0        GET NEXT EDIT COMMAND
 4670  *---------------------------------
 4680  E.POSN LDA #19        POSITION TO LINE 19,
 4690         STA CV
 4700         LDA #0         COLUMN 0
 4710         STA CH
 4720         JMP MON.VTAB
 4730  *---------------------------------
 4740  E.DISP STX EDPTR
 4750         JSR E.POSN     POSITION DISPLAY
 4760         LDX #$FF
 4770  .1     INX
 4780         LDA WBUF,X     GET BUFFER CHAR
 4790         BEQ .3         END OF BUFFER
 4800         CMP #$A0       CONTROL CHAR?
 4810         BCS .2         NO
 4820         AND #$7F       PRINT INVERSE ALPHA
 4830  .2     JSR MON.COUT   PRINT CHAR
 4840         JMP .1         NEXT CHAR
 4850  .3     JSR MON.CLREOP CLEAN ANY REMAINING SCREEN
 4860         LDX EDPTR
 4870         RTS
 4880  *---------------------------------
 4890  E.BEG  LDX #0         SET CURSOR TO BEGINNING OF LINE
 4900         CLC
 4910         RTS
 4920  *---------------------------------
 4930  E.DEL  LDA WBUF+5,X   IS THIS END
 4940         BEQ .2
 4950  .1     INX
 4960         LDA WBUF+5,X   SHIFT TO LOWER MEMORY
 4970         STA WBUF+4,X   TO DELETE CHAR
 4980         BNE .1
 4990         LDX EDPTR
 5000  .2     SEC            RETURN WITH DISPLAY
 5010         RTS
 5020  *---------------------------------
 5030  E.END  LDA WBUF+5,X   END OF BUFFER?
 5040         BEQ .1         YES
 5050         INX            NO
 5060         BNE E.END      TRY END AGAIN
 5070  .1     CLC            RETURN NO DISPLAY
 5080         RTS
 5090  *---------------------------------
 5100  E.FIND LDA WBUF+5,X   END OF BUFFER?
 5110         BNE .2         NO
 5120  .1     STA FKEY       YES SO ERR
 5130         JSR MON.BELL   RING BELL
 5140         CLC            RETURN NO DISPLAY
 5150         RTS
 5160  .2     JSR E.INPUT    GET 1 CHAR
 5170         STA FKEY       SAVE KEY TO LOCATE
 5180  .3     INX
 5190         LDA WBUF+5,X   TEST BUFFER
 5200         BEQ .1         END OF BUFFER
 5210         CMP FKEY       NO, SEE IF KEY
 5220         BNE .3         NO, GO FORWARD
 5230         JSR E.INPUT    TRY ANOTHER KEY
 5240         CMP FKEY       SAME CHAR?
 5250         BEQ .3         YES, SEARCH AGAIN
 5260         PLA
 5270         PLA
 5280         STX EDPTR      NO, EXIT POINTING HERE
 5290         JMP E.2
 5300  *---------------------------------
 5310  E.BKSP TXA            AT BEGINNING?
 5320         BEQ .1         YES, STAY THERE
 5330         DEX            BACKUP
 5340  .1     CLC            RETURN NO DISPLAY
 5350         RTS
 5360  *---------------------------------
 5370  E.OVR  JSR E.INPUT    READ CHAR
 5380         JMP E.INS1     SKIP CONTROL CHECK
 5390  *---------------------------------
 5400  E.INS  JSR E.INPUT    READ CHAR
 5410         CMP #$A0       CONTROL CHAR POPS USER OUT
 5420         BCC E.INS2     OF INSERT
 5430  E.INS1 CPX #256-5-2   END OF BLOCK
 5440         BEQ .1         YES STAY THERE
 5450         INX
 5460  .1     STX EDPTR
 5470  .2     PHA            CHAR TO INSERT
 5480         LDA WBUF+4,X   SAVE CHAR TO MOVE
 5490         TAY
 5500         PLA            GET CHAR TO INSERT
 5510         STA WBUF+4,X   PUT OVER SAVED CHAR
 5520         INX
 5530         TYA            INSERT SAVED CHAR
 5540         BNE .2         IF NOT BUFFER END
 5550         STA WBUF+4,X   STUFF END CODE
 5560         STA WBUF+256-5-1 INSURE AN END CODE
 5570         LDX EDPTR
 5580         JSR E.DISP     DISPLAY LINE
 5590         JMP E.INS      GET NEXT INSERT CHAR
 5600  E.INS2 PLA            SEND CHAR TO
 5610         PLA            COMMAND SEARCH
 5620         LDX EDPTR
 5630  *---------------------------------
 5640         JMP E.2
 5650  E.RETQ LDA #0         CLEAR REST OF LINE
 5660         STA WBUF+5,X
 5670         JSR E.DISP     DISPLAY LINE
 5680  E.RET  LDX #$FF       SUBMIT LINE TO ASSEMBLER
 5690  .1     INX            COMPUTE LINE SIZE
 5700         LDA WBUF,X
 5710         BNE .1
 5720         DEX
 5730  .2     STX $E1        SAVE SIZE
 5740         PLA
 5750         PLA
 5760         JMP MY.NML     SUBMIT THE LINE
 5770  *---------------------------------
 5780  E.TAB  CPX #20        <COL 20?
 5790         BCS .1         NO
 5800         LDA WBUF+5,X   END OF BUFFER?
 5810         BEQ .1         YES
 5820         INX            MOVE FORWARD
 5830         CPX #7         TAB MATCH?
 5840         BEQ .1
 5850         CPX #11        TAB MATCH?
 5860         BNE E.TAB
 5870  .1     CLC            RETURN WITHOUT DISPLAY
 5880         RTS
 5890  *---------------------------------
 5900  E.RIT  LDA WBUF+5,X   END OF BUFFER?
 5910         BNE .1         NO
 5920         STA WBUF+6,X
 5930         LDA #$A0       PUT A BLANK
 5940         STA WBUF+5,X   TO EXTEND LINE
 5950         CPX #256-5-2
 5960         BEQ .2
 5970  .1     INX            MOVE AHEAD
 5980  .2     CLC            RETURN NO DISPLAY
 5990         RTS
 6000  *---------------------------------
 6010  E.ABORT LDA #$DC      OUTPUT BACKSLASH
 6020         STA WBUF+5
 6030         LDA #0
 6040         STA WBUF+6
 6050         JSR E.DISP     SHOW CANCEL
 6060         JMP GNL        GET NEXT COMMAND
 6070  *---------------------------------
 6080  E.INPUT LDA #19
 6090         STA CV
 6100         TXA            POSITION TO CURSOR
 6110         CLC
 6120         ADC #5
 6130  .1     CMP #40        THIS LINE?
 6140         BCC .2         YES
 6150         SEC
 6160         SBC #40
 6170         INC CV         ON NEXT LINE
 6180         BNE .1
 6190  .2     STA CH
 6200         JSR MON.VTAB   SET BASL
 6210         JSR MON.RDKEY  INPUT A CHAR
 6220         STA CHAR
 6230         RTS
 6240  *---------------------------------
 6250  *  COMMAND TABLE
 6260  *---------------------------------
 6270  EDTB   .DA #3,#1      ITEM SIZE, KEY SIZE
 6280         .DA #$82,E.BEG-1   ^B
 6290         .DA #$84,E.DEL-1   ^D
 6300         .DA #$8E,E.END-1   ^N
 6310         .DA #$86,E.FIND-1  ^F
 6320         .DA #$88,E.BKSP-1  ^H
 6330         .DA #$89,E.INS-1   ^I
 6340         .DA #$8D,E.RET-1   ^M
 6350         .DA #$8F,E.OVR-1   ^O
 6360         .DA #$91,E.RETQ-1  ^Q
 6370         .DA #$94,E.TAB-1   ^T
 6380         .DA #$95,E.RIT-1   ^U
 6390         .DA #$98,E.ABORT-1 ^X
 6400         .DA #0
 6410         .EN

