Ejemplo n.º 1
0
SDL_bool dr_load_game(DRIVER *dr,char *name) {
    unzFile *gz;
    int i;
    LIST *l;
    char *zip=get_zip_name(name);
    gz = unzOpen(zip);
    free(zip);
    if (gz==NULL) {
	return SDL_FALSE;
    }
    if (dr->special_bios) {
	memory.bios=malloc(dr->bios.size);
	memory.bios_size=dr->bios.size;
	if (!dr_load_section(gz,dr->bios,memory.bios)) return SDL_FALSE;
    }
    for (i=0;i<SEC_MAX;i++) {
	int s=dr->section[i].size;
	Uint8 *current_buf=NULL;
	//if (dr->section[i].item==NULL) continue;
	if (s==0) continue;
	//      printf("%p %d \n",dr->section[i].item,i);
	switch (i) {
	case SEC_CPU:
	    memory.cpu = malloc(s);
	    current_buf = memory.cpu;
	    memory.cpu_size = s;
	    break;
	case SEC_SFIX:
	    memory.sfix_game = malloc(s);
	    memory.fix_game_usage = malloc(s >> 5);
	    current_buf = memory.sfix_game;
	    memory.sfix_size = s;
	    break;
	case SEC_SM1:
	    memory.sm1 = malloc(s);
	    current_buf = memory.sm1;
	    memory.sm1_size = s;
	    break;
	case SEC_SOUND1:
	    memory.sound1 = malloc(s);
	    memory.sound1_size = s;
	    current_buf = memory.sound1;
	    break;
	case SEC_SOUND2:
	    memory.sound2 = malloc(s);
	    memory.sound2_size = s;
	    current_buf = memory.sound2;
	    break;
	case SEC_GFX:
	    memory.gfx = malloc(s);
	    //printf("Alloc %x for GFX: %p\n",s,memory.gfx);
	    memory.gfx_size = s;
	    current_buf = memory.gfx;
	    memory.pen_usage = malloc((s >> 7) * sizeof(int));
	    memset(memory.pen_usage, 0, (s >> 7) * sizeof(int));
	    memory.nb_of_tiles = s >> 7;
	    break;
	    /* TODO: Crypted rom */
	default:
	    break;
	}
	if (!dr_load_section(gz,dr->section[i],current_buf)) return SDL_FALSE;
    }
    unzClose(gz);

    /* TODO: Use directly the driver value insteed of recopying them */
    conf.game=dr->name;
    conf.rom_type=dr->rom_type;
    conf.special_bios=dr->special_bios;
    conf.extra_xor=dr->xor;
    set_bankswitchers(dr->banksw_type);
    for(i=0;i<6;i++)
	memory.bksw_unscramble[i]=dr->banksw_unscramble[i];
    for(i=0;i<64;i++)
	memory.bksw_offset[i]=dr->banksw_off[i];


    if (conf.rom_type == MGD2) {
	create_progress_bar("Convert MGD2");
	convert_mgd2_tiles(memory.gfx, memory.gfx_size);
	convert_mgd2_tiles(memory.gfx, memory.gfx_size);
	terminate_progress_bar();
    }
    if (conf.rom_type == MVS_CMC42) {
	create_progress_bar("Decrypt GFX ");
	kof99_neogeo_gfx_decrypt(conf.extra_xor);
	terminate_progress_bar();
    }
    if (conf.rom_type == MVS_CMC50) {
	create_progress_bar("Decrypt GFX ");
	kof2000_neogeo_gfx_decrypt(conf.extra_xor);
	terminate_progress_bar();
    }

    convert_all_char(memory.sfix_game, memory.sfix_size,
		     memory.fix_game_usage);


    if (CF_BOOL(cf_get_item_by_name("convtile"))) {
	create_progress_bar("Convert tile");
	for (i = 0; i < memory.nb_of_tiles; i++) {
	    convert_tile(i);
	    if (i%100==0) update_progress_bar(i,memory.nb_of_tiles);
	}
	terminate_progress_bar();
    }

    if (memory.sound2 == NULL) {
	memory.sound2 = memory.sound1;
	memory.sound2_size = memory.sound1_size;
    }
    //backup neogeo game vectors
    memcpy(memory.game_vector,memory.cpu,0x80);
    printf("                                                                             \r");

    return SDL_TRUE;
}
Ejemplo n.º 2
0
void open_bios(void)
{
    FILE *f;
    char *romfile;
    char *path = CF_STR(cf_get_item_by_name("rompath"));//conf.rom_path;
    int len = strlen(path) + 15;

    if (conf.game!=NULL) free_bios_memory();

    /* allocation de la ram */
    memory.ram = (Uint8 *) malloc(0x10000);
    memset(memory.ram,0,0x10000);
    memory.sfix_board = (Uint8 *) malloc(0x20000);
    memory.ng_lo = (Uint8 *) malloc(0x10000);

    /* partie video */
    memory.pal1 = (Uint8 *) malloc(0x2000);
    memory.pal2 = (Uint8 *) malloc(0x2000);

    memory.pal_pc1 = (Uint8 *) malloc(0x2000);
    memory.pal_pc2 = (Uint8 *) malloc(0x2000);

    memset(memory.video, 0, 0x20000);

    romfile = (char *) malloc(len);
    memset(romfile, 0, len);
    if (!conf.special_bios) {
      memory.bios = (Uint8 *) malloc(0x20000);
      memory.bios_size=0x20000;
      /* try new bios */
      if (conf.system==SYS_HOME) {
          sprintf(romfile, "%s/aes-bios.bin", path);
      } else {
          if (conf.country==CTY_JAPAN) {
              sprintf(romfile, "%s/vs-bios.rom", path);
          } else if (conf.country==CTY_USA) {
              sprintf(romfile, "%s/usa_2slt.bin", path);
          } else if (conf.country==CTY_ASIA) {
              sprintf(romfile, "%s/asia-s3.rom", path);
          } else {
              sprintf(romfile, "%s/sp-s2.sp1", path);
          }
      }
      f = fopen(romfile, "rb");
      if (f == NULL) {
          printf("Can't find %s\n", romfile);
          exit(1);
      }
      fread(memory.bios, 1, 0x20000, f);
      fclose(f);
    }
    sprintf(romfile, "%s/ng-sfix.rom", path);
    f = fopen(romfile, "rb");
    if (f == NULL) {
	/* try new bios */
	sprintf(romfile, "%s/sfix.sfx", path);
	f = fopen(romfile, "rb");
	if (f == NULL) {
	    printf("Can't find %s\n", romfile);
	    exit(1);
	}
    }
    fread(memory.sfix_board, 1, 0x20000, f);
    fclose(f);

    sprintf(romfile, "%s/ng-lo.rom", path);
    f = fopen(romfile, "rb");
    if (f == NULL) {
	/* try new bios */
	sprintf(romfile, "%s/000-lo.lo", path);
	f = fopen(romfile, "rb");
	if (f == NULL) {
	    printf("Can't find %s\n", romfile);
	    exit(1);
	}
    }
    fread(memory.ng_lo, 1, 0x10000, f);
    fclose(f);


    /* convert bios fix char */
    convert_all_char(memory.sfix_board, 0x20000, memory.fix_board_usage);

    fix_usage = memory.fix_board_usage;
    current_pal = memory.pal1;
    current_fix = memory.sfix_board;
    current_pc_pal = (Uint16 *) memory.pal_pc1;

    free(romfile);
}