Skip to content
angreePublic

About

Amiga porting attempt of GTA 1

Resources

Stars

27 stars

Watchers

2 watching

Forks

Latest commit

 

History

15 Commits

Folders and files

Repository files navigation

AmiGTA

A native AmigaOS 68k port of Grand Theft Auto (1997), targeting classic hardware — 68020 and up, AGA or RTG. Not PiStorm, not Vampire, not Emu68.

This is a reimplementation of the engine, not a wrapper and not an emulator. It contains no game code and no game data. You supply your own copy of GTA and the port converts it on your own machine.

Current release: v0.4.0 — the missions work. The game opens on its own title screen; the level starts where the script says; the South Park phones ring; answering one gives you a job, an arrow and a car to steal, and delivering it pays. Liberty City's first two missions play from the phone to the pay-out, including the second one's passenger. The HUD is the original's own — the wanted level's flashing cop heads, the weapon in hand, the pager scrolling through its device, the brief box with its icon, MISSION COMPLETE across the middle. And a car can jump a gap. See what is and is not in it.


Download

Grab the archive from Releases. It has the game, a settings editor, a data converter, a startup script and a README. It has no game data — step-by-step setup instructions are in the README inside the archive.

One binary, since v0.0.4. v0.0.3 shipped three — gta-aga, gta-rtg240 and gta-rtg480 — which were the same program built at three screen sizes, so the player had to pick their display by picking an icon. The screen is a setting now:

screen what it is
320x200 AGA. The reference; every speed figure is measured at this size.
320x240 CyberGraphX / Picasso96. More of the city on screen.
640x480 RTG, really rasterised at 640x480 — every tile, car and person at the art's own size, nothing stretched, twice as much city on screen. About four times the drawing.
640x480 doubled RTG. Renders 320x240 and doubles every pixel: the picture of 320x240 on a 640x480 screen, for almost nothing. What a plain 020 wants.

Measured on the RTG calibration machine (68020 core, throttle standing in for a faster CPU, JIT off): 38.4 fps doubled, 14.7 fps native. That is the whole trade, and it is why both are offered instead of one being called "640x480".

Settings

gtaprefs is a small Intuition window that picks the sound path (Paula or AHI), the display path (AGA, RTG or a window on Workbench) and the screen size, and tells you which of those your machine actually has. It writes gta.prefs next to the game.

It needs no mouse — A, G, R, S and Esc drive it — and it has a command line for machines with no working pointer at all:

gtaprefs SHOW              print the settings and what was detected
gtaprefs GFX=WB            set it and save, no window
gtaprefs SCREEN=640x480    the size the game opens at
gtaprefs AUDIO=AHI

On MorphOS, use the native build instead — see MorphOS. If you do run these 68k binaries there under emulation, set Graphics to Window (gtaprefs GFX=WB): they otherwise open a screen of their own, cannot get an 8-bit mode, fall back to the planar + c2p path that needs the real Amiga chipset, and draw the city as colour noise.

Sound does not play on the Amiga yet; the setting is recorded for when it does.

You need a 68020 or better (no FPU is required and none is used), about 8 MB of fast RAM, and your own copy of GTA (1997) for the PC. The DOS 8-bit release is what it was built against; the 2002 Windows re-release carries the same data files, so that works too. Two files are required (the art and the map); five more are optional and make the game whole — the level script for the crates, the texts for the pager, and three fonts. The README in the archive lists them.

What v0.4.0 actually is

Works: the city renders in 2.5D with correct projection and no gaps in the geometry; you walk, run and turn; pedestrians keep to the pavements, turn corners, cross roads at a run and are knocked down or killed by a car; traffic drives itself along real routes, gives way, queues, takes corners as an arc, stops for a person in the road, and steers rather than slides — a car blocked off a junction changes lane through an S-curve after looking down the new lane, a car with nowhere to go turns round, and a car shoved off its lane steers back onto it; cars climb every ramp in the city and are drawn on it rather than under it; getting in and out of a car is animated door-by-door, you vault the car when you approach it from the far side, drag the driver out if there is one, and ride a bike or a convertible in view; the driven car has the original's own physics — mass, moment of inertia, contact point, and cornering that rotates the car when you clip it rather than sliding it bodily; cars collide with each other and with walls, and neither of them can be pushed through the other or thrown out of a contact; all five weapons work — fists, pistol, machine gun, rocket launcher and flamethrower — and the street reacts to a shot; cars take damage from crashes and gunfire, wear the dents, and at a hundred points burn and explode, taking whatever is parked next to them with them, and leave a burnt-out wreck behind; a rocket leaves fires burning on the wall it hits; the police: a wanted level from the original's own heat rules, patrol cars, cars sent by the level's quota that chase, cut you off and ram, a cop who gets out and arrests you — or shoots, when you are armed or the level is high — roadblocks across the exits of your district at level 3, BUSTED with the multiplier halved and your weapons gone and the release outside a police station; you can die: health, armour, four lives, WASTED, the hospital; the crates from the level script hold the weapons and the rest — armour, bribes, multipliers, jail-free cards — and you start with your fists, as the original does; traffic lights run and are drawn, and pedestrians wait at the kerb and cross on the green; the score, the pager line and the BUSTED / WASTED cards are drawn in the original's own fonts from its own text file.

THE MISSIONS. The level script is read and run — both halves of it: the 575 objects a level is played with, and the 2116 commands of its logic, at the original's own rate of one command per process per tick. The level starts itself, because the block the script puts you on is also the trigger that begins it. The four South Park telephones ring; walk up to one on foot and the job starts; the arrow points the way the original places it, out in the street rather than over the target; the car appears where the script parks it and stays there however far away you are; stealing it pays, delivering it to the right garage pays more, and the game rings you back on another phone for the next job. Missions 1 and 2 of Liberty City play end to end, the second with a passenger to pick up on the way.

THE UI IS THE ORIGINAL'S. Its icons were in the art all along, in a sprite category nothing had opened: the wanted level's cop heads flashing across the top, the weapon in hand with its ammunition, armour and the jail-free card down the left, and the three text displays the game actually has — the brief box along the bottom with an icon and its text wrapped above it, the pager at the top left with the line scrolling through the device, and the big two-line card in the middle. The score has the multiplier under it in the font the original keeps for nothing else.

THE FRONT END. The game starts on the title screen, logo animating, with START GAME and QUIT in the game's own menu font.

And a car can jump. A ramp with a hole after it is a jump, and the arc is the original's: it clears the water at (91,105..108) and lands on the far ramp. Spray shops work too — drive in, the car changes colour and the police lose interest.

Not there yet: missions past the second — the rest of the script's vocabulary is written up and the game's own log says which commands it reaches next; no sound; the police cars have no siren; tyre marks, blood and oil are not drawn; only Liberty City.

Speed: 60.3 fps at 320x200 on the project's calibration machine — a 68020 core with the throttle set to stand in for a faster CPU, JIT off. That number is a measurement on one specific configuration, not a promise about your Amiga.

How it was made

The engine is written from scratch as native 68020 code — fixed point throughout, sin/cos lookup tables, built around c2p — rather than translated from anything. The original's behaviour is the specification: how fast a car accelerates, how far it slides, how the AI picks a route and when it brakes, how much a collision pushes and how much it spins. Those numbers are the game's own rather than values tuned by hand until the result looked plausible, which is why the comments in native/gta_traffic.c and native/gta_vehphys.c read the way they do.

The data layer follows the official DMA CityScape Data Structure spec and the MIT-licensed Carnage3D project.

The platform layer — AGA screen handling, c2p, RTG, Paula audio, the soft-float fixes for the m68k GCC — is carried over from the same author's openttd_amiga_68k and OpenXcom ports.

There is no floating point anywhere in the game code. On this target it is not an optimisation but a hazard: Kickstart 3.1's mathieeesingbas.library has broken single-precision multiply and divide entries on FPU-less machines, and 68040/68060 FPUs are partly trap-emulated anyway.

MorphOS

There is a native PowerPC build for MorphOS. It is not the 68k binary under emulation — that does not work, and the reason decided the shape of the port: the RTG path asks CyberGraphX for an 8-bit screen and falls back to AGA when there is none, and modern MorphOS hardware frequently offers no 8-bit chunky mode at all. The fallback then allocates bitplanes and runs Kalms' 68020 chunky-to-planar against a chipset that is not there.

tools/bin/build_morphos.sh                      # AmiGTA-morphos + the three tools
make -f makefile.morphos release ARCHIVEDIR=    # the shippable drawer, archived

build_morphos.sh sits beside build.sh and has the same shape — same root discovery, same compile helper, same written-out file list, same refusal to strip. makefile.morphos adds only the beta / release staging and archiving; they write into ram: by default, so pass ARCHIVEDIR= on the Linux cross box where that is not a path.

Toolchain: ppc-morphos-gcc-9 with the MorphOS SDK at /gg. Nothing else — no vasm, and no vendored CyberGraphX headers: cybergraphx/ is part of the MorphOS SDK, so the "you must supply your own" rule below does not apply here.

The whole engine is compiled from the same sources the Amiga build uses. It was already portable: fixed point throughout with no floating point anywhere, and GTA's little-endian data files read a byte at a time rather than by casting a struct over them, because the same code has to build for the big-endian 68k and for the host test harness. PowerPC is big-endian too and got that for free.

What changes is the platform layer, and only that:

native/morphos_gfx.c new. The RTG path natively — screen, palette, blit, input. Replaces amiga_gfx.c, whose other three backends are Chip RAM bitplanes and c2p.
native/morphos_audio.c new. The amiga_audio.h contract over AHI. Replaces amiga_audio.c, which does not drive an audio API — it drives Paula.
native/amiga_uclock.c TimerBase is struct Library * here, plus a timer.device sleep for the frame cap.

Everything MorphOS-specific is under #ifdef __MORPHOS__. amiga_gfx.c, amiga_audio.c, amiga_startup.c, amiga_trap.c, fp_single.c, fp_conv.c, libnix_fixes.c and the four assembler files are not built at all.

Three differences you will notice:

  • 640x480 by default, really rasterised. The doubled variant exists because a 68020 cannot draw four times the pixels at a playable rate — a statement about that CPU. All four sizes stay selectable with gtaprefs SCREEN=....
  • Sound is AHI, using whatever output you have set up in AHI's preferences. Every audio setting except OFF opens it, PAULA included.
  • The frame cap sleeps on timer.device instead of spinning. A G4 would otherwise pin a core at 100% for fifteen of every sixteen milliseconds and look hung while running perfectly.

The 68k build is unaffected, and that is checked rather than asserted: with __MORPHOS__ undefined, every shared file preprocesses byte-for-byte identically to the commit this branched from.

Not verified: the MorphOS build has not been run on a MorphOS machine. It compiles clean; the AHI backend in particular has never made a sound.

Building

Toolchain: bebbo amiga-gcc 6.5.0b, plus vasm. The build runs under WSL or any Linux. (For MorphOS see above.)

tools/bin/build.sh          # the Amiga game, the settings editor, the converter
tools/bin/build_host.sh     # the renderer as a host binary, for fast iteration
tools/bin/package.sh        # the release archives

You must supply CyberGraphX developer headers yourself. They are copyright phase5 digital products and not redistributable, so they are not in this repository. Put cybergraphx/, clib/, inline/, libraries/ and proto/ into native/cgx-include/ and the RTG build will find them.

Some flags are not negotiable, and each one cost real time to find:

  • -O1, not -O2 — -O2 breaks C++ exception unwinding on this toolchain.
  • -mcpu=68020 -msoft-float — -m68040 silently selects the 68881 multilib.
  • never -lpthread or -lc — they pull newlib in beside libnix.
  • never strip — m68k-amigaos-strip produces a Hunk executable that halts the machine: black screen, no Guru, no output.
  • never call sprintf — it produces nonsense on this libc. snprintf, fprintf and the v* forms are all correct.

The shell scripts and the WinUAE configs carry the author's own paths (I:\GITHUB\Amiga_GTA, C:\temp\amiga_gta). build.sh and build_host.sh work out the repository root from their own location; the rest are development harness and you will want to edit them.

Testing

The renderer has no Amiga headers in it, so the same code builds and runs on the host in a second instead of a two-minute emulator round trip:

build/host/gtadump view   <nyc.cmp> build/data/style001.til 64 64 320 200 out/v.bmp
build/host/gtadump column <nyc.cmp> 66 62      # every field of one map column
tools/bin/holecheck.sh                          # must print 0

holecheck.sh is the renderer's regression test. A black tile and an undrawn pixel look identical, and GTA's roofs are full of dark tiles, so gaps in the geometry are invisible to the eye — it clears the frame to a colour Liberty City never uses and counts what survives.

The game is driven from inside the emulated machine, from a script in tools/scripts/, never by synthesising host input.

Licence

MIT — see LICENSE.

Two files are not mine and keep their own headers: the chunky-to-planar kernels native/c2p1x1_6_c5_bm_040.s and native/c2p_rect.s, both © Mikael Kalms. The wrappers around them are MIT like everything else. What is included but not mine, and what is deliberately absent, is set out in THIRD-PARTY.md.

Credits

  • Mikael Kalms — the c2p kernels, the fast part of every frame.
  • DMA Design — Grand Theft Auto, and the CityScape Data Structure specification they published.
  • Carnage3D (MIT, © 2019 jericho) — the reading of the data formats.

Grand Theft Auto is © DMA Design / BMG Interactive / Take-Two Interactive. This project is not affiliated with any of them, and it ships nothing of theirs.

About

Amiga porting attempt of GTA 1

Resources

Stars

27 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages