Beispiel #1
0
u16 m68000_read_pcrelative_16(u32 offset)
{
	if (offset >= m68k_encrypt_start && offset <= m68k_encrypt_end)
		return *(u16 *)&m68k_decrypted_rom[offset];
	else
		return m68000_read_memory_16(offset);
}
Beispiel #2
0
int neogeo_check_game(void)
{
    FILE *fp;
    char fname[16], path[MAX_PATH], linebuf[128];
    int i, fd, found = 0, NGH_number;

    neogeo_ngh = 0;
    hack_irq = 0;

    if (neogeo_boot_bios)
    {
        strcpy(game_name, games[99].name);
        game_index = 99;
    }
    else
    {
        strcpy(game_name, default_name);
        game_index = 0;

        sprintf(path, "%sIPL.TMP", launchDir);

        zip_open(game_dir);

        i = zlength("IPL.TXT");

        if ((fd = zopen("IPL.TXT")) == -1)
        {
            zip_close();
            return 0;
        }
        zread(fd, memory_region_cpu1, i);
        zclose(fd);
        zip_close();

        if ((fp = fopen(path, "w")) == NULL)
        {
            return 0;
        }
        fwrite(memory_region_cpu1, 1, i, fp);
        fclose(fp);

        if ((fp = fopen(path, "r")) == NULL)
        {
            sceIoRemove(path);
            return 0;
        }

        while (fgets(linebuf, 127, fp))
        {
            char *strfname = strtok(linebuf, ",\r\n");
            char *strbank  = strtok(NULL, ",\r\n");
            char *stroffs  = strtok(NULL, ",\r\n");
            char *ext;
            int bank, offs;

            if (strfname == NULL || strbank == NULL || stroffs == NULL)
                break;

            sscanf(strbank, "%d", &bank);
            sscanf(stroffs, "%x", &offs);
            ext = strrchr(strfname, '.');

            if (stricmp(ext, ".PRG") == 0 || stricmp(ext, ".ARG") == 0)
            {
                if (!bank && !offs)
                {
                    strcpy(fname, strfname);
                    found = 1;
                    break;
                }
            }
        }
        fclose(fp);

        sceIoRemove(path);

        if (!found) return 0;

        zip_open(game_dir);
        if ((fd = zopen(fname)) == -1)
        {
            zip_close();
            return 0;
        }

        zread(fd, memory_region_cpu1, 0x110);
        zclose(fd);
        zip_close();

        swab(memory_region_cpu1, memory_region_cpu1, 0x110);
        memcpy(neogeo_game_vectors, memory_region_cpu1, 0x100);

        NGH_number = m68000_read_memory_16(0x108);

        for (i = 0; games[i].ngh_number; i++)
        {
            if (games[i].ngh_number == NGH_number)
            {
                game_index = i + 1;
                neogeo_ngh = NGH_number;
                strcpy(game_name, games[i].name);

                if (NGH_NUMBER(0x0243))	// lastbld2
                    hack_irq = 1;

                break;
            }
        }
    }

    neogeo_reset_driver_type();

    return 1;
}