--- title: "Dragon’s Companion" id: 53835 type: "computer_media" slug: "dragons-companion" url: "http://localhost/computer_media/dragons-companion/" markdown_url: "http://localhost/computer_media/dragons-companion.md" published_at: "2024-05-13T19:02:00+00:00" modified_at: "2026-03-30T21:41:45+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2024/05/Dragon-Companion-1.png" excerpt: "Cast virtual I Ching coins, decode hexagrams with their ruling lines, and explore trigram attributes — all driven by machine code utilities running in an 85-column display mode." category: - name: "Archived Media" slug: "archived-media" taxonomy: "category" url: "http://localhost/category/archived-media/" 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/" model: - name: "Timex/Sinclair 2068" slug: "ts-2068" taxonomy: "model" url: "http://localhost/model/ts-2068/" indiv: - name: "Richard Hurd" slug: "richard-hurd" taxonomy: "indiv" url: "http://localhost/indiv/richard-hurd/" genre: - name: "Entertainment" slug: "entertainment" taxonomy: "genre" url: "http://localhost/type/entertainment/" media_contents: - id: 55361 title: "SINCUS Exchange Tape 102 – Utilities & Business" type: "computer_media" url: "http://localhost/computer_media/sincus-exchange-tape-102-utilities-business/" media_type: "Program" programmers: - name: "Richard Hurd" slug: "richard-hurd" taxonomy: "indiv" url: "http://localhost/indiv/richard-hurd/" mediadate: "198x" images: - url: "http://localhost/wp-content/uploads/2024/05/Dragon-Companion-1.png" - url: "http://localhost/wp-content/uploads/2024/05/Dragon-Companion-2.png" - url: "http://localhost/wp-content/uploads/2024/05/Dragon-Companion-3.png" - url: "http://localhost/wp-content/uploads/2024/05/Dragon-Companion-4.png" - url: "http://localhost/wp-content/uploads/2024/05/Dragon-Companion-5.png" media_type_tags: "Entertainment" --- The Dragon’s Companion is an I Ching (Book of Changes) consultation program that simulates the traditional three-coin toss method to generate hexagrams for divination. It uses an 85-column display mode provided by a machine code utility suite (“Timex 85”) loaded from tape alongside the BASIC program, with routines mapped above RAMTOP starting at address 56422. The program calls numerous USR entry points for screen operations including cursor positioning (SETCUB at 57353), character writing (WRCHRB at 57345), string output (WRSTRB at 57348), screen clearing (CLRSCB at 57358), line scrolling (SCRLB at 57386), and a word-wrap text retrieval routine at 59653. A machine code screen-copy routine at 63010 supports printing via an AERCO/Epson-compatible interface in extended double-wide mode. Hexagram lookup uses an 8×8 table (lines 7400–7470) indexed by lower and upper trigram numbers, and changing lines (values 6 and 9) trigger display of a second, transformed hexagram. Uses the Timex 85 Column Mode code as listed in the 2068 Technical Manual. *** ## Program Analysis ### Program Structure The program is divided into clearly labeled regions by REM statements. Execution begins at line 10, which sets up the display mode and branches to the main menu at line 1000. The major functional sections are: 1. **Lines 10–217**: Initialization, 85-column mode setup, and subroutine wrappers for machine code calls. 2. **Lines 229–235**: Screen clearing utilities. 3. **Lines 300–380**: Trigram identification subroutine — converts a 3-element array into a trigram index 1–8. 4. **Lines 599–605**: Data retrieval loop using the word-wrap M/C routine. 5. **Lines 700–800**: Ink/paper color selection menu. 6. **Lines 1000–1150**: Main menu dispatcher. 7. **Lines 1200–2170**: Full coin-toss hexagram generation, display, and changing-line handling. 8. **Lines 3000–3260**: Manual individual-line entry mode. 9. **Lines 4000–4120**: Component and nuclear trigram attribute display. 10. **Lines 7000–7040**: Information text retrieval using word-wrap M/C routine. 11. **Lines 7100–7640**: DATA blocks for hexagram names, ruling lines, trigram addresses, screen layout parameters, and menu strings. 12. **Lines 8999–9999**: Error handler, loader stub, UDG initialization, sound, and SAVE routine. ### Machine Code Integration The program relies heavily on a suite of machine code routines loaded from tape as a CODE block (56422 to approximately 63179). All calls follow the pattern of POKEing parameters into fixed addresses then invoking `USR`. The return value of each call is captured in `l` (typically discarded). Key entry points include: | Entry Point | Name | Function | | --- | --- | --- | | 57381 | SETMDB | Set display mode (POKEd via 57380) | | 57345 | WRCHRB | Write character (char in 57344) | | 57348 | WRSTRB | Write string (address via 23747) | | 57353 | SETCUB | Set cursor (col in 57351, ln in 57352) | | 57358 | CLRSCB | Clear lines (strtln in 57356, count in 57357) | | 57362 | SETATB | Set ink attribute (ink in 57361) | | 57366 | SETMSB | Set mask (mask in 57365) | | 57371 | GTCHRB | Get character at position | | 57377 | GETCUR | Get current cursor position | | 57386 | SCRLB | Scroll lines (strtln in 57384, count in 57385) | | 59653 | Word-wrap | Copy ASCII data to A$ with line-length limit | | 59749 | Line editor | Single-line text input with DELETE/ENTER | | 59862 | Line copy | Copy screen lines between positions | | 63010 | Screen copy | AERCO/Epson double-wide hardcopy | The `ON ERR GO TO 8999` at line 10 provides a recovery path if any M/C call fails, falling back to 32-column mode and halting cleanly. Line 110 explicitly tests the USR return value and calls `ON ERR RESET: STOP` if mode initialization fails. ### I Ching Logic The coin-toss simulation at lines 1480–1690 uses `INT(RND*2)+2` to generate values 2 (yin) or 3 (yang) for each of three coins per line. The sum across three coins yields a line value of 6 (old yin, moving), 7 (young yang, stable), 8 (young yin, stable), or 9 (old yang, moving). These map to standard I Ching line types. The trigram subroutine (lines 300–380) takes a 3-element array `t()` and returns an index 1–8, encoding all eight possible yang/yin (7/8) combinations. The hexagram lookup at lines 1700–1730 uses an 8×8 DATA table (lines 7400–7470) indexed by lower and upper trigram numbers to return the hexagram number 1–64. Nuclear trigrams — derived from lines 2–4 (`lnt`) and 3–5 (`unt`) of the primary hexagram — are also computed and displayed via the component trigram screen (line 4000 onward). ### Display Architecture The 85-column mode (activated by POKEing 57380 with the mode value and calling SETMDB) allows significantly more text per row than standard display modes. The cursor system uses separate `ln` (line) and `col` (column) variables, always set before calling the SETCUB wrapper at line 130. String output uses WRSTRB, which references the system variable at 23747 as a pointer to the string data for `a$`. Hexagram lines are drawn using two UDG characters defined at line 9992: `CHR$ 144` (a filled/special mark symbol) and `CHR$ 145`/`CHR$ 146` (likely broken and solid line block graphics). The DATA at line 9992 defines the UDG bitmaps for characters “a” and “b” using `POKE USR "a"` style initialization. The strings `y$` and `z$` built at lines 1410–1420 represent yang (solid) and yin (broken) hexagram lines using these UDGs with a gap in the center for `z$`. ### Notable BASIC Idioms and Techniques - **POKE 23658,8 / POKE 23658,0**: Enables and disables CAPS LOCK to enforce uppercase key input at prompts (lines 1230, 1370, etc.). - **Shared loop variable `f`**: Used pervasively as a generic loop counter, with outer and inner loops sometimes both using `f` in ways that could conflict — for example, line 9992 uses `f` for UDG loading, and the main loops also use `f`. This is manageable because sections are non-reentrant. - **Address arithmetic**: The word-wrap routine state is maintained by two-byte address pairs at 59648/59649, updated after each call. Lines 7010 and 600 decompose and recompose 16-bit addresses using `256*INT(address/256)` and `address-256*INT(address/256)`. - **RESTORE to computed offsets**: Lines like `RESTORE h(lpt,upt)+7100` use the hexagram number as an offset into the DATA block at line 7101 onward. This is a clean technique for indexed data lookup without arrays of strings. - **`LET lines=1` flag**: The `lines` variable is used as a Boolean to alter behavior inside shared subroutines (lines 1472, 1680), allowing the coin-toss and manual-entry code paths to share line-display logic. - **Scroll vs. clear**: Line 230 implements a visual wipe effect by interleaving scroll calls on mirrored pairs of lines, whereas line 235 is a simple bulk clear. ### Startup and Save Routine Line 9991 loads the machine code block from tape with `LOAD ""CODE`, and line 9992 initializes two UDG characters. Line 9993 uses the `SOUND` keyword (TS2068 extension) to produce a startup sound via direct AY register writes. Line 9997 sets `CLEAR 56421` to place RAMTOP just below the machine code block, protecting it from BASIC, then transfers to line 10. The SAVE routine at line 9999 saves both the BASIC program (with auto-run at line 9991) and the machine code block as separate tape files, followed by VERIFY passes. ### Bugs and Anomalies - **Line 1445, double `GO SUB 170`**: The yang line display for the Heaven/Authority row calls `GO SUB 170` twice consecutively after the second `LET a$=y$`, likely a typo — the second call would re-output the same string at an unchanged cursor position. - **Line 2120 logic**: The loop checks `INKEY$=""` and falls through to a GO TO 2130, effectively making the empty-key check a no-op gateway; the actual key checks at 2130–2150 re-read INKEY$ independently, creating a slight window where a key might be missed between the two reads. - **`strln` vs. `strtln`**: The error handler at line 8999 uses `LET strln=0` (missing a ‘t’), so this assignment sets a new variable rather than the expected `strtln`. The subsequent `GO SUB 120` call would then use whatever value `strtln` currently holds. - **Line 3260**: This line calls `GO SUB 210` (which doesn’t exist as a standalone subroutine — line 205 is the prompt routine but has no RETURN of its own path for line 210) then jumps to 1010, but it is unreachable in normal program flow after line 3250’s GO TO 3220. ## Source Code ``` 1 REM The DRAGON'S COMPANION Version 1.0 By R. Hurd 4 REM MEMORY MAP above RAMTOP Data at 56422, 85 Col. Mode at 57344, Utilities at 59646, Data at 59949, nothing at 61285, Extended (Double Wide) AERCO/Epson screen copy at 63000 to 63179. See line 215 5 REM **** RUN ME **** 6 REM NOTE THE M/C UTILITIES I'VE INCLUDED HAVE LIMITED ERROR TRAPS. BE CAREFUL! 10 PAPER 7: INK 9: ON ERR GO TO 8999: LET mode=8: GO SUB 110 20 POKE 57405,0: POKE 57395,85: REM SET TO 85 COLUMNS 30 LET ink=0: GO SUB 140 99 GO TO 1000 100 REM 85 COL SUBROUTINES ALL ARE LISTED WITH THE EXCEPTION OF GETATB 110 POKE 57380,mode: LET l=USR 57381: IF l<>0 THEN ON ERR RESET : STOP : REM SETMDB 115 RETURN 120 POKE 57356,strtln: POKE 57357,count: LET l=USR 57358: RETURN : REM CLRSCB 130 POKE 57351,col: POKE 57352,ln: LET l=USR 57353: RETURN : REM SETCUB 140 POKE 57361,ink: LET l=USR 57362: RETURN : REM SETATB 150 POKE 57344,char: LET l=USR 57345: RETURN : REM WRCHRB 160 POKE 57365,mask: LET l=USR 57366: RETURN : REM SETMSB 170 POKE 23747,CODE "A": LET l=USR 57348: RETURN : REM WRSTRB 180 POKE 57384,strtln: POKE 57385,count: LET l=USR 57386: RETURN : REM SCRLB 190 POKE 57369,col: POKE 57370,ln: LET l=USR 57371: RETURN : REM GTCHRB 200 LET l=USR 57377: RETURN : REM GETCUR 201 REM DC SUBROUTINES 205 LET a$="<<<<< Press SpaceBar For Menu >>>>>": LET ln=23: LET col=24: GO SUB 130: GO SUB 170 213 IF INKEY$="" THEN GO TO 213 215 REM 64 COLUMN COPY The list of init codes is at 63171 and can be modified if necessary, simply end the list with code 255. In at 63010. Address 63173 holds line spacing value, set up for text. Change to 14 or what you require for graphics copy. (eliminate line spacing.) 216 IF INKEY$="c" OR INKEY$="C" THEN LET strtln=23: LET count=1: GO SUB 120: RANDOMIZE USR 63010 217 RETURN 229 REM CLEAR 24 LINE SCREEN 230 LET count=1: LET up=11: FOR j=12 TO 23: LET strtln=j: GO SUB 120: LET strtln=up: GO SUB 120: LET up=up-1: NEXT j: RETURN 235 LET strtln=0: LET count=24: GO SUB 120: RETURN 300 REM TRIGRAM SUBROUTINE 310 IF t(1)=7 AND t(2)=7 AND t(3)=7 THEN LET tri=1: RETURN 320 IF t(1)=7 AND t(2)=8 AND t(3)=8 THEN LET tri=2: RETURN 330 IF t(1)=8 AND t(2)=7 AND t(3)=8 THEN LET tri=3: RETURN 340 IF t(1)=8 AND t(2)=8 AND t(3)=7 THEN LET tri=4: RETURN 350 IF t(1)=8 AND t(2)=8 AND t(3)=8 THEN LET tri=5: RETURN 360 IF t(1)=8 AND t(2)=7 AND t(3)=7 THEN LET tri=6: RETURN 370 IF t(1)=7 AND t(2)=8 AND t(3)=7 THEN LET tri=7: RETURN 380 IF t(1)=7 AND t(2)=7 AND t(3)=8 THEN LET tri=8: RETURN 599 REM SUBROUTINE DATA RETRIEVAL 600 FOR f=1 TO 8: READ ln: READ col: READ len: DIM b$(len): GO SUB 130: LET a$=b$: POKE 59650,66: POKE 59648,address-256*INT (address/256): POKE 59649,INT (address/256): RANDOMIZE USR 59653: GO SUB 170: LET address=PEEK 59648+256*PEEK 59649: NEXT f 605 RETURN 700 REM CHANGE INK/PAPER 710 GO SUB 235: RESTORE 7200: LET ln=3: LET col=30: GO SUB 130: LET a$="Change Ink - Paper Colors": GO SUB 170 730 LET ln=ln+1: FOR f=1 TO 10: LET ln=ln+1: GO SUB 130: READ a$: GO SUB 170: NEXT f 740 LET ln=ln+2: GO SUB 130: LET a$="Press Appropriate Key": GO SUB 170 750 IF INKEY$<>"" THEN GO TO 750 760 IF INKEY$="" THEN GO TO 760 770 IF INKEY$<"0" OR INKEY$>"8" THEN GO TO 750 780 IF INKEY$="8" THEN GO TO 1010 790 LET ink=VAL INKEY$: GO SUB 140 800 GO TO 750 1000 REM MAIN MENU 1010 LET lines=0: LET change=0: GO SUB 230: LET a$="The DRAGON'S COMPANION": LET ln=5: LET col=30: GO SUB 130: GO SUB 170 1015 LET a$="Main Menu": LET col=37: LET ln=ln+1: GO SUB 130: GO SUB 170 1020 LET a$="1) Simulate Coin Toss": LET col=30: LET ln=ln+2: GO SUB 130: GO SUB 170 1025 LET a$="2) Enter Individual Lines": LET ln=ln+1: GO SUB 130: GO SUB 170 1030 LET a$="3) Information": LET ln=ln+1: GO SUB 130: GO SUB 170 1035 LET a$="4) Change Ink/Paper Color": LET ln=ln+1: GO SUB 130: GO SUB 170 1040 LET a$="5) Quit To BASIC": LET ln=ln+1: GO SUB 130: GO SUB 170 1050 LET a$="Choose One": LET ln=ln+2: LET col=37: GO SUB 130: GO SUB 170 1100 IF INKEY$="" THEN GO TO 1100 1105 IF INKEY$="1" THEN GO TO 1210 1110 IF INKEY$="2" THEN GO TO 3010 1115 IF INKEY$="3" THEN GO TO 7005 1120 IF INKEY$="4" THEN GO TO 710 1130 IF INKEY$="5" THEN GO TO 8990 1150 GO TO 1100 1200 REM COIN TOSS 1210 LET q$="": GO SUB 235: LET a$="The DRAGON'S COMPANION 1.0": LET ln=0: LET col=0: GO SUB 130: GO SUB 170 1220 LET col=7: LET a$="Do you have a specific question or thought to focus on? (Yes or No)": LET ln=20: GO SUB 130: GO SUB 170 1230 POKE 23658,8 1240 IF INKEY$="" THEN GO TO 1240 1250 IF INKEY$="Y" THEN POKE 23658,0: GO TO 1300 1260 IF INKEY$="N" THEN POKE 23658,0: LET q$="Thoughts for now!": GO TO 1400 1270 GO TO 1240 1299 REM SINGLE LINE EDITOR M/C subroutine. Before calling set cursor position. In at 59749. Accepts text and DELETE, ENTER to exit. Use GETCHRB to retrieve data. 1300 LET q$="": LET strtln=2: LET count=22: GO SUB 120 1310 LET col=0: LET a$="Input your thought or question": LET ln=20: GO SUB 130: GO SUB 170 1320 LET ln=23: GO SUB 130: RANDOMIZE USR 59749 1330 LET ln=23: FOR f=0 TO (PEEK 59651-1) 1340 LET col=f: GO SUB 190 1350 LET q$=q$+CHR$ l: NEXT f 1360 LET strtln=22: LET count=2: GO SUB 180 1370 POKE 23658,8: LET a$="Is this O.K.? (Yes or No)": LET ln=23: LET col=0: GO SUB 130: GO SUB 170 1380 IF INKEY$="" THEN GO TO 1380 1385 IF INKEY$="N" THEN POKE 23658,0: GO TO 1300 1390 IF INKEY$<>"Y" THEN GO TO 1380 1395 POKE 23658,0 1400 LET strtln=2: LET count=22: GO SUB 120 1405 LET ln=1: LET col=0: GO SUB 130: LET a$=q$: GO SUB 170 1410 LET y$=CHR$ 146+CHR$ 146+CHR$ 146+CHR$ 146+CHR$ 146+CHR$ 146+CHR$ 146+CHR$ 146 1420 LET z$=CHR$ 146+CHR$ 146+CHR$ 146+" "+CHR$ 146+CHR$ 146+CHR$ 146 1430 LET a$="Naturally Correct": LET col=84-LEN a$: LET ln=3: GO SUB 130: GO SUB 170: LET a$="Line Position": LET col=82-LEN a$: LET ln=4: GO SUB 130: GO SUB 170 1435 LET a$="Nature Aspect": LET ln=3: LET col=38: GO SUB 130: GO SUB 170 1440 LET a$="Heaven Wisdom": LET ln=5: LET col=38: GO SUB 130: GO SUB 170: LET a$=z$: LET col=71: GO SUB 130: GO SUB 170 1445 LET a$="Heaven Authority": LET ln=6: LET col=38: GO SUB 130: GO SUB 170: LET a$=y$: LET col=71: GO SUB 170: GO SUB 170 1450 LET a$="Man Social Consciousness": LET ln=7: LET col=38: GO SUB 130: GO SUB 170: LET a$=z$: LET col=71: GO SUB 130: GO SUB 170 1455 LET a$="Man Individual Endeavors": LET ln=8: LET col=38: GO SUB 130: GO SUB 170: LET a$=y$: LET col=71: GO SUB 130: GO SUB 170 1460 LET a$="Earth Self Interest": LET ln=9: LET col=38: GO SUB 130: GO SUB 170: LET a$=z$: LET col=71: GO SUB 130: GO SUB 170 1465 LET a$="Earth Instincts": LET ln=10: LET col=38: GO SUB 130: GO SUB 170: LET a$=y$: LET col=71: GO SUB 130: GO SUB 170 1470 RESTORE 7390: DIM e(3): DIM d(6): DIM c(6): DIM d$(6,9): DIM c$(6,9) 1472 IF lines THEN RETURN 1475 LET a$="Press SpaceBar To Toss Coin": LET ln=23: LET col=29: GO SUB 130: GO SUB 170 1480 RANDOMIZE : FOR f=1 TO 6 1485 READ a$: LET a$=a$+" Line": READ ln: LET col=0: GO SUB 130: GO SUB 170 1495 LET col=7 1500 FOR g=1 TO 3 1505 IF INKEY$<>"" THEN GO TO 1505 1510 IF INKEY$="" THEN GO TO 1510 1515 LET e(g)=INT (RND*2)+2: REM Coin Tosser 1520 LET col=col+5: GO SUB 130 1530 IF e(g)=2 THEN LET a$="yin" 1540 IF e(g)=3 THEN LET a$="yang" 1550 GO SUB 170 1560 NEXT g 1570 FOR g=1 TO 3: LET d(f)=d(f)+e(g): NEXT g 1580 IF d(f)=6 THEN LET d$(f)=z$+CHR$ 145 1590 IF d(f)=7 THEN LET d$(f)=y$ 1600 IF d(f)=8 THEN LET d$(f)=z$ 1610 IF d(f)=9 THEN LET d$(f)=y$+CHR$ 145 1620 LET col=col+5: GO SUB 130: LET a$=d$(f): GO SUB 170 1630 LET c(f)=d(f) 1640 IF c(f)=6 THEN LET c(f)=7 1650 IF c(f)=9 THEN LET c(f)=8 1660 IF c(f)=7 THEN LET c$(f)=y$ 1670 IF c(f)=8 THEN LET c$(f)=z$ 1680 IF lines THEN RETURN 1690 NEXT f 1695 LET strtln=23: LET count=1: GO SUB 120 1700 REM HEXAGRAM LOOKUP TABLE 1710 DIM h(8,8) 1720 RESTORE 7400: FOR f=1 TO 8: FOR g=1 TO 8: READ h(f,g): NEXT g: NEXT f 1730 FOR f=1 TO 6 1735 IF d(f)=9 THEN LET d(f)=7: LET change=1 1740 IF d(f)=6 THEN LET d(f)=8: LET change=1 1750 NEXT f 1759 REM TRIGRAM LOOKUP 1760 DIM t(3) 1770 FOR f=1 TO 3: LET t(f)=d(f): NEXT f: GO SUB 310: LET lpt=tri 1780 FOR f=1 TO 3: LET t(f)=d(f+3): NEXT f: GO SUB 310: LET upt=tri 1790 FOR f=1 TO 3: LET t(f)=c(f): NEXT f: GO SUB 310: LET lst=tri 1800 FOR f=1 TO 3: LET t(f)=c(f+3): NEXT f: GO SUB 310: LET ust=tri 1810 FOR f=1 TO 3: LET t(f)=d(f+2): NEXT f: GO SUB 310: LET unt=tri 1820 FOR f=1 TO 3: LET t(f)=d(f+1): NEXT f: GO SUB 310: LET lnt=tri 1899 REM DISPLAY PRIMARY HEXAGRAM 1940 LET ln=4: LET col=30: GO SUB 130: LET a$=STR$ h(lpt,upt): GO SUB 170 1950 RESTORE h(lpt,upt)+7100: READ e$: READ r1: READ r2: LET a$="Your Hexagram: "+e$: LET ln=2: LET col=0: GO SUB 130: GO SUB 170 1960 DIM b$(15): LET a$=b$: LET col=12: FOR f=5 TO 10: LET ln=f: GO SUB 130: GO SUB 170: NEXT f 1970 LET a$="Cosmic Ideals": LET ln=6: GO SUB 130: GO SUB 170: LET char=47: LET ln=5: LET col=25: GO SUB 130: GO SUB 150: LET ln=7: GO SUB 130: LET char=92: GO SUB 150 1980 LET col=12: LET a$="Human Affairs": LET ln=9: GO SUB 130: GO SUB 170: LET col=25: LET ln=8: GO SUB 130: LET char=47: GO SUB 150: LET ln=10: GO SUB 130: LET char=92: GO SUB 150 1990 LET col=26: LET ln=11-r1: GO SUB 130: LET char=144: GO SUB 150 2000 IF r2 THEN LET ln=11-r2: GO SUB 130: GO SUB 150 2010 LET strtln=23: LET count=1: GO SUB 120 2020 IF NOT change THEN LET strtln=15: LET count=7: GO SUB 120: LET ln=17: LET col=18: LET a$="There is no movement in your hexagram, no change": GO SUB 130: GO SUB 170: GO TO 2110 2030 REM LET ln=13: LET col=0: GO SUB 130: RESTORE h(lst,ust)+7100: READ x$: READ r1: READ r2: LET a$="Changing To: "+x$: GO SUB 170 2039 REM M/C LINE COPY Before calling, POKE 59856, Starting line. 59857, Destination line. 59858, # of lines to copy. In at 59862 2040 POKE 59856,3: POKE 59857,14: POKE 59858,8: RANDOMIZE USR 59862 2045 LET ln=13: LET col=0: GO SUB 130: RESTORE h(lst,ust)+7100: READ x$: READ r1: READ r2: LET a$="Changing To: "+x$: GO SUB 170 2050 LET ln=15: LET col=30: LET a$=" ": GO SUB 130: GO SUB 170 2060 GO SUB 130: LET a$=STR$ h(lst,ust): GO SUB 170 2070 LET col=27: LET lin=6: FOR f=16 TO 21: LET a$=c$(lin): LET lin=lin-1: LET ln=f: GO SUB 130: GO SUB 170: NEXT f 2080 LET col=26: LET char=32: FOR f=16 TO 21: LET ln=f: GO SUB 130: GO SUB 150: NEXT f 2090 LET col=26: LET ln=22-r1: GO SUB 130: LET char=144: GO SUB 150 2100 IF r2 THEN LET ln=22-r2: GO SUB 130: GO SUB 150 2110 RESTORE 7640: READ a$: LET ln=23: LET col=43-LEN a$/2: GO SUB 130: GO SUB 170 2120 IF INKEY$="" THEN GO TO 2130 2130 IF INKEY$="1" THEN GO TO 4000 2140 IF INKEY$="2" THEN LET strtln=23: LET count=1: GO SUB 120: RANDOMIZE USR 63010: GO TO 2110 2150 IF INKEY$="3" THEN GO TO 1010 2160 GO TO 2120 2170 GO TO 4000 3000 REM INDIVIDUAL LINES 3010 RESTORE 7390: LET lines=1: LET strtln=0: LET count=24: GO SUB 120 3020 LET a$="The DRAGON'S COMPANION 1.0": LET ln=0: LET col=0: GO SUB 130: GO SUB 170: LET q$="Thoughts For Now!": LET a$=q$: LET ln=1: GO SUB 130: GO SUB 170 3030 GO SUB 1400 3040 LET ln=14: LET col=40: GO SUB 130 3050 LET a$="6) "+z$+CHR$ 145: GO SUB 170 3060 LET ln=ln+2: GO SUB 130: LET a$="7) "+y$: GO SUB 170 3070 LET ln=ln+2: GO SUB 130: LET a$="8) "+z$: GO SUB 170 3080 LET ln=ln+2: GO SUB 130: LET a$="9) "+y$+CHR$ 145: GO SUB 170 3090 LET ln=17: LET col=0: GO SUB 130 3100 LET a$="Press Corresponding Key To Choose >": GO SUB 170 3110 FOR f=1 TO 6 3115 READ a$: READ ln: LET col=0: GO SUB 130: LET a$=a$+" Line": GO SUB 170 3120 IF INKEY$<>"" THEN GO TO 3120 3130 IF INKEY$="" THEN GO TO 3130 3140 IF INKEY$<"6" OR INKEY$>"9" THEN GO TO 3120 3150 LET d(f)=VAL INKEY$ 3170 LET col=22: GO SUB 130: GO SUB 1580 3180 NEXT f 3190 LET strtln=12: LET count=11: GO SUB 120 3200 LET ln=18: LET col=29: GO SUB 130 3210 LET a$="Is This O.K.? (Yes or No)": GO SUB 170 3220 POKE 23658,8: IF INKEY$="" THEN GO TO 3220 3230 IF INKEY$="Y" THEN POKE 23658,0: LET strtln=18: LET count=1: GO SUB 120: GO TO 1710 3240 IF INKEY$="N" THEN POKE 23658,0: GO TO 3010 3250 GO TO 3220 3260 GO SUB 210: GO TO 1010 3999 REM PRIMARY TRIGRAMS DISPLAY 4000 GO SUB 235: RESTORE 7600: READ a$: LET ln=0: LET col=28: GO SUB 130: GO SUB 170: READ a$: LET col=29: LET ln=12: GO SUB 130: GO SUB 170 4010 READ a$: LET ln=1: LET col=0: GO SUB 130: GO SUB 170: LET ln=13: GO SUB 130: GO SUB 170 4020 READ a$: READ col: FOR f=1 TO 4: READ ln: GO SUB 130: GO SUB 170: NEXT f 4030 READ a$: FOR f=1 TO 4: READ ln: GO SUB 130: GO SUB 170: NEXT f 4040 RESTORE 7479+upt: READ address: LET col=0: LET lin=6: FOR f=3 TO 5: LET ln=f: GO SUB 130: LET a$=d$(lin): GO SUB 170: LET lin=lin-1: NEXT f: RESTORE 7550: GO SUB 600 4050 RESTORE 7479+lpt: READ address: LET col=0: LET lin=3: FOR f=8 TO 10: LET ln=f: GO SUB 130: LET a$=d$(lin): GO SUB 170: LET lin=lin-1: NEXT f: RESTORE 7560: GO SUB 600 4060 RESTORE 7479+unt: READ address: LET col=0: LET lin=5: FOR f=15 TO 17: LET ln=f: GO SUB 130: LET a$=d$(lin): GO SUB 170: LET lin=lin-1: NEXT f: RESTORE 7570: GO SUB 600 4070 RESTORE 7479+lnt: READ address: LET col=0: LET lin=4: FOR f=20 TO 22: LET ln=f: GO SUB 130: LET a$=d$(lin): GO SUB 170: LET lin=lin-1: NEXT f: RESTORE 7580: GO SUB 600 4080 RESTORE 7630: READ a$: LET ln=23: LET col=43-LEN a$/2: GO SUB 130: GO SUB 170 4090 IF INKEY$="" THEN GO TO 4090 4100 IF INKEY$="1" THEN LET strtln=23: LET count=1: GO SUB 120: RANDOMIZE USR 63010: GO TO 4080 4110 IF INKEY$="2" THEN GO TO 1010 4120 GO TO 4090 7000 REM INFORMATION RETRIEVAL M/C Word Wrap subroutine. The variable data, points to address of ASCII code. Routine copies code to string A$ and returns to BASIC. Before calling set A$ length (I used a dummy dimensioned string B$). Also poke 59650, max line length wanted. In at 59653. After calling, the value in Address 59648,9 points to the next byte of data. 7005 GO SUB 235: DIM b$(85) 7010 POKE 59650,85: LET data=59949: POKE 59648,data-256*INT (data/256): POKE 59649,INT (data/256): LET col=0: LET ln=0: GO SUB 130 7020 LET a$=b$: RANDOMIZE USR 59653: GO SUB 170 7030 IF PEEK (PEEK 59648+256*PEEK 59649)=255 THEN GO SUB 205: GO TO 1010 7040 GO TO 7020 7100 REM HEXAGRAM NAMES, RULING LINES 7101 DATA "CH'IEN CREATIVE POWER (The Creative)",5,0 7102 DATA "K'UN NATURAL RESPONSE (The Receptive)",2,0 7103 DATA "CHUN DIFFICULT BEGINNINGS (Difficulty at the Beginning)",1,5 7104 DATA "MENG INEXPERIENCE (Youthful Folly)",2,5 7105 DATA "HSU CALCULATED WAITING (Waiting (Nourishment))",5,0 7106 DATA "SUNG CONFLICT",5,0 7107 DATA "SHIH COLLECTIVE FORCE (The Army)",2,5 7108 DATA "PI UNITY (Holding Together (Union))",5,0 7109 DATA "HSIAO CH'U RESTRAINED (The Taming Power of the Small)",5,0 7110 DATA "LU CONDUCT (Treading)",5,0 7111 DATA "T'AI PROSPERING (Peace)",2,5 7112 DATA "P'I STAGNATION (Standstill)",5,0 7113 DATA "T'UNG JEN COMMUNITY (Fellowship With Men)",2,5 7114 DATA "TA YU SOVEREIGNTY (Possession in Great Measure)",5,0 7115 DATA "CH'IEN MODERATION (Modesty)",3,0 7116 DATA "YU HARMONIZE (Enthusiasm)",4,0 7117 DATA "SUI ADAPTING (Following)",1,5 7118 DATA "KU REPAIR (Work On What Has Been Spoiled (Decay))",5,0 7119 DATA "LIN PROMOTION (Approach)",1,2 7120 DATA "KUAN CONTEMPLATING (Contemplation (View))",5,6 7121 DATA "SHIH HO REFORM (Biting Through)",5,0 7122 DATA "PI GRACE",2,6 7123 DATA "PO DETERIORATION (Splitting Apart)",6,0 7124 DATA "FU RETURNING (Return (The Turning Point))",1,0 7125 DATA "WU WANG INNOCENCE (The Unexpected)",1,5 7126 DATA "TA CH'U POTENTIAL ENERGY (The Taming Power of the Great)",5,6 7127 DATA "I NOURISHING (The Corners of the Mouth (Providing Nourishment))",5,6 7128 DATA "TA KUO CRITICAL MASS (Preponderance of the Great)",2,4 7129 DATA "K'AN DANGER (The Abysmal (Water))",2,5 7130 DATA "LI SYNERGY (The Clinging, Fire)",2,5 7131 DATA "HSIEN ATTRACTION (Influence (Wooing))",4,5 7132 DATA "HENG CONTINUING (Enduring (Duration))",2,0 7133 DATA "TUN RETREAT",5,0 7134 DATA "TA CHUANG GREAT POWER (The Power of the Great)",4,0 7135 DATA "CHIN PROGRESS",5,0 7136 DATA "MING I CENSORSHIP (Darkening of the Light)",2,5 7137 DATA "CHIA JEN FAMILY (The Clan)",2,5 7138 DATA "K'UEI CONTRADICTION (Opposition)",2,5 7139 DATA "CHIEN OBSTACLES (Obstruction)",5,0 7140 DATA "HSIEH LIBERATION (Deliverance)",2,5 7141 DATA "SUN DECLINE (Decrease)",5,0 7142 DATA "I BENEFIT (Increase)",2,5 7143 DATA "KUAI RESOLUTION (Breakthrough (Resoluteness))",5,0 7144 DATA "KOU TEMPTATION (Coming to Meet)",2,5 7145 DATA "TS'UI ASSEMBLING (Gathering Together (Massing))",4,5 7146 DATA "SHENG ADVANCEMENT (Pushing Upward)",5,0 7147 DATA "K'UN ADVERSITY (Oppression (Exhaustion))",2,5 7148 DATA "CHING THE SOURCE (The Well)",5,0 7149 DATA "KO CHANGING (Revolution (Molting))",5,0 7150 DATA "TING COSMIC ORDER (The Cauldron)",5,6 7151 DATA "CHEN SHOCKING (The Arousing (Shock, Thunder))",1,0 7152 DATA "KEN MEDITATION (Keeping Still, Mountain)",6,0 7153 DATA "CHIEN DEVELOPING (Development (Gradual Progress))",2,5 7154 DATA "KUEI MEI SUBORDINATE (The Marrying Maiden)",5,0 7155 DATA "FENG ZENITH (Abundance (Fullness))",5,0 7156 DATA "LU TRAVELING (The Wanderer)",5,0 7157 DATA "SUN PENETRATING INFLUENCE (The Gentle (The Penetrating, Wind))",5,0 7158 DATA "TUI ENCOURAGING (The Joyous, Lake)",2,5 7159 DATA "HUAN REUNITING (Dispersion (Dissolution))",5,0 7160 DATA "CHIEH LIMITATIONS",5,0 7161 DATA "CHUNG FU INSIGHT (Inner Truth)",5,0 7162 DATA "HSIAO KUO CONSCIENTIOUS (Preponderance of the Small)",2,5 7163 DATA "CHI CHI AFTER THE END (After Completion)",2,0 7164 DATA "WEI CHI BEFORE THE END (Before Completion)",5,0 7199 REM MENU DATA & SCREEN PARAMETERS 7200 DATA "0) Black - White","1) Blue - Yellow","2) Red - Cyan","3) Magenta - Green","4) Green - Magenta","5) Cyan - Red","6) Yellow - Blue","7) White - Black"," ","8) Return To Main Menu" 7389 REM SCREEN PARAMETERS 7390 DATA "Bottom",10,"Second",9,"Third",8,"Fourth",7,"Fifth",6,"Top",5 7399 REM HEXAGRAM LOOKUP CHART 7400 DATA 1,34,5,26,11,9,14,43 7410 DATA 25,51,3,27,24,42,21,17 7420 DATA 6,40,29,4,7,59,64,47 7430 DATA 33,62,39,52,15,53,56,31 7440 DATA 12,16,8,23,2,20,35,45 7450 DATA 44,32,48,18,46,57,50,28 7460 DATA 13,55,63,22,36,37,30,49 7470 DATA 10,54,60,41,19,61,38,58 7479 REM TRIGRAM DATA ABOVE RAMTOP 7480 DATA 56422 7481 DATA 56520 7482 DATA 56625 7483 DATA 56750 7484 DATA 56873 7485 DATA 56992 7486 DATA 57109 7487 DATA 57232 7549 REM SCREEN PARAMETERS 7550 DATA 3,15,32,2,0,32,4,20,65,2,21,32,2,32,32,2,50,32,2,57,15,2,72,13 7560 DATA 8,15,32,7,0,32,9,20,65,7,21,32,7,32,32,7,50,15,7,57,15,7,72,13 7570 DATA 15,15,32,14,0,32,16,20,65,14,21,32,14,32,32,14,50,13,14,57,14,14,72,13 7580 DATA 20,15,32,19,0,32,21,20,65,19,21,32,19,32,32,19,50,15,19,57,15,19,72,13 7600 DATA "<<<<< COMPONENT TRIGRAMS >>>>>","<<<<< NUCLEAR TRIGRAMS >>>>>" 7605 DATA "---- IMAGE -------- DIRECTION - RELATION ------- BODY - TIME OF YEAR - TIME OF DAY --" 7610 DATA "NAME:",10,3,8,15,20 7620 DATA "QUALITIES:",4,9,16,21 7630 DATA "* OPTIONS * 1) COPY 2) MAIN MENU * CHOOSE *" 7640 DATA "* OPTIONS * 1) TRIGRAM ATTRIBUTES 2) COPY 3) MAIN MENU * CHOOSE *" 8999 LET strln=0: LET count=24: GO SUB 120: CLS : LET mode=0: GO SUB 110: ON ERR RESET : STOP 9991 PRINT AT 3,0;: LOAD ""CODE 9992 DATA 0,192,176,136,136,176,192,0,0,12,52,68,68,52,12,0,0,0,252,252,252,252,0,0: RESTORE 9992: FOR f=0 TO 23: READ a: POKE (USR "a"+f),a: NEXT f 9993 SOUND 7,56;8,16;9,16;10,16;12,75;13,0;0,251;1,0;2,139;3,0;4,167;5,0 9994 PRINT #1;AT 1,4;"Press SpaceBar For Menu" 9995 IF INKEY$="" THEN GO TO 9995 9997 CLEAR 56421: GO TO 10 9999 CLEAR : SAVE "D_C" LINE 9991: SAVE "DC&Timex85"CODE 56422,6758: BEEP .1,10: PRINT " Rewind Tape And Play To Verify": VERIFY "": VERIFY ""CODE : RUN ```