code wiki / (root) / nx_chip8.nx

nx_chip8.nx

buildroot/runtime/nx_chip8.nx

11031 B261 linesdepth 0pulls 0 transitivereach 2 importersview sourcekind librarytopic chip8
docsdependenciesstructsconstsfunctions

about

nx_chip8.nx -- Implements a CHIP-8 interpreter with framebuffer, input, timers, and memory management in a single binary.

dependencies 0 imports · 2 importers

nx_chip8.nx nx_chip8_font_gate.nx nx_chip8_gate.nx

imports: none

imported by: nx_chip8_font_gate.nxnx_chip8_gate.nx

structs

none

consts

2const O_MAGIC_4096: i64 = 4096
3const O_MAGIC_2048: i64 = 2048
4const O_MAGIC_439041101: i64 = 439041101
5const O_MAGIC_88172645463325252: i64 = 88172645463325252
15const O_MEM: i64 = 0 // 4096 guest bytes (programs load at 0x200)
16const O_V: i64 = 4096 // 16 V registers (i64 each, hold an 8-bit value) -> 4224
17const O_REG: i64 = 4224 // 6 i64: I, PC, SP, DT, ST, RNG -> 4272
18const O_STACK: i64 = 4272 // 16-level call stack (i64) -> 4400
19const O_KEYS: i64 = 4400 // 16 key states 0/1 (i64) -> 4528
20const O_DISP: i64 = 4528 // 64*32 display pixels 0/1 (i64) -> 20912
22const RI_I: i64 = 0
23const RI_PC: i64 = 1
24const RI_SP: i64 = 2
25const RI_DT: i64 = 3
26const RI_ST: i64 = 4
27const RI_RNG: i64 = 5

functions

30func ch8_fw(mem: *u8, off: i64, a: i64, b: i64, c: i64, d: i64, e: i64) -> i64
called by 1: ch8_load_font
35func ch8_load_font(base: i64) -> i64
called by 1: ch8_reset calls 1: ch8_fw
56func ch8_reset(base: i64) -> i64
called by 2: mainmain calls 1: ch8_load_font
80func ch8_load(base: i64, addr: i64, byte: i64) -> i64
called by 2: mainmain
87func ch8_rand(s: i64) -> i64
called by 1: ch8_step
97func ch8_step(base: i64) -> i64
called by 3: ch8_run_framemainmain calls 1: ch8_rand
239func ch8_run_frame(base: i64, cycles: i64) -> i64
calls 1: ch8_step
249func ch8_key(base: i64, k: i64, down: i64) -> i64
254func ch8_reg(base: i64, xi: i64) -> i64 { let V: *i64 = (base + O_V) as *i64; return V[xi & 15] }
called by 1: main
255func ch8_vf(base: i64) -> i64 { let V: *i64 = (base + O_V) as *i64; return V[15] }
called by 1: main
256func ch8_geti(base: i64) -> i64 { let reg: *i64 = (base + O_REG) as *i64; return reg[RI_I] }
called by 2: mainmain
257func ch8_getpc(base: i64) -> i64 { let reg: *i64 = (base + O_REG) as *i64; return reg[RI_PC] }
258func ch8_pixel(base: i64, px: i64, py: i64) -> i64 { let disp: *i64 = (base + O_DISP) as *i64; return disp[py * 64 + px] }
called by 2: mainmain
259func ch8_disp_off() -> i64 { return O_DISP }
260func ch8_disp_w() -> i64 { return 64 }
261func ch8_disp_h() -> i64 { return 32 }