Qbasicnews.com

Full Version: About saving to a file
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am making a GCS right now that uses tiles. When I save a map, I would have to make different stats for each tile on the 80x60 (FreeBasic SDL) screen. Each block would need to write the x, y, color, character number, and type to a file. The problem is, it would be inconvenient to store all of those stats directly to the file because it would make the file exceedingly large. The file might also contain several sets of those. Each set has 4800 blocks, and each tile would need to write about 8-11 numbers to the file. Yes, I know, it would be a whole lot of numbers.

What are some file format "tricks" I can use to reduce the size of a file such as that? (I know I can use zlib for FreeBasic, but I need to find another way to reduce the size without a library)
Well, Binary Mode will help you to some extent. the width and height can be single UBYTEs as they only go up to 80 and 60. The colour is the same if you're in 16-colour or 256-colour mode, but if you're in 16bit or 32bit mode you'll need a 32-bit space (UINTEGER) to store the colour. The character can be stored as a UBYTE, and the type, I would have thought a UBYTE as well, unless there are more than 256 types, in which case use SHORT