--- title: "Fantasia in Color" id: 72685 type: "computer_media" slug: "fantasia-in-color" url: "http://localhost/computer_media/fantasia-in-color/" markdown_url: "http://localhost/computer_media/fantasia-in-color.md" published_at: "2026-10-26T23:19:28+00:00" modified_at: "2026-10-26T23:19:28+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2026/10/fantasia-2.png" excerpt: "A paged tutorial on putting colour control codes into program listings and strings, with helper routines for inspecting attribute bytes and program memory." post_tag: - name: "Downloadable" slug: "downloadable" taxonomy: "post_tag" url: "http://localhost/tag/downloadable/" - name: "TS 2068" slug: "ts2068" taxonomy: "post_tag" url: "http://localhost/tag/ts2068/" - name: "WIDJUP Company" slug: "widjup-company" taxonomy: "post_tag" url: "http://localhost/tag/widjup-company/" model: - name: "Timex/Sinclair 2068" slug: "ts-2068" taxonomy: "model" url: "http://localhost/model/ts-2068/" indiv: - name: "William J. Pedersen" slug: "william-j-pedersen" taxonomy: "indiv" url: "http://localhost/indiv/william-j-pedersen/" genre: - name: "Tutorial" slug: "tutorial" taxonomy: "genre" url: "http://localhost/type/tutorial/" media_type: "Program" programmers: - name: "William J. Pedersen" slug: "william-j-pedersen" taxonomy: "indiv" url: "http://localhost/indiv/william-j-pedersen/" download_url: "https://archive.org/download/timex-sinclair-software-archive/Fantasia%20in%20Color%20%281985%29%28Pedersen%2C%20William%20J.%29%28TS2068%29%28US%29%28Program%29.zip" tsrun_member: "Fantasia in Color (1985)(Pedersen, William J.)(TS2068)(US)(Program)/Fantasia in Color (1985)(Pedersen, William J.)(TS2068)(US)(Program).tap" mediadate: "1985" producer_company: - id: 27769 title: "WIDJUP Company" type: "company" url: "http://localhost/company/widjup-company/" images: - url: "http://localhost/wp-content/uploads/2026/10/fantasia-2.png" - url: "http://localhost/wp-content/uploads/2026/10/fantasia-3.png" - url: "http://localhost/wp-content/uploads/2026/10/fantasia-4.png" media_type_tags: "Tutorial" license: false --- # Fantasia in Color Fantasia in Color is a tutorial on adding colour to BASIC listings. Page by page it explains how the display is split into the bitmap and the attribute (ATTR) area, how colour commands travel in the print stream as control codes 16 to 19 followed by a value, how to type them straight into a line with the E cursor, and what the special values 8 and 9 (transparent and contrast) do. It shows the sixteen colours directly available, the bit layout of an attribute byte, a flowchart of the keystrokes, and how cursor and position codes can be faked with dummy bytes. The program’s own REM lines (1–20) are the demonstration: they are coloured with embedded codes, and some text is hidden by setting the ink to the paper colour. You see this when you LIST the program. Three extra routines can be run with `GO TO`: `STRING` lets you enter a string and shows the attribute bits of each character, `SPY` dumps memory from an address so you can find a dummy colour byte and POKE an 8 or 9 over it, and `SAVE` saves the program. The title screens read “Adding COLOR to LISTings. ©1985 The WIDJUP Co. by William J. Pedersen” and “The WIDJUP Co. Presents… FANTASIA IN COLOR”. The program was saved under the name “Color LIST”. ## Program Analysis ### Program Structure - Lines 1–20: coloured REM lines that make up the reference text. - Lines 1000–1099: the tutorial pages, each ending with `GO SUB Key: PAUSE 0: CLS`; the subroutine at 1100 counts and prints the page number. Line 1099 loops back to page 3. - Lines 2000–2095 (`String`): string attribute explorer. Lines 4000–4025 (`Spy`): byte dump. ### Notable Techniques - Line numbers are held in variables (`Key`, `String`, `Save`, `Spy`) so the user can type `GO TO SPY` and so on. - The string explorer decodes each attribute byte arithmetically into FLASH, BRIGHT, PAPER and INK and reprints the character in those colours. - The flowchart on page 12 is drawn with `PLOT`/`DRAW` arrowheads. ### Potential Issues - The SPY routine at 4015–4025 runs forever until BREAK; the program tells you to use CAPS SHIFT and BREAK. - Typing over a coloured REM line in the editor can lose its codes, as line 3 itself explains. This copy comes from an Oliger (JLO SAFE) disk. It was converted for tape (the disk save at line 3000 was changed to a tape `SAVE`) and tested in ZEsarUX. ## Source Code ``` 1 REM You can enter color commands from the keyboard when the E cursor is active. 2 REM This line is colored by inserting a PAPER-GREEN afterthe line number, and PAPER-WHITEat the end of the line. 3 REM Color LIST Attemptingto place color commands in frontof the line number is defeated. It works while editing but is lost when entered. You may try this using this remark line. 4 REM Color LIST Sixteen colors are directly available: , , , , , , , , , , , , , , , . Onevanishes into the background. 5 REM This is what happens when PAPER-CYAN ends line4, and a PAPER-WHITE is in line 5. This provides a way to color line numbers when they are not at the top of the screen. 6 REM Color LIST Because it is impossible to input bytes forcontrast or transparent from thekeyboard, a WHITE command can beused as a dummy. Then the SPY utility can be used to find the memory address to poke a 9 or 8 over the 7 as needed. 7 REM Color LIST This trickcan be used to conceal parts of the listing from curious eyes. The leading PAPER color is the default INK color (black). Changing the default INK color to YELLOW and LIST 6 will revealthis hidden code--and obliterateline 6. 8 REM Color commands CONTROL TOKEN - BYTE VALUE INK 16 0 to 7, 8, 9 PAPER 17 0 to 7, 8, 9 FLASH 18 0, 1, 8 BRIGHT 19 0, 1, 8 9 REM The ATTR control byte is organized as follows. ATTRIBUTE BITS INK b0 to b2 PAPER b3 to b5 BRIGHT b6 FLASH b7 10 REM Obviously, control byte values 8 and 9 cannot be stored in the bits available in ATTR. 8 results in no change inATTR. 9 results in reading ATTRand setting INK/PAPER to 0 or 7 to contrast PAPER/INK. 11 REM Non-Color Commands INVERSE and OVER are Token-bytecommands which can be initially inserted as dummies. They don'teffect ATTR. They control the bit mapped SCREEN IMAGE. All other commands are either one orthree bytes long. 12 REM Cursor Commands TAB and AT have the structure--Token-byte-byte. CURSOR LEFT, RIGHT, DOWN, and UP are simply Token. A dummy color command + "*", or "***" can be used for TAB and AT. A single "*" servesfor the others. 13 REM Other Commands Though there are others, and a group ofunused commands, their use with listings is inappropriate. 15 REM Inputting ATTRIBUTES CONTROL TOKEN - BYTE VALUE INK 16 0 to 7 PAPER 17 0 to 7 FLASH 18 0, 1 BRIGHT 19 0, 1 All these commands can be inputdirectly from the keyboard. Thefirst requirement is to invoke the E cursor, using: CAPS & SYMBOL SHIFTS. 16 REM PAPER Commands With E: 0 gives BLACK, 1 gives BLUE, .............., and 7 gives WHITE PAPER. 17 REM INK Commands With E: CAPS & 0 gives BLACK, CAPS & 1 gives BLUE, ......................., and CAPS & 7 gives WHITE INK. 18 REM BRIGHT Commands With E: 9 gives BRIGHT, 8 gives UNBRIGHT. NOTE: BRIGHT effects both INK PAPER colors. 19 REM FLASH Commands With E: CAPS & 9 gives FLASH, CAPS & 8 gives STEADY. 20 REM What happened to REM in the lines above? Why, they are simply INK-WHITE! 1000 REM Entry 1001 LET b$=" ATTRIBUTES ": LET Key=1100: LET Pg=0: INK 0: PAPER 7: BRIGHT 0: INVERSE 0: OVER 0: BORDER 7: CLS : FLASH 1: PRINT AT 8,5," ";AT 9,5;" STOP RECORDER ";AT 10,5," ": FLASH 0: PRINT ''" Adding COLOR to LISTings."'' INK 4'" *1985 The WIDJUP Co."'" by William J. Pedersen": GO SUB Key: PAUSE 0: CLS 1002 LET String=2000: LET Save=3000: LET Spy=4000: LET W$="FANTASIA IN COLOR": PRINT AT 8,3;"The WIDJUP Co. Presents.";AT 11,6;W$: GO SUB Key: PAUSE 0: CLS 1003 LET Pg=2: PRINT '" DISPLAY MEMORYY "''" ATTR "'"Attributes:"'" PAPER Color"'" INK Color"'" BRIGHT"'" FLASH"' INK 2;"Character mapped.";AT 1,21;"ATTR";AT 4,19;"SCREEN";AT 6,19;"IMAGE"''' INK 0''" SCREEN IMAGE "'"INK/PAPER(Foreground/Background)"; INK 2'"Bit mapped INK pixels." 1004 INK 1: PLOT 144,156: DRAW 0,15: DRAW 80,0: DRAW 0,-49: DRAW -8,0: DRAW 0,-16: DRAW -80,0: DRAW 0,49: DRAW 80,0: DRAW 0,-32: INK 0 1005 PRINT INK 1'" There is one ATTRR byte for eachcharacter space on the screen."'" There are eight SCREEN IMAGEE bytes for each character space on the screen.": GO SUB Key: PAUSE 0: CLS 1006 PRINT ''" You can imagine a data stream directed at this display. It isdiverted to ATTR or SCREEN IMAGEby Tokens in the stream." 1007 PRINT '" Some stream sources are:"''" Listing,"'" Editing,"'" Program execution,"'" Keyboard echo,"'" Error reporting and"'" Tape I/O."''" Only the first four sources arerelevant to this tutorial.": GO SUB Key: PAUSE 0: CLS 1008 PRINT ''" Keywords in your BASIC program are interpreted into commands-- which join the data stream."''" It is possible in many cases toavoid interpretation by putting the commands in directly."''" 1 PRINT PAPER 4;""GREEN"""''"becomes"''" 1 PRINT ""GREEN"""''" Not only is this more elegant, but it shows up in the LISTings in full color.": GO SUB Key: PAUSE 0: CLS 1009 PRINT '''" Why stop here? You may wish tocolor code all your PRINT state-ments so they are easy to find."''" 1 PRINT ""GREEN"""''"isn't too shabby."''" Blocking data groups, stressingcomments and important code, andjust making it look good are a few other benefits."''" It might even be "; INK 2;"FUN"; INK 0;".": GO SUB Key: PAUSE 0: CLS 1013 PRINT ''" Color in LISTings and strings "'" COLOR commands can be enter- ed from the keyboard whenever the E cursor is in effect.", 1014 PRINT ''" Color in LISTings "'" Use LIST. See how color looks in LISTings.",," There are so many ways to use COLOR commands, it is hopeless to show them all.", 1015 PRINT ''" Color in strings "'" This string was colored by in- serting a PAPER-GREEN after the first"", and a PAPER-WHITE just before the last"".",: GO SUB Key: PAUSE 0: CLS 1016 PRINT ''" COLOR Choices Sixteen colorsare directly available: , , , , , , , , , , , , , , , . Onevanishes into the background." 1017 PRINT '" You can't directly input color commands for transparent or con-trast. A dummy WHITE command can be used temporarily.",,," Then the SPY feature can find the memory address so you can POKE an 8 or 9 over the 7.", 1018 PRINT ''" Use GO TO SPY to access this feature.": GO SUB key: PAUSE 0: CLS 1019 PRINT "Color commands"'"CONTROL TOKEN - BYTE VALUE INK 16 0 to 7, 8, 9 PAPER 17 0 to 7, 8, 9 FLASH 18 0, 1, 8 BRIGHT 19 0, 1, 8" 1020 PRINT '"ATTR control byte"'"ATTRIBUTE BITS INK b0 to b2 PAPER b3 to b5 BRIGHT b6 FLASH b7" 1021 PRINT " Obviously, control byte values 8 and 9 cannot be stored in the bits available in ATTR."'" 8 results in no change in ATTR. 9 results in reading ATTR and setting INK/PAPER to 0 or 7 to contrast PAPER/INK.": GO SUB Key: PAUSE 0: CLS 1022 PRINT ''" Inputting ATTRIBUTES "''" CONTROL TOKEN - BYTE VALUE"'" INK 16 0 to 7"'" PAPER 17 0 to 7"'" FLASH 18 0, 1"'" BRIGHT 19 0, 1"''" All these commands can be inputdirectly from the keyboard."''" The first requirement is to getthe E cursor, using:"''" CAPS & SYMBOL SHIFTS.": GO SUB Key: PAUSE 0: CLS 1023 PRINT ''''" PAPER Commands With E:"''" 0 gives BLACK,"'" 1 gives BLUE,"'" .............., and"'" 7 gives WHITE." 1024 PRINT ''" INK Commands With E:"''" CAPS & 0 gives BLACK,"'" CAPS & 1 gives BLUE,"'" ......................., and"'" CAPS & 7 gives WHITE.": GO SUB Key: PAUSE 0: CLS 1025 PRINT ''''" BRIGHT Commands With E:"''" 9 gives BRIGHT,"'" 8 gives UNBRIGHT."''" NOTE: BRIGHT effects both INK and PAPER colors." 1026 PRINT ''" FLASH Commands With E:"''" CAPS & 9 gives FLASH,"'" CAPS & 8 gives STEADY.": GO SUB Key: PAUSE 0: CLS 1027 PRINT '" COLOR Command Flowchart "'''" CAPS & SYMBOL "''" yes"'" CAPS &? 0 to 7 = INK"''" no"," 8 = STEADY"''," 9 = FLASH" 1028 PRINT ''" 0 to 7 = PAPER"''," 8 = UNBRIGHT"''," 9 = BRIGHT" 1029 PLOT 20,135: DRAW 0,-14: DRAW 3,3: DRAW -3,-3: DRAW -3,3: PLOT 20,110: DRAW 0,-51: DRAW 66,0: DRAW -3,3: DRAW 3,-3: DRAW -3,-3 1030 PLOT 65,115: DRAW 21,0: DRAW -3,3: DRAW 3,-3: DRAW -3,-3: PLOT 74,114: DRAW 0,-15: DRAW 67,0: DRAW -3,3: DRAW 3,-3: DRAW -3,-3 1031 PLOT 74,99: DRAW 0,-15: DRAW 67,0: DRAW -3,3: DRAW 3,-3: DRAW -3,-3: PLOT 74,58: DRAW 0,-15: DRAW 67,0: DRAW -3,3: DRAW 3,-3: DRAW -3,-3 1032 PLOT 74,42: DRAW 0,-15: DRAW 67,0: DRAW -3,3: DRAW 3,-3: DRAW -3,-3 1033 GO SUB Key: PAUSE 0: CLS 1034 PRINT ''"Non-Color Commands"'" INVERSE and OVER are Token-bytecommands which can be initially inserted as dummies. They don'teffect ATTR. They control the bit mapped SCREEN IMAGE. All other commands are either one orthree bytes long." 1035 PRINT '"Cursor Commands"'" TAB and AT have the structure: Token-byte-byte. CURSOR LEFT, RIGHT, DOWN, and UP are simply Token. A color command plus a ""*"" (or ""***"") can be used as a dummy for TAB or AT. A single ""*"" serves for the others.": GO SUB Key: PAUSE 0: CLS 1036 PRINT ''"Other Commands"'" Though there are others (and a group of unused commands), they are seldom appropriate." 1037 PRINT PAPER 5'" Strings that are not PRINT lit-erals are more easily edited by the slice-and-insert method, or by assignment, using CHR$.",: PRINT ''" GOTO STRING will let you prac- tice to your heart's content." 1038 PRINT " Get familiar with assembling strings before attempting POKE operations into LISTings."''" GOTO STRING+4 for an example.": GO SUB Key: PAUSE 0: CLS 1039 PRINT '''''" Like any good programming lang-uage, you can do simple things without learning everything. "''" SAVEing before POKEing might bea good habit to get into." 1040 PRINT INK 1'" Press CAPS SHIFT and BREAK to return control to the keyboard." 1099 GO SUB Key: PAUSE 0: CLS : GO TO 1003 1100 LET Pg=Pg+1: PRINT AT 21,5;" PRESS ANY KEY Page ";Pg: RETURN 2000 REM STRING ATTRIBUTE BYTES 2001 CLS : PRINT " Enter any string you like. Thestring can contain ATTRIBUTE commands, and/or be concatenatedwith CHR$(control byte)'s.",: PRINT "CHR$ Control"'" 8 Cursor left (backspace)"'" 9 Cursor right"'" 10 Cursor down"'" 11 Cursor up"'" 13 ENTER (newline)"'" 16 INK"'" 17 PAPER"'" 18 FLASH"'" 19 BRIGHT"'" 20 INVERSE"'" 21 OVER"'" 22 AT"'" 23 TAB" 2002 PRINT '"You can edit";AT 19,8; OVER 1;"____. Assign or add newcharacters and/or CHR$ and CONT." 2003 INPUT "W$=";W$ 2004 CLS : PRINT AT 0,0;W$,: PRINT "LEN=";LEN W$ 2010 FOR j=0 TO 15: LET W=ATTR (0,j) 2015 PRINT AT 2+j,24; PAPER 4;b$(j+1); PAPER 7;AT 2+j,0;j;TAB 3;W;TAB 7; 2016 LET W1=INT (W/128) 2017 LET W=W-128*W1 2018 LET W2=INT (W/64) 2019 LET W=W-64*W2 2020 LET W3=INT (W/8) 2021 LET W=W-8*W3 2051 LET a$=SCREEN$ (0,j): PRINT " ";a$;" "; INK W; PAPER W3; FLASH W1; BRIGHT W2;a$+("?" AND a$="");: PRINT , PAPER 4;W1;" ";W2;" ";W3;" ";W 2060 NEXT j 2065 PRINT 2070 FOR j=1 TO LEN W$: LET W=CODE W$(j) 2080 PRINT TAB 4*(j-1); PAPER (4 AND W>31)+(6 AND W<32);W; 2090 NEXT j 2095 STOP : GO TO 2004 3000 SAVE "Color LIST" LINE 1000 3010 STOP : GO TO Save 4000 REM SPY 4005 CLS 4010 PRINT AT 21,0;"BASIC program starts at ";PEEK 23635+256*PEEK 23636: INPUT "START WHERE? ";B 4015 LET W=PEEK B: PRINT PAPER 4+B-3*INT (B/3);B;TAB 6;W;TAB 12;CHR$ W AND PEEK B>31;TAB 31 4020 LET B=B+1 4025 GO TO 4015 ```