generic types, any -> opaque

This commit is contained in:
2026-07-17 11:44:05 +02:00
parent af08d1888a
commit 1471c229c2
20 changed files with 284 additions and 167 deletions

View File

@@ -14,15 +14,15 @@ extern IsKeyDown
struct CHIP8
memory: ptr
pc: i64
stack: Array
stack: Array<i64>
sp: i64
reg: ptr
I: i64
delay_timer: u8
sound_timer: u8
keyboard: Array
keyboard: Array<i64>
display: ptr
keyboard_map: Array
keyboard_map: Array<i64>
func CHIP8.init[c: CHIP8] : void
c->memory = mem.alloc(4096)
@@ -242,14 +242,14 @@ func CHIP8.step[c: CHIP8] : void
if IsKeyDown(c->keyboard_map->nth(c->reg[x] as i64))
c->pc += 2
else if kk == 0xa1
if !IsKeyDown(c->keyboard_map->nth(c->reg[x] as i64))
if !(IsKeyDown(c->keyboard_map->nth(c->reg[x] as i64)) as bool)
c->pc += 2
else if op == 0xf
if kk == 0x07
c->reg[x] = c->delay_timer
else if kk == 0x0A
key_pressed := false
while !key_pressed && !WindowShouldClose()
while !key_pressed && !(WindowShouldClose() as bool)
for i in 0..16
if IsKeyDown(c->keyboard_map->nth(i))
key_pressed = true
@@ -305,7 +305,7 @@ func main[argc: i64, argv: ptr] : i64
InitWindow(640, 320, "CHIP-8")
SetTargetFPS(60)
while !WindowShouldClose()
while !(WindowShouldClose() as bool)
if c->delay_timer > 0
c->delay_timer = c->delay_timer - 1
if c->sound_timer > 0