src/sound.cpp
branchNewGRF_ports
changeset 6720 35756db7e577
parent 6719 4cc327ad39d5
child 6870 ca3fd1fbe311
equal deleted inserted replaced
6719:4cc327ad39d5 6720:35756db7e577
   150 	MxSetChannelVolume(mc, left_vol * 128 / PANNING_LEVELS, right_vol * 128 / PANNING_LEVELS);
   150 	MxSetChannelVolume(mc, left_vol * 128 / PANNING_LEVELS, right_vol * 128 / PANNING_LEVELS);
   151 	MxActivateChannel(mc);
   151 	MxActivateChannel(mc);
   152 }
   152 }
   153 
   153 
   154 
   154 
   155 static const byte _vol_factor_by_zoom[] = {255, 190, 134, 87, 49};
   155 static const byte _vol_factor_by_zoom[] = {255, 190, 134, 87};
   156 assert_compile(lengthof(_vol_factor_by_zoom) == ZOOM_LVL_END);
   156 assert_compile(lengthof(_vol_factor_by_zoom) == ZOOM_LVL_END);
   157 
   157 
   158 static const byte _sound_base_vol[] = {
   158 static const byte _sound_base_vol[] = {
   159 	128,  90, 128, 128, 128, 128, 128, 128,
   159 	128,  90, 128, 128, 128, 128, 128, 128,
   160 	128,  90,  90, 128, 128, 128, 128, 128,
   160 	128,  90,  90, 128, 128, 128, 128, 128,
   209 				IS_INSIDE_1D(y, vp->virtual_top, vp->virtual_height)) {
   209 				IS_INSIDE_1D(y, vp->virtual_top, vp->virtual_height)) {
   210 			int left = (x - vp->virtual_left);
   210 			int left = (x - vp->virtual_left);
   211 
   211 
   212 			StartSound(
   212 			StartSound(
   213 				sound,
   213 				sound,
   214 				left / (vp->virtual_width / ((PANNING_LEVELS << 1) + 1)) - PANNING_LEVELS,
   214 				left / max(1, vp->virtual_width / ((PANNING_LEVELS << 1) + 1)) - PANNING_LEVELS,
   215 				(GetSound(sound)->volume * msf.effect_vol * _vol_factor_by_zoom[vp->zoom]) >> 15
   215 				(GetSound(sound)->volume * msf.effect_vol * _vol_factor_by_zoom[vp->zoom]) >> 15
   216 			);
   216 			);
   217 			return;
   217 			return;
   218 		}
   218 		}
   219 	}
   219 	}