diff src/win32/RomInfo.cpp @ 1:f9f4f1b99eed

importing src directory
author Robert McIntyre <rlm@mit.edu>
date Sat, 03 Mar 2012 10:31:27 -0600
parents
children
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/win32/RomInfo.cpp	Sat Mar 03 10:31:27 2012 -0600
     1.3 @@ -0,0 +1,555 @@
     1.4 +// RomInfo.cpp : implementation file
     1.5 +//
     1.6 +
     1.7 +#include "stdafx.h"
     1.8 +#include "resource.h"
     1.9 +#include "RomInfo.h"
    1.10 +#include "WinResUtil.h"
    1.11 +
    1.12 +extern int32 gbRomSize;
    1.13 +
    1.14 +struct WinGBACompanyName
    1.15 +{
    1.16 +	LPCTSTR code;
    1.17 +	LPCTSTR name;
    1.18 +};
    1.19 +
    1.20 +static WinGBACompanyName winGBARomInfoCompanies[] = {
    1.21 +	{ "01", "Nintendo"							  },
    1.22 +	{ "02", "Rocket Games"						  },
    1.23 +	{ "08", "Capcom"							  },
    1.24 +	{ "09", "Hot B Co."							  },
    1.25 +	{ "0A", "Jaleco"							  },
    1.26 +	{ "0B", "Coconuts Japan"					  },
    1.27 +	{ "0C", "Coconuts Japan/G.X.Media"			  },
    1.28 +	{ "0H", "Starfish"							  },
    1.29 +	{ "0L", "Warashi Inc."						  },
    1.30 +	{ "0N", "Nowpro"							  },
    1.31 +	{ "0P", "Game Village"						  },
    1.32 +	{ "13", "Electronic Arts Japan"				  },
    1.33 +	{ "18", "Hudson Soft Japan"					  },
    1.34 +	{ "19", "S.C.P."							  },
    1.35 +	{ "1A", "Yonoman"							  },
    1.36 +	{ "1G", "SMDE"								  },
    1.37 +	{ "1P", "Creatures Inc."					  },
    1.38 +	{ "1Q", "TDK Deep Impresion"				  },
    1.39 +	{ "20", "Destination Software"				  },
    1.40 +	{ "22", "VR 1 Japan"						  },
    1.41 +	{ "25", "San-X"								  },
    1.42 +	{ "28", "Kemco Japan"						  },
    1.43 +	{ "29", "Seta"								  },
    1.44 +	{ "2H", "Ubisoft Japan"						  },
    1.45 +	{ "2K", "NEC InterChannel"					  },
    1.46 +	{ "2L", "Tam"								  },
    1.47 +	{ "2M", "Jordan"							  },
    1.48 +	{ "2N", "Smilesoft"							  },
    1.49 +	{ "2Q", "Mediakite"							  },
    1.50 +	{ "36", "Codemasters"						  },
    1.51 +	{ "37", "GAGA Communications"				  },
    1.52 +	{ "38", "Laguna"							  },
    1.53 +	{ "39", "Telstar Fun and Games"				  },
    1.54 +	{ "41", "Ubi Soft Entertainment"			  },
    1.55 +	{ "42", "Sunsoft"							  },
    1.56 +	{ "47", "Spectrum Holobyte"					  },
    1.57 +	{ "49", "IREM"								  },
    1.58 +	{ "4D", "Malibu Games"						  },
    1.59 +	{ "4F", "Eidos/U.S. Gold"					  },
    1.60 +	{ "4J", "Fox Interactive"					  },
    1.61 +	{ "4K", "Time Warner Interactive"			  },
    1.62 +	{ "4Q", "Disney"							  },
    1.63 +	{ "4S", "Black Pearl"						  },
    1.64 +	{ "4X", "GT Interactive"					  },
    1.65 +	{ "4Y", "RARE"								  },
    1.66 +	{ "4Z", "Crave Entertainment"				  },
    1.67 +	{ "50", "Absolute Entertainment"			  },
    1.68 +	{ "51", "Acclaim"							  },
    1.69 +	{ "52", "Activision"						  },
    1.70 +	{ "53", "American Sammy Corp."				  },
    1.71 +	{ "54", "Take 2 Interactive"				  },
    1.72 +	{ "55", "Hi Tech"							  },
    1.73 +	{ "56", "LJN LTD."							  },
    1.74 +	{ "58", "Mattel"							  },
    1.75 +	{ "5A", "Mindscape/Red Orb Ent."			  },
    1.76 +	{ "5C", "Taxan"								  },
    1.77 +	{ "5D", "Midway"							  },
    1.78 +	{ "5F", "American Softworks"				  },
    1.79 +	{ "5G", "Majesco Sales Inc"					  },
    1.80 +	{ "5H", "3DO"								  },
    1.81 +	{ "5K", "Hasbro"							  },
    1.82 +	{ "5L", "NewKidCo"							  },
    1.83 +	{ "5M", "Telegames"							  },
    1.84 +	{ "5N", "Metro3D"							  },
    1.85 +	{ "5P", "Vatical Entertainment"				  },
    1.86 +	{ "5Q", "LEGO Media"						  },
    1.87 +	{ "5S", "Xicat Interactive"					  },
    1.88 +	{ "5T", "Cryo Interactive"					  },
    1.89 +	{ "5W", "Red Storm Ent./BKN Ent."			  },
    1.90 +	{ "5X", "Microids"							  },
    1.91 +	{ "5Z", "Conspiracy Entertainment Corp."	  },
    1.92 +	{ "60", "Titus Interactive Studios"			  },
    1.93 +	{ "61", "Virgin Interactive"				  },
    1.94 +	{ "62", "Maxis"								  },
    1.95 +	{ "64", "LucasArts Entertainment"			  },
    1.96 +	{ "67", "Ocean"								  },
    1.97 +	{ "69", "Electronic Arts"					  },
    1.98 +	{ "6E", "Elite Systems Ltd."				  },
    1.99 +	{ "6F", "Electro Brain"						  },
   1.100 +	{ "6G", "The Learning Company"				  },
   1.101 +	{ "6H", "BBC"								  },
   1.102 +	{ "6J", "Software 2000"						  },
   1.103 +	{ "6L", "BAM! Entertainment"				  },
   1.104 +	{ "6M", "Studio 3"							  },
   1.105 +	{ "6Q", "Classified Games"					  },
   1.106 +	{ "6S", "TDK Mediactive"					  },
   1.107 +	{ "6U", "DreamCatcher"						  },
   1.108 +	{ "6V", "JoWood Productions"				  },
   1.109 +	{ "6W", "SEGA"								  },
   1.110 +	{ "6X", "Wannado Edition"					  },
   1.111 +	{ "6Y", "LSP"								  },
   1.112 +	{ "6Z", "ITE Media"							  },
   1.113 +	{ "70", "Infogrames"						  },
   1.114 +	{ "71", "Interplay"							  },
   1.115 +	{ "72", "JVC Musical Industries Inc"		  },
   1.116 +	{ "73", "Parker Brothers"					  },
   1.117 +	{ "75", "SCI"								  },
   1.118 +	{ "78", "THQ"								  },
   1.119 +	{ "79", "Accolade"							  },
   1.120 +	{ "7A", "Triffix Ent. Inc."					  },
   1.121 +	{ "7C", "Microprose Software"				  },
   1.122 +	{ "7D", "Universal Interactive Studios"		  },
   1.123 +	{ "7F", "Kemco"								  },
   1.124 +	{ "7G", "Rage Software"						  },
   1.125 +	{ "7H", "Encore"							  },
   1.126 +	{ "7J", "Zoo"								  },
   1.127 +	{ "7K", "BVM"								  },
   1.128 +	{ "7L", "Simon & Schuster Interactive"		  },
   1.129 +	{ "7M", "Asmik Ace Entertainment Inc./AIA"	  },
   1.130 +	{ "7N", "Empire Interactive"				  },
   1.131 +	{ "7Q", "Jester Interactive"				  },
   1.132 +	{ "7T", "Scholastic"						  },
   1.133 +	{ "7U", "Ignition Entertainment"			  },
   1.134 +	{ "7W", "Stadlbauer"						  },
   1.135 +	{ "80", "Misawa"							  },
   1.136 +	{ "83", "LOZC"								  },
   1.137 +	{ "8B", "Bulletproof Software"				  },
   1.138 +	{ "8C", "Vic Tokai Inc."					  },
   1.139 +	{ "8J", "General Entertainment"				  },
   1.140 +	{ "8N", "Success"							  },
   1.141 +	{ "8P", "SEGA Japan"						  },
   1.142 +	{ "91", "Chun Soft"							  },
   1.143 +	{ "92", "Video System"						  },
   1.144 +	{ "93", "BEC"								  },
   1.145 +	{ "96", "Yonezawa/S'pal"					  },
   1.146 +	{ "97", "Kaneko"							  },
   1.147 +	{ "99", "Victor Interactive Software"		  },
   1.148 +	{ "9A", "Nichibutsu/Nihon Bussan"			  },
   1.149 +	{ "9B", "Tecmo"								  },
   1.150 +	{ "9C", "Imagineer"							  },
   1.151 +	{ "9F", "Nova"								  },
   1.152 +	{ "9H", "Bottom Up"							  },
   1.153 +	{ "9L", "Hasbro Japan"						  },
   1.154 +	{ "9N", "Marvelous Entertainment"			  },
   1.155 +	{ "9P", "Keynet Inc."						  },
   1.156 +	{ "9Q", "Hands-On Entertainment"			  },
   1.157 +	{ "A0", "Telenet"							  },
   1.158 +	{ "A1", "Hori"								  },
   1.159 +	{ "A4", "Konami"							  },
   1.160 +	{ "A6", "Kawada"							  },
   1.161 +	{ "A7", "Takara"							  },
   1.162 +	{ "A9", "Technos Japan Corp."				  },
   1.163 +	{ "AA", "JVC"								  },
   1.164 +	{ "AC", "Toei Animation"					  },
   1.165 +	{ "AD", "Toho"								  },
   1.166 +	{ "AF", "Namco"								  },
   1.167 +	{ "AG", "Media Rings Corporation"			  },
   1.168 +	{ "AH", "J-Wing"							  },
   1.169 +	{ "AK", "KID"								  },
   1.170 +	{ "AL", "MediaFactory"						  },
   1.171 +	{ "AP", "Infogrames Hudson"					  },
   1.172 +	{ "AQ", "Kiratto. Ludic Inc"				  },
   1.173 +	{ "B0", "Acclaim Japan"						  },
   1.174 +	{ "B1", "ASCII"								  },
   1.175 +	{ "B2", "Bandai"							  },
   1.176 +	{ "B4", "Enix"								  },
   1.177 +	{ "B6", "HAL Laboratory"					  },
   1.178 +	{ "B7", "SNK"								  },
   1.179 +	{ "B9", "Pony Canyon Hanbai"				  },
   1.180 +	{ "BA", "Culture Brain"						  },
   1.181 +	{ "BB", "Sunsoft"							  },
   1.182 +	{ "BD", "Sony Imagesoft"					  },
   1.183 +	{ "BF", "Sammy"								  },
   1.184 +	{ "BG", "Magical"							  },
   1.185 +	{ "BJ", "Compile"							  },
   1.186 +	{ "BL", "MTO Inc."							  },
   1.187 +	{ "BN", "Sunrise Interactive"				  },
   1.188 +	{ "BP", "Global A Entertainment"			  },
   1.189 +	{ "BQ", "Fuuki"								  },
   1.190 +	{ "C0", "Taito"								  },
   1.191 +	{ "C2", "Kemco"								  },
   1.192 +	{ "C3", "Square Soft"						  },
   1.193 +	{ "C5", "Data East"							  },
   1.194 +	{ "C6", "Tonkin House"						  },
   1.195 +	{ "C8", "Koei"								  },
   1.196 +	{ "CA", "Konami/Palcom/Ultra"				  },
   1.197 +	{ "CB", "Vapinc/NTVIC"						  },
   1.198 +	{ "CC", "Use Co.,Ltd."						  },
   1.199 +	{ "CD", "Meldac"							  },
   1.200 +	{ "CE", "FCI/Pony Canyon"					  },
   1.201 +	{ "CF", "Angel"								  },
   1.202 +	{ "CM", "Konami Computer Entertainment Osaka" },
   1.203 +	{ "CP", "Enterbrain"						  },
   1.204 +	{ "D1", "Sofel"								  },
   1.205 +	{ "D2", "Quest"								  },
   1.206 +	{ "D3", "Sigma Enterprises"					  },
   1.207 +	{ "D4", "Ask Kodansa"						  },
   1.208 +	{ "D6", "Naxat"								  },
   1.209 +	{ "D7", "Copya System"						  },
   1.210 +	{ "D9", "Banpresto"							  },
   1.211 +	{ "DA", "TOMY"								  },
   1.212 +	{ "DB", "LJN Japan"							  },
   1.213 +	{ "DD", "NCS"								  },
   1.214 +	{ "DF", "Altron Corporation"				  },
   1.215 +	{ "DH", "Gaps Inc."							  },
   1.216 +	{ "DN", "ELF"								  },
   1.217 +	{ "E2", "Yutaka"							  },
   1.218 +	{ "E3", "Varie"								  },
   1.219 +	{ "E5", "Epoch"								  },
   1.220 +	{ "E7", "Athena"							  },
   1.221 +	{ "E8", "Asmik Ace Entertainment Inc."		  },
   1.222 +	{ "E9", "Natsume"							  },
   1.223 +	{ "EA", "King Records"						  },
   1.224 +	{ "EB", "Atlus"								  },
   1.225 +	{ "EC", "Epic/Sony Records"					  },
   1.226 +	{ "EE", "IGS"								  },
   1.227 +	{ "EL", "Spike"								  },
   1.228 +	{ "EM", "Konami Computer Entertainment Tokyo" },
   1.229 +	{ "EN", "Alphadream Corporation"			  },
   1.230 +	{ "F0", "A Wave"							  },
   1.231 +	{ "G1", "PCCW"								  },
   1.232 +	{ "G4", "KiKi Co Ltd"						  },
   1.233 +	{ "G5", "Open Sesame Inc."					  },
   1.234 +	{ "G6", "Sims"								  },
   1.235 +	{ "G7", "Broccoli"							  },
   1.236 +	{ "G8", "Avex"								  },
   1.237 +	{ "G9", "D3 Publisher"						  },
   1.238 +	{ "GB", "Konami Computer Entertainment Japan" },
   1.239 +	{ "GD", "Square-Enix"						  },
   1.240 +	{ "HY", "Sachen"							  },
   1.241 +	{ NULL, NULL								  }
   1.242 +};
   1.243 +
   1.244 +static LPCTSTR winGBARomInfoFindMakerCode(LPCTSTR code)
   1.245 +{
   1.246 +	int i = 0;
   1.247 +	while (winGBARomInfoCompanies[i].code)
   1.248 +	{
   1.249 +		if (!strcmp(winGBARomInfoCompanies[i].code, code))
   1.250 +			return winGBARomInfoCompanies[i].name;
   1.251 +		i++;
   1.252 +	}
   1.253 +	return (LPCTSTR)winResLoadString(IDS_UNKNOWN);
   1.254 +}
   1.255 +
   1.256 +/////////////////////////////////////////////////////////////////////////////
   1.257 +// RomInfoGB dialog
   1.258 +
   1.259 +RomInfoGB::RomInfoGB(u8 *rom, CWnd *pParent /*=NULL*/)
   1.260 +	: CDialog(RomInfoGB::IDD, pParent)
   1.261 +{
   1.262 +	//{{AFX_DATA_INIT(RomInfoGB)
   1.263 +	// NOTE: the ClassWizard will add member initialization here
   1.264 +	//}}AFX_DATA_INIT
   1.265 +	this->rom = rom;
   1.266 +}
   1.267 +
   1.268 +void RomInfoGB::DoDataExchange(CDataExchange *pDX)
   1.269 +{
   1.270 +	CDialog::DoDataExchange(pDX);
   1.271 +	//{{AFX_DATA_MAP(RomInfoGB)
   1.272 +	// NOTE: the ClassWizard will add DDX and DDV calls here
   1.273 +	//}}AFX_DATA_MAP
   1.274 +}
   1.275 +
   1.276 +BEGIN_MESSAGE_MAP(RomInfoGB, CDialog)
   1.277 +//{{AFX_MSG_MAP(RomInfoGB)
   1.278 +ON_BN_CLICKED(ID_OK, OnOk)
   1.279 +//}}AFX_MSG_MAP
   1.280 +END_MESSAGE_MAP()
   1.281 +
   1.282 +/////////////////////////////////////////////////////////////////////////////
   1.283 +// RomInfoGB message handlers
   1.284 +
   1.285 +void RomInfoGB::OnOk()
   1.286 +{
   1.287 +	EndDialog(TRUE);
   1.288 +}
   1.289 +
   1.290 +BOOL RomInfoGB::OnInitDialog()
   1.291 +{
   1.292 +	CDialog::OnInitDialog();
   1.293 +
   1.294 +	char buffer[128];
   1.295 +
   1.296 +	strncpy(buffer, (const char *)&rom[0x134], 15);
   1.297 +	buffer[15] = 0;
   1.298 +	GetDlgItem(IDC_ROM_TITLE)->SetWindowText(buffer);
   1.299 +
   1.300 +	sprintf(buffer, "%02x", rom[0x143]);
   1.301 +	GetDlgItem(IDC_ROM_COLOR)->SetWindowText(buffer);
   1.302 +
   1.303 +	strncpy(buffer, (const char *)&rom[0x144], 2);
   1.304 +	buffer[2] = 0;
   1.305 +	GetDlgItem(IDC_ROM_MAKER_CODE)->SetWindowText(buffer);
   1.306 +
   1.307 +	if (rom[0x14b] != 0x33)
   1.308 +	{
   1.309 +		sprintf(buffer, "%02X", rom[0x14b]);
   1.310 +		GetDlgItem(IDC_ROM_MAKER_CODE)->SetWindowText(buffer);
   1.311 +	}
   1.312 +	GetDlgItem(IDC_ROM_MAKER_NAME2)->SetWindowText(winGBARomInfoFindMakerCode(buffer));
   1.313 +
   1.314 +	sprintf(buffer, "%02x", rom[0x146]);
   1.315 +	GetDlgItem(IDC_ROM_UNIT_CODE)->SetWindowText(buffer);
   1.316 +
   1.317 +	CString type = winResLoadString(IDS_UNKNOWN);
   1.318 +	switch (rom[0x147])
   1.319 +	{
   1.320 +	case 0x00:
   1.321 +		type = "ROM";
   1.322 +		break;
   1.323 +	case 0x01:
   1.324 +		type = "ROM+MBC1";
   1.325 +		break;
   1.326 +	case 0x02:
   1.327 +		type = "ROM+MBC1+RAM";
   1.328 +		break;
   1.329 +	case 0x03:
   1.330 +		type = "ROM+MBC1+RAM+BATT";
   1.331 +		break;
   1.332 +	case 0x05:
   1.333 +		type = "ROM+MBC2";
   1.334 +		break;
   1.335 +	case 0x06:
   1.336 +		type = "ROM+MBC2+BATT";
   1.337 +		break;
   1.338 +	case 0x0f:
   1.339 +		type = "ROM+MBC3+TIMER+BATT";
   1.340 +		break;
   1.341 +	case 0x10:
   1.342 +		type = "ROM+MBC3+TIMER+RAM+BATT";
   1.343 +		break;
   1.344 +	case 0x11:
   1.345 +		type = "ROM+MBC3";
   1.346 +		break;
   1.347 +	case 0x12:
   1.348 +		type = "ROM+MBC3+RAM";
   1.349 +		break;
   1.350 +	case 0x13:
   1.351 +		type = "ROM+MBC3+RAM+BATT";
   1.352 +		break;
   1.353 +	case 0x19:
   1.354 +		type = "ROM+MBC5";
   1.355 +		break;
   1.356 +	case 0x1a:
   1.357 +		type = "ROM+MBC5+RAM";
   1.358 +		break;
   1.359 +	case 0x1b:
   1.360 +		type = "ROM+MBC5+RAM+BATT";
   1.361 +		break;
   1.362 +	case 0x1c:
   1.363 +		type = "ROM+MBC5+RUMBLE";
   1.364 +		break;
   1.365 +	case 0x1d:
   1.366 +		type = "ROM+MBC5+RUMBLE+RAM";
   1.367 +		break;
   1.368 +	case 0x1e:
   1.369 +		type = "ROM+MBC5+RUMBLE+RAM+BATT";
   1.370 +		break;
   1.371 +	case 0x22:
   1.372 +		type = "ROM+MBC7+BATT";
   1.373 +		break;
   1.374 +	case 0xfe:
   1.375 +		type = "ROM+HuC-3";
   1.376 +		break;
   1.377 +	case 0xff:
   1.378 +		type = "ROM+HuC-1";
   1.379 +		break;
   1.380 +	}
   1.381 +	sprintf(buffer, "%02x (%s)", rom[0x147], (const char *)type);
   1.382 +	GetDlgItem(IDC_ROM_DEVICE_TYPE)->SetWindowText(buffer);
   1.383 +
   1.384 +	type = winResLoadString(IDS_UNKNOWN);
   1.385 +	switch (rom[0x148])
   1.386 +	{
   1.387 +	case 0:
   1.388 +		type = "32K";
   1.389 +		break;
   1.390 +	case 1:
   1.391 +		type = "64K";
   1.392 +		break;
   1.393 +	case 2:
   1.394 +		type = "128K";
   1.395 +		break;
   1.396 +	case 3:
   1.397 +		type = "256K";
   1.398 +		break;
   1.399 +	case 4:
   1.400 +		type = "512K";
   1.401 +		break;
   1.402 +	case 5:
   1.403 +		type = "1M";
   1.404 +		break;
   1.405 +	case 6:
   1.406 +		type = "2M";
   1.407 +		break;
   1.408 +	case 7:
   1.409 +		type = "4M";
   1.410 +		break;
   1.411 +	}
   1.412 +
   1.413 +	sprintf(buffer, "%02x (%s)", rom[0x148], (const char *)type);
   1.414 +	GetDlgItem(IDC_ROM_SIZE)->SetWindowText(buffer);
   1.415 +
   1.416 +	type = winResLoadString(IDS_UNKNOWN);
   1.417 +	switch (rom[0x149])
   1.418 +	{
   1.419 +	case 0:
   1.420 +		type = winResLoadString(IDS_NONE);
   1.421 +		break;
   1.422 +	case 1:
   1.423 +		type = "2K";
   1.424 +		break;
   1.425 +	case 2:
   1.426 +		type = "8K";
   1.427 +		break;
   1.428 +	case 3:
   1.429 +		type = "32K";
   1.430 +		break;
   1.431 +	case 4:
   1.432 +		type = "128K";
   1.433 +		break;
   1.434 +	case 5:
   1.435 +		type = "64K";
   1.436 +		break;
   1.437 +	}
   1.438 +
   1.439 +	sprintf(buffer, "%02x (%s)", rom[0x149], (const char *)type);
   1.440 +	GetDlgItem(IDC_ROM_RAM_SIZE)->SetWindowText(buffer);
   1.441 +
   1.442 +	sprintf(buffer, "%02x", rom[0x14a]);
   1.443 +	GetDlgItem(IDC_ROM_DEST_CODE)->SetWindowText(buffer);
   1.444 +
   1.445 +	sprintf(buffer, "%02x", rom[0x14b]);
   1.446 +	GetDlgItem(IDC_ROM_LIC_CODE)->SetWindowText(buffer);
   1.447 +
   1.448 +	sprintf(buffer, "%02x", rom[0x14c]);
   1.449 +	GetDlgItem(IDC_ROM_VERSION)->SetWindowText(buffer);
   1.450 +
   1.451 +	u8	crc8 = 25;
   1.452 +	int i;
   1.453 +	for (i = 0x134; i < 0x14d; i++)
   1.454 +	{
   1.455 +		crc8 = (crc8 + rom[i]) & 0xFF;
   1.456 +	}
   1.457 +
   1.458 +	crc8 = 256 - crc8;
   1.459 +
   1.460 +	sprintf(buffer, "%02x (%02x)", crc8, rom[0x14d]);
   1.461 +	GetDlgItem(IDC_ROM_CRC)->SetWindowText(buffer);
   1.462 +
   1.463 +	u16 crc16 = 0;
   1.464 +	for (i = 0; i < gbRomSize; i++)
   1.465 +	{
   1.466 +		crc16 = (crc16 + rom[i]) & 0xFFFF;
   1.467 +	}
   1.468 +
   1.469 +	crc16 -= rom[0x14e];
   1.470 +	crc16 -= rom[0x14f];
   1.471 +	sprintf(buffer, "%04x (%04x)", crc16, (rom[0x14e] << 8) | rom[0x14f]);
   1.472 +	GetDlgItem(IDC_ROM_CHECKSUM)->SetWindowText(buffer);
   1.473 +
   1.474 +	CenterWindow();
   1.475 +
   1.476 +	return TRUE; // return TRUE unless you set the focus to a control
   1.477 +	             // EXCEPTION: OCX Property Pages should return FALSE
   1.478 +}
   1.479 +
   1.480 +/////////////////////////////////////////////////////////////////////////////
   1.481 +// RomInfoGBA dialog
   1.482 +
   1.483 +RomInfoGBA::RomInfoGBA(u8 *rom, CWnd *pParent /*=NULL*/)
   1.484 +	: CDialog(RomInfoGBA::IDD, pParent)
   1.485 +{
   1.486 +	//{{AFX_DATA_INIT(RomInfoGBA)
   1.487 +	// NOTE: the ClassWizard will add member initialization here
   1.488 +	//}}AFX_DATA_INIT
   1.489 +	this->rom = rom;
   1.490 +}
   1.491 +
   1.492 +void RomInfoGBA::DoDataExchange(CDataExchange *pDX)
   1.493 +{
   1.494 +	CDialog::DoDataExchange(pDX);
   1.495 +	//{{AFX_DATA_MAP(RomInfoGBA)
   1.496 +	// NOTE: the ClassWizard will add DDX and DDV calls here
   1.497 +	//}}AFX_DATA_MAP
   1.498 +}
   1.499 +
   1.500 +BEGIN_MESSAGE_MAP(RomInfoGBA, CDialog)
   1.501 +//{{AFX_MSG_MAP(RomInfoGBA)
   1.502 +ON_BN_CLICKED(ID_OK, OnOk)
   1.503 +//}}AFX_MSG_MAP
   1.504 +END_MESSAGE_MAP()
   1.505 +
   1.506 +/////////////////////////////////////////////////////////////////////////////
   1.507 +// RomInfoGBA message handlers
   1.508 +
   1.509 +void RomInfoGBA::OnOk()
   1.510 +{
   1.511 +	EndDialog(TRUE);
   1.512 +}
   1.513 +
   1.514 +BOOL RomInfoGBA::OnInitDialog()
   1.515 +{
   1.516 +	CDialog::OnInitDialog();
   1.517 +
   1.518 +	char buffer[13];
   1.519 +
   1.520 +	strncpy(buffer, (const char *)&rom[0xa0], 12);
   1.521 +	buffer[12] = 0;
   1.522 +	GetDlgItem(IDC_ROM_TITLE)->SetWindowText(buffer);
   1.523 +
   1.524 +	strncpy(buffer, (const char *)&rom[0xac], 4);
   1.525 +	buffer[4] = 0;
   1.526 +	GetDlgItem(IDC_ROM_GAME_CODE)->SetWindowText(buffer);
   1.527 +
   1.528 +	strncpy(buffer, (const char *)&rom[0xb0], 2);
   1.529 +	buffer[2] = 0;
   1.530 +	GetDlgItem(IDC_ROM_MAKER_CODE)->SetWindowText(buffer);
   1.531 +
   1.532 +	GetDlgItem(IDC_ROM_MAKER_NAME)->SetWindowText(winGBARomInfoFindMakerCode(buffer));
   1.533 +
   1.534 +	sprintf(buffer, "%02x", rom[0xb3]);
   1.535 +	GetDlgItem(IDC_ROM_UNIT_CODE)->SetWindowText(buffer);
   1.536 +
   1.537 +	sprintf(buffer, "%02x", rom[0xb4]);
   1.538 +	GetDlgItem(IDC_ROM_DEVICE_TYPE)->SetWindowText(buffer);
   1.539 +
   1.540 +	sprintf(buffer, "%02x", rom[0xbc]);
   1.541 +	GetDlgItem(IDC_ROM_VERSION)->SetWindowText(buffer);
   1.542 +
   1.543 +	u8 crc = 0x19;
   1.544 +	for (int i = 0xa0; i < 0xbd; i++)
   1.545 +	{
   1.546 +		crc = (crc + rom[i]) & 0xff;
   1.547 +	}
   1.548 +
   1.549 +	crc = (-crc) & 0xff;
   1.550 +
   1.551 +	sprintf(buffer, "%02x (%02x)", crc, rom[0xbd]);
   1.552 +	GetDlgItem(IDC_ROM_CRC)->SetWindowText(buffer);
   1.553 +	CenterWindow();
   1.554 +
   1.555 +	return TRUE; // return TRUE unless you set the focus to a control
   1.556 +	             // EXCEPTION: OCX Property Pages should return FALSE
   1.557 +}
   1.558 +