all repos — xyw @ 22fff66e4740a575cab8d813b2d8d6be68022cd2

A minimal virtual machine and assembler for terminals.

Processing metadata.
h3rald h3rald@h3rald.com
Wed, 07 Jan 2026 11:33:54 +0100
commit

22fff66e4740a575cab8d813b2d8d6be68022cd2

parent

3bc789df5b9584b48b5dcb5b1e17d90730eadd83

3 files changed, 42 insertions(+), 16 deletions(-)

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

@@ -16,9 +16,10 @@ (void)data;

(void)addr; } -void display_input(xyw_byte *data, xyw_byte addr, xyw_byte *error) +xyw_byte display_input(xyw_byte *data, xyw_byte addr, xyw_byte *error) { (void)error; (void)data; (void)addr; + return 0; }
M examples/window.xywexamples/window.xyw

@@ -6,9 +6,9 @@ ; metadata

.string "---" ; metadata marker .string "Test Program" ; title .string "Just a test program" ; description -.string "by H3RALD" ; author +.string "H3RALD" ; author .string "2025-12-18" ; date -.byte $ff $20 ; preferred width and height +.byte $ff $1f ; preferred width and height .string "---" ; metadata marker .label init
M xywrun.cxywrun.c

@@ -270,48 +270,67 @@ // ...

}; // clang-format on -char *title, *description, *author, *date; -xyw_byte width, height; +char *title = "xyw", *description = 0, *author = 0, *date = 0; +int width = MAX_WIDTH, height = MAX_HEIGHT; static void process_metadata() { - if ((xyw_memory[0x0003] == (0x1C | XYW_MODE_W)) && xyw_memory[0x0004] == '-' && xyw_memory[0x0005] == '-' && xyw_memory[0x0006] == '-') + if ((xyw_memory[0x0003] == (0x1C | XYW_MODE_W)) && xyw_memory[0x0004] == '-' && xyw_memory[0x0005] == '-' && xyw_memory[0x0006] == '-' && xyw_memory[0x0007] == 0) { + xyw_dbg("Metadata found\n"); // JMPw found followed by ---, read metadata - xyw_word p = 0x0007; + xyw_word p = 0x0008; title = (char *)&xyw_memory[p]; while (p < MEMORY_SIZE && xyw_memory[p] != 0) p++; if (p >= MEMORY_SIZE) - return; + { + xyw_memory[MEMORY_SIZE - 1] = 0; + p = MEMORY_SIZE - 1; + } p++; + xyw_dbg("- title: %s\n", title); description = (char *)&xyw_memory[p]; while (p < MEMORY_SIZE && xyw_memory[p] != 0) p++; if (p >= MEMORY_SIZE) - return; + { + xyw_memory[MEMORY_SIZE - 1] = 0; + p = MEMORY_SIZE - 1; + } p++; + xyw_dbg("- description: %s\n", description); author = (char *)&xyw_memory[p]; while (p < MEMORY_SIZE && xyw_memory[p] != 0) p++; if (p >= MEMORY_SIZE) - return; + { + xyw_memory[MEMORY_SIZE - 1] = 0; + p = MEMORY_SIZE - 1; + } p++; + xyw_dbg("- author: %s\n", author); date = (char *)&xyw_memory[p]; while (p < MEMORY_SIZE && xyw_memory[p] != 0) - p++; // skip date string + p++; if (p >= MEMORY_SIZE) - return; + { + xyw_memory[MEMORY_SIZE - 1] = 0; + p = MEMORY_SIZE - 1; + } p++; + xyw_dbg("- date: %s\n", date); if (p + 1 >= MEMORY_SIZE) return; - width = xyw_memory[p++]; - height = xyw_memory[p++]; + width = xyw_memory[p++] + 1; + xyw_dbg("- width: %d\n", width); + height = xyw_memory[p++] + 1; + xyw_dbg("- height: %d\n", height); } }

@@ -348,8 +367,13 @@ process_metadata();

// Set direct page to device page by default xyw_memory[SYSTEM_PAGE] = 0xff; // Initialize fenster - uint32_t buf[MAX_WIDTH * MAX_HEIGHT] = {0}; - struct fenster f = {.title = "xyw", .width = MAX_WIDTH, .height = MAX_HEIGHT, .buf = buf}; + uint32_t *buf = calloc((size_t)width * (size_t)height, sizeof(uint32_t)); + if (!buf) + { + fprintf(stderr, "Error - Could not allocate frame buffer (%dx%d)\n", width, height); + return -1; + } + struct fenster f = {.title = title, .width = width, .height = height, .buf = buf}; fenster_open(&f); while (fenster_loop(&f) == 0 && xyw_memory[SYSTEM_STATE] && *pc < SYSTEM_MEMORY_START) {

@@ -397,5 +421,6 @@ // because we are relying on the fact that pc will be incremented at the end of the loop

(*pc)++; } fenster_close(&f); + free(buf); return 0; }