Hmmm, I guess Homer was a little premature up there.
Well, let's see what we can do. Let's choose another "Marker", kind of like the 0x7E, but this time we'll use it to mark the changes in a "Thread". So I'll choose 0xFF, but could be just about any other non-printable number. Along with the Marker, we'll put another number to indicate what to do next. So the end of a Thread section will have something like 0x01FF.
Taking the same data again, and splitting it into "Threads". I realize the text doesn't make sense when playing it back, but it's some sample data to use for now.
Code:
Inst1:
ASM
da " TO SET THE ", 0xC0FE, "WATERING SCEDULE",0 ; both threads
da " ALLOW THE SOIL ", 0xC0FE, "TO DRY OUT UNTIL",0 ; start here
da " IT REQUIRES ", 0xC0FE, " A WATERING ",0
da " THEN ADJUST ", 0xC0FE, " THE PUMP ON # ",0,0x01FF
Thread1
da " BY ROTATING POT", 0xC0FE, " #4 UNTIL IT ",0 ; only shows
da "EQUALS THE MOIST", 0xC0FE, "# AT WHICH TIME ",0 ; when Thread=1
da " THE PUMP WILL ", 0xC0FE, " TURN ON ",0,0x02FF
Thread2
da " BY ROTATING POT", 0xC0FE, " #5 UNTIL IT ",0 ; only shows
da "EQUALS THE MOIST", 0xC0FE, "# AT WHICH TIME ",0 ; when Thread=2
da " THE PUMP WILL ", 0xC0FE, " TURN OFF ",0,0x02FF
Inst1End
da " NOW EVERY TIME ", 0xC0FE, "IT DRIES OUT TO ",0 ; both threads
da " THAT MOISTURE ", 0xC0FE, "LEVEL IT WILL BE",0 ; finish here
da " WATERED ", 0xC0FE, " AUTOMATICALLY ",0
da " SET IT ONCE AND", 0xC0FE, " FORGET IT ",0
da " PRESS SWITCH 4 ", 0xC0FE, " TO EXIT ",0,0x7E
EndAsm ' The Last word must always be 0x7E
Then, just above where the routine checks for $7E, add this code that looks for the Marker. And decides where to go next.
Code:
if Char = $FF then
Addr = Addr + 1
Readcode Addr, Char
IF Char = 1 then ; 0x01FF found
if Thread = 1 then
@ GetAddress Thread1, _Addr
endif
if Thread = 2 then
@ GetAddress Thread2, _Addr
Endif
endif
if Char = 2 then ; 0x02FF found
@ GetAddress Inst1End, _Addr
endif
endif
Of course you'll need to add a variable
Thread VAR BYTE
Now then, before starting the Display routines, set the Thread variable to indicate which path to take and then call the display routines like normal.
Code:
Thread = 2
@ GetAddress _Inst1, _Addr
Gosub NextLine
The sample Markers are just an example, you could have any number of different tasks specified in that "Number" that goes with the Marker. Allowing you to jump in and out of any portion as needed.
HTH,
Darrel
Bookmarks