From 565685776a143e46743dfa759f7e49411ce7a0ad Mon Sep 17 00:00:00 2001 From: Ry Date: Thu, 27 Oct 2022 22:32:16 -0700 Subject: [PATCH] Add power control port --- src/bus.c | 10 +++++++++- src/main.c | 3 ++- 2 files changed, 11 insertions(+), 2 deletions(-) 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();