From 4d752ef67cfebccf22417da9e47e2e94e14c9687 Mon Sep 17 00:00:00 2001 From: Gelthor Date: Fri, 4 Sep 2026 15:25:40 +0100 Subject: [PATCH] Added initial draft of globals and errno --- errno.asm | 24 ++++++++++++++++++++++++ globals.asm | 18 ++++++++++++++++++ start.asm | 4 ++++ 3 files changed, 46 insertions(+) create mode 100755 errno.asm create mode 100755 globals.asm create mode 100755 start.asm diff --git a/errno.asm b/errno.asm new file mode 100755 index 0000000..6f2bfb3 --- /dev/null +++ b/errno.asm @@ -0,0 +1,24 @@ +; Error numbers should be 16 bit ODD numbers, so they can be loaded as immediates +; and can be checked with: +; +; qcall falible_function +; jne falible_ok ; Jump no error +; ; handle error +; falible_ok: +; ; Happy path +; ; ... +; OR +; qcall falible_function +; je handle_error ; Jump if error +; ; Happy path +; ; ... +; handle_error: +; ; handle error + +pub const OK = 0x0000 +pub const SCREEN_INVALID_MODE = 0x0001 +pub const SCREEN_INVALID_WIDTH = 0x0003 +pub const SCREEN_FB_TOO_SMALL = 0x0005 + +; Extended error codes, these would require loading a 32 bit value. +pub const EXT_OK = 0x00000000 \ No newline at end of file diff --git a/globals.asm b/globals.asm new file mode 100755 index 0000000..9dc0df4 --- /dev/null +++ b/globals.asm @@ -0,0 +1,18 @@ +; Addresses of global variables + +; If not double buffering these point to the same buffer +pub const FB_DISPLAY_PTR = 16 ; U32 Currently displayed buffer +pub const FB_DRAW_PTR = 20 ; U32 Draw to this buffer +pub const FRAME_BUFFER_SIZE = 24 ; U32 +pub const PIXEL_WIDTH = 28 ; U16 +pub const PIXEL_HEIGHT = 30 ; U16 + +; Log2 of width in pixels, e.g. +; * 10 => 1024 * 768 +pub const LOG_WIDTH = 32 ; U8 + +pub const BYTES_PER_PIXEL = 33 ; U8 +; Log2 of bytes per pixel +; * 0 => 8 bits per pixel +; * 2 => 32 bits per pixel +pub const LOG_BPP = 34 ; U8 diff --git a/start.asm b/start.asm new file mode 100755 index 0000000..4c7f7f2 --- /dev/null +++ b/start.asm @@ -0,0 +1,4 @@ +@0 ; Reserve space for globals + +jmp 0x100 ; jump over them +@0x100 ; start of user code \ No newline at end of file