Added GDB debugger stub.
This commit is contained in:
parent
35168b3e01
commit
9fb807fe7e
|
@ -160,6 +160,7 @@ AC_CONFIG_FILES([Makefile
|
||||||
src/gtk-glade/Makefile
|
src/gtk-glade/Makefile
|
||||||
src/gtk-glade/desmume-glade.desktop
|
src/gtk-glade/desmume-glade.desktop
|
||||||
src/windows/Makefile
|
src/windows/Makefile
|
||||||
|
src/gdbstub/Makefile
|
||||||
autopackage/default.apspec
|
autopackage/default.apspec
|
||||||
debian/rules
|
debian/rules
|
||||||
debian/changelog
|
debian/changelog
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
EXTRA_DIST = build.bat instruction_tabdef.inc thumb_tabdef.inc fs-linux.c fs-windows.c
|
EXTRA_DIST = build.bat instruction_tabdef.inc thumb_tabdef.inc fs-linux.c fs-windows.c
|
||||||
DIST_SUBDIRS = . cli gtk gtk-glade windows
|
DIST_SUBDIRS = . gdbstub cli gtk gtk-glade windows
|
||||||
SUBDIRS = . $(UI_DIR)
|
SUBDIRS = . gdbstub $(UI_DIR)
|
||||||
noinst_LIBRARIES = libdesmume.a
|
noinst_LIBRARIES = libdesmume.a
|
||||||
libdesmume_a_SOURCES = \
|
libdesmume_a_SOURCES = \
|
||||||
armcpu.c armcpu.h ARM9.h \
|
armcpu.c armcpu.h ARM9.h \
|
||||||
|
@ -19,6 +19,7 @@ libdesmume_a_SOURCES = \
|
||||||
render3D.c render3D.h \
|
render3D.c render3D.h \
|
||||||
saves.c saves.h \
|
saves.c saves.h \
|
||||||
SPU.c SPU.h \
|
SPU.c SPU.h \
|
||||||
|
gdbstub.h \
|
||||||
matrix.c matrix.h \
|
matrix.c matrix.h \
|
||||||
opengl_collector_3Demu.c opengl_collector_3Demu.h \
|
opengl_collector_3Demu.c opengl_collector_3Demu.h \
|
||||||
thumb_instructions.c thumb_instructions.h types.h
|
thumb_instructions.c thumb_instructions.h types.h
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
bin_PROGRAMS = desmume-cli
|
bin_PROGRAMS = desmume-cli
|
||||||
desmume_cli_SOURCES = main.c ../sndsdl.c ../ctrlssdl.h ../ctrlssdl.c
|
desmume_cli_SOURCES = main.c ../sndsdl.c ../ctrlssdl.h ../ctrlssdl.c
|
||||||
desmume_cli_LDADD = ../libdesmume.a $(SDL_LIBS)
|
desmume_cli_LDADD = ../libdesmume.a ../gdbstub/libgdbstub.a $(SDL_LIBS)
|
||||||
desmume_cli_CFLAGS = $(SDL_CFLAGS)
|
desmume_cli_CFLAGS = $(SDL_CFLAGS)
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
* Boston, MA 02111-1307, USA.
|
* Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
#include "SDL.h"
|
#include "SDL.h"
|
||||||
|
#include "SDL_thread.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <libgen.h>
|
#include <libgen.h>
|
||||||
|
@ -46,6 +47,7 @@
|
||||||
#include "../sndsdl.h"
|
#include "../sndsdl.h"
|
||||||
#include "../ctrlssdl.h"
|
#include "../ctrlssdl.h"
|
||||||
#include "../render3D.h"
|
#include "../render3D.h"
|
||||||
|
#include "../gdbstub.h"
|
||||||
|
|
||||||
volatile BOOL execute = FALSE;
|
volatile BOOL execute = FALSE;
|
||||||
|
|
||||||
|
@ -95,27 +97,35 @@ const u16 cli_kb_cfg[NB_KEYS] =
|
||||||
SDLK_o // BOOST
|
SDLK_o // BOOST
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct my_config {
|
struct my_config {
|
||||||
|
u16 arm9_gdb_port;
|
||||||
|
u16 arm7_gdb_port;
|
||||||
|
|
||||||
int disable_sound;
|
int disable_sound;
|
||||||
|
|
||||||
#ifdef INCLUDE_OPENGL_2D
|
#ifdef INCLUDE_OPENGL_2D
|
||||||
int opengl_2d;
|
int opengl_2d;
|
||||||
int soft_colour_convert;
|
int soft_colour_convert;
|
||||||
#endif
|
#endif
|
||||||
|
int disable_limiter;
|
||||||
|
|
||||||
const char *nds_file;
|
const char *nds_file;
|
||||||
|
const char *cflash_disk_image_file;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
init_config( struct my_config *config) {
|
init_config( struct my_config *config) {
|
||||||
|
config->arm9_gdb_port = 0;
|
||||||
|
config->arm7_gdb_port = 0;
|
||||||
|
|
||||||
config->disable_sound = 0;
|
config->disable_sound = 0;
|
||||||
|
|
||||||
|
config->disable_limiter = 0;
|
||||||
|
|
||||||
config->nds_file = NULL;
|
config->nds_file = NULL;
|
||||||
|
|
||||||
|
config->cflash_disk_image_file = NULL;
|
||||||
|
|
||||||
#ifdef INCLUDE_OPENGL_2D
|
#ifdef INCLUDE_OPENGL_2D
|
||||||
config->opengl_2d = 0;
|
config->opengl_2d = 0;
|
||||||
config->soft_colour_convert = 0;
|
config->soft_colour_convert = 0;
|
||||||
|
@ -135,12 +145,20 @@ fill_config( struct my_config *config,
|
||||||
printf( "USAGE: %s <nds-file>\n", argv[0]);
|
printf( "USAGE: %s <nds-file>\n", argv[0]);
|
||||||
printf( "OPTIONS:\n");
|
printf( "OPTIONS:\n");
|
||||||
printf( " --disable-sound Disables the sound emulation\n");
|
printf( " --disable-sound Disables the sound emulation\n");
|
||||||
|
printf( " --disable-limiter Disables the 60 fps limiter\n");
|
||||||
#ifdef INCLUDE_OPENGL_2D
|
#ifdef INCLUDE_OPENGL_2D
|
||||||
printf( " --opengl-2d Enables using OpenGL for screen rendering\n");
|
printf( " --opengl-2d Enables using OpenGL for screen rendering\n");
|
||||||
printf( " --soft-convert Use software colour conversion during OpenGL\n");
|
printf( " --soft-convert Use software colour conversion during OpenGL\n");
|
||||||
printf( " screen rendering. May produce better or worse\n");
|
printf( " screen rendering. May produce better or worse\n");
|
||||||
printf( " frame rates depending on hardware.\n");
|
printf( " frame rates depending on hardware.\n");
|
||||||
#endif
|
#endif
|
||||||
|
printf( "\n");
|
||||||
|
printf( " --arm9gdb=PORT_NUM Enable the ARM9 GDB stub on the given port\n");
|
||||||
|
printf( " --arm7gdb=PORT_NUM Enable the ARM7 GDB stub on the given port\n");
|
||||||
|
//printf( " --sticky Enable sticky keys and stylus\n");
|
||||||
|
printf( "\n");
|
||||||
|
printf( " --cflash=PATH_TO_DISK_IMAGE\n");
|
||||||
|
printf( " Enable disk image GBAMP compact flash emulation\n");
|
||||||
printf( "\n");
|
printf( "\n");
|
||||||
printf( " --help Display this message\n");
|
printf( " --help Display this message\n");
|
||||||
good_args = 0;
|
good_args = 0;
|
||||||
|
@ -156,6 +174,43 @@ fill_config( struct my_config *config,
|
||||||
config->soft_colour_convert = 1;
|
config->soft_colour_convert = 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
else if ( strcmp( argv[i], "--disable-limiter") == 0) {
|
||||||
|
config->disable_limiter = 1;
|
||||||
|
}
|
||||||
|
else if ( strncmp( argv[i], "--arm9gdb=", 10) == 0) {
|
||||||
|
char *end_char;
|
||||||
|
unsigned long port_num = strtoul( &argv[i][10], &end_char, 10);
|
||||||
|
|
||||||
|
if ( port_num > 0 && port_num < 65536) {
|
||||||
|
config->arm9_gdb_port = port_num;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fprintf( stderr, "ARM9 GDB stub port must be in the range 1 to 65535\n");
|
||||||
|
good_args = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ( strncmp( argv[i], "--arm7gdb=", 10) == 0) {
|
||||||
|
char *end_char;
|
||||||
|
unsigned long port_num = strtoul( &argv[i][10], &end_char, 10);
|
||||||
|
|
||||||
|
if ( port_num > 0 && port_num < 65536) {
|
||||||
|
config->arm7_gdb_port = port_num;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fprintf( stderr, "ARM7 GDB stub port must be in the range 1 to 65535\n");
|
||||||
|
good_args = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ( strncmp( argv[i], "--cflash=", 9) == 0) {
|
||||||
|
if ( config->cflash_disk_image_file == NULL) {
|
||||||
|
config->cflash_disk_image_file = &argv[i][9];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fprintf( stderr, "CFlash disk image file (\"%s\") already set\n",
|
||||||
|
config->cflash_disk_image_file);
|
||||||
|
good_args = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
if ( config->nds_file == NULL) {
|
if ( config->nds_file == NULL) {
|
||||||
config->nds_file = argv[i];
|
config->nds_file = argv[i];
|
||||||
|
@ -182,6 +237,26 @@ fill_config( struct my_config *config,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The thread handling functions needed by the GDB stub code.
|
||||||
|
*/
|
||||||
|
void *
|
||||||
|
createThread_gdb( void (*thread_function)( void *data),
|
||||||
|
void *thread_data) {
|
||||||
|
SDL_Thread *new_thread = SDL_CreateThread( (int (*)(void *data))thread_function,
|
||||||
|
thread_data);
|
||||||
|
|
||||||
|
return new_thread;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
joinThread_gdb( void *thread_handle) {
|
||||||
|
int ignore;
|
||||||
|
SDL_WaitThread( thread_handle, &ignore);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A SDL timer callback function. Signals the supplied SDL semaphore
|
* A SDL timer callback function. Signals the supplied SDL semaphore
|
||||||
* if its value is small.
|
* if its value is small.
|
||||||
|
@ -420,16 +495,25 @@ Draw( void) {
|
||||||
if(rawImage == NULL) return;
|
if(rawImage == NULL) return;
|
||||||
|
|
||||||
SDL_BlitSurface(rawImage, 0, surface, 0);
|
SDL_BlitSurface(rawImage, 0, surface, 0);
|
||||||
|
|
||||||
SDL_UpdateRect(surface, 0, 0, 0, 0);
|
SDL_UpdateRect(surface, 0, 0, 0, 0);
|
||||||
|
|
||||||
SDL_FreeSurface(rawImage);
|
SDL_FreeSurface(rawImage);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char ** argv) {
|
int main(int argc, char ** argv) {
|
||||||
static unsigned short keypad = 0;
|
static unsigned short keypad = 0;
|
||||||
struct my_config my_config;
|
struct my_config my_config;
|
||||||
u32 last_cycle = 0;
|
u32 last_cycle = 0;
|
||||||
|
gdbstub_handle_t arm9_gdb_stub;
|
||||||
|
gdbstub_handle_t arm7_gdb_stub;
|
||||||
|
struct armcpu_memory_iface *arm9_memio = &arm9_base_memory_iface;
|
||||||
|
struct armcpu_memory_iface *arm7_memio = &arm7_base_memory_iface;
|
||||||
|
struct armcpu_ctrl_iface *arm9_ctrl_iface;
|
||||||
|
struct armcpu_ctrl_iface *arm7_ctrl_iface;
|
||||||
|
|
||||||
int limiter_frame_counter = 0;
|
int limiter_frame_counter = 0;
|
||||||
SDL_sem *fps_limiter_semaphore;
|
SDL_sem *fps_limiter_semaphore;
|
||||||
SDL_TimerID limiter_timer;
|
SDL_TimerID limiter_timer;
|
||||||
|
@ -454,20 +538,55 @@ int main(int argc, char ** argv) {
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( my_config.arm9_gdb_port != 0) {
|
||||||
|
arm9_gdb_stub = createStub_gdb( my_config.arm9_gdb_port,
|
||||||
|
&arm9_memio,
|
||||||
|
&arm9_direct_memory_iface);
|
||||||
|
|
||||||
|
if ( arm9_gdb_stub == NULL) {
|
||||||
|
fprintf( stderr, "Failed to create ARM9 gdbstub on port %d\n",
|
||||||
|
my_config.arm9_gdb_port);
|
||||||
|
exit( 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( my_config.arm7_gdb_port != 0) {
|
||||||
|
arm7_gdb_stub = createStub_gdb( my_config.arm7_gdb_port,
|
||||||
|
&arm7_memio,
|
||||||
|
&arm7_base_memory_iface);
|
||||||
|
|
||||||
|
if ( arm7_gdb_stub == NULL) {
|
||||||
|
fprintf( stderr, "Failed to create ARM7 gdbstub on port %d\n",
|
||||||
|
my_config.arm7_gdb_port);
|
||||||
|
exit( 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
LogStart();
|
LogStart();
|
||||||
#endif
|
#endif
|
||||||
NDS_Init();
|
NDS_Init( arm9_memio, &arm9_ctrl_iface,
|
||||||
|
arm7_memio, &arm7_ctrl_iface);
|
||||||
|
|
||||||
if ( !my_config.disable_sound) {
|
if ( !my_config.disable_sound) {
|
||||||
SPU_ChangeSoundCore(SNDCORE_SDL, 735 * 4);
|
SPU_ChangeSoundCore(SNDCORE_SDL, 735 * 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( NDS_LoadROM( my_config.nds_file, MC_TYPE_AUTODETECT, 1) < 0) {
|
if (NDS_LoadROM( my_config.nds_file, MC_TYPE_AUTODETECT, 1, my_config.cflash_disk_image_file) < 0) {
|
||||||
fprintf(stderr, "error while loading %s\n", my_config.nds_file);
|
fprintf(stderr, "error while loading %s\n", my_config.nds_file);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Activate the GDB stubs
|
||||||
|
* This has to come after the NDS_Init where the cpus are set up.
|
||||||
|
*/
|
||||||
|
if ( my_config.arm9_gdb_port != 0) {
|
||||||
|
activateStub_gdb( arm9_gdb_stub, arm9_ctrl_iface);
|
||||||
|
}
|
||||||
|
if ( my_config.arm7_gdb_port != 0) {
|
||||||
|
activateStub_gdb( arm7_gdb_stub, arm7_ctrl_iface);
|
||||||
|
}
|
||||||
|
|
||||||
/* // This has to get fixed yet
|
/* // This has to get fixed yet
|
||||||
strcpy(szRomPath, dirname(argv[1]));
|
strcpy(szRomPath, dirname(argv[1]));
|
||||||
cflash_close();
|
cflash_close();
|
||||||
|
@ -555,6 +674,7 @@ int main(int argc, char ** argv) {
|
||||||
/* Load our own keyboard configuration */
|
/* Load our own keyboard configuration */
|
||||||
set_kb_keys(cli_kb_cfg);
|
set_kb_keys(cli_kb_cfg);
|
||||||
|
|
||||||
|
if ( !my_config.disable_limiter) {
|
||||||
/* create the semaphore used for fps limiting */
|
/* create the semaphore used for fps limiting */
|
||||||
fps_limiter_semaphore = SDL_CreateSemaphore( 1);
|
fps_limiter_semaphore = SDL_CreateSemaphore( 1);
|
||||||
|
|
||||||
|
@ -566,6 +686,7 @@ int main(int argc, char ** argv) {
|
||||||
SDL_GetError());
|
SDL_GetError());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -596,6 +717,7 @@ int main(int argc, char ** argv) {
|
||||||
#endif
|
#endif
|
||||||
Draw();
|
Draw();
|
||||||
|
|
||||||
|
if ( !my_config.disable_limiter) {
|
||||||
limiter_frame_counter += 1;
|
limiter_frame_counter += 1;
|
||||||
if ( limiter_frame_counter >= FPS_LIMITER_FRAME_PERIOD) {
|
if ( limiter_frame_counter >= FPS_LIMITER_FRAME_PERIOD) {
|
||||||
limiter_frame_counter = 0;
|
limiter_frame_counter = 0;
|
||||||
|
@ -603,6 +725,7 @@ int main(int argc, char ** argv) {
|
||||||
/* wait for the timer to expire */
|
/* wait for the timer to expire */
|
||||||
SDL_SemWait( fps_limiter_semaphore);
|
SDL_SemWait( fps_limiter_semaphore);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef DISPLAY_FPS
|
#ifdef DISPLAY_FPS
|
||||||
fps_frame_counter += 1;
|
fps_frame_counter += 1;
|
||||||
|
@ -620,22 +743,34 @@ int main(int argc, char ** argv) {
|
||||||
fps_frame_counter = 0;
|
fps_frame_counter = 0;
|
||||||
fps_timing = 0;
|
fps_timing = 0;
|
||||||
|
|
||||||
sprintf( win_title, "%f Desmume", fps);
|
sprintf( win_title, "Desmume %f", fps);
|
||||||
|
|
||||||
SDL_WM_SetCaption( win_title, NULL);
|
SDL_WM_SetCaption( win_title, NULL);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Unload joystick */
|
/* Unload joystick */
|
||||||
uninit_joy();
|
uninit_joy();
|
||||||
|
|
||||||
|
if ( !my_config.disable_limiter) {
|
||||||
/* tidy up the FPS limiter timer and semaphore */
|
/* tidy up the FPS limiter timer and semaphore */
|
||||||
SDL_RemoveTimer( limiter_timer);
|
SDL_RemoveTimer( limiter_timer);
|
||||||
SDL_DestroySemaphore( fps_limiter_semaphore);
|
SDL_DestroySemaphore( fps_limiter_semaphore);
|
||||||
|
}
|
||||||
|
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
NDS_DeInit();
|
NDS_DeInit();
|
||||||
|
|
||||||
|
if ( my_config.arm9_gdb_port != 0) {
|
||||||
|
destroyStub_gdb( arm9_gdb_stub);
|
||||||
|
}
|
||||||
|
if ( my_config.arm7_gdb_port != 0) {
|
||||||
|
destroyStub_gdb( arm7_gdb_stub);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
LogStop();
|
LogStop();
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -17,7 +17,7 @@ desmume_glade_SOURCES = \
|
||||||
gladedir = $(datadir)/desmume/glade
|
gladedir = $(datadir)/desmume/glade
|
||||||
glade_DATA = glade/DeSmuMe_Dtools.glade glade/DeSmuMe.glade glade/DeSmuME.xpm
|
glade_DATA = glade/DeSmuMe_Dtools.glade glade/DeSmuMe.glade glade/DeSmuME.xpm
|
||||||
|
|
||||||
desmume_glade_LDADD = ../libdesmume.a $(SDL_LIBS) $(GTKGLEXT_LIBS) $(LIBGLADE_LIBS) $(GTHREAD_LIBS)
|
desmume_glade_LDADD = ../libdesmume.a ../gdbstub/libgdbstub.a $(SDL_LIBS) $(GTKGLEXT_LIBS) $(LIBGLADE_LIBS) $(GTHREAD_LIBS)
|
||||||
desmume_glade_CFLAGS = $(SDL_CFLAGS) $(GTKGLEXT_CFLAGS) $(LIBGLADE_CFLAGS) $(GTHREAD_CFLAGS) -DDATADIR=\"$(gladedir)/\"
|
desmume_glade_CFLAGS = $(SDL_CFLAGS) $(GTKGLEXT_CFLAGS) $(LIBGLADE_CFLAGS) $(GTHREAD_CFLAGS) -DDATADIR=\"$(gladedir)/\"
|
||||||
desmume_glade_LDFLAGS = -rdynamic
|
desmume_glade_LDFLAGS = -rdynamic
|
||||||
|
|
||||||
|
|
|
@ -39,9 +39,13 @@ void desmume_mem_init();
|
||||||
u8 *desmume_rom_data = NULL;
|
u8 *desmume_rom_data = NULL;
|
||||||
u32 desmume_last_cycle;
|
u32 desmume_last_cycle;
|
||||||
|
|
||||||
void desmume_init()
|
void desmume_init( struct armcpu_memory_iface *arm9_mem_if,
|
||||||
|
struct armcpu_ctrl_iface **arm9_ctrl_iface,
|
||||||
|
struct armcpu_memory_iface *arm7_mem_if,
|
||||||
|
struct armcpu_ctrl_iface **arm7_ctrl_iface)
|
||||||
{
|
{
|
||||||
NDS_Init();
|
NDS_Init( arm9_mem_if, arm9_ctrl_iface,
|
||||||
|
arm7_mem_if, arm7_ctrl_iface);
|
||||||
SPU_ChangeSoundCore(SNDCORE_SDL, 735 * 4);
|
SPU_ChangeSoundCore(SNDCORE_SDL, 735 * 4);
|
||||||
execute = FALSE;
|
execute = FALSE;
|
||||||
}
|
}
|
||||||
|
@ -57,7 +61,7 @@ int desmume_open(const char *filename)
|
||||||
int i;
|
int i;
|
||||||
noticed_3D=attempted_3D_op=FALSE;
|
noticed_3D=attempted_3D_op=FALSE;
|
||||||
clear_savestates();
|
clear_savestates();
|
||||||
i = NDS_LoadROM(filename, savetype, savesize);
|
i = NDS_LoadROM(filename, savetype, savesize, NULL);
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,22 +22,24 @@
|
||||||
|
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
|
|
||||||
|
|
||||||
#define FPS_LIMITER_FRAME_PERIOD 5
|
#define FPS_LIMITER_FRAME_PERIOD 5
|
||||||
extern SDL_sem *glade_fps_limiter_semaphore;
|
extern SDL_sem *glade_fps_limiter_semaphore;
|
||||||
extern int glade_fps_limiter_disabled;
|
extern int glade_fps_limiter_disabled;
|
||||||
|
|
||||||
extern void desmume_init();
|
extern void desmume_init( struct armcpu_memory_iface *arm9_mem_if,
|
||||||
extern void desmume_free();
|
struct armcpu_ctrl_iface **arm9_ctrl_iface,
|
||||||
|
struct armcpu_memory_iface *arm7_mem_if,
|
||||||
|
struct armcpu_ctrl_iface **arm7_ctrl_iface);
|
||||||
|
extern void desmume_free( void);
|
||||||
|
|
||||||
extern int desmume_open(const char *filename);
|
extern int desmume_open(const char *filename);
|
||||||
extern void desmume_savetype(int type);
|
extern void desmume_savetype(int type);
|
||||||
extern void desmume_pause();
|
extern void desmume_pause( void);
|
||||||
extern void desmume_resume();
|
extern void desmume_resume( void);
|
||||||
extern void desmume_reset();
|
extern void desmume_reset( void);
|
||||||
extern void desmume_toggle();
|
extern void desmume_toggle( void);
|
||||||
extern BOOL desmume_running();
|
extern BOOL desmume_running( void);
|
||||||
|
|
||||||
extern void desmume_cycle();
|
extern void desmume_cycle( void);
|
||||||
#endif /*__DESMUME_H__*/
|
#endif /*__DESMUME_H__*/
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include "callbacks_IO.h"
|
#include "callbacks_IO.h"
|
||||||
#include "dTools/callbacks_dtools.h"
|
#include "dTools/callbacks_dtools.h"
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
|
#include "../gdbstub.h"
|
||||||
|
|
||||||
#ifdef GTKGLEXT_AVAILABLE
|
#ifdef GTKGLEXT_AVAILABLE
|
||||||
#include <gtk/gtkgl.h>
|
#include <gtk/gtkgl.h>
|
||||||
|
@ -67,11 +68,18 @@ struct configured_features {
|
||||||
int software_colour_convert;
|
int software_colour_convert;
|
||||||
int disable_3d;
|
int disable_3d;
|
||||||
int disable_limiter;
|
int disable_limiter;
|
||||||
|
|
||||||
|
u16 arm9_gdb_port;
|
||||||
|
u16 arm7_gdb_port;
|
||||||
|
|
||||||
const char *nds_file;
|
const char *nds_file;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
init_configured_features( struct configured_features *config) {
|
init_configured_features( struct configured_features *config) {
|
||||||
|
config->arm9_gdb_port = 0;
|
||||||
|
config->arm7_gdb_port = 0;
|
||||||
|
|
||||||
config->software_colour_convert = 0;
|
config->software_colour_convert = 0;
|
||||||
|
|
||||||
config->disable_3d = 0;
|
config->disable_3d = 0;
|
||||||
|
@ -102,6 +110,10 @@ fill_configured_features( struct configured_features *config,
|
||||||
#endif
|
#endif
|
||||||
g_print( " --disable-limiter Disables the 60 fps limiter\n");
|
g_print( " --disable-limiter Disables the 60 fps limiter\n");
|
||||||
g_print( "\n");
|
g_print( "\n");
|
||||||
|
g_print( " --arm9gdb=PORT_NUM Enable the ARM9 GDB stub on the given port\n");
|
||||||
|
g_print( " --arm7gdb=PORT_NUM Enable the ARM7 GDB stub on the given port\n");
|
||||||
|
//g_print( " --sticky Enable sticky keys and stylus\n");
|
||||||
|
g_print( "\n");
|
||||||
g_print( " --help Display this message\n");
|
g_print( " --help Display this message\n");
|
||||||
good_args = 0;
|
good_args = 0;
|
||||||
}
|
}
|
||||||
|
@ -113,6 +125,30 @@ fill_configured_features( struct configured_features *config,
|
||||||
config->disable_3d = 1;
|
config->disable_3d = 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
else if ( strncmp( argv[i], "--arm9gdb=", 10) == 0) {
|
||||||
|
char *end_char;
|
||||||
|
unsigned long port_num = strtoul( &argv[i][10], &end_char, 10);
|
||||||
|
|
||||||
|
if ( port_num > 0 && port_num < 65536) {
|
||||||
|
config->arm9_gdb_port = port_num;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
g_print( "ARM9 GDB stub port must be in the range 1 to 65535\n");
|
||||||
|
good_args = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ( strncmp( argv[i], "--arm7gdb=", 10) == 0) {
|
||||||
|
char *end_char;
|
||||||
|
unsigned long port_num = strtoul( &argv[i][10], &end_char, 10);
|
||||||
|
|
||||||
|
if ( port_num > 0 && port_num < 65536) {
|
||||||
|
config->arm7_gdb_port = port_num;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
g_print( "ARM7 GDB stub port must be in the range 1 to 65535\n");
|
||||||
|
good_args = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
else if ( strcmp( argv[i], "--disable-limiter") == 0) {
|
else if ( strcmp( argv[i], "--disable-limiter") == 0) {
|
||||||
config->disable_limiter = 1;
|
config->disable_limiter = 1;
|
||||||
}
|
}
|
||||||
|
@ -314,6 +350,27 @@ void update_savestate(u8 num)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The thread handling functions needed by the GDB stub code.
|
||||||
|
*/
|
||||||
|
void *
|
||||||
|
createThread_gdb( void (*thread_function)( void *data),
|
||||||
|
void *thread_data) {
|
||||||
|
GThread *new_thread = g_thread_create( (GThreadFunc)thread_function,
|
||||||
|
thread_data,
|
||||||
|
TRUE,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
return new_thread;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
joinThread_gdb( void *thread_handle) {
|
||||||
|
g_thread_join( thread_handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A SDL timer callback function. Signals the supplied SDL semaphore
|
* A SDL timer callback function. Signals the supplied SDL semaphore
|
||||||
* if its value is small.
|
* if its value is small.
|
||||||
|
@ -340,7 +397,12 @@ glade_fps_limiter_fn( Uint32 interval, void *param) {
|
||||||
static int
|
static int
|
||||||
common_gtk_glade_main( struct configured_features *my_config) {
|
common_gtk_glade_main( struct configured_features *my_config) {
|
||||||
SDL_TimerID limiter_timer;
|
SDL_TimerID limiter_timer;
|
||||||
|
gdbstub_handle_t arm9_gdb_stub;
|
||||||
|
gdbstub_handle_t arm7_gdb_stub;
|
||||||
|
struct armcpu_memory_iface *arm9_memio = &arm9_base_memory_iface;
|
||||||
|
struct armcpu_memory_iface *arm7_memio = &arm7_base_memory_iface;
|
||||||
|
struct armcpu_ctrl_iface *arm9_ctrl_iface;
|
||||||
|
struct armcpu_ctrl_iface *arm7_ctrl_iface;
|
||||||
|
|
||||||
#ifdef GTKGLEXT_AVAILABLE
|
#ifdef GTKGLEXT_AVAILABLE
|
||||||
// check if you have GTHREAD when running configure script
|
// check if you have GTHREAD when running configure script
|
||||||
|
@ -353,6 +415,30 @@ common_gtk_glade_main( struct configured_features *my_config) {
|
||||||
#endif
|
#endif
|
||||||
init_keyvals();
|
init_keyvals();
|
||||||
|
|
||||||
|
if ( my_config->arm9_gdb_port != 0) {
|
||||||
|
arm9_gdb_stub = createStub_gdb( my_config->arm9_gdb_port,
|
||||||
|
&arm9_memio,
|
||||||
|
&arm9_base_memory_iface);
|
||||||
|
|
||||||
|
if ( arm9_gdb_stub == NULL) {
|
||||||
|
g_print( "Failed to create ARM9 gdbstub on port %d\n",
|
||||||
|
my_config->arm9_gdb_port);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( my_config->arm7_gdb_port != 0) {
|
||||||
|
arm7_gdb_stub = createStub_gdb( my_config->arm7_gdb_port,
|
||||||
|
&arm7_memio,
|
||||||
|
&arm7_base_memory_iface);
|
||||||
|
|
||||||
|
if ( arm7_gdb_stub == NULL) {
|
||||||
|
g_print( "Failed to create ARM7 gdbstub on port %d\n",
|
||||||
|
my_config->arm7_gdb_port);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if(SDL_Init( SDL_INIT_TIMER | SDL_INIT_VIDEO) == -1)
|
if(SDL_Init( SDL_INIT_TIMER | SDL_INIT_VIDEO) == -1)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Error trying to initialize SDL: %s\n",
|
fprintf(stderr, "Error trying to initialize SDL: %s\n",
|
||||||
|
@ -360,8 +446,21 @@ common_gtk_glade_main( struct configured_features *my_config) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
desmume_init( arm9_memio, &arm9_ctrl_iface,
|
||||||
|
arm7_memio, &arm7_ctrl_iface);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Activate the GDB stubs
|
||||||
|
* This has to come after the NDS_Init (called in desmume_init)
|
||||||
|
* where the cpus are set up.
|
||||||
|
*/
|
||||||
|
if ( my_config->arm9_gdb_port != 0) {
|
||||||
|
activateStub_gdb( arm9_gdb_stub, arm9_ctrl_iface);
|
||||||
|
}
|
||||||
|
if ( my_config->arm7_gdb_port != 0) {
|
||||||
|
activateStub_gdb( arm7_gdb_stub, arm7_ctrl_iface);
|
||||||
|
}
|
||||||
|
|
||||||
desmume_init();
|
|
||||||
/* Initialize joysticks */
|
/* Initialize joysticks */
|
||||||
if(!init_joy()) return 1;
|
if(!init_joy()) return 1;
|
||||||
|
|
||||||
|
@ -476,6 +575,9 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
init_configured_features( &my_config);
|
init_configured_features( &my_config);
|
||||||
|
|
||||||
|
if (!g_thread_supported())
|
||||||
|
g_thread_init( NULL);
|
||||||
|
|
||||||
gtk_init(&argc, &argv);
|
gtk_init(&argc, &argv);
|
||||||
|
|
||||||
#ifdef GTKGLEXT_AVAILABLE
|
#ifdef GTKGLEXT_AVAILABLE
|
||||||
|
|
|
@ -16,6 +16,7 @@ desmume_SOURCES = \
|
||||||
../ctrlssdl.h ../ctrlssdl.c \
|
../ctrlssdl.h ../ctrlssdl.c \
|
||||||
gdk_3Demu.c gdk_3Demu.h \
|
gdk_3Demu.c gdk_3Demu.h \
|
||||||
main.c
|
main.c
|
||||||
desmume_LDADD = ../libdesmume.a $(SDL_LIBS) $(GTK_LIBS) $(GTKGLEXT_LIBS)
|
desmume_LDADD = ../libdesmume.a ../gdbstub/libgdbstub.a \
|
||||||
desmume_CFLAGS = $(SDL_CFLAGS) $(GTK_CFLAGS) $(GTKGLEXT_CFLAGS)
|
$(SDL_LIBS) $(GTK_LIBS) $(GTKGLEXT_LIBS) $(GTHREAD_LIBS)
|
||||||
|
desmume_CFLAGS = $(SDL_CFLAGS) $(GTK_CFLAGS) $(GTKGLEXT_CFLAGS) $(GTHREAD_CFLAGS)
|
||||||
#desmume_LDFLAGS = -rdynamic
|
#desmume_LDFLAGS = -rdynamic
|
||||||
|
|
|
@ -29,9 +29,14 @@ unsigned long glock = 0;
|
||||||
u8 *desmume_rom_data = NULL;
|
u8 *desmume_rom_data = NULL;
|
||||||
u32 desmume_last_cycle;
|
u32 desmume_last_cycle;
|
||||||
|
|
||||||
void desmume_init( int disable_sound)
|
void desmume_init( struct armcpu_memory_iface *arm9_mem_if,
|
||||||
|
struct armcpu_ctrl_iface **arm9_ctrl_iface,
|
||||||
|
struct armcpu_memory_iface *arm7_mem_if,
|
||||||
|
struct armcpu_ctrl_iface **arm7_ctrl_iface,
|
||||||
|
int disable_sound)
|
||||||
{
|
{
|
||||||
NDS_Init();
|
NDS_Init( arm9_mem_if, arm9_ctrl_iface,
|
||||||
|
arm7_mem_if, arm7_ctrl_iface);
|
||||||
if ( !disable_sound) {
|
if ( !disable_sound) {
|
||||||
SPU_ChangeSoundCore(SNDCORE_SDL, 735 * 4);
|
SPU_ChangeSoundCore(SNDCORE_SDL, 735 * 4);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,11 @@
|
||||||
|
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
|
|
||||||
extern void desmume_init( int disable_sound);
|
extern void desmume_init( struct armcpu_memory_iface *arm9_mem_if,
|
||||||
|
struct armcpu_ctrl_iface **arm9_ctrl_iface,
|
||||||
|
struct armcpu_memory_iface *arm7_mem_if,
|
||||||
|
struct armcpu_ctrl_iface **arm7_ctrl_iface,
|
||||||
|
int disable_sound);
|
||||||
extern void desmume_free( void);
|
extern void desmume_free( void);
|
||||||
|
|
||||||
extern void desmume_pause( void);
|
extern void desmume_pause( void);
|
||||||
|
|
|
@ -27,6 +27,8 @@
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
#include "../debug.h"
|
#include "../debug.h"
|
||||||
|
|
||||||
|
#include "../gdbstub.h"
|
||||||
|
|
||||||
#ifdef GTKGLEXT_AVAILABLE
|
#ifdef GTKGLEXT_AVAILABLE
|
||||||
#include "../opengl_collector_3Demu.h"
|
#include "../opengl_collector_3Demu.h"
|
||||||
#include "gdk_3Demu.h"
|
#include "gdk_3Demu.h"
|
||||||
|
@ -36,8 +38,23 @@
|
||||||
|
|
||||||
#define EMULOOP_PRIO (G_PRIORITY_HIGH_IDLE + 20)
|
#define EMULOOP_PRIO (G_PRIORITY_HIGH_IDLE + 20)
|
||||||
|
|
||||||
|
|
||||||
|
#define ENABLE_MEMORY_PROFILING 1
|
||||||
|
|
||||||
|
#ifdef ENABLE_MEMORY_PROFILING
|
||||||
|
#include <gdk/gdkkeysyms.h>
|
||||||
|
|
||||||
|
void
|
||||||
|
print_memory_profiling( void);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static const char *bad_glob_cflash_disk_image_file;
|
||||||
|
|
||||||
|
|
||||||
#define FPS_LIMITER_FRAME_PERIOD 8
|
#define FPS_LIMITER_FRAME_PERIOD 8
|
||||||
static SDL_sem *fps_limiter_semaphore;
|
static SDL_sem *fps_limiter_semaphore;
|
||||||
|
static int gtk_fps_limiter_disabled = 0;
|
||||||
|
|
||||||
|
|
||||||
/************************ CONFIG FILE *****************************/
|
/************************ CONFIG FILE *****************************/
|
||||||
|
|
||||||
|
@ -87,13 +104,23 @@ struct screen_render_config {
|
||||||
|
|
||||||
struct configured_features {
|
struct configured_features {
|
||||||
struct screen_render_config screen;
|
struct screen_render_config screen;
|
||||||
|
|
||||||
int disable_sound;
|
int disable_sound;
|
||||||
int disable_3d;
|
int disable_3d;
|
||||||
|
int disable_limiter;
|
||||||
|
|
||||||
|
u16 arm9_gdb_port;
|
||||||
|
u16 arm7_gdb_port;
|
||||||
|
|
||||||
const char *nds_file;
|
const char *nds_file;
|
||||||
|
const char *cflash_disk_image_file;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
init_configured_features( struct configured_features *config) {
|
init_configured_features( struct configured_features *config) {
|
||||||
|
config->arm9_gdb_port = 0;
|
||||||
|
config->arm7_gdb_port = 0;
|
||||||
|
|
||||||
config->disable_sound = 0;
|
config->disable_sound = 0;
|
||||||
|
|
||||||
config->screen.opengl = 0;
|
config->screen.opengl = 0;
|
||||||
|
@ -101,7 +128,11 @@ init_configured_features( struct configured_features *config) {
|
||||||
|
|
||||||
config->disable_3d = 0;
|
config->disable_3d = 0;
|
||||||
|
|
||||||
|
config->disable_limiter = 0;
|
||||||
|
|
||||||
config->nds_file = NULL;
|
config->nds_file = NULL;
|
||||||
|
|
||||||
|
config->cflash_disk_image_file = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -125,6 +156,14 @@ fill_configured_features( struct configured_features *config,
|
||||||
printf( "\n");
|
printf( "\n");
|
||||||
#endif
|
#endif
|
||||||
printf( " --disable-sound Disables the sound emulation\n");
|
printf( " --disable-sound Disables the sound emulation\n");
|
||||||
|
printf( " --disable-limiter Disables the 60 fps limiter\n");
|
||||||
|
printf( "\n");
|
||||||
|
printf( " --arm9gdb=PORT_NUM Enable the ARM9 GDB stub on the given port\n");
|
||||||
|
printf( " --arm7gdb=PORT_NUM Enable the ARM7 GDB stub on the given port\n");
|
||||||
|
//printf( " --sticky Enable sticky keys and stylus\n");
|
||||||
|
printf( "\n");
|
||||||
|
printf( " --cflash=PATH_TO_DISK_IMAGE\n");
|
||||||
|
printf( " Enable disk image GBAMP compact flash emulation\n");
|
||||||
printf( "\n");
|
printf( "\n");
|
||||||
printf( " --help Display this message\n");
|
printf( " --help Display this message\n");
|
||||||
good_args = 0;
|
good_args = 0;
|
||||||
|
@ -143,6 +182,43 @@ fill_configured_features( struct configured_features *config,
|
||||||
config->disable_3d = 1;
|
config->disable_3d = 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
else if ( strcmp( argv[i], "--disable-limiter") == 0) {
|
||||||
|
config->disable_limiter = 1;
|
||||||
|
}
|
||||||
|
else if ( strncmp( argv[i], "--arm9gdb=", 10) == 0) {
|
||||||
|
char *end_char;
|
||||||
|
unsigned long port_num = strtoul( &argv[i][10], &end_char, 10);
|
||||||
|
|
||||||
|
if ( port_num > 0 && port_num < 65536) {
|
||||||
|
config->arm9_gdb_port = port_num;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fprintf( stderr, "ARM9 GDB stub port must be in the range 1 to 65535\n");
|
||||||
|
good_args = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ( strncmp( argv[i], "--arm7gdb=", 10) == 0) {
|
||||||
|
char *end_char;
|
||||||
|
unsigned long port_num = strtoul( &argv[i][10], &end_char, 10);
|
||||||
|
|
||||||
|
if ( port_num > 0 && port_num < 65536) {
|
||||||
|
config->arm7_gdb_port = port_num;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fprintf( stderr, "ARM7 GDB stub port must be in the range 1 to 65535\n");
|
||||||
|
good_args = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ( strncmp( argv[i], "--cflash=", 9) == 0) {
|
||||||
|
if ( config->cflash_disk_image_file == NULL) {
|
||||||
|
config->cflash_disk_image_file = &argv[i][9];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fprintf( stderr, "CFlash disk image file (\"%s\") already set\n",
|
||||||
|
config->cflash_disk_image_file);
|
||||||
|
good_args = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
if ( config->nds_file == NULL) {
|
if ( config->nds_file == NULL) {
|
||||||
config->nds_file = argv[i];
|
config->nds_file = argv[i];
|
||||||
|
@ -168,6 +244,29 @@ fill_configured_features( struct configured_features *config,
|
||||||
return good_args;
|
return good_args;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The thread handling functions needed by the GDB stub code.
|
||||||
|
*/
|
||||||
|
void *
|
||||||
|
createThread_gdb( void (*thread_function)( void *data),
|
||||||
|
void *thread_data) {
|
||||||
|
GThread *new_thread = g_thread_create( (GThreadFunc)thread_function,
|
||||||
|
thread_data,
|
||||||
|
TRUE,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
return new_thread;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
joinThread_gdb( void *thread_handle) {
|
||||||
|
g_thread_join( thread_handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
u16 Keypad_Temp[NB_KEYS];
|
u16 Keypad_Temp[NB_KEYS];
|
||||||
|
|
||||||
int Write_ConfigFile()
|
int Write_ConfigFile()
|
||||||
|
@ -286,9 +385,10 @@ void About(GtkWidget* widget, gpointer data)
|
||||||
g_object_unref(pixbuf);
|
g_object_unref(pixbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int Open(const char *filename)
|
static int Open(const char *filename, const char *cflash_disk_image)
|
||||||
{
|
{
|
||||||
int i = NDS_LoadROM(filename, MC_TYPE_AUTODETECT, 1);
|
int i = NDS_LoadROM( filename, MC_TYPE_AUTODETECT, 1,
|
||||||
|
cflash_disk_image);
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -366,7 +466,7 @@ static void *Open_Select(GtkWidget* widget, gpointer data)
|
||||||
case GTK_RESPONSE_OK:
|
case GTK_RESPONSE_OK:
|
||||||
/* Recuperation du chemin */
|
/* Recuperation du chemin */
|
||||||
sChemin = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(pFileSelection));
|
sChemin = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(pFileSelection));
|
||||||
if(Open((const char*)sChemin) < 0)
|
if(Open((const char*)sChemin, bad_glob_cflash_disk_image_file) < 0)
|
||||||
{
|
{
|
||||||
GtkWidget *pDialog = gtk_message_dialog_new(GTK_WINDOW(pFileSelection),
|
GtkWidget *pDialog = gtk_message_dialog_new(GTK_WINDOW(pFileSelection),
|
||||||
GTK_DIALOG_MODAL,
|
GTK_DIALOG_MODAL,
|
||||||
|
@ -865,6 +965,12 @@ static gint Key_Press(GtkWidget *w, GdkEventKey *e)
|
||||||
u16 Key = lookup_key(e->keyval);
|
u16 Key = lookup_key(e->keyval);
|
||||||
ADD_KEY( Cur_Keypad, Key );
|
ADD_KEY( Cur_Keypad, Key );
|
||||||
if(desmume_running()) update_keypad(Cur_Keypad);
|
if(desmume_running()) update_keypad(Cur_Keypad);
|
||||||
|
|
||||||
|
#ifdef ENABLE_MEMORY_PROFILING
|
||||||
|
if ( e->keyval == GDK_Tab) {
|
||||||
|
print_memory_profiling();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1381,6 +1487,7 @@ gboolean EmuLoop(gpointer data)
|
||||||
_updateDTools();
|
_updateDTools();
|
||||||
gtk_widget_queue_draw( nds_screen_widget);
|
gtk_widget_queue_draw( nds_screen_widget);
|
||||||
|
|
||||||
|
if ( !gtk_fps_limiter_disabled) {
|
||||||
limiter_frame_counter += 1;
|
limiter_frame_counter += 1;
|
||||||
if ( limiter_frame_counter >= FPS_LIMITER_FRAME_PERIOD) {
|
if ( limiter_frame_counter >= FPS_LIMITER_FRAME_PERIOD) {
|
||||||
limiter_frame_counter = 0;
|
limiter_frame_counter = 0;
|
||||||
|
@ -1388,6 +1495,7 @@ gboolean EmuLoop(gpointer data)
|
||||||
/* wait for the timer to expire */
|
/* wait for the timer to expire */
|
||||||
SDL_SemWait( fps_limiter_semaphore);
|
SDL_SemWait( fps_limiter_semaphore);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -1438,11 +1546,43 @@ common_gtk_main( struct configured_features *my_config) {
|
||||||
GdkGLConfig *glconfig;
|
GdkGLConfig *glconfig;
|
||||||
GdkGLContext *glcontext;
|
GdkGLContext *glcontext;
|
||||||
#endif
|
#endif
|
||||||
|
gdbstub_handle_t arm9_gdb_stub;
|
||||||
|
gdbstub_handle_t arm7_gdb_stub;
|
||||||
|
struct armcpu_memory_iface *arm9_memio = &arm9_base_memory_iface;
|
||||||
|
struct armcpu_memory_iface *arm7_memio = &arm7_base_memory_iface;
|
||||||
|
struct armcpu_ctrl_iface *arm9_ctrl_iface;
|
||||||
|
struct armcpu_ctrl_iface *arm7_ctrl_iface;
|
||||||
|
|
||||||
|
bad_glob_cflash_disk_image_file = my_config->cflash_disk_image_file;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
LogStart();
|
LogStart();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if ( my_config->arm9_gdb_port != 0) {
|
||||||
|
arm9_gdb_stub = createStub_gdb( my_config->arm9_gdb_port,
|
||||||
|
&arm9_memio,
|
||||||
|
&arm9_base_memory_iface);
|
||||||
|
|
||||||
|
if ( arm9_gdb_stub == NULL) {
|
||||||
|
fprintf( stderr, "Failed to create ARM9 gdbstub on port %d\n",
|
||||||
|
my_config->arm9_gdb_port);
|
||||||
|
exit( -1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( my_config->arm7_gdb_port != 0) {
|
||||||
|
arm7_gdb_stub = createStub_gdb( my_config->arm7_gdb_port,
|
||||||
|
&arm7_memio,
|
||||||
|
&arm7_base_memory_iface);
|
||||||
|
|
||||||
|
if ( arm7_gdb_stub == NULL) {
|
||||||
|
fprintf( stderr, "Failed to create ARM7 gdbstub on port %d\n",
|
||||||
|
my_config->arm7_gdb_port);
|
||||||
|
exit( -1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef GTKGLEXT_AVAILABLE
|
#ifdef GTKGLEXT_AVAILABLE
|
||||||
/* Try double-buffered visual */
|
/* Try double-buffered visual */
|
||||||
glconfig = gdk_gl_config_new_by_mode (GDK_GL_MODE_RGB |
|
glconfig = gdk_gl_config_new_by_mode (GDK_GL_MODE_RGB |
|
||||||
|
@ -1470,8 +1610,23 @@ common_gtk_main( struct configured_features *my_config) {
|
||||||
SDL_GetError());
|
SDL_GetError());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
desmume_init( arm9_memio, &arm9_ctrl_iface,
|
||||||
|
arm7_memio, &arm7_ctrl_iface,
|
||||||
|
my_config->disable_sound);
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Activate the GDB stubs
|
||||||
|
* This has to come after the NDS_Init (called in desmume_init)
|
||||||
|
* where the cpus are set up.
|
||||||
|
*/
|
||||||
|
if ( my_config->arm9_gdb_port != 0) {
|
||||||
|
activateStub_gdb( arm9_gdb_stub, arm9_ctrl_iface);
|
||||||
|
}
|
||||||
|
if ( my_config->arm7_gdb_port != 0) {
|
||||||
|
activateStub_gdb( arm7_gdb_stub, arm7_ctrl_iface);
|
||||||
|
}
|
||||||
|
|
||||||
desmume_init( my_config->disable_sound);
|
|
||||||
/* Initialize joysticks */
|
/* Initialize joysticks */
|
||||||
if(!init_joy()) return 1;
|
if(!init_joy()) return 1;
|
||||||
|
|
||||||
|
@ -1789,6 +1944,8 @@ common_gtk_main( struct configured_features *my_config) {
|
||||||
|
|
||||||
//LoadFirmware("fw.bin");
|
//LoadFirmware("fw.bin");
|
||||||
|
|
||||||
|
gtk_fps_limiter_disabled = my_config->disable_limiter;
|
||||||
|
if ( !gtk_fps_limiter_disabled) {
|
||||||
/* create the semaphore used for fps limiting */
|
/* create the semaphore used for fps limiting */
|
||||||
fps_limiter_semaphore = SDL_CreateSemaphore( 1);
|
fps_limiter_semaphore = SDL_CreateSemaphore( 1);
|
||||||
|
|
||||||
|
@ -1799,6 +1956,7 @@ common_gtk_main( struct configured_features *my_config) {
|
||||||
SDL_GetError());
|
SDL_GetError());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set the 3D emulation to use
|
* Set the 3D emulation to use
|
||||||
|
@ -1836,7 +1994,7 @@ common_gtk_main( struct configured_features *my_config) {
|
||||||
/* Vérifie la ligne de commandes */
|
/* Vérifie la ligne de commandes */
|
||||||
if( my_config->nds_file != NULL)
|
if( my_config->nds_file != NULL)
|
||||||
{
|
{
|
||||||
if(Open( my_config->nds_file) >= 0)
|
if(Open( my_config->nds_file, bad_glob_cflash_disk_image_file) >= 0)
|
||||||
{
|
{
|
||||||
Launch();
|
Launch();
|
||||||
}
|
}
|
||||||
|
@ -1861,9 +2019,11 @@ common_gtk_main( struct configured_features *my_config) {
|
||||||
|
|
||||||
desmume_free();
|
desmume_free();
|
||||||
|
|
||||||
|
if ( !gtk_fps_limiter_disabled) {
|
||||||
/* tidy up the FPS limiter timer and semaphore */
|
/* tidy up the FPS limiter timer and semaphore */
|
||||||
SDL_RemoveTimer( limiter_timer);
|
SDL_RemoveTimer( limiter_timer);
|
||||||
SDL_DestroySemaphore( fps_limiter_semaphore);
|
SDL_DestroySemaphore( fps_limiter_semaphore);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
LogStop();
|
LogStop();
|
||||||
|
@ -1875,6 +2035,13 @@ common_gtk_main( struct configured_features *my_config) {
|
||||||
|
|
||||||
Write_ConfigFile();
|
Write_ConfigFile();
|
||||||
|
|
||||||
|
if ( my_config->arm9_gdb_port != 0) {
|
||||||
|
destroyStub_gdb( arm9_gdb_stub);
|
||||||
|
}
|
||||||
|
if ( my_config->arm7_gdb_port != 0) {
|
||||||
|
destroyStub_gdb( arm7_gdb_stub);
|
||||||
|
}
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1885,6 +2052,9 @@ main (int argc, char *argv[]) {
|
||||||
|
|
||||||
init_configured_features( &my_config);
|
init_configured_features( &my_config);
|
||||||
|
|
||||||
|
if (!g_thread_supported())
|
||||||
|
g_thread_init( NULL);
|
||||||
|
|
||||||
gtk_init(&argc, &argv);
|
gtk_init(&argc, &argv);
|
||||||
|
|
||||||
#ifdef GTKGLEXT_AVAILABLE
|
#ifdef GTKGLEXT_AVAILABLE
|
||||||
|
|
|
@ -50,9 +50,14 @@
|
||||||
#include "FirmConfig.h"
|
#include "FirmConfig.h"
|
||||||
#include "OGLRender.h"
|
#include "OGLRender.h"
|
||||||
#include "../render3D.h"
|
#include "../render3D.h"
|
||||||
|
#include "../gdbstub.h"
|
||||||
|
|
||||||
#include "snddx.h"
|
#include "snddx.h"
|
||||||
|
|
||||||
|
/* The compact flash disk image file */
|
||||||
|
static const char *bad_glob_cflash_disk_image_file;
|
||||||
|
static char cflash_filename_buffer[512];
|
||||||
|
|
||||||
/* Declare Windows procedure */
|
/* Declare Windows procedure */
|
||||||
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
|
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
|
||||||
|
|
||||||
|
@ -113,6 +118,78 @@ static u32 backupmemorysize=1;
|
||||||
LRESULT CALLBACK SoundSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam,
|
LRESULT CALLBACK SoundSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam,
|
||||||
LPARAM lParam);
|
LPARAM lParam);
|
||||||
|
|
||||||
|
struct configured_features {
|
||||||
|
u16 arm9_gdb_port;
|
||||||
|
u16 arm7_gdb_port;
|
||||||
|
|
||||||
|
const char *cflash_disk_image_file;
|
||||||
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
|
init_configured_features( struct configured_features *config) {
|
||||||
|
config->arm9_gdb_port = 0;
|
||||||
|
config->arm7_gdb_port = 0;
|
||||||
|
|
||||||
|
config->cflash_disk_image_file = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
fill_configured_features( struct configured_features *config, LPSTR lpszArgument) {
|
||||||
|
int good_args = 0;
|
||||||
|
LPTSTR cmd_line;
|
||||||
|
LPWSTR *argv;
|
||||||
|
int argc;
|
||||||
|
|
||||||
|
argv = CommandLineToArgvW( GetCommandLineW(), &argc);
|
||||||
|
|
||||||
|
if ( argv != NULL) {
|
||||||
|
int i;
|
||||||
|
good_args = 1;
|
||||||
|
for ( i = 1; i < argc && good_args; i++) {
|
||||||
|
if ( wcsncmp( argv[i], L"--arm9gdb=", 10) == 0) {
|
||||||
|
wchar_t *end_char;
|
||||||
|
unsigned long port_num = wcstoul( &argv[i][10], &end_char, 10);
|
||||||
|
|
||||||
|
if ( port_num > 0 && port_num < 65536) {
|
||||||
|
config->arm9_gdb_port = port_num;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
MessageBox(NULL,"ARM9 GDB stub port must be in the range 1 to 65535","Error",MB_OK);
|
||||||
|
good_args = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ( wcsncmp( argv[i], L"--arm7gdb=", 10) == 0) {
|
||||||
|
wchar_t *end_char;
|
||||||
|
unsigned long port_num = wcstoul( &argv[i][10], &end_char, 10);
|
||||||
|
|
||||||
|
if ( port_num > 0 && port_num < 65536) {
|
||||||
|
config->arm7_gdb_port = port_num;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
MessageBox(NULL,"ARM9 GDB stub port must be in the range 1 to 65535","Error",MB_OK);
|
||||||
|
good_args = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ( wcsncmp( argv[i], L"--cflash=", 9) == 0) {
|
||||||
|
if ( config->cflash_disk_image_file == NULL) {
|
||||||
|
size_t convert_count = wcstombs( &cflash_filename_buffer[0], &argv[i][9], 512);
|
||||||
|
if ( convert_count > 0) {
|
||||||
|
config->cflash_disk_image_file = cflash_filename_buffer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
MessageBox(NULL,"CFlash disk image file already set","Error",MB_OK);
|
||||||
|
good_args = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LocalFree( argv);
|
||||||
|
}
|
||||||
|
|
||||||
|
return good_args;
|
||||||
|
}
|
||||||
|
|
||||||
// Rotation definitions
|
// Rotation definitions
|
||||||
u8 GPU_screenrotated[4*256*192];
|
u8 GPU_screenrotated[4*256*192];
|
||||||
short GPU_rotation = 0;
|
short GPU_rotation = 0;
|
||||||
|
@ -423,16 +500,34 @@ void StateLoadSlot(int num)
|
||||||
NDS_UnPause();
|
NDS_UnPause();
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL LoadROM(char * filename)
|
BOOL LoadROM(char * filename, const char *cflash_disk_image)
|
||||||
{
|
{
|
||||||
NDS_Pause();
|
NDS_Pause();
|
||||||
|
|
||||||
if (NDS_LoadROM(filename, backupmemorytype, backupmemorysize) > 0)
|
if (NDS_LoadROM(filename, backupmemorytype, backupmemorysize, cflash_disk_image) > 0)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The thread handling functions needed by the GDB stub code.
|
||||||
|
*/
|
||||||
|
void *
|
||||||
|
createThread_gdb( void (*thread_function)( void *data),
|
||||||
|
void *thread_data) {
|
||||||
|
void *new_thread = CreateThread( NULL, 0,
|
||||||
|
(LPTHREAD_START_ROUTINE)thread_function, thread_data,
|
||||||
|
0, NULL);
|
||||||
|
|
||||||
|
return new_thread;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
joinThread_gdb( void *thread_handle) {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void SetLanguage(int langid)
|
void SetLanguage(int langid)
|
||||||
{
|
{
|
||||||
switch(langid)
|
switch(langid)
|
||||||
|
@ -491,6 +586,14 @@ int WINAPI WinMain (HINSTANCE hThisInstance,
|
||||||
int nFunsterStil)
|
int nFunsterStil)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
gdbstub_handle_t arm9_gdb_stub;
|
||||||
|
gdbstub_handle_t arm7_gdb_stub;
|
||||||
|
struct armcpu_memory_iface *arm9_memio = &arm9_base_memory_iface;
|
||||||
|
struct armcpu_memory_iface *arm7_memio = &arm7_base_memory_iface;
|
||||||
|
struct armcpu_ctrl_iface *arm9_ctrl_iface;
|
||||||
|
struct armcpu_ctrl_iface *arm7_ctrl_iface;
|
||||||
|
struct configured_features my_config;
|
||||||
|
|
||||||
MSG messages; /* Here messages to the application are saved */
|
MSG messages; /* Here messages to the application are saved */
|
||||||
char text[80];
|
char text[80];
|
||||||
cwindow_struct MainWindow;
|
cwindow_struct MainWindow;
|
||||||
|
@ -505,6 +608,13 @@ int WINAPI WinMain (HINSTANCE hThisInstance,
|
||||||
|
|
||||||
sprintf(text, "DeSmuME v%s", VERSION);
|
sprintf(text, "DeSmuME v%s", VERSION);
|
||||||
|
|
||||||
|
init_configured_features( &my_config);
|
||||||
|
if ( !fill_configured_features( &my_config, lpszArgument)) {
|
||||||
|
MessageBox(NULL,"Unable to parse command line arguments","Error",MB_OK);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
bad_glob_cflash_disk_image_file = my_config.cflash_disk_image_file;
|
||||||
|
|
||||||
hAccel = LoadAccelerators(hAppInst, MAKEINTRESOURCE(IDR_MAIN_ACCEL));
|
hAccel = LoadAccelerators(hAppInst, MAKEINTRESOURCE(IDR_MAIN_ACCEL));
|
||||||
|
|
||||||
if (CWindow_Init(&MainWindow, hThisInstance, szClassName, text,
|
if (CWindow_Init(&MainWindow, hThisInstance, szClassName, text,
|
||||||
|
@ -535,6 +645,41 @@ int WINAPI WinMain (HINSTANCE hThisInstance,
|
||||||
|
|
||||||
NDS_Init();
|
NDS_Init();
|
||||||
|
|
||||||
|
if ( my_config.arm9_gdb_port != 0) {
|
||||||
|
arm9_gdb_stub = createStub_gdb( my_config.arm9_gdb_port,
|
||||||
|
&arm9_memio, &arm9_direct_memory_iface);
|
||||||
|
|
||||||
|
if ( arm9_gdb_stub == NULL) {
|
||||||
|
MessageBox(hwnd,"Failed to create ARM9 gdbstub","Error",MB_OK);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( my_config.arm7_gdb_port != 0) {
|
||||||
|
arm7_gdb_stub = createStub_gdb( my_config.arm7_gdb_port,
|
||||||
|
&arm7_memio,
|
||||||
|
&arm7_base_memory_iface);
|
||||||
|
|
||||||
|
if ( arm7_gdb_stub == NULL) {
|
||||||
|
MessageBox(hwnd,"Failed to create ARM7 gdbstub","Error",MB_OK);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
NDS_Init( arm9_memio, &arm9_ctrl_iface,
|
||||||
|
arm7_memio, &arm7_ctrl_iface);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Activate the GDB stubs
|
||||||
|
* This has to come after the NDS_Init where the cpus are set up.
|
||||||
|
*/
|
||||||
|
if ( my_config.arm9_gdb_port != 0) {
|
||||||
|
activateStub_gdb( arm9_gdb_stub, arm9_ctrl_iface);
|
||||||
|
}
|
||||||
|
if ( my_config.arm7_gdb_port != 0) {
|
||||||
|
activateStub_gdb( arm7_gdb_stub, arm7_ctrl_iface);
|
||||||
|
}
|
||||||
|
|
||||||
GetPrivateProfileString("General", "Language", "0", text, 80, IniName);
|
GetPrivateProfileString("General", "Language", "0", text, 80, IniName);
|
||||||
CheckLanguage(IDC_LANGENGLISH+atoi(text));
|
CheckLanguage(IDC_LANGENGLISH+atoi(text));
|
||||||
|
|
||||||
|
@ -581,7 +726,7 @@ int WINAPI WinMain (HINSTANCE hThisInstance,
|
||||||
if (lpszArgument[0] == '\"')
|
if (lpszArgument[0] == '\"')
|
||||||
sscanf(lpszArgument, "\"%[^\"]\"", lpszArgument);
|
sscanf(lpszArgument, "\"%[^\"]\"", lpszArgument);
|
||||||
|
|
||||||
if(LoadROM(lpszArgument))
|
if(LoadROM(lpszArgument, bad_glob_cflash_disk_image_file))
|
||||||
{
|
{
|
||||||
EnableMenuItem(menu, IDM_EXEC, MF_GRAYED);
|
EnableMenuItem(menu, IDM_EXEC, MF_GRAYED);
|
||||||
EnableMenuItem(menu, IDM_PAUSE, MF_ENABLED);
|
EnableMenuItem(menu, IDM_PAUSE, MF_ENABLED);
|
||||||
|
@ -690,7 +835,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
||||||
char filename[MAX_PATH] = "";
|
char filename[MAX_PATH] = "";
|
||||||
DragQueryFile((HDROP)wParam,0,filename,MAX_PATH);
|
DragQueryFile((HDROP)wParam,0,filename,MAX_PATH);
|
||||||
DragFinish((HDROP)wParam);
|
DragFinish((HDROP)wParam);
|
||||||
if(LoadROM(filename))
|
if(LoadROM(filename, bad_glob_cflash_disk_image_file))
|
||||||
{
|
{
|
||||||
EnableMenuItem(menu, IDM_EXEC, MF_GRAYED);
|
EnableMenuItem(menu, IDM_EXEC, MF_GRAYED);
|
||||||
EnableMenuItem(menu, IDM_PAUSE, MF_ENABLED);
|
EnableMenuItem(menu, IDM_PAUSE, MF_ENABLED);
|
||||||
|
@ -948,7 +1093,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
||||||
|
|
||||||
LOG("%s\r\n", filename);
|
LOG("%s\r\n", filename);
|
||||||
|
|
||||||
if(LoadROM(filename))
|
if(LoadROM(filename, bad_glob_cflash_disk_image_file))
|
||||||
{
|
{
|
||||||
EnableMenuItem(menu, IDM_EXEC, MF_GRAYED);
|
EnableMenuItem(menu, IDM_EXEC, MF_GRAYED);
|
||||||
EnableMenuItem(menu, IDM_PAUSE, MF_ENABLED);
|
EnableMenuItem(menu, IDM_PAUSE, MF_ENABLED);
|
||||||
|
|
Loading…
Reference in New Issue