/* StarForth — Steady-State Virtual Machine Runtime Copyright (c) 2023–2025 Robert A. James All rights reserved. Licensed under the StarForth License, Version 1.0 */ /* framebuffer_words.c — raw framebuffer hardware-boundary FORTH words * (FABRIC-0.md item 4.3.3). Kernel-only; no-op on hosted builds. */ #include "include/framebuffer_words.h" #include "../../include/log.h" #include "../../include/word_registry.h" #ifdef __STARKERNEL__ #include "starkernel/framebuffer.h" #endif /* PLOT ( x y color -- ) : raw raster pixel write, top-left origin, Y-down. * No Cartesian awareness -- that is capsules/fabric.4th's job. */ static void fbw_plot(VM *vm) { if (vm->dsp < 2) { log_message(LOG_ERROR, "PLOT: Stack underflow"); vm->error = 1; return; } cell_t color = vm_pop(vm); cell_t y = vm_pop(vm); cell_t x = vm_pop(vm); #ifdef __STARKERNEL__ fb_put_pixel((uint32_t)x, (uint32_t)y, (uint32_t)color); #else (void)x; (void)y; (void)color; #endif } /* FB-WIDTH ( -- n ) */ static void fbw_width(VM *vm) { #ifdef __STARKERNEL__ vm_push(vm, (cell_t)fb_width()); #else vm_push(vm, 0); #endif } /* FB-HEIGHT ( -- n ) */ static void fbw_height(VM *vm) { #ifdef __STARKERNEL__ vm_push(vm, (cell_t)fb_height()); #else vm_push(vm, 0); #endif } void register_framebuffer_words(VM *vm) { register_word(vm, "PLOT", fbw_plot); register_word(vm, "FB-WIDTH", fbw_width); register_word(vm, "FB-HEIGHT", fbw_height); }