Jump to content
IGNORED

Optimising code in TurboBASIC


Recommended Posts

Well, I have started on my first programming project on the Atari 8-bit in about 20 years: A Super Breakout game ... I am currently coding in TurboBASIC, tho I may end up porting into Action if I can ever learn enough about it. Among the things I will be doing, is using a Display List interrupt on a Graphics 0 screen with the GTIA bit set to 1 (Graphics 9) so I can get 16 shades of one color on the screen, in rainbow bands, much like in the 2600 Breakout game.

 

My question is, are there any tricks to speeding up TurboBASIC execution? I can imagine one way is to use hardware registers to read your controllers, instead of PADDLE(0) and the like ... and also PEEKing and POKEing the screen directly instead of using PRINT and the other BASIC commands. Although I plan on using the MOVE command along with a string variable if I need to do block operations to the screen.

 

I noticed also, I have some variables in my code which determine factors like wall collisions, that are set to either 1 or 0. If I instead dedicated a page zero register to this, and just put bits into it rather than waste variables on these, would this speed up execution? Also wondering, what Page Zero locations are safe for use?

 

Are there any other tricks which can speed up the code?

 

The other question I have: There is a ML routine from an issue of Compute! magazine, which allows for playing sounds in the background while your program is running. You feed the routine with a string variable containing the sound data, and it plays this string in the background. Does anyone have this routine, or know where I can find it on the web? I want to simulate the many sounds used in the 2600 Super Breakout game, only with the POKEY chip.

  • Like 1
Link to comment
Share on other sites

The STICK and PADDLE functions are actually quicker than PEEK in normal Atari Basic, probably because the floating point conversion of the paramater happens a bit quicker.

 

Clever programming will probably help you out somewhat, but I don't think TurboBasic suffers from a lot of the same penalties as normal Basic, like running slower the further into the program etc.

 

There's Compute magazines archived in various places on the 'net, so the old articles aren't lost (I don't have the links), but if you had a rough idea of year/month or the name of the article, I might have it here somewhere.

Link to comment
Share on other sites

  • 3 weeks later...
The other question I have: There is a ML routine from an issue of Compute! magazine, which allows for playing sounds in the background while your program is running. You feed the routine with a string variable containing the sound data, and it plays this string in the background. Does anyone have this routine, or know where I can find it on the web? I want to simulate the many sounds used in the 2600 Super Breakout game, only with the POKEY chip.

http://www.atariage.com/forums/index.php?s...t&p=1551380

Link to comment
Share on other sites

  • 1 month later...

The STICK and PADDLE functions are actually quicker than PEEK in normal Atari Basic, probably because the floating point conversion of the paramater happens a bit quicker.

 

Clever programming will probably help you out somewhat, but I don't think TurboBasic suffers from a lot of the same penalties as normal Basic, like running slower the further into the program etc.

 

There's Compute magazines archived in various places on the 'net, so the old articles aren't lost (I don't have the links), but if you had a rough idea of year/month or the name of the article, I might have it here somewhere.

This is very interesting to me (especially as I'm usually using plain old Atari Basic)... will put back the stick and strig commands, has anyone got an article on this?

 

The 'sound commander' link looks very interesting too :thumbsup: as I normally end up minimising/not having sounds to allow for faster movement.

 

Any thoughts on using the ON command instead of IF to allow more than one decision to be made on a single line of code? I went for this approach as thought would be quicker for basic to run subsequent lines of code (as less lines of code before it) if this makes sense!

e.g.

50 IF z=1 then this

51 IF z=2 then that

vs

50 ON Z=1 goto this:ON Z=2 goto that

 

Something I've just done on my current abbuc game entry 'Gorilla Warfare' was to use blocks of sequential characters (if using redefined character set graphics for locating), this allows me to check (locate command) a batch of items collected that may kill you etc ;-)

Link to comment
Share on other sites

  • 2 weeks later...
  • 5 years later...

Seems I have found it:

 

http://www.atarimagazines.com/compute/issu...d_Commander.php

 

This is a ML program which will play your sounds in the background while your basic program runs.

 

Question now is: I also want to use a DLI in my program, will this sound utility interfere with that?

Does anybody have a working version of this Sound Commander program from Compute! Issue 78?

 

It sounds very interesting, but the scanned code at this link clearly has some issues probably due to OCR when it was scanned. I tried to fix it myself, but it is not generating and sound.

 

I'd love to get a working version to check it out.

 

Thanks!

Link to comment
Share on other sites

Does anybody have a working version of this Sound Commander program from Compute! Issue 78?

 

It sounds very interesting, but the scanned code at this link clearly has some issues probably due to OCR when it was scanned. I tried to fix it myself, but it is not generating and sound.

 

I'd love to get a working version to check it out.

 

Thanks!

Just an FYI. To get the demo on that .ATR to run properly, PROG2.BAS, you have to delete all lines below 100 or type

G.100

And there is still an error in the program. Change line to

5030 DIM S1$(200),S2$(30),S3$(100)

as the one on the disk still has an error SL$ vs. S1$

Link to comment
Share on other sites

Rainy day pastime. Binary save from DOS, DIS6502, mucho editing, then TASM. It assembles fine but I didn't bother putting it back together as DATA statements to insure accuracy with the original because I was going to rewrite it as an Action! procedure for the fun of it. So much fun my mind and lips are numb from the effort! :)

 

I like TASM for many reasons, one of the best is it makes ASCII object files that only take a few seconds to modify for inclusion in Action! code blocks. I be tired, thought at this stage someone may find it useful for studying ASM or for relocation or ???

 

I'm having trouble uploading the source file, the white space gets munged. Becomes

 

LO222: PLA

LDA

 

 

is there an easy fix for this?

Edited by ricortes
Link to comment
Share on other sites

 

Wow never thinked of that.. What a space saver, Not bad.

One caveat:

 

I think Gosub X*100 might cause problems if you compile the program. Also, you have to make sure you don't renumber the program or it will break the program. But it is an excellent space saver. I don't think other microsoft based BASIC's of the time even had this.

Link to comment
Share on other sites

Rainy day pastime. Binary save from DOS, DIS6502, mucho editing, then TASM. It assembles fine but I didn't bother putting it back together as DATA statements to insure accuracy with the original because I was going to rewrite it as an Action! procedure for the fun of it. So much fun my mind and lips are numb from the effort! :)

 

I like TASM for many reasons, one of the best is it makes ASCII object files that only take a few seconds to modify for inclusion in Action! code blocks. I be tired, thought at this stage someone may find it useful for studying ASM or for relocation or ???

 

I'm having trouble uploading the source file, the white space gets munged. Becomes

 

LO222: PLA

LDA

 

 

is there an easy fix for this?

I'm having trouble uploading the source file, the white space gets munged. Becomes

LO222: PLA
LDA


is there an easy fix for this? 
Edited by rdea6
Link to comment
Share on other sites

I think Gosub X*100 might cause problems if you compile the program. Also, you have to make sure you don't renumber the program or it will break the program.

 

Yes, that's why I called it eeeeevil.

 

I suppose a smart compiler might turn a computed gosub into a jump table. . . and would likely get it wrong. It's one of those things that won't translate well.

Link to comment
Share on other sites

 

SETVBV      = $E45C
XITVBV      = $E462
AUDF1       = $D200
AUDC1       = $D201
;
; Code equates
;
L00CB       = $00CB
L00CC       = $00CC
L0600       = $0600
L0604       = $0604
L0608       = $0608
L060C       = $060C
L0610       = $0610
L0614       = $0614
L0618       = $0618
;TO CALL FROM BASIC
;
;INIT with
;A=USR(1564)
;
;Use from BASIC with
;DUMMY = USR(SETSND,V,ADR(S$),LEN(S$),L)
;DUMMY = USR(QUIET, V1, V2)
;WHERE
;SETSND & QUIET will depend on where in
;memory you assemble it for
;V# => Defines a voice number (from 03)
;ADR(S$) Defines the address of the string 
;containing the definition of the sound 
;LEN(S$). Defines the length of the sound 
;string to be played
;L=> Defines the length of time to play each note.
;More details can be found in Compute
;issue 78 page 61
;
; Start of code
;
            *= $061C
;
            pla
            ldx #$03
            lda #$00
INIT:       sta L0618,X
            dex
            bpl INIT
            ldy #$31
            ldx #$06
            lda #$07
            jsr SETVBV
            rts
            cld
            ldx #$03
L0634:      lda L0618,X
            beq L06A0
            lda L0610,X
            dec L0610,X
            bne L06A0
            lda L0614,X
            sta L0610,X
            lda L060C,X
            bne L065E
            lda L0608,X
            bne L065E
            sta L0618,X
            txa
            asl A
            tay
            lda #$00
            sta AUDC1,Y
            beq L06A0
L065E:      lda L0600,X
            sta L00CB
            lda L0604,X
            sta L00CC
            ldy #$00
            lda (L00CB),Y
            pha
            txa
            asl A
            tay
            pla
            sta AUDC1,Y
            ldy #$01
            lda (L00CB),Y
            pha
            txa
            asl A
            tay
            pla
            sta AUDF1,Y
            lda L00CB
            clc
            adc #$02
            sta L0600,X
            lda L00CC
            adc #$00
            sta L0604,X
            lda L0608,X
            sec
            sbc #$02
            sta L0608,X
            lda L060C,X
            sbc #$00
            sta L060C,X
L06A0:      dex
            bpl L0634
            jmp XITVBV
SETSND:     pla
            pla
            pla
            tax
            lda #$00
            sta L0618,X
            pla
            sta L0604,X
            pla
            sta L0600,X
            pla
            sta L060C,X
            pla
            sta L0608,X
            pla
            pla
            sta L0614,X
            lda #$01
            sta L0610,X
            sta L0618,X
            rts
QUIET:      pla
            tax
L06CF:      pla
            pla
            tay
            lda #$00
            sta L0618,Y
            tya
            asl A
            tay
            lda #$00
            sta AUDC1,Y
            dex
            bne L06CF
            rts
            .end

 

Thanks for the help. I think I got the right version. Not sure how I want to do it in Action! Could leave it on page six and just change parameter passing...

Link to comment
Share on other sites

  • 2 months later...

i remember i published the Gamedesigner's Kit. it is a small ml routine that runs in vertical blank and handles music, sound effects, characterset switching and horizontal movement of 4 players, plus a second smaller routine for 20 dli's. both free placeable in ram, and just about 500 bytes in size.

that is quite useful for making games in turbobasic.

search for ke-soft gamedesigner's kit.

  • Like 1
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...