various fixes towards getting it to build for Mac OS 9 again

This commit is contained in:
kreatordxx 2007-11-06 01:30:07 +00:00
parent c6407e0c2d
commit fef59bdb3f
6 changed files with 32 additions and 18 deletions

View file

@ -1,9 +1,13 @@
D2X-Rebirth Changelog
20071106
--------
arch/sdl/digi_mixer.c, arch/sdl/digi_mixer_music.c, arch/sdl/jukebox.c, include/args.h, misc/hmp2mid.h: various fixes towards getting it to build for Mac OS 9 again
20071105
--------
arch/carbon/conf.h, English.lproj/InfoPlist.strings, d2x-Info.plist, d2xgl-Info.plist: update Mac version info, set SHAREPATH to application folder for Mac OS X
arch/sdl/jukebox.c: Fixed crash on absent or invalid jukebox directory
arch/sdl/jukebox.c: Fixed crash on absent or invalid jukebox directory
20071103
--------

View file

@ -132,18 +132,19 @@ void mixdigi_convert_sound(int i) {
// Volume 0-F1_0
int digi_mixer_start_sound(short soundnum, fix volume, int pan, int looping, int loop_start, int loop_end, int soundobj)
{
int mix_vol = fix2byte(fixmul(digi_volume, volume));
int mix_pan = fix2byte(pan);
int mix_loop = looping * -1;
int channel;
if (!digi_initialised) return -1;
Assert(GameSounds[soundnum].data != (void *)-1);
mixdigi_convert_sound(soundnum);
int mix_vol = fix2byte(fixmul(digi_volume, volume));
int mix_pan = fix2byte(pan);
int mix_loop = looping * -1;
if (MIX_DIGI_DEBUG) printf("digi_start_sound %d, volume %d, pan %d (start=%d, end=%d)\n", soundnum, mix_vol, mix_pan, loop_start, loop_end);
int channel = Mix_PlayChannel(-1, &(SoundChunks[soundnum]), mix_loop);
channel = Mix_PlayChannel(-1, &(SoundChunks[soundnum]), mix_loop);
Mix_SetPanning(channel, 255-mix_pan, mix_pan);
Mix_SetDistance(channel, 255-mix_vol);
@ -151,8 +152,8 @@ int digi_mixer_start_sound(short soundnum, fix volume, int pan, int looping, int
}
void digi_mixer_set_channel_volume(int channel, int volume) {
if (!digi_initialised) return;
int mix_vol = fix2byte(volume);
if (!digi_initialised) return;
Mix_SetDistance(channel, 255-mix_vol);
}

View file

@ -16,6 +16,7 @@
#include "digi_mixer_music.h"
#include "jukebox.h"
#include "cfile.h"
#include "u_mem.h"
#define MIX_MUSIC_DEBUG 0
#define MUSIC_FADE_TIME 500 //milliseconds
@ -74,15 +75,14 @@ void convert_hmp(char *filename, char *mid_filename) {
*/
void mix_play_music(char *filename, int loop) {
loop *= -1;
int i, got_end=0;
char real_filename[PATH_MAX];
char rel_filename[32]; // just the filename of the actual music file used
char music_title[16];
char *basedir = "Music";
loop *= -1;
// Quick hack to filter out the .hmp extension
for (i=0; !got_end; i++) {
switch (filename[i]) {
@ -120,11 +120,12 @@ void mix_play_music(char *filename, int loop) {
void mix_play_file(char *basedir, char *filename, int loop) {
int fn_buf_len = strlen(basedir) + strlen(filename) + 1;
char real_filename[fn_buf_len];
sprintf(real_filename, "%s%s", basedir, filename); // build absolute path
char *real_filename = d_malloc(strlen(basedir) + strlen(filename) + 1);
if ((current_music = Mix_LoadMUS(real_filename))) {
if (real_filename)
sprintf(real_filename, "%s%s", basedir, filename); // build absolute path
if (real_filename && (current_music = Mix_LoadMUS(real_filename))) {
if (Mix_PlayingMusic()) {
// Fade-in effect sounds cleaner if we're already playing something
Mix_FadeInMusic(current_music, loop, MUSIC_FADE_TIME);
@ -138,6 +139,9 @@ void mix_play_file(char *basedir, char *filename, int loop) {
fprintf(stderr, "Music %s could not be loaded%s\n", filename, basedir);
Mix_HaltMusic();
}
if (real_filename)
d_free(real_filename);
}
void mix_set_music_volume(int vol) {

View file

@ -101,8 +101,10 @@ void jukebox_load() {
}
void jukebox_play() {
char *music_filename;
if (!jukebox_loaded) return;
char *music_filename = (char *) JukeboxSongs->current->data;
music_filename = (char *) JukeboxSongs->current->data;
mix_play_file(jukebox_path, music_filename, 0);

View file

@ -21,6 +21,8 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
#ifndef _ARGS_H
#define _ARGS_H
#include "pstypes.h" // for __packed__ definition (varies with compiler)
extern int Num_args;
extern char *Args[];
extern void AppendIniArgs(void);
@ -111,7 +113,7 @@ typedef struct Arg
#else
int DbgSdlHWSurface;
#endif
} __attribute__ ((packed)) Arg;
} __pack__ Arg;
extern struct Arg GameArg;

View file

@ -53,8 +53,9 @@
if (PHYSFS_write(mid_out, buf, 1, count) != (count)) \
{ \
free(mid_track_buf); \
snprintf(hmp2mid_error, sizeof(hmp2mid_error), mid_write_error_templ, \
PHYSFS_getLastError); \
strncpy(hmp2mid_error, mid_write_error_templ, sizeof(hmp2mid_error)); \
strncat(hmp2mid_error, PHYSFS_getLastError(), \
sizeof(hmp2mid_error) - sizeof(mid_write_error_templ) + 1); \
return hmp2mid_error; \
}