Crude drawing call for now just to test.
This commit is contained in:
@@ -8,20 +8,35 @@ import rl "vendor:raylib"
|
||||
SCALE :: 20
|
||||
SCREEN_WITDH :: 64 * SCALE
|
||||
SCREEN_HEIGHT :: 32 * SCALE
|
||||
CYCLES_PER_FRAME :: 12
|
||||
|
||||
// Display will handle all the screen drawing with raylib etc
|
||||
init_display_and_cycle :: proc(s: ^System) {
|
||||
run_system :: proc(s: ^System) {
|
||||
rl.InitWindow(SCREEN_WITDH, SCREEN_HEIGHT, "chip8")
|
||||
|
||||
// Cap at 60hz/60fps
|
||||
rl.SetTargetFPS(60)
|
||||
|
||||
for !rl.WindowShouldClose() {
|
||||
rl.BeginDrawing()
|
||||
|
||||
rl.ClearBackground(rl.WHITE)
|
||||
rl.ClearBackground(rl.BLACK)
|
||||
|
||||
// Do a cpu cycle
|
||||
for _ in 0..<CYCLES_PER_FRAME {
|
||||
cycle(s)
|
||||
}
|
||||
|
||||
// update display with display buffer bits
|
||||
// get row
|
||||
for y in 0..<len(s.display) {
|
||||
// get cols
|
||||
for x in 0..<len(s.display[0]) {
|
||||
if s.display[y][x] == 0x01 {
|
||||
rl.DrawRectangle(i32(x * SCALE), i32(y * SCALE), SCALE, SCALE, rl.WHITE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user