Page 1 of 1

Problem in bas2tap and sync bytes

Posted: Sat Apr 26, 2014 12:33 pm
by Godzil
Hi there,

It seems that bas2tap is unable to handle basic tape that was not generated by himself (or to be precise, that use more than three 0x16 byte for the synchronisation)

Oricutron (or may I say, the Oric ROM?) use 4bytes and bas2tap is unable to decode it.

The current version use hardcoded position :

Code: Select all

  if (ptr_buffer[0]!=0x16 || ptr_buffer[3]!=0x24) 
  { 
    ShowError("Not an Oric file");
  }
  if (ptr_buffer[6]) 
  { 
    ShowError("Not a BASIC file"); 
  }
  i=13;
So I made a simple patch to allow any number ≥ 3 of 0x16 before the 0x24:

Code: Select all

  i = 0;
  /* Get in sync with the header, number of 0x16 can't be determined.. */
  if (ptr_buffer[i] != 0x16)
  {
      ShowError("Not an Oric file [Byte 0 is not 0x16]");
  }
  while(ptr_buffer[++i] == 0x16);
  if (i < 3)
  {
      ShowError("Not an Oric file [Less than 3 0x16]");
  }
  if (ptr_buffer[i] != 0x24)
  {
      ShowError("Not an Oric file [0x16 stream is not followed by 0x24]");
  }
  
  /* Now we are "synchronized" */
  if  (ptr_buffer[i+3])
  { 
    ShowError("Not a BASIC file"); 
  }
  i += 10;