all repos — xyw @ 0fdb058f1a0cf7aaaab15c67f5113657fa6ca42d

A minimal virtual machine and assembler for terminals.

Implemented preferred width/height, fixed assembler issues.
h3rald h3rald@h3rald.com
Wed, 07 Jan 2026 13:51:02 +0100
commit

0fdb058f1a0cf7aaaab15c67f5113657fa6ca42d

parent

22fff66e4740a575cab8d813b2d8d6be68022cd2

2 files changed, 13 insertions(+), 13 deletions(-)

jump to
M examples/window.xywexamples/window.xyw

@@ -8,7 +8,7 @@ .string "Test Program" ; title

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

@@ -322,14 +322,16 @@ {

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++] + 1; + p++; + width = (xyw_memory[p] > 0 && xyw_memory[p]) ? xyw_memory[p] + 1 : MAX_WIDTH; + p++; + height = (xyw_memory[p] > 0 && xyw_memory[p]) ? xyw_memory[p] + 1 : MAX_HEIGHT; + p++; xyw_dbg("- width: %d\n", width); - height = xyw_memory[p++] + 1; xyw_dbg("- height: %d\n", height); } }

@@ -367,21 +369,20 @@ process_metadata();

// Set direct page to device page by default xyw_memory[SYSTEM_PAGE] = 0xff; // Initialize fenster - 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; - } + uint32_t buf[width * height]; struct fenster f = {.title = title, .width = width, .height = height, .buf = buf}; fenster_open(&f); + xyw_byte paused = 0; while (fenster_loop(&f) == 0 && xyw_memory[SYSTEM_STATE] && *pc < SYSTEM_MEMORY_START) { - xyw_dbg("PC: %04X -> %02X (%s) [U:%02X|S:%02X|X:%02X|Y:%02X|XW:%04X|YW:%04X]\n", *pc, xyw_memory[*pc], xyw_instructions[xyw_memory[*pc] & 0x1F], *u, *s, *x, *y, *xw, *yw); + if (!paused) + { + xyw_dbg("PC: %04X -> %02X (%s) [U:%02X|S:%02X|X:%02X|Y:%02X|XW:%04X|YW:%04X]\n", *pc, xyw_memory[*pc], xyw_instructions[xyw_memory[*pc] & 0x1F], *u, *s, *x, *y, *xw, *yw); + } switch (xyw_memory[*pc]) { // clang-format off - /* BRK */ case 0x00: return 0; // Halting execution for now + /* BRK */ case 0x00: (*pc)--; paused = 1; break; // Stop at current instruction, keep loop running /* PSH */ OPC_SR1(0x01, , if (rx||ry) { PUSH(ARG); } else { (*pc)++; PUSH(READ(*pc)); if (w) { (*pc)++; } }) /* POP */ OPC_SR1(0x02, , if (rx||ry) { SET(POP()); } else { POP(); } ); /* CLR */ OPC_SR1(0x03, , SET(0));

@@ -421,6 +422,5 @@ // 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; }