
DOOM launched on "regular expressions," but one frame renders for several minutes
The classic shooter DOOM continues to be launched on the most unexpected "platforms." Recently, a programmer decided to present his project to run the game on regular expressions.
From a technical point of view, the entire "machine" for launching is one very long string of 96.6 MB. Registers, RAM, frame buffer, the DOOM engine compiled into a custom instruction set, and the WAD file are stored within this string as plain text.
A special driver goes through this string and uses a given list of rules:
The driver applies a fixed ordered list of "find and replace" rules to [the string]; the first matched rule fires exactly once — this is considered one "step." No other computations are hidden anywhere: no interpreter, no host-side arithmetic. Remove the rules — and what remains is just a plain text file.
The developer explained that the rules used implement a small 32-bit processor:
544 rules implement a 32-bit CPU, where the adder is a 512-element lookup table with carry "threaded" through capture groups; memory access is done by jumping a precise number of characters collected from address digits, and instruction fetching hits the current opcode in the same way, controlled by a program counter.
DOOM itself is compiled for this "processor" using 8cc and ELV. The frame rendering speed is not very fast — for tests, he recorded a video, and frame processing took 3 minutes, with the calculation performed on five machines working in parallel.
The source code for the "doom-regex" project is publicly available in the 4RH1T3CT0R7 repository.

Комментарии