Esempio n. 1
0
void *ice_load(istream_t *is, int *ulen)
{
  char header[12], *inbuf = 0, * outbuf = 0;
  int dsize, csize;
  const char * fname;

  fname = istream_filename(is);

  if (istream_read(is,header,12) != 12) {
    SC68error_add("ice_load(%s) : no header", fname);
    goto error;
  }

  csize = 0;
  dsize = unice68_get_depacked_size(header, &csize);

  if (dsize < 0) {
    SC68error_add("ice_load(%s) : not ICE!", fname);
    goto error;
  }

  inbuf = SC68alloc(csize + 12);

  if (!inbuf) {
    SC68error_add("ice_load(%s) : alloc input buffer failed", fname);
    goto error;
  }

  memcpy(inbuf,header,12);
  if (istream_read(is,inbuf+12,csize) != csize) {
    SC68error_add("ice_load(%s) : read failed", fname);
    goto error;
  }

  outbuf = SC68alloc(dsize);

  if (!outbuf) {
    SC68error_add("ice_load(%s) : alloc output buffer failed", fname);
    goto error;
  }

  if (!unice68_depacker(outbuf, inbuf)) {
    goto success;
  }
  
 error:

  SC68free(outbuf);
  outbuf = 0;
  dsize = 0;
 success:
  SC68free(inbuf);
  if (ulen) {
    *ulen = dsize;
  }
  return outbuf;
}
Esempio n. 2
0
/* Get indice of named field in SC68config_t array
 * return <0 if field doesn't exist
 */
int SC68config_get_id(const char * name)
{
  int i;
  if (name) {
    for(i=0; i<nconfig; i++) {
      if (!SC68strcmp(name,tab[i].name)) {
	return i;
      }
    }
    SC68error_add("SC68config_get_id(%s) : Not found", name);
  } else {
    SC68error_add("SC68config_get_id() : NULL pointer");
  }
  return -1;
}
Esempio n. 3
0
static int config_check(SC68config_t * conf)
{
  if (!conf) {
    return SC68error_add("SC68config_check() : NULL pointer");
  }
  return 0;
}
Esempio n. 4
0
/** Initialize 68000 emulator.
 */
static int init_68K(reg68_t * r, u32 sz)
{
  if (EMU68_init(sz) < 0) {
    return SC68error_add(EMU68error_get());
  }
  *r = reg68;
  r->sr = 0x2000;
  r->a[7] = sz - 4;
  if (MW_init() < 0)
    return SC68error_add("Microwire emulator init failed");
  if (MFP_init() < 0)
    return SC68error_add("MFP emulator init failed");
  if (YM_init() < 0)
    return SC68error_add("Yamaha 2149 emulator init failed");
  if (PL_init() < 0)
    return SC68error_add("Paula emulator init failed");
  return 0;
}
Esempio n. 5
0
static int init(any_driver_t *d)
{
  int err = 0;
  int frq;

/*   SDDEBUG("sc68 : Init [%s]\n", d->name); */

  /* check whether EMU68 is compiled without debug option */
  if (EMU68_sizeof_reg68() != sizeof(reg68_t)) {
    SC68error_add
      ("Internal : Bad EMU68 version : should not define SC68DEBUG ...");
    err = __LINE__;
    goto error;
  }

  /* Set default configuration */
  set_sc68app_default(&app);

  /* Copy config parameters to app */
  SC68app_configure(&app);

  frq = (int) app.mix.real_frq;

  /* 68K & IO-Emulators init */
  if (init_68K(&app.reg68, MEMORY68)) {
    err = __LINE__;
    goto error;
  }
/*   SDDEBUG("sc68: 68K emulator init : OK\n"); */

  /* IO replay frequency init */
  app.mix.real_frq = 44100;
  YM_set_replay_frq(app.mix.real_frq);
  MW_set_replay_frq((int) app.mix.real_frq);
  PL_set_replay_frq((int) app.mix.real_frq);
  app.mix.buf = YM_get_buffer();

  SDDEBUG("[sc68] : create sc68 romdisk\n");
  fs_rz_init(sc68newdisk);

 error:
  if (err) {
    spool_error_message();
    SDERROR("[%s] : error line [%d]\n", __FUNCTION__ , err);
    shutdown_68K();
  }

  return -!!err;
}