Skip to content

Commit

Permalink
Add wasm target
Browse files Browse the repository at this point in the history
  • Loading branch information
mohd-akram committed Sep 17, 2024
1 parent f617d2f commit f995c5f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Setup emsdk
uses: mymindstorm/setup-emsdk@v14
- name: Build Space Travel
run: emcc st.c -s USE_SDL=2 -o html/st.js
run: make wasm
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
*.dll
*.exe
/st
/html/st.js
/html/st.wasm
11 changes: 10 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
INSTALL = install
MKDIR = mkdir -p
EMCC = emcc

prefix = /usr/local
bindir = $(prefix)/bin
Expand All @@ -16,9 +17,17 @@ prefix=. # \
!endif

LDLIBS = -lm -lSDL2

all: st$(EXEEXT)

wasm: html/st.js

html/st.js: st.c
$(EMCC) -s USE_SDL=2 -o $@ st.c

clean:
$(RM) st$(EXEEXT)
$(RM) st$(EXEEXT) html/st.js html/st.wasm

install: st$(EXEEXT) $(DESTDIR)$(bindir)
$(INSTALL) st$(EXEEXT) "$(DESTDIR)$(bindir)"

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

## Install

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

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

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

## Controls

| Key | Action |
Expand Down

0 comments on commit f995c5f

Please sign in to comment.