cyberspace-demo: Real first-person fly-through of the Net

Replace the spinning-cube placeholder with a proper System Shock
Cyberspace fly-through (shodan.fandom.com/wiki/Cyberspace):

- Camera dragged along a gently curving data-current spline with
  banking roll and weightless bob; look direction blended toward
  straight-ahead so the vanishing point stays centered
- Octagonal tunnel rings + longitudinal ribs with depth fade and
  near-plane segment clipping; radius swells between four named
  zones (military spur / research grotto / data cistern / security
  grid) via smoothstep blends
- Wiki-canon objects recycled around a 256-unit loop: data object
  (purple cube), data fragment (yellow square + orange diamonds),
  infonode signpost, security mine, integrity restorative, ICE
  pyramid growths, and SHODAN's diamond core with Bezier tentacles
  + rotating shield ring once per loop
- NetDeck-style HUD: 3x5 bitmap font, crosshair, LNK/TRACE meters,
  zone banners, DIST/VEL/NODE readouts; Space = freeze convention
- 3x3 view matrix built per frame from the path tangent; Bresenham
  lines against the direct framebuffer, dimc() depth fading

Verified: clean build (0 warnings), 240-frame smoke, 5000-frame
soak, frame dumps inspected at five flight points.
This commit is contained in:
Dejvino
2026-11-16 21:02:10 +01:00
parent 57d79ee296
commit cebfed96a8
2 changed files with 70 additions and 57 deletions
@@ -199,10 +199,11 @@ static void drawBar(int x, int y, int w, int hgt, float frac, uint32_t c)
// Camera + data-current path
// ---------------------------------------------------------------------------
// The current flows along +Z; its center drifts like a slow river.
static float pathX(float z) { return 6.0f * sinf(z * 0.045f) + 3.0f * sinf(z * 0.013f + 1.7f); }
static float pathY(float z) { return 4.0f * sinf(z * 0.031f + 4.0f) + 2.0f * sinf(z * 0.08f); }
static float pathXdz(float z) { return 6.0f * 0.045f * cosf(z * 0.045f) + 3.0f * 0.013f * cosf(z * 0.013f + 1.7f); }
static float pathYdz(float z) { return 4.0f * 0.031f * cosf(z * 0.031f + 4.0f) + 2.0f * 0.08f * cosf(z * 0.08f); }
// (Gentle amplitudes + long wavelengths: rivers drag, they don't whip.)
static float pathX(float z) { return 3.5f * sinf(z * 0.020f) + 1.5f * sinf(z * 0.008f + 1.7f); }
static float pathY(float z) { return 2.0f * sinf(z * 0.015f + 4.0f) + 1.2f * sinf(z * 0.05f); }
static float pathXdz(float z) { return 3.5f * 0.020f * cosf(z * 0.020f) + 1.5f * 0.008f * cosf(z * 0.008f + 1.7f); }
static float pathYdz(float z) { return 2.0f * 0.015f * cosf(z * 0.015f + 4.0f) + 1.2f * 0.05f * cosf(z * 0.05f); }
// Zones: alternate narrow hallways and immense rooms (wiki: "immense rooms
// of glowing wireframe" connected by rivers of data).
@@ -257,11 +258,13 @@ static void buildView()
camY = pathY(camDist) + 0.3f * sinf(tGlobal * 0.9f); // weightless bob
camZ = camDist;
// Orientation follows the current's tangent (+z dominant).
float fx = pathXdz(camDist), fy = pathYdz(camDist);
float yaw = atan2f(fx, 1.0f);
float n = sqrtf(fx * fx + 1.0f);
float pitch = atan2f(fy, n);
// Orientation mostly follows the current's tangent, but blended toward
// straight +Z so the vanishing point stays near screen center.
float tx = pathXdz(camDist), ty = pathYdz(camDist);
const float STEER = 0.55f; // 0 = straight ahead, 1 = follow tangent fully
float yaw = atan2f(tx * STEER, 1.0f);
float n = sqrtf(tx * STEER * tx * STEER + 1.0f);
float pitch = atan2f(ty * STEER, n);
// Bank into curves, like drifting weightlessly through the current.
static float prevYaw = 0.0f;
@@ -545,7 +548,7 @@ static void drawObjInfonode(float cx, float cy, float cz, float s, float spin)
}
// Security Mine: blue sphere (billboard circles, pulsing)
static void drawObjMine(float cx, float cy, float cz, float s, float vx, float vy, float vz)
static void drawObjMine(float cx, float, float, float s, float vx, float vy, float vz)
{
float pulse = 1.0f + 0.15f * sinf(tGlobal * 3.0f + cx);
int fade = (int)(256.0f * (1.0f - 0.85f * vz / FARZ));
@@ -585,7 +588,6 @@ static void drawShodan(float wx, float wy, float wz)
float pulse = 0.65f + 0.35f * sinf(tGlobal * 2.4f);
int bright = (int)(150 + 106 * pulse);
float rot = tGlobal * 0.35f;
float c = cosf(rot), si = sinf(rot);
// rotate ring/tentacle anchor points around Y
const int NR = 8;