COLON algorithm
Posted: Sun Jan 19, 2025 12:42 pm
Hi all!
Overview
All times I asked, I got same answer: It is not possible in QL to know from where a software was launching, MDV1, MDV2, FLP1, WIN... whatever. It is so annoying that before to dig deeper in OS and System vars, I decided to create an algorithm that shows "from where" the software was launched.
Actually, what it does is to tells where it is. So anyone can using this algorithm or the code that I am going to release soon to create software that can be launch from any device post-release. You don't need any more to ask to the user which unit is the main one to launch the software. It does it by itself.
Does it work with previos software? No directly. The software would need some modification in order to use the program or implement the algorithm. But it doesn't mean that could be impossible because on the same way the launched unit could be virtualized (something that I discovered reading about Minerva) by software thanks to the algorithm and that would allow to also use it.
State of the algorithm
Now the algorithm is being implementing in SuperBasic (for prototype purpose) before compile it.
The code in SuperBasic is plain and very very general, so it should work with any ROM and ROM version. No needs to use particular TKII, Minerva, JM, J... whatever.
Last night I was testing it in QEmulator and that worked fine. Just left last part to handle exceptions, and getting info about it.
How does it work?
The diagram will be posted here but in some words.
More
As always, I am very easy trigger XD so I forwarded before finish it (my style to encourage myself to finish it and don't loose the interest about it), and before to loose the interesting in this solved puzzle.
Why did I name it Colon?
There are two + 2 reasons:
Credits:
Special thanks to Andrei for his support debugging in SuperBasic where I am completely new.
Code demostration
Download demo
Attached file contains an MDV image with a basic demonstration.
Pay attemption the TOKEN must match the patter into the code. Later version will allows to pass it as a parameter to do it even more general.
With a compiled and basic version.
You can download a demo about how it works. It is not finished yet as I would like but...with my free version of QEmulator and my QLs with only MDPs I cannot test for demonstration purpose more than is shown
You may find some errors, the code doesn't pretend to be a stable version but the implementation of COLON. For that purpose what I do is to set the code in the MDV1 and in the MDV2 the right TOKEN, but you can put it another place, just keep in mind that since I didn't implement the exception manager (or OPEN function) yet, those units must be with something inside (not empty).
I am sure you know better than I how to use OPEN or TRAPs better than I and can implement it.
Basic is fine, C much easier and faster. ASM no idea
Overview
All times I asked, I got same answer: It is not possible in QL to know from where a software was launching, MDV1, MDV2, FLP1, WIN... whatever. It is so annoying that before to dig deeper in OS and System vars, I decided to create an algorithm that shows "from where" the software was launched.
Actually, what it does is to tells where it is. So anyone can using this algorithm or the code that I am going to release soon to create software that can be launch from any device post-release. You don't need any more to ask to the user which unit is the main one to launch the software. It does it by itself.
Does it work with previos software? No directly. The software would need some modification in order to use the program or implement the algorithm. But it doesn't mean that could be impossible because on the same way the launched unit could be virtualized (something that I discovered reading about Minerva) by software thanks to the algorithm and that would allow to also use it.
State of the algorithm
Now the algorithm is being implementing in SuperBasic (for prototype purpose) before compile it.
The code in SuperBasic is plain and very very general, so it should work with any ROM and ROM version. No needs to use particular TKII, Minerva, JM, J... whatever.
Last night I was testing it in QEmulator and that worked fine. Just left last part to handle exceptions, and getting info about it.
How does it work?
The diagram will be posted here but in some words.
- It use a TOKEN to ID the unit that store the rest of the program.
- The algorithm explore in a determinate order (can be set by the programmer/user) the units searching for the TOKEN
- When a unit is not present, ignores it and process the next one.
- If a unit contains its disk or cartridge but not token, ignore and process the next one
- When a unit contains its device and has a token but it is not the right one, ignore and process the next one
- When it is found, the unit is stored into a var accessible from QDOS named unit$.
- If not matching token was found, assign to the var unit$ the value of 'none'
- Now the rest of the software (Boot, loading program) can use this var to reference the loading unit$_myprogram_bas or whatever.
- The TOKEN ID is just a text file with a number that the programmer decide and the searching algorithm use to match the searching.
- When the TOKEN is in the same support than the calling program, it results in finding itself and identified the origin device from where it was launched.
- From this point, the programmer can use this var instead absolute references in his code. Allowing from then on, to run it freely from any source (floppy, mdv, win, ramdisk, etc)
- It can be modified as please.
- To use a user define system var instead a basic var. But need time due my lack of QL programming experience.
- Accept parameters in order to make it more modular
- To use OPEN function instead of Merge (mandatory) in order to manage in a better way the exceptions
- Expert explorations of the units instead scalar order (MDV1, FLP1, WIN1, MDV2, FLP2, WIN2, MDV3,MDV4...) instead of (MDV1...MDV8, FLP1...FLP8, so on)
- Add a last function that once the unit is found, if the user desire it set that unit as another one by software, what gives a lot of retrocompatibility.
More
As always, I am very easy trigger XD so I forwarded before finish it (my style to encourage myself to finish it and don't loose the interest about it), and before to loose the interesting in this solved puzzle.
Why did I name it Colon?
There are two + 2 reasons:
- Because always the answer was that it is impossible.
- Due to its simplicity, same than the Egg demonstration of Colon (Columbus)
Credits:
Special thanks to Andrei for his support debugging in SuperBasic where I am completely new.
Code demostration
Code: Select all
10 REMark @Copyright Silverio M. Rosales Santana 2025
20 CLS : CLEAR
30 CTOKEN = 1234 : REMark Token value verification ID
40 NToken$ = '_TOKEN': REMark File token name
50 CheckF = 800 : REMark Line for checking procedure
60 unit$ = 'none'
70 NEXT_BUCLE = 220 : REMark Address for the next part to use in seeking
80 MAIN_BUCLE = 130 : REMark Base for calling the main bucle
90 AT 0,6 : PRINT "Demo of algorithm, COLON"
95 AT 4,0 : PRINT "The variable unit$ stores the result"
97 AT 6,6 : PRINT "Otherwise unit$ is none"
100 AT 10,6 : PRINT "press any key to proceed"
110 PAUSE
120 unit$ = 'mdv'
130 REMark Bucle for MDV units
140 i = 1
150 unitAux$ = unit$ & i
160 REMark PRINT unitAux$
170 MERGE unitAux$ & NToken$
180 GO SUB CheckF
190 i = i + 1
200 IF i > 8 THEN GO TO NEXT_BUCLE
210 GO TO 150
220 REMark Bucle for FLP units
230 unit$ = 'flp'
240 NEXT_BUCLE = 260
250 GO TO MAIN_BUCLE
260 REMark bucle for WIN units
270 unit$ = 'win'
275 NEXT_BUCLE = 290
280 GO TO MAIN_BUCLE
290 PRINT "Not found, END"
300 REMark set none and stop
310 unit$ = 'none' : STOP
320 REMark if not before STOP should clear and free mem
800 TOKEN = 12345
900 IF CTOKEN = TOKEN THEN
905 CLS
910 AT 8,8 : PRINT "Token"! CTOKEN ; " in >"! unitAux$
915 unit$ = unitAux$ : STOP
935 END IF
940 RETurn
Download demo
Attached file contains an MDV image with a basic demonstration.
Pay attemption the TOKEN must match the patter into the code. Later version will allows to pass it as a parameter to do it even more general.
With a compiled and basic version.
You can download a demo about how it works. It is not finished yet as I would like but...with my free version of QEmulator and my QLs with only MDPs I cannot test for demonstration purpose more than is shown


Basic is fine, C much easier and faster. ASM no idea
