Made hmp code actually read tempo. Due to missing documentation of the format I can only guess it's a 4 bit int

This commit is contained in:
zico 2013-06-10 16:34:45 +02:00
parent 47d8ca0713
commit 6b0e493500
2 changed files with 20 additions and 3 deletions

View file

@ -1,5 +1,9 @@
D1X-Rebirth Changelog
20130610
--------
misc/hmp.c: Made hmp code actually read tempo. Due to missing documentation of the format I can only guess it's a 4 bit int
20130422
--------
main/net_udp.c: In restricted game mode check for player callsign and sockaddr at the same time; Clear Netgame struct each time player enters a new IP in manual join menu

View file

@ -44,7 +44,7 @@ void hmp_close(hmp_file *hmp)
}
hmp_file *hmp_open(const char *filename) {
int i, data, num_tracks;
int i, data, num_tracks, tempo;
char buf[256];
PHYSFS_file *fp;
hmp_file *hmp;
@ -88,9 +88,21 @@ hmp_file *hmp_open(const char *filename) {
hmp_close(hmp);
return NULL;
}
hmp->num_trks = num_tracks;
hmp->tempo = 120;
if (PHYSFSX_fseek(fp, 0x38, SEEK_SET))
{
PHYSFS_close(fp);
hmp_close(hmp);
return NULL;
}
if (PHYSFS_read(fp, &tempo, 4, 1) != 1)
{
PHYSFS_close(fp);
hmp_close(hmp);
return NULL;
}
hmp->tempo = tempo;
if (PHYSFSX_fseek(fp, 0x308, SEEK_SET))
{
@ -720,6 +732,7 @@ void hmp2mid(char *hmp_name, unsigned char **midbuf, unsigned int *midlen)
return;
*midlen = 0;
time_div = hmp->tempo*1.6;
// write MIDI-header
*midbuf = d_realloc(*midbuf, *midlen + 4);