コード例 #1
0
ファイル: GameInfo.cpp プロジェクト: amichaelt/pentagram
std::string GameInfo::getPrintDetails() const
{
	std::string ret;

	std::string title = getGameTitle();
	if (title == "") title = "Unknown";

	ret = title + ", ";

	std::string lang = getLanguage();
	if (lang == "") lang = "Unknown";
	ret += lang;

	if (type != GAME_PENTAGRAM_MENU) {
		// version, md5 don't make sense for the pentagram menu

		ret += ", version ";
		ret += getPrintableVersion();

		ret += ", md5 ";
		ret += getPrintableMD5();
	}

	return ret;
}
コード例 #2
0
ファイル: CartridgeHeader.cpp プロジェクト: ghost7/gameboyC
CartridgeHeader::CartridgeHeader(data_t* rawRom, size_t size)
{
    // TODO: return a good error/exception
    if( size < 0x0150 )
        std::cout << "The cartridge is to small; it might cause a segfault." << std::endl;
    title = getGameTitle(rawRom);
    isCGBOnly = isColorOnly(rawRom);
    isSGB = hasSGBFunctionality(rawRom);
    newLicense = getLicenseCode(rawRom, &oldLicenseCode);
    getRomSize(rawRom, &romSize, &romBanks);
    getRamSize(rawRom, &ramSize, &ramBanks);
    isJap = isJapanese(rawRom);
    romVersion = getMaskRomVersion(rawRom);
    validHeaderSum = hasValidHeaderSum(rawRom);
    validGlobalSum = hasValidGlobalSum(rawRom, romSize);

    isCGBOnly = rawRom[0x0143] == 0xC0;
    isSGB = rawRom[0x0146] == 0x03;
    romType = (RomType)rawRom[0x0147];
    isJap = rawRom[0x014A] == 0;
    romVersion = rawRom[0x014C];

    std::stringstream descStream;
    descStream       << "Title:                   " << title 
        << std::endl << "Old License Code:        " << (int)oldLicenseCode
        << std::endl << "New License:             " << newLicense 
        << std::endl << "Rom Size:                " << romSize
        << std::endl << "Rom Banks:               " << romBanks
        << std::endl << "GameBoy Color Only:      " << std::boolalpha << isCGBOnly
        << std::endl << "Super Gameboy Functions: " << std::boolalpha << isSGB
        << std::endl << "Japanese:                " << std::boolalpha << isJap
        << std::endl << "Rom Version:             " << romVersion
        << std::endl << "Header Check Sum:        " << std::boolalpha << validHeaderSum
        << std::endl << "Global Check Sum:        " << std::boolalpha << validGlobalSum
        << std::endl << "Rom Type:                " << getRomTypeString(rawRom);
    desc = descStream.str();
}
コード例 #3
0
ファイル: compile.c プロジェクト: mlafeldt/xp2cc
AST *frontend(char *txt, u32 txtlen)
{
	char *s = NULL;
	u32 *code = NULL;
	u32 i = 0;
	u32 slen;
	int tokcur, tokexp = TOK_GAME_TITLE;
	AST *tree = (AST*) malloc(sizeof(AST));

	memset(tree, 0, sizeof(AST));

	// Text MUST contain a new line char at the end
	if (txt[txtlen - 1] != '\n') {
		txt = (char*) realloc(txt, ++txtlen);
		txt[txtlen - 1] = '\n';
	}

	printf("*** Compiler front end ***\n");
	printf("Parsing...\n");

	/*** Scanner ***/
	while (i < txtlen) {
		slen = indexOfChr(&txt[i], '\n');

		if (!_isEmptyStr(&txt[i], slen)) {
			s = &txt[i];
			s[slen] = NUL;
			/*** Screener ***/
			remCmtFromStr(s);
			trimStr(s);

			if (strlen(s) > 0) {
				/*** Parser ***/
				tokcur = getToken(s);

				if (!(tokexp & tokcur)) {
					fprintf(stderr, "ERROR(%i): '%s' : ", nline, s);
					if (tokexp & TOK_CHEAT_DESC) {
						fprintf(stderr, "Cheat description expected\n");
						tokexp = TOK_ALL;
					} else /* if (tokexp & TOK_GAME_TITLE) */ {
						fprintf(stderr, "Game title expected\n");
						tokexp = TOK_GAME_TITLE | TOK_CHEAT_DESC;
					}
					nerr++;
				} else switch (tokcur) {
					case TOK_GAME_TITLE:
						s = getGameTitle(s);
						if (*s == NUL) {
							fprintf(stderr, "ERROR(%i): Empty game title\n", nline);
							nerr++;
						} else {
							checkStr(s);
							if (!nerr && addGameToTree(tree, s) < 0) {
								fprintf(stderr, "ERROR(%i): '%s' : Cannot add more games\n", nline, s);
								nerr++;
							}
						}
						tokexp = TOK_GAME_TITLE | TOK_CHEAT_DESC;
						break;

					case TOK_CHEAT_DESC:
						checkStr(s);
						if (!nerr && addCheatToTree(tree, s) < 0) {
							fprintf(stderr, "ERROR(%i): '%s' : Cannot add more cheats\n", nline, s);
							nerr++;
						}
						tokexp = TOK_ALL;
						break;

					case TOK_CHEAT_CODE:
						code = getCheatCode(s);
						if (!nerr && addCodeToTree(tree, code) < 0) {
							fprintf(stderr, "ERROR(%i): %08X %08X : Cannot add more codes\n", nline, code[0], code[1]);
							nerr++;
						}
						tokexp = TOK_ALL;
						break;
				}
			}
		}
		nline++;
		i += slen + 1;
	}

	printf("Parsing done: %i error(s), %i warning(s)\n", nerr, nwarn);

	if (nerr) {
		fprintf(stderr, "Error(s) occurred during parsing.\n");
		freeTree(tree);
		return NULL;
	} else if (!tree->ngames) {
		fprintf(stderr, "Nothing parsed.\n");
		freeTree(tree);
		return NULL;
	}

	printf("Stats: %u game(s), %u cheat(s), %u code(s)\n", tree->ngames, tree->nallcheats, tree->nallcodes);

	return tree;
}