Example #1
0
File: digi.c Project: btb/d2x
void digi_debug()
{
	int i;
	int n_voices = 0;

	if (!Digi_initialized)
		return;

	for (i = 0; i < digi_max_channels; i++)
	{
		if (digi_is_channel_playing(i))
			n_voices++;
	}

	mprintf_at((0, 2, 0, "DIGI: Active Sound Channels: %d/%d (HMI says %d/32)      ", n_voices, digi_max_channels, -1));
	//mprintf_at((0, 3, 0, "DIGI: Number locked sounds:  %d                          ", digi_total_locks ));
}
Example #2
0
/*	joy_handler_win
		This function takes the place of the joy_handler function for dos.  
		The main window procedure will call this function whenever a joystick message
		is transmitted.
*/
LRESULT joy_handler_win(HWND hWnd, UINT joymsg, UINT wParam, LPARAM lParam)
{
	DWORD interval_time;
	DWORD new_time;
	static DWORD old_time = 0xffffffff;
	
	Button_info *button;
	int state=0;
	DWORD value=0;
	int i;

//	take care of first time initialization
	if (!joy_installed) return 1;
	if (old_time == 0xffffffff) {
		old_time = timer_get_fixed_seconds();
		return 0;
	}

//	read and translate buttons 0-3
	switch (joymsg)
	{
		JOYINFOEX	joy;

		case MM_JOY1MOVE:
		//	For now we support just four buttons
			memset(&joy, 0, sizeof(joy));
			joy.dwSize = sizeof(joy);
			joy.dwFlags = JOY_RETURNBUTTONS | JOY_RETURNPOV;
			joyGetPosEx(joystick.joyid, &joy);

			if (CHStickHack) {
				if (joy.dwPOV == JOY_POVCENTERED && joy.dwButtons > 0) {		  
					value = (1 << (joy.dwButtons-1));
				}
				else value = 0;
				mprintf_at((0, 2, 32, "RAW:%08x OUR:%08x\n", joy.dwButtons, value));
			}	
			else {
				value = joy.dwButtons;
			}
			break;
	}

	new_time = timer_get_fixed_seconds();
	if (new_time < old_time) old_time = abs(new_time - old_time);
	interval_time = new_time - old_time;

	for (i = 0; i < MAX_BUTTONS; i++)
	{
	//	Check status of each button and translate information to the button
	// structure.
		button = &joystick.buttons[i];
		
		if (!button->ignore) {
			if ( i < (MAX_BUTTONS-4) ) state = (value >> i) & 1;
			else state = 0;

			if ( button->last_state == state )	{
				if (state) {
					button->timedown += interval_time;	//interval_ms;
				}
			} else {
				if (state)	{
					button->downcount += state;
					button->state = 1;
				} else {	
					button->upcount += button->state;
					button->state = 0;
				}
				button->last_state = state;
			}
		}
	}