Skip to content

Commit 976889e

Browse files
committed
Add wasm target
1 parent f617d2f commit 976889e

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

.github/workflows/pages.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
- name: Setup emsdk
3434
uses: mymindstorm/setup-emsdk@v14
3535
- name: Build Space Travel
36-
run: emcc st.c -s USE_SDL=2 -o html/st.js
36+
run: make wasm
3737
- name: Upload artifact
3838
uses: actions/upload-pages-artifact@v3
3939
with:

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22
*.obj
33
*.dll
44
*.exe
5+
*.wasm
56
/st
7+
/html/st.js

Makefile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
INSTALL = install
22
MKDIR = mkdir -p
3+
EMCC = emcc
34

45
prefix = /usr/local
56
bindir = $(prefix)/bin
@@ -16,9 +17,17 @@ prefix=. # \
1617
!endif
1718

1819
LDLIBS = -lm -lSDL2
20+
1921
all: st$(EXEEXT)
22+
23+
wasm: html/st.js
24+
25+
html/st.js: st.c
26+
$(EMCC) -s USE_SDL=2 -o $@ st.c
27+
2028
clean:
21-
$(RM) st$(EXEEXT)
29+
$(RM) st$(EXEEXT) html/st.js html/*.wasm
30+
2231
install: st$(EXEEXT) $(DESTDIR)$(bindir)
2332
$(INSTALL) st$(EXEEXT) "$(DESTDIR)$(bindir)"
2433

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
This is a C port of Ken Thompson's
44
[Space Travel](https://en.wikipedia.org/wiki/Space_Travel_\(video_game\)),
55
ported from PDP-7 assembly. The original source files are in `src/cmd/st*.s`
6-
in the [pdp7-unix](https://github.com/DoctorWkt/pdp7-unix) repository.
6+
in the [pdp7-unix](https://github.com/DoctorWkt/pdp7-unix) repository. The game
7+
is available to [play online](https://akr.am/st) via WebAssembly.
78

89
## Install
910

@@ -13,6 +14,10 @@ Run `make` to build `st`.
1314

1415
Run `make install` to install to `/usr/local/bin`.
1516

17+
Run `make wasm` (requires [Emscripten](https://emscripten.org)) to build a
18+
WebAssembly version of the game. To play it, launch a web server via
19+
`python3 -m http.server -d html` and go to http://localhost:8000.
20+
1621
## Controls
1722

1823
| Key | Action |

0 commit comments

Comments
 (0)