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