Exemplo n.º 1
0
void MFModel_DeinitModule()
{
	// list all non-freed textures...
	MFModelPool::Iterator pI = gModelBank.First();
	bool bShowHeader = true;

	while(pI)
	{
		if(bShowHeader)
		{
			bShowHeader = false;
			MFDebug_Message("\nUn-freed models:\n----------------------------------------------------------");
		}

		MFDebug_Message(MFStr("'%s' - x%d", (*pI)->pName, (*pI)->refCount));

		// Destroy template...

		pI = gModelBank.Next(pI);
	}

	MFModel_DeinitModulePlatformSpecific();

	gModelBank.Deinit();
}
Exemplo n.º 2
0
int F3DFile::ReadOBJ(const char *pFilename)
{
	pModel = this;

	MFFile *pFile = MFFileSystem_Open(pFilename, MFOF_Read);
	if(!pFile)
	{
		MFDebug_Warn(2, MFStr("Failed to open OBJ file %s", pFilename));
		return 1;
	}

	int size = MFFile_Seek(pFile, 0, MFSeek_End);
	MFFile_Seek(pFile, 0, MFSeek_Begin);

	char *pMem = (char*)MFHeap_Alloc(size+1);
	MFFile_Read(pFile, pMem, size);
	pMem[size] = 0;

	MFFile_Close(pFile);

	ParseOBJFile(pMem);
	MFHeap_Free(pMem);

	return 0;
}
Exemplo n.º 3
0
MF_API void MFSound_Unlock(MFSound *pSound)
{
	MFDebug_Assert(pSound->flags & MFPF_Locked, MFStr("Dynamic sound '%s' is not locked.", pSound->name));

	if(pSound->pInternal->p3DBuffer)
	{
		// copy new data into 3d buffer...
		VOID *pBuffer, *pB2;
		DWORD bufferLen, l2;

		pSound->pInternal->p3DBuffer->Lock(pSound->lockOffset, pSound->lockBytes, &pBuffer, &bufferLen, &pB2, &l2, pSound->lockBytes == 0 ? DSBLOCK_ENTIREBUFFER : 0);
		MFCopyMemory(pBuffer, pSound->pLock1, pSound->lockSize1);
		if(pB2)
			MFCopyMemory(pB2, pSound->pLock2, pSound->lockSize2);
		pSound->pInternal->p3DBuffer->Unlock(pBuffer, bufferLen, pB2, l2);
	}

	// and unlock the main buffer
	pSound->pInternal->pBuffer->Unlock(pSound->pLock1, pSound->lockSize1, pSound->pLock2, pSound->lockSize2);

	pSound->pLock1 = NULL;
	pSound->lockSize1 = 0;
	pSound->pLock2 = NULL;
	pSound->lockSize2 = 0;

	pSound->flags = pSound->flags & ~MFPF_Locked;
}
Exemplo n.º 4
0
const char *ParseAnimationSet(const char *pText)
{
	const char *pName = GetNextToken(pText, &pText);

	if(MFString_Compare(pName, "{"))
		SkipToken(pText, "{");

	const char *pTok = GetNextToken(pText, &pText);

	while(MFString_Compare(pTok, "}"))
	{
		if(!MFString_Compare(pTok, "Animation"))
		{
			pText = ParseAnimation(pText);
		}
		else
		{
			MFDebug_Warn(4, MFStr("Unexpected token '%s'\n", pTok));
			SkipSection(pText);
		}

		pTok = GetNextToken(pText, &pText);
	}

	return pText;
}
Exemplo n.º 5
0
static void MissingStates(MFStateBlockConstantType type, uint32 missing)
{
	static const char * const sStateType[MFSB_CT_TypeCount] =
	{
		"Bool",
		"Vector",
		"Matrix",
		"RenderState",
		"Texture",
		"Misc",
		"",
		"Unknown"
	};

	MFString states;
	for(int a=0; a<32; ++a)
	{
		if(missing & (1<<a))
		{
			if(!states.IsNull())
				states += ", ";
			states += MFStateBlock_GetRenderStateName(type, a);
		}
	}

	MFDebug_Assert(missing == 0, MFStr("Missing %s states: %s", sStateType[type], states.CStr()));
}
Exemplo n.º 6
0
void CopyTrackData()
{
	gpListBox->Show(MFTranslation_GetString(pStrings, COPY_TRACK_DATA), CopyDataCallback);

	int difficulty = gTargetTrack / GHS_NumTracks;
	int track = gTargetTrack % GHS_NumTracks;
	const char *pTargetTrack = MFStr("%s - %s", gEditor.pSong->GetDifficultyName(difficulty), gEditor.pSong->GetTrackName(track));
	gpListBox->AddItem(MFStr("%s: %s", MFTranslation_GetString(pStrings, TARGET_TRACK), pTargetTrack));

	const char *pYes = MFTranslation_GetString(pStrings, MENU_YES);
	const char *pNo = MFTranslation_GetString(pStrings, MENU_NO);
	gpListBox->AddItem(MFStr("%s: %s", MFTranslation_GetString(pStrings, COPY_NOTES), gbNotes ? pYes : pNo));
	gpListBox->AddItem(MFStr("%s: %s", MFTranslation_GetString(pStrings, COPY_SPECIALS), gbSpecials ? pYes : pNo));
	gpListBox->AddItem(MFStr("%s: %s", MFTranslation_GetString(pStrings, COPY_EVENTS), gbEvents ? pYes : pNo));

	gpListBox->AddItem(MFTranslation_GetString(pStrings, MENU_COPY));
}
Exemplo n.º 7
0
MF_API const char* MFFile_HomePath(const char *pFilename)
{
	MFCALLSTACK;

	pFilename = pFilename ? pFilename : "";

#if defined(MF_XBOX)
	return MFStr("E:\\Home\\%s", pFilename);
#elif defined(_LINUX)
	return MFStr("~/%s", pFilename);
#elif defined(MF_IPHONE)
	const char *GetUserHome();
	return MFStr("%s/%s", GetUserHome(), pFilename);
#else
	return MFStr("Home/%s", pFilename);
#endif
}
Exemplo n.º 8
0
MF_API void DebugMenu_AddItemTo(const char *name, Menu *pParent, MenuObject *pObject, DebugCallback callback, void *userData)
{
	MFDebug_Assert(pParent, "Invalid parent menu.");
	MFDebug_Assert(pParent->type == MenuType_Menu, MFStr("Cant add menu '%s', Parent is not of Menu type.", name));
	MFDebug_Assert(MFString_Length(name) < 64, "Max of 64 characters in Menu Name.");
	MFDebug_Assert(pParent->numChildren < MENU_MAX_CHILDREN, MFStr("Maximum number of items in menu: '%s'", pParent->name));

	MFString_Copy(pObject->name, name);

	pObject->pParent = pParent;
	pObject->menuDepth = pParent->menuDepth+1;

	pObject->pCallback = callback;
	pObject->pUserData = userData;

	pParent->pChildren[pParent->numChildren] = pObject;
	++pParent->numChildren;
}
Exemplo n.º 9
0
void MFMaterial_DeinitModule()
{
	MFCALLSTACK;

	// destroy stock materials
	MFMaterial_Release(pNoneMaterial);
	MFMaterial_Release(pWhiteMaterial);
	MFMaterial_Release(pSysLogoLarge);
	MFMaterial_Release(pSysLogoSmall);

#if defined(_PSP)
	// destroy PSP specific stock materials
	MFMaterial_Release(pConnected);
	MFMaterial_Release(pDisconnected);
	MFMaterial_Release(pPower);
	MFMaterial_Release(pCharging);
	MFMaterial_Release(pUSB);
#endif

	MaterialDefinition *pDef = pDefinitionRegistry;

	while(pDef)
	{
		MaterialDefinition *pNext = pDef->pNextDefinition;
		MFMaterial_DestroyDefinition(pDef);
		pDef = pNext;
	}

	bool bShowHeader = true;

	// list all non-freed materials...
	MFResourceIterator *pI = MFResource_EnumerateFirst(MFRT_Material);
	while(pI)
	{
		if(bShowHeader)
		{
			bShowHeader = false;
			MFDebug_Message("\nUn-freed materials:\n----------------------------------------------------------");
		}

		MFMaterial *pMat = (MFMaterial*)MFResource_Get(pI);

		MFDebug_Message(MFStr("'%s' - x%d", pMat->pName, pMat->refCount));

		pMat->refCount = 1;
		MFMaterial_Release(pMat);

		pI = MFResource_EnumerateNext(pI, MFRT_Material);
	}

	MFMaterial_UnregisterMaterialType("Standard");
	MFMaterial_UnregisterMaterialType("Effect");

	gMaterialDefList.Deinit();
	gMaterialRegistry.Deinit();
}
Exemplo n.º 10
0
	virtual HRESULT STDMETHODCALLTYPE OnDeviceAdded(LPCWSTR pwstrDeviceId)
	{
		MFDebug_Log(2, MFStr("WASAPI: Device added: %S", pwstrDeviceId));
		char temp[128];
		MFString_CopyUTF16ToUTF8(temp, pwstrDeviceId);
		MFDevice *pDev = MFDevice_GetDeviceById(temp);
		if(!pDev)
			pDev = NewDevice(pwstrDeviceId);
		return S_OK;
	}
Exemplo n.º 11
0
MFFileSystemHandle MFFileSystem_RegisterFileSystem(const char *pFilesystemName, MFFileSystemCallbacks *pCallbacks)
{
	MFDebug_Log(5, MFStr("Call: MFFileSystem_RegisterFileSystem(\"%s\")", pFilesystemName));

	GET_MODULE_DATA(MFFileSystemState);

	for(uint32 a=0; a<gDefaults.filesys.maxFileSystems; a++)
	{
		if(pModuleData->ppFileSystemList[a] == NULL)
		{
			MFDebug_Assert(pCallbacks->Open, "No Open function supplied.");
			MFDebug_Assert(pCallbacks->Close, "No Close function supplied.");
			MFDebug_Assert(pCallbacks->Read, "No Read function supplied.");
			MFDebug_Assert(pCallbacks->Write, "No Write function supplied.");
			MFDebug_Assert(pCallbacks->Seek, "No Seek function supplied.");

			MFFileSystem *pFS = pModuleData->gFileSystems.Create();
			MFZeroMemory(pFS, sizeof(MFFileSystem));
			MFString_Copy(pFS->name, pFilesystemName);
			MFCopyMemory(&pFS->callbacks, pCallbacks, sizeof(MFFileSystemCallbacks));
			pModuleData->ppFileSystemList[a] = pFS;

#if defined(USE_JOB_THREAD)
			pFS->ppJobQueue = (MFJob**)MFHeap_Alloc(sizeof(MFJob*)*MAX_JOBS);
			pFS->jobs.Init(MFStr("%s Job List", pFilesystemName), MAX_JOBS+2);
			pFS->readJob = 0;
			pFS->writeJob = 0;
			pFS->numJobs = MAX_JOBS;
			pFS->semaphore = MFThread_CreateSemaphore("Filesystem Semaphore", MAX_JOBS, 0);
			pFS->thread = MFThread_CreateThread(MFStr("%s Thread", pFilesystemName), MKFileJobThread, pFS, MFPriority_AboveNormal);
#endif

			if(pFS->callbacks.RegisterFS)
				pFS->callbacks.RegisterFS();

			return a;
		}
	}

	MFDebug_Assert(false, MFStr("Exceeded maximum of %d Filesystems. Modify 'gDefaults.filesys.maxFileSystems'.", gDefaults.filesys.maxFileSystems));

	return -1;
}
Exemplo n.º 12
0
MF_API void MFDebug_DebugAssert(const char *pReason, const char *pMessage, const char *pFile, int line)
{
	MFDebug_Message(MFStr("%s(%d) : Assertion Failure.",pFile,line));
	MFDebug_Message(MFStr("Failed Condition: (%s)\n%s", pReason, pMessage));

	// build callstack log string for message box
#if !defined(_RETAIL)
	MFCallstack_Log();
	const char *pCallstack = MFCallstack_GetCallstackString();
#else
	const char *pCallstack = "Not available in _RETAIL builds";
#endif

	// query for debug or exit of process
	if(!MFDebugPC_MsgBox(MFStr("Failed Condition: (%s)\n%s\nFile: %s\nLine: %d\n\nCallstack:\n%s", pReason, pMessage, pFile, line, pCallstack), "Assertion Failure, do you wish to debug?"))
	{
		ExitProcess(0);
	}
}
Exemplo n.º 13
0
void MFMaterial_DeinitModule()
{
	MFCALLSTACK;

	// destroy stock materials
	MFMaterial_Destroy(pNoneMaterial);
	MFMaterial_Destroy(pWhiteMaterial);
	MFMaterial_Destroy(pSysLogoLarge);
	MFMaterial_Destroy(pSysLogoSmall);

#if defined(_PSP)
	// destroy PSP specific stock materials
	MFMaterial_Destroy(pConnected);
	MFMaterial_Destroy(pDisconnected);
	MFMaterial_Destroy(pPower);
	MFMaterial_Destroy(pCharging);
	MFMaterial_Destroy(pUSB);
#endif

	MaterialDefinition *pDef = pDefinitionRegistry;

	while(pDef)
	{
		MaterialDefinition *pNext = pDef->pNextDefinition;
		MFMaterial_DestroyDefinition(pDef);
		pDef = pNext;
	}

	// list all non-freed materials...
	MFMaterial **ppI = gMaterialList.Begin();
	bool bShowHeader = true;

	while(*ppI)
	{
		if(bShowHeader)
		{
			bShowHeader = false;
			MFDebug_Message("\nUn-freed materials:\n----------------------------------------------------------");
		}

		MFDebug_Message(MFStr("'%s' - x%d", (*ppI)->pName, (*ppI)->refCount));

		(*ppI)->refCount = 1;
		MFMaterial_Destroy(*ppI);

		ppI++;
	}

	MFMaterial_UnregisterMaterialType("Standard");
	MFMaterial_UnregisterMaterialType("Effect");

	gMaterialList.Deinit();
	gMaterialDefList.Deinit();
	gMaterialRegistry.Deinit();
}
Exemplo n.º 14
0
void MFSound_InitModulePlatformSpecific(int *pSoundDataSize, int *pVoiceDataSize)
{
	MFCALLSTACK;

	// we need to return the size of the internal structures so the platform independant
	// code can make the correct allocations..
	*pSoundDataSize = sizeof(MFSoundDataInternal);

	MFDebug_Log(2, "Initialising PortAudio driver.");

	// init portaudio
	Pa_Initialize();

	// choose the output device
	PaDeviceIndex device = Pa_GetDefaultOutputDevice();

	// HACK: try and find an ALSA device (default OSS sucks)
	PaHostApiIndex alsaAPI = Pa_HostApiTypeIdToHostApiIndex(paALSA);
	if(alsaAPI >= 0)
	{
		int numDevices = Pa_GetDeviceCount();
		for(int a=0; a<numDevices; ++a)
		{
			pDeviceInfo = Pa_GetDeviceInfo(a);
			if(pDeviceInfo->hostApi == alsaAPI)
			{
				device = a;
				break;
			}
		}
	}

	pDeviceInfo = Pa_GetDeviceInfo(device);
	pHostAPIInfo = Pa_GetHostApiInfo(pDeviceInfo->hostApi);

	MFDebug_Log(2, MFStr("PortAudio output: %s", pDeviceInfo->name));
	MFDebug_Log(2, MFStr("PortAudio host: %s", pHostAPIInfo->name));
	MFDebug_Log(2, MFStr("Sample rate: %g", (float)pDeviceInfo->defaultSampleRate));
	MFDebug_Log(2, MFStr("In/Out channels: %d/%d", pDeviceInfo->maxInputChannels, pDeviceInfo->maxOutputChannels));
	MFDebug_Log(2, MFStr("Input latency: %g-%g", (float)pDeviceInfo->defaultLowInputLatency, (float)pDeviceInfo->defaultHighInputLatency));
	MFDebug_Log(2, MFStr("Output latency: %g-%g", (float)pDeviceInfo->defaultLowOutputLatency, (float)pDeviceInfo->defaultHighOutputLatency));

	// create a very low latency audio output stream
	PaStreamParameters params;
	params.device = Pa_GetDefaultOutputDevice();
	params.channelCount = 2;
	params.sampleFormat = paInt16;
	params.suggestedLatency = 0.0167;
	params.hostApiSpecificStreamInfo = NULL;

	PaError error = Pa_OpenStream(&pPAStream, NULL, &params, pDeviceInfo->defaultSampleRate, paFramesPerBufferUnspecified, paPrimeOutputBuffersUsingStreamCallback, MFSound_MixCallback, NULL);

	if(error != paNoError)
		MFDebug_Log(2, MFStr("Error: %s", Pa_GetErrorText(error)));
	else
		Pa_StartStream(pPAStream);
}
Exemplo n.º 15
0
static Context *CreateContext(MFDevice *pDevice)
{
	AudioDevice &device = *(AudioDevice*)pDevice->pInternal;

	if(!device.pDevice)
		device.pDevice = alcOpenDevice(pDevice->strings[MFDS_ID]);
	if(!device.pDevice)
		return NULL;

	Context *pContext = (Context*)MFHeap_Alloc(sizeof(Context));
	pContext->pContext = alcCreateContext(device.pDevice, NULL);
	pContext->pDevice = pDevice;
	pContext->pRender = &device;

	Context *pOld = MakeCurrent(pContext);

	const char *pVersion = alGetString(AL_VERSION);
	const char *pExtensions = alGetString(AL_EXTENSIONS);
	MFDebug_Log(0, MFStr("OpenAL Version: %s", pVersion));
	MFDebug_Log(0, MFStr("OpenAL Extensions: %s", pExtensions));

	pContext->ext.static_buffer = alIsExtensionPresent("ALC_EXT_STATIC_BUFFER") == AL_TRUE;
	pContext->ext.offset = alIsExtensionPresent("AL_EXT_OFFSET") == AL_TRUE;
	pContext->ext.float32 = alIsExtensionPresent("AL_EXT_float32") == AL_TRUE;
	pContext->ext.source_radius = alIsExtensionPresent("AL_EXT_SOURCE_RADIUS") == AL_TRUE;
	pContext->ext.buffer_sub_data = alIsExtensionPresent("AL_SOFT_buffer_sub_data") == AL_TRUE;
	pContext->ext.buffer_samples = alIsExtensionPresent("AL_SOFT_buffer_samples") == AL_TRUE;

	if(pContext->ext.static_buffer)
		alBufferDataStatic = (PFNALBUFFERDATASTATICPROC)alGetProcAddress("alBufferDataStatic");
	if(pContext->ext.buffer_sub_data)
		alBufferSubDataSOFT = (PFNALBUFFERSUBDATASOFTPROC)alGetProcAddress("alBufferSubDataSOFT");

	alListener3f(AL_POSITION, 0, 0, 0);
	alListener3f(AL_VELOCITY, 0, 0, 0);
	alListener3f(AL_ORIENTATION, 0, 0, -1);

	MakeCurrent(pOld);

	return pContext;
}
Exemplo n.º 16
0
bool MFFileNative_FindFirst(MFFind *pFind, const char *pSearchPattern, MFFindData *pFindData)
{
	// separate path and search pattern..
	char *pPath = (char*)MFStr("%s%s", (char*)pFind->pMount->pFilesysData, pSearchPattern);
	const char *pPattern = pPath;

	char *pLast = MFString_RChr(pPath, '/');
	if(pLast)
	{
		*pLast = 0;
		pPattern = pLast + 1;
	}
	else
	{
		// find pattern refers to current directory..
		pPath = (char*)".";
	}

	// open the directory
	DIR *hFind = opendir(pPath);

	if(!hFind)
	{
		MFDebug_Warn(2, MFStr("Couldnt open directory '%s' with search pattern '%s'", pPath, pPattern));
		return false;
	}

	MFString_CopyCat(pFindData->pSystemPath, (char*)pFind->pMount->pFilesysData, pSearchPattern);
	pLast = MFString_RChr(pFindData->pSystemPath, '/');
	if(pLast)
		pLast[1] = 0;
	else
		pFindData->pSystemPath[0] = 0;

	pFind->pFilesystemData = (void*)hFind;

	bool bFound = MFFileNative_FindNext(pFind, pFindData);
	if(!bFound)
		MFFileNative_FindClose(pFind);
	return bFound;
}
Exemplo n.º 17
0
	virtual HRESULT STDMETHODCALLTYPE OnDeviceStateChanged(LPCWSTR pwstrDeviceId, DWORD dwNewState)
	{
		MFDebug_Log(2, MFStr("WASAPI: State changed: %d (%S)", dwNewState, pwstrDeviceId));
		char temp[128];
		MFString_CopyUTF16ToUTF8(temp, pwstrDeviceId);
		MFDevice *pDev = MFDevice_GetDeviceById(temp);
		if(!pDev)
			pDev = NewDevice(pwstrDeviceId);
		if(pDev)
			UpdateState(pDev, dwNewState);
		return S_OK;
	}
Exemplo n.º 18
0
static void DestroyOutputDevice(MFDevice *pDevice)
{
	MFMidiPC_MidiOutputDevice *pDev = (MFMidiPC_MidiOutputDevice*)pDevice->pInternal;
	if (pDev->hMidiOut)
	{
		MFDebug_Warn(1, MFStr("MIDI output device not closed: %s", pDevice->strings[MFDS_ID]));

		midiOutReset(pDev->hMidiOut);
		midiOutClose(pDev->hMidiOut);
	}
	MFHeap_Free(pDev);
}
Exemplo n.º 19
0
	virtual HRESULT STDMETHODCALLTYPE OnDefaultDeviceChanged(EDataFlow flow, ERole role, LPCWSTR pwstrDefaultDeviceId)
	{
		MFDebug_Log(2, MFStr("WASAPI: Default device changed: %S", pwstrDefaultDeviceId));
		char temp[128];
		MFString_CopyUTF16ToUTF8(temp, pwstrDefaultDeviceId);
		MFDevice *pDev = MFDevice_GetDeviceById(temp);
		if(!pDev)
			pDev = NewDevice(pwstrDefaultDeviceId);
		if(pDev)
			MFDevice_SetDefaultDevice(gDt[flow], gDef[role], pDev);
		return S_OK;
	}
Exemplo n.º 20
0
	virtual HRESULT STDMETHODCALLTYPE OnDeviceRemoved(LPCWSTR pwstrDeviceId)
	{
		MFDebug_Log(2, MFStr("WASAPI: Device removed: %S", pwstrDeviceId));
		char temp[128];
		MFString_CopyUTF16ToUTF8(temp, pwstrDeviceId);
		MFDevice *pDev = MFDevice_GetDeviceById(temp);
		if(!pDev)
			pDev = NewDevice(pwstrDeviceId);
		if(pDev)
			UpdateState(pDev, DEVICE_STATE_UNPLUGGED);
		return S_OK;
	}
Exemplo n.º 21
0
MF_API void MFMidi_SendShortMessage(MFDevice *pDevice, uint32 message)
{
	MFMidiPC_MidiOutputDevice *pMidi = (MFMidiPC_MidiOutputDevice*)pDevice->pInternal;

	MMRESULT r = midiOutShortMsg(pMidi->hMidiOut, (DWORD)message);
	if (r != MMSYSERR_NOERROR)
	{
		wchar_t errorBuffer[256];
		midiOutGetErrorText(r, errorBuffer, sizeof(errorBuffer));
		MFDebug_Warn(1, MFStr("Failed to send MIDI message: %s", MFString_WCharAsUTF8(errorBuffer)));
	}
}
Exemplo n.º 22
0
int MFFileNative_Open(MFFile *pFile, MFOpenData *pOpenData)
{
	MFCALLSTACK;

	MFDebug_Assert(pOpenData->cbSize == sizeof(MFOpenDataNative), "Incorrect size for MFOpenDataNative structure. Invalid pOpenData.");
	MFOpenDataNative *pNative = (MFOpenDataNative*)pOpenData;

	int access = ((pOpenData->openFlags&MFOF_Read) ? PSP_O_RDONLY : NULL) | ((pOpenData->openFlags&MFOF_Write) ? PSP_O_WRONLY|PSP_O_CREAT|PSP_O_TRUNC : NULL);
	MFDebug_Assert(access, "Neither MFOF_Read nor MFOF_Write specified.");

	const char *pFilename = MFStr("%s/%s", gPSPSystemPath, pNative->pFilename);
	SceUID hFile = sceIoOpen(pFilename, access, 0777);

	if(hFile < 0)
	{
		MFDebug_Warn(4, MFStr("File does not exist: '%s'", pFilename));
		return -1;
	}

	pFile->pFilesysData = (void*)hFile;
	pFile->createFlags = pOpenData->openFlags;
	pFile->offset = 0;

	// find file length
	SceOff fileSize = sceIoLseek(hFile, 0, SEEK_END);

	// TODO: something's very wrong with this line! :/
//	MFDebug_Assert(fileSize < 2147483648LL, MFStr("Error opening file '%s', Fuji does not support files larger than 2,147,483,647 bytes.", pFilename));
	pFile->length = (int64)fileSize;

	// return to start of file
	sceIoLseek32(hFile, 0, SEEK_SET);

#if defined(_DEBUG)
	MFString_Copy(pFile->fileIdentifier, pFilename);
#endif

	return 0;
}
Exemplo n.º 23
0
void ShowPopupMenu()
{
#if defined(MF_PSP)
	float w = 300.f;
#else
	float w = 200.f;
#endif
	gpListBox->Show(MFTranslation_GetString(pStrings, MENU_QUICK_MENU), QuickMenuCallback, w, 198.0f);
	gpListBox->AddItem(MFStr("%s %s", MFTranslation_GetString(pStrings, bMetronome ? MENU_DISABLE : MENU_ENABLE), MFTranslation_GetString(pStrings, MENU_METRONOME)));
	gpListBox->AddItem(MFStr("%s %s", MFTranslation_GetString(pStrings, bClaps ? MENU_DISABLE : MENU_ENABLE), MFTranslation_GetString(pStrings, MENU_CLAPS)));
	gpListBox->AddItem(MFTranslation_GetString(pStrings, MENU_PLACE_EVENT));
	gpListBox->AddItem(MFTranslation_GetString(pStrings, MENU_PLACE_TRACK_EVENT));
	gpListBox->AddItem(MFTranslation_GetString(pStrings, MENU_PLACE_SECTION));
	gpListBox->AddItem(MFTranslation_GetString(pStrings, MENU_SELECT_DIFFICULTY));
	gpListBox->AddItem(MFTranslation_GetString(pStrings, SELECT_TRACK));
	gpListBox->AddItem(MFTranslation_GetString(pStrings, SHOW_REFERENCE));
	gpListBox->AddItem(MFTranslation_GetString(pStrings, MENU_COPY_CHART));
	gpListBox->AddItem(MFTranslation_GetString(pStrings, MENU_CHART_SETTINGS));
	gpListBox->AddItem(MFTranslation_GetString(pStrings, MENU_VOLUME));
	gpListBox->AddItem(MFTranslation_GetString(pStrings, MENU_MAIN_MENU));
	gpListBox->AddItem(MFTranslation_GetString(pStrings, MENU_HELP));
}
Exemplo n.º 24
0
// validate a block of memory. returns false if memory had been corrupted.
MF_API bool MFHeap_ValidateMemory(const void *pMemory)
{
	MFCALLSTACK;

	if(!pMemory)
		return true;

	MFAllocHeader *pHeader = GetAllocHeader(pMemory);
	if(!pHeader)
	{
		MFDebug_Warn(0, MFStr("Missing allocation header for allocation 0x%p.", pMemory));
		return false;
	}

#if defined(USE_PRE_MUNGWALL)
	if(MFMemCompare((const char*)pMemory - MFHeap_MungwallBytes, gLlawgnum, MFHeap_MungwallBytes) == 0)
#endif
	if(MFMemCompare((const char*)pMemory + pHeader->size, gMungwall, MFHeap_MungwallBytes) == 0)
		return true;

	MFDebug_Log(0, MFStr("%s(" MFFMT_SIZE_T ") : Corrupted mungwall detected in allocation 0x%p.", pHeader->pFile, pHeader->line, pMemory));
	return false;
}
Exemplo n.º 25
0
MF_API const char* MFInput_EnumerateString(int button, int device, int deviceID, bool includeDevice, bool includeDeviceID)
{
	MFDebug_Assert(device >= 0 && device < IDD_Max, "Invalid Input Device");

	switch(device)
	{
		case IDD_Gamepad:
			return MFStr("%s%s%s%s", includeDevice ? MFInput_GetDeviceName(device, deviceID) : "", includeDeviceID ? MFStr("(%d)", deviceID) : "", (includeDevice||includeDeviceID) ? " " : "", MFInput_GetGamepadButtonName(button, deviceID));
		case IDD_Mouse:
			if(button < Mouse_MaxAxis)
			{

			}
			else
			{
				return MFStr("%s%s%sButton %d", includeDevice ? MFInput_GetDeviceName(device, deviceID) : "", includeDeviceID ? MFStr("(%d)", deviceID) : "", (includeDevice||includeDeviceID) ? " " : "", button - Mouse_MaxAxis + 1);
			}
		case IDD_Keyboard:
			return MFStr("%s%s%s%s", includeDevice ? MFInput_GetDeviceName(device, deviceID) : "", includeDeviceID ? MFStr("(%d)", deviceID) : "", (includeDevice||includeDeviceID) ? " " : "", gKeyNames[button]);
	}

	return "";
}
Exemplo n.º 26
0
MF_API const char* MFCallstack_GetCallstackString()
{
#if defined(_MFCALLSTACK)
    char callstack[2048] = "";
    size_t bufferUsed = 0;

    for(int a = gCallDepth-1; a >= 0; a--)
    {
        const char *pTemp = MFStr("  %-32s\n",pCallstack[a]);
        size_t tempLen = MFString_Length(pTemp);
//		char *pTemp = MFStr("  %-32s\t(%s)%s\n",Callstack[a].c_str(),ModuleName(pFunc->pStats->pModuleName),pFunc->pComment ? MFStr(" [%s]",pFunc->pComment) : "");
        if(bufferUsed + tempLen < sizeof(callstack) - 1)
        {
            MFString_Cat(callstack, pTemp);
            bufferUsed += tempLen;
        }
    }

    return MFStr(callstack);
#else
    return "Callstack not available in this build.";
#endif
}
Exemplo n.º 27
0
char* FixXBoxFilename(const char *pFilename)
{
	if(!pFilename) return NULL;

	char *pXFilename;

	int len = MFString_Length(pFilename);

	if(len > 1 && pFilename[1] != ':')
	{
		pXFilename = (char*)MFStr("D:\\%s", pFilename);
		len += 3;
	}
	else
		pXFilename = (char*)MFStr("%s", pFilename);

	for(int a=0; a<len; a++)
	{
		if(pXFilename[a] == '/') pXFilename[a] = '\\';
	}

	return pXFilename;
}
Exemplo n.º 28
0
MF_API const char* MFInput_GetDeviceName(int device, int deviceID)
{
	if(deviceID >= gNetGamepadStart && device == IDD_Gamepad)
	{
		return MFStr("Remote %s", MFNetwork_GetRemoteGamepadName(deviceID - gNetGamepadStart));
	}
	else
	{
#if !defined(_RETAIL)
		if(deviceID == IDD_Gamepad && gDeviceStatus[device][deviceID] == IDS_Unavailable)
			return "Keyboard Emulation";
#endif
		return MFInput_GetDeviceNameInternal(device, deviceID);
	}
}
Exemplo n.º 29
0
MF_API void MFMaterial_UnregisterMaterialType(const char *pName)
{
	MFCALLSTACK;

	MFMaterialType *pMatType = MaterialInternal_GetMaterialType(pName);

	MFDebug_Assert(pMatType, MFStr("Material type '%s' doesn't exist!", pName));

	if(pMatType)
	{
		pMatType->materialCallbacks.pUnregisterMaterial();
		gMaterialRegistry.Destroy(pMatType);
		MFHeap_Free(pMatType);
	}
}
Exemplo n.º 30
0
MF_API size_t MFFileSystem_Save(const char *pFilename, const char *pBuffer, size_t size)
{
	MFDebug_Log(5, MFStr("Call: MFFileSystem_Save(\"%s\")", pFilename));

	size_t bytesWritten = 0;

	MFFile *hFile = MFFileSystem_Open(pFilename, MFOF_Write|MFOF_Truncate|MFOF_Binary|MFOF_CreateDirectory);
	if(hFile)
	{
		bytesWritten = MFFile_Write(hFile, pBuffer, size, false);

		MFFile_Close(hFile);
	}

	return bytesWritten;
}