![]() |
|
".dat" files? what, who, were and why? |
jaime barrachina
Member #6,780
January 2006
![]() |
I've recently started whith C++ (and with programming, come to that) and everyday I find surprises, today, the winner is the ".dat" file. While cheking out the code to make a RPG's map I come to find that all the images and data concerning them are in a misterious file, sealed off from mortal eyes, called "data.dat". So, what exactly is a .dat file? what does it do, how does it work, and how can I open and edit it? Plese escuse my incredibly basic question but as ignorance ain't a crime (yet) I think I'll do my best to put a remedy to it, if any of you can help me out, I'd be realy thankfull cause its really frustrating to go trught the page of code labeled map.cpp only to find lonelly drawing functions there (which come to it I still don't fully understand xD) Cheers and thanks! "Under the sword lifted high There is hell making you tremble: But go ahead, And you have the land of bliss. - Miyamoto Musahshi" |
Arthur Kalliokoski
Second in Command
February 2005
![]() |
You're talking about Allegro? If you've downloaded & installed it, check out the manuals in /allegro/docs/html or /allegro/docs/text etc. In the tools section there's a "grabber.exe" program that'll show you what's in the .dat files & import/export bitmaps, wave files, etc. They all watch too much MSNBC... they get ideas. |
ReyBrujo
Moderator
January 2001
![]() |
It is basically a compressed file, like a tar.gz or a .zip. You can either load it all in memory, or load just chuncks as you need them. Check grabber.txt and datafile.txt somewhere in Allegro source to learn more about the technical details. -- |
jaime barrachina
Member #6,780
January 2006
![]() |
Oks thanks people "Under the sword lifted high There is hell making you tremble: But go ahead, And you have the land of bliss. - Miyamoto Musahshi" |
Elverion
Member #6,239
September 2005
![]() |
Like others have said, the .dat files are generally produced by grabber (in Allegro programs, anyways). This isn't always the case, though. the .dat extension could be used for virtually anything. Someone might want to serialize their classes out into a random-access .dat file (in short - a simple database), which is much different than a compressed file that could contain several medias. -- |
Johan Halmén
Member #1,550
September 2001
|
The Allegro dat files don't have to be compressed. If they aren't, they are there only to keep everything in as few file as possible. You could have your 100 sprites in 100 bmp files or in one dat file. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Years of thorough research have revealed that what people find beautiful about the Mandelbrot set is not the set itself, but all the rest. |
jaime barrachina
Member #6,780
January 2006
![]() |
Mmm, ive managed to open the file whith the grabber and it shows a kind of bunched up images compresed into a single drawing, pieces and bits of trees, fences, grass, ect. I supose the program somehow cuts the picture like if it were on a grid, how does it do that? Anyone could post a simple example of the code needed to slice my rectangular pizza? Txs a bunch people, i dont know wht i'd do whithout this forum (Rott in some forgoten room, surrounded by empty coke cans and pizza boxes i supose) Cheers!! "Under the sword lifted high There is hell making you tremble: But go ahead, And you have the land of bliss. - Miyamoto Musahshi" |
Kitty Cat
Member #2,815
October 2002
![]() |
That's called a tileset. It's a single big image that holds many different tiles and/or sprites used for a specific area of a game. Typically, each tile/sprite is a fixed size (16x16 or 32x32 usually), so you just need to use create_sub_bitmap at 16 or 32 pixel intervals to grab each one. -- |
Johan Halmén
Member #1,550
September 2001
|
Quote: i dont know wht i'd do whithout this forum You would be having a life. Like we would. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Years of thorough research have revealed that what people find beautiful about the Mandelbrot set is not the set itself, but all the rest. |
gnolam
Member #2,030
March 2002
![]() |
Johan Halmén said: You would be having a life. Like we would.
And still you let your children in here? -- |
jaime barrachina
Member #6,780
January 2006
![]() |
I supose xDDD "Under the sword lifted high There is hell making you tremble: But go ahead, And you have the land of bliss. - Miyamoto Musahshi" |
DanielH
Member #934
January 2001
![]() |
The following is an assumption: You are looking at my datafile that I created. The bitmap itself is a complete set of tiles. There are simple ways of accessing which tile I need at any point. The bitmap is arranged as 256x1024 or 8x32 of 32x32 pixel tiles. Let's say that you want to draw the tile at 2 rows down and 4 from left at screen position 128x128. That would be tile ( 2 * TILE_SET_WIDTH ) + 4 = 20; draw_tile( buffer, (BITMAP*)datafile[ BMP_TILES ].dat, 20, 128, 128 ); 20 is broken down in the function as tx = ( 20 % 8 ) << 5 = 128 ty = ( 20 / 8 ) << 5 = 64 So the section of the bitmap with be drawn like: blit( tiles, buffer, 128, 64, 128, 128, 32, 32 ); Or for a grid
POINT If you need to do special things to the tiles such as transparency, translucency, etc. This will not be possible. You would then need to separate the entire tile bitmap into 256 bitmaps. This can be done easily enough in the grabber program. 1. Read in a bitmap You will end up with 256 tiles named TILES000 to TILES255 Or you could do it yourself in a function
|
jaime barrachina
Member #6,780
January 2006
![]() |
TXS for all the replies!! I'll try and see if anithing comes out xD "Under the sword lifted high There is hell making you tremble: But go ahead, And you have the land of bliss. - Miyamoto Musahshi" |
|