
 1000         .TF B.PRETTY.LISTER
 1010         .LIST OFF
 1020  *---------------------------------
 1030  *      INTEGER BASIC PRETTY-LIST
 1040  *---------------------------------
 1050  LINE.LENGTH         .EQ $00
 1060  LINE.POSITION       .EQ $01
 1070  MON.CH              .EQ $24
 1080  PP     .EQ $CA,CB
 1090  HIMEM  .EQ $4C,4D
 1100  SRCP   .EQ $E2,E3
 1110  TKNP   .EQ $CE,CF
 1120  IB.FLAG    .EQ $EA
 1130  IB.FILL    .EQ $FA
 1140  *---------------------------------
 1150  DOS.REENTRY         .EQ $3D0
 1160  GET.NEXT.BYTE       .EQ $E02A
 1170  TOKEN.TABLE         .EQ $ED00
 1180  MON.COUT            .EQ $FDED
 1190  MON.CROUT           .EQ $FD8E
 1200  *---------------------------------
 1210  TOKEN.EOL           .EQ $01
 1220  TOKEN.COLON         .EQ $03
 1230  TOKEN.REM           .EQ $5D
 1240  TOKEN.QUOTE         .EQ $28
 1250  *---------------------------------
 1260  PRETTY.LIST
 1270         LDA PP
 1280         STA SRCP
 1290         LDA PP+1
 1300         STA SRCP+1
 1310  .1     LDA SRCP     SEE IF AT END
 1320         CMP HIMEM
 1330         LDA SRCP+1
 1340         SBC HIMEM+1
 1350         BCS .2       FINISHED
 1360         JSR PRINT.ONE.LINE
 1370         JMP .1
 1380  .2     JMP DOS.REENTRY
 1390  *---------------------------------
 1400  PRINT.ONE.LINE
 1410         LDA #0
 1420         STA LINE.POSITION
 1430         LDA #$A0     SET UP PRINT.DECIMAL FOR RJBF
 1440         STA IB.FILL
 1450         JSR GET.NEXT.BYTE SKIP OVER BYTE COUNT
 1460         TYA          (A)=0
 1470  .1     STA IB.FLAG
 1480         JSR GET.NEXT.BYTE GET LINE NUMBER
 1490         TAX          LOW BYTE
 1500         JSR GET.NEXT.BYTE HIGH BYTE
 1510         JSR PRINT.DECIMAL  PRINT THE LINE NUMBER RJBF
 1520  .2     LDA #-7      WITHIN 7 OF END OF LINE
 1530         JSR CHECK.EOL.GET.NEXT.BYTE
 1540         STY IB.FILL  CLEAR RJBF
 1550         TAX          TEST BYTE AND SAVE IN X-REG
 1560         BPL .6       TOKEN
 1570         ASL
 1580         BPL .1       CONSTANT, GO PRINT IT
 1590         LDA IB.FLAG
 1600         BNE .3       DO NOT NEED A BLANK
 1610         LDA #$A0
 1620         STA IB.FLAG
 1630         JSR CHAR.OUT
 1640  .3     TXA          RETRIEVE BYTE
 1650  .4     JSR CHAR.OUT AND PRINT IT
 1660  .5     LDA #-3      WITHIN 3 OF EOL
 1670         JSR CHECK.EOL.GET.NEXT.BYTE
 1680         TAX          TEST BYTE, SAVE IN X-REG
 1690         BMI .4       NORMAL CHAR
 1700         STA IB.FLAG
 1710  *---------------------------------
 1720  .6     CMP #TOKEN.EOL
 1730         BNE .7       NOT END OF LINE
 1740         JMP MON.CROUT   END OF LINE
 1750  .7     CMP #TOKEN.COLON
 1760         BNE .8
 1770         JSR CR.7.BLANKS
 1780         LDA #TOKEN.COLON
 1790  .8     PHA          SAVE TOKEN
 1800         JSR FIND.TOKEN
 1810         BIT IB.FLAG
 1820         BMI .9
 1830         JSR $EFF8
 1840  .9     LDA (TKNP),Y  GET CHAR OF TOKEN NAME
 1850         BPL .10
 1860         TAX          SAVE CHAR IN X
 1870         AND #$3F
 1880         STA IB.FLAG
 1890         CLC
 1900         ADC #$A0
 1910         JSR CHAR.OUT
 1920         DEY
 1930         CPX #$C0
 1940         BCC .9
 1950  .10    JSR $E00C
 1960         PLA          GET ORIGINAL UNMOLESTED TOKEN
 1970         CMP #TOKEN.REM
 1980         BEQ .5       REM
 1990         CMP #TOKEN.QUOTE
 2000         BEQ .5       QUOTATION
 2010         BNE .2       NEITHER
 2020  *---------------------------------
 2030  FIND.TOKEN
 2040         LDX #TOKEN.TABLE
 2050         STX TKNP
 2060         LDX /TOKEN.TABLE
 2070         CMP #$51     SEE IF NEED OTHER HALF TOKEN.TABLE
 2080         BCC .1       NO
 2090         DEX          YES
 2100         SBC #$50
 2110  .1     STX TKNP+1
 2120  .2     PHA          SAVE MODIFIED TOKEN ON STACK
 2130         LDA (TKNP),Y  Y GOES 0,FF,FE,...
 2140  .3     TAX
 2150         DEY
 2160         LDA (TKNP),Y LOOK FOR NEGATIVE BYTE
 2170         BPL .3
 2180         CPX #$C0     IF BYTE BEFORE NEGATIVE BYTE IS
 2190         BCS .4       BTWN $C0 AND $FF, THEN
 2200         CPX #$00     KEEP LOOKING
 2210         BMI .3
 2220  .4     TAX
 2230         PLA
 2240         SBC #1       DECREMENT TOKEN
 2250         BNE .2       NOT THERE YET
 2260         RTS
 2270  *---------------------------------
 2280  CHECK.EOL.GET.NEXT.BYTE
 2290         CLC
 2300         ADC LINE.LENGTH
 2310         CMP LINE.POSITION
 2320         BCS .1
 2330         JSR CR.7.BLANKS
 2340  .1     JMP GET.NEXT.BYTE
 2350  *---------------------------------
 2360  CR.7.BLANKS
 2370         LDA #$8D
 2380         LDY #7
 2390         STY LINE.POSITION
 2400  .1     JSR CHAR.OUT
 2410         LDA #$A0
 2420         DEY
 2430         BNE .1
 2440         RTS
 2450  *---------------------------------
 2460  CHAR.OUT
 2470         INC LINE.POSITION
 2480         JMP MON.COUT
 2490  *---------------------------------
 2500  PRINT.DECIMAL
 2510         STA $F3
 2520         STX $F2
 2530         LDX #4
 2540         STA $C9      LEADING ZERO FLAG
 2550  .7     LDA #$B0
 2560         STA $F9
 2570  .1     LDA $F2
 2580         CMP $E563,X
 2590         LDA $F3
 2600         SBC $E568,X
 2610         BCC .2
 2620         STA $F3
 2630         LDA $F2
 2640         SBC $E563,X
 2650         STA $F2
 2660         INC $F9
 2670         BNE .1       ...ALWAYS
 2680  .2     LDA $F9
 2690         CPX #0       SEE IF LAST DIGIT
 2700         BEQ .4       YES
 2710         CMP #$B0     NO, SEE IF LEADING ZERO
 2720         BEQ .3       MAYBE
 2730         STA $C9      NO
 2740  .3     BIT $C9      STILL PLUS IF LEADING ZERO
 2750         BMI .4       NOT LEADING ZERO
 2760         LDA IB.FILL  SEE IF BLANK FILL
 2770         BEQ .5       NO
 2780  .4     JSR CHAR.OUT PRINT CHAR
 2790  .5     DEX
 2800         BPL .7
 2810         RTS

