rlm@1: // BugReport.cpp : implementation file rlm@1: // rlm@1: rlm@1: #include "stdafx.h" rlm@1: #include "resource.h" rlm@1: #include "BugReport.h" rlm@1: #include "VBA.h" rlm@1: rlm@1: #include "../version.h" rlm@1: #include "../gba/agbprint.h" rlm@1: #include "../gba/Flash.h" rlm@1: #include "../gba/GBACheats.h" rlm@1: #include "../gba/GBAGlobals.h" rlm@1: #include "../gb/gbCheats.h" rlm@1: #include "../gb/gbGlobals.h" rlm@1: #include "../gba/RTC.h" rlm@1: #include "../gba/GBASound.h" rlm@1: #include "../common/vbalua.h" rlm@1: rlm@1: ///////////////////////////////////////////////////////////////////////////// rlm@1: // BugReport dialog rlm@1: rlm@1: BugReport::BugReport(CWnd*pParent /*=NULL*/) rlm@1: : CDialog(BugReport::IDD, pParent) rlm@1: { rlm@1: //{{AFX_DATA_INIT(BugReport) rlm@1: // NOTE: the ClassWizard will add member initialization here rlm@1: //}}AFX_DATA_INIT rlm@1: } rlm@1: rlm@1: void BugReport::DoDataExchange(CDataExchange*pDX) rlm@1: { rlm@1: CDialog::DoDataExchange(pDX); rlm@1: //{{AFX_DATA_MAP(BugReport) rlm@1: DDX_Control(pDX, IDC_BUG_REPORT, m_report); rlm@1: //}}AFX_DATA_MAP rlm@1: } rlm@1: rlm@1: BEGIN_MESSAGE_MAP(BugReport, CDialog) rlm@1: //{{AFX_MSG_MAP(BugReport) rlm@1: ON_BN_CLICKED(IDC_COPY, OnCopy) rlm@1: ON_BN_CLICKED(ID_OK, OnOk) rlm@1: //}}AFX_MSG_MAP rlm@1: END_MESSAGE_MAP() rlm@1: rlm@1: ///////////////////////////////////////////////////////////////////////////// rlm@1: // BugReport message handlers rlm@1: rlm@1: void BugReport::OnCopy() rlm@1: { rlm@1: OpenClipboard(); rlm@1: rlm@1: EmptyClipboard(); rlm@1: CString report; rlm@1: m_report.GetWindowText(report); rlm@1: rlm@1: HGLOBAL hglbCopy = GlobalAlloc(GMEM_MOVEABLE, rlm@1: (report.GetLength() + 1) * sizeof(CHAR)); rlm@1: if (hglbCopy == NULL) rlm@1: { rlm@1: CloseClipboard(); rlm@1: return; rlm@1: } rlm@1: rlm@1: // Lock the handle and copy the text to the buffer. rlm@1: rlm@1: LPSTR lptstrCopy = (LPSTR)GlobalLock(hglbCopy); rlm@1: memcpy(lptstrCopy, (const char *)report, rlm@1: report.GetLength() * sizeof(CHAR)); rlm@1: lptstrCopy[report.GetLength()] = (TCHAR) 0; // null character rlm@1: GlobalUnlock(hglbCopy); rlm@1: rlm@1: // Place the handle on the clipboard. rlm@1: rlm@1: SetClipboardData(CF_TEXT, hglbCopy); rlm@1: CloseClipboard(); rlm@1: rlm@1: systemMessage(IDS_BUG_REPORT, "Bug report has been copied to the Clipboard"); rlm@1: } rlm@1: rlm@1: void BugReport::OnOk() rlm@1: { rlm@1: EndDialog(TRUE); rlm@1: } rlm@1: rlm@1: BOOL BugReport::OnInitDialog() rlm@1: { rlm@1: CDialog::OnInitDialog(); rlm@1: rlm@1: CenterWindow(); rlm@1: rlm@1: CString report = createReport(); rlm@1: rlm@1: m_report.SetFont(CFont::FromHandle((HFONT)GetStockObject(SYSTEM_FIXED_FONT))); rlm@1: rlm@1: m_report.SetWindowText(report); rlm@1: rlm@1: return TRUE; // return TRUE unless you set the focus to a control rlm@1: // EXCEPTION: OCX Property Pages should return FALSE rlm@1: } rlm@1: rlm@1: static void AppendFormat(CString& report, const char *format, ...) rlm@1: { rlm@1: CString buffer; rlm@1: va_list valist; rlm@1: rlm@1: va_start(valist, format); rlm@1: buffer.FormatV(format, valist); rlm@1: va_end(valist); rlm@1: report += buffer; rlm@1: } rlm@1: rlm@1: CString BugReport::createReport() rlm@1: { rlm@1: theApp.winCheckFullscreen(); rlm@1: rlm@1: CString report = ""; rlm@1: AppendFormat(report, "Emu version : %s\r\n", VBA_VERSION_STRING); rlm@1: AppendFormat(report, "Emu type : %s\r\n", VBA_BUILDTYPE_STRING); rlm@1: rlm@1: if (systemIsEmulating()) rlm@1: { rlm@1: AppendFormat(report, "Game : %s\r\n", theApp.gameFilename); rlm@1: rlm@1: char buffer[20]; rlm@1: if (systemCartridgeType == 0) rlm@1: { rlm@1: u32 check = 0; rlm@1: for (int i = 0; i < 0x4000; i += 4) rlm@1: { rlm@1: check += *((u32 *)&bios[i]); rlm@1: } rlm@1: AppendFormat(report, "BIOS checksum: %08X\r\n", check); rlm@1: rlm@1: strncpy(buffer, (const char *)&rom[0xa0], 12); rlm@1: buffer[12] = 0; rlm@1: AppendFormat(report, "Internal name: %s\r\n", buffer); rlm@1: rlm@1: strncpy(buffer, (const char *)&rom[0xac], 4); rlm@1: buffer[4] = 0; rlm@1: AppendFormat(report, "Game code : %s\r\n", buffer); rlm@1: rlm@1: CString res = ""; rlm@1: u32 * p = (u32 *)rom; rlm@1: u32 * end = (u32 *)((char *)rom+theApp.romSize); rlm@1: while (p < end) rlm@1: { rlm@1: u32 d = READ32LE(p); rlm@1: rlm@1: if (d == 0x52504545) rlm@1: { rlm@1: if (memcmp(p, "EEPROM_", 7) == 0) rlm@1: { rlm@1: res += (const char *)p; rlm@1: res += ' '; rlm@1: } rlm@1: } rlm@1: else if (d == 0x4D415253) rlm@1: { rlm@1: if (memcmp(p, "SRAM_", 5) == 0) rlm@1: { rlm@1: res += (const char *)p; rlm@1: res += ' '; rlm@1: } rlm@1: } rlm@1: else if (d == 0x53414C46) rlm@1: { rlm@1: if (memcmp(p, "FLASH1M_", 8) == 0) rlm@1: { rlm@1: res += (const char *)p; rlm@1: res += ' '; rlm@1: } rlm@1: } rlm@1: else if (memcmp(p, "FLASH", 5) == 0) rlm@1: { rlm@1: res += (const char *)p; rlm@1: res += ' '; rlm@1: } rlm@1: else if (d == 0x52494953) rlm@1: { rlm@1: if (memcmp(p, "SIIRTC_V", 8) == 0) rlm@1: { rlm@1: res += (const char *)p; rlm@1: res += ' '; rlm@1: } rlm@1: } rlm@1: p++; rlm@1: } rlm@1: if (res.GetLength() > 0) rlm@1: AppendFormat(report, "Cart Save : %s\r\n", res); rlm@1: } rlm@1: else if (systemCartridgeType == 1) rlm@1: { rlm@1: strncpy(buffer, (const char *)&gbRom[0x134], 15); rlm@1: buffer[15] = 0; rlm@1: AppendFormat(report, "Game title : %s\r\n", buffer); rlm@1: } rlm@1: } rlm@1: rlm@1: AppendFormat(report, "Using BIOS : %d\r\n", useBios); rlm@1: AppendFormat(report, "Skip BIOS : %d\r\n", theApp.skipBiosFile); rlm@1: AppendFormat(report, "Disable SFX : %d\r\n", cpuDisableSfx); rlm@1: /// AppendFormat(report, "Skip intro : %d\r\n", theApp.removeIntros); rlm@1: AppendFormat(report, "Throttle : %d\r\n", theApp.throttle); rlm@1: AppendFormat(report, "Rewind : %d\r\n", theApp.rewindTimer); rlm@1: AppendFormat(report, "Lua : %d\r\n", VBALuaRunning()); rlm@1: /// AppendFormat(report, "Auto frame : %d\r\n", theApp.autoFrameSkip); rlm@1: AppendFormat(report, "Video option : %d\r\n", theApp.videoOption); rlm@1: AppendFormat(report, "Render type : %d\r\n", theApp.renderMethod); rlm@1: AppendFormat(report, "Color depth : %d\r\n", systemColorDepth); rlm@1: AppendFormat(report, "Red shift : %08x\r\n", systemRedShift); rlm@1: AppendFormat(report, "Green shift : %08x\r\n", systemGreenShift); rlm@1: AppendFormat(report, "Blue shift : %08x\r\n", systemBlueShift); rlm@1: AppendFormat(report, "Layer setting: %04X\r\n", layerSettings); rlm@1: AppendFormat(report, "Save type : %d (%d)\r\n", rlm@1: theApp.winSaveType, cpuSaveType); rlm@1: AppendFormat(report, "Flash size : %08X (%08x)\r\n", rlm@1: theApp.winFlashSize, flashSize); rlm@1: AppendFormat(report, "RTC : %d (%d)\r\n", theApp.winRtcEnable, rlm@1: rtcIsEnabled()); rlm@1: AppendFormat(report, "AGBPrint : %d\r\n", agbPrintIsEnabled()); rlm@1: AppendFormat(report, "Turbo Mode : %d\r\n", theApp.speedupToggle); rlm@1: AppendFormat(report, "Synchronize : %d\r\n", synchronize); rlm@1: AppendFormat(report, "Sound OFF : %d\r\n", soundOffFlag); rlm@1: AppendFormat(report, "Channels : %04x\r\n", soundGetEnabledChannels() & 0x30f); rlm@1: AppendFormat(report, "Old Sync : %d\r\n", theApp.useOldSync); rlm@1: AppendFormat(report, "Priority : %d\r\n", theApp.threadPriority); rlm@1: AppendFormat(report, "Filters : %d (%d)\r\n", theApp.filterType, theApp.ifbType); rlm@1: AppendFormat(report, "Cheats : %d\r\n", cheatsNumber); rlm@1: AppendFormat(report, "GB Cheats : %d\r\n", gbCheatNumber); rlm@1: AppendFormat(report, "GB Emu Type : %d\r\n", gbEmulatorType); rlm@1: rlm@1: return report; rlm@1: } rlm@1: