A RISC-V emulator has been developed that successfully runs the classic game DOOM, utilizing the RV32IM instruction set and a custom syscall interface to execute the game's C code. The emulator's implementation of newlib and ELF loading enabled the porting of DOOM, which now renders to a fixed area in memory.
Overview
The emulator, called rvcore, is a single-core RISC-V emulator that implements the RV32IM ISA, except for the FENCE and EBREAK instructions, which are currently NOP. It was built using CMake and a compiler that supports C++20, with dependencies including libsdl3-dev or sdl3-devel.
What it does
To port DOOM, the developer used doomgeneric, which was quite convenient to get working once the required stubs were in place. The emulator renders DOOM to a fixed area in memory, specifically at address 0x705FDD, also referred to as VRAM_START. The developer achieved several milestones, including running flat binaries written in assembly language, running flat binaries written in C language, running ELF binaries with a single PT_LOAD segment, implementing the newlib stubs needed to run DOOM, getting DOOM to boot, and making DOOM playable.
The build instructions for the emulator involve creating a build directory, running CMake with the Release build type, and then building the project. The build instructions for doomgeneric involve cloning the repository, installing the riscv64-unknown-elf-gcc or the riscv64-gnu-toolchain, and then running make.
In practical terms, this achievement highlights the growing accessibility of RISC-V emulation and demonstrates the potential for running complex applications like DOOM on RISC-V based systems. For developers interested in experimenting with RISC-V emulation, the rvcore emulator and doomgeneric provide a useful starting point.