0b5006f985
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.
54 lines
1.4 KiB
Odin
54 lines
1.4 KiB
Odin
package simulator
|
|
|
|
import "core:log"
|
|
|
|
import emu "../machine"
|
|
import rl "vendor:raylib"
|
|
|
|
gui_control_bar :: proc(rect: rl.Rectangle, sim: ^Simulator) {
|
|
rl.DrawRectangleLinesEx(rect, 1, rl.DARKGRAY)
|
|
|
|
rl.DrawTextEx(sim.font, "Octal Cookie Chip 8 Sim ", {rect.x + PADDING_X, rect.y + 12}, 25, 1, rl.WHITE)
|
|
text_size := rl.MeasureTextEx(sim.font, "Octal Cookie Chip 8 Sim ", 25, 1)
|
|
|
|
// Cursor moves for every btn call places them left to right with padding
|
|
cursor : f32 = text_size.x + 5 + rect.x + PADDING_X
|
|
|
|
if btn(&cursor, rect, BUTTON_HEIGHT, BUTTON_WIDTH, PADDING_X, "RUN") {
|
|
if sim.rom_loaded {
|
|
sim.paused = false
|
|
} else {
|
|
log.info("no rom selected, can't run")
|
|
}
|
|
}
|
|
|
|
if btn(&cursor, rect, BUTTON_HEIGHT, BUTTON_WIDTH, PADDING_X, "PAUSE") {
|
|
sim.paused = true
|
|
}
|
|
|
|
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 {
|
|
r := rl.Rectangle{cursor^, rect.y + PADDING_X, w, h}
|
|
cursor^ += w + gap
|
|
return rl.GuiButton(r, label)
|
|
}
|