diff --git a/desmume/src/NDSSystem.cpp b/desmume/src/NDSSystem.cpp index 41efe0e94..4c71f2309 100644 --- a/desmume/src/NDSSystem.cpp +++ b/desmume/src/NDSSystem.cpp @@ -1807,6 +1807,16 @@ void NDS_exec(s32 nb) { for(;;) { + + #ifdef GDB_STUB + //at worst, this will happen once per scanline. + //does it need to be more accurate than that? we think now + while((NDS_ARM9.stalled || NDS_ARM7.stalled) && execute) + { + driver->EMU_DebugIdleUpdate(); + } + #endif + nds.cpuloopIterationCount++; sequencer.execHardware(); diff --git a/desmume/src/armcpu.cpp b/desmume/src/armcpu.cpp index 190b9e461..c3a63ca5f 100644 --- a/desmume/src/armcpu.cpp +++ b/desmume/src/armcpu.cpp @@ -111,14 +111,14 @@ armcpu_t NDS_ARM9; static void stall_cpu( void *instance) { armcpu_t *armcpu = (armcpu_t *)instance; - + printf("UNSTALL\n"); armcpu->stalled = 1; } static void unstall_cpu( void *instance) { armcpu_t *armcpu = (armcpu_t *)instance; - + printf("UNSTALL\n"); armcpu->stalled = 0; } diff --git a/desmume/src/driver.h b/desmume/src/driver.h index aa006542f..f6871dccf 100644 --- a/desmume/src/driver.h +++ b/desmume/src/driver.h @@ -78,6 +78,7 @@ public: virtual bool EMU_IsFastForwarding() { return false; } virtual bool EMU_HasEmulationStarted() { return true; } virtual bool EMU_IsAtFrameBoundary() { return true; } + virtual void EMU_DebugIdleUpdate() {} enum eDebug_IOReg { diff --git a/desmume/src/gtk/main.cpp b/desmume/src/gtk/main.cpp index 4d4134df8..0a0eae667 100644 --- a/desmume/src/gtk/main.cpp +++ b/desmume/src/gtk/main.cpp @@ -119,6 +119,7 @@ enum { gboolean EmuLoop(gpointer data); +static void DoQuit(); static void RecordMovieDialog(); static void PlayMovieDialog(); static void StopMovie(); @@ -288,7 +289,7 @@ static const GtkActionEntry action_entries[] = { { "loadfirmware","gtk-open", "Load Firm_ware file", "l", NULL, SelectFirmwareFile }, #endif { "printscreen","gtk-media-record", "Take a _screenshot", "s", NULL, Printscreen }, - { "quit", "gtk-quit", "_Quit", "q", NULL, gtk_main_quit }, + { "quit", "gtk-quit", "_Quit", "q", NULL, DoQuit }, { "EmulationMenu", NULL, "_Emulation" }, { "run", "gtk-media-play", "_Run", "r", NULL, Launch }, @@ -397,9 +398,6 @@ public: int disable_limiter; int savetype; - int arm9_gdb_port; - int arm7_gdb_port; - int firmware_language; const char *cflash_disk_image_file; @@ -411,9 +409,6 @@ public: static void init_configured_features( struct configured_features *config) { - config->arm9_gdb_port = 0; - config->arm7_gdb_port = 0; - config->disable_sound = 0; config->engine_3d = 1; @@ -1608,6 +1603,25 @@ static inline void _updateDTools() /////////////////////////////// MAIN EMULATOR LOOP /////////////////////////////// +class GtkDriver : public BaseDriver +{ +public: + virtual void EMU_DebugIdleUpdate() + { + usleep(1000); + _updateDTools(); + while (gtk_events_pending()) + gtk_main_iteration(); + } +}; + +static void DoQuit() +{ + emu_halt(); + gtk_main_quit(); +} + + gboolean EmuLoop(gpointer data) { static Uint32 fps_SecStart, next_fps_SecStart, fps_FrameCount, skipped_frames; @@ -1811,6 +1825,8 @@ static gboolean timeout_exit_cb(gpointer data) static int common_gtk_main( struct configured_features *my_config) { + driver = new GtkDriver(); + SDL_TimerID limiter_timer = NULL; GtkAccelGroup * accel_group; @@ -1865,7 +1881,7 @@ common_gtk_main( struct configured_features *my_config) #ifdef GDB_STUB if ( my_config->arm9_gdb_port != 0) { - arm9_gdb_stub = createStub_gdb( my_config->arm9_gdb_port, + arm9_gdb_stub = createStub_gdb( my_config->arm9_gdb_port, &arm9_memio, &arm9_base_memory_iface); diff --git a/desmume/src/wifi.cpp b/desmume/src/wifi.cpp index 989a45c02..619955978 100644 --- a/desmume/src/wifi.cpp +++ b/desmume/src/wifi.cpp @@ -62,6 +62,11 @@ const u8 BroadcastMAC[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; pcap_t *wifi_bridge = NULL; #endif +//sometimes this isnt defined +#ifndef PCAP_OPENFLAG_PROMISCUOUS +#define PCAP_OPENFLAG_PROMISCUOUS 1 +#endif + wifimac_t wifiMac; Adhoc_t Adhoc; SoftAP_t SoftAP; diff --git a/desmume/src/windows/main.cpp b/desmume/src/windows/main.cpp index 2df088859..c0ae55be0 100644 --- a/desmume/src/windows/main.cpp +++ b/desmume/src/windows/main.cpp @@ -2228,6 +2228,12 @@ class WinDriver : public BaseDriver if(anyLiveIORegViews) RefreshAllIORegViews(); } + + virtual void EMU_DebugIdleUpdate() + { + CheckMessages(); + Sleep(1); + } }; //----------------------------------------------------------------------------- diff --git a/desmume/src/windows/winpcap.h b/desmume/src/windows/winpcap.h index 7ab9fd840..cd3b62384 100644 --- a/desmume/src/windows/winpcap.h +++ b/desmume/src/windows/winpcap.h @@ -65,7 +65,6 @@ static void LoadWinPCap() LOADSYMBOL(pcap_sendpacket); LOADSYMBOL(pcap_dispatch); - CloseHandle(wpcap); bWinPCapAvailable = true; }