Arecibo in gtbasic

Using, learning, programming and modding the Gigatron and anything related.
Forum rules
Be nice. No drama.
Post Reply
petersieg
Posts: 111
Joined: 28 Jun 2023, 09:06

Arecibo in gtbasic

Post by petersieg »

My first gtbasic program and for sure a really humble version!
So please be polite with me.

But it compiles and runs..

But I have so many question..

I tried to find a gtbasic documentation.
I only could locate: https://forum.gigatron.io/viewtopic.php?t=232

Question:
Dim array is integer. Is there a dim byte function? def byte(address) needs an address?
Or can one do:
address:
def byte = 1,2,3
---
There is a line drawing function, that I used. But is there a pixel drawing function?
---
Are there left/right shift function?

So, if you spot idiotic syntax, anything that has to be done better - please let me know ;-)

thx, Peter
Attachments
arecibo.gbas.zip
(1.12 KiB) Downloaded 13 times
arecibo_gtbasic.png
arecibo_gtbasic.png (58.89 KiB) Viewed 430 times
petersieg
Posts: 111
Joined: 28 Jun 2023, 09:06

Re: Arecibo in gtbasic

Post by petersieg »

Ah. pset ist pixel set:

Code: Select all

        for j=0 &to 7 
        	d = digit AND 128
        	xpos=xx+x+j
         	if d &<> 0 
         		'set FG_COLOUR, c+1
         		'line xpos,y,xpos,y
         		'vline xpos,y,y
         		pset xpos,y,c+1
         	else 
         		'set FG_COLOUR, c
         		'line xpos,y,xpos,y
         		'vline xpos,y,y
         		pset xpos,y,c
         	endif       	
        	digit = digit * 2
        next j
at67
Site Admin
Posts: 647
Joined: 14 May 2018, 08:29

Re: Arecibo in gtbasic

Post by at67 »

petersieg wrote: 17 Feb 2024, 18:06 I tried to find a gtbasic documentation.
There are around 100 tutorials/tests/examples under the gbas folder, they document every gtBASIC function and statement.
petersieg wrote: 17 Feb 2024, 18:06 Question:
Dim array is integer. Is there a dim byte function? def byte(address) needs an address?
Or can one do:
address:
def byte = 1,2,3
Use % in your variable name and it will be a byte array instead of a word array, *NOTE* you only use the % during declaration, i.e. only during the DIM statement.

The DEF command is quite complicated and extremely powerful, it lets you create powerful LUT's using high level C math functions and loops, there are many examples in the gbas folder.
petersieg wrote: 17 Feb 2024, 18:06 There is a line drawing function, that I used. But is there a pixel drawing function?
PSET
petersieg wrote: 17 Feb 2024, 18:06 Are there left/right shift function?
LSL, LSR and ASR

I've slightly modified the code to this:

Code: Select all

_runtimePath_ "../gbas/runtime"
_codeRomType_ ROMvX0


dim msg%(237) =  2,168,0,40,40,8,136,137,100,170,170,72,0,0,0,0,12,0,0,52,0,0,52,0,0,84,0,0,124,0,0,0,0,195,140,48,128,3,32,209,140,52,251,239,190,0,0,0,16,0,4,0,0,0,8,0,2,248,0,62,0,0,0,195,14,48,128,128,32,208,199,52,251,239,190,0,0,0,16,48,4,0,48,0,8,48,2,248,48,62,0,48,0,32,16,8,16,48,16,12,48,32,3,16,192,0,51,0,3,16,192,12,48,32,16,32,16,32,48,8,64,48,8,64,16,16,32,32,32,16,0,192,12,3,0,35,172,0,32,32,0,32,248,0,33,116,182,2,114,126,184,112,110,0,80,118,32,80,126,32,80,96,32,216,0,0,0,0,56,32,0,58,138,170,56,2,168,0,2,128,0,248,0,3,254,0,14,3,128,24,0,192,52,1,96,102,3,48,69,5,16,68,137,16,4,81,0,4,33,0,4,1,0,1,40,0,121,244,240,0,0,0

cls

    
loop:    
    x = 0 : y = x : xx = y

    repeat
        c = rnd(0) AND 63 : cc = NOT c

        for i=0 &to 236
            digit = msg(i)

            for j=0 &to 7 
                xxx = xx+x+j
                if (digit AND 128)
                    pset xxx, y, cc
                else 
                    pset xxx, y, c
                endif       	
                digit = digit LSL 1
            next j

            x = x + 8
            if x.lo &&> 23
                x = 0
                y = y + 1
            endif
        next i

        y = 0
        xx = xx + 25
    until xx.lo &&>= 150

goto &loop
ROMv4: compiles to a 597 byte gt1 file.
ROMv5a: compiles to a 582 byte gt1 file.
ROMvX1: compiles to a 488 byte gt1 file and is about 2.5x times faster.
petersieg
Posts: 111
Joined: 28 Jun 2023, 09:06

Re: Arecibo in gtbasic

Post by petersieg »

Many thanks! Good to learn from.
Yes, the examples programs are a good way to see different aspects/usage of gtbasic.

best, Peter
Post Reply