├── .gitignore ├── LICENSE.txt ├── Makefile ├── README.md ├── index.html ├── rom2html ├── rom2url ├── roms ├── animation.rom ├── asma.rom ├── audio.channels.rom ├── audio.rom ├── automata.rom ├── bifurcan.rom ├── console.lib.rom ├── console.rom ├── controller.buttons.rom ├── controller.keys.rom ├── darena.rom ├── datetime.rom ├── drum-rack.rom ├── file.load.rom ├── file.rom ├── file.save.rom ├── hover.rom ├── label.rom ├── life.rom ├── mouse.rom ├── musictracker.rom ├── neralie.rom ├── piano.rom ├── picture.rom ├── polycat.rom ├── proportional-font.rom ├── screen.rom ├── shapes.rom ├── theme.rom └── wallpaper.rom ├── src ├── devices │ ├── apu.c │ ├── apu.h │ ├── mpu.c │ ├── mpu.h │ ├── ppu.c │ └── ppu.h ├── uxn-fast.c ├── uxn.h └── webuxn.c └── webuxn.js /.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) Bruno Garcia 2 | 3 | Permission to use, copy, modify, and/or distribute this software for any 4 | purpose with or without fee is hereby granted, provided that the above 5 | copyright notice and this permission notice appear in all copies. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 8 | REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 9 | FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 10 | INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 12 | OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 13 | PERFORMANCE OF THIS SOFTWARE. 14 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Build-time dependencies 2 | CC = emcc 3 | WASM_OPT = "$(EMSDK)/upstream/bin/wasm-opt" 4 | ROLLUP = npx rollup 5 | TERSER = npx terser 6 | 7 | BUILD_DIR ?= ./build 8 | SRC_DIRS ?= ./src 9 | 10 | RELEASE=1 11 | ifeq ($(RELEASE),1) 12 | OPT_FLAGS = -O2 13 | else 14 | OPT_FLAGS = -g4 --source-map-base "http://0.0.0.0:7001/build/" # -s DEMANGLE_SUPPORT=1 15 | endif 16 | LDFLAGS = $(OPT_FLAGS) --no-entry -s WASM=1 -s ERROR_ON_UNDEFINED_SYMBOLS=0 17 | CFLAGS ?= $(INC_FLAGS) -MMD -MP $(OPT_FLAGS) -W -Wall -Wextra 18 | 19 | SRCS := $(shell find $(SRC_DIRS) -name "*.c") 20 | OBJS := $(SRCS:%=$(BUILD_DIR)/%.o) 21 | DEPS := $(OBJS:.o=.d) 22 | 23 | INC_DIRS := $(shell find $(SRC_DIRS) -type d) 24 | INC_FLAGS := $(addprefix -I,$(INC_DIRS)) 25 | 26 | all: $(BUILD_DIR)/webuxn.wasm $(BUILD_DIR)/webuxn.min.js 27 | 28 | $(BUILD_DIR)/webuxn.wasm: $(OBJS) 29 | $(CC) $(OBJS) -o $@ $(LDFLAGS) 30 | ifeq ($(RELEASE),1) 31 | $(WASM_OPT) -O4 $@ -o $@.opt 32 | mv $@.opt $@ 33 | endif 34 | 35 | $(BUILD_DIR)/%.wat: $(BUILD_DIR)/%.wasm 36 | $(WASM_DIS) $< -o $@ 37 | 38 | $(BUILD_DIR)/%.c.o: %.c 39 | mkdir -p $(dir $@) 40 | $(CC) $(CFLAGS) -c $< -o $@ 41 | 42 | $(BUILD_DIR)/%.min.js: %.js 43 | $(ROLLUP) $< --format iife --output.name webuxn | $(TERSER) --compress --mangle > $@ 44 | 45 | .PHONY: clean 46 | 47 | clean: 48 | $(RM) -r $(BUILD_DIR) 49 | 50 | -include $(DEPS) 51 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # webuxn 2 | 3 | A light-weight port of the [uxn virtual machine](https://100r.co/site/uxn.html) to the web via WebAssembly. 4 | 5 | ## Demos 6 | 7 | - [life.rom](https://aduros.com/webuxn/?rom=roms/life.rom) 8 | - [darena.rom](https://aduros.com/webuxn/?rom=roms/darena.rom) 9 | - [animation.rom](https://aduros.com/webuxn/?rom=roms/animation.rom) 10 | - [musictracker.rom](https://aduros.com/webuxn/?rom=roms/musictracker.rom) 11 | - [Bring Your Own Rom](https://aduros.com/webuxn/) 12 | 13 | ## Hotkeys 14 | 15 | - F2: Save state 16 | - F4: Load state 17 | - F5: Reboot 18 | - F9: Take screenshot 19 | - F11: Toggle fullscreen 20 | 21 | ## rom2html 22 | 23 | `rom2html` bakes a rom and VM into a fully self-contained html that can be easily distributed. 24 | 25 | ``` 26 | make 27 | ./rom2html roms/life.rom > life.html 28 | ``` 29 | 30 | ## rom2url 31 | 32 | `rom2url` embeds a rom into a playable URL. The rom is never uploaded to a server, but embedded into 33 | the URL string itself. This is one way you can share (or pirate?) roms even if you don't have a 34 | website. If your rom is small enough, it can even fit into a QR code and printed onto paper. 35 | 36 | ``` 37 | ./rom2url roms/animation.rom | qrencode -o qrcode.png 38 | ``` 39 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 |