Modding discussion for Driver 2.
User avatar
By VAIMAHDO
#54821
This is soo cool! Driver 2, earthquake edition! Who else would jump those? xD Perhaps one day we can optimize Driver 2. I've seen how Driver 2 draws up polygons and it's horribly optimized. It draws by faces per distance, which is why the PS1 struggles with this game and the game engine struggles itself. If more modern optimization (Such as each road containing 2 faces (although simulating 1, triangle meshes is the correct way to draw polygons). And maybe we would one day see this game hit a solid 30FPS without a sweat!
User avatar
By someone972
Registration Days Posts Posts Posts Avatar
#54884
Driver 2 models are indeed the same format as Driver 1 it seems, perhaps with a few differences that I can't quite remember atm. I've gotten models to render with textures in a severely hacked up DLE, so maybe I can upload the relevant code or something. It's been a while since I've touched it so I don't remember how much of the Driver 2 lev file format I had figured out. I don't think I was loading any of the model positions like some of the previous images show. Maybe it will be useful to some of you guys though, since you all seem to be doing more work on it than I'd have time for.
User avatar
By kierowca12
Registration Days Posts Avatar
#54886
Any source code is very important to me. GitHub is a good idea. In upcoming days I'm going to create repository on github with my code.

In previous post I made a mistake. Proper struct looks like:
unsigned short int x;
short int z;
unsigned short int y;
short int{
6 bit: rotation;
10bit: nrObject;
}
Offset: 0xce000(from chicago multiplayer map). Noumber objects: 2234. But I still don't know where is structure to connect this pieces of map.

Piece map:
Image
User avatar
By Klancnik777
Registration Days Posts Posts Posts Posts Avatar
#54889
awesome work!

btw what do them arrows mean? a polygon or something else? (i seriously doubt its a vertex. but i realy wonder :P)
By Wheels
Registration Days Posts Posts Posts
#54912
kierowca12 wrote:
Piece map:
Image
This (I have a feeling) is the Player and Cop driving routes. A player could drive through and ally and have the cop chase him on the same route the player is moving.
By Krishty
Registration Days Posts Posts Posts
#54917
I'm sure these are the tiles' Z axes (i.e. the direction a tile faces when spawned). The X axis is (-z.z, 1, z.x) and the Y axis is always (0, 1, 0).

You can see pretty clear the roads are mirrored and the buildings always face the roads. Just instantiate the object at the 10-bit number at that position and rotation, and all should be fine.
User avatar
By someone972
Registration Days Posts Posts Posts Avatar
#54918
Looking at your code it looks like you're on the right track. I apologize for not uploading my research into Driver 2 level formats, it's just that documentation is no fun and my code rapidly changes to test the newest hack. I'm currently writing up a file spec with what I know so far, but if you have any pressing questions on the format that I might be able to answer, you can hit me up on Skype (pm me for my username (EDIT: Actually, you can probably just enter my Driver Madness username into the search and find me)). Once I'm done with what I know of the spec, you all can add in all the missing pieces that you've figured out and maybe we will get the file format mostly figured out.
User avatar
By SOAP
Registration Days Posts Posts Posts Avatar
#54930
Made very correct lump identifiers using Driver 2 demo and coding
Code: Select all
// known lumps indexes
#define LUMP_MODELS			1
#define LUMP_MAP				2
#define LUMP_TEXTURENAMES		5
#define LUMP_MODELNAMES		12

#define LUMP_SUBDIVISION		20
#define LUMP_LOWDETAILTABLE		21
#define LUMP_MOTIONCAPTURE		22
#define LUMP_OVERLAYMAP		24
#define LUMP_PALLET				25
#define LUMP_SPOOLINFO			26
#define LUMP_CAR_MODELS		28

#define LUMP_CHAIR				33
#define LUMP_TEXTUREINFO		34

#define LUMP_LEVELDESC			35
#define LUMP_LEVELDATA			36
#define LUMP_LUMPDESC			37

#define LUMP_STRAIGHTS2			40
#define LUMP_CURVES2			41
#define LUMP_JUNCTIONS2			42

/*
Still unknown
LUMP_ROADMAP
LUMP_ROADS	
LUMP_JUNCTIONS
LUMP_ROADBOUNDS
LUMP_JUNCBOUNDS
LUMP_ROADSURF
*/
User avatar
By SOAP
Registration Days Posts Posts Posts Avatar
#54931
So, here compiled executable and some exported models:
http://www.mediafire.com/download/fe3ca ... _level.rar

Also uploaded code of this app
https://github.com/SoapyMan/psx_driver2_lev

ExportDMODELToOBJ procedure is reading model, decoding faces 99% correct by their bitflags (the only thing i can't check is vertex normal and colors)

DkCore sources not included for now, but you can easily replace some stuff by std and cstdlib
User avatar
By someone972
Registration Days Posts Posts Posts Avatar
#54932
Wow, your face handling code is really nice. I can't believe how hard I had made it when the type is apparently just a bit-field. I'm at work now, but when I get back I'll try and get the format for the Car Models lump and some more texture stuff.

Just for reference, here are the lumps that I mostly know the format for:
Spool Info (sort of)
Palettes
Map (maybe)
Texture Info

You'll need the spool info lump if you want to load all the textures/models in the level, as they are scattered around in section 4.
User avatar
By SOAP
Registration Days Posts Posts Posts Avatar
#54934
Also I have analysed kierowca12 sources, and I think he discovered a PACKED_CELL_OBJECT structure (this name also came from D2 Demo debug output):
Code: Select all
struct dcell_t
{
	ushort		x;
	short		y;
	ushort		z;

	short		cellprops;	// 6 bit rotation and 10 bit model index
};
Also the similar structure (but not size) have PSX_ModelDef from your psx_code.zip (attachment from this thread)

Need to find pointers to cell data, i think they should skip 4x 2048 byte padding (maybe LUMP_SUBDIVISION or LUMP_MAP points to them?)
User avatar
By someone972
Registration Days Posts Posts Posts Avatar
#54935
Its a bit of an involved process to find that sort of stuff. I'll try and explain it a bit here.

The majority of the "cell" (I referred to them as sectors) data is in section 4. There is some of those "cell object"/"model def" entries in the MAP lump I think, but only for models that bridge cell boundaries. In order to read the last section you have to read the spool info lump. This contains two main things (and a bit of unknown data): Shared data group info, and sector data info. The shared data group info tells what offset to find textures and maybe models. The sector data info tells what offset and size each of the different bits of data for a sector are. All the offsets and sizes need to be multiplied by 2048 to get the actual offset/size, which is why they have 2048 byte boundary padding. I mostly figured out the format for Driver 1's PSX levels, but the specifics changed a bit for Driver 2.

That's just a quick overview, but let me know if you have questions about it. I'll try and get the format up on the wikia page after work.

EDIT: It looks like I won't have time to write up a spec tonight, but I'll try and get to it as soon as possible.
User avatar
By kierowca12
Registration Days Posts Avatar
#54937
someone972 wrote:Here's a link to the start of the spec. I've locked it for editing since it's being actively updated, but you will be free to edit it once I'm out of it.
http://driver.wikia.com/wiki/User:Someo ... cification
Thanks for wiki. Do you know more about Sector Info(0x1a)?
How association model names with models?(I have name model and I want find correct model.) Model names is more than models.

I loaded piece of map but in my opinion something is wrong:
Image Image
User avatar
By someone972
Registration Days Posts Posts Posts Avatar
#54939
The names are associated based on the occurrence of the null ('\0') character. So if you had TREE\0BOAT\0\0\0SIGN\0 as the string, it would associate to the following model indices:

0 - TREE
1 - BOAT
2 -
3 -
4 - SIGN

There may be more null's in the names block than there are models, simply due to padding.
User avatar
By someone972
Registration Days Posts Posts Posts Avatar
#54941
I forgot to mention (which you've probably already figured out), but some of the models have a 0 size and are contained in the forth section. So unless you've gotten lucky and found them, some of the models will be missing. You can find them from the sector info block, which I'll spec out later today. Last night I was figuring out what order the data comes in etc, and I got enough so that you'll at least be able to load textures, models, and the model positions that you're loading now.
User avatar
By VAIMAHDO
#54942
Hey guys, I tried to give it away on Free Chat but didn't seem to work. Thanks to all of your guy's work, exporting some Driver 2 models has been done, and earlier on was textures. So, with those materials, I was able to start re-constructing Driver 2 thanks to you guys, Driver 2 animations is possible!
[youtube]
[/youtube]
Although quite simple, the idea is that this is now possible :)
User avatar
By SOAP
Registration Days Posts Posts Posts Avatar
#54944
DaRkProDucTioNs00 wrote:Hey guys, I tried to give it away on Free Chat but didn't seem to work. Thanks to all of your guy's work, exporting some Driver 2 models has been done, and earlier on was textures. So, with those materials, I was able to start re-constructing Driver 2. I got strongly motivated that my first C++ game should be Driver 2 for PC. (With some graphics enhancements available if I get that far) But thanks to you guys, Driver 2 animations is possible!
{cut video}
Although quite simple, the idea is that this is now possible :)
LOL!

--------------------

By the way, i've found that some faces in some models have some indices out of range, i can't understand why this was done.

Also i need other lump specs
User avatar
By someone972
Registration Days Posts Posts Posts Avatar
#54946
Alright, it's 1:00 AM and I've been up all day doing work and making a quiche, but I said I was going to get the spec up and so I will. It's going to suck being up so late, but look for it soon.

EDIT: I updated the spec to have the sector info and more of the texture info blocks. The writeup is rushed and terrible, and there's massive amounts of unknown data, but it should at least get you on the right track. I'd post more information about some of the other sectors but it's late enough as is. Like always, you can contact me on skype if you have questions about the spec. Be sure to update this thread with your findings so that we don't do as much duplication of work.

I'll have to work with you to figure out the model indices thing sometime if you don't figure it out. I've never had any trouble with it, but I'm also loading the models differently.
User avatar
By kierowca12
Registration Days Posts Avatar
#54950
someone972 wrote:Alright, it's 1:00 AM and I've been up all day doing work and making a quiche, but I said I was going to get the spec up and so I will. It's going to suck being up so late, but look for it soon.

EDIT: I updated the spec to have the sector info and more of the texture info blocks. The writeup is rushed and terrible, and there's massive amounts of unknown data, but it should at least get you on the right track. I'd post more information about some of the other sectors but it's late enough as is. Like always, you can contact me on skype if you have questions about the spec. Be sure to update this thread with your findings so that we don't do as much duplication of work.

I'll have to work with you to figure out the model indices thing sometime if you don't figure it out. I've never had any trouble with it, but I'm also loading the models differently.
You have done good job. This information is very important to me. I begin implement this to my program. If I figure something out I will tell you.
User avatar
By SOAP
Registration Days Posts Posts Posts Avatar
#54957
LUMP_SPOOLINFO is something mystical, but tried to decompile function that loads offsets
It's difficult to understand MIPS assembly sometimes :D

Procedure is directly taken from driver 2 demo executable, and decompiled to C
It loads spool info (may be partial, because cell allocation function call is next after this)
Code: Select all
struct struct_0 {
    int32_t e0[4];
    int32_t e1;
};

int32_t * g1; // 0xa41e8
struct struct_0 g2; // 0xa41f8
struct struct_0 g3; // 0xa4620
int32_t g4 = 0; // gpregs4 - initially lump data pointer

void function_40000(void) {
    int32_t v1 = g4; // 0x40000
    int32_t v2 = *(int32_t *)0x94ec0; // 0x40010
    g4 = v2;
    int32_t v3 = 2048 * *(int32_t *)v1; // 0x40014
    *(int32_t *)3076 = v2;
    int32_t v4 = v1 + 4;
    int32_t v5; // 0x4002c
    if ((int32_t)(v3 > 0xffff) == 0) {
        // 0x40024
        v5 = 0x10000;
        // branch -> 0x4002c
    } else {
        // .dec_label_pc_4002c_crit_edge
        v5 = v3;
        // branch -> 0x4002c
    }
    int32_t v6 = g4 + v5; // 0x4002c
    int32_t v7 = v6;
    int32_t v8 = 0xa41e8;
    *(int32_t *)0x94ec0 = v6;
    *(int32_t *)3068 = v4 + 4;
    int32_t v9 = *(int32_t *)v4 + 4 + v4; // 0x40074
    g4 = *(int32_t *)v9;
    *(int32_t *)3020 = v9 + 4;
    int32_t v10 = 16 * g4; // 0x40084
    int32_t v11 = (v10 | 4) + v9; // 0x4008c
    *(int32_t *)3088 = v11;
    int32_t v12 = v10 + v11; // 0x40094
    *(int32_t *)3040 = g4;
    g1[v8] = v7;
    int32_t v13 = 0; // 0x400a4
    int32_t v14 = 0xa4620;
    g3.e0[v14] = v13;
    int32_t v15 = 0; // 0x400a8
    int32_t v16 = 0xa41f8;
    g2.e0[v16] = v15;
    int32_t v17 = v12; // 0x400ac
    int32_t v18 = v8 + 4; // 0x400c4
    int32_t v19 = 2; // 0x400c8
    int32_t v20 = *(int32_t *)v17 + v13; // 0x400cc
    int32_t v21 = *(int32_t *)(v17 + 16) + v15; // 0x400d0
    int32_t v22 = v7 + (*(int32_t *)(v17 + 32) + 2047 & -2048); // 0x400dc
    // branch -> 0x400a0
    while (v19 > 0xffffffff) {
        // 0x400a0
        g1[v18] = v22;
        v13 = v20;
        v14 += 4;
        g3.e0[v14] = v13;
        v15 = v21;
        v16 += 4;
        g2.e0[v16] = v15;
        v17 += 4;
        v18 += 4;
        v19--;
        v20 = *(int32_t *)v17 + v13;
        v21 = *(int32_t *)(v17 + 16) + v15;
        v22 += (*(int32_t *)(v17 + 32) + 2047 & -2048);
        // continue -> 0x400a0
    }
    // 0x400e0
    v4 = v12 + 48;
    g3.e1 = v20;
    g2.e1 = v21;
    *(int32_t *)0x94ec0 = v22;
    *(int32_t *)3048 = v4 + 4;
    *(int32_t *)2968 = 2 * *(int32_t *)v4 + 4 + v4 + 4;
}
Looks like i've found a nice MIPS translator at http://decompiler.fit.vutbr.cz (code structure only, data types and numbers may be wrong)
Other decompilers which i've tried aren't capable to generate valid code (even asm in IDA didn't look good while i've tried to translate it manually)

I think this code might be helpful. I'll test it soon to load lump properly
User avatar
By kierowca12
Registration Days Posts Avatar
#54967
I discovered something out. If you add to sectorInfo.sectorDataInfo.offset*2048 + 2048*5 you get piece of map(not always). I don't know the position of this pieces map on the whole map so I can load only multiplayer map becouse it has little pieces map.
Image
  • 1
  • 3
  • 4
  • 5
  • 6
  • 7
  • 14
Crazy Copper Frenzy

https://youtu.be/xAE3QsULyB4

https://youtu.be/AxdGf3F0yIg

Driv3r "Nice Getaway"

https://youtu.be/CYkmGAPoO9s Lucas in Driv3r's Ni[…]

https://youtu.be/Yvc_xKrKhnc?si=k4I5kraarTXctHJp […]