Exemplo n.º 1
0
int open_tapefile(char *name, int type)
{
  int res;
  int ok;

  seg_desc[0] = '\0';
  currlev = 0;

  if(type != TAP_TAP && type != TAP_TZX) {
    rb->snprintf(seg_desc,DESC_LEN, "Illegal tape type");
    return 0;
  }

  /*tapefp = fopen(name, "rb");*/
  tapefd = rb->open(name, O_RDONLY);
  if(tapefd < 0 ) {
    /*rb->snprintf(seg_desc,DESC_LEN, "Could not open `%s': %s", name, strerror(errno));*/
    return 0;
  }
  
  tf_tpi.type = type;
  tf_cseg.pause = DEF_LEAD_PAUSE;
  INITTAPEOPT(tapeopt);

  currsegi = segi = 0;
  isbeg();

  firstseg_offs = 0;
  
  ok = 1;
  
  if(tf_tpi.type == TAP_TZX) {
    
    firstseg_offs = 10;
    res = readbuf(rbuf, 10, tapefd);
    if(res == 10 && rb->strncasecmp((char *)rbuf, tzxheader, 8) == 0) {
      tf_tpi.tzxmajver = rbuf[8];
      tf_tpi.tzxminver = rbuf[9];
      
      if(tf_tpi.tzxmajver > TZXMAJPROG) {
    rb->snprintf(seg_desc, DESC_LEN,
        "Cannot handle TZX file version (%i.%02i)", 
        tf_tpi.tzxmajver, tf_tpi.tzxminver);
    ok = 0;
      }
    }
    else {
      rb->snprintf(seg_desc,DESC_LEN, "Illegal TZX file header");
      ok = 0;
    }
  }
  
  if(!ok) {
    close_tapefile();
    return 0;
  }
  endnext = 0;

  loopctr = 0;
  callctr = 0;

  return 1;
}
Exemplo n.º 2
0
static void stop_playing(void)
{
  if(playing) close_tapefile();
  playing = 0;
}