Jump to content


Multi-Part Loader for Compiled Turbo Basic XL 1.5 Programs

Turbo Basic Compiler CTB

2 replies to this topic




  • 1,811 posts
  • Always looking for GFX and MSX for my demos
  • Location:Lebach, Germany

Posted Mon Jan 18, 2016 5:00 PM

When apemaster (aka Kemal aka Yoda) released the 25 years "Techo Ninja" edition




a lot of people had trouble starting the program in emulators. The reason behind that was that when Yoda wrote the program 25 year ago, he was faced with the problem that a compiled Turbo Basic program cannot load another part that is also compiled. Back then he came up with a clever trick to circumvent this problem:


If the RUNTIME.COM is loaded, (for example by renaming it to AUTORUN.SYS), it tried to automatically load the program "D:AUTORUN.CTB". So what Yoda did was, that he had the TITLE and the MAIN program on disk and depending on which was to be started, he renamed it to "AUTORUN.CTB" and restarts to runtime. Because the default for mounting files as disk images in Altirra is "Read/Only" exactly this renaming failed and the pogram was stuck was a DOS error message (you could not see, because a dedicated display list is active).


When he told me amout the issue I thought is was an interesting problem. So after only 8 months of tracing and debugging from time to time, here is the solution. Pitty it won't help TecnoNinja itself because the sources are long lost, but maybe it will be useful for other Turbo Basic fans.



The solution is a relcoatable inline machine language routine to which you can pass the name of the file  (with ".TUR" extension!).

  • If the routine is called from within regular Turbo Basic,it will return without doing something and you can load the uncompiled program using RUN "D:....TUR".
  • If the routine is called from within the compiled runtime, it will load the compiled program with the ".CTB" extension instead of the ".TUR" extensions.

This way you can have a single source that transparently works with uncompiled and compiled programs.




The archive contains and ATR and also the MADS source for the routine.




Attached Files




  • Topic Starter
  • 1,811 posts
  • Always looking for GFX and MSX for my demos
  • Location:Lebach, Germany

Posted Mon May 16, 2016 1:49 PM

The week after the post above I finally found the time to read the "Das neue Turbo-Basic XL 1.5 Handbuch" published by the ABBUC in 2015. And guess what, when I arrived at the "RUN" command it stated that "RUN" worked in compiled program and can load compiled programs then. Murphy's law: You HAVE TO FIND THE HARD SOLUTION FIRST YOURSELF, before you can find the easy solution of somebody else.


Today I finished proof reading the book and submitted the changes to the ABBUC for the new revision of the book. So I thought that is a good occation to show you the reading books about Atari computer pays off. The whole problem can be reduced to detecting if you are in the interpreter or the compiled runtime. This can be easily distingushed by looking at $2081. It contains $80 is interpreted, $7d if compiled. So basically a simple IF does the trick.




Attached File  RunCTB-Simple.atr   140.02KB   91 downloads




#3 flashjazzcat OFFLINE  



  • 14,315 posts
  • Location:United Kingdom

Posted Mon May 16, 2016 2:04 PM

Very cool. It's nice that we can still discover new things after all these years!

Also tagged with one or more of these keywords: Turbo Basic, Compiler, CTB

0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users