package machine import rl "vendor:raylib" // Handle the "display" and all of its required functions // raylib window, rendering, scale constants SCALE :: 20 SCREEN_WITDH :: 64 * SCALE SCREEN_HEIGHT :: 32 * SCALE CYCLES_PER_FRAME :: 12 // Display will handle all the screen drawing with raylib etc run_system :: proc(s: ^System) { rl.InitWindow(SCREEN_WITDH, SCREEN_HEIGHT, "raylib") rl.InitAudioDevice() rl.SetTargetFPS(60) beep := rl.LoadSound("./beep.wav") for !rl.WindowShouldClose() { rl.BeginDrawing() rl.ClearBackground(rl.BLACK) // Do a cpu cycle // Cap at 60hz/60fps for _ in 0.. 0 do s.delay_timer -= 1 // Current sound file is around 1s so stop // immediately when timer is 0 if s.sound_timer > 0 { s.sound_timer -= 1 if !rl.IsSoundPlaying(beep) do rl.PlaySound(beep) } else { rl.StopSound(beep) } render_display_buffer(&s.display) rl.EndDrawing() } rl.UnloadSound(beep) rl.CloseAudioDevice() rl.CloseWindow() } // update display with display buffer bits render_display_buffer :: proc(display_buffer: ^[32][64]u8) { // get row for y in 0..