all repos — xyw @ d24943cc0a59101c503859b02a03a8fa016cbdf6

A minimal virtual machine and assembler for terminals.

Added stub for display device.
h3rald h3rald@h3rald.com
Fri, 19 Dec 2025 11:39:18 +0100
commit

d24943cc0a59101c503859b02a03a8fa016cbdf6

parent

85f7ba0ea6622afd4c390df0efcca6368072d84f

5 files changed, 50 insertions(+), 2 deletions(-)

jump to
M MakefileMakefile

@@ -1,7 +1,7 @@

CC = gcc CFLAGS = -Wall -Wextra -g -SOURCES = xyw.c xywasm.c xywrun.c devices/console.c devices/clock.c -OBJS = xyw.o xywasm.o xywrun.o devices/console.o devices/clock.o +SOURCES = xyw.c xywasm.c xywrun.c devices/console.c devices/clock.c devices/display.c +OBJS = xyw.o xywasm.o xywrun.o devices/console.o devices/clock.o devices/display.o # Detect platform for fenster build flags UNAME_S := $(shell uname -s 2>/dev/null)

@@ -41,6 +41,9 @@ $(CC) $(CFLAGS) -c devices/console.c -o devices/console.o

devices/clock.o: devices/clock.c xyw.h $(CC) $(CFLAGS) -c devices/clock.c -o devices/clock.o + +devices/display.o: devices/display.c xyw.h + $(CC) $(CFLAGS) -c devices/display.c -o devices/display.o clean: rm -f xyw xyw.exe $(OBJS)
A devices/display.c

@@ -0,0 +1,24 @@

+#include <stdio.h> +#include "../xyw.h" + +/* display device */ +#define DISPLAY_WIDTH 0x40 +#define DISPLAY_HEIGHT 0x41 +#define DISPLAY_FILL 0x42 +#define DISPLAY_X 0x43 +#define DISPLAY_Y 0x44 +#define DISPLAY_ON_RENDER 0x45 + +void display_output(xyw_byte *data, xyw_byte addr, xyw_byte *error) +{ + (void)error; + (void)data; + (void)addr; +} + +void display_input(xyw_byte *data, xyw_byte addr, xyw_byte *error) +{ + (void)error; + (void)data; + (void)addr; +}
A devices/display.h

@@ -0,0 +1,4 @@

+#include "../xyw.h" + +void display_output(xyw_byte *data, xyw_byte addr, xyw_byte *error); +void display_input(xyw_byte *data, xyw_byte addr, xyw_byte *error);
M examples/window.xywexamples/window.xyw

@@ -1,1 +1,15 @@

.include "devices.xyw" +; vm will skip the first 3 bytes +; and try to process metadata wrapped by --- +init JMPw +; metadata +.string "---" ; metadata marker +.string "Test Program" ; title +.string "Just a test program" ; description +.string "by H3RALD" ; author +.string "2025-12-18" ; date +.byte $ff $20 ; preferred width and height +.string "---" ; metadata marker + +.label init +; actual program starts here
M xywrun.cxywrun.c

@@ -5,6 +5,7 @@ #include "xyw.h"

#include "devices/console.h" #include "devices/clock.h" +#include "devices/display.h" #define MEMORY_SIZE 0xffff #define STACK_SIZE 0xff

@@ -261,6 +262,8 @@ // Console device

{&xyw_memory[0xff10], 0, 0, console_output}, // Clock device {&xyw_memory[0xff20], clock_init, clock_input, 0}, + // Display device + {&xyw_memory[0xff40], 0, display_input, display_output}, // ... }; // clang-format on