Tag Archive for 'gta2engine'

GTA2 Engine – Source tree

Luckily MSVC6, which was used to compile GTA2 (at least originally) leaves a lot of interesting stuff behind, here is the approximate source tree recovered from strings in executable file (it includes some of files, far from entire list):

  • C:\gbh\coop101release\car.cpp
    Car respraying. Trailer handling (it has some strings connected to putting cars on trailers, and handling trailers)

  • C:\gbh\coop101release\carinfo.cpp

  • C:\gbh\coop101release\char.cpp
    References to police peds and normal peds visible on screen (it might have been managing different types of pedestrians, and possibly storing their stats & parameters)

  • C:\gbh\coop101release\collide.cpp
    Collision detection (generic)

  • C:\gbh\coop101release\display.cpp

  • C:\gbh\coop101release\diutil.cpp
    DirectInput. Joystick handling.

  • C:\gbh\coop101release\door.cpp
    Door code (map doors which are placed by script, like garage doors).

  • C:\gbh\coop101release\File.cpp
    File IO, reader for chunked files

  • C:\gbh\coop101release\frontend2.cpp
    Frontend code (references to TGA graphic files)
    Plays intro movie. Seems to be loading car handling data.

  • C:\gbh\coop101release\game.cpp
    Counts some bonuses (accuracy bonus, something else?).
    Tracks number of spawned cars, mission cars, etc. Must also track game money, lives, etc

  • C:\gbh\coop101release\input.cpp
    Keyboard input, remapping input
    References chunks KBIT and KIDX (these do not seem to be used in any of resource files)

  • C:\gbh\coop101release\kanji.cpp
    References to chunk KANJ, seeming from file data\kanji.dat.
    It seems that this file is chunked file, and someone suggested it exists only in PS1 version. Time to get PS1 version somewhere…

  • C:\gbh\coop101release\keybrd.cpp
    Keyboard mapping, loads info from data\keyboard\eng_kb.cfg file (or any other one, depends on language)

  • C:\gbh\coop101release\main.cpp
    Has reference to ExitGameCallback function or routine
    Seems to be checking for multiplayer compatibility (on start), references these messages:

    Player %s: Car handling file 'nyc.gci' is different
    Player %s: Game file 'GTA2.EXE' is different
    Player %s: Script file '%s' is different
    Player %s: Style file '%s' is different
    Player %s: Level file '%s' is different
    Player %s: Debug flags are different
    Player %s: Language version is different
    

  • C:\gbh\coop101release\map.cpp
    Loads map data from GMP map.
    References chunks RGEN LGHT ANIM MOBJ ZONE DMAP
    As you can see, it only loads DMAP compressed chunk, although map files contain CMAP and UMAP maps too. It also skips some unknown chunks, possibly left by GTA2 map editor for storing temp stuff like current camera view position (in editor).

  • C:\gbh\coop101release\medical.cpp

  • C:\gbh\coop101release\Memory.cpp
    Memory manager, also manages textures

  • C:\gbh\coop101release\miss2.cpp
    MISS2 virtual machine. References strings:

    svmiss
    svscore
    svdone
    kfstart
    kffail
    kfpass

  • C:\gbh\coop101release\movie2.cpp
    Runs intro movie (from BIK file)

  • C:\gbh\coop101release\multip.cpp
    Contains some dialog box, seemingly the dialog you see when you try to start new MP game. Sets server parameters (time limit, game speed, police, game type, map). Does not allow connecting if you dont have target map.

  • C:\gbh\coop101release\NetworkX.cpp

  • C:\gbh\coop101release\object.cpp

  • C:\gbh\coop101release\park.cpp

  • C:\gbh\coop101release\particle.cpp

  • C:\gbh\coop101release\physics.cpp
    Physics handler/physics engine for cars (and maybe bullets)

  • C:\gbh\coop101release\player.cpp
    Refrences these player death reasons: shocked nicked fried wasted (“nicked” doesn’t seem to be used anywhere in-game though)

  • C:\gbh\coop101release\plydat.cpp
    These are default player names:

    	ALISDAIR
    	BILLY
    	BRIAN
    	COLIN
    	IAIN
    	IAN
    	KEITH
    	MARTIN
    	STEPHEN
    	WILLIAM
    

    There are also references to these default highscore names:

    	JACKSON
    	IMOGEN
    	HECTOR
    	GRAEME
    	FRANK
    	ERIC
    	DAVE
    	COLIN
    	BRIAN
    	ALAN
    	MUCHCASH <-- cheat code for a lot of money
    

  • C:\gbh\coop101release\pubtrans.cpp
    Public transportation. References some navigation paths (for trains?)

  • C:\gbh\coop101release\registry.cpp
    Registry handling. References some registry keys (and also debug flags which are stored in registry)

  • C:\gbh\coop101release\sprite.cpp

  • C:\gbh\coop101release\style.cpp
    Loads STY files. Has reference to following chunks:
    RECY (car recycling info)
    SPEC (unknown chunk)
    OVLY (unknown chunk, possible overlays data, whatever that would be. It might be from PS1 version, need to get those style files and check...)
    PSXT (PS1 tile graphics, not present in PC version style files)
    CARI (car info)
    DELX (delta index)
    DELS (delta store/data)
    TILE (tile graphics)
    SPRG (sprite graphics)
    PPAL (physical palettes)
    PALX (palette index)
    OBJI (map object info)
    SPRX (sprite index)
    FONB (font bases)
    SPRB (sprite bases)
    PALB (palette bases)
    GBST (style file header)

  • C:\gbh\coop101release\taxi.cpp
    Taxi handling. References these briefing messages (message references are not present in rockstar.com version): 8013 8012 8011
    Seems to be ability to drive pedestrians around in taxi, cut from final game. These are the briefings (they do not seem to make much sense):
    [8011] z!I'll take care of him. You can go now!
    [8012] z!What the hell is going on?! He wasn't supposed to kill him! Assassinate the real traitor!
    [8013] YOU'RE DA IRON MAN!

  • C:\gbh\coop101release\text.cpp
    Loads GXT files (text/briefing/messages data).
    References these chunks: TDAT TKEY GBL%c (last one is different for language picked)

  • C:\gbh\coop101release\tileanim.cpp
    Handles tile animations

  • C:\gbh\coop101release\user.cpp

  • C:\gbh\coop101release\video.cpp
    Video properties (sets video gamma, something else)

  • C:\gbh\coop101release\weapon.cpp

  • C:\gbh\coop101release\winmain.cpp
    Wrapper for WINAPI functions. References to mutexes COOP MUTEX and GBH MUTEX

GTA2 Engine – General info

(I have a month of exams, so updates will be coming out once per two days, or most likely just randomly)

While working on OpenGTA2 I spent (and still spending) some time on actually reverse-engineering GTA2 engine. It’s not source code reverse engineering – but rather I’m just working out how the engine handles different stuff, etc. This gives some interesting ideas.

In this post I’ll tell you about some general stuff about GTA2 engine and it’s developement environment. Right now I have two versions of GTA2 on my hands – one is official russian translation from Buka (released back in 1999), and the other one is GTA2 downloaded from Rockstar official website (at least I think it is, because someone else downloaded it for me).

First thing to notice is that these two versions are very different:
GTA2.EXE (rockstar.com)
File date: 27 april 2004
File size: 1.58 MB (1 667 072 bytes)
File version: 9.6

GTA2.EXE (Buka)
File date: 22 november 1999
File size: 2.80 MB (2 944 512 bytes)
File version: 10.1



It is interesting that version you can download from official website is older than one released long time ago. It also contains a lot of bugs, for example there is a bug with sound system in 9.6 which was fixed in 10.1 (it causes some sounds to be played at 255% pitch without no obvious reasons). More about bugs in one of next posts.

The Rockstar version was compiled from c:\code\gta2\source\ folder, while the Buka one was compiled from c:\gbh\coop101release\ folder (it is the original version, as you can see the reference to early GTA2 name – GBH).



There are no differences in what registry keys these both versions use:
Software\DMA Design Ltd\GTA2\Network
SOFTWARE\DMA Design Ltd\GTA2\Sound
SOFTWARE\DMA Design Ltd\GTA2\Debug
SOFTWARE\DMA Design Ltd\GTA2\Option
SOFTWARE\DMA Design Ltd\GTA2\Control
SOFTWARE\DMA Design Ltd\GTA2\Screen%sd%
SOFTWARE\DMA Design Ltd\GTA2\Player



And also there is no difference between files these versions use:
test\error.log (debug error log)
test\warning.log (debug warnings log)
data\s.gxt (spanish translation)
data\j.gxt (japanese translation, not present in either version)
data\i.gxt (italian translation)
data\g.gxt (german translation)
data\f.gxt (french translation)
data\e.gxt (english translation)
data\r.gxt (russian translation, only in Buka version)
data\movie\intro.bik (short snippets from the “GTA2: Movie”)
data\movie\preintro.bik (rockstar logo)
data\fstyle.sty (graphics files for the menu screen)
data\nyc.gci (car handling file)
player\data\q.scr (unknown script file – for debugging?)
data\style.sty (unknown graphics file)
data\jointmap.gmp (unknown map file)
test\replay.rep (test replay playback file)
data\kanji.dat (unknown file – not present in either of versions)
player\plyslot%d.svg (save file data)
test\MISSLOG.TXT (mission log file)
player\hiscores.hsc (highscores file)
data\audio\ (GTA2 sounds)
data\gtaudio\ (radio station files)
data\audio\vocals\ (GTA2 narrator sounds)
data\attract\attr1.rep (replay files)
data\attract\attr2.rep
data\attract\attr3.rep

Curious note: the Rockstar version has only e.gxt and s.gxt file, and it seems that kanji.dat file exists only in Japanese version of GTA2 (there was japanese version?).

Seeing how the rockstar.com version seems to be older than the one originally released, they might have lost the original sourcecode.