diff options
| author | user <user@clank> | 2026-07-18 22:19:59 +0200 |
|---|---|---|
| committer | user <user@clank> | 2026-07-18 22:19:59 +0200 |
| commit | c2b512e803285223959e0a97601c017730d1b0bb (patch) | |
| tree | 8cb28702cffcfccce8a244d7d5bfabb0424c30a3 /src/syscall.asm | |
| parent | demo: boot through the CGB BIOS + double-speed ROM in the README gif (diff) | |
| download | gbos-c2b512e803285223959e0a97601c017730d1b0bb.tar.gz gbos-c2b512e803285223959e0a97601c017730d1b0bb.tar.xz gbos-c2b512e803285223959e0a97601c017730d1b0bb.zip | |
term+libc: batched write rendering - one tile render per write(), 2.3x lines
sys_write sets wBatch; render_cursor_tile - the single choke point all
of term_putc's visible mutations pass through - then marks a dirty
span (per LINE-SLOT, so spans survive scroll rotation for free)
instead of rendering. term_write_end renders every dirty tile exactly
once, then the cursor. Scrolls stay immediate (blank rebuild is cheap
and artifact-free); file-bound writes flush for free.
The enabler is in libc: puts() was a SYS_PUTC trap PER CHARACTER, so
almost no console output ever went through sys_write. It now issues
one SYS_WRITE for the whole string - one trap, one batch, and every
line-printer (echo, irc, the shell) gets the batched path.
Measured: 37-char write = 128k cycles (3.5k/char) vs ~8k/char down
the per-char trap path. Full demo passes; GIF regenerated.
Diffstat (limited to 'src/syscall.asm')
| -rw-r--r-- | src/syscall.asm | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/syscall.asm b/src/syscall.asm index 4bcb601..cab3e79 100644 --- a/src/syscall.asm +++ b/src/syscall.asm @@ -85,6 +85,8 @@ sys_write: ld a, b or a ret z ; len 0 + ld a, 1 + ld [wBatch], a ; defer terminal rendering for the whole write .loop ld a, [de] push de @@ -96,7 +98,7 @@ sys_write: inc de dec b jr nz, .loop - ret + jp term_write_end ; render each dirty tile once + the cursor ; ----------------------------------------------------------------------------- ; CurStdin / CurStdout -> A = current process PROC_STDIN / PROC_STDOUT |
