Summer interrupt

Sorry for the summer interrupt, it’s just that I had exams first, but now I’m done with them, and I’m gonna move to other place for summer, away from the internet - so there will be less than one post each week. Or something like that.

I’m done with my exams, I’ve mostly did flying in X-Plane during this time, recorded this video of a short B-1B Lancer training mission:

I’ve did a 6-hour flight to a flight-in last Sunday, and will do a 9-hour flight next Sunday. Why? I dunno, it’s kinda entertaining… It was a mach-1 flight from Edwards AFB to Nuuk, Greenland. Sunday one will be from Thule, Greenland to Thaiti! From cold to hot.

screenshot_9

I might do some more posts later, but by this moment I did not do any programming for two weeks, and I feel like the very moment I’m gonna open a source file, I’ll be coding for next 10 hours, so I guess I’ll open OpenGBH project soon (aka OpenGTA2).



X-30 landing video

I did some landing practice today, and I recorded a better video - I tuned up rendering settings to “very high”, and this is how it looks like (although I think I should have set higher texture quality instead of more objects):

I’m afraid X-30 aerodynamics do not allow to descend more sharply than that - it has no flaps, so the descent/landing has to be done smoothly. It’s unusual, but you can live with it. Most likely X-30 lacks flaps because those are unneccessary complexity to already very complex wings (not only they have ailerons on them, but also entire fuel system flows jet fuel through wings to cool them down, so they don’t melt from excessive heat when flying at high speeds).



XS6

XS6 was another X-30 mission, but this time suborbital mission - the vehicle never really reached the orbit. I started with full load of jet fuel, and flew to Antonov Intl. It took only 1 hour to cross ~6000 miles (at speed of 12 mach).

Antonov Intl. seems to be a perfect airport for X-30 - the runway is long enough to launch and land, although there are trees right near runway base, and I usually fly over them at height of 5-10 meters.

I encountered a technical problem mid-flight when fuel system of scramjet #1 failed, resulting in constant fuel flow fluctuation, which didn’t affect the flight much though. But at some point the engines stopped! I considered returning to Edwards AFB, but I successfully restarted the engines, and reached Antonov Intl.

Here’s video of the landing:

Flying over Cherkasy:
screenshot_45



XS5 video recordings

A bit late, but I updated X-Plane to beta #12, and it allowed me to load replays from XS5 mission (they seemed to be broken previously).

Here is the launch video, but too bad that there’s a bug that prevents rocket exhaust from being seen (but rocket engines are activated). I had to cut a lot from it, because it’s mostly boring, I left the best parts here. It shows acceleration from 0 km/h to about 28000 km/h. That’s 7.8 km/sec, and it’s the orbital speed for 430,000 feet (124 km).

You can hear loud noise when it lifts off - because it does so at about 300-400 km/h. Why so fast? The X-30 lacks flaps or anything like that, so it has to gain huge speed before it can lift off. It also starts with initial weight of 270 tonnes. You can imagine forces that main gear should withstand - it probably needs to be replaced after every flight.

Oh yeah, I did some mistakes while transcoding videos, so the sound is broken in some parts:



This is re-entry, I had to cut it down from 28 minutes. I left the trajectory a bit early, and ended up 50 miles away from Edwards, but I got a chance to fly over Los-Angeles, and do some sightseeing from height of 24km (80,000 feet).

The landing wasn’t perfect, I didn’t land on this runway before and kind of underestimated it’s size. This runway is 7 km long, so that is not really a problem. Oh yeah, the engines sound as if they would turn on, that’s cause of airflow making them spin + it’s a bug in X-Plane:

Also here’s “artists impression” (I am the artist, and impression is my poor photoshop of the screenshot) of how X-30 reentry could look like. It has only slight basis on reality, and the fire color might be different in reality (due to specifics in the heat shield materials used):
x30reentry



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.



XS5

Another mission complete - XS5 didn’t end in much success (I didn’t manage to fly over polar caps, missed them by few hundred miles), but I recorded re-entry and launch sequences and although I have problems playing them right now, it should be fixed in new X-Plane version, so I’ll be able to record a video.

X-30 behaved perfectly good in this trip, all systems were working as intended (except that I forgot fuel indicator in the on-board system, I should really fix it).

As usual, some screenshots:
x30feed2

You can see that X-Plane actually renders only small part of the earth (at least when you are not very far up), so you can see “edge of the world”, and also some weird grid-like artifact:
screenshot_44

Picture from re-entry at high altitude:
screenshot_63

Guess what city this is:
screenshot_681

Circling around Edwards AFB to loose the remaining speed and altitude:
screenshot_72



Flying around

I didn’t do much today, just some flying and stuff. Nothing intersting, but here are some screenshots and videos I took, in case you are interested:

screenshot_19
screenshot_24

And here’s neat comparsion between my Buran and real one (you can see some problems with the nose, and the tail seems to be too big):
compar