Esempio n. 1
0
  private byte[] getVoiceData(String folder, int offset) {
    _RandomAccessFile in = null;
    byte[] data = new byte[0];
    int leftDataLen = 0;
    if (offset == -1) return data;
    byte[] head = new byte[HEADERLEN];
    try {
      String fileName = RA4DATAFILE;
      if ((offset & 0xf0000000) == 0x10000000) {
        offset = offset & 0x0fffffff;
        fileName = RA3DATAFILE;
      }
      in = new _RandomAccessFile(folder + fileName, "r", true);
      in.seek(offset);
      in.readFully(head);

      cipher.reset();
      cipher.setXY(offset);
      cipher.processBytes(head);
      switch (head[5]) {
        case 3: // ra3? MVOICE1.DAT
          leftDataLen = ((head[0x14] & 0xff) << 8 | (head[0x15] & 0xff)) + 0x08;
          break;
        case 4: // ra4 MVOICE0.DAT
          leftDataLen = ((head[0x0e] & 0xff) << 8 | (head[0x0f] & 0xff)) + 0x10;
          break;
        default:
          return null;
      }
      data = new byte[leftDataLen + HEADERLEN];
      in.readFully(data, HEADERLEN, leftDataLen);
      cipher.processBytes(data, HEADERLEN);

      System.arraycopy(head, 0, data, 0, HEADERLEN);
    } catch (FileNotFoundException e) {
      Logger.err(e);
    } catch (IOException e) {
      Logger.err(e);
    } finally {
      try {
        if (in != null) in.close();
      } catch (IOException e) {
        Logger.err(e);
      }
    }
    return data;
  }
Esempio n. 2
0
  protected void load() throws IOException, BadFormatException {
    _RandomAccessFile in = null;
    try {
      in = new _RandomAccessFile(srcFolder + KSINDEXFILE, "r", true);
      int size;

      size = 26 * 26;
      index0.read(in, ++size);

      size = ((VoiceIndex0Item) index0.getItem(index0.getSize() - 1)).getIndex1();
      index1.read(in, ++size);

      size = ((VoiceIndex1Item) index1.getItem(index1.getSize() - 1)).getIndex2Offset();
      index2.read(in, size); // size parameter is actually the length

    } finally {
      try {
        if (in != null) in.close();
      } catch (IOException e) {
        Logger.err(e);
      }
    }
  }