gtBASIC

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

Re: gtBASIC

Post by wbushby »

OK, so what is the limit a sprite can go to the screen edge. Must it stay 100% on screen all around ?
at67
Site Admin
Posts: 647
Joined: 14 May 2018, 08:29

Re: gtBASIC

Post by at67 »

Hopefully this explains it:
Video_RAM_and_Sprites.jpg
Video_RAM_and_Sprites.jpg (170.05 KiB) Viewed 369 times
wbushby
Posts: 208
Joined: 16 Jul 2021, 10:59

Re: gtBASIC

Post 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
at67
Site Admin
Posts: 647
Joined: 14 May 2018, 08:29

Re: gtBASIC

Post by at67 »

Out of curiosity what does your FREE command look like?

It should probably look something like this:

Code: Select all

free &h08A0, 9, 16, 0x0100
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:

Code: Select all

SPRITE SHOW, id
SPRITE HIDE, id
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.
wbushby
Posts: 208
Joined: 16 Jul 2021, 10:59

Re: gtBASIC

Post by wbushby »

OK, that's great on the SHOW and HIDE command. Solves my problem with the off screen sprites
wbushby
Posts: 208
Joined: 16 Jul 2021, 10:59

Re: gtBASIC

Post 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
Attachments
Screen3.jpg
Screen3.jpg (394.66 KiB) Viewed 344 times
Screen2.jpg
Screen2.jpg (530.66 KiB) Viewed 344 times
Screen4.jpg
Screen4.jpg (359.13 KiB) Viewed 344 times
at67
Site Admin
Posts: 647
Joined: 14 May 2018, 08:29

Re: gtBASIC

Post 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.
wbushby
Posts: 208
Joined: 16 Jul 2021, 10:59

Re: gtBASIC

Post by wbushby »

I am saving them as 32 bit. I will convert them to 24 bit....

Thank you again. That fixed the issue. :D
wbushby
Posts: 208
Joined: 16 Jul 2021, 10:59

Re: gtBASIC

Post 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
at67
Site Admin
Posts: 647
Joined: 14 May 2018, 08:29

Re: gtBASIC

Post 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.
Post Reply