gtBASIC

Using, learning, programming and modding the Gigatron and anything related.
Forum rules
Be nice. No drama.
at67
Site Admin
Posts: 647
Joined: 14 May 2018, 08:29

Re: gtBASIC

Post by at67 »

Lots of useful information here: https://github.com/at67/gigatron-rom/tr ... ols/gtmidi

Some of the documentation is a little outdated, for example gtMIDI does support the -v volume/velocity option now.

It's basically a Gigatron specific version of the miditones format, there is an extra command 0xD0 that stitches segmented midi chunks together and a one byte repeatable field for delays rather that two bytes, (this saves a lot of RAM as most delays are one byte when using a delay resolution of 16.66667ms).

P.S. ROMvX0 has one vCPU instruction to setup and then play gtMIDI's for you already if you are thinking of writing your own player, (you won't be able to beat it for efficiency in terms of RAM usage or CPU cycles), but if you want to add for example a white noise/drum channel, (which is trivial to do), there are players in "audio.i", "audio_ROMv5a.i" and "audio_ROMvX0.i" in the gbas runtime folder that you can use as a guide.

P.P.S. If you type gtMIDI at the console, it gives example command lines. There are five source code outputs, (GCL, vCPU, GBAS, CPP, Py), that you can embed into your source code and one binary output, (gtMID). gtMIDI is the format I normally use as it doesn't blow out the gbas source code with irrelevant static data declarations.
wbushby
Posts: 208
Joined: 16 Jul 2021, 10:59

Re: gtBASIC

Post by wbushby »

I am having issues with the data in arrays within my program with the latest version of GTBasic.
Is there a boundary requirement for arrays.

This is the definition. The first array reads ok in the program but the second array has random (appearing) values when I print them out during execution

' The first 280 bytes are the attributes that define the layout of the cavern.

DIM CentralCavernData(279)={3,0,0,0,0,6,0,0,6,0,0,0,0,0,0,0,0,0,0,3,
3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,
3,0,0,0,0,0,0,0,0,0,0,5,0,0,0,5,0,0,0,3,
3,1,1,1,1,2,2,2,2,1,2,2,2,2,1,1,1,1,2,3,
3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,
3,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,
3,0,0,0,0,0,0,0,0,0,3,3,3,0,5,0,0,0,0,3,
3,1,1,1,0,0,4,4,4,4,4,4,4,4,4,4,4,0,0,3,
3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,3,
3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,
3,0,0,0,0,0,0,5,0,0,3,3,3,2,2,2,1,1,1,3,
3,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,3,
3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,
3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3}

CentralCavernName$ = "Central Cavern"

' This specifies the location and ID of the items in the cavern.

DIM CentralCavernItem(4,2)

CentralCavernItem(0,0) = 8 ' Item 1 ID ' Orange
CentralCavernItem(0,1) = 0 ' Item 1 Location X
CentralCavernItem(0,2) = 9 ' Item 1 Location Y
CentralCavernItem(1,0) = 9 ' Item 2 ID ' Yellow
CentralCavernItem(1,1) = 0 ' Item 2 Location X
CentralCavernItem(1,2) = 17 ' Item 2 Location Y
CentralCavernItem(2,0) = 10 ' Item 3 ID ' Purple
CentralCavernItem(2,1) = 1 ' Item 3 Location X
CentralCavernItem(2,2) = 13 ' Item 3 Location Y
CentralCavernItem(3,0) = 11 ' Item 4 ID ' Green
CentralCavernItem(3,1) = 4 ' Item 4 Location X
CentralCavernItem(3,2) = 14 ' Item 4 Location Y
CentralCavernItem(4,0) = 8 ' Item 5 ID ' Orange
CentralCavernItem(4,1) = 6 ' Item 5 Location X
CentralCavernItem(4,2) = 18 ' Item 5 Location Y

I have attached a printout of the data in the second array on execution
Attachments
Screen.jpg
Screen.jpg (425.01 KiB) Viewed 300 times
wbushby
Posts: 208
Joined: 16 Jul 2021, 10:59

Re: gtBASIC

Post by wbushby »

Further information. If I move the statement 'DIM CentralCavernItem(4,2)' to somewhere else in the program the values in the array change.

I find this very strange as they are specifically input.
wbushby
Posts: 208
Joined: 16 Jul 2021, 10:59

Re: gtBASIC

Post by wbushby »

Redefining it this way corrected the problem

DIM CentralCavernItem(4,2) = {8,0,5,
9,0,17,
10,1,8,
11,2,12,
8,4,17}
wbushby
Posts: 208
Joined: 16 Jul 2021, 10:59

Re: gtBASIC

Post by wbushby »

I am finding that the array data changes mysteriously as I define more of the application.

I have plenty of free RAM
Free RAM on 64K Gigatron : 30374 bytes
at67
Site Admin
Posts: 647
Joined: 14 May 2018, 08:29

Re: gtBASIC

Post by at67 »

It looks like you have found a bug, but I can't recreate it:

- If I compile without "_arraysStart_ &hFFFF" then the compiler gives me "not enough contiguous memory for CentralCavernData"

- If I compile with "_arraysStart_ &hFFFF" then everything works fine, no matter where the arrays are defined.

Is there anyway you can recreate the issue with a small example?
wbushby
Posts: 208
Joined: 16 Jul 2021, 10:59

Re: gtBASIC

Post by wbushby »

I can send you the project if that helps ?
wbushby
Posts: 208
Joined: 16 Jul 2021, 10:59

Re: gtBASIC

Post by wbushby »

I made a stripped down version with just the screen drawing section and it is working.

I am going to gradually add the sound and scrolling routines back until it stops working and identify where it fails
wbushby
Posts: 208
Joined: 16 Jul 2021, 10:59

Re: gtBASIC

Post by wbushby »

Well, I gradually put it back together albeit reorganising the code order somewhat to make it a bit better and now it is all working.

I did not actually change anything except the array orders, particularly moving the music definition to after the screen definitions. That possibly made the difference.

If it happens again, I will immediately stop coding and reverse what I did to identify what happened.
at67
Site Admin
Posts: 647
Joined: 14 May 2018, 08:29

Re: gtBASIC

Post by at67 »

Sounds good, one more thing, if your array data only contains values between 0 <-> 255, then you can use the % sign to change the declarations to:

Code: Select all

DIM CentralCavernData%(279)={ ... }
DIM CentralCavernItem%(4,2)={ ... }
This will make the arrays use bytes instead of words, saving you a lot of memory and potentially making them easier to fit in amongst all the the other memory allocations.

You don't need to use the % sign anywhere else, only in the declaration.
Post Reply