I'm trying to write an emulator in rust to learn the language, but i've gotten stuck.
Basically I'm trying to add a gui to the program and the gui needs to have a reference to a Machine struct that holds variable representing RAM, CPU registers etc.
I then want to do run the emulation and as the data updates have the gui update using it's reference to the machine data.
Something like this...
However I don't know how to write a function start_gui() method that will compile.
When I try to do anything with the machine variable in the start__gui() function, It complains about "explicit lifetime required" and to use static I read up on lifetimes but I guess I didn't understand what I read as I still have no idea what to do to make it compile.
How do i write a function that can read from the struct in the variable machine
? It just has to read the data, any changes will be done in the loop section.
use chip8_gui::*;
use chip8::*;
fn main() {
let rom_file_name = "test.rom";
let mut machine = c8::machine::new_machine(rom_file_name);
Chip8Gui::start_gui(&machine);
loop {
// do things with machine
}
}