Gimp for sprites

handy tools that can assist in the development of new software
Post Reply
AJW
Posts: 881
Joined: Sun Feb 15, 2004 2:01 pm
Contact:

Gimp for sprites

Post by AJW » Wed Jul 29, 2020 4:02 pm

Just reading about Repton TLR graphics.
http://kecskebak.blogspot.com/2010/11/d ... s.html?m=1


If one uses Gimp how easy is it to align thrm all as Dave did? Also having converted to Beeb format graphics how to extract or use from there?
For example if you want to use a sprite in a game you need a start memory pointer, width and line offset to read each one's data before replotting with the same method.

julie_m
Posts: 214
Joined: Wed Jul 24, 2019 9:53 pm
Location: Derby, UK
Contact:

Re: Gimp for sprites

Post by julie_m » Wed Jul 29, 2020 9:11 pm

If you use GIMP at a high enough magnification to edit individual pixels, then it's pretty easy to keep everything aligned, assuming you know your multiplication tables for the height and width you want your sprites to be!

Then you need a way to get an image from a format GIMP understands, to BBC format. See viewtopic.php?f=55&t=19993 and viewtopic.php?f=55&t=20047 for some ideas.

The display memory is not laid out strictly linearly as you might naïvely expect, although it does make sense for some value of "sense". (The order of the bytes is the computer's business; the MOS is supposed to take care of all that for you, so the memory can be laid out to suit the computer's hardware. But that's too slow for an action game; writing data directly to the screen, while less portable, is much quicker.) If you try writing directly to screen memory in BASIC with ?, you'll get the idea but basically the screen is divided into 8-pixel-high character rows of 640 or 320 bytes; and each character row is divided into columns 8 bytes high where each byte contains the colour information for 2 (MODE 2), 4 (MODE 1 / MODE 5) or 8 (MODE 0 / MODE 4) pixels, with the bits interleaved just to confuse you :) . Basically, try writing 1, 2, 4, 8, 16, 32, 64 and 128 to various locations until you get used to the order.

Lastly you will need some code to write your sprites to screen memory. See viewtopic.php?f=54&t=19717&p=277981#p277981 for some code I wrote to try to get to grips with BeebAsm before transferring my main project over to it, that you might be able to do something with .....

AJW
Posts: 881
Joined: Sun Feb 15, 2004 2:01 pm
Contact:

Re: Gimp for sprites

Post by AJW » Thu Jul 30, 2020 3:36 pm

He somehow aligns them like this:
GIMP.png
but doesn't say how it's done. Then converts with BBC Micro Image Converter.

also he doesn't say how the data is dealt with after. Surely it's faster to have the sprite data in linear fashion per sprite in memory rather than extracting it from a block at the point of use?

julie_m
Posts: 214
Joined: Wed Jul 24, 2019 9:53 pm
Location: Derby, UK
Contact:

Re: Gimp for sprites

Post by julie_m » Thu Jul 30, 2020 4:46 pm

Well, my code deliberately includes a section to read data from anywhere on screen (as long as it be byte-aligned horizontally), given X and Y co-ordinates, width and total length, and store it linearly in a contiguous block in memory. This is intended for storing the background that was there before painting a sprite, so it can be restored afterwards; but it can also be used to grab data from screen memory (agnostically towards however it might have got there in the first place) to use as a sprite. What's important is that even although the screen address is all over the place, the storage address increases linearly.

So I would load up a screenful of sprite images; then just grab the bits I wanted, and have them in memory already in the right order for my code to paint to the screen.

Whatever "display some bytes at a given position on screen" code you are adapting, just needs changing so it does an LDA from the screen address followed by an STA to the sprite table. (In fact, since you only need to do this when first writing your game, not every time you play it, you could even use BASIC for this step.)

itszor
Posts: 1
Joined: Wed Aug 07, 2019 4:29 pm
Contact:

Re: Gimp for sprites

Post by itszor » Thu Jul 30, 2020 8:02 pm

I used grafx2 for "Sugar Smash" -- its tools might be more appropriate for low-res pixel graphics than the Gimp's. (I don't actually remember how much help it is for things like lining up sprites, so YMMV...)

User avatar
Kecske Bak
Posts: 715
Joined: Wed Jul 13, 2005 8:03 am
Location: Treddle's Wharf, Chigley
Contact:

Re: Gimp for sprites

Post by Kecske Bak » Fri Jul 31, 2020 7:28 am

What I did for the graphics for the unreleased Secret Realms was a bit more sophisticated than what I did for Lost Realms.

I drew each graphic on a separate layer (with a special name) in an XCF file.

I used a GIMP plug-in (Save layers as images) to export my XCF layers as PNGs. (In fact, I tended to use multiple XCF files, one for the wall, one for the monsters so I could swap things around easily if I wanted).

I wrote a Python "make" file to take the exported PNGs and put that into a Secret Realms file on a BBC disc image (.ssd) file. The Python file would work with BBC Micro or Electron files - BBC graphics were 32x32 in the GIMP and Electron were 24x24. You can see my Python file actually has a really rubbish emulation of Acorn DFS in it!

You can see what I did here - https://paste.ubuntu.com/p/gnqZWs7fqh/

I was inspired by the wonderful tools written for Jungle Journey and Castle Raider by David Boddie. Then, every time I altered the graphics in my GIMP .xcf file, all I had to do was type in a command in the console and my disc image was updated.

AJW
Posts: 881
Joined: Sun Feb 15, 2004 2:01 pm
Contact:

Re: Gimp for sprites

Post by AJW » Fri Jul 31, 2020 1:14 pm

itszor wrote:
Thu Jul 30, 2020 8:02 pm
I used grafx2 for "Sugar Smash" -- its tools might be more appropriate for low-res pixel graphics than the Gimp's. (I don't actually remember how much help it is for things like lining up sprites, so YMMV...)
Outstanding use of colour.

AJW
Posts: 881
Joined: Sun Feb 15, 2004 2:01 pm
Contact:

Re: Gimp for sprites

Post by AJW » Fri Jul 31, 2020 1:17 pm

Kecske Bak wrote:
Fri Jul 31, 2020 7:28 am
What I did for the graphics for the unreleased Secret Realms was a bit more sophisticated than what I did for Lost Realms.

I drew each graphic on a separate layer (with a special name) in an XCF file.

I used a GIMP plug-in (Save layers as images) to export my XCF layers as PNGs. (In fact, I tended to use multiple XCF files, one for the wall, one for the monsters so I could swap things around easily if I wanted).

I wrote a Python "make" file to take the exported PNGs and put that into a Secret Realms file on a BBC disc image (.ssd) file. The Python file would work with BBC Micro or Electron files - BBC graphics were 32x32 in the GIMP and Electron were 24x24. You can see my Python file actually has a really rubbish emulation of Acorn DFS in it!
A single file containing all graphics which is then extracted by the Repton game?



Also why unreleased?

Naomasa298
Posts: 386
Joined: Sat Feb 16, 2013 12:49 pm
Contact:

Re: Gimp for sprites

Post by Naomasa298 » Fri Jul 31, 2020 11:57 pm

Using GIMP, I just create 1 file per sprite, save in BMP format, and then use an external utility to convert, insert width, height and format headers, then and concatenate all the converted file into a single file with the lookup table at the start.

Post Reply

Return to “development tools”