siegemund.dev

HG Engine

This project is based on the idea to create an accurate re-implementation of the Hired Guns game engine. This is finally achievable now because the game's original source code has been released in 2021. Its code has been written in 68k Assembler, except the accompanying asset processing and UI-tools. So for today's standards the assembler code is not so common to read and understand (although Scott's comment lines and variable naming are pretty good). And it's time consuming, even if several parts can be translated with the help of AI. That's why this project needs to have some focus, especially in the beginning.

There are two major goals of the project.

Goal 1: Accurate Core Engine

The primary goal ist to recreate the core engine in ANSI-C that is compiled to WebAssembly (WASM) so the implementation can be used in nearly any kind of environment with a runtime/language that can execute and use WASM. All the visualization concerns of the game world, including user input, audio etc. are completely decoupled from the core using a simple API as part of the WASM Bridge.

The core engine handles all game logic, physics, state calculations & updates, including player & monster movements, etc. as close to the original game as possible. To achieve this goal ANSI-C has been chosen as the implementation language. It not only is rather simple, has a small footprint and is the closest to Assembler. Most importantly it supports goto-statements anywhere. This seems to be an relict of the past, a true anti-pattern to today's standards. But in Assembler you usually not only call subroutines but use jumps to labels a lot. Allowing goto-statements in the new code is the only way to easily compare the original Assembler code with the re-implementation in C, especially to not overlook something important and to find missing spots. Of course, this can be refactored at a later stage, when plenty of tests have been implemented.

Goal 2: Authentic visualization

This goal tries to achieve an authentic recreation of the original pseudo-3d game in a modern 3d engine. The mood of the original game should be retained including high resolution versions of textures and models. This includes the right amount of lighting and shading as well as FPS-perspectives with rather extreme FOV aligned to the original faked 3D views.

Right now, the project includes a web-based frontend using the low level Three.js 3D engine (based on WebGL) and other Web-APIs. A web-browser is not only the primary environment for executing WASM binaries but the implementation in JavaScript is also pretty easy to understand and a good starting point to learn about the architecture. This can also help if someone plans to implement his own frontend using e.g. Go or Rust and a different graphics engine / visualization approach.

The web frontend runs the WASM game loop which allows examination of all the runtime events as well as the map structure and game logic in detail. It can also be played partially, a game mode is planned, too.

Non-Goals

A non-goal for the web frontend is to recreate the original 2D graphics system like in the Amiga version. Additionally all the other platform-specific things are dispensable like the original audio system (which is very specific to the Amiga hardware) or supporting all the input devices of the original game.

Furthermore, all parts of the game which don't belong to the core gameplay, are a non-goal. This includes all the other frontends of the game like menus, character selection, world map etc.

Right now, the web frontend is only for trying out the implementation progress and state visualization. But it has no editing capabilities yet because a pretty good replacement for the original Amiga editor has already been implemented for Windows.

Features

  • Opening and viewing maps with some geometry trimming and filtering options to focus on some floors or to look inside
  • some basic optimized mesh building (partly) for solid performance
  • Logic Layer View to easily see what things are how connected on the map
  • integrated runtime mode for a single player perspective

Map Viewer (Old)

HG Engine map viewer

Architecture

HG Engine architecture