Hires GPI and the GPH file

Posted by petrus 
Hires GPI and the GPH file
Date: August 20, 2020 04:38PM
Posted by: petrus
Hires GPI and the GPH file

Additional posts
* GPHUpdater - first versions
* Hires gridcar examples
* Implementing the new "Hi_GP2001.gph" file into a CSM mod - step-by-step instruction
* GPH record: horizontal and vertical stretch values
* More GPH file details
* GPHUpdater v.0912
* Hires GPI Tips
* GPI files with subareas and the meaning of the GPH extra bytes


In this thread I will share with you my experience with high resolution GPI files and modifying a GPH file to get a correct display of them.

The first time I took notice of the possibility (and problematic) of hires GPI files was with the IndyCar Series 2017 mod by rracunis. Driver images, gridcars, teamlogos and weather images seemed to be corrupt as I got only garbage display. But rracunis explained to me that the files are not corrupt but high resolution. As I was not the only one with display problems, I added standard resolution GPIs. For the NTT Indycar mod 2020 I made an update including a "Teamart file resolution" selection in the CSM menu to choose between the high and the standard GPIs.

But only recently I got aware of the fact that the high resolution GPI display problem had already been solved. While I checked some downloaded files from the 2019 F1 season I discovered the 2019 Grid Cars Final by gap177 (Glenn). He provided a GP2001.gph file and remarked "If anyone has display issues in game, just copy and paste the file in the folder named 'misc' into >menudata\pc\gp2001" in the thread. I checked it and it worked! This encouraged me to examine how to create a GPH file fitting some hires GPI for the 2019 mod resp. the Indycar 2020 mod. This is described in detail below.

I have read about the GPH file some time ago in the thread Menu editing questions, where Lo2k explained
"All files describing menus are in GP4folder/MenuData/PC/GP2001 folder.
...
gpi files are stored in the images folder and are 32bit pictures (containing an alpha channel).
All menus drawings and pictures are stored in gpi files.
But not all gpis are used by the game, in fact gpis from 388 to 401 are not used cause they are already there in previous gpis.
The tool i talked about on my forum is not a gpm browser but a gpi browser, allowing preview only of all gpi files.

gph file is storing descriptions about gpi files stored in the images folder.
As madman said, you can got there Number of gpis used, gpis ID, width and height and other datas that Madman might be right about even if i never test them personnaly.
...
"
The tool he is talking about is his GPI Browser 1.2 that is a great help while creating specific GPH files.

GPH file

The structure of the GPH file was not hard to understand. The following extract shows four records (you need a hexeditor to reproduce it):
84 01 00 00 00 00 00 00; starting sequence: 00000-00006, offset to record 1 = 9
01 00 00 00 00 00 f0 00 00 00 b4 00 00 00 00 00 00 00 00 00 70 3f 00 00 34 3f 00 00 00 00 00 00 00 00 00 00 00 00 00 00 34 3f 00 00 70 3f  
8d 00 00 00 1e 00 00 01 00 00 d5 00 00 00 00 00 00 00 00 00 80 3f 00 00 55 3f 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 3f 00 00 80 3f 
... 480 bytes area 01afe-01cdd
8e 00 00 00 00 00 80 00 00 00 60 00 00 00 00 00 00 00 00 00 80 3f 00 00 40 3f 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 3f 00 00 80 3f 
83 01 00 00 00 00 c8 00 00 00 96 00 00 00 00 00 00 00 00 00 48 3f 00 00 16 3f 00 00 00 00 00 00 00 00 00 00 00 00 00 00 16 3f 00 00 48 3f
There are some other extra areas besides the one in front of ID 142 with 480 bytes: 32 bytes each in front of 9,10 and 35 , 64 bytes in front of 11 and 256 in front of 43.
You can see a full description in the GPH Offsets Widths Heights text file.

The format is double byte with lowbyte, highbyte order. A hexadecimal value 0200 (=512) is given as "00 02".
387 GPI records are included, each with a length of 46 bytes and offsets for id=0, width=6 and height=10.
Thus I get from the four records:
ID=001 (01 00), width=240 (00 f0), height=132 (b4 00)
ID=141 (8d 00), width=256 (00 01), height=213 (d5 00)
ID=142 (8e 00), width=128 (80 00), height= 56 (60 00)
ID=387 (83 01), width=200 (c8 00), height=150 (96 00)

Now I could edit the values of the GPH file with the hexeditor, but I was more comfortable with using the GPI Browser instead. To get a modified GPH file in a testing environment, I copied my complete GP4 backup folder into a GP4-test folder and directed GPI Browser to it by "Change GP4 path". Now I loaded TGA files with the desired size into the GPIs of the browser window and finished it by pressing the button "Apply all changes", to update the GPH file. As I was only interested into the new width and height of the GPI, the display of the image in the browser didn't matter. Finally I copied the new file GP4_test\MenuData\PC\GP2001\GP2001.gph to the place I wanted it to use.


Creating hires GPI for the 2019 F1 mod

For the 2019 mod V2.2 compiled by MSchumi24 I wanted to test the following hires GPI files:
1) 2019 Grid Cars Final by gap177 (Glenn Perk). Glenn had also provided the standard grid car files of the mod.
2) files 2019 by augustogibim, Grid Cars + Pitcrew&Engineers + Driver Art+ Garages 2019
3) Visors + driver arts + logos + gridcars 2019] by rracunis. He has also provided the standard driver and teamlogo files of the mod.

First I made some changes in the 2019 CSM mod structure to support hires and standard GPI. I did this using the %texres% variable that is defined in the Settings\GlobalVars.ini file for texture resolution selection to support GPI file resolution also. %texres% can have the values "Hi" and "Std". In the "Teamart" subfolders "Drivers", "Gridcars", and "Logos" I created new subfolders "Hi" to contain the new hires GPI files.
In the "2019.csm" file I changed the following line of section [Files]:
TeamArt             	=Teamart\teamart-%texres%.ini
and in the folder "Teamart" I created two new INI files: "teamart-std.ini" with the same content as "teamart.ini" and "teamart-hi.ini". In "teamart-hi.ini" I replaced "Drivers\" with "Drivers\%texres%\", "Logos\" with "Logos\%texres%\" and "Gridcars\" with "Gridcars\%texres%\". In the 2019 F1 mod the teamart helmets were disabled by using empty GPI files.

In the Settings\swap.ini files section [Swapfiles] I added the line
File20	=Menu\%texres%_GP2001.gph,MenuData\PC\GP2001\GP2001.gph
Now, if texture resolution is set to "Hi" in the CSM menu, the GPH file was swapped.

1) 2019 Grid Cars Final][/url] by gap177 (Glenn Perk).
This release had GPI files for gridcars in two versions: drivernames.gpi for CSM, gpi-number.gpi for Non-CSM. TGA files were not included, but a GPH file. I did a hexeditor compare with the original GPH file to see what was changed.

Logos (default 80 00, 60 00 = 128x96px)
with new width 00 02 = 512px, height 80 01 = 384px for GPI ID numbers
 31 00 =  49
 32 00 =  50
 33 00 =  51
 8e 00 = 142
 8f 00 = 143 			
 90 00 = 144
 91 00 = 145
 92 00 = 146
 93 00 = 147
 94 00 = 148
 95 00 = 149
Gridcars (default: C8 00, 31 00 = 200x49px)
with new width 90 01 = 400px, height 77 00 = 119px for GPI ID numbers
 b2 00 = 178
 b3 00 = 179
 b6 00 = 182
 b7 00 = 183
 b8 00 = 184
 b9 00 = 185
 ba 00 = 186
 bb 00 = 187
(bc 00 = 188 for team11 is intentionally not changed)
 bd 00 = 189
 be 00 = 190

This GPH was not only designed for hires gridcars, but for hires teamlogos also, though GPI files for logos were not included. The gridcar height of 119 was unexpected but worked. The usual value would have been 99.

I copied the GPH file into folder Menu and renamed it to "Hi_GP2001.gph".
Then I copied the new hires gridcar GPI files from Glenn into the "Gridcars" subfolder "Hi". Here I had to be careful and check if the team names fit in the mod. Three names had to be adjusted: "Alfa Romeo" to "AlfaRomeo", "Racing Point" to "RacingPoint" and "Red Bull" to "RedBull". Finally I copied the file "team11.gpi" from folder "Std" to folder "Hi".

Now I started the mod with "Texture resolution" set to "Hi" and "Race Type" set to "Non Championship Race" to get the grid displayed. After starting a race, I admired the beautiful hires gridcars. Back to the main menu I selected a driver. The teamlogo was not shown in the background because of the wrong size in the GPH, but that was no big deal. After I quit GP4 and started the mod again with "Texture resolution" set to "Standard", the teamlogo - in standard size - was shown correctly.

2) "files 2019" by augustogibim, Grid Cars + Pitcrew&Engineers + Driver Art+ Garages 2019
From this archive I used "Drivers 2019.rar" and "Gridcars 2019.rar". Included were only TGA files, no GPI or GPH. The files were provided in two versions: one for 4:3 and one for widescreen. I took the 4:3 images, but the process is the same with the widescreen part. Driver images had a size of 512x512px while the gridcars were special: they had a view from above and a size of 1200x300px. From TGA I created GPI using Slimtex. The names of the drivers were only 3 characters long, so the drivers GPI files had to be renamed to fit the mod. The gridcar names were almost perfect, only "racingp" had to be changed to "racingpoint".

Now I created the GPH file. First I copied the default GP2001.gph file from my backup folder into my GP4-test folder MenuData\PC\GP2001\ to have a clean start. Then I loaded a driver TGA file in GPI Browser over all driver GPI (33, 55-56, 60-64, 66, 68, 70, 72, 74-75, 193, 268-273, 304) and a gridcar file over all gridcar GPI (178-179,182-190). Finally I pressed "Apply all changes", copied the modified GPH to the 2019 mods Menu folder and renamed it to "Hi_GP2001.gph". A look into the GPH file showed that the driver GPI width and height were both set to 00 02 (=512) while the gridcar GPI width and height are b0 04 (=1200) resp. 2c 01 (=300).

I replaced the files in Teamart\Drivers\Hi and Teamart\Gridcar\Hi with the new GPI. Now I started the mod with "Texture resolution" set to "Hi" and and "Race Type" set to "Non Championship Race" and tested the resulting displays.

3) "Visors + driver arts + logos + gridcars 2019" by rracunis.
I used the "Gridcars 1.0" (HD and Normal, GPI and TGA files) and the "Teamart 2019" (GPI only) with hires "Drivers" and "Logos" providing two hires versions, one in the subfolder HD. The normal gridcars had a size of 200x49px as usual, while the HD gridcars had the size 400x99px. Drivers were sized 512x512px, which was also true for the HD logos. The latter surprised me a bit. Because the standard size for teamlogos is 128x96px I expected something like 512x384px (4x).

In "Drivers" and "Logos" I created one TGA file using Slimtex. Then I generated the GPH file using GPI Browser and the TGA files. Now I made a backup of the original gridcars "Std" folder and copied the GPI files into their mod folder. Finally I started the mod and tested the result.

Six driver images and eight gridcars were corrupt and the logos were not shown. The research showed: I had not updated the drivers GPI 268-273 with GPI Browser, I had forgotten to rename the gridcar names of the double word teams and I had forgotten to edit the [logos] section in the teamart.ini file. Second try after correction: drivers and gridcars ok, but logos were not shown. Something was wrong with the GPH size I suggested. I created TGA files of other sizes (400x300, 512x384), imported them with GPI Browser into the logos GPI, but it didn't work either.

Finally I gave up and used the other GPI logos from the main folder "Logos" of rracunis files that were correct displayed in Slimtex - in contrast to the HD logos. These 512x512px logos worked with a GPH size of 512x512px as well as 512x384px and I could at last enjoy the enhanced display.

2019 F1 mod teamart hires update
In the original mod the authors of the standard files are:
Teamart
-Drivers		rracunis
-Helmets		(nohelmets)
-Gridcars		Glenn Perk
-Logos			rracunis
It is therefore reasonable to take the hires files from the same authors and update the mod with them in the way I explained above. As the rracunis files are already loaded, all I had to do was to take the backup "Std" folder for gridcars and put Glenn's hires gridcars into the "Hi" folder. I could use the same GPH as above because the GPH size 400x99px worked with Glenns hires gridcars also.

Download:2019 F1 mod teamart hires update


Creating hires GPI for the Indycar2020 mod

The NTT Indycar mod 2020 compiled by rracunis had already got hires and lowres teamart GPI files (Drivers, Gridcars and Logos) and a "Teamart resolution" selection in the CSM menu. On my computer the hires GPI was displayed disturbed so I always had to play with low resolution ('Med';) teamart. With the implementation of the GPH file I hoped to make all the hires files visible to me.

The driver images with a hires format of 512x512px made no problem. This was different with the gridcars, logos and weather (in folder 'Data\Files\Weather\Hi';) hires GPI:
type        standard    hires gpi   gph size    result
drivers     256x256     512x512     512x512     okay	
gridcars    200x49      512x512     512x512 ?   no
                                    512x125 ?   no
                        400x99                  okay
logos       128x96      512x512     512x384 ?   no
weather:
124-139     160x128     512x512     480x384 ?   no
                                    320x356 ?   no
131         244x128     512x512     488x256 ?   no
132         256x32      512x512     512x64  ?   no
                                    400x50  ?   no
While I was successful with the gridcars GPH size 400x99 (90 01, 63 00) over a 512x512 GPI file, all my effort to get the logos and/or weather hires files displayed properly was in vain. Finally I decided to replace those GPIs. Fortunately I had got weather files from rracunis for a previous Indycar mod. The hires logos I made myself. This worked:

type        standard    hires gpi   gph size    result
logos       128x96      512x384     512x384     okay
weather:
134-139     160x128     640x512     640x512     okay
131         244x128     488x256     488x256     okay
132         256x32      256x512     256x512     okay

Downlaod: Indycar 2020 mod teamart and weather hires update

Summary

As a conclusion of this experience I can say that it feels good to be able to see the hires GPI now.
The size of hires GPI files should in general have the same aspect ratio than the corresponding original GPIs to avoid problems.
It is good for the user if TGA files are provided in a hires GPI release.

Several questions are remaining:
a) Why have some users hires GPI display problems on their computer but others do not?
b) Does a correct GPH file solve all problems or are there still users that cannot see all hires GPIs.
c) Why is it sometimes possible to display a GPI that has a size (i.e. 512x512) different from the GPH size (i.e. 400x99) and sometimes not?

GPH Information
Information for GPH file creation. The hires sizes are just examples.

Drivers 
driver images are shown in driver selection and driver gpaedia.
gpi 33, 55-56, 60-64, 66, 68, 70, 72, 74-75, 193, 268-273, 304
Default: 256x256 px	00 01, 00 01
Hires:	 512x512 px	00 02, 00 02

GPI	ID	Offset	Driver
033 = 21 00	00648	01
055 = 37 00	00B62	09
056 = 38 00		10
060 = 3C 00		11
061 = 3D 00		02
062 = 3E 00		08
063 = 3F 00		04
064 = 40 00		18
066 = 42 00	00D56	07		
068 = 44 00	00DB2	15
070 = 46 00	00E0E	17
072 = 48 00	00E6A	05
074 = 4A 00	00EC6	12
075 = 4B 00		13
193 = C1 00	02608	03
268 = 0C 01	03382	20
269 = 0D 01		19
270 = 0E 01		14
271 = 0F 01		22
272 = 10 01		06
273 = 11 01		16
304 = 30 01	039FA	21
-------------------------------------

Helmets
A teamart helmet is shown in the background of the driver gpaedia.

gpi 195,199-218,336
Default: 64x64 px	40 00, 40 00 
Hires:	256x256		00 01, 00 01 

GPI	ID	Offset	Driver
195 = C3 00	02664	04
199 = C7 00	0271C	14
200 = C8 00 		17
201 = C9 00		01
202 = CA 00		19
203 = CB 00		07
204 = CC 00		21
205 = CD 00		11
206 = CE 00		08
207 = CF 00		06
208 = D0 00		12
209 = D1 00		13
210 = D2 00		09
211 = D3 00		16
212 = D4 00		22
213 = D5 00		03
214 = D6 00		15
215 = D7 00		10
216 = D8 00		18
217 = D9 00		02
218 = DA 00		05
336 = 50 01	03FBA	20
-------------------------------------
	
Logos 
A teamlogo is shown in the background of the selected driver.

gpi 49-51, 142-149
Default: 128x96 px	80 00, 60 00
Hires:   512x384 px	00 02, 80 01	

GPI	ID	Offset	Team 		
049 = 31 00	00A4E	05
050 = 32 00		04
051 = 33 00		01
142 = 8E 00	01CE4	09
143 = 8F 00		06
144 = 90 00		02
145 = 91 00		10
146 = 92 00		11
147 = 93 00		08
148 = 94 00		03
149 = 95 00		07
-------------------------------------

Gridcars
Gridcars are shown at the start of a championship or non championship race.

gpi 178-179,182-190
Default: 200x49px	C8 00, 31 00
Hires examples: 
* 400x119	90 01, 77 00
* 400x99	90 01, 63 00
* 1200x300	B0 04, 2C 01 (view from above)

GPI	ID	Offset	Team
178 = B2 00	02356	01
179 = B3 00		02
182 = B6 00		03
183 = B7 00		05
184 = B8 00		04
185 = B9 00		09
186 = BA 00		06
187 = BB 00		10
188 = BC 00		11
189 = BD 00		08
190 = BE 00		07
-------------------------------------

Weather
Weather images are shown at the start of a (championship or non championship) race.

gpi-num			default	                	hires
gpi 124-130,133-139	160x128 px	00 A0, 00 80	640x512
gpi 131			244x128 px	00 F4, 00 80	488x256
gpi 132		 	128x64  px	00 40, 00 80	256x512 

Nr.	ID	Offset 	
124 = 7C 00	017C2
125 = 7D 00
126 = 7E 00
127 = 7F 00
128 = 80 00
129 = 81 00	
130 = 82 00
131 = 83 00
132 = 84 00
133 = 85 00
134 = 86 00
135 = 87 00
136 = 88 00
137 = 89 00
138 = 8A 00
139 = 8B 00


petrus' gpaedia files



Edited 20 time(s). Last edit at 10/13/2021 03:32PM by petrus.
Re: Hires GPI and the GPH file
Date: August 20, 2020 07:27PM
Posted by: MSchumi24
Nice tutorial, thanks Peter, also for the update of my mod! (Y)



Edited 1 time(s). Last edit at 08/20/2020 07:29PM by MSchumi24.
Re: Hires GPI and the GPH file
Date: August 20, 2020 08:51PM
Posted by: Turbo Lover
Amazing find, just fantastic.



My Grand Prix 4 Files

I'm a total dick. How many people can say that?
Re: Hires GPI and the GPH file
Date: August 20, 2020 10:04PM
Posted by: Carl_gpgames
that's fantastic, thanky you very much!!! is there a similar way to improve the ingame graphics' resolution (starting lights for example)? because they don't work if i use any other resolution than the original one.



GP Files | GP Videos | Discord: Carl_gpgames#2350
Re: Hires GPI and the GPH file
Date: August 20, 2020 11:09PM
Posted by: quickslick
that's awesome from you Peter, thank you very much for this :)
Re: Hires GPI and the GPH file
Date: August 21, 2020 12:12AM
Posted by: AugustoGibim
Can grid cars be in hires?
I made these at 1200 x 300px
Re: Hires GPI and the GPH file
Date: August 21, 2020 01:37AM
Posted by: petrus
AugustoGibim: Can grid cars be in hires? I made these at 1200 x 300px (https://i.imgur.com/dVZORpx.jpg?1)

Yes they can. That's was this thread is about.
I have tested your files (as explained in the first post, 2019 F1 mod, part 2) and with the adjusted GPH file they worked - both normal and widescreen.
The look from above is a very interesting idea.


petrus' gpaedia files



Edited 3 time(s). Last edit at 08/22/2020 10:50PM by petrus.
Re: Hires GPI and the GPH file
Date: August 22, 2020 11:14PM
Posted by: petrus
The 1200x300 format does not seem to be the best choice. Compare them with the downsized 400x99, which is the more usual hires format. The latter is looking better.
The third image is an hires example with 400x99 images from Glenn.

1200x300 gridcars by augustogibim


Downsized to 400x99


400x99 gridcars by gap177 (Glenn)



petrus' gpaedia files
Re: Hires GPI and the GPH file
Date: August 26, 2020 03:54PM
Posted by: petrus
And the story continues.

I didn't feel comfortable with the GPIBrowser 1.2 while testing different GPH files with the 2019 f1 CSM mod.
To get the GPH quicker I decided to make my own tool. You can already download and try a beta version:

GPHUpdater_0827.zip

First I read the GPH records structure using my tool "GPHRecords" (also included in the download archive).
The output in file "GPH_Offsets.txt" looked like
ID  ID_Hex Offset   Length             width  height  aspect ratio
1   0001   00000A   10                 0000   0000    0x0
2   0002   000036   44                 0008   0008    8x8
3   0003   000064   46                 0020   0020    32x32
4   0004   000092   46                 0100   0100    256x256
5   0005   0000C0   46                 0002   0002    2x2
6   0006   0000EE   46                 0100   0100    256x256
7   0007   00011C   46                 0010   0010    16x16
8   0008   00014A   46                 0040   0040    64x64
9   0009   000198   78  = 32 + 46      0010   0008    16x8
10  000A   0001E6   78  = 32 + 46      0010   0010    16x16
11  000B   000254   110 = 64 + 46      0100   0020    256x32
12  000C   000282   46                 0080   0100    128x256
13  000D   0002B0   46                 0100   00EB    256x235
14  000E   0002DE   46                 0100   0100    256x256
15  000F   00030C   46                 0100   0100    256x256
16  0010   00033A   46                 0100   0100    256x256
...
See complete file: GPH Offsets Widths Heights.

I had to accept that my first assumptions about the GPH file structure were too premature.
There are more extra areas between the 46 byte long records than I had realized at first. So I edited my first post in this thread with the new data.

The offset values were useful as I made an offset array for the GPHUpdater program, that allowed quickly pointing to the ID records start position. Thus the first part of the GPHUpdater creation - 1) Making the program work - was soon done: version 0.825. The remaining parts were
2) Making the program user friendly
3) Making the program error resistent

For part 2 I opted for a flexible way. I refused hardcoding some often used GPH parts like drivers, gridcars, logos. Instead I chose to allow the user to define his own ID lists in the controlling INI file which made it possible to update every part of the GPH. As a more comfortable way to define those lists I included the possibilities of defining variables for them and of shortening consecutive id values. The new width and height values are written in a familiar way like an image resolution.
As an example a part of the "gph.ini" (in \Size the backslash has to be omitted):
...
[Vars]
drivers = 33,55,56,60-64,66,68,70,72,74,75,193,268-273,304 
;helmets = 195,199-218,336
logos = 49-51,142-149
gridcars = 178,179,182-190

[\Size]
%drivers% = 512x512
;%helmets% = 256x256
%logos% = 512x384
%gridcars% = 400x99
;131 = 488x256
;132 = 256x512
Result: program version 0.826

Part 3 was testing and testing again. I realized a problem with readonly GPH files and included a checking routine. Checking was also done for valid specifications, maximum id list length (which I set to 32), id values out of range 1 to 387 and width resp. height values out of range 1 to 4096 (intentionally set as maximum).
Unfortunately the resulting program version 0.827 didn't work properly yet.
EDIT 2020-08-27: problem fixed; version 0.827 available as "GPHUpdater.exe" in the download archive.

As I have used the program only for a short time it is still kind of a "beta" release.
I hope it is useful for someone else anyway.


petrus' gpaedia files



Edited 12 time(s). Last edit at 10/27/2020 06:24PM by petrus.
Re: Hires GPI and the GPH file
Date: August 26, 2020 04:49PM
Posted by: Turbo Lover
Incredible work, thanks.



My Grand Prix 4 Files

I'm a total dick. How many people can say that?
Re: Hires GPI and the GPH file
Date: August 27, 2020 12:02PM
Posted by: petrus
Implementing the new "Hi_GP2001.gph" file into a CSM mod - step-by-step instruction.

Examples are valid for the 2019 F1 mod.
The following procedure preassumes that in the CSM mods globalvars.ini file a variable [texres] is defined with a selection for resolutions "Std" and "Hi".

First let the mod use the new gph (steps 1 and 2):

1) Put the gph file into one of the mods folders
gph folder: "Menu", path = Menu\Hi_GP2001.gph

2) Add a line in "Settings\swap.ini" section [Swapfiles].
File20 =Menu\%texres%_GP2001.gph,MenuData\PC\GP2001\GP2001.gph
The number behind "File" may have to be adjusted.
With %texres% set to "Hi" the GPH file will be swapped.
With %texres% = "Std" a file "Std_GP2001.gph" does not exist and no swap is done.

Now adjust the teamart processing (steps 3 to 5):

3) In the main CSM file - e.g. "2019.CSM" - edit line "TeamArt" in section [Files]:
TeamArt	=Teamart\teamart-%texres%.ini

4) In folder "Teamart" create two new INI files:
"teamart-std.ini" with the same content as the old "teamart.ini" is for the standard resolution specifications;
"teamart-hi.ini" - temporary also a copy of "teamart.ini" - to contain the necessary specifications for hires GPI.

5) Edit "teamart-hi.ini".
For every hires GPI the specification must point to the subfolder "Hi" like
File1 =Gridcars\Hi\%team01%.gpi
...

Alternative

If you want to have the GPI resolution independent from the texture resolution. then in the Settings/Globalvars.ini file create a new selection, lets say "gpires":
[gpires]
Allowchange	=1
Name			=GPI File Resolution
VarCount		=2
Var1			=Hi
Var2			=Std
VarName1		=High
VarName2		=Standard

Now you can implement the GPH the same way as above with %gpires% taken instead of %texres%.


petrus' gpaedia files



Edited 4 time(s). Last edit at 04/11/2022 06:58PM by petrus.
Re: Hires GPI and the GPH file
Date: September 15, 2020 04:13PM
Posted by: 32BOBO32
Hi petrus, do you think that this trick may work also for GPF (font) files?

Samuele
32BOBO32
Re: Hires GPI and the GPH file
Date: September 15, 2020 08:30PM
Posted by: petrus
32BOBO32: Do you think that this trick may work also for GPF (font) files?

I don't think so. As far as I know the GPH file is related to GPI (numbers 1 to 387) files only.


petrus' gpaedia files
Re: Hires GPI and the GPH file
Date: September 19, 2020 12:37PM
Posted by: TomMK
Really nice work.

=====================================================


Intel NUC 8i3, 8GB RAM, MS Sidewinder Wheel
Re: Hires GPI and the GPH file
Date: October 06, 2020 04:32PM
Posted by: petrus
GPH record: horizontal and vertical stretch values

Until now I have only used the ID with the width and height values. But there is still more to be discovered. As an example I will examine the record of the driver01 GPI in the GPH file:

ID=33, length = 46 byte (00 to 45)
21 00 00 00 00 00 00 01 00 00 00 01 00 00 00 00 00 00 00 00 80 3f 00 00 80 3f 00 00 00 00 00 00 00 00 00 00 00 00 00 00 80 3f 00 00 80 3f  
meaning  hex     dec     offset	
ID       21 00    33     00-01
width    00 01   256     06-07
height   00 01   256     10-11
?        80 3f           20-21
?        80 3f           24-25
?        80 3f           40-41
?        80 3f           44-45
What is the meaning of the four 80 3f hex values in the record?

A very useful hint was once given by madman271 in the GP4Italia forum:

Remind me if I'm wrong.
Menu textures perhaps stored in *.gpi files. You can obtaining *.gpi information from *.gph or *.gpm file (these files seem to be identical). I'm just looking on the *.gph file and there was stored the *.gpi ID number, dimension (width and height), as well as position and dimension in screen in float values. These values similar like when we using UV mapping, mean minimum value is 0.0 and maximum value is 1.0.
Hope this is help.


First I am searching for "floating point hexadecimal" and found the IEEE-754 Floating Point Converter.
Here into the field "Hexadecimal Representation" I wrote 0x3f800000 to see which value 3f80 is representing. Result = 1.0 .
Okay, then if the values are between 0 and 1 as madman271 guessed, what will be the hexadecimal representation of 0.5? Result = 0x3f00.

The two values 1 (80 3f) and 0.5 (00 3f) should be enough for a first test. I created a framed 33.gpi and checked all combinations of this two values in the four record positions using a hex editor. While the last two positions (40-41, 44-45) had effects on the display of the GPI file, the first two did not. Depending on the last two values this is what I got:

80 3f - 80 3f, normal


00 3f - 80 3f


80 3f - 00 3f


00 3f - 00 3f


The images show, that the value 0.5 (00 3f) stretches upper resp. left half to fill the full image area.
The first value makes vertical, the second horizontal stretching.

Wouldn't it be nice to get an image not stretched but compressed in a way that it compensates the widescreen (16:9) stretching?
If a value between 0 and 1 makes a stretching, can I make a compression with a value greater than 1?.
Lets evaluate: to come down from 16:9 to standard 4:3 one has to multiply with 3/4. The GPH stretching factor is the reciprocal value 4/3 (when 0.5 does double stretching, a value 2.0 = 00 40 should do compressing to half size). My wanted value is 4/3 = 1.3333..., thus I put 1.3333 into the floating point converter and get the hexadecimal representation 0x3faaa993. This gives me "aa 3f" (or "ab 3f", that makes not a great difference) as horizontal stretching value. I put it into the GPH file:

80 3f - aa 3f

Yes, it works! But what about the white area at the right?
Well, I had made a white 1px frame aroung the driver image. Apparently the rightmost 1px column is taken to fill the space that is left by the compression.
I deleted that column (I always use Paint.NET for tga editing) to transparency and displayed the image again, this time in 16:9 screen resolution:

80 3f - aa 3f widesrceen stretch compensated


Compare this with the normal not compensated widescreen display:
80 3f - 80 3f, widescreen stretched


This is a satisfying result and I will now go on and update the GPHUpdater tool to support the stretching values.


petrus' gpaedia files



Edited 2 time(s). Last edit at 04/11/2022 06:58PM by petrus.
Re: Hires GPI and the GPH file
Date: October 06, 2020 05:42PM
Posted by: 32BOBO32
WOW petrus! This is a really great reverse engineering! Congratulation!

Samuele
32BOBO32



Edited 1 time(s). Last edit at 10/07/2020 08:01AM by 32BOBO32.
Re: Hires GPI and the GPH file
Date: October 06, 2020 08:27PM
Posted by: Carl_gpgames
that's a real great improvement! thank you Peter!



GP Files | GP Videos | Discord: Carl_gpgames#2350
Re: Hires GPI and the GPH file
Date: October 07, 2020 07:43AM
Posted by: petrus
Thanks.
@Samuele: could you please delete the citation. I think it is unnecessary and disturbs the readability of the thread.


petrus' gpaedia files
Re: Hires GPI and the GPH file
Date: October 07, 2020 08:02AM
Posted by: 32BOBO32
Done ;)

Samuele
32BOBO32
Re: Hires GPI and the GPH file
Date: October 12, 2020 03:13PM
Posted by: petrus
More GPH file details

Lets go back to the GPH record of the 33.gpi for driver01:
21 00 00 00 00 00 00 01 00 00 00 01 00 00 00 00 00 00 00 00 80 3f 00 00 80 3f 00 00 00 00 00 00 00 00 00 00 00 00 00 00 80 3f 00 00 80 3f
The meaning of the 2-byte numbers for ID, width and height is understood.
The other four I have marked as 4-byte values instead of 2-byte. The reason for this is that they are actually single precision floating point values and therefore use 32 bit = 4 bytes each. I recognized it because the value 1 is represented by hex 3F80, more precisely written as 3F800000.

What will happen if the 00 00 in front of the 80 3F are changed in one of the last two values? Does it have any effect? I made the stretching test with the driver01 image again, but this time instead of just 3FAA I used 3FAAA993. With the hexeditor I changed the last four bytes of the GPI record to "93 A9 AA 3F" in the GPH file. Then I run GP4, made a screenshot of the driver image display and compared it with the one gotten from "3FAA". There was a tiny difference, not more than a 1px column. This proved that the two additional bytes have an effect, but it is almost invisible. Actually in the GPH file these bytes are "00 00" in every GPI record. I will stick to this with the new GPHUpdater, so this result just gives a deeper understanding of the record structure.

While working on the new GPHUpdater version I also made a new GPHRecords tool. This is the output of the first 16 records after processing the GP2001.gph:
ID  ID_Hex Offset   Length   width  height  asp.ratio  dimension   vdim hdim   dimh dec   dimv dec    asp.quot  dim quot
           000000 8 byte init
1   0001   000008   8        00F0   00B4    240x180    3F70 3F34   3F34 3F70   0.9375     0.703125    1.333333  1.333333 
2   0002   000036   46       0008   0008    8x8        3F80 3F80   3F80 3F80   1          1           1         1        
3   0003   000064   46       0020   0020    32x32      3F80 3F80   3F80 3F80   1          1           1         1        
4   0004   000092   46       0100   0100    256x256    3F80 3F80   3F80 3F80   1          1           1         1        
5   0005   0000C0   46       0002   0002    2x2        3F80 3F80   3F80 3F80   1          1           1         1        
6   0006   0000EE   46       0100   0100    256x256    3F80 3F80   3F80 3F80   1          1           1         1        
7   0007   00011C   46       0010   0010    16x16      3F80 3F80   3F80 3F80   1          1           1         1        
8   0008   00014A   46       0040   0040    64x64      3F80 3F80   3F80 3F80   1          1           1         1        
           000178 32 bytes
9   0009   000198   78       0010   0008    16x8       3F80 3F00   3F00 3F80   1          0.5         2         2        
           0001C6 32 bytes
10  000A   0001E6   78       0010   0010    16x16      3F80 3F80   3F80 3F80   1          1           1         1        
           000214 64 bytes
11  000B   000254   110      0100   0020    256x32     3F80 3E00   3E00 3F80   1          0.125       8         8        
12  000C   000282   46       0080   0100    128x256    3F00 3F80   3F80 3F00   0.5        1           0.5       0.5      
13  000D   0002B0   46       0100   00EB    256x235    3F80 3F6B   3F6B 3F80   1          0.9179688   1.089362  1.089362 
14  000E   0002DE   46       0100   0100    256x256    3F80 3F80   3F80 3F80   1          1           1         1        
15  000F   00030C   46       0100   0100    256x256    3F80 3F80   3F80 3F80   1          1           1         1        
16  0010   00033A   46       0100   0100    256x256    3F80 3F80   3F80 3F80   1          1           1         1        
...
The complete file: GPHOffsets.txt
To give credit to madman271 I took his name "dimension" for the floating point values.

For every record I compared the aspect-ratio quotient with the dimension-quotient. For example in record 1 this is 240:180 and 3F700000=0.9375 : 3F340000=0.703125. As you can see, the two quotient values are equal, and this is the case for all GPI records with a few exceptions due to small conversion errors.
This means that the first dimension values are the floating point representation of the (original GPH) aspect ratio = width:height. Their order is therefore width dimension, height dimension. The latter dimension values are in the original GPH file identical to the first ones, but the order is reverse (height, width). If edited you may get an stretching- resp. compressing-effect on the images display.

Record summary:

meaning         hex             dec     offset	
ID              21 00            33     00-01
width           00 01           256     06-07
height          00 01           256     10-11
dim-width org.  00 00 80 3f     1.0     18-21
dim-height org. 00 00 80 3f     1.0     22-25
dim-height      00 00 80 3f     1.0     38-41
dim-width       00 00 80 3f     1.0     42-45


petrus' gpaedia files



Edited 8 time(s). Last edit at 04/11/2022 06:52PM by petrus.
Sorry, only registered users may post in this forum.

Click here to login

Maintainer: mortal, stephan | Design: stephan, Lo2k | Moderatoren: mortal, TomMK, Noog, stephan | Downloads: Lo2k | Supported by: Atlassian Experts Berlin | Forum Rules | Policy