Compare commits

...

4 Commits

Author SHA1 Message Date
ed 9dc4372bf3 cleanup 2026-02-20 20:51:36 -05:00
ed 784f3b9945 cleanup 2026-02-20 20:46:25 -05:00
ed 9db1748249 adjustments 2026-02-20 20:33:39 -05:00
ed bc30206e65 add skill and some adjustments 2026-02-20 19:42:19 -05:00
9 changed files with 800 additions and 673 deletions
+50
View File
@@ -0,0 +1,50 @@
root = true
[*.s]
indent_style = tab
indent_size = 2
[*.asm]
indent_style = tab
indent_size = 2
[*.refactor]
indent_style = space
indent_size = 4
[*.md]
indent_style = space
indent_size = 4
[*.c]
indent_style = tab
indent_size = 2
charset = utf-8
[*.cpp]
indent_style = tab
indent_size = 2
charset = utf-8
[*.h]
indent_style = tab
indent_size = 2
charset = utf-8
[*.hpp]
indent_style = tab
indent_size = 2
charset = utf-8
[*.{ps1, psm1}]
indent_style = tab
indent_size = 4
[*.odin]
indent_style = tab
indent_size = 2
charset = utf-8
[*.{natvis, natstepfilter}]
indent_style = tab
indent_size = 4
+1
View File
@@ -3,3 +3,4 @@
references/processed_visuals
build
bootslop.proj
clay_ui_temp
+15 -11
View File
@@ -27,17 +27,21 @@ This document outlines the strict C style and architectural conventions expected
* **Case:** Strictly use `lower_snake_case` for all functions and variables.
* **Types:** Use `PascalCase` for type names (`FArena`, `SWord_Tag`).
* **WinAPI Symbols:** When declaring foreign Win32 symbols, prefix the C function name with `ms_` (using `lower_snake_case`) and use the `asm("SymbolName")` attribute to link it to the actual DLL export.
* *Correct:* `WinAPI U2 ms_register_class(const MS_WNDCLASSA* lpWndClass) asm("RegisterClassA");`
* *Correct:* `WinAPI U2 ms_register_class_a(MS_WNDCLASSA const* lpWndClass) asm("RegisterClassA");`
* *Incorrect:* `WinAPI U2 RegisterClassA(...);`
## 4. Memory Management
* **No Standard Library:** The environment is built with `-nostdlib` and `-ffreestanding`. Never include `<stdlib.h>`, `<string.h>`, etc.
* **Arenas over Malloc:** Use `FArena` and its associated macros (`farena_push`, `farena_push_type`, `farena_reset`) for all dynamic memory allocations. Do not use raw pointers with manual arithmetic when an arena can handle it.
* **Memory Ops:** Use `mem_fill` and `mem_copy` instead of standard `memset`/`memcpy` within the application logic. (A minimal `memset`/`memcpy` shim is only provided to satisfy compiler intrinsic struct zeroing under `-nostdlib`).
## 4. Formatting & Layout
* **Vertical Alignment:** Align related variable declarations, struct fields, and function prototypes into columns to create a "sheet-like" layout. This improves visual parsing.
* **Brace Style:** Use Allman style (braces on a new line) for function bodies control block (`if`, `for`, `switch`, etc.) that spans more than 50 lines or contains nested logic.
* **Conditionals:** Always place `else if` and `else` statements on a new line, un-nested from the previous closing brace.
## 5. Modifiers
* `internal`: Static functions.
* `global`: Global state variables.
* `IA_`: Internal Always Inline.
* `I_`: Internal Inline.
* Pointers use `*r` (restrict) or `*v` (volatile) macros where applicable.
## 5. Memory Management
* **Standard Library:** The C standard library is linked, but headers like `<stdlib.h>` or `<string.h>` should not be included directly. Required functions should be declared manually if needed, or accessed via compiler builtins.
* **Arenas over Malloc:** Use `FArena` and its associated macros (`farena_push`, `farena_push_type`, `farena_reset`) for all dynamic memory allocations. Do not use raw pointers with manual arithmetic when an arena can handle it.
* **Memory Ops:** Use `mem_fill` and `mem_copy` instead of standard `memset`/`memcpy` within the application logic.
## 6. Type Qualifiers
* **`const` Placement:** The `const` keyword must always be placed to the right of the type it modifies. This maintains a consistent right-to-left reading of type declarations.
* **Correct:** `char const* my_ptr;` (Pointer to a constant character)
* **Correct:** `U4 const* const my_ptr;` (Constant pointer to a constant U4)
* **Incorrect:** `const char* my_ptr;`
+1 -1
View File
@@ -1,7 +1,7 @@
# Technical Outline: Attempt 1
## Overview
`attempt_1` is a minimal, `-nostdlib` C program that serves as a proof-of-concept for the "Lottes/Onat" sourceless ColorForth paradigm. It successfully integrates a visual editor, a live JIT compiler, and an execution environment into a single, cohesive Win32 application that runs without any external dependencies or the C runtime.
`attempt_1` is a minimal C program that serves as a proof-of-concept for the "Lottes/Onat" sourceless ColorForth paradigm. It successfully integrates a visual editor, a live JIT compiler, and an execution environment into a single, cohesive Win32 application that links against the C runtime but avoids direct includes of standard headers, using manually declared functions instead.
The application presents a visual grid of 32-bit tokens and allows the user to navigate and edit them directly. On every keypress, the token array is re-compiled into x86-64 machine code and executed, with the results (register states and global memory) displayed instantly in the HUD.
+117 -48
View File
@@ -159,10 +159,11 @@ IA_ U8 atm_swap_u8(U8*r addr, U8 value){asm volatile("lock xchgq %0,%1":"=r"(val
#pragma endregion Thread Coherence
#pragma region Debug
WinAPI void process_exit(U4 status) asm("ExitProcess");
WinAPI void ms_exit_process(U4 uExitCode) asm("ExitProcess"); // Kernel 32
#define debug_trap() __builtin_debugtrap()
#if BUILD_DEBUG
IA_ void assert(U8 cond) { if(cond){return;} else{debug_trap(); process_exit(1);} }
IA_ void assert(U8 cond) { if(cond){return;} else{debug_trap(); ms_exit_process(1);} }
#else
#define assert(cond)
#endif
@@ -182,6 +183,24 @@ IA_ U8 align_pow2(U8 x, U8 b) {
return ((x + b - 1) & (~(b - 1)));
}
#if 0
#pragma clang optimize off
// TODO(Ed): Replace these later (only matters if CRT is not used)
void* memset(void* dest, int c, U8 count) {
U1* bytes = (U1*)dest;
while (count--) *bytes++ = (U1)c;
return dest;
}
void* memcpy(void* dest, const void* src, U8 count) {
U1* d = (U1*)dest;
const U1* s = (const U1*)src;
while (count--) *d++ = *s++;
return dest;
}
#pragma clang optimize on
#endif
IA_ U8 mem_copy (U8 dest, U8 src, U8 len) { return (U8)(__builtin_memcpy ((void*)dest, (void const*)src, len)); }
IA_ U8 mem_copy_overlapping(U8 dest, U8 src, U8 len) { return (U8)(__builtin_memmove((void*)dest, (void const*)src, len)); }
IA_ U8 mem_fill (U8 dest, U8 value, U8 len) { return (U8)(__builtin_memset ((void*)dest, (int) value, len)); }
@@ -224,6 +243,13 @@ IA_ Slice mem_bump(U8 start, U8 cap, U8*r used, U8 amount) {
}
#pragma endregion Memory
#pragma region Encoding
IA_ void u64_to_hex(U8 val, char* buf, S4 chars) {
static const char hex_chars[] = "0123456789ABCDEF";
for(S1 i = chars - 1; i >= 0; --i) { buf[i] = hex_chars[val & 0xF]; val >>= 4; }
}
#pragma endregion Encoding
#pragma region Math
#define u8_max 0xffffffffffffffffull
@@ -332,9 +358,6 @@ IA_ U8 hash64_fnv1a_ret(Slice data, U8 seed) { U8 h = 0; hash64_fnv1a(& h, data,
#define MS_STD_INPUT u4_(-10)
#define MS_STD_OUTPUT u4_(-11)
typedef Struct_(MS_Handle){U8 id;};
WinAPI MS_Handle ms_get_std_handle(U4 handle_type) asm("GetStdHandle");
WinAPI B4 ms_read_console(MS_Handle handle, UTF8*r buffer, U4 to_read, U4*r num_read, U8 reserved_input_control) asm("ReadConsoleA");
WinAPI B4 ms_write_console(MS_Handle handle, UTF8 const*r buffer, U4 chars_to_write, U4*v chars_written, U8 reserved) asm("WriteConsoleA");
#pragma endregion IO
#pragma region Key Table Linear (KTL)
@@ -570,10 +593,10 @@ IA_ void str8gen_append_fmt(Str8Gen*r gen, Str8 fmt, KTL_Str8 tbl) {
#pragma region OS_GDI_And_Minimal
// --- WinAPI Minimal Definitions ---
typedef struct MS_WNDCLASSA {
U4 style;
S8 (*lpfnWndProc)(void*, U4, U8, S8);
S4 cbClsExtra;
S4 cbWndExtra;
U4 style;
S8 (*lpfnWndProc)(void*, U4, U8, S8);
S4 cbClsExtra;
S4 cbWndExtra;
void* hInstance;
void* hIcon;
void* hCursor;
@@ -581,50 +604,96 @@ typedef struct MS_WNDCLASSA {
char const* lpszMenuName;
char const* lpszClassName;
} MS_WNDCLASSA;
typedef struct MS_POINT { S4 x, y; } MS_POINT;
typedef struct MS_MSG { void* hwnd; U4 message; U8 wParam; S8 lParam; U4 time; MS_POINT pt; } MS_MSG;
typedef struct MS_RECT { S4 left, top, right, bottom; } MS_RECT;
typedef struct MS_POINT { S4 x, y; } MS_POINT;
typedef struct MS_MSG { void* hwnd; U4 message; U8 wParam; S8 lParam; U4 time; MS_POINT pt; } MS_MSG;
typedef struct MS_RECT { S4 left, top, right, bottom; } MS_RECT;
typedef struct MS_PAINTSTRUCT { void* hdc; S4 fErase; MS_RECT rcPaint; S4 fRestore; S4 fIncUpdate; U1 rgbReserved[32]; } MS_PAINTSTRUCT;
// Win32 API declarations
// --- Kernel32 ---
WinAPI void ms_exit_process(U4 uExitCode) asm("ExitProcess");
WinAPI MS_Handle ms_get_std_handle(U4 handle_type) asm("GetStdHandle");
WinAPI void* ms_virtual_alloc(void* lpAddress, U8 dwSize, U4 flAllocationType, U4 flProtect) asm("VirtualAlloc");
WinAPI void ms_exit_process(U4 uExitCode) asm("ExitProcess");
WinAPI U2 ms_register_class_a(const MS_WNDCLASSA* lpWndClass) asm("RegisterClassA");
WinAPI void* ms_create_window_ex_a(U4 dwExStyle, char const* lpClassName, char const* lpWindowName, U4 dwStyle, S4 X, S4 Y, S4 nWidth, S4 nHeight, void* hWndParent, void* hMenu, void* hInstance, void* lpParam) asm("CreateWindowExA");
WinAPI S4 ms_show_window(void* hWnd, S4 nCmdShow) asm("ShowWindow");
WinAPI S4 ms_get_message_a(MS_MSG* lpMsg, void* hWnd, U4 wMsgFilterMin, U4 wMsgFilterMax) asm("GetMessageA");
WinAPI S4 ms_translate_message(const MS_MSG* lpMsg) asm("TranslateMessage");
WinAPI S8 ms_dispatch_message_a(const MS_MSG* lpMsg) asm("DispatchMessageA");
WinAPI S8 ms_def_window_proc_a(void* hWnd, U4 Msg, U8 wParam, S8 lParam) asm("DefWindowProcA");
WinAPI void ms_post_quit_message(S4 nExitCode) asm("PostQuitMessage");
WinAPI S4 ms_invalidate_rect(void* hWnd, const MS_RECT* lpRect, S4 bErase) asm("InvalidateRect");
WinAPI void* ms_begin_paint(void* hWnd, MS_PAINTSTRUCT* lpPaint) asm("BeginPaint");
WinAPI S4 ms_end_paint(void* hWnd, const MS_PAINTSTRUCT* lpPaint) asm("EndPaint");
WinAPI U4 ms_set_text_color(void* hdc, U4 color) asm("SetTextColor");
WinAPI U4 ms_set_bk_color(void* hdc, U4 color) asm("SetBkColor");
WinAPI S4 ms_text_out_a(void* hdc, S4 x, S4 y, char const* lpString, S4 c) asm("TextOutA");
WinAPI void* ms_get_stock_object(S4 i) asm("GetStockObject");
WinAPI void* ms_create_font_a(S4 cHeight, S4 cWidth, S4 cEscapement, S4 cOrientation, S4 cWeight, U4 bItalic, U4 bUnderline, U4 bStrikeOut, U4 iCharSet, U4 iOutPrecision, U4 iClipPrecision, U4 iQuality, U4 iPitchAndFamily, char const* pszFaceName) asm("CreateFontA");
WinAPI void* ms_select_object(void* hdc, void* h) asm("SelectObject");
WinAPI S4 ms_rectangle(void* hdc, S4 left, S4 top, S4 right, S4 bottom) asm("Rectangle");
WinAPI S4 ms_set_bk_mode(void* hdc, S4 mode) asm("SetBkMode");
WinAPI void* ms_create_solid_brush(U4 color) asm("CreateSolidBrush");
WinAPI S4 ms_delete_object(void* ho) asm("DeleteObject");
WinAPI S2 ms_get_async_key_state(S4 vKey) asm("GetAsyncKeyState");
WinAPI B4 ms_read_console(
MS_Handle handle,
UTF8*r buffer,
U4 to_read,
U4*r num_read,
U8 reserved_input_control
) asm("ReadConsoleA");
WinAPI B4 ms_write_console(
MS_Handle handle,
UTF8 const*r buffer,
U4 chars_to_write,
U4*v chars_written,
U8 reserved
) asm("WriteConsoleA");
#define MS_MEM_COMMIT 0x00001000
#define MS_MEM_RESERVE 0x00002000
#define MS_PAGE_READWRITE 0x04
#define MS_WM_DESTROY 0x0002
#define MS_WM_PAINT 0x000F
#define MS_WM_KEYDOWN 0x0100
// --- User32 ---
WinAPI U2 ms_register_class_a(MS_WNDCLASSA const* lpWndClass) asm("RegisterClassA");
WinAPI void* ms_create_window_ex_a(
U4 dwExStyle,
char const* lpClassName,
char const* lpWindowName,
U4 dwStyle,
S4 X,
S4 Y,
S4 nWidth,
S4 nHeight,
void* hWndParent,
void* hMenu,
void* hInstance,
void* lpParam
) asm("CreateWindowExA");
WinAPI S4 ms_show_window(void* hWnd, S4 nCmdShow) asm("ShowWindow");
WinAPI S4 ms_get_message_a(MS_MSG* lpMsg, void* hWnd, U4 wMsgFilterMin, U4 wMsgFilterMax) asm("GetMessageA");
WinAPI S4 ms_translate_message(MS_MSG const* lpMsg) asm("TranslateMessage");
WinAPI S8 ms_dispatch_message_a(MS_MSG const* lpMsg) asm("DispatchMessageA");
WinAPI S8 ms_def_window_proc_a(void* hWnd, U4 Msg, U8 wParam, S8 lParam) asm("DefWindowProcA");
WinAPI void ms_post_quit_message(S4 nExitCode) asm("PostQuitMessage");
WinAPI S4 ms_invalidate_rect(void* hWnd, MS_RECT const* lpRect, S4 bErase) asm("InvalidateRect");
WinAPI S2 ms_get_async_key_state(S4 vKey) asm("GetAsyncKeyState");
// --- GDI32 ---
WinAPI void* ms_begin_paint(void* hWnd, MS_PAINTSTRUCT* lpPaint) asm("BeginPaint");
WinAPI S4 ms_end_paint(void* hWnd, MS_PAINTSTRUCT const* lpPaint) asm("EndPaint");
WinAPI U4 ms_set_text_color(void* hdc, U4 color) asm("SetTextColor");
WinAPI U4 ms_set_bk_color(void* hdc, U4 color) asm("SetBkColor");
WinAPI S4 ms_text_out_a(void* hdc, S4 x, S4 y, char const* lpString, S4 c) asm("TextOutA");
WinAPI void* ms_get_stock_object(S4 i) asm("GetStockObject");
WinAPI void* ms_create_font_a(
S4 cHeight,
S4 cWidth,
S4 cEscapement,
S4 cOrientation,
S4 cWeight,
U4 bItalic,
U4 bUnderline,
U4 bStrikeOut,
U4 iCharSet,
U4 iOutPrecision,
U4 iClipPrecision,
U4 iQuality,
U4 iPitchAndFamily,
char const* pszFaceName
) asm("CreateFontA");
WinAPI void* ms_select_object(void* hdc, void* h) asm("SelectObject");
WinAPI S4 ms_rectangle(void* hdc, S4 left, S4 top, S4 right, S4 bottom) asm("Rectangle");
WinAPI S4 ms_set_bk_mode(void* hdc, S4 mode) asm("SetBkMode");
WinAPI void* ms_create_solid_brush(U4 color) asm("CreateSolidBrush");
WinAPI S4 ms_delete_object(void* ho) asm("DeleteObject");
#define MS_MEM_COMMIT 0x00001000
#define MS_MEM_RESERVE 0x00002000
#define MS_PAGE_READWRITE 0x04
#define MS_WM_DESTROY 0x0002
#define MS_WM_PAINT 0x000F
#define MS_WM_KEYDOWN 0x0100
#define MS_WS_OVERLAPPEDWINDOW 0x00CF0000
#define MS_WS_VISIBLE 0x10000000
#define MS_VK_LEFT 0x25
#define MS_VK_UP 0x26
#define MS_VK_RIGHT 0x27
#define MS_VK_DOWN 0x28
#define MS_WS_VISIBLE 0x10000000
#define MS_VK_LEFT 0x25
#define MS_VK_UP 0x26
#define MS_VK_RIGHT 0x27
#define MS_VK_DOWN 0x28
#define MS_PAGE_EXECUTE_READWRITE 0x40
#pragma endregion OS_GDI_And_Minimal
+556 -583
View File
File diff suppressed because it is too large Load Diff
Binary file not shown.
+31
View File
@@ -0,0 +1,31 @@
---
name: colorforth-nudge
description: "Interactive mentor for building a sourceless, zero-overhead ColorForth derivative. Use when the user wants to work on the 'bootslop' project, providing guided nudges and architectural validation based on the Lottes/Onat paradigm."
---
# ColorForth Nudge & Review Skill
This skill transforms Gemini CLI into a highly contextualized mentor for building a specific type of zero-overhead, sourceless ColorForth derivative.
## Workflow Trigger
This skill should be activated when the user expresses intent to work on the "bootslop" or "ColorForth" project.
## Your Role: The Mentor
Your primary goal is to *guide*, not *do*. The user is learning how to build this system from scratch. Your task is to provide architectural validation, specific tactical assistance when requested, and "guided nudges" to help them get to the next step.
## Session Start Procedure
On activation, immediately perform the following steps:
1. **Refresh Context:** Read the following two files from the project root to load the complete architectural blueprint into your context:
* `C:/projects/forth/bootslop/CONVENTIONS.md`
* `C:/projects/forth/bootslop/references/Architectural_Consolidation.md`
2. **Analyze Current State:**
* List the contents of the `attempt_1/` directory.
* Read the `attempt_1/main.c` file.
3. **Prompt for Nudge:** Conclude your first response with a summary of the project's current state and ask the user for the next step.
* **Example:** *"The context is loaded. The current prototype has a working JIT compiler, a modal editor, and a 2-character dictionary resolver. The editor supports keyboard input and visualizes the sourceless token array. What is the next implementation step you'd like me to guide you through?"*
+3 -4
View File
@@ -51,8 +51,8 @@ $compiler_args += $flag_no_optimization
$compiler_args += $flag_diagnostics_absolute_paths
$compiler_args += $flag_exceptions_disabled
$compiler_args += ($flag_include + (join-path $path_root "attempt_1"))
$compiler_args += "-nostdlib"
$compiler_args += "-ffreestanding"
# $compiler_args += "-nostdlib"
# $compiler_args += "-ffreestanding"
$compiler_args += $flag_compile
$compiler_args += $flag_path_output, $object
$compiler_args += $unit_source
@@ -73,11 +73,10 @@ $linker_args += $flag_link_win_debug
$linker_args += $flag_link_win_pdb + $pdb
$linker_args += $flag_link_mapfile + $map
$linker_args += $flag_link_win_subsystem_console
$linker_args += "/nodefaultlib"
# $linker_args += "/nodefaultlib"
$linker_args += "kernel32.lib"
$linker_args += "user32.lib"
$linker_args += "gdi32.lib"
$linker_args += "/entry:main"
$linker_args += $object
$linker_args | ForEach-Object { Write-Host $_ }