Page 1 of 14

LEV files revisited

Posted: Wed Jan 02, 2013 11:46 pm
by Krishty
Hi!

I'm Chris; I'm looking at Driver 2's LEV files; this is my first post; and I want to discuss what I've discovered so far.

For my investigation I'm using Driver 2 PAL Europe. I'm analyzing DRIVER2\MLEVELS\CHICAGO.LEV (i.e., the multiplayer Chicago level) because 1) multiplayer levels are smaller and simpler than single-player levels, and therefore easier to analyze; and 2) Chicago is the level I have most memories on. But if not stated otherwise, whatever I say is also valid for the other cities and levels (I'm running some unit tests here).

To proceed, you need to have worked with a hex editor before. Please also mind the PSX was a little-endian architecture — i.e., the hexadecimal number 90ABCDEF would be found in the LEV file as EFCDAB90. Also, KiB is 1024 bytes and kb is 1000 bits.

Confused enough? ;) Let's begin with the general structure of the file. The layout is mostly chunk-based, i.e. each matter is assigned a unique ID and a size (both being 4-byte-values). If one does not need or understand a chunk of data, it can easily be skipped. Well, there's lots of exceptions (Driver 2 is constantly paging in from the CD-ROM, and requires random access to do so), but for the beginning this is sufficient. Furthermore, this post states that the chunks are internally called lumps, and that's how I will refer to them.

So, let's open Chicago. The first thing we see is:
Code: Select all
offset		value(s)
\/\/\/\/	\/\/\/\/\/\/\/\/\/\/\/\/
00000000	25000000 F8070000
This is the ID (0x25) and size (2040 B counted from the 8th byte; i.e., pointing to 00000800) of the dictionary lump.

It contains eight 4-B values:
Code: Select all
					00080000 00B80200			
					00C00200 00A00800
					00600B00 00380100
					00980C00 00E00D00
Each pair describes one of the major lumps in a file. The first pair describes the 2nd lump starting at 00000800 (Recognize that number?) and being 174 KiB large; and so on. This is the same for any LEV file you open. What's also the same is, the first lump listed here will be of type 00000023, and the third one will be of type 00000024. (I have not analyzed the second and fourth lump in the list, as their format is slightly different. These lumps keep most of geometry and textures, and I'll come back to them later.) What's after this, on the other hand, differs from level to level – for any kind of CHICAGO.LEV, the remaining space is padded with magic numbers; for the other LEV's, it holds offsets I have not yet further looked into.

Let's proceed with the 00000023 lump, as there is some interesting information in it:
Code: Select all
00000800	23000000					type
				10B30200					size (points to 0002BB18)
Inside are the sub-lumps 0000005, 0…22, 0C, 19, 02, 16, 1C, and FF.
05 keeps texture names:
Code: Select all
					00000005					type
					C81B0000					size (points to 000023C8) — consider: the chunk data ends at 000023C8, but the next chunk will start at 000023>D<8 because chunks are always 4-B-aligned!
						<zero-terminated strings>		904 (0x388) of them; each one is a texture name
These are easy to spot even with a text editor; don't bother processing them — they're referenced by the next lump (22):
Code: Select all
000023D8	22000000
				A8200000					size (points to 00004488)
					46000000					number of active texture atlases
					89030000					equals the number of texture names in the previous chunk
					Texture atlases incoming! Consider: There were 0x46 atlases declared, but 0x47 actually occur! I guess the last one is skipped …
					0001 0000 00001F98
					0001 0000 000093A0
					0001 0000 00010C90
					0002 0000 000178EC
					0002 0000 0001EC60
					0002 0000 00025ED0
					0002 0000 0002D760
					0002 0000 00035340
					0002 0000 0003C944
					0002 0000 00043C44
					0002 0000 0004AC40
					0002 0000 0005234C
					0002 0000 000594F0
					0002 0000 00060E6C
					0002 0000 00067A60
					0002 0000 0006E7B8
					0002 0000 00075B20
					0002 0000 0007C664
					0002 0000 00083C70
					0002 0000 0008AF14
					0002 0000 000921A0
					0002 0000 00099774
					0002 0000 000A038C
					0002 0000 000A4F24
					0002 0000 000AC534
					0002 0000 000B3EC0
					0002 0000 000BB810
					0002 0000 000C2748
					0002 0000 000C95D4
					0002 0000 000D0280
					0002 0000 000D708C
					0002 0000 000DE5AC
					0002 0000 000E4C04
					0002 0000 000E7D00
					0002 0000 000EF008
					0002 0000 000F67E4
					0002 0000 000FE1B0
					0002 0000 00105B78
					0002 0000 0010C7C4
					0002 0000 00113294
					0002 0000 0011A4F0
					0002 0000 00121E60
					0002 0000 001293AC
					0002 0000 00130214
					0002 0000 001370D0
					0002 0000 0013E420
					0002 0000 00142DC8
					0002 0000 00142FD4
					0001 0000 001431E0
					0002 0000 00149ED8
					0001 0000 0014A0E4
					0001 0000 00150A00
					0001 0000 00156B40
					0002 0000 0015D8AC
					0004 0000 00163714
					0004 0000 0016A9D8
					0004 0000 001701D0
					0004 0000 0017676C
					0001 0000 0017B400
					0002 0000 00181ED0
					0002 0000 001899B4
					0004 0000 0018AF18
					0001 0000 00191304
					0001 0000 00197AD0
					0004 0000 0019DE4C
					0001 0000 001A3370
					0004 0000 001A9EAC
					0004 0000 001B0234
					0004 0000 001B54C0
					0004 0000 001BBF74
					          ^^^^^^^^ offset of texture data, not yet worked out
					     ^^^^ mostly <= 4, but 5, 6, 7, 8, 9, and -8747 for Vegas …
					^^^^ Flags; I don't know what for. Always 1, 2, or 4.
Those are really interesting. Consider Driver 2 gathers several small textures in a large texture, called an atlas. The 70 texture atlases declared here will feed more than 800 actual textures.
The offsets are really interesting: The offsets are mostly 20–30 KiB apart. If you go through the file with a hex editor and take notes where you find texture-like looking blocks, those blocks are also mostly 20–30 KiB apart. But unfortunately, the offsets given in the file do not point to valid locations — some of them even point beyond the file. I guess there is additional information coded in the 11 least significand bits (as texture atlases seem always aligned to 0x800), and I'll need to take a closer look at this later. But first, proceed with the rest of the 22 lump – actual textures:
Code: Select all
					0000001E	286F 0000 00/00 40/18	23B2 0004 40/00 20/40	28CF 000C A0/00 40/20	6841 0014 E3/04 14/30	23A2 001B 00/58 40/40	2565 0021 80/78 80/08	6963 0026 80/40 20/22	286E 002A 00/98 40/20	28D0 0032 00/B8 40/20	737E 003A 80/6C 60/0A	279F 003E 40/80 40/40	2390 0046 00/18 40/40	2395 004C 40/40 40/40	2394 0052 A0/20 40/40	7401 0059 80/62 60/0A	2389 005F 40/C0 40/40	7487 0066 80/E0 46/20	7075 006E C6/E0 20/20	7629 0073 E6/E0 18/18	273E 007C 00/D8 40/20	75A6 0085 60/00 40/40	2385 008E 80/80 40/40	7448 0095 F7/00 08/60	2592 009B 80/C0 40/20	73BD 009F C0/C0 40/20	75A9 00A4 C0/80 10/40	7927 00AD E8/80 14/14	792A 00B5 E8/94 18/18	23AA 00BD D0/80 18/3E	79B0 00C6 E0/34 14/14
					0000001E	25D7 00C9 E0/40 20/40	26B9 00CF 40/C0 40/40	011A 00D8 00/C0 40/40	2472 00DC 80/40 60/40	2460 00E4 40/00 80/10	279E 00ED C0/00 40/40	2590 00F6 80/10 40/20	27A0 00FA C0/80 40/20	72EF 0103 80/A0 45/60	23B5 010A C5/A0 3B/60	7545 0111 80/30 40/0A	2830 0117 00/80 80/40	0106 0120 00/00 40/40	78CB 0129 60/40 10/20	78CD 0130 70/40 10/20	78D7 0135 80/80 14/14	78D8 013D 94/80 14/14	7921 0145 40/40 20/40	72F0 014C 60/60 0D/20	7923 0155 6D/60 10/20	7926 015E 80/94 28/08	23DB 0166 A8/80 08/20	6996 016E B0/80 0E/20	78C6 0172 00/40 40/40	7B51 0178 40/10 14/14	7B52 0180 54/10 14/14	7B53 0188 68/10 14/14	7B54 0190 40/24 14/14	7B55 0199 54/24 14/14	7B56 01A1 68/24 14/14
					0000001D	6C7B 01A6 00/00 80/40	6CF6 01AA 80/00 60/40	2683 01B3 00/40 40/43	69F1 01B9 40/40 40/40	267E 01BF 80/40 40/40	6D3B 01C5 C0/40 40/40	6D6D 01C9 40/80 40/40	6DEA 01CD 80/80 38/3A	6B4E 01D5 B8/80 30/40	2688 01DD 00/83 38/35	6C3B 01E3 00/B8 30/30	6C3A 01EB 80/BA 30/30	6A53 01F3 E8/80 18/60	2687 01FB B0/C0 28/28	6EF1 0202 E0/00 20/20	27A1 020A 70/C0 10/40	75DF 0211 D8/C0 10/40	7500 0218 E8/E0 18/18	7501 0221 00/E8 18/18	7502 022A 18/E8 18/18	762C 0233 E0/20 18/18	78DA 023A 80/EA 14/14	79B3 0242 B0/E8 18/18	267C 024B 30/C0 40/13	7B4B 0253 94/EA 16/10	7B4E 025C 58/D3 16/10	7B4F 0265 58/E3 14/0D	7B50 026D 30/D3 24/13	7C12 0274 48/F0 14/0A
					0000000C	23B9 0279 00/00 40/40	23C1 0280 00/80 80/40	23C3 0289 00/C0 80/40	23C2 028F 80/80 80/40	23C6 0295 80/C0 80/40	7007 029E C0/40 40/40	2645 02A7 C0/00 40/40	23BF 02B0 80/40 40/40	23BD 02B9 00/40 40/40	23BE 02C2 40/40 40/40	23BB 02CB 80/00 40/40	264B 02D4 40/00 40/40
					0000000D	23C9 02DD 80/40 80/40	23D5 02E6 40/80 40/40	2402 02EF 40/E0 40/20	23C7 02F6 40/00 80/40	23C5 02FC 00/00 40/40	23D6 0305 80/80 40/40	23D8 030E 00/C0 40/40	23D7 0317 C0/80 40/40	23E5 0320 C0/C0 40/40	23D3 0326 C0/00 40/40	270F 032F 00/40 80/40	2644 0335 00/80 40/40	768B 033E 80/C0 40/30
					0000000C	23E6 0343 00/00 40/40	23EA 034A 00/40 80/40	23EC 0353 00/80 80/40	23ED 035C 80/80 80/40	23F0 0365 80/C0 40/40	23E9 036E C0/00 40/40	23E7 0375 40/00 40/40	23EB 037E 80/40 80/40	264A 0387 80/00 40/40	23EF 038E 40/C0 40/40	23F1 0397 C0/C0 40/40	23EE 03A0 00/C0 40/40
					0000000C	23F4 03A9 00/40 80/40	23F5 03AF C0/00 40/40	23F6 03B8 80/40 80/40	23FB 03C1 C0/80 40/40	23F8 03C9 40/80 40/40	23FC 03D2 80/C0 40/40	23F9 03DA 80/80 40/40	23FD 03E2 C0/C0 40/40	2400 03EA 00/80 40/40	23FA 03F0 00/C0 80/40	23F2 03F8 00/00 80/40	23F3 0401 80/00 40/40
					0000000E	2774 040A C0/00 40/40	2401 0411 00/40 40/40	2640 041A 80/80 80/40	2641 0423 00/C0 80/40	28A2 042C 80/C0 17/40	28A3 0435 97/C0 17/40	68A5 043E AE/C0 40/40	6E23 0447 EE/C0 12/40	6E8B 0450 80/00 40/40	6F25 0455 80/40 40/40	2404 045E C0/40 40/40	23FE 0466 00/00 80/40	2405 046E 00/80 80/40	2403 0476 40/40 40/40
					00000008	2409 047D 80/40 80/40	240A 0486 00/80 80/40	240D 048F 80/C0 80/40	2407 0498 80/00 80/40	2406 04A1 00/00 80/40	2408 04AA 00/40 80/40	240C 04B3 00/C0 80/40	240B 04BC 80/80 80/40
					00000008	2411 04C5 80/40 80/40	240F 04CE 80/00 80/40	240E 04D7 00/00 80/40	2410 04E0 00/40 80/40	2413 04E9 80/80 80/40	2414 04F2 00/C0 80/40	2412 04FB 00/80 80/40	2415 0504 80/C0 80/40
					0000000B	2418 050D 00/40 80/40	241C 0516 C0/80 40/40	241F 051F 80/C0 40/40	2416 0528 00/00 80/40	2420 0531 C0/C0 40/40	241A 0538 00/80 80/40	241D 0541 00/C0 40/40	241E 054A 40/C0 40/40	241B 0553 80/80 40/40	2419 055C 80/40 80/40	2417 0565 80/00 80/40
					0000000C	2422 056E 40/00 40/40	2429 0577 80/80 80/40	242A 057F 00/C0 40/40	2771 0587 40/C0 80/40	2772 0590 C0/C0 40/40	2423 0599 80/00 40/40	2425 05A2 00/40 40/40	2426 05A9 40/40 40/40	2421 05B0 00/00 40/40	2424 05B9 C0/00 40/40	2427 05C2 80/40 80/40	27D3 05CA 00/80 80/40
					00000014	2773 05D3 00/00 40/40	2775 05DC 80/00 40/40	2776 05E5 C0/00 40/40	2777 05EE 40/00 40/40	27FC 05F7 40/40 40/40	6A22 0600 00/80 40/40	6A23 0609 40/80 28/40	6A24 0611 68/80 18/40	6CAD 061A 80/80 40/40	6F64 0621 C0/80 20/20	27FB 062A 00/40 40/40	771D 0633 E0/80 20/20	771E 063B 40/C0 40/20	7B9B 0642 00/C0 40/40	768C 064B C0/A0 40/20	7BD5 0650 80/C0 40/40	7BD7 0659 C0/C0 40/40	27FD 0662 80/40 80/40	7CF7 066B 40/E0 20/0C	7CF8 0673 60/E0 20/20
					00000008	242F 067A 00/00 80/40	2430 0682 80/00 80/40	2431 068A 00/40 80/40	2432 0692 80/40 80/40	2433 069A 00/80 80/40	2434 06A2 80/80 80/40	2435 06AA 00/C0 80/40	2436 06B2 80/C0 80/40
					00000009	2437 06BA 00/00 80/40	2438 06C2 80/00 80/40	2439 06CA 00/40 80/40	243A 06D2 80/40 80/40	243B 06DA 00/80 80/40	243C 06E2 80/80 80/40	243D 06EA 00/C0 80/40	243E 06F2 80/C0 40/40	243F 06FA C0/C0 40/40
					00000012	2440 0702 00/00 40/40	2442 070A 80/00 40/40	2443 0712 C0/00 40/40	2444 071A 00/40 40/40	2445 0722 40/40 40/40	2446 072A 80/40 40/40	2447 0732 C0/40 40/40	2448 073A 00/80 40/40	2449 0742 40/80 40/40	244A 074A 80/80 40/40	244B 0752 C0/80 40/40	244C 075A 00/C0 40/40	244D 0762 40/C0 40/40	244E 076A 80/C0 80/10	244F 0771 80/D0 7B/10	2450 0778 80/E0 40/10	2451 077C C0/E0 40/10	2441 0784 40/00 40/40
					00000010	6AD1 078C C0/C0 30/40	2459 0795 00/00 40/40	245A 079E 40/00 40/40	687D 07A7 40/C0 40/40	687F 07B0 A8/C0 18/40	6882 07B9 F0/C0 10/40	687C 07C2 00/C0 40/40	687E 07CB 80/C0 28/40	6940 07D4 00/40 40/40	6874 07DD C0/00 40/40	6876 07E6 80/40 40/40	245E 07EF B0/00 10/40	6879 07F8 40/80 80/40	6878 0801 00/80 40/40	6877 080A C0/40 40/40	7A57 0813 40/40 40/40
					0000000A	2454 081A 00/40 80/40	2455 0823 80/40 80/40	2456 082A 00/80 80/40	2457 0831 80/80 40/40	2458 083A C0/80 40/40	6880 0843 40/C0 40/40	2452 084C 00/00 80/40	687A 0855 80/00 80/40	245B 085E 00/C0 40/40	7CF5 0867 80/C0 80/40
					00000008	2498 086C 80/C0 80/40	2483 0875 00/00 80/40	2484 087D 80/00 80/40	2486 0885 00/40 80/40	2487 088D 80/40 80/40	2489 0895 00/80 80/40	2488 089D 80/80 80/40	2485 08A5 00/C0 80/40
					0000000F	2493 08AD 40/80 40/40	6DC8 08B5 80/C0 80/28	248B 08BE 40/00 40/40	248C 08C6 80/00 40/40	248D 08CF C0/00 40/40	2496 08D8 00/C0 40/40	248E 08E1 00/40 40/40	248F 08EA 40/40 40/40	2490 08F2 80/40 40/40	248A 08FA 00/00 40/40	2492 0902 00/80 40/40	2494 090A 80/80 40/40	2497 0912 40/C0 40/40	2491 0919 C0/40 40/40	2495 0921 C0/80 40/40
					0000000A	2511 0929 00/80 80/40	2512 0932 00/C0 80/40	250C 093B 20/00 80/40	6CD6 0943 E0/00 20/40	6AB6 094C 80/C0 80/40	250D 0955 00/40 80/40	250E 095E A0/00 40/40	2510 0967 C0/40 40/80	250F 0970 80/40 40/80	249A 0979 00/00 20/40
					00000008	6AB8 0981 00/00 80/40	6AB9 098A 80/00 80/40	6ABC 0993 00/40 80/60	72C5 099C 40/C0 55/40	6ABF 09A1 00/A0 80/20	6AD0 09AA 80/40 80/40	6ACF 09B3 80/80 80/40	6AC0 09BC 00/C0 40/40
					00000006	6AC2 09C5 40/00 80/40	6ACD 09CE C0/00 40/40	6AC7 09D7 00/40 80/40	6AC4 09E0 80/40 80/40	6ACE 09E9 00/80 80/40	6AC1 09F2 00/00 40/40
					00000009	249B 09FB 00/00 80/40	249D 0A02 C0/00 40/40	249E 0A08 00/40 80/40	249F 0A0E 80/40 80/40	24A0 0A15 00/80 80/40	24A1 0A1C 80/80 80/40	24A2 0A22 00/C0 80/40	24A3 0A28 80/C0 80/40	71C2 0A2E 80/00 40/40
					0000000C	24A4 0A36 00/00 80/40	24A5 0A3C 80/00 80/40	24A6 0A42 00/40 40/40	24A7 0A49 40/40 40/40	24A8 0A4F 80/40 40/40	24A9 0A55 C0/40 40/40	24AA 0A5C 00/80 40/40	24AB 0A63 40/80 40/40	24AD 0A6A C0/80 40/40	6E86 0A71 00/C0 80/40	71C0 0A76 80/C0 80/40	71C1 0A7C 80/80 40/40
					0000000B	6ED2 0A82 40/00 40/40	6ED3 0A8B 80/00 80/40	6ED4 0A94 00/40 40/40	6FA1 0A9D 40/40 40/40	6FA2 0AA6 80/40 40/40	6FBF 0AAF 00/80 80/40	716C 0AB8 00/00 40/40	716D 0AC1 80/80 80/40	716E 0ACA 00/C0 80/40	71C3 0AD3 C0/40 40/40	71FE 0AD9 80/C0 80/40
					0000000F	71FF 0ADF 00/00 40/40	7200 0AE5 40/00 40/40	7546 0AED 80/00 80/40	7690 0AF6 00/40 60/30	7691 0AFB 60/40 20/20	7692 0B01 80/40 40/40	76F3 0B09 C0/40 40/40	76F4 0B10 60/80 40/40	76CA 0B17 00/70 60/18	7758 0B1C A0/80 1A/40	77A7 0B23 BA/80 40/40	77A8 0B2B 00/C0 80/40	781A 0B32 00/88 60/30	7C6D 0B39 80/C0 40/40	7C6E 0B42 C0/C0 40/40
					0000000A	7C63 0B4B 00/00 80/40	7C64 0B54 80/00 80/40	7C65 0B5D 00/40 80/40	7C66 0B66 80/40 80/40	7C67 0B6F 00/80 80/40	7C68 0B78 80/80 80/40	7C69 0B81 00/C0 40/40	7C6A 0B8A 40/C0 40/40	7C6B 0B93 80/C0 40/40	7C6C 0B9C C0/C0 40/40
					00000008	24B1 0BA5 00/40 80/40	24B2 0BAE 80/40 80/40	24B3 0BB7 00/80 80/40	24B4 0BC0 80/80 80/40	24B5 0BC9 00/C0 80/40	24B6 0BD2 80/C0 80/40	6BFC 0BDB 80/00 80/40	24AF 0BE4 00/00 80/40
					00000008	24B9 0BED 00/40 80/40	24BA 0BF6 80/40 80/40	24BC 0BFF 00/80 80/40	24BD 0C08 80/80 80/40	24BE 0C11 00/C0 80/40	24BF 0C1A 80/C0 80/40	24BB 0C23 80/00 80/40	7269 0C2C 00/00 80/40
					0000000F	24C1 0C35 40/00 40/40	24C2 0C3E 80/00 40/40	24C3 0C47 C0/00 40/40	24C5 0C50 40/40 40/40	24C7 0C59 C0/40 40/40	24C8 0C61 00/80 40/40	24C9 0C69 40/80 40/40	24CA 0C71 80/80 40/40	24CC 0C79 00/C0 40/40	24CD 0C81 40/C0 40/40	24CE 0C89 80/C0 80/40	24C4 0C92 00/40 40/40	24C6 0C9B 80/40 40/40	24CB 0CA3 C0/80 40/40	6EBB 0CAB 00/00 40/40
					0000000C	24CF 0CB3 00/00 80/40	24D0 0CBC 80/00 80/40	24D1 0CC5 00/40 80/40	6B83 0CCE 00/80 80/40	6B84 0CD7 80/80 40/40	6B88 0CE0 C0/80 10/40	6B89 0CE9 D0/80 18/40	6B8A 0CF2 E8/80 18/40	6B8B 0CFB 00/C0 40/20	6B8C 0D00 40/C0 30/20	24D2 0D06 80/40 80/40	7783 0D0F 70/C0 56/40
					00000005	728D 0D17 00/00 40/40	726D 0D20 40/00 40/40	726E 0D29 80/00 40/40	7270 0D32 00/40 80/40	768D 0D3B 80/40 60/40
					0000000A	6B2D 0D40 80/40 80/40	6B30 0D47 00/C0 40/40	6B32 0D50 80/C0 40/40	6B2B 0D57 80/00 80/40	6B31 0D5E 40/C0 40/40	6B2A 0D65 00/00 80/40	6B2C 0D6C 00/40 80/40	6B2E 0D73 00/80 80/40	6B2F 0D7A 80/80 80/40	6B33 0D81 C0/C0 40/40
					0000000D	6B36 0D88 80/00 40/40	6B37 0D8F C0/00 40/2E	6BEA 0D97 80/C0 80/40	6DB5 0DA0 00/C0 80/40	6B49 0DA9 00/40 40/40	70DD 0DB0 C0/6E 40/12	6B35 0DB9 40/00 40/40	6B4B 0DC0 80/40 40/40	6B38 0DC7 C0/2E 40/40	6B4C 0DCE 00/80 80/40	6B4D 0DD5 80/80 80/40	6B34 0DDC 00/00 40/40	6B4A 0DE3 40/40 40/40
					0000000B	6BE7 0DEA 00/00 40/80	6BE8 0DF3 40/00 80/40	6BE9 0DFC C0/00 40/40	70CF 0E05 00/80 80/40	70D0 0E0C C0/40 40/40	70D1 0E13 80/80 40/40	70D2 0E1A 00/C0 40/40	70D3 0E21 C0/80 40/80	6DA5 0E28 40/C0 80/40	6CAF 0E2F 80/40 40/40	6CAE 0E37 40/40 40/40
					0000000C	70D5 0E3F 40/00 40/40	70D6 0E46 80/40 80/40	70D7 0E4F 40/40 40/40	70D8 0E58 00/80 40/80	70D9 0E61 80/00 80/40	70DA 0E6A C0/80 40/80	70DB 0E73 40/C0 40/2E	70DC 0E7C 40/EE 40/12	6DB6 0E85 40/80 80/40	6DAF 0E8E 80/C0 40/27	6DB0 0E97 80/E7 40/19	70D4 0EA0 00/00 40/80
					0000000A	6DB1 0EA7 00/00 80/40	72AB 0EB0 80/00 80/27	732D 0EB5 80/27 80/40	732F 0EBC 00/40 80/40	7347 0EC2 80/67 40/40	75AC 0EC9 00/80 80/40	75AD 0ED2 C0/67 40/40	75AE 0EDB 80/A7 40/40	75AF 0EE4 C0/A7 40/40	768A 0EED 00/C0 60/30
					00000008	24D5 0EF2 00/00 80/40	24D7 0EFB 00/40 80/40	24DA 0F04 80/80 80/40	24DB 0F0D 00/C0 80/40	24D9 0F16 00/80 80/40	24D6 0F1F 80/00 80/40	24D8 0F28 80/40 80/40	24DC 0F31 80/C0 80/40
					0000000C	2862 0F3A 40/C0 40/40	6BEB 0F43 80/00 40/40	24E5 0F4C 00/C0 40/40	24E4 0F55 C0/80 40/40	24E8 0F5E C0/C0 40/40	24E7 0F67 80/C0 40/40	24DD 0F70 00/00 80/40	24DF 0F79 00/40 80/40	24E0 0F82 80/40 80/40	24E1 0F8B 00/80 80/40	24E3 0F94 80/80 40/40	6BEC 0F9D C0/00 40/40
					0000001A	24F1 0FA6 00/80 40/40	24F3 0FAF 80/80 40/20	24F6 0FB8 C0/A0 40/10	24F7 0FC1 C0/B0 40/10	24F8 0FCA 00/C0 10/40	24F9 0FD3 10/C0 40/20	24FA 0FDC 50/C0 40/20	24EE 0FE5 40/40 40/40	24EC 0FEE C0/00 40/40	2825 0FF7 80/00 40/40	2501 1000 90/E0 20/20	2502 1009 B0/E0 20/20	2503 1012 D0/E0 20/20	2500 101B D0/C0 20/20	24FE 1024 10/E0 80/0C	24FF 102D 10/EC 80/08	24E9 1036 00/00 40/40	24EF 103F 80/40 40/40	24ED 1048 00/40 40/40	24F0 1051 C0/40 40/40	24FB 105A 90/C0 40/20	24F2 1063 40/80 40/40	2509 106C F0/C0 10/40	24F4 1075 C0/80 40/20	24F5 107E 80/A0 40/20	24EA 1087 40/00 40/40
					0000000A	2504 108F 00/00 40/40	6BD4 1098 00/80 80/40	6BD6 10A1 00/C0 80/40	6BD7 10AA 80/C0 80/40	6BD3 10B3 80/40 80/40	6BD5 10BC 80/80 80/40	2506 10C5 80/00 80/40	2507 10CE 00/40 40/40	2505 10D7 40/00 40/40	2508 10E0 40/40 40/40
					0000000B	6C30 10E9 C0/00 40/40	6C7C 10F2 40/40 80/40	6C1B 10F8 00/00 40/40	74D6 1101 80/80 80/40	74D7 110A 00/80 80/40	6C1C 1113 40/00 40/40	6C26 111C 80/00 40/40	74E1 1125 C0/40 40/40	6C70 112E 00/40 40/40	768E 1134 00/C0 40/36	7A56 113A 40/C0 80/40
					0000000C	70AF 1143 00/00 00/40	70B0 114C 00/40 80/40	70B1 1155 80/40 80/40	70B2 115E 00/80 40/80	70B3 1167 C0/80 40/40	70B4 1170 40/C0 20/40	70B5 1179 40/80 40/40	70B6 1182 80/80 40/40	70B8 118B E0/C0 20/40	70BB 1194 A0/C0 40/40	70BC 119D 60/F0 40/10	70C1 11A6 60/C0 40/30
					0000000F	70B7 11AF 20/00 08/40	70B9 11B8 00/00 20/40	70BA 11C1 C0/C0 40/18	70BE 11CA 00/40 80/40	70BF 11D3 00/80 80/40	70C0 11DC 80/40 80/40	70C2 11E5 28/28 80/18	70C3 11EE E8/00 18/40	70C4 11F7 80/80 80/40	70C5 1200 A8/00 40/40	70C6 1209 00/C0 80/40	70C7 1212 C0/D8 40/14	70C8 121B C0/EC 40/14	70C9 1224 80/C0 40/40	70CA 122D 28/00 40/28
					00000007	70BD 1236 00/00 00/40	70CD 123F 40/40 80/40	70CE 1248 C0/40 40/40	7620 1251 00/80 80/40	7C9A 125A 80/80 80/40	70CC 1263 00/40 40/40	7621 126C 00/C0 80/06
					00000000
					00000000
					0000000B	6C73 1275 00/40 80/40	6C78 127B 80/80 80/40	6C79 127F 00/C0 80/40	6C7A 1283 80/C0 80/40	6C76 1287 00/80 40/40	6C75 128B C0/40 40/40	6E1E 128F 40/80 40/40	2648 1293 00/00 80/40	24AC 129A 80/00 40/40	6C72 12A1 C0/00 40/40	6C74 12A5 80/40 40/40
					00000000
					0000001E	6AF4 12A9 00/00 40/20	6AF5 12B1 40/00 40/20	6AF6 12B9 80/00 40/20	6AF7 12C1 00/20 40/20	6AF8 12C9 40/20 40/20	6AF9 12D1 80/20 40/20	6AFB 12D9 40/40 40/20	6AFC 12E1 80/40 40/20	6AFE 12E9 40/60 40/20	6AFF 12F1 80/60 40/20	6B06 12F9 40/A0 40/40	6B08 12FF 00/C0 40/20	6B09 1306 80/C0 40/20	6B0A 130D 00/E0 40/20	6B0B 1313 40/E0 40/20	6B0C 1319 80/E0 40/20	6B00 1320 00/80 40/20	6B01 1328 40/80 40/20	6B02 132F 80/80 40/20	6B03 1337 C0/80 40/20	6B04 133E 00/A0 40/20	6B05 1346 80/A0 40/20	71B2 134E C0/E0 14/14	71B3 1354 D4/E0 14/14	6AFA 135C 00/40 40/20	6AFD 1364 00/60 40/20	6B07 136C C0/A0 40/40	7B2E 1372 E8/E0 10/20	25BF 137B C0/00 40/40	25C6 1384 C0/40 40/40
					0000000F	6BA2 138C 00/00 80/80	6D39 1395 00/C0 80/40	6D3A 139E 80/C0 80/40	6D32 13A7 C0/00 40/40	6D34 13AB 80/40 40/40	6D31 13AF 80/00 40/40	6D37 13B3 80/80 80/40	6D35 13B7 C0/40 40/40	72ED 13BB 00/80 40/40	7624 13C2 40/80 24/20	7C5A 13C9 64/80 18/18	7C5B 13CF 64/98 14/14	7C62 13D6 40/A0 18/18	7D32 13DE 58/AC 14/14	7D33 13E5 6C/AC 14/14
					00000010	6E53 13EB 00/40 80/40	6E88 13EF 00/80 40/40	6E89 13F4 40/80 40/40	6E8A 13F9 C0/80 40/40	6E87 13FE 80/A0 40/40	74FE 1402 80/80 40/20	7A05 140B 00/00 60/3B	74FB 1411 60/00 40/40	6D6E 1419 80/40 80/40	6F55 141D A0/00 20/40	6DEB 1425 C0/00 40/40	6D36 142E 00/C0 80/40	7623 1432 80/E0 80/20	7C60 1439 D4/C0 14/14	7C61 1442 E8/C0 14/14	7D34 1447 C0/C0 0E/20
					0000000A	6EF0 1450 00/00 60/80	6EF2 1458 60/00 80/40	6F8F 1460 E0/00 20/40	6F90 1469 60/40 40/40	6F91 1472 A0/40 0C/40	7250 147B 00/80 80/40	7251 1482 AC/40 40/40	7252 1488 80/80 80/40	7253 148E 00/C0 50/16	768F 1496 50/C0 40/30
					00000010	7D41 149B 40/00 40/40	7D42 14A4 80/00 40/40	7D43 14AD C0/00 40/40	7D44 14B6 00/40 40/40	7D46 14BF 80/40 40/40	7D47 14C8 C0/40 40/40	7D49 14D1 00/80 40/30	7D4A 14DA 40/80 40/30	7D4B 14E3 80/80 80/30	7D4C 14EC 00/B0 C0/30	7D4D 14F5 C0/B0 40/10	7D4E 14FE C0/C0 40/40	7D50 1507 80/E0 40/20	7D40 1510 00/00 40/40	7D4F 1519 00/E0 80/20	7D45 1522 40/40 40/40
					00000005	7D35 152B 00/80 00/80	7D51 1533 00/00 80/40	7D52 153C 80/00 80/40	7D53 1545 00/40 80/40	7D54 154E 80/40 80/40
					0000000E	796D 1557 00/00 60/30	796E 155F 60/00 20/30	7972 1566 00/A0 80/30	7975 156D 00/D0 40/30	798D 1574 00/30 80/40	7992 157B 40/D0 40/30	799D 1582 80/00 60/30	799E 158B E0/00 20/30	799F 1594 80/30 80/40	798F 159C 00/70 80/30	79A1 15A4 80/70 80/30	79A2 15AD 80/A0 80/30	7977 15B5 80/D0 40/30	79A4 15BB C0/D0 40/30
					00000007	7978 15C3 00/00 80/40	7979 15CA 80/00 80/40	797A 15D1 00/40 40/30	797B 15D8 40/40 40/30	797C 15DF 80/40 40/30	797D 15E5 C0/40 40/30	7B21 15EC 00/80 00/80
					0000001E	718F 15F4 00/00 40/20	7190 15FC 40/00 40/20	7191 1604 80/00 40/20	7193 160C 00/20 40/20	7194 1614 40/20 40/20	7195 161C 80/20 40/20	7196 1624 00/40 40/20	7197 162C 40/40 40/20	7198 1634 80/40 40/20	719A 163C 00/60 40/20	719B 1644 40/60 40/20	719C 164C 80/60 40/20	719D 1654 00/80 40/20	719E 165C 40/80 40/20	719F 1663 80/80 40/20	71A0 166B C0/80 40/20	71A1 1672 00/A0 40/20	71A2 167A 40/A0 40/40	71A3 1680 80/A0 40/20	71A4 1688 C0/A0 40/40	71A5 168E 00/C0 40/20	71A6 1695 80/C0 40/20	71A7 169C C0/00 40/20	71A8 16A3 C0/20 40/20	23D9 16A9 00/E0 80/20	71FB 16B2 C0/E0 40/0C	71BD 16BB 80/E8 10/10	7625 16C1 90/E8 18/18	2A17 16C9 C0/40 40/40	7D63 16D2 A8/EC 40/13
					0000000C	7259 16DA 00/00 40/40	725A 16E1 40/00 40/40	725B 16E8 80/00 40/40	725C 16EF C0/00 40/40	725E 16F6 00/40 80/40	7260 16FD 80/40 40/40	7261 1704 C0/40 40/40	7262 170B 00/80 80/40	7263 1712 80/80 40/40	7264 1719 C0/80 40/40	7265 1721 00/C0 80/40	7266 1728 80/C0 80/40
					00000002	7267 172F 00/00 50/30	7268 1737 50/00 60/40
					00000012	7CB4 173F 00/00 40/20	7CB5 1748 40/00 40/20	7CB6 1751 80/00 40/20	7CB8 175A C0/00 40/20	7CB9 1763 00/20 40/20	7CBA 176C 40/20 40/20	7CBC 1775 C0/20 40/20	7CBE 177E 00/40 40/40	7CBF 1787 40/40 40/40	7CC0 1790 80/40 40/40	7CC1 1799 C0/40 40/40	7CC2 17A2 00/80 40/40	7CC3 17AB 40/80 40/40	7CC4 17B4 80/80 40/40	7CC5 17BD C0/80 40/40	7CC6 17C6 00/C0 80/40	7CC7 17CF 80/C0 80/40	7CD1 17D8 80/20 40/20
					0000001E	7871 17E1 00/00 40/20	7872 17E9 40/00 40/20	7873 17F1 80/00 40/20	7875 17F9 00/20 40/20	7876 1801 40/20 40/20	7877 1809 80/20 40/20	7878 1811 00/40 40/20	7879 1819 40/40 40/20	787A 1821 80/40 40/20	787C 1829 00/60 40/20	787D 1831 40/60 40/20	787E 1839 80/60 40/20	787F 1841 00/80 40/20	7880 1849 40/80 40/20	7881 1850 80/80 40/20	7882 1858 C0/80 40/20	7883 185F 00/A0 40/20	7884 1867 40/A0 40/40	7885 186D 80/A0 40/20	7886 1875 C0/A0 40/40	7887 187B 00/C0 40/20	7888 1882 80/C0 40/20	7889 1889 C0/00 40/20	788A 1890 C0/20 40/20	788B 1896 C0/40 40/20	788C 189D C0/60 40/20	706F 18A3 00/E0 60/20	7845 18A9 60/E0 30/20	6A84 18B0 90/E0 40/20	79BC 18B4 D0/E0 20/0D
					0000001E	7854 18BC 00/00 40/20	7855 18C4 40/00 40/20	7856 18CC 80/00 40/20	7857 18D4 00/20 40/20	7858 18DC 40/20 40/20	7859 18E4 80/20 40/20	785A 18EC 00/40 40/20	785B 18F4 40/40 40/20	785C 18FC 80/40 40/20	785D 1904 00/60 40/20	785E 190C 40/60 40/20	785F 1914 80/60 40/20	7860 191C 00/80 40/20	7861 1924 40/80 40/20	7862 192B 80/80 40/20	7863 1933 C0/80 40/20	7864 193A 00/A0 40/20	7865 1942 40/A0 40/20	7866 1948 80/A0 40/20	7868 1950 00/C0 40/20	7869 1956 40/C0 40/20	786A 195E 80/C0 40/20	786B 1964 C0/C0 40/20	75A3 196B C0/40 40/40	2A16 1974 C0/00 40/40	7687 197A 80/E0 40/20	786C 1983 00/E0 40/20	7867 1989 C0/A0 40/20	0051 198F C0/E0 40/20	7CEE 1994 40/E0 40/20
					00000005	7CC8 199B 00/00 80/60	7CC9 19A4 80/00 80/60	7CCA 19AD 00/60 80/20	7CCB 19B6 80/60 80/20	7D3F 19BF 00/80 00/80
					0000001D	7586 19C7 00/00 40/20	758A 19CF 00/20 40/20	758D 19D7 00/40 40/20	758E 19DF 40/40 40/20	758F 19E7 80/40 40/20	7591 19EF 00/60 40/20	7592 19F7 40/60 40/20	7593 19FF 80/60 40/20	7594 1A07 00/80 40/20	7595 1A0F 40/80 40/20	7596 1A16 80/80 40/20	7597 1A1E C0/80 40/20	7598 1A25 00/A0 40/20	7599 1A2D 40/A0 40/40	759A 1A33 80/A0 40/20	759B 1A3B C0/A0 40/40	759C 1A41 00/C0 40/20	759D 1A48 80/C0 40/20	7588 1A4F 80/00 40/20	7587 1A57 40/00 40/20	758C 1A5F 80/20 40/20	758B 1A67 40/20 40/20	759E 1A6F 00/E0 40/20	759F 1A75 40/E0 40/20	75A0 1A7C 80/E0 40/20	75DC 1A82 C0/00 40/80	78A8 1A87 C0/E0 14/14	78A9 1A8E D4/E0 14/14	78AA 1A94 E8/E0 14/14
					00000010	7A8B 1A9C 00/00 40/40	7A8E 1AA5 C0/00 40/40	7A8F 1AAE 00/40 40/40	7A92 1AB7 C0/40 40/40	7A93 1AC0 00/80 40/40	7A9A 1AC9 C0/C0 40/40	7A8D 1AD2 40/00 40/40	7A8C 1ADB 80/00 40/40	7A91 1AE4 40/40 40/40	7A90 1AED 80/40 40/40	7A94 1AF6 80/80 40/40	7A99 1AFF 40/C0 40/40	7A95 1B08 40/80 40/40	7A96 1B11 C0/80 40/40	7A9D 1B1A 00/C0 40/40	7A9E 1B23 80/C0 40/40
					00000009	7AA3 1B2C 40/00 40/30	7A97 1B35 00/00 40/30	7A98 1B3E 80/00 40/30	7AA4 1B47 C0/00 40/30	7A9C 1B50 80/30 40/30	7A9B 1B59 C0/30 40/30	7AC2 1B62 00/60 80/20	7AA2 1B6B 00/30 80/30	7D36 1B74 00/80 00/80
					0000000C	7CDB 1B7C 00/00 80/60	7CDC 1B7F 80/00 80/60	7CDD 1B83 00/60 80/40	7CDE 1B85 80/60 80/40	7CDF 1B8B 00/A0 40/30	7CE0 1B8D 40/A0 40/30	7CE1 1B90 80/A0 40/30	7CE2 1B96 C0/A0 40/30	7CE3 1B99 00/D0 40/30	7CE4 1B9D 40/D0 40/30	7CE5 1BA1 80/D0 40/30	7CE7 1BA5 C0/D0 40/30
					00000007	7CE8 1BA9 00/00 40/40	7CE9 1BAD 40/00 60/40	7CEA 1BB1 A0/00 60/40	7CEB 1BB4 00/40 40/30	7CEC 1BB8 40/40 40/30	7CED 1BBA 80/40 80/30	7D3E 1BBE 00/80 00/80
					0000000B	0000 0000 08/74 00/00	0001 0000 F0/78 00/00	0002 0000 5C/6C 00/00	0030 0000 F8/6C 00/00	0032 0000 1C/69 00/00	0033 0000 40/61 00/00	0034 0000 6C/6D 00/00	003A 0000 D0/6A 00/00	003E 0000 CC/67 00/00	003F 0000 7C/63 00/00	0041 0000 3C/6B 00/00
					00000000
					00000000
					00000000
					00000000
					00000000
					00000000
					00000000
					00000000
					00000000
					00000000
					0000000A	0036 0000 C4/72 00/00	0037 0000 F8/57 00/00	0038 0000 9C/65 00/00	0039 0000 94/4C 00/00	003D 0000 EC/63 00/00	0040 0000 24/55 00/00	0042 0000 88/63 00/00	0043 0000 8C/52 00/00	0044 0000 B4/6A 00/00	0045 0000 0C/54 00/00
					00000000
					00000000
					00000000
					00000000
					00000000
					00000000
					00000000
					00000000
					00000000
					00000000
					00000000
					00000000
00004488	0C000000
There is one entry for each texture atlas. Wait, no — there are even too many entries. But fortunately, the last entries look a little different than the others (sometimes width and height is just zero), and so I'm confident they can just be skipped. So: read only the first 70 entries, skip the rest.

For each texture atlas, a collection of textures referencing this atlas is given. A 4-B integer gives the number of textures on the atlas, and then the entries follow immediately. Each entry is in the form of
Code: Select all
2-B integer with unknown meaning
2-B integer with offset of the texture name in the previous lump
two 1-B integers giving the origin of the texture on the atlas, in pixels
two 1-B integers giving the dimensions of the texture on the atlas, in pixels, where 0 means 256.
E.g. you know the first texture atlas is referenced by 30 textures, and their names are:
  • CTA (the string at 0x00000810 + 0x0000), which is a 64×24 texture starting at (0, 0);
  • CARSHAD (the string at 0x00000810 + 0x0004), which is a 32×64 texture starting at (64, 0);
  • … and so on.
(How do I know it's origin and dimension? Well, the PSX supports only 256² textures, and in many cases, origin + dimension equals 256, but never more. I also verified one entry manually in MSPaint ;) )

Okay; this was quite a lot. I'm working on the next post while you're reading (the posts here have a character limit); if there are any questions, please feel free to ask :)

— Chris

Re: LEV files revisited

Posted: Thu Jan 03, 2013 2:20 am
by Krishty
So, let's have a look at the lump hierarchy again:
Code: Select all
00000025
00000023
+ 00000005
+ 00000022
+ 0000000C
+ 00000019
+ 00000002
+ 00000016
+ 0000001C
+ 000000FF
00000024
+ 0000001E
+ 00000001
+ 0000001A
+ 00000028
+ 00000029
+ 0000002B
+ 00000014
+ 00000018
+ 00000021
+ 00000015
+ 000000FF
The last post was about 25, 23, 05, and 22. Proceed to 0000000C:

This one looks like 00000005, but this time, empty strings (i.e., strings consisting of no more than a zero) occur:
Code: Select all
offset		value(s)
00004488	0C000000					type
				72060000					size (points to 00004B02) — unaligned again!
				<zero-terminated strings>		356 (0x164) of them in Chicago; many being empty
These are very likely model names. I have not yet found the place where they're referenced, but the number 0x164 should be remembered as it will come back later.

Now for 00000019. To be honest: I have no idea what's the purpose of this lump. It starts with a 4-B integer, and if this integer is FFFFFFFF, then 16 2-B values follow. In any case there are also three 4-B integers:
Code: Select all
00004B04	19000000
				D83C0000					size (points to 000087E4); 535 (0x217) entries (of which ca. 220 start with FFFFFFFF)
					DB000000  																				 00000000 0D000000 01000000
					FFFFFFFF 2184 428C 4290 4294 6398 839C 839C 84A0 2184 6390 A4A0 C5A4 E6A8 0000 0080 0080 01000000 0D000000 01000000
					FFFFFFFF 2184 638C 8490 A594 C694 E798 E798 089D 2184 8490 08A1 29A5 4AA9 0000 0080 0080 02000000 0D000000 01000000
					FFFFFFFF 6390 A498 C49C C4A0 E4A4 05A9 25A9 26AD 8490 C59C 46AD 67B1 88B5 0000 0080 0080 03000000 0D000000 01000000
					…
					C7000000 																				 01000000 1B000000 3F000000
					C8000000 																				 02000000 1B000000 3F000000
					C9000000 																				 03000000 1B000000 3F000000
					CA000000 																				 04000000 1B000000 3F000000
					CB000000 FFFFFFFF
I tried to associate them with the model names, but neither their number nor any value proved a relation. These values do not resemble any geometry I've found so far neither. It is noticable that FFFFFFFF most often occur in blocks of five, although there are exceptions. Ideas are welcome.

The next lump is 00000002. It can be grouped into 202 8-B entries:
Code: Select all
000087E4	00000002
				00000650					size (points to 00008E3C); 202 (0xCA) entries
					0002 0000 0003 0000
					0008 0000 8001 0000
					2000 0000 DB42 0000
					DE77 0000 0008 0000
					8000 0000 9C01 0000
					0002 0000 C400 0000
					8058 0000 0006 2058
					0002 0000 00A2 B029
					80FF 0000 0086 602D
					0002 0000 00B3 8027
					806F 0000 0006 6058
					8003 0000 80AB E022
					8003 0000 80AB B029
					0002 0000 0096 C02C
					0002 0000 009A 7028
					0002 0000 008A 0022
					00FE 0000 0073 0029
					8003 0000 8057 E022
					0002 0000 004E B029
					0002 0000 0046 802B
					0002 0000 0042 E021
					00FE DEFF 001F 0029
					…
Notice FFDE in the last line. This is one of the most common numbers, often used for models. This implies 00000002 could define an array of vertices. Actually, interpreted as X, Y, and Z, it looks like this:
Image
These points might define the shape of cars, of a skyline, or of a Chicago map (we'll see one of those later). Who knows.

Even more mysterious are 00000016 blocks. There are many of them, and in contrast to the rest of the data, they entries are rather 'fat' with 142 B each:
Code: Select all
00008E3C	00000016
				92090000					size (points to 000097D6); not aligned!
					1700 0000					???
					1100     					number of entries (+1?)
					0000 0000 0000 0E00 0000 0B00 0000 0000 4700 F8FF 0000 5400 FFFF 0000 7800 0300 1C00 4000 FCFF 4D00 4000 F5FF 7000 4000 0200 8C00 4000 FCFF E4FF 4000 F8FF B3FF 4000 F5FF 90FF 4000 0200 74FF 4000 FCFF 0000 0000 0000 0E00 FBFF 0200 1500 B5FF 0900 1C00 68FF EFFF 1C00 5AFF 1700 F2FF FBFF 0200 EBFF B5FF 0900 E4FF 68FF EEFF E4FF 5AFF 1700 0000 EDFF 1000
					0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 8300 0000 F7FF 0000 0000 0000 46FF CCFF 8303 FDFF BF01 0200 0000 0000 0000 0000 0000 0000 3C00 8900 44FC 0000 E6FF 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 B6FF F5FF 0000 4200 0600 FEFF 0000 0000 0000 0000 0000 0000 BB00 5A00 C3FF C8FF 0500 FFFF 0000 0000 0000 0000 0000 0000 0000 0000 0000
					0000 0000 0000 0000 0200 0900 EFFF 0900 0200 0000 0000 0000 8500 EDFF EAFF 0000 0000 0000 B9FF 79FF 8703 FCFF 3702 0000 0000 0000 0000 0000 0000 0000 CBFF 4B00 55FC 0000 2CFF 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 F9FF F8FF E8FF F5FF FFFF 0000 0000 0000 0000 0000 0000 0000 ED00 3A00 D0FF C0FE 1F00 FAFF F0FF 0000 0000 0000 0000 0000 0000 0000 0000
					0000 0200 0000 0100 0400 1400 DDFF 1300 0500 0000 0000 0000 8700 D2FF D4FF 0000 0000 0000 3900 38FF A403 FCFF 2F02 FCFF 0000 0000 0000 0000 0000 0000 68FF E9FF 69FC 0000 AAFE 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 2E00 FDFF CEFF BDFF FAFF 0100 0000 0000 0000 0000 0000 0000 D800 2600 D7FF 24FE 2E00 F7FF DDFF 0000 0000 0000 0000 0000 0000 0000 0000
					0000 0300 0000 0200 0600 1E00 CDFF 1B00 0700 0000 0000 0000 8800 B8FF BDFF 0000 0000 0000 A700 2CFF BF03 FCFF B301 F7FF 0000 0000 0000 0000 0000 0000 25FF 85FF 70FC 0000 62FE 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 5A00 0100 B8FF 98FF F6FF 0200 0000 0000 0000 0000 0000 0000 8400 1A00 DEFF F1FD 3300 F6FF CEFF 0000 0000 0000 0000 0000 0000 0000 0000
					0000 0400 0000 0200 0700 2200 C6FF 1E00 0800 0000 0000 0000 8A00 AEFF B4FF 0000 0000 0000 D000 44FF BA03 FCFF 4C01 F5FF 0000 0000 0000 0000 0000 0000 07FF 4EFF 71FC 0000 4CFE 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 7D00 0800 AEFF 87FF F5FF 0200 0000 0000 0000 0000 0000 0000 F5FF 1600 E8FF 40FE 2B00 F8FF C7FF 0000 0000 0000 0000 0000 0000 0000 0000
…
13 more of those follow; I won't be repeating them here. I have not yet decoded their data, but visualizing them in 3d space leads to bizarre Bézier-like curves. I'd guess it's motion capture data.

We're almost at the end of the first quarter of the file! Just two more lumps:

0000001C must be skipped entirely for now. I had a hard time finding regular patterns in it, and I think the entries are 24-B each.

Eventually, 000000FF marks the end of the super lump. Its size is always zero, and it returns control to 00000023, which has then reached its end.

In the next lump (00000024), we'll see where this neat Chicago map comes from:
Image

But I need to get some sleep first ;)

Re: LEV files revisited

Posted: Thu Jan 03, 2013 4:17 am
by PrototypeDriver
So it's actually possible to mod Driver 2 Cars?!

Re: LEV files revisited

Posted: Thu Jan 03, 2013 4:23 am
by RacingFreak
Excellent progress!

Re: LEV files revisited

Posted: Thu Jan 03, 2013 5:59 am
by Runo
Keep up the good work, legend!

Re: LEV files revisited

Posted: Thu Jan 03, 2013 8:03 am
by max.thunder
Preparing some popcorn Image

Good work

Re: LEV files revisited

Posted: Thu Jan 03, 2013 8:33 am
by PostalDude
Wonder if Stuntman's .LEV files follow a similar format.

Re: LEV files revisited

Posted: Thu Jan 03, 2013 10:07 am
by Fireboyd78
Reflections CHUNK File Format...V1. These are CHUNK files, no doubt in my mind. These are so easy to read, I can write a BMS script to split this into individual files :P

Yep, these definitely are CHUNK'd files. The dictionary up top with offsets and sizes, and then of course the sub-chunks that have lengths inside as well.

Re: LEV files revisited

Posted: Thu Jan 03, 2013 10:12 am
by PrototypeDriver
max.thunder wrote:Preparing some popcorn Image

Good work
Can i have some?

Re: LEV files revisited

Posted: Thu Jan 03, 2013 10:18 am
by max.thunder
Yeah, take a seat
Image

Re: LEV files revisited

Posted: Thu Jan 03, 2013 10:48 am
by Fireboyd78
Image

LUMP files, the grandaddy of CHUNK files. This is what I find funny...

Lump - A compact mass of a substance, esp. one without a definite or regular shape.; The first part has an ID and size, but serves as a dictionary pointing to other sub-lumps! And those sub-lumps can have a size as well!

Chunk - Divide (something) into chunks.; The dictionary containing ALL of the files are at the very top, with each sub-CHUNK following a specific format to create a special kind of file format.

Re: LEV files revisited

Posted: Thu Jan 03, 2013 6:40 pm
by PrototypeDriver
max.thunder wrote:Yeah, take a seat
Image
*take the scat* there we Go!
If this Was goin to be a very great step on modding Driver 2 we could do every thing!

Re: LEV files revisited

Posted: Thu Jan 03, 2013 9:23 pm
by Krishty
PrototypeDriver wrote:So it's actually possible to mod Driver 2 Cars?!
I have not tried writing modified data back to a CD image, but considering Driver 2 has been modded before (i.e., there is no dedicated protection mechanism), if we find out where exactly the cars are stored, they can be modded, yes.
PostalDude wrote:Wonder if Stuntman's .LEV files follow a similar format.
I've got stuntman lying around somewhere, but I'll take a look later. Driver 2 has priority now.
CarLuver69 wrote:Reflections CHUNK File Format...V1. These are CHUNK files, no doubt in my mind. These are so easy to read, I can write a BMS script to split this into individual files :P

Yep, these definitely are CHUNK'd files. The dictionary up top with offsets and sizes, and then of course the sub-chunks that have lengths inside as well.
Well, not the entire file is built up like this (because chunks are too slow for random access, which is required by PSX's low RAM). For example, the actual level is subdivided into tiles, and those are written into the file following a different format (it's actually stuff for an upcoming post). If I remember correctly, only the 1st and 3rd entry in the dictionary is readable as chunks/lumps.

To the others: Thanks for your kind words.

I'll write on then.

Edit: I won't get that post finished today; sorry :(

Re: LEV files revisited

Posted: Fri Jan 04, 2013 4:02 am
by Klancnik777
CarLuver69 wrote:Reflections CHUNK File Format...V1. These are CHUNK files, no doubt in my mind. These are so easy to read, I can write a BMS script to split this into individual files :P

Yep, these definitely are CHUNK'd files. The dictionary up top with offsets and sizes, and then of course the sub-chunks that have lengths inside as well.

CHNK files?... like driv3r also uses a CHNK format

i need to get driv3r back on my computer to see if i can do something!

Re: LEV files revisited

Posted: Sat Jan 05, 2013 4:31 am
by Krishty
Okay, so the first entry of the dictionary is parsed. Since the 2nd and 4th entries are in a different format, we'll proceed to the 3rd entry, which is quite like the 1st.

Again, this is a chunk-based format. The super lump is now 00000024.

The first sub-lump (00000001) is a list of blobs: The number of blobs is given as a 4-B integer, then for each blob its size (4-B integer) and its data follow:
Code: Select all
000B6000	24000000					type
				90340100					size
				01000000					sub-lump
					08960000					size (points to 000BF618)
					63010000					number of blobs
000B6014				A4020000					size (points to 000B62BC)
						0100 1000
						FFFF 0040 B400 0000
						1E00 1400 2400 0000
						1401 0000 1401 0000
						1401 0000 0000 0000
						37FF 98FF 0000 0000
						0000 98FF C900 0000
						B3FF 98FF BA00 0000
						72FF 98FF 8E00 0000
						46FF 98FF 4D00 0000
						0000 C8FF 0701 0000
						9CFF C8FF F300 0000
						46FF C8FF BA00 0000
						0DFF C8FF 6400 0000
						F9FE C8FF 0000 0000
						0000 1400 1D01 0000
						93FF 1400 0701 0000
						37FF 1400 C900 0000
						F9FE 1400 6D00 0000
						E3FE 1400 0000 0000
						0000 4C00 0701 0000
						9CFF 4C00 F300 0000
						46FF 4C00 BA00 0000
						0DFF 4C00 6400 0000
						F9FE 4C00 0000 0000
						0000 7C00 C900 0000
						B3FF 7C00 BA00 0000
						72FF 7C00 8E00 0000
						46FF 7C00 4D00 0000
						37FF 7C00 0000 0000
						93FF 8CFF 2D00 0000
						89FF 8CFF 0000 0000
						ACFF 8CFF 5400 0000
						D3FF 8CFF 6D00 0000
						0000 8CFF 7700 0000
						1500 0400 04 00 1A 19 0058 3F58 3F97 0097 00BF 5BFC
						1500 0400 04 19 1B 03 0058 3F58 3F97 0097 00BF 5BFC
						1500 0400 02 03 1B 1C 0058 3F58 3F97 0097 00BF 5BFC
						1500 0400 02 1C 1D 01 0058 3F58 3F97 0097 00BF 5BFC
						1500 0400 05 06 02 01 0058 3F58 3F97 0097 00BF 5BFC
						1500 0400 06 07 03 02 0058 3F58 3F97 0097 00BF 5BFC
						1500 0400 07 08 04 03 0058 3F58 3F97 0097 00BF 5BFC
						1500 0400 08 09 00 04 0058 3F58 3F97 0097 00BF 5BFC
						1500 0400 0A 0B 06 05 0058 3F58 3F97 0097 00BF 5BFC
						1500 0400 0B 0C 07 06 0058 3F58 3F97 0097 00BF 5BFC
						1500 0400 0C 0D 08 07 0058 3F58 3F97 0097 00BF 5BFC
						1500 0400 0D 0E 09 08 0058 3F58 3F97 0097 00BF 5BFC
						1500 0400 0F 10 0B 0A 0058 3F58 3F97 0097 00BF 5BFC
						1500 0400 10 11 0C 0B 0058 3F58 3F97 0097 00BF 5BFC
						1500 0400 11 12 0D 0C 0058 3F58 3F97 0097 00BF 5BFC
						1500 0400 12 13 0E 0D 0058 3F58 3F97 0097 00BF 5BFC
						1500 0400 14 15 10 0F 0058 3F58 3F97 0097 00BF 5BFC
						1500 0400 15 16 11 10 0058 3F58 3F97 0097 00BF 5BFC
						1500 0400 16 17 12 11 0058 3F58 3F97 0097 00BF 5BFC
						1500 0400 17 18 13 12 0058 3F58 3F97 0097 00BF 5BFC
000B62BC				A4020000					size (points to 000B6564)
						0100 0000
						FFFF 0040 B400 0000
						1E00 1400 2400 0000
						1401 0000 1401 0000
						1401 0000 0000 0000
						0000 98FF C900 0000
						C900 98FF 0000 0000
						BA00 98FF 4D00 0000
						8E00 98FF 8E00 0000
						4D00 98FF BA00 0000
						0701 C8FF 0000 0000
						F300 C8FF 6400 0000
						BA00 C8FF BA00 0000
						6400 C8FF F300 0000
						0000 C8FF 0701 0000
						1D01 1400 0000 0000
						0701 1400 6D00 0000
						C900 1400 C900 0000
						6D00 1400 0701 0000
						0000 1400 1D01 0000
						0701 4C00 0000 0000
						F300 4C00 6400 0000
						BA00 4C00 BA00 0000
						6400 4C00 F300 0000
						0000 4C00 0701 0000
						C900 7C00 0000 0000
						BA00 7C00 4D00 0000
						8E00 7C00 8E00 0000
						4D00 7C00 BA00 0000
						0000 7C00 C900 0000
						2D00 8CFF 6D00 0000
						0000 8CFF 7700 0000
						5400 8CFF 5400 0000
						6D00 8CFF 2D00 0000
						7700 8CFF 0000 0000
						1500 0400 04 00 1A 19 0058 3F58 3F97 0097 00BF 5BFC
						1500 0400 04 19 1B 03 0058 3F58 3F97 0097 00BF 5BFC
						1500 0400 02 03 1B 1C 0058 3F58 3F97 0097 00BF 5BFC
						1500 0400 02 1C 1D 01 0058 3F58 3F97 0097 00BF 5BFC
						1500 0400 05 06 02 01 0058 3F58 3F97 0097 00BF 5BFC
						1500 0400 06 07 03 02 0058 3F58 3F97 0097 00BF 5BFC
						1500 0400 07 08 04 03 0058 3F58 3F97 0097 00BF 5BFC
						1500 0400 08 09 00 04 0058 3F58 3F97 0097 00BF 5BFC
						1500 0400 0A 0B 06 05 0058 3F58 3F97 0097 00BF 5BFC
						1500 0400 0B 0C 07 06 0058 3F58 3F97 0097 00BF 5BFC
						1500 0400 0C 0D 08 07 0058 3F58 3F97 0097 00BF 5BFC
						1500 0400 0D 0E 09 08 0058 3F58 3F97 0097 00BF 5BFC
						1500 0400 0F 10 0B 0A 0058 3F58 3F97 0097 00BF 5BFC
						1500 0400 10 11 0C 0B 0058 3F58 3F97 0097 00BF 5BFC
						1500 0400 11 12 0D 0C 0058 3F58 3F97 0097 00BF 5BFC
						1500 0400 12 13 0E 0D 0058 3F58 3F97 0097 00BF 5BFC
						1500 0400 14 15 10 0F 0058 3F58 3F97 0097 00BF 5BFC
						1500 0400 15 16 11 10 0058 3F58 3F97 0097 00BF 5BFC
						1500 0400 16 17 12 11 0058 3F58 3F97 0097 00BF 5BFC
						1500 0400 17 18 13 12 0058 3F58 3F97 0097 00BF 5BFC
…
…
…
Surprisingly, the number of blobs equals the number of model names declared in the 0000000C lump of the 00000023 super-lump, so I'm pretty sure this is model data. If you have a closer look at the data above, you may notice the formatting: The lines consisting of four 2-B integers are vertices; the other lines are triangles and quads:
Code: Select all
0000 8CFF 7700 0000
			   ^^^^ probably texture coordinates
		  ^^^^ Z
	 ^^^^ Y
^^^^ X

1500 0400 04 00 1A 19 0058 3F58 3F97 0097 00BF 5BFC
		  ^^ ^^ ^^ ^^ vertex indices
	 ^^^^ number of vertices (0004 for a quad)
Exporting the first blob of multi-player CHICAGO.LEV this way leads to these vertices:
Image
Adding connectivity information:
Image
Obviously, the vertices are not yet right. The major problem with the block is finding out how many vertices and polygons there are, and I have not yet worked this out.

Proceeding to 000BF618, where the 0000001A sub-lump is located. I don't have an idea on this one (apart from it being 2-B values), and it is mostly empty, so I'll just skip it.

The next lump is 00000028, which is a 4-B number (the number of entries) followed by 28-B structures. Each structure begins with two signed 4-B integers, which are X and Z positions. I have not yet had a look at the other data, but I'm pretty sure it will contain model indices somewhere, because if we look at the coordinates, it does look a lot like model insertion positions:
Image

The same goes for 00000029, which seems to have the same format, but with less entries:
Image

Now for the last lump I've analyzed: 0000002B. From what I can see, it again has a layout of a 4-B integer as number of entries, and then the given number of entries. Each entry is made up of eight bytes with unknown purpose, and a 4-B integer whose value is either 00000002 or 00000003.

I have not yet looked at the following lumps, whose types are 00000014, 00000018, 00000021, and 00000015.

I'll proceed to the actual tile data the next time. A quick preview:
Image

Re: LEV files revisited

Posted: Sat Jan 05, 2013 4:39 am
by Skylabh
Really interesting :)

Re: LEV files revisited

Posted: Sat Jan 05, 2013 6:36 am
by Krishty
Just found a head at 000BD318:
Image

Re: LEV files revisited

Posted: Sat Jan 05, 2013 6:58 am
by max.thunder
Probably a pedestrian

Great job

Re: LEV files revisited

Posted: Sat Jan 05, 2013 9:57 am
by 0takumetalhead
Can't wait to see more of your findings :D

Also welcome to DM!

Re: LEV files revisited

Posted: Sat Jan 05, 2013 9:27 pm
by Fireboyd78
Congrats, you found Tanner's blocky head.

Re: LEV files revisited

Posted: Sun Jan 06, 2013 5:28 am
by Krishty
Okay, just converted the vertices and triangles (without any textures or colors) of the 355 Chicago models. Along with Tanner's head I can identify tires, limbs, traffic lights, and something which might resemble buildings.
Image
The format of a model header is:
Code: Select all
4-B unsigned int		size of the model
2× 2 B					???
2 B						FFFF if the model has vertices
3× 2 B					???
2-B unsigned int		number of vertices
2-B unsigned int		number of faces
4-B unsigned int		offset of vertices counted from after the size of the model
4-B unsigned int		offset of the faces
3× 4-B unsigned int	probably offsets of normals and colors
Vertices are given as signed 2-B integers with X, Y, Z, and zero.

Faces are a lot more complex; I'll test other LEV files first. The structure reminds of what I had seen in the Driver Texture Editor source code, but with type IDs being dramatically different and different formats due to the PSX not supporting floating-point numbers.

Re: LEV files revisited

Posted: Sun Jan 06, 2013 5:15 pm
by Fireboyd78
I can't wait to see the cars! We need to convert Driver 2 cars to Driver! And then we can also recreate them in glorious HD! :D

Re: LEV files revisited

Posted: Mon Jan 07, 2013 12:33 am
by gamersin
:shock: Good stuff, keep it up. :mrgreen:

Re: LEV files revisited

Posted: Mon Jan 07, 2013 9:09 am
by max.thunder
CarLuver69 wrote:I can't wait to see the cars! We need to convert Driver 2 cars to Driver! And then we can also recreate them in glorious HD! :D
A great idea, i know it isn't easy but it could be the beginning of a Driver 2 PC version with solved problems of frame rate and others. Only if we could import the cities into Driver 1. Although probably we couldn't use on foot.

Re: LEV files revisited

Posted: Mon Jan 07, 2013 6:37 pm
by RacingFreak
I see a Driver 2 model viewer coming in :P

Re: LEV files revisited

Posted: Tue Jan 08, 2013 3:05 am
by Krishty
I have found various buildings, trains, plants, signs, even highways. But I have not yet found any cars, sorry. Whatever will come, it will take a certain while …

Re: LEV files revisited

Posted: Tue Jan 08, 2013 3:37 am
by Fireboyd78
How are you displaying the 3D models? Noesis? Some other program?

Re: LEV files revisited

Posted: Tue Jan 08, 2013 6:42 am
by Krishty
I'm dumping vertices and triangles to PLY, then displaying them using Mesh Viewer.

Re: LEV files revisited

Posted: Wed Jan 09, 2013 2:40 am
by Maverick
Brilliant work :)

Re: LEV files revisited

Posted: Wed Jan 16, 2013 10:29 pm
by Submaniac
Wow man! That's impressive to say the least. (To me at least!)

Keep up the awesome work =D