Devlog — Snake, Breakout, a Smarter Shell, and Build Hygiene
This week I added two new games (Snake and Breakout, bringing the total to seven), expanded the shell with new built-ins and command history, and cleaned up the build system. Everything boots and runs in QEMU.
Snake
The ring buffer approach makes movement O(1) instead of O(n):
uint16_t s_body[SN_CAP]; /* ring buffer of cell indices */
int s_head, s_len;
Input and movement run on separate clocks. Input latches every 33 ms, movement every 130 - 4×score ms (minimum 60 ms). This way no keypresses drop and difficulty scales naturally.
The grid is 16 pixel cells, clamped to window size. Apples spawn via rejection sampling. Filling the entire board wins the round.
Breakout
26.6 fixed point physics handles shallow angles that integer pixels would quantise to zero. Paddle english depends on where you hit it:
int off = bx - g->k_px;
g->k_bvy = -g->k_bvy;
g->k_bvx = (off << 6) / (pw / 6);
Ball starts stuck to the paddle, launches with Space. Three lives, then game over.
Integration
Adding two games touched almost no window-manager code. Two enum entries in games.h, two lines per dispatch switch in games.c, and the Start menu entry in taskbar.c. The WM handles everything else automatically.
Shell Improvements
Added five new built-ins: free, uptime, history, ver, and fixed echo to print blank lines. Terminal got uptime too.
One Version String
#define PEFIA_VERSION "pefiaOS 0.3 (Stardance)"
All three places that display version now build from this single define.
Build Fixes
Fixed header dependency tracking:
CFLAGS += -MMD -MP
-include $(OBJS:.o=.d)
Editing a header now correctly rebuilds only the objects that include it. Cleaned up boot.asm trailing whitespace too.
Testing
Verified in my virtual machine: both games launch and play correctly, Terminal shows the new version string, all shell commands work.
Seven games on a kernel I wrote from scratch!! :D
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.