diff options
author | Ian C <ianc@noddybox.co.uk> | 2023-01-09 15:11:53 +0000 |
---|---|---|
committer | Ian C <ianc@noddybox.co.uk> | 2023-01-09 15:11:53 +0000 |
commit | 2df835d00591d085de589ddf4d40ea3edc8f3fac (patch) | |
tree | 01bce387296a3590a26eb0856a51f12f9f207242 /source/main.c | |
parent | 5b9ffe70b622cee65ed5678163bee0e22fc0433d (diff) |
Added support for debug logging over a socket.
Diffstat (limited to 'source/main.c')
-rw-r--r-- | source/main.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/source/main.c b/source/main.c index b5f9c72..30e9359 100644 --- a/source/main.c +++ b/source/main.c @@ -22,6 +22,7 @@ #include <stdlib.h> #include <stdio.h> #include <string.h> +#include <malloc.h> #include <3ds.h> #include "framebuffer.h" @@ -32,6 +33,7 @@ #include "config.h" #include "snapshot.h" #include "snap.h" +#include "debug.h" #define DSSPEC_VERSION "0.1" @@ -67,6 +69,7 @@ static const char *main_menu[]= "Load Memory Snapshot", "Save Joypad/Key State", "Load Joypad/Key State", + "Enable Debug", "Exit 3DSSPEC", "Cancel", NULL @@ -82,6 +85,7 @@ typedef enum MenuLoadSnapshot, MenuSaveMappings, MenuLoadMappings, + MenuDebug, MenuExit } MenuOpt; @@ -236,6 +240,8 @@ int main(int argc, char *argv[]) Z80 *z80; int quit = FALSE; float mix[12] = {1.0, 1.0}; + u32 *SOC_buffer; + int soc_initialised = FALSE; gfxInit(GSP_RGB565_OES, GSP_RGB565_OES, FALSE); ndspInit(); @@ -249,6 +255,29 @@ int main(int argc, char *argv[]) FB_Init(); GUI_Init(); + SOC_buffer = (u32*)memalign(0x1000,0x100000); + + if (SOC_buffer) + { + int ret; + + if ((ret = socInit(SOC_buffer, 0x100000)) == 0) + { + soc_initialised = TRUE; + } + else + { + char msg[256]; + snprintf(msg, sizeof msg, "Failed to initialise SOC\n0x%08X", + (unsigned int)ret); + GUI_Alert(FALSE, msg); + } + } + else + { + GUI_Alert(FALSE, "Failed to allocate memory for SOC!"); + } + z80 = Z80Init(SPECReadPort, SPECWritePort); if (!z80) @@ -343,6 +372,31 @@ int main(int argc, char *argv[]) SNAP_Load(z80, NULL, SNAP_TYPE_KEYBOARD); break; + case MenuDebug: + if (soc_initialised) + { + char host[32] = {0}; + char port[32] = {0}; + + debug_enabled = TRUE; + + GUI_Input("Enter host", host, 31); + GUI_Input("Enter port", port, 31); + + if (!host[0]) + { + strcpy(host, "192.168.0.77"); + } + + if (!port[0]) + { + strcpy(port, "12345"); + } + + DEBUG_SetAddress(host, port); + } + break; + case MenuExit: quit = TRUE; break; @@ -360,5 +414,10 @@ int main(int argc, char *argv[]) ndspExit(); gfxExit(); + if (soc_initialised) + { + socExit(); + } + return 0; } |