Git Product home page Git Product logo

dpt / the-great-escape-in-c Goto Github PK

View Code? Open in Web Editor NEW
111.0 13.0 12.0 5.66 MB

Classic ZX Spectrum game "The Great Escape" rewritten in portable C

Home Page: http://www.davespace.co.uk/the.great.escape/

Python 0.30% C 92.62% Objective-C 3.37% Makefile 0.71% C++ 1.29% CMake 1.36% Shell 0.30% Rich Text Format 0.05%
game c zx-spectrum reimplementation port macos windows retrogaming remake isometric

the-great-escape-in-c's Introduction

“The Great Escape” Ported to C

Build status

© David Thomas, 2013-2022

17th April 2022

Demo

Overview

This is a port to C of “The Great Escape”: the classic isometric 3D game for the 48K Sinclair ZX Spectrum in which you execute a daring escape from a wartime prison camp. Very loosely based on the film of the same name, it was created by Denton Designs and published in 1986 by Ocean Software.

Over here I reverse engineered the original game from a binary snapshot of the Spectrum version, decoding the graphics, data tables and all of the logic. Originally written in Z80 assembly language, I have translated it into portable C code where now builds and runs exactly like the original on macOS, Windows and RISC OS but without the need of an emulator.

The portable C sources have allowed builds for the web, using emscripten and even the BBC Micro, via a Raspberry Pi second processor.

Project Write-up

http://www.davespace.co.uk/the.great.escape/ (2019)

Goals of the Project

  1. Fully disassemble, document and understand the original game.
    • Attempting to reimplement the game logic forces you to explore every nook and cranny of the game logic, enabling a complete reimplementation to be made and the original code fully understood.
  2. Reimplement The Great Escape in portable C code.
    • While being as accurate a recreation of the original as possible.
  3. Fix some bugs in the original game.
  4. Analyse the before-and-after metrics.
    • How much bigger and slower is the compiled C reimplementation compared to the original game?
    • What can we learn from the original’s tight coding techniques?
  5. Provide a basis for porting the game to contemporary systems of the ZX Spectrum.

Running the Game

The port is an exact recreation of the ZX Spectrum version of The Great Escape including the input device selection menu. It builds and runs on macOS, Windows and RISC OS. The macOS version is currently the "best" featuring the menu music and sound effects which the Windows port lacks.

When you start the game hit 0 to start - this will let you define your preferred keys. You could also choose 3 for Sinclair (keys 6/7/8/9/0). The macOS port will let you choose Kempston and use the arrow keys and . for fire.

There are various other controls which vary by OS. On macOS consult the menus for keyboard shortcuts.

The front-ends attempt to always preserve the game's aspect ratio and snap to whole pixels.

Current Builds

Port Maintained? Notes
macOS CMake Yes My default build; the most likely to be up-to-date. To build use cd <src> && mkdir build && cd build && cmake .. && cmake --build ., or build.sh which does the same.
macOS native Probably To build open up the Xcode project platform/osx/The Great Escape.xcodeproj and build that using ⌘B. Run using ⌘R.
Windows CMake Yes CMake build - like above
Windows native Probably Needs Visual Studio 2013. Trunk build lacks sound and UI niceties (but there are improvements on a branch somewhere...) To build open up the Visual Studio solution platform/windows/TheGreatEscape/TheGreatEscape.sln and build that using F7. Run using F5.
RISC OS Yes Runs on RISC OS 3.1 or later. Sound requires a Risc PC or later with a 16-bit sound system. To build this uses GCCSDK and CMake. If you're nutty enough to want to build the RISC OS version then you might want to talk to me first, or take a look at riscos-ci-build.sh.
Makefile Occasionally This builds a minimal headless (no display) version of the game for testing. It runs the game for 100,000 iterations of the main loop then stops.
SDL Perhaps SDL build. No sound or UI niceties and broken timing.
Browser, via emscripten Maybe Try it here using the arrow keys and . for fire. This uses the SDL build but targets emscripten. The structure of the game is not exactly amenable to the browser world (the RISC OS build has a similar issues).

Consult the github actions file for exact build commands.

Components

TheGreatEscape

This is the main game reimplemented in a single (static) library.

ZXSpectrum

Defines an interface to a virtual ZX Spectrum to which the game talks, replacing the bare-metal IN and OUT instructions and providing a screen to draw to, its border, a keyboard and a speaker. This can convert the Spectrum screen memory to 4bpp or 32bpp pixel formats pretty quickly.

Source Layout

./
    include/            - public headers
        TheGreatEscape/
        ZXSpectrum/
    libraries/          - sources
        TheGreatEscape/
            include/    - private headers
        ZXSpectrum/
    platform/           - platform-specific source
        generic/        - generic Makefile build environment
        osx/            - Xcode build environment
        riscos/         - RISC OS build environment
        windows/        - Windows build environment

Chat

Join the chat at https://gitter.im/The-Great-Escape/Lobby

Related Links

Porting Chuckie Egg

the-great-escape-in-c's People

Contributors

archifishaldev avatar dougieh avatar dpt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

the-great-escape-in-c's Issues

Add full screen mode (RISC OS)

Add a full-screen mode to the RISC OS build. This won't multitask and will perhaps speed up the game on ARM2 to an acceptable level.

CMake build

Complete the CMake build work. In particular CMake builds on Windows will need to be supported.

License of the source code

Hi,

The headers of the source file say "It is free software provided without warranty in the interests of education and software preservation.". I'm not sure what this exactly would mean.

  • Is it compatible with the MIT or GPL license?
  • How did the translation took place? There is a conversion document but I'm not sure if all the code was just recreated or if it's more like a disassembly? If it was more like a disassembly, can it become free software? Did the original authors maybe give their consent?

Kind regards

build on Linux

I tryed to build on Linux.
Both running:
The-Great-Escape-in-C/platform/generic$ gcc -I../../include sdlmain.c -o tge
or
The-Great-Escape-in-C/platform/generic$ make -f SDL.mk build
it stop with this error:

sdlmain.c: In function ‘key_handler’:
sdlmain.c:102:41: error: incompatible type for argument 2 of ‘zxkeyset_for_port’
  102 |     return zxkeyset_for_port(port, state->keys);
      |                                    ~~~~~^~~~~~
      |                                         |
      |                                         zxkeyset_t
In file included from sdlmain.c:19:
../../include/ZXSpectrum/Keyboard.h:99:56: note: expected ‘const zxkeyset_t *’ but argument is of type ‘zxkeyset_t’
   99 | int zxkeyset_for_port(uint16_t port, const zxkeyset_t *keystate);
      |                                      ~~~~~~~~~~~~~~~~~~^~~~~~~~
sdlmain.c: In function ‘sdl_key_pressed’:
sdlmain.c:221:32: error: incompatible type for argument 1 of ‘zxkeyset_setchar’
  221 |       *keys = zxkeyset_setchar(*keys, k->keysym.sym);
      |                                ^~~~~
      |                                |
      |                                zxkeyset_t
../../include/ZXSpectrum/Keyboard.h:104:35: note: expected ‘zxkeyset_t *’ but argument is of type ‘zxkeyset_t’
  104 | void zxkeyset_setchar(zxkeyset_t *keystate, int c);
      |                       ~~~~~~~~~~~~^~~~~~~~
sdlmain.c:223:34: error: incompatible type for argument 1 of ‘zxkeyset_clearchar’
  223 |       *keys = zxkeyset_clearchar(*keys, k->keysym.sym);
      |                                  ^~~~~
      |                                  |
      |                                  zxkeyset_t
../../include/ZXSpectrum/Keyboard.h:109:37: note: expected ‘zxkeyset_t *’ but argument is of type ‘zxkeyset_t’
  109 | void zxkeyset_clearchar(zxkeyset_t *keystate, int c);
      |                         ~~~~~~~~~~~~^~~~~~~~
sdlmain.c: In function ‘main’:
sdlmain.c:326:21: error: incompatible types when assigning to type ‘zxkeyset_t’ from type ‘long long unsigned int’
  326 |   state.keys      = 0ULL;
      |                     ^~~~

26/32-bit neutral build... isn't (RISC OS)

I saw a GtEscape build crashing on ArcEm, Arculator and ArchiEmu but only when configured for ARM2, not ARM250. In fact it locked the virtual machines solid. After some digging I found that the OSLib that I link against isn't 26/32-bit neutral. The 32-bit version uses MRS instructions and they somehow work on emulated ARM250's, but not on emulated ARM2's.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.