gtBASIC
Forum rules
Be nice. No drama.
Be nice. No drama.
Re: gtBASIC
I am trying to use Sprites. Is there some documentation on how to utilise ?
Re: gtBASIC
If you're not scrolling the screen then sprites are pretty simple to use:
Loading:
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:
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).
Loading:
Code: Select all
load sprite, <name>, <sprite index>
load pattern, <name>, <pattern index>
Sprites:
Code: Select all
sprite move, <sprite index>, x, y
sprite pattern, <sprite index>, <pattern index>
sprite show, <sprite index>, <disable=0/enable=!0>
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)
Re: gtBASIC
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.
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.
Re: gtBASIC
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:
I forgot to post display code, try something like this in your main loop.
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.
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>
Code: Select all
sprites init
repeat
poke &hB8, 0
sprites draw, SORTY
gosub updateSprites
sprites restore, WAITVB
forever
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.
Re: gtBASIC
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
Re: gtBASIC
Yes there is:
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).
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
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).
Re: gtBASIC
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
That is why I started them both at zero