summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi.dcr@tutanota.com>2020-05-23 01:06:07 +0200
committerXavier Del Campo Romero <xavi.dcr@tutanota.com>2020-05-23 18:05:53 +0200
commit470da05658a97a51bd2ad2db7834bcc13dd995fd (patch)
treef2c85327bfe13813098446ff91a61b725116fa86
parentaea565d558f929729c0cb889f9c3296f2f487d0d (diff)
Started implementing GDB server
-rw-r--r--gui/ConfDlg.c4
-rw-r--r--gui/LnxMain.c6
-rw-r--r--libpcsxcore/CMakeLists.txt1
-rw-r--r--libpcsxcore/debug.c2
-rw-r--r--libpcsxcore/debug.h2
-rw-r--r--libpcsxcore/gdb_server.c128
-rw-r--r--libpcsxcore/gdb_server.h10
-rw-r--r--libpcsxcore/psxcommon.h1
-rw-r--r--libpcsxcore/psxcounters.c1
-rw-r--r--libpcsxcore/psxinterpreter.c45
-rw-r--r--libpcsxcore/socket.c4
-rw-r--r--win32/gui/WndMain.c177
12 files changed, 270 insertions, 111 deletions
diff --git a/gui/ConfDlg.c b/gui/ConfDlg.c
index e40a99fa..2e16be08 100644
--- a/gui/ConfDlg.c
+++ b/gui/ConfDlg.c
@@ -929,6 +929,10 @@ void OnCpu_Clicked(GtkDialog *dialog, gint arg1, gpointer user_data) {
else StopDebugger();
}
+ if (Config.GdbServer) {
+ GdbStartServer();
+ }
+
t = Config.Cpu;
Config.Cpu = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder, "GtkCheckButton_Cpu")));
if (t != Config.Cpu) {
diff --git a/gui/LnxMain.c b/gui/LnxMain.c
index d6dd9316..19187836 100644
--- a/gui/LnxMain.c
+++ b/gui/LnxMain.c
@@ -443,7 +443,7 @@ int main(int argc, char *argv[]) {
}
}
}
-
+
if (loadst==0) {
loadst = UpdateMenuSlots() + 1;
}
@@ -494,6 +494,10 @@ int SysInit() {
StartDebugger();
}
+ if (Config.GdbServer) {
+ GdbStartServer();
+ }
+
return 0;
}
diff --git a/libpcsxcore/CMakeLists.txt b/libpcsxcore/CMakeLists.txt
index 827a8f0a..04633ce1 100644
--- a/libpcsxcore/CMakeLists.txt
+++ b/libpcsxcore/CMakeLists.txt
@@ -98,6 +98,7 @@ set(SRCS psxbios.c
pgxp_gte.c
pgxp_mem.c
pgxp_value.c
+ gdb_server.c
)
set(LIBS "-lm")
diff --git a/libpcsxcore/debug.c b/libpcsxcore/debug.c
index 463df73b..972343d4 100644
--- a/libpcsxcore/debug.c
+++ b/libpcsxcore/debug.c
@@ -474,7 +474,7 @@ void ProcessDebug() {
MarkMap(_Rd_, MAP_EXEC_JAL);
}
}
- while (paused) {
+ while (paused || GdbServerRunning()) {
if (client_socket < 1)
{
diff --git a/libpcsxcore/debug.h b/libpcsxcore/debug.h
index f54c4883..4ca2e5ec 100644
--- a/libpcsxcore/debug.h
+++ b/libpcsxcore/debug.h
@@ -46,7 +46,7 @@ extern char *disRNameCP0[];
char* disR3000AF(u32 code, u32 pc);
-/*
+/*
* Specficies which logs should be activated.
*/
diff --git a/libpcsxcore/gdb_server.c b/libpcsxcore/gdb_server.c
new file mode 100644
index 00000000..7f7ea2ca
--- /dev/null
+++ b/libpcsxcore/gdb_server.c
@@ -0,0 +1,128 @@
+#include "socket.h"
+#include "psxcommon.h"
+#include "misc.h"
+#include "system.h"
+#include "dynstr.h"
+#include <stdio.h>
+#include <string.h>
+#include <stddef.h>
+
+static int server_socket, client_socket;
+static int debugger_active, resetting, reset, paused, ack_expected;
+
+enum { PACKET_SIZE = 256 };
+
+void GdbStartServer(void)
+{
+ enum { PORT = 3333 };
+
+ if (server_socket > 0) {
+ GdbStopServer();
+ }
+
+ server_socket = StartServer(PORT);
+
+ if (server_socket > 0) {
+ printf("GDB server started on port %hu\n", PORT);
+ debugger_active = 1;
+ }
+ else
+ {
+ fprintf(stderr, "Could not start GDB server\n");
+ }
+}
+
+int GdbServerRunning(void)
+{
+ return server_socket > 0;
+}
+
+void GdbStopServer(void)
+{
+}
+
+static void ack(struct dynstr *const reply)
+{
+ dynstr_append(reply, "OK");
+}
+
+static void nack(struct dynstr *const reply, const int err)
+{
+ dynstr_append(reply, "E %02X", err);
+}
+
+static void HandlePacket(char *const packet, const size_t len)
+{
+ struct dynstr reply;
+ const char *c = packet;
+
+ dynstr_init(&reply);
+
+ if (strstr(packet, "qSupported")) {
+ dynstr_append(&reply, "PacketSize=%x;swbreak+;hwbreak+", PACKET_SIZE - 1);
+ }
+ else {
+ fprintf(stderr, "Unexpected packet \"%s\"\n", packet);
+ return;
+ }
+
+ printf("gdb <- \"%s\"\n", reply.str);
+ WriteSocket(client_socket, reply.str, reply.len);
+ dynstr_free(&reply);
+}
+
+static void ProcessCommands(void)
+{
+ if (HasClient(client_socket)) {
+ char packet[PACKET_SIZE];
+ size_t len = sizeof packet;
+ const enum read_socket_err err = ReadSocket(client_socket, packet, &len);
+
+ switch (err)
+ {
+ case READ_SOCKET_OK:
+ if (len && len < sizeof packet) {
+ /* gdb apparently does not send null-terminated strings. */
+ packet[len] = '\0';
+ printf("gdb -> \"%s\"\n", packet);
+ HandlePacket(packet, len);
+ }
+ break;
+
+ case READ_SOCKET_ERR_INVALID_ARG:
+ /* Fall through. */
+ case READ_SOCKET_ERR_RECV:
+ /* Fall through. */
+ case READ_SOCKET_SHUTDOWN:
+ /* Fall through. */
+ default:
+ return;
+ }
+ }
+}
+
+void GdbServerProcessDebug(void)
+{
+ ProcessCommands();
+}
+
+void GdbServerVSync(void)
+{
+ if (!debugger_active || resetting)
+ return;
+
+ if (reset) {
+ resetting = 1;
+ SysReset();
+ if (reset == 2)
+ LoadCdrom();
+ reset = resetting = 0;
+ return;
+ }
+
+ if (client_socket < 1) {
+ client_socket = GetClient(server_socket);
+ }
+
+ ProcessCommands();
+}
diff --git a/libpcsxcore/gdb_server.h b/libpcsxcore/gdb_server.h
new file mode 100644
index 00000000..d0e925a6
--- /dev/null
+++ b/libpcsxcore/gdb_server.h
@@ -0,0 +1,10 @@
+#ifndef GDB_SERVER_H
+#define GDB_SERVER_H
+
+void GdbStartServer(void);
+void GdbStopServer(void);
+void GdbServerProcessDebug(void);
+void GdbServerVSync(void);
+int GdbServerRunning(void);
+
+#endif /* GDB_SERVER_H */
diff --git a/libpcsxcore/psxcommon.h b/libpcsxcore/psxcommon.h
index c6deaa9f..babdff96 100644
--- a/libpcsxcore/psxcommon.h
+++ b/libpcsxcore/psxcommon.h
@@ -70,6 +70,7 @@ typedef uint8_t boolean;
// Local includes
#include "system.h"
#include "debug.h"
+#include "gdb_server.h"
#if defined (__linux__) || defined (__MACOSX__)
#define strnicmp strncasecmp
diff --git a/libpcsxcore/psxcounters.c b/libpcsxcore/psxcounters.c
index a6d7e10e..46f9947e 100644
--- a/libpcsxcore/psxcounters.c
+++ b/libpcsxcore/psxcounters.c
@@ -324,6 +324,7 @@ void psxRcntUpdate()
}
DebugVSync();
+ GdbServerVSync();
}
/******************************************************************************/
diff --git a/libpcsxcore/psxinterpreter.c b/libpcsxcore/psxinterpreter.c
index a4f38e6d..685c9abf 100644
--- a/libpcsxcore/psxinterpreter.c
+++ b/libpcsxcore/psxinterpreter.c
@@ -152,12 +152,12 @@ static void delayReadWrite(int reg, u32 bpc) {
psxBranchTest();
}
-// this defines shall be used with the tmp
+// this defines shall be used with the tmp
// of the next func (instead of _Funct_...)
-#define _tFunct_ ((tmp ) & 0x3F) // The funct part of the instruction register
-#define _tRd_ ((tmp >> 11) & 0x1F) // The rd part of the instruction register
-#define _tRt_ ((tmp >> 16) & 0x1F) // The rt part of the instruction register
-#define _tRs_ ((tmp >> 21) & 0x1F) // The rs part of the instruction register
+#define _tFunct_ ((tmp ) & 0x3F) // The funct part of the instruction register
+#define _tRd_ ((tmp >> 11) & 0x1F) // The rd part of the instruction register
+#define _tRt_ ((tmp >> 16) & 0x1F) // The rt part of the instruction register
+#define _tRs_ ((tmp >> 21) & 0x1F) // The rs part of the instruction register
#define _tSa_ ((tmp >> 6) & 0x1F) // The sa part of the instruction register
int psxTestLoadDelay(int reg, u32 tmp) {
@@ -184,7 +184,7 @@ int psxTestLoadDelay(int reg, u32 tmp) {
// SYSCALL/BREAK just a break;
case 0x20: case 0x21: case 0x22: case 0x23:
- case 0x24: case 0x25: case 0x26: case 0x27:
+ case 0x24: case 0x25: case 0x26: case 0x27:
case 0x2a: case 0x2b: // ADD/ADDU...
case 0x04: case 0x06: case 0x07: // SLLV...
if (_tRd_ == reg && (_tRt_ == reg || _tRs_ == reg)) return 1; else
@@ -271,7 +271,7 @@ int psxTestLoadDelay(int reg, u32 tmp) {
case 0x12: // COP2
switch (_tFunct_) {
- case 0x00:
+ case 0x00:
switch (_tRs_) {
case 0x00: // MFC2
if (_tRt_ == reg) return 3;
@@ -721,9 +721,9 @@ void psxLB() {
if (_Rt_) {
- _i32(_rRt_) = (signed char)psxMemRead8(_oB_);
+ _i32(_rRt_) = (signed char)psxMemRead8(_oB_);
} else {
- psxMemRead8(_oB_);
+ psxMemRead8(_oB_);
}
}
@@ -743,7 +743,7 @@ void psxLBU() {
if (_Rt_) {
_u32(_rRt_) = psxMemRead8(_oB_);
} else {
- psxMemRead8(_oB_);
+ psxMemRead8(_oB_);
}
}
@@ -828,7 +828,7 @@ void psxLWL() {
if (!_Rt_) return;
- _u32(_rRt_) = ( _u32(_rRt_) & LWL_MASK[shift]) |
+ _u32(_rRt_) = ( _u32(_rRt_) & LWL_MASK[shift]) |
( mem << LWL_SHIFT[shift]);
/*
@@ -850,7 +850,7 @@ void psxLWR() {
u32 mem = psxMemRead32(addr & ~3);
-
+
// load delay = 1 latency
if( branch == 0 )
{
@@ -864,7 +864,7 @@ void psxLWR() {
if (!_Rt_) return;
- _u32(_rRt_) = ( _u32(_rRt_) & LWR_MASK[shift]) |
+ _u32(_rRt_) = ( _u32(_rRt_) & LWR_MASK[shift]) |
( mem >> LWR_SHIFT[shift]);
/*
@@ -940,7 +940,7 @@ void psxMFC0()
if (!_Rt_) return;
-
+
_i32(_rRt_) = (int)_rFs_;
}
@@ -958,7 +958,7 @@ void psxCFC0()
if (!_Rt_) return;
-
+
_i32(_rRt_) = (int)_rFs_;
}
@@ -1031,7 +1031,7 @@ void psxCFC2()
* Unknow instruction (would generate an exception) *
* Format: ? *
*********************************************************/
-void psxNULL() {
+void psxNULL() {
#ifdef PSXCPU_LOG
PSXCPU_LOG("psx: Unimplemented op %x\n", psxRegs.code);
#endif
@@ -1071,9 +1071,9 @@ void (*psxBSC[64])() = {
psxCOP0 , psxNULL , psxCOP2, psxNULL , psxNULL, psxNULL, psxNULL, psxNULL,
psxNULL , psxNULL , psxNULL, psxNULL , psxNULL, psxNULL, psxNULL, psxNULL,
psxLB , psxLH , psxLWL , psxLW , psxLBU , psxLHU , psxLWR , psxNULL,
- psxSB , psxSH , psxSWL , psxSW , psxNULL, psxNULL, psxSWR , psxNULL,
+ psxSB , psxSH , psxSWL , psxSW , psxNULL, psxNULL, psxSWR , psxNULL,
psxNULL , psxNULL , gteLWC2, psxNULL , psxNULL, psxNULL, psxNULL, psxNULL,
- psxNULL , psxNULL , gteSWC2, psxHLE , psxNULL, psxNULL, psxNULL, psxNULL
+ psxNULL , psxNULL , gteSWC2, psxHLE , psxNULL, psxNULL, psxNULL, psxNULL
};
@@ -1108,7 +1108,7 @@ void (*psxCP2[64])() = {
gteDPCS , gteINTPL, gteMVMVA, gteNCDS, gteCDP , psxNULL , gteNCDT , psxNULL, // 10
psxNULL , psxNULL , psxNULL , gteNCCS, gteCC , psxNULL , gteNCS , psxNULL, // 18
gteNCT , psxNULL , psxNULL , psxNULL, psxNULL, psxNULL , psxNULL , psxNULL, // 20
- gteSQR , gteDCPL , gteDPCT , psxNULL, psxNULL, gteAVSZ3, gteAVSZ4, psxNULL, // 28
+ gteSQR , gteDCPL , gteDPCT , psxNULL, psxNULL, gteAVSZ3, gteAVSZ4, psxNULL, // 28
gteRTPT , psxNULL , psxNULL , psxNULL, psxNULL, psxNULL , psxNULL , psxNULL, // 30
psxNULL , psxNULL , psxNULL , psxNULL, psxNULL, gteGPF , gteGPL , gteNCCT // 38
};
@@ -1182,7 +1182,7 @@ static void intReset() {
}
static void intExecute() {
- for (;;)
+ for (;;)
execI();
}
@@ -1198,13 +1198,14 @@ static void intShutdown() {
}
// interpreter execution
-static inline void execI() {
+static inline void execI() {
u32 *code = Read_ICache(psxRegs.pc, FALSE);
psxRegs.code = ((code == NULL) ? 0 : SWAP32(*code));
debugI();
- if (Config.Debug) ProcessDebug();
+ if (Config.GdbServer) GdbServerProcessDebug();
+ else if (Config.Debug) ProcessDebug();
psxRegs.pc += 4;
psxRegs.cycle += BIAS;
diff --git a/libpcsxcore/socket.c b/libpcsxcore/socket.c
index 2755aaa1..1faffd3d 100644
--- a/libpcsxcore/socket.c
+++ b/libpcsxcore/socket.c
@@ -256,7 +256,9 @@ void WriteSocket(int client_socket, const char *buffer, size_t len) {
if (!client_socket)
return;
- send(client_socket, buffer, len, 0);
+ if (send(client_socket, buffer, len, 0) == -1) {
+ perror("send():");
+ }
}
void SetsBlock(int s_socket) {
diff --git a/win32/gui/WndMain.c b/win32/gui/WndMain.c
index 67e29ef3..5d16debc 100644
--- a/win32/gui/WndMain.c
+++ b/win32/gui/WndMain.c
@@ -34,6 +34,7 @@
#include "sio.h"
#include "misc.h"
#include "cheat.h"
+#include "gdb_server.h"
#ifdef __MINGW32__
#ifndef LVM_GETSELECTIONMARK
@@ -261,10 +262,10 @@ void RestoreWindow() {
AccBreak = 1;
DestroyWindow(gApp.hWnd);
CreateMainWindow(SW_SHOWNORMAL);
-
+
if(Config.HideCursor)
ShowCursor(TRUE);
-
+
//SetCursor(LoadCursor(gApp.hInstance, IDC_ARROW));
//ShowCursor(TRUE);
@@ -279,7 +280,7 @@ void ResetMenuSlots() {
GetStateFilename(str, i);
if (CheckState(str) == -1)
EnableMenuItem(gApp.hMenu, ID_FILE_STATES_LOAD_SLOT1+i, MF_GRAYED);
- else
+ else
EnableMenuItem(gApp.hMenu, ID_FILE_STATES_LOAD_SLOT1+i, MF_ENABLED);
}
}
@@ -382,7 +383,7 @@ void OnStates_LoadOther() {
Running = 1;
psxCpu->Execute();
}
-}
+}
void OnStates_SaveOther() {
OPENFILENAME ofn;
@@ -428,7 +429,7 @@ void OnStates_SaveOther() {
Running = 1;
psxCpu->Execute();
}
-}
+}
LRESULT WINAPI MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
char File[256];
@@ -475,7 +476,7 @@ LRESULT WINAPI MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
SysMessage(_("The CD does not appear to be a valid Playstation CD"));
return TRUE;
}
-
+
// Auto-detect: region first, then rcnt reset
SysReset();
@@ -532,7 +533,7 @@ LRESULT WINAPI MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
// Auto-detect: region first, then rcnt reset
SysReset();
-
+
if (LoadCdrom() == -1) {
ClosePlugins();
RestoreWindow();
@@ -559,7 +560,7 @@ LRESULT WINAPI MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
// Auto-detect: region first, then rcnt reset
SysReset();
-
+
Load(File);
Running = 1;
psxCpu->Execute();
@@ -604,7 +605,7 @@ LRESULT WINAPI MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
// Auto-detect: region first, then rcnt reset
SysReset();
-
+
if (LoadCdrom() == -1) {
fprintf(stderr, _("Could not load CD-ROM!"));
ClosePlugins();
@@ -634,7 +635,7 @@ LRESULT WINAPI MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
// Auto-detect: region first, then rcnt reset
SysReset();
-
+
LoadCdrom();
if(Config.HideCursor)
ShowCursor(FALSE);
@@ -820,48 +821,48 @@ void CreateListView(int idc) {
int GetRGB() {
HDC scrDC, memDC;
- HBITMAP oldBmp = NULL;
+ HBITMAP oldBmp = NULL;
HBITMAP curBmp = NULL;
COLORREF oldColor;
COLORREF curColor = RGB(255,255,255);
int i, R, G, B;
R = G = B = 1;
-
+
scrDC = CreateDC("DISPLAY", NULL, NULL, NULL);
- memDC = CreateCompatibleDC(NULL);
- curBmp = CreateCompatibleBitmap(scrDC, 1, 1);
+ memDC = CreateCompatibleDC(NULL);
+ curBmp = CreateCompatibleBitmap(scrDC, 1, 1);
oldBmp = (HBITMAP)SelectObject(memDC, curBmp);
-
+
for (i = 255; i >= 0; --i) {
oldColor = curColor;
curColor = SetPixel(memDC, 0, 0, RGB(i, i, i));
-
- if (GetRValue(curColor) < GetRValue(oldColor)) ++R;
+
+ if (GetRValue(curColor) < GetRValue(oldColor)) ++R;
if (GetGValue(curColor) < GetGValue(oldColor)) ++G;
if (GetBValue(curColor) < GetBValue(oldColor)) ++B;
}
-
+
DeleteObject(oldBmp);
DeleteObject(curBmp);
DeleteDC(scrDC);
DeleteDC(memDC);
-
+
return (R * G * B);
}
-
+
HICON GetIcon(short *icon) {
ICONINFO iInfo;
HDC hDC;
char mask[16*16];
int x, y, c, Depth;
-
+
hDC = CreateIC("DISPLAY",NULL,NULL,NULL);
Depth=GetDeviceCaps(hDC, BITSPIXEL);
DeleteDC(hDC);
-
+
if (Depth == 16) {
- if (GetRGB() == (32 * 32 * 32))
+ if (GetRGB() == (32 * 32 * 32))
Depth = 15;
}
@@ -869,8 +870,8 @@ HICON GetIcon(short *icon) {
for (x=0; x<16; x++) {
c = icon[y*16+x];
if (Depth == 15 || Depth == 32)
- c = ((c&0x001f) << 10) |
- ((c&0x7c00) >> 10) |
+ c = ((c&0x001f) << 10) |
+ ((c&0x7c00) >> 10) |
((c&0x03e0) );
else
c = ((c&0x001f) << 11) |
@@ -879,20 +880,20 @@ HICON GetIcon(short *icon) {
icon[y*16+x] = c;
}
- }
+ }
iInfo.fIcon = TRUE;
memset(mask, 0, 16*16);
iInfo.hbmMask = CreateBitmap(16, 16, 1, 1, mask);
- iInfo.hbmColor = CreateBitmap(16, 16, 1, 16, icon);
-
+ iInfo.hbmColor = CreateBitmap(16, 16, 1, 16, icon);
+
return CreateIconIndirect(&iInfo);
}
HICON hICON[2][3][15];
-int aIover[2];
+int aIover[2];
int ani[2];
-
+
void LoadMcdItems(int mcd, int idc) {
HWND List = GetDlgItem(mcdDlg, idc);
LV_ITEM item;
@@ -900,37 +901,37 @@ void LoadMcdItems(int mcd, int idc) {
int i, j;
HICON hIcon;
McdBlock *Info;
-
+
aIover[mcd-1]=0;
ani[mcd-1]=0;
-
+
ListView_DeleteAllItems(List);
for (i=0; i<15; i++) {
-
+
item.mask = LVIF_TEXT | LVIF_IMAGE;
item.iItem = i;
item.iImage = i;
item.pszText = LPSTR_TEXTCALLBACK;
item.iSubItem = 0;
-
+
IconC[mcd-1][i] = 0;
Info = &Blocks[mcd-1][i];
-
+
if ((Info->Flags & 0xF) == 1 && Info->IconCount != 0) {
- hIcon = GetIcon(Info->Icon);
-
+ hIcon = GetIcon(Info->Icon);
+
if (Info->IconCount > 1) {
for(j = 0; j < 3; j++)
hICON[mcd-1][j][i]=hIcon;
}
} else {
- hIcon = eICON;
+ hIcon = eICON;
}
-
+
ImageList_ReplaceIcon(iml, -1, hIcon);
ListView_InsertItem(List, &item);
- }
+ }
}
void UpdateMcdItems(int mcd, int idc) {
@@ -940,38 +941,38 @@ void UpdateMcdItems(int mcd, int idc) {
int i, j;
McdBlock *Info;
HICON hIcon;
-
+
aIover[mcd-1]=0;
ani[mcd-1]=0;
-
- for (i=0; i<15; i++) {
-
+
+ for (i=0; i<15; i++) {
+
item.mask = LVIF_TEXT | LVIF_IMAGE;
item.iItem = i;
item.iImage = i;
item.pszText = LPSTR_TEXTCALLBACK;
item.iSubItem = 0;
-
- IconC[mcd-1][i] = 0;
+
+ IconC[mcd-1][i] = 0;
Info = &Blocks[mcd-1][i];
-
+
if ((Info->Flags & 0xF) == 1 && Info->IconCount != 0) {
- hIcon = GetIcon(Info->Icon);
-
- if (Info->IconCount > 1) {
+ hIcon = GetIcon(Info->Icon);
+
+ if (Info->IconCount > 1) {
for(j = 0; j < 3; j++)
hICON[mcd-1][j][i]=hIcon;
}
- } else {
- hIcon = eICON;
+ } else {
+ hIcon = eICON;
}
-
+
ImageList_ReplaceIcon(iml, i, hIcon);
ListView_SetItem(List, &item);
- }
+ }
ListView_Update(List, -1);
}
-
+
void McdListGetDispInfo(int mcd, int idc, LPNMHDR pnmh) {
LV_DISPINFO *lpdi = (LV_DISPINFO *)pnmh;
McdBlock *Info;
@@ -1050,22 +1051,22 @@ void UpdateMcdIcon(int mcd, int idc) {
HIMAGELIST iml = Iiml[mcd-1];
int i;
McdBlock *Info;
- int *count;
-
+ int *count;
+
if(!aIover[mcd-1]) {
- ani[mcd-1]++;
-
+ ani[mcd-1]++;
+
for (i=0; i<15; i++) {
Info = &Blocks[mcd-1][i];
count = &IconC[mcd-1][i];
-
+
if ((Info->Flags & 0xF) != 1) continue;
if (Info->IconCount <= 1) continue;
-
+
if (*count < Info->IconCount) {
(*count)++;
aIover[mcd-1]=0;
-
+
if(ani[mcd-1] <= (Info->IconCount-1)) // last frame and below...
hICON[mcd-1][ani[mcd-1]][i] = GetIcon(&Info->Icon[(*count)*16*16]);
} else {
@@ -1073,14 +1074,14 @@ void UpdateMcdIcon(int mcd, int idc) {
}
}
- } else {
-
+ } else {
+
if (ani[mcd-1] > 1) ani[mcd-1] = 0; // 1st frame
else ani[mcd-1]++; // 2nd, 3rd frame
-
+
for(i=0;i<15;i++) {
Info = &Blocks[mcd-1][i];
-
+
if (((Info->Flags & 0xF) == 1) && (Info->IconCount > 1))
ImageList_ReplaceIcon(iml, i, hICON[mcd-1][ani[mcd-1]][i]);
}
@@ -1116,7 +1117,7 @@ BOOL CALLBACK ConfigureMcdsDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lPa
Button_SetText(GetDlgItem(hW, IDC_PASTE), _("Paste"));
Button_SetText(GetDlgItem(hW, IDC_DELETE1), _("<- Un/Delete"));
Button_SetText(GetDlgItem(hW, IDC_DELETE2), _("Un/Delete ->"));
-
+
Static_SetText(GetDlgItem(hW, IDC_FRAMEMCD1), _("Memory Card 1"));
Static_SetText(GetDlgItem(hW, IDC_FRAMEMCD2), _("Memory Card 2"));
@@ -1143,10 +1144,10 @@ BOOL CALLBACK ConfigureMcdsDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lPa
CreateListView(IDC_LIST1);
CreateListView(IDC_LIST2);
-
+
Iiml[0] = ImageList_Create(16, 16, ILC_COLOR16, 0, 0);
Iiml[1] = ImageList_Create(16, 16, ILC_COLOR16, 0, 0);
-
+
ListView_SetImageList(GetDlgItem(mcdDlg, IDC_LIST1), Iiml[0], LVSIL_SMALL);
ListView_SetImageList(GetDlgItem(mcdDlg, IDC_LIST2), Iiml[1], LVSIL_SMALL);
@@ -1274,18 +1275,18 @@ BOOL CALLBACK ConfigureMcdsDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lPa
return TRUE;
- case IDC_MCDSEL1:
- Open_Mcd_Proc(hW, 1);
+ case IDC_MCDSEL1:
+ Open_Mcd_Proc(hW, 1);
return TRUE;
- case IDC_MCDSEL2:
- Open_Mcd_Proc(hW, 2);
+ case IDC_MCDSEL2:
+ Open_Mcd_Proc(hW, 2);
return TRUE;
- case IDC_RELOAD1:
+ case IDC_RELOAD1:
Edit_GetText(GetDlgItem(hW,IDC_MCD1), str, 256);
LoadMcd(1, str);
UpdateMcdDlg();
return TRUE;
- case IDC_RELOAD2:
+ case IDC_RELOAD2:
Edit_GetText(GetDlgItem(hW,IDC_MCD2), str, 256);
LoadMcd(2, str);
UpdateMcdDlg();
@@ -1340,12 +1341,12 @@ BOOL CALLBACK ConfigureMcdsDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lPa
}
-BOOL CALLBACK ConfigurePGXPDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
+BOOL CALLBACK ConfigurePGXPDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
long tmp;
RECT rect;
- switch (uMsg)
+ switch (uMsg)
{
case WM_INITDIALOG:
SetWindowText(hW, _("PGXP Config"));
@@ -1374,7 +1375,7 @@ BOOL CALLBACK ConfigurePGXPDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lPa
Static_SetText(GetDlgItem(hW, IDC_PGXP_MODETEXT), _("Error: Uknown mode"));
}
- case WM_COMMAND:
+ case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDCANCEL:
@@ -1423,7 +1424,7 @@ BOOL CALLBACK ConfigurePGXPDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lPa
return TRUE;
}
}
-
+
return FALSE;
}
@@ -1506,7 +1507,7 @@ BOOL CALLBACK ConfigureCpuDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lPar
if (Config.OverClock)
EnableWindow(GetDlgItem(hW, IDC_PSXCLOCK), TRUE);
- else
+ else
EnableWindow(GetDlgItem(hW, IDC_PSXCLOCK), FALSE);
break;
@@ -1569,6 +1570,10 @@ BOOL CALLBACK ConfigureCpuDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lPar
else StopDebugger();
}
+ if (Config.GdbServer) {
+ GdbStartServer();
+ }
+
SaveConfig();
EndDialog(hW,TRUE);
@@ -1619,7 +1624,7 @@ void Open_Mcd_Proc(HWND hW, int mcd) {
memset(&szFilter, 0, sizeof(szFilter));
strcpy(szFilter, _("Psx Mcd Format (*.mcr;*.mc;*.mem;*.vgs;*.mcd;*.gme;*.ddf)"));
- str = szFilter + strlen(szFilter) + 1;
+ str = szFilter + strlen(szFilter) + 1;
strcpy(str, "*.mcr;*.mcd;*.mem;*.gme;*.mc;*.ddf");
str+= strlen(str) + 1;
@@ -1725,7 +1730,7 @@ int Open_Iso_Proc(char *file) {
ofn.hwndOwner = gApp.hWnd;
strcpy(szFilter, _("Psx Isos (*.iso;*.mdf;*.img;*.bin;*.cue;*.pbp;*.cbn)"));
- str = szFilter + strlen(szFilter) + 1;
+ str = szFilter + strlen(szFilter) + 1;
strcpy(str, "*.iso;*.mdf;*.img;*.bin;*.cue;*.pbp;*.cbn");
str += strlen(str) + 1;
@@ -1942,15 +1947,15 @@ void InitLanguages() {
}
char *GetLanguageNext() {
- if (lFind == INVALID_HANDLE_VALUE)
+ if (lFind == INVALID_HANDLE_VALUE)
return NULL;
for (;;) {
if (lFirst == 0) {
if (FindNextFile(lFind, &lFindData) == FALSE)
return NULL;
- }
- else
+ }
+ else
lFirst = 0;
if (!strcmp(lFindData.cFileName, ".") ||
@@ -1993,6 +1998,8 @@ int SysInit() {
if (Config.Debug) StartDebugger();
+ if (Config.GdbServer) GdbStartServer();
+
return 0;
}