Combining sprites in RiscOS

chat about arc/risc pc gaming & RISC OS software here (NOT the core OS!)Related forum: adventures


Post Reply
User avatar
DutchAcorn
Posts: 1943
Joined: Fri Mar 21, 2014 9:56 am
Location: Maarn, Netherlands
Contact:

Combining sprites in RiscOS

Post by DutchAcorn » Sat Oct 13, 2018 11:18 am

Inspired by the ray traced spheres thread I took a look the animated ray traced spheres program my brother made in the late eighties on an A310. I found it and it works but it produces individual sprite files which can be shown using a separate play program. The play program however expects a single sprite file containing the individual sprites. It uses *SCHOOSE to select the correct screen dump.

I can't remember how to combine individual sprite files into a single file, and the user guide is not much help. Does anyone here know how to do that, preferably using the command line?

So I have 19 individual sprite files named SCR1 - SCR19 that I want to combine into a single "ALLSCREENS" file, using *SCHOOSE to select a sprite..
Paul

Image

User avatar
IanS
Posts: 716
Joined: Mon Aug 31, 2009 6:02 pm
Contact:

Re: Combining sprites in RiscOS

Post by IanS » Sat Oct 13, 2018 12:18 pm

DutchAcorn wrote:
Sat Oct 13, 2018 11:18 am
I can't remember how to combine individual sprite files into a single file, and the user guide is not much help. Does anyone here know how to do that, preferably using the command line?
Command-line, no idea.

Easy enough to do using the GUI, open one file, open another, then save the sprite from file 2 into file 1, using the menu, there is a "Sprite <x>"->Save option, drag the icon onto the first file (may need to ensure the sprite name, not the file name, is unique). You can the accumulate all the sprites within one container file.

RobC
Posts: 2366
Joined: Sat Sep 01, 2007 9:41 pm
Contact:

Re: Combining sprites in RiscOS

Post by RobC » Sat Oct 13, 2018 1:31 pm

I think Ian's suggestion is the simplest but think you can merge sprites with the system sprite area by using *SMerge and then save out the whole area to a file with *SSave.

User avatar
DutchAcorn
Posts: 1943
Joined: Fri Mar 21, 2014 9:56 am
Location: Maarn, Netherlands
Contact:

Re: Combining sprites in RiscOS

Post by DutchAcorn » Sat Oct 13, 2018 2:23 pm

Thanks guys, that really helped. The code I used:

Code: Select all

 *SLOAD SCR1
 *SRENAME SCREENDUMP SCR1
 FOR N=2 TO 19
   OSCLI("SMERGE SCR")+STR$(N)
   OSCLI("SRENAME SCREENDUMP SCR")+STR$(N)
 NEXT
 *SSAVE ALLSCREENS
Paul

Image

joachim
Posts: 146
Joined: Wed Jun 21, 2006 1:20 am
Contact:

Re: Combining sprites in RiscOS

Post by joachim » Sat Oct 13, 2018 7:01 pm

Just in case anyone wants to construct a general solution, the sprite file format is (obliquely) documented in the PRMs at http://www.riscos.com/support/developer ... rites.html. (Note in "Technical Details", the sentence "The format of the file created by a *ScreenSave or *SSave command is the same as a sprite area, save that word 1 of the control block is not saved.")

This means that a sprite file is three 4-byte words of header, followed by blocks of sprite data. So to combine sprite files, just:
  • strip off the first 12 bytes of each file
  • concatenate the files
  • write a new 12-byte header on the beginning of the concatenated file,
where the header format is:
  • number of sprites (4 bytes)
  • header length (always 12) (4 bytes)
  • length of sprite file, including the 12-byte header (4 bytes).

Post Reply