diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/hexen/a_action.c | 13 | ||||
-rw-r--r-- | src/i_oplmusic.c | 23 | ||||
-rw-r--r-- | src/i_sdlmusic.c | 6 |
3 files changed, 29 insertions, 13 deletions
diff --git a/src/hexen/a_action.c b/src/hexen/a_action.c index 3100a074..e25b4f84 100644 --- a/src/hexen/a_action.c +++ b/src/hexen/a_action.c @@ -295,10 +295,15 @@ void A_LeafSpawn(mobj_t * actor) for (i = (P_Random() & 3) + 1; i; i--) { - mo = P_SpawnMobj(actor->x + ((P_Random() - P_Random()) << 14), - actor->y + ((P_Random() - P_Random()) << 14), - actor->z + (P_Random() << 14), - MT_LEAF1 + (P_Random() & 1)); + // Official release of Hexen's source code relies on unspecified behavior + // the in order of function's argument evaluation, + // see ISO-IEC 9899-1999, [6.5.2.2.10] + mobjtype_t type = MT_LEAF1 + (P_Random() & 1); + fixed_t z = actor->z + (P_Random() << 14); + fixed_t y = actor->y + ((P_Random() - P_Random()) << 14); + fixed_t x = actor->x + ((P_Random() - P_Random()) << 14); + + mo = P_SpawnMobj(x, y, z, type); if (mo) { P_ThrustMobj(mo, actor->angle, (P_Random() << 9) + 3 * FRACUNIT); diff --git a/src/i_oplmusic.c b/src/i_oplmusic.c index f38e7162..5f9ab462 100644 --- a/src/i_oplmusic.c +++ b/src/i_oplmusic.c @@ -47,7 +47,7 @@ #define PERCUSSION_LOG_LEN 16 // TODO: Figure out why this is needed. -#define TEMPO_FUDGE_FACTOR 0.26 +#define TEMPO_FUDGE_FACTOR 260 typedef struct { @@ -1016,6 +1016,12 @@ static void PitchBendEvent(opl_track_data_t *track, midi_event_t *event) } } +static void MetaSetTempo(unsigned int tempo) +{ + OPL_AdjustCallbacks((float) us_per_beat / tempo); + us_per_beat = tempo; +} + // Process a meta event. static void MetaEvent(opl_track_data_t *track, midi_event_t *event) @@ -1041,7 +1047,7 @@ static void MetaEvent(opl_track_data_t *track, midi_event_t *event) case MIDI_META_SET_TEMPO: if (data_len == 3) { - us_per_beat = (data[0] << 16) | (data[1] << 8) | data[2]; + MetaSetTempo((data[0] << 16) | (data[1] << 8) | data[2]); } break; @@ -1154,7 +1160,7 @@ static void TrackTimerCallback(void *arg) if (running_tracks <= 0 && song_looping) { - OPL_SetCallback(5, RestartSong, NULL); + OPL_SetCallback(5000, RestartSong, NULL); } return; @@ -1168,19 +1174,18 @@ static void TrackTimerCallback(void *arg) static void ScheduleTrack(opl_track_data_t *track) { unsigned int nticks; - unsigned int ms; - static int total = 0; + uint64_t us; - // Get the number of milliseconds until the next event. + // Get the number of microseconds until the next event. nticks = MIDI_GetDeltaTime(track->iter); - ms = (nticks * us_per_beat * TEMPO_FUDGE_FACTOR) / ticks_per_beat; - total += ms; + us = ((uint64_t) nticks * us_per_beat * TEMPO_FUDGE_FACTOR) + / ticks_per_beat; // Set a timer to be invoked when the next event is // ready to play. - OPL_SetCallback(ms, TrackTimerCallback, track); + OPL_SetCallback(us, TrackTimerCallback, track); } // Initialize a channel. diff --git a/src/i_sdlmusic.c b/src/i_sdlmusic.c index 81b28515..e7f0aacb 100644 --- a/src/i_sdlmusic.c +++ b/src/i_sdlmusic.c @@ -485,6 +485,11 @@ static char *GetFullPath(char *base_filename, char *path) } #endif + // Paths in the substitute filenames can contain Unix-style / + // path separators, but we should convert this to the separator + // for the native platform. + path = M_StringReplace(path, "/", DIR_SEPARATOR_S); + // Copy config filename and cut off the filename to just get the // parent dir. basedir = strdup(base_filename); @@ -499,6 +504,7 @@ static char *GetFullPath(char *base_filename, char *path) result = strdup(path); } free(basedir); + free(path); return result; } |