mirror of
https://github.com/ondra-novak/gates_of_skeldal.git
synced 2025-07-18 04:06:45 -04:00
sound, music, mixer
This commit is contained in:
parent
42087c926c
commit
f8a1501289
42 changed files with 1345 additions and 157 deletions
|
@ -42,4 +42,5 @@ target_link_libraries(skeldal
|
|||
skeldal_libs
|
||||
skeldal_platform
|
||||
skeldal_sdl
|
||||
skeldal_libs
|
||||
${SDL2_LIBRARIES} pthread)
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include <libs/devices.h>
|
||||
#include <libs/bmouse.h>
|
||||
#include <libs/bgraph.h>
|
||||
#include <libs/zvuk.h>
|
||||
#include <platform/sound.h>
|
||||
#include <libs/strlite.h>
|
||||
#include "engine1.h"
|
||||
#include <libs/pcx.h>
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include <libs/devices.h>
|
||||
#include <libs/bmouse.h>
|
||||
#include <libs/bgraph.h>
|
||||
#include <libs/zvuk.h>
|
||||
#include <platform/sound.h>
|
||||
#include <libs/strlite.h>
|
||||
#include "engine1.h"
|
||||
#include <libs/pcx.h>
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include <libs/devices.h>
|
||||
#include <libs/bmouse.h>
|
||||
#include <libs/bgraph.h>
|
||||
#include <libs/zvuk.h>
|
||||
#include <platform/sound.h>
|
||||
#include <libs/gui.h>
|
||||
#include <libs/basicobj.h>
|
||||
#include "engine1.h"
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include <libs/devices.h>
|
||||
#include <libs/bmouse.h>
|
||||
#include <libs/bgraph.h>
|
||||
#include <libs/zvuk.h>
|
||||
#include <platform/sound.h>
|
||||
#include <libs/gui.h>
|
||||
#include <libs/basicobj.h>
|
||||
#include "engine1.h"
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include <libs/devices.h>
|
||||
#include <libs/bmouse.h>
|
||||
#include <libs/bgraph.h>
|
||||
#include <libs/zvuk.h>
|
||||
#include <platform/sound.h>
|
||||
#include <libs/strlite.h>
|
||||
#include <libs/mgifmem.h>
|
||||
#include "engine1.h"
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include <libs/event.h>
|
||||
#include <libs/memman.h>
|
||||
#include <libs/bgraph.h>
|
||||
#include <libs/zvuk.h>
|
||||
#include <platform/sound.h>
|
||||
#include "engine1.h"
|
||||
#include "globals.h"
|
||||
#include "specproc.h"
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include <libs/memman.h>
|
||||
#include <libs/bgraph.h>
|
||||
#include <libs/event.h>
|
||||
#include <libs/zvuk.h>
|
||||
#include <platform/sound.h>
|
||||
#include "math.h"
|
||||
#include "globals.h"
|
||||
#include "engine1.h"
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include <libs/bmouse.h>
|
||||
#include <libs/memman.h>
|
||||
#include <fcntl.h>
|
||||
#include <libs/zvuk.h>
|
||||
#include <platform/sound.h>
|
||||
#include <stdarg.h>
|
||||
#include "globals.h"
|
||||
#include "temp_storage.h"
|
||||
|
|
|
@ -1428,12 +1428,12 @@ extern char **sound_table;
|
|||
|
||||
void init_tracks(void);
|
||||
void recalc_volumes(int sector,int side);
|
||||
void play_effekt(int x,int y,int xd,int yd,int side,int sided,const TMA_SOUND *p);
|
||||
void play_effekt(int x,int y,int xd,int yd,int sector, int side,const TMA_SOUND *p);
|
||||
void create_playlist(char *playlist);
|
||||
const char *get_next_music_from_playlist(void);
|
||||
const char * end_of_song_callback(void *ctx);
|
||||
void purge_playlist(void);
|
||||
void play_sample_at_sector(int sample,int sector1,int sector2,int track, char loop);
|
||||
void play_sample_at_sector(int sample,int listener,int source,int track, char loop);
|
||||
void play_sample_at_channel(int sample,int channel,int vol);
|
||||
void stop_track(int track);
|
||||
char test_playing(int track);
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include <libs/devices.h>
|
||||
#include <libs/bmouse.h>
|
||||
#include <libs/bgraph.h>
|
||||
#include <libs/zvuk.h>
|
||||
#include <platform/sound.h>
|
||||
#include <libs/strlite.h>
|
||||
#include "engine1.h"
|
||||
#include <libs/pcx.h>
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include <libs/devices.h>
|
||||
#include <libs/bmouse.h>
|
||||
#include <libs/memman.h>
|
||||
#include <libs/zvuk.h>
|
||||
#include <platform/sound.h>
|
||||
#include <libs/strlite.h>
|
||||
#include <ctype.h>
|
||||
#include <libs/gui.h>
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include <libs/devices.h>
|
||||
#include <libs/bmouse.h>
|
||||
#include <libs/bgraph.h>
|
||||
#include <libs/zvuk.h>
|
||||
#include <platform/sound.h>
|
||||
#include <libs/gui.h>
|
||||
#include <libs/basicobj.h>
|
||||
#include "engine1.h"
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include <libs/devices.h>
|
||||
#include <libs/bmouse.h>
|
||||
#include <libs/bgraph.h>
|
||||
#include <libs/zvuk.h>
|
||||
#include <platform/sound.h>
|
||||
#include <libs/strlite.h>
|
||||
#include "engine1.h"
|
||||
#include <libs/pcx.h>
|
||||
|
@ -185,7 +185,7 @@ void macro_sound(const TMA_SOUND *p,int psect,int pdir,int sect,int dir)
|
|||
if (sound_side_flags & SD_PRIM_FORV) up=2;
|
||||
if (~(p->bit16) & up) {
|
||||
if (psect) {
|
||||
play_effekt(map_coord[sect].x,map_coord[sect].y,map_coord[psect].x,map_coord[psect].y,dir,pdir,p);
|
||||
play_effekt(map_coord[sect].x,map_coord[sect].y,map_coord[psect].x,map_coord[psect].y,psect,pdir,p);
|
||||
} else {
|
||||
play_effekt(0,0,0,0,-1,-1,p);
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include <libs/devices.h>
|
||||
#include <libs/bmouse.h>
|
||||
#include <libs/bgraph.h>
|
||||
#include <libs/zvuk.h>
|
||||
#include <platform/sound.h>
|
||||
#include <libs/strlite.h>
|
||||
#include <stdarg.h>
|
||||
#include "engine1.h"
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include <libs/devices.h>
|
||||
#include <libs/bmouse.h>
|
||||
#include <libs/bgraph.h>
|
||||
#include <libs/zvuk.h>
|
||||
#include <platform/sound.h>
|
||||
#include <libs/strlite.h>
|
||||
#include "engine1.h"
|
||||
#include <libs/pcx.h>
|
||||
|
@ -185,7 +185,6 @@ int load_map(char *filename)
|
|||
mob_template=NULL;
|
||||
mob_size=0;
|
||||
if (f==NULL) return -1;
|
||||
if (snd_devnum==DEV_DAC) stop_mixing();
|
||||
do
|
||||
{
|
||||
r=load_section(f,&temp,§,&size);
|
||||
|
@ -329,7 +328,6 @@ int load_map(char *filename)
|
|||
exit(0);
|
||||
}
|
||||
doNotLoadMapState=0;
|
||||
if (snd_devnum==DEV_DAC) start_mixing();
|
||||
return suc;
|
||||
}
|
||||
|
||||
|
@ -1605,45 +1603,49 @@ void step_zoom(char smer)
|
|||
if (cur_mode==MD_GAME) recalc_volumes(viewsector,viewdir);
|
||||
}
|
||||
|
||||
void turn_zoom(int smer)
|
||||
{
|
||||
if (running_anm) return;
|
||||
if (pass_zavora) return;else pass_zavora=1;
|
||||
if (!GlobEvent(MAGLOB_ONTURN,viewsector,viewdir)) return;
|
||||
if (set_halucination) do_halucinace();
|
||||
norefresh=1;
|
||||
hold_timer(TM_BACK_MUSIC,1);
|
||||
viewdir=(viewdir+smer)&3;
|
||||
render_scene(viewsector,viewdir);
|
||||
hide_ms_at(387);
|
||||
OutBuffer2nd();
|
||||
other_draw();
|
||||
bott_draw(0);
|
||||
if (smer==1)
|
||||
{
|
||||
anim_sipky(H_SIPKY_SV,1);
|
||||
anim_sipky(0,255);
|
||||
turn_left();
|
||||
}
|
||||
else
|
||||
{
|
||||
anim_sipky(H_SIPKY_SZ,1);
|
||||
anim_sipky(0,255);
|
||||
turn_right();
|
||||
}
|
||||
chod_s_postavama(0);
|
||||
if (battle || (game_extras & EX_ALWAYS_MINIMAP)) draw_medium_map();
|
||||
update_mysky();
|
||||
ukaz_mysku();
|
||||
showview(0,0,0,0);
|
||||
recalc_volumes(viewsector,viewdir);
|
||||
if (!battle) calc_game();
|
||||
norefresh=0;
|
||||
cancel_render=1;
|
||||
hold_timer(TM_BACK_MUSIC,0);
|
||||
mix_back_sound(0);
|
||||
pass_zavora=0;
|
||||
}
|
||||
void turn_zoom(int smer) {
|
||||
if (running_anm)
|
||||
return;
|
||||
if (pass_zavora)
|
||||
return;
|
||||
else
|
||||
pass_zavora = 1;
|
||||
if (!GlobEvent(MAGLOB_ONTURN, viewsector, viewdir))
|
||||
return;
|
||||
if (set_halucination)
|
||||
do_halucinace();
|
||||
norefresh = 1;
|
||||
hold_timer(TM_BACK_MUSIC, 1);
|
||||
viewdir = (viewdir + smer) & 3;
|
||||
recalc_volumes(viewsector, viewdir);
|
||||
render_scene(viewsector, viewdir);
|
||||
hide_ms_at(387);
|
||||
OutBuffer2nd();
|
||||
other_draw();
|
||||
bott_draw(0);
|
||||
if (smer == 1) {
|
||||
anim_sipky(H_SIPKY_SV, 1);
|
||||
anim_sipky(0, 255);
|
||||
turn_left();
|
||||
} else {
|
||||
anim_sipky(H_SIPKY_SZ, 1);
|
||||
anim_sipky(0, 255);
|
||||
turn_right();
|
||||
}
|
||||
chod_s_postavama(0);
|
||||
if (battle || (game_extras & EX_ALWAYS_MINIMAP))
|
||||
draw_medium_map();
|
||||
update_mysky();
|
||||
ukaz_mysku();
|
||||
showview(0, 0, 0, 0);
|
||||
if (!battle)
|
||||
calc_game();
|
||||
norefresh = 0;
|
||||
cancel_render = 1;
|
||||
hold_timer(TM_BACK_MUSIC, 0);
|
||||
mix_back_sound(0);
|
||||
pass_zavora = 0;
|
||||
}
|
||||
|
||||
int check_path(word **path,word tosect)
|
||||
{
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include <libs/devices.h>
|
||||
#include <libs/bmouse.h>
|
||||
#include <libs/bgraph.h>
|
||||
#include <libs/zvuk.h>
|
||||
#include <platform/sound.h>
|
||||
#include <libs/strlite.h>
|
||||
#include "engine1.h"
|
||||
#include <libs/pcx.h>
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include <libs/event.h>
|
||||
#include <libs/bmouse.h>
|
||||
#include <libs/memman.h>
|
||||
#include <libs/zvuk.h>
|
||||
#include <platform/sound.h>
|
||||
#include <libs/strlite.h>
|
||||
#include <libs/gui.h>
|
||||
#include <libs/basicobj.h>
|
||||
|
@ -87,8 +87,6 @@ THUMAN postavy[POCET_POSTAV],postavy_save[POCET_POSTAV];
|
|||
void (*unwire_proc)(void);
|
||||
void (*wire_proc)(void);
|
||||
char cur_mode,battle_mode;
|
||||
static int init_music_vol=127;
|
||||
static int init_gfx_vol=255;
|
||||
static char titles_on=0;
|
||||
|
||||
const void *pcx_fade_decomp(const void *p, int32_t *s);
|
||||
|
@ -498,25 +496,6 @@ void set_font(int font,int c1,...)
|
|||
memcpy(f_default,charcolors,sizeof(charcolors));
|
||||
}
|
||||
|
||||
void music_init(void)
|
||||
{
|
||||
// char *path;
|
||||
/* if (sound_detection)
|
||||
{
|
||||
|
||||
if (sound_detect(&snd_devnum,&snd_parm1,&snd_parm2,&snd_parm3)) snd_devnum=DEV_NOSOUND;
|
||||
}*/
|
||||
SEND_LOG("(SOUND) SOUND_SET Setting Sound: Device '%s' Port: %3X",device_name(snd_devnum),snd_parm1);
|
||||
SEND_LOG("(SOUND) SOUND_SET Setting Sound: IRQ: %X DMA: %X",snd_parm2,snd_parm3);
|
||||
set_mixing_device(snd_devnum,snd_mixing,snd_parm1,snd_parm2,snd_parm3);
|
||||
|
||||
start_mixing();
|
||||
set_snd_effect(SND_GFX,init_gfx_vol);
|
||||
set_snd_effect(SND_MUSIC,init_music_vol);
|
||||
// path=plugins_path;
|
||||
|
||||
|
||||
}
|
||||
|
||||
void clrscr(void)
|
||||
{
|
||||
|
@ -984,7 +963,8 @@ void init_skeldal(const INI_CONFIG *cfg)
|
|||
|
||||
add_game_window();
|
||||
|
||||
music_init();
|
||||
game_sound_init_device(ini_section_open(cfg, "audio"));
|
||||
start_mixing();
|
||||
|
||||
if ((verr=init_mysky())!=0)
|
||||
{
|
||||
|
@ -1267,7 +1247,7 @@ void play_anim(int anim_num)
|
|||
TSTR_LIST titl=NULL;
|
||||
const char *s = build_pathname(2,gpathtable[SR_VIDEO], texty[anim_num]);
|
||||
s = local_strdup(s);
|
||||
if (snd_devnum==DEV_NOSOUND || titles_on)
|
||||
if (titles_on)
|
||||
{
|
||||
concat(t,s," ");
|
||||
z=strrchr(t,'.');
|
||||
|
@ -1344,8 +1324,8 @@ static void game_big_circle(char enforced)
|
|||
{viewdir=i;break;}
|
||||
}
|
||||
}
|
||||
for(r=0;r<mapsize*4;r++) call_macro(r,MC_STARTLEV);
|
||||
recalc_volumes(viewsector,viewdir);
|
||||
for(r=0;r<mapsize*4;r++) call_macro(r,MC_STARTLEV);
|
||||
loadlevel.name[0]=0;
|
||||
reroll_all_shops();
|
||||
|
||||
|
|
209
game/sndandmus.c
209
game/sndandmus.c
|
@ -3,7 +3,7 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
#include <libs/memman.h>
|
||||
#include <libs/zvuk.h>
|
||||
#include <platform/sound.h>
|
||||
#include <libs/wav_mem.h>
|
||||
#include <libs/event.h>
|
||||
#include "globals.h"
|
||||
|
@ -29,13 +29,27 @@ typedef struct snd_info
|
|||
{
|
||||
const TMA_SOUND *data; //4
|
||||
short xpos,ypos,side; //10
|
||||
word volume,block; //14
|
||||
word volume,sample_block; //14
|
||||
word sector;
|
||||
}SND_INFO;
|
||||
|
||||
static short chan_state[CHANNELS];
|
||||
static short track_state[TRACKS];
|
||||
short sample_volume=255;
|
||||
|
||||
typedef struct sound_side_map_dir_t {
|
||||
uint32_t distance;
|
||||
int32_t visit_counter;
|
||||
} TSOUND_SIDE_MAP_DIR;
|
||||
|
||||
typedef struct sound_side_map_t {
|
||||
TSOUND_SIDE_MAP_DIR parts[4];
|
||||
} TSOUND_SIDE_MAP;
|
||||
|
||||
static TSOUND_SIDE_MAP *current_sound_sector_map = NULL;
|
||||
static size_t current_sound_sector_map_size = 0;
|
||||
static int32_t current_sound_sector_map_counter = 0;
|
||||
|
||||
//static struct t_wave wav_last_head;
|
||||
//static int wav_last_size;
|
||||
static int mute_task=-1;
|
||||
|
@ -140,7 +154,7 @@ void release_channel(int channel)
|
|||
if (i==-1) return;
|
||||
mute_channel(channel);
|
||||
{
|
||||
aunlock(playings[channel].block);
|
||||
aunlock(playings[channel].sample_block);
|
||||
chan_state[channel]=-1;
|
||||
track_state[i]=-1;
|
||||
}
|
||||
|
@ -158,7 +172,62 @@ int calc_volume(int *x,int *y,int side)
|
|||
return ds;
|
||||
}
|
||||
|
||||
int calcul_volume(int chan,int x,int y,int side,int volume)
|
||||
int set_channel_volume_from_sector(int channel,
|
||||
int sound_source_sector,
|
||||
int sound_source_side,
|
||||
int listener_sector,
|
||||
int listener_direction,
|
||||
int volume) {
|
||||
const int maxvolume = 32768;
|
||||
volume = 255*volume/100;
|
||||
int left = maxvolume;
|
||||
int right = maxvolume;
|
||||
if (sound_source_sector > mapsize) return 0;
|
||||
if (sound_source_sector <0 || sound_source_sector == listener_sector) {
|
||||
if (sound_source_side >= 0) {
|
||||
int ddf = (sound_source_side + 4 - listener_direction) & 3;
|
||||
switch (ddf) {
|
||||
default:
|
||||
case 0:
|
||||
case 2: left = right = maxvolume;break;
|
||||
case 1: left = maxvolume/4; right = maxvolume;break;
|
||||
case 3: left = maxvolume; right = maxvolume/4;break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
const TSOUND_SIDE_MAP *p = current_sound_sector_map+sound_source_sector;
|
||||
left = 0;
|
||||
right = 0;
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
if (p->parts[i].visit_counter == current_sound_sector_map_counter) {
|
||||
int dist = p->parts[i].distance;
|
||||
if (!dist) return 1; //error
|
||||
int inc = maxvolume/(dist*dist);
|
||||
switch(i) {
|
||||
default:
|
||||
case 2:
|
||||
case 0: left += inc; right += inc; break;
|
||||
case 1: right += inc;break;
|
||||
case 3: left += inc;break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
left = (left * volume) >> 8;
|
||||
right = (right * volume) >> 8;
|
||||
if (left > maxvolume) left = maxvolume;
|
||||
if (right > maxvolume) right = maxvolume;
|
||||
if (left == 0 && right == 0) return 0;
|
||||
|
||||
set_channel_volume(channel,left,right);
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
/*int calcul_volume(int chan,int x,int y,int side,int volume)
|
||||
{
|
||||
int lv,rv;
|
||||
int ds,bal,i;
|
||||
|
@ -195,7 +264,7 @@ int calcul_volume(int chan,int x,int y,int side,int volume)
|
|||
set_channel_volume(chan,lv,rv);
|
||||
return 0;
|
||||
}
|
||||
|
||||
*/
|
||||
const void *wav_load(const void *p, int32_t *s)
|
||||
{
|
||||
const char *sr;
|
||||
|
@ -220,7 +289,7 @@ const void *wav_load(const void *p, int32_t *s)
|
|||
return tgr;
|
||||
}
|
||||
|
||||
void play_effekt(int x,int y,int xd,int yd,int side,int sided,const TMA_SOUND *p)
|
||||
void play_effekt(int x,int y,int xd,int yd,int sector,int side,const TMA_SOUND *p)
|
||||
{
|
||||
int chan;
|
||||
int blockid;
|
||||
|
@ -228,14 +297,14 @@ void play_effekt(int x,int y,int xd,int yd,int side,int sided,const TMA_SOUND *p
|
|||
const char *s;
|
||||
|
||||
if (!sound_enabled) return;
|
||||
side;
|
||||
chan=find_free_channel(p->soundid);
|
||||
release_channel(chan);
|
||||
track=&tracks[p->soundid];
|
||||
track->data=p;
|
||||
track->xpos=xd;
|
||||
track->ypos=yd;
|
||||
track->side=sided;
|
||||
track->side=side;
|
||||
track->sector = sector;
|
||||
track_state[p->soundid]=-1;
|
||||
if (p->bit16 & 0x8)
|
||||
{
|
||||
|
@ -244,7 +313,8 @@ void play_effekt(int x,int y,int xd,int yd,int side,int sided,const TMA_SOUND *p
|
|||
else set_channel_volume(chan,vol,rnd(vol));
|
||||
}
|
||||
else {
|
||||
if (calcul_volume(chan,x-xd,y-yd,/*side-*/sided,p->volume)) return;
|
||||
if (!set_channel_volume_from_sector(chan, sector, side, viewsector, viewdir, p->volume))
|
||||
return;
|
||||
}
|
||||
|
||||
blockid = find_handle(p->filename, wav_load);
|
||||
|
@ -260,12 +330,75 @@ void play_effekt(int x,int y,int xd,int yd,int side,int sided,const TMA_SOUND *p
|
|||
playings[chan].data=p;
|
||||
playings[chan].xpos=xd;
|
||||
playings[chan].ypos=yd;
|
||||
playings[chan].side=sided;
|
||||
playings[chan].sector = sector;
|
||||
playings[chan].side=side;
|
||||
playings[chan].volume=p->volume;
|
||||
playings[chan].block=blockid;
|
||||
playings[chan].sample_block=blockid;
|
||||
chan_state[chan]=p->soundid;
|
||||
track_state[p->soundid]=chan;
|
||||
}
|
||||
|
||||
typedef struct _sound_map_queue_t {
|
||||
int from_sector;
|
||||
int to_sector;
|
||||
} TSOUND_MAP_QUEUE;
|
||||
|
||||
static void build_dungeon_sound_map_in_dir(int sector, int side, int position, int32_t counter) {
|
||||
if (map_sectors[sector].step_next[side] == 0
|
||||
|| !(map_sides[sector * 4 +side].flags & SD_TRANSPARENT)) return;
|
||||
|
||||
TSOUND_MAP_QUEUE queue[128];
|
||||
int qbeg = 0;
|
||||
int qend = 0;
|
||||
queue[qend].from_sector = sector;
|
||||
queue[qend].to_sector = map_sectors[sector].step_next[side];
|
||||
++qend;
|
||||
while (qbeg != qend) {
|
||||
const TSOUND_MAP_QUEUE *item = queue+(qbeg % countof(queue));
|
||||
int cursect = item->to_sector;
|
||||
int fromsect = item->from_sector;
|
||||
++qbeg;
|
||||
if (current_sound_sector_map[cursect].parts[position].visit_counter != counter) {
|
||||
current_sound_sector_map[cursect].parts[position].visit_counter = counter;
|
||||
int d = current_sound_sector_map[cursect].parts[position].distance =
|
||||
current_sound_sector_map[fromsect].parts[position].distance + 1;
|
||||
if (d<32) {
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
int nx = map_sectors[cursect].step_next[i];
|
||||
if (nx && (map_sides[cursect * 4 +i].flags & SD_TRANSPARENT)) {
|
||||
if (current_sound_sector_map[nx].parts[position].visit_counter != counter) {
|
||||
TSOUND_MAP_QUEUE *t = queue+(qend % countof(queue));
|
||||
++qend;
|
||||
t->from_sector = cursect;
|
||||
t->to_sector = nx;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void build_dungeon_sound_map(int sector, int side) {
|
||||
if (mapsize != (int)current_sound_sector_map_size) {
|
||||
free(current_sound_sector_map);
|
||||
current_sound_sector_map = NewArr(TSOUND_SIDE_MAP, mapsize);
|
||||
current_sound_sector_map_size = mapsize;
|
||||
}
|
||||
int32_t counter = ++current_sound_sector_map_counter;
|
||||
if (sector > mapsize) return;
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
current_sound_sector_map[sector].parts[i].distance = 0;
|
||||
current_sound_sector_map[sector].parts[i].visit_counter = counter;
|
||||
}
|
||||
build_dungeon_sound_map_in_dir(sector, side, 0, counter);
|
||||
build_dungeon_sound_map_in_dir(sector, (side+1)&3, 1, counter);
|
||||
build_dungeon_sound_map_in_dir(sector, (side+2)&3, 2, counter);
|
||||
build_dungeon_sound_map_in_dir(sector, (side+3)&3, 3, counter);
|
||||
}
|
||||
|
||||
|
||||
void recalc_volumes(int sector,int side)
|
||||
{
|
||||
int i;
|
||||
|
@ -275,16 +408,29 @@ void recalc_volumes(int sector,int side)
|
|||
|
||||
side;
|
||||
SEND_LOG("(SOUND) %s","Recalculating volumes");
|
||||
build_dungeon_sound_map(sector, side);
|
||||
newx=map_coord[sector].x;
|
||||
newy=map_coord[sector].y;
|
||||
// layer=map_coord[sector].layer;
|
||||
for(i=0;i<CHANNELS;i++)
|
||||
for(i=0;i<CHANNELS;i++) {
|
||||
int volume = playings[i].volume;
|
||||
if (chan_state[i]>=0 && playings[i].side>=0)
|
||||
{
|
||||
calcul_volume(i,newx-playings[i].xpos,newy-playings[i].ypos,/*side-*/playings[i].side,playings[i].volume);
|
||||
set_channel_volume_from_sector(
|
||||
i,
|
||||
playings[i].sector,
|
||||
playings[i].side,
|
||||
sector,
|
||||
side,
|
||||
volume);
|
||||
//calcul_volume(i,newx-playings[i].xpos,newy-playings[i].ypos,/*side-*/playings[i].side,playings[i].volume);
|
||||
if (!get_channel_state(i)) release_channel(i);
|
||||
}
|
||||
else calcul_volume(i,0,0,-1,playings[i].volume);
|
||||
else {
|
||||
int v = SND_EFF_MAXVOL*volume / 100;
|
||||
set_channel_volume(i, v, v);
|
||||
}
|
||||
}
|
||||
for(i=1;i<TRACKS;i++) if (track_state[i]<0 && tracks[i].data!=NULL)
|
||||
{
|
||||
if (tracks[i].side<0)
|
||||
|
@ -296,7 +442,8 @@ void recalc_volumes(int sector,int side)
|
|||
{
|
||||
int x=newx-tracks[i].xpos, y=newy-tracks[i].ypos;
|
||||
if (calc_volume(&x,&y,tracks[i].side)>0)
|
||||
if (have_loop(tracks[i].data))play_effekt(newx,newy,tracks[i].xpos,tracks[i].ypos,side,tracks[i].side,tracks[i].data);
|
||||
if (have_loop(tracks[i].data))
|
||||
play_effekt(newx,newy,tracks[i].xpos,tracks[i].ypos,tracks[i].sector,tracks[i].side,tracks[i].data);
|
||||
}
|
||||
}
|
||||
mute_task=-1;
|
||||
|
@ -360,7 +507,7 @@ const char *get_next_music_from_playlist()
|
|||
if (!remain_play)
|
||||
for(i=0;cur_playlist[i]!=NULL;remain_play++,i++) cur_playlist[i][0]=32;
|
||||
if (play_list_mode==PL_RANDOM)
|
||||
step=rand()*(playlist_size-1)/32768+1;
|
||||
step=rnd(playlist_size)+1;
|
||||
else
|
||||
step=1;
|
||||
i=playing_track;
|
||||
|
@ -387,24 +534,22 @@ void purge_playlist()
|
|||
cur_playlist=NULL;
|
||||
}
|
||||
|
||||
void play_sample_at_sector(int sample,int sector1,int sector2,int track, char loop)
|
||||
void play_sample_at_sector(int sample,int listener,int source,int track, char loop)
|
||||
{
|
||||
int x,y,xd,yd,chan;
|
||||
int xd,yd,chan;
|
||||
const char *s;
|
||||
struct t_wave *p;
|
||||
int siz;
|
||||
int oldtrack;
|
||||
|
||||
if (!sound_enabled) return;
|
||||
if (map_coord[sector1].layer!=map_coord[sector2].layer) return;
|
||||
x=map_coord[sector1].x;
|
||||
y=map_coord[sector1].y;
|
||||
xd=map_coord[sector2].x;
|
||||
yd=map_coord[sector2].y;
|
||||
if (map_coord[listener].layer!=map_coord[source].layer) return;
|
||||
xd=map_coord[source].x;
|
||||
yd=map_coord[source].y;
|
||||
chan=find_free_channel(track);
|
||||
oldtrack=track_state[track];
|
||||
if (!track || oldtrack==-1) release_channel(chan);
|
||||
if (calcul_volume(chan,x-xd,y-yd,viewdir,100)) return;
|
||||
if (!set_channel_volume_from_sector(chan, source, -1, listener, -1, 100)) return;
|
||||
if (!track || oldtrack==-1)
|
||||
{
|
||||
alock(sample);
|
||||
|
@ -419,7 +564,8 @@ void play_sample_at_sector(int sample,int sector1,int sector2,int track, char lo
|
|||
playings[chan].ypos=yd;
|
||||
playings[chan].side=viewdir;
|
||||
playings[chan].volume=100;
|
||||
playings[chan].block=sample;
|
||||
playings[chan].sample_block=sample;
|
||||
playings[chan].sector=source;
|
||||
chan_state[chan]=track;
|
||||
track_state[track]=chan;
|
||||
}
|
||||
|
@ -519,7 +665,8 @@ char test_playing(int track)
|
|||
return track_state[track]!=-1;
|
||||
}
|
||||
|
||||
static int flute_canal=30;
|
||||
static int flute_channel=30;
|
||||
static int flute_channel_offset = 0;
|
||||
|
||||
void start_play_flute(char note)
|
||||
{
|
||||
|
@ -534,8 +681,9 @@ void start_play_flute(char note)
|
|||
q=ablock(H_FLETNA);
|
||||
w=q;w+=sizeof(struct t_wave)+4;
|
||||
vol*=SND_EFF_MAXVOL/100;
|
||||
set_channel_volume(flute_canal,vol,vol);
|
||||
play_sample(flute_canal,w,0x1665,0xADE,(int)(realfrq+0.5),1);
|
||||
int ch = flute_channel+flute_channel_offset;
|
||||
set_channel_volume(ch,vol,vol);
|
||||
play_sample(ch,w,0x1665,0xADE,(int)(realfrq+0.5),1);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -552,8 +700,9 @@ void stop_play_flute()
|
|||
{
|
||||
q=ablock(H_FLETNA);
|
||||
w=q;w+=sizeof(struct t_wave);
|
||||
chan_break_ext(flute_canal,w+4,*(int *)w);
|
||||
flute_canal^=1;
|
||||
int ch = flute_channel+flute_channel_offset;
|
||||
chan_break_ext(ch,w+4,*(int *)w);
|
||||
flute_channel_offset = (flute_channel_offset+1) & 7;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <libs/event.h>
|
||||
#include <libs/zvuk.h>
|
||||
#include <platform/sound.h>
|
||||
#include <libs/bgraph.h>
|
||||
#include <libs/bmouse.h>
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include <libs/devices.h>
|
||||
#include <libs/bmouse.h>
|
||||
#include <libs/memman.h>
|
||||
#include <libs/zvuk.h>
|
||||
#include <platform/sound.h>
|
||||
#include <libs/strlite.h>
|
||||
#include <libs/gui.h>
|
||||
#include <libs/basicobj.h>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue