Refactor artLockFrameData with FrmImage

This commit is contained in:
Alexander Batalov 2022-09-24 16:39:15 +03:00
parent f59c072d68
commit e50e26cf87
1 changed files with 60 additions and 190 deletions

View File

@ -112,92 +112,33 @@ static unsigned char* gCharacterSelectorBackground = NULL;
// 0x51C804 // 0x51C804
static int gCharacterSelectorWindowPreviousButton = -1; static int gCharacterSelectorWindowPreviousButton = -1;
// 0x51C808
static CacheEntry* gCharacterSelectorWindowPreviousButtonUpFrmHandle = NULL;
// 0x51C80C
static CacheEntry* gCharacterSelectorWindowPreviousButtonDownFrmHandle = NULL;
// 0x51C810 // 0x51C810
static int gCharacterSelectorWindowNextButton = -1; static int gCharacterSelectorWindowNextButton = -1;
// 0x51C814
static CacheEntry* gCharacterSelectorWindowNextButtonUpFrmHandle = NULL;
// 0x51C818
static CacheEntry* gCharacterSelectorWindowNextButtonDownFrmHandle = NULL;
// 0x51C81C // 0x51C81C
static int gCharacterSelectorWindowTakeButton = -1; static int gCharacterSelectorWindowTakeButton = -1;
// 0x51C820
static CacheEntry* gCharacterSelectorWindowTakeButtonUpFrmHandle = NULL;
// 0x51C824
static CacheEntry* gCharacterSelectorWindowTakeButtonDownFrmHandle = NULL;
// 0x51C828 // 0x51C828
static int gCharacterSelectorWindowModifyButton = -1; static int gCharacterSelectorWindowModifyButton = -1;
// 0x51C82C
static CacheEntry* gCharacterSelectorWindowModifyButtonUpFrmHandle = NULL;
// 0x51C830
static CacheEntry* gCharacterSelectorWindowModifyButtonDownFrmHandle = NULL;
// 0x51C834 // 0x51C834
static int gCharacterSelectorWindowCreateButton = -1; static int gCharacterSelectorWindowCreateButton = -1;
// 0x51C838
static CacheEntry* gCharacterSelectorWindowCreateButtonUpFrmHandle = NULL;
// 0x51C83C
static CacheEntry* gCharacterSelectorWindowCreateButtonDownFrmHandle = NULL;
// 0x51C840 // 0x51C840
static int gCharacterSelectorWindowBackButton = -1; static int gCharacterSelectorWindowBackButton = -1;
// 0x51C844 static FrmImage _takeButtonNormalFrmImage;
static CacheEntry* gCharacterSelectorWindowBackButtonUpFrmHandle = NULL; static FrmImage _takeButtonPressedFrmImage;
static FrmImage _modifyButtonNormalFrmImage;
// 0x51C848 static FrmImage _modifyButtonPressedFrmImage;
static CacheEntry* gCharacterSelectorWindowBackButtonDownFrmHandle = NULL; static FrmImage _createButtonNormalFrmImage;
static FrmImage _createButtonPressedFrmImage;
// 0x667764 static FrmImage _backButtonNormalFrmImage;
static unsigned char* gCharacterSelectorWindowTakeButtonUpFrmData; static FrmImage _backButtonPressedFrmImage;
static FrmImage _nextButtonNormalFrmImage;
// 0x667768 static FrmImage _nextButtonPressedFrmImage;
static unsigned char* gCharacterSelectorWindowModifyButtonDownFrmData; static FrmImage _previousButtonNormalFrmImage;
static FrmImage _previousButtonPressedFrmImage;
// 0x66776C
static unsigned char* gCharacterSelectorWindowBackButtonUpFrmData;
// 0x667770
static unsigned char* gCharacterSelectorWindowCreateButtonUpFrmData;
// 0x667774
static unsigned char* gCharacterSelectorWindowModifyButtonUpFrmData;
// 0x667778
static unsigned char* gCharacterSelectorWindowBackButtonDownFrmData;
// 0x66777C
static unsigned char* gCharacterSelectorWindowCreateButtonDownFrmData;
// 0x667780
static unsigned char* gCharacterSelectorWindowTakeButtonDownFrmData;
// 0x667784
static unsigned char* gCharacterSelectorWindowNextButtonDownFrmData;
// 0x667788
static unsigned char* gCharacterSelectorWindowNextButtonUpFrmData;
// 0x66778C
static unsigned char* gCharacterSelectorWindowPreviousButtonUpFrmData;
// 0x667790
static unsigned char* gCharacterSelectorWindowPreviousButtonDownFrmData;
static std::vector<PremadeCharacterDescription> gCustomPremadeCharacterDescriptions; static std::vector<PremadeCharacterDescription> gCustomPremadeCharacterDescriptions;
@ -308,9 +249,6 @@ int characterSelectorOpen()
// 0x4A7468 // 0x4A7468
static bool characterSelectorWindowInit() static bool characterSelectorWindowInit()
{ {
int backgroundFid;
unsigned char* backgroundFrmData;
if (gCharacterSelectorWindow != -1) { if (gCharacterSelectorWindow != -1) {
return false; return false;
} }
@ -327,14 +265,13 @@ static bool characterSelectorWindowInit()
return characterSelectorWindowFatalError(false); return characterSelectorWindowFatalError(false);
} }
CacheEntry* backgroundFrmHandle; FrmImage backgroundFrmImage;
backgroundFid = buildFid(OBJ_TYPE_INTERFACE, 174, 0, 0, 0); int backgroundFid = buildFid(OBJ_TYPE_INTERFACE, 174, 0, 0, 0);
backgroundFrmData = artLockFrameData(backgroundFid, 0, 0, &backgroundFrmHandle); if (!backgroundFrmImage.lock(backgroundFid)) {
if (backgroundFrmData == NULL) {
return characterSelectorWindowFatalError(false); return characterSelectorWindowFatalError(false);
} }
blitBufferToBuffer(backgroundFrmData, blitBufferToBuffer(backgroundFrmImage.getData(),
CS_WINDOW_WIDTH, CS_WINDOW_WIDTH,
CS_WINDOW_HEIGHT, CS_WINDOW_HEIGHT,
CS_WINDOW_WIDTH, CS_WINDOW_WIDTH,
@ -345,27 +282,25 @@ static bool characterSelectorWindowInit()
if (gCharacterSelectorBackground == NULL) if (gCharacterSelectorBackground == NULL)
return characterSelectorWindowFatalError(false); return characterSelectorWindowFatalError(false);
blitBufferToBuffer(backgroundFrmData + CS_WINDOW_WIDTH * CS_WINDOW_BACKGROUND_Y + CS_WINDOW_BACKGROUND_X, blitBufferToBuffer(backgroundFrmImage.getData() + CS_WINDOW_WIDTH * CS_WINDOW_BACKGROUND_Y + CS_WINDOW_BACKGROUND_X,
CS_WINDOW_BACKGROUND_WIDTH, CS_WINDOW_BACKGROUND_WIDTH,
CS_WINDOW_BACKGROUND_HEIGHT, CS_WINDOW_BACKGROUND_HEIGHT,
CS_WINDOW_WIDTH, CS_WINDOW_WIDTH,
gCharacterSelectorBackground, gCharacterSelectorBackground,
CS_WINDOW_BACKGROUND_WIDTH); CS_WINDOW_BACKGROUND_WIDTH);
artUnlock(backgroundFrmHandle); backgroundFrmImage.unlock();
int fid; int fid;
// Setup "Previous" button. // Setup "Previous" button.
fid = buildFid(OBJ_TYPE_INTERFACE, 122, 0, 0, 0); fid = buildFid(OBJ_TYPE_INTERFACE, 122, 0, 0, 0);
gCharacterSelectorWindowPreviousButtonUpFrmData = artLockFrameData(fid, 0, 0, &gCharacterSelectorWindowPreviousButtonUpFrmHandle); if (!_previousButtonNormalFrmImage.lock(fid)) {
if (gCharacterSelectorWindowPreviousButtonUpFrmData == NULL) {
return characterSelectorWindowFatalError(false); return characterSelectorWindowFatalError(false);
} }
fid = buildFid(OBJ_TYPE_INTERFACE, 123, 0, 0, 0); fid = buildFid(OBJ_TYPE_INTERFACE, 123, 0, 0, 0);
gCharacterSelectorWindowPreviousButtonDownFrmData = artLockFrameData(fid, 0, 0, &gCharacterSelectorWindowPreviousButtonDownFrmHandle); if (!_previousButtonPressedFrmImage.lock(fid)) {
if (gCharacterSelectorWindowPreviousButtonDownFrmData == NULL) {
return characterSelectorWindowFatalError(false); return characterSelectorWindowFatalError(false);
} }
@ -378,8 +313,8 @@ static bool characterSelectorWindowInit()
-1, -1,
-1, -1,
500, 500,
gCharacterSelectorWindowPreviousButtonUpFrmData, _previousButtonNormalFrmImage.getData(),
gCharacterSelectorWindowPreviousButtonDownFrmData, _previousButtonPressedFrmImage.getData(),
NULL, NULL,
0); 0);
if (gCharacterSelectorWindowPreviousButton == -1) { if (gCharacterSelectorWindowPreviousButton == -1) {
@ -390,14 +325,12 @@ static bool characterSelectorWindowInit()
// Setup "Next" button. // Setup "Next" button.
fid = buildFid(OBJ_TYPE_INTERFACE, 124, 0, 0, 0); fid = buildFid(OBJ_TYPE_INTERFACE, 124, 0, 0, 0);
gCharacterSelectorWindowNextButtonUpFrmData = artLockFrameData(fid, 0, 0, &gCharacterSelectorWindowNextButtonUpFrmHandle); if (!_nextButtonNormalFrmImage.lock(fid)) {
if (gCharacterSelectorWindowNextButtonUpFrmData == NULL) {
return characterSelectorWindowFatalError(false); return characterSelectorWindowFatalError(false);
} }
fid = buildFid(OBJ_TYPE_INTERFACE, 125, 0, 0, 0); fid = buildFid(OBJ_TYPE_INTERFACE, 125, 0, 0, 0);
gCharacterSelectorWindowNextButtonDownFrmData = artLockFrameData(fid, 0, 0, &gCharacterSelectorWindowNextButtonDownFrmHandle); if (!_nextButtonPressedFrmImage.lock(fid)) {
if (gCharacterSelectorWindowNextButtonDownFrmData == NULL) {
return characterSelectorWindowFatalError(false); return characterSelectorWindowFatalError(false);
} }
@ -410,8 +343,8 @@ static bool characterSelectorWindowInit()
-1, -1,
-1, -1,
501, 501,
gCharacterSelectorWindowNextButtonUpFrmData, _nextButtonNormalFrmImage.getData(),
gCharacterSelectorWindowNextButtonDownFrmData, _nextButtonPressedFrmImage.getData(),
NULL, NULL,
0); 0);
if (gCharacterSelectorWindowNextButton == -1) { if (gCharacterSelectorWindowNextButton == -1) {
@ -422,14 +355,12 @@ static bool characterSelectorWindowInit()
// Setup "Take" button. // Setup "Take" button.
fid = buildFid(OBJ_TYPE_INTERFACE, 8, 0, 0, 0); fid = buildFid(OBJ_TYPE_INTERFACE, 8, 0, 0, 0);
gCharacterSelectorWindowTakeButtonUpFrmData = artLockFrameData(fid, 0, 0, &gCharacterSelectorWindowTakeButtonUpFrmHandle); if (!_takeButtonNormalFrmImage.lock(fid)) {
if (gCharacterSelectorWindowTakeButtonUpFrmData == NULL) {
return characterSelectorWindowFatalError(false); return characterSelectorWindowFatalError(false);
} }
fid = buildFid(OBJ_TYPE_INTERFACE, 9, 0, 0, 0); fid = buildFid(OBJ_TYPE_INTERFACE, 9, 0, 0, 0);
gCharacterSelectorWindowTakeButtonDownFrmData = artLockFrameData(fid, 0, 0, &gCharacterSelectorWindowTakeButtonDownFrmHandle); if (!_takeButtonPressedFrmImage.lock(fid)) {
if (gCharacterSelectorWindowTakeButtonDownFrmData == NULL) {
return characterSelectorWindowFatalError(false); return characterSelectorWindowFatalError(false);
} }
@ -442,8 +373,8 @@ static bool characterSelectorWindowInit()
-1, -1,
-1, -1,
KEY_LOWERCASE_T, KEY_LOWERCASE_T,
gCharacterSelectorWindowTakeButtonUpFrmData, _takeButtonNormalFrmImage.getData(),
gCharacterSelectorWindowTakeButtonDownFrmData, _takeButtonPressedFrmImage.getData(),
NULL, NULL,
BUTTON_FLAG_TRANSPARENT); BUTTON_FLAG_TRANSPARENT);
if (gCharacterSelectorWindowTakeButton == -1) { if (gCharacterSelectorWindowTakeButton == -1) {
@ -454,13 +385,11 @@ static bool characterSelectorWindowInit()
// Setup "Modify" button. // Setup "Modify" button.
fid = buildFid(OBJ_TYPE_INTERFACE, 8, 0, 0, 0); fid = buildFid(OBJ_TYPE_INTERFACE, 8, 0, 0, 0);
gCharacterSelectorWindowModifyButtonUpFrmData = artLockFrameData(fid, 0, 0, &gCharacterSelectorWindowModifyButtonUpFrmHandle); if (!_modifyButtonNormalFrmImage.lock(fid))
if (gCharacterSelectorWindowModifyButtonUpFrmData == NULL)
return characterSelectorWindowFatalError(false); return characterSelectorWindowFatalError(false);
fid = buildFid(OBJ_TYPE_INTERFACE, 9, 0, 0, 0); fid = buildFid(OBJ_TYPE_INTERFACE, 9, 0, 0, 0);
gCharacterSelectorWindowModifyButtonDownFrmData = artLockFrameData(fid, 0, 0, &gCharacterSelectorWindowModifyButtonDownFrmHandle); if (!_modifyButtonPressedFrmImage.lock(fid)) {
if (gCharacterSelectorWindowModifyButtonDownFrmData == NULL) {
return characterSelectorWindowFatalError(false); return characterSelectorWindowFatalError(false);
} }
@ -473,8 +402,8 @@ static bool characterSelectorWindowInit()
-1, -1,
-1, -1,
KEY_LOWERCASE_M, KEY_LOWERCASE_M,
gCharacterSelectorWindowModifyButtonUpFrmData, _modifyButtonNormalFrmImage.getData(),
gCharacterSelectorWindowModifyButtonDownFrmData, _modifyButtonPressedFrmImage.getData(),
NULL, NULL,
BUTTON_FLAG_TRANSPARENT); BUTTON_FLAG_TRANSPARENT);
if (gCharacterSelectorWindowModifyButton == -1) { if (gCharacterSelectorWindowModifyButton == -1) {
@ -485,14 +414,12 @@ static bool characterSelectorWindowInit()
// Setup "Create" button. // Setup "Create" button.
fid = buildFid(OBJ_TYPE_INTERFACE, 8, 0, 0, 0); fid = buildFid(OBJ_TYPE_INTERFACE, 8, 0, 0, 0);
gCharacterSelectorWindowCreateButtonUpFrmData = artLockFrameData(fid, 0, 0, &gCharacterSelectorWindowCreateButtonUpFrmHandle); if (!_createButtonNormalFrmImage.lock(fid)) {
if (gCharacterSelectorWindowCreateButtonUpFrmData == NULL) {
return characterSelectorWindowFatalError(false); return characterSelectorWindowFatalError(false);
} }
fid = buildFid(OBJ_TYPE_INTERFACE, 9, 0, 0, 0); fid = buildFid(OBJ_TYPE_INTERFACE, 9, 0, 0, 0);
gCharacterSelectorWindowCreateButtonDownFrmData = artLockFrameData(fid, 0, 0, &gCharacterSelectorWindowCreateButtonDownFrmHandle); if (!_createButtonPressedFrmImage.lock(fid)) {
if (gCharacterSelectorWindowCreateButtonDownFrmData == NULL) {
return characterSelectorWindowFatalError(false); return characterSelectorWindowFatalError(false);
} }
@ -505,8 +432,8 @@ static bool characterSelectorWindowInit()
-1, -1,
-1, -1,
KEY_LOWERCASE_C, KEY_LOWERCASE_C,
gCharacterSelectorWindowCreateButtonUpFrmData, _createButtonNormalFrmImage.getData(),
gCharacterSelectorWindowCreateButtonDownFrmData, _createButtonPressedFrmImage.getData(),
NULL, NULL,
BUTTON_FLAG_TRANSPARENT); BUTTON_FLAG_TRANSPARENT);
if (gCharacterSelectorWindowCreateButton == -1) { if (gCharacterSelectorWindowCreateButton == -1) {
@ -517,14 +444,12 @@ static bool characterSelectorWindowInit()
// Setup "Back" button. // Setup "Back" button.
fid = buildFid(OBJ_TYPE_INTERFACE, 8, 0, 0, 0); fid = buildFid(OBJ_TYPE_INTERFACE, 8, 0, 0, 0);
gCharacterSelectorWindowBackButtonUpFrmData = artLockFrameData(fid, 0, 0, &gCharacterSelectorWindowBackButtonUpFrmHandle); if (!_backButtonNormalFrmImage.lock(fid)) {
if (gCharacterSelectorWindowBackButtonUpFrmData == NULL) {
return characterSelectorWindowFatalError(false); return characterSelectorWindowFatalError(false);
} }
fid = buildFid(OBJ_TYPE_INTERFACE, 9, 0, 0, 0); fid = buildFid(OBJ_TYPE_INTERFACE, 9, 0, 0, 0);
gCharacterSelectorWindowBackButtonDownFrmData = artLockFrameData(fid, 0, 0, &gCharacterSelectorWindowBackButtonDownFrmHandle); if (!_backButtonPressedFrmImage.lock(fid)) {
if (gCharacterSelectorWindowBackButtonDownFrmData == NULL) {
return characterSelectorWindowFatalError(false); return characterSelectorWindowFatalError(false);
} }
@ -537,8 +462,8 @@ static bool characterSelectorWindowInit()
-1, -1,
-1, -1,
KEY_ESCAPE, KEY_ESCAPE,
gCharacterSelectorWindowBackButtonUpFrmData, _backButtonNormalFrmImage.getData(),
gCharacterSelectorWindowBackButtonDownFrmData, _backButtonPressedFrmImage.getData(),
NULL, NULL,
BUTTON_FLAG_TRANSPARENT); BUTTON_FLAG_TRANSPARENT);
if (gCharacterSelectorWindowBackButton == -1) { if (gCharacterSelectorWindowBackButton == -1) {
@ -570,102 +495,48 @@ static void characterSelectorWindowFree()
gCharacterSelectorWindowPreviousButton = -1; gCharacterSelectorWindowPreviousButton = -1;
} }
if (gCharacterSelectorWindowPreviousButtonDownFrmData != NULL) { _previousButtonNormalFrmImage.unlock();
artUnlock(gCharacterSelectorWindowPreviousButtonDownFrmHandle); _previousButtonPressedFrmImage.unlock();
gCharacterSelectorWindowPreviousButtonDownFrmHandle = NULL;
gCharacterSelectorWindowPreviousButtonDownFrmData = NULL;
}
if (gCharacterSelectorWindowPreviousButtonUpFrmData != NULL) {
artUnlock(gCharacterSelectorWindowPreviousButtonUpFrmHandle);
gCharacterSelectorWindowPreviousButtonUpFrmHandle = NULL;
gCharacterSelectorWindowPreviousButtonUpFrmData = NULL;
}
if (gCharacterSelectorWindowNextButton != -1) { if (gCharacterSelectorWindowNextButton != -1) {
buttonDestroy(gCharacterSelectorWindowNextButton); buttonDestroy(gCharacterSelectorWindowNextButton);
gCharacterSelectorWindowNextButton = -1; gCharacterSelectorWindowNextButton = -1;
} }
if (gCharacterSelectorWindowNextButtonDownFrmData != NULL) { _nextButtonNormalFrmImage.unlock();
artUnlock(gCharacterSelectorWindowNextButtonDownFrmHandle); _nextButtonPressedFrmImage.unlock();
gCharacterSelectorWindowNextButtonDownFrmHandle = NULL;
gCharacterSelectorWindowNextButtonDownFrmData = NULL;
}
if (gCharacterSelectorWindowNextButtonUpFrmData != NULL) {
artUnlock(gCharacterSelectorWindowNextButtonUpFrmHandle);
gCharacterSelectorWindowNextButtonUpFrmHandle = NULL;
gCharacterSelectorWindowNextButtonUpFrmData = NULL;
}
if (gCharacterSelectorWindowTakeButton != -1) { if (gCharacterSelectorWindowTakeButton != -1) {
buttonDestroy(gCharacterSelectorWindowTakeButton); buttonDestroy(gCharacterSelectorWindowTakeButton);
gCharacterSelectorWindowTakeButton = -1; gCharacterSelectorWindowTakeButton = -1;
} }
if (gCharacterSelectorWindowTakeButtonDownFrmData != NULL) { _takeButtonNormalFrmImage.unlock();
artUnlock(gCharacterSelectorWindowTakeButtonDownFrmHandle); _takeButtonPressedFrmImage.unlock();
gCharacterSelectorWindowTakeButtonDownFrmHandle = NULL;
gCharacterSelectorWindowTakeButtonDownFrmData = NULL;
}
if (gCharacterSelectorWindowTakeButtonUpFrmData != NULL) {
artUnlock(gCharacterSelectorWindowTakeButtonUpFrmHandle);
gCharacterSelectorWindowTakeButtonUpFrmHandle = NULL;
gCharacterSelectorWindowTakeButtonUpFrmData = NULL;
}
if (gCharacterSelectorWindowModifyButton != -1) { if (gCharacterSelectorWindowModifyButton != -1) {
buttonDestroy(gCharacterSelectorWindowModifyButton); buttonDestroy(gCharacterSelectorWindowModifyButton);
gCharacterSelectorWindowModifyButton = -1; gCharacterSelectorWindowModifyButton = -1;
} }
if (gCharacterSelectorWindowModifyButtonDownFrmData != NULL) { _modifyButtonNormalFrmImage.unlock();
artUnlock(gCharacterSelectorWindowModifyButtonDownFrmHandle); _modifyButtonPressedFrmImage.unlock();
gCharacterSelectorWindowModifyButtonDownFrmHandle = NULL;
gCharacterSelectorWindowModifyButtonDownFrmData = NULL;
}
if (gCharacterSelectorWindowModifyButtonUpFrmData != NULL) {
artUnlock(gCharacterSelectorWindowModifyButtonUpFrmHandle);
gCharacterSelectorWindowModifyButtonUpFrmHandle = NULL;
gCharacterSelectorWindowModifyButtonUpFrmData = NULL;
}
if (gCharacterSelectorWindowCreateButton != -1) { if (gCharacterSelectorWindowCreateButton != -1) {
buttonDestroy(gCharacterSelectorWindowCreateButton); buttonDestroy(gCharacterSelectorWindowCreateButton);
gCharacterSelectorWindowCreateButton = -1; gCharacterSelectorWindowCreateButton = -1;
} }
if (gCharacterSelectorWindowCreateButtonDownFrmData != NULL) { _createButtonNormalFrmImage.unlock();
artUnlock(gCharacterSelectorWindowCreateButtonDownFrmHandle); _createButtonPressedFrmImage.unlock();
gCharacterSelectorWindowCreateButtonDownFrmHandle = NULL;
gCharacterSelectorWindowCreateButtonDownFrmData = NULL;
}
if (gCharacterSelectorWindowCreateButtonUpFrmData != NULL) {
artUnlock(gCharacterSelectorWindowCreateButtonUpFrmHandle);
gCharacterSelectorWindowCreateButtonUpFrmHandle = NULL;
gCharacterSelectorWindowCreateButtonUpFrmData = NULL;
}
if (gCharacterSelectorWindowBackButton != -1) { if (gCharacterSelectorWindowBackButton != -1) {
buttonDestroy(gCharacterSelectorWindowBackButton); buttonDestroy(gCharacterSelectorWindowBackButton);
gCharacterSelectorWindowBackButton = -1; gCharacterSelectorWindowBackButton = -1;
} }
if (gCharacterSelectorWindowBackButtonDownFrmData != NULL) { _backButtonNormalFrmImage.unlock();
artUnlock(gCharacterSelectorWindowBackButtonDownFrmHandle); _backButtonPressedFrmImage.unlock();
gCharacterSelectorWindowBackButtonDownFrmHandle = NULL;
gCharacterSelectorWindowBackButtonDownFrmData = NULL;
}
if (gCharacterSelectorWindowBackButtonUpFrmData != NULL) {
artUnlock(gCharacterSelectorWindowBackButtonUpFrmHandle);
gCharacterSelectorWindowBackButtonUpFrmHandle = NULL;
gCharacterSelectorWindowBackButtonUpFrmData = NULL;
}
if (gCharacterSelectorBackground != NULL) { if (gCharacterSelectorBackground != NULL) {
internal_free(gCharacterSelectorBackground); internal_free(gCharacterSelectorBackground);
@ -712,18 +583,17 @@ static bool characterSelectorWindowRenderFace()
{ {
bool success = false; bool success = false;
CacheEntry* faceFrmHandle; FrmImage faceFrmImage;
int faceFid = buildFid(OBJ_TYPE_INTERFACE, gCustomPremadeCharacterDescriptions[gCurrentPremadeCharacter].face, 0, 0, 0); int faceFid = buildFid(OBJ_TYPE_INTERFACE, gCustomPremadeCharacterDescriptions[gCurrentPremadeCharacter].face, 0, 0, 0);
Art* frm = artLock(faceFid, &faceFrmHandle); if (faceFrmImage.lock(faceFid)) {
if (frm != NULL) { unsigned char* data = faceFrmImage.getData();
unsigned char* data = artGetFrameData(frm, 0, 0);
if (data != NULL) { if (data != NULL) {
int width = artGetWidth(frm, 0, 0); int width = faceFrmImage.getWidth();
int height = artGetHeight(frm, 0, 0); int height = faceFrmImage.getHeight();
blitBufferToBufferTrans(data, width, height, width, (gCharacterSelectorWindowBuffer + CS_WINDOW_WIDTH * 23 + 27), CS_WINDOW_WIDTH); blitBufferToBufferTrans(data, width, height, width, (gCharacterSelectorWindowBuffer + CS_WINDOW_WIDTH * 23 + 27), CS_WINDOW_WIDTH);
success = true; success = true;
} }
artUnlock(faceFrmHandle); faceFrmImage.unlock();
} }
return success; return success;