re-add gtk+2 frontend in gtk2 directory

This commit is contained in:
rofl0r 2021-10-29 17:14:40 +00:00
parent 54f3549108
commit 03e14584f6
37 changed files with 6278 additions and 0 deletions

View File

@ -0,0 +1,50 @@
/* XPM */
static const char * DeSmuME_xpm[] = {
"32 32 15 1",
" c None",
". c #000000",
"+ c #F6F6FB",
"@ c #ECECF6",
"# c #E2E2F1",
"$ c #D8D8EC",
"% c #CFCFE7",
"& c #C5C5E2",
"* c #BBBBDE",
"= c #B1B1D9",
"- c #A8A8D4",
"; c #9E9ECF",
"> c #9494CA",
", c #8A8AC5",
"' c #8080C0",
" .................... ",
" .................... ",
".....++..+++++..+++++.. ",
".....++..++.....++..... ",
"..@@@@@..@@@@@..@@@@@.. ",
"..@@.@@..@@........@@.. ",
"..##.##..##.##..##.##.. ",
"..##.##..##.##..##.##.. ",
"..$$.$$..$$.$$..$$.$$.. ",
"..$$.$$..$$.$$..$$.$$.. ",
"..%%.%%..%%.%%..%%.%%.. ",
"..%%.%%..%%.%%..%%.%%.. ",
"..&&&&&..&&&&&..&&&&&.. ",
"....................... ",
".......********.**.**.. ",
" ..==.==.==.==.==.. ",
" ..==.==.==.==.==.. ",
" ..--.--.--.--.--.. ",
" ..--.--.--.--.--.. ",
" ..;;.;;.;;.;;;;;.. ",
" ..................... ",
" ..................... ",
" ..>>>>>>>>.>>>>>.. ",
" ..>>.>>.>>.>>..... ",
" ..,,.,,.,,.,,,,,.. ",
" ..,,.,,.,,.,,..... ",
" ..''.''.''.''.''.. ",
" ..''.''.''.''.''.. ",
" ..''.''.''.''.''.. ",
" ..''.''.''.'''''.. ",
" .................. ",
" .................. "};

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>desmume</string>
<key>CFBundleGetInfoString</key>
<string>desmume</string>
<key>CFBundleIdentifier</key>
<string>org.desmume.desmume.gtk</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>Desmume</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
</dict>
</plist>

View File

@ -0,0 +1,46 @@
SUBDIRS = doc
include ../desmume.mk
AM_CPPFLAGS += $(SDL_CFLAGS) $(GTK_CFLAGS) $(GTHREAD_CFLAGS) $(ALSA_CFLAGS) $(LIBAGG_CFLAGS) $(LIBSOUNDTOUCH_CFLAGS)
Applicationsdir = $(datadir)/applications
Applications_DATA = desmume.desktop
pixmapdir = $(datadir)/pixmaps
pixmap_DATA = DeSmuME.xpm
EXTRA_DIST = DeSmuME.xpm desmume.desktop
bin_PROGRAMS = desmume
desmume_SOURCES = \
avout.h \
avout_pipe_base.cpp avout_pipe_base.h \
avout_x264.cpp avout_x264.h \
avout_flac.cpp avout_flac.h \
config.cpp config.h config_opts.h \
desmume.h desmume.cpp \
dTool.h dToolsList.cpp \
tools/ioregsView.cpp tools/ioregsView.h \
../shared/sndsdl.cpp \
../shared/ctrlssdl.h ../shared/ctrlssdl.cpp \
osmesa_3Demu.cpp osmesa_3Demu.h \
sdl_3Demu.cpp sdl_3Demu.h \
cheatsGTK.h cheatsGTK.cpp \
main.cpp main.h
desmume_LDADD = ../libdesmume.a \
$(X_LIBS) -lX11 $(SDL_LIBS) $(GTK_LIBS) $(GTHREAD_LIBS) $(ALSA_LIBS) $(LIBAGG_LIBS) $(LIBSOUNDTOUCH_LIBS)
if HAVE_LIBOSMESA
desmume_LDADD += $(OSMESA_LIBS)
else
endif
UPDATE_DESKTOP = \
appsdir=$(DESTDIR)$(datadir)/applications ; \
if [ -f $$appsdir/mimeinfo.cache ] ; then \
if test ! "x$(UPDATEDESKTOP)" = "x" ; then \
$(UPDATEDESKTOP) $$appsdir ; \
fi \
fi
install-data-hook:
$(UPDATE_DESKTOP)
uninstall-hook:
$(UPDATE_DESKTOP)

View File

@ -0,0 +1,32 @@
/*
Copyright (C) 2014 DeSmuME team
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the this software. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _AVOUT_H_
#define _AVOUT_H_
#include "types.h"
class AVOut {
public:
virtual bool begin(const char* fname) { return false; }
virtual void end() {}
virtual bool isRecording() { return false; }
virtual void updateAudio(void* soundData, int soundLen) {}
virtual void updateVideo(const u16* buffer) {}
};
#endif

View File

@ -0,0 +1,61 @@
/*
Copyright (C) 2014 DeSmuME team
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the this software. If not, see <http://www.gnu.org/licenses/>.
*/
#include <cstdlib>
#include <cstring>
#include "avout_flac.h"
#include "SPU.h"
// Helper macros to convert numerics to strings
#if defined(_MSC_VER)
//re: http://72.14.203.104/search?q=cache:HG-okth5NGkJ:mail.python.org/pipermail/python-checkins/2002-November/030704.html+_msc_ver+compiler+version+string&hl=en&gl=us&ct=clnk&cd=5
#define _Py_STRINGIZE(X) _Py_STRINGIZE1((X))
#define _Py_STRINGIZE1(X) _Py_STRINGIZE2 ## X
#define _Py_STRINGIZE2(X) #X
#define TOSTRING(X) _Py_STRINGIZE(X) // Alias _Py_STRINGIZE so that we have a common macro name
#else
#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x)
#endif
AVOutFlac::AVOutFlac() {
const char* const args[] = {
"flac",
"-f",
"-o", this->filename,
"--endian=little",
"--channels=2",
"--bps=16",
"--sample-rate=" TOSTRING(DESMUME_SAMPLE_RATE),
"--sign=signed",
"--force-raw-format",
"-",
NULL
};
memcpy(this->args, args, sizeof(args));
}
const char* const* AVOutFlac::getArgv(const char* fname) {
if (strlen(fname) >= sizeof(this->filename)) {
return NULL;
}
strncpy(this->filename, fname, sizeof(this->filename));
return this->args;
}

View File

@ -0,0 +1,34 @@
/*
Copyright (C) 2014 DeSmuME team
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the this software. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _AVOUT_FLAC_H_
#define _AVOUT_FLAC_H_
#include "avout_pipe_base.h"
class AVOutFlac : public AVOutPipeBase {
public:
AVOutFlac();
protected:
Type type() { return TYPE_AUDIO; }
const char* const* getArgv(const char* fname);
private:
char filename[1024];
const char* args[12];
};
#endif

View File

@ -0,0 +1,102 @@
/*
Copyright (C) 2014 DeSmuME team
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the this software. If not, see <http://www.gnu.org/licenses/>.
*/
#include <unistd.h>
#include <cerrno>
#include "types.h"
#include "SPU.h"
#include "avout_pipe_base.h"
static inline int writeAll(int fd, const void* buf, size_t count) {
ssize_t written = 0, writtenTotal = 0;
do {
written = write(fd, ((u8*)buf) + writtenTotal, count - writtenTotal);
} while (written >= 0 && (writtenTotal += written) < count);
return written;
}
bool AVOutPipeBase::begin(const char* fname) {
if (this->recording) {
return false;
}
const char* const* args = this->getArgv(fname);
if (args == NULL) {
return false;
}
int pipefd[2];
if (pipe(pipefd) < 0) {
fprintf(stderr, "Fail to open pipe\n");
return false;
}
pid_t pid = fork();
if (pid == 0) {
close(pipefd[1]);
dup2(pipefd[0], STDIN_FILENO);
execvp(args[0], (char* const*)args);
fprintf(stderr, "Fail to start %s: %d %s\n", args[0], errno, strerror(errno));
_exit(1);
}
close(pipefd[0]);
this->pipe_fd = pipefd[1];
this->recording = true;
return true;
}
void AVOutPipeBase::end() {
if (this->recording) {
close(this->pipe_fd);
this->recording = false;
}
}
bool AVOutPipeBase::isRecording() {
return this->recording;
}
void AVOutPipeBase::updateAudio(void* soundData, int soundLen) {
if(!this->recording || this->type() != TYPE_AUDIO) {
return;
}
if (writeAll(this->pipe_fd, soundData, soundLen * 2 * 2) == -1) {
fprintf(stderr, "Error on writing audio: %d %s\n", errno, strerror(errno));
this->end();
}
}
void AVOutPipeBase::updateVideo(const u16* buffer) {
if(!this->recording || this->type() != TYPE_VIDEO) {
return;
}
u8 rgb[256 * 384 * 3];
u8* cur = rgb;
for (int i = 0; i < 256 * 384; i++) {
u16 gpu_pixel = buffer[i];
*cur = ((gpu_pixel >> 0) & 0x1f) << 3;
cur++;
*cur = ((gpu_pixel >> 5) & 0x1f) << 3;
cur++;
*cur = ((gpu_pixel >> 10) & 0x1f) << 3;
cur++;
}
if (write(this->pipe_fd, rgb, 256 * 384 * 3) == -1) {
fprintf(stderr, "Error on writing video: %d %s\n", errno, strerror(errno));
this->end();
}
}

View File

@ -0,0 +1,39 @@
/*
Copyright (C) 2014 DeSmuME team
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the this software. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _AVOUT_PIPE_BASE_H_
#define _AVOUT_PIPE_BASE_H_
#include "avout.h"
class AVOutPipeBase : public AVOut {
public:
bool begin(const char* fname);
void end();
bool isRecording();
void updateAudio(void* soundData, int soundLen);
void updateVideo(const u16* buffer);
protected:
enum Type { TYPE_AUDIO, TYPE_VIDEO };
virtual Type type() = 0;
virtual const char* const* getArgv(const char* fname) = 0;
private:
bool recording;
int pipe_fd;
};
#endif

View File

@ -0,0 +1,47 @@
/*
Copyright (C) 2014 DeSmuME team
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the this software. If not, see <http://www.gnu.org/licenses/>.
*/
#include <cstdlib>
#include <cstring>
#include "avout_x264.h"
AVOutX264::AVOutX264() {
const char* const args[] = {
"x264",
"--qp", "0",
"--demuxer", "raw",
"--input-csp", "rgb",
"--input-depth", "8",
"--input-res", "256x384",
"--fps", "60",
"--output-csp", "i444",
"-o", this->filename,
"-",
NULL
};
memcpy(this->args, args, sizeof(args));
}
const char* const* AVOutX264::getArgv(const char* fname) {
if (strlen(fname) >= sizeof(this->filename)) {
return NULL;
}
strncpy(this->filename, fname, sizeof(this->filename));
return this->args;
}

View File

@ -0,0 +1,34 @@
/*
Copyright (C) 2014 DeSmuME team
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the this software. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _AVOUT_X264_H_
#define _AVOUT_X264_H_
#include "avout_pipe_base.h"
class AVOutX264 : public AVOutPipeBase {
public:
AVOutX264();
protected:
Type type() { return TYPE_VIDEO; }
const char* const* getArgv(const char* fname);
private:
char filename[1024];
const char* args[19];
};
#endif

View File

@ -0,0 +1,440 @@
/* cheats.cpp - this file is part of DeSmuME
*
* Copyright (C) 2006-2009 DeSmuME Team
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <stdio.h>
#include <stdlib.h>
#include <gtk/gtk.h>
#include "cheatsGTK.h"
#include "cheatSystem.h"
#include "main.h"
#include "desmume.h"
#undef GPOINTER_TO_INT
#define GPOINTER_TO_INT(p) ((gint) (glong) (p))
enum {
COLUMN_ENABLED,
COLUMN_SIZE,
COLUMN_HI,
COLUMN_LO,
COLUMN_DESC,
NUM_COL
};
enum
{
COLUMN_SIZE_TEXT,
NUM_SIZE_COLUMNS
};
enum {
TYPE_TOGGLE,
TYPE_COMBO,
TYPE_STRING
};
static struct {
const gchar *caption;
gint type;
gint column;
} columnTable[]={
{ "Enabled", TYPE_TOGGLE, COLUMN_ENABLED},
{ "Size", TYPE_COMBO, COLUMN_SIZE},
{ "Offset", TYPE_STRING, COLUMN_HI},
{ "Value", TYPE_STRING, COLUMN_LO},
{ "Description", TYPE_STRING, COLUMN_DESC}
};
static GtkWidget *win = NULL;
static BOOL shouldBeRunning = FALSE;
// ---------------------------------------------------------------------------------
// SEARCH
// ---------------------------------------------------------------------------------
static void
enabled_toggled(GtkCellRendererToggle * cell,
gchar * path_str, gpointer data)
{
GtkTreeModel *model = (GtkTreeModel *) data;
GtkTreeIter iter;
GtkTreePath *path = gtk_tree_path_new_from_string(path_str);
gboolean enabled;
gtk_tree_model_get_iter(model, &iter, path);
gtk_tree_model_get(model, &iter, COLUMN_ENABLED, &enabled, -1);
enabled ^= 1;
CHEATS_LIST cheat;
u32 ii;
GtkTreePath *path1;
path1 = gtk_tree_model_get_path (model, &iter);
ii = gtk_tree_path_get_indices (path)[0];
cheats->get(&cheat, ii);
cheats->update(cheat.size, cheat.code[0][0], cheat.code[0][1], cheat.description,
enabled, ii);
gtk_list_store_set(GTK_LIST_STORE(model), &iter, COLUMN_ENABLED, enabled, -1);
gtk_tree_path_free(path);
}
static void cheat_list_modify_cheat(GtkCellRendererText * cell,
const gchar * path_string,
const gchar * new_text, gpointer data)
{
GtkTreeModel *model = (GtkTreeModel *) data;
GtkTreePath *path = gtk_tree_path_new_from_string(path_string);
GtkTreeIter iter;
gint column =
GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cell), "column"));
gtk_tree_model_get_iter(model, &iter, path);
{
u32 ii;
GtkTreePath *path1;
CHEATS_LIST cheat;
path1 = gtk_tree_model_get_path (model, &iter);
ii = gtk_tree_path_get_indices (path)[0];
cheats->get(&cheat, ii);
gtk_tree_path_free (path1);
if (column == COLUMN_LO || column == COLUMN_HI
|| column == COLUMN_SIZE) {
u32 v = atoi(new_text);
switch (column) {
case COLUMN_SIZE:
cheats->update(v-1, cheat.code[0][0], cheat.code[0][1],
cheat.description, cheat.enabled, ii);
break;
case COLUMN_HI:
cheats->update(cheat.size, v, cheat.code[0][1], cheat.description,
cheat.enabled, ii);
break;
case COLUMN_LO:
cheats->update(cheat.size, cheat.code[0][0], v, cheat.description,
cheat.enabled, ii);
break;
}
gtk_list_store_set(GTK_LIST_STORE(model), &iter, column,
atoi(new_text), -1);
} else if (column == COLUMN_DESC){
cheats->update(cheat.size, cheat.code[0][0], cheat.code[0][1],
g_strdup(new_text), cheat.enabled, ii);
gtk_list_store_set(GTK_LIST_STORE(model), &iter, column,
g_strdup(new_text), -1);
}
}
}
static void cheat_list_remove_cheat(GtkWidget * widget, gpointer data)
{
GtkTreeView *tree = (GtkTreeView *) data;
GtkTreeSelection *selection = gtk_tree_view_get_selection (tree);
GtkTreeModel *model = gtk_tree_view_get_model (tree);
GtkTreeIter iter;
if (gtk_tree_selection_get_selected (selection, NULL, &iter)){
u32 ii;
GtkTreePath *path;
path = gtk_tree_model_get_path (model, &iter);
ii = gtk_tree_path_get_indices (path)[0];
gtk_list_store_remove(GTK_LIST_STORE(model), &iter);
cheats->remove(ii);
gtk_tree_path_free (path);
}
}
static void cheat_list_add_cheat(GtkWidget * widget, gpointer data)
{
#define NEW_DESC "New cheat"
GtkListStore *store = (GtkListStore *) data;
GtkTreeIter iter;
cheats->add(1, 0, 0, g_strdup(NEW_DESC), FALSE);
gtk_list_store_append(store, &iter);
gtk_list_store_set(store, &iter,
COLUMN_ENABLED, FALSE,
COLUMN_SIZE, 1,
COLUMN_HI, 0,
COLUMN_LO, 0, COLUMN_DESC, NEW_DESC, -1);
#undef NEW_DESC
}
static GtkTreeModel * create_numbers_model (void)
{
#define N_NUMBERS 4
gint i = 0;
GtkListStore *model;
GtkTreeIter iter;
/* create list store */
model = gtk_list_store_new (NUM_SIZE_COLUMNS, G_TYPE_STRING, G_TYPE_INT);
/* add numbers */
for (i = 1; i < N_NUMBERS+1; i++)
{
char str[2];
str[0] = '0' + i;
str[1] = '\0';
gtk_list_store_append (model, &iter);
gtk_list_store_set (model, &iter,
COLUMN_SIZE_TEXT, str,
-1);
}
return GTK_TREE_MODEL (model);
#undef N_NUMBERS
}
static void cheat_list_add_columns(GtkTreeView * tree, GtkListStore * store)
{
GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(tree));
static GtkTreeModel * size_model;
for (u32 ii = 0; ii < sizeof(columnTable) / sizeof(columnTable[0]); ii++) {
GtkCellRenderer *renderer = NULL;
GtkTreeViewColumn *column;
const gchar *attrib = NULL;
switch (columnTable[ii].type) {
case TYPE_TOGGLE:
renderer = gtk_cell_renderer_toggle_new();
g_signal_connect(renderer, "toggled",
G_CALLBACK(enabled_toggled), model);
attrib = "active";
break;
case TYPE_STRING:
renderer = gtk_cell_renderer_text_new();
g_object_set(renderer, "editable", TRUE, NULL);
g_signal_connect(renderer, "edited",
G_CALLBACK(cheat_list_modify_cheat), store);
attrib = "text";
break;
case TYPE_COMBO:
renderer = gtk_cell_renderer_combo_new();
size_model = create_numbers_model();
g_object_set(renderer,
"model", size_model,
"text-column", COLUMN_SIZE_TEXT,
"editable", TRUE,
"has-entry", FALSE,
NULL);
g_object_unref(size_model);
g_signal_connect(renderer, "edited",
G_CALLBACK(cheat_list_modify_cheat), store);
attrib = "text";
break;
}
column =
gtk_tree_view_column_new_with_attributes(columnTable[ii].
caption, renderer,
attrib, columnTable[ii].column,
NULL);
g_object_set_data(G_OBJECT(renderer), "column",
GINT_TO_POINTER(columnTable[ii].column));
gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);
}
}
static void cheatListEnd()
{
cheats->save();
if(shouldBeRunning)
Launch();
}
static GtkListStore *cheat_list_populate()
{
GtkListStore *store = gtk_list_store_new (5, G_TYPE_BOOLEAN,
G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_STRING);
CHEATS_LIST cheat;
u32 chsize = cheats->getSize();
for(u32 ii = 0; ii < chsize; ii++){
GtkTreeIter iter;
cheats->get(&cheat, ii);
gtk_list_store_append(store, &iter);
gtk_list_store_set(store, &iter,
COLUMN_ENABLED, cheat.enabled,
COLUMN_SIZE, cheat.size+1,
COLUMN_HI, cheat.code[0][0],
COLUMN_LO, cheat.code[0][1],
COLUMN_DESC, cheat.description,
-1);
}
return store;
}
static GtkWidget *cheat_list_create_ui()
{
GtkListStore *store = cheat_list_populate();
GtkWidget *tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));
GtkWidget *vbox = gtk_vbox_new(FALSE, 1);
GtkWidget *hbbox = gtk_hbutton_box_new();
GtkWidget *button;
gtk_container_add(GTK_CONTAINER(vbox), GTK_WIDGET(tree));
gtk_container_add(GTK_CONTAINER(vbox), GTK_WIDGET(hbbox));
gtk_container_add(GTK_CONTAINER(win), GTK_WIDGET(vbox));
button = gtk_button_new_with_label("add cheat");
g_signal_connect (button, "clicked", G_CALLBACK (cheat_list_add_cheat), store);
gtk_container_add(GTK_CONTAINER(hbbox),button);
button = gtk_button_new_with_label("Remove cheat");
g_signal_connect (button, "clicked", G_CALLBACK (cheat_list_remove_cheat), tree);
gtk_container_add(GTK_CONTAINER(hbbox),button);
cheat_list_add_columns(GTK_TREE_VIEW(tree), store);
/* Setup the selection handler */
GtkTreeSelection *select;
select = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree));
gtk_tree_selection_set_mode (select, GTK_SELECTION_SINGLE);
return tree;
}
void CheatList ()
{
shouldBeRunning = desmume_running();
Pause();
win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(win),"Cheat List");
gtk_window_set_modal(GTK_WINDOW(win), TRUE);
g_signal_connect(G_OBJECT(win), "destroy", cheatListEnd, NULL);
cheat_list_create_ui();
gtk_widget_show_all(win);
}
// ---------------------------------------------------------------------------------
// SEARCH
// ---------------------------------------------------------------------------------
static void cheat_search_create_ui()
{
GtkWidget *button;
GtkWidget *vbox = gtk_vbox_new(FALSE, 1);
GtkWidget *hbbox = gtk_hbutton_box_new();
GtkWidget *b;
gtk_container_add(GTK_CONTAINER(win), GTK_WIDGET(vbox));
{
b = gtk_hbox_new(FALSE, 1);
gtk_container_add(GTK_CONTAINER(vbox), GTK_WIDGET(b));
{
GtkTreeModel * size_model;
GtkWidget *w;
w = gtk_label_new("size");
gtk_container_add(GTK_CONTAINER(b), w);
size_model = create_numbers_model();
w = gtk_combo_box_new_with_model(size_model);
g_object_unref(size_model);
GtkCellRenderer * renderer = gtk_cell_renderer_text_new ();
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (w), renderer, TRUE);
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (w), renderer,
"text", COLUMN_SIZE_TEXT,
NULL);
gtk_combo_box_set_active (GTK_COMBO_BOX (w), 0);
gtk_container_add(GTK_CONTAINER(b), w);
}
b = gtk_hbox_new(FALSE, 1);
gtk_container_add(GTK_CONTAINER(vbox), GTK_WIDGET(b));
{
GtkWidget *w;
w = gtk_label_new("signedness");
gtk_container_add(GTK_CONTAINER(b), w);
// m = create_sign_model();
w = gtk_combo_box_new();
// w = gtk_combo_box_new_with_model(size_model);
// g_object_unref(size_model);
// size_model = NULL;
GtkCellRenderer * renderer = gtk_cell_renderer_text_new ();
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (w), renderer, TRUE);
// gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (w), renderer,
// "text", COLUMN_SIZE_TEXT,
// NULL);
gtk_combo_box_set_active (GTK_COMBO_BOX (w), 0);
gtk_container_add(GTK_CONTAINER(b), w);
}
}
// BUTTONS:
gtk_container_add(GTK_CONTAINER(vbox), GTK_WIDGET(hbbox));
button = gtk_button_new_with_label("add cheats");
// g_signal_connect (button, "clicked", g_callback (cheat_list_add_cheat), store);
gtk_container_add(GTK_CONTAINER(hbbox),button);
button = gtk_button_new_with_label("search");
// g_signal_connect (button, "clicked", g_callback (cheat_list_add_cheat), store);
gtk_container_add(GTK_CONTAINER(hbbox),button);
// GtkWidget *vbox = gtk_vbox_new(FALSE, 1);
// gtk_container_add(GTK_CONTAINER(win), GTK_WIDGET(vbox));
}
static void cheatSearchEnd()
{
}
void CheatSearch ()
{
shouldBeRunning = desmume_running();
Pause();
win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(win),"Cheat Search");
gtk_window_set_modal(GTK_WINDOW(win), TRUE);
g_signal_connect(G_OBJECT(win), "destroy", cheatSearchEnd, NULL);
cheat_search_create_ui();
gtk_widget_show_all(win);
}

View File

@ -0,0 +1,29 @@
/* cheatsGtk.h - this file is part of DeSmuME
*
* Copyright (C) 2006,2007 DeSmuME Team
* Copyright (C) 2007 Pascal Giard (evilynux)
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __CHEATS_H__
#define __CHEATS_H__
void CheatSearch ();
void CheatList ();
#endif /*__CHEATS_H__*/

View File

@ -0,0 +1,9 @@
#!/bin/sh
for filename in desmume.app/libs/*
do
echo $filename
otool -L $filename | grep "Cairo.framework"
otool -L $filename | grep "Gtk.framework"
otool -L $filename | grep "GLib.framework"
done;

View File

@ -0,0 +1,166 @@
/*
Copyright (C) 2014 DeSmuME team
Copyright (C) 2014 Alvin Wong
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the this software. If not, see <http://www.gnu.org/licenses/>.
*/
#include <glib.h>
#include <glib/gstdio.h>
#include "config.h"
using std::string;
using std::vector;
namespace desmume {
namespace config {
/* class value<bool> */
template<>
void value<bool>::load() {
GError* err = NULL;
bool val = g_key_file_get_boolean(this->mKeyFile, this->mSection.c_str(), this->mKey.c_str(), &err);
if (err != NULL) {
g_error_free(err);
} else {
this->mData = val;
}
}
template<>
void value<bool>::save() {
g_key_file_set_boolean(this->mKeyFile, this->mSection.c_str(), this->mKey.c_str(), this->mData ? TRUE : FALSE);
}
/* class value<int> */
template<>
void value<int>::load() {
GError* err = NULL;
int val = g_key_file_get_integer(this->mKeyFile, this->mSection.c_str(), this->mKey.c_str(), &err);
if (err != NULL) {
g_error_free(err);
} else {
this->mData = val;
}
}
template<>
void value<int>::save() {
g_key_file_set_integer(this->mKeyFile, this->mSection.c_str(), this->mKey.c_str(), this->mData);
}
/* class value<string> */
template<>
void value<string>::load() {
char* val = g_key_file_get_string(this->mKeyFile, this->mSection.c_str(), this->mKey.c_str(), NULL);
if (val != NULL) {
this->mData = val;
g_free(val);
}
}
template<>
void value<string>::save() {
g_key_file_set_string(this->mKeyFile, this->mSection.c_str(), this->mKey.c_str(), this->mData.c_str());
}
/* class Config */
Config::Config()
: mKeyFile(g_key_file_new())
# define OPT(name, type, default, section, key) \
, name(default, #section, #key)
# include "config_opts.h"
# undef OPT
{
# define OPT(name, type, default, section, key) \
this->name.mKeyFile = this->mKeyFile;
# include "config_opts.h"
# undef OPT
}
Config::~Config() {
g_key_file_free(this->mKeyFile);
}
void Config::load() {
char* config_dir = g_build_filename(g_get_user_config_dir(), "desmume", NULL);
g_mkdir_with_parents(config_dir, 0755);
char* config_file = g_build_filename(config_dir, "config.cfg", NULL);
g_key_file_load_from_file(this->mKeyFile, config_file, G_KEY_FILE_KEEP_COMMENTS, NULL);
g_free(config_file);
g_free(config_dir);
# define OPT(name, type, default, section, key) \
this->name.load();
# include "config_opts.h"
# undef OPT
}
void Config::save() {
# define OPT(name, type, default, section, key) \
this->name.save();
# include "config_opts.h"
# undef OPT
gsize length;
char* data = g_key_file_to_data(this->mKeyFile, &length, NULL);
char* config_dir = g_build_filename(g_get_user_config_dir(), "desmume", NULL);
g_mkdir_with_parents(config_dir, 0755);
char* config_file = g_build_filename(config_dir, "config.cfg", NULL);
g_file_set_contents(config_file, data, length, NULL);
g_free(config_file);
g_free(config_dir);
g_free(data);
}
#if 0
/* class Config::Input */
Config::Input::Input()
: keys(NB_KEYS)
, joykeys(NB_KEYS)
{
static const u16 gtk_kb_cfg[NB_KEYS] = {
GDK_x, // A
GDK_z, // B
GDK_Shift_R, // select
GDK_Return, // start
GDK_Right, // Right
GDK_Left, // Left
GDK_Up, // Up
GDK_Down, // Down
GDK_w, // R
GDK_q, // L
GDK_s, // X
GDK_a, // Y
GDK_p, // DEBUG
GDK_o, // BOOST
GDK_BackSpace, // Lid
};
for (size_t i = 0; i < NB_KEYS; i++) {
this->keys[i] = new value<int>(gtk_kb_cfg[i], "Keys", ...);
}
}
void Config::Input::load();
void Config::Input::save();
#endif
} /* namespace config */
} /* namespace desmume */

View File

@ -0,0 +1,113 @@
/*
Copyright (C) 2014 DeSmuME team
Copyright (C) 2014 Alvin Wong
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the this software. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DESMUME_CONFIG_CLASS_H_
#define DESMUME_CONFIG_CLASS_H_
#include <string>
#include <vector>
#include <glib.h>
namespace desmume {
namespace config {
template<class T>
class value {
friend class Config;
std::string mSection;
std::string mKey;
GKeyFile* mKeyFile;
T mDefaultVal;
T mData;
value(const value&); // DO NOT IMPLEMENT
value operator=(const value&); // DO NOT IMPLEMENT
void load();
void save();
public:
value(const T& defaultVal, const std::string& section, const std::string& key)
: mSection(section)
, mKey(key)
, mDefaultVal(defaultVal)
, mData(defaultVal) {}
inline T defaultVal() {
return this->mDefaultVal;
}
inline T get() {
return this->mData;
}
inline operator T() {
return this->mData;
}
inline void set(const T& value) {
this->mData = value;
//this->save();
}
inline T operator=(const T& value) {
this->mData = value;
return this->mData;
}
}; /* class value<T> */
#ifdef OPT
# undef OPT
#endif
class Config {
protected:
GKeyFile* mKeyFile;
Config(const Config&); // DO NOT IMPLEMENT
Config operator=(const Config&); // DO NOT IMPLEMENT
public:
// member fields
# define OPT(name, type, default, section, key) \
value<type> name;
# include "config_opts.h"
# undef OPT
#if 0
// Special case: input config
class Input {
friend class Config;
std::vector<value<int>*> keys;
std::vector<value<int>*> joykeys;
Input();
void load();
void save();
} inputs;
#endif
// constructor
Config();
// methods
virtual ~Config();
void load();
void save();
}; /* class Config */
#undef DESMUME_CONFIG_CONFIG
} /* namespace config */
} /* namespace desmume */
#endif /* DESMUME_CONFIG_CLASS_H_ */

View File

@ -0,0 +1,74 @@
/*
Copyright (C) 2014 DeSmuME team
Copyright (C) 2014 Alvin Wong
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the this software. If not, see <http://www.gnu.org/licenses/>.
*/
/*
This file contains a list of config options.
#define OPT(name, type, default, section, key)
*/
/* View */
OPT(view_orient, int, 0, View, ScreenLayout)
OPT(view_swap, bool, false, View, SwapScreens)
OPT(view_rot, int, 0, View, Rotation)
OPT(view_gap, bool, false, View, ScreenGap)
OPT(view_filter, int, 0, View, Filter)
OPT(view_cairoFilter, int, 3, View, SecondaryFilter) /* default: nearest-neighbour */
OPT(view_menu, bool, true, View, ShowMenu)
OPT(view_toolbar, bool, true, View, ShowToolbar)
OPT(view_statusbar, bool, true, View, ShowStatusbar)
/* Window */
OPT(window_scale, int, 0, Window, Scale2x)
/*OPT(window_x, int, -1, Window, X)*/
/*OPT(window_y, int, -1, Window, Y)*/
/*OPT(window_w, int, 0, Window, Width)*/
/*OPT(window_h, int, 0, Window, Height)*/
/*OPT(window_maximized, bool, false, Window, Maximized)*/
OPT(window_fullscreen, bool, false, Window, Fullscreen)
/* HUD display */
OPT(hud_fps, bool, false, HudDisplay, Fps)
OPT(hud_frameCounter, bool, false, HudDisplay, FrameCounter)
OPT(hud_lagCounter, bool, false, HudDisplay, LagCounter)
OPT(hud_input, bool, false, HudDisplay, Input)
OPT(hud_graphicalInput, bool, false, HudDisplay, GraphicalInput)
OPT(hud_rtc, bool, false, HudDisplay, RTC)
OPT(hud_mic, bool, false, HudDisplay, Mic)
/* Config */
OPT(fpslimiter, bool, true, Config, FpsLimiter)
OPT(autoframeskip, bool, true, Config, AudoFrameskip)
OPT(frameskip, int, 0, Config, Frameskip)
OPT(use_jit,bool,false,Config,JIT_Enabled)
OPT(jit_max_block_size,int,100,Config,JITBlockSize)
OPT(core3D, int, 1, Config, Core3D)
OPT(textureDeposterize, bool, false, Config, 3DTextureDeposterization)
OPT(textureSmoothing, bool, false, Config, 3DTextureSmoothing)
OPT(textureUpscale, int, 1, Config, 3DTextureUpscaling)
OPT(highColorInterpolation, bool, true, Config, HighResolutionColorInterpolation)
OPT(multisampling, bool, false, Config, OpenGLMultisampling)
OPT(multisamplingSize, int, 0, Config, OpenGLMultisamplingSize)
OPT(command_line_overriding_firmware_language, bool, false, Config, CommandLineOverridingFirmwareLanguage)
OPT(firmware_language, int, 1, Config, FirmwareLanguage)
/* Audio */
OPT(audio_enabled, bool, true, Audio, Enabled)
OPT(audio_sync, int, 0, Audio, Synchronization)
OPT(audio_interpolation, int, 1, Audio, Interpolation)
OPT(audio_volume, int, 128, Audio, Volume)

View File

@ -0,0 +1,20 @@
#ifndef __DTOOL_H__
#define __DTOOL_H__
typedef void (*dTool_openFn)(int id);
typedef void (*dTool_updateFn)();
typedef void (*dTool_closeFn)();
typedef struct
{
/* this should be the same name of the action in the gui xml */
const char shortname[16];
const char name[32];
dTool_openFn open;
dTool_updateFn update;
dTool_closeFn close;
} dTool_t;
extern void dTool_CloseCallback(int id);
#endif /*__DTOOL_H__*/

View File

@ -0,0 +1,33 @@
/* dToolsList.cpp
*
* Copyright (C) 2006 Thoduv
* Copyright (C) 2006-2015 DeSmuME Team
*
* This file is part of DeSmuME
*
* DeSmuME is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* DeSmuME is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with DeSmuME; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "dTool.h"
#include "../types.h"
#include "tools/ioregsView.h"
dTool_t *dTools_list[] =
{
&dTool_ioregsView
};
int dTools_list_size = ARRAY_SIZE(dTools_list);

View File

@ -0,0 +1,74 @@
/* desmume.c - this file is part of DeSmuME
*
* Copyright (C) 2006-2015 DeSmuME Team
* Copyright (C) 2007 Pascal Giard (evilynux)
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "desmume.h"
#include "../NDSSystem.h"
#include "../SPU.h"
#include "../shared/sndsdl.h"
#include "../movie.h"
volatile bool execute = false;
BOOL click = FALSE;
void desmume_init( int disable_sound)
{
NDS_Init();
if ( !disable_sound) {
SPU_ChangeSoundCore(SNDCORE_SDL, 735 * 4);
}
execute = false;
}
void desmume_free( void)
{
execute = false;
NDS_DeInit();
}
void desmume_pause( void)
{
execute = false;
SPU_Pause(1);
}
void desmume_resume( void)
{
execute = true;
SPU_Pause(0);
}
void desmume_toggle( void)
{
execute ^= true;
}
bool desmume_running( void)
{
return execute;
}
void desmume_cycle( void)
{
FCEUMOV_AddInputState();
NDS_exec<false>();
SPU_Emulate_user();
}

View File

@ -0,0 +1,10 @@
[Desktop Entry]
Version=1.0
Type=Application
Name=DeSmuME (Gtk)
Comment=Nintento DS emulator
TryExec=desmume
Exec=desmume
Icon=DeSmuME
Categories=GNOME;GTK;Game;Emulator;
MimeType=application/x-nintendo-ds-rom;

View File

@ -0,0 +1,36 @@
/* desmume.h - this file is part of DeSmuME
*
* Copyright (C) 2006,2007 DeSmuME Team
* Copyright (C) 2007 Pascal Giard (evilynux)
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __DESMUME_H__
#define __DESMUME_H__
extern void desmume_init( int disable_sound);
extern void desmume_free( void);
extern void desmume_pause( void);
extern void desmume_resume( void);
extern void desmume_toggle( void);
extern bool desmume_running( void);
extern void desmume_cycle( void);
#endif /*__DESMUME_H__*/

View File

@ -0,0 +1 @@
dist_man_MANS = desmume.1

View File

@ -0,0 +1,169 @@
.\" Hey, EMACS: -*- nroff -*-
.\" First parameter, NAME, should be all caps
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
.\" other parameters are allowed: see man(7), man(1)
.TH DESMUME 1 "June 26, 2007"
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
.\" .nh disable hyphenation
.\" .hy enable hyphenation
.\" .ad l left justify
.\" .ad b justify to both left and right margins
.\" .nf disable filling
.\" .fi enable filling
.\" .br insert line break
.\" .sp <n> insert n+1 empty lines
.\" for manpage-specific macros, see man(7)
.SH NAME
desmume \- Nintendo DS emulator
.SH SYNOPSIS
.B desmume
.RI [ options ] " files" ...
.SH DESCRIPTION
This manual page documents briefly the
.B desmume
program
.PP
.\" TeX users may be more comfortable with the \fB<whatever>\fP and
.\" \fI<whatever>\fP escape sequences to invode bold face and italics,
.\" respectively.
\fBdesmume\fP is a Nintendo DS emulator running homebrew demos and commercial games.
.SH OPTIONS
These programs follow the usual GNU command line syntax, with long
options starting with two dashes (`-').
A summary of options is included below.
.TP
.B \-\-load-slot=NUM
Loads savegame from slot NUM
.TP
.B \-\-opengl-2d
Enables using OpenGL for screen rendering
.TP
.B \-\-soft-convert
Use software colour conversion during OpenGL screen rendering. May produce better or worse frame rates depending on hardware.
.TP
.B \-\-3d-engine=ENGINE
Select available 3d emulation:
.RS
0 = 3d disabled
.RE
.RS
1 = internal desmume software rasterizer (default)
.RE
.RS
2 = osmesa or gtkglext opengl (if available, depending on compilation options, see desmume \-\-help)
.RE
.TP
.B \-\-disable-sound
Disables the sound emulation
.TP
.B \-\-disable-limiter
Disables the 60 fps limiter
.TP
.B \-\-arm9gdb=PORT_NUM
Enable the ARM9 GDB stub on the given port
.TP
.B \-\-arm7gdb=PORT_NUM
Enable the ARM7 GDB stub on the given port
.TP
.B \-\-save-type=TYPE
Select savetype from the following:
.RS
0 = Autodetect
.RE
.RS
1 = EEPROM 4kbit
.RE
.RS
2 = EEPROM 64kbit
.RE
.RS
3 = EEPROM 512kbit
.RE
.RS
4 = FRAM 256kbit
.RE
.RS
5 = FLASH 2mbit
.RE
.RS
6 = FLASH 4mbit
.RE
.TP
.B \-\-fwlang=LANG
Set the language in the firmware, LANG as follows:
.RS
0 = Japanese
.RE
.RS
1 = English
.RE
.RS
2 = French
.RE
.RS
3 = German
.RE
.RS
4 = Italian
.RE
.RS
5 = Spanish
.RE
.TP
.B \-\-cflash=PATH_TO_DISK_IMAGE
Enable disk image GBAMP compact flash emulation
.TP
.B \-h, \-\-help
Show summary of options.
.TP
.B \-v, \-\-version
Show version of program.
.SH INPUT
Mouse cursor acts as stylus, mouse click replaces stylus touch.
.PP
Keyboard can be configured and by default works as follows:
.RS
F1-F10 load savegame from slot 1-10
.RE
.RS
Shift+F1-F10 save game to slot 1-10
.RE
.RS
Non-keypad arrows act as d-pad
.RE
.RS
z = A
.RE
.RS
x = B
.RE
.RS
a = Y
.RE
.RS
s = X
.RE
.RS
q = L
.RE
.RS
w = R
.RE
.RS
Enter = START
.RE
.RS
Left Shift = SELECT
.RE
.RS
Backspace = LID
.RE
.PP
Desmume accepts joystick events, which can be configured by user.
.SH AUTHOR
desmume was written by DeSmuME team
(http://sourceforge.net/projects/desmume).
.PP
This manual page was written by Reinhard Tartler <siretart@tauware.de> and modified by Pascal Giard <pascal@debian.org>, for the Debian project (but may be used by others).

Binary file not shown.

View File

@ -0,0 +1,94 @@
/*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "Settings.h"
#include <vector>
#include <iostream>
namespace Settings
{
bool overwrite_files = false;
bool overwrite_dir = false;
bool create_dir = false;
bool canOverwriteFiles(){ return overwrite_files; }
bool canOverwriteDir(){ return overwrite_dir; }
bool canCreateDir(){ return create_dir; }
void canOverwriteFiles(bool permission){ overwrite_files = permission; }
void canOverwriteDir(bool permission){ overwrite_dir = permission; }
void canCreateDir(bool permission){ create_dir = permission; }
bool bundleLibs_bool = false;
bool bundleLibs(){ return bundleLibs_bool; }
void bundleLibs(bool on){ bundleLibs_bool = on; }
std::string dest_folder_str = "./libs/";
std::string destFolder(){ return dest_folder_str; }
void destFolder(std::string path)
{
dest_folder_str = path;
// fix path if needed so it ends with '/'
if( dest_folder_str[ dest_folder_str.size()-1 ] != '/' ) dest_folder_str += "/";
}
std::vector<std::string> files;
void addFileToFix(std::string path){ files.push_back(path); }
int fileToFixAmount(){ return files.size(); }
std::string fileToFix(const int n){ return files[n]; }
std::string inside_path_str = "@executable_path/../libs/";
std::string inside_lib_path(){ return inside_path_str; }
void inside_lib_path(std::string p)
{
inside_path_str = p;
// fix path if needed so it ends with '/'
if( inside_path_str[ inside_path_str.size()-1 ] != '/' ) inside_path_str += "/";
}
std::vector<std::string> prefixes_to_ignore;
void ignore_prefix(std::string prefix)
{
if( prefix[ prefix.size()-1 ] != '/' ) prefix += "/";
prefixes_to_ignore.push_back(prefix);
}
bool isPrefixBundled(std::string prefix)
{
//std::cout << "Testing " << prefix << " : " << std::endl;
if(prefix.find("Gtk.framework") == std::string::npos
&& prefix.find("GLib.framework") == std::string::npos
&& prefix.find("Cairo.framework") == std::string::npos)
if(prefix.find(".framework") != std::string::npos) return false;
if(prefix.find("@executable_path") != std::string::npos) return false;
if(prefix.compare("/usr/lib/") == 0) return false;
const int prefix_amount = prefixes_to_ignore.size();
for(int n=0; n<prefix_amount; n++)
{
if(prefix.compare(prefixes_to_ignore[n]) == 0) return false;
}
//printf("TRUE!\n");
return true;
}
}

View File

@ -0,0 +1,9 @@
#!/bin/sh
install_name_tool -change /Library/Frameworks/Cairo.framework/Libraries/libpng12.0.dylib @executable_path/../libs/libpng12.0.dylib desmume.app/libs/Cairo
install_name_tool -change /Library/Frameworks/Cairo.framework/Libraries/libcairo.2.dylib @executable_path/../libs/libcairo.2.dylib desmume.app/libs/Cairo
install_name_tool -change /Library/Frameworks/Gtk.framework/Libraries/libpixman-1.0.dylib @executable_path/../libs/libpixman-1.0.dylib desmume.app/libs/libcairo.2.dylib
install_name_tool -change /Library/Frameworks/Gtk.framework/Libraries/libintl.8.dylib @executable_path/../libs/libintl.8.dylib desmume.app/libs/libgdk-pixbuf-2.0.0.dylib
install_name_tool -change /Library/Frameworks/Gtk.framework/Libraries/libintl.8.dylib @executable_path/../libs/libintl.8.dylib desmume.app/libs/libgdk-quartz-2.0.0.dylib
install_name_tool -change /Library/Frameworks/Gtk.framework/Libraries/libintl.8.dylib @executable_path/../libs/libintl.8.dylib desmume.app/libs/libgtk-quartz-2.0.0.dylib
install_name_tool -change /Library/Frameworks/Gtk.framework/Libraries/libintl.8.dylib @executable_path/../libs/libintl.8.dylib desmume.app/libs/libigemacintegration.0.dylib

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
#ifndef __DESMUME_GTK_MAIN_H__
#define __DESMUME_GTK_MAIN_H__
void Pause();
void Launch();
#endif

View File

@ -0,0 +1,40 @@
dep_gtk3 = dependency('gtk+-3.0')
dep_x11 = dependency('x11')
gtk_dependencies = dependencies + [dep_gtk3, dep_x11]
desmume_src = [
'avout_pipe_base.cpp',
'avout_x264.cpp',
'avout_flac.cpp',
'config.cpp',
'desmume.cpp',
'dToolsList.cpp',
'tools/ioregsView.cpp',
'../shared/sndsdl.cpp',
'../shared/ctrlssdl.cpp',
'osmesa_3Demu.cpp',
'sdl_3Demu.cpp',
'cheatsGTK.cpp',
'main.cpp',
]
# TODO: why do we have to redeclare it here with one more fs level?
includes = include_directories(
'../../../../src',
'../../../../src/libretro-common/include',
'../../../../src/frontend',
)
executable('desmume',
desmume_src,
dependencies: gtk_dependencies,
include_directories: includes,
link_with: libdesmume,
install: true,
)
install_data('desmume.desktop', install_dir: join_paths(get_option('datadir'), 'applications'))
install_data('org.desmume.DeSmuME.metainfo.xml', install_dir: join_paths(get_option('datadir'), 'metainfo'))
install_data('DeSmuME.xpm', install_dir: join_paths(get_option('datadir'), 'pixmaps'))
install_man('doc/desmume.1')

View File

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop-application">
<id>org.desmume.DeSmuME</id>
<name>DeSmuME</name>
<summary>Nintendo DS emulator</summary>
<project_license>GPL-2.0-or-later</project_license>
<metadata_license>CC0-1.0</metadata_license>
<developer_name>DeSmuME Team</developer_name>
<update_contact>linkmauve_AT_linkmauve.fr</update_contact>
<launchable type="desktop-id">desmume.desktop</launchable>
<url type="homepage">http://desmume.org</url>
<url type="bugtracker">https://github.com/TASVideos/desmume/issues</url>
<description>
<p>
DeSmuME is a Nintendo DS emulator.
</p>
</description>
<provides>
<binary>desmume</binary>
</provides>
<screenshots>
<screenshot type="default">
<image>https://linkmauve.fr/files/desmume-pokémon.png</image>
<caption>DeSmuME running Pokémon Heart Gold</caption>
</screenshot>
</screenshots>
<releases>
<release version="0.9.11" date="2015-04-15"/>
</releases>
<content_rating type="oars-1.1"/>
</component>

View File

@ -0,0 +1,112 @@
/*
Copyright (C) 2009 Guillaume Duhamel
Copyright (C) 2009-2017 DeSmuME team
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the this software. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef HAVE_LIBOSMESA
#include <stdlib.h>
#include <GL/osmesa.h>
#include "../OGLRender.h"
#include "../OGLRender_3_2.h"
#include "osmesa_3Demu.h"
static void *buffer = NULL;
static OSMesaContext ctx = NULL;
static bool osmesa_beginOpenGL(void) { return 1; }
static void osmesa_endOpenGL(void) { }
static bool osmesa_init(void) { return is_osmesa_initialized(); }
void deinit_osmesa_3Demu (void)
{
free(buffer);
buffer = NULL;
OSMesaDestroyContext(ctx);
ctx = NULL;
}
bool init_osmesa_3Demu(void)
{
#if (((OSMESA_MAJOR_VERSION * 100) + OSMESA_MINOR_VERSION) >= 1102) && defined(OSMESA_CONTEXT_MAJOR_VERSION)
static const int attributes_3_2_core_profile[] = {
OSMESA_FORMAT, OSMESA_RGBA,
OSMESA_DEPTH_BITS, 24,
OSMESA_STENCIL_BITS, 8,
OSMESA_ACCUM_BITS, 0,
OSMESA_PROFILE, OSMESA_CORE_PROFILE,
OSMESA_CONTEXT_MAJOR_VERSION, 3,
OSMESA_CONTEXT_MINOR_VERSION, 2,
0 };
ctx = OSMesaCreateContextAttribs(attributes_3_2_core_profile, NULL);
if (ctx == NULL)
{
printf("OSMesa: Could not create a 3.2 Core Profile context. Will attempt to create a 2.1 compatibility context...\n");
static const int attributes_2_1[] = {
OSMESA_FORMAT, OSMESA_RGBA,
OSMESA_DEPTH_BITS, 24,
OSMESA_STENCIL_BITS, 8,
OSMESA_ACCUM_BITS, 0,
OSMESA_PROFILE, OSMESA_COMPAT_PROFILE,
OSMESA_CONTEXT_MAJOR_VERSION, 2,
OSMESA_CONTEXT_MINOR_VERSION, 1,
0 };
ctx = OSMesaCreateContextAttribs(attributes_2_1, NULL);
}
#endif
if (ctx == NULL)
{
ctx = OSMesaCreateContextExt(OSMESA_RGBA, 24, 8, 0, NULL);
if (ctx == NULL)
{
printf("OSMesa: OSMesaCreateContextExt() failed!\n");
return false;
}
}
buffer = malloc(GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT * sizeof(uint32_t));
if (!buffer)
{
printf("OSMesa: Could not allocate enough memory for the context!\n");
return false;
}
if (!OSMesaMakeCurrent(ctx, buffer, GL_UNSIGNED_BYTE, GPU_FRAMEBUFFER_NATIVE_WIDTH, GPU_FRAMEBUFFER_NATIVE_HEIGHT))
{
printf("OSMesa: OSMesaMakeCurrent() failed!\n");
free(buffer);
return false;
}
oglrender_init = osmesa_init;
oglrender_beginOpenGL = osmesa_beginOpenGL;
oglrender_endOpenGL = osmesa_endOpenGL;
return true;
}
bool is_osmesa_initialized(void)
{
return (ctx != NULL);
}
#endif

View File

@ -0,0 +1,27 @@
/*
Copyright (C) 2009 Guillaume Duhamel
Copyright (C) 2009-2017 DeSmuME team
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the this software. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OSMESA_3DEMU_H
#define OSMESA_3DEMU_H
bool init_osmesa_3Demu(void);
void deinit_osmesa_3Demu(void);
bool is_osmesa_initialized(void);
#endif // OSMESA_3DEMU_H

View File

@ -0,0 +1,11 @@
#!/bin/sh
rm desmume.app.zip
rm -rf desmume.app
mkdir desmume.app
mkdir desmume.app/MacOS
cp desmume desmume.app/MacOS
cp Info.plist desmume.app
./dylibbundler -cd -d desmume.app/libs -b -x desmume.app/MacOS/desmume
./fixups
zip -r desmume.app.zip desmume.app

View File

@ -0,0 +1,87 @@
/*
Copyright (C) 2020 Emmanuel Gil Peyrot
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the this software. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <SDL.h>
#include "../OGLRender.h"
#include "sdl_3Demu.h"
static bool sdl_beginOpenGL(void) { return 1; }
static void sdl_endOpenGL(void) { }
static bool sdl_init(void) { return is_sdl_initialized(); }
static SDL_Window *win = NULL;
static SDL_GLContext ctx = NULL;
bool deinit_sdl_3Demu(void)
{
bool ret = false;
if (ctx) {
SDL_GL_DeleteContext(ctx);
ctx = NULL;
ret = true;
}
if (win) {
SDL_DestroyWindow(win);
win = NULL;
ret = true;
}
return ret;
}
bool init_sdl_3Demu(void)
{
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
win = SDL_CreateWindow(NULL, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 256, 192, SDL_WINDOW_OPENGL | SDL_WINDOW_HIDDEN);
if (!win) {
fprintf(stderr, "SDL: Failed to create a window: %s\n", SDL_GetError());
return false;
}
ctx = SDL_GL_CreateContext(win);
if (!ctx) {
fprintf(stderr, "SDL: Failed to create an OpenGL context: %s\n", SDL_GetError());
return false;
}
printf("OGL/SDL Renderer has finished the initialization.\n");
oglrender_init = sdl_init;
oglrender_beginOpenGL = sdl_beginOpenGL;
oglrender_endOpenGL = sdl_endOpenGL;
return true;
}
bool is_sdl_initialized(void)
{
return (ctx != NULL);
}

View File

@ -0,0 +1,26 @@
/*
Copyright (C) 2020 Emmanuel Gil Peyrot
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the this software. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SDL_3DEMU_H
#define SDL_3DEMU_H
bool init_sdl_3Demu(void);
bool deinit_sdl_3Demu(void);
bool is_sdl_initialized(void);
#endif // SDL_3DEMU_H

View File

@ -0,0 +1,492 @@
/* ioregsView.cpp - this file is part of DeSmuME
*
* Copyright (C) 2006 Thoduv
* Copyright (C) 2006-2015 DeSmuME Team
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <gtk/gtk.h>
#include <string.h>
#include "../dTool.h"
#include "../../MMU.h"
#include "../../registers.h"
#undef GPOINTER_TO_INT
#define GPOINTER_TO_INT(p) ((gint) (glong) (p))
#define SHORTNAME "ioregs"
#define TOOL_NAME "IO regs view"
#if !GTK_CHECK_VERSION(2,24,0)
#define gtk_combo_box_text_new gtk_combo_box_new_text
#define gtk_combo_box_text_append_text gtk_combo_box_append_text
#define GTK_COMBO_BOX_TEXT GTK_COMBO_BOX
#endif
BOOL CPUS [2] = {TRUE, TRUE};
static GtkWidget *mWin[2];
static GtkWidget *mVbox0[2];
static GtkWidget *mIoRegCombo[2];
static GtkWidget *mRegInfos[2];
typedef void (*reg_dispFn)(int c);
typedef u32 (*reg_valFn)(int c);
typedef struct
{
char name[64];
u32 adress;
int size;
reg_dispFn create;
reg_dispFn update;
reg_dispFn destroy;
reg_valFn value;
} reg_t;
static reg_t *current_reg[2] = {NULL, NULL};
#define REGFN_BEGIN(reg) \
GtkWidget **_wl_ = Widgets_##reg [c];
#define BIT_CHECK(w, n, s) { \
char _bit_check_buf[64]; \
snprintf(_bit_check_buf, ARRAY_SIZE(_bit_check_buf), "Bit %d: %s", n,s); \
_wl_[w] = gtk_check_button_new_with_label(_bit_check_buf ); \
gtk_box_pack_start(GTK_BOX(mVbox0[c]), _wl_[w], FALSE, FALSE, 0); }
#define BIT_COMBO(w,n,s) { \
_wl_[w] = gtk_hbox_new(FALSE, 0); \
gtk_box_pack_start(GTK_BOX(mVbox0[c]), _wl_[w], FALSE, FALSE, 0); } \
char _bit_combo_buf[64]; \
snprintf(_bit_combo_buf, ARRAY_SIZE(_bit_combo_buf), "Bits %s: %s", n,s); \
GtkWidget *__combo_lbl_tmp = gtk_label_new(_bit_combo_buf); \
GtkWidget *__combo_tmp = gtk_combo_box_text_new(); \
#define BIT_COMBO_ADD(w, s) { \
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(__combo_tmp), s); }
#define BIT_COMBO_GET(w) (GTK_WIDGET(g_list_first(gtk_container_get_children(GTK_CONTAINER(_wl_[w])))->data))
#define BIT_COMBO_END(w) \
gtk_box_pack_start(GTK_BOX(_wl_[w]), __combo_tmp, FALSE, FALSE, 0); \
gtk_box_pack_start(GTK_BOX(_wl_[w]), __combo_lbl_tmp, FALSE, FALSE, 0);
#define CREA_END() \
gtk_widget_show_all(mWin[c]);
/////////////////////////////// REG_IME ///////////////////////////////
static GtkWidget *Widgets_REG_IME[2][1];
static void crea_REG_IME(int c)
{
REGFN_BEGIN(REG_IME);
BIT_CHECK(0, 0, "Master interrupt enable");
CREA_END();
}
static void updt_REG_IME(int c) { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(Widgets_REG_IME[c][0]), MMU.reg_IME[c] ? 1 : 0); }
static void dest_REG_IME(int c) { gtk_widget_destroy(Widgets_REG_IME[c][0]); }
static u32 val_REG_IME(int c) { return MMU.reg_IME[c]; }
/////////////////////////////// REG_IE ///////////////////////////////
static const char *interrupt_strings[25] =
{
"LCD VBlank", // 0
"LCD HBlank", // 1
"LCD VCount", // 2
"Timer0 overflow", // 3
"Timer1 overflow",
"Timer2 overflow",
"Timer3 overflow",
"Serial communication (RTC)", // 7
"DMA0", // 8
"DMA1",
"DMA2",
"DMA3",
"Keypad", // 12
"Game Pak (GBA slot)", // 13
"", // 14
"", // 15
"IPC Sync", // 16
"IPC Send FIFO empty", // 17
"IPC Recv FIFO not empty", // 18
"Card Data Transfer Completion (DS-card slot)", // 19
"Card IREQ_MC (DS-card slot)", // 20
"Geometry (3D) command FIFO", // 21
"Screens unfolding", // 22
"SPI bus", // 23
"Wifi" // 24
};
#define INTERRUPT_SKIP(c) if(i == 14 || i == 15 || (c == 0 && (i == 7 || i == 22 || i == 23 || i == 24)) || (c == 1 && i == 21))continue;
static GtkWidget *Widgets_REG_IE[2][32];
static void crea_REG_IE(int c)
{
REGFN_BEGIN(REG_IE);
int i;
for(i = 0; i < 24; i++) { INTERRUPT_SKIP(c); BIT_CHECK(i, i, interrupt_strings[i]); }
CREA_END();
}
static void updt_REG_IE(int c)
{
int i;
for(i = 0; i < 24; i++) { INTERRUPT_SKIP(c); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(Widgets_REG_IE[c][i]), (MMU.reg_IE[c] & (1<<i)) ? 1 : 0); }
}
static void dest_REG_IE(int c)
{
int i;
for(i = 0; i < 24; i++) { INTERRUPT_SKIP(c); gtk_widget_destroy(Widgets_REG_IE[c][i]); }
}
static u32 val_REG_IE(int c) { return MMU.reg_IE[c]; }
/////////////////////////////// REG_IF ///////////////////////////////
static GtkWidget *Widgets_REG_IF[2][32];
static void crea_REG_IF(int c)
{
REGFN_BEGIN(REG_IF);
int i;
for(i = 0; i < 24; i++) { INTERRUPT_SKIP(c); BIT_CHECK(i, i, interrupt_strings[i]); }
CREA_END();
}
static void updt_REG_IF(int c)
{
int i;
for(i = 0; i < 24; i++) { INTERRUPT_SKIP(c); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(Widgets_REG_IF[c][i]), ((c==0?MMU.gen_IF<0>():MMU.gen_IF<1>()) & (1<<i)) ? 1 : 0); }
}
static void dest_REG_IF(int c)
{
int i;
for(i = 0; i < 24; i++) { INTERRUPT_SKIP(c); gtk_widget_destroy(Widgets_REG_IF[c][i]); }
}
static u32 val_REG_IF(int c) { return (c==0?MMU.gen_IF<0>():MMU.gen_IF<1>()); }
/////////////////////////////// REG_IPCFIFOCNT ///////////////////////////////
static const char *fifocnt_strings[] =
{
"Send FIFO empty",
"Send FIFO full",
"Send FIFO empty IRQ",
"Send FIFO clear (flush)",
"","","","",
"Receive FIFO empty",
"Receive FIFO full",
"Receive FIFO not empty IRQ",
"","","",
"Error (read when empty/write when full)",
"Enable FIFOs"
};
#define FIFOCNT_SKIP(c) if(i==4||i==5||i==6||i==11||i==12||i==13)continue;
static GtkWidget *Widgets_REG_IPCFIFOCNT[2][16];
static void crea_REG_IPCFIFOCNT(int c)
{
REGFN_BEGIN(REG_IPCFIFOCNT);
int i;
for(i = 0; i < 16; i++) { FIFOCNT_SKIP(c); BIT_CHECK(i, i, fifocnt_strings[i]); }
CREA_END();
}
static void updt_REG_IPCFIFOCNT(int c)
{
int i;
for(i = 0; i < 16; i++) { FIFOCNT_SKIP(c); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(Widgets_REG_IPCFIFOCNT[c][i]), (((u16 *)(MMU.MMU_MEM[c][0x40]))[0x184>>1]&(1<<i)) ? 1 : 0); }
}
static void dest_REG_IPCFIFOCNT(int c)
{
int i;
for(i = 0; i < 16; i++) { FIFOCNT_SKIP(c); gtk_widget_destroy(Widgets_REG_IPCFIFOCNT[c][i]); }
}
static u32 val_REG_IPCFIFOCNT(int c) { return ((u16 *)(MMU.MMU_MEM[c][0x40]))[0x184>>1]; }
/////////////////////////////// POWER_CR ///////////////////////////////
static const char *powercr9_strings[] =
{
"Enable LCD",
"2D A engine",
"3D render engine",
"3D geometry engine (matrix)",
"", "", "", "", "",
"2D B engine",
"", "", "", "", "",
"Swap LCD"
};
static const char *powercr7_strings[] =
{
"Sound speakers",
"Wifi system"
};
#define POWER_CR_SKIP(c) if(i==4||i==5||i==6||i==7||i==8||i==10||i==11||i==12||i==13||i==14)continue;
#define POWER_CR_SIZE(c) ((c==0)?16:2)
static GtkWidget *Widgets_POWER_CR[2][16];
static void crea_POWER_CR(int c)
{
REGFN_BEGIN(POWER_CR);
int i;
for(i = 0; i < POWER_CR_SIZE(c); i++) { POWER_CR_SKIP(c); BIT_CHECK(i, i, (c==0?powercr9_strings:powercr7_strings)[i]); }
CREA_END();
}
static void updt_POWER_CR(int c)
{
int i;
for(i = 0; i < POWER_CR_SIZE(c); i++) { POWER_CR_SKIP(c); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(Widgets_POWER_CR[c][i]), (((u16 *)(MMU.MMU_MEM[c][0x40]))[0x304>>1]&(1<<i)) ? 1 : 0); }
}
static void dest_POWER_CR(int c)
{
int i;
for(i = 0; i < POWER_CR_SIZE(c); i++) { POWER_CR_SKIP(c); gtk_widget_destroy(Widgets_POWER_CR[c][i]); }
}
static u32 val_POWER_CR(int c) { return ((u16 *)(MMU.MMU_MEM[c][0x40]))[0x304>>1]; }
/////////////////////////////// REG_SPICNT ///////////////////////////////
static const char *spicnt_strings[16] =
{
"Baudrate",
"","","","","","",
"Busy flag",
"Device",
"",
"Transfer size",
"Chipselect Hold",
"Unknown",
"Unknown",
"Interrupt request",
"Enable SPI bus",
};
// 0-1 Baudrate (0=4MHz/Firmware, 1=2MHz/Touchscr, 2=1MHz/Powerman., 3=512KHz)
// 2-6 Not used (Zero)
// 7 Busy Flag (0=Ready, 1=Busy) (presumably Read-only)
// 8-9 Device Select (0=Powerman., 1=Firmware, 2=Touchscr, 3=Reserved)
// 10 Transfer Size (0=8bit, 1=16bit)
// 11 Chipselect Hold (0=Deselect after transfer, 1=Keep selected)
// 12 Unknown (usually 0) (set equal to Bit11 when BIOS accesses firmware)
// 13 Unknown (usually 0) (set to 1 when BIOS accesses firmware)
// 14 Interrupt Request (0=Disable, 1=Enable)
// 15 SPI Bus Enable (0=Disable, 1=Enable)
#define REG_SPICNT_SKIP(c) if(i==1||i==2||i==3||i==4||i==5||i==6||i==9)continue;
#define REG_SPICNT_ISCHECK(c) (i==7||i==11||i==14||i==15||i==12||i==13)
static GtkWidget *Widgets_REG_SPICNT[2][16];
static void crea_REG_SPICNT(int c)
{
REGFN_BEGIN(REG_SPICNT);
int i;
for(i = 0; i < 16; i++) { REG_SPICNT_SKIP(c);
if(REG_SPICNT_ISCHECK(c)) { BIT_CHECK(i, i, spicnt_strings[i]); }
else if(i == 0) { BIT_COMBO(i, "0-1", spicnt_strings[0]);
BIT_COMBO_ADD(i, "0= 4Mhz");
BIT_COMBO_ADD(i, "1= 2Mhz");
BIT_COMBO_ADD(i, "2= 1Mhz");
BIT_COMBO_ADD(i, "3= 512Khz");
BIT_COMBO_END(i); }
else if(i == 8) { BIT_COMBO(i, "8-9", spicnt_strings[8]);
BIT_COMBO_ADD(i, "0= Power management device");
BIT_COMBO_ADD(i, "1= Firmware");
BIT_COMBO_ADD(i, "2= Touchscreen/Microphone");
BIT_COMBO_ADD(i, "3= Reserved/Prohibited");
BIT_COMBO_END(i); }
else if(i == 10) { BIT_COMBO(i, "10", spicnt_strings[10]);
BIT_COMBO_ADD(i, "0= 8 bits");
BIT_COMBO_ADD(i, "1= 16 bits");
BIT_COMBO_END(i); }
}
CREA_END();
}
static u32 val_REG_SPICNT(int c) { return ((u16 *)(MMU.MMU_MEM[c][0x40]))[0x1C0>>1]; }
static void updt_REG_SPICNT(int c)
{
REGFN_BEGIN(REG_SPICNT);
u16 val = val_REG_SPICNT(c);
int i;
for(i = 0; i < 16; i++) { REG_SPICNT_SKIP(c);
if(REG_SPICNT_ISCHECK(c)) { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(Widgets_REG_SPICNT[c][i]), (((u16 *)(MMU.MMU_MEM[c][0x40]))[0x1C0>>1]&(1<<i)) ? 1 : 0); }
else if(i == 0) { gtk_combo_box_set_active(GTK_COMBO_BOX(BIT_COMBO_GET(i)) , val&3); }
else if(i == 8) { gtk_combo_box_set_active(GTK_COMBO_BOX(BIT_COMBO_GET(i)) , (val>>8)&3); }
else if(i == 10) { gtk_combo_box_set_active(GTK_COMBO_BOX(BIT_COMBO_GET(i)) , (val>>10)&1); }
}
}
static void dest_REG_SPICNT(int c)
{
int i;
for(i = 0; i < 16; i++) { REG_SPICNT_SKIP(c); gtk_widget_destroy(Widgets_REG_SPICNT[c][i]); }
}
/////////////////////////////// LIST ///////////////////////////////
#define BITS_8 1
#define BITS_16 2
#define BITS_32 4
static const char *bits_strings[5] = {"0", "8", "16", "24", "32"};
#define REG_STR(r, s) {#r, r, s, &crea_##r, &updt_##r, &dest_##r, &val_##r}
#define REG_FNS(r) &crea_##r, &updt_##r, &dest_##r, &val_##r
//////// ARM9 ////////
#define REG_LIST_SIZE_ARM9 5
static const reg_t regs_list_9[] =
{
{"REG_IME", REG_IME, BITS_16, REG_FNS(REG_IME)},
{"REG_IE", REG_IE, BITS_32, REG_FNS(REG_IE)},
{"REG_IF", REG_IF, BITS_32, REG_FNS(REG_IF)},
{"REG_IPCFIFOCNT", 0x04000184, BITS_16, REG_FNS(REG_IPCFIFOCNT)},
{"POWER_CR", REG_POWCNT1, BITS_16, REG_FNS(POWER_CR)}
};
//////// ARM7 ////////
#define REG_LIST_SIZE_ARM7 6
static const reg_t regs_list_7[] =
{
{"REG_IME", REG_IME, BITS_16, REG_FNS(REG_IME)},
{"REG_IE", REG_IE, BITS_32, REG_FNS(REG_IE)},
{"REG_IF", REG_IF, BITS_32, REG_FNS(REG_IF)},
{"REG_IPCFIFOCNT", 0x04000184, BITS_16, REG_FNS(REG_IPCFIFOCNT)},
{"POWER_CR", REG_POWCNT1, BITS_16, REG_FNS(POWER_CR)},
{"REG_SPICNT", REG_SPICNT, BITS_16, REG_FNS(REG_SPICNT)}
};
#define GET_REG_LIST_SIZE(i) ((i==0)?REG_LIST_SIZE_ARM9:REG_LIST_SIZE_ARM7)
#define GET_REG_LIST(i) ((i==0)?regs_list_9:regs_list_7)
static void _clearContainer(GtkWidget *widget, gpointer data)
{
if(widget == mRegInfos[0] || widget == mRegInfos[1]) return;
if(widget == mIoRegCombo[0] || widget == mIoRegCombo[1]) return;
gtk_container_remove(GTK_CONTAINER((GtkWidget*)data), widget);
// gtk_widget_destroy(widget);
// gtk_object_destroy(GTK_OBJECT(widget));
}
static void selected_reg(GtkWidget* widget, gpointer data)
{
int c = GPOINTER_TO_INT(data);
gchar *regInfosBuffer;
guint active = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
if(current_reg[c]) current_reg[c]->destroy(c);
gtk_container_foreach(GTK_CONTAINER(mVbox0[c]), _clearContainer, (gpointer)mVbox0[c]);
current_reg[c] = (reg_t*)&(GET_REG_LIST(c)[active]);
// gtk_box_pack_start(GTK_BOX(mVbox0[c]), mIoRegCombo[c], FALSE, FALSE, 0);
switch (current_reg[c]->size) {
case BITS_8:
regInfosBuffer = g_strdup_printf("0x%02X", current_reg[c]->value(c));
break;
case BITS_16:
regInfosBuffer = g_strdup_printf("0x%04X", current_reg[c]->value(c));
break;
default:
regInfosBuffer = g_strdup_printf("0x%08X", current_reg[c]->value(c));
}
// gtk_box_pack_start(GTK_BOX(mVbox0[c]), mRegInfos[c], FALSE, FALSE, 0);
gtk_label_set_label(GTK_LABEL(mRegInfos[c]), regInfosBuffer);
g_free(regInfosBuffer);
current_reg[c]->create(c);
current_reg[c]->update(c);
}
/////////////////////////////// TOOL ///////////////////////////////
static int DTOOL_ID;
static void close()
{
memset(current_reg, 0, sizeof(current_reg));
dTool_CloseCallback(DTOOL_ID);
}
static void _closeOne(GtkWidget *widget, gpointer data)
{
int c = GPOINTER_TO_INT(data);
CPUS[c] = FALSE;
if(c == 0 && !CPUS[1]) close();
if(c == 1 && !CPUS[0]) close();
gtk_widget_destroy(mRegInfos[c]);
gtk_widget_destroy(mIoRegCombo[c]);
gtk_widget_destroy(mVbox0[c]);
// gtk_widget_destroy(mWin[c]);
}
static void update()
{
int c;
for(c = 0; c < 2; c++)
{
if(!CPUS[c]) continue;
current_reg[c]->update(c);
}
}
static void open(int ID)
{
int c, i;
DTOOL_ID = ID;
for(c = 0; c < 2; c++)
{
CPUS[c] = TRUE;
mWin[c]= gtk_window_new(GTK_WINDOW_TOPLEVEL);
if(c == 0) gtk_window_set_title(GTK_WINDOW(mWin[c]), TOOL_NAME " : ARM9");
else gtk_window_set_title(GTK_WINDOW(mWin[c]), TOOL_NAME " : ARM7");
g_signal_connect(G_OBJECT(mWin[c]), "destroy", G_CALLBACK(&_closeOne), GINT_TO_POINTER(c));
mVbox0[c] = gtk_vbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(mWin[c]), mVbox0[c]);
mIoRegCombo[c] = gtk_combo_box_text_new();
mRegInfos[c] = gtk_label_new("");
for(i = 0; i < GET_REG_LIST_SIZE(c); i++)
{
gchar *reg_name_buffer;
reg_name_buffer = g_strdup_printf("0x%08X : %s (%s)", GET_REG_LIST(c)[i].adress, GET_REG_LIST(c)[i].name, bits_strings[GET_REG_LIST(c)[i].size]);
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(mIoRegCombo[c]), reg_name_buffer);
g_free(reg_name_buffer);
}
gtk_combo_box_set_active(GTK_COMBO_BOX(mIoRegCombo[c]), 0);
g_signal_connect(G_OBJECT(mIoRegCombo[c]), "changed", G_CALLBACK(selected_reg), GINT_TO_POINTER(c));
gtk_box_pack_start(GTK_BOX(mVbox0[c]), mIoRegCombo[c], FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(mVbox0[c]), mRegInfos[c], FALSE, FALSE, 0);
selected_reg(mIoRegCombo[c], GINT_TO_POINTER(c));
gtk_widget_show_all(mWin[c]);
}
}
/////////////////////////////// TOOL DEFINITION ///////////////////////////////
dTool_t dTool_ioregsView =
{
SHORTNAME,
TOOL_NAME,
&open,
&update,
&close
};

View File

@ -0,0 +1,29 @@
/* ioregsview.h - this file is part of DeSmuME
*
* Copyright (C) 2006,2007 DeSmuME Team
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __IOREGSVIEW_H__
#define __IOREGSVIEW_H__
#include "../dTool.h"
extern dTool_t dTool_ioregsView;
#endif /*__IOREGSVIEW_H__*/