msikma / allegro-4.2.2-xc

Fork of Allegro 4.2.2 for cross compiling for DOS game development

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Check VOC file loading

nick7inc opened this issue · comments

Hello. I am use Allegro 4.2.1 and [found] (liballeg/allegro5#1341 (comment)), that one VOC file loads incorrectly in my 4.2.1 and Allegro 5 voc load function. I successfully backports _al_load_voc_f() from 5 to 4.2.1. If someone can check this file in 4.2.2 I can give my _al_load_voc_mod() function adopted for 4.2.1.

Source code is added in mentioned topic.

Hi @nick7inc. Thanks for your comment. I'm gonna be honest: I'm not really much of a C programmer, besides a few small experiments. The only thing I did for this repo is make sure it cross compiles correctly on DJGPP. As I understand it, there's a bug in 4.2.1 _al_load_voc_f() which you have fixed in the code in your comment, and it should be checked with the same file in 4.2.2 to see if the fix can be backported, correct?

I'll try to have a look at it soon, but I'm not sure I can actually verify myself if the fix works correctly and doesn't break anything else because I just don't have the experience for that.

Yes, _al_load_voc_pf() (to be correct) in Allegro4. It is loads only 1st block of VOC file (only first 2 of total 12 seconds). The _al_load_voc_f() from original Allegro5 do the same, but has more complex (and commented) code, so I could fix it to load whole VOC file from DukeNukem3D GRP resource file.

If you will have troubles, let me know (I use old MinGW, it is GCC-type compiler as well as DJGPP). If I'll have time (and health) I can try to convert C++ into C. I also have little experience in C, but the most code of _al5_uload_voc_mod() is C-type code. You need to get rid of template, refference, class (may be - enum) and little correct structure to fit C restrictions.

enum is supported by C, but not a bool type. I done it! Just need to test if it is works.

patch.zip
You need Allegro4.C\allegro4_patch.c file. You can compare it with my CPP version Tested Allegro4 C++ with UFILE\al_voc.cpp and original Allegro 5 file.

And useful function:

  inline float get_sample_instance_time(const struct SAMPLE *spl)
{
   if (!spl) return 0.0;
   return (float)(spl->len) / (float)spl->freq;
}

I don't actually understand where this file and that function are supposed to go. Is there any chance you could make this into a PR?

I have no Allegro 4.2.2 source code, and no experience with git-specific actions (what is the PR-?).

  1. You need to find, in which *.c file function load_voc_pf() with body exist, comment it (do not remove, old code).
  2. Open my allegro4_patch.c file (I forget to rename load_voc_pf_mod() back to load_voc_pf(), so do it), copy this function, _al_count_to_channel_conf() function, #define READNBYTES, all enums, init_AL_VOC_DATA() function and struct AL_VOC_DATA definition. May be there is some macros in orign Alegro 4.2.2 *.c file.
    May be if you send me the *.c file with old load_voc_pf() implementation I can patch it by myself, but I have to go into a hospital, don't know when I can do it.