Small cleanup with new run machine proc.
This commit is contained in:
+26
-31
@@ -7,16 +7,16 @@ import rl "vendor:raylib"
|
||||
WINDOW_WIDTH :: 1920
|
||||
WINDOW_HEIGHT :: 1080
|
||||
|
||||
// TODO: If this grows lets move it into its own file
|
||||
// @TODO: If this grows lets move it into its own file
|
||||
SIDEBAR_PERCENT :: 0.20
|
||||
DISPLAY_PERCENT :: 0.30
|
||||
CONTROLBAR_PERCENT :: 0.05
|
||||
|
||||
Layout :: struct {
|
||||
left_panel : rl.Rectangle,
|
||||
right_panel : rl.Rectangle,
|
||||
display : rl.Rectangle,
|
||||
control_bar : rl.Rectangle,
|
||||
left_panel : rl.Rectangle,
|
||||
display : rl.Rectangle,
|
||||
right_panel : rl.Rectangle,
|
||||
}
|
||||
|
||||
// Initialize main the gui 'window'
|
||||
@@ -34,20 +34,16 @@ init_gui :: proc(s: ^m.System) {
|
||||
screen_height := f32(rl.GetScreenHeight())
|
||||
sidebar_width := screen_width * 0.20
|
||||
|
||||
// set all the layout structs dynamically with the screen size
|
||||
layout := calc_layout(screen_width, screen_height)
|
||||
|
||||
rl.BeginDrawing()
|
||||
rl.ClearBackground(rl.BLACK)
|
||||
|
||||
// TODO: move this out / make better
|
||||
// --------------------------------------
|
||||
// CPU cycles
|
||||
for _ in 0..<12 {
|
||||
m.handle_input(s)
|
||||
m.cycle(s)
|
||||
}
|
||||
// --------------------------------------
|
||||
// Cycle the machine to update memory etc
|
||||
m.run_machine(s)
|
||||
|
||||
// Now draw the update data
|
||||
gui_left_panel(layout.left_panel, s)
|
||||
gui_right_panel(layout.right_panel, s)
|
||||
gui_screen(layout.display, s)
|
||||
@@ -60,38 +56,37 @@ init_gui :: proc(s: ^m.System) {
|
||||
rl.CloseWindow()
|
||||
}
|
||||
|
||||
// TODO: If this grows lets move it into its own file
|
||||
// @TODO: If this grows lets move it into its own file
|
||||
calc_layout :: proc(screen_width: f32, screen_height: f32) -> Layout {
|
||||
control_bar_height := screen_height * CONTROLBAR_PERCENT
|
||||
sidebar_width := screen_width * SIDEBAR_PERCENT
|
||||
display_height := screen_height * DISPLAY_PERCENT
|
||||
sidebar_height := screen_height - control_bar_height
|
||||
display_height := screen_height * DISPLAY_PERCENT - control_bar_height
|
||||
|
||||
return Layout {
|
||||
left_panel = rl.Rectangle {
|
||||
control_bar = rl.Rectangle {
|
||||
x = 0,
|
||||
y = 0,
|
||||
width = sidebar_width,
|
||||
height = screen_height
|
||||
width = screen_width,
|
||||
height = control_bar_height
|
||||
},
|
||||
|
||||
right_panel = rl.Rectangle {
|
||||
x = screen_width - sidebar_width,
|
||||
y = 0,
|
||||
left_panel = rl.Rectangle {
|
||||
x = 0,
|
||||
y = control_bar_height,
|
||||
width = sidebar_width,
|
||||
height = screen_height
|
||||
height = sidebar_height
|
||||
},
|
||||
|
||||
display = rl.Rectangle {
|
||||
x = sidebar_width,
|
||||
y = 0,
|
||||
y = control_bar_height,
|
||||
width = screen_width - (sidebar_width * 2),
|
||||
height = display_height
|
||||
},
|
||||
|
||||
control_bar = rl.Rectangle {
|
||||
x = sidebar_width,
|
||||
y = display_height,
|
||||
width = screen_width - (sidebar_width * 2),
|
||||
height = (screen_height * 0.05)
|
||||
}
|
||||
right_panel = rl.Rectangle {
|
||||
x = screen_width - sidebar_width,
|
||||
y = control_bar_height,
|
||||
width = sidebar_width,
|
||||
height = sidebar_height
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -334,4 +334,3 @@ op_mem_get :: proc(s: ^System, vx_idx: u16) {
|
||||
s.v[loop_idx] = s.memory[s.i + loop_idx]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -60,3 +60,11 @@ init :: proc() -> System {
|
||||
|
||||
return s
|
||||
}
|
||||
|
||||
run_machine :: proc(s: ^System) {
|
||||
// CPU cycles
|
||||
for _ in 0..<12 {
|
||||
handle_input(s)
|
||||
cycle(s)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user