Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / .SPR Format from the 90's

Author
Message
Burning Feet Man
16
Years of Service
User Offline
Joined: 4th Jan 2008
Location: Sydney, Australia
Posted: 4th Mar 2013 03:59
With game revivals such as Open Transport Tycoon (OpenTTD) and Corsix Theme Hospital (CorsixTH) becoming more & more popular, I've become curious with my own childhood sweet heart, Acclaims Constructor.

In looking at the .DATA files, I've found files within the .DATA archive the extension .SPR which I'm lead to believe contain all of the delicious sprite art work for the game.

My problem is that I need to write a program which translates the .SPR file into an image which I can then use in a DBpro attempt at my own revival of the game (In all honesty, all I'll probably do is get a little man walking about, but who knows! Gotta be in it to win it!).

I've found some information on the specific file format here;

https://github.com/shlainn/game-file-formats/wiki/Constructor-.SPR-files

Quote: "Format

SPR files contain a header with offsets to every sprite in the file.
"




Quote: "Offsets can be 0. In this case no sprite data is present and the entry should be skipped.

Each sprite has an 8 byte header"




Quote: "After that follows the image data. Transparent areas are RLE-encoded. Any bytes with a value of zero are followed by a byte giving the length of the transparent run. Note that this doesn't apply to FONTS.SPR. Bytes with a value > 0 point to palette entries."


From this given information, is there enough for me to get from A to B, as far as extracting the art work goes?

I'm assuming I'll have to load the file into a memblock, then extract image data from that memblock? Expert opinions would be appreciated here.

Or is there a better way of doing this, say, writing a .SPR extension plug-in for GIMP?

Help build an online DarkBASIC Professional help archive.
DarkBasic Help Wikia
MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Kevin Picone
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 4th Mar 2013 20:45 Edited at: 5th Mar 2013 00:11
@Burning Feet Man,

Quote: "
From this given information, is there enough for me to get from A to B, as far as extracting the art work goes?
"



Yeah, that's assuming you can get the colour palette from the other file. See here https://github.com/shlainn/game-file-formats/wiki/Constructor-Level-files

Looks like they've used IFF file format, so skimming through those files should be pretty easy. First you ID the header (IFF stamp), after that the data blocks are in chunks. Each chunk has an ID and size. You just loop through the chunks look for the ID's you want, in this case the palette data. The colour entries are probably in triple form, (24bit colour) probably R,G,B or perhaps even B,G,R.

Once you've the colours then what I'd do would be load the entire SPR file into a mem block / bank (in PB terms) since sprite files may contain many frames. The main header is pretty self explanatory, first we pull the first long, which gives the number of frames. Depending on the platform the file was created upon, you might have to flip these bytes (see http://en.wikipedia.org/wiki/Endianness), we'll assume not for now.

Pseudo PlayBASIC / DarkBASIC styled code: (completely untested)




Well, this is not necessarily the most efficient method, but you should be able to write something from the bare logic.

Burning Feet Man
16
Years of Service
User Offline
Joined: 4th Jan 2008
Location: Sydney, Australia
Posted: 12th Mar 2013 03:16
Thank you kindly for your replies and steering me in the right direction. I'm afraid this type of project might be a little over my head, but I'll give it a crack for a few hours over the coming days.

Attached to this post is an example .SPR file, which I suspect holds some picture data.

Help build an online DarkBASIC Professional help archive.
DarkBasic Help Wikia

Attachments

Login to view attachments
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 12th Mar 2013 10:59
Sounds like a challenge to me, first to get an SPR file loaded into the basic of their choice and saved out again as a more usable format (PNG, BMP, TGA whatever), wins the internet.

I got a fever, and the only prescription, is more memes.
Kevin Picone
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 12th Mar 2013 14:58 Edited at: 12th Mar 2013 15:02
Done.

The decoder routine above almost works sight unseen. Just needed to bump the PIXELCOUNT offset when grabbing the pixels back, when paint the image.




The SPR files only include the raw null compressed palette mapped frames, they don't actually include the PALETTE data, so I just set the palette to gray scale since none was supplied.

Burning Feet Man
16
Years of Service
User Offline
Joined: 4th Jan 2008
Location: Sydney, Australia
Posted: 27th Mar 2013 01:37
That's very impressive Kevin. Thanks for the time that you've spent on this, as it helps me understand the logic of such a project.

Help build an online DarkBASIC Professional help archive.
DarkBasic Help Wikia

Login to post a reply

Server time is: 2024-02-29 09:50:28
Your offset time is: 2024-02-29 09:50:28