Skip to content

About

Doom as a ZAPiT Game Wave game script (Lua on the console's own ZIT engine), developed in the Undertow emulator

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

15 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gamewave-doom

Doom for the ZAPiT Game Wave, written as a game script for the console's own ZIT engine (Lua 5.0.2 with 32-bit integer numbers), developed and tested in the Undertow emulator.

Honest status: this runs in an emulator that runs Game Wave games. It uses nothing but the engine's own script API, so in principle the same disc would run on a real console, but it has never been tried there, and the console would be far slower than a PC.

It is a port of the Doom source (by way of Chocolate Doom) to Lua, kept as close to the original as Lua allows: the demos of the shareware IWAD, Freedoom 1 and 2 and Doom II all play back in sync with a C port, to the tic and to the bit.

What works

  • The whole game: renderer, automap, play simulation, status bar and messages
  • Menus, the title loop with the IWAD's demos, the intermission screens, the finales, the screen melt, low detail and the screen size option
  • Sound effects and music (see below)
  • IWADs: shareware and registered Doom, Ultimate Doom, Doom II, TNT, Plutonia, Freedoom
  • The IWAD's own DEHACKED lump, read at build time: Freedoom's level names, texts, par times and frame tweaks (Text, BEX [STRINGS] and [PARS], Frame, Thing, Pointer)
  • Savegames, six slots on the console's save EEPROM (see below)
  • Two players on one console, split screen: co-op, deathmatch and deathmatch 2.0

How it works

Display. The engine has no way for a script to upload pixels into a texture. It does have text.Render, which draws a string with a bitmap font into a new texture. The build makes a "palette font" for each Doom palette: glyph c is a 2x2 block of palette colour c, in the OSD pixel format 655 (Y6 Cb5 Cr5). A 320x200 frame becomes one string of 200 lines of 320 characters, and a single text.Render call turns it into a 640x400 texture. Five byte values cannot appear in the string (0, tab, \n, \r, space), so those palette entries are drawn with their nearest other colour.

Sound effects. The engine's audio library can load and play a sound, and nothing else: no volume, no panning, no stop. The build converts every effect to the console's .zwf format at five volume levels, and the game plays the one closest to Doom's distance attenuation, never more than the eight sounds the engine plays at once.

Music. The Game Wave is a DVD player with hardware MPEG audio. The build renders each song once through Chocolate Doom's OPL music player and the Nuked OPL3 emulator (the sound of an AdLib / Sound Blaster, with the IWAD's own instruments) and wraps it in an MPEG-2 movie like the discs' own; the game plays it with the movie library on the video plane, under the OSD that shows the game.

Savegames. The console keeps saves on a 32 KB EEPROM shared by every Game Wave game, about 28 KB of it usable; a vanilla savegame is often over 100 KB. A save here holds only what differs from the level as it loads: the players, the changed sectors, lines and sides, every mobj with just the fields that are not at their defaults, and the moving sectors and lights. That is 2 to 8 KB. Loading reloads the level and applies the save, as vanilla does; unlike vanilla, monsters keep their targets and alerts, and flickering lights and switches survive. The engine cannot delete a save or make one bigger, so each slot is a chain of 1 KB records that grows when a save needs more and is reused afterwards; if the EEPROM is full, the game says so and the slot keeps its previous save. With no letters on a remote, a save is named after its map.

Split screen. Main menu, Two Players: the screen is cut in two 320x100 views, remote 1 playing the top one and remote 2 the bottom one, each view with its own weapon, numbers (ammo, health, armor or frags, keys), messages and palette effects: the frame is two text.Render calls, each in its player's palette font. The automap opens in the half of whoever asks for it. The game runs by Doom's net game rules (respawning, co-op weapons that stay, multiplayer-only things, the co-op and deathmatch intermission tables) but, all being on one console, the menu pauses it and it can be saved and loaded.

Building a disc

Bring your own files: an IWAD (shareware DOOM1.WAD, a commercial IWAD, or the free Freedoom) and /data/app_sdram_3.cat.bin from one of your Game Wave discs. Neither is part of this repository.

You need Python 3, zbcc from an Undertow build (looked for in ../pc-gizwiz/build/, or pass --zbcc), and for the music gcc and ffmpeg on the PATH (--no-music skips it).

python tools/build.py --wad freedoom1.wad --engine app_sdram_3.cat.bin --out disc
undertow disc --ir-repeat 100

A disc folder takes from about 80 MB (shareware) to 380 MB (Doom II), mostly music.

Controls (Game Wave remote)

Remote In the game In the menus
Arrows move and turn move / change
SELECT fire choose; "yes"
A use (doors, switches)
B strafe (hold)
C automap
D next weapon
1-7 weapon
DVD MENU show the last message back; "no"
GAME MENU menu close

In a two player game, remote 2 plays the bottom view with the same buttons; either remote works the menus. In Undertow the keyboard is remote 1 and a game controller remote 2.

The engine reports key presses only, no releases. Doom needs to know how long a key is held, so a key counts as held while presses keep arriving: on a remote that repeats a held button this is a held key. In Undertow, run with --ir-repeat 100 to get that remote.

Testing

  • --warp E1M8 / --warp MAP07: start straight in a map; with --players 2 (and --deathmatch 1 or 2) as a split screen game
  • --timedemo demo1: play a demo as fast as possible and print where it ended (tic, position, health, kills...). tools/doomgeneric_headless.c builds a C reference that prints the same line; matching lines mean the Lua simulation is still exact. Saving and loading every few hundred tics during a demo keeps it in sync too (all the demos of DOOM1, Freedoom 1 and 2), so a save loses nothing the simulation depends on.

Credits

Doom by id Software (source release under the GPL). The port follows Chocolate Doom, whose OPL music code and the Nuked OPL3 emulator are used, unchanged, by tools/musrender (see tools/musrender/chocolate/README.md). doomgeneric is the reference for demo sync tests.

License

GPL-2.0 - see LICENSE.md.

About

Doom as a ZAPiT Game Wave game script (Lua on the console's own ZIT engine), developed in the Undertow emulator

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages