DOOM in Yakuza 0

After the great reception of DOOM for the SEGA Genesis, we are happy to announce that this beloved franchise is coming to yet another SEGA product!

- some SEGA conference, probably

Half a year ago, when playing Yakuza 0, I decided to take a look at its game files. An idea quickly came to mind.

Intro

I have a cursory interest in proprietary, in house game engines and how they're structured.

Some game engines are relatively modular looking in from the outside, with lots of DLLs to separate concerns, while others will opt to build their games + engines as monoliths, with few or no dynamic libraries (save for 3rd party dependencies like the Steam API, DLSS, etc.), instead baking it all into one chonky executable.

Some examples for modular engines:

Some monolith engines:

  • The engine (or rather, accumulation of libraries) used in Black Box era Need for Speed games (which are not on Steam...).
    (Commonly dubbed either "EAGL"1 or "Speed" engine in the modding community)
  • Toylogic's Toylo Engine: https://steamdb.info/depot/1113561/

Structural decisions like this are often made because of the development team's structure, workflow or even just the build system used. "Monolith" games might still even have DLLs but from third parties or other teams within the studio. One very common example nowadays is the Steam API.

Other times, you might see an extra library when a game integrates functionality from relatively unrelated projects. For example, Need for Speed: Underground 2 ships with a stripped down version of a matchmaking server for its LAN multiplayer functionality, which speaks a subset of the protocol used for its (long shut down) online multiplayer counterpart.

Yakuza 0

So, when I looked at Yakuza 0's game directory, I found its executable, 'Yakuza0.exe' and two DLLs - the usual steam_api64.dll and a 'libtgsa.dll'. Wondering what it was for, I fired up Ghidra to take a look:

A few symbol names in the "Exports" section: ArcadeTestDLL_CanInsertCoin ArcadeTestDLL_CanStartGame ArcadeTestDLL_InitRom ArcadeTestDLL_Shutdown ArcadeTestDLL_Update entry

"ArcadeTestDLL" immediately piqued my interest. See, Yakuza 0 is loaded with minigames and activities, and a few of these happen to be "playing old SEGA games at in-game arcades accurate to the time period the game takes place in". Yakuza 0 is set in the late 80s, with the following games available to play:

  • Out Run
  • Space Harrier
  • Super Hang-On
  • Fantasy Zone 1

What do these games have in common? They were all developed for the SEGA System 16 arcade board, or more powerful derivations of it. Given that one of the exported functions is called "InitRom", I'm pretty confident this DLL contains a System 16 emulator. Specifically, this means Yakuza 0 ships with both a M68k emulator and (maybe) a Z80 emulator lol

Analyzing these functions further, I learned that the ROMs must be contained within the DLL itself, as the game only provides one of four names plus stuff like the output formats for audio and video.

Now taking apart this emulator beyond its interface with the game seems mostly boring, though it might be interesting to find out whether this is some in-house emulator or a license violation of some sort :P

Instead, I did the obvious thing:

Porting DOOM to it

Having never ported DOOM to anything before, I actually found the hardest part was choosing a DOOM codebase. In the end, I settled on fbDOOM which a friend pointed me to 2.

Because I'd also never looked at DOOM source code before, it took a while to find my bearings. Making a list of problems to solve certainly helped me keep focus, though :)

This is where I'd probably write all about the challenges encountered and so on. Unfortunately I actually did all this more than a year ago, so I'll just point to the source code instead of trying to piece together the how and why again ^^'

Here it is: https://github.com/fridtjof/fbDOOM-yakuza0/tree/tgsa

Demo

The control scheme is mapped as follows:

ActionController
Move, Look (tank controls)Left stick
ShootRight Trigger/B
InteractLeft Trigger/A
Select (Menu)A
Move (Menu)Left stick

Due to the limited amount of controls, tank controls are the only viable control scheme here unfortunately.

Some things worth improving:

  1. I suspect the timing is off, it doesn't feel as "fluid" as it should?

  2. Sound is missing. In theory, this could definitely be hacked up with a source port that actually handles sound rendering. I decided not to bother because I felt those source ports would also come hand in hand with more build system combat than I wanted to deal with.

Outlook

When playing other titles in the Yakuza series, I realized these embedded arcade games are actually present in many other titles as well. So I checked out the file listings on SteamDB and found quite a lot!

A quick overview, albeit incomplete. Basically all games have some DLLs, many of them seem to be other minigames/functionality though. I have only listed those that are very obviously related by name.

GameSteam DepotPath
Yakuza 61388591libtgsa.dll
Yakuza LaD (7)1235141runtime/media/data/minigame/segaages_w64/ArcadeTestDLL.dll
Judgment2058181runtime/media/data/minigame/segaages_w64/arcadetestdll.dll
Lost Judgment2058191runtime/media/data/minigame/segaages_w64/arcadetestdll.dll

The RED-Project also seems to have this on their radar already: https://github.com/farmerbb/RED-Project/issues/133

1

EAGL is actually the name of an in-house library developed at EA used for animations. While it is used in these NFS games, it is merely one of many libraries statically linked into the game.

2

Next time I'd like to give doomgeneric a shot, but I was far enough with fbDOOM already when I found it.