Moving resources from human viewable to binary?

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

User avatar
epicasian
Chaos Rift Junior
Chaos Rift Junior
Posts: 232
Joined: Mon Feb 22, 2010 10:32 pm
Current Project: Gigazilla Engine
Favorite Gaming Platforms: Dreamcast, SNES, PS2, PC
Programming Language of Choice: C/++
Location: WoFo, KY

Moving resources from human viewable to binary?

Post by epicasian »

I've been wondering how to (for lack of a better word) convert all of a games resources like the sprites, scripts and audio files to binary.

Thanks in advance.
User avatar
Ginto8
ES Beta Backer
ES Beta Backer
Posts: 1064
Joined: Tue Jan 06, 2009 4:12 pm
Programming Language of Choice: C/C++, Java

Re: Moving resources from human viewable to binary?

Post by Ginto8 »

Well, on windows there are resources, which (IIRC) allows a mini-filesystem inside of your binary. You could sort of mimic this on linux (ie. mkfs'ing a file and using some utility to open/read from that filesystem), but it's really up to you and whether or not you actually want it that way.
Quit procrastinating and make something awesome.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
User avatar
epicasian
Chaos Rift Junior
Chaos Rift Junior
Posts: 232
Joined: Mon Feb 22, 2010 10:32 pm
Current Project: Gigazilla Engine
Favorite Gaming Platforms: Dreamcast, SNES, PS2, PC
Programming Language of Choice: C/++
Location: WoFo, KY

Re: Moving resources from human viewable to binary?

Post by epicasian »

Could I also use something like zlib to compress a bunch of resources in one file, then load from that file?
User avatar
Ginto8
ES Beta Backer
ES Beta Backer
Posts: 1064
Joined: Tue Jan 06, 2009 4:12 pm
Programming Language of Choice: C/C++, Java

Re: Moving resources from human viewable to binary?

Post by Ginto8 »

maybe, but again you'd need some sort of filesystem-in a file. You could do a tarball, which would probably work.
Quit procrastinating and make something awesome.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
User avatar
kamokow
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 68
Joined: Wed Aug 05, 2009 9:36 pm
Programming Language of Choice: C++
Location: Canada

Re: Moving resources from human viewable to binary?

Post by kamokow »

If I'm understanding what you want to do, then you might want to read these:

http://www.gamedev.net/reference/articl ... cle825.asp
http://www.gamedev.net/reference/articl ... le1991.asp
Image
K-Bal
ES Beta Backer
ES Beta Backer
Posts: 701
Joined: Sun Mar 15, 2009 3:21 pm
Location: Germany, Aachen
Contact:

Re: Moving resources from human viewable to binary?

Post by K-Bal »

Pretty pointless in my opinion since your program contains all the information on how to extract these files again. Not hard to write an unzipper with little assembly knowledge.
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
Posts: 4709
Joined: Tue Apr 29, 2008 3:24 pm
Current Project: https://github.com/dbechrd/RicoTech
Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
Programming Language of Choice: C
Location: San Francisco
Contact:

Re: Moving resources from human viewable to binary?

Post by dandymcgee »

K-Bal wrote:Pretty pointless in my opinion since your program contains all the information on how to extract these files again. Not hard to write an unzipper with little assembly knowledge.
If done right it can save a lot of space, that alone seems like a solid point to me.
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
K-Bal
ES Beta Backer
ES Beta Backer
Posts: 701
Joined: Sun Mar 15, 2009 3:21 pm
Location: Germany, Aachen
Contact:

Re: Moving resources from human viewable to binary?

Post by K-Bal »

dandymcgee wrote:
K-Bal wrote:Pretty pointless in my opinion since your program contains all the information on how to extract these files again. Not hard to write an unzipper with little assembly knowledge.
If done right it can save a lot of space, that alone seems like a solid point to me.
Even if "done right" it doesn't save space in the RAM but only on the HDD. Actually you will use more RAM when both the zip file and the extracted files are in memory at the same time. Furthermore, if you develop for standard desktop computers memory shouldn't be an issue for most applications.
User avatar
LeonBlade
Chaos Rift Demigod
Chaos Rift Demigod
Posts: 1314
Joined: Thu Jan 22, 2009 12:22 am
Current Project: Trying to make my first engine in C++ using OGL
Favorite Gaming Platforms: PS3
Programming Language of Choice: C++
Location: Blossvale, NY

Re: Moving resources from human viewable to binary?

Post by LeonBlade »

I just guessed with my map files ;)
There's no place like ~/
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
Posts: 4709
Joined: Tue Apr 29, 2008 3:24 pm
Current Project: https://github.com/dbechrd/RicoTech
Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
Programming Language of Choice: C
Location: San Francisco
Contact:

Re: Moving resources from human viewable to binary?

Post by dandymcgee »

K-Bal wrote:
dandymcgee wrote:
K-Bal wrote:Pretty pointless in my opinion since your program contains all the information on how to extract these files again. Not hard to write an unzipper with little assembly knowledge.
If done right it can save a lot of space, that alone seems like a solid point to me.
Even if "done right" it doesn't save space in the RAM but only on the HDD. Actually you will use more RAM when both the zip file and the extracted files are in memory at the same time. Furthermore, if you develop for standard desktop computers memory shouldn't be an issue for most applications.
By "memory" did you mean RAM or hard drive space? The first would be countering your own point, and while the second may be true for small applications (as this surely is), it is still somewhat ignorant. I don't see any harm in learning conceptually how to save resources, which could be quite a big deal for a large-scale project.
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
qpHalcy0n
Respected Programmer
Respected Programmer
Posts: 387
Joined: Fri Dec 19, 2008 3:33 pm
Location: Dallas
Contact:

Re: Moving resources from human viewable to binary?

Post by qpHalcy0n »

Realtime data encoding and virtualization is among the fastest growing subfields of computer graphics. In many cases it saves both, there are multiple formats for both geometric and image data that do not need to be decompressed to be sampled. There are also multiple image formats that are compressions to save bandwidth. Trust me, when you start chunking around several dozen gigs of data around per second....compression and encoding become a BIG BIG deal.

I hardly see how this is anywhere near useless.
K-Bal
ES Beta Backer
ES Beta Backer
Posts: 701
Joined: Sun Mar 15, 2009 3:21 pm
Location: Germany, Aachen
Contact:

Re: Moving resources from human viewable to binary?

Post by K-Bal »

I was (unfoundedly) assuming the OP just wants to hide resources from 3rd party users. This is quite impossible because the application is already the key for decoding the data. This is what I meant with pointless.

And you guys are right, you can save both RAM and HDD when using streaming techniques, so I take back that statement. However, when decompressing a single chunk one will have both the compressed and the uncompressed chunk in memory at one time.
User avatar
avansc
Respected Programmer
Respected Programmer
Posts: 1708
Joined: Sun Nov 02, 2008 6:29 pm

Re: Moving resources from human viewable to binary?

Post by avansc »

I'm not going to get involved in this argument, but I will say this.

If I understand you correctly, you are talking about something called serialization(donno if someone has already mentioned that), and I for one am in favor for it. Now I'm not going to comment on the things like speed and size, even though there are implications, more so for the prior. I will say that it does make it harder, not impossible, for people to get your resources, and or change em, and secondly, why I am in favor for it, is that it makes it much easier to deal with resources, there is some "pre backing" that takes place, but in the end you cut down the file interaction time significantly.

It's also a lot nicer to have something like (and the extension should say a lot) resources.WAD, then do have level1.bsp dude.png etc. for ever single resource.

Anyways, if nothing else, look into it for the experience.

On a semi germane note, Java has a fantastic serialization implementation.
Some person, "I have a black belt in karate"
Dad, "Yea well I have a fan belt in street fighting"
User avatar
EccentricDuck
Chaos Rift Junior
Chaos Rift Junior
Posts: 305
Joined: Sun Feb 21, 2010 11:18 pm
Current Project: Isometric "2.5D" Airship Game
Favorite Gaming Platforms: PS2, SNES, GBA, PC
Programming Language of Choice: C#, Python, JScript
Location: Edmonton, Alberta

Re: Moving resources from human viewable to binary?

Post by EccentricDuck »

avansc wrote: Anyways, if nothing else, look into it for the experience.

On a semi germane note, Java has a fantastic serialization implementation.
I'm also quite interested in this (for a couple of the mentioned reasons and, if nothing else, what you just said). Which one in particular are you referring to?
User avatar
avansc
Respected Programmer
Respected Programmer
Posts: 1708
Joined: Sun Nov 02, 2008 6:29 pm

Re: Moving resources from human viewable to binary?

Post by avansc »

Java actually has a few, but the two main ones that will be of interest would be implements Serializable and implements Externalizable
Some person, "I have a black belt in karate"
Dad, "Yea well I have a fan belt in street fighting"
Post Reply