Writing RSC files in C

C and PASCAL (or any other high-level languages) in here please

Moderators: exxos, simonsunnyboy, Mug UK, Zorro 2, Moderator Team

itaboy
Captain Atari
Captain Atari
Posts: 174
Joined: Sun May 04, 2014 6:24 pm

Writing RSC files in C

Postby itaboy » Tue Apr 04, 2017 4:49 pm

Hello guys, someone has an example of how to write back to disk a RSC file, after it has been modified in memory (e.g. after having translated or modified parts of it). I need a C routine (Pure C or Lattice C is tha same... I'll adapt)

Thank you guys!

Enrico

ijor
Hardware Guru
Hardware Guru
Posts: 3148
Joined: Sat May 29, 2004 7:52 pm
Contact:

Re: Writing RSC files in C

Postby ijor » Tue Apr 04, 2017 9:15 pm

If you have a RSC file, why not use a RSC editor?

But probably the source of an RSC editor, which does more or less what you might want, might be useful.

ThorstenOtto
Captain Atari
Captain Atari
Posts: 176
Joined: Sun Aug 03, 2014 5:54 pm

Re: Writing RSC files in C

Postby ThorstenOtto » Wed Apr 05, 2017 9:35 am

itaboy wrote:Hello guys, someone has an example of how to write back to disk a RSC file, after it has been modified in memory (e.g. after having translated or modified parts of it)


That largely depends upon how you loaded it, and what modifications you made. If you loaded it with rsrc_load(), and only modified the contents of the strings (but not the pointers to them), all you have to do is convert back all pointers into offsets from the header start, then write it back to disk. You get the address of the header, as well as the filesize from the aes global array after the rsrc_load() call. If you modified pointers to some area outside of the original resource data, or deleted/added objects, or the resource contains color icons, things are getting more complicated. Then you have to count all the invidiual objects, tedinfos, bitblks, strings etc, allocate space for it then copy your resource data over, calculating the offsets while you do. Dunno wether it helps, but at
http://www.retroarchive.org/cpm/archive ... gemrcs.zip you will find the source of DRI's RCS.

AtariZoll
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2930
Joined: Mon Feb 20, 2012 4:42 pm
Contact:

Re: Writing RSC files in C

Postby AtariZoll » Wed Apr 05, 2017 9:40 am

Plenty of good RSC editors available.
Structure of RSC files is well decsribed in Atari ProfiBuch, so you can go on it even without some C source :D
But I really don't see why do it at all now.
There is way to stop global warming.

itaboy
Captain Atari
Captain Atari
Posts: 174
Joined: Sun May 04, 2014 6:24 pm

Re: Writing RSC files in C

Postby itaboy » Wed Apr 05, 2017 5:01 pm

Hi guys, first of all thank you for the replies. What I am doing is writing a RSC file translator. That is a program that has the only specific purpose to be able to adapt the text within the existing objects in a given rsc file to a different language.
The difference between this program and a full fledged resource editor is that a program like this makes it much easier and convenient to prepare 1 original resource file and to add a text file which contains all the different variations in any given language.
The beta version is already up and running, and works pretty well, I must say. I have been able to work on different rsc files of other programs and map the strings within. This way it is really much much easier to prepare translations (the only constraint being that the translated text must never be longer than the original text).
My only problem is in writing back the modified rsc file to disk. I assume I am making some errors during the conversion of pointers to offests, as ThorstenOtto suggested... I'll double check for that!

Thanks again!

User avatar
wongck
Ultimate Atarian
Ultimate Atarian
Posts: 11990
Joined: Sat May 03, 2008 2:09 pm
Location: Far East
Contact:

Re: Writing RSC files in C

Postby wongck » Wed Apr 05, 2017 11:01 pm

itaboy wrote:My only problem is in writing back the modified rsc file to disk. I assume I am making some errors during the conversion of pointers to offests, as ThorstenOtto suggested... I'll double check for that!

Thanks again!


Also make sure you do not change the sequence of indexes. PRG needs the index not changed.
My Stuff: FB/Falcon CT63+CTPCI_ATI_RTL8139 14+512MB 30GB HDD CF HxC_SD/ TT030 68882 4+32MB 520MB Nova/ 520STFM 4MB Tos206 SCSI
Shared SCSI Bus:ScsiLink ethernet, 9GB HDD,SD-reader @ http://phsw.atari.org
My Atari stuff for sale - click here for list

User avatar
lp
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2257
Joined: Wed Nov 12, 2003 11:09 pm
Location: GFA Headquarters
Contact:

Re: Writing RSC files in C

Postby lp » Fri Apr 07, 2017 12:57 pm

A long time ago I wrote a desk accessory for dumping RSC files from ram to disk. A sort of rsc ripping tool. Thorsten is correct, it can get complicated with certain object types. Simplifying translations sounds like an interesting project. I hope you get it sorted.

ThorstenOtto
Captain Atari
Captain Atari
Posts: 176
Joined: Sun Aug 03, 2014 5:54 pm

Re: Writing RSC files in C

Postby ThorstenOtto » Fri Apr 07, 2017 5:00 pm

itaboy wrote:What I am doing is writing a RSC file translator. That is a program that has the only specific purpose to be able to adapt the text within the existing objects in a given rsc file to a different language.


Sounds like you only want to modify the text of existing resource file of foreign programs? Then the attached routines might help. They are simplified versions of ones i used in other programs, and i did only a quick check after the modifications, but they look ok. There is almost no error checking except for a failed fopen(), and especially the rsc_write() function assumes that all pointers still point to some area in the originally allocated area.
What's left to be done is to convert the object coordinates.
You do not have the required permissions to view the files attached to this post.

itaboy
Captain Atari
Captain Atari
Posts: 174
Joined: Sun May 04, 2014 6:24 pm

Re: Writing RSC files in C

Postby itaboy » Fri Apr 07, 2017 5:52 pm

Thanks ThorstenOtto, I'll check straight away! :)

itaboy
Captain Atari
Captain Atari
Posts: 174
Joined: Sun May 04, 2014 6:24 pm

Re: Writing RSC files in C

Postby itaboy » Fri Apr 07, 2017 9:45 pm

OK, if any of you is curious, I have made a test program.
It is just a proof of concept, not a full fledged app... but it works.
You can load a RSC file, go through all the strings and change (translate) the ones you want.
When you're done you can save back to disk the new RSC file and use it...

Now it works... thanks Thorsten!
You do not have the required permissions to view the files attached to this post.


Social Media

     

Return to “C / PASCAL etc.”

Who is online

Users browsing this forum: No registered users and 1 guest