diff --git a/src/bus.c b/src/bus.c index 06097fc..a18a97d 100644 --- a/src/bus.c +++ b/src/bus.c @@ -16,9 +16,11 @@ #include "keyboard.h" #include "mouse.h" +bool bus_requests_exit = false; + extern struct timeval rtc_current_time; extern uint32_t rtc_uptime; - +; extern fox32_vm_t vm; extern disk_controller_t disk_controller; extern mouse_t mouse; @@ -220,6 +222,12 @@ int bus_io_write(void *user, uint32_t value, uint32_t port) { break; }; + + case 0x80010000: { // power control port + if (value == 0) { + bus_requests_exit = true; + } + }; } return 0; diff --git a/src/main.c b/src/main.c index 0feec46..4b18ddc 100644 --- a/src/main.c +++ b/src/main.c @@ -24,6 +24,7 @@ fox32_vm_t vm; +extern bool bus_requests_exit; extern disk_controller_t disk_controller; uint32_t tick_start; @@ -95,7 +96,7 @@ int main(int argc, char *argv[]) { tick_start = SDL_GetTicks(); tick_end = SDL_GetTicks(); - while (!done) { + while (!done && !bus_requests_exit) { main_loop(); tick_end = SDL_GetTicks();