code wiki / _hdl_build / nx_game_gallery.nx
nx_game_gallery.nx source
↩ module page · 106 lines · 9549 B
1// nx_game_gallery.nx -- SOVEREIGN games-gallery emitter for nishifamily.com/games. Builds a SELF-CONTAINED
2// HTML page that SHOWS the ecosystem's game-genre coverage: each genre's REAL rendered frame inlined as a
3// base64 data: URI (no separate image files to serve), plus links to the wasm-playable titles. This is the
4// operator's "let me SEE the growth" page. Data-driven: add a frame()/play() call as genres land. Reuses our
5// own nx_base64 encoder + nx_png frames. Sovereign (no JS logic, the images are static data URIs).
6// usage: nx_game_gallery [out.html] (default knowledge/games.html) license_tier: ORIGINAL expect_exit: 0
7import "nx_syscalls.nx"
8import "nx_base64.nx"
9
10func w(fd: i64, s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(fd, s, n); return 0 }
11
12// a FRAME card: inline the genre's rendered PNG as a data: URI. Returns 1 if the frame was found+embedded.
13func frame(fd: i64, title: *u8, png_path: *u8, blurb: *u8) -> i64 {
14 let pl: *i64 = sys_mmap(16) as *i64
15 let png: *u8 = sys_read_file(png_path, pl)
16 if (png as i64) == 0 { return 0 }
17 let pnglen: i64 = pl[0]
18 let b64: *u8 = sys_mmap(pnglen*2 + 64)
19 let b64len: i64 = b64_encode(png, pnglen, b64)
20 w(fd, "<div class='card'><div class='thumb'><img src='data:image/png;base64," as *u8)
21 sys_write(fd, b64, b64len)
22 w(fd, "' alt='" as *u8); w(fd, title); w(fd, "'></div><div class='meta'><h3>" as *u8); w(fd, title)
23 w(fd, "</h3><p>" as *u8); w(fd, blurb); w(fd, "</p><span class='tag'>live frame · sovereign · no-float</span></div></div>\n" as *u8)
24 return 1
25}
26// a PLAY card: a link to a wasm-playable title, with a gradient thumb.
27func play(fd: i64, title: *u8, href: *u8, blurb: *u8, accent: *u8) -> i64 {
28 w(fd, "<a class='card' href='" as *u8); w(fd, href)
29 w(fd, "'><div class='thumb' style='background:" as *u8); w(fd, accent)
30 w(fd, "'><span class='playbtn'>► play</span></div><div class='meta'><h3>" as *u8); w(fd, title)
31 w(fd, "</h3><p>" as *u8); w(fd, blurb); w(fd, "</p><span class='tag play'>wasm-playable · sovereign</span></div></a>\n" as *u8)
32 return 0
33}
34
35// a PLAYABLE card: the rendered frame as the thumb, wrapped in a link to the wasm playable.
36func play_frame(fd: i64, title: *u8, href: *u8, png_path: *u8, blurb: *u8) -> i64 {
37 let pl: *i64 = sys_mmap(16) as *i64
38 let png: *u8 = sys_read_file(png_path, pl)
39 if (png as i64) == 0 { return 0 }
40 let pnglen: i64 = pl[0]
41 let b64: *u8 = sys_mmap(pnglen*2 + 64)
42 let b64len: i64 = b64_encode(png, pnglen, b64)
43 w(fd, "<a class='card' href='" as *u8); w(fd, href)
44 w(fd, "'><div class='thumb'><img src='data:image/png;base64," as *u8)
45 sys_write(fd, b64, b64len)
46 w(fd, "' alt='" as *u8); w(fd, title); w(fd, "'><span class='playbtn' style='position:absolute'>►</span></div><div class='meta'><h3>" as *u8); w(fd, title)
47 w(fd, "</h3><p>" as *u8); w(fd, blurb); w(fd, "</p><span class='tag play'>wasm-playable · sovereign</span></div></a>\n" as *u8)
48 return 1
49}
50
51func main(argc: i64, argv: *i64) -> i64 {
52 var out: *u8 = "knowledge/games.html" as *u8
53 if argc >= 2 { out = argv[1] as *u8 }
54 let fd: i64 = sys_openat_wr(out, 420)
55 if fd < 0 { w(2, "gallery: open failed\n" as *u8); sys_exit(1); return 1 }
56
57 w(fd, "<!doctype html><html lang=en><head><meta charset=utf-8><meta name=viewport content='width=device-width,initial-scale=1'>" as *u8)
58 w(fd, "<title>Nishi Game Ecosystem</title><style>" as *u8)
59 w(fd, "body{margin:0;background:#0d1117;color:#e6edf3;font:15px/1.5 system-ui,-apple-system,Segoe UI,sans-serif}" as *u8)
60 w(fd, "header{padding:30px 20px;text-align:center;background:linear-gradient(135deg,#161b22,#0d1117);border-bottom:1px solid #21262d}" as *u8)
61 w(fd, "header h1{margin:0 0 6px;font-size:27px}header p{margin:4px 0;color:#9aa4b2}" as *u8)
62 w(fd, ".badge{display:inline-block;margin-top:10px;padding:5px 14px;border-radius:999px;background:#1f6f3f;color:#bdf0cf;font-weight:600;font-size:14px}" as *u8)
63 w(fd, ".grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:16px;padding:22px;max-width:1120px;margin:0 auto}" as *u8)
64 w(fd, ".card{background:#161b22;border:1px solid #21262d;border-radius:10px;overflow:hidden;transition:.15s ease;text-decoration:none;color:inherit;display:block}" as *u8)
65 w(fd, ".card:hover{border-color:#3b82f6;transform:translateY(-2px)}" as *u8)
66 w(fd, ".thumb{background:#080a0e;display:flex;align-items:center;justify-content:center;height:150px;position:relative}" as *u8)
67 w(fd, ".thumb img{width:100%;height:100%;object-fit:contain;image-rendering:pixelated}" as *u8)
68 w(fd, ".playbtn{color:#fff;font-weight:700;text-shadow:0 1px 3px rgba(0,0,0,.5);font-size:16px}" as *u8)
69 w(fd, ".meta{padding:13px}.meta h3{margin:0 0 4px;font-size:16px}.meta p{margin:0 0 9px;color:#9aa4b2;font-size:13px}" as *u8)
70 w(fd, ".tag{font-size:11px;color:#6e7681}.tag.play{color:#5aa0d2}" as *u8)
71 w(fd, "footer{text-align:center;padding:26px;color:#6e7681;font-size:13px;border-top:1px solid #21262d}" as *u8)
72 w(fd, "</style></head><body>" as *u8)
73 w(fd, "<header><h1>Nishi Game Ecosystem</h1>" as *u8)
74 w(fd, "<p>Every game built sovereignly — our own compiler & assembler (nx_cc → nxasm), integer / no-float, no third-party engine.</p>" as *u8)
75 w(fd, "<p style='color:#c8a96a'>NEW: a Diablo-generation graphics engine — isometric world, 2.5D walls, shaded sprites & dynamic torch lighting.</p>" as *u8)
76 w(fd, "<span class='badge'>17 / 17 open-source genres covered · live gated evidence</span></header><div class='grid'>" as *u8)
77
78 var n: i64 = 0
79 // --- FEATURED: the new Diablo-generation isometric ARPG (graphics-engine showcase) ---
80 play_frame(fd, "ARPG: Sanctuary ►" as *u8, "arpg.html" as *u8, "knowledge/nx_wasm_diablo_native.png" as *u8, "NEW — isometric dungeon · click-to-move · dynamic torch-follow lighting · fight the fallen" as *u8)
81 // --- wasm-playable titles ---
82 play(fd, "Nishi Arcade" as *u8, "arcade.html" as *u8, "Action — collect-class, integer raster, no canvas-draw" as *u8, "linear-gradient(135deg,#1b5e3a,#5ad27a)" as *u8)
83 play(fd, "Nishi 2048" as *u8, "2048.html" as *u8, "Puzzle — sliding-tile merge logic, sovereign-font numbers" as *u8, "linear-gradient(135deg,#b8893a,#edc850)" as *u8)
84 play(fd, "Nishi Platformer" as *u8, "platformer.html" as *u8, "Platformer — integer jump physics, scaffolded from the catalog" as *u8, "linear-gradient(135deg,#1d3a5e,#5aa0d2)" as *u8)
85 play(fd, "Voxel World" as *u8, "voxelworld/" as *u8, "First-Person — navigable voxel world, hardware-f32 wasm" as *u8, "linear-gradient(135deg,#2a5e2a,#7ac86a)" as *u8)
86 // --- genres built this session (live rendered frames, gated playthroughs) ---
87 play_frame(fd, "Shoot ’em up ►" as *u8, "shmup.html" as *u8, "knowledge/nx_wasm_shmup_native.png" as *u8, "PLAYABLE — ←→ move, Space to shoot, endless waves & score" as *u8)
88 play_frame(fd, "Tower Defence ►" as *u8, "td.html" as *u8, "knowledge/nx_wasm_td_native.png" as *u8, "PLAYABLE — CLICK to build towers, defend the lane, survive escalating waves" as *u8)
89 play_frame(fd, "Racing ►" as *u8, "racing.html" as *u8, "knowledge/nx_wasm_racing_native.png" as *u8, "PLAYABLE — ←→ steer through endless traffic, distance score" as *u8)
90 n = n + frame(fd, "Turn-Based Strategy" as *u8, "knowledge/nx_game_tbs.png" as *u8, "grid tactics — move toward the foe, adjacency combat, HP" as *u8)
91 play_frame(fd, "Sport: Pong ►" as *u8, "pong.html" as *u8, "knowledge/nx_wasm_pong_native.png" as *u8, "PLAYABLE — ↑↓ paddle, spin physics, beat the AI" as *u8)
92 play_frame(fd, "City-Building ►" as *u8, "city.html" as *u8, "knowledge/nx_wasm_city_native.png" as *u8, "PLAYABLE — CLICK toolbar + grid to build; balance food & gold to grow population" as *u8)
93 play_frame(fd, "Adventure ►" as *u8, "adventure.html" as *u8, "knowledge/nx_wasm_adventure_native.png" as *u8, "PLAYABLE — WASD through the maze, grab the key, open the door" as *u8)
94 n = n + frame(fd, "Real-Time Strategy" as *u8, "knowledge/nx_game_rts.png" as *u8, "gather → build an army → destroy the enemy base" as *u8)
95 n = n + frame(fd, "Sandbox" as *u8, "knowledge/nx_game_sandbox.png" as *u8, "freeform place/remove typed blocks — build anything" as *u8)
96 play_frame(fd, "Third-Person ►" as *u8, "explorer.html" as *u8, "knowledge/nx_wasm_thirdperson_native.png" as *u8, "PLAYABLE — WASD explore, follow-camera, collect & reach the goal" as *u8)
97 n = n + frame(fd, "Business / Tycoon" as *u8, "knowledge/nx_game_tycoon.png" as *u8, "fluctuating market — buy low, sell high, grow cash" as *u8)
98
99 w(fd, "</div><footer>Genre coverage measured by <code>nx_game_genre_census</code>: <b>17 / 17 EXCEEDS</b>, fabricated-genre neg-control stays ABSENT (liar-killed). " as *u8)
100 w(fd, "Each frame is a real, gated, deterministic playthrough rendered by the ecosystem — sovereign, integer, no float.</footer></body></html>" as *u8)
101 sys_close(fd)
102 w(1, "gallery: wrote " as *u8); w(1, out); w(1, " with " as *u8)
103 let dig: *u8 = sys_mmap(8); dig[0] = (48 + n) as u8; sys_write(1, dig, 1)
104 w(1, " embedded frames + 4 playable cards\n" as *u8)
105 sys_exit(0); return 0
106}