all repos — xyw @ 481fe7eafa064f39b9ea831d00de282712f3ef06

A minimal virtual machine and assembler for terminals.

Attempting to draw pixels.
h3rald h3rald@h3rald.com
Mon, 19 Jan 2026 14:56:54 +0100
commit

481fe7eafa064f39b9ea831d00de282712f3ef06

parent

59937d38477dd125a90bdfb890b9f58ccec1e896

5 files changed, 32 insertions(+), 20 deletions(-)

jump to
M devices/display.cdevices/display.c

@@ -1,6 +1,8 @@

#include <stdio.h> #include "../xyw.h" +#define COLOR 0xFFFFFF + /* display device */ #define DISPLAY_FILL 0x40 #define DISPLAY_X 0x41

@@ -12,6 +14,13 @@ {

(void)error; (void)data; (void)addr; + printf("Display output called: addr=%02X\n", addr); + switch (addr) + { + case DISPLAY_FILL: + fenster_pixel(&xyw_fenster, data[DISPLAY_X], data[DISPLAY_Y]) = data[DISPLAY_FILL]; + break; + } } xyw_byte display_input(xyw_byte *data, xyw_byte addr, xyw_byte *error)
M examples/devices.abs.xywexamples/devices.abs.xyw

@@ -34,12 +34,10 @@ .macro file.write $FF36

.macro file.append $FF37 ;display -.macro display.width $FF40 -.macro display.height $FF41 -.macro display.fill $FF42 -.macro display.x $FF43 -.macro display.y $FF44 -.macro display.on_render $FF45 +.macro display.fill $FF40 +.macro display.x $FF41 +.macro display.y $FF42 +.macro display.on_render $FF43 ;beeper .macro beeper.state $FF50
M examples/devices.xywexamples/devices.xyw

@@ -34,12 +34,10 @@ .macro file.write $36

.macro file.append $37 ;display -.macro display.width $40 -.macro display.height $41 -.macro display.fill $42 -.macro display.x $43 -.macro display.y $44 -.macro display.on_render $45 +.macro display.fill $40 +.macro display.x $41 +.macro display.y $42 +.macro display.on_render $43 ;beeper .macro beeper.state $50
M examples/window.xywexamples/window.xyw

@@ -12,3 +12,12 @@ .string "---" ; metadata marker

.label init ; actual program starts here +$10 display.x STB +$10 display.y STB +$1 display.fill STB +$11 display.x STB +$10 display.y STB +$1 display.fill STB +$12 display.x STB +$10 display.y STB +$1 display.fill STB
M xywrun.cxywrun.c

@@ -73,14 +73,9 @@ }

static inline xyw_byte get_device_address(xyw_word addr) { - // Should return a number between 0 and 15, add validation - xyw_byte port = (addr - DEVICE_AREA_START) % 16; - if (port >= 16) - { - *error = XYW_ERROR_DEVICE_UNAVAILABLE; - return -1; - } - return port; + // Given $FF40, it should return $40 + // TODO: verify correctness + return (xyw_byte)(addr - DEVICE_AREA_START); } //// Read/write memory helpers

@@ -123,11 +118,14 @@ }

static inline void write(xyw_word addr, xyw_byte val) { + printf("Write to addr=%04X val=%02X\n", addr, val); xyw_memory[addr] = val; int dev_num = get_device(addr); + printf("Device number: %d\n", dev_num); if (dev_num >= 0 && xyw_devices[dev_num].output) { xyw_byte dev_addr = get_device_address(addr); + printf("Device address: %02X\n", dev_addr); xyw_devices[dev_num].output(get_device_data(addr), dev_addr, error); } }