annotate src/win32/BugReport.cpp @ 3:b05d00f19d80

fix some formatting
author Robert McIntyre <rlm@mit.edu>
date Sat, 03 Mar 2012 10:33:11 -0600
parents f9f4f1b99eed
children
rev   line source
rlm@1 1 // BugReport.cpp : implementation file
rlm@1 2 //
rlm@1 3
rlm@1 4 #include "stdafx.h"
rlm@1 5 #include "resource.h"
rlm@1 6 #include "BugReport.h"
rlm@1 7 #include "VBA.h"
rlm@1 8
rlm@1 9 #include "../version.h"
rlm@1 10 #include "../gba/agbprint.h"
rlm@1 11 #include "../gba/Flash.h"
rlm@1 12 #include "../gba/GBACheats.h"
rlm@1 13 #include "../gba/GBAGlobals.h"
rlm@1 14 #include "../gb/gbCheats.h"
rlm@1 15 #include "../gb/gbGlobals.h"
rlm@1 16 #include "../gba/RTC.h"
rlm@1 17 #include "../gba/GBASound.h"
rlm@1 18 #include "../common/vbalua.h"
rlm@1 19
rlm@1 20 /////////////////////////////////////////////////////////////////////////////
rlm@1 21 // BugReport dialog
rlm@1 22
rlm@1 23 BugReport::BugReport(CWnd*pParent /*=NULL*/)
rlm@1 24 : CDialog(BugReport::IDD, pParent)
rlm@1 25 {
rlm@1 26 //{{AFX_DATA_INIT(BugReport)
rlm@1 27 // NOTE: the ClassWizard will add member initialization here
rlm@1 28 //}}AFX_DATA_INIT
rlm@1 29 }
rlm@1 30
rlm@1 31 void BugReport::DoDataExchange(CDataExchange*pDX)
rlm@1 32 {
rlm@1 33 CDialog::DoDataExchange(pDX);
rlm@1 34 //{{AFX_DATA_MAP(BugReport)
rlm@1 35 DDX_Control(pDX, IDC_BUG_REPORT, m_report);
rlm@1 36 //}}AFX_DATA_MAP
rlm@1 37 }
rlm@1 38
rlm@1 39 BEGIN_MESSAGE_MAP(BugReport, CDialog)
rlm@1 40 //{{AFX_MSG_MAP(BugReport)
rlm@1 41 ON_BN_CLICKED(IDC_COPY, OnCopy)
rlm@1 42 ON_BN_CLICKED(ID_OK, OnOk)
rlm@1 43 //}}AFX_MSG_MAP
rlm@1 44 END_MESSAGE_MAP()
rlm@1 45
rlm@1 46 /////////////////////////////////////////////////////////////////////////////
rlm@1 47 // BugReport message handlers
rlm@1 48
rlm@1 49 void BugReport::OnCopy()
rlm@1 50 {
rlm@1 51 OpenClipboard();
rlm@1 52
rlm@1 53 EmptyClipboard();
rlm@1 54 CString report;
rlm@1 55 m_report.GetWindowText(report);
rlm@1 56
rlm@1 57 HGLOBAL hglbCopy = GlobalAlloc(GMEM_MOVEABLE,
rlm@1 58 (report.GetLength() + 1) * sizeof(CHAR));
rlm@1 59 if (hglbCopy == NULL)
rlm@1 60 {
rlm@1 61 CloseClipboard();
rlm@1 62 return;
rlm@1 63 }
rlm@1 64
rlm@1 65 // Lock the handle and copy the text to the buffer.
rlm@1 66
rlm@1 67 LPSTR lptstrCopy = (LPSTR)GlobalLock(hglbCopy);
rlm@1 68 memcpy(lptstrCopy, (const char *)report,
rlm@1 69 report.GetLength() * sizeof(CHAR));
rlm@1 70 lptstrCopy[report.GetLength()] = (TCHAR) 0; // null character
rlm@1 71 GlobalUnlock(hglbCopy);
rlm@1 72
rlm@1 73 // Place the handle on the clipboard.
rlm@1 74
rlm@1 75 SetClipboardData(CF_TEXT, hglbCopy);
rlm@1 76 CloseClipboard();
rlm@1 77
rlm@1 78 systemMessage(IDS_BUG_REPORT, "Bug report has been copied to the Clipboard");
rlm@1 79 }
rlm@1 80
rlm@1 81 void BugReport::OnOk()
rlm@1 82 {
rlm@1 83 EndDialog(TRUE);
rlm@1 84 }
rlm@1 85
rlm@1 86 BOOL BugReport::OnInitDialog()
rlm@1 87 {
rlm@1 88 CDialog::OnInitDialog();
rlm@1 89
rlm@1 90 CenterWindow();
rlm@1 91
rlm@1 92 CString report = createReport();
rlm@1 93
rlm@1 94 m_report.SetFont(CFont::FromHandle((HFONT)GetStockObject(SYSTEM_FIXED_FONT)));
rlm@1 95
rlm@1 96 m_report.SetWindowText(report);
rlm@1 97
rlm@1 98 return TRUE; // return TRUE unless you set the focus to a control
rlm@1 99 // EXCEPTION: OCX Property Pages should return FALSE
rlm@1 100 }
rlm@1 101
rlm@1 102 static void AppendFormat(CString& report, const char *format, ...)
rlm@1 103 {
rlm@1 104 CString buffer;
rlm@1 105 va_list valist;
rlm@1 106
rlm@1 107 va_start(valist, format);
rlm@1 108 buffer.FormatV(format, valist);
rlm@1 109 va_end(valist);
rlm@1 110 report += buffer;
rlm@1 111 }
rlm@1 112
rlm@1 113 CString BugReport::createReport()
rlm@1 114 {
rlm@1 115 theApp.winCheckFullscreen();
rlm@1 116
rlm@1 117 CString report = "";
rlm@1 118 AppendFormat(report, "Emu version : %s\r\n", VBA_VERSION_STRING);
rlm@1 119 AppendFormat(report, "Emu type : %s\r\n", VBA_BUILDTYPE_STRING);
rlm@1 120
rlm@1 121 if (systemIsEmulating())
rlm@1 122 {
rlm@1 123 AppendFormat(report, "Game : %s\r\n", theApp.gameFilename);
rlm@1 124
rlm@1 125 char buffer[20];
rlm@1 126 if (systemCartridgeType == 0)
rlm@1 127 {
rlm@1 128 u32 check = 0;
rlm@1 129 for (int i = 0; i < 0x4000; i += 4)
rlm@1 130 {
rlm@1 131 check += *((u32 *)&bios[i]);
rlm@1 132 }
rlm@1 133 AppendFormat(report, "BIOS checksum: %08X\r\n", check);
rlm@1 134
rlm@1 135 strncpy(buffer, (const char *)&rom[0xa0], 12);
rlm@1 136 buffer[12] = 0;
rlm@1 137 AppendFormat(report, "Internal name: %s\r\n", buffer);
rlm@1 138
rlm@1 139 strncpy(buffer, (const char *)&rom[0xac], 4);
rlm@1 140 buffer[4] = 0;
rlm@1 141 AppendFormat(report, "Game code : %s\r\n", buffer);
rlm@1 142
rlm@1 143 CString res = "";
rlm@1 144 u32 * p = (u32 *)rom;
rlm@1 145 u32 * end = (u32 *)((char *)rom+theApp.romSize);
rlm@1 146 while (p < end)
rlm@1 147 {
rlm@1 148 u32 d = READ32LE(p);
rlm@1 149
rlm@1 150 if (d == 0x52504545)
rlm@1 151 {
rlm@1 152 if (memcmp(p, "EEPROM_", 7) == 0)
rlm@1 153 {
rlm@1 154 res += (const char *)p;
rlm@1 155 res += ' ';
rlm@1 156 }
rlm@1 157 }
rlm@1 158 else if (d == 0x4D415253)
rlm@1 159 {
rlm@1 160 if (memcmp(p, "SRAM_", 5) == 0)
rlm@1 161 {
rlm@1 162 res += (const char *)p;
rlm@1 163 res += ' ';
rlm@1 164 }
rlm@1 165 }
rlm@1 166 else if (d == 0x53414C46)
rlm@1 167 {
rlm@1 168 if (memcmp(p, "FLASH1M_", 8) == 0)
rlm@1 169 {
rlm@1 170 res += (const char *)p;
rlm@1 171 res += ' ';
rlm@1 172 }
rlm@1 173 }
rlm@1 174 else if (memcmp(p, "FLASH", 5) == 0)
rlm@1 175 {
rlm@1 176 res += (const char *)p;
rlm@1 177 res += ' ';
rlm@1 178 }
rlm@1 179 else if (d == 0x52494953)
rlm@1 180 {
rlm@1 181 if (memcmp(p, "SIIRTC_V", 8) == 0)
rlm@1 182 {
rlm@1 183 res += (const char *)p;
rlm@1 184 res += ' ';
rlm@1 185 }
rlm@1 186 }
rlm@1 187 p++;
rlm@1 188 }
rlm@1 189 if (res.GetLength() > 0)
rlm@1 190 AppendFormat(report, "Cart Save : %s\r\n", res);
rlm@1 191 }
rlm@1 192 else if (systemCartridgeType == 1)
rlm@1 193 {
rlm@1 194 strncpy(buffer, (const char *)&gbRom[0x134], 15);
rlm@1 195 buffer[15] = 0;
rlm@1 196 AppendFormat(report, "Game title : %s\r\n", buffer);
rlm@1 197 }
rlm@1 198 }
rlm@1 199
rlm@1 200 AppendFormat(report, "Using BIOS : %d\r\n", useBios);
rlm@1 201 AppendFormat(report, "Skip BIOS : %d\r\n", theApp.skipBiosFile);
rlm@1 202 AppendFormat(report, "Disable SFX : %d\r\n", cpuDisableSfx);
rlm@1 203 /// AppendFormat(report, "Skip intro : %d\r\n", theApp.removeIntros);
rlm@1 204 AppendFormat(report, "Throttle : %d\r\n", theApp.throttle);
rlm@1 205 AppendFormat(report, "Rewind : %d\r\n", theApp.rewindTimer);
rlm@1 206 AppendFormat(report, "Lua : %d\r\n", VBALuaRunning());
rlm@1 207 /// AppendFormat(report, "Auto frame : %d\r\n", theApp.autoFrameSkip);
rlm@1 208 AppendFormat(report, "Video option : %d\r\n", theApp.videoOption);
rlm@1 209 AppendFormat(report, "Render type : %d\r\n", theApp.renderMethod);
rlm@1 210 AppendFormat(report, "Color depth : %d\r\n", systemColorDepth);
rlm@1 211 AppendFormat(report, "Red shift : %08x\r\n", systemRedShift);
rlm@1 212 AppendFormat(report, "Green shift : %08x\r\n", systemGreenShift);
rlm@1 213 AppendFormat(report, "Blue shift : %08x\r\n", systemBlueShift);
rlm@1 214 AppendFormat(report, "Layer setting: %04X\r\n", layerSettings);
rlm@1 215 AppendFormat(report, "Save type : %d (%d)\r\n",
rlm@1 216 theApp.winSaveType, cpuSaveType);
rlm@1 217 AppendFormat(report, "Flash size : %08X (%08x)\r\n",
rlm@1 218 theApp.winFlashSize, flashSize);
rlm@1 219 AppendFormat(report, "RTC : %d (%d)\r\n", theApp.winRtcEnable,
rlm@1 220 rtcIsEnabled());
rlm@1 221 AppendFormat(report, "AGBPrint : %d\r\n", agbPrintIsEnabled());
rlm@1 222 AppendFormat(report, "Turbo Mode : %d\r\n", theApp.speedupToggle);
rlm@1 223 AppendFormat(report, "Synchronize : %d\r\n", synchronize);
rlm@1 224 AppendFormat(report, "Sound OFF : %d\r\n", soundOffFlag);
rlm@1 225 AppendFormat(report, "Channels : %04x\r\n", soundGetEnabledChannels() & 0x30f);
rlm@1 226 AppendFormat(report, "Old Sync : %d\r\n", theApp.useOldSync);
rlm@1 227 AppendFormat(report, "Priority : %d\r\n", theApp.threadPriority);
rlm@1 228 AppendFormat(report, "Filters : %d (%d)\r\n", theApp.filterType, theApp.ifbType);
rlm@1 229 AppendFormat(report, "Cheats : %d\r\n", cheatsNumber);
rlm@1 230 AppendFormat(report, "GB Cheats : %d\r\n", gbCheatNumber);
rlm@1 231 AppendFormat(report, "GB Emu Type : %d\r\n", gbEmulatorType);
rlm@1 232
rlm@1 233 return report;
rlm@1 234 }
rlm@1 235