Make credits fullscreen

See #3, #215
This commit is contained in:
Alexander Batalov 2023-01-02 13:09:03 +03:00
parent 6224af6178
commit 812079004c

View File

@ -22,8 +22,6 @@
namespace fallout {
#define CREDITS_WINDOW_WIDTH (640)
#define CREDITS_WINDOW_HEIGHT (480)
#define CREDITS_WINDOW_SCROLLING_DELAY (38)
static bool creditsFileParseNextLine(char* dest, int* font, int* color);
@ -78,39 +76,35 @@ void creditsOpen(const char* filePath, int backgroundFid, bool useReversedStyle)
mouseShowCursor();
}
int creditsWindowX = (screenGetWidth() - CREDITS_WINDOW_WIDTH) / 2;
int creditsWindowY = (screenGetHeight() - CREDITS_WINDOW_HEIGHT) / 2;
int window = windowCreate(creditsWindowX, creditsWindowY, CREDITS_WINDOW_WIDTH, CREDITS_WINDOW_HEIGHT, _colorTable[0], 20);
int windowWidth = screenGetWidth();
int windowHeight = screenGetHeight();
int window = windowCreate(0, 0, windowWidth, windowHeight, _colorTable[0], 20);
soundContinueAll();
if (window != -1) {
unsigned char* windowBuffer = windowGetBuffer(window);
if (windowBuffer != NULL) {
unsigned char* backgroundBuffer = (unsigned char*)internal_malloc(CREDITS_WINDOW_WIDTH * CREDITS_WINDOW_HEIGHT);
unsigned char* backgroundBuffer = (unsigned char*)internal_malloc(windowWidth * windowHeight);
if (backgroundBuffer) {
soundContinueAll();
memset(backgroundBuffer, _colorTable[0], CREDITS_WINDOW_WIDTH * CREDITS_WINDOW_HEIGHT);
memset(backgroundBuffer, _colorTable[0], windowWidth * windowHeight);
if (backgroundFid != -1) {
CacheEntry* backgroundFrmHandle;
Art* frm = artLock(backgroundFid, &backgroundFrmHandle);
if (frm != NULL) {
int width = artGetWidth(frm, 0, 0);
int height = artGetHeight(frm, 0, 0);
unsigned char* backgroundFrmData = artGetFrameData(frm, 0, 0);
blitBufferToBuffer(backgroundFrmData,
width,
height,
width,
backgroundBuffer + CREDITS_WINDOW_WIDTH * ((CREDITS_WINDOW_HEIGHT - height) / 2) + (CREDITS_WINDOW_WIDTH - width) / 2,
CREDITS_WINDOW_WIDTH);
artUnlock(backgroundFrmHandle);
FrmImage backgroundFrmImage;
if (backgroundFrmImage.lock(backgroundFid)) {
blitBufferToBuffer(backgroundFrmImage.getData(),
backgroundFrmImage.getWidth(),
backgroundFrmImage.getHeight(),
backgroundFrmImage.getWidth(),
backgroundBuffer + windowWidth * ((windowHeight - backgroundFrmImage.getHeight()) / 2) + (windowWidth - backgroundFrmImage.getWidth()) / 2,
windowWidth);
backgroundFrmImage.unlock();
}
}
unsigned char* intermediateBuffer = (unsigned char*)internal_malloc(CREDITS_WINDOW_WIDTH * CREDITS_WINDOW_HEIGHT);
unsigned char* intermediateBuffer = (unsigned char*)internal_malloc(windowWidth * windowHeight);
if (intermediateBuffer != NULL) {
memset(intermediateBuffer, 0, CREDITS_WINDOW_WIDTH * CREDITS_WINDOW_HEIGHT);
memset(intermediateBuffer, 0, windowWidth * windowHeight);
fontSetCurrent(gCreditsWindowTitleFont);
int titleFontLineHeight = fontGetLineHeight();
@ -119,21 +113,20 @@ void creditsOpen(const char* filePath, int backgroundFid, bool useReversedStyle)
int nameFontLineHeight = fontGetLineHeight();
int lineHeight = nameFontLineHeight + (titleFontLineHeight >= nameFontLineHeight ? titleFontLineHeight - nameFontLineHeight : 0);
int stringBufferSize = CREDITS_WINDOW_WIDTH * lineHeight;
int stringBufferSize = windowWidth * lineHeight;
unsigned char* stringBuffer = (unsigned char*)internal_malloc(stringBufferSize);
if (stringBuffer != NULL) {
blitBufferToBuffer(backgroundBuffer,
CREDITS_WINDOW_WIDTH,
CREDITS_WINDOW_HEIGHT,
CREDITS_WINDOW_WIDTH,
windowWidth,
windowHeight,
windowWidth,
windowBuffer,
CREDITS_WINDOW_WIDTH);
windowWidth);
windowRefresh(window);
paletteFadeTo(_cmap);
unsigned char* v40 = intermediateBuffer + CREDITS_WINDOW_WIDTH * CREDITS_WINDOW_HEIGHT - CREDITS_WINDOW_WIDTH;
char str[260];
int font;
int color;
@ -142,15 +135,15 @@ void creditsOpen(const char* filePath, int backgroundFid, bool useReversedStyle)
while (creditsFileParseNextLine(str, &font, &color)) {
fontSetCurrent(font);
int v19 = fontGetStringWidth(str);
if (v19 >= CREDITS_WINDOW_WIDTH) {
int stringWidth = fontGetStringWidth(str);
if (stringWidth >= windowWidth) {
continue;
}
memset(stringBuffer, 0, stringBufferSize);
fontDrawText(stringBuffer, str, CREDITS_WINDOW_WIDTH, CREDITS_WINDOW_WIDTH, color);
fontDrawText(stringBuffer, str, windowWidth, windowWidth, color);
unsigned char* dest = intermediateBuffer + CREDITS_WINDOW_WIDTH * CREDITS_WINDOW_HEIGHT - CREDITS_WINDOW_WIDTH + (CREDITS_WINDOW_WIDTH - v19) / 2;
unsigned char* dest = intermediateBuffer + windowWidth * windowHeight - windowWidth + (windowWidth - stringWidth) / 2;
unsigned char* src = stringBuffer;
for (int index = 0; index < lineHeight; index++) {
sharedFpsLimiter.mark();
@ -160,22 +153,22 @@ void creditsOpen(const char* filePath, int backgroundFid, bool useReversedStyle)
break;
}
memmove(intermediateBuffer, intermediateBuffer + CREDITS_WINDOW_WIDTH, CREDITS_WINDOW_WIDTH * CREDITS_WINDOW_HEIGHT - CREDITS_WINDOW_WIDTH);
memcpy(dest, src, v19);
memmove(intermediateBuffer, intermediateBuffer + windowWidth, windowWidth * windowHeight - windowWidth);
memcpy(dest, src, stringWidth);
blitBufferToBuffer(backgroundBuffer,
CREDITS_WINDOW_WIDTH,
CREDITS_WINDOW_HEIGHT,
CREDITS_WINDOW_WIDTH,
windowWidth,
windowHeight,
windowWidth,
windowBuffer,
CREDITS_WINDOW_WIDTH);
windowWidth);
blitBufferToBufferTrans(intermediateBuffer,
CREDITS_WINDOW_WIDTH,
CREDITS_WINDOW_HEIGHT,
CREDITS_WINDOW_WIDTH,
windowWidth,
windowHeight,
windowWidth,
windowBuffer,
CREDITS_WINDOW_WIDTH);
windowWidth);
while (getTicksSince(tick) < CREDITS_WINDOW_SCROLLING_DELAY) {
}
@ -184,7 +177,7 @@ void creditsOpen(const char* filePath, int backgroundFid, bool useReversedStyle)
windowRefresh(window);
src += CREDITS_WINDOW_WIDTH;
src += windowWidth;
sharedFpsLimiter.throttle();
renderPresent();
@ -196,29 +189,29 @@ void creditsOpen(const char* filePath, int backgroundFid, bool useReversedStyle)
}
if (!stop) {
for (int index = 0; index < CREDITS_WINDOW_HEIGHT; index++) {
for (int index = 0; index < windowHeight; index++) {
sharedFpsLimiter.mark();
if (inputGetInput() != -1) {
break;
}
memmove(intermediateBuffer, intermediateBuffer + CREDITS_WINDOW_WIDTH, CREDITS_WINDOW_WIDTH * CREDITS_WINDOW_HEIGHT - CREDITS_WINDOW_WIDTH);
memset(intermediateBuffer + CREDITS_WINDOW_WIDTH * CREDITS_WINDOW_HEIGHT - CREDITS_WINDOW_WIDTH, 0, CREDITS_WINDOW_WIDTH);
memmove(intermediateBuffer, intermediateBuffer + windowWidth, windowWidth * windowHeight - windowWidth);
memset(intermediateBuffer + windowWidth * windowHeight - windowWidth, 0, windowWidth);
blitBufferToBuffer(backgroundBuffer,
CREDITS_WINDOW_WIDTH,
CREDITS_WINDOW_HEIGHT,
CREDITS_WINDOW_WIDTH,
windowWidth,
windowHeight,
windowWidth,
windowBuffer,
CREDITS_WINDOW_WIDTH);
windowWidth);
blitBufferToBufferTrans(intermediateBuffer,
CREDITS_WINDOW_WIDTH,
CREDITS_WINDOW_HEIGHT,
CREDITS_WINDOW_WIDTH,
windowWidth,
windowHeight,
windowWidth,
windowBuffer,
CREDITS_WINDOW_WIDTH);
windowWidth);
while (getTicksSince(tick) < CREDITS_WINDOW_SCROLLING_DELAY) {
}