Linux: Moved the new memcard work to separate files, and enabled it, as it seems to be about as safe as switching memcards in the Windows port. Cleaned up Linux.h a bit, and started a bit of work on the debugger.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@491 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
arcum42 2009-02-14 10:28:25 +00:00
parent 2cc719d5b0
commit a8706a94ce
12 changed files with 267 additions and 184 deletions

View File

@ -23,6 +23,19 @@
#include "R3000A.h"
#include "IopMem.h"
typedef enum
{
GS,
PAD1,
PAD2,
SPU,
CDVD,
DEV9,
USB,
FW,
BIOS
} plugin_types;
typedef struct
{
GtkWidget *Combo;
@ -59,10 +72,6 @@ static void ConfPlugin(PluginConf confs, char* plugin, const char* name);
static void TestPlugin(PluginConf confs, char* plugin, const char* name);
extern void CheckSlots();
extern bool configuringplug;
#endif // __CONFIGDLG_H__

View File

@ -18,11 +18,11 @@
#include "DebugDlg.h"
using namespace R5900;
unsigned long DebuggerPC = 0;
void UpdateDebugger()
/*void UpdateDebugger()
{
char *str;
char syscall_str[g_MaxPath] = "";
int i;
std::string output;
@ -34,29 +34,81 @@ void UpdateDebugger()
GtkTreeIter iter;
u32 *mem;
u32 pc = dPC + i * 4;
if (DebugMode)
/*if (DebugMode)
{
mem = (u32*)PSXM(pc);
}
else
else*//*
mem = (u32*)PSM(pc);
if (mem == NULL)
{
sprintf(nullAddr, "%8.8lX:\tNULL MEMORY", pc);
str = nullAddr;
}
else
{
std::string output;
disR5900Fasm(output, *mem, pc);
output.copy(str, 256);
{
*//* special procesing for syscall. This should probably be moved into the disR5900Fasm() call in the future. */
/*if (0x0c == *mem && 0x24030000 == (*(mem-1) & 0xFFFFFF00))
{
*//* it's a syscall preceeded by a li v1,$data instruction. */
/*u8 bios_call = *(mem-1) & 0xFF;
sprintf(syscall_str, "%08X:\tsyscall\t%s", pc, R5900::bios[bios_call]);
}
else *//*
{
std::string str;
R5900::disR5900Fasm(str, *mem,pc);
str.copy( syscall_str, 256 );
syscall_str[str.length()] = 0;
}
}
gtk_list_store_append(ListDVModel, &iter);
gtk_list_store_set(ListDVModel, &iter, 0, str, -1);
if (syscall_str != "") gtk_list_store_set(ListDVModel, &iter, 0, syscall_str, -1);
}
}*/
void UpdateDebugger(void)
{
/* unsigned long t;
int cnt;
if (DebuggerPC == 0) DebuggerPC = cpuRegs.pc; //- 0x00000038;
gtk_list_store_clear(ListDVModel);
for (t = DebuggerPC, cnt = 0; t < (DebuggerPC + 0x00000074); t += 0x00000004, cnt++)
{
GtkTreeIter iter;
char syscall_str[256];
// Make the opcode.
u32 *mem = (u32*)PSM(t);
if (mem == NULL)
{
sprintf(syscall_str, "%8.8lx 00000000: NULL MEMORY", t);
}
else
{
*//* special procesing for syscall. This should probably be moved into the disR5900Fasm() call in the future. */
/*if (0x0c == *mem && 0x24030000 == (*(mem-1) & 0xFFFFFF00))
{
*//* it's a syscall preceeded by a li v1,$data instruction. */
/*u8 bios_call = *(mem-1) & 0xFF;
sprintf(syscall_str, "%08X:\tsyscall\t%s", t, R5900::bios[bios_call]);
}
else
{
std::string str;
R5900::disR5900Fasm(str, *mem, t);
str.copy( syscall_str, 256 );
syscall_str[str.length()] = 0;
}
}
gtk_list_store_append(ListDVModel, &iter);
gtk_list_store_set(ListDVModel, &iter, 0, syscall_str, -1);
}*/
}
void OnDebug_Close(GtkButton *button, gpointer user_data)
@ -340,6 +392,7 @@ void OnDebug_Go(GtkButton *button, gpointer user_data)
if (HasBreakPoint(cpuRegs.pc)) break;
Cpu->Step();
}
dPC = cpuRegs.pc;
UpdateDebugger();
}
@ -370,8 +423,9 @@ void OnMemWrite32_Ok(GtkButton *button, gpointer user_data)
char *mem = (char*)gtk_entry_get_text(GTK_ENTRY(MemEntry));
char *data = (char*)gtk_entry_get_text(GTK_ENTRY(DataEntry));
printf("memWrite32: %s, %s\n", mem, data);
Console::Notice("memWrite32: %s, %s\n", params mem, data);
memWrite32(strtol(mem, (char**)NULL, 0), strtol(data, (char**)NULL, 0));
gtk_widget_destroy(MemWriteDlg);
gtk_main_quit();
gtk_widget_set_sensitive(DebugWnd, TRUE);
@ -398,34 +452,22 @@ void OnDebug_memWrite32(GtkButton *button, gpointer user_data)
UpdateDebugger();
}
void OnDebug_Debugger(GtkMenuItem *menuitem, gpointer user_data)
void Create_Debugger()
{
GtkWidget *scroll;
GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
if (OpenPlugins(NULL) == -1) return;
/*if (!efile)
efile=GetPS2ElfName(elfname);
if (efile)
loadElfFile(elfname);
efile=0;*/
dPC = cpuRegs.pc;
DebugWnd = create_DebugWnd();
ListDVModel = gtk_list_store_new(1, G_TYPE_STRING);
ListDV = lookup_widget(DebugWnd, "GtkList_DisView");
gtk_tree_view_set_model(GTK_TREE_VIEW(ListDV), GTK_TREE_MODEL(ListDVModel));
renderer = gtk_cell_renderer_text_new();
column = gtk_tree_view_column_new_with_attributes("heading", renderer,
"text", 0,
NULL);
column = gtk_tree_view_column_new_with_attributes("heading", renderer, "text", 0, NULL);
gtk_tree_view_append_column(GTK_TREE_VIEW(ListDV), column);
scroll = lookup_widget(DebugWnd, "GtkVScrollbar_VList");
DebugAdj = GTK_RANGE(scroll)->adjustment;
DebugAdj->lower = (gfloat)0x00000000 / 4;
DebugAdj->upper = (gfloat)0xffffffff / 4;
@ -433,10 +475,17 @@ void OnDebug_Debugger(GtkMenuItem *menuitem, gpointer user_data)
DebugAdj->page_increment = (gfloat)20;
DebugAdj->page_size = (gfloat)23;
gtk_signal_connect(GTK_OBJECT(DebugAdj),
"value_changed", GTK_SIGNAL_FUNC(OnDebug_ScrollChange),
NULL);
gtk_signal_connect(GTK_OBJECT(DebugAdj), "value_changed", GTK_SIGNAL_FUNC(OnDebug_ScrollChange), NULL);
}
void OnDebug_Debugger(GtkMenuItem *menuitem, gpointer user_data)
{
if (OpenPlugins(NULL) == -1) return;
dPC = cpuRegs.pc;
Create_Debugger();
UpdateDebugger();
gtk_widget_show_all(DebugWnd);

View File

@ -19,40 +19,23 @@
#ifndef __LINUX_H__
#define __LINUX_H__
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <stdbool.h>
#include <dirent.h>
#include <dlfcn.h>
#include <fcntl.h>
#include <errno.h>
#include <signal.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/time.h>
#include <pthread.h>
#include <X11/keysym.h>
#include <gtk/gtk.h>
#include <glib/gthread.h>
#include <gdk/gdkkeysyms.h>
#include <gtk/gtkdialog.h>
#include <glib.h>
#include "PrecompiledHeader.h"
#include "Paths.h"
#include "Common.h"
//For CpuDlg
#include "Counters.h"
#include "VUmicro.h"
#include "Plugins.h"
// For AdvancedDialog
#include "x86/ix86/ix86.h"
#include "x86/iR5900.h"
#include <dirent.h>
#include <dlfcn.h>
#include <X11/keysym.h>
#include <gtk/gtk.h>
#include <glib/gthread.h>
#include <glib.h>
#ifdef __cplusplus
extern "C"
@ -68,48 +51,16 @@ extern "C"
#endif
extern void SaveConfig();
extern int LoadConfig();
extern void SysRestorableReset();
extern bool UseGui;
extern int Pcsx2Configure();
extern int LoadConfig();
extern void SaveConfig();
extern void SysRestorableReset();
extern void SignalExit(int sig);
extern bool isSlotUsed(int num);
typedef struct
{
char lang[g_MaxPath];
} _langs;
_langs *langs;
unsigned int langsMax;
typedef enum
{
GS,
PAD1,
PAD2,
SPU,
CDVD,
DEV9,
USB,
FW,
BIOS
} plugin_types;
extern GtkWidget *MainWindow;
extern bool configuringplug;
char cfgfile[g_MaxPath];
/* Hacks */
int Config_hacks_backup;
#define is_checked(main_widget, widget_name) (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(main_widget, widget_name))))
#define set_checked(main_widget,widget_name, state) gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(main_widget, widget_name)), state)

View File

@ -232,8 +232,7 @@ void StartGui()
gtk_box_pack_start(GTK_BOX(lookup_widget(MainWindow, "status_box")), pStatusBar, TRUE, TRUE, 0);
gtk_widget_show(pStatusBar);
gtk_statusbar_push(GTK_STATUSBAR(pStatusBar), 0,
"F1 - save, F2 - next state, Shift+F2 - prev state, F3 - load, F8 - snapshot");
StatusBar_SetMsg( "F1 - save, F2 - next state, Shift+F2 - prev state, F3 - load, F8 - snapshot");
// add all the languages
Item = lookup_widget(MainWindow, "GtkMenuItem_Language");
@ -261,7 +260,8 @@ void StartGui()
// disable anything not implemented or not working properly.
gtk_widget_set_sensitive(GTK_WIDGET(lookup_widget(MainWindow, "patch_browser1")), FALSE);
gtk_widget_set_sensitive(GTK_WIDGET(lookup_widget(MainWindow, "patch_finder2")), FALSE);
gtk_widget_set_sensitive(GTK_WIDGET(lookup_widget(MainWindow, "GtkMenuItem_Memcards")), FALSE);
gtk_widget_set_sensitive(GTK_WIDGET(lookup_widget(MainWindow, "GtkMenuItem_EnterDebugger")), FALSE);
//gtk_widget_set_sensitive(GTK_WIDGET(lookup_widget(MainWindow, "GtkMenuItem_Memcards")), FALSE);
#ifndef PCSX2_DEVBUILD
gtk_widget_set_sensitive(GTK_WIDGET(lookup_widget(MainWindow, "GtkMenuItem_Logging")), FALSE);
#endif
@ -526,75 +526,6 @@ void OnDebug_Logging(GtkMenuItem *menuitem, gpointer user_data)
gtk_main();
}
void OnConf_Memcards(GtkMenuItem *menuitem, gpointer user_data)
{
char file[g_MaxPath], card[g_MaxPath];
DIR *dir;
struct dirent *entry;
struct stat statinfo;
GtkWidget *memcombo1, *memcombo2;
int i = 0;
MemDlg = create_MemDlg();
memcombo1 = lookup_widget(MemDlg, "memcard1combo");
memcombo2 = lookup_widget(MemDlg, "memcard2combo");
getcwd(file, ARRAYSIZE(file)); /* store current dir */
sprintf( card, "%s/%s", file, MEMCARDS_DIR );
chdir(card); /* change dirs so that plugins can find their config file*/
if ((dir = opendir(card)) == NULL)
{
Console::Error("ERROR: Could not open directory %s\n", params card);
return;
}
while ((entry = readdir(dir)) != NULL)
{
stat(entry->d_name, &statinfo);
if (S_ISREG(statinfo.st_mode))
{
char path[g_MaxPath];
sprintf( path, "%s/%s", MEMCARDS_DIR, entry->d_name);
gtk_combo_box_append_text(GTK_COMBO_BOX(memcombo1), entry->d_name);
gtk_combo_box_append_text(GTK_COMBO_BOX(memcombo2), entry->d_name);
if (strcmp(Config.Mcd1, path) == 0)
gtk_combo_box_set_active(GTK_COMBO_BOX(memcombo1), i);
if (strcmp(Config.Mcd2, path) == 0)
gtk_combo_box_set_active(GTK_COMBO_BOX(memcombo2), i);
i++;
}
}
closedir(dir);
chdir(file);
gtk_widget_show_all(MemDlg);
gtk_widget_set_sensitive(MainWindow, FALSE);
gtk_main();
}
void OnMemcards_Ok(GtkButton *button, gpointer user_data)
{
strcpy(Config.Mcd1, MEMCARDS_DIR "/");
strcpy(Config.Mcd2, MEMCARDS_DIR "/");
strcat(Config.Mcd1, gtk_combo_box_get_active_text(GTK_COMBO_BOX(lookup_widget(MemDlg, "memcard1combo"))));
strcat(Config.Mcd2, gtk_combo_box_get_active_text(GTK_COMBO_BOX(lookup_widget(MemDlg, "memcard2combo"))));
SaveConfig();
gtk_widget_destroy(MemDlg);
gtk_widget_set_sensitive(MainWindow, TRUE);
gtk_main_quit();
}
void on_patch_browser1_activate(GtkMenuItem *menuitem, gpointer user_data) {}
void on_patch_finder2_activate(GtkMenuItem *menuitem, gpointer user_data) {}

View File

@ -21,34 +21,43 @@
#include "Linux.h"
void SignalExit(int sig);
extern bool applychanges;
extern SafeArray<u8>* g_RecoveryState;
extern bool g_EmulationInProgress; // Set TRUE if a game is actively running (set to false on reset)
extern void RunExecute(const char* elf_file, bool use_bios = false);
void OnLanguage(GtkMenuItem *menuitem, gpointer user_data);
extern void ExecuteCpu();
extern void CheckSlots();
extern bool isSlotUsed(int num);
extern bool ParseCommandLine(int argc, char *argv[], char *file);
extern void MemoryCard_Init();
extern void StatusBar_Notice( const std::string& text );
extern void StatusBar_SetMsg( const std::string& text );
void OnLanguage(GtkMenuItem *menuitem, gpointer user_data);
void InitLanguages();
char *GetLanguageNext();
void CloseLanguages();
void StartGui();
void pcsx2_exit();
GtkWidget *MainWindow;
GtkWidget *pStatusBar = NULL, *Status_Box;
GtkWidget *CmdLine; //2002-09-28 (Florin)
GtkWidget *widgetCmdLine;
GtkWidget *LogDlg, *MemDlg;
GtkWidget *MainWindow, *Status_Box;
GtkWidget *pStatusBar = NULL;
GtkWidget *CmdLine, *widgetCmdLine;
GtkWidget *LogDlg, *MemDlg;
GtkAccelGroup *AccelGroup;
typedef struct
{
char lang[g_MaxPath];
} _langs;
_langs *langs;
unsigned int langsMax;
const char* phelpmsg =
"\tpcsx2 [options] [file]\n\n"
"-cfg [file] {configuration file}\n"

View File

@ -30,6 +30,25 @@ bool g_EmulationInProgress = false; // Set TRUE if a game is actively running (s
static bool sinit = false;
GtkWidget *FileSel;
// For issuing notices to both the status bar and the console at the same time.
// Single-line text only please! Mutli-line msgs should be directed to the
// console directly, thanks.
void StatusBar_Notice( const std::string& text )
{
// mirror output to the console!
Console::Status( text.c_str() );
// don't try this in Visual C++ folks!
gtk_statusbar_push(GTK_STATUSBAR(pStatusBar), 0, text.c_str());
}
// Sets the status bar message without mirroring the output to the console.
void StatusBar_SetMsg( const std::string& text )
{
// don't try this in Visual C++ folks!
gtk_statusbar_push(GTK_STATUSBAR(pStatusBar), 0, text.c_str());
}
bool ParseCommandLine(int argc, char *argv[], char *file)
{
int i = 1;
@ -679,7 +698,6 @@ void KeyEvent(keyEvent* ev)
if (CAPS_LOCK_EVT(ev->key))
{
//Set up anything we want to happen while caps lock is down.
//Config_hacks_backup = Config.Hacks;
}
switch (ev->key)
@ -761,7 +779,6 @@ void KeyEvent(keyEvent* ev)
if (CAPS_LOCK_EVT(ev->key))
{
//Release caps lock
//Config_hacks_backup = Config.Hacks;
}
}

View File

@ -22,9 +22,14 @@
#include "Linux.h"
#include "GS.h"
#include <sys/mman.h>
#include "x86/iR5900.h"
extern void StartGui();
extern void CheckSlots();
extern void SignalExit(int sig);
extern const char* g_pRunGSState;
extern int efile;
extern GtkWidget *pStatusBar;
#endif

View File

@ -6,8 +6,8 @@ bin_PROGRAMS = pcsx2
# the application source, library search path, and link libraries
pcsx2_SOURCES = \
interface.c support.c LnxMain.cpp LnxThreads.cpp LnxConsole.cpp LnxSysExec.cpp \
AboutDlg.cpp ConfigDlg.cpp DebugDlg.cpp AdvancedDlg.cpp CpuDlg.cpp HacksDlg.cpp Pref.cpp \
GtkGui.h Linux.h LnxMain.h ConfigDlg.h DebugDlg.h interface.h callbacks.h memzero.h support.h
AboutDlg.cpp ConfigDlg.cpp DebugDlg.cpp AdvancedDlg.cpp CpuDlg.cpp HacksDlg.cpp McdDlgs.cpp Pref.cpp \
GtkGui.h Linux.h LnxMain.h ConfigDlg.h DebugDlg.h McdDlgs.h interface.h callbacks.h memzero.h support.h
pcsx2_LDFLAGS =

88
pcsx2/Linux/McdDlgs.cpp Normal file
View File

@ -0,0 +1,88 @@
/* Pcsx2 - Pc Ps2 Emulator
* Copyright (C) 2002-2008 Pcsx2 Team
*
* 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 "McdDlgs.h"
void OnConf_Memcards(GtkMenuItem *menuitem, gpointer user_data)
{
char file[g_MaxPath], card[g_MaxPath];
DIR *dir;
struct dirent *entry;
struct stat statinfo;
GtkWidget *memcombo1, *memcombo2;
int i = 0;
MemDlg = create_MemDlg();
memcombo1 = lookup_widget(MemDlg, "memcard1combo");
memcombo2 = lookup_widget(MemDlg, "memcard2combo");
getcwd(file, ARRAYSIZE(file)); /* store current dir */
sprintf( card, "%s/%s", file, MEMCARDS_DIR );
chdir(card); /* change dirs so that plugins can find their config file*/
if ((dir = opendir(card)) == NULL)
{
Console::Error("ERROR: Could not open directory %s\n", params card);
return;
}
while ((entry = readdir(dir)) != NULL)
{
stat(entry->d_name, &statinfo);
if (S_ISREG(statinfo.st_mode))
{
char path[g_MaxPath];
sprintf( path, "%s/%s", MEMCARDS_DIR, entry->d_name);
gtk_combo_box_append_text(GTK_COMBO_BOX(memcombo1), entry->d_name);
gtk_combo_box_append_text(GTK_COMBO_BOX(memcombo2), entry->d_name);
if (strcmp(Config.Mcd1, path) == 0)
gtk_combo_box_set_active(GTK_COMBO_BOX(memcombo1), i);
if (strcmp(Config.Mcd2, path) == 0)
gtk_combo_box_set_active(GTK_COMBO_BOX(memcombo2), i);
i++;
}
}
closedir(dir);
chdir(file);
gtk_widget_show_all(MemDlg);
gtk_widget_set_sensitive(MainWindow, FALSE);
gtk_main();
}
void OnMemcards_Ok(GtkButton *button, gpointer user_data)
{
strcpy(Config.Mcd1, MEMCARDS_DIR "/");
strcpy(Config.Mcd2, MEMCARDS_DIR "/");
strcat(Config.Mcd1, gtk_combo_box_get_active_text(GTK_COMBO_BOX(lookup_widget(MemDlg, "memcard1combo"))));
strcat(Config.Mcd2, gtk_combo_box_get_active_text(GTK_COMBO_BOX(lookup_widget(MemDlg, "memcard2combo"))));
SaveConfig();
gtk_widget_destroy(MemDlg);
gtk_widget_set_sensitive(MainWindow, TRUE);
gtk_main_quit();
}

26
pcsx2/Linux/McdDlgs.h Normal file
View File

@ -0,0 +1,26 @@
/* Pcsx2 - Pc Ps2 Emulator
* Copyright (C) 2002-2008 Pcsx2 Team
*
* 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
*/
#ifndef __MCDDLGS_H__
#define __MCDDLGS_H__
#include "Linux.h"
GtkWidget *MemDlg;
#endif

View File

@ -2691,7 +2691,6 @@ create_MainWindow (void)
GtkMenuItem_EnterDebugger = gtk_menu_item_new_with_mnemonic (_("Enter Debugger ..."));
gtk_widget_show (GtkMenuItem_EnterDebugger);
gtk_container_add (GTK_CONTAINER (GtkMenuItem_Debug_menu), GtkMenuItem_EnterDebugger);
gtk_widget_set_sensitive (GtkMenuItem_EnterDebugger, FALSE);
GtkMenuItem_Logging = gtk_menu_item_new_with_mnemonic (_("Logging"));
gtk_widget_show (GtkMenuItem_Logging);

View File

@ -5197,7 +5197,6 @@ Version x.x</property>
<child>
<widget class="GtkMenuItem" id="GtkMenuItem_EnterDebugger">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="label" translatable="yes">Enter Debugger ...</property>
<property name="use_underline">True</property>
<signal name="activate" handler="OnDebug_Debugger"/>