uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

commit e860fc893228562a9e84bdc7a60ffb39d995a8c3
parent f884031c2d69c68a6d0b98c1edcde4fdb72a1b7f
Author: Andrew Alderwick <andrew@alderwick.co.uk>
Date:   Mon, 22 Mar 2021 09:20:49 +0000

Add emulator without SDL window.

Diffstat:
Mbuild.sh | 1+
Memulator.c | 10++++++++++
Arun.sh | 13+++++++++++++
3 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/build.sh b/build.sh @@ -17,6 +17,7 @@ clang-format -i uxn.c clang-format -i emulator.c rm -f ./bin/emulator cc -std=c89 -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og -fsanitize=address -fsanitize=undefined uxn.c emulator.c -L/usr/local/lib -lSDL2 -o bin/emulator +cc -std=c89 -DNO_SDL -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og -fsanitize=address -fsanitize=undefined uxn.c emulator.c -L/usr/local/lib -lSDL2 -o bin/emulator-nosdl # cc uxn.c emulator.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -L/usr/local/lib -lSDL2 -o bin/emulator # run diff --git a/emulator.c b/emulator.c @@ -238,6 +238,7 @@ quit(void) int init(void) { +#ifndef NO_SDL if(SDL_Init(SDL_INIT_VIDEO) < 0) return error("Init", SDL_GetError()); gWindow = SDL_CreateWindow("Uxn", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, WIDTH * ZOOM, HEIGHT * ZOOM, SDL_WINDOW_SHOWN); @@ -254,6 +255,7 @@ init(void) clear(pixels); SDL_StartTextInput(); SDL_ShowCursor(SDL_DISABLE); +#endif screen.bounds.x1 = PAD * 8; screen.bounds.x2 = WIDTH - PAD * 8 - 1; screen.bounds.y1 = PAD * 8; @@ -429,12 +431,17 @@ ppnil(Uint8 *m, Uint16 ptr, Uint8 b0, Uint8 b1) int start(Uxn *u) { +#ifndef NO_SDL int ticknext = 0; +#endif evaluxn(u, u->vreset); loadtheme(u->ram.dat + PAGE_DEVICE + 0x00f8); +#ifndef NO_SDL if(screen.reqdraw) redraw(pixels, u); +#endif while(1) { +#ifndef NO_SDL int tick = SDL_GetTicks(); SDL_Event event; if(tick < ticknext) @@ -455,9 +462,12 @@ start(Uxn *u) break; } } +#endif evaluxn(u, u->vframe); +#ifndef NO_SDL if(screen.reqdraw) redraw(pixels, u); +#endif } } diff --git a/run.sh b/run.sh @@ -0,0 +1,13 @@ +#!/bin/bash +set -e +EMULATOR=./bin/emulator +if [ "${1}" = '--no-sdl' ]; then + EMULATOR=./bin/emulator-nosdl + shift +fi +if [ -z "${1}" ]; then + printf 'usage: %s [--no-sdl] USM_FILE\n' "${0}" >&2 + exit 2 +fi +./bin/assembler "${1}" bin/boot.rom +"${EMULATOR}" bin/boot.rom