GMP rotator - Rotate your map by 90°, 180° or 270°
GMP rotator - Rotate your map by 90°, 180° or 270°
Hi!
I'm developing a GMP rotator. It already rotates:
- Block positions
- Block tile lids
- Block tile sides
- All types of slopes
- Road arrows (green & red) & field arrows (for trains)
- Light coordinates
- Zone coordinates
The source code is here: https://github.com/Valps/gta2-gmp-rotator
Downtown, Residential and Industrial singleplayer maps rotated ready to play:
For now it only rotates uncompressed maps, but I can make it rotate compressed gmps when I understand how GTA2 maps are compressed. There are official docs and some GTA2 source code decompiled, but I gonna take a break for now.
Also, it uses python. I know that it's possible to create executables from python, but for now if you have python installed, you can use the GMP rotator.
EDIT: I developed a program which rotates xyz and rotation parameters in gta2 script. The source code is also here.
I'm developing a GMP rotator. It already rotates:
- Block positions
- Block tile lids
- Block tile sides
- All types of slopes
- Road arrows (green & red) & field arrows (for trains)
- Light coordinates
- Zone coordinates
The source code is here: https://github.com/Valps/gta2-gmp-rotator
Downtown, Residential and Industrial singleplayer maps rotated ready to play:
For now it only rotates uncompressed maps, but I can make it rotate compressed gmps when I understand how GTA2 maps are compressed. There are official docs and some GTA2 source code decompiled, but I gonna take a break for now.
Also, it uses python. I know that it's possible to create executables from python, but for now if you have python installed, you can use the GMP rotator.
EDIT: I developed a program which rotates xyz and rotation parameters in gta2 script. The source code is also here.
Last edited by valps on 05 Mar 2025, 23:27, edited 8 times in total.
Re: GMP rotator - Rotate your map by 90°, 180° or 270°
This can be really disorienting, but it gives some variation to the classical maps.
In TDC, i've implemented rotating camera to follow your orientation that also feels weird and you really need to get used to it.
In TDC, i've implemented rotating camera to follow your orientation that also feels weird and you really need to get used to it.
Re: GMP rotator - Rotate your map by 90°, 180° or 270°
You "stole" my idea valps.
I wanted to do this years ago but got stuck and left it. I guess im lazy.
Im just too busy with working on my Youtube channels.
Need to grow the income and stuff.
No time to code so much.
Compression / decompression is easy in GTA2.
If you use C++ then youre fine.
Hint: use std::map and std::vector for compression.
std::map is to get unique blocks and columns and vector to store array of blocks.
But of course you need to write custom sorter for std::map, just use block_info struct memmbers as struct for sorter.
I have source pieces for this too. If its confusing
I wanted to do this years ago but got stuck and left it. I guess im lazy.
Im just too busy with working on my Youtube channels.
Need to grow the income and stuff.
No time to code so much.
Compression / decompression is easy in GTA2.
If you use C++ then youre fine.
Hint: use std::map and std::vector for compression.
std::map is to get unique blocks and columns and vector to store array of blocks.
But of course you need to write custom sorter for std::map, just use block_info struct memmbers as struct for sorter.
I have source pieces for this too. If its confusing
Always wear safety glasses while programming.
Re: GMP rotator - Rotate your map by 90°, 180° or 270°
Sorry, I didn't know that. After managing to get PSX tiles from .sty binary, I wanted to explore even more the power of python, and rotating maps was a longing for me for a long time.B-$hep wrote: ↑14 Feb 2025, 18:22 You "stole" my idea valps.
I wanted to do this years ago but got stuck and left it. I guess im lazy.
Im just too busy with working on my Youtube channels.
Need to grow the income and stuff.
No time to code so much.
Compression / decompression is easy in GTA2.
If you use C++ then youre fine.
Hint: use std::map and std::vector for compression.
std::map is to get unique blocks and columns and vector to store array of blocks.
But of course you need to write custom sorter for std::map, just use block_info struct memmbers as struct for sorter.
I have source pieces for this too. If its confusing
My gmp rotator only doesn't rotate junctions, which stills elusive for me.
My next desire is to port the PSX maps to PC. Just knowing how to get block info from compressed data is enough.
Re: GMP rotator - Rotate your map by 90°, 180° or 270°
is cmap not same as DMAP but 16 / 32 bit lookup for blocks?
it even says so in documentation:
In a CMAP, there is a limit of 65536 distinct blocks in the world. In a DMAP, the limit is 131072 blocks.
Code: Select all
CMAP version :
struct col_info
{
UInt8 height;
UInt8 offset;
[b] UInt16 blockd[variable size - see height];[/b]
};
DMAP version :
struct col_info
{
UInt8 height;
UInt8 offset;
[b] UInt16 pad;
UInt32 blockd[variable size - see height];[/b]
};
does gta2 map editor not load cmap and dmap?
So.. compressed cmap is basically 256 * 256 16 bit lookup table of columns (called base)
followed by 16 bit nuber of all columns structures
followed by column structures of varying lengths. and then table of blocks
base is lookup into columns and column specifies which blocks are in it.
i guess you could just convert CMAP into dmap (16 bit structs into 32 bit structs) and map editor could load it.
Re: GMP rotator - Rotate your map by 90°, 180° or 270°
DMA map editor can load CMAPs but the gmp format of PSX files are a bit different from PC version (besides using 16 instead of 32) in a way that it can't load them. I guess it's because the gmp format has changed after releasing the PSX version of GTA2.JernejL wrote: ↑15 Feb 2025, 08:39
does gta2 map editor not load cmap and dmap?
So.. compressed cmap is basically 256 * 256 16 bit lookup table of columns (called base)
followed by 16 bit nuber of all columns structures
followed by column structures of varying lengths. and then table of blocks
base is lookup into columns and column specifies which blocks are in it.
i guess you could just convert CMAP into dmap (16 bit structs into 32 bit structs) and map editor could load it.
As to decompression stuff, yesterday I was struggling to:
1: calculate number of blocks per column, so I get each column byte size;
2: calculate the total number of columns of the map.
I solved the first item by looking at some fully decompiled functions of GTA2. I knew it was something to do with subtracting offset from height, but without solving the second item I was getting errors and thus I thought I have not solved the first item.
To solve the second item I just need to interpretate what is the word/dword stored in data section for each (x,y). I thought it would be the column index, but actually it is an word/dword offset.
Then I finally managed to read block info from DMAP and I guess read from PSX CMAP also. Now I will rebuild the compressed data into an uncompressed map using all columns info. I will let the DMA editor to re-compress it into a valid .gmp file. I'm closer to port the PSX maps.
EDIT:
The column array data of the PSX gmp files has 1024 null bytes (padding?) before the block info array. Perhaps it's one of the reasons DMA editor don't open PSX gmp files (besides don't having a GBMP header). Also, the size of the CMAP chunks for some reason is completely wrong.
I got to read block info from PSX files but the columns positions are wrong.
Re: GMP rotator - Rotate your map by 90°, 180° or 270°
It says that in documentation tho that it's an offset (so, address), not a index.
gta2 map format wrote:a 2D array of 16-bit/32-bit unsigned ints, where each int stores a word/dword offset into column –
Might be padded so it would be aligned better in memory to fit into cache or might be empty space reserved by editor for further edits to speedup re-compression?
Something similar was done by gta1 map editors (gta1 cmp is very similar in structure to cmap) - they would reserve data and only recompress when they ran out of columns ( junction 25 worked like this).
That chunk sizes would be wrong is a bit strange, i'm not sure how the game would then know how to read it properly?
Re: GMP rotator - Rotate your map by 90°, 180° or 270°
I know the "blockd" param stores the block indexes of a column in DMAP and CMAP when compressing the map using map editor, but the "blockd" param in PSX gmp files seems to be different. My code now can read correctly CMAPs created by map editor, as well as DMAPs, but I'm struggling to read PSX maps.
The block info section says the PSX maps have about 8000 to 9300 unique blocks. Indeed, computing the block info size (12 bytes) times the number of unique blocks I get the end of the info block section. However, instead of finishing the CMAP chunk, a 0x600 null bytes follows it before starting another unknown data (which I suspect they are another block info array) and then finishing CMAP.
The "blockd" param of PSX gmp files can't store the index of blocks because some values are above the number of unique blocks. The maximum values I've encountered were around 34000. They can assume odd numbers, which I suspect I should at least multiply them by two. I tried to interpret them as the number of words (an offset like the columns) but it isn't correct.
For now this is what I've got: the landscape is there, the issue is just mapping the block ids to their respective block info offset.
EDIT: I got it!
The block info section says the PSX maps have about 8000 to 9300 unique blocks. Indeed, computing the block info size (12 bytes) times the number of unique blocks I get the end of the info block section. However, instead of finishing the CMAP chunk, a 0x600 null bytes follows it before starting another unknown data (which I suspect they are another block info array) and then finishing CMAP.
The "blockd" param of PSX gmp files can't store the index of blocks because some values are above the number of unique blocks. The maximum values I've encountered were around 34000. They can assume odd numbers, which I suspect I should at least multiply them by two. I tried to interpret them as the number of words (an offset like the columns) but it isn't correct.
For now this is what I've got: the landscape is there, the issue is just mapping the block ids to their respective block info offset.
EDIT: I got it!
Re: GMP rotator - Rotate your map by 90°, 180° or 270°
News! I've finished a program which changes xyz parameters from gta2 script. It uses python as well. I've annexed on the first post the singleplayer maps rotated. I need to fix Industrial District weird crash though. It crashes after some ~20 seconds of gameplay for a unknown reason, even if I stand still and do nothing.
Re: GMP rotator - Rotate your map by 90°, 180° or 270°
This could be a problem with traffic lights.valps wrote: ↑05 Mar 2025, 03:08 News! I've finished a program which changes xyz parameters from gta2 script. It uses python as well. I've annexed on the first post the singleplayer maps rotated. I need to fix Industrial District weird crash though. It crashes after some ~20 seconds of gameplay for a unknown reason, even if I stand still and do nothing.
If you change map 90 or 270 degrees, originally horisontal layout made for 4:3 screen ratio will fit closer horisontally, and could cause 2 traffic lights to be seen that were originally not.
Traffic light zones must be at least a screen away from each other.
See if it works rotated 180 degree without crash, and if it crashes when 90 and 270.
Re: GMP rotator - Rotate your map by 90°, 180° or 270°
Well thought out. However the 180 degree version also crashes and the multiplayer version of Industrial don't crash whatever the rotation angle, which I suppose it have the same traffic lights zones as the singleplayer one. I tried to reduce every zone that is touching the map border but it still crashes.JernejL wrote: ↑05 Mar 2025, 06:51
This could be a problem with traffic lights.
If you change map 90 or 270 degrees, originally horisontal layout made for 4:3 screen ratio will fit closer horisontally, and could cause 2 traffic lights to be seen that were originally not.
Traffic light zones must be at least a screen away from each other.
See if it works rotated 180 degree without crash, and if it crashes when 90 and 270.
However, you gave me an idea: it could be something to do with trains, and it really is. I disabled the trains in script and it don't crashes anymore. I will investigate it.
EDIT: for some unknown reason, two consecutive 45° slopes to the left, top or bottom in a railtrack causes the game to crash when a train runs on it. There was only one location in Industrial where it happens, and I've fixed it transforming these slopes into two consecutive 22.5° slopes. Luckly I fit these slopes without changing the building which covers them.
- wolfenator
- Ped
- Posts: 3
- Joined: 28 Feb 2025, 10:58
Re: GMP rotator - Rotate your map by 90°, 180° or 270°
BANANAS! So weird yet refreshing, curious as to which version most people would prefer.