velxio/test/test_custom_chips/sdk/examples/reset-gen.c

24 lines
911 B
C
Raw Normal View History

feat(chipbus): Galaksija home computer gallery example + browser perf throttle Ships the full Galaksija (1983 Z80 home computer) as a runnable Retro gallery example, plus the pieces needed to run a multi-chip bus live in the browser. Gallery example (examples-retro-intel.ts, id 'galaksija-z80-computer'): Z80 + galaksija-rom (public-domain ROM A+B) + ram-64k + inverter (A13 decode) + galaksija-display + a power-on reset chip, wired chip-to-chip over the bus (76 wires), no board. Click Resume and it boots the real ROM to the "READY" prompt on the green display. Chip wasm is embedded (wasmBase64) so it runs without a backend compile. - ChipRuntime.tickTimers gains a wall-clock budget (CustomChipPart passes 6 ms): a faithful-but-slow event-driven bus can't run a real-time CPU in one animation frame, so without a cap a Z80 fetching over the settle kernel froze the tab. With the budget the sim advances slower than real time (boots over a few seconds) and the UI stays responsive; fast single-chip examples finish under budget and are unaffected. - galaksija-display: blits its framebuffer on a ~30 fps timer instead of on every character write, so a clear-screen burst doesn't flood the canvas. - reset-gen: power-on reset (pulses RESET high, ties WAIT/BUSREQ/INT/NMI high) so the machine boots on Resume without a manual reset. - chipbus flag now defaults ON (override with ?chipbus=off): chip-to-chip buses are a core capability; single-chip and board nets never take this path, so the only thing enabled is multi-chip buses, previously broken. Verified live in the browser: the example boots and renders "@'READY" with the ">_" prompt, responsive. Full suite 2084 pass (5 pre-existing, unrelated env failures). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-05 23:49:33 +07:00
/*
* reset-gen power-on reset + control-line pull-ups for a Z80 bus computer
* (Phase 3, project/multichip-bus/). Holds RESET low at power-on, then drives
* it HIGH after ~2 ms (a rising edge that releases the CPU). Ties WAIT, BUSREQ,
* INT and NMI high (deasserted) so the CPU runs freely. Lets a multi-chip Z80
* machine boot on its own when the user clicks Run.
*/
#include "velxio-chip.h"
static vx_pin reset_;
static vx_timer t;
static void release(void* ud) { (void)ud; vx_pin_write(reset_, 1); }
void chip_setup(void) {
reset_ = vx_pin_register("RESET", VX_OUTPUT_LOW); /* hold CPU in reset */
vx_pin_register("WAIT", VX_OUTPUT_HIGH);
vx_pin_register("BUSREQ", VX_OUTPUT_HIGH);
vx_pin_register("INT", VX_OUTPUT_HIGH);
vx_pin_register("NMI", VX_OUTPUT_HIGH);
t = vx_timer_create(release, 0);
vx_timer_start(t, 2000000ULL, false); /* one-shot, ~2 ms */
}