Page 30 of 44
Re: gtBASIC
Posted: 31 Jan 2023, 08:48
by wbushby
OK, so what is the limit a sprite can go to the screen edge. Must it stay 100% on screen all around ?
Re: gtBASIC
Posted: 31 Jan 2023, 10:00
by at67
Hopefully this explains it:
- Video_RAM_and_Sprites.jpg (170.05 KiB) Viewed 794 times
Re: gtBASIC
Posted: 31 Jan 2023, 11:30
by wbushby
OK, then I am fine as I am putting my sprites at 160,0 and they are 9 pixels wide and 16 pixels high and that space is free
Re: gtBASIC
Posted: 31 Jan 2023, 11:36
by at67
Out of curiosity what does your FREE command look like?
It should probably look something like this:
Also the more of the off-screen area you FREE, the less sprites you can have. Sprites use the offscreen area for data and a restore buffer.
P.S. I've fixed the SPRITE SHOW bug, it was toggling. The new commands are:
I have a few more things to fix, which I can hopefully do before bedtime, if I do get them done, I'll release the ROM and gtBASIC shortly, if not sometime tomorrow after work.
Re: gtBASIC
Posted: 31 Jan 2023, 16:02
by wbushby
OK, that's great on the SHOW and HIDE command. Solves my problem with the off screen sprites
Re: gtBASIC
Posted: 31 Jan 2023, 17:04
by wbushby
I have another weird issue with sprites. My background is black in all my 6 sprites used for walking both left and right. When I am using the right facing sprites the black background is transparent as expected. But when I walk left the 3 left sprites black background shows as dark blue on the application.
I have redrawn the left facing sprites several times but same result
Re: gtBASIC
Posted: 31 Jan 2023, 20:18
by at67
How are you saving the .tga images? In 24bit mode or in 32bit mode?
Here's a portion of the SPRITE image loader code in "load.cpp", (pixels have been pre-converted to either BGR2 or ABGR2).
Code: Select all
// Build sprite data from image data
std::vector<uint8_t> spriteData;
for(int i=0; i<int(gtRgbFile._data.size()); i++)
{
uint8_t pixel = 0;
switch(tgaFile._header._bitsPerPixel)
{
case 24:
{
pixel = gtRgbFile._data[i] & 0x3F;
}
break;
case 32:
{
pixel = gtRgbFile._data[i];
pixel = ((pixel & 0x80) && (pixel & 0x3F) == 0x00) ? 0x90 : pixel; // black to darkest blue
pixel = ((pixel & 0x80) == 0x00) ? 0x00 : pixel & 0x3F; // alpha < 0.5 = black
}
break;
default: break;
}
spriteData.push_back(pixel);
}
1) 24 bit per pixel images get converted to 6bit per pixel images, (2bits per channel XBGR), with black representing transparency.
2) 32 bit per pixel images get converted to 8bit per pixel images, (2bits per channel ABGR), with <0.5 alpha representing transparency.
This means that if you save in 32bit format, you must have a valid alpha channel, if you save all your .tga's in 24bit uncompressed format, everything should just work.
I can't think of anything else that would cause this issue.
Re: gtBASIC
Posted: 01 Feb 2023, 00:37
by wbushby
I am saving them as 32 bit. I will convert them to 24 bit....
Thank you again. That fixed the issue.
Re: gtBASIC
Posted: 02 Feb 2023, 12:38
by wbushby
I have a weird issue today.
DIM GameStatus(6) = 0,0,0,0,0,0,0
GameStatus(0) = 252
GameStatus(1) = 1008
GameStatus(1) = GameStatus(1) - 1
GameStatus(0) = GameStatus(1) / 4
Result is GameStatus(1) - 1007 but GameStatus(0) = 16315
As GameStatus(1) decreases GameStatus(0) is always 16315
Changed the code to:
GameStatus(1) = GameStatus(1) - 1
Timer = GameStatus(1)
Pixels = Timer / 4
And this works correctly
Re: gtBASIC
Posted: 02 Feb 2023, 16:47
by at67
Nice! You found a couple of separate Optimiser bugs that were introduced in the last couple of updates, I'm fixing them now.
Next time something weird like this happens use the OPTIMISE keyword like this:
Code: Select all
DIM GameStatus(6) = 0,0,0,0,0,0,0
OPTIMISE OFF
GameStatus(0) = 252
GameStatus(1) = 1008
GameStatus(1) = GameStatus(1) - 1
GameStatus(0) = GameStatus(1) / 4
OPTIMISE ON
print GameStatus(0);" ";GameStatus(1)
But please don't forget to report the bug, turning the optimiser off usually results in horribly inefficient code.