├── .gitattributes ├── test ├── badcode │ ├── Makefile │ ├── rom │ │ ├── Makefile │ │ └── rom.c │ └── test │ │ └── tests.c ├── extram │ ├── Makefile │ ├── rom │ │ └── Makefile │ └── shared.h ├── meter │ ├── Makefile │ ├── rom │ │ ├── Makefile │ │ └── rom.c │ └── test │ │ └── tests.c ├── opcodes │ ├── Makefile │ ├── rom │ │ ├── Makefile │ │ └── rom.c │ └── shared.h ├── syscall_args │ ├── Makefile │ ├── rom │ │ ├── Makefile │ │ └── rom.c │ └── shared.h ├── basic_syscalls │ ├── Makefile │ ├── rom │ │ ├── Makefile │ │ └── rom.c │ └── test │ │ └── tests.c ├── custom_syscall │ ├── Makefile │ └── rom │ │ ├── Makefile │ │ └── rom.c ├── minirv32_internal │ ├── Makefile │ ├── rom │ │ ├── Makefile │ │ └── rom.c │ └── test │ │ └── tests.c ├── stackoverflow │ ├── rom │ │ ├── Makefile │ │ └── rom.c │ ├── Makefile │ └── test │ │ └── tests.c ├── unity │ └── auto │ │ ├── __init__.py │ │ ├── type_sanitizer.rb │ │ ├── yaml_helper.rb │ │ ├── extract_version.py │ │ ├── test_file_filter.rb │ │ ├── run_test.erb │ │ ├── colour_reporter.rb │ │ └── generate_config.yml ├── common │ ├── makefile-rom.common │ └── makefile.common └── Makefile ├── precompiled ├── fib.bin ├── gfx.bin ├── heap.bin ├── maze.bin ├── self.bin ├── agnes.bin ├── conio.bin ├── mandel.bin ├── sketch.bin ├── tinygl.bin ├── hello-asm.bin ├── lissajous.bin ├── memtest.bin ├── zigalloc.bin ├── zigdoom.bin ├── zigtris.bin ├── helloworld.bin └── rust-hello.bin ├── apps ├── zigdoom │ ├── src │ │ ├── puredoom │ │ │ ├── pocketmod.c │ │ │ ├── PureDOOM.c │ │ │ ├── doomdef.c │ │ │ ├── p_inter.h │ │ │ ├── doomstat.c │ │ │ ├── i_net.h │ │ │ ├── p_tick.h │ │ │ ├── r_segs.h │ │ │ ├── p_setup.h │ │ │ ├── m_argv.h │ │ │ ├── m_random.h │ │ │ ├── r_sky.h │ │ │ ├── d_textur.h │ │ │ ├── f_finale.h │ │ │ ├── m_argv.c │ │ │ ├── m_fixed.h │ │ │ ├── m_bbox.h │ │ │ ├── m_swap.c │ │ │ ├── d_items.h │ │ │ ├── r_sky.c │ │ │ ├── m_swap.h │ │ │ ├── m_bbox.c │ │ │ ├── m_cheat.h │ │ │ ├── p_saveg.h │ │ │ ├── wi_stuff.h │ │ │ ├── f_wipe.h │ │ │ ├── d_main.h │ │ │ ├── r_local.h │ │ │ ├── d_ticcmd.h │ │ │ ├── m_fixed.c │ │ │ ├── i_video.h │ │ │ ├── am_map.h │ │ │ ├── r_data.h │ │ │ ├── doom_config.h │ │ │ ├── dstrings.h │ │ │ ├── m_misc.h │ │ │ ├── r_plane.h │ │ │ ├── hu_stuff.h │ │ │ ├── m_menu.h │ │ │ ├── r_bsp.h │ │ │ ├── doomtype.h │ │ │ ├── r_things.h │ │ │ ├── d_think.h │ │ │ ├── w_wad.h │ │ │ ├── p_pspr.h │ │ │ ├── g_game.h │ │ │ ├── st_stuff.h │ │ │ └── m_cheat.c │ │ ├── doom1.wad │ │ └── console.zig │ ├── Makefile │ └── build.zig.zon ├── agnes │ ├── src │ │ ├── croom.nes │ │ └── console.zig │ ├── Makefile │ └── build.zig.zon ├── rust-hello │ ├── uvm32_headers.h │ ├── Cargo.toml │ ├── Makefile │ ├── build.rs │ └── src │ │ └── main.rs ├── helloworld │ ├── helloworld.c │ └── Makefile ├── tinygl │ ├── src │ │ ├── TinyGL │ │ │ ├── src │ │ │ │ ├── zmath.c │ │ │ │ ├── msghandling.h │ │ │ │ ├── error.c │ │ │ │ ├── memory.c │ │ │ │ ├── clear.c │ │ │ │ ├── specbuf.h │ │ │ │ ├── Makefile │ │ │ │ ├── zmath.h │ │ │ │ ├── zfeatures.h │ │ │ │ ├── msghandling.c │ │ │ │ ├── specbuf.c │ │ │ │ ├── get.c │ │ │ │ ├── opinfo.h │ │ │ │ └── zline.c │ │ │ ├── examples │ │ │ │ ├── glu.c │ │ │ │ ├── ui.h │ │ │ │ ├── Makefile │ │ │ │ └── glu.h │ │ │ ├── BeOS │ │ │ │ ├── Makefile │ │ │ │ └── GLView.h │ │ │ ├── Makefile │ │ │ ├── INSTALL │ │ │ ├── include │ │ │ │ ├── GL │ │ │ │ │ ├── nglx.h │ │ │ │ │ └── oscontext.h │ │ │ │ └── GLView.h │ │ │ ├── README.BEOS │ │ │ ├── LICENSE │ │ │ ├── Changelog │ │ │ └── config.mk │ │ └── console.zig │ ├── Makefile │ └── build.zig.zon ├── hello-asm │ ├── Makefile │ └── hello-asm.S ├── conio │ ├── Makefile │ └── conio.c ├── fib │ ├── Makefile │ └── fib.c ├── sketch │ ├── Makefile │ └── sketch.c ├── lissajous │ └── Makefile ├── maze │ ├── Makefile │ └── maze.c ├── heap │ ├── Makefile │ ├── malloc_freelist.h │ └── heap.c ├── memtest │ ├── memtest.c │ ├── Makefile │ └── barr_memtest.h ├── gfx │ ├── Makefile │ └── gfx.c ├── zigtris │ ├── Makefile │ ├── build.zig.zon │ └── src │ │ ├── console.zig │ │ ├── main.zig │ │ └── uvm.zig ├── zig-mandel │ ├── Makefile │ ├── src │ │ ├── uvm.zig │ │ └── main.zig │ └── build.zig ├── zigalloc │ ├── src │ │ ├── main.zig │ │ ├── console.zig │ │ └── uvm.zig │ ├── Makefile │ └── build.zig ├── common │ ├── crt0.S │ ├── target-stdint.h │ ├── makefile.common │ ├── linker.ld │ └── uvm32_target.h ├── self │ ├── Makefile │ ├── self.c │ └── mandel.h └── Makefile ├── hosts ├── host-arduino │ ├── config.h │ └── Makefile ├── host │ └── Makefile ├── fuzz │ ├── Makefile │ └── fuzz.c ├── Makefile ├── host-parallel │ └── Makefile ├── host-mini │ ├── Makefile │ ├── mandel.h │ └── host-mini.c └── host-sdl │ └── Makefile ├── common ├── uvm32_sys.h └── uvm32_common_custom.h ├── Makefile ├── Dockerfile ├── LICENSE └── .github └── workflows └── build.yml /.gitattributes: -------------------------------------------------------------------------------- 1 | *.h linguist-language=C 2 | 3 | -------------------------------------------------------------------------------- /test/badcode/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR=../.. 2 | include ${TOPDIR}/test/common/makefile.common 3 | -------------------------------------------------------------------------------- /test/extram/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR=../.. 2 | include ${TOPDIR}/test/common/makefile.common 3 | -------------------------------------------------------------------------------- /test/meter/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR=../.. 2 | include ${TOPDIR}/test/common/makefile.common 3 | -------------------------------------------------------------------------------- /test/opcodes/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR=../.. 2 | include ${TOPDIR}/test/common/makefile.common 3 | -------------------------------------------------------------------------------- /test/syscall_args/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR=../.. 2 | include ${TOPDIR}/test/common/makefile.common 3 | -------------------------------------------------------------------------------- /precompiled/fib.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/uvm32/HEAD/precompiled/fib.bin -------------------------------------------------------------------------------- /precompiled/gfx.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/uvm32/HEAD/precompiled/gfx.bin -------------------------------------------------------------------------------- /precompiled/heap.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/uvm32/HEAD/precompiled/heap.bin -------------------------------------------------------------------------------- /precompiled/maze.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/uvm32/HEAD/precompiled/maze.bin -------------------------------------------------------------------------------- /precompiled/self.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/uvm32/HEAD/precompiled/self.bin -------------------------------------------------------------------------------- /test/basic_syscalls/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR=../.. 2 | include ${TOPDIR}/test/common/makefile.common 3 | -------------------------------------------------------------------------------- /test/custom_syscall/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR=../.. 2 | include ${TOPDIR}/test/common/makefile.common 3 | -------------------------------------------------------------------------------- /test/extram/rom/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR=../../.. 2 | include ${TOPDIR}/test/common/makefile-rom.common 3 | -------------------------------------------------------------------------------- /test/meter/rom/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR=../../.. 2 | include ${TOPDIR}/test/common/makefile-rom.common 3 | -------------------------------------------------------------------------------- /test/minirv32_internal/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR=../.. 2 | include ${TOPDIR}/test/common/makefile.common 3 | -------------------------------------------------------------------------------- /apps/zigdoom/src/puredoom/pocketmod.c: -------------------------------------------------------------------------------- 1 | #define POCKETMOD_IMPLEMENTATION 2 | #include "pocketmod.h" 3 | -------------------------------------------------------------------------------- /precompiled/agnes.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/uvm32/HEAD/precompiled/agnes.bin -------------------------------------------------------------------------------- /precompiled/conio.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/uvm32/HEAD/precompiled/conio.bin -------------------------------------------------------------------------------- /precompiled/mandel.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/uvm32/HEAD/precompiled/mandel.bin -------------------------------------------------------------------------------- /precompiled/sketch.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/uvm32/HEAD/precompiled/sketch.bin -------------------------------------------------------------------------------- /precompiled/tinygl.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/uvm32/HEAD/precompiled/tinygl.bin -------------------------------------------------------------------------------- /test/badcode/rom/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR=../../.. 2 | include ${TOPDIR}/test/common/makefile-rom.common 3 | -------------------------------------------------------------------------------- /test/opcodes/rom/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR=../../.. 2 | include ${TOPDIR}/test/common/makefile-rom.common 3 | -------------------------------------------------------------------------------- /apps/agnes/src/croom.nes: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/uvm32/HEAD/apps/agnes/src/croom.nes -------------------------------------------------------------------------------- /precompiled/hello-asm.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/uvm32/HEAD/precompiled/hello-asm.bin -------------------------------------------------------------------------------- /precompiled/lissajous.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/uvm32/HEAD/precompiled/lissajous.bin -------------------------------------------------------------------------------- /precompiled/memtest.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/uvm32/HEAD/precompiled/memtest.bin -------------------------------------------------------------------------------- /precompiled/zigalloc.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/uvm32/HEAD/precompiled/zigalloc.bin -------------------------------------------------------------------------------- /precompiled/zigdoom.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/uvm32/HEAD/precompiled/zigdoom.bin -------------------------------------------------------------------------------- /precompiled/zigtris.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/uvm32/HEAD/precompiled/zigtris.bin -------------------------------------------------------------------------------- /test/basic_syscalls/rom/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR=../../.. 2 | include ${TOPDIR}/test/common/makefile-rom.common 3 | -------------------------------------------------------------------------------- /test/custom_syscall/rom/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR=../../.. 2 | include ${TOPDIR}/test/common/makefile-rom.common 3 | -------------------------------------------------------------------------------- /test/stackoverflow/rom/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR=../../.. 2 | include ${TOPDIR}/test/common/makefile-rom.common 3 | -------------------------------------------------------------------------------- /test/syscall_args/rom/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR=../../.. 2 | include ${TOPDIR}/test/common/makefile-rom.common 3 | -------------------------------------------------------------------------------- /apps/zigdoom/src/doom1.wad: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/uvm32/HEAD/apps/zigdoom/src/doom1.wad -------------------------------------------------------------------------------- /precompiled/helloworld.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/uvm32/HEAD/precompiled/helloworld.bin -------------------------------------------------------------------------------- /precompiled/rust-hello.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/uvm32/HEAD/precompiled/rust-hello.bin -------------------------------------------------------------------------------- /test/minirv32_internal/rom/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR=../../.. 2 | include ${TOPDIR}/test/common/makefile-rom.common 3 | -------------------------------------------------------------------------------- /apps/rust-hello/uvm32_headers.h: -------------------------------------------------------------------------------- 1 | #include "../../common/uvm32_sys.h" 2 | #include "../../common/uvm32_common_custom.h" 3 | -------------------------------------------------------------------------------- /test/stackoverflow/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR=../.. 2 | UVM32_MEMORY_SIZE=512 3 | include ${TOPDIR}/test/common/makefile.common 4 | -------------------------------------------------------------------------------- /apps/helloworld/helloworld.c: -------------------------------------------------------------------------------- 1 | #include "uvm32_target.h" 2 | 3 | void main(void) { 4 | println("Hello world"); 5 | } 6 | 7 | -------------------------------------------------------------------------------- /apps/tinygl/src/TinyGL/src/zmath.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/uvm32/HEAD/apps/tinygl/src/TinyGL/src/zmath.c -------------------------------------------------------------------------------- /apps/tinygl/src/TinyGL/examples/glu.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/uvm32/HEAD/apps/tinygl/src/TinyGL/examples/glu.c -------------------------------------------------------------------------------- /hosts/host-arduino/config.h: -------------------------------------------------------------------------------- 1 | // Arduino cannot do -DUVM32_MEMORY_SIZE, so set this explicitly 2 | #define UVM32_MEMORY_SIZE 512 3 | -------------------------------------------------------------------------------- /test/minirv32_internal/rom/rom.c: -------------------------------------------------------------------------------- 1 | #include "uvm32_target.h" 2 | 3 | void main(void) { 4 | println("Hello world"); 5 | } 6 | 7 | -------------------------------------------------------------------------------- /test/badcode/rom/rom.c: -------------------------------------------------------------------------------- 1 | #include "uvm32_target.h" 2 | 3 | void main(void) { 4 | void *p = NULL; 5 | println(p); 6 | } 7 | 8 | -------------------------------------------------------------------------------- /test/opcodes/shared.h: -------------------------------------------------------------------------------- 1 | #define SYSCALL_BASE 0x200 2 | #define SYSCALL_PICKTEST SYSCALL_BASE+0 3 | 4 | enum { 5 | TEST1, 6 | TEST2, 7 | }; 8 | -------------------------------------------------------------------------------- /apps/hello-asm/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR=../.. 2 | PROJECT:=hello-asm 3 | SRCS=${PROJECT}.S 4 | all: all_common 5 | test: test_common 6 | clean: clean_common 7 | include ${TOPDIR}/apps/common/makefile.common 8 | -------------------------------------------------------------------------------- /test/stackoverflow/rom/rom.c: -------------------------------------------------------------------------------- 1 | #include "uvm32_target.h" 2 | 3 | int foo(int a) { 4 | yield(0); 5 | printdec(a); 6 | return foo(a+1); 7 | } 8 | 9 | void main(void) { 10 | foo(1); 11 | } 12 | 13 | -------------------------------------------------------------------------------- /apps/conio/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR=../.. 2 | PROJECT:=$(shell basename ${PWD}) 3 | SRCS=${PROJECT}.c ${TOPDIR}/apps/common/crt0.S 4 | all: all_common 5 | test: test_common 6 | clean: clean_common 7 | include ${TOPDIR}/apps/common/makefile.common 8 | -------------------------------------------------------------------------------- /apps/fib/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR=../.. 2 | PROJECT:=$(shell basename ${PWD}) 3 | SRCS=${PROJECT}.c ${TOPDIR}/apps/common/crt0.S 4 | all: all_common 5 | test: test_common 6 | clean: clean_common 7 | include ${TOPDIR}/apps/common/makefile.common 8 | -------------------------------------------------------------------------------- /apps/sketch/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR=../.. 2 | PROJECT:=$(shell basename ${PWD}) 3 | SRCS=${PROJECT}.c ${TOPDIR}/apps/common/crt0.S 4 | all: all_common 5 | test: test_common 6 | clean: clean_common 7 | include ${TOPDIR}/apps/common/makefile.common 8 | -------------------------------------------------------------------------------- /test/basic_syscalls/rom/rom.c: -------------------------------------------------------------------------------- 1 | #include "uvm32_target.h" 2 | 3 | void main(void) { 4 | println("Hello world"); 5 | print("Hello world"); 6 | printdec(42); 7 | printhex(0xDEADBEEF); 8 | putc('G'); 9 | } 10 | 11 | -------------------------------------------------------------------------------- /apps/helloworld/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR=../.. 2 | PROJECT:=$(shell basename ${PWD}) 3 | SRCS=${PROJECT}.c ${TOPDIR}/apps/common/crt0.S 4 | all: all_common 5 | test: test_common 6 | clean: clean_common 7 | include ${TOPDIR}/apps/common/makefile.common 8 | -------------------------------------------------------------------------------- /apps/lissajous/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR=../.. 2 | PROJECT:=$(shell basename ${PWD}) 3 | SRCS=${PROJECT}.c ${TOPDIR}/apps/common/crt0.S 4 | all: all_common 5 | test: test_common 6 | clean: clean_common 7 | include ${TOPDIR}/apps/common/makefile.common 8 | -------------------------------------------------------------------------------- /apps/maze/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR=../.. 2 | PROJECT:=$(shell basename ${PWD}) 3 | SRCS=${PROJECT}.c ${TOPDIR}/apps/common/crt0.S 4 | OPT=-O2 5 | all: all_common 6 | test: test_common 7 | clean: clean_common 8 | include ${TOPDIR}/apps/common/makefile.common 9 | -------------------------------------------------------------------------------- /hosts/host/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR=../.. 2 | 3 | all: 4 | gcc -Wall -Werror -pedantic -std=c99 -O2 -DUVM32_ERROR_STRINGS -DUVM32_MEMORY_SIZE=65536 -I${TOPDIR}/uvm32 -I${TOPDIR}/common -o host ${TOPDIR}/uvm32/uvm32.c host.c 5 | 6 | clean: 7 | rm -f host 8 | -------------------------------------------------------------------------------- /test/custom_syscall/rom/rom.c: -------------------------------------------------------------------------------- 1 | #include "uvm32_target.h" 2 | 3 | void main(void) { 4 | if (0xAABBCCDD == syscall(0xDEADBEEF, 0xABCD1234, 0xDECAFBAD)) { 5 | print("ok"); 6 | } else { 7 | print("fail"); 8 | } 9 | } 10 | 11 | -------------------------------------------------------------------------------- /apps/zigdoom/src/puredoom/PureDOOM.c: -------------------------------------------------------------------------------- 1 | #define DOOM_IMPLEMENTATION 2 | extern void doom_print_impl(const char* str); 3 | #include "PureDOOM.h" 4 | 5 | static char *argv[] = {"pd"}; 6 | void pd_init(void) { 7 | doom_init(1, argv, 0); 8 | } 9 | 10 | 11 | -------------------------------------------------------------------------------- /apps/tinygl/src/TinyGL/src/msghandling.h: -------------------------------------------------------------------------------- 1 | #ifndef _msghandling_h_ 2 | #define _msghandling_h_ 3 | 4 | extern void tgl_warning(const char *text, ...); 5 | extern void tgl_trace(const char *text, ...); 6 | extern void tgl_fixme(const char *text, ...); 7 | 8 | #endif /* _msghandling_h_ */ 9 | -------------------------------------------------------------------------------- /test/meter/rom/rom.c: -------------------------------------------------------------------------------- 1 | #include "uvm32_target.h" 2 | 3 | void stall(void) { 4 | volatile uint32_t i; 5 | for (i=0;i<100;i++) { 6 | } 7 | } 8 | 9 | void main(void) { 10 | for (int i=0;i<100;i++) { 11 | stall(); 12 | printdec(i); 13 | } 14 | } 15 | 16 | -------------------------------------------------------------------------------- /apps/hello-asm/hello-asm.S: -------------------------------------------------------------------------------- 1 | #include "uvm32_sys.h" 2 | #include "uvm32_common_custom.h" 3 | .section .initial_jump , "ax", %progbits 4 | .global _start 5 | _start: 6 | la a0, str 7 | li a7, UVM32_SYSCALL_PRINTLN 8 | ecall 9 | li a7, UVM32_SYSCALL_HALT 10 | ecall 11 | str: 12 | .ascii "Hi\0" 13 | -------------------------------------------------------------------------------- /apps/conio/conio.c: -------------------------------------------------------------------------------- 1 | #include "uvm32_target.h" 2 | 3 | void main(void) { 4 | uint32_t c; 5 | println("Press a key!"); 6 | while(c = getc()) { 7 | if (c != 0xFFFFFFFF) { 8 | print("Got: "); 9 | printhex(c); 10 | println(""); 11 | } 12 | } 13 | } 14 | 15 | -------------------------------------------------------------------------------- /hosts/fuzz/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR=../.. 2 | all: 3 | afl-clang-fast -g3 -fsanitize=address,undefined -Wall -DUVM32_MEMORY_SIZE=4096 -I${TOPDIR}/uvm32 -I${TOPDIR}/common -o host-fuzz ${TOPDIR}/uvm32/uvm32.c fuzz.c 4 | afl-fuzz -i${TOPDIR}/precompiled -oo ./host-fuzz 5 | 6 | clean: 7 | rm -rf host-fuzz o host-fuzz.dSYM 8 | 9 | 10 | -------------------------------------------------------------------------------- /apps/tinygl/src/TinyGL/BeOS/Makefile: -------------------------------------------------------------------------------- 1 | OBJS=GLView.o 2 | INCLUDES = -I../include 3 | LIB = libGLView.a 4 | 5 | all: $(LIB) 6 | 7 | $(LIB): $(OBJS) 8 | rm -f $(LIB) 9 | ar rcs $(LIB) $(OBJS) 10 | cp $(LIB) ../lib 11 | 12 | clean: 13 | rm -f *~ *.o *.a 14 | 15 | GLView.o: GLView.cpp GLView.h 16 | $(CC) $(CFLAGS) $(INCLUDES) -c GLView.cpp 17 | -------------------------------------------------------------------------------- /hosts/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | (cd host && make) 3 | (cd host-mini && make) 4 | (cd host-parallel && make) 5 | (cd host-arduino && make) 6 | (cd host-sdl && make) 7 | 8 | clean: 9 | (cd host && make clean) 10 | (cd host-mini && make clean) 11 | (cd host-parallel && make clean) 12 | (cd host-arduino && make clean) 13 | (cd host-sdl && make clean) 14 | 15 | -------------------------------------------------------------------------------- /test/unity/auto/__init__.py: -------------------------------------------------------------------------------- 1 | # ========================================================================= 2 | # Unity - A Test Framework for C 3 | # ThrowTheSwitch.org 4 | # Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams 5 | # SPDX-License-Identifier: MIT 6 | # ========================================================================= 7 | 8 | -------------------------------------------------------------------------------- /apps/rust-hello/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rust-hello" 3 | version = "0.0.1" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | panic-halt = "1.0.0" 8 | 9 | [profile.dev] 10 | panic = "abort" 11 | 12 | [profile.release] 13 | panic = "abort" 14 | opt-level = "z" # Optimize for size 15 | lto = true 16 | strip = true 17 | 18 | [build-dependencies] 19 | bindgen = "0.71.0" 20 | -------------------------------------------------------------------------------- /apps/tinygl/src/TinyGL/src/error.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "zgl.h" 3 | 4 | void gl_fatal_error(char *format, ...) 5 | { 6 | // FIXME 7 | // va_list ap; 8 | // 9 | // va_start(ap,format); 10 | // 11 | // fprintf(stderr,"TinyGL: fatal error: "); 12 | // vfprintf(stderr,format,ap); 13 | // fprintf(stderr,"\n"); 14 | // exit(1); 15 | // 16 | // va_end(ap); 17 | } 18 | -------------------------------------------------------------------------------- /apps/rust-hello/Makefile: -------------------------------------------------------------------------------- 1 | PROJECT=rust-hello 2 | TOPDIR=../.. 3 | 4 | all: 5 | cargo build -r --target riscv32im-unknown-none-elf && ${PREFIX}objcopy target/riscv32im-unknown-none-elf/release/${PROJECT} -O binary ${PROJECT}.bin 6 | 7 | clean: clean_common 8 | rm -rf target 9 | 10 | test: all 11 | ${TOPDIR}/host/host ${PROJECT}.bin 12 | 13 | include ${TOPDIR}/apps/common/makefile.common 14 | -------------------------------------------------------------------------------- /apps/heap/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR=../.. 2 | PROJECT:=$(shell basename ${PWD}) 3 | 4 | HEAP_SIZE=$(shell echo "1024 * 512" | bc) 5 | OPT=-Os 6 | CFLAGS=-DHEAP_SIZE=${HEAP_SIZE} 7 | SRCS=${PROJECT}.c ${TOPDIR}/apps/common/crt0.S malloc_freelist.c 8 | HOST_EXTRA=-e ${HEAP_SIZE} -i 100000 9 | all: all_common 10 | test: test_common 11 | clean: clean_common 12 | include ${TOPDIR}/apps/common/makefile.common 13 | -------------------------------------------------------------------------------- /apps/memtest/memtest.c: -------------------------------------------------------------------------------- 1 | #include "uvm32_target.h" 2 | #include "barr_memtest.h" 3 | 4 | void main(void) { 5 | datum * base = (datum *)UVM32_EXTRAM_BASE; 6 | if ((memTestDataBus(base) != 0) || (memTestAddressBus(base, HEAP_SIZE) != NULL) || (memTestDevice(base, HEAP_SIZE) != NULL)) { 7 | println("Memory error!"); 8 | } else { 9 | println("Memory ok"); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /apps/tinygl/src/TinyGL/src/memory.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Memory allocator for TinyGL 3 | */ 4 | #include "zgl.h" 5 | 6 | /* modify these functions so that they suit your needs */ 7 | 8 | void gl_free(void *p) 9 | { 10 | free(p); 11 | } 12 | 13 | void *gl_malloc(int size) 14 | { 15 | return malloc(size); 16 | } 17 | 18 | void *gl_zalloc(int size) 19 | { 20 | return calloc(1, size); 21 | } 22 | -------------------------------------------------------------------------------- /apps/memtest/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR=../.. 2 | PROJECT:=$(shell basename ${PWD}) 3 | 4 | HEAP_SIZE=$(shell echo "1024 * 1024 * 32" | bc) 5 | OPT=-Os 6 | CFLAGS=-DHEAP_SIZE=${HEAP_SIZE} 7 | SRCS=${PROJECT}.c ${TOPDIR}/apps/common/crt0.S barr_memtest.c 8 | 9 | HOST_EXTRA=-e ${HEAP_SIZE} -i 4294967295 10 | all: all_common 11 | test: test_common 12 | clean: clean_common 13 | include ${TOPDIR}/apps/common/makefile.common 14 | -------------------------------------------------------------------------------- /test/extram/shared.h: -------------------------------------------------------------------------------- 1 | #define SYSCALL_BASE 0x200 2 | 3 | #define SYSCALL_PICKTEST SYSCALL_BASE+0 4 | enum { 5 | TEST1, 6 | TEST2, 7 | TEST3, 8 | TEST4, 9 | TEST5, 10 | TEST6, 11 | TEST7, 12 | TEST8, 13 | TEST9, 14 | TEST10, 15 | TEST11, 16 | TEST12, 17 | TEST13, 18 | TEST14, 19 | TEST15, 20 | TEST16, 21 | TEST17, 22 | TEST18, 23 | }; 24 | 25 | -------------------------------------------------------------------------------- /apps/gfx/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR=../.. 2 | PROJECT:=$(shell basename ${PWD}) 3 | 4 | OPT=-Os 5 | SRCS=${PROJECT}.c ${TOPDIR}/apps/common/crt0.S 6 | 7 | HEAP_SIZE=$(shell echo "320 * 200 * 4" | bc) 8 | HOST_EXTRA=-e ${HEAP_SIZE} -i 9999999 9 | 10 | all: all_common 11 | test: all 12 | ${TOPDIR}/hosts/host-sdl/host-sdl ${HOST_EXTRA} ${PWD}/${PROJECT}.bin 13 | 14 | clean: clean_common 15 | include ${TOPDIR}/apps/common/makefile.common 16 | -------------------------------------------------------------------------------- /apps/tinygl/src/TinyGL/Makefile: -------------------------------------------------------------------------------- 1 | include config.mk 2 | 3 | all: 4 | ( for f in $(DIRS); do ( cd $$f ; make all ) || exit 1 ; done ) 5 | 6 | clean: 7 | rm -f *~ lib/libTinyGL.a include/GL/*~ TAGS 8 | ( for f in $(DIRS); do ( cd $$f ; make clean ; ) done ) 9 | 10 | install: 11 | ( for f in $(DIRS); do ( cd $$f ; make install ; ) done ) 12 | 13 | 14 | tar: 15 | ( cd .. ; tar zcvf /tmp/TinyGL-0.4.1.tar.gz TinyGL --exclude .svn --exclude TAGS ) 16 | -------------------------------------------------------------------------------- /apps/tinygl/src/TinyGL/examples/ui.h: -------------------------------------------------------------------------------- 1 | /* 2 | * tk like ui 3 | */ 4 | void draw( void ); 5 | void idle( void ); 6 | GLenum key(int k, GLenum mask); 7 | void reshape( int width, int height ); 8 | void init( void ); 9 | int ui_loop(int argc, char **argv, const char *name); 10 | void tkSwapBuffers(void); 11 | 12 | #define KEY_UP 0xe000 13 | #define KEY_DOWN 0xe001 14 | #define KEY_LEFT 0xe002 15 | #define KEY_RIGHT 0xe003 16 | #define KEY_ESCAPE 0xe004 17 | 18 | -------------------------------------------------------------------------------- /apps/zigtris/Makefile: -------------------------------------------------------------------------------- 1 | PROJECT=zigtris 2 | TOPDIR=../.. 3 | 4 | all: 5 | @# zig's objcopy is broken, so use external tool 6 | @# https://ziggit.dev/t/addobjcopy-producing-zero-padding-at-start-of-binary/13384 7 | zig build && ${PREFIX}objcopy zig-out/bin/${PROJECT} -O binary ${PROJECT}.bin 8 | 9 | clean: clean_common 10 | rm -rf zig-out .zig-cache 11 | 12 | test: all 13 | ${TOPDIR}/hosts/host/host ${PROJECT}.bin 14 | 15 | include ${TOPDIR}/apps/common/makefile.common 16 | -------------------------------------------------------------------------------- /apps/zig-mandel/Makefile: -------------------------------------------------------------------------------- 1 | PROJECT=mandel 2 | TOPDIR=../.. 3 | 4 | all: 5 | @# zig's objcopy is broken, so use external tool 6 | @# https://ziggit.dev/t/addobjcopy-producing-zero-padding-at-start-of-binary/13384 7 | zig build && ${PREFIX}objcopy zig-out/bin/${PROJECT} -O binary ${PROJECT}.bin 8 | 9 | clean: clean_common 10 | rm -rf zig-out .zig-cache 11 | 12 | test: all 13 | ${TOPDIR}/hosts/host/host ${PROJECT}.bin 14 | 15 | include ${TOPDIR}/apps/common/makefile.common 16 | -------------------------------------------------------------------------------- /common/uvm32_sys.h: -------------------------------------------------------------------------------- 1 | #ifndef UVM32_SYS_H 2 | #define UVM32_SYS_H 1 3 | 4 | // Common definitions used by both uvm32.c and any code running inside VM 5 | 6 | // System provided UVM32_SYSCALLs, start at 0x10000000 7 | #define UVM32_SYSCALL_HALT 0x1000000 8 | #define UVM32_SYSCALL_YIELD 0x1000001 9 | #define UVM32_SYSCALL_STACKPROTECT 0x1000002 10 | 11 | // Address of External RAM, when offered by host 12 | #define UVM32_EXTRAM_BASE 0x10000000 13 | 14 | #endif 15 | 16 | -------------------------------------------------------------------------------- /apps/tinygl/src/TinyGL/INSTALL: -------------------------------------------------------------------------------- 1 | Installation: 2 | 3 | - Edit config.mk and change what is needed. You can also look at 4 | src/zfeatures.h to change very specific details (only useful to tune 5 | TinyGL to your needs). You can link the examples with either OpenGL, 6 | Mesa or TinyGL. 7 | 8 | - Type 'make'. The library 'libTinyGL.a' is copied into './lib'. The 9 | examples are build in './examples'. Only the directories './lib' and 10 | './include' are needed to use TinyGL from another program. 11 | -------------------------------------------------------------------------------- /apps/zigalloc/src/main.zig: -------------------------------------------------------------------------------- 1 | const uvm = @import("uvm.zig"); 2 | const console = @import("console.zig").getWriter(); 3 | 4 | fn submain() !void { 5 | try console.print("Hello world\n", .{}); 6 | try console.flush(); 7 | 8 | const foo = try uvm.allocator().dupe(u8, "copy me"); 9 | try console.print("dupe={s}\n", .{foo}); 10 | try console.flush(); 11 | 12 | } 13 | 14 | export fn main() void { 15 | _ = submain() catch { 16 | uvm.println("Caught err"); 17 | }; 18 | } 19 | -------------------------------------------------------------------------------- /hosts/host-parallel/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR = ../.. 2 | all: 3 | @echo "const unsigned char fib[] = {" > fib.h 4 | @cat ${TOPDIR}/precompiled/fib.bin | xxd -i >> fib.h 5 | @echo "};\nunsigned int fib_len = " >> fib.h 6 | @wc -c ${TOPDIR}/precompiled/fib.bin | awk '{print $$1}' >> fib.h 7 | @echo ";" >> fib.h 8 | gcc -Wall -DUVM32_ERROR_STRINGS -DUVM32_MEMORY_SIZE=16386 -I${TOPDIR}/uvm32 -I${TOPDIR}/common -o host-parallel ${TOPDIR}/uvm32/uvm32.c host-parallel.c 9 | 10 | clean: 11 | rm -f host-parallel 12 | -------------------------------------------------------------------------------- /hosts/host-mini/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR=../.. 2 | 3 | all: 4 | @echo "const unsigned char mandel[] = {" > mandel.h 5 | @cat ${TOPDIR}/precompiled/mandel.bin | xxd -i >> mandel.h 6 | @echo "};\nunsigned int mandel_len = " >> mandel.h 7 | @wc -c ${TOPDIR}/precompiled/mandel.bin | awk '{print $$1}' >> mandel.h 8 | @echo ";" >> mandel.h 9 | gcc -Wall -DUVM32_ERROR_STRINGS -DUVM32_MEMORY_SIZE=512 -O2 -I${TOPDIR}/uvm32 -I${TOPDIR}/common -o host-mini ${TOPDIR}/uvm32/uvm32.c host-mini.c 10 | 11 | clean: 12 | rm -f host-mini 13 | -------------------------------------------------------------------------------- /apps/sketch/sketch.c: -------------------------------------------------------------------------------- 1 | #include "uvm32_target.h" 2 | 3 | // provide main, with setup()/loop() flow 4 | void setup(void); 5 | bool loop(void); 6 | 7 | 8 | uint32_t count; 9 | 10 | bool loop(void) { 11 | printdec(count); 12 | println(""); 13 | if (count++ >= 10) { 14 | return false; 15 | } else { 16 | return true; 17 | } 18 | } 19 | 20 | void setup(void) { 21 | count = 0; 22 | } 23 | 24 | 25 | void main(void) { 26 | setup(); 27 | while(loop()) { 28 | yield(0); 29 | } 30 | } 31 | 32 | -------------------------------------------------------------------------------- /test/common/makefile-rom.common: -------------------------------------------------------------------------------- 1 | TOPDIR=../../../ 2 | PROJECT:=$(shell basename ${PWD}) 3 | SRCS=${PROJECT}.c ${TOPDIR}/apps/common/crt0.S 4 | OPT=-O0 5 | CFLAGS=-DUVM32_MEMORY_SIZE=16384 6 | all: all_common 7 | @# Convert ROM to C file and header 8 | @xxd -i ${PROJECT}.bin > ${PROJECT}-header.c 9 | @echo "extern unsigned char ${PROJECT}_bin[]; extern int ${PROJECT}_bin_len;" > ${PROJECT}-header.h 10 | 11 | test: test_common 12 | clean: clean_common 13 | rm -f ${PROJECT}-header.h ${PROJECT}-header.c 14 | 15 | include ${TOPDIR}/apps/common/makefile.common 16 | -------------------------------------------------------------------------------- /test/opcodes/rom/rom.c: -------------------------------------------------------------------------------- 1 | #include "uvm32_target.h" 2 | #include "../shared.h" 3 | 4 | void main(void) { 5 | switch(syscall(SYSCALL_PICKTEST, 0, 0)) { 6 | case TEST1: 7 | asm("auipc t0, 0"); // copy pc into t0 8 | asm("auipc t1, 0"); // copy pc into t1 9 | break; 10 | case TEST2: 11 | asm("li t0, 2"); 12 | asm("li t1, 1"); 13 | label2: 14 | println("loop"); 15 | asm goto("blt t0, t1, %l0" : : : : label2); 16 | break; 17 | 18 | } 19 | } 20 | 21 | -------------------------------------------------------------------------------- /hosts/host-sdl/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR=../.. 2 | 3 | UNAME_S := $(shell uname -s) 4 | 5 | ifeq ($(UNAME_S),Linux) 6 | LIBS = ${SDL} -lm -lSDL3 7 | else 8 | LIBS = `pkg-config sdl3 --libs --static` 9 | CFLAGS += `pkg-config sdl3 --cflags` 10 | endif 11 | 12 | CFLAGS += -Wall -Werror 13 | CFLAGS += -pedantic -std=c99 -O3 14 | CFLAGS += -DUVM32_ERROR_STRINGS -DUVM32_MEMORY_SIZE=$(shell echo "1024 * 1024 * 8" | bc) 15 | 16 | all: 17 | gcc ${CFLAGS} -I${TOPDIR}/uvm32 -I${TOPDIR}/common -o host-sdl ${TOPDIR}/uvm32/uvm32.c host-sdl.c ${LIBS} 18 | 19 | clean: 20 | rm -f host-sdl 21 | -------------------------------------------------------------------------------- /test/badcode/test/tests.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "unity.h" 3 | #include "uvm32.h" 4 | #include "../common/uvm32_common_custom.h" 5 | 6 | #include "rom-header.h" 7 | 8 | static uvm32_state_t vmst; 9 | //static uvm32_evt_t evt; 10 | 11 | void setUp(void) { 12 | } 13 | 14 | void tearDown(void) { 15 | } 16 | 17 | void test_giant_rom(void) { 18 | // try to load a ROM bigger than we have space for 19 | uvm32_init(&vmst); 20 | TEST_ASSERT_EQUAL(false, uvm32_load(&vmst, rom_bin, UVM32_MEMORY_SIZE+1)); // if it reads off end of rom_bin, will crash 21 | } 22 | 23 | 24 | -------------------------------------------------------------------------------- /test/unity/auto/type_sanitizer.rb: -------------------------------------------------------------------------------- 1 | # ========================================================================= 2 | # Unity - A Test Framework for C 3 | # ThrowTheSwitch.org 4 | # Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams 5 | # SPDX-License-Identifier: MIT 6 | # ========================================================================= 7 | 8 | module TypeSanitizer 9 | def self.sanitize_c_identifier(unsanitized) 10 | # convert filename to valid C identifier by replacing invalid chars with '_' 11 | unsanitized.gsub(/[-\/\\.,\s]/, '_') 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /apps/common/crt0.S: -------------------------------------------------------------------------------- 1 | #include "uvm32_sys.h" 2 | 3 | .equ uvm32_syscall_halt, 0x1000000 4 | .equ uvm32_syscall_yield, 0x1000001 5 | .equ uvm32_syscall_stackprotect, 0x1000002 6 | 7 | .section .initial_jump , "ax", %progbits 8 | .global _start 9 | .align 4 10 | _start: 11 | 12 | # Uncomment below to enable stack protection, requires -DUVM32_STACK_PROTECTION 13 | # la a0, _estack 14 | # li a7, uvm32_syscall_stackprotect 15 | # ecall 16 | 17 | # sp is already setup by vm 18 | sw ra,12(sp) 19 | jal ra, main 20 | 21 | li a7, uvm32_syscall_halt 22 | ecall 23 | 24 | .section .data 25 | 26 | -------------------------------------------------------------------------------- /test/syscall_args/shared.h: -------------------------------------------------------------------------------- 1 | #define SYSCALL_BASE 0x200 2 | 3 | 4 | #define SYSCALL_A_DATA0 "Hello\033" // non-printing char 5 | #define SYSCALL_A_DATA1 "" // empty string 6 | 7 | #define SYSCALL_PICKTEST SYSCALL_BASE+0 8 | #define SYSCALL_A SYSCALL_BASE+1 9 | #define SYSCALL_B SYSCALL_BASE+2 10 | #define SYSCALL_C SYSCALL_BASE+3 11 | #define SYSCALL_D SYSCALL_BASE+4 12 | #define SYSCALL_E SYSCALL_BASE+5 13 | #define SYSCALL_F SYSCALL_BASE+6 14 | #define SYSCALL_G SYSCALL_BASE+7 15 | #define SYSCALL_H SYSCALL_BASE+8 16 | #define SYSCALL_I SYSCALL_BASE+9 17 | #define SYSCALL_J SYSCALL_BASE+10 18 | 19 | -------------------------------------------------------------------------------- /apps/zigalloc/Makefile: -------------------------------------------------------------------------------- 1 | PROJECT=zigalloc 2 | TOPDIR=../.. 3 | 4 | HEAP_SIZE=$(shell echo "1024 * 1024 * 8" | bc) 5 | HOST_EXTRA=-e ${HEAP_SIZE} -i 100000 6 | 7 | all: 8 | @# zig's objcopy is broken, so use external tool 9 | @# https://ziggit.dev/t/addobjcopy-producing-zero-padding-at-start-of-binary/13384 10 | zig build -Dheapsize=${HEAP_SIZE} && ${PREFIX}objcopy zig-out/bin/${PROJECT} -O binary ${PROJECT}.bin 11 | 12 | clean: clean_common 13 | rm -rf zig-out .zig-cache 14 | 15 | test: all 16 | ${TOPDIR}/hosts/host/host ${HOST_EXTRA} ${PROJECT}.bin 17 | 18 | include ${TOPDIR}/apps/common/makefile.common 19 | -------------------------------------------------------------------------------- /apps/tinygl/Makefile: -------------------------------------------------------------------------------- 1 | PROJECT=tinygl 2 | TOPDIR=../.. 3 | 4 | HEAP_SIZE=$(shell echo "1024 * 1024 * 8" | bc) 5 | HOST_EXTRA=-e ${HEAP_SIZE} -i 9999999 6 | 7 | all: 8 | @# zig's objcopy is broken, so use external tool 9 | @# https://ziggit.dev/t/addobjcopy-producing-zero-padding-at-start-of-binary/13384 10 | zig build -Dheapsize=${HEAP_SIZE} && ${PREFIX}objcopy zig-out/bin/${PROJECT} -O binary ${PROJECT}.bin 11 | 12 | clean: clean_common 13 | rm -rf zig-out .zig-cache 14 | 15 | test: all 16 | ${TOPDIR}/hosts/host-sdl/host-sdl ${HOST_EXTRA} ${PROJECT}.bin 17 | 18 | include ${TOPDIR}/apps/common/makefile.common 19 | -------------------------------------------------------------------------------- /apps/zigdoom/Makefile: -------------------------------------------------------------------------------- 1 | PROJECT=zigdoom 2 | TOPDIR=../.. 3 | 4 | HEAP_SIZE=$(shell echo "1024 * 1024 * 8" | bc) 5 | HOST_EXTRA=-e ${HEAP_SIZE} -i 9999999 6 | 7 | all: 8 | @# zig's objcopy is broken, so use external tool 9 | @# https://ziggit.dev/t/addobjcopy-producing-zero-padding-at-start-of-binary/13384 10 | zig build -Dheapsize=${HEAP_SIZE} && ${PREFIX}objcopy zig-out/bin/${PROJECT} -O binary ${PROJECT}.bin 11 | 12 | clean: clean_common 13 | rm -rf zig-out .zig-cache 14 | 15 | test: all 16 | ${TOPDIR}/hosts/host-sdl/host-sdl ${HOST_EXTRA} ${PROJECT}.bin 17 | 18 | include ${TOPDIR}/apps/common/makefile.common 19 | -------------------------------------------------------------------------------- /apps/agnes/Makefile: -------------------------------------------------------------------------------- 1 | PROJECT=agnes 2 | TOPDIR=../.. 3 | 4 | HEAP_SIZE=$(shell echo "1024 * 1024 * 1" | bc) 5 | HOST_EXTRA=-e ${HEAP_SIZE} -i 99999999 -W 256 -H 240 6 | 7 | all: 8 | @# zig's objcopy is broken, so use external tool 9 | @# https://ziggit.dev/t/addobjcopy-producing-zero-padding-at-start-of-binary/13384 10 | zig build -Dheapsize=${HEAP_SIZE} && ${PREFIX}objcopy zig-out/bin/${PROJECT} -O binary ${PROJECT}.bin 11 | 12 | clean: clean_common 13 | rm -rf zig-out .zig-cache 14 | 15 | test: all 16 | ${TOPDIR}/hosts/host-sdl/host-sdl ${HOST_EXTRA} ${PROJECT}.bin 17 | 18 | include ${TOPDIR}/apps/common/makefile.common 19 | -------------------------------------------------------------------------------- /apps/tinygl/src/TinyGL/include/GL/nglx.h: -------------------------------------------------------------------------------- 1 | #ifndef NGLX_H 2 | #define NGLX_H 3 | 4 | #include 5 | #include 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | typedef void *NGLXContext; 12 | typedef GR_DRAW_ID NGLXDrawable; 13 | 14 | extern NGLXContext nglXCreateContext( NGLXContext shareList, int flags ); 15 | 16 | extern void nglXDestroyContext( NGLXContext ctx ); 17 | 18 | extern int nglXMakeCurrent( NGLXDrawable drawable, 19 | NGLXContext ctx); 20 | 21 | extern void nglXSwapBuffers( NGLXDrawable drawable ); 22 | 23 | #ifdef __cplusplus 24 | } 25 | #endif 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /apps/self/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR=../.. 2 | PROJECT:=$(shell basename ${PWD}) 3 | SRCS=${PROJECT}.c ${TOPDIR}/apps/common/crt0.S ${TOPDIR}/uvm32/uvm32.c 4 | CFLAGS=-DUVM32_MEMORY_SIZE=8192 -DCUSTOM_STDLIB_H=\"uvm32_target.h\" -I../../uvm32 5 | all: 6 | @echo "const unsigned char mandel[] = {" > mandel.h 7 | @cat ${TOPDIR}/precompiled/mandel.bin | xxd -i >> mandel.h 8 | @echo "};\nunsigned int mandel_len = " >> mandel.h 9 | @wc -c ${TOPDIR}/precompiled/mandel.bin | awk '{print $$1}' >> mandel.h 10 | @echo ";" >> mandel.h 11 | make all_common 12 | test: test_common 13 | clean: clean_common 14 | include ${TOPDIR}/apps/common/makefile.common 15 | -------------------------------------------------------------------------------- /apps/heap/malloc_freelist.h: -------------------------------------------------------------------------------- 1 | #ifndef __MALLOC_FREELIST_H_ 2 | #define __MALLOC_FREELIST_H_ 3 | 4 | #include "uvm32_target.h" 5 | 6 | #ifdef __cplusplus 7 | extern "C" 8 | { 9 | #endif //__cplusplus 10 | 11 | /** 12 | * Initialize malloc with a memory address and pool size 13 | */ 14 | void malloc_addblock(void* addr, size_t size); 15 | 16 | /** 17 | * Free-list malloc implementation 18 | */ 19 | void* fl_malloc(size_t size); 20 | 21 | /** 22 | * Corresponding free-list free implementation 23 | */ 24 | void fl_free(void* ptr); 25 | 26 | #ifdef __cplusplus 27 | } 28 | #endif //__cplusplus 29 | 30 | #endif //__MALLOC_FREELIST_H_ 31 | -------------------------------------------------------------------------------- /apps/zigtris/build.zig.zon: -------------------------------------------------------------------------------- 1 | .{ 2 | .name = .zigtris, 3 | .version = "0.15.2", 4 | .dependencies = .{ 5 | .mibu = .{ 6 | .url = "git+https://github.com/xyaman/mibu.git#be3713ff04e7db3584669e679253ef388e426dc6", 7 | .hash = "mibu-0.0.1-dev-Ddr1riTEAAAYAe1TWBT--W8fPUL8UyBE7dy-yNNZ3z5V", 8 | }, 9 | .zigtris = .{ 10 | .url = "git+https://github.com/ringtailsoftware/zigtris.git#60206d8f12f80dde8e5dac93a4fd217523c2e5be", 11 | .hash = "zigtris-0.0.1-of0vIo1sAACGoev2776uehcqO3gr5wJo2os2cg2XFqK2", 12 | }, 13 | }, 14 | .paths = .{""}, 15 | .fingerprint = 0x1f86de49aac15bec, 16 | } 17 | -------------------------------------------------------------------------------- /test/unity/auto/yaml_helper.rb: -------------------------------------------------------------------------------- 1 | # ========================================================================= 2 | # Unity - A Test Framework for C 3 | # ThrowTheSwitch.org 4 | # Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams 5 | # SPDX-License-Identifier: MIT 6 | # ========================================================================= 7 | 8 | require 'yaml' 9 | 10 | module YamlHelper 11 | def self.load(body) 12 | if YAML.respond_to?(:unsafe_load) 13 | YAML.unsafe_load(body) 14 | else 15 | YAML.load(body) 16 | end 17 | end 18 | 19 | def self.load_file(file) 20 | body = File.read(file) 21 | self.load(body) 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /apps/rust-hello/build.rs: -------------------------------------------------------------------------------- 1 | use std::env; 2 | use std::path::PathBuf; 3 | 4 | fn main() { 5 | // linker 6 | println!("cargo:rustc-link-arg-bin=rust-hello=-T../common/linker.ld"); 7 | 8 | let bindings = bindgen::Builder::default() 9 | .header("uvm32_headers.h") 10 | .parse_callbacks(Box::new(bindgen::CargoCallbacks::new())) 11 | .generate() 12 | .expect("Unable to generate bindings"); 13 | 14 | // Write the bindings to the $OUT_DIR/bindings.rs file. 15 | let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); 16 | bindings 17 | .write_to_file(out_path.join("bindings.rs")) 18 | .expect("Couldn't write bindings!"); 19 | } 20 | 21 | 22 | -------------------------------------------------------------------------------- /apps/tinygl/src/TinyGL/examples/Makefile: -------------------------------------------------------------------------------- 1 | include ../config.mk 2 | 3 | PROGS = mech texobj gears spin 4 | 5 | all: $(PROGS) 6 | 7 | clean: 8 | rm -f core *.o *~ $(PROGS) 9 | 10 | mech: mech.o glu.o $(UI_OBJS) $(GL_DEPS) 11 | $(CC) $(LFLAGS) $^ -o $@ $(GL_LIBS) $(UI_LIBS) -lm 12 | 13 | texobj: texobj.o $(UI_OBJS) $(GL_DEPS) 14 | $(CC) $(LFLAGS) $^ -o $@ $(GL_LIBS) $(UI_LIBS) -lm 15 | 16 | gears: gears.o $(UI_OBJS) $(GL_DEPS) 17 | $(CC) $(LFLAGS) $^ -o $@ $(GL_LIBS) $(UI_LIBS) -lm 18 | 19 | spin: spin.o $(UI_OBJS) $(GL_DEPS) 20 | $(CC) $(LFLAGS) $^ -o $@ $(GL_LIBS) $(UI_LIBS) -lm 21 | 22 | .c.o: 23 | $(CC) $(CFLAGS) $(GL_INCLUDES) $(UI_INCLUDES) -c $*.c 24 | 25 | mech.o: glu.h 26 | 27 | glu.o: glu.h 28 | 29 | ui.o: ui.h 30 | -------------------------------------------------------------------------------- /test/unity/auto/extract_version.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # ========================================================================= 3 | # Unity - A Test Framework for C 4 | # ThrowTheSwitch.org 5 | # Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams 6 | # SPDX-License-Identifier: MIT 7 | # ========================================================================= 8 | 9 | import re 10 | import sys 11 | 12 | ver_re = re.compile(r"^#define\s+UNITY_VERSION_(?:MAJOR|MINOR|BUILD)\s+(\d+)$") 13 | version = [] 14 | 15 | with open(sys.argv[1], "r") as f: 16 | for line in f: 17 | m = ver_re.match(line) 18 | if m: 19 | version.append(m.group(1)) 20 | 21 | print(".".join(version)) 22 | 23 | -------------------------------------------------------------------------------- /apps/tinygl/src/TinyGL/src/clear.c: -------------------------------------------------------------------------------- 1 | #include "zgl.h" 2 | 3 | 4 | void glopClearColor(GLContext *c,GLParam *p) 5 | { 6 | c->clear_color.v[0]=p[1].f; 7 | c->clear_color.v[1]=p[2].f; 8 | c->clear_color.v[2]=p[3].f; 9 | c->clear_color.v[3]=p[4].f; 10 | } 11 | void glopClearDepth(GLContext *c,GLParam *p) 12 | { 13 | c->clear_depth=p[1].f; 14 | } 15 | 16 | 17 | void glopClear(GLContext *c,GLParam *p) 18 | { 19 | int mask=p[1].i; 20 | int z=0; 21 | int r=(int)(c->clear_color.v[0]*65535); 22 | int g=(int)(c->clear_color.v[1]*65535); 23 | int b=(int)(c->clear_color.v[2]*65535); 24 | 25 | /* TODO : correct value of Z */ 26 | 27 | ZB_clear(c->zb,mask & GL_DEPTH_BUFFER_BIT,z, 28 | mask & GL_COLOR_BUFFER_BIT,r,g,b); 29 | } 30 | 31 | -------------------------------------------------------------------------------- /apps/tinygl/src/TinyGL/src/specbuf.h: -------------------------------------------------------------------------------- 1 | #ifndef _tgl_specbuf_h_ 2 | #define _tgl_specbuf_h_ 3 | 4 | /* Max # of specular light pow buffers */ 5 | #define MAX_SPECULAR_BUFFERS 8 6 | /* # of entries in specular buffer */ 7 | #define SPECULAR_BUFFER_SIZE 1024 8 | /* specular buffer granularity */ 9 | #define SPECULAR_BUFFER_RESOLUTION 1024 10 | 11 | typedef struct GLSpecBuf { 12 | int shininess_i; 13 | int last_used; 14 | float buf[SPECULAR_BUFFER_SIZE+1]; 15 | struct GLSpecBuf *next; 16 | } GLSpecBuf; 17 | 18 | GLSpecBuf *specbuf_get_buffer(GLContext *c, const int shininess_i, 19 | const float shininess); 20 | void specbuf_cleanup(GLContext *c); /* free all memory used */ 21 | 22 | #endif /* _tgl_specbuf_h_ */ 23 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: test 2 | 3 | all: 4 | (cd test && make) 5 | (cd hosts && make) 6 | (cd apps && make) 7 | 8 | clean: 9 | (cd test && make clean) 10 | (cd hosts && make clean) 11 | (cd apps && make clean) 12 | 13 | ci: 14 | (cd test && make ci) 15 | 16 | test: 17 | make -C test 18 | 19 | distrib: all 20 | cp apps/*/*.bin precompiled/ 21 | 22 | dockerbuild: 23 | DOCKER_BUILDKIT=1 docker build -t uvm32 . --no-cache 24 | 25 | dockerbuild_cached: 26 | DOCKER_BUILDKIT=1 docker build -t uvm32 . 27 | 28 | dockershell: 29 | docker run -v `pwd`:/data -w /data --rm -ti uvm32 /bin/bash 30 | 31 | docker: 32 | docker run -v `pwd`:/data -w /data --rm uvm32 make 33 | 34 | dockerci: 35 | docker run -v `pwd`:/data -w /data --rm uvm32 make ci 36 | 37 | 38 | -------------------------------------------------------------------------------- /apps/tinygl/src/TinyGL/examples/glu.h: -------------------------------------------------------------------------------- 1 | 2 | void gluPerspective( GLdouble fovy, GLdouble aspect, 3 | GLdouble zNear, GLdouble zFar ); 4 | 5 | typedef struct { 6 | int draw_style; 7 | } GLUquadricObj; 8 | 9 | #define GLU_LINE 0 10 | 11 | GLUquadricObj *gluNewQuadric(void); 12 | void gluQuadricDrawStyle(GLUquadricObj *obj, int style); 13 | 14 | void gluSphere(GLUquadricObj *qobj, 15 | float radius,int slices,int stacks); 16 | void gluCylinder( GLUquadricObj *qobj, 17 | GLdouble baseRadius, GLdouble topRadius, GLdouble height, 18 | GLint slices, GLint stacks ); 19 | void gluDisk( GLUquadricObj *qobj, 20 | GLdouble innerRadius, GLdouble outerRadius, 21 | GLint slices, GLint loops ); 22 | 23 | void drawTorus(float rc, int numc, float rt, int numt); 24 | -------------------------------------------------------------------------------- /apps/zig-mandel/src/uvm.zig: -------------------------------------------------------------------------------- 1 | const uvm32 = @cImport({ 2 | @cDefine("USE_MAIN", "1"); 3 | @cInclude("uvm32_target.h"); 4 | }); 5 | const std = @import("std"); 6 | 7 | pub inline fn syscall(id: u32, param1: u32, param2: u32) u32 { 8 | var val: u32 = undefined; 9 | asm volatile ("ecall" 10 | : [val] "={a1}" (val), 11 | : [param1] "{a0}" (param1), [param2] "{a1}" (param2), 12 | [id] "{a7}" (id), 13 | : .{ .memory = true }); 14 | return val; 15 | } 16 | 17 | pub inline fn println(val: [:0]const u8) void { 18 | _ = syscall(uvm32.UVM32_SYSCALL_PRINTLN, @intFromPtr(val.ptr), 0); 19 | } 20 | 21 | pub inline fn yield() void { 22 | _ = syscall(uvm32.UVM32_SYSCALL_YIELD, 0, 0); 23 | } 24 | 25 | pub inline fn putc(c:u8) void { 26 | _ = syscall(uvm32.UVM32_SYSCALL_PUTC, c, 0); 27 | } 28 | 29 | -------------------------------------------------------------------------------- /test/stackoverflow/test/tests.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "unity.h" 3 | #include "uvm32.h" 4 | #include "../common/uvm32_common_custom.h" 5 | 6 | #include "rom-header.h" 7 | 8 | static uvm32_state_t vmst; 9 | static uvm32_evt_t evt; 10 | 11 | void setUp(void) { 12 | // runs before each test 13 | uvm32_init(&vmst); 14 | uvm32_load(&vmst, rom_bin, rom_bin_len); 15 | } 16 | 17 | void tearDown(void) { 18 | } 19 | 20 | void test_stackoverflow(void) { 21 | // run the vm 22 | while(1) { 23 | uvm32_run(&vmst, &evt, 100); 24 | if (evt.typ == UVM32_EVT_SYSCALL) { 25 | // ignore syscalls 26 | } else { 27 | TEST_ASSERT_EQUAL(UVM32_EVT_ERR, evt.typ); 28 | TEST_ASSERT_EQUAL(UVM32_ERR_INTERNAL_CORE, evt.data.err.errcode); 29 | break; 30 | } 31 | } 32 | } 33 | 34 | 35 | -------------------------------------------------------------------------------- /apps/gfx/gfx.c: -------------------------------------------------------------------------------- 1 | #include "uvm32_target.h" 2 | 3 | uint32_t* framebuffer = (uint32_t*)UVM32_EXTRAM_BASE; 4 | #define WIDTH 320 5 | #define HEIGHT 200 6 | 7 | void main(void) { 8 | uint8_t r = 0, g = 0, b = 0; 9 | uint32_t framecount = 0; 10 | while (1) { 11 | for (int y = 0; y < HEIGHT; y++) { 12 | for (int x = 0; x < WIDTH; x++) { 13 | r = ((x + framecount) ^ y); 14 | g = (x ^ (y + framecount)); 15 | b = (x ^ y); 16 | r += framecount; 17 | g += framecount * 2; 18 | b += framecount * 3; 19 | framebuffer[y * WIDTH + x] = (r << 24) | (g << 16) | (b << 8) | 0xFF; 20 | } 21 | } 22 | render(UVM32_EXTRAM_BASE, WIDTH*HEIGHT*4); 23 | printdec(framecount++); 24 | println(""); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /hosts/fuzz/fuzz.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "uvm32.h" 6 | #include "../common/uvm32_common_custom.h" 7 | 8 | __AFL_FUZZ_INIT(); 9 | 10 | int main(int argc, char *argv[]) { 11 | __AFL_INIT(); 12 | uvm32_evt_t evt; 13 | 14 | uvm32_state_t *vmst = malloc(sizeof(uvm32_state_t)); 15 | 16 | while (__AFL_LOOP(100000)) { 17 | memset(vmst, 0x00, sizeof(uvm32_state_t)); 18 | uvm32_init(vmst); 19 | unsigned char *rom = __AFL_FUZZ_TESTCASE_BUF; 20 | uvm32_load(vmst, rom, __AFL_FUZZ_TESTCASE_LEN); 21 | 22 | uvm32_extram(vmst, rom, __AFL_FUZZ_TESTCASE_LEN); 23 | 24 | memset(&evt, 0x00, sizeof(evt)); 25 | for (int i=0;i<10;i++) { 26 | uvm32_run(vmst, &evt, 1000); 27 | } 28 | } 29 | 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /common/uvm32_common_custom.h: -------------------------------------------------------------------------------- 1 | // Syscall definitions needed by both host and target for sample apps 2 | // These are not required when building a custom host target code with uvm32 3 | 4 | // syscalls for exposed host functions, start at 0 5 | #define UVM32_SYSCALL_PUTC 0x00000000 6 | #define UVM32_SYSCALL_GETC 0x00000001 7 | #define UVM32_SYSCALL_PRINT 0x00000002 8 | #define UVM32_SYSCALL_PRINTLN 0x00000003 9 | #define UVM32_SYSCALL_PRINTDEC 0x00000004 10 | #define UVM32_SYSCALL_PRINTHEX 0x00000005 11 | #define UVM32_SYSCALL_MILLIS 0x00000006 12 | #define UVM32_SYSCALL_PRINTBUF 0x00000007 13 | #define UVM32_SYSCALL_RENDER 0x00000008 14 | #define UVM32_SYSCALL_GETKEY 0x00000009 15 | #define UVM32_SYSCALL_RENDERAUDIO 0x0000000A 16 | #define UVM32_SYSCALL_CANRENDERAUDIO 0x0000000B 17 | #define UVM32_SYSCALL_RAND 0x0000000C 18 | 19 | 20 | -------------------------------------------------------------------------------- /test/Makefile: -------------------------------------------------------------------------------- 1 | TESTS = \ 2 | basic_syscalls \ 3 | stackoverflow \ 4 | custom_syscall \ 5 | syscall_args \ 6 | meter \ 7 | extram \ 8 | badcode \ 9 | opcodes \ 10 | minirv32_internal 11 | 12 | RUNCMD = $(foreach TEST,${TESTS},make -C ${TEST} &&) 13 | CLEANCMD = $(foreach TEST,${TESTS},make -C ${TEST} clean &&) 14 | 15 | ifeq (,$(shell which gcovr)) 16 | GCOVRCMD=echo Install gcovr for code coverage reports 17 | else 18 | GCOVRCMD=gcovr -r ../ --filter ".*uvm32.*" 19 | PERC=$(shell gcovr -r ../ --filter ".*uvm32.*" | grep TOTAL | awk '{print $$4}') 20 | endif 21 | 22 | all: 23 | ${RUNCMD} true 24 | @${GCOVRCMD} 25 | 26 | ci: 27 | @${GCOVRCMD} 28 | mkdir -p badge 29 | curl "https://img.shields.io/badge/Code%20Coverage-${PERC}25-success?style=flat" > badge/badge.svg 30 | 31 | clean: 32 | ${CLEANCMD} true 33 | rm -f coverage.xml 34 | 35 | -------------------------------------------------------------------------------- /apps/common/target-stdint.h: -------------------------------------------------------------------------------- 1 | #ifndef TARGET_STDINT_H 2 | #define TARGET_STDINT_H 1 3 | 4 | // 5 | typedef unsigned long long uint64_t; 6 | typedef unsigned long uint32_t; 7 | typedef unsigned short uint16_t; 8 | typedef unsigned char uint8_t; 9 | typedef signed long long int64_t; 10 | typedef signed long int32_t; 11 | typedef signed short int16_t; 12 | typedef signed char int8_t; 13 | 14 | #ifndef size_assert 15 | #define size_assert( what, howmuch ) \ 16 | typedef char what##_size_wrong_[( !!(sizeof(what) == howmuch) )*2-1 ] 17 | #endif 18 | 19 | // sanity check 20 | size_assert(uint64_t, 8); 21 | size_assert(uint32_t, 4); 22 | size_assert(uint16_t, 2); 23 | size_assert(uint8_t, 1); 24 | size_assert(int64_t, 8); 25 | size_assert(int32_t, 4); 26 | size_assert(int16_t, 2); 27 | size_assert(int8_t, 1); 28 | 29 | #define INT32_MIN 0 30 | #define INT16_MAX 32767 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /apps/tinygl/src/TinyGL/include/GL/oscontext.h: -------------------------------------------------------------------------------- 1 | #ifndef _tgl_osbuffer_h_ 2 | #define _tgl_osbuffer_h_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | typedef struct { 9 | void **zbs; 10 | void **framebuffers; 11 | int numbuffers; 12 | int xsize, ysize; 13 | } ostgl_context; 14 | 15 | ostgl_context * 16 | ostgl_create_context(const int xsize, 17 | const int ysize, 18 | const int depth, 19 | void **framebuffers, 20 | const int numbuffers); 21 | void 22 | ostgl_delete_context(ostgl_context *context); 23 | 24 | void 25 | ostgl_make_current(ostgl_context *context, const int index); 26 | 27 | void 28 | ostgl_resize(ostgl_context * context, 29 | const int xsize, 30 | const int ysize, 31 | void **framebuffers); 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | 37 | #endif /* _tgl_osbuffer_h_ */ 38 | -------------------------------------------------------------------------------- /hosts/host-arduino/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR=../.. 2 | 3 | # Auto-generate the Arduino example 4 | # Arduino cannot set -DUVM32_MEMORY_SIZE, so add a config file 5 | # Arduino expects .cpp files 6 | 7 | # make test, runs in qemu 8 | 9 | all: 10 | echo '#include "config.h"' > uvm32.cpp 11 | cat ${TOPDIR}/uvm32/uvm32.c >> uvm32.cpp 12 | cp ${TOPDIR}/uvm32/uvm32.h uvm32.h 13 | cp ${TOPDIR}/uvm32/mini-rv32ima.h mini-rv32ima.h 14 | cp ${TOPDIR}/common/uvm32_common_custom.h uvm32_common_custom.h 15 | cp ${TOPDIR}/common/uvm32_sys.h uvm32_sys.h 16 | xxd -n mandel -i ${TOPDIR}/precompiled/mandel.bin | sed -e "s/unsigned char/const unsigned char/" > mandel.h 17 | arduino-cli compile -b arduino:avr:uno -e 18 | 19 | test: all 20 | qemu-system-avr -machine uno -bios build/arduino.avr.uno/host-arduino.ino.elf -nographic -serial mon:stdio 21 | 22 | clean: 23 | rm -rf uvm32.cpp uvm32.h mini-rv32ima.h uvm32_common_custom.h uvm32_sys.h mandel.h build 24 | -------------------------------------------------------------------------------- /test/unity/auto/test_file_filter.rb: -------------------------------------------------------------------------------- 1 | # ========================================================================= 2 | # Unity - A Test Framework for C 3 | # ThrowTheSwitch.org 4 | # Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams 5 | # SPDX-License-Identifier: MIT 6 | # ========================================================================= 7 | 8 | require_relative 'yaml_helper' 9 | 10 | module RakefileHelpers 11 | class TestFileFilter 12 | def initialize(all_files = false) 13 | @all_files = all_files 14 | 15 | return unless @all_files 16 | 17 | file = 'test_file_filter.yml' 18 | return unless File.exist?(file) 19 | 20 | filters = YamlHelper.load_file(file) 21 | @all_files = filters[:all_files] 22 | @only_files = filters[:only_files] 23 | @exclude_files = filters[:exclude_files] 24 | end 25 | 26 | attr_accessor :all_files, :only_files, :exclude_files 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /apps/zigdoom/src/puredoom/doomdef.c: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // $Log:$ 18 | // 19 | // DESCRIPTION: 20 | // DoomDef - basic defines for DOOM, e.g. Version, game mode 21 | // and skill level, and display parameters. 22 | // 23 | //----------------------------------------------------------------------------- 24 | 25 | #include "doom_config.h" 26 | 27 | #include "doomdef.h" 28 | -------------------------------------------------------------------------------- /apps/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | (cd sketch && make) 3 | (cd fib && make) 4 | (cd helloworld && make) 5 | (cd lissajous && make) 6 | (cd conio && make) 7 | (cd self && make) 8 | (cd zig-mandel && make) 9 | (cd zigtris && make) 10 | (cd rust-hello && make) 11 | (cd hello-asm && make) 12 | (cd maze && make) 13 | (cd heap && make) 14 | (cd memtest && make) 15 | (cd zigalloc && make) 16 | (cd gfx && make) 17 | (cd zigdoom && make) 18 | (cd tinygl && make) 19 | (cd agnes && make) 20 | 21 | clean: 22 | (cd sketch && make clean) 23 | (cd fib && make clean) 24 | (cd helloworld && make clean) 25 | (cd lissajous && make clean) 26 | (cd conio && make clean) 27 | (cd self && make clean) 28 | (cd zig-mandel && make clean) 29 | (cd zigtris && make clean) 30 | (cd rust-hello && make clean) 31 | (cd hello-asm && make clean) 32 | (cd maze && make clean) 33 | (cd heap && make clean) 34 | (cd memtest && make clean) 35 | (cd zigalloc && make clean) 36 | (cd gfx && make clean) 37 | (cd zigdoom && make clean) 38 | (cd tinygl && make clean) 39 | (cd agnes && make clean) 40 | 41 | -------------------------------------------------------------------------------- /apps/tinygl/src/TinyGL/README.BEOS: -------------------------------------------------------------------------------- 1 | BeOS support for TinyGL, 1998 Peder Blekken 2 | 3 | I implemented (a limited version of) the BGLView class. There is 4 | no DirectWindow support, and some other funtions are missing too, 5 | but it should work ok for most uses. Feel free to use and modify 6 | GLView.cpp and GLView.h in any way you desire. 7 | 8 | You will need to take a look in Makefile to compile the library 9 | under BeOS. For those of you not familiar with using makefiles: too bad :) 10 | 11 | Also, you will probably need to remove /boot/develop/headers/be/opengl 12 | from the BEINCLUDES environment variable. Unfortunately, this means 13 | editing the /boot/beos/system/boot/SetupEnvironment. It might be possible 14 | to just make sure the TinyGL path is before Be's OpenGL in the include-paths 15 | though. But I prefer to remove /boot/develop/headers/be/opengl, since I 16 | often use Mesa as well. It is a better to add the OpenGL include path in your 17 | makefile; or BeIDE project if that is what you use. 18 | 19 | Contact me for any reason: 20 | 21 | -------------------------------------------------------------------------------- /test/common/makefile.common: -------------------------------------------------------------------------------- 1 | C_COMPILER=gcc 2 | 3 | UNITY_ROOT=../unity 4 | 5 | UVM32_MEMORY_SIZE ?= 16384 6 | 7 | CFLAGS +=-std=c99 8 | CFLAGS += -Wall 9 | CFLAGS += -Werror 10 | CFLAGS += -DUVM32_MEMORY_SIZE=${UVM32_MEMORY_SIZE} 11 | CFLAGS += -fprofile-arcs -ftest-coverage 12 | 13 | SUITE_NAME=tests 14 | 15 | TARGET_BASE1=test1 16 | TARGET1 = $(TARGET_BASE1) 17 | SRC_FILES1=$(UNITY_ROOT)/src/unity.c test/${SUITE_NAME}.c test/test_runners/${SUITE_NAME}_Runner.c ../../uvm32/uvm32.c 18 | INC_DIRS=-I$(UNITY_ROOT)/src -I../../uvm32/ -I../../common -Irom 19 | 20 | .PHONY: rom 21 | 22 | default: $(SRC_FILES1) rom 23 | $(C_COMPILER) $(CFLAGS) $(INC_DIRS) $(SYMBOLS) $(SRC_FILES1) rom/rom-header.c -o $(TARGET1) 24 | @./$(TARGET1) 25 | 26 | rom: 27 | @(cd rom && make) 28 | 29 | test/test_runners/${SUITE_NAME}_Runner.c: test/${SUITE_NAME}.c 30 | @mkdir -p test/test_runners 31 | @ruby $(UNITY_ROOT)/auto/generate_test_runner.rb test/${SUITE_NAME}.c test/test_runners/${SUITE_NAME}_Runner.c 32 | 33 | clean: 34 | rm -rf $(TARGET1) test/test_runners *.gcno *.gcda *.gcov 35 | (cd rom && make clean) 36 | 37 | -------------------------------------------------------------------------------- /test/unity/auto/run_test.erb: -------------------------------------------------------------------------------- 1 | /*=======Test Runner Used To Run Each Test=====*/ 2 | static void run_test(UnityTestFunction func, const char* name, UNITY_LINE_TYPE line_num) 3 | { 4 | Unity.CurrentTestName = name; 5 | Unity.CurrentTestLineNumber = (UNITY_UINT) line_num; 6 | #ifdef UNITY_USE_COMMAND_LINE_ARGS 7 | if (!UnityTestMatches()) 8 | return; 9 | #endif 10 | Unity.NumberOfTests++; 11 | UNITY_CLR_DETAILS(); 12 | UNITY_EXEC_TIME_START(); 13 | CMock_Init(); 14 | if (TEST_PROTECT()) 15 | { 16 | <% if @options[:plugins].include?(:cexception) %> 17 | volatile CEXCEPTION_T e; 18 | Try { 19 | <%= @options[:setup_name] %>(); 20 | func(); 21 | } Catch(e) { 22 | TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, "Unhandled Exception!"); 23 | } 24 | <% else %> 25 | <%= @options[:setup_name] %>(); 26 | func(); 27 | <% end %> 28 | } 29 | if (TEST_PROTECT()) 30 | { 31 | <%= @options[:teardown_name] %>(); 32 | CMock_Verify(); 33 | } 34 | CMock_Destroy(); 35 | UNITY_EXEC_TIME_STOP(); 36 | UnityConcludeTest(); 37 | } 38 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:25.04 2 | ENV LANG=C.UTF-8 3 | ENV LC_ALL=C.UTF-8 4 | RUN apt-get -y update 5 | 6 | # tzdata 7 | ARG DEBIAN_FRONTEND=noninteractive 8 | ENV TZ=Etc/UTC 9 | RUN apt-get install -y tzdata 10 | 11 | # for unity test 12 | RUN apt-get install -y ruby xxd 13 | 14 | # risc-v cross compiler 15 | RUN apt-get install -y gcc-riscv64-unknown-elf build-essential bc 16 | 17 | # zig 18 | RUN apt-get install -y curl 19 | RUN curl https://raw.githubusercontent.com/tristanisham/zvm/master/install.sh | bash 20 | ENV ZVM_INSTALL=/root/.zvm/self 21 | ENV PATH="$PATH:/root/.zvm/bin:/root/.zvm/self" 22 | ENV PATH="$PATH:/.zvm/bin" 23 | RUN zvm i 0.15.2 24 | 25 | # rust 26 | RUN apt-get install -y rustup libclang1 27 | RUN rustup default stable 28 | RUN rustup target add riscv32im-unknown-none-elf 29 | RUN apt-get install -y libclang1 30 | 31 | # arduino 32 | RUN curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh 33 | RUN arduino-cli core install arduino:avr 34 | RUN apt-get install -y qemu-system-misc 35 | 36 | # host-sdl 37 | RUN apt-get install -y libsdl3-0 libsdl3-dev 38 | 39 | # code coverage 40 | RUN apt-get install -y gcovr 41 | 42 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2025 Toby Jaffey 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /apps/tinygl/src/TinyGL/LICENSE: -------------------------------------------------------------------------------- 1 | TinyGL 2 | 3 | Copyright (c) 1997-2022 Fabrice Bellard 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /apps/tinygl/src/TinyGL/src/Makefile: -------------------------------------------------------------------------------- 1 | include ../config.mk 2 | 3 | OBJS= api.o list.o vertex.o init.o matrix.o texture.o \ 4 | misc.o clear.o light.o clip.o select.o get.o error.o \ 5 | zbuffer.o zline.o zdither.o ztriangle.o \ 6 | zmath.o image_util.o oscontext.o msghandling.o \ 7 | arrays.o specbuf.o memory.o 8 | ifdef TINYGL_USE_GLX 9 | OBJS += glx.o 10 | endif 11 | ifdef TINYGL_USE_NANOX 12 | OBJS += nglx.o 13 | endif 14 | 15 | INCLUDES = -I../include 16 | LIB = libTinyGL.a 17 | 18 | all: $(LIB) 19 | 20 | $(LIB): $(OBJS) 21 | rm -f $(LIB) 22 | ar rcs $(LIB) $(OBJS) 23 | cp $(LIB) ../lib 24 | 25 | clean: 26 | rm -f *~ *.o *.a 27 | 28 | .c.o: 29 | $(CC) $(CFLAGS) $(INCLUDES) -c $*.c 30 | 31 | clip.o: zgl.h zfeatures.h 32 | vertex.o: zgl.h zfeatures.h 33 | light.o: zgl.h zfeatures.h 34 | matrix.o: zgl.h zfeatures.h 35 | list.o: zgl.h opinfo.h zfeatures.h 36 | arrays.c: zgl.h zfeatures.h 37 | specbuf.o: zgl.h zfeatures.h 38 | glx.o: zgl.h zfeatures.h 39 | nglx.o: zgl.h zfeatures.h 40 | zline.o: zgl.h zfeatures.h zline.h 41 | 42 | ztriangle.o: ztriangle.c ztriangle.h zgl.h zfeatures.h 43 | $(CC) $(CFLAGS) -Wno-uninitialized $(INCLUDES) -c $*.c 44 | -------------------------------------------------------------------------------- /apps/zigdoom/src/puredoom/p_inter.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // 19 | // 20 | //----------------------------------------------------------------------------- 21 | 22 | #ifndef __P_INTER__ 23 | #define __P_INTER__ 24 | 25 | 26 | #include "d_player.h" 27 | 28 | 29 | doom_boolean P_GivePower(player_t*, int); 30 | 31 | 32 | #endif 33 | 34 | //----------------------------------------------------------------------------- 35 | // 36 | // $Log:$ 37 | // 38 | //----------------------------------------------------------------------------- 39 | -------------------------------------------------------------------------------- /apps/fib/fib.c: -------------------------------------------------------------------------------- 1 | #include "uvm32_target.h" 2 | 3 | void write(int n) { 4 | printdec(n); 5 | println(""); 6 | } 7 | 8 | // print n terms of fibonacci series 9 | void printFib(int n) { 10 | int prev1 = 1; 11 | int prev2 = 0; 12 | 13 | for (int i = 1; i <= n; i++) { 14 | if (i > 2) { 15 | int curr = prev1 + prev2; 16 | prev2 = prev1; 17 | prev1 = curr; 18 | write(curr); 19 | } else if (i == 1) { 20 | write(prev2); 21 | } else if (i == 2) { 22 | write(prev1); 23 | } 24 | } 25 | } 26 | 27 | // print n terms of fibonacci series, recursively 28 | void fib_recursive(int n, int prev1, int prev2) { 29 | if (n < 3) { 30 | return; 31 | } 32 | 33 | int curr = prev1 + prev2; 34 | write(curr); 35 | 36 | return fib_recursive(n - 1, prev2, curr); 37 | } 38 | 39 | void printFibRec(int n) { 40 | write(0); 41 | write(1); 42 | fib_recursive(n, 0, 1); 43 | } 44 | 45 | void main(void) { 46 | int n = 40; 47 | println("fib() loop"); 48 | printFib(n); 49 | println("fib() recursive"); 50 | printFibRec(n); 51 | } 52 | 53 | -------------------------------------------------------------------------------- /apps/tinygl/src/TinyGL/src/zmath.h: -------------------------------------------------------------------------------- 1 | #ifndef __ZMATH__ 2 | #define __ZMATH__ 3 | 4 | /* Matrix & Vertex */ 5 | 6 | typedef struct { 7 | float m[4][4]; 8 | } M4; 9 | 10 | typedef struct { 11 | float m[3][3]; 12 | } M3; 13 | 14 | typedef struct { 15 | float m[3][4]; 16 | } M34; 17 | 18 | 19 | #define X v[0] 20 | #define Y v[1] 21 | #define Z v[2] 22 | #define W v[3] 23 | 24 | typedef struct { 25 | float v[3]; 26 | } V3; 27 | 28 | typedef struct { 29 | float v[4]; 30 | } V4; 31 | 32 | void gl_M4_Id(M4 *a); 33 | int gl_M4_IsId(M4 *a); 34 | void gl_M4_Move(M4 *a,M4 *b); 35 | void gl_MoveV3(V3 *a,V3 *b); 36 | void gl_MulM4V3(V3 *a,M4 *b,V3 *c); 37 | void gl_MulM3V3(V3 *a,M4 *b,V3 *c); 38 | 39 | void gl_M4_MulV4(V4 * a,M4 *b,V4 * c); 40 | void gl_M4_InvOrtho(M4 *a,M4 b); 41 | void gl_M4_Inv(M4 *a,M4 *b); 42 | void gl_M4_Mul(M4 *c,M4 *a,M4 *b); 43 | void gl_M4_MulLeft(M4 *c,M4 *a); 44 | void gl_M4_Transpose(M4 *a,M4 *b); 45 | void gl_M4_Rotate(M4 *c,float t,int u); 46 | int gl_V3_Norm(V3 *a); 47 | 48 | V3 gl_V3_New(float x,float y,float z); 49 | V4 gl_V4_New(float x,float y,float z,float w); 50 | 51 | int gl_Matrix_Inv(float *r,float *m,int n); 52 | 53 | #endif /* __ZMATH__ */ 54 | -------------------------------------------------------------------------------- /apps/zig-mandel/src/main.zig: -------------------------------------------------------------------------------- 1 | const uvm = @import("uvm.zig"); 2 | 3 | fn mandel() void { 4 | const xmin: i32 = -8601; 5 | const xmax: i32 = 2867; 6 | const ymin: i32 = -4915; 7 | const ymax: i32 = 4915; 8 | const maxiter: usize = 32; 9 | const dx: i32 = @divTrunc((xmax - xmin), 79); 10 | const dy: i32 = @divTrunc((ymax - ymin), 24); 11 | var cy = ymin; 12 | 13 | while (cy <= ymax) { 14 | var cx = xmin; 15 | while (cx <= xmax) { 16 | var x: i32 = 0; 17 | var y: i32 = 0; 18 | var x2: i32 = 0; 19 | var y2: i32 = 0; 20 | var iter: usize = 0; 21 | while (iter < maxiter) : (iter += 1) { 22 | if (x2 + y2 > 16384) break; 23 | y = ((x * y) >> 11) + cy; 24 | x = x2 - y2 + cx; 25 | x2 = (x * x) >> 12; 26 | y2 = (y * y) >> 12; 27 | uvm.yield(); 28 | } 29 | uvm.putc(' ' + @as(u8, @intCast(iter))); 30 | cx += dx; 31 | } 32 | uvm.putc('\n'); 33 | cy += dy; 34 | } 35 | } 36 | 37 | export fn main() void { 38 | mandel(); 39 | } 40 | -------------------------------------------------------------------------------- /apps/zigdoom/src/puredoom/doomstat.c: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // $Log:$ 18 | // 19 | // DESCRIPTION: 20 | // Put all global tate variables here. 21 | // 22 | //----------------------------------------------------------------------------- 23 | 24 | 25 | #include "doom_config.h" 26 | #include "doomstat.h" 27 | 28 | 29 | // Game Mode - identify IWAD as shareware, retail etc. 30 | GameMode_t gamemode = indetermined; 31 | GameMission_t gamemission = doom; 32 | 33 | // Language. 34 | Language_t language = english; 35 | 36 | // Set if homebrew PWAD stuff has been added. 37 | doom_boolean modifiedgame; 38 | -------------------------------------------------------------------------------- /apps/zigdoom/src/puredoom/i_net.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // System specific network interface stuff. 19 | // 20 | //----------------------------------------------------------------------------- 21 | 22 | #ifndef __I_NET__ 23 | #define __I_NET__ 24 | 25 | 26 | // Called by D_DoomMain. 27 | 28 | void I_InitNetwork (void); 29 | void I_NetCmd (void); 30 | 31 | 32 | #endif 33 | 34 | //----------------------------------------------------------------------------- 35 | // 36 | // $Log:$ 37 | // 38 | //----------------------------------------------------------------------------- 39 | -------------------------------------------------------------------------------- /apps/rust-hello/src/main.rs: -------------------------------------------------------------------------------- 1 | #![no_std] 2 | #![no_main] 3 | 4 | use core::arch::global_asm; 5 | use core::arch::asm; 6 | use core::panic::PanicInfo; 7 | 8 | // fetch UVM32_SYSCALL definitions from C header 9 | include!(concat!(env!("OUT_DIR"), "/bindings.rs")); 10 | 11 | // startup code 12 | global_asm!(include_str!("../../common/crt0.S")); 13 | 14 | fn syscall(id: u32, param1: u32, param2: u32) -> u32 { 15 | let mut value; 16 | unsafe { 17 | asm!("ecall", 18 | in("a0") param1, in("a1") param2, 19 | in("a7") id, 20 | lateout("a2") value, 21 | ); 22 | } 23 | return value; 24 | } 25 | 26 | fn println(message: &str) { 27 | let addr_value = message.as_ptr() as u32; 28 | syscall(UVM32_SYSCALL_PRINTLN, addr_value, 0); 29 | } 30 | 31 | fn printdec(n: u32) { 32 | syscall(UVM32_SYSCALL_PRINTDEC, n, 0); 33 | } 34 | 35 | #[no_mangle] 36 | pub extern "C" fn main() { 37 | for i in 0..10 { 38 | printdec(i); 39 | println("\0"); 40 | } 41 | println("Hello, world!\0"); 42 | } 43 | 44 | #[panic_handler] 45 | fn panic(_info: &PanicInfo) -> ! { 46 | //println("Something went wrong"); 47 | loop { 48 | continue; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /apps/zigdoom/src/puredoom/p_tick.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // ? 19 | // 20 | //----------------------------------------------------------------------------- 21 | 22 | #ifndef __P_TICK__ 23 | #define __P_TICK__ 24 | 25 | 26 | // Called by C_Ticker, 27 | // can call G_PlayerExited. 28 | // Carries out all thinking of monsters and players. 29 | void P_Ticker(void); 30 | 31 | 32 | #endif 33 | 34 | //----------------------------------------------------------------------------- 35 | // 36 | // $Log:$ 37 | // 38 | //----------------------------------------------------------------------------- 39 | -------------------------------------------------------------------------------- /apps/zigdoom/src/puredoom/r_segs.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // Refresh module, drawing LineSegs from BSP. 19 | // 20 | //----------------------------------------------------------------------------- 21 | 22 | #ifndef __R_SEGS__ 23 | #define __R_SEGS__ 24 | 25 | 26 | #include "r_defs.h" 27 | 28 | 29 | void R_RenderMaskedSegRange(drawseg_t* ds, int x1, int x2); 30 | 31 | 32 | #endif 33 | 34 | //----------------------------------------------------------------------------- 35 | // 36 | // $Log:$ 37 | // 38 | //----------------------------------------------------------------------------- 39 | -------------------------------------------------------------------------------- /apps/common/makefile.common: -------------------------------------------------------------------------------- 1 | PREFIX:=riscv64-elf- 2 | OPT ?= -Os 3 | CFLAGS+=-I${TOPDIR}/common -I${TOPDIR}/apps/common 4 | CFLAGS+=${OPT} -fno-stack-protector -fno-builtin-memcpy -fno-builtin 5 | CFLAGS+=-static-libgcc -fdata-sections -ffunction-sections 6 | CFLAGS+=-g -march=rv32im -mabi=ilp32 -static 7 | LDFLAGS:= -T ${TOPDIR}/apps/common/linker.ld -nostdlib -Wl,--gc-sections 8 | LIBS:= -lgcc # needed for softfp 9 | 10 | # check if the compiler is installed 11 | UNAME_S := $(shell uname -s) 12 | ifeq ($(UNAME_S),Darwin) 13 | PREFIX=riscv64-elf- 14 | ifeq (,$(shell which ${PREFIX}gcc)) 15 | $(error "Try brew install riscv64-elf-gcc riscv64-elf-binutils") 16 | endif 17 | else 18 | PREFIX=riscv64-unknown-elf- 19 | ifeq (,$(shell which ${PREFIX}gcc)) 20 | $(error "Try apt-get install gcc-riscv64-unknown-elf") 21 | endif 22 | endif 23 | 24 | all_common: 25 | ${PREFIX}gcc -o ${PROJECT}.elf ${CFLAGS} ${LDFLAGS} ${SRCS} ${LIBS} 26 | @$(PREFIX)objcopy ${PROJECT}.elf -O binary ${PROJECT}.bin 27 | 28 | disasm_common: all 29 | $(PREFIX)objdump -S -d -f ${PROJECT}.elf 30 | 31 | test_common: all 32 | ${TOPDIR}/hosts/host/host ${HOST_EXTRA} ${PWD}/${PROJECT}.bin 33 | 34 | clean_common: 35 | rm -f ${PROJECT}.o ${PROJECT}.elf ${PROJECT}.bin 36 | 37 | -------------------------------------------------------------------------------- /apps/zigdoom/src/puredoom/p_setup.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // Setup a game, startup stuff. 19 | // 20 | //----------------------------------------------------------------------------- 21 | 22 | #ifndef __P_SETUP__ 23 | #define __P_SETUP__ 24 | 25 | 26 | // NOT called by W_Ticker. Fixme. 27 | void P_SetupLevel(int episode, int map, int playermask, skill_t skill); 28 | 29 | // Called by startup code. 30 | void P_Init(void); 31 | 32 | 33 | #endif 34 | 35 | //----------------------------------------------------------------------------- 36 | // 37 | // $Log:$ 38 | // 39 | //----------------------------------------------------------------------------- 40 | -------------------------------------------------------------------------------- /apps/zigdoom/src/puredoom/m_argv.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // Nil. 19 | // 20 | //----------------------------------------------------------------------------- 21 | 22 | #ifndef __M_ARGV__ 23 | #define __M_ARGV__ 24 | 25 | 26 | // 27 | // MISC 28 | // 29 | extern int myargc; 30 | extern char** myargv; 31 | 32 | // Returns the position of the given parameter 33 | // in the arg list (0 if not found). 34 | int M_CheckParm(char* check); 35 | 36 | 37 | #endif 38 | 39 | //----------------------------------------------------------------------------- 40 | // 41 | // $Log:$ 42 | // 43 | //----------------------------------------------------------------------------- 44 | -------------------------------------------------------------------------------- /apps/memtest/barr_memtest.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * Filename: memtest.h 4 | * 5 | * Description: Memory-testing module API. 6 | * 7 | * Notes: The memory tests can be easily ported to systems with 8 | * different data bus widths by redefining 'datum' type. 9 | * 10 | * 11 | * Copyright (c) 2000 by Michael Barr. This software is placed into 12 | * the public domain and may be used for any purpose. However, this 13 | * notice must not be changed or removed and no warranty is either 14 | * expressed or implied by its publication or distribution. 15 | **********************************************************************/ 16 | 17 | #ifndef _memtest_h 18 | #define _memtest_h 19 | 20 | 21 | /* 22 | * Define NULL pointer value. 23 | */ 24 | #ifndef NULL 25 | #define NULL (void *) 0 26 | #endif 27 | 28 | /* 29 | * Set the data bus width. 30 | */ 31 | typedef unsigned long datum; 32 | 33 | /* 34 | * Function prototypes. 35 | */ 36 | datum memTestDataBus(volatile datum * address); 37 | datum * memTestAddressBus(volatile datum * baseAddress, unsigned long nBytes); 38 | datum * memTestDevice(volatile datum * baseAddress, unsigned long nBytes); 39 | 40 | 41 | #endif /* _memtest_h */ 42 | -------------------------------------------------------------------------------- /apps/agnes/src/console.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | extern fn console_write(data: [*]const u8, len: usize) void; 3 | var wbuf:[4096]u8 = undefined; 4 | var cw = ConsoleWriter.init(&wbuf); 5 | const uvm = @import("uvm.zig"); 6 | 7 | pub const WriteError = error{ Unsupported, NotConnected }; 8 | 9 | pub const ConsoleWriter = struct { 10 | interface: std.Io.Writer, 11 | err: ?WriteError = null, 12 | 13 | fn drain(w: *std.Io.Writer, data: []const []const u8, splat: usize) std.Io.Writer.Error!usize { 14 | var ret: usize = 0; 15 | 16 | const b = w.buffered(); 17 | uvm.print(b); 18 | _ = w.consume(b.len); 19 | 20 | for (data) |d| { 21 | uvm.print(d); 22 | ret += d.len; 23 | } 24 | 25 | const pattern = data[data.len - 1]; 26 | for (0..splat) |_| { 27 | uvm.print(pattern); 28 | ret += pattern.len; 29 | } 30 | 31 | return ret; 32 | } 33 | 34 | pub fn init(buf: []u8) ConsoleWriter { 35 | return ConsoleWriter{ 36 | .interface = .{ 37 | .buffer = buf, 38 | .vtable = &.{ 39 | .drain = drain, 40 | }, 41 | }, 42 | }; 43 | } 44 | }; 45 | 46 | pub fn getWriter() *std.Io.Writer { 47 | return &cw.interface; 48 | } 49 | 50 | -------------------------------------------------------------------------------- /apps/tinygl/src/console.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | extern fn console_write(data: [*]const u8, len: usize) void; 3 | var wbuf:[4096]u8 = undefined; 4 | var cw = ConsoleWriter.init(&wbuf); 5 | const uvm = @import("uvm.zig"); 6 | 7 | pub const WriteError = error{ Unsupported, NotConnected }; 8 | 9 | pub const ConsoleWriter = struct { 10 | interface: std.Io.Writer, 11 | err: ?WriteError = null, 12 | 13 | fn drain(w: *std.Io.Writer, data: []const []const u8, splat: usize) std.Io.Writer.Error!usize { 14 | var ret: usize = 0; 15 | 16 | const b = w.buffered(); 17 | uvm.print(b); 18 | _ = w.consume(b.len); 19 | 20 | for (data) |d| { 21 | uvm.print(d); 22 | ret += d.len; 23 | } 24 | 25 | const pattern = data[data.len - 1]; 26 | for (0..splat) |_| { 27 | uvm.print(pattern); 28 | ret += pattern.len; 29 | } 30 | 31 | return ret; 32 | } 33 | 34 | pub fn init(buf: []u8) ConsoleWriter { 35 | return ConsoleWriter{ 36 | .interface = .{ 37 | .buffer = buf, 38 | .vtable = &.{ 39 | .drain = drain, 40 | }, 41 | }, 42 | }; 43 | } 44 | }; 45 | 46 | pub fn getWriter() *std.Io.Writer { 47 | return &cw.interface; 48 | } 49 | 50 | -------------------------------------------------------------------------------- /apps/zigdoom/src/console.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | extern fn console_write(data: [*]const u8, len: usize) void; 3 | var wbuf:[4096]u8 = undefined; 4 | var cw = ConsoleWriter.init(&wbuf); 5 | const uvm = @import("uvm.zig"); 6 | 7 | pub const WriteError = error{ Unsupported, NotConnected }; 8 | 9 | pub const ConsoleWriter = struct { 10 | interface: std.Io.Writer, 11 | err: ?WriteError = null, 12 | 13 | fn drain(w: *std.Io.Writer, data: []const []const u8, splat: usize) std.Io.Writer.Error!usize { 14 | var ret: usize = 0; 15 | 16 | const b = w.buffered(); 17 | uvm.print(b); 18 | _ = w.consume(b.len); 19 | 20 | for (data) |d| { 21 | uvm.print(d); 22 | ret += d.len; 23 | } 24 | 25 | const pattern = data[data.len - 1]; 26 | for (0..splat) |_| { 27 | uvm.print(pattern); 28 | ret += pattern.len; 29 | } 30 | 31 | return ret; 32 | } 33 | 34 | pub fn init(buf: []u8) ConsoleWriter { 35 | return ConsoleWriter{ 36 | .interface = .{ 37 | .buffer = buf, 38 | .vtable = &.{ 39 | .drain = drain, 40 | }, 41 | }, 42 | }; 43 | } 44 | }; 45 | 46 | pub fn getWriter() *std.Io.Writer { 47 | return &cw.interface; 48 | } 49 | 50 | -------------------------------------------------------------------------------- /apps/zigtris/src/console.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | extern fn console_write(data: [*]const u8, len: usize) void; 3 | var wbuf:[4096]u8 = undefined; 4 | var cw = ConsoleWriter.init(&wbuf); 5 | const uvm = @import("uvm.zig"); 6 | 7 | pub const WriteError = error{ Unsupported, NotConnected }; 8 | 9 | pub const ConsoleWriter = struct { 10 | interface: std.Io.Writer, 11 | err: ?WriteError = null, 12 | 13 | fn drain(w: *std.Io.Writer, data: []const []const u8, splat: usize) std.Io.Writer.Error!usize { 14 | var ret: usize = 0; 15 | 16 | const b = w.buffered(); 17 | uvm.print(b); 18 | _ = w.consume(b.len); 19 | 20 | for (data) |d| { 21 | uvm.print(d); 22 | ret += d.len; 23 | } 24 | 25 | const pattern = data[data.len - 1]; 26 | for (0..splat) |_| { 27 | uvm.print(pattern); 28 | ret += pattern.len; 29 | } 30 | 31 | return ret; 32 | } 33 | 34 | pub fn init(buf: []u8) ConsoleWriter { 35 | return ConsoleWriter{ 36 | .interface = .{ 37 | .buffer = buf, 38 | .vtable = &.{ 39 | .drain = drain, 40 | }, 41 | }, 42 | }; 43 | } 44 | }; 45 | 46 | pub fn getWriter() *std.Io.Writer { 47 | return &cw.interface; 48 | } 49 | 50 | -------------------------------------------------------------------------------- /apps/zigalloc/src/console.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | extern fn console_write(data: [*]const u8, len: usize) void; 3 | var wbuf:[4096]u8 = undefined; 4 | var cw = ConsoleWriter.init(&wbuf); 5 | const uvm = @import("uvm.zig"); 6 | 7 | pub const WriteError = error{ Unsupported, NotConnected }; 8 | 9 | pub const ConsoleWriter = struct { 10 | interface: std.Io.Writer, 11 | err: ?WriteError = null, 12 | 13 | fn drain(w: *std.Io.Writer, data: []const []const u8, splat: usize) std.Io.Writer.Error!usize { 14 | var ret: usize = 0; 15 | 16 | const b = w.buffered(); 17 | uvm.print(b); 18 | _ = w.consume(b.len); 19 | 20 | for (data) |d| { 21 | uvm.print(d); 22 | ret += d.len; 23 | } 24 | 25 | const pattern = data[data.len - 1]; 26 | for (0..splat) |_| { 27 | uvm.print(pattern); 28 | ret += pattern.len; 29 | } 30 | 31 | return ret; 32 | } 33 | 34 | pub fn init(buf: []u8) ConsoleWriter { 35 | return ConsoleWriter{ 36 | .interface = .{ 37 | .buffer = buf, 38 | .vtable = &.{ 39 | .drain = drain, 40 | }, 41 | }, 42 | }; 43 | } 44 | }; 45 | 46 | pub fn getWriter() *std.Io.Writer { 47 | return &cw.interface; 48 | } 49 | 50 | -------------------------------------------------------------------------------- /apps/zigdoom/src/puredoom/m_random.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // 19 | // 20 | //----------------------------------------------------------------------------- 21 | 22 | #ifndef __M_RANDOM__ 23 | #define __M_RANDOM__ 24 | 25 | 26 | #include "doomtype.h" 27 | 28 | 29 | // Returns a number from 0 to 255, 30 | // from a lookup table. 31 | int M_Random(void); 32 | 33 | // As M_Random, but used only by the play simulation. 34 | int P_Random(void); 35 | 36 | // Fix randoms for demos. 37 | void M_ClearRandom(void); 38 | 39 | 40 | #endif 41 | 42 | //----------------------------------------------------------------------------- 43 | // 44 | // $Log:$ 45 | // 46 | //----------------------------------------------------------------------------- 47 | -------------------------------------------------------------------------------- /apps/zigdoom/src/puredoom/r_sky.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // Sky rendering. 19 | // 20 | //----------------------------------------------------------------------------- 21 | 22 | #ifndef __R_SKY__ 23 | #define __R_SKY__ 24 | 25 | // SKY, store the number for name. 26 | #define SKYFLATNAME "F_SKY1" 27 | 28 | // The sky map is 256*128*4 maps. 29 | #define ANGLETOSKYSHIFT 22 30 | 31 | extern int skytexture; 32 | extern int skytexturemid; 33 | 34 | // Called whenever the view size changes. 35 | void R_InitSkyMap(void); 36 | 37 | #endif 38 | 39 | //----------------------------------------------------------------------------- 40 | // 41 | // $Log:$ 42 | // 43 | //----------------------------------------------------------------------------- 44 | -------------------------------------------------------------------------------- /test/unity/auto/colour_reporter.rb: -------------------------------------------------------------------------------- 1 | # ========================================================================= 2 | # Unity - A Test Framework for C 3 | # ThrowTheSwitch.org 4 | # Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams 5 | # SPDX-License-Identifier: MIT 6 | # ========================================================================= 7 | 8 | require_relative 'colour_prompt' 9 | 10 | $colour_output = true 11 | 12 | def report(message) 13 | if !$colour_output 14 | $stdout.puts(message) 15 | else 16 | message = message.join('\n') if message.instance_of?(Array) 17 | message.each_line do |line| 18 | line.chomp! 19 | colour = case line 20 | when /(?:total\s+)?tests:?\s+(\d+)\s+(?:total\s+)?failures:?\s+\d+\s+Ignored:?/i 21 | Regexp.last_match(1).to_i.zero? ? :green : :red 22 | when /PASS/ 23 | :green 24 | when /^OK$/ 25 | :green 26 | when /(?:FAIL|ERROR)/ 27 | :red 28 | when /IGNORE/ 29 | :yellow 30 | when /^(?:Creating|Compiling|Linking)/ 31 | :white 32 | else 33 | :silver 34 | end 35 | colour_puts(colour, line) 36 | end 37 | end 38 | $stdout.flush 39 | $stderr.flush 40 | end 41 | -------------------------------------------------------------------------------- /apps/zigdoom/src/puredoom/d_textur.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // Typedefs related to to textures etc., 19 | // isolated here to make it easier separating modules. 20 | // 21 | //----------------------------------------------------------------------------- 22 | 23 | #ifndef __D_TEXTUR__ 24 | #define __D_TEXTUR__ 25 | 26 | 27 | #include "doomtype.h" 28 | 29 | 30 | // 31 | // Flats? 32 | // 33 | // a pic is an unmasked block of pixels 34 | typedef struct 35 | { 36 | byte width; 37 | byte height; 38 | byte data; 39 | } pic_t; 40 | 41 | 42 | #endif 43 | 44 | //----------------------------------------------------------------------------- 45 | // 46 | // $Log:$ 47 | // 48 | //----------------------------------------------------------------------------- 49 | -------------------------------------------------------------------------------- /apps/zigdoom/src/puredoom/f_finale.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // 19 | // 20 | //----------------------------------------------------------------------------- 21 | 22 | #ifndef __F_FINALE__ 23 | #define __F_FINALE__ 24 | 25 | 26 | #include "doomtype.h" 27 | #include "d_event.h" 28 | 29 | 30 | // 31 | // FINALE 32 | // 33 | 34 | // Called by main loop. 35 | doom_boolean F_Responder(event_t* ev); 36 | 37 | // Called by main loop. 38 | void F_Ticker(void); 39 | 40 | // Called by main loop. 41 | void F_Drawer(void); 42 | 43 | void F_StartFinale(void); 44 | 45 | 46 | #endif 47 | 48 | //----------------------------------------------------------------------------- 49 | // 50 | // $Log:$ 51 | // 52 | //----------------------------------------------------------------------------- 53 | -------------------------------------------------------------------------------- /apps/zigdoom/src/puredoom/m_argv.c: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // $Log:$ 18 | // 19 | // DESCRIPTION: 20 | // 21 | //----------------------------------------------------------------------------- 22 | 23 | 24 | #include "doom_config.h" 25 | 26 | 27 | // #if defined(DOOM_WIN32) 28 | // #define strcasecmp stricmp 29 | // #endif 30 | 31 | 32 | int myargc; 33 | char** myargv; 34 | 35 | 36 | // 37 | // M_CheckParm 38 | // Checks for the given parameter 39 | // in the program's command line arguments. 40 | // Returns the argument number (1 to argc-1) 41 | // or 0 if not present 42 | int M_CheckParm(char* check) 43 | { 44 | int i; 45 | 46 | for (i = 1; i < myargc; i++) 47 | { 48 | if (!doom_strcasecmp(check, myargv[i])) 49 | return i; 50 | } 51 | 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /apps/zigdoom/src/puredoom/m_fixed.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // Fixed point arithemtics, implementation. 19 | // 20 | //----------------------------------------------------------------------------- 21 | 22 | #ifndef __M_FIXED__ 23 | #define __M_FIXED__ 24 | 25 | 26 | // 27 | // Fixed point, 32bit as 16.16. 28 | // 29 | #define FRACBITS 16 30 | #define FRACUNIT (1<> 8) | (x << 8); 39 | } 40 | 41 | 42 | // Swapping 32bit. 43 | unsigned long SwapLONG(unsigned long x) 44 | { 45 | return 46 | (x >> 24) 47 | | ((x >> 8) & 0xff00) 48 | | ((x << 8) & 0xff0000) 49 | | (x << 24); 50 | } 51 | 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /apps/zigdoom/src/puredoom/d_items.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // Items: key cards, artifacts, weapon, ammunition. 19 | // 20 | //----------------------------------------------------------------------------- 21 | 22 | #ifndef __D_ITEMS__ 23 | #define __D_ITEMS__ 24 | 25 | 26 | #include "doomdef.h" 27 | 28 | 29 | // Weapon info: sprite frames, ammunition use. 30 | typedef struct 31 | { 32 | ammotype_t ammo; 33 | int upstate; 34 | int downstate; 35 | int readystate; 36 | int atkstate; 37 | int flashstate; 38 | } weaponinfo_t; 39 | 40 | 41 | extern weaponinfo_t weaponinfo[NUMWEAPONS]; 42 | 43 | 44 | #endif 45 | 46 | //----------------------------------------------------------------------------- 47 | // 48 | // $Log:$ 49 | // 50 | //----------------------------------------------------------------------------- 51 | -------------------------------------------------------------------------------- /apps/zigdoom/src/puredoom/r_sky.c: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // $Log:$ 18 | // 19 | // DESCRIPTION: 20 | // Sky rendering. The DOOM sky is a texture map like any 21 | // wall, wrapping around. A 1024 columns equal 360 degrees. 22 | // The default sky map is 256 columns and repeats 4 times 23 | // on a 320 screen? 24 | // 25 | // 26 | //----------------------------------------------------------------------------- 27 | 28 | 29 | #include "doom_config.h" 30 | 31 | #include "m_fixed.h" // Needed for FRACUNIT. 32 | #include "r_data.h" // Needed for Flat retrieval. 33 | #include "r_sky.h" 34 | 35 | 36 | // 37 | // sky mapping 38 | // 39 | int skyflatnum; 40 | int skytexture; 41 | int skytexturemid; 42 | 43 | 44 | // 45 | // R_InitSkyMap 46 | // Called whenever the view size changes. 47 | // 48 | void R_InitSkyMap(void) 49 | { 50 | skytexturemid = 100 * FRACUNIT; 51 | } 52 | -------------------------------------------------------------------------------- /apps/tinygl/src/TinyGL/src/msghandling.c: -------------------------------------------------------------------------------- 1 | //#include 2 | //#include 3 | 4 | #define NDEBUG 5 | 6 | #ifdef NDEBUG 7 | #define NO_DEBUG_OUTPUT 8 | #endif 9 | 10 | /* Use this function to output messages when something unexpected 11 | happens (which might be an indication of an error). *Don't* use it 12 | when there's internal errors in the code - these should be handled 13 | by asserts. */ 14 | void 15 | tgl_warning(const char *format, ...) 16 | { 17 | #ifndef NO_DEBUG_OUTPUT 18 | va_list args; 19 | va_start(args, format); 20 | fprintf(stderr, "*WARNING* "); 21 | vfprintf(stderr, format, args); 22 | va_end(args); 23 | #endif /* !NO_DEBUG_OUTPUT */ 24 | } 25 | 26 | /* This function should be used for debug output only. */ 27 | void 28 | tgl_trace(const char *format, ...) 29 | { 30 | #ifndef NO_DEBUG_OUTPUT 31 | va_list args; 32 | va_start(args, format); 33 | fprintf(stderr, "*DEBUG* "); 34 | vfprintf(stderr, format, args); 35 | va_end(args); 36 | #endif /* !NO_DEBUG_OUTPUT */ 37 | } 38 | 39 | /* Use this function to output info about things in the code which 40 | should be fixed (missing handling of special cases, important 41 | features not implemented, known bugs/buglets, ...). */ 42 | void 43 | tgl_fixme(const char *format, ...) 44 | { 45 | #ifndef NO_DEBUG_OUTPUT 46 | va_list args; 47 | va_start(args, format); 48 | fprintf(stderr, "*FIXME* "); 49 | vfprintf(stderr, format, args); 50 | va_end(args); 51 | #endif /* !NO_DEBUG_OUTPUT */ 52 | } 53 | -------------------------------------------------------------------------------- /apps/zigdoom/src/puredoom/m_swap.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // Endianess handling, swapping 16bit and 32bit. 19 | // 20 | //----------------------------------------------------------------------------- 21 | 22 | #ifndef __M_SWAP__ 23 | #define __M_SWAP__ 24 | 25 | 26 | // Endianess handling. 27 | // WAD files are stored little endian. 28 | #ifdef __BIG_ENDIAN__ 29 | unsigned short SwapSHORT(unsigned short); 30 | unsigned long SwapLONG(unsigned long); 31 | #define SHORT(x) ((short)SwapSHORT((unsigned short) (x))) 32 | #define LONG(x) ((long)SwapLONG((unsigned long) (x))) 33 | #else 34 | #define SHORT(x) (x) 35 | #define LONG(x) (x) 36 | #endif 37 | 38 | 39 | #endif 40 | 41 | //----------------------------------------------------------------------------- 42 | // 43 | // $Log:$ 44 | // 45 | //----------------------------------------------------------------------------- 46 | -------------------------------------------------------------------------------- /apps/zigdoom/src/puredoom/m_bbox.c: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // $Log:$ 18 | // 19 | // DESCRIPTION: 20 | // Main loop menu stuff. 21 | // Random number LUT. 22 | // Default Config File. 23 | // PCX Screenshots. 24 | // 25 | //----------------------------------------------------------------------------- 26 | 27 | 28 | #include "doom_config.h" 29 | 30 | #include "m_bbox.h" 31 | 32 | 33 | void M_ClearBox(fixed_t* box) 34 | { 35 | box[BOXTOP] = box[BOXRIGHT] = DOOM_MININT; 36 | box[BOXBOTTOM] = box[BOXLEFT] = DOOM_MAXINT; 37 | } 38 | 39 | 40 | void M_AddToBox(fixed_t* box, fixed_t x, fixed_t y) 41 | { 42 | if (x < box[BOXLEFT]) 43 | box[BOXLEFT] = x; 44 | else if (x > box[BOXRIGHT]) 45 | box[BOXRIGHT] = x; 46 | if (y < box[BOXBOTTOM]) 47 | box[BOXBOTTOM] = y; 48 | else if (y > box[BOXTOP]) 49 | box[BOXTOP] = y; 50 | } 51 | -------------------------------------------------------------------------------- /apps/zigtris/src/main.zig: -------------------------------------------------------------------------------- 1 | const uvm = @import("uvm.zig"); 2 | 3 | const mibu = @import("mibu"); 4 | const zigtris = @import("zigtris"); 5 | var nextEvent:mibu.events.Event = .none; 6 | 7 | const console = @import("console.zig").getWriter(); 8 | 9 | export fn main() void { 10 | var gameRunning = true; 11 | var lastUpdate:u32 = 0; 12 | 13 | zigtris.gamesetup(console, uvm.rand()) catch |err| { 14 | _ = console.print("err {any}\n", .{err}) catch 0; 15 | _ = console.flush() catch 0; 16 | return; 17 | }; 18 | 19 | while(gameRunning) { 20 | const now = uvm.millis(); 21 | if (uvm.getc()) |key| { 22 | switch(key) { 23 | ' ' => nextEvent = mibu.events.Event{.key = .{.code = .{.char = ' '}}}, 24 | 0x44 => nextEvent = mibu.events.Event{.key = .{.code = .left}}, 25 | 0x43 => nextEvent = mibu.events.Event{.key = .{.code = .right}}, 26 | 0x41 => nextEvent = mibu.events.Event{.key = .{.code = .up}}, 27 | 0x42 => nextEvent = mibu.events.Event{.key = .{.code = .down}}, 28 | 'q' => gameRunning = false, 29 | else => {}, 30 | } 31 | } 32 | 33 | if (now > lastUpdate + 100 or nextEvent != .none) { 34 | 35 | lastUpdate = now; 36 | gameRunning = zigtris.gameloop(console, now, nextEvent) catch false; 37 | nextEvent = .none; 38 | _ = console.flush() catch 0; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /apps/zigdoom/src/puredoom/m_cheat.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // Cheat code checking. 19 | // 20 | //----------------------------------------------------------------------------- 21 | 22 | #ifndef __M_CHEAT__ 23 | #define __M_CHEAT__ 24 | 25 | 26 | // 27 | // CHEAT SEQUENCE PACKAGE 28 | // 29 | 30 | #define SCRAMBLE(a) \ 31 | ((((a)&1)<<7) + (((a)&2)<<5) + ((a)&4) + (((a)&8)<<1) \ 32 | + (((a)&16)>>1) + ((a)&32) + (((a)&64)>>5) + (((a)&128)>>7)) 33 | 34 | 35 | typedef struct 36 | { 37 | unsigned char* sequence; 38 | unsigned char* p; 39 | } cheatseq_t; 40 | 41 | 42 | int cht_CheckCheat(cheatseq_t* cht, char key); 43 | void cht_GetParam(cheatseq_t* cht, char* buffer); 44 | 45 | 46 | #endif 47 | 48 | //----------------------------------------------------------------------------- 49 | // 50 | // $Log:$ 51 | // 52 | //----------------------------------------------------------------------------- 53 | -------------------------------------------------------------------------------- /apps/zigdoom/src/puredoom/p_saveg.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // Savegame I/O, archiving, persistence. 19 | // 20 | //----------------------------------------------------------------------------- 21 | 22 | #ifndef __P_SAVEG__ 23 | #define __P_SAVEG__ 24 | 25 | 26 | #include "doomtype.h" 27 | 28 | 29 | // Persistent storage/archiving. 30 | // These are the load / save game routines. 31 | void P_ArchivePlayers(void); 32 | void P_UnArchivePlayers(void); 33 | void P_ArchiveWorld(void); 34 | void P_UnArchiveWorld(void); 35 | void P_ArchiveThinkers(void); 36 | void P_UnArchiveThinkers(void); 37 | void P_ArchiveSpecials(void); 38 | void P_UnArchiveSpecials(void); 39 | 40 | extern byte* save_p; 41 | 42 | 43 | #endif 44 | 45 | //----------------------------------------------------------------------------- 46 | // 47 | // $Log:$ 48 | // 49 | //----------------------------------------------------------------------------- 50 | -------------------------------------------------------------------------------- /apps/zigdoom/src/puredoom/wi_stuff.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // Intermission. 19 | // 20 | //----------------------------------------------------------------------------- 21 | 22 | #ifndef __WI_STUFF__ 23 | #define __WI_STUFF__ 24 | 25 | #include "doomdef.h" 26 | 27 | // States for the intermission 28 | typedef enum 29 | { 30 | NoState = -1, 31 | StatCount, 32 | ShowNextLoc 33 | } stateenum_t; 34 | 35 | // Called by main loop, animate the intermission. 36 | void WI_Ticker(void); 37 | 38 | // Called by main loop, 39 | // draws the intermission directly into the screen buffer. 40 | void WI_Drawer(void); 41 | 42 | // Setup for an intermission screen. 43 | void WI_Start(wbstartstruct_t* wbstartstruct); 44 | 45 | #endif 46 | 47 | //----------------------------------------------------------------------------- 48 | // 49 | // $Log:$ 50 | // 51 | //----------------------------------------------------------------------------- 52 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: [push, pull_request] 4 | 5 | # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages 6 | permissions: 7 | contents: read 8 | pages: write 9 | id-token: write 10 | 11 | # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. 12 | # However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. 13 | concurrency: 14 | group: "pages" 15 | cancel-in-progress: false 16 | 17 | jobs: 18 | test: 19 | strategy: 20 | matrix: 21 | os: [ubuntu-latest] 22 | environment: 23 | name: github-pages 24 | url: ${{ steps.deployment.outputs.page_url }} 25 | runs-on: ${{matrix.os}} 26 | steps: 27 | - name: Checkout 28 | uses: actions/checkout@v4 29 | with: 30 | path: uvm32 31 | - name: Build 32 | run: make dockerbuild_cached && make docker 33 | working-directory: uvm32 34 | - name: CI test 35 | run: make dockerci 36 | working-directory: uvm32 37 | - name: Setup Pages 38 | if: github.ref == 'refs/heads/main' 39 | uses: actions/configure-pages@v5 40 | - name: Upload Artifact 41 | if: github.ref == 'refs/heads/main' 42 | uses: actions/upload-pages-artifact@v3 43 | with: 44 | path: uvm32/test/badge 45 | name: github-pages 46 | - name: Deploy to GitHub Pages 47 | if: github.ref == 'refs/heads/main' 48 | id: deployment 49 | uses: actions/deploy-pages@v4 50 | 51 | -------------------------------------------------------------------------------- /apps/zigdoom/src/puredoom/f_wipe.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // Mission start screen wipe/melt, special effects. 19 | // 20 | //----------------------------------------------------------------------------- 21 | 22 | #ifndef __F_WIPE_H__ 23 | #define __F_WIPE_H__ 24 | 25 | 26 | // 27 | // SCREEN WIPE PACKAGE 28 | // 29 | 30 | enum 31 | { 32 | // simple gradual pixel change for 8-bit only 33 | wipe_ColorXForm, 34 | 35 | // weird screen melt 36 | wipe_Melt, 37 | 38 | wipe_NUMWIPES 39 | }; 40 | 41 | 42 | int wipe_StartScreen(int x, int y, int width, int height); 43 | int wipe_EndScreen(int x, int y, int width, int height); 44 | int wipe_ScreenWipe(int wipeno, int x, int y, int width, int height, int ticks); 45 | 46 | 47 | #endif 48 | 49 | //----------------------------------------------------------------------------- 50 | // 51 | // $Log:$ 52 | // 53 | //----------------------------------------------------------------------------- 54 | -------------------------------------------------------------------------------- /apps/self/self.c: -------------------------------------------------------------------------------- 1 | #include "uvm32_target.h" 2 | #include "uvm32.h" 3 | #include "../common/uvm32_common_custom.h" 4 | #include "mandel.h" 5 | 6 | void main(void) { 7 | uvm32_state_t vmst; 8 | uvm32_evt_t evt; 9 | bool isrunning = true; 10 | 11 | uvm32_init(&vmst); 12 | uvm32_load(&vmst, mandel, mandel_len); 13 | 14 | while(isrunning) { 15 | uvm32_run(&vmst, &evt, 100); // num instructions before vm considered hung 16 | 17 | switch(evt.typ) { 18 | case UVM32_EVT_END: 19 | isrunning = false; 20 | break; 21 | case UVM32_EVT_SYSCALL: // vm has paused to handle UVM32_SYSCALL 22 | switch(evt.data.syscall.code) { 23 | case UVM32_SYSCALL_YIELD: 24 | break; 25 | case UVM32_SYSCALL_PUTC: 26 | putc(uvm32_arg_getval(&vmst, &evt, ARG0)); 27 | break; 28 | case UVM32_SYSCALL_PRINTLN: { 29 | //const char *str = uvm32_arg_getcstr(&vmst, &evt, ARG0); 30 | //println(str); 31 | } break; 32 | default: 33 | // println("Unhandled syscall"); 34 | break; 35 | } 36 | break; 37 | case UVM32_EVT_ERR: 38 | // println("error: "); 39 | // printdec(evt.data.err.errcode); 40 | // println(""); 41 | break; 42 | default: 43 | break; 44 | } 45 | } 46 | } 47 | 48 | -------------------------------------------------------------------------------- /apps/self/mandel.h: -------------------------------------------------------------------------------- 1 | const unsigned char mandel[] = { 2 | 0x23, 0x26, 0x11, 0x00, 0xef, 0x00, 0xc0, 0x00, 0xb7, 0x08, 0x00, 0x01, 3 | 0x73, 0x00, 0x00, 0x00, 0x13, 0x01, 0x01, 0xff, 0x23, 0x26, 0x81, 0x00, 4 | 0x37, 0xf5, 0xff, 0xff, 0xb7, 0x15, 0x00, 0x00, 0x37, 0xe6, 0xff, 0xff, 5 | 0x13, 0x07, 0xf0, 0x01, 0xb7, 0x47, 0x00, 0x00, 0xb7, 0x06, 0x00, 0x01, 6 | 0x13, 0x08, 0xd5, 0xcc, 0x93, 0x82, 0x35, 0x33, 0x13, 0x03, 0x76, 0xe6, 7 | 0x93, 0x83, 0x35, 0xb3, 0x13, 0x86, 0x16, 0x00, 0x63, 0xce, 0x02, 0x09, 8 | 0x13, 0x0e, 0x03, 0x00, 0x63, 0xce, 0x63, 0x06, 0x93, 0x0f, 0x00, 0x00, 9 | 0x13, 0x0f, 0x00, 0x00, 0x13, 0x04, 0x00, 0x00, 0x93, 0x0e, 0x00, 0x00, 10 | 0x93, 0x06, 0x00, 0x02, 0x13, 0x85, 0x06, 0xfe, 0x63, 0x64, 0xa7, 0x04, 11 | 0x33, 0x05, 0xff, 0x01, 0x63, 0xe0, 0xa7, 0x04, 0x13, 0x05, 0x00, 0x00, 12 | 0x93, 0x05, 0x00, 0x00, 0x93, 0x08, 0x06, 0x00, 0xb3, 0x8e, 0x8e, 0x02, 13 | 0x33, 0x0f, 0xff, 0x41, 0x13, 0xd4, 0xbe, 0x40, 0xb3, 0x0e, 0xcf, 0x01, 14 | 0x73, 0x00, 0x00, 0x00, 0x33, 0x04, 0x04, 0x01, 0x33, 0x85, 0xde, 0x03, 15 | 0x13, 0x5f, 0xc5, 0x00, 0x33, 0x05, 0x84, 0x02, 0x93, 0x5f, 0xc5, 0x00, 16 | 0x93, 0x86, 0x16, 0x00, 0x6f, 0xf0, 0x9f, 0xfb, 0x13, 0x85, 0x06, 0x00, 17 | 0x93, 0x05, 0x00, 0x00, 0x93, 0x08, 0x00, 0x00, 0x73, 0x00, 0x00, 0x00, 18 | 0x13, 0x0e, 0x1e, 0x09, 0xe3, 0xd6, 0xc3, 0xf9, 0x13, 0x05, 0xa0, 0x00, 19 | 0x93, 0x05, 0x00, 0x00, 0x93, 0x08, 0x00, 0x00, 0x73, 0x00, 0x00, 0x00, 20 | 0x13, 0x08, 0x98, 0x19, 0xe3, 0xd6, 0x02, 0xf7, 0x03, 0x24, 0xc1, 0x00, 21 | 0x13, 0x01, 0x01, 0x01, 0x67, 0x80, 0x00, 0x00 22 | }; 23 | unsigned int mandel_len = 24 | 236 25 | ; 26 | -------------------------------------------------------------------------------- /apps/zigdoom/src/puredoom/d_main.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // $Log:$ 18 | // 19 | // DESCRIPTION: 20 | // System specific interface stuff. 21 | // 22 | //----------------------------------------------------------------------------- 23 | 24 | #ifndef __D_MAIN__ 25 | #define __D_MAIN__ 26 | 27 | 28 | #include "d_event.h" 29 | 30 | 31 | #define MAXWADFILES 20 32 | 33 | 34 | extern char* wadfiles[MAXWADFILES]; 35 | 36 | 37 | void D_AddFile(char* file); 38 | 39 | // 40 | // D_DoomMain() 41 | // Not a globally visible function, just included for source reference, 42 | // calls all startup code, parses command line options. 43 | // If not overrided by user input, calls N_AdvanceDemo. 44 | // 45 | void D_DoomMain(void); 46 | 47 | // Called by IO functions when input is detected. 48 | void D_PostEvent(event_t* ev); 49 | 50 | // 51 | // BASE LEVEL 52 | // 53 | void D_PageTicker(void); 54 | void D_PageDrawer(void); 55 | void D_AdvanceDemo(void); 56 | void D_StartTitle(void); 57 | 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /hosts/host-mini/mandel.h: -------------------------------------------------------------------------------- 1 | const unsigned char mandel[] = { 2 | 0x23, 0x26, 0x11, 0x00, 0xef, 0x00, 0xc0, 0x00, 0xb7, 0x08, 0x00, 0x01, 3 | 0x73, 0x00, 0x00, 0x00, 0x13, 0x01, 0x01, 0xff, 0x23, 0x26, 0x81, 0x00, 4 | 0x37, 0xf5, 0xff, 0xff, 0xb7, 0x15, 0x00, 0x00, 0x37, 0xe6, 0xff, 0xff, 5 | 0x13, 0x07, 0xf0, 0x01, 0xb7, 0x47, 0x00, 0x00, 0xb7, 0x06, 0x00, 0x01, 6 | 0x13, 0x08, 0xd5, 0xcc, 0x93, 0x82, 0x35, 0x33, 0x13, 0x03, 0x76, 0xe6, 7 | 0x93, 0x83, 0x35, 0xb3, 0x13, 0x86, 0x16, 0x00, 0x63, 0xce, 0x02, 0x09, 8 | 0x13, 0x0e, 0x03, 0x00, 0x63, 0xce, 0x63, 0x06, 0x93, 0x0f, 0x00, 0x00, 9 | 0x13, 0x0f, 0x00, 0x00, 0x13, 0x04, 0x00, 0x00, 0x93, 0x0e, 0x00, 0x00, 10 | 0x93, 0x06, 0x00, 0x02, 0x13, 0x85, 0x06, 0xfe, 0x63, 0x64, 0xa7, 0x04, 11 | 0x33, 0x05, 0xff, 0x01, 0x63, 0xe0, 0xa7, 0x04, 0x13, 0x05, 0x00, 0x00, 12 | 0x93, 0x05, 0x00, 0x00, 0x93, 0x08, 0x06, 0x00, 0xb3, 0x8e, 0x8e, 0x02, 13 | 0x33, 0x0f, 0xff, 0x41, 0x13, 0xd4, 0xbe, 0x40, 0xb3, 0x0e, 0xcf, 0x01, 14 | 0x73, 0x00, 0x00, 0x00, 0x33, 0x04, 0x04, 0x01, 0x33, 0x85, 0xde, 0x03, 15 | 0x13, 0x5f, 0xc5, 0x00, 0x33, 0x05, 0x84, 0x02, 0x93, 0x5f, 0xc5, 0x00, 16 | 0x93, 0x86, 0x16, 0x00, 0x6f, 0xf0, 0x9f, 0xfb, 0x13, 0x85, 0x06, 0x00, 17 | 0x93, 0x05, 0x00, 0x00, 0x93, 0x08, 0x00, 0x00, 0x73, 0x00, 0x00, 0x00, 18 | 0x13, 0x0e, 0x1e, 0x09, 0xe3, 0xd6, 0xc3, 0xf9, 0x13, 0x05, 0xa0, 0x00, 19 | 0x93, 0x05, 0x00, 0x00, 0x93, 0x08, 0x00, 0x00, 0x73, 0x00, 0x00, 0x00, 20 | 0x13, 0x08, 0x98, 0x19, 0xe3, 0xd6, 0x02, 0xf7, 0x03, 0x24, 0xc1, 0x00, 21 | 0x13, 0x01, 0x01, 0x01, 0x67, 0x80, 0x00, 0x00 22 | }; 23 | unsigned int mandel_len = 24 | 236 25 | ; 26 | -------------------------------------------------------------------------------- /apps/common/linker.ld: -------------------------------------------------------------------------------- 1 | /*__heap_size = 0x100; */ 2 | /*__stack_size = 0x100; */ 3 | 4 | ENTRY(_start) 5 | 6 | SECTIONS 7 | { 8 | . = 0x80000000; 9 | /* 10 | .header : ALIGN( 16 ) 11 | { 12 | LONG( 0 ) 13 | LONG( 0 ) 14 | } 15 | */ 16 | .text : ALIGN(16) { 17 | __TEXT_BEGIN__ = .; 18 | *(.initial_jump) 19 | *(.entry.text) 20 | *(.init.literal) 21 | *(.init) 22 | *(.text) 23 | *(.literal .text .literal.* .text.* .stub) 24 | *(.out_jump.literal.*) 25 | *(.out_jump.*) 26 | __TEXT_END__ = .; 27 | } 28 | 29 | /* If we're on a newer compiler */ 30 | /DISCARD/ : 31 | { 32 | *(.interp) 33 | *(.dynsym) 34 | *(.dynstr) 35 | *(.header) 36 | } : phdr 37 | 38 | .data : ALIGN(16) { 39 | __DATA_BEGIN__ = .; 40 | *(.rodata) 41 | *(.rodata.*) 42 | *(.gnu.linkonce.r.*) 43 | *(.rodata1) 44 | *(.dynsbss) 45 | *(.gnu.linkonce.sb.*) 46 | *(.scommon) 47 | *(.gnu.linkonce.sb2.*) 48 | *(.sbss) 49 | *(.sbss.*) 50 | *(.sbss2) 51 | *(.sbss2.*) 52 | *(.dynbss) 53 | *(.data) 54 | *(.data.*) 55 | *(.got) 56 | *(.got.*) 57 | __DATA_END__ = .; 58 | } 59 | 60 | .bss : ALIGN( 16 ) { 61 | __BSS_BEGIN__ = .; 62 | *(.bss) /* Tricky: BSS needs to be allocated but not sent. GCC Will not populate these for calculating data size */ 63 | *(.bss.*) 64 | __BSS_END__ = .; 65 | } 66 | 67 | /* 68 | .heap : ALIGN( 16 ) { 69 | _sheap = .; 70 | . = . + __heap_size; 71 | _eheap = .; 72 | } 73 | */ 74 | /* 75 | .stack : ALIGN( 16 ) { 76 | _estack = .; 77 | . = . + __stack_size; 78 | _sstack = .; 79 | } 80 | */ 81 | .stack : ALIGN( 16 ) { 82 | _estack = .; 83 | } 84 | } 85 | 86 | 87 | -------------------------------------------------------------------------------- /apps/zigdoom/src/puredoom/r_local.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // Refresh (R_*) module, global header. 19 | // All the rendering/drawing stuff is here. 20 | // 21 | //----------------------------------------------------------------------------- 22 | 23 | #ifndef __R_LOCAL__ 24 | #define __R_LOCAL__ 25 | 26 | // Binary Angles, sine/cosine/atan lookups. 27 | #include "tables.h" 28 | 29 | // Screen size related parameters. 30 | #include "doomdef.h" 31 | 32 | // Include the refresh/render data structs. 33 | #include "r_data.h" 34 | 35 | // 36 | // Separate header file for each module. 37 | // 38 | #include "r_main.h" 39 | #include "r_bsp.h" 40 | #include "r_segs.h" 41 | #include "r_plane.h" 42 | #include "r_data.h" 43 | #include "r_things.h" 44 | #include "r_draw.h" 45 | 46 | #endif // __R_LOCAL__ 47 | 48 | //----------------------------------------------------------------------------- 49 | // 50 | // $Log:$ 51 | // 52 | //----------------------------------------------------------------------------- 53 | -------------------------------------------------------------------------------- /apps/zigdoom/src/puredoom/d_ticcmd.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // System specific interface stuff. 19 | // 20 | //----------------------------------------------------------------------------- 21 | 22 | #ifndef __D_TICCMD__ 23 | #define __D_TICCMD__ 24 | 25 | 26 | #include "doomtype.h" 27 | 28 | 29 | // The data sampled per tick (single player) 30 | // and transmitted to other peers (multiplayer). 31 | // Mainly movements/button commands per game tick, 32 | // plus a checksum for internal state consistency. 33 | typedef struct 34 | { 35 | char forwardmove; // *2048 for move 36 | char sidemove; // *2048 for move 37 | short angleturn; // <<16 for angle delta 38 | short consistancy; // checks for net game 39 | byte chatchar; 40 | byte buttons; 41 | } ticcmd_t; 42 | 43 | 44 | #endif 45 | 46 | //----------------------------------------------------------------------------- 47 | // 48 | // $Log:$ 49 | // 50 | //----------------------------------------------------------------------------- 51 | -------------------------------------------------------------------------------- /apps/heap/heap.c: -------------------------------------------------------------------------------- 1 | #include "uvm32_target.h" 2 | #include "malloc_freelist.h" 3 | 4 | uint32_t* extram = (uint32_t*)UVM32_EXTRAM_BASE; 5 | uint32_t extram_len = HEAP_SIZE; 6 | 7 | void* memcpy(void* dst, const void* src, int len) { 8 | uint8_t* d = (uint8_t*)dst; 9 | const uint8_t* s = (const uint8_t*)src; 10 | while (len--) { 11 | *(d++) = *(s++); 12 | } 13 | return dst; 14 | } 15 | 16 | void* memset(void* buf, int c, int len) { 17 | uint8_t* b = (uint8_t*)buf; 18 | while (len--) { 19 | *(b++) = c; 20 | } 21 | return buf; 22 | } 23 | 24 | void* memmove(void* dest, const void* src, size_t len) { 25 | char* d = dest; 26 | const char* s = src; 27 | if (d < s) 28 | while (len--) 29 | *d++ = *s++; 30 | else { 31 | const char* lasts = s + (len - 1); 32 | char* lastd = d + (len - 1); 33 | while (len--) 34 | *lastd-- = *lasts--; 35 | } 36 | return dest; 37 | } 38 | 39 | void force_crash(void) { 40 | uint8_t *p = (uint8_t *)0; 41 | p[0] = 0; 42 | } 43 | 44 | void main(void) { 45 | malloc_addblock(extram, extram_len); 46 | 47 | uint8_t* p1 = fl_malloc(128); 48 | if (p1 == NULL) { 49 | println("malloc failed"); 50 | } else { 51 | println("malloc ok"); 52 | } 53 | memset(p1, 'a', 128); 54 | fl_free(p1); 55 | 56 | uint8_t* p2 = fl_malloc(256); 57 | if (p2 == NULL) { 58 | println("malloc failed"); 59 | } else { 60 | println("malloc ok"); 61 | } 62 | memset(p2, 'b', 256); 63 | fl_free(p2); 64 | 65 | //force_crash(); // allows dump to be inspected 66 | } 67 | -------------------------------------------------------------------------------- /apps/zigdoom/src/puredoom/m_fixed.c: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // $Log:$ 18 | // 19 | // DESCRIPTION: 20 | // Fixed point implementation. 21 | // 22 | //----------------------------------------------------------------------------- 23 | 24 | 25 | #include "doom_config.h" 26 | 27 | //#include "stdlib.h" 28 | #include "doomtype.h" 29 | #include "i_system.h" 30 | #include "m_fixed.h" 31 | 32 | 33 | fixed_t FixedMul(fixed_t a, fixed_t b) 34 | { 35 | return ((long long)a * (long long)b) >> FRACBITS; 36 | } 37 | 38 | 39 | // 40 | // FixedDiv, C version. 41 | // 42 | fixed_t FixedDiv(fixed_t a, fixed_t b) 43 | { 44 | if ((doom_abs(a) >> 14) >= doom_abs(b)) 45 | return (a ^ b) < 0 ? DOOM_MININT : DOOM_MAXINT; 46 | return FixedDiv2(a, b); 47 | } 48 | 49 | 50 | fixed_t FixedDiv2(fixed_t a, fixed_t b) 51 | { 52 | double c; 53 | 54 | c = ((double)a) / ((double)b) * FRACUNIT; 55 | 56 | if (c >= 2147483648.0 || c < -2147483648.0) 57 | I_Error("Error: FixedDiv: divide by zero"); 58 | return (fixed_t)c; 59 | } 60 | -------------------------------------------------------------------------------- /apps/zigdoom/src/puredoom/i_video.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // System specific interface stuff. 19 | // 20 | //----------------------------------------------------------------------------- 21 | 22 | #ifndef __I_VIDEO__ 23 | #define __I_VIDEO__ 24 | 25 | 26 | #include "doomtype.h" 27 | 28 | 29 | // Called by D_DoomMain, 30 | // determines the hardware configuration 31 | // and sets up the video mode 32 | void I_InitGraphics(void); 33 | 34 | void I_ShutdownGraphics(void); 35 | 36 | // Takes full 8 bit values. 37 | void I_SetPalette(byte* palette); 38 | 39 | void I_UpdateNoBlit(void); 40 | void I_FinishUpdate(void); 41 | 42 | // Wait for vertical retrace or pause a bit. 43 | void I_WaitVBL(int count); 44 | 45 | void I_ReadScreen(byte* scr); 46 | 47 | void I_BeginRead(void); 48 | void I_EndRead(void); 49 | 50 | 51 | #endif 52 | 53 | //----------------------------------------------------------------------------- 54 | // 55 | // $Log:$ 56 | // 57 | //----------------------------------------------------------------------------- 58 | -------------------------------------------------------------------------------- /apps/tinygl/src/TinyGL/src/specbuf.c: -------------------------------------------------------------------------------- 1 | #include "zgl.h" 2 | #include "msghandling.h" 3 | //#include 4 | //#include 5 | 6 | static void calc_buf(GLSpecBuf *buf, const float shininess) 7 | { 8 | int i; 9 | float val, inc; 10 | val = 0.0f; 11 | inc = 1.0f/SPECULAR_BUFFER_SIZE; 12 | for (i = 0; i <= SPECULAR_BUFFER_SIZE; i++) { 13 | buf->buf[i] = zpow(val, shininess); 14 | val += inc; 15 | } 16 | } 17 | 18 | GLSpecBuf * 19 | specbuf_get_buffer(GLContext *c, const int shininess_i, 20 | const float shininess) 21 | { 22 | GLSpecBuf *found, *oldest; 23 | found = oldest = c->specbuf_first; 24 | while (found && found->shininess_i != shininess_i) { 25 | if (found->last_used < oldest->last_used) { 26 | oldest = found; 27 | } 28 | found = found->next; 29 | } 30 | if (found) { /* hey, found one! */ 31 | found->last_used = c->specbuf_used_counter++; 32 | return found; 33 | } 34 | if (oldest == NULL || c->specbuf_num_buffers < MAX_SPECULAR_BUFFERS) { 35 | /* create new buffer */ 36 | GLSpecBuf *buf = gl_malloc(sizeof(GLSpecBuf)); 37 | if (!buf) gl_fatal_error("could not allocate specular buffer"); 38 | c->specbuf_num_buffers++; 39 | buf->next = c->specbuf_first; 40 | c->specbuf_first = buf; 41 | buf->last_used = c->specbuf_used_counter++; 42 | buf->shininess_i = shininess_i; 43 | calc_buf(buf, shininess); 44 | return buf; 45 | } 46 | /* overwrite the lru buffer */ 47 | /*tgl_trace("overwriting spec buffer :(\n");*/ 48 | oldest->shininess_i = shininess_i; 49 | oldest->last_used = c->specbuf_used_counter++; 50 | calc_buf(oldest, shininess); 51 | return oldest; 52 | } 53 | -------------------------------------------------------------------------------- /apps/zigdoom/src/puredoom/am_map.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // AutoMap module. 19 | // 20 | //----------------------------------------------------------------------------- 21 | 22 | #ifndef __AMMAP_H__ 23 | #define __AMMAP_H__ 24 | 25 | 26 | #include "d_event.h" 27 | 28 | 29 | // Used by ST StatusBar stuff. 30 | #define AM_MSGHEADER (('a'<<24)+('m'<<16)) 31 | #define AM_MSGENTERED (AM_MSGHEADER | ('e'<<8)) 32 | #define AM_MSGEXITED (AM_MSGHEADER | ('x'<<8)) 33 | 34 | 35 | // Called by main loop. 36 | doom_boolean AM_Responder(event_t* ev); 37 | 38 | // Called by main loop. 39 | void AM_Ticker(void); 40 | 41 | // Called by main loop, 42 | // called instead of view drawer if automap active. 43 | void AM_Drawer(void); 44 | 45 | // Called to force the automap to quit 46 | // if the level is completed while it is up. 47 | void AM_Stop(void); 48 | 49 | 50 | #endif 51 | 52 | //----------------------------------------------------------------------------- 53 | // 54 | // $Log:$ 55 | // 56 | //----------------------------------------------------------------------------- 57 | -------------------------------------------------------------------------------- /hosts/host-mini/host-mini.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "uvm32.h" 5 | #include "../common/uvm32_common_custom.h" 6 | #include "mandel.h" 7 | 8 | int main(int argc, char *argv[]) { 9 | uvm32_state_t vmst; 10 | uvm32_evt_t evt; 11 | bool isrunning = true; 12 | 13 | uvm32_init(&vmst); 14 | uvm32_load(&vmst, mandel, mandel_len); 15 | 16 | while(isrunning) { 17 | uvm32_run(&vmst, &evt, 100); // num instructions before vm considered hung 18 | 19 | switch(evt.typ) { 20 | case UVM32_EVT_END: 21 | isrunning = false; 22 | break; 23 | case UVM32_EVT_SYSCALL: // vm has paused to handle UVM32_SYSCALL 24 | switch(evt.data.syscall.code) { 25 | case UVM32_SYSCALL_YIELD: 26 | break; 27 | case UVM32_SYSCALL_PUTC: 28 | printf("%c", uvm32_arg_getval(&vmst, &evt, ARG0)); 29 | break; 30 | case UVM32_SYSCALL_PRINTLN: { 31 | const char *str = uvm32_arg_getcstr(&vmst, &evt, ARG0); 32 | printf("%s\n", str); 33 | } break; 34 | default: 35 | printf("Unhandled syscall 0x%08x\n", evt.data.syscall.code); 36 | break; 37 | } 38 | break; 39 | case UVM32_EVT_ERR: 40 | printf("UVM32_EVT_ERR '%s' (%d)\n", evt.data.err.errstr, (int)evt.data.err.errcode); 41 | break; 42 | default: 43 | break; 44 | } 45 | } 46 | 47 | return 0; 48 | } 49 | -------------------------------------------------------------------------------- /apps/agnes/build.zig.zon: -------------------------------------------------------------------------------- 1 | .{ 2 | // This is the default name used by packages depending on this one. For 3 | // example, when a user runs `zig fetch --save `, this field is used 4 | // as the key in the `dependencies` table. Although the user can choose a 5 | // different name, most users will stick with this provided value. 6 | // 7 | // It is redundant to include "zig" in this name because it is already 8 | // within the Zig package namespace. 9 | .name = .zigdoom, 10 | .fingerprint = 0xf734231076ec3b9f, 11 | 12 | // This is a [Semantic Version](https://semver.org/). 13 | // In a future version of Zig it will be used for package deduplication. 14 | .version = "0.0.1", 15 | 16 | // This field is optional. 17 | // This is currently advisory only; Zig does not yet do anything 18 | // with this value. 19 | //.minimum_zig_version = "0.11.0", 20 | 21 | // This field is optional. 22 | // Each dependency must either provide a `url` and `hash`, or a `path`. 23 | // `zig build --fetch` can be used to fetch all dependencies of a package, recursively. 24 | // Once all dependencies are fetched, `zig build` no longer requires 25 | // internet connectivity. 26 | .dependencies = .{ 27 | .zeptolibc = .{ 28 | .url = "git+https://github.com/ringtailsoftware/zeptolibc.git#d787abfdd597bee5616a439f12393e11fb370822", 29 | .hash = "zeptolibc-0.0.1-T3flJ4M4AAAEx1K1DS-SmkmuXvJJ3JqnNHIw4Aqo0PfD", 30 | }, 31 | }, 32 | .paths = .{ 33 | "build.zig", 34 | "build.zig.zon", 35 | "src", 36 | // For example... 37 | //"LICENSE", 38 | //"README.md", 39 | }, 40 | } 41 | -------------------------------------------------------------------------------- /apps/tinygl/build.zig.zon: -------------------------------------------------------------------------------- 1 | .{ 2 | // This is the default name used by packages depending on this one. For 3 | // example, when a user runs `zig fetch --save `, this field is used 4 | // as the key in the `dependencies` table. Although the user can choose a 5 | // different name, most users will stick with this provided value. 6 | // 7 | // It is redundant to include "zig" in this name because it is already 8 | // within the Zig package namespace. 9 | .name = .zigdoom, 10 | .fingerprint = 0xf734231076ec3b9f, 11 | 12 | // This is a [Semantic Version](https://semver.org/). 13 | // In a future version of Zig it will be used for package deduplication. 14 | .version = "0.0.1", 15 | 16 | // This field is optional. 17 | // This is currently advisory only; Zig does not yet do anything 18 | // with this value. 19 | //.minimum_zig_version = "0.11.0", 20 | 21 | // This field is optional. 22 | // Each dependency must either provide a `url` and `hash`, or a `path`. 23 | // `zig build --fetch` can be used to fetch all dependencies of a package, recursively. 24 | // Once all dependencies are fetched, `zig build` no longer requires 25 | // internet connectivity. 26 | .dependencies = .{ 27 | .zeptolibc = .{ 28 | .url = "git+https://github.com/ringtailsoftware/zeptolibc.git#d787abfdd597bee5616a439f12393e11fb370822", 29 | .hash = "zeptolibc-0.0.1-T3flJ4M4AAAEx1K1DS-SmkmuXvJJ3JqnNHIw4Aqo0PfD", 30 | }, 31 | }, 32 | .paths = .{ 33 | "build.zig", 34 | "build.zig.zon", 35 | "src", 36 | // For example... 37 | //"LICENSE", 38 | //"README.md", 39 | }, 40 | } 41 | -------------------------------------------------------------------------------- /apps/zigdoom/build.zig.zon: -------------------------------------------------------------------------------- 1 | .{ 2 | // This is the default name used by packages depending on this one. For 3 | // example, when a user runs `zig fetch --save `, this field is used 4 | // as the key in the `dependencies` table. Although the user can choose a 5 | // different name, most users will stick with this provided value. 6 | // 7 | // It is redundant to include "zig" in this name because it is already 8 | // within the Zig package namespace. 9 | .name = .zigdoom, 10 | .fingerprint = 0xf734231076ec3b9f, 11 | 12 | // This is a [Semantic Version](https://semver.org/). 13 | // In a future version of Zig it will be used for package deduplication. 14 | .version = "0.0.1", 15 | 16 | // This field is optional. 17 | // This is currently advisory only; Zig does not yet do anything 18 | // with this value. 19 | //.minimum_zig_version = "0.11.0", 20 | 21 | // This field is optional. 22 | // Each dependency must either provide a `url` and `hash`, or a `path`. 23 | // `zig build --fetch` can be used to fetch all dependencies of a package, recursively. 24 | // Once all dependencies are fetched, `zig build` no longer requires 25 | // internet connectivity. 26 | .dependencies = .{ 27 | .zeptolibc = .{ 28 | .url = "git+https://github.com/ringtailsoftware/zeptolibc.git#d787abfdd597bee5616a439f12393e11fb370822", 29 | .hash = "zeptolibc-0.0.1-T3flJ4M4AAAEx1K1DS-SmkmuXvJJ3JqnNHIw4Aqo0PfD", 30 | }, 31 | }, 32 | .paths = .{ 33 | "build.zig", 34 | "build.zig.zon", 35 | "src", 36 | // For example... 37 | //"LICENSE", 38 | //"README.md", 39 | }, 40 | } 41 | -------------------------------------------------------------------------------- /apps/zigdoom/src/puredoom/r_data.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // Refresh module, data I/O, caching, retrieval of graphics 19 | // by name. 20 | // 21 | //----------------------------------------------------------------------------- 22 | 23 | #ifndef __R_DATA__ 24 | #define __R_DATA__ 25 | 26 | 27 | #include "r_defs.h" 28 | #include "r_state.h" 29 | 30 | 31 | // Retrieve column data for span blitting. 32 | byte* R_GetColumn(int tex, int col); 33 | 34 | // I/O, setting up the stuff. 35 | void R_InitData(void); 36 | void R_PrecacheLevel(void); 37 | 38 | // Retrieval. 39 | // Floor/ceiling opaque texture tiles, 40 | // lookup by name. For animation? 41 | int R_FlatNumForName(char* name); 42 | 43 | // Called by P_Ticker for switches and animations, 44 | // returns the texture number for the texture name. 45 | int R_TextureNumForName(char* name); 46 | int R_CheckTextureNumForName(char* name); 47 | 48 | #endif 49 | 50 | //----------------------------------------------------------------------------- 51 | // 52 | // $Log:$ 53 | // 54 | //----------------------------------------------------------------------------- 55 | -------------------------------------------------------------------------------- /apps/zigdoom/src/puredoom/doom_config.h: -------------------------------------------------------------------------------- 1 | #ifndef __DOOM_CONFIG_H__ 2 | #define __DOOM_CONFIG_H__ 3 | 4 | 5 | #if defined(WIN32) 6 | #define DOOM_WIN32 7 | #elif defined(__APPLE__) 8 | #define DOOM_APPLE 9 | #else 10 | #define DOOM_LINUX 11 | #endif 12 | 13 | 14 | #include "DOOM.h" 15 | 16 | 17 | #define doom_abs(x) ((x) < 0 ? -(x) : (x)) 18 | 19 | 20 | extern char error_buf[260]; 21 | extern int doom_flags; 22 | extern doom_print_fn doom_print; 23 | extern doom_malloc_fn doom_malloc; 24 | extern doom_free_fn doom_free; 25 | extern doom_open_fn doom_open; 26 | extern doom_close_fn doom_close; 27 | extern doom_read_fn doom_read; 28 | extern doom_write_fn doom_write; 29 | extern doom_seek_fn doom_seek; 30 | extern doom_tell_fn doom_tell; 31 | extern doom_eof_fn doom_eof; 32 | extern doom_gettime_fn doom_gettime; 33 | extern doom_exit_fn doom_exit; 34 | extern doom_getenv_fn doom_getenv; 35 | 36 | 37 | const char* doom_itoa(int i, int radix); 38 | const char* doom_ctoa(char c); 39 | const char* doom_ptoa(void* p); 40 | void doom_memset(void* ptr, int value, int num); 41 | void* doom_memcpy(void* destination, const void* source, int num); 42 | int doom_fprint(void* handle, const char* str); 43 | int doom_strlen(const char* str); 44 | char* doom_concat(char* dst, const char* src); 45 | char* doom_strcpy(char* destination, const char* source); 46 | char* doom_strncpy(char* destination, const char* source, int num); 47 | int doom_strcmp(const char* str1, const char* str2); 48 | int doom_strncmp(const char* str1, const char* str2, int n); 49 | int doom_strcasecmp(const char* str1, const char* str2); 50 | int doom_strncasecmp(const char* str1, const char* str2, int n); 51 | int doom_atoi(const char* str); 52 | int doom_atox(const char* str); 53 | int doom_toupper(int c); 54 | 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /test/unity/auto/generate_config.yml: -------------------------------------------------------------------------------- 1 | # ========================================================================= 2 | # Unity - A Test Framework for C 3 | # ThrowTheSwitch.org 4 | # Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams 5 | # SPDX-License-Identifier: MIT 6 | # ========================================================================= 7 | 8 | #this is a sample configuration file for generate_module 9 | #you would use it by calling generate_module with the -ygenerate_config.yml option 10 | #files like this are useful for customizing generate_module to your environment 11 | :generate_module: 12 | :defaults: 13 | #these defaults are used in place of any missing options at the command line 14 | :path_src: ../src/ 15 | :path_inc: ../src/ 16 | :path_tst: ../test/ 17 | :update_svn: true 18 | :includes: 19 | #use [] for no additional includes, otherwise list the includes on separate lines 20 | :src: 21 | - Defs.h 22 | - Board.h 23 | :inc: [] 24 | :tst: 25 | - Defs.h 26 | - Board.h 27 | - Exception.h 28 | :boilerplates: 29 | #these are inserted at the top of generated files. 30 | #just comment out or remove if not desired. 31 | #use %1$s where you would like the file name to appear (path/extension not included) 32 | :src: | 33 | //------------------------------------------- 34 | // %1$s.c 35 | //------------------------------------------- 36 | :inc: | 37 | //------------------------------------------- 38 | // %1$s.h 39 | //------------------------------------------- 40 | :tst: | 41 | //------------------------------------------- 42 | // Test%1$s.c : Units tests for %1$s.c 43 | //------------------------------------------- 44 | -------------------------------------------------------------------------------- /apps/zigtris/src/uvm.zig: -------------------------------------------------------------------------------- 1 | const uvm32 = @cImport({ 2 | @cDefine("USE_MAIN", "1"); 3 | @cInclude("uvm32_target.h"); 4 | }); 5 | const std = @import("std"); 6 | 7 | pub inline fn syscall(id: u32, param1: u32, param2: u32) u32 { 8 | var val: u32 = undefined; 9 | asm volatile ("ecall" 10 | : [val] "={a2}" (val), 11 | : [param1] "{a0}" (param1), [param2] "{a1}" (param2), 12 | [id] "{a7}" (id), 13 | : .{ .memory = true }); 14 | return val; 15 | } 16 | 17 | pub inline fn getc() ?u8 { 18 | const key = syscall(uvm32.UVM32_SYSCALL_GETC, 0, 0); 19 | if (key == 0xFFFFFFFF) { 20 | return null; 21 | } else { 22 | return @truncate(key); 23 | } 24 | } 25 | 26 | pub inline fn millis() u32 { 27 | return syscall(uvm32.UVM32_SYSCALL_MILLIS, 0, 0); 28 | } 29 | 30 | pub inline fn rand() u32 { 31 | return syscall(uvm32.UVM32_SYSCALL_RAND, 0, 0); 32 | } 33 | 34 | // dupeZ would be better, but want to avoid using an allocator 35 | // this is of course, unsafe... 36 | var termination_buf:[128]u8 = undefined; 37 | 38 | pub inline fn print(m: []const u8) void { 39 | @memcpy(termination_buf[0..m.len], m); 40 | termination_buf[m.len] = 0; 41 | const s = termination_buf[0..m.len :0]; 42 | _ = syscall(uvm32.UVM32_SYSCALL_PRINT, @intFromPtr(s.ptr), 0); 43 | } 44 | 45 | pub inline fn println(m: []const u8) void { 46 | @memcpy(termination_buf[0..m.len], m); 47 | termination_buf[m.len] = 0; 48 | const s = termination_buf[0..m.len :0]; 49 | _ = syscall(uvm32.UVM32_SYSCALL_PRINTLN, @intFromPtr(s.ptr), 0); 50 | } 51 | 52 | pub inline fn yield() void { 53 | _ = syscall(uvm32.UVM32_SYSCALL_YIELD, 0, 0); 54 | } 55 | 56 | pub inline fn putc(c:u8) void { 57 | _ = syscall(uvm32.UVM32_SYSCALL_PUTC, c, 0); 58 | } 59 | 60 | -------------------------------------------------------------------------------- /apps/zigdoom/src/puredoom/dstrings.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // 18 | // $Log:$ 19 | // 20 | // DESCRIPTION: 21 | // DOOM strings, by language. 22 | // 23 | //----------------------------------------------------------------------------- 24 | 25 | #ifndef __DSTRINGS__ 26 | #define __DSTRINGS__ 27 | 28 | 29 | // All important printed strings. 30 | // Language selection (message strings). 31 | // Use -DFRENCH etc. 32 | 33 | #ifdef FRENCH 34 | #include "d_french.h" // Leave the extra space there, to throw off regex in PureDOOM.h creation 35 | #else 36 | #include "d_englsh.h" 37 | #endif 38 | 39 | 40 | // Misc. other strings. 41 | #define SAVEGAMENAME "doomsav" 42 | 43 | // 44 | // File locations, 45 | // relative to current position. 46 | // Path names are OS-sensitive. 47 | // 48 | #define DEVMAPS "devmaps" 49 | #define DEVDATA "devdata" 50 | 51 | // Not done in french? 52 | 53 | // QuitDOOM messages 54 | #define NUM_QUITMESSAGES 22 55 | 56 | 57 | extern char* endmsg[]; 58 | 59 | 60 | #endif 61 | 62 | //----------------------------------------------------------------------------- 63 | // 64 | // $Log:$ 65 | // 66 | //----------------------------------------------------------------------------- 67 | -------------------------------------------------------------------------------- /apps/zigdoom/src/puredoom/m_misc.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // 19 | // 20 | //----------------------------------------------------------------------------- 21 | 22 | #ifndef __M_MISC__ 23 | #define __M_MISC__ 24 | 25 | 26 | #include "doomtype.h" 27 | 28 | 29 | // 30 | // MISC 31 | // 32 | typedef struct 33 | { 34 | char* name; 35 | int* location; 36 | int defaultvalue; 37 | int scantranslate; // PC scan code hack 38 | int untranslated; // lousy hack 39 | char** text_location; // [pd] int* location was used to store text pointer. Can't change to intptr_t unless we change all settings type 40 | char* default_text_value; // [pd] So we don't change defaultvalue behavior for int to intptr_t 41 | } default_t; 42 | 43 | 44 | doom_boolean M_WriteFile(char const* name, void* source, int length); 45 | int M_ReadFile(char const* name, byte** buffer); 46 | void M_ScreenShot(void); 47 | void M_LoadDefaults(void); 48 | void M_SaveDefaults(void); 49 | int M_DrawText(int x, int y, doom_boolean direct, char* string); 50 | 51 | 52 | #endif 53 | 54 | //----------------------------------------------------------------------------- 55 | // 56 | // $Log:$ 57 | // 58 | //----------------------------------------------------------------------------- 59 | -------------------------------------------------------------------------------- /apps/zigdoom/src/puredoom/r_plane.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // Refresh, visplane stuff (floor, ceilings). 19 | // 20 | //----------------------------------------------------------------------------- 21 | 22 | #ifndef __R_PLANE__ 23 | #define __R_PLANE__ 24 | 25 | 26 | #include "r_data.h" 27 | 28 | 29 | // Visplane related. 30 | extern short* lastopening; 31 | 32 | typedef void (*planefunction_t) (int top, int bottom); 33 | 34 | extern planefunction_t floorfunc; 35 | extern planefunction_t ceilingfunc_t; 36 | 37 | extern short floorclip[SCREENWIDTH]; 38 | extern short ceilingclip[SCREENWIDTH]; 39 | 40 | extern fixed_t yslope[SCREENHEIGHT]; 41 | extern fixed_t distscale[SCREENWIDTH]; 42 | 43 | void R_InitPlanes(void); 44 | void R_ClearPlanes(void); 45 | void R_MapPlane(int y, int x1, int x2); 46 | void R_MakeSpans(int x, int t1, int b1, int t2, int b2); 47 | void R_DrawPlanes(void); 48 | visplane_t* R_FindPlane(fixed_t height, int picnum, int lightlevel); 49 | visplane_t* R_CheckPlane(visplane_t* pl, int start, int stop); 50 | 51 | 52 | #endif 53 | 54 | //----------------------------------------------------------------------------- 55 | // 56 | // $Log:$ 57 | // 58 | //----------------------------------------------------------------------------- 59 | -------------------------------------------------------------------------------- /apps/tinygl/src/TinyGL/Changelog: -------------------------------------------------------------------------------- 1 | version 0.4.1: 2 | - changed license to MIT 3 | - fixed compilation errors 4 | - fixed lighting bug 5 | - fixed color conversions 6 | 7 | version 0.4: 8 | - added 24/32 bit rendering support (Olivier Landemarre - F. Bellard) 9 | - fixed GL_TRIANGLE_STRIP (Olivier Landemarre) 10 | - added gl_malloc, gl_free, gl_zalloc wrappers (Olivier Landemarre) 11 | 12 | version 0.3: 13 | - added NanoX API (nglx) (F. Bellard) 14 | - added gears example and unified GUI in examples (F. Bellard) 15 | - added TGL_FEATURE_RENDER_BITS so that it will be possible to render 16 | natively in 15/16/24 or 32 bits. (F. Bellard) 17 | - interpolated lines (Olivier Landemarre) 18 | - fast no shading case (Olivier Landemarre) 19 | - fast no projection case (Olivier Landemarre) 20 | 21 | version 0.2: Fabrice Bellard 22 | - added 24/32 bpp support. Added some features.h ifdefs. 23 | - fixed some error reporting cases in the examples 24 | - endianness is deduced from the glibc (BYTE_ORDER macro) 25 | 26 | version 0.19: Peder Blekken 27 | - new files BeOS/* src/msghandling.*, src/arrays.*, src/oscontext.c 28 | include/GL/oscontext.h src/features.h 29 | - added support for BeOS, see README.BEOS 30 | - added support for drawing convex polygons with unlimited # of vertices 31 | - added support for GL_LIGHT_MODEL_TWO_SIDE 32 | - added generic rotation code for glopRotate 33 | - added support for opengl 1.1 arrays 34 | - added support for glPolygonOffset, not implemented. 35 | - added glGetFloatv, limited support. 36 | - added some pnames for glGetIntegerv 37 | - added some empty functions in include/GL/gl.h to compile VRMLView 38 | - added GL_VERSION_1_1 define in include/GL/gl.h 39 | - fixed "bug" when context->gl_resize_viewport is not set. 40 | - fixed bug in glBindTexture (didn't accept texture object 0) 41 | 42 | version 0.1: 43 | - Initial revision, Fabrice Bellard 44 | 45 | -------------------------------------------------------------------------------- /test/minirv32_internal/test/tests.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "unity.h" 3 | #include "uvm32.h" 4 | #include "../common/uvm32_common_custom.h" 5 | 6 | #include "rom-header.h" 7 | 8 | static uvm32_state_t vmst; 9 | static uvm32_evt_t evt; 10 | 11 | void setUp(void) { 12 | // runs before each test 13 | uvm32_init(&vmst); 14 | uvm32_load(&vmst, rom_bin, rom_bin_len); 15 | } 16 | 17 | void tearDown(void) { 18 | } 19 | 20 | void test_pc_too_big(void) { 21 | // No code should be doing this, but... 22 | TEST_ASSERT_EQUAL(0x80000000, uvm32_getProgramCounter(&vmst)); 23 | vmst._core.pc = 0x80000000 + 1024 * 16 * 4; // off end 24 | uvm32_run(&vmst, &evt, 1); 25 | TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_ERR); 26 | TEST_ASSERT_EQUAL(evt.data.err.errcode, UVM32_ERR_INTERNAL_CORE); 27 | } 28 | 29 | void test_pc_unaligned_1(void) { 30 | // No code should be doing this, but... 31 | TEST_ASSERT_EQUAL(0x80000000, uvm32_getProgramCounter(&vmst)); 32 | vmst._core.pc = 0x80000000 + 1; 33 | uvm32_run(&vmst, &evt, 1); 34 | TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_ERR); 35 | TEST_ASSERT_EQUAL(evt.data.err.errcode, UVM32_ERR_INTERNAL_CORE); 36 | } 37 | 38 | void test_pc_unaligned_2(void) { 39 | // No code should be doing this, but... 40 | TEST_ASSERT_EQUAL(0x80000000, uvm32_getProgramCounter(&vmst)); 41 | vmst._core.pc = 0x80000000 + 2; 42 | uvm32_run(&vmst, &evt, 1); 43 | TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_ERR); 44 | TEST_ASSERT_EQUAL(evt.data.err.errcode, UVM32_ERR_INTERNAL_CORE); 45 | } 46 | 47 | void test_pc_unaligned_3(void) { 48 | // No code should be doing this, but... 49 | TEST_ASSERT_EQUAL(0x80000000, uvm32_getProgramCounter(&vmst)); 50 | vmst._core.pc = 0x80000000 + 3; 51 | uvm32_run(&vmst, &evt, 1); 52 | TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_ERR); 53 | TEST_ASSERT_EQUAL(evt.data.err.errcode, UVM32_ERR_INTERNAL_CORE); 54 | } 55 | 56 | -------------------------------------------------------------------------------- /apps/tinygl/src/TinyGL/src/get.c: -------------------------------------------------------------------------------- 1 | #include "zgl.h" 2 | 3 | void glGetIntegerv(int pname,int *params) 4 | { 5 | GLContext *c=gl_get_context(); 6 | 7 | switch(pname) { 8 | case GL_VIEWPORT: 9 | params[0]=c->viewport.xmin; 10 | params[1]=c->viewport.ymin; 11 | params[2]=c->viewport.xsize; 12 | params[3]=c->viewport.ysize; 13 | break; 14 | case GL_MAX_MODELVIEW_STACK_DEPTH: 15 | *params = MAX_MODELVIEW_STACK_DEPTH; 16 | break; 17 | case GL_MAX_PROJECTION_STACK_DEPTH: 18 | *params = MAX_PROJECTION_STACK_DEPTH; 19 | break; 20 | case GL_MAX_LIGHTS: 21 | *params = MAX_LIGHTS; 22 | break; 23 | case GL_MAX_TEXTURE_SIZE: 24 | *params = 256; /* not completely true, but... */ 25 | break; 26 | case GL_MAX_TEXTURE_STACK_DEPTH: 27 | *params = MAX_TEXTURE_STACK_DEPTH; 28 | break; 29 | default: 30 | gl_fatal_error("glGet: option not implemented"); 31 | break; 32 | } 33 | } 34 | 35 | void glGetFloatv(int pname, float *v) 36 | { 37 | int i; 38 | int mnr = 0; /* just a trick to return the correct matrix */ 39 | GLContext *c = gl_get_context(); 40 | switch (pname) { 41 | case GL_TEXTURE_MATRIX: 42 | mnr++; 43 | case GL_PROJECTION_MATRIX: 44 | mnr++; 45 | case GL_MODELVIEW_MATRIX: 46 | { 47 | float *p = &c->matrix_stack_ptr[mnr]->m[0][0];; 48 | for (i = 0; i < 4; i++) { 49 | *v++ = p[0]; 50 | *v++ = p[4]; 51 | *v++ = p[8]; 52 | *v++ = p[12]; 53 | p++; 54 | } 55 | } 56 | break; 57 | case GL_LINE_WIDTH: 58 | *v = 1.0f; 59 | break; 60 | case GL_LINE_WIDTH_RANGE: 61 | v[0] = v[1] = 1.0f; 62 | break; 63 | case GL_POINT_SIZE: 64 | *v = 1.0f; 65 | break; 66 | case GL_POINT_SIZE_RANGE: 67 | v[0] = v[1] = 1.0f; 68 | default: 69 | //fprintf(stderr,"warning: unknown pname in glGetFloatv()\n"); 70 | // FIXME 71 | break; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /apps/zigdoom/src/puredoom/hu_stuff.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: Head up display 18 | // 19 | //----------------------------------------------------------------------------- 20 | 21 | #ifndef __HU_STUFF_H__ 22 | #define __HU_STUFF_H__ 23 | 24 | 25 | #include "d_event.h" 26 | 27 | 28 | // 29 | // Globally visible constants. 30 | // 31 | #define HU_FONTSTART '!' // the first font characters 32 | #define HU_FONTEND '_' // the last font characters 33 | 34 | // Calculate # of glyphs in font. 35 | #define HU_FONTSIZE (HU_FONTEND - HU_FONTSTART + 1) 36 | 37 | #define HU_BROADCAST 5 38 | 39 | #define HU_MSGREFRESH KEY_ENTER 40 | #define HU_MSGX 0 41 | #define HU_MSGY 0 42 | #define HU_MSGWIDTH 64 // in characters 43 | #define HU_MSGHEIGHT 1 // in lines 44 | 45 | #define HU_MSGTIMEOUT (4*TICRATE) 46 | 47 | 48 | // 49 | // HEADS UP TEXT 50 | // 51 | 52 | void HU_Init(void); 53 | void HU_Start(void); 54 | doom_boolean HU_Responder(event_t* ev); 55 | void HU_Ticker(void); 56 | void HU_Drawer(void); 57 | char HU_dequeueChatChar(void); 58 | void HU_Erase(void); 59 | 60 | 61 | #endif 62 | 63 | //----------------------------------------------------------------------------- 64 | // 65 | // $Log:$ 66 | // 67 | //----------------------------------------------------------------------------- 68 | -------------------------------------------------------------------------------- /apps/zigdoom/src/puredoom/m_menu.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // Menu widget stuff, episode selection and such. 19 | // 20 | //----------------------------------------------------------------------------- 21 | 22 | #ifndef __M_MENU__ 23 | #define __M_MENU__ 24 | 25 | 26 | #include "d_event.h" 27 | 28 | 29 | // 30 | // MENUS 31 | // 32 | 33 | // Called by main loop, 34 | // saves config file and calls I_Quit when user exits. 35 | // Even when the menu is not displayed, 36 | // this can resize the view and change game parameters. 37 | // Does all the real work of the menu interaction. 38 | doom_boolean M_Responder(event_t* ev); 39 | 40 | // Called by main loop, 41 | // only used for menu (skull cursor) animation. 42 | void M_Ticker(void); 43 | 44 | // Called by main loop, 45 | // draws the menus directly into the screen buffer. 46 | void M_Drawer(void); 47 | 48 | // Called by D_DoomMain, 49 | // loads the config file. 50 | void M_Init(void); 51 | 52 | // Called by intro code to force menu up upon a keypress, 53 | // does nothing if menu is already up. 54 | void M_StartControlPanel(void); 55 | 56 | 57 | #endif 58 | 59 | //----------------------------------------------------------------------------- 60 | // 61 | // $Log:$ 62 | // 63 | //----------------------------------------------------------------------------- 64 | -------------------------------------------------------------------------------- /apps/tinygl/src/TinyGL/config.mk: -------------------------------------------------------------------------------- 1 | ##################################################################### 2 | # C compiler 3 | 4 | # linux 5 | CC= gcc 6 | CFLAGS= -g -Wall -O2 7 | LFLAGS= 8 | 9 | # for BeOS PPC 10 | #CC= mwcc 11 | #CFLAGS= -I. -i- 12 | #LFLAGS= 13 | 14 | ##################################################################### 15 | # TinyGL configuration 16 | 17 | ##################################################################### 18 | # Select window API for TinyGL: 19 | 20 | # standard X11 GLX like API 21 | TINYGL_USE_GLX=y 22 | 23 | # BEOS API 24 | #TINYGL_USE_BEOS=y 25 | 26 | # Micro Windows NanoX API 27 | #TINYGL_USE_NANOX=y 28 | 29 | ##################################################################### 30 | # X11 configuration (for the examples only) 31 | 32 | ifdef TINYGL_USE_GLX 33 | # Linux 34 | UI_LIBS= -L/usr/X11R6/lib -lX11 -lXext 35 | UI_INCLUDES= 36 | # Solaris 37 | #UI_LIBS= -L/usr/X11/lib -lX11 -lXext -lsocket -lnsl 38 | #UI_INCLUDES= 39 | 40 | UI_OBJS=x11.o 41 | endif 42 | 43 | ##################################################################### 44 | # Micro windowX11 configuration (for the examples only) 45 | 46 | ifdef TINYGL_USE_NANOX 47 | UI_LIBS= -lnano-X -lmwengine -lmwdrivers -lmwfonts 48 | UI_INCLUDES= 49 | 50 | # X11 target for nanoX 51 | UI_LIBS+= -L/usr/X11R6/lib -lX11 -lXext 52 | 53 | UI_OBJS=nanox.o 54 | endif 55 | 56 | ##################################################################### 57 | # OpenGL configuration (for the examples only) 58 | 59 | # use TinyGL 60 | GL_LIBS= -L../lib -lTinyGL 61 | GL_INCLUDES= -I../include 62 | GL_DEPS= ../lib/libTinyGL.a 63 | 64 | # use Mesa 65 | #GL_LIBS= -lMesaGL 66 | #GL_INCLUDES= 67 | #GL_DEPS= 68 | 69 | # use OpenGL 70 | #GL_LIBS= -lGL 71 | #GL_INCLUDES= 72 | #GL_DEPS= 73 | 74 | #################################################################### 75 | # Compile and link control 76 | 77 | # UNIX systems 78 | DIRS= src examples 79 | 80 | # BeOS 81 | # DIRS= src BeOS 82 | 83 | -------------------------------------------------------------------------------- /apps/zigdoom/src/puredoom/r_bsp.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // Refresh module, BSP traversal and handling. 19 | // 20 | //----------------------------------------------------------------------------- 21 | 22 | #ifndef __R_BSP__ 23 | #define __R_BSP__ 24 | 25 | 26 | #include "r_defs.h" 27 | 28 | 29 | extern seg_t* curline; 30 | extern side_t* sidedef; 31 | extern line_t* linedef; 32 | extern sector_t* frontsector; 33 | extern sector_t* backsector; 34 | 35 | extern int rw_x; 36 | extern int rw_stopx; 37 | 38 | extern doom_boolean segtextured; 39 | 40 | // false if the back side is the same plane 41 | extern doom_boolean markfloor; 42 | extern doom_boolean markceiling; 43 | 44 | extern doom_boolean skymap; 45 | 46 | extern drawseg_t drawsegs[MAXDRAWSEGS]; 47 | extern drawseg_t* ds_p; 48 | 49 | extern lighttable_t** hscalelight; 50 | extern lighttable_t** vscalelight; 51 | extern lighttable_t** dscalelight; 52 | 53 | 54 | typedef void (*drawfunc_t) (int start, int stop); 55 | 56 | 57 | // BSP? 58 | void R_ClearClipSegs(void); 59 | void R_ClearDrawSegs(void); 60 | void R_RenderBSPNode(int bspnum); 61 | 62 | 63 | #endif 64 | 65 | //----------------------------------------------------------------------------- 66 | // 67 | // $Log:$ 68 | // 69 | //----------------------------------------------------------------------------- 70 | -------------------------------------------------------------------------------- /apps/zigdoom/src/puredoom/doomtype.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // Simple basic typedefs, isolated here to make it easier 19 | // separating modules. 20 | // 21 | //----------------------------------------------------------------------------- 22 | 23 | #ifndef __DOOMTYPE__ 24 | #define __DOOMTYPE__ 25 | 26 | 27 | // Fixed to use builtin bool type with C++. 28 | #ifdef __cplusplus 29 | typedef bool doom_boolean; 30 | #else 31 | #if !defined(false) && !defined(true) 32 | typedef enum 33 | { 34 | false, true 35 | } doom_boolean; 36 | #else 37 | typedef int doom_boolean; 38 | #endif 39 | #endif 40 | 41 | 42 | typedef unsigned char byte; 43 | 44 | 45 | #define DOOM_MAXCHAR ((char)0x7f) 46 | #define DOOM_MAXSHORT ((short)0x7fff) 47 | 48 | // Max pos 32-bit int. 49 | #define DOOM_MAXINT ((int)0x7fffffff) 50 | #define DOOM_MAXLONG ((long)0x7fffffff) 51 | #define DOOM_MINCHAR ((char)0x80) 52 | #define DOOM_MINSHORT ((short)0x8000) 53 | 54 | // Max negative 32-bit integer. 55 | #define DOOM_MININT ((int)0x80000000) 56 | #define DOOM_MINLONG ((long)0x80000000) 57 | 58 | 59 | #endif 60 | 61 | //----------------------------------------------------------------------------- 62 | // 63 | // $Log:$ 64 | // 65 | //----------------------------------------------------------------------------- 66 | -------------------------------------------------------------------------------- /apps/tinygl/src/TinyGL/src/opinfo.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | ADD_OP(Color,7,"%f %f %f %f %d %d %d") 4 | ADD_OP(TexCoord,4,"%f %f %f %f") 5 | ADD_OP(EdgeFlag,1,"%d") 6 | ADD_OP(Normal,3,"%f %f %f") 7 | 8 | ADD_OP(Begin,1,"%C") 9 | ADD_OP(Vertex,4,"%f %f %f %f") 10 | ADD_OP(End,0,"") 11 | 12 | ADD_OP(EnableDisable,2,"%C %d") 13 | 14 | ADD_OP(MatrixMode,1,"%C") 15 | ADD_OP(LoadMatrix,16,"") 16 | ADD_OP(LoadIdentity,0,"") 17 | ADD_OP(MultMatrix,16,"") 18 | ADD_OP(PushMatrix,0,"") 19 | ADD_OP(PopMatrix,0,"") 20 | ADD_OP(Rotate,4,"%f %f %f %f") 21 | ADD_OP(Translate,3,"%f %f %f") 22 | ADD_OP(Scale,3,"%f %f %f") 23 | 24 | ADD_OP(Viewport,4,"%d %d %d %d") 25 | ADD_OP(Frustum,6,"%f %f %f %f %f %f") 26 | 27 | ADD_OP(Material,6,"%C %C %f %f %f %f") 28 | ADD_OP(ColorMaterial,2,"%C %C") 29 | ADD_OP(Light,6,"%C %C %f %f %f %f") 30 | ADD_OP(LightModel,5,"%C %f %f %f %f") 31 | 32 | ADD_OP(Clear,1,"%d") 33 | ADD_OP(ClearColor,4,"%f %f %f %f") 34 | ADD_OP(ClearDepth,1,"%f") 35 | 36 | ADD_OP(InitNames,0,"") 37 | ADD_OP(PushName,1,"%d") 38 | ADD_OP(PopName,0,"") 39 | ADD_OP(LoadName,1,"%d") 40 | 41 | ADD_OP(TexImage2D,9,"%d %d %d %d %d %d %d %d %d") 42 | ADD_OP(BindTexture,2,"%C %d") 43 | ADD_OP(TexEnv,7,"%C %C %C %f %f %f %f") 44 | ADD_OP(TexParameter,7,"%C %C %C %f %f %f %f") 45 | ADD_OP(PixelStore,2,"%C %C") 46 | 47 | ADD_OP(ShadeModel,1,"%C") 48 | ADD_OP(CullFace,1,"%C") 49 | ADD_OP(FrontFace,1,"%C") 50 | ADD_OP(PolygonMode,2,"%C %C") 51 | 52 | ADD_OP(CallList,1,"%d") 53 | ADD_OP(Hint,2,"%C %C") 54 | 55 | /* special opcodes */ 56 | ADD_OP(EndList,0,"") 57 | ADD_OP(NextBuffer,1,"%p") 58 | 59 | /* opengl 1.1 arrays */ 60 | ADD_OP(ArrayElement, 1, "%d") 61 | ADD_OP(EnableClientState, 1, "%C") 62 | ADD_OP(DisableClientState, 1, "%C") 63 | ADD_OP(VertexPointer, 4, "%d %C %d %p") 64 | ADD_OP(ColorPointer, 4, "%d %C %d %p") 65 | ADD_OP(NormalPointer, 3, "%C %d %p") 66 | ADD_OP(TexCoordPointer, 4, "%d %C %d %p") 67 | 68 | /* opengl 1.1 polygon offset */ 69 | ADD_OP(PolygonOffset, 2, "%f %f") 70 | 71 | #undef ADD_OP 72 | -------------------------------------------------------------------------------- /apps/zigdoom/src/puredoom/r_things.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // Rendering of moving objects, sprites. 19 | // 20 | //----------------------------------------------------------------------------- 21 | 22 | #ifndef __R_THINGS__ 23 | #define __R_THINGS__ 24 | 25 | 26 | #include "r_defs.h" 27 | 28 | 29 | #define MAXVISSPRITES 128 30 | 31 | 32 | extern vissprite_t vissprites[MAXVISSPRITES]; 33 | extern vissprite_t* vissprite_p; 34 | extern vissprite_t vsprsortedhead; 35 | 36 | // Constant arrays used for psprite clipping 37 | // and initializing clipping. 38 | extern short negonearray[SCREENWIDTH]; 39 | extern short screenheightarray[SCREENWIDTH]; 40 | 41 | // vars for R_DrawMaskedColumn 42 | extern short* mfloorclip; 43 | extern short* mceilingclip; 44 | extern fixed_t spryscale; 45 | extern fixed_t sprtopscreen; 46 | 47 | extern fixed_t pspritescale; 48 | extern fixed_t pspriteiscale; 49 | 50 | 51 | void R_DrawMaskedColumn(column_t* column); 52 | void R_SortVisSprites(void); 53 | void R_AddSprites(sector_t* sec); 54 | void R_InitSprites(char** namelist); 55 | void R_ClearSprites(void); 56 | void R_DrawMasked(void); 57 | 58 | 59 | #endif 60 | 61 | //----------------------------------------------------------------------------- 62 | // 63 | // $Log:$ 64 | // 65 | //----------------------------------------------------------------------------- 66 | -------------------------------------------------------------------------------- /apps/maze/maze.c: -------------------------------------------------------------------------------- 1 | #include "uvm32_target.h" 2 | 3 | // This example generates a random maze using the recursive backtracking algorithm. 4 | // https://github.com/ccattuto/riscv-python/blob/main/tests/test_newlib_maze.c 5 | 6 | #define WIDTH 79 // must be odd 7 | #define HEIGHT 31 // must be odd 8 | 9 | char maze[HEIGHT * WIDTH]; 10 | 11 | void* my_memset(void* buf, int c, int len) { 12 | uint8_t* b = (uint8_t*)buf; 13 | while (len--) { 14 | *(b++) = c; 15 | } 16 | return buf; 17 | } 18 | 19 | int dx[] = {0, 1, 0, -1}; 20 | int dy[] = {-1, 0, 1, 0}; 21 | 22 | uint32_t state = 0x1; 23 | 24 | int32_t mulberry32(void) { 25 | uint32_t z = (state += 0x6D2B79F5UL); 26 | z = (z ^ (z >> 15)) * (z | 1UL); 27 | z ^= z + (z ^ (z >> 7)) * (z | 61UL); 28 | return z ^ (z >> 14); 29 | } 30 | 31 | void init_maze() { 32 | my_memset(maze, '#', sizeof(maze)); 33 | } 34 | 35 | int in_bounds(int x, int y) { 36 | return x > 0 && y > 0 && x < WIDTH - 1 && y < HEIGHT - 1; 37 | } 38 | 39 | void carve(int x, int y) { 40 | maze[y * WIDTH + x] = ' '; 41 | 42 | int dirs[] = {0, 1, 2, 3}; 43 | // Fisher-Yates shuffle 44 | for (int i = 3; i > 0; i--) { 45 | int j = (unsigned)mulberry32() % (i + 1); 46 | int tmp = dirs[i]; 47 | dirs[i] = dirs[j]; 48 | dirs[j] = tmp; 49 | } 50 | 51 | for (int i = 0; i < 4; i++) { 52 | int nx = x + dx[dirs[i]] * 2; 53 | int ny = y + dy[dirs[i]] * 2; 54 | 55 | if (in_bounds(nx, ny) && maze[ny * WIDTH + nx] == '#') { 56 | maze[(y + dy[dirs[i]]) * WIDTH + (x + dx[dirs[i]])] = ' '; 57 | carve(nx, ny); 58 | } 59 | } 60 | } 61 | 62 | void print_maze() { 63 | for (int y = 0; y < HEIGHT; y++) { 64 | for (int x = 0; x < WIDTH; x++) { 65 | putc(maze[y * WIDTH + x]); 66 | } 67 | putc('\n'); 68 | } 69 | } 70 | 71 | 72 | void main(void) { 73 | init_maze(); 74 | carve(1, 1); 75 | print_maze(); 76 | } 77 | -------------------------------------------------------------------------------- /apps/zigalloc/src/uvm.zig: -------------------------------------------------------------------------------- 1 | const uvm32 = @cImport({ 2 | @cDefine("USE_MAIN", "1"); 3 | @cInclude("uvm32_target.h"); 4 | }); 5 | const buildopts = @import("buildopts"); 6 | const std = @import("std"); 7 | 8 | const extram:[*]u8 = @ptrFromInt(uvm32.UVM32_EXTRAM_BASE); 9 | const extram_len = buildopts.heapsize; 10 | 11 | var fba:std.heap.FixedBufferAllocator = .init(extram[0..extram_len]); 12 | 13 | pub fn allocator() std.mem.Allocator { 14 | return fba.allocator(); 15 | } 16 | 17 | pub inline fn syscall(id: u32, param1: u32, param2: u32) u32 { 18 | var val: u32 = undefined; 19 | asm volatile ("ecall" 20 | : [val] "={a1}" (val), 21 | : [param1] "{a0}" (param1), [param2] "{a1}" (param2), 22 | [id] "{a7}" (id), 23 | : .{ .memory = true }); 24 | return val; 25 | } 26 | 27 | pub inline fn getc() ?u8 { 28 | const key = syscall(uvm32.UVM32_SYSCALL_GETC, 0, 0); 29 | if (key == 0xFFFFFFFF) { 30 | return null; 31 | } else { 32 | return @truncate(key); 33 | } 34 | } 35 | 36 | pub inline fn millis() u32 { 37 | return syscall(uvm32.UVM32_SYSCALL_MILLIS, 0, 0); 38 | } 39 | 40 | // dupeZ would be better, but want to avoid using an allocator 41 | // this is of course, unsafe... 42 | var termination_buf:[128]u8 = undefined; 43 | 44 | pub inline fn print(m: []const u8) void { 45 | @memcpy(termination_buf[0..m.len], m); 46 | termination_buf[m.len] = 0; 47 | const s = termination_buf[0..m.len :0]; 48 | _ = syscall(uvm32.UVM32_SYSCALL_PRINT, @intFromPtr(s.ptr), 0); 49 | } 50 | 51 | pub inline fn println(m: []const u8) void { 52 | @memcpy(termination_buf[0..m.len], m); 53 | termination_buf[m.len] = 0; 54 | const s = termination_buf[0..m.len :0]; 55 | _ = syscall(uvm32.UVM32_SYSCALL_PRINTLN, @intFromPtr(s.ptr), 0); 56 | } 57 | 58 | pub inline fn yield() void { 59 | _ = syscall(uvm32.UVM32_SYSCALL_YIELD, 0, 0); 60 | } 61 | 62 | pub inline fn putc(c:u8) void { 63 | _ = syscall(uvm32.UVM32_SYSCALL_PUTC, c, 0); 64 | } 65 | 66 | -------------------------------------------------------------------------------- /apps/zigdoom/src/puredoom/d_think.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // MapObj data. Map Objects or mobjs are actors, entities, 19 | // thinker, take-your-pick... anything that moves, acts, or 20 | // suffers state changes of more or less violent nature. 21 | // 22 | //----------------------------------------------------------------------------- 23 | 24 | #ifndef __D_THINK__ 25 | #define __D_THINK__ 26 | 27 | 28 | // 29 | // Experimental stuff. 30 | // To compile this as "ANSI C with classes" 31 | // we will need to handle the various 32 | // action functions cleanly. 33 | // 34 | typedef void (*actionf_v)(); 35 | typedef void (*actionf_p1)(void*); 36 | typedef void (*actionf_p2)(void*, void*); 37 | 38 | typedef union 39 | { 40 | actionf_p1 acp1; 41 | actionf_v acv; 42 | actionf_p2 acp2; 43 | } actionf_t; 44 | 45 | 46 | // Historically, "think_t" is yet another 47 | // function pointer to a routine to handle 48 | // an actor. 49 | typedef actionf_t think_t; 50 | 51 | 52 | // Doubly linked list of actors. 53 | typedef struct thinker_s 54 | { 55 | struct thinker_s* prev; 56 | struct thinker_s* next; 57 | think_t function; 58 | } thinker_t; 59 | 60 | 61 | #endif 62 | 63 | //----------------------------------------------------------------------------- 64 | // 65 | // $Log:$ 66 | // 67 | //----------------------------------------------------------------------------- 68 | -------------------------------------------------------------------------------- /apps/zig-mandel/build.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | const CrossTarget = @import("std").zig.CrossTarget; 3 | const Target = @import("std").Target; 4 | const Feature = @import("std").Target.Cpu.Feature; 5 | 6 | pub fn build(b: *std.Build) void { 7 | const features = Target.riscv.Feature; 8 | var disabled_features = Feature.Set.empty; 9 | var enabled_features = Feature.Set.empty; 10 | 11 | // disable all CPU extensions 12 | disabled_features.addFeature(@intFromEnum(features.a)); 13 | disabled_features.addFeature(@intFromEnum(features.c)); 14 | disabled_features.addFeature(@intFromEnum(features.d)); 15 | disabled_features.addFeature(@intFromEnum(features.e)); 16 | disabled_features.addFeature(@intFromEnum(features.f)); 17 | // except multiply 18 | enabled_features.addFeature(@intFromEnum(features.m)); 19 | 20 | const target = b.resolveTargetQuery(.{ 21 | .cpu_arch = Target.Cpu.Arch.riscv32, 22 | .os_tag = Target.Os.Tag.freestanding, 23 | .abi = Target.Abi.none, 24 | .cpu_model = .{ .explicit = &std.Target.riscv.cpu.generic_rv32}, 25 | .cpu_features_sub = disabled_features, 26 | .cpu_features_add = enabled_features 27 | }); 28 | 29 | const exe = b.addExecutable(.{ 30 | .name = "mandel", 31 | .root_module = b.createModule(.{ 32 | .root_source_file = b.path("src/main.zig"), 33 | .target = target, 34 | .optimize = .ReleaseSmall, 35 | }), 36 | }); 37 | 38 | b.installArtifact(exe); 39 | 40 | exe.addAssemblyFile(b.path("../common/crt0.S")); 41 | exe.setLinkerScript(b.path("../common/linker.ld")); 42 | exe.addIncludePath(b.path("../../common")); 43 | exe.addIncludePath(b.path("../common")); 44 | 45 | const bin = b.addObjCopy(exe.getEmittedBin(), .{ 46 | .format = .bin, 47 | }); 48 | bin.step.dependOn(&exe.step); 49 | 50 | const copy_bin = b.addInstallBinFile(bin.getOutput(), "mandel.bin"); 51 | b.default_step.dependOn(©_bin.step); 52 | } 53 | -------------------------------------------------------------------------------- /apps/zigdoom/src/puredoom/w_wad.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // WAD I/O functions. 19 | // 20 | //----------------------------------------------------------------------------- 21 | 22 | #ifndef __W_WAD__ 23 | #define __W_WAD__ 24 | 25 | 26 | // 27 | // TYPES 28 | // 29 | typedef struct 30 | { 31 | // Should be "IWAD" or "PWAD". 32 | char identification[4]; 33 | int numlumps; 34 | int infotableofs; 35 | } wadinfo_t; 36 | 37 | 38 | typedef struct 39 | { 40 | int filepos; 41 | int size; 42 | char name[8]; 43 | } filelump_t; 44 | 45 | 46 | // 47 | // WADFILE I/O related stuff. 48 | // 49 | typedef struct 50 | { 51 | char name[8]; 52 | void* handle; 53 | int position; 54 | int size; 55 | } lumpinfo_t; 56 | 57 | 58 | extern void** lumpcache; 59 | extern lumpinfo_t* lumpinfo; 60 | extern int numlumps; 61 | 62 | void W_InitMultipleFiles(char** filenames); 63 | void W_Reload(void); 64 | 65 | int W_CheckNumForName(char* name); 66 | int W_GetNumForName(char* name); 67 | 68 | int W_LumpLength(int lump); 69 | void W_ReadLump(int lump, void* dest); 70 | 71 | void* W_CacheLumpNum(int lump, int tag); 72 | void* W_CacheLumpName(char* name, int tag); 73 | 74 | 75 | #endif 76 | 77 | //----------------------------------------------------------------------------- 78 | // 79 | // $Log:$ 80 | // 81 | //----------------------------------------------------------------------------- 82 | -------------------------------------------------------------------------------- /apps/zigdoom/src/puredoom/p_pspr.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // Sprite animation. 19 | // 20 | //----------------------------------------------------------------------------- 21 | 22 | 23 | #ifndef __P_PSPR__ 24 | #define __P_PSPR__ 25 | 26 | // Basic data types. 27 | // Needs fixed point, and BAM angles. 28 | #include "m_fixed.h" 29 | #include "tables.h" 30 | 31 | // Needs to include the precompiled 32 | // sprite animation tables. 33 | // Header generated by multigen utility. 34 | // This includes all the data for thing animation, 35 | // i.e. the Thing Atrributes table 36 | // and the Frame Sequence table. 37 | #include "info.h" 38 | 39 | // 40 | // Frame flags: 41 | // handles maximum brightness (torches, muzzle flare, light sources) 42 | // 43 | #define FF_FULLBRIGHT 0x8000 // flag in thing->frame 44 | #define FF_FRAMEMASK 0x7fff 45 | 46 | 47 | // 48 | // Overlay psprites are scaled shapes 49 | // drawn directly on the view screen, 50 | // coordinates are given for a 320*200 view screen. 51 | // 52 | typedef enum 53 | { 54 | ps_weapon, 55 | ps_flash, 56 | NUMPSPRITES 57 | } psprnum_t; 58 | 59 | 60 | typedef struct 61 | { 62 | state_t* state; // a 0 state means not active 63 | int tics; 64 | fixed_t sx; 65 | fixed_t sy; 66 | } pspdef_t; 67 | 68 | 69 | #endif 70 | 71 | //----------------------------------------------------------------------------- 72 | // 73 | // $Log:$ 74 | // 75 | //----------------------------------------------------------------------------- 76 | -------------------------------------------------------------------------------- /apps/common/uvm32_target.h: -------------------------------------------------------------------------------- 1 | #ifndef UVM32_TARGET_H 2 | #define UVM32_TARGET_H 3 | // Common to all target code 4 | 5 | #include "uvm32_sys.h" 6 | #include 7 | //// 8 | ////typedef unsigned char bool; 9 | //#define true 1 10 | //#define false 0 11 | 12 | #include "target-stdint.h" 13 | 14 | typedef uint32_t size_t; 15 | typedef int32_t ssize_t; 16 | 17 | typedef uint32_t uintptr_t; 18 | 19 | #define NULL 0 20 | 21 | void *memcpy(void *dst, const void *src, int len); 22 | void *memset(void *buf, int c, int len); 23 | void *memmove(void *dest, const void *src, size_t len); 24 | 25 | static uint32_t syscall(uint32_t id, uint32_t param1, uint32_t param2) { 26 | register uint32_t a0 asm("a0") = (uint32_t)(param1); 27 | register uint32_t a1 asm("a1") = (uint32_t)(param2); 28 | register uint32_t a2 asm("a2"); 29 | register uint32_t a7 asm("a7") = (uint32_t)(id); 30 | 31 | asm volatile ( 32 | "ecall" 33 | : "=r"(a2) // output 34 | : "r"(a7), "r"(a0), "r"(a1) // input 35 | : "memory" 36 | ); 37 | return a2; 38 | } 39 | 40 | #define syscall_cast(id, p1, p2) syscall((uint32_t)id, (uint32_t)p1, (uint32_t)p2) 41 | 42 | #define println(x) syscall_cast(UVM32_SYSCALL_PRINTLN, x, 0) 43 | #define print(x) syscall_cast(UVM32_SYSCALL_PRINT, x, 0) 44 | #define printdec(x) syscall_cast(UVM32_SYSCALL_PRINTDEC, x, 0) 45 | #define printhex(x) syscall_cast(UVM32_SYSCALL_PRINTHEX, x, 0) 46 | #define millis() syscall_cast(UVM32_SYSCALL_MILLIS, 0, 0) 47 | #define putc(x) syscall_cast(UVM32_SYSCALL_PUTC, x, 0) 48 | #define getc() syscall_cast(UVM32_SYSCALL_GETC, 0, 0) 49 | #define yield(x) syscall_cast(UVM32_SYSCALL_YIELD, x, 0) 50 | #define printbuf(x, y) syscall_cast(UVM32_SYSCALL_PRINTBUF, x, y) 51 | #define render(x, y) syscall_cast(UVM32_SYSCALL_RENDER, x, y) 52 | #define getkey() syscall_cast(UVM32_SYSCALL_GETKEY, 0, 0) 53 | #define rand() syscall_cast(UVM32_SYSCALL_RAND, 0, 0) 54 | 55 | extern char _estack; 56 | 57 | static void stackprotect(void) { 58 | syscall_cast(UVM32_SYSCALL_STACKPROTECT, &_estack, 0); 59 | } 60 | 61 | #include "uvm32_common_custom.h" 62 | 63 | #endif 64 | 65 | -------------------------------------------------------------------------------- /apps/zigdoom/src/puredoom/g_game.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // Duh. 19 | // 20 | //----------------------------------------------------------------------------- 21 | 22 | #ifndef __G_GAME__ 23 | #define __G_GAME__ 24 | 25 | 26 | #include "doomdef.h" 27 | #include "d_event.h" 28 | 29 | 30 | // 31 | // GAME 32 | // 33 | void G_DeathMatchSpawnPlayer(int playernum); 34 | 35 | void G_InitNew(skill_t skill, int episode, int map); 36 | 37 | // Can be called by the startup code or M_Responder. 38 | // A normal game starts at map 1, 39 | // but a warp test can start elsewhere 40 | void G_DeferedInitNew(skill_t skill, int episode, int map); 41 | 42 | void G_DeferedPlayDemo(char* demo); 43 | 44 | // Can be called by the startup code or M_Responder, 45 | // calls P_SetupLevel or W_EnterWorld. 46 | void G_LoadGame(char* name); 47 | 48 | void G_DoLoadGame(void); 49 | 50 | // Called by M_Responder. 51 | void G_SaveGame(int slot, char* description); 52 | 53 | // Only called by startup code. 54 | void G_RecordDemo(char* name); 55 | 56 | void G_BeginRecording(void); 57 | 58 | void G_TimeDemo(char* name); 59 | doom_boolean G_CheckDemoStatus(void); 60 | 61 | void G_ExitLevel(void); 62 | void G_SecretExitLevel(void); 63 | 64 | void G_WorldDone(void); 65 | 66 | void G_Ticker(void); 67 | doom_boolean G_Responder(event_t* ev); 68 | 69 | void G_ScreenShot(void); 70 | 71 | 72 | #endif 73 | 74 | //----------------------------------------------------------------------------- 75 | // 76 | // $Log:$ 77 | // 78 | //----------------------------------------------------------------------------- 79 | -------------------------------------------------------------------------------- /apps/zigdoom/src/puredoom/st_stuff.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // Status bar code. 19 | // Does the face/direction indicator animatin. 20 | // Does palette indicators as well (red pain/berserk, bright pickup) 21 | // 22 | //----------------------------------------------------------------------------- 23 | 24 | #ifndef __STSTUFF_H__ 25 | #define __STSTUFF_H__ 26 | 27 | #include "doomtype.h" 28 | #include "d_event.h" 29 | 30 | // Size of statusbar. 31 | // Now sensitive for scaling. 32 | #define ST_HEIGHT (32 * SCREEN_MUL) 33 | #define ST_WIDTH SCREENWIDTH 34 | #define ST_Y (SCREENHEIGHT - ST_HEIGHT) 35 | 36 | 37 | // 38 | // STATUS BAR 39 | // 40 | 41 | // Called by main loop. 42 | doom_boolean ST_Responder(event_t* ev); 43 | 44 | // Called by main loop. 45 | void ST_Ticker(void); 46 | 47 | // Called by main loop. 48 | void ST_Drawer(doom_boolean fullscreen, doom_boolean refresh); 49 | 50 | // Called when the console player is spawned on each level. 51 | void ST_Start(void); 52 | 53 | // Called by startup code. 54 | void ST_Init(void); 55 | 56 | 57 | // States for status bar code. 58 | typedef enum 59 | { 60 | AutomapState, 61 | FirstPersonState 62 | } st_stateenum_t; 63 | 64 | 65 | // States for the chat code. 66 | typedef enum 67 | { 68 | StartChatState, 69 | WaitDestState, 70 | GetChatState 71 | } st_chatstateenum_t; 72 | 73 | 74 | doom_boolean ST_Responder(event_t* ev); 75 | 76 | #endif 77 | 78 | //----------------------------------------------------------------------------- 79 | // 80 | // $Log:$ 81 | // 82 | //----------------------------------------------------------------------------- 83 | -------------------------------------------------------------------------------- /apps/tinygl/src/TinyGL/BeOS/GLView.h: -------------------------------------------------------------------------------- 1 | #ifndef _glview_h_ 2 | #define _glview_h_ 3 | 4 | #define BGL_RGB 0 5 | #define BGL_INDEX 1 6 | #define BGL_SINGLE 0 7 | #define BGL_DOUBLE 2 8 | #define BGL_DIRECT 0 9 | #define BGL_INDIRECT 4 10 | #define BGL_ACCUM 8 11 | #define BGL_ALPHA 16 12 | #define BGL_DEPTH 32 13 | #define BGL_OVERLAY 64 14 | #define BGL_UNDERLAY 128 15 | #define BGL_STENCIL 512 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | class BGLView : public BView { 25 | public: 26 | BGLView(BRect rect, char *name, 27 | ulong resizingMode, ulong mode, 28 | ulong options); 29 | virtual ~BGLView(); 30 | 31 | void LockGL(); 32 | void UnlockGL(); 33 | void SwapBuffers(); 34 | // BView *EmbeddedView(); 35 | // status_t CopyPixelsOut(BPoint source, BBitmap *dest); 36 | // status_t CopyPixelsIn(BBitmap *source, BPoint dest); 37 | 38 | virtual void ErrorCallback(GLenum errorCode); 39 | virtual void Draw(BRect updateRect); 40 | virtual void AttachedToWindow(); 41 | virtual void AllAttached(); 42 | virtual void DetachedFromWindow(); 43 | virtual void AllDetached(); 44 | virtual void FrameResized(float width, float height); 45 | // virtual status_t Perform(perform_code d, void *arg); 46 | 47 | // 48 | // Methods below are pass-throughs to BView for the moment. 49 | // 50 | 51 | virtual status_t Archive(BMessage *data, bool deep = true) const; 52 | virtual void MessageReceived(BMessage *msg); 53 | virtual void SetResizingMode(uint32 mode); 54 | 55 | virtual void Show(); 56 | virtual void Hide(); 57 | 58 | virtual BHandler *ResolveSpecifier(BMessage *msg, int32 index, 59 | BMessage *specifier, int32 form, 60 | const char *property); 61 | virtual status_t GetSupportedSuites(BMessage *data); 62 | //void DirectConnected( direct_buffer_info *info ); 63 | //void EnableDirectMode( bool enabled ); 64 | 65 | private: 66 | ostgl_context *context; 67 | BBitmap *bitmaps[2]; 68 | int currBitmap; 69 | static BLocker locker; 70 | }; 71 | 72 | #endif // _glview_h_ 73 | -------------------------------------------------------------------------------- /apps/tinygl/src/TinyGL/include/GLView.h: -------------------------------------------------------------------------------- 1 | #ifndef _glview_h_ 2 | #define _glview_h_ 3 | 4 | #define BGL_RGB 0 5 | #define BGL_INDEX 1 6 | #define BGL_SINGLE 0 7 | #define BGL_DOUBLE 2 8 | #define BGL_DIRECT 0 9 | #define BGL_INDIRECT 4 10 | #define BGL_ACCUM 8 11 | #define BGL_ALPHA 16 12 | #define BGL_DEPTH 32 13 | #define BGL_OVERLAY 64 14 | #define BGL_UNDERLAY 128 15 | #define BGL_STENCIL 512 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | class BGLView : public BView { 25 | public: 26 | BGLView(BRect rect, char *name, 27 | ulong resizingMode, ulong mode, 28 | ulong options); 29 | virtual ~BGLView(); 30 | 31 | void LockGL(); 32 | void UnlockGL(); 33 | void SwapBuffers(); 34 | // BView *EmbeddedView(); 35 | // status_t CopyPixelsOut(BPoint source, BBitmap *dest); 36 | // status_t CopyPixelsIn(BBitmap *source, BPoint dest); 37 | 38 | virtual void ErrorCallback(GLenum errorCode); 39 | virtual void Draw(BRect updateRect); 40 | virtual void AttachedToWindow(); 41 | virtual void AllAttached(); 42 | virtual void DetachedFromWindow(); 43 | virtual void AllDetached(); 44 | virtual void FrameResized(float width, float height); 45 | // virtual status_t Perform(perform_code d, void *arg); 46 | 47 | // 48 | // Methods below are pass-throughs to BView for the moment. 49 | // 50 | 51 | virtual status_t Archive(BMessage *data, bool deep = true) const; 52 | virtual void MessageReceived(BMessage *msg); 53 | virtual void SetResizingMode(uint32 mode); 54 | 55 | virtual void Show(); 56 | virtual void Hide(); 57 | 58 | virtual BHandler *ResolveSpecifier(BMessage *msg, int32 index, 59 | BMessage *specifier, int32 form, 60 | const char *property); 61 | virtual status_t GetSupportedSuites(BMessage *data); 62 | //void DirectConnected( direct_buffer_info *info ); 63 | //void EnableDirectMode( bool enabled ); 64 | 65 | private: 66 | ostgl_context *context; 67 | BBitmap *bitmaps[2]; 68 | int currBitmap; 69 | static BLocker locker; 70 | }; 71 | 72 | #endif // _glview_h_ 73 | -------------------------------------------------------------------------------- /test/meter/test/tests.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "unity.h" 3 | #include "uvm32.h" 4 | #include "../common/uvm32_common_custom.h" 5 | 6 | #include "rom-header.h" 7 | 8 | static uvm32_state_t vmst; 9 | static uvm32_evt_t evt; 10 | 11 | void setUp(void) { 12 | // runs before each test 13 | uvm32_init(&vmst); 14 | uvm32_load(&vmst, rom_bin, rom_bin_len); 15 | } 16 | 17 | void tearDown(void) { 18 | } 19 | 20 | // run program until printdec() reaches 100 21 | // every time it hangs, resume 22 | // run in batches of num_instr 23 | uint32_t metered_run(uint32_t num_instr) { 24 | uint32_t expected = 0; 25 | uint32_t total_instr = 0; 26 | 27 | while(expected < 100) { 28 | total_instr += uvm32_run(&vmst, &evt, num_instr); 29 | switch(evt.typ) { 30 | case UVM32_EVT_SYSCALL: { 31 | TEST_ASSERT_EQUAL(UVM32_SYSCALL_PRINTDEC, evt.data.syscall.code); 32 | uint32_t val = uvm32_arg_getval(&vmst, &evt, ARG0); 33 | TEST_ASSERT_EQUAL(val, expected); 34 | expected++; 35 | } break; 36 | case UVM32_EVT_ERR: 37 | TEST_ASSERT_EQUAL(evt.data.err.errcode, UVM32_ERR_HUNG); 38 | uvm32_clearError(&vmst); // clear the hung error so it can continue 39 | break; 40 | case UVM32_EVT_END: 41 | TEST_ASSERT_EQUAL(0, 1); // trigger an assert, we didn't get to 100000 yet 42 | break; 43 | } 44 | } 45 | 46 | // run vm to completion 47 | total_instr += uvm32_run(&vmst, &evt, 10000); 48 | TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_END); 49 | return total_instr; 50 | } 51 | 52 | void test_meter(void) { 53 | // test many different meter values, including 0 (which should run 1 instruction, as 0 is going to hang) 54 | uint32_t total_instr = 0; 55 | 56 | for (uint32_t i=0;i<1000;i++) { 57 | uvm32_init(&vmst); 58 | uvm32_load(&vmst, rom_bin, rom_bin_len); 59 | uint32_t instrs = metered_run(i); 60 | if (total_instr == 0) { // first run 61 | total_instr = instrs; 62 | } else { 63 | TEST_ASSERT_EQUAL(total_instr, instrs); // check that every run takes the total number of instructions 64 | } 65 | } 66 | } 67 | 68 | -------------------------------------------------------------------------------- /apps/zigalloc/build.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | const CrossTarget = @import("std").zig.CrossTarget; 3 | const Target = @import("std").Target; 4 | const Feature = @import("std").Target.Cpu.Feature; 5 | 6 | pub fn build(b: *std.Build) void { 7 | var options = b.addOptions(); 8 | const heapsize = b.option(u32, "heapsize", "heap size in bytes") orelse 0; // -Dheapsize=u32 9 | options.addOption(u32, "heapsize", heapsize); 10 | 11 | const features = Target.riscv.Feature; 12 | var disabled_features = Feature.Set.empty; 13 | var enabled_features = Feature.Set.empty; 14 | 15 | // disable all CPU extensions 16 | disabled_features.addFeature(@intFromEnum(features.a)); 17 | disabled_features.addFeature(@intFromEnum(features.c)); 18 | disabled_features.addFeature(@intFromEnum(features.d)); 19 | disabled_features.addFeature(@intFromEnum(features.e)); 20 | disabled_features.addFeature(@intFromEnum(features.f)); 21 | // except multiply 22 | enabled_features.addFeature(@intFromEnum(features.m)); 23 | 24 | const target = b.resolveTargetQuery(.{ 25 | .cpu_arch = Target.Cpu.Arch.riscv32, 26 | .os_tag = Target.Os.Tag.freestanding, 27 | .abi = Target.Abi.none, 28 | .cpu_model = .{ .explicit = &std.Target.riscv.cpu.generic_rv32}, 29 | .cpu_features_sub = disabled_features, 30 | .cpu_features_add = enabled_features 31 | }); 32 | 33 | const exe = b.addExecutable(.{ 34 | .name = "zigalloc", 35 | .root_module = b.createModule(.{ 36 | .root_source_file = b.path("src/main.zig"), 37 | .target = target, 38 | .optimize = .ReleaseSmall, 39 | }), 40 | }); 41 | exe.root_module.addOptions("buildopts", options); 42 | 43 | b.installArtifact(exe); 44 | 45 | exe.addAssemblyFile(b.path("../common/crt0.S")); 46 | exe.setLinkerScript(b.path("../common/linker.ld")); 47 | exe.addIncludePath(b.path("../../common")); 48 | exe.addIncludePath(b.path("../common")); 49 | 50 | const bin = b.addObjCopy(exe.getEmittedBin(), .{ 51 | .format = .bin, 52 | }); 53 | bin.step.dependOn(&exe.step); 54 | 55 | const copy_bin = b.addInstallBinFile(bin.getOutput(), "zigalloc.bin"); 56 | b.default_step.dependOn(©_bin.step); 57 | } 58 | -------------------------------------------------------------------------------- /apps/tinygl/src/TinyGL/src/zline.c: -------------------------------------------------------------------------------- 1 | //#include 2 | #include "zbuffer.h" 3 | 4 | #define ZCMP(z,zpix) ((z) >= (zpix)) 5 | 6 | void ZB_plot(ZBuffer * zb, ZBufferPoint * p) 7 | { 8 | unsigned short *pz; 9 | PIXEL *pp; 10 | int zz; 11 | 12 | pz = zb->zbuf + (p->y * zb->xsize + p->x); 13 | pp = (PIXEL *) ((char *) zb->pbuf + zb->linesize * p->y + p->x * PSZB); 14 | zz = p->z >> ZB_POINT_Z_FRAC_BITS; 15 | if (ZCMP(zz, *pz)) { 16 | #if TGL_FEATURE_RENDER_BITS == 24 17 | pp[0]=p->r>>8; 18 | pp[1]=p->g>>8; 19 | pp[2]=p->b>>8; 20 | #else 21 | *pp = RGB_TO_PIXEL(p->r, p->g, p->b); 22 | #endif 23 | *pz = zz; 24 | } 25 | } 26 | 27 | #define INTERP_Z 28 | static void ZB_line_flat_z(ZBuffer * zb, ZBufferPoint * p1, ZBufferPoint * p2, 29 | int color) 30 | { 31 | #include "zline.h" 32 | } 33 | 34 | /* line with color interpolation */ 35 | #define INTERP_Z 36 | #define INTERP_RGB 37 | static void ZB_line_interp_z(ZBuffer * zb, ZBufferPoint * p1, ZBufferPoint * p2) 38 | { 39 | #include "zline.h" 40 | } 41 | 42 | /* no Z interpolation */ 43 | 44 | static void ZB_line_flat(ZBuffer * zb, ZBufferPoint * p1, ZBufferPoint * p2, 45 | int color) 46 | { 47 | #include "zline.h" 48 | } 49 | 50 | #define INTERP_RGB 51 | static void ZB_line_interp(ZBuffer * zb, ZBufferPoint * p1, ZBufferPoint * p2) 52 | { 53 | #include "zline.h" 54 | } 55 | 56 | void ZB_line_z(ZBuffer * zb, ZBufferPoint * p1, ZBufferPoint * p2) 57 | { 58 | int color1, color2; 59 | 60 | color1 = RGB_TO_PIXEL(p1->r, p1->g, p1->b); 61 | color2 = RGB_TO_PIXEL(p2->r, p2->g, p2->b); 62 | 63 | /* choose if the line should have its color interpolated or not */ 64 | if (color1 == color2) { 65 | ZB_line_flat_z(zb, p1, p2, color1); 66 | } else { 67 | ZB_line_interp_z(zb, p1, p2); 68 | } 69 | } 70 | 71 | void ZB_line(ZBuffer * zb, ZBufferPoint * p1, ZBufferPoint * p2) 72 | { 73 | int color1, color2; 74 | 75 | color1 = RGB_TO_PIXEL(p1->r, p1->g, p1->b); 76 | color2 = RGB_TO_PIXEL(p2->r, p2->g, p2->b); 77 | 78 | /* choose if the line should have its color interpolated or not */ 79 | if (color1 == color2) { 80 | ZB_line_flat(zb, p1, p2, color1); 81 | } else { 82 | ZB_line_interp(zb, p1, p2); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /apps/zigdoom/src/puredoom/m_cheat.c: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // $Log:$ 18 | // 19 | // DESCRIPTION: 20 | // Cheat sequence checking. 21 | // 22 | //----------------------------------------------------------------------------- 23 | 24 | 25 | #include "doom_config.h" 26 | 27 | #include "m_cheat.h" 28 | 29 | 30 | // 31 | // CHEAT SEQUENCE PACKAGE 32 | // 33 | 34 | static int firsttime = 1; 35 | static unsigned char cheat_xlate_table[256]; 36 | 37 | 38 | // 39 | // Called in st_stuff module, which handles the input. 40 | // Returns a 1 if the cheat was successful, 0 if failed. 41 | // 42 | int cht_CheckCheat(cheatseq_t* cht, char key) 43 | { 44 | int i; 45 | int rc = 0; 46 | 47 | if (firsttime) 48 | { 49 | firsttime = 0; 50 | for (i = 0; i < 256; i++) cheat_xlate_table[i] = SCRAMBLE(i); 51 | } 52 | 53 | if (!cht->p) 54 | cht->p = cht->sequence; // initialize if first time 55 | 56 | if (*cht->p == 0) 57 | *(cht->p++) = key; 58 | else if 59 | (cheat_xlate_table[(unsigned char)key] == *cht->p) cht->p++; 60 | else 61 | cht->p = cht->sequence; 62 | 63 | if (*cht->p == 1) 64 | cht->p++; 65 | else if (*cht->p == 0xff) // end of sequence character 66 | { 67 | cht->p = cht->sequence; 68 | rc = 1; 69 | } 70 | 71 | return rc; 72 | } 73 | 74 | 75 | void cht_GetParam(cheatseq_t* cht, char* buffer) 76 | { 77 | unsigned char* p, c; 78 | 79 | p = cht->sequence; 80 | while (*(p++) != 1); 81 | 82 | do 83 | { 84 | c = *p; 85 | *(buffer++) = c; 86 | *(p++) = 0; 87 | } while (c && *p != 0xff); 88 | 89 | if (*p == 0xff) 90 | *buffer = 0; 91 | } 92 | -------------------------------------------------------------------------------- /test/basic_syscalls/test/tests.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "unity.h" 3 | #include "uvm32.h" 4 | #include "../common/uvm32_common_custom.h" 5 | 6 | #include "rom-header.h" 7 | 8 | static uvm32_state_t vmst; 9 | static uvm32_evt_t evt; 10 | 11 | void setUp(void) { 12 | // runs before each test 13 | uvm32_init(&vmst); 14 | uvm32_load(&vmst, rom_bin, rom_bin_len); 15 | } 16 | 17 | void tearDown(void) { 18 | } 19 | 20 | void test_syscalls(void) { 21 | TEST_ASSERT_EQUAL(0x80000000, uvm32_getProgramCounter(&vmst)); 22 | 23 | // check for println syscall 24 | uvm32_run(&vmst, &evt, 1000); 25 | TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_SYSCALL); 26 | TEST_ASSERT_EQUAL(evt.data.syscall.code, UVM32_SYSCALL_PRINTLN); 27 | TEST_ASSERT_EQUAL(0, strcmp(uvm32_arg_getcstr(&vmst, &evt, ARG0), "Hello world")); 28 | 29 | // check for print syscall 30 | uvm32_run(&vmst, &evt, 1000); 31 | TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_SYSCALL); 32 | TEST_ASSERT_EQUAL(evt.data.syscall.code, UVM32_SYSCALL_PRINT); 33 | TEST_ASSERT_EQUAL(0, strcmp(uvm32_arg_getcstr(&vmst, &evt, ARG0), "Hello world")); 34 | 35 | // check for printdec syscall 36 | uvm32_run(&vmst, &evt, 1000); 37 | TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_SYSCALL); 38 | TEST_ASSERT_EQUAL(evt.data.syscall.code, UVM32_SYSCALL_PRINTDEC); 39 | TEST_ASSERT_EQUAL(42, uvm32_arg_getval(&vmst, &evt, ARG0)); 40 | 41 | // check for printhex syscall 42 | uvm32_run(&vmst, &evt, 1000); 43 | TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_SYSCALL); 44 | TEST_ASSERT_EQUAL(evt.data.syscall.code, UVM32_SYSCALL_PRINTHEX); 45 | TEST_ASSERT_EQUAL(0xDEADBEEF, uvm32_arg_getval(&vmst, &evt, ARG0)); 46 | 47 | // check for putc syscall 48 | uvm32_run(&vmst, &evt, 1000); 49 | TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_SYSCALL); 50 | TEST_ASSERT_EQUAL(evt.data.syscall.code, UVM32_SYSCALL_PUTC); 51 | TEST_ASSERT_EQUAL('G', uvm32_arg_getval(&vmst, &evt, ARG0)); 52 | 53 | // run vm to completion 54 | TEST_ASSERT_EQUAL(false, uvm32_hasEnded(&vmst)); 55 | uvm32_run(&vmst, &evt, 10000); 56 | TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_END); 57 | TEST_ASSERT_EQUAL(true, uvm32_hasEnded(&vmst)); 58 | 59 | TEST_ASSERT_EQUAL(vmst._memory, uvm32_getMemory(&vmst)); 60 | TEST_ASSERT_NOT_EQUAL(0x80000000, uvm32_getProgramCounter(&vmst)); 61 | 62 | } 63 | 64 | 65 | -------------------------------------------------------------------------------- /test/syscall_args/rom/rom.c: -------------------------------------------------------------------------------- 1 | #include "uvm32_target.h" 2 | #include "../shared.h" 3 | 4 | void syscall_a_test(void) { 5 | // two strings 6 | syscall((uint32_t)SYSCALL_A, (uint32_t)SYSCALL_A_DATA0, (uint32_t)SYSCALL_A_DATA1); 7 | } 8 | 9 | void syscall_b_test(void) { 10 | // two null values 11 | syscall((uint32_t)SYSCALL_B, 0, 0); 12 | } 13 | 14 | void syscall_c_test(void) { 15 | // valid buffer 16 | uint8_t buf[32]; 17 | for (int i=0;i<32;i++) { 18 | buf[i] = i; 19 | } 20 | syscall((uint32_t)SYSCALL_C, (uint32_t)buf, sizeof(buf)); 21 | } 22 | 23 | void syscall_d_test(void) { 24 | // invalid address 25 | syscall((uint32_t)SYSCALL_D, 0xFF000000, 100); 26 | } 27 | 28 | void syscall_ef_test(void) { 29 | // ask for two values, then send them back 30 | uint32_t a, b; 31 | syscall((uint32_t)SYSCALL_E, (uint32_t)&a, (uint32_t)&b); 32 | syscall((uint32_t)SYSCALL_F, a, b); 33 | } 34 | 35 | void syscall_gh_test(void) { 36 | // ask for a buffer, mutate it, send it back 37 | uint8_t buf[32]; 38 | syscall((uint32_t)SYSCALL_G, (uint32_t)buf, 32); 39 | for (int i=0;i<32;i++) { 40 | buf[i] *= 2; 41 | } 42 | syscall((uint32_t)SYSCALL_H, (uint32_t)buf, 32); 43 | } 44 | 45 | void syscall_i_test(void) { 46 | char *p = "hello"; // runner will overwrite memory 47 | syscall((uint32_t)SYSCALL_I, (uint32_t)p, 0); 48 | } 49 | 50 | void syscall_j_test(void) { 51 | uint32_t *p = (uint32_t *)0xF0000000; 52 | syscall((uint32_t)SYSCALL_I, (uint32_t)p[0], 0); // try to read from beyond memory and not in MMIO region 53 | } 54 | 55 | void main(void) { 56 | switch(syscall(SYSCALL_PICKTEST, 0, 0)) { 57 | case SYSCALL_A: 58 | syscall_a_test(); 59 | break; 60 | case SYSCALL_B: 61 | syscall_b_test(); 62 | break; 63 | case SYSCALL_C: 64 | syscall_c_test(); 65 | break; 66 | case SYSCALL_D: 67 | syscall_d_test(); 68 | break; 69 | case SYSCALL_E: 70 | syscall_ef_test(); 71 | break; 72 | case SYSCALL_G: 73 | syscall_gh_test(); 74 | break; 75 | case SYSCALL_I: 76 | syscall_i_test(); 77 | break; 78 | case SYSCALL_J: 79 | syscall_j_test(); 80 | break; 81 | 82 | } 83 | } 84 | 85 | --------------------------------------------------------------------------------