Sprites on QL

Anything QL Software or Programming Related.
User avatar
bwinkel67
QL Wafer Drive
Posts: 1202
Joined: Thu Oct 03, 2019 2:09 am

Re: Sprites on QL

Post by bwinkel67 »

Andrew wrote: Sun Dec 10, 2023 2:16 pm I simply used Photoshop to create the sprite sheet, saved is as a RAW file that uses QL mode 8 pallette, then converted it in QL screen format.
There is a sprite sheet for the owl's blink and one for Santa. The gift box is just an image (only one frame).
Keep in mind that my sprites are NOT the same sprites as used by PE environment.
Hi Andrew,

For Owl, there is a single panel of 6x20 and 8 frames so 120x8=960. The Owl_spr is 480 bytes in size.

For Santa there are three consecutive panels 24x25, 24x25, and 20x25 (which is 68x25 pixels for 1,700 in total). There are 8 frames, so that would be 13,600 pixels in all. The Santa_spr file is 13,600 bytes in size.

I though in mode 8 a pixel took 4 bits (half a byte), so the Owl makes sense at 480 bytes for 960 pixels.Why is Santa_spr twice the size of what the 13,600 half bytes would yield (i.e. 6,800). Just a bit confused by that.


User avatar
bwinkel67
QL Wafer Drive
Posts: 1202
Joined: Thu Oct 03, 2019 2:09 am

Re: Sprites on QL

Post by bwinkel67 »

I was able to convert it to half its size and it still works.

santa2_spr.zip
(1.72 KiB) Downloaded 29 times

I wrote a little BASIC program to do so:

Code: Select all

10 REMark loads original sprite
15 PRINT #0, "Loading original Santa into memory.": a = RESPR(13600): LBYTES win1_santa_spr, a
20 REMark now generate new sprite using half of original memory and save to file
25 MODE 8: PRINT #0, "Converting Santa Sprite and saving." : c=RESPR(6800): b=0: FOR i=0 TO 199: FOR j=0 TO 33: POKE (c+i*34+j),PEEK(a+i*68+j): POKE (131072+b+j),PEEK(c+i*34+j): NEXT j:b=b+128: NEXT i: SBYTES win1_santa2_spr,c,6800
30 REMark test to see if new sprite works from file
35 MODE 8: PRINT #0, "Loading new Santa...": d=RESPR(6800): LBYTES win1_santa2_spr,d: b=0: FOR i=0 TO 199: FOR j=0 TO 33: POKE (131072+b+j),PEEK(d+i*34+j): NEXT j:b=b+128: NEXT i
Here's what it displays out...i took a screen shot in Windows, cut out the sprite part and saved it as a low-compression jpeg:

santa_sprite.jpg
santa_sprite.jpg (45.73 KiB) Viewed 675 times

I can load the image into QLAY using Photon and re-create a new animated sprite using a variant of the above program. So I think that's how I'll try and create an animated sprite that uses MOVE_MEMORY, since it works so well (and I can create the sprite in Windows Paint, which I like doing simple drawings in).

Photon.png


User avatar
Andrew
Aurora
Posts: 796
Joined: Tue Jul 17, 2018 9:10 pm

Re: Sprites on QL

Post by Andrew »

bwinkel67 wrote: Sun Dec 10, 2023 11:39 pm .Why is Santa_spr twice the size of what the 13,600 half bytes would yield (i.e. 6,800). Just a bit confused by that.
Because at that time I considered using a mask to allow for transparent sprite. So each frame has space for the sprite + mask (68x25 sprite + 68x25 mask)
I ended up not using the mask, but the space for it remained in the _spr file


User avatar
bwinkel67
QL Wafer Drive
Posts: 1202
Joined: Thu Oct 03, 2019 2:09 am

Re: Sprites on QL

Post by bwinkel67 »

Ah, that makes sense. I really like your Sprite-like mechanism. I'm wondering if MOVE_MEMORY can be replaced by an inner for loop if compiled. I'll have to try it since, in BASIC, that inner for loop runs really slow. But with this technique it would be pretty easy to create a game in BASIC.

The animated Sprite runs a bit slow on a BBQL, but if you make the images smaller, the animation shorter, and compile the BASIC with one of the QL's BASIC compilers (I use SuperCharge), I bet it would run decently.

My technique to convert an image into this Sprite-like graphic is done with a little BASIC program. This allows me to create the image in my favorite Windows drawing program, save it is a low compression JPEG (so there is little approximation in the image), and use QL's Photon to generate a QL screen image out o fit.

Here it is...some of the values in the code below would change depending on the size of each panel and how many frames you had for animation. But is also shows the versatility of SuperBASIC, as I was initially looking to see if I could do this in Windows.

Code: Select all

10 EW win1_photon;"win1_santa_sprite_jpg\m8\d0\r"
20 c=RESPR(6800): b=0: FOR i=0 TO 199: FOR j=0 TO 33: POKE (c+i*34+j),PEEK(131072+(28*128)+44+b+j): NEXT j:b=b+128: NEXT i: SBYTES win1_santa3_spr,c,6800
30 MODE 8: PRINT #0, "Loading new Santa...": d=RESPR(6800): LBYTES win1_santa3_spr,d: b=0: FOR i=0 TO 199: FOR j=0 TO 33: POKE (131072+b+j),PEEK(d+i*34+j): NEXT j:b=b+128: NEXT i
My initial try was to change the sled to light blue and recreate the QL santa_spr and run it in the santa_bas program...and it all worked (I changed the values to work with the small 6800 size).


Mackinnon
ROM Dongle
Posts: 1
Joined: Mon Jan 01, 2024 1:37 pm

Re: Sprites on QL

Post by Mackinnon »

hi and happy new year

I have taken some time today to look at old QL files I had on old floppy disks which I managed to still recover the files from

So maybe this sprite designer in SuperBasic is close to what you are trying to do here as well. I am afraid there is no documentation other than the code itself

If anyone manages to play with it and figure it out in any way, it would be interesting to hear about it. I can't remember much of the details, but it seems workable if you take care. You use the arrow keys to move around the pixel grid. Press space and enter a colour number. Then if you move and press enter it enters the same colour. so you can fill it out slowly pixel by pixel. I know it sounds like torture, but it worked well for me

https://github.com/PDMackinnon/QL-designer

I posted the code to the above.

the file is called "designer"


Post Reply