gtBASIC

Using, learning, programming and modding the Gigatron and anything related.
Forum rules
Be nice. No drama.
wbushby
Posts: 135
Joined: 16 Jul 2021, 10:59

Re: gtBASIC

Post by wbushby »

Level 1 done, 19 to go :)
Attachments
Screen.jpg
Screen.jpg (422.01 KiB) Viewed 149 times
at67
Posts: 553
Joined: 14 May 2018, 08:29

Re: gtBASIC

Post by at67 »

wbushby
Posts: 135
Joined: 16 Jul 2021, 10:59

Re: gtBASIC

Post by wbushby »

Level 2 drawn
Attachments
Screen.jpg
Screen.jpg (496.01 KiB) Viewed 110 times
wbushby
Posts: 135
Joined: 16 Jul 2021, 10:59

Re: gtBASIC

Post by wbushby »

I am trying to use Sprites. Is there some documentation on how to utilise ?
at67
Posts: 553
Joined: 14 May 2018, 08:29

Re: gtBASIC

Post by at67 »

If you're not scrolling the screen then sprites are pretty simple to use:

Loading:

Code: Select all

load sprite, <name>, <sprite index>
load pattern, <name>, <pattern index>
The difference between "sprite" and "pattern" is that sprite loads into sprite memory, (what is displayed), and pattern loads into pattern memory, (what is animated).

Sprites:

Code: Select all

sprite move, <sprite index>, x, y
sprite pattern, <sprite index>, <pattern index>
sprite show, <sprite index>, <disable=0/enable=!0>
There are sprite examples in the demos and graphics tutorial sections.

Also there are more advanced sprite commands for batching of sprite updates, reduction of flicker, when/if to wait for VBlank, GET of sprite internal data structures, etc, (you probably don't need these right now I would guess).

Code: Select all

const lutAddress = get("SPRITE_LUTS", 0)
const lutTmpAddress = get("SPRITE_LUTS", 1)
const indicesAddress = get("SPRITE_LUTS", 2)
const xposAddress = get("SPRITE_LUTS", 3)
const xposTmpAddress = get("SPRITE_LUTS", 4)
const yposAddress = get("SPRITE_LUTS", 5)
const yposTmpAddress = get("SPRITE_LUTS", 6)
wbushby
Posts: 135
Joined: 16 Jul 2021, 10:59

Re: gtBASIC

Post by wbushby »

My problem is even though I coded this as above it doesn't show on the screen

LOAD BLIT, Images/ColdRoom/Guardian8.tga, 38, NoFlip

LOAD SPRITE, Images/Willy1.tga, 0

Then later I show it by:

SPRITE MOVE, 0, 24, 24

The image is white shape on black background

Besides the obvious problem with no display of the sprite I also wanted to know the file types I could use instead of .tga and how to make the background (Black) invisible.
at67
Posts: 553
Joined: 14 May 2018, 08:29

Re: gtBASIC

Post by at67 »

I chose .TGA because it is has always been the simplest to implement and extend, if you need other formats then you'll either need to do the conversions to .TGA yourself or you could code up loaders for them and push them to the gtemuAT67 repo.

Black is the transparent colour, (this keeps things very simple and efficient on the firmware side), if you need a black in your sprites as well as transparency, then use the darkest blue.

SPRITES command:

Code: Select all

SPRITES INIT
SPRITES DRAW, <optional SORTY>
SPRITES RESTORE, <optional WAITVB>
I forgot to post display code, try something like this in your main loop.

Code: Select all

sprites init
repeat
    poke &hB8, 0
    sprites draw, SORTY

    gosub updateSprites

    sprites restore, WAITVB
forever
updateSprites is where you do your MOVE's, PATTERN's and SHOW's.

The poke &hB8, 0 is an experimental feature that may or may not exist in the final ROM, it's basically an XOR so that you can do very fast and cheap colour effects on sprites, (make them glow, fade to black or white, etc), XOR with 0 means no effect.

P.S. Your .TGA images need to be saved in either 24bit or 32bit uncompressed format, (the same as for blits), anything else should be rejected by the .TGA loader.
wbushby
Posts: 135
Joined: 16 Jul 2021, 10:59

Re: gtBASIC

Post by wbushby »

Is there any relationship between Image IDs and Sprite IDs. I seem to be having a conflict with Image ID 0 and Sprite ID 0
at67
Posts: 553
Joined: 14 May 2018, 08:29

Re: gtBASIC

Post by at67 »

Yes there is:

Code: Select all

load sprite, ../../res/image/Digits/zero.tga,  0
load sprite, ../../res/image/Digits/one.tga,   1
load sprite, ../../res/image/Digits/two.tga,   2
load sprite, ../../res/image/Digits/three.tga, 3
load sprite, ../../res/image/Digits/four.tga,  4
load sprite, ../../res/image/Digits/five.tga,  5
load sprite, ../../res/image/Digits/six.tga,   6
load sprite, ../../res/image/Digits/seven.tga, 7
The above code means that zero.tga is loaded into sprite 0's memory, one.tga is loaded into sprite 1's memory, etc.

Or do you mean a conflict between blit id's and sprite id's? There may be a bug there, I'll have to check, if there is a bug, then just make them unique for now, (i.e. don't share blit id's with sprite id's).
wbushby
Posts: 135
Joined: 16 Jul 2021, 10:59

Re: gtBASIC

Post by wbushby »

OK. I was concerned because I noticed a couple of days ago that if I skipped an Image ID then the image retrieved by ID was incorrect.
That is why I started them both at zero
Post Reply