uxn

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

commit 97d299261f52b52caf7f7995cc1a7f86c0e107fb
parent 13570f790d33ccad25078d7f5a345edad0e183d0
Author: neauoire <aliceffekt@gmail.com>
Date:   Tue,  8 Aug 2023 14:13:07 -0700

Setting up stage to add versioning

Diffstat:
Mbuild.sh | 4++--
Mmkfile | 7++++---
Msrc/devices/audio.h | 5+++++
Asrc/devices/console.c | 41+++++++++++++++++++++++++++++++++++++++++
Asrc/devices/console.h | 22++++++++++++++++++++++
Msrc/devices/controller.h | 4++++
Msrc/devices/datetime.h | 4++++
Msrc/devices/file.h | 4++++
Msrc/devices/mouse.h | 5+++++
Msrc/devices/screen.h | 4++++
Msrc/devices/system.c | 26--------------------------
Msrc/devices/system.h | 11++++-------
Msrc/uxncli.c | 1+
Msrc/uxnemu.c | 1+
14 files changed, 101 insertions(+), 38 deletions(-)

diff --git a/build.sh b/build.sh @@ -81,8 +81,8 @@ else fi ${CC} ${CFLAGS} src/uxnasm.c -o bin/uxnasm -${CC} ${CFLAGS} src/uxn.c src/devices/system.c src/devices/file.c src/devices/datetime.c src/devices/mouse.c src/devices/controller.c src/devices/screen.c src/devices/audio.c src/uxnemu.c ${UXNEMU_LDFLAGS} ${FILE_LDFLAGS} -o bin/uxnemu -${CC} ${CFLAGS} src/uxn.c src/devices/system.c src/devices/file.c src/devices/datetime.c src/uxncli.c ${FILE_LDFLAGS} -o bin/uxncli +${CC} ${CFLAGS} src/uxn.c src/devices/system.c src/devices/console.c src/devices/file.c src/devices/datetime.c src/devices/mouse.c src/devices/controller.c src/devices/screen.c src/devices/audio.c src/uxnemu.c ${UXNEMU_LDFLAGS} ${FILE_LDFLAGS} -o bin/uxnemu +${CC} ${CFLAGS} src/uxn.c src/devices/system.c src/devices/console.c src/devices/file.c src/devices/datetime.c src/uxncli.c ${FILE_LDFLAGS} -o bin/uxncli if [ $install = 1 ] then diff --git a/mkfile b/mkfile @@ -14,6 +14,7 @@ HFILES=\ src/devices/mouse.h\ src/devices/screen.h\ src/devices/system.h\ + src/devices/console.h\ src/uxn.h\ CLEANFILES=$TARG $ROM @@ -34,19 +35,19 @@ bin: %.rom:Q: %.tal bin/uxnasm bin/uxnasm $stem.tal $target >/dev/null -bin/uxncli: file.$O datetime.$O system.$O uxncli.$O uxn.$O +bin/uxncli: file.$O datetime.$O system.$O console.$O uxncli.$O uxn.$O $LD $LDFLAGS -o $target $prereq bin/uxnasm: uxnasm.$O $LD $LDFLAGS -o $target $prereq -bin/uxnemu: audio.$O controller.$O datetime.$O file.$O mouse.$O screen.$O system.$O uxn.$O uxnemu.$O +bin/uxnemu: audio.$O controller.$O datetime.$O file.$O mouse.$O screen.$O system.$O console.$O uxn.$O uxnemu.$O $LD $LDFLAGS -o $target $prereq (uxnasm|uxncli|uxnemu|uxn)\.$O:R: src/\1.c $CC $CFLAGS -Isrc -o $target src/$stem1.c -(audio|controller|datetime|file|mouse|screen|system)\.$O:R: src/devices/\1.c +(audio|controller|datetime|file|mouse|screen|system|console)\.$O:R: src/devices/\1.c $CC $CFLAGS -Isrc -o $target src/devices/$stem1.c nuke:V: clean diff --git a/src/devices/audio.h b/src/devices/audio.h @@ -12,6 +12,11 @@ WITH REGARD TO THIS SOFTWARE. typedef signed int Sint32; + +#define AUDIO_VERSION 1 +#define AUDIO_DEIMASK 0x0000 +#define AUDIO_DEOMASK 0x0000 + #define SAMPLE_FREQUENCY 44100 #define POLYPHONY 4 diff --git a/src/devices/console.c b/src/devices/console.c @@ -0,0 +1,40 @@ +#include <stdio.h> +#include <stdlib.h> + +#include "../uxn.h" +#include "console.h" + +/* +Copyright (c) 2022-2023 Devine Lu Linvega, Andrew Alderwick + +Permission to use, copy, modify, and distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE. +*/ + +int +console_input(Uxn *u, char c, int type) +{ + Uint8 *d = &u->dev[0x10]; + d[0x2] = c; + d[0x7] = type; + return uxn_eval(u, PEEK2(d)); +} + +void +console_deo(Uint8 *d, Uint8 port) +{ + switch(port) { + case 0x8: + fputc(d[port], stdout); + fflush(stdout); + return; + case 0x9: + fputc(d[port], stderr); + fflush(stderr); + return; + } +} +\ No newline at end of file diff --git a/src/devices/console.h b/src/devices/console.h @@ -0,0 +1,22 @@ +/* +Copyright (c) 2022 Devine Lu Linvega, Andrew Alderwick + +Permission to use, copy, modify, and distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE. +*/ + +#define CONSOLE_VERSION 1 +#define CONSOLE_DEIMASK 0x0000 +#define CONSOLE_DEOMASK 0x0000 + +#define CONSOLE_STD 0x1 +#define CONSOLE_ARG 0x2 +#define CONSOLE_EOA 0x3 +#define CONSOLE_END 0x4 + +int console_input(Uxn *u, char c, int type); +void console_deo(Uint8 *d, Uint8 port); diff --git a/src/devices/controller.h b/src/devices/controller.h @@ -9,6 +9,10 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE. */ +#define CONTROL_VERSION 1 +#define CONTROL_DEIMASK 0x0000 +#define CONTROL_DEOMASK 0x0000 + void controller_down(Uxn *u, Uint8 *d, Uint8 mask); void controller_up(Uxn *u, Uint8 *d, Uint8 mask); void controller_key(Uxn *u, Uint8 *d, Uint8 key); diff --git a/src/devices/datetime.h b/src/devices/datetime.h @@ -9,4 +9,8 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE. */ +#define DATETIME_VERSION 1 +#define DATETIME_DEIMASK 0x0000 +#define DATETIME_DEOMASK 0x0000 + Uint8 datetime_dei(Uxn *u, Uint8 addr); diff --git a/src/devices/file.h b/src/devices/file.h @@ -9,6 +9,10 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE. */ +#define FILE_VERSION 1 +#define FILE_DEIMASK 0x0000 +#define FILE_DEOMASK 0x0000 + #define POLYFILEY 2 #define DEV_FILE0 0xa diff --git a/src/devices/mouse.h b/src/devices/mouse.h @@ -9,6 +9,11 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE. */ + +#define MOUSE_VERSION 1 +#define MOUSE_DEIMASK 0x0000 +#define MOUSE_DEOMASK 0x0000 + void mouse_down(Uxn *u, Uint8 *d, Uint8 mask); void mouse_up(Uxn *u, Uint8 *d, Uint8 mask); void mouse_pos(Uxn *u, Uint8 *d, Uint16 x, Uint16 y); diff --git a/src/devices/screen.h b/src/devices/screen.h @@ -10,6 +10,10 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE. */ +#define SCREEN_VERSION 1 +#define SCREEN_DEIMASK 0x0000 +#define SCREEN_DEOMASK 0x0000 + typedef struct UxnScreen { int width, height, x1, y1, x2, y2; Uint32 palette[4], *pixels; diff --git a/src/devices/system.c b/src/devices/system.c @@ -96,32 +96,6 @@ system_deo(Uxn *u, Uint8 *d, Uint8 port) } } -/* Console */ - -int -console_input(Uxn *u, char c, int type) -{ - Uint8 *d = &u->dev[0x10]; - d[0x2] = c; - d[0x7] = type; - return uxn_eval(u, PEEK2(d)); -} - -void -console_deo(Uint8 *d, Uint8 port) -{ - switch(port) { - case 0x8: - fputc(d[port], stdout); - fflush(stdout); - return; - case 0x9: - fputc(d[port], stderr); - fflush(stderr); - return; - } -} - /* Errors */ int diff --git a/src/devices/system.h b/src/devices/system.h @@ -9,16 +9,13 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE. */ -#define RAM_PAGES 0x10 +#define SYSTEM_VERSION 1 +#define SYSTEM_DEIMASK 0x0000 +#define SYSTEM_DEOMASK 0x0000 -#define CONSOLE_STD 0x1 -#define CONSOLE_ARG 0x2 -#define CONSOLE_EOA 0x3 -#define CONSOLE_END 0x4 +#define RAM_PAGES 0x10 int system_load(Uxn *u, char *filename); void system_inspect(Uxn *u); int system_error(char *msg, const char *err); void system_deo(Uxn *u, Uint8 *d, Uint8 port); -int console_input(Uxn *u, char c, int type); -void console_deo(Uint8 *d, Uint8 port); diff --git a/src/uxncli.c b/src/uxncli.c @@ -3,6 +3,7 @@ #include "uxn.h" #include "devices/system.h" +#include "devices/console.h" #include "devices/file.h" #include "devices/datetime.h" diff --git a/src/uxnemu.c b/src/uxnemu.c @@ -10,6 +10,7 @@ #pragma clang diagnostic ignored "-Wtypedef-redefinition" #include <SDL.h> #include "devices/system.h" +#include "devices/console.h" #include "devices/screen.h" #include "devices/audio.h" #include "devices/file.h"