You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: doom/README.md
+38-1
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ But we want to build everything from scratch in this series, without Emscripten.
7
7
8
8
---
9
9
10
-
We start with the original vanilla DOOM sources from https://github.com/id-Software/DOOM at [6ed1e40](https://github.com/diekmann/wasm-fizzbuzz/commit/6ed1e4067082bfe61a7b767b91dc981aa1517f94).
10
+
We start with the original vanilla DOOM sources from <https://github.com/id-Software/DOOM> at [6ed1e40](https://github.com/diekmann/wasm-fizzbuzz/commit/6ed1e4067082bfe61a7b767b91dc981aa1517f94).
11
11
12
12
Some minor tweaks are necessary to compile the 1997 sources on my 64bit Ubuntu 20.04.
13
13
@@ -28,3 +28,40 @@ With those tweaks, DOOM is starting with X11 rendering:
28
28

29
29
30
30
Time to port this to WebAssembly next.
31
+
32
+
---
33
+
34
+
Following <https://surma.dev/things/c-to-webassembly/>, we want to compile DOOM as `wasm32`.
35
+
But this will be a long journey.
36
+
And we cannot play doom once we switch to `wasm32` untill the graphics driver for X11 is removed and replaced by a graphics driver for the web.
37
+
Therefore, to test as much as possible and be able to play doom during development, I will develop on X86 for as long as possible and change architecture to `wasm32` reather late.
38
+
39
+
First, let's replace the compiler from `gcc` to `clang`, turn on optimization, and disable debugging.
40
+
This reduces binary size from `1,9M` to `383K`
41
+
42
+
To get doom ready for the web, we need to do the following
43
+
44
+
* Replace the X11 graphics driver with something that works in the browser.
45
+
* Replace the sound driver with, .... my PC does not have speakers, let's just remove sound.
46
+
* Replace all calls DOOM makes into the C stand library (such as `malloc` or `fopen`) with implementations that work in the browser. Either by implementing them in WebAssembly or JavaScript.
47
+
48
+
Since the year is 2021, there is no reason to write new C code, ...
49
+
50
+
```
51
+
~/git/wasm-fizzbuzz/doom$ cargo init
52
+
```
53
+
54
+
To make the doom C code callable interoperable with rust, we no longer compile it into a binry, but build a static library (`liblinuxxdoom.a`) instead.
55
+
Inspired by <https://docs.rust-embedded.org/book/interoperability/c-with-rust.html>, we should be able to call DOOM's `D_DoomMain` from rust then.
56
+
57
+
We are essentially still working on a 32bit application, remeber?
58
+
59
+
```
60
+
cargo run --target=i686-unknown-linux-gnu
61
+
```
62
+
63
+
Adding a `.cargo/config` to select the default target and a runner...
64
+
65
+
And we got DOOM starting from rust \m/
66
+
67
+

0 commit comments