gtBASIC
Forum rules
Be nice. No drama.
Be nice. No drama.
Re: gtBASIC
Also I am finding that if I include this line
Sprites Draw, SORTY
I get an error:
Assembler::assemble() : 'testsprite.gasm:810' : invalid label/equate '_vtX'
This is the code:
_runtimePath_ "../runtime"
_runtimeStart_ &hFFFF
_arraysStart_ &hFFFF
_codeRomType_ ROMvX0
'audio fix for ROMv5a
poke &h21, peek(&h21) OR 3
const NUM_SPRITES = 1
DEF PX,PY
MODE 2
SET BG_COLOUR, 0
SET FG_COLOUR,63
CLS
LOAD SPRITE, Images/A.tga, 0
const xAddr = get("SPRITE_LUTS", 3)
const yAddr = get("SPRITE_LUTS", 5)
SPRITES INIT
poke &hB8, 0
sprites draw, SORTY
SPRITE SHOW, 0, 1
SPRITE MOVE, 0, 24, 24
REPEAT
WAIT
&FOREVER
Sprites Draw, SORTY
I get an error:
Assembler::assemble() : 'testsprite.gasm:810' : invalid label/equate '_vtX'
This is the code:
_runtimePath_ "../runtime"
_runtimeStart_ &hFFFF
_arraysStart_ &hFFFF
_codeRomType_ ROMvX0
'audio fix for ROMv5a
poke &h21, peek(&h21) OR 3
const NUM_SPRITES = 1
DEF PX,PY
MODE 2
SET BG_COLOUR, 0
SET FG_COLOUR,63
CLS
LOAD SPRITE, Images/A.tga, 0
const xAddr = get("SPRITE_LUTS", 3)
const yAddr = get("SPRITE_LUTS", 5)
SPRITES INIT
poke &hB8, 0
sprites draw, SORTY
SPRITE SHOW, 0, 1
SPRITE MOVE, 0, 24, 24
REPEAT
WAIT
&FOREVER
Re: gtBASIC
Here's a code example that works, with some explanations that follow.
There's a few bugs, caveats and issues to contend with here:
1) _arraysStart_ &hFDFF : you need to use &hFDFF instead of &hFFFF, this is a bug where if you don't free the STRINGWORKAREA it causes array issues in general and for sprites, (this may be the explanation for some of your array weirdness earlier in the thread). Use _arraysStart_ &hFDFF for the 64k RAM model if you are not freeing the string work area, (which it seems you are not).
2) dim vtX%(119) = 0 : you need to declare this array with this name as a temporary buffer for the sprite engine, why? Because a lot of ROMvX0 and it's gtBASIC support code is unfinished.
3) You can only use the SORTY option if there is at least two sprites, (logically it doesn't make sense to sort one anyway), if you do use SORTY with just one sprite, the code will crash, why? See the reason in 2)
You will most certainly find other weird and nasty issues as you are developing your apps/games, why? See the reason in 2). It's unfortunate that this is the current state of ROMvX0 and gtBASIC, but I was forced to release them prematurely, it is what it is I guess.
Code: Select all
_runtimePath_ "../runtime"
_runtimeStart_ &hFFFF
_arraysStart_ &hFDFF
_codeRomType_ ROMvX0
MODE 2
SET BG_COLOUR, 0
SET FG_COLOUR,63
dim vtX%(119) = 0
load image, ../../res/image/juggler.tga
load sprite, ../../res/image/Digits/A.tga, 0
load sprite, ../../res/image/Digits/B.tga, 1
sprites init
x = 0
s = 1
repeat
poke &hB8, 0
sprites draw, SORTY
sprite move, 0, x, 46
sprite move, 1, 151-x, 66
sprites restore, WAITVB
x = x + s
if (x>150) OR (x<0)
s = -s
endif
forever
1) _arraysStart_ &hFDFF : you need to use &hFDFF instead of &hFFFF, this is a bug where if you don't free the STRINGWORKAREA it causes array issues in general and for sprites, (this may be the explanation for some of your array weirdness earlier in the thread). Use _arraysStart_ &hFDFF for the 64k RAM model if you are not freeing the string work area, (which it seems you are not).
2) dim vtX%(119) = 0 : you need to declare this array with this name as a temporary buffer for the sprite engine, why? Because a lot of ROMvX0 and it's gtBASIC support code is unfinished.
3) You can only use the SORTY option if there is at least two sprites, (logically it doesn't make sense to sort one anyway), if you do use SORTY with just one sprite, the code will crash, why? See the reason in 2)
You will most certainly find other weird and nasty issues as you are developing your apps/games, why? See the reason in 2). It's unfortunate that this is the current state of ROMvX0 and gtBASIC, but I was forced to release them prematurely, it is what it is I guess.
Re: gtBASIC
OK, no problem with that. Now that I understand I can work with it. It also explains an issue that just popped up yesterday with a string variable that was storing the Level name going blank.
Re: gtBASIC
Here's a new code sample, the only difference is that the vtX array is now allocated at a fixed address, the reason _arraysStart_ had to be set to &hFDFF, is that vtX could cross a page boundary and for efficiency reasons the SPRITE routines expect buffers to be wholly contained within a page; here's the new code that now works with any value for _arraysStart_ .
You can see the only difference is that vtX is now firmly planted at 0x0600.
Code: Select all
_runtimePath_ "../runtime"
_runtimeStart_ &hFFFF
_arraysStart_ &hFFFF
_codeRomType_ ROMvX0
MODE 2
SET BG_COLOUR, 0
SET FG_COLOUR,63
const vtX = &h0600
def byte(vtX, 0, 1, 120) = 0
load image, ../../res/image/juggler.tga
load sprite, ../../res/image/Digits/A.tga, 0
load sprite, ../../res/image/Digits/D.tga, 1
sprites init
x = 0
s = 1
repeat
poke &hB8, 0
sprites draw, SORTY
sprite move, 0, x, 46
sprite move, 1, 151-x, 66
sprites restore, WAITVB
x = x + s
if (x>150) OR (x<0)
s = -s
endif
forever
Re: gtBASIC
So with my experimentation I find the following issues with images and sprites
If I don't Load BLIT... from ID 0 and keep the numbering continuous there are issues with displaying the incorrect graphic
If I don't ID sprites from 0 and up they don't display on screen
If I have Load BLIT with ID 0,1,2 and Load SPRITE with ID 0,1,2 they get mixed up and cause a crash when I try and draw the screen
This is my code loading images into my game
PROC LoadImages
LOAD SPRITE, Images/Willy1.tga, 0
LOAD SPRITE, Images/Willy2.tga, 1
' LOAD SPRITE, Images/Willy3.tga, 2
' LOAD SPRITE, Images/Willy4.tga, 3
' LOAD SPRITE, Images/Willy5.tga, 4
' LOAD SPRITE, Images/Willy6.tga, 5
LOAD BLIT, Images/Life.tga, 0, NoFlip
LOAD BLIT, Images/CentralCavern/Floor.tga, 1, NoFlip
LOAD BLIT, Images/CentralCavern/CrumblingFloor.tga, 2, NoFlip
LOAD BLIT, Images/CentralCavern/Wall.tga, 3, NoFlip
LOAD BLIT, Images/CentralCavern/Conveyor.tga, 4, NoFlip
LOAD BLIT, Images/CentralCavern/Nasty1.tga, 5, NoFlip
LOAD BLIT, Images/CentralCavern/Nasty2.tga, 6, NoFlip
LOAD BLIT, Images/CentralCavern/Portal.tga, 7, NoFlip
LOAD BLIT, Images/CentralCavern/ItemOrange.tga, 8, NoFlip
LOAD BLIT, Images/CentralCavern/ItemYellow.tga, 9, NoFlip
LOAD BLIT, Images/CentralCavern/ItemPurple.tga, 10, NoFlip
LOAD BLIT, Images/CentralCavern/ItemGreen.tga, 11, NoFlip
LOAD BLIT, Images/CentralCavern/Guardian1.tga, 12, NoFlip
LOAD BLIT, Images/CentralCavern/Guardian2.tga, 13, NoFlip
LOAD BLIT, Images/CentralCavern/Guardian3.tga, 14, NoFlip
LOAD BLIT, Images/CentralCavern/Guardian4.tga, 15, NoFlip
LOAD BLIT, Images/CentralCavern/Guardian5.tga, 16, NoFlip
LOAD BLIT, Images/CentralCavern/Guardian6.tga, 17, NoFlip
LOAD BLIT, Images/CentralCavern/Guardian7.tga, 18, NoFlip
LOAD BLIT, Images/CentralCavern/Guardian8.tga, 19, NoFlip
LOAD BLIT, Images/Plynth.tga, 20, NoFlip
LOAD BLIT, Images/ColdRoom/Floor.tga, 21, NoFlip
LOAD BLIT, Images/ColdRoom/CrumblingFloor.tga, 22, NoFlip
LOAD BLIT, Images/ColdRoom/Wall.tga, 23, NoFlip
LOAD BLIT, Images/ColdRoom/Conveyor.tga, 24, NoFlip
LOAD BLIT, Images/ColdRoom/Nasty2.tga, 25, NoFlip
LOAD BLIT, Images/ColdRoom/Portal.tga, 26, NoFlip
LOAD BLIT, Images/ColdRoom/ItemBlue.tga, 27, NoFlip
LOAD BLIT, Images/ColdRoom/ItemYellow.tga, 28, NoFlip
LOAD BLIT, Images/ColdRoom/ItemPurple.tga, 29, NoFlip
LOAD BLIT, Images/ColdRoom/ItemGreen.tga, 30, NoFlip
' LOAD BLIT, Images/ColdRoom/Guardian1.tga, 31, NoFlip
' LOAD BLIT, Images/ColdRoom/Guardian2.tga, 32, NoFlip
' LOAD BLIT, Images/ColdRoom/Guardian3.tga, 33, NoFlip
' LOAD BLIT, Images/ColdRoom/Guardian4.tga, 34, NoFlip
' LOAD BLIT, Images/ColdRoom/Guardian5.tga, 35, NoFlip
' LOAD BLIT, Images/ColdRoom/Guardian6.tga, 36, NoFlip
' LOAD BLIT, Images/ColdRoom/Guardian7.tga, 37, NoFlip
' LOAD BLIT, Images/ColdRoom/Guardian8.tga, 38, NoFlip
ENDPROC
If I don't Load BLIT... from ID 0 and keep the numbering continuous there are issues with displaying the incorrect graphic
If I don't ID sprites from 0 and up they don't display on screen
If I have Load BLIT with ID 0,1,2 and Load SPRITE with ID 0,1,2 they get mixed up and cause a crash when I try and draw the screen
This is my code loading images into my game
PROC LoadImages
LOAD SPRITE, Images/Willy1.tga, 0
LOAD SPRITE, Images/Willy2.tga, 1
' LOAD SPRITE, Images/Willy3.tga, 2
' LOAD SPRITE, Images/Willy4.tga, 3
' LOAD SPRITE, Images/Willy5.tga, 4
' LOAD SPRITE, Images/Willy6.tga, 5
LOAD BLIT, Images/Life.tga, 0, NoFlip
LOAD BLIT, Images/CentralCavern/Floor.tga, 1, NoFlip
LOAD BLIT, Images/CentralCavern/CrumblingFloor.tga, 2, NoFlip
LOAD BLIT, Images/CentralCavern/Wall.tga, 3, NoFlip
LOAD BLIT, Images/CentralCavern/Conveyor.tga, 4, NoFlip
LOAD BLIT, Images/CentralCavern/Nasty1.tga, 5, NoFlip
LOAD BLIT, Images/CentralCavern/Nasty2.tga, 6, NoFlip
LOAD BLIT, Images/CentralCavern/Portal.tga, 7, NoFlip
LOAD BLIT, Images/CentralCavern/ItemOrange.tga, 8, NoFlip
LOAD BLIT, Images/CentralCavern/ItemYellow.tga, 9, NoFlip
LOAD BLIT, Images/CentralCavern/ItemPurple.tga, 10, NoFlip
LOAD BLIT, Images/CentralCavern/ItemGreen.tga, 11, NoFlip
LOAD BLIT, Images/CentralCavern/Guardian1.tga, 12, NoFlip
LOAD BLIT, Images/CentralCavern/Guardian2.tga, 13, NoFlip
LOAD BLIT, Images/CentralCavern/Guardian3.tga, 14, NoFlip
LOAD BLIT, Images/CentralCavern/Guardian4.tga, 15, NoFlip
LOAD BLIT, Images/CentralCavern/Guardian5.tga, 16, NoFlip
LOAD BLIT, Images/CentralCavern/Guardian6.tga, 17, NoFlip
LOAD BLIT, Images/CentralCavern/Guardian7.tga, 18, NoFlip
LOAD BLIT, Images/CentralCavern/Guardian8.tga, 19, NoFlip
LOAD BLIT, Images/Plynth.tga, 20, NoFlip
LOAD BLIT, Images/ColdRoom/Floor.tga, 21, NoFlip
LOAD BLIT, Images/ColdRoom/CrumblingFloor.tga, 22, NoFlip
LOAD BLIT, Images/ColdRoom/Wall.tga, 23, NoFlip
LOAD BLIT, Images/ColdRoom/Conveyor.tga, 24, NoFlip
LOAD BLIT, Images/ColdRoom/Nasty2.tga, 25, NoFlip
LOAD BLIT, Images/ColdRoom/Portal.tga, 26, NoFlip
LOAD BLIT, Images/ColdRoom/ItemBlue.tga, 27, NoFlip
LOAD BLIT, Images/ColdRoom/ItemYellow.tga, 28, NoFlip
LOAD BLIT, Images/ColdRoom/ItemPurple.tga, 29, NoFlip
LOAD BLIT, Images/ColdRoom/ItemGreen.tga, 30, NoFlip
' LOAD BLIT, Images/ColdRoom/Guardian1.tga, 31, NoFlip
' LOAD BLIT, Images/ColdRoom/Guardian2.tga, 32, NoFlip
' LOAD BLIT, Images/ColdRoom/Guardian3.tga, 33, NoFlip
' LOAD BLIT, Images/ColdRoom/Guardian4.tga, 34, NoFlip
' LOAD BLIT, Images/ColdRoom/Guardian5.tga, 35, NoFlip
' LOAD BLIT, Images/ColdRoom/Guardian6.tga, 36, NoFlip
' LOAD BLIT, Images/ColdRoom/Guardian7.tga, 37, NoFlip
' LOAD BLIT, Images/ColdRoom/Guardian8.tga, 38, NoFlip
ENDPROC
Re: gtBASIC
*Edit* I'm looking at the code and can't actually find an issue, as long as the sprite and blit id's start at 0 and increase monotonically/consecutively, then it all seems to work, here's some example code that works.
I'll keep looking.
Code: Select all
_runtimePath_ "../runtime"
_runtimeStart_ &hFFFF
_arraysStart_ &hFFFF
_codeRomType_ ROMvX0
MODE 2
SET BG_COLOUR, 0
SET FG_COLOUR,63
const vtX = &h0600
def byte(vtX, 0, 1, 120) = 0
load image, ../../res/image/juggler.tga
load blit, ../../res/image/Turrican.tga, 0
load blit, ../../res/image/at67.tga, 1
load blit, ../../res/image/Invader/Barrier.tga, 2
load blit, ../../res/image/Invader/Saucer.tga, 3
load blit, ../../res/image/Invader/Player.tga, 4
load blit, ../../res/image/Invader/Six.tga, 5
load blit, ../../res/image/Invader/Three.tga, 6
load sprite, ../../res/image/Digits/A.tga, 0
load sprite, ../../res/image/Digits/D.tga, 1
load sprite, ../../res/image/Digits/zero.tga, 2
load sprite, ../../res/image/Digits/one.tga, 3
blit noFlip, 1, 0, 0
blit noFlip, 2, 10, 50
blit noFlip, 3, 30, 10
blit noFlip, 4, 40, 70
blit noFlip, 5, 60, 100
blit noFlip, 6, 80, 30
sprites init
x = 0
s = 1
repeat
poke &hB8, 0
sprites draw', SORTY
blit noFlip, 0, 60, 50
sprite move, 0, x, 26
sprite move, 1, x, 46
sprite move, 2, 151-x, 66
sprite move, 3, 151-x, 86
x = x + s
if (x>150) OR (x<0)
s = -s
endif
sprites restore, WAITVB
forever
Re: gtBASIC
Then the issue must be something else manifesting itself in the images. I am going to try removing significant parts of the program such as the music and see if it starts working.
Re: gtBASIC
OK, it seems the problem was the sprites draw, SORTY statement. When I removed the SORTY it started working
I have an issue with the positioning of the sprite. If I use:
POKE &hB8,0
SPRITES DRAW
SPRITE MOVE, 1, PX, PY (PX=16, PY=88)
SPRITES RESTORE, WAITVB
Then Sprite 0 displays in position 0,0
If I use:
POKE &hB8,0
SPRITES DRAW
SPRITE MOVE, 1, PX, PY
SPRITES RESTORE, WAITVB
SPRITES DRAW
SPRITE MOVE, 1, PX, PY
Then Sprite 0 displays in position 0,0 AND Sprite 1 displays in position PX,PY
What do these 2 statements do ?
POKE &hB8,0
SPRITES RESTORE, WAITVB
I have an issue with the positioning of the sprite. If I use:
POKE &hB8,0
SPRITES DRAW
SPRITE MOVE, 1, PX, PY (PX=16, PY=88)
SPRITES RESTORE, WAITVB
Then Sprite 0 displays in position 0,0
If I use:
POKE &hB8,0
SPRITES DRAW
SPRITE MOVE, 1, PX, PY
SPRITES RESTORE, WAITVB
SPRITES DRAW
SPRITE MOVE, 1, PX, PY
Then Sprite 0 displays in position 0,0 AND Sprite 1 displays in position PX,PY
What do these 2 statements do ?
POKE &hB8,0
SPRITES RESTORE, WAITVB
Re: gtBASIC
This doesn't make a lot of sense, but lets put it aside for now.
The first makes sure that the SPRITES DRAW command does an XOR with 0, without it all your sprite colours will be messed up.
The second restores the backgrounds that were saved as part of the SPRITES DRAW command.
What this means is that you should only have one of each of these three per render loop/frame.
Code: Select all
repeat
' colour effects for SPRITES DRAW, 0 means no effect
POKE &hB8,0
' draws ALL sprites
SPRITES DRAW
' do updates/moves/animation/etc here
gosub doUpdates
' restores backgrounds for ALL sprites
SPRITES RESTORE, WAITVB
forever
If you want to only draw some of the sprites, then you use SPRITE SHOW, <id>, <0/1>, SPRITES DRAW and SPRITES RESTORE are smart enough to skip any sprites that are hidden/disabled.
Re: gtBASIC
I am not sure what happened. I had the sprites looking OK in a basic one step display. Then I moved the display code to my game loop, all tidied up and this is the result.
I am hoping this looks familiar to you and you can point me in the right direction.
The sprite (white) on the upper left starts to draw then goes random after a few lines. It's placement is also incorrect.
I am hoping this looks familiar to you and you can point me in the right direction.
The sprite (white) on the upper left starts to draw then goes random after a few lines. It's placement is also incorrect.
- Attachments
-
- spriteissue.jpg (452 KiB) Viewed 319 times