@@ -49,7 +49,7 @@ Export_TKListConvertLine:
4949 ; Do the line number
5050 ;
5151 ldy #2 ; convert line number to string
52- .cget
52+ .cget
5353 tax
5454 dey
5555 .cget
@@ -62,9 +62,9 @@ Export_TKListConvertLine:
6262 bpl _LCNoAdjust ; don't adjust indent if +ve, do after.
6363 clc ; add to list indent and make 0 if goes -ve.
6464 adc listIndent
65- sta listIndent
65+ sta listIndent
6666 bpl _LCNoAdjust
67- stz listIndent
67+ stz listIndent
6868_LCNoAdjust:
6969 clc ; work out actual indent.
7070 lda listIndent
@@ -98,14 +98,14 @@ _LCMainLoop:
9898 cmp #64 ; 32-64 are as stored, punc and digits
9999 bcc _LCPunctuation
100100 cmp #128 ; 64-127 are variable identifiers.
101- bcc _LCIdentifiers
101+ bcc _LCIdentifiers
102102 cmp #254 ; 128-253 are tokenised words
103103 bcc _LCTokens
104104 jmp _LCData ; 254-5 are data objects
105105 ;
106106 ; Exit - do +ve indent here.
107107 ;
108- _LCExit:
108+ _LCExit:
109109 pla ; get old indent adjust
110110 bmi _LCExit2
111111 clc ; add to indent if +ve
@@ -141,12 +141,12 @@ _LCShiftPunc:
141141 and #7 ; lower 3 bits
142142 beq _LCNoAdd
143143 ora #24 ; adds $18 to it.
144- _LCNoAdd:
144+ _LCNoAdd:
145145 cpx #24 ; if >= 24 add $20
146146 bcc _LCNoAdd2
147147 ora #32 ; adds $20
148148_LCNoAdd2:
149- ora #$40 ; shift into 64-127 range and fall through.
149+ ora #$40 ; shift into 64-127 range and fall through.
150150
151151 ; -------------------------------------------------------------------
152152 ;
@@ -158,7 +158,7 @@ _LCPunctuation:
158158 cmp #':' ; check if :
159159 bne _LCPContinue
160160 jsr LCLDeleteLastSpace ; if so delete any preceding spaces
161- _LCPContinue:
161+ _LCPContinue:
162162 cmp #'.'
163163 beq _LCPIsConstant
164164 cmp #'0'
@@ -169,7 +169,11 @@ _LCPIsConstant:
169169 pha
170170 .setcolour CLIConstant
171171 pla
172- _LCPNotConstant:
172+ _LCPNotConstant:
173+ cmp #KWD_QUOTE ; apostrophe (comment to end of line)
174+ bne _LCPWrite
175+ jsr LCLAddSpaceIfNeeded
176+ _LCPWrite:
173177 iny ; consume character
174178 jsr LCLWrite ; write it out.
175179 bra _LCMainLoop ; go round again.
@@ -182,7 +186,7 @@ _LCPNotConstant:
182186
183187_LCIdentifiers:
184188 clc ; convert to physical address
185- adc #((VariableSpace >> 8 ) - $40 ) & $FF
189+ adc #((VariableSpace >> 8 ) - $40 ) & $FF
186190 sta zTemp0+1
187191 iny
188192 .cget
@@ -197,7 +201,7 @@ _LCOutIdentifier:
197201 and #$7F
198202 jsr LCLLowerCase
199203 jsr LCLWrite
200- lda (zTemp0),y ; ends when bit 7 set.
204+ lda (zTemp0),y ; ends when bit 7 set.
201205 bpl _LCOutIdentifier
202206 ply ; restore position
203207 jmp _LCMainLoop
@@ -224,7 +228,7 @@ _LCNoShift:
224228 jsr LCLCheckSpaceRequired ; do we need a space ?
225229 .cget ; get the token again
226230 tax ; into X
227- _LCFindText:
231+ _LCFindText:
228232 dex
229233 bpl _LCFoundText ; found text.
230234 lda (zTemp0) ; length of text
@@ -235,7 +239,7 @@ _LCFindText:
235239 bcc _LCFindText
236240 inc zTemp0+1
237241 bra _LCFindText
238- _LCFoundText:
242+ _LCFoundText:
239243 phy ; save List position
240244 lda (zTemp0) ; count to print
241245 tax
@@ -255,7 +259,7 @@ _LCCopyToken: ; copy token out.
255259_LCNoSpace:
256260 ply ; restore position.
257261 iny ; consume token
258- jmp _LCMainLoop ; and go around again.
262+ jmp _LCMainLoop ; and go around again.
259263
260264 ; -------------------------------------------------------------------
261265 ;
@@ -269,19 +273,17 @@ _LCData:
269273 cmp #$FE
270274 beq _LCHaveOpener
271275 ldx #'"'
272- .setcolour CLIData
276+ .setcolour CLIData
273277 ;
274- ; Check for comment on line by itself.
278+ ; Check for apostrophe comment
275279 ;
276- cpy #4 ; must be 2nd thing on line
277- bne _LCHaveOpener
278280 dey ; what precedes it ?
279281 .cget
280282 iny
281- cmp #KWD_QUOTE ; if quote
283+ cmp #KWD_QUOTE ; if apostrophe
282284 bne _LCHaveOpener
283- lda #9 ; tab
284- jsr LCLWrite
285+ lda #' ' ; add space before comment
286+ jsr LCLWrite
285287 lda CLIBComment
286288 bmi _LCHaveOpener
287289 ora #$90
@@ -293,7 +295,7 @@ _LCHaveOpener:
293295 iny ; get count
294296 .cget
295297 tax
296- iny ; point at first character
298+ iny ; point at first character
297299_LCOutData:
298300 .cget ; get next
299301 cmp #0
@@ -311,10 +313,22 @@ _LCNoPrint:
311313 lda EXTTextColour
312314 and #$0F
313315 ora #$90
314- jsr LCLWrite
315- _LCNoQuote:
316+ jsr LCLWrite
317+ _LCNoQuote:
316318 jmp _LCMainLoop
317319
320+
321+ LCLAddSpaceIfNeeded:
322+ cpy #3 ; don't add space if it's the first token on the line
323+ beq _exit
324+ pha
325+ lda #' ' ; add space before the next token
326+ jsr LCLWrite
327+ pla
328+ _exit:
329+ rts
330+
331+
318332; ************************************************************************************************
319333;
320334; Output write colour ($80-$8F) only if it has changed
@@ -342,9 +356,9 @@ LCLWrite:
342356 stz tokenBuffer+1 ,x
343357 inc tbOffset ; bump the position
344358 ora #0 ; don't update last character if colour data
345- bmi _LCLNoColour
359+ bmi _LCLNoColour
346360 sta lcLastCharacter
347- _LCLNoColour:
361+ _LCLNoColour:
348362 plx
349363 rts
350364
@@ -366,7 +380,7 @@ LCLDeleteLastSpace:
366380_LCDLSExit:
367381 plx
368382 pla
369- rts
383+ rts
370384
371385; ************************************************************************************************
372386;
@@ -396,7 +410,7 @@ _LCCSRSpace: ; output the space
396410 jsr LCLWrite
397411
398412_LCCSRExit:
399- rts
413+ rts
400414
401415; ************************************************************************************************
402416;
@@ -432,7 +446,7 @@ LCLWriteNumberXA:
432446 stz zTemp0+1 ; index into digit table.
433447_LCLWNLoop1:
434448 stz zTemp0 ; subtraction count.
435- _LCLWNLoop2:
449+ _LCLWNLoop2:
436450 pha ; save initial LSB
437451 sec
438452 ldy zTemp0+1 ; position in table.
@@ -450,15 +464,15 @@ _LCLWNLoop2:
450464_LCLWNUnderflow:
451465 ldy zTemp0 ; count of subtractions.
452466 bne _LCLWNOut
453- lda tbOffset ; suppress leading zeroes
467+ lda tbOffset ; suppress leading zeroes
454468 dec a
455469 beq _LCLWNNext
456470_LCLWNOut:
457471 tya
458- jsr _LCLWNOutDigit
472+ jsr _LCLWNOutDigit
459473_LCLWNNext:
460474 ply ; restore original value.
461- pla
475+ pla
462476 ldy zTemp0+1 ; bump the index
463477 iny
464478 iny
@@ -467,14 +481,14 @@ _LCLWNNext:
467481 bne _LCLWNLoop1
468482_LCLWNOutDigit:
469483 ora #'0'
470- jsr LCLWrite
484+ jsr LCLWrite
471485 rts
472486
473487_LCLWNTable:
474488 .word 10000
475489 .word 1000
476490 .word 100
477- .word 10
491+ .word 10
478492
479493; ************************************************************************************************
480494;
@@ -483,7 +497,7 @@ _LCLWNTable:
483497; ************************************************************************************************
484498
485499CLIDefault:
486- .byte CONBrown, CONYellow, CONRed, CONOrange, CONCyan, CONYellow, CONPink, CONWhite
500+ .byte CONBrown, CONYellow, CONRed, CONOrange, CONCyan, CONYellow, CONPink, CONWhite
487501
488502 .send code
489503
@@ -495,11 +509,11 @@ CLIDefault:
495509
496510CLIFComment = ControlStorage + 0
497511CLIBComment = ControlStorage + 1
498- CLILineNumber = ControlStorage + 2
512+ CLILineNumber = ControlStorage + 2
499513CLIToken = ControlStorage + 3
500- CLIConstant = ControlStorage + 4
501- CLIIdentifier = ControlStorage + 5
502- CLIPunctuation = ControlStorage + 6
514+ CLIConstant = ControlStorage + 4
515+ CLIIdentifier = ControlStorage + 5
516+ CLIPunctuation = ControlStorage + 6
503517CLIData = ControlStorage + 7
504518
505519; ************************************************************************************************
0 commit comments