Exemplo n.º 1
0
TbBool read_heap_item(struct HeapMgrHandle *hmhandle, long offs, long len)
{
    if (file_handle == -1) {
        return false;
    }
    // TODO make error handling
    _DK_LbFileSeek(file_handle, offs, 0);
    _DK_LbFileRead(file_handle, hmhandle->buf, len);
    return true;
}
Exemplo n.º 2
0
long parse_sound_file(TbFileHandle fileh, unsigned char *buf, long *nsamples, long buf_len, long a5)
{
    struct SoundBankHead bhead;
    struct SoundBankEntry bentries[9];
    struct SoundBankSample bsample;

    unsigned char rbuf[8];
    struct SampleTable *smpl;
    struct SoundBankEntry *bentry;
    long fsize;
    long i,k;

    // TODO SOUND use rewritten version when sound routines are rewritten

    switch ( a5 )
    {
    case 1610:
        k = 5;
        break;
    case 822:
        k = 6;
        break;
    case 811:
        k = 7;
        break;
    case 800:
        k = 8;
        break;
    case 1611:
        k = 4;
        break;
    case 1620:
        k = 3;
        break;
    case 1622:
        k = 2;
        break;
    case 1640:
        k = 1;
        break;
    case 1644:
        k = 0;
        break;
    default:
        return 0;
    }
    _DK_LbFileSeek(fileh, 0, Lb_FILE_SEEK_END);
    fsize = _DK_LbFilePosition(fileh);
    _DK_LbFileSeek(fileh, fsize-4, Lb_FILE_SEEK_BEGINNING);
    _DK_LbFileRead(fileh, &rbuf, 4);
    i = read_int32_le_buf(rbuf);
    _DK_LbFileSeek(fileh, i, Lb_FILE_SEEK_BEGINNING);
    _DK_LbFileRead(fileh, &bhead, sizeof(bhead));
    _DK_LbFileRead(fileh, bentries, sizeof(bentries));
    bentry = &bentries[k];
    if (bentry->field_0 == 0) {
        return 0;
    }
    if (bentry->field_8 == 0) {
        return 0;
    }
    i = bentry->field_8 / sizeof(struct SoundBankSample);
    *nsamples = i;
    if (sizeof(struct SampleTable) * (*nsamples) >= buf_len) {
        return 0;
    }
    _DK_LbFileSeek(fileh, bentry->field_0, Lb_FILE_SEEK_BEGINNING);
    smpl = (struct SampleTable *)buf;
    k = bentry->field_4;
    for (i=0; i < *nsamples; i++)
    {
        _DK_LbFileRead(fileh, &bsample, sizeof(struct SoundBankSample));
        smpl->file_pos = k + bsample.field_12;
        smpl->data_size = bsample.data_size;
        smpl->sfxid = bsample.sfxid;
        smpl->hmhandle = NULL;
        smpl++;
    }
    //TODO SOUND Check why we're returning nsamples * 32 and not nsamples * 16
    return sizeof(struct SoundBankSample) * (*nsamples);
}