cellFont, cellRudp cleanup

This commit is contained in:
Nekotekina 2015-08-04 17:47:37 +03:00
parent 9e5daa1737
commit 2113fce2fb
2 changed files with 17 additions and 75 deletions

View File

@ -8,22 +8,11 @@
extern Module cellFont;
struct font_instance_t
{
std::atomic<bool> init{ false };
}
g_font;
// Functions
s32 cellFontInitializeWithRevision(u64 revisionFlags, vm::ptr<CellFontConfig> config)
{
cellFont.Warning("cellFontInitializeWithRevision(revisionFlags=0x%llx, config=*0x%x)", revisionFlags, config);
if (g_font.init.load())
{
return CELL_FONT_ERROR_ALREADY_INITIALIZED;
}
if (config->fc_size < 24)
{
return CELL_FONT_ERROR_INVALID_PARAMETER;
@ -34,11 +23,6 @@ s32 cellFontInitializeWithRevision(u64 revisionFlags, vm::ptr<CellFontConfig> co
cellFont.Error("cellFontInitializeWithRevision: Unknown flags (0x%x)", config->flags);
}
if (g_font.init.exchange(true))
{
throw EXCEPTION("Unexpected");
}
return CELL_OK;
}
@ -52,16 +36,6 @@ s32 cellFontEnd()
{
cellFont.Warning("cellFontEnd()");
if (!g_font.init.load())
{
return CELL_FONT_ERROR_UNINITIALIZED;
}
if (!g_font.init.exchange(false))
{
throw EXCEPTION("Unexpected");
}
return CELL_OK;
}
@ -75,11 +49,6 @@ s32 cellFontOpenFontMemory(vm::ptr<CellFontLibrary> library, u32 fontAddr, u32 f
{
cellFont.Warning("cellFontOpenFontMemory(library=*0x%x, fontAddr=0x%x, fontSize=%d, subNum=%d, uniqueId=%d, font=*0x%x)", library, fontAddr, fontSize, subNum, uniqueId, font);
if (!g_font.init.load())
{
return CELL_FONT_ERROR_UNINITIALIZED;
}
font->stbfont = (stbtt_fontinfo*)((u8*)&(font->stbfont) + sizeof(void*)); // hack: use next bytes of the struct
if (!stbtt_InitFont(font->stbfont, vm::get_ptr<unsigned char>(fontAddr), 0))
@ -115,11 +84,6 @@ s32 cellFontOpenFontset(PPUThread& ppu, vm::ptr<CellFontLibrary> library, vm::pt
{
cellFont.Warning("cellFontOpenFontset(library=*0x%x, fontType=*0x%x, font=*0x%x)", library, fontType, font);
if (!g_font.init.load())
{
return CELL_FONT_ERROR_UNINITIALIZED;
}
if (fontType->map != CELL_FONT_MAP_UNICODE)
{
cellFont.Warning("cellFontOpenFontset: Only Unicode is supported");
@ -223,11 +187,6 @@ s32 cellFontCreateRenderer(vm::ptr<CellFontLibrary> library, vm::ptr<CellFontRen
{
cellFont.Todo("cellFontCreateRenderer(library=*0x%x, config=*0x%x, Renderer=*0x%x)", library, config, Renderer);
if (!g_font.init.load())
{
return CELL_FONT_ERROR_UNINITIALIZED;
}
//Write data in Renderer
return CELL_OK;
@ -468,11 +427,6 @@ s32 cellFontOpenFontsetOnMemory(PPUThread& ppu, vm::ptr<CellFontLibrary> library
{
cellFont.Todo("cellFontOpenFontsetOnMemory(library=*0x%x, fontType=*0x%x, font=*0x%x)", library, fontType, font);
if (!g_font.init.load())
{
return CELL_FONT_ERROR_UNINITIALIZED;
}
if (fontType->map != CELL_FONT_MAP_UNICODE)
{
cellFont.Warning("cellFontOpenFontsetOnMemory: Only Unicode is supported");
@ -789,8 +743,6 @@ s32 cellFontGraphicsGetLineRGBA()
Module cellFont("cellFont", []()
{
g_font.init = false;
REG_FUNC(cellFont, cellFontSetFontsetOpenMode);
REG_FUNC(cellFont, cellFontSetFontOpenMode);
REG_FUNC(cellFont, cellFontCreateRenderer);

View File

@ -1,5 +1,6 @@
#include "stdafx.h"
#include "Emu/Memory/Memory.h"
#include "Emu/IdManager.h"
#include "Emu/System.h"
#include "Emu/SysCalls/Modules.h"
@ -8,42 +9,41 @@
extern Module cellRudp;
struct RudpInternal
struct rudp_t
{
std::atomic<bool> init;
// allocator functions
std::function<vm::ptr<void>(PPUThread& ppu, u32 size)> malloc;
std::function<void(PPUThread& ppu, vm::ptr<void> ptr)> free;
// event handler function
vm::ptr<CellRudpEventHandler> handler;
vm::ptr<CellRudpEventHandler> handler = vm::null;
vm::ptr<void> handler_arg;
}
g_rudp;
};
s32 cellRudpInit(vm::ptr<CellRudpAllocator> allocator)
{
cellRudp.Warning("cellRudpInit(allocator=*0x%x)", allocator);
if (g_rudp.init.load())
const auto rudp = Emu.GetIdManager().make_fixed<rudp_t>();
if (!rudp)
{
return CELL_RUDP_ERROR_ALREADY_INITIALIZED;
}
if (allocator)
{
g_rudp.malloc = allocator->app_malloc;
g_rudp.free = allocator->app_free;
rudp->malloc = allocator->app_malloc;
rudp->free = allocator->app_free;
}
else
{
g_rudp.malloc = [](PPUThread& ppu, u32 size)
rudp->malloc = [](PPUThread& ppu, u32 size)
{
return vm::ptr<void>::make(vm::alloc(size, vm::main));
};
g_rudp.free = [](PPUThread& ppu, vm::ptr<void> ptr)
rudp->free = [](PPUThread& ppu, vm::ptr<void> ptr)
{
if (!vm::dealloc(ptr.addr(), vm::main))
{
@ -52,11 +52,6 @@ s32 cellRudpInit(vm::ptr<CellRudpAllocator> allocator)
};
}
if (g_rudp.init.exchange(true))
{
throw EXCEPTION("Unexpected");
}
return CELL_OK;
}
@ -64,16 +59,11 @@ s32 cellRudpEnd()
{
cellRudp.Warning("cellRudpEnd()");
if (!g_rudp.init.load())
if (!Emu.GetIdManager().remove<rudp_t>())
{
return CELL_RUDP_ERROR_NOT_INITIALIZED;
}
if (!g_rudp.init.exchange(false))
{
throw EXCEPTION("Unexpected");
}
return CELL_OK;
}
@ -87,13 +77,15 @@ s32 cellRudpSetEventHandler(vm::ptr<CellRudpEventHandler> handler, vm::ptr<void>
{
cellRudp.Todo("cellRudpSetEventHandler(handler=*0x%x, arg=*0x%x)", handler, arg);
if (!g_rudp.init.load())
const auto rudp = Emu.GetIdManager().get<rudp_t>();
if (!rudp)
{
return CELL_RUDP_ERROR_NOT_INITIALIZED;
}
g_rudp.handler = handler;
g_rudp.handler_arg = arg;
rudp->handler = handler;
rudp->handler_arg = arg;
return CELL_OK;
}
@ -250,8 +242,6 @@ s32 cellRudpProcessEvents()
Module cellRudp("cellRudp", []()
{
g_rudp.init = false;
REG_FUNC(cellRudp, cellRudpInit);
REG_FUNC(cellRudp, cellRudpEnd);
REG_FUNC(cellRudp, cellRudpEnableInternalIOThread);