Game Development Reference
In-Depth Information
under the hood. Learn about the memory and how it is organized. See how the secondary storage works.
Get a basic clue about the graphics chipset. Most importantly, learn how data flows to and from all
these systems, and how it can be stalled. This knowledge can turn a hobbyist into a professional.
Packaging Resources into a Single File
It
s a serious mistake to store every game asset, such as a texture or sound effect, in
its own file. Separating thousands of assets in their own files wastes valuable storage
space and makes it impossible to get your load times faster.
Hard drives are logically organized into blocks or clusters that have surprisingly large
sizes. Most hard drives in the gigabit range have cluster sizes of 16KB
'
32KB. File
systems like FAT32 and NTFS were written to store a maximum of one file per clus-
ter to enable optimal storage of the directory structure. This means that if you have
500 sound effect files, each ½-second long and recorded at 44KHz mono, you
-
'
ll have
5.13MB of wasted space on the hard disk:
0.5 seconds * 44KHz mono = 22,000 bytes
32,768 bytes minimum cluster size
-
22,000 bytes in each file = 10,768 bytes wasted per file
10,768 bytes wasted in each file * 500 files = 5.13MB wasted space
You can easily get around this problem by packing your game assets into a single file.
If you
re familiar with WAD files; they
are a perfect example of this technique. These packed file formats are file systems in
miniature, although most are read only. Ultima VIII and Ultima IX had a read/write
version (FLX files) that had multiuser locking capabilities for development. Almost
every game on the market uses some custom packing scheme for more reasons than
saving hard drive space.
'
ve ever played with DOOM level editors, you
'
Other Benefits of Packaging Resources
The biggest advantage of combining your resources by far is load time optimization.
Opening files is an extremely slow operation on most operating systems. The full file-
name must be parsed, the directory structure traversed, the hardware must locate and
read a number of blocks into the operating system read cache, and more. This can
cause multiple seeks, depending on the organization of the media. Another advantage
is security. You can use a proprietary logical organization of the file that will hamper
armchair hackers from getting to your art and sounds. While this security is quite
light, and serious hackers will usually break it before the sun sets the first day your
game is on the shelves, it ' s better than nothing. Of course, you can always publish the
format of your files and get the mod community going. Either way, it is your choice.
 
 
 
Search WWH ::




Custom Search