Exemplo n.º 1
0
// Return FALSE on fatal error(IPS file found but couldn't be applied),
// or TRUE on success(IPS patching succeeded, or IPS file not found).
static bool LoadIPS(MDFNFILE &GameFile, const char *path)
{
    FILE *IPSFile;

    MDFN_printf(_("Applying IPS file \"%s\"...\n"), path);

    IPSFile = fopen(path, "rb");
    if(!IPSFile)
    {
        ErrnoHolder ene(errno);

        MDFN_printf(_("Failed: %s\n"), ene.StrError());

        if(ene.Errno() == ENOENT)
            return(1);
        else
        {
            MDFN_PrintError(_("Error opening IPS file: %s\n"), ene.StrError());
            return(0);
        }
    }

    if(!GameFile.ApplyIPS(IPSFile))
    {
        fclose(IPSFile);
        return(0);
    }
    fclose(IPSFile);

    return(1);
}
Exemplo n.º 2
0
static int Load(const char *name, MDFNFILE *fp)
{
   lynxie = new CSystem(GET_FDATA_PTR(fp), GET_FSIZE_PTR(fp));

 int rot = lynxie->CartGetRotate();
 if(rot == CART_ROTATE_LEFT) MDFNGameInfo->rotated = MDFN_ROTATE270;
 else if(rot == CART_ROTATE_RIGHT) MDFNGameInfo->rotated = MDFN_ROTATE90;

 gAudioEnabled = 1;

 memcpy(MDFNGameInfo->MD5, lynxie->mCart->MD5, 16);
 MDFNGameInfo->GameSetMD5Valid = FALSE;

 MDFN_printf(_("ROM:       %dKiB\n"), (lynxie->mCart->InfoROMSize + 1023) / 1024);
 MDFN_printf(_("ROM CRC32: 0x%08x\n"), lynxie->mCart->CRC32());
 MDFN_printf(_("ROM MD5:   0x%s\n"), md5_context::asciistr(MDFNGameInfo->MD5, 0).c_str());

 MDFNGameInfo->fps = (uint32)(59.8 * 65536 * 256);

 if(MDFN_GetSettingB("lynx.lowpass"))
 {
  lynxie->mMikie->miksynth.treble_eq(-35);
 }
 else
 {
  lynxie->mMikie->miksynth.treble_eq(0);
 }
 return(1);
}
Exemplo n.º 3
0
static void LoadCPalette(const char *syspalname, uint8 **ptr, uint32 num_entries)
{
 std::string colormap_fn = MDFN_MakeFName(MDFNMKF_PALETTE, 0, syspalname).c_str();

 MDFN_printf(_("Loading custom palette from \"%s\"...\n"),  colormap_fn.c_str());
 MDFN_indent(1);

 try
 {
  FileStream fp(colormap_fn.c_str(), FileStream::MODE_READ);

  *ptr = new uint8[num_entries * 3];

  fp.read(*ptr, num_entries * 3);
 }
 catch(MDFN_Error &e)
 {
  MDFN_printf(_("Error: %s\n"), e.what());
  MDFN_indent(-1);

  if(e.GetErrno() != ENOENT)
   throw;

  return;
 }
 catch(std::exception &e)
 {
  MDFN_printf(_("Error: %s\n"), e.what());
  MDFN_indent(-1);
  throw;
 }

 MDFN_indent(-1);
}
Exemplo n.º 4
0
static void DINF(Stream *fp)
{
 union
 {
  struct
  {
   char name[100];
   uint8 raw_date[4];
   char method[100];
  };
  uint8 raw[100 + 4 + 100];
 } dinf;
 uint8 d, m;
 uint16 y;

 fp->read(dinf.raw, sizeof(dinf.raw));

 d = dinf.raw_date[0];
 m = dinf.raw_date[1];
 y = MDFN_de16lsb(&dinf.raw_date[2]);

 dinf.name[99] = dinf.method[99] = 0;

 MDFN_RemoveControlChars(dinf.name);
 MDFN_RemoveControlChars(dinf.method);

 MDFN_printf(_("Dumped by: %s\n"), dinf.name);
 MDFN_printf(_("Dumped with: %s\n"), dinf.method);
 {
  const char* months[12]={_("January"),_("February"),_("March"),_("April"),_("May"),_("June"),_("July"),
		    _("August"),_("September"),_("October"),_("November"),_("December")};
  MDFN_printf(_("Dumped on: %s %d, %d\n"),months[(m-1)%12],d,y);
 }
}
Exemplo n.º 5
0
bool CDIF_DumpCD(const char *fn)
{
 FILE *fp;

 if(!(fp = fopen(fn, "wb")))
 {
  ErrnoHolder ene(errno);

  MDFN_printf("File open error: %s\n", ene.StrError());
  return(0);
 }

 for(long long i = 0; i < toc.tracks[100].lba; i++)
 {
  uint8 buf[2352 + 96];

  CDIF_ReadRawSector(buf, i);

  if(fwrite(buf, 1, 2352 + 96, fp) != 2352 + 96)
  {
   ErrnoHolder ene(errno);

   MDFN_printf("File write error: %s\n", ene.StrError());
  }
 }

 if(fclose(fp))
 {
  ErrnoHolder ene(errno);

  MDFN_printf("fclose error: %s\n", ene.StrError());
 }

 return(1);
}
Exemplo n.º 6
0
void MDFNFILE::ApplyIPS(Stream *ips)
{
//
// If the stream is not a MemoryStream, turn it into one.
//
//if(!(str->attributes() & Stream::ATTRIBUTE_WRITEABLE))
    if(dynamic_cast<MemoryStream*>(str.get()) == nullptr)
    {
        str.reset(new MemoryStream(str.release(), MaxROMImageSize));
    }

    {
        MDFN_AutoIndent aind(1);
        uint32 count;

        count = IPSPatcher::Apply(ips, str.get());

        MDFN_printf(_("IPS EOF:  Did %u patches\n\n"), count);

        if(ips->tell() < ips->size())
        {
            MDFN_AutoIndent aindw(1);

            MDFN_printf(_("Warning:  trailing unused data in IPS file.\n"));
        }
    }
}
Exemplo n.º 7
0
//=============================================================================
static void rom_hack(void)
{
	//=============================
	// SPECIFIC ROM HACKS !
	//=============================

	//"Neo-Neo! V1.0 (PD)"
	if (MATCH_CATALOG(0, 16))
	{
		ngpc_rom.data[0x23] = 0x10;	// Fix rom header

		MDFN_printf("HACK: \"Neo-Neo! V1.0 (PD)\"\n");
	}

	//"Cool Cool Jam SAMPLE (U)"
	if (MATCH_CATALOG(4660, 161))
	{
		ngpc_rom.data[0x23] = 0x10;	// Fix rom header

		MDFN_printf("HACK: \"Cool Cool Jam SAMPLE (U)\"\n");
	}

	//"Dokodemo Mahjong (J)"
	if (MATCH_CATALOG(51, 33))
	{
		ngpc_rom.data[0x23] = 0x00;	// Fix rom header

		MDFN_printf("HACK: \"Dokodemo Mahjong (J)\"\n");
	}
}
Exemplo n.º 8
0
static bool cdif_open_sub(const char *device_name)
{
 MDFN_printf(_("Loading %s...\n\n"), device_name ? device_name : _("PHYSICAL CDROM DISC"));
 MDFN_indent(1);

 if(!(p_cdrfile = cdrfile_open(device_name)))
 {
  MDFN_indent(-1);
  return(0);
 }

 CD_Info.NumTracks = cdrfile_get_num_tracks(p_cdrfile);
 if(CD_Info.NumTracks < 1 || CD_Info.NumTracks > 100)
 {
  MDFN_indent(-1);
  return(0);
 }

 CD_Info.FirstTrack = cdrfile_get_first_track_num(p_cdrfile);

 for(track_t track = CD_Info.FirstTrack; track < CD_Info.FirstTrack + CD_Info.NumTracks; track++)
 {
  CD_Info.Tracks[track].LSN = cdrfile_get_track_lsn(p_cdrfile, track);
  CD_Info.Tracks[track].Format = cdrfile_get_track_format(p_cdrfile, track);
  MDFN_printf(_("Track %2d, LSN: %6d %s\n"), track, CD_Info.Tracks[track].LSN, track_format2str[CD_Info.Tracks[track].Format]);
 }
 MDFN_indent(-1);
 return(1);
}
Exemplo n.º 9
0
static bool LoadCPalette(const char *syspalname, uint8 **ptr, uint32 num_entries)
{
 std::string colormap_fn = MDFN_MakeFName(MDFNMKF_PALETTE, 0, syspalname).c_str();

 MDFN_printf(_("Loading custom palette from \"%s\"...\n"),  colormap_fn.c_str());
 MDFN_indent(1);

 *ptr = NULL;
 try
 {
  FileStream fp(colormap_fn.c_str(), FileStream::MODE_READ);

  if(!(*ptr = (uint8 *)MDFN_malloc(num_entries * 3, _("custom color map"))))
  {
   MDFN_indent(-1);
   return(false);
  }

  fp.read(*ptr, num_entries * 3);
 }
 catch(MDFN_Error &e)
 {
  if(*ptr)
  {
   MDFN_free(*ptr);
   *ptr = NULL;
  }

  MDFN_printf(_("Error: %s\n"), e.what());
  MDFN_indent(-1);
  return(e.GetErrno() == ENOENT);        // Return fatal error if it's an error other than the file not being found.
 }
 catch(std::exception &e)
 {
  if(*ptr)
  {
   MDFN_free(*ptr);
   *ptr = NULL;
  }

  MDFN_printf(_("Error: %s\n"), e.what());
  MDFN_indent(-1);
  return(false);
 }

 MDFN_indent(-1);

 return(true);
}
Exemplo n.º 10
0
static void Load(MDFNFILE *fp)
{
 try
 {
  const uint64 fp_size = fp->size();

  if(fp_size > 1024 * 1024 * 8) // 4MiB maximum ROM size, 2* to be a little tolerant of garbage.
   throw MDFN_Error(0, _("NGP/NGPC ROM image is too large."));

  ngpc_rom.length = fp_size;
  ngpc_rom.data = new uint8[ngpc_rom.length];
  fp->read(ngpc_rom.data, ngpc_rom.length);

  md5_context md5;
  md5.starts();
  md5.update(ngpc_rom.data, ngpc_rom.length);
  md5.finish(MDFNGameInfo->MD5);

  rom_loaded();
  MDFN_printf(_("ROM:       %uKiB\n"), (ngpc_rom.length + 1023) / 1024);
  MDFN_printf(_("ROM MD5:   0x%s\n"), md5_context::asciistr(MDFNGameInfo->MD5, 0).c_str());
  FLASH_LoadNV();

  MDFNMP_Init(1024, 1024 * 1024 * 16 / 1024);

  NGPGfx = new NGPGFX_CLASS();

  MDFNGameInfo->fps = (uint32)((uint64)6144000 * 65536 * 256 / 515 / 198); // 3072000 * 2 * 10000 / 515 / 198
  MDFNGameInfo->GameSetMD5Valid = FALSE;

  MDFNNGPCSOUND_Init();

  MDFNMP_AddRAM(16384, 0x4000, CPUExRAM);

  SetFRM(); // Set up fast read memory mapping

  bios_install();

  //main_timeaccum = 0;
  z80_runtime = 0;

  reset();
 }
 catch(...)
 {
  Cleanup();
  throw;
 }
}
Exemplo n.º 11
0
static void Load(MDFNFILE *fp)
{
 try
 {
  lynxie = new CSystem(fp);

  switch(lynxie->CartGetRotate())
  {
   case CART_ROTATE_LEFT:
	MDFNGameInfo->rotated = MDFN_ROTATE270;
	break;

   case CART_ROTATE_RIGHT:
	MDFNGameInfo->rotated = MDFN_ROTATE90;
	break;
  }

  MDFNGameInfo->GameSetMD5Valid = false;
  if(lynxie->mRam->InfoRAMSize)
  {
   memcpy(MDFNGameInfo->MD5, lynxie->mRam->MD5, 16);
   MDFN_printf(_("RAM:       %u bytes\n"), lynxie->mRam->InfoRAMSize);
   MDFN_printf(_("RAM MD5:   0x%s\n"), md5_context::asciistr(MDFNGameInfo->MD5, 0).c_str());
  }
  else
  {
   memcpy(MDFNGameInfo->MD5, lynxie->mCart->MD5, 16);
   MDFN_printf(_("ROM:       %dKiB\n"), (lynxie->mCart->InfoROMSize + 1023) / 1024);
   MDFN_printf(_("ROM MD5:   0x%s\n"), md5_context::asciistr(MDFNGameInfo->MD5, 0).c_str());
  }

  MDFNGameInfo->fps = (uint32)(59.8 * 65536 * 256);

  if(MDFN_GetSettingB("lynx.lowpass"))
  {
   lynxie->mMikie->miksynth.treble_eq(-35);
  }
  else
  {
   lynxie->mMikie->miksynth.treble_eq(0);
  }
 }
 catch(std::exception &e)
 {
  Cleanup();

  throw;
 }
}
Exemplo n.º 12
0
 MPCReader(FILE *fp)
 {
	fseek(fp, 0, SEEK_SET);
	lseek(fileno(fp), 0, SEEK_SET);

	memset(&MPCReaderFile, 0, sizeof(MPCReaderFile));
	memset(&MPCStreamInfo, 0, sizeof(MPCStreamInfo));
	memset(&MPCDecoder, 0, sizeof(MPCDecoder));
	memset(MPCBuffer, 0, sizeof(MPCBuffer));

	mpc_streaminfo_init(&MPCStreamInfo);
	mpc_reader_setup_file_reader(&MPCReaderFile, fp);

        if(mpc_streaminfo_read(&MPCStreamInfo, &MPCReaderFile.reader) != ERROR_CODE_OK)
        {
         throw(0);
        }

        mpc_decoder_setup(&MPCDecoder, &MPCReaderFile.reader);
        if(!mpc_decoder_initialize(&MPCDecoder, &MPCStreamInfo))
        {
         MDFN_printf(_("Error initializing MusePack decoder!\n"));
         throw(0);
        }
 }
Exemplo n.º 13
0
int32 PCECD_Init()
{
	if (!CDIF_Init())
		return -1;

	CDDAVolumeSetting = (double)MDFN_GetSettingUI("pce.cddavolume");

	if(CDDAVolumeSetting != 100)
	{
	 MDFN_printf(_("CD-DA Volume: %d%%\n"), (int)CDDAVolumeSetting);
	}

	CDDAVolumeSetting /= 100;


        CurrentCDVolume = InitialCdVolume = 65536;
        VolumeStep      = InitialCdVolume / 100;

        bFadeOut = FALSE;
        bFadeIn  = FALSE;

	ADPCM_SetNotificationFunction(adpcm_state_notification_callback_function);

	SCSICD_Init(SCSICD_PCE, 1 * pce_overclocked, &sbuf[0], &sbuf[1], 126000 * MDFN_GetSettingUI("pce.cdspeed"), 7159091 * pce_overclocked, CDIRQ, StuffSubchannel);

	SyncCDVolume();


	#ifdef WANT_DEBUGGER
	MDFNDBG_AddRegGroup(&PCECDRegsGroup);
	#endif
	return 0;
}
Exemplo n.º 14
0
static void LoadPRG(Stream *fp)
{
 uint32 t;
 unsigned z;

 z = uchead.ID[3] - '0';	// FIXME hex

 if(z > 15)
  throw MDFN_Error(0, "Invalid PRG ROM index '%c'.\n", uchead.ID[3]);

 MDFN_printf(_("PRG ROM %u size: %u\n"), z, uchead.info);

 if(malloced[z])
  free(malloced[z]);

 t = FixRomSize(uchead.info, 2048);

 malloced[z] = (uint8 *)MDFN_malloc_T(t, _("PRG ROM"));
 mallocedsizes[z] = t;
 memset(malloced[z] + uchead.info, 0xFF, t - uchead.info);

 fp->read(malloced[z], uchead.info);

 SetupCartPRGMapping(z,malloced[z],t,0); 
}
Exemplo n.º 15
0
static void MakeSFMap(SFORMAT *sf, SFMap_t &sfmap)
{
 while(sf->size || sf->name) // Size can sometimes be zero, so also check for the text name.  These two should both be zero only at the end of a struct.
 {
  if(!sf->size || !sf->v)
  {
   sf++;
   continue;
  }

  if(sf->size == (uint32)~0)            /* Link to another SFORMAT structure. */
   MakeSFMap((SFORMAT *)sf->v, sfmap);
  else
  {
   assert(sf->name);

   if(sfmap.find(sf->name) != sfmap.end())
	   MDFN_printf("Duplicate save state variable in internal emulator structures(CLUB THE PROGRAMMERS WITH BREADSTICKS): %s\n", sf->name);

   sfmap[sf->name] = sf;
  }

  sf++;
 }
}
Exemplo n.º 16
0
bool MDFNI_StartAVRecord(const char *path, double SoundRate)
{
 try
 {
  QTRecord::VideoSpec spec;

  memset(&spec, 0, sizeof(spec));

  spec.SoundRate = SoundRate;
  spec.SoundChan = MDFNGameInfo->soundchan;
  spec.VideoWidth = MDFNGameInfo->lcm_width;
  spec.VideoHeight = MDFNGameInfo->lcm_height;
  spec.VideoCodec = MDFN_GetSettingI("qtrecord.vcodec");
  spec.MasterClock = MDFNGameInfo->MasterClock;

  if(spec.VideoWidth < MDFN_GetSettingUI("qtrecord.w_double_threshold"))
   spec.VideoWidth *= 2;

  if(spec.VideoHeight < MDFN_GetSettingUI("qtrecord.h_double_threshold"))
   spec.VideoHeight *= 2;


  spec.AspectXAdjust = ((double)MDFNGameInfo->nominal_width * 2) / spec.VideoWidth;
  spec.AspectYAdjust = ((double)MDFNGameInfo->nominal_height * 2) / spec.VideoHeight;

  MDFN_printf("\n");
  MDFN_printf(_("Starting QuickTime recording to file \"%s\":\n"), path);
  MDFN_indent(1);
  MDFN_printf(_("Video width: %u\n"), spec.VideoWidth);
  MDFN_printf(_("Video height: %u\n"), spec.VideoHeight);
  MDFN_printf(_("Video codec: %s\n"), MDFN_GetSettingS("qtrecord.vcodec").c_str());

  if(spec.SoundRate && spec.SoundChan)
  {
   MDFN_printf(_("Sound rate: %u\n"), std::min<uint32>(spec.SoundRate, 64000));
   MDFN_printf(_("Sound channels: %u\n"), spec.SoundChan);
  }
  else
   MDFN_printf(_("Sound: Disabled\n"));

  MDFN_indent(-1);
  MDFN_printf("\n");

  qtrecorder = new QTRecord(path, spec);
 }
 catch(std::exception &e)
 {
  MDFND_PrintError(e.what());
  return(false);
 }
 return(true);
}
Exemplo n.º 17
0
static int Load(const char *name, MDFNFILE *fp)
{
 try
 {
  lynxie = new CSystem(fp->data, fp->size);

  switch(lynxie->CartGetRotate())
  {
   case CART_ROTATE_LEFT:
	MDFNGameInfo->rotated = MDFN_ROTATE270;
	break;

   case CART_ROTATE_RIGHT:
	MDFNGameInfo->rotated = MDFN_ROTATE90;
	break;
  }

  memcpy(MDFNGameInfo->MD5, lynxie->mCart->MD5, 16);
  MDFNGameInfo->GameSetMD5Valid = FALSE;

  MDFN_printf(_("ROM:       %dKiB\n"), (lynxie->mCart->InfoROMSize + 1023) / 1024);
  MDFN_printf(_("ROM CRC32: 0x%08x\n"), lynxie->mCart->CRC32());
  MDFN_printf(_("ROM MD5:   0x%s\n"), md5_context::asciistr(MDFNGameInfo->MD5, 0).c_str());

  MDFNGameInfo->fps = (uint32)(59.8 * 65536 * 256);

  if(MDFN_GetSettingB("lynx.lowpass"))
  {
   lynxie->mMikie->miksynth.treble_eq(-35);
  }
  else
  {
   lynxie->mMikie->miksynth.treble_eq(0);
  }
 }
 catch(std::exception &e)
 {
  MDFN_PrintError("%s", e.what());

  Cleanup();

  return(0);
 }

 return(1);
}
Exemplo n.º 18
0
MCGenjin::MCGenjin(Blip_Buffer *bb, const uint8 *rr, uint32 rr_size)
{
 uint8 revision, num256_pages, region, cs_di[2];

 if(rr_size < 8192)
  throw MDFN_Error(0, _("MCGenjin ROM size is too small!"));

 if(memcmp(rr + 0x1FD0, "MCGENJIN", 8))
  throw MDFN_Error(0, _("MC Genjin header magic missing!"));

 rom.resize(round_up_pow2(rr_size));

 memcpy(&rom[0], rr, rr_size);

 revision = rom[0x1FD8];
 num256_pages = rom[0x1FD9];
 region = rom[0x1FDA];
 cs_di[0] = rom[0x1FDB];
 cs_di[1] = rom[0x1FDC];

 for(unsigned i = 0; i < 2; i++)
 {
  switch(cs_di[i])
  {
   default:
	for(unsigned si = 0; si < i; si++) // FIXME: auto ptr to make this not necessary
         delete cs[si];

	throw MDFN_Error(0, _("Unsupported MCGENJIN device on CS%d: 0x%02x"), i, cs_di[i]);
	break;

   case 0x00:
	MDFN_printf(_("CS%d: Unused\n"), i);
	cs[i] = new MCGenjin_CS_Device();
	break;

   case 0x10 ... 0x18:
   case 0x20 ... 0x28:
	MDFN_printf(_("CS%d: %uKiB %sRAM\n"), i, 8 << (cs_di[i] & 0xF), (cs_di[i] & 0x20) ? "Nonvolatile " : "");
	cs[i] = new MCGenjin_CS_Device_RAM(8192 << (cs_di[i] & 0xF), (bool)(cs_di[i] & 0x20));
	break;
  }
 }
}
Exemplo n.º 19
0
static void EnableBattery(Stream *fp)
{
 uint8 t;

 fp->read(&t, 1);

 MDFN_printf(_("Battery-backed.\n"));

 UNIFCart.battery = 1;
}
Exemplo n.º 20
0
void PCE_InitCD(void)
{
 PCECD_Settings cd_settings;
 memset(&cd_settings, 0, sizeof(PCECD_Settings));

 cd_settings.CDDA_Volume = (double)MDFN_GetSettingUI("pce_fast.cddavolume") / 100;
 cd_settings.CD_Speed = MDFN_GetSettingUI("pce_fast.cdspeed");

 cd_settings.ADPCM_Volume = (double)MDFN_GetSettingUI("pce_fast.adpcmvolume") / 100;
 cd_settings.ADPCM_LPF = MDFN_GetSettingB("pce_fast.adpcmlp");

 if(cd_settings.CDDA_Volume != 1.0)
  MDFN_printf(_("CD-DA Volume: %d%%\n"), (int)(100 * cd_settings.CDDA_Volume));

 if(cd_settings.ADPCM_Volume != 1.0)
  MDFN_printf(_("ADPCM Volume: %d%%\n"), (int)(100 * cd_settings.ADPCM_Volume));

 PCECD_Init(&cd_settings, PCECDIRQCB, PCE_MASTER_CLOCK, pce_overclocked, sbuf);
}
Exemplo n.º 21
0
static void NAME(Stream *fp)
{
 assert(uchead.info <= (SIZE_MAX - 1));

 MDFNGameInfo->name.resize((size_t)uchead.info);
 fp->read(&MDFNGameInfo->name[0], (size_t)uchead.info);
 MDFN_zapctrlchars(MDFNGameInfo->name);

 MDFN_printf(_("Name: %s\n"), MDFNGameInfo->name.c_str());
}
Exemplo n.º 22
0
static MDFN_COLD void Load(MDFNFILE *fp)
{
 try
 {
  uint8 hes_header[4];

  const bool IsHES = false;
  IsSGX = false;

  fp->read(hes_header, 4);
  fp->seek(0, SEEK_SET);

  /*if(!memcmp(hes_header, "HESM", 4))
   IsHES = true;*/

  LoadCommonPre();

  for(int x = 0; x < 0x100; x++)
  {
   HuCPU.PCERead[x] = PCEBusRead;
   HuCPU.PCEWrite[x] = PCENullWrite;
  }

  if(IsHES)
   HES_Load(fp);
  else
  {
   uint32 crc;

   crc = HuC_Load(fp);

   if(fp->ext == "sgx")
    IsSGX = true;
   else
   {
    for(auto const& e : sgx_table)
    {
     if(e.crc == crc)
     {
      IsSGX = true;
      MDFN_printf(_("SuperGrafx: %s\n"), e.name);
      break;
     }
    }
   }
  }

  LoadCommon();
 }
 catch(...)
 {
  Cleanup();
  throw;
 }
}
Exemplo n.º 23
0
void  instruction_error(char* vaMessage,...)
{
	char message[1000];
	va_list vl;

	va_start(vl, vaMessage);
	vsprintf(message, vaMessage, vl);
	va_end(vl);

	MDFN_printf("[PC %06X] %s\n", pc, message);
}
Exemplo n.º 24
0
bool CDIF_ReadSector(uint8* pBuf, uint32 lba, uint32 nSectors)
{
 while(nSectors--)
 {
  uint8 tmpbuf[2352 + 96];

  if(!CDIF_ReadRawSector(tmpbuf, lba))
  {
	  MDFN_printf("CDIF Raw Read error");
   return(FALSE);
  }

  if(!CDIF_ValidateRawSector(tmpbuf))
  {
   MDFN_DispMessage(_("Uncorrectable data at sector %d"), lba);
   MDFN_PrintError(_("Uncorrectable data at sector %d"), lba);
   return(false);
  }

  const int mode = tmpbuf[12 + 3];

  if(mode == 1)
  {
   memcpy(pBuf, &tmpbuf[12 + 4], 2048);
  }
  else if(mode == 2)
  {
   memcpy(pBuf, &tmpbuf[12 + 4 + 8], 2048);
  }
  else
  {
	  MDFN_printf("CDIF_ReadSector() invalid sector type at LBA=%u\n", (unsigned int)lba);
   return(false);
  }

  pBuf += 2048;
  lba++;
 }

 return(true);
}
Exemplo n.º 25
0
static void LoadCommonPre(void)
{
 // FIXME:  Make these globals less global!
 pce_overclocked = MDFN_GetSettingUI("pce_fast.ocmultiplier");
 PCE_ACEnabled = MDFN_GetSettingB("pce_fast.arcadecard");

 if(pce_overclocked > 1)
  MDFN_printf(_("CPU overclock: %dx\n"), pce_overclocked);

 if(MDFN_GetSettingUI("pce_fast.cdspeed") > 1)
  MDFN_printf(_("CD-ROM speed:  %ux\n"), (unsigned int)MDFN_GetSettingUI("pce_fast.cdspeed"));

 memset(HuCPUFastMap, 0, sizeof(HuCPUFastMap));
 for(int x = 0; x < 0x100; x++)
 {
  PCERead[x] = PCEBusRead;
  PCEWrite[x] = PCENullWrite;
 }

 MDFNMP_Init(1024, (1 << 21) / 1024);
}
Exemplo n.º 26
0
void VBlur_Init(void)
{
        std::string sn = MDFNGameInfo->shortname;

        if(MDFN_GetSettingB(std::string(sn + "." + std::string("vblur")).c_str()))
        {
         AccumBlurAmount = (uint32)(16384 * MDFN_GetSettingF(std::string(sn + "." + std::string("vblur.accum.amount")).c_str()) / 100);
         if(MDFN_GetSettingB(std::string(sn + "." + std::string("vblur.accum")).c_str()))
         {
          AccumBlurBuf = (HQPixelEntry *)calloc(sizeof(HQPixelEntry), (MDFNGameInfo->pitch >> 2) * 256);
          MDFN_printf(_("Video frame blur enabled with accumulation: %f.\n"), (double)AccumBlurAmount * 100 / 16384);
         }
Exemplo n.º 27
0
int DetectMMC5WRAMSize(uint32 crc32)
{
 int x;

 for(x=0;x<MMC5_NOCARTS;x++)
  if(crc32==MMC5CartList[x].crc32)
  {
    MDFN_printf(_(">8KB external WRAM present.  Use UNIF if you hack the ROM image.\n"));
    return(MMC5CartList[x].size*8);
  }
 return(8);
}
Exemplo n.º 28
0
static int Load(const char *name, MDFNFILE *fp)
{
 if(!(ngpc_rom.data = (uint8 *)MDFN_malloc(GET_FSIZE_PTR(fp), _("Cart ROM"))))
  return(0);

 ngpc_rom.length = GET_FSIZE_PTR(fp);
 memcpy(ngpc_rom.data, GET_FDATA_PTR(fp), GET_FSIZE_PTR(fp));

 md5_context md5;
 md5.starts();
 md5.update(ngpc_rom.data, ngpc_rom.length);
 md5.finish(MDFNGameInfo->MD5);

 rom_loaded();
 MDFN_printf(_("ROM:       %dKiB\n"), (ngpc_rom.length + 1023) / 1024);
 MDFN_printf(_("ROM MD5:   0x%s\n"), md5_context::asciistr(MDFNGameInfo->MD5, 0).c_str());

 MDFNMP_Init(1024, 1024 * 1024 * 16 / 1024);

 NGPGfx = new NGPGFX_CLASS();

 MDFNGameInfo->fps = (uint32)((uint64)6144000 * 65536 * 256 / 515 / 198); // 3072000 * 2 * 10000 / 515 / 198
 MDFNGameInfo->GameSetMD5Valid = FALSE;

 MDFNNGPCSOUND_Init();

 MDFNMP_AddRAM(16384, 0x4000, CPUExRAM);

 SetFRM(); // Set up fast read memory mapping

 bios_install();

 //main_timeaccum = 0;
 z80_runtime = 0;

 reset();

 return(1);
}
Exemplo n.º 29
0
static void SetBoardName(Stream *fp)
{
 assert(uchead.info <= (SIZE_MAX - 1));
 boardname = (uint8*)MDFN_malloc_T((size_t)uchead.info + 1, _("Board Name"));

 fp->read(boardname, uchead.info);
 boardname[uchead.info] = 0;
 MDFN_RemoveControlChars((char*)boardname);

 MDFN_printf(_("Board name: %s\n"), boardname);
 sboardname=boardname;
 if(!memcmp(boardname,"NES-",4) || !memcmp(boardname,"UNL-",4) || !memcmp(boardname,"HVC-",4) || !memcmp(boardname,"BTL-",4) || !memcmp(boardname,"BMC-",4))
  sboardname+=4;
}
Exemplo n.º 30
0
static int DetectMMC1WRAMSize(uint32 crc32)
{
        switch(crc32)
        {
         default:return(8);
	 case 0xc6182024:	/* Romance of the 3 Kingdoms */
         case 0x2225c20f:       /* Genghis Khan */
         case 0x4642dda6:       /* Nobunaga's Ambition */
	 case 0x29449ba9:	/* ""	"" (J) */
	 case 0x2b11e0b0:	/* ""	"" (J) */
		MDFN_printf(_(">8KB external WRAM present.  Use UNIF if you hack the ROM image.\n"));
		return(16);
        }
}