Step, reset, tick_timer proc and struct cleanup.
Added a tick_timer proc so the code handles the step neatly. Added some new struct fields to accomodate this and moved danglings struct defs into the simulator definition.
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package simulator
|
||||
|
||||
import "core:log"
|
||||
|
||||
import emu "../machine"
|
||||
import rl "vendor:raylib"
|
||||
|
||||
gui_control_bar :: proc(rect: rl.Rectangle, sim: ^Simulator) {
|
||||
@@ -15,7 +17,6 @@ gui_control_bar :: proc(rect: rl.Rectangle, sim: ^Simulator) {
|
||||
if btn(&cursor, rect, BUTTON_HEIGHT, BUTTON_WIDTH, PADDING_X, "RUN") {
|
||||
if sim.rom_loaded {
|
||||
sim.paused = false
|
||||
sim.running = true
|
||||
} else {
|
||||
log.info("no rom selected, can't run")
|
||||
}
|
||||
@@ -23,12 +24,26 @@ gui_control_bar :: proc(rect: rl.Rectangle, sim: ^Simulator) {
|
||||
|
||||
if btn(&cursor, rect, BUTTON_HEIGHT, BUTTON_WIDTH, PADDING_X, "PAUSE") {
|
||||
sim.paused = true
|
||||
sim.running = false
|
||||
}
|
||||
|
||||
if btn(&cursor, rect, BUTTON_HEIGHT, BUTTON_WIDTH, PADDING_X, "STEP") {
|
||||
if !sim.step do sim.step = true
|
||||
}
|
||||
|
||||
if btn(&cursor, rect, BUTTON_HEIGHT, BUTTON_WIDTH, PADDING_X, "RESET") {
|
||||
|
||||
sim.paused = true
|
||||
sim.disasm_count = 0
|
||||
emu.reset_machine(sim.machine)
|
||||
}
|
||||
|
||||
// @TODO: Get this working
|
||||
slider_rect := rl.Rectangle{
|
||||
x = rect.width - 100 - 50,
|
||||
y = rect.y + 15,
|
||||
width = 100,
|
||||
height = 15
|
||||
}
|
||||
rl.GuiSlider(slider_rect, "Speed ", nil, &sim.speed_value, 0, 100)
|
||||
}
|
||||
|
||||
btn :: proc(cursor: ^f32, rect: rl.Rectangle, h, w, gap: f32, label: cstring) -> bool {
|
||||
|
||||
Reference in New Issue
Block a user