IMG

 
IMG
IMG   IMG
  Welcome to GTAForums! Be sure to check out the Grand Theft Auto V Forum.

You are not registered! (If you are, click here to login) Registering is fast, free and easy and allows you to instantly reply to any topic on GTAForums.
Why wait? Click here to register your own unique username and become part of the ever-growing community!


( Log In | Register | Revalidate Validation E-mail )
Quick Log-In:
  IMG
       
>
Forum Rules GTA Modification Forums

This section is for any editing topics that don't fit into any of the other forums, any questions on how to mod belong in Editing Discussion

GTAGarage.com
free mod hosting from GTANet, simply login with your GTAForums account details

GTAModding.com
GTANet's modding wiki

GTA Modding Chatroom
provided by irc.gtanet.com (Don't have an IRC client? Click here)


Pages: (2) [1] 2   ( Go to first unread post ) Reply to this topicStart new topicStart Poll

 SA: IMG Format

 How to handel the new format
 
REspawn  
Posted: Thursday, Jun 9 2005, 14:50
Quote Post


REgent
Group Icon
Group: Members
Joined: Jul 6, 2002

il.gif

Member Award




Ok,
Now that SA is out for the PC we need to look at the format of the IMG files so we can add custom objects and such to the game.
The SA:PC version of the IMG files are the same as the Playstation 2 versions.

I have been thinking about this for a while and i think the below way is the best way of dealing with the new format.
But to implement it we need to agree on some standards so that the different SA based IMG tools and can all work in harmony without destroying the end users files.

I will start with a quick explanation of the IMG format for GTA3 and Vice City so people can see how it has evolved and then i will explain the SA format.

Grand Theft Auto 3 / Vice City IMG Format
There are 2 files, the first is the .img which holds the files. These files are stored in blocks of 2048 bytes.
Even if a file is 34 bytes it will occupy a full 2048 byte block.

The second file is the .dir file.
This is like a listing of each file in the .img file, it holds the name, offset and the number of blocks taken up by the file.
The name of the file as you can guess is the name of the file.
The offset is its position inside the .img file, the best way to explain this is to think of a shelf, one shelf one there is a texture file and on shelf two there is a model file.
The shelf number is like the offset, the position on the shelf where you can find what your looking for.
The size of the file is the number of blocks the file is currently occupying inside the .img file.

So when we wanted to add a file to Vice City or GTA3 all we had to do was put the file at the end of the .img and add a new entry to the .dir file.
So now that you know how GTA3 and Vice City works lets look at San Andreas...

San Andreas IMG Format
There is no longer 2 separate files, they have been merged into one singular file.
The dir listing of what is inside the .img is now at the start of the .img file.
The formats are still the same, files are kept in contiguous 2048 byte blocks, the dir listing still has an offset, size (num of blocks) and a name.
The only difference is that at the very start of the file is "VER2" and then a number which is the total number of files contained within the IMG.

You can start to see a problem already, now when we want to add a file we have to create an dir listing for it which means moving the blocks containing the files.
So this is where we need to work together and devise a solution, and after some thinking i think that this is the best way...

Proposed solution...
Blank dir entries are kept inside the IMG.
When you want to add a file the IMG tool checks for blank entire and if one is there it uses it.
Files being added to the archive can be added to the end.
If a blank entry is not available then one is created.

user posted image
Data: The blocks containing the files
IMG Information: The version number and number of files in the IMG
DIR Information: The dir listings, the offset, name and num of blocks used

user posted image

Step 1.
The first file directly after the dir listing is moved to the very end of the file and its corresponding dir entire has its offset updated.
user posted image

Step 2.
This free space is then used to create the maximum amount of dir listing entires.
Each 2048 byte block will give us 64 blank entires.
user posted image

This is best way i can see, using this method we create empty spaces that can be used at a later date and we don't have the overhead of moving all the files just so we can create some blank spaces.
The only real standard we need to agree on is what we name the empty spaces, we need a universal file name so all IMG tools created from now on can recognize the blank spaces.
Something like "-X27-X27-X27-X27-X27-X27"
There is never going to be a file called this so it should be perfectly safe.

Anywho im gonna start by trying out this method tomorrow, but for now im gonna go play with my brand spanking new copy of SA.
If any one else, not just the other coders out there has any thoughts or suggestions on this topic or how we should go about it then please post it.
This is only a suggestion on a way we can handle the file.

All the best,
-Dave
PMICQ
  Top
 

 
RainingAcid  
Posted: Thursday, Jun 9 2005, 14:54
Quote Post


Hustler
Group Icon
Group: Members
Joined: Mar 28, 2005

XXXXX



Hmm...I don't really understand what you're saying, but it's possible to make an IMG for San Andreas, correct? If so, I want to help, just let me know how I can help. smile.gif
PM
  Top
 

 
REspawn  
Posted: Thursday, Jun 9 2005, 15:06
Quote Post


REgent
Group Icon
Group: Members
Joined: Jul 6, 2002

il.gif

Member Award




QUOTE (RainingAcid @ Jun 9 2005, 14:54)
Hmm...I don't really understand what you're saying, but it's possible to make an IMG for San Andreas, correct? If so, I want to help, just let me know how I can help. smile.gif

SA already has an IMG, we know how to read it, we just need to decide on how we are going to write to it so that we don't end up with conflicts down the line.
Thats all.
PMICQ
  Top
 

 
steve-m  
Posted: Thursday, Jun 9 2005, 15:33
Quote Post



Group Icon
Group: Members
Joined: Jul 26, 2002

gr.gif

Member Award




QUOTE (REspawn @ Jun 9 2005, 16:50)
The only real standard we need to agree on is what we name the empty spaces, we need a universal file name so all IMG tools created from now on can recognize the blank spaces.
Something like "-X27-X27-X27-X27-X27-X27"
There is never going to be a file called this so it should be perfectly safe.

Why do you want to name them? The safest way would be to scan through the file offsets and filter out the lowest. This is where the first file starts, and everything before (except for the header) can be used for the directory, no matter if it was filled with garbage or zeros. On reading, the program would skip the free space anyway. And this would work with every upcoming img tool, no matter if it complies with any standards or not.
Sorry, I got it completely wrong. The block offsets are relative to the end of the file list, right? Sure, we would need empty file names then, and a file counter higher than the actual ammount of files. You could try to fill the whole 32 byte of each entry with zeros, the game and any other img tools should get zero strings and a filelength of 0 then, so it wouldn't cause any trouble. And all img tools wouldn't display those entry entries to the user, but keep them "in mind".
Users WebsitePM
  Top
 

 
illspirit  
Posted: Thursday, Jun 9 2005, 18:51
Quote Post


lycanthroplasty
Group Icon
Group: Network Admins
Joined: May 1, 1976

gadsden.gif

Member Award




Not sure I like the idea of moving the first chunk of data to the end to make room for more dir. Might cause some lagging and/or errors while the engine is scanning up and down to find things it expects to be in order. How about if on first opening of the img, the tools force a rebuild to move all the data down a bit? This could be checked via CRC or something to see if the file has been modded yet.

That said, there should (in a perfect world) also be an info box in the status bar somewhere that says how many dir entries are available/total. Whenever it reaches 0/X, the tools could/should/would prompt to rebuild and add entries, maybe even giving an option on how many entries to add. Maybe this check and prompt could also be done on first run instead of a CRC?
Users WebsitePMXbox Live
  Top
 

 
aad  
Posted: Thursday, Jun 9 2005, 18:53
Quote Post


3d artist
Group Icon
Group: Members
Joined: Mar 15, 2004

nl.gif

Member Award




Im just hoping someone makes a good working IMG tool that can reconise the IMG file and the Dir file and then makes it editable like its now with vice city and gta3. Maybe im wrong and maybe this will not be possible but i really like if this can be made. biggrin.gif
PMYahoo
  Top
 

 
steve-m  
Posted: Thursday, Jun 9 2005, 18:54
Quote Post



Group Icon
Group: Members
Joined: Jul 26, 2002

gr.gif

Member Award




Moving the first file to the end is just a temporary thing. The filename is still in the right place in the directory, so after a proper rebuild, everything is in order again. And rebuilding is recommended anyway after adding lots of files.
Users WebsitePM
  Top
 

 
Un3462  
Posted: Thursday, Jun 9 2005, 19:00
Quote Post


Mack Pimp
Group Icon
Group: Members
Joined: Jun 27, 2002

Member Award




steve? what you said first seems more right to me. block offsets are absolute, not relative at all (at least in script.img). i still don't get why everyone's making such a problem out of this, it's pretty obvious.
PM
  Top
 

 
ThaKilla  
Posted: Thursday, Jun 9 2005, 19:21
Quote Post


I'm not wack, im all wacked-out!
Group Icon
Group: Members
Joined: Sep 17, 2004

us.gif

XXXXX



As I see it.. as long as we make sure to move the first file in the IMG to the end and update the Dir part for it... and as long as all the IMG tools use this idea than there shouldn't be any problems. But hopefully we can find a way to add a new IMG altogether.

Edit: Also we would need to check to see if after the first file move if there is enough space to just add a new dir entry or if we need to move another file.


This post has been edited by ThaKilla on Thursday, Jun 9 2005, 19:25
Users WebsitePMMSNAOLYahoo
  Top
 

 
DexX  
Posted: Thursday, Jun 9 2005, 19:26
Quote Post


Black Hat
Group Icon
Group: Retired Staff
Joined: May 16, 2002

Member Award




im not sure i see the problem; if a new model/col/whatever is added, rebuild the dir in a temporary file, then append the contents of the IMG to that file after the dir and header info, delete the gta3.img, and set the temp file as the new IMG.

or am i missing something?
PM
  Top
 

 
ThaKilla  
Posted: Thursday, Jun 9 2005, 19:39
Quote Post


I'm not wack, im all wacked-out!
Group Icon
Group: Members
Joined: Sep 17, 2004

us.gif

XXXXX



Well with a 300+ MB file it would take 30mins-1hr depending on the speed, where when u just move one file and create a spacer, it will only take a min or two.
Users WebsitePMMSNAOLYahoo
  Top
 

 
steve-m  
Posted: Thursday, Jun 9 2005, 19:41
Quote Post



Group Icon
Group: Members
Joined: Jul 26, 2002

gr.gif

Member Award




QUOTE (CyQ @ Jun 9 2005, 21:00)
steve? what you said first seems more right to me. block offsets are absolute, not relative at all (at least in script.img). i still don't get why everyone's making such a problem out of this, it's pretty obvious.

Ok, I checked again: 522240 bytes before the first file starts. That are exactly 255 blocks, including the 8 byte header. According to the directory, the first file starts at 255, so you are totally right, file offset is absolute.

That means, what I first said applies:

QUOTE
Why do you want to name them? The safest way would be to scan through the file offsets and filter out the lowest. This is where the first file starts, and everything before (except for the header) can be used for the directory, no matter if it was filled with garbage or zeros. On reading, the program would skip the free space anyway. And this would work with every upcoming img tool, no matter if it complies with any standards or not.

No dummy files needed then.

Edit:
QUOTE (ThaKilla @ Jun 9 2005, 21:39)
when u just move one file and create a spacer, it will only take a min or two.

rather a sec or two tounge.gif
Users WebsitePM
  Top
 

 
ThaKilla  
Posted: Thursday, Jun 9 2005, 21:19
Quote Post


I'm not wack, im all wacked-out!
Group Icon
Group: Members
Joined: Sep 17, 2004

us.gif

XXXXX



Ok....

I have edited my GTASA-UE to handle the IMG this way... but i cant test it till i get the game tomarrow. If any of you would like to test it for me than here is the link.

This is BETA and is mainly a proof of concept.

GTASA Ultimate Editor

IF you find any problems let me know, because i used the PS2 Img file to make this.

Edit: To test this you should only have to add some B.S. fiel to the Gta3.IMG and it should move the 1st file to the end and add the B.S. file after it.

This post has been edited by ThaKilla on Thursday, Jun 9 2005, 21:21
Users WebsitePMMSNAOLYahoo
  Top
 

 
Kuiosikle  
Posted: Thursday, Jun 9 2005, 22:54
Quote Post


Who?
Group Icon
Group: Members
Joined: Feb 18, 2004

us.gif

XXXXX



Well, adding files works Killa, I haven't tried replacing any yet though...

user posted image


This post has been edited by Kuiosikle on Friday, Jun 10 2005, 02:51
Users WebsitePMMSNAOLXbox LivePlayStation Network
  Top
 

 
ThaKilla  
Posted: Friday, Jun 10 2005, 02:40
Quote Post


I'm not wack, im all wacked-out!
Group Icon
Group: Members
Joined: Sep 17, 2004

us.gif

XXXXX



I was just looking threw the "DATA" directory of GTASA.. and noticed a file called "gta_quick.dat".. here are some lines from it...

CODE

#
# Load IDEs first, then the models and after that the IPLs
#

IMG DATA\PATHS\CARREC.IMG

#
# Object types
#
IDE DATA\MAPS\generic\vegepart.IDE



well that is a good way to make your own IMG entries. (I Think confused.gif )
Users WebsitePMMSNAOLYahoo
  Top
 

 
DexX  
Posted: Friday, Jun 10 2005, 02:59
Quote Post


Black Hat
Group Icon
Group: Retired Staff
Joined: May 16, 2002

Member Award




i succesfully replaced a file, but my "Add" and "Delete" and grayed out, and unusable..
PM
  Top
 

 
Kuiosikle  
Posted: Friday, Jun 10 2005, 04:14
Quote Post


Who?
Group Icon
Group: Members
Joined: Feb 18, 2004

us.gif

XXXXX



QUOTE (ashdexx @ Jun 9 2005, 22:59)
i succesfully replaced a file, but my "Add" and "Delete" and grayed out, and unusable..

Hmm, that's strange, they are selectable for me..

Killa said he made a few fixes and will release a new version tommorow.

Anyways, did some fooling around;

user posted imageuser posted imageuser posted image

user posted imageuser posted imageuser posted image

Proof of concept?.....


This post has been edited by Kuiosikle on Friday, Jun 10 2005, 06:17
Users WebsitePMMSNAOLXbox LivePlayStation Network
  Top
 

 
JernejL  
Posted: Friday, Jun 10 2005, 06:47
Quote Post


Big Homie
Group Icon
Group: Retired Staff
Joined: Mar 11, 2002

se.gif

Member Award




QUOTE (illspirit @ Jun 9 2005, 19:51)
Not sure I like the idea of moving the first chunk of data to the end to make room for more dir. Might cause some lagging and/or errors while the engine is scanning up and down to find things it expects to be in order. How about if on first opening of the img, the tools force a rebuild to move all the data down a bit? This could be checked via CRC or something to see if the file has been modded yet.

That said, there should (in a perfect world) also be an info box in the status bar somewhere that says how many dir entries are available/total. Whenever it reaches 0/X, the tools could/should/would prompt to rebuild and add entries, maybe even giving an option on how many entries to add. Maybe this check and prompt could also be done on first run instead of a CRC?

not really, gta-sa has to seek to each file offset separately aniway, so there is absolutely no lag, i will also use this block-moving-for-more-dir-room method
in my tools as well, it is the only clean way without rebuilding the whole img,
imagine this like windows' defrag program, file blocks are anywhere..
Users WebsitePMMSN
  Top
 

 
Stretchnutter  
Posted: Friday, Jun 10 2005, 08:50
Quote Post


Also known as Racer_S
Group Icon
Group: Members
Joined: Jun 15, 2002

us.gif

Member Award




my iRipper utitlity rebuilds the whole 900mb IMG file in 120 seconds on my machine.

Its using the same code as the PS2 IMG file.. no changes..so dont expect anything special tounge.gif


(think of it as notepad, you click Save, it rebuilds the whole file with the changes youve made and you can make several changes before saving)


also please note that the VB source is there for the taking if you need to change something. (my site in sig)

This post has been edited by Stretchnutter on Friday, Jun 10 2005, 08:56
Users WebsitePM
  Top
 

 
ThaKilla  
Posted: Friday, Jun 10 2005, 15:17
Quote Post


I'm not wack, im all wacked-out!
Group Icon
Group: Members
Joined: Sep 17, 2004

us.gif

XXXXX



Well I have updated my GTASA-UE. It should be able to edit the DATA files now.

Also I went threw and cleaned up a few things.

GTASA Ultimate Editor
Users WebsitePMMSNAOLYahoo
  Top
 

 

0 User(s) are reading this topic (0 Guests and 0 Anonymous Users)

0 Members:

Pages: (2) [1] 2 

Topic Options Reply to this topicStart new topicStart Poll
Search topic for posted by (exact match)



 
IMG IMG