From 83a955976fc866886082807a6959c254160f9444 Mon Sep 17 00:00:00 2001 From: zicodxx Date: Tue, 30 Nov 2010 12:20:09 +0100 Subject: [PATCH] Little fixes for rev950 - changed definition from WIN32 to _WIN32, added little hack for incorrectly set HMP loop in Descent2-version of descent.hmp --- CHANGELOG.txt | 6 +++++- include/hmp.h | 6 ++++-- misc/hmp.c | 10 +++++++++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 36636b71a..8d9d619eb 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,12 +1,16 @@ D2X-Rebirth Changelog +20101130 +-------- +include/hmp.h, misc/hmp.c: Little fixes for rev950 - changed definition from WIN32 to _WIN32, added little hack for incorrectly set HMP loop in Descent2-version of descent.hmp + 20101128 -------- main/multi.c: In multi_new_game when initializing Players structures, also correctly init connected variable which is highly important for spreading pdata to clients and should be set correctly anyways (Thanks to Gold Leader and Flip for help with debugging/testing recent Multiplayer bugs) main/powerup.c: in do_powerup added check for distance of other players to powerup object to make redundant pickups less likely arch/carbon/messagebox.c, arch/include/messagebox.h, arch/linux/messagebox.c, arch/sdl/rbaudio.c, arch/win32/messagebox.c, d2x-rebirth.xcodeproj/project.pbxproj, main/editor/med.c, main/game.c, main/inferno.c, SConstruct: Add support for OS native error/warning boxes, only implemented for Mac for now SConstruct: Added missing brackets gone missing in r936 -arch/sdl/digi.c, arch/sdl/digi_mixer_music.c, include/hmp.h, main/digi.h, main/songs.c, misc/args.c, misc/hmp.c: Large improvement for _WIN32 native MIDI code by TURRICAN0: supprt for HMP track loop, seamless song looping, GS reset, pausing/resuming midi, volume control for each MIDI channel; Set GameArg.SndDisableSdlMixer automatically if compiled without SDL_mixer support; On _WIN32 play HMP natively again +arch/sdl/digi.c, arch/sdl/digi_mixer_music.c, include/hmp.h, main/digi.h, main/songs.c, misc/args.c, misc/hmp.c: Large improvement for _WIN32 native MIDI code by TURRICAN: supprt for HMP track loop, seamless song looping, GS reset, pausing/resuming midi, volume control for each MIDI channel; Set GameArg.SndDisableSdlMixer automatically if compiled without SDL_mixer support; On _WIN32 play HMP natively again 20101126 -------- diff --git a/include/hmp.h b/include/hmp.h index f837e8021..1db702bc3 100644 --- a/include/hmp.h +++ b/include/hmp.h @@ -1,10 +1,11 @@ #ifndef __HMP_H #define __HMP_H -#ifdef WIN32 +#ifdef _WIN32 #include #include #endif +#include "physfsx.h" #define HMP_TRACKS 32 #ifdef _WIN32 @@ -53,6 +54,7 @@ typedef struct hmp_track { } hmp_track; typedef struct hmp_file { + PHYSFS_sint64 filesize; int num_trks; hmp_track trks[HMP_TRACKS]; unsigned int cur_time; @@ -77,7 +79,7 @@ typedef struct hmp_file { hmp_file *hmp_open(const char *filename); void hmp_close(hmp_file *hmp); void hmp2mid(char *hmp_name, unsigned char **midbuf, unsigned int *midlen); -#ifdef WIN32 +#ifdef _WIN32 void hmp_setvolume(hmp_file *hmp, int volume); int hmp_play(hmp_file *hmp, int bLoop); void hmp_pause(hmp_file *hmp); diff --git a/misc/hmp.c b/misc/hmp.c index 50682088b..7e956afaf 100644 --- a/misc/hmp.c +++ b/misc/hmp.c @@ -127,6 +127,7 @@ hmp_file *hmp_open(const char *filename) { } hmp->trks[i].loop_set = 0; } + hmp->filesize = PHYSFS_fileLength(fp); cfclose(fp); return hmp; } @@ -236,7 +237,14 @@ static int get_event(hmp_file *hmp, event *ev) { trk->cur_time += delta; if (!hmp->loop_start && *(trk->cur + got) >> 4 == MIDI_CONTROL_CHANGE && *(trk->cur + got + 1) == HMP_LOOP_START) - hmp->loop_start = trk->cur_time; + { + hmp->loop_start = trk->cur_time; + if ((hmp->filesize == 86949) && (trk->cur_time == 29)) // special ugly HACK HACK HACK for Descent2-version of descent.hmp where loop at this point causes instruments not being reset properly. No track supporting HMP loop I know of meets the requirements for the condition below and even if so - it only disabled the HMP loop feature. + { + hmp->loop_start = 0; + } + + } if (!hmp->loop_end && *(trk->cur + got) >> 4 == MIDI_CONTROL_CHANGE && *(trk->cur + got + 1) == HMP_LOOP_END) hmp->loop_end = trk->cur_time;