Esempio n. 1
0
void	MIOSprite_UpdateIfNecessary (BOOL pmCopyToOffscreen,
				     BOOL pmUpdateNow)
{
    // Go through the windows and update any that have dirty windows.
    WindowQueue	*myWindowQueuePtr;

    if (pmUpdateNow || 
	    (stSpritesInUse &&
		(MIOTime_GetTicks () > stSpriteLastTime + stSpriteInterval)))
    {

	myWindowQueuePtr = stSpriteWindowQueueHead;
	while (myWindowQueuePtr != NULL)
	{
	    if (myWindowQueuePtr -> windowInfoPtr -> dirtyRectHead != NULL)
	    {
		// Update window
		MDIOSprite_UpdateWindow (myWindowQueuePtr -> windowInfoPtr,
					 pmCopyToOffscreen);
	    }
	    myWindowQueuePtr = myWindowQueuePtr -> next;
	}
	stSpriteLastTime = MIOTime_GetTicks ();
    }
} // MIOSprite_UpdateIfNecessary
Esempio n. 2
0
BOOL	MIOMusic_EventCheckNote (EventDescriptor *pmEvent)
{
    if (pmEvent -> count > MIOTime_GetTicks ())
    {
	return FALSE;
    }
    stCurrentTone++;
    if (stCurrentTone < stNumTones) 
    {
	pmEvent -> count = MIOTime_GetTicks () + 
		           stToneList [stCurrentTone].duration;
	if (stToneList [stCurrentTone].freq == 0)
	{
	    MDIOMusic_NoteStop ();
	}
	else
	{
	    MDIOMusic_NotePlay (stToneList [stCurrentTone].midiTone, 
				stToneList [stCurrentTone].freq, 
				stToneList [stCurrentTone].volume);
	}
	return FALSE;
    }
    return TRUE;
} // MIOMusic_EventCheckNote
Esempio n. 3
0
BOOL	MIOMusic_EventCheckFreq (EventDescriptor *pmEvent)
{
    Sound	*mySound = (Sound *) (pmEvent -> count);

    MIO_DebugOut ("%x %d %d %d", mySound, mySound -> stopTime, mySound -> soundID, MIOTime_GetTicks ());
    if (!MDIOMusic_FreqStillPlaying (mySound -> soundID))
    {
	// The frequency is not still playing, so it has been cancelled
	// in some fashion.  Don't stop the frequency, since it's already
	// stopped.
	free (mySound);
	return TRUE;
    }
    if (mySound -> stopTime > MIOTime_GetTicks ())
    {
	// Time has not yet expired, return FALSE
	return FALSE;
    }

    // Time has expired and the frequency is still playing.  Cancel the sound.
    MDIOMusic_FreqStop ();

    // Note: MIOMusic_Sound creates a EventDescriptor and the sound that appears
    // in it, so they must be freed here.
    free (mySound);
    
    return TRUE;
} // MIOMusic_EventCheckFreq
Esempio n. 4
0
void	MIOSprite_Init_Run (void)
{
    stSpritesInUse = FALSE;
    stSpriteInterval = DEFAULT_SPRITE_INTERVAL;
    stSpriteLastTime = MIOTime_GetTicks ();
    stSpriteWindowQueueHead = NULL;
} // MIOSprite_Init_Run
Esempio n. 5
0
BOOL	MIOMusic_Play (EventDescriptor *pmEvent, OOTstring pmPlayStr)
{
    char        myStrippedPlayStr [STRLEN];
    int		i = 0;
    int		j = 0;

    if (!stAllowSound)
    {
        SET_ERRNO(E_MUSIC_DISABLED);
        return FALSE;
    }

    //
    // Strip out any white space
    //
    while (pmPlayStr [i]) 
    {
	if (!isspace (pmPlayStr[i])) 
	{
	    myStrippedPlayStr [j] = pmPlayStr [i];
	    j++;
	}
	i++;
    }
    myStrippedPlayStr [j] = 0;

    MyParsePlayString (myStrippedPlayStr, stToneList, &stNumTones);

    if (stNumTones > 0) 
    {
        stCurrentTone = 0;
	if (MDIOMusic_NotePlay (stToneList [stCurrentTone].midiTone, 
				stToneList [stCurrentTone].freq, 
				stToneList [stCurrentTone].volume))
	{
	    stNumTones = 0;
	    return FALSE;
	}

        pmEvent -> mode = EventMode_PlayNoteDone;
        pmEvent -> count = MIOTime_GetTicks () + 
			   stToneList [stCurrentTone].duration;
	return TRUE;
    }

    SET_ERRNO(E_MUSIC_NO_NOTES);
    return FALSE;
} // MIOMusic_Play
Esempio n. 6
0
BOOL	MIOMusic_Sound (EventDescriptor *pmEvent, OOTint pmFrequency, 
			OOTint pmDuration)
{
    int		mySoundID;
    Sound	*mySound;

    if (!stAllowSound)
    {
        SET_ERRNO(E_MUSIC_DISABLED);
        return FALSE;
    }

    if (pmFrequency < 0 || pmFrequency > 20000) 
    {
	SET_ERRNO(E_MUSIC_FREQUENCY_OUT_OF_RANGE);
	return FALSE;
    }

    if (pmDuration < 0 || pmDuration > 60000) 
    {
	SET_ERRNO(E_MUSIC_DURATION_OUT_OF_RANGE);
	return FALSE;
    }

    if (!MDIOMusic_FreqPlay (pmFrequency, &mySoundID))
    {
	return FALSE;
    }

    mySound = (Sound *) malloc (sizeof (Sound));
    mySound -> stopTime = MIOTime_GetTicks () + pmDuration;
    mySound -> soundID = mySoundID;
    MIO_DebugOut ("%x %d %d %d %d", mySound, mySound -> stopTime, mySound -> soundID, MIOTime_GetTicks (), pmDuration);

    pmEvent -> mode  = EventMode_PlayFreqDone;
    pmEvent -> count = (int) mySound;
    
    return TRUE;
} // MIOMusic_Sound