mirror of https://github.com/mgba-emu/mgba.git
GUI: Screenshot dimensions are now passed through
This commit is contained in:
parent
b70a601e37
commit
63a06ecc05
1
CHANGES
1
CHANGES
|
@ -38,6 +38,7 @@ Misc:
|
||||||
- Qt: Make audio channel/video layer options shortcut mappable
|
- Qt: Make audio channel/video layer options shortcut mappable
|
||||||
- GBA Memory: Optimize stalling behavior
|
- GBA Memory: Optimize stalling behavior
|
||||||
- 3DS: Attempt to use Core 2 for threads
|
- 3DS: Attempt to use Core 2 for threads
|
||||||
|
- GUI: Screenshot dimensions are now passed through
|
||||||
|
|
||||||
0.4.1: (2016-07-11)
|
0.4.1: (2016-07-11)
|
||||||
Bugfixes:
|
Bugfixes:
|
||||||
|
|
|
@ -60,13 +60,13 @@ static void _drawState(struct GUIBackground* background, void* id) {
|
||||||
struct mGUIBackground* gbaBackground = (struct mGUIBackground*) background;
|
struct mGUIBackground* gbaBackground = (struct mGUIBackground*) background;
|
||||||
int stateId = ((int) id) >> 16;
|
int stateId = ((int) id) >> 16;
|
||||||
if (gbaBackground->p->drawScreenshot) {
|
if (gbaBackground->p->drawScreenshot) {
|
||||||
|
unsigned w, h;
|
||||||
|
gbaBackground->p->core->desiredVideoDimensions(gbaBackground->p->core, &w, &h);
|
||||||
if (gbaBackground->screenshot && gbaBackground->screenshotId == (int) id) {
|
if (gbaBackground->screenshot && gbaBackground->screenshotId == (int) id) {
|
||||||
gbaBackground->p->drawScreenshot(gbaBackground->p, gbaBackground->screenshot, true);
|
gbaBackground->p->drawScreenshot(gbaBackground->p, gbaBackground->screenshot, w, h, true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
struct VFile* vf = mCoreGetState(gbaBackground->p->core, stateId, false);
|
struct VFile* vf = mCoreGetState(gbaBackground->p->core, stateId, false);
|
||||||
unsigned w, h;
|
|
||||||
gbaBackground->p->core->desiredVideoDimensions(gbaBackground->p->core, &w, &h);
|
|
||||||
uint32_t* pixels = gbaBackground->screenshot;
|
uint32_t* pixels = gbaBackground->screenshot;
|
||||||
if (!pixels) {
|
if (!pixels) {
|
||||||
pixels = anonymousMemoryMap(w * h * 4);
|
pixels = anonymousMemoryMap(w * h * 4);
|
||||||
|
@ -88,7 +88,7 @@ static void _drawState(struct GUIBackground* background, void* id) {
|
||||||
vf->close(vf);
|
vf->close(vf);
|
||||||
}
|
}
|
||||||
if (success) {
|
if (success) {
|
||||||
gbaBackground->p->drawScreenshot(gbaBackground->p, pixels, true);
|
gbaBackground->p->drawScreenshot(gbaBackground->p, pixels, w, h, true);
|
||||||
gbaBackground->screenshotId = (int) id;
|
gbaBackground->screenshotId = (int) id;
|
||||||
} else if (gbaBackground->p->drawFrame) {
|
} else if (gbaBackground->p->drawFrame) {
|
||||||
gbaBackground->p->drawFrame(gbaBackground->p, true);
|
gbaBackground->p->drawFrame(gbaBackground->p, true);
|
||||||
|
|
|
@ -57,7 +57,7 @@ struct mGUIRunner {
|
||||||
void (*gameUnloaded)(struct mGUIRunner*);
|
void (*gameUnloaded)(struct mGUIRunner*);
|
||||||
void (*prepareForFrame)(struct mGUIRunner*);
|
void (*prepareForFrame)(struct mGUIRunner*);
|
||||||
void (*drawFrame)(struct mGUIRunner*, bool faded);
|
void (*drawFrame)(struct mGUIRunner*, bool faded);
|
||||||
void (*drawScreenshot)(struct mGUIRunner*, const uint32_t* pixels, bool faded);
|
void (*drawScreenshot)(struct mGUIRunner*, const uint32_t* pixels, unsigned width, unsigned height, bool faded);
|
||||||
void (*paused)(struct mGUIRunner*);
|
void (*paused)(struct mGUIRunner*);
|
||||||
void (*unpaused)(struct mGUIRunner*);
|
void (*unpaused)(struct mGUIRunner*);
|
||||||
void (*incrementScreenMode)(struct mGUIRunner*);
|
void (*incrementScreenMode)(struct mGUIRunner*);
|
||||||
|
|
|
@ -409,16 +409,15 @@ static void _drawFrame(struct mGUIRunner* runner, bool faded) {
|
||||||
_drawTex(runner->core, faded);
|
_drawTex(runner->core, faded);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _drawScreenshot(struct mGUIRunner* runner, const uint32_t* pixels, bool faded) {
|
static void _drawScreenshot(struct mGUIRunner* runner, const uint32_t* pixels, unsigned width, unsigned height, bool faded) {
|
||||||
UNUSED(runner);
|
|
||||||
|
|
||||||
C3D_Tex* tex = &outputTexture;
|
C3D_Tex* tex = &outputTexture;
|
||||||
|
|
||||||
u16* newPixels = linearMemAlign(256 * VIDEO_VERTICAL_PIXELS * sizeof(u32), 0x100);
|
u16* newPixels = linearMemAlign(256 * height * sizeof(u32), 0x100);
|
||||||
|
|
||||||
// Convert image from RGBX8 to BGR565
|
// Convert image from RGBX8 to BGR565
|
||||||
for (unsigned y = 0; y < VIDEO_VERTICAL_PIXELS; ++y) {
|
for (unsigned y = 0; y < height; ++y) {
|
||||||
for (unsigned x = 0; x < VIDEO_HORIZONTAL_PIXELS; ++x) {
|
for (unsigned x = 0; x < width; ++x) {
|
||||||
// 0xXXBBGGRR -> 0bRRRRRGGGGGGBBBBB
|
// 0xXXBBGGRR -> 0bRRRRRGGGGGGBBBBB
|
||||||
u32 p = *pixels++;
|
u32 p = *pixels++;
|
||||||
newPixels[y * 256 + x] =
|
newPixels[y * 256 + x] =
|
||||||
|
@ -426,12 +425,12 @@ static void _drawScreenshot(struct mGUIRunner* runner, const uint32_t* pixels, b
|
||||||
(p << 16 >> (24 + 2) << 5) | // G
|
(p << 16 >> (24 + 2) << 5) | // G
|
||||||
(p << 8 >> (24 + 3) << 0); // B
|
(p << 8 >> (24 + 3) << 0); // B
|
||||||
}
|
}
|
||||||
memset(&newPixels[y * 256 + VIDEO_HORIZONTAL_PIXELS], 0, (256 - VIDEO_HORIZONTAL_PIXELS) * sizeof(u32));
|
memset(&newPixels[y * 256 + width], 0, (256 - width) * sizeof(u32));
|
||||||
}
|
}
|
||||||
|
|
||||||
GSPGPU_FlushDataCache(newPixels, 256 * VIDEO_VERTICAL_PIXELS * sizeof(u32));
|
GSPGPU_FlushDataCache(newPixels, 256 * height * sizeof(u32));
|
||||||
C3D_SafeDisplayTransfer(
|
C3D_SafeDisplayTransfer(
|
||||||
(u32*) newPixels, GX_BUFFER_DIM(256, VIDEO_VERTICAL_PIXELS),
|
(u32*) newPixels, GX_BUFFER_DIM(256, height),
|
||||||
tex->data, GX_BUFFER_DIM(256, 256),
|
tex->data, GX_BUFFER_DIM(256, 256),
|
||||||
GX_TRANSFER_IN_FORMAT(GX_TRANSFER_FMT_RGB565) |
|
GX_TRANSFER_IN_FORMAT(GX_TRANSFER_FMT_RGB565) |
|
||||||
GX_TRANSFER_OUT_FORMAT(GX_TRANSFER_FMT_RGB565) |
|
GX_TRANSFER_OUT_FORMAT(GX_TRANSFER_FMT_RGB565) |
|
||||||
|
|
|
@ -283,12 +283,12 @@ void mPSP2Draw(struct mGUIRunner* runner, bool faded) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void mPSP2DrawScreenshot(struct mGUIRunner* runner, const uint32_t* pixels, bool faded) {
|
void mPSP2DrawScreenshot(struct mGUIRunner* runner, const uint32_t* pixels, unsigned width, unsigned height, bool faded) {
|
||||||
UNUSED(runner);
|
UNUSED(runner);
|
||||||
uint32_t* texpixels = vita2d_texture_get_datap(screenshot);
|
uint32_t* texpixels = vita2d_texture_get_datap(screenshot);
|
||||||
int y;
|
int y;
|
||||||
for (y = 0; y < VIDEO_VERTICAL_PIXELS; ++y) {
|
for (y = 0; y < height; ++y) {
|
||||||
memcpy(&texpixels[256 * y], &pixels[VIDEO_HORIZONTAL_PIXELS * y], VIDEO_HORIZONTAL_PIXELS * 4);
|
memcpy(&texpixels[256 * y], &pixels[width * y], width * 4);
|
||||||
}
|
}
|
||||||
switch (screenMode) {
|
switch (screenMode) {
|
||||||
case SM_BACKDROP:
|
case SM_BACKDROP:
|
||||||
|
@ -296,10 +296,10 @@ void mPSP2DrawScreenshot(struct mGUIRunner* runner, const uint32_t* pixels, bool
|
||||||
vita2d_draw_texture_tint(backdrop, 0, 0, (faded ? 0 : 0xC0000000) | 0x3FFFFFFF);
|
vita2d_draw_texture_tint(backdrop, 0, 0, (faded ? 0 : 0xC0000000) | 0x3FFFFFFF);
|
||||||
// Fall through
|
// Fall through
|
||||||
case SM_PLAIN:
|
case SM_PLAIN:
|
||||||
vita2d_draw_texture_tint_part_scale(screenshot, 120, 32, 0, 0, 240, 160, 3.0f, 3.0f, (faded ? 0 : 0xC0000000) | 0x3FFFFFFF);
|
vita2d_draw_texture_tint_part_scale(screenshot, (960.0f - width * 3.0f) / 2.0f, (544.0f - height * 3.0f) / 2.0f, 0, 0, width, height, 3.0f, 3.0f, (faded ? 0 : 0xC0000000) | 0x3FFFFFFF);
|
||||||
break;
|
break;
|
||||||
case SM_FULL:
|
case SM_FULL:
|
||||||
vita2d_draw_texture_tint_scale(screenshot, 0, 0, 960.0f / 240.0f, 544.0f / 160.0f, (faded ? 0 : 0xC0000000) | 0x3FFFFFFF);
|
vita2d_draw_texture_tint_scale(screenshot, 0, 0, 960.0f / width, 544.0f / height, (faded ? 0 : 0xC0000000) | 0x3FFFFFFF);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ void mPSP2UnloadROM(struct mGUIRunner* runner);
|
||||||
void mPSP2PrepareForFrame(struct mGUIRunner* runner);
|
void mPSP2PrepareForFrame(struct mGUIRunner* runner);
|
||||||
void mPSP2Unpaused(struct mGUIRunner* runner);
|
void mPSP2Unpaused(struct mGUIRunner* runner);
|
||||||
void mPSP2Draw(struct mGUIRunner* runner, bool faded);
|
void mPSP2Draw(struct mGUIRunner* runner, bool faded);
|
||||||
void mPSP2DrawScreenshot(struct mGUIRunner* runner, const uint32_t* pixels, bool faded);
|
void mPSP2DrawScreenshot(struct mGUIRunner* runner, const uint32_t* pixels, unsigned width, unsigned height, bool faded);
|
||||||
void mPSP2IncrementScreenMode(struct mGUIRunner* runner);
|
void mPSP2IncrementScreenMode(struct mGUIRunner* runner);
|
||||||
uint16_t mPSP2PollInput(struct mGUIRunner* runner);
|
uint16_t mPSP2PollInput(struct mGUIRunner* runner);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue