nx_chip8.nx
buildroot/runtime/nx_chip8.nx
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
imports: none
imported by: nx_chip8_font_gate.nxnx_chip8_gate.nx
structs
| none |
consts
| 2 | const O_MAGIC_4096: i64 = 4096 |
| 3 | const O_MAGIC_2048: i64 = 2048 |
| 4 | const O_MAGIC_439041101: i64 = 439041101 |
| 5 | const O_MAGIC_88172645463325252: i64 = 88172645463325252 |
| 15 | const O_MEM: i64 = 0 // 4096 guest bytes (programs load at 0x200) |
| 16 | const O_V: i64 = 4096 // 16 V registers (i64 each, hold an 8-bit value) -> 4224 |
| 17 | const O_REG: i64 = 4224 // 6 i64: I, PC, SP, DT, ST, RNG -> 4272 |
| 18 | const O_STACK: i64 = 4272 // 16-level call stack (i64) -> 4400 |
| 19 | const O_KEYS: i64 = 4400 // 16 key states 0/1 (i64) -> 4528 |
| 20 | const O_DISP: i64 = 4528 // 64*32 display pixels 0/1 (i64) -> 20912 |
| 22 | const RI_I: i64 = 0 |
| 23 | const RI_PC: i64 = 1 |
| 24 | const RI_SP: i64 = 2 |
| 25 | const RI_DT: i64 = 3 |
| 26 | const RI_ST: i64 = 4 |
| 27 | const RI_RNG: i64 = 5 |
functions
| 30 | func ch8_fw(mem: *u8, off: i64, a: i64, b: i64, c: i64, d: i64, e: i64) -> i64 called by 1: ch8_load_font |
| 35 | func ch8_load_font(base: i64) -> i64 |
| 56 | func ch8_reset(base: i64) -> i64 |
| 80 | func ch8_load(base: i64, addr: i64, byte: i64) -> i64 |
| 87 | func ch8_rand(s: i64) -> i64 called by 1: ch8_step |
| 97 | func ch8_step(base: i64) -> i64 |
| 239 | func ch8_run_frame(base: i64, cycles: i64) -> i64 calls 1: ch8_step |
| 249 | func ch8_key(base: i64, k: i64, down: i64) -> i64 |
| 254 | func ch8_reg(base: i64, xi: i64) -> i64 { let V: *i64 = (base + O_V) as *i64; return V[xi & 15] } called by 1: main |
| 255 | func ch8_vf(base: i64) -> i64 { let V: *i64 = (base + O_V) as *i64; return V[15] } called by 1: main |
| 256 | func ch8_geti(base: i64) -> i64 { let reg: *i64 = (base + O_REG) as *i64; return reg[RI_I] } |
| 257 | func ch8_getpc(base: i64) -> i64 { let reg: *i64 = (base + O_REG) as *i64; return reg[RI_PC] } |
| 258 | func ch8_pixel(base: i64, px: i64, py: i64) -> i64 { let disp: *i64 = (base + O_DISP) as *i64; return disp[py * 64 + px] } |
| 259 | func ch8_disp_off() -> i64 { return O_DISP } |
| 260 | func ch8_disp_w() -> i64 { return 64 } |
| 261 | func ch8_disp_h() -> i64 { return 32 } |