Refactor artLockFrameData with FrmImage
This commit is contained in:
parent
9ceb490f72
commit
f203cfcc83
|
@ -5402,22 +5402,19 @@ static void _combat_standup(Object* a1)
|
||||||
// 0x42603C
|
// 0x42603C
|
||||||
static void _print_tohit(unsigned char* dest, int destPitch, int accuracy)
|
static void _print_tohit(unsigned char* dest, int destPitch, int accuracy)
|
||||||
{
|
{
|
||||||
CacheEntry* numbersFrmHandle;
|
FrmImage numbersFrmImage;
|
||||||
int numbersFrmFid = buildFid(OBJ_TYPE_INTERFACE, 82, 0, 0, 0);
|
int numbersFid = buildFid(OBJ_TYPE_INTERFACE, 82, 0, 0, 0);
|
||||||
unsigned char* numbersFrmData = artLockFrameData(numbersFrmFid, 0, 0, &numbersFrmHandle);
|
if (!numbersFrmImage.lock(numbersFid)) {
|
||||||
if (numbersFrmData == NULL) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (accuracy >= 0) {
|
if (accuracy >= 0) {
|
||||||
blitBufferToBuffer(numbersFrmData + 9 * (accuracy % 10), 9, 17, 360, dest + 9, destPitch);
|
blitBufferToBuffer(numbersFrmImage.getData() + 9 * (accuracy % 10), 9, 17, 360, dest + 9, destPitch);
|
||||||
blitBufferToBuffer(numbersFrmData + 9 * (accuracy / 10), 9, 17, 360, dest, destPitch);
|
blitBufferToBuffer(numbersFrmImage.getData() + 9 * (accuracy / 10), 9, 17, 360, dest, destPitch);
|
||||||
} else {
|
} else {
|
||||||
blitBufferToBuffer(numbersFrmData + 108, 6, 17, 360, dest + 9, destPitch);
|
blitBufferToBuffer(numbersFrmImage.getData() + 108, 6, 17, 360, dest + 9, destPitch);
|
||||||
blitBufferToBuffer(numbersFrmData + 108, 6, 17, 360, dest, destPitch);
|
blitBufferToBuffer(numbersFrmImage.getData() + 108, 6, 17, 360, dest, destPitch);
|
||||||
}
|
}
|
||||||
|
|
||||||
artUnlock(numbersFrmHandle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 0x42612C
|
// 0x42612C
|
||||||
|
@ -5489,52 +5486,63 @@ static int calledShotSelectHitLocation(Object* critter, int* hitLocation, int hi
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int fid;
|
|
||||||
CacheEntry* handle;
|
|
||||||
unsigned char* data;
|
|
||||||
|
|
||||||
unsigned char* windowBuffer = windowGetBuffer(gCalledShotWindow);
|
unsigned char* windowBuffer = windowGetBuffer(gCalledShotWindow);
|
||||||
|
|
||||||
fid = buildFid(OBJ_TYPE_INTERFACE, 118, 0, 0, 0);
|
FrmImage backgroundFrm;
|
||||||
data = artLockFrameData(fid, 0, 0, &handle);
|
int backgroundFid = buildFid(OBJ_TYPE_INTERFACE, 118, 0, 0, 0);
|
||||||
if (data == NULL) {
|
if (!backgroundFrm.lock(backgroundFid)) {
|
||||||
windowDestroy(gCalledShotWindow);
|
windowDestroy(gCalledShotWindow);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
blitBufferToBuffer(data, CALLED_SHOT_WINDOW_WIDTH, CALLED_SHOT_WINDOW_HEIGHT, CALLED_SHOT_WINDOW_WIDTH, windowBuffer, CALLED_SHOT_WINDOW_WIDTH);
|
blitBufferToBuffer(backgroundFrm.getData(),
|
||||||
artUnlock(handle);
|
CALLED_SHOT_WINDOW_WIDTH,
|
||||||
|
CALLED_SHOT_WINDOW_HEIGHT,
|
||||||
|
CALLED_SHOT_WINDOW_WIDTH,
|
||||||
|
windowBuffer,
|
||||||
|
CALLED_SHOT_WINDOW_WIDTH);
|
||||||
|
|
||||||
fid = buildFid(OBJ_TYPE_CRITTER, critter->fid & 0xFFF, ANIM_CALLED_SHOT_PIC, 0, 0);
|
FrmImage critterFrm;
|
||||||
data = artLockFrameData(fid, 0, 0, &handle);
|
int critterFid = buildFid(OBJ_TYPE_CRITTER, critter->fid & 0xFFF, ANIM_CALLED_SHOT_PIC, 0, 0);
|
||||||
if (data != NULL) {
|
if (critterFrm.lock(critterFid)) {
|
||||||
blitBufferToBuffer(data, 170, 225, 170, windowBuffer + CALLED_SHOT_WINDOW_WIDTH * 31 + 168, CALLED_SHOT_WINDOW_WIDTH);
|
blitBufferToBuffer(critterFrm.getData(),
|
||||||
artUnlock(handle);
|
170,
|
||||||
|
225,
|
||||||
|
170,
|
||||||
|
windowBuffer + CALLED_SHOT_WINDOW_WIDTH * 31 + 168,
|
||||||
|
CALLED_SHOT_WINDOW_WIDTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
fid = buildFid(OBJ_TYPE_INTERFACE, 8, 0, 0, 0);
|
FrmImage cancelButtonNormalFrmImage;
|
||||||
|
int cancelButtonNormalFid = buildFid(OBJ_TYPE_INTERFACE, 8, 0, 0, 0);
|
||||||
CacheEntry* upHandle;
|
if (!cancelButtonNormalFrmImage.lock(cancelButtonNormalFid)) {
|
||||||
unsigned char* up = artLockFrameData(fid, 0, 0, &upHandle);
|
|
||||||
if (up == NULL) {
|
|
||||||
windowDestroy(gCalledShotWindow);
|
windowDestroy(gCalledShotWindow);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fid = buildFid(OBJ_TYPE_INTERFACE, 9, 0, 0, 0);
|
FrmImage cancelButtonPressedFrmImage;
|
||||||
|
int cancelButtonPressedFid = buildFid(OBJ_TYPE_INTERFACE, 9, 0, 0, 0);
|
||||||
CacheEntry* downHandle;
|
if (!cancelButtonPressedFrmImage.lock(cancelButtonPressedFid)) {
|
||||||
unsigned char* down = artLockFrameData(fid, 0, 0, &downHandle);
|
|
||||||
if (down == NULL) {
|
|
||||||
artUnlock(upHandle);
|
|
||||||
windowDestroy(gCalledShotWindow);
|
windowDestroy(gCalledShotWindow);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cancel button
|
// Cancel button
|
||||||
int btn = buttonCreate(gCalledShotWindow, 210, 268, 15, 16, -1, -1, -1, KEY_ESCAPE, up, down, NULL, BUTTON_FLAG_TRANSPARENT);
|
int cancelBtn = buttonCreate(gCalledShotWindow,
|
||||||
if (btn != -1) {
|
210,
|
||||||
buttonSetCallbacks(btn, _gsound_red_butt_press, _gsound_red_butt_release);
|
268,
|
||||||
|
15,
|
||||||
|
16,
|
||||||
|
-1,
|
||||||
|
-1,
|
||||||
|
-1,
|
||||||
|
KEY_ESCAPE,
|
||||||
|
cancelButtonNormalFrmImage.getData(),
|
||||||
|
cancelButtonPressedFrmImage.getData(),
|
||||||
|
NULL,
|
||||||
|
BUTTON_FLAG_TRANSPARENT);
|
||||||
|
if (cancelBtn != -1) {
|
||||||
|
buttonSetCallbacks(cancelBtn, _gsound_red_butt_press, _gsound_red_butt_release);
|
||||||
}
|
}
|
||||||
|
|
||||||
int oldFont = fontGetCurrent();
|
int oldFont = fontGetCurrent();
|
||||||
|
@ -5594,8 +5602,6 @@ static int calledShotSelectHitLocation(Object* critter, int* hitLocation, int hi
|
||||||
|
|
||||||
fontSetCurrent(oldFont);
|
fontSetCurrent(oldFont);
|
||||||
|
|
||||||
artUnlock(downHandle);
|
|
||||||
artUnlock(upHandle);
|
|
||||||
windowDestroy(gCalledShotWindow);
|
windowDestroy(gCalledShotWindow);
|
||||||
|
|
||||||
if (eventCode == KEY_ESCAPE) {
|
if (eventCode == KEY_ESCAPE) {
|
||||||
|
|
Loading…
Reference in New Issue