Пример #1
0
void Destroy(void) {
  TTF_Quit();
  Mix_CloseAudio();
  DestroyInput();
  SDL_FreeSurface(screen);
  SDL_Quit();
}
Пример #2
0
void CInputManager::Shutdown()
{
	if (sUseSprockets)
	{
		sPausedState=false;
		DestroyInput();
		::ISpShutdown();
	}
}
Пример #3
0
static void DriverKill(void) {
	sprintf(TempArray, "%s/fceu98.cfg", BaseDirectory);
	SaveConfig(TempArray);
	DestroyInput();
	ResetVideo();
	if (soundo) TrashSound();
	CloseWave();
	ByebyeWindow();
}
Пример #4
0
void CInputManager::LoadInputResource(
	CResourceContainer	*inResContainer,
	TResId				inResId,
	OSType				inCreator)
{
	if (sUseSprockets)
	{
		// If there was some input already allocated then delete it
		DestroyInput();

		::ISpResume();
			
		// Activate the keyboard and mouse
		::ISpDevices_ActivateClass(kISpDeviceClass_Mouse);
		::ISpDevices_ActivateClass(kISpDeviceClass_Keyboard);

		Try_
		{
			// Create the sNeeds structures from the file
			if (inResContainer->ResourceExists(kInputSprocketResType,inResId))
			{
				StTNTResource		ires(inResContainer,kInputSprocketResType,inResId);
				TNewHandleStream	stream(ires->GetReadOnlyDataHandle(),false);
				short				version;

				// Parse the resource
				stream >> version;
				
				if (version==0)
				{
					stream >> sNumOfElements;
					
					if (!sNumOfElements)
						UTBException::ThrowNoInputElementsDefined();		// will cause an error in ISpElement_NewVirtualFromNeeds

					sNeeds=new ISpNeed[sNumOfElements];
					sElements=new ISpElementReference[sNumOfElements];

					for (short n=0; n<sNumOfElements; n++)
					{
						stream >> sNeeds[n].name;
						stream >> sNeeds[n].iconSuiteResourceId;
						stream >> sNeeds[n].theKind;
						stream >> sNeeds[n].theLabel;
						
						sNeeds[n].playerNum=0;
						sNeeds[n].group=0;
						sNeeds[n].flags=0;
						sNeeds[n].reserved1=0;
						sNeeds[n].reserved2=0;
						sNeeds[n].reserved3=0;
					}
				}
				else if (version==1)
				{
					stream >> sNumOfElements;

					if (!sNumOfElements)
						UTBException::ThrowNoInputElementsDefined();		// will cause an error in ISpElement_NewVirtualFromNeeds

					sNeeds=new ISpNeed[sNumOfElements];
					sElements=new ISpElementReference[sNumOfElements];

					for (short n=0; n<sNumOfElements; n++)
					{
						stream >> sNeeds[n].name;
						stream >> sNeeds[n].theLabel;
						
						switch (sNeeds[n].theLabel)
						{
							case 'fire': sNeeds[n].theKind=kISpElementKind_Button; break;
							// Note, kISpElementKind_Movement is a complex input element. It
							// returns two analogue readings of the x,y axis and an overall
							// direction indicator.
							// TB's poll input returns an int, so we have to use dpads instead.
							// kISpElementKind_DPad
							case 'move': sNeeds[n].theKind=kISpElementKind_DPad; break;
							case 'xaxi': sNeeds[n].theKind=kISpElementKind_Axis; break;
							case 'yaxi': sNeeds[n].theKind=kISpElementKind_Axis; break;
							default: sNeeds[n].theKind=kISpElementKind_Button; break;
						}
						
						sNeeds[n].iconSuiteResourceId=0;
						sNeeds[n].playerNum=0;
						sNeeds[n].group=0;
						sNeeds[n].flags=0;
						sNeeds[n].reserved1=0;
						sNeeds[n].reserved2=0;
						sNeeds[n].reserved3=0;
					}
				}
Пример #5
0
void LexStream::Dump()
{
    FILE* tokfile;
    // +1 for '\0' +4 for length(".tok")
    char* tokfile_name = new char[FileNameLength() + 5];
    strcpy(tokfile_name, FileName());
    strcat(tokfile_name, StringConstant::U8S_DO_tok);

    if ((tokfile = SystemFopen(tokfile_name, "w")) == NULL)
    {
        Coutput << "*** Cannot open LexStream dump output file "
                << tokfile_name << endl;
        return;
    }

    RereadInput();
    SetUpComments();

    TokenIndex tok = 0;
    for (CommentIndex com = FirstComment(tok);
         com > 0 && com < NumComments() && PrecedingToken(com) == tok; com++)
    {
        fprintf(tokfile, "*%5d ", com);
        fprintf(tokfile, "%s", FileName());
        fprintf(tokfile, ", line %d.%d: ",
                FindLine(comments[com].location),
                FindColumn(comments[com].location - 1) + 1);
        for (const wchar_t* s = CommentString(com); *s; s++)
            fprintf(tokfile, "%c", *s);
        fprintf(tokfile, "\n");
    }
    do
    {
        tok = Gettoken();
        fprintf(tokfile, "%6d ", tok);
        fprintf(tokfile, " %s", FileName());
        fprintf(tokfile, ", %cline %d.%d: %s %s  ",
                (AfterEol(tok) ? '*' : ' '),
                Line(tok), (Kind(tok) == TK_EOF ? 0 : Column(tok)),
                token_type(Kind(tok)),
                (tokens[tok].Deprecated() ? "(d)" : " "));
        for (const wchar_t* s = NameString(tok); *s; s++)
            fprintf(tokfile, "%c", *s);
        fprintf(tokfile, "\n");

        for (CommentIndex com = FirstComment(tok);
             com > 0 && com < NumComments() && PrecedingToken(com) == tok; com++)
        {
            fprintf(tokfile, "*%5d ", com);
            fprintf(tokfile, " %s", FileName());
            fprintf(tokfile, ", line %d.%d: ",
                    FindLine(comments[com].location),
                    FindColumn(comments[com].location - 1) + 1);
            for (const wchar_t* s = CommentString(com); *s; s++)
                fprintf(tokfile, "%c", *s);
            fprintf(tokfile, "\n");
        }
    } while (Kind(tok) != TK_EOF);

    DestroyInput();
    fprintf(tokfile, "\n");
#ifdef UNIQUE_NAMES
    fprintf(tokfile, "\nThe unique names are:\n\n");
    for (int i = 0; i < control.name_table.symbol_pool.length(); i++)
    {
        fprintf(tokfile, "%4d ", i);
        for (const wchar_t* s = control.name_table.symbol_pool[i].name();
             *s; s++)
        {
            fprintf(tokfile, "%c", *s);
        }
        fprintf(tokfile, "\n");
    }
#endif // UNIQUE_NAMES

    if (tokfile)
        fclose(tokfile);
    delete [] tokfile_name;
}