Jump to content
IGNORED

Turbo Basic Programming for Compiler.


Grevle

Recommended Posts

I did som speed tests comparing turbo basic XL Basic and Turbo Basic Xl compiled code and the compiled code seems to be about 10 times faster than uncompiled turbo basic.

 

I did not try compile a Basic program that have some assembler routines, but if that wold work the speed that can be achieved would be way beyond any 8-bit basic it seem.

 

When programming for compiler one cannot use Goto or Gosub variables and peek adresses and so and, Even thou gosub peek(632) is a conveniant way of reading joysticks, when writing for compiler one must use a more traditional aproach like using " If stick(0) then gosub or If Peek(632) then gosub and so on.

 

Even thoug programming for compiler is a little more cumbersome, the speed that can be achived is worth it i think, So il gonna try that sometime in the future.

 

Anyone know if other specific considerartion needs to be taken when programming for compiler ?

 

Thanks.

Link to comment
Share on other sites

Im used to Basic programming so , understanding assembler is not so easy to get the hang of. I can make some small assembler routines, But to make a program in 100% assembler is hard in the beginning because one needs to learn how everything is done and there can be many ways of doing the same function, Also with very little experince with assembler its not so easy to create something usefull.

 

In Turbo basic its nice to use string handling for Player missile data since String handling is basically a machine language operation so vertical movement then is fast enough to program games.

 

A Turbo basic program with some assembler routines and then compile it is actually a little dream come true, as i remember how slow Atari basic was back in the 80's.

 

Nothing can beat Pure assembler for speed but Turbo basic is a nice alternative for us Hobby programmers :)

Edited by Grevle
Link to comment
Share on other sites

Turbo-BASIC itself isn't that bad. It actually is an excellent Basic. The problem I have with it is that you always need to have the RunTime or the Basic itself at hand if you come across a .CTB or .TRB program. Thereby comes that I'm a SpartaDos 3.x user and that doesn't mix with Turbo-Basic.

Link to comment
Share on other sites

TBLINKER.ATR

 

make turbobasic program.

compile it'

run turbobasic

RUN "D1:LINKER.TXL

 

Also for SicCart. http://www.atariage....s/#entry2637730

 

Err well,

 

the problem is, that the CTB-Linker will first try to load Runtime2.EXE and if it is not there you get an Error. So, why not use the compiled version of the CTB-linker ?!? Do it like this:

 

1) compile your TB XL program and save it as *.CTB onto a disk with lots of free sectors...

2) with DOS option "L" binary load, load the Runtime2.EXE program (Runtime for CTB files, required to load the compiled version of the CTB-linker))

3) if the CTB-linker is named Autorun.CTB it will be loaded automatically

4) as soon as the CTB-linker is loaded it does what - it loads the Runtime2.EXE again (this time required for YOUR compiled program that should be linked with the Runtime)

5) now the CTB-linker asks for a source and destination filename (without D: or D1:-D9:, only D1: is supported anyways, no subdirs), e.g. type in Program.CTB for source and Program.COM for destination

6) now the CTB-linker will save a patched version of the Runtime to disk (using your given filename)

7) next, the CTB-linker will load your compiled program

8 ) finally it will append the compiled program to the Runtime (saving it under the given filename)

 

Note: TB XL does switch off Atari Basic automatically, however the Runtime for CTB files does not and so the *.COM/*.EXE/*.XEX file created with the CTB-linker will also NOT switch off Atari Basic automatically. You either have to hold down the Option key, each time you boot this program or better put a short (55+2 bytes) Basic-off switcher in front of the linked program (e.g. use copy + append function under DOS or use Superpacker on the A8 or on the PC to do this).

 

Regarding the length of linked CTB-files, well, if one requires e.g. 80 sectors for an Atari Basic or TB XL file, it may have 120 sectors in length when compiled. Since the Runtime consumes 88 sectors, a linked CTB file will therefore consume 120 + 88 = 208 sectors. Much longer than the AB or TB file indeed, however you may use a packer to make such linked files shorter on diskette. With Code3-Cruncher 3.x try to pack the linked program with step 9 (under emulation use full-speed). With Superpacker you can pack all data-segments between page 6 INIT and page 6 RUN...

 

-Andreas Koch.

ctb_linker.zip

Link to comment
Share on other sites

Also regarding the length, you don't have that 8192 bytes of Atari Basic present (if that is an issue), but you do have the extra time it takes the drive to load those additional program bytes. If loaded from a hard drive, that's not much delay.

-Larry

Link to comment
Share on other sites

  • 6 months later...

10 ------------------------------
100 M=18400:DIM T$(M),F$(64),C$(6),C1$(6),N$(13),S$(64):T$(M)=CHR$(0):POKE 82,8:POKE 694,0:POKE 702,64:CLS 
110 ------------------------------
120 N$="D:AUTORUN.BAS"
130 ------------------------------
140 ? " TURBO-BASIC Modifier"
150 ? "CAUTION work on a copy" "This program is FINAL." "It won't work on files"
160 ? "once they are modified" "(including this mod!)"
169 ------------------------------
170 ?  "Insert TURBO-BASIC disk" "Enter complete filespec" :INPUT "=> ",F$
180 TRAP 580:OPEN #1,4,0,F$
190 TRAP 200:BGET #1,ADR(T$),M
200 CLOSE :T$=T$(1,DPEEK($0358)):C1$="©Æ©":C$="©”Æ©"
210 X=INSTR(T$,C1$):IF X>0:T$(X,X+6)=C$:X1=X:ENDIF
220 FOR X=1 TO 6:READ Y:S$(X)=CHR$(Y):NEXT X:DATA 67,4,50,0,0,0
230 X=INSTR(T$,S$):ON X=0 GOTO 560
240 T$(X+1,X+1)=CHR$(5)
250 T$(X+2,X+2)=CHR$(24)
260 T$(X+3,X+3)=CHR$(64)
270 RESTORE 270:FOR X=1 TO 6:READ Y:S$(X)=CHR$(Y):NEXT X:DATA 32,242,251,32,236,251
280 X=INSTR(T$,S$):ON X=0 GOTO 310
290 RESTORE 290:FOR X=X TO X+5:READ Y:T$(X,X)=CHR$(Y):NEXT X:DATA 32,19,252,234,234,234
300 GOTO 350
309 ------------------------------
310 RESTORE 310:FOR X=1 TO 6:READ Y:S$(X)=CHR$(Y):NEXT X:DATA 32,152,82,32,172,82
320 X=INSTR(T$,S$):ON X=0 GOTO 560
330 RESTORE 330:FOR X=X TO X+5:READ Y:T$(X,X)=CHR$(Y):NEXT X:DATA 32,205,82,234,234,234
340 VERSION=1
349 ------------------------------
350 X=INSTR(T$,"YDAER"):ON X=0 GOTO 560
360 IF VERSION
370 T$(X,X+4)="obruT"
380 ELSE
390 T$(X,X+4)="OBRUT"
400 ENDIF
410 X=INSTR(T$,"D:AUTORUN.BAS"):ON X=0 GOTO 560
420 T$(X,X+12)=N$
430 ?  "TURBO-BASIC patched" "for NTSC.";
440 IF N$<>"D:AUTORUN.BAS" THEN ? " Autorun" "filespec changed."
449 ------------------------------
450 ?  "START to write file"
459 ------------------------------
460 R=PEEK(53279):ON R<>6 GOTO 460
470 S$="" :?  "Ready to write file." :? "Enter new filespec or"
480 ? "(caution) to write to" F$
489 ------------------------------
490 ? CHR$(156);"just hit Return":INPUT "=> ",S$:IF S$="" THEN S$=F$
500 ? S$:F$=S$:TRAP 510:UNLOCK S$
509 ------------------------------
510 TRAP 580:OPEN #1,8,0,S$
520 BPUT #1,ADR(T$),LEN(T$):CLOSE
529 ------------------------------
530 ?  "Another copy START" :? "Quit program OPTION"
539 ------------------------------
540 M=PEEK(53279):ON M=6 GOTO 490:ON M<>3 GOTO 540
549 ------------------------------
550 POKE 82,2:TRAP 40000:END
559 ------------------------------
560 IF X1<>0 THEN GOTO 450
570 ? "File previously modified":GOTO 550
579 ------------------------------
580 CLOSE  :? " DISK ERROR #";ERR:? :ON S$="" GOTO 170:GOTO 530

Does anyone here remember the TBASIC patch for NTSC time functions? IIRC, the clock would run too fast using the time functions.

10 pos.5,5:?time$:g.10 seems to run fast. There was also a patch for runtime.

 

Google has been no help so far.

 

Thanks!

 

-K

I have modified this code to change the brown screen to blue. This should modify Turbo basic and the SpartaDOS Fix called TB32Q.COM. It has been awhile so I am not real positive that it modifies the RUNTIME also but you can try.. In it's original form it had REM lines for instructions. First prompt will ask for D:Filename [sTART] Second prompt will either ask for new name or Enter for same name. Last prompt will be [OPTION] to quit program.

 

TBFIX.ZIP The listed file zipped because AtariAge didn't like to upload a 'LST' file..

Edited by rdea6
Link to comment
Share on other sites

The speed comparison was not right. the speed of compiled code vs Uncompiled Turbo basic seem to usually be between 3 to 5 times faster for the compiled code, depends on what the program is doing.

 

And heres a discovery on the compiler, it may be already know, And that is that the compiler do support on Gosub or On goto Branching.

 

And i have testet that myself susscesfully.

 

That works because in On gosub and On goto as in this example On X Goto 10,20,30, the Compiler know that

 

if X=1 then goto 10 or if X=2 then goto 20 or if X=3 then goto 30, so the numbers are set and the compiler understands it.

 

So this works But a Goto X (goto varable) will not work with the compiler because X can be anything and the number X is not set while compiling the code. Also tested.

 

But On Gosub And On goto is a good substitue for Goto Variable, very usefull for branching in games etc etc.

Edited by Grevle
Link to comment
Share on other sites

I hope I did this correctly... Attached should be TurboBASIC-XL complete package for NTSC Clock. Includes Linker. Linker DOES NOT WORK if compiled and linked. Run it in TBASIC.

 

Please let me know if it works for you. *** PLEASE RENAME TO TBNTSC.ARC*** For some reason, it wouldn't let me attach .arc file. Just remove the .zip from the filename.

 

-K

 

TBNTSC.ARC.zip

Link to comment
Share on other sites

I hope I did this correctly... Attached should be TurboBASIC-XL complete package for NTSC Clock. Includes Linker. Linker DOES NOT WORK if compiled and linked. Run it in TBASIC.

 

Please let me know if it works for you. *** PLEASE RENAME TO TBNTSC.ARC*** For some reason, it wouldn't let me attach .arc file. Just remove the .zip from the filename.

 

-K

 

TBNTSC.ARC.zip

This arc file seems to be slightly corrupted, both for Windows ARC extractor and SpartaDos ARC . Programs states bad header and several files return CRC errors.
Link to comment
Share on other sites

  • 1 year later...

Command Line Linker!

 

Here's a linked linker for TurboBASIC-XL for the SDX command line. Syntax: C:>LINK PROGRAM.CTB produces PROGRAM.EXE. If ran without a command line arguement, it asks for the filename (as the usual linker does). It requires RUNTIME2.EXE in the same directory as the linker.

 

You may use the NTSC or PAL runtime, just make sure it's the same size, and named RUNTIME2.EXE.

 

This file is rather large, so it's intended for those with hard drives, and of course SDX.

 

EDIT: Please note that this reads the command line in a 64 byte buffer, so complete pathnames must not exceed that value. Pathnames are internally expanded to for example, "DSKC:\DIRECTORY\SUBDIR\SUBDIR2>LINK OBJECT.CTB

LINK.ARC

Edited by Kyle22
  • Like 1
Link to comment
Share on other sites

  • 3 months later...

Is there a way to link together the:

1) runtime

2) compiled CTB

3) other XEX file that the CTB would load data from into memory using BGET?

 

For memory saving reasons i had to move most of my data to an external xex file that is loaded into memory using BGET.

 

However, I'd still like to end up with a single executable file if possible.

 

Is there a way?

 

Thanks!

-Eric

 

Link to comment
Share on other sites

  • 2 weeks later...

I've been playing with the TBXL Compiler recently and found it had trouble dealing with arrays. This:

 

100 B(2,0)=B(2,2)-D(1,1)-D(1,4)-D(1,6)=B(2,0)

 

Does just fine in the Interpreter - but compiled will crash on execution, reporting a Dim error. One dimensional arrays do the same thing. Strangely, this:

 

100 X=B(2,2)-D(1,1)-D(1,4)-D(1,6):B(2,0)=X

 

Will execute but come up with the wrong number! This executed accurately:

 

100 X=B(2,2)-D(1,1):x=X-D(1,4):x=X-D(1,6):B(2,0)=X

 

Similar math with regular variables have had no problems. In fact, this floating point tongue twister-

 

100 Y=(SIN(XT)+SIN(XT*3)*0.4)*56

 

Worked perfectly.

Edited by JD6502
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...