Highlist by Alberto Apostolo
A downloadable tool
H I G H L I S T : HAVING A LIST WITH COLORFUL SPECCY TOKENS!
===========================================================
(By Alberto Apostolo 2021/02/05)
1. Getting Started
------------------
This utility for ZX Spectrum (coded without "GO TO"s) lists a program showing
colorful BASIC tokens.
It could be appended to another BASIC program in order to have a colorful list,
running the command "RUN 9000" or "GO TO 9000".
At line 9010, you can set different values to the variables "ls" (line-start)
and "le" (line-end) in order to list just few lines and not an entire program.
Because it's coded without "GO TO"s, it also possible renumber this utility
as you like.
2. Program Structure
--------------------
Line 9000 : Remarks
Line 9010 : Initialization of variables ls (line-start), le (line-end).
Calculation of s (program start address) and e
(program end address/variables start address)
pointed by Spectrum system variables PROG (addr. LSB-MSB 23635/6)
and VARS (addr. LSB-MSB 23627/8).
Set foreground and background default colors.
Begin main n-loop.
Line 9020 : Initialization of a$, needed to store a line of BASIC program.
Each line of BASIC program has the form:
- Line number : 2 bytes (HSB,LSB)
- Length text included ENTER : 2 bytes (LSB,HSB)
- Text : 1 or more bytes
- ENTER : 1 byte.
Calculation of q (line number) and w (length text).
Increase of n by 3.
Line 9030 : If q greater than ls then "break;" the n-loop (by means of that "weird" FOR)
(the limit value has been exceeded)
Line 9040 : If q greater or equal ls then initialize a$ with q (converted in
string and justified right when q < 1000).
Line 9050 : Begin "Parsing Text" m-loop (performed if a$ is not empty).
Store in z the content of memory cell addressed by n+m.
Choose a color for the BASIC token (black for other characters):
- Magenta for functions (coded from 165 to 194)
- Red for binary operators (coded from 195 to 201)
- Blue for commands (coded from 202 to 255)
- Green for REM (coded 234).
Lines 9060-9070: Deploy of a kind of "CASE-WHEN" ("weird" FOR even here):
CASE WHEN z>164 THEN add a colored BASIC token (coded z) to a$
(chr 16 represents INK control, chr in variabile c
represents a color,
chr 0 represents black, the foreground default color)
WHEN z=14 THEN skip next 5 bytes after a numeric literal
( chr 14 is a delimiter)
WHEN z=13 then print a$ on screen
ELSE add the character (coded z) to a$
END-CASE.
End of m-loop.
Line 9080 : Increase of n by w (length of text).
End of main n-loop.
Restore background and foreground default colors.
End of utility.
3. Listing
----------
9000 REM HIGHLIST (apoalb 2021)
9010 LET ls=1: LET le=9999: LET s=23635: LET s=256*PEEK (s+1)+PEEK s: LET e=23627:
LET e=256*PEEK (e+1)+PEEK e: CLS: INK 0: PAPER 7: FOR n=s TO e-1
9020 LET a$="": LET q=PEEK (n+1)+256*PEEK n: LET w=256*PEEK (n+3)+PEEK (n+2):n=n+3
9030 IF q>le THEN FOR n=1 TO 0
9040 IF q>=ls THEN LET a$=STR$ q: LET a$=" "( TO 4-LEN a$)+a$
9050 FOR m=1 TO w*(a$<>""): LET z=PEEK (n+m): LET c=3*(z>=165 AND z<=194) +2*(z>=
195 AND z<=201)+(z>=202): LET c=c+3*(z=234)
9060 LET k=3*(z>164)+2*(z=14)+(z=13): FOR g=1 TO K=3: LET a$=a$+CHR$ (16)+ CHR$(c)
+CHR$ (z) +CHR$ (16)+ CHR$(0): NEXT g: FOR g=1 TO k=2: LET m=m+5: NEXT g
9070 FOR g=1 TO k=1: PRINT a$: NEXT g: FOR g=1 TO k=0: LET a$=a$+CHR$ (z): NEXT g:
NEXT m
9080 LET n=n+w: NEXT n: PAPER 7: INK 0: STOP
Status | Released |
Category | Tool |
Author | BASIC 10Liner |
Tags | 8-Bit, basic, basic10liner, ZX Spectrum |
Download
Development log
- Image downloadApr 08, 2021
Leave a comment
Log in with itch.io to leave a comment.