mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-24 05:49:58 +00:00
Hack around font problem that caused Dissidia to crash with fastmem (calling the supplied alloc fails).
This commit is contained in:
parent
1b1252b9ed
commit
f72f471370
@ -217,13 +217,23 @@ class FontLib {
|
|||||||
public:
|
public:
|
||||||
FontLib(u32 paramPtr) : fontHRes_(128.0f), fontVRes_(128.0f) {
|
FontLib(u32 paramPtr) : fontHRes_(128.0f), fontVRes_(128.0f) {
|
||||||
Memory::ReadStruct(paramPtr, ¶ms_);
|
Memory::ReadStruct(paramPtr, ¶ms_);
|
||||||
|
fakeAlloc_ = 0x13370;
|
||||||
// We use the same strange scheme that JPCSP uses.
|
// We use the same strange scheme that JPCSP uses.
|
||||||
u32 allocSize = 4 + 4 * params_.numFonts;
|
u32 allocSize = 4 + 4 * params_.numFonts;
|
||||||
PostAllocCallback *action = (PostAllocCallback*) __KernelCreateAction(actionPostAllocCallback);
|
PostAllocCallback *action = (PostAllocCallback*) __KernelCreateAction(actionPostAllocCallback);
|
||||||
action->SetFontLib(this);
|
action->SetFontLib(this);
|
||||||
|
|
||||||
|
if (false) {
|
||||||
|
// This fails in dissidia. The function at 088ff320 (params_.allocFuncAddr) calls some malloc function, the second one returns 0 which causes
|
||||||
|
// bad stores later. So we just ignore this with if (false) and fake it.
|
||||||
u32 args[1] = { allocSize };
|
u32 args[1] = { allocSize };
|
||||||
__KernelDirectMipsCall(params_.allocFuncAddr, action, args, 1, false);
|
__KernelDirectMipsCall(params_.allocFuncAddr, action, args, 1, false);
|
||||||
|
} else {
|
||||||
|
AllocDone(fakeAlloc_);
|
||||||
|
fakeAlloc_ += allocSize;
|
||||||
|
fontLibMap[handle()] = this;
|
||||||
|
INFO_LOG(HLE, "Leaving PostAllocCallback::run");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Close() {
|
void Close() {
|
||||||
@ -232,7 +242,7 @@ public:
|
|||||||
|
|
||||||
void Done() {
|
void Done() {
|
||||||
for (size_t i = 0; i < fonts_.size(); i++) {
|
for (size_t i = 0; i < fonts_.size(); i++) {
|
||||||
if (Memory::Read_U32(fonts_[i]) == FONT_IS_OPEN) {
|
if (isfontopen_[i] == FONT_IS_OPEN) {
|
||||||
fontMap[fonts_[i]]->Close();
|
fontMap[fonts_[i]]->Close();
|
||||||
delete fontMap[fonts_[i]];
|
delete fontMap[fonts_[i]];
|
||||||
fontMap.erase(fonts_[i]);
|
fontMap.erase(fonts_[i]);
|
||||||
@ -326,6 +336,8 @@ private:
|
|||||||
int fileFontHandle_;
|
int fileFontHandle_;
|
||||||
int handle_;
|
int handle_;
|
||||||
int altCharCode_;
|
int altCharCode_;
|
||||||
|
|
||||||
|
u32 fakeAlloc_;
|
||||||
DISALLOW_COPY_AND_ASSIGN(FontLib);
|
DISALLOW_COPY_AND_ASSIGN(FontLib);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -479,8 +491,9 @@ u32 sceFontNewLib(u32 paramPtr, u32 errorCodePtr) {
|
|||||||
|
|
||||||
FontLib *newLib = new FontLib(paramPtr);
|
FontLib *newLib = new FontLib(paramPtr);
|
||||||
// The game should never see this value, the return value is replaced
|
// The game should never see this value, the return value is replaced
|
||||||
// by the action.
|
// by the action. Except if we disable the alloc, in this case we return
|
||||||
return 0xDEADDEAD;
|
// the handle correctly here.
|
||||||
|
return newLib->handle();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user