
 1000  *---------------------------------
 1010  *           LINE.EDIT
 1020  *
 1030  *       BY SANDY MOSSBERG
 1040  *
 1050  *   COMMERCIAL RIGHTS RESERVED
 1060  *
 1070  *---------------------------------
 1080  * 1.PACKS PROGRAM LINE FOR EASY EDITING.
 1090  *
 1100  * 2.USES CHRGET/CHRGOT FILTER ROUTINE NOTED IN AAL 9/81.
 1110  *
 1120  * 3.CHARACTER OUTPUT ROUTINE MODIFIED FROM APSOFT ROM
 1130  *   CODE (LIST, $D6A5-$D765).
 1140  *
 1150  * 4.INSTALLATION AND USE:
 1160  *    (A) BRUN LINE.EDIT.
 1170  *    (B) COMMAND "/LINENUMBER" PRODUCES PACKED LINE AT
 1180  *        TOP OF SCREEN.
 1190  *    (C) IF CHRGET/CHRGOT VECTOR DESTROYED BY APSOFT
 1200  *        COLDSTART (]FP, *E000G, *CTL-B), RESET LINE.EDIT
 1210  *        VECTOR BY CALL 768.
 1220  *---------------------------------
 1230             .OR $300
 1240  *---------------------------------
 1250  *          APPLESOFT POINTERS
 1260  *---------------------------------
 1270  AS.FORPNT  .EQ  $85     ;HOLD Y-REGISTER
 1280  AS.LOWTR   .EQ  $9B,$9C ;LOCATION OF CHARACTER OR TOKEN IN PGM
 1290  AS.DSCTMP  .EQ  $9D,$9E ;LOCATION IN KEYWORD TABLE
 1300  *---------------------------------
 1310  *          APPLESOFT CHRGET/CHRGOT
 1320  *---------------------------------
 1330  AS.CHRGET  .EQ  $B1     ;GETS CHARACTER AT TEXT POINTER
 1340  AS.TXTPTR  .EQ  $B8,$B9 ;TEXT POINTER
 1350  AS.CHREXT  .EQ  $BA     ;CHRGET/CHRGOT VECTOR TO LINE.EDIT
 1360  AS.CHRENT  .EQ  $BE     ;RE-ENTRY TO CHRGET/CHRGOT
 1370  *---------------------------------
 1380  *          APPLESOFT ROM
 1390  *---------------------------------
 1400  AS.FNDLIN  .EQ  $D61A   ;ADDR NMBR IN LINNUM ($50,$51) TO LOWTR
 1410  AS.CRDO    .EQ  $DAFB   ;LINEFEED
 1420  AS.OUTSP   .EQ  $DB57   ;OUTPUT SPACE
 1430  AS.OUTDO   .EQ  $DB5C   ;OUTPUT CHARACTER
 1440  AS.FRMEVL  .EQ  $DD7B   ;FORMULA AT TEXT POINTER TO FAC ($9D-$A2)
 1450  AS.GETADR  .EQ  $E752   ;FAC TO INTEGER IN LINNUM ($50,$51)
 1460  AS.LINPRT  .EQ  $ED24   ;PRINT DECIMAL OF (A,X)
 1470  *---------------------------------
 1480  *          MONITOR ROM
 1490  *---------------------------------
 1500  MON.TABV   .EQ  $FB5B   ;VTAB TO VALUE IN (A)
 1510  MON.HOME   .EQ  $FC58   ;HOME CURSOR, CLEAR SCREEN
 1520  MON.BELL   .EQ  $FF3A   ;BEEP!
 1530         .PG
 1540  *---------------------------------
 1550  *  PUT LINE.EDIT VECTOR INTO CHRGET/CHRGOT
 1560  *---------------------------------
 1570  START  LDA #$4C         ;JMP 'LINE.EDIT'
 1580         STA AS.CHREXT
 1590         LDA #EDIT
 1600         STA AS.CHREXT+1
 1610         LDA /EDIT
 1620         STA AS.CHREXT+2
 1630  RTS1   RTS
 1640  *---------------------------------
 1650  *  CHECK FOR VALID COMMAND
 1660  *---------------------------------
 1670  EDIT   CMP #$2F         ;IS IT A SLASH (/)?
 1680         BNE .1           ;NO. RETURN
 1690         INC AS.TXTPTR    ;YES. BUMP TEXT POINTER
 1700         BNE .2           ;BRANCH ALWAYS
 1710  *---------------------------------
 1720  *  RETURN TO CHRGET/CHRGOT OR CALLER
 1730  *---------------------------------
 1740  .1     CMP #$3A         ;IF COLON (EOS), SET Z AND C
 1750         BCS RTS1         ; FLAGS AND RETURN TO CALLER
 1760         JMP AS.CHRENT    ;IF NOT EOS, RE-ENTER CHRGET/CHRGOT
 1770  *---------------------------------
 1780  *  FIND LOCATION OF LINE NUMBER
 1790  *---------------------------------
 1800  .2     JSR AS.FRMEVL    ;PUT LINE NUMBER INTO FAC ($9D-$A2)
 1810         JSR AS.GETADR    ;PUT FAC INTO LINNUM ($50,$51)
 1820         JSR AS.FNDLIN    ;PUT ADDR OF LINE INTO LOWTR
 1830         BCC .5           ;CARRY CLEAR IF LINE NMBR NOT FOUND
 1840  *---------------------------------
 1850  *  CLEAR SCREEN AND SET TO ROW 2, COLUMN 2
 1860  *---------------------------------
 1870         JSR MON.HOME
 1880         JSR AS.CRDO
 1890         JSR AS.OUTSP
 1900  *---------------------------------
 1910  *  PRINT LINE NUMBER
 1920  *---------------------------------
 1930         LDY #02          ;SET INDEX TO LINE NUMBER BYTES
 1940         LDA (AS.LOWTR),Y ;PUT LINE NUMBER LO
 1950         TAX              ; INTO (X)
 1960         INY
 1970         LDA (AS.LOWTR),Y ;PUT LINE NUMBER HI INTO (A)
 1980         STY AS.FORPNT    ;HOLD (Y)
 1990         JSR AS.LINPRT    ;PRINT DECIMAL OF (A,X)
 2000  *---------------------------------
 2010  *  GET CHARACTER OR TOKEN
 2020  *---------------------------------
 2030         LDA #$20         ;SPACE
 2040  .3     LDY AS.FORPNT    ;RESTORE (Y)
 2050  .4     JSR AS.OUTDO     ;PRINT CHARACTER IN (A)
 2060         INY
 2070         LDA (AS.LOWTR),Y ;GET CHARACTER OR TOKEN
 2080         BNE .8           ;IF NOT EOS (0), GET MORE
 2090         .PG
 2100  *---------------------------------
 2110  *  TWO ENDINGS -- ONE HAPPY, ONE SAD
 2120  *---------------------------------
 2130         LDA #00          ;LINE WAS FOUND. END WITH
 2140         JMP MON.TABV     ; CURSOR AT ROW 2, COLUMN 2
 2150  .5     JSR MON.BELL     ;LINE WAS NOT FOUND. END WITH
 2160         JMP AS.CRDO      ; CURSOR BELOW COMMAND INPUT
 2170  *---------------------------------
 2180  *  GET CHARACTER IN KEYWORD TABLE
 2190  *---------------------------------
 2200  .6     INY  
 2210         BNE .7
 2220         INC AS.DSCTMP+1
 2230  .7     LDA (AS.DSCTMP),Y
 2240         RTS
 2250  *---------------------------------
 2260  *  PRINT CHARACTER OR KEYWORD
 2270  *---------------------------------
 2280  .8     BPL .4           ;NON-TOKEN IS POS ASCII
 2290         SEC              ;TOKEN MINUS $7F EQUALS INDEX TO
 2300         SBC #$7F         ; LOCATION OF KEYWORD IN TABLE
 2310         TAX              ;PUT INDEX IN (X)
 2320         STY AS.FORPNT    ;HOLD (Y)
 2330         LDY #$D0         ;KEYWORD TABLE STARTS AT $D0D0
 2340         STY AS.DSCTMP
 2350         LDY #$CF
 2360         STY AS.DSCTMP+1
 2370         LDY #$FF         ;WHEN BUMPED, (Y) WILL BE ZERO
 2380  .9     DEX              ;DEC INDEX TO KEYWORD LOCATION
 2390         BEQ .11          ;WHEN (X) IS ZERO, KEYWORD LOCATED
 2400  .10    JSR .6           ;GET CHARACTER IN KEYWORD TABLE
 2410         BPL .10          ;IF POS ASCII, GET ANOTHER
 2420         BMI .9           ;IF NEG ASCII, DEC LOCATION INDEX
 2430  .11    JSR AS.OUTSP     ;PRINT SPACE
 2440  .12    JSR .6           ;GET CHARACTER IN KEYWORD TABLE
 2450         BMI .13          ;IT'S THE FINAL CHAR IN KEYWORD
 2460         JSR AS.OUTDO     ;PRINT NON-FINAL CHAR (POS ASCII)
 2470         BNE .12          ;BRANCH ALWAYS
 2480  .13    JSR AS.OUTDO     ;PRINT FINAL CHAR (NEG ASCII)
 2490         LDA #$20         ;SPACE
 2500         BNE .3           ;BRANCH ALWAYS
 2510  *---------------------------------
 2520  SIZE   .EQ *-START
 2530         .PG

