use less memory for snapshot screenshots - so now thumbs are activated for GameCube, revert some GBA changes

This commit is contained in:
dborth 2010-06-03 23:16:47 +00:00
parent fe4b8d46ef
commit ae34742e6d
12 changed files with 325 additions and 270 deletions

View File

@ -538,7 +538,9 @@ class GuiImageData
//!Constructor
//!Converts the image data to RGBA8 - expects PNG format
//!\param i Image data
GuiImageData(const u8 * i);
//!\param w Max image width (0 = not set)
//!\param h Max image height (0 = not set)
GuiImageData(const u8 * i, int w=0, int h=0);
//!Destructor
~GuiImageData();
//!Gets a pointer to the image data

View File

@ -13,14 +13,14 @@
/**
* Constructor for the GuiImageData class.
*/
GuiImageData::GuiImageData(const u8 * i)
GuiImageData::GuiImageData(const u8 * i, int maxw, int maxh)
{
data = NULL;
width = 0;
height = 0;
if(i)
data = DecodePNG(i, &width, &height);
data = DecodePNG(i, &width, &height, maxw, maxh);
}
/**

View File

@ -327,8 +327,6 @@ void GuiSaveBrowser::Update(GuiTrigger * t)
saveType[1]->SetText("Snapshot");
savePreviewImg[0]->SetImage(gameSaveBlank);
savePreviewImg[1]->SetImage(gameSaveBlank);
savePreviewImg[0]->SetScale(1);
savePreviewImg[1]->SetScale(1);
saveBtn[0]->SetVisible(true);
saveBtn[1]->SetVisible(true);
@ -367,16 +365,9 @@ void GuiSaveBrowser::Update(GuiTrigger * t)
saveType[i]->SetText(savetext);
if(saves->previewImg[listOffset+i] != NULL)
{
savePreviewImg[i]->SetImage(saves->previewImg[listOffset+i]);
savePreviewImg[i]->SetScale(0.1);
}
else
{
savePreviewImg[i]->SetImage(gameSaveBlank);
savePreviewImg[i]->SetScale(1);
}
}
else
{

View File

@ -1390,6 +1390,7 @@ static int MenuGame()
{
free(gameScreenTex);
gameScreenTex = NULL;
gameScreenPngSize = 0;
}
bgImg->SetVisible(true);
#ifndef NO_SOUND
@ -1600,7 +1601,7 @@ static int MenuGameSaves(int action)
memset(savebuffer, 0, SAVEBUFFERSIZE);
if(LoadFile(scrfile, SILENT))
saves.previewImg[j] = new GuiImageData(savebuffer);
saves.previewImg[j] = new GuiImageData(savebuffer, 64, 48);
}
snprintf(filepath, 1024, "%s%s/%s", pathPrefix[GCSettings.SaveMethod], GCSettings.SaveFolder, saves.filename[j]);
if (stat(filepath, &filestat) == 0)
@ -4223,6 +4224,15 @@ MainMenu (int menu)
if(gameScreenTex)
{
IMGCTX pngContext = PNGU_SelectImageFromBuffer(gameScreenPng);
if (pngContext != NULL)
{
gameScreenPngSize = PNGU_EncodeFromGXTexture(pngContext, vmode->fbWidth, vmode->efbHeight, gameScreenTex, 0);
PNGU_ReleaseImageContext(pngContext);
DCFlushRange(gameScreenPng, 50*1024);
}
gameScreenImg = new GuiImage(gameScreenTex, vmode->fbWidth, vmode->efbHeight);
gameScreenImg->SetAlpha(192);
gameScreenImg->ColorStripe(30);
@ -4372,11 +4382,7 @@ MainMenu (int menu)
{
free(gameScreenTex);
gameScreenTex = NULL;
}
if(gameScreenTex2)
{
free(gameScreenTex2);
gameScreenTex2 = NULL;
gameScreenPngSize = 0;
}
// wait for keys to be depressed

View File

@ -374,34 +374,56 @@ static inline PNGU_u32 coordsRGBA8(PNGU_u32 x, PNGU_u32 y, PNGU_u32 w)
return ((((y >> 2) * (w >> 2) + (x >> 2)) << 5) + ((y & 3) << 2) + (x & 3)) << 1;
}
static PNGU_u8 * PNGU_DecodeTo4x4RGBA8 (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, PNGU_u8 default_alpha)
static u8 * PNGU_DecodeTo4x4RGBA8 (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, int * dstWidth, int * dstHeight, int maxWidth, int maxHeight)
{
PNGU_u8 *dst;
PNGU_u32 x, y, offset;
PNGU_u8 default_alpha = 255;
u8 *dst;
int x, y, x2, y2, offset;
int xRatio = 0, yRatio = 0;
png_byte *pixel;
if (pngu_decode (ctx, width, height, 0) != PNGU_OK)
return NULL;
PNGU_u32 newWidth = width;
if(newWidth%4) newWidth += (4-newWidth%4);
PNGU_u32 newHeight = height;
if(newHeight%4) newHeight += (4-newHeight%4);
int newWidth = width;
int newHeight = height;
int len = (newWidth * newHeight) << 2;
if((maxWidth > 0 && width > maxWidth) || (maxHeight > 0 && height > maxHeight))
{
float ratio = (float)width/(float)height;
newWidth = maxWidth;
newHeight = maxWidth/ratio;
if(newHeight > maxHeight)
{
newWidth = maxHeight*ratio;
newHeight = maxHeight;
}
xRatio = (int)((width<<16)/newWidth)+1;
yRatio = (int)((height<<16)/newHeight)+1;
}
int padWidth = newWidth;
int padHeight = newHeight;
if(padWidth%4) padWidth += (4-padWidth%4);
if(padHeight%4) padHeight += (4-padHeight%4);
int len = (padWidth * padHeight) << 2;
if(len%32) len += (32-len%32);
dst = memalign (32, len);
if(!dst)
return NULL;
for (y = 0; y < newHeight; y++)
for (y = 0; y < padHeight; y++)
{
for (x = 0; x < newWidth; x++)
for (x = 0; x < padWidth; x++)
{
offset = coordsRGBA8(x, y, newWidth);
if(y >= height || x >= width)
offset = coordsRGBA8(x, y, padWidth);
if(y >= newHeight || x >= newWidth)
{
dst[offset] = 0;
dst[offset+1] = 255;
@ -410,10 +432,20 @@ static PNGU_u8 * PNGU_DecodeTo4x4RGBA8 (IMGCTX ctx, PNGU_u32 width, PNGU_u32 hei
}
else
{
if(xRatio > 0)
{
x2 = ((x*xRatio)>>16);
y2 = ((y*yRatio)>>16);
}
if (ctx->prop.imgColorType == PNGU_COLOR_TYPE_GRAY_ALPHA ||
ctx->prop.imgColorType == PNGU_COLOR_TYPE_RGB_ALPHA)
{
pixel = &(ctx->row_pointers[y][x*4]);
if(xRatio > 0)
pixel = &(ctx->row_pointers[y2][x2*4]);
else
pixel = &(ctx->row_pointers[y][x*4]);
dst[offset] = pixel[3]; // Alpha
dst[offset+1] = pixel[0]; // Red
dst[offset+32] = pixel[1]; // Green
@ -421,7 +453,11 @@ static PNGU_u8 * PNGU_DecodeTo4x4RGBA8 (IMGCTX ctx, PNGU_u32 width, PNGU_u32 hei
}
else
{
pixel = &(ctx->row_pointers[y][x*3]);
if(xRatio > 0)
pixel = &(ctx->row_pointers[y2][x2*3]);
else
pixel = &(ctx->row_pointers[y][x*3]);
dst[offset] = default_alpha; // Alpha
dst[offset+1] = pixel[0]; // Red
dst[offset+32] = pixel[1]; // Green
@ -435,6 +471,8 @@ static PNGU_u8 * PNGU_DecodeTo4x4RGBA8 (IMGCTX ctx, PNGU_u32 width, PNGU_u32 hei
free (ctx->img_data);
free (ctx->row_pointers);
*dstWidth = padWidth;
*dstHeight = padHeight;
DCFlushRange(dst, len);
return dst;
}
@ -519,23 +557,18 @@ int PNGU_GetImageProperties (IMGCTX ctx, PNGUPROP *imgprop)
return PNGU_OK;
}
PNGU_u8 * DecodePNG(const PNGU_u8 *src, int * width, int * height)
PNGU_u8 * DecodePNG(const PNGU_u8 *src, int * width, int * height, int maxwidth, int maxheight)
{
PNGUPROP imgProp;
IMGCTX ctx = PNGU_SelectImageFromBuffer(src);
PNGU_u8 *dst = NULL;
u8 *dst = NULL;
if(!ctx)
return NULL;
if(PNGU_GetImageProperties(ctx, &imgProp) == PNGU_OK)
{
dst = PNGU_DecodeTo4x4RGBA8 (ctx, imgProp.imgWidth, imgProp.imgHeight, 255);
*width = imgProp.imgWidth;
*height = imgProp.imgHeight;
}
dst = PNGU_DecodeTo4x4RGBA8 (ctx, imgProp.imgWidth, imgProp.imgHeight, width, height, maxwidth, maxheight);
PNGU_ReleaseImageContext (ctx);
return dst;
}

View File

@ -67,7 +67,7 @@ int PNGU_GetImageProperties (IMGCTX ctx, PNGUPROP *fileproperties);
* Image conversion *
****************************************************************************/
PNGU_u8 * DecodePNG(const PNGU_u8 *src, int *width, int *height);
PNGU_u8 * DecodePNG(const PNGU_u8 *src, int *width, int *height, int maxwidth, int maxheight);
int PNGU_EncodeFromRGB (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buffer, PNGU_u32 stride);
int PNGU_EncodeFromGXTexture (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buffer, PNGU_u32 stride);

View File

@ -93,17 +93,17 @@ extern int gfxLastVCOUNT;
static inline void gfxClearArray(u32 *array)
{
for(unsigned i = 0; i < 240u; ++i) {
*array++ = 0x80000000;
}
for(int i = 0; i < 240; i++) {
*array++ = 0x80000000;
}
}
static inline void gfxDrawTextScreen(u16 control, u16 hofs, u16 vofs,
u32 *line)
{
u16 *palette = (u16 *)paletteRAM;
u8 *charBase = &vram[((control >> 2) & 0x03) << 14];
u16 *screenBase = (u16 *)&vram[((control >> 8) & 0x1f) << 11];
u8 *charBase = &vram[((control >> 2) & 0x03) * 0x4000];
u16 *screenBase = (u16 *)&vram[((control >> 8) & 0x1f) * 0x800];
u32 prio = ((control & 3)<<25) + 0x1000000;
int sizeX = 256;
int sizeY = 256;
@ -125,13 +125,13 @@ static inline void gfxDrawTextScreen(u16 control, u16 hofs, u16 vofs,
int maskX = sizeX-1;
int maskY = sizeY-1;
bool mosaicOn = (control & 0x40) ? true : false;
int xxx = hofs & maskX;
int yyy = (vofs + VCOUNT) & maskY;
int mosaicX = (MOSAIC & 0x000F)+1;
int mosaicY = ((MOSAIC & 0x00F0)>>4)+1;
bool mosaicOn = (control & 0x40) ? true : false;
if(mosaicOn) {
if((VCOUNT % mosaicY) != 0) {
mosaicY = VCOUNT - (VCOUNT % mosaicY);
@ -148,8 +148,8 @@ static inline void gfxDrawTextScreen(u16 control, u16 hofs, u16 vofs,
int yshift = ((yyy>>3)<<5);
if((control) & 0x80) {
u16 *screenSource = screenBase + ((xxx>>8) << 10) + ((xxx & 255)>>3) + yshift;
for(u32 x = 0; x < 240u; x++) {
u16 *screenSource = screenBase + 0x400 * (xxx>>8) + ((xxx & 255)>>3) + yshift;
for(int x = 0; x < 240; x++) {
u16 data = READ16LE(screenSource);
int tile = data & 0x3FF;
@ -157,18 +157,18 @@ static inline void gfxDrawTextScreen(u16 control, u16 hofs, u16 vofs,
int tileY = yyy & 7;
if(tileX == 7)
++screenSource;
screenSource++;
if(data & 0x0400)
tileX = 7 - tileX;
if(data & 0x0800)
tileY = 7 - tileY;
u8 color = charBase[(tile<<6) + (tileY<<3) + tileX];
u8 color = charBase[tile * 64 + tileY * 8 + tileX];
line[x] = color ? (READ16LE(&palette[color]) | prio): 0x80000000;
++xxx;
xxx++;
if(xxx == 256) {
if(sizeX > 256)
screenSource = screenBase + 0x400 + yshift;
@ -181,9 +181,10 @@ static inline void gfxDrawTextScreen(u16 control, u16 hofs, u16 vofs,
screenSource = screenBase + yshift;
}
}
} else {
u16 *screenSource = screenBase + ((xxx>>8) << 10) +((xxx&255)>>3) + yshift;
for(u32 x = 0; x < 240u; ++x) {
} else {
u16 *screenSource = screenBase + 0x400*(xxx>>8)+((xxx&255)>>3) +
yshift;
for(int x = 0; x < 240; x++) {
u16 data = READ16LE(screenSource);
int tile = data & 0x3FF;
@ -191,7 +192,7 @@ static inline void gfxDrawTextScreen(u16 control, u16 hofs, u16 vofs,
int tileY = yyy & 7;
if(tileX == 7)
++screenSource;
screenSource++;
if(data & 0x0400)
tileX = 7 - tileX;
@ -201,7 +202,7 @@ static inline void gfxDrawTextScreen(u16 control, u16 hofs, u16 vofs,
u8 color = charBase[(tile<<5) + (tileY<<2) + (tileX>>1)];
if(tileX & 1) {
color >>= 4;
color = (color >> 4);
} else {
color &= 0x0F;
}
@ -209,7 +210,7 @@ static inline void gfxDrawTextScreen(u16 control, u16 hofs, u16 vofs,
int pal = (data>>8) & 0xF0;
line[x] = color ? (READ16LE(&palette[pal + color])|prio): 0x80000000;
++xxx;
xxx++;
if(xxx == 256) {
if(sizeX > 256)
screenSource = screenBase + 0x400 + yshift;
@ -226,12 +227,12 @@ static inline void gfxDrawTextScreen(u16 control, u16 hofs, u16 vofs,
if(mosaicOn) {
if(mosaicX > 1) {
int m = 1;
for(u32 i = 0; i < 239u; ++i) {
for(int i = 0; i < 239; i++) {
line[i+1] = line[i];
++m;
m++;
if(m == mosaicX) {
m = 1;
++i;
i++;
}
}
}
@ -248,12 +249,12 @@ static inline void gfxDrawRotScreen(u16 control,
u32 *line)
{
u16 *palette = (u16 *)paletteRAM;
u8 *charBase = &vram[((control >> 2) & 0x03) << 14];
u8 *screenBase = (u8 *)&vram[((control >> 8) & 0x1f) << 11];
u8 *charBase = &vram[((control >> 2) & 0x03) * 0x4000];
u8 *screenBase = (u8 *)&vram[((control >> 8) & 0x1f) * 0x800];
int prio = ((control & 3) << 25) + 0x1000000;
u32 sizeX = 128;
u32 sizeY = 128;
int sizeX = 128;
int sizeY = 128;
switch((control >> 14) & 3) {
case 0:
break;
@ -316,7 +317,7 @@ static inline void gfxDrawRotScreen(u16 control,
}
if(control & 0x2000) {
for(u32 x = 0; x < 240u; ++x) {
for(int x = 0; x < 240; x++) {
int xxx = (realX >> 8) & maskX;
int yyy = (realY >> 8) & maskY;
@ -333,12 +334,17 @@ static inline void gfxDrawRotScreen(u16 control,
realY += dy;
}
} else {
for(u32 x = 0; x < 240u; ++x) {
for(int x = 0; x < 240; x++) {
int xxx = (realX >> 8);
int yyy = (realY >> 8);
if(unsigned(xxx) < sizeX && unsigned(yyy) < sizeY) {
int tile = screenBase[(xxx>>3) + ((yyy>>3)<<yshift)];
if(xxx < 0 ||
yyy < 0 ||
xxx >= sizeX ||
yyy >= sizeY) {
line[x] = 0x80000000;
} else {
int tile = screenBase[(xxx>>3) + ((yyy>>3)<<yshift)];
int tileX = (xxx & 7);
int tileY = yyy & 7;
@ -346,8 +352,6 @@ static inline void gfxDrawRotScreen(u16 control,
u8 color = charBase[(tile<<6) + (tileY<<3) + tileX];
line[x] = color ? (READ16LE(&palette[color])|prio): 0x80000000;
} else {
line[x] = 0x80000000;
}
realX += dx;
realY += dy;
@ -358,12 +362,12 @@ static inline void gfxDrawRotScreen(u16 control,
int mosaicX = (MOSAIC & 0xF) + 1;
if(mosaicX > 1) {
int m = 1;
for(u32 i = 0; i < 239u; ++i) {
for(int i = 0; i < 239; i++) {
line[i+1] = line[i];
++m;
m++;
if(m == mosaicX) {
m = 1;
++i;
i++;
}
}
}
@ -381,9 +385,8 @@ static inline void gfxDrawRotScreen16Bit(u16 control,
{
u16 *screenBase = (u16 *)&vram[0];
int prio = ((control & 3) << 25) + 0x1000000;
u32 sizeX = 240;
u32 sizeY = 160;
int sizeX = 240;
int sizeY = 160;
int startX = (x_l) | ((x_h & 0x07FF)<<16);
if(x_h & 0x0800)
@ -436,13 +439,15 @@ static inline void gfxDrawRotScreen16Bit(u16 control,
int xxx = (realX >> 8);
int yyy = (realY >> 8);
for(u32 x = 0; x < 240u; ++x) {
if(unsigned(xxx) < sizeX && unsigned(yyy) < sizeY) {
line[x] = (READ16LE(&screenBase[yyy * sizeX + xxx]) | prio);
for(int x = 0; x < 240; x++) {
if(xxx < 0 ||
yyy < 0 ||
xxx >= sizeX ||
yyy >= sizeY) {
line[x] = 0x80000000;
} else {
line[x] = 0x80000000;
line[x] = (READ16LE(&screenBase[yyy * sizeX + xxx]) | prio);
}
realX += dx;
realY += dy;
@ -454,12 +459,12 @@ static inline void gfxDrawRotScreen16Bit(u16 control,
int mosaicX = (MOSAIC & 0xF) + 1;
if(mosaicX > 1) {
int m = 1;
for(u32 i = 0; i < 239u; ++i) {
for(int i = 0; i < 239; i++) {
line[i+1] = line[i];
++m;
m++;
if(m == mosaicX) {
m = 1;
++i;
i++;
}
}
}
@ -478,8 +483,8 @@ static inline void gfxDrawRotScreen256(u16 control,
u16 *palette = (u16 *)paletteRAM;
u8 *screenBase = (DISPCNT & 0x0010) ? &vram[0xA000] : &vram[0x0000];
int prio = ((control & 3) << 25) + 0x1000000;
u32 sizeX = 240;
u32 sizeY = 160;
int sizeX = 240;
int sizeY = 160;
int startX = (x_l) | ((x_h & 0x07FF)<<16);
if(x_h & 0x0800)
@ -533,12 +538,16 @@ static inline void gfxDrawRotScreen256(u16 control,
int xxx = (realX >> 8);
int yyy = (realY >> 8);
for(u32 x = 0; x < 240; ++x) {
if(unsigned(xxx) < sizeX && unsigned(yyy) < sizeY) {
u8 color = screenBase[yyy * 240 + xxx];
line[x] = color ? (READ16LE(&palette[color])|prio): 0x80000000;
} else {
for(int x = 0; x < 240; x++) {
if(xxx < 0 ||
yyy < 0 ||
xxx >= sizeX ||
yyy >= sizeY) {
line[x] = 0x80000000;
} else {
u8 color = screenBase[yyy * 240 + xxx];
line[x] = color ? (READ16LE(&palette[color])|prio): 0x80000000;
}
realX += dx;
realY += dy;
@ -551,12 +560,12 @@ static inline void gfxDrawRotScreen256(u16 control,
int mosaicX = (MOSAIC & 0xF) + 1;
if(mosaicX > 1) {
int m = 1;
for(u32 i = 0; i < 239u; ++i) {
for(int i = 0; i < 239; i++) {
line[i+1] = line[i];
++m;
m++;
if(m == mosaicX) {
m = 1;
++i;
i++;
}
}
}
@ -575,8 +584,8 @@ static inline void gfxDrawRotScreen16Bit160(u16 control,
u16 *screenBase = (DISPCNT & 0x0010) ? (u16 *)&vram[0xa000] :
(u16 *)&vram[0];
int prio = ((control & 3) << 25) + 0x1000000;
u32 sizeX = 160;
u32 sizeY = 128;
int sizeX = 160;
int sizeY = 128;
int startX = (x_l) | ((x_h & 0x07FF)<<16);
if(x_h & 0x0800)
@ -630,11 +639,14 @@ static inline void gfxDrawRotScreen16Bit160(u16 control,
int xxx = (realX >> 8);
int yyy = (realY >> 8);
for(u32 x = 0; x < 240u; ++x) {
if(unsigned(xxx) < sizeX && unsigned(yyy) < sizeY) {
line[x] = (READ16LE(&screenBase[yyy * sizeX + xxx]) | prio);
} else {
for(int x = 0; x < 240; x++) {
if(xxx < 0 ||
yyy < 0 ||
xxx >= sizeX ||
yyy >= sizeY) {
line[x] = 0x80000000;
} else {
line[x] = (READ16LE(&screenBase[yyy * sizeX + xxx]) | prio);
}
realX += dx;
realY += dy;
@ -647,12 +659,12 @@ static inline void gfxDrawRotScreen16Bit160(u16 control,
int mosaicX = (MOSAIC & 0xF) + 1;
if(mosaicX > 1) {
int m = 1;
for(u32 i = 0; i < 239u; ++i) {
for(int i = 0; i < 239; i++) {
line[i+1] = line[i];
++m;
m++;
if(m == mosaicX) {
m = 1;
++i;
i++;
}
}
}
@ -672,11 +684,11 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
u16 *spritePalette = &((u16 *)paletteRAM)[256];
int mosaicY = ((MOSAIC & 0xF000)>>12) + 1;
int mosaicX = ((MOSAIC & 0xF00)>>8) + 1;
for(u32 x = 0; x < 128u; ++x) {
for(int x = 0; x < 128 ; x++) {
u16 a0 = READ16LE(sprites++);
u16 a1 = READ16LE(sprites++);
u16 a2 = READ16LE(sprites++);
++sprites;
sprites++;
lineOBJpixleft[x]=lineOBJpix;
@ -693,8 +705,8 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
a1 &= 0x3FFF;
}
u32 sizeX = 8<<(a1>>14);
u32 sizeY = sizeX;
int sizeX = 8<<(a1>>14);
int sizeY = sizeX;
if ((a0>>14) & 1)
{
@ -730,7 +742,7 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
if((sy+sizeY) > 256)
sy -= 256;
if ((sx+sizeX)> 512)
sx -= 512;
sx-=512;
if (sx<0)
{
sizeX+=sx;
@ -740,10 +752,10 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
sizeX=240-sx;
if ((VCOUNT>=sy) && (VCOUNT<sy+sizeY) && (sx<240))
{
lineOBJpix -= (sizeX-2);
if (a0 & 0x0100)
lineOBJpix -= (10+sizeX);
if (a0 & 0x0100)
lineOBJpix-=8+2*sizeX;
else
lineOBJpix-=sizeX-2;
}
continue;
}
@ -755,9 +767,11 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
if (lineOBJpix<0)
continue;
if(a0 & 0x0100) {
u32 fieldX = sizeX;
u32 fieldY = sizeY;
int fieldX = sizeX;
int fieldY = sizeY;
if(a0 & 0x0200) {
fieldX <<= 1;
fieldY <<= 1;
@ -765,8 +779,8 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
if((sy+fieldY) > 256)
sy -= 256;
int t = VCOUNT - sy;
if(unsigned(t) < fieldY) {
u32 startpix = 0;
if((t >= 0) && (t < fieldY)) {
int startpix = 0;
if ((sx+fieldX)> 512)
{
startpix=512-sx;
@ -775,18 +789,18 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
if((sx < 240) || startpix) {
lineOBJpix-=8;
// int t2 = t - (fieldY >> 1);
int rot = (((a1 >> 9) & 0x1F) << 4);
int rot = (a1 >> 9) & 0x1F;
u16 *OAM = (u16 *)oam;
int dx = READ16LE(&OAM[3 + rot]);
int dx = READ16LE(&OAM[3 + (rot << 4)]);
if(dx & 0x8000)
dx |= 0xFFFF8000;
int dmx = READ16LE(&OAM[7 + rot]);
int dmx = READ16LE(&OAM[7 + (rot << 4)]);
if(dmx & 0x8000)
dmx |= 0xFFFF8000;
int dy = READ16LE(&OAM[11 + rot]);
int dy = READ16LE(&OAM[11 + (rot << 4)]);
if(dy & 0x8000)
dy |= 0xFFFF8000;
int dmy = READ16LE(&OAM[15 + rot]);
int dmy = READ16LE(&OAM[15 + (rot << 4)]);
if(dmy & 0x8000)
dmy |= 0xFFFF8000;
@ -794,8 +808,10 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
t -= (t % mosaicY);
}
int realX = ((sizeX) << 7) - (fieldX >> 1)*dx + ((t - (fieldY>>1))* dmx);
int realY = ((sizeY) << 7) - (fieldX >> 1)*dy + ((t - (fieldY>>1))* dmy);
int realX = ((sizeX) << 7) - (fieldX >> 1)*dx - (fieldY>>1)*dmx
+ t * dmx;
int realY = ((sizeY) << 7) - (fieldX >> 1)*dy - (fieldY>>1)*dmy
+ t * dmy;
u32 prio = (((a2 >> 10) & 3) << 25) | ((a0 & 0x0c00)<<6);
@ -808,16 +824,18 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
inc = sizeX >> 2;
else
c &= 0x3FE;
for(u32 x = 0; x < fieldX; x++) {
for(int x = 0; x < fieldX; x++) {
if (x >= startpix)
lineOBJpix-=2;
if (lineOBJpix<0)
continue;
int xxx = realX >> 8;
int yyy = realY >> 8;
if(unsigned(xxx) < sizeX &&
unsigned(yyy) < sizeY && sx < 240){
if(xxx < 0 || xxx >= sizeX ||
yyy < 0 || yyy >= sizeY ||
sx >= 240);
else {
u32 color = vram[0x10000 + ((((c + (yyy>>3) * inc)<<5)
+ ((yyy & 7)<<3) + ((xxx >> 3)<<6) +
(xxx & 7))&0x7FFF)];
@ -833,7 +851,7 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
}
if (a0 & 0x1000) {
++m;
m++;
if (m==mosaicX)
m=0;
}
@ -855,19 +873,20 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
if(DISPCNT & 0x40)
inc = sizeX >> 3;
int palette = (a2 >> 8) & 0xF0;
for(u32 x = 0; x < fieldX; ++x) {
for(int x = 0; x < fieldX; x++) {
if (x >= startpix)
lineOBJpix-=2;
if (lineOBJpix<0)
continue;
int xxx = realX >> 8;
int yyy = realY >> 8;
if(unsigned(xxx) < sizeX &&
unsigned(yyy) < sizeY && sx < 240){
if(xxx < 0 || xxx >= sizeX ||
yyy < 0 || yyy >= sizeY ||
sx >= 240);
else {
u32 color = vram[0x10000 + ((((c + (yyy>>3) * inc)<<5)
+ ((yyy & 7)<<2) + ((xxx >> 3)<<5)
+ ((xxx & 7)>>1))&0x7FFF)];
+ ((yyy & 7)<<2) + ((xxx >> 3)<<5) +
((xxx & 7)>>1))&0x7FFF)];
if(xxx & 1)
color >>= 4;
else
@ -885,7 +904,7 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
}
}
if((a0 & 0x1000) && m) {
++m;
m++;
if (m==mosaicX)
m=0;
}
@ -906,8 +925,8 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
if(sy+sizeY > 256)
sy -= 256;
int t = VCOUNT - sy;
if(unsigned(t) < sizeY) {
u32 startpix = 0;
if((t >= 0) && (t < sizeY)) {
int startpix = 0;
if ((sx+sizeX)> 512)
{
startpix=512-sx;
@ -942,9 +961,9 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
xxx = 7;
u32 prio = (((a2 >> 10) & 3) << 25) | ((a0 & 0x0c00)<<6);
for(u32 xx = 0; xx < sizeX; xx++) {
for(int xx = 0; xx < sizeX; xx++) {
if (xx >= startpix)
--lineOBJpix;
lineOBJpix--;
if (lineOBJpix<0)
continue;
if(sx < 240) {
@ -961,7 +980,7 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
}
if (a0 & 0x1000) {
++m;
m++;
if (m==mosaicX)
m=0;
}
@ -974,8 +993,8 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
sx = (sx+1) & 511;
if(a1 & 0x1000) {
--xxx;
--address;
xxx--;
address--;
if(xxx == -1) {
address -= 56;
xxx = 7;
@ -983,8 +1002,8 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
if(address < 0x10000)
address += 0x8000;
} else {
++xxx;
++address;
xxx++;
address++;
if(xxx == 8) {
address += 56;
xxx = 0;
@ -1018,16 +1037,15 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
int palette = (a2 >> 8) & 0xF0;
if(a1 & 0x1000) {
xxx = 7;
int xx = sizeX - 1;
do{
if (xx >= (int)(startpix))
--lineOBJpix;
for(int xx = sizeX - 1; xx >= 0; xx--) {
if (xx >= startpix)
lineOBJpix--;
if (lineOBJpix<0)
continue;
if(sx < 240) {
u8 color = vram[address];
if(xx & 1) {
color >>= 4;
color = (color >> 4);
} else
color &= 0x0F;
@ -1043,7 +1061,7 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
}
}
if (a0 & 0x1000) {
++m;
m++;
if (m==mosaicX)
m=0;
}
@ -1052,27 +1070,26 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
lineOBJ[sx] = 0x001F;
#endif
sx = (sx+1) & 511;
--xxx;
xxx--;
if(!(xx & 1))
--address;
address--;
if(xxx == -1) {
xxx = 7;
address -= 28;
}
if(address < 0x10000)
address += 0x8000;
--xx;
}while(xx >= 0);
}
} else {
for(u32 xx = 0; xx < sizeX; ++xx) {
for(int xx = 0; xx < sizeX; xx++) {
if (xx >= startpix)
--lineOBJpix;
lineOBJpix--;
if (lineOBJpix<0)
continue;
if(sx < 240) {
u8 color = vram[address];
if(xx & 1) {
color >>= 4;
color = (color >> 4);
} else
color &= 0x0F;
@ -1089,7 +1106,7 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
}
}
if (a0 & 0x1000) {
++m;
m++;
if (m==mosaicX)
m=0;
}
@ -1098,9 +1115,9 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
lineOBJ[sx] = 0x001F;
#endif
sx = (sx+1) & 511;
++xxx;
xxx++;
if(xx & 1)
++address;
address++;
if(xxx == 8) {
address += 28;
xxx = 0;
@ -1123,12 +1140,12 @@ static inline void gfxDrawOBJWin(u32 *lineOBJWin)
if((layerEnable & 0x9000) == 0x9000) {
u16 *sprites = (u16 *)oam;
// u16 *spritePalette = &((u16 *)paletteRAM)[256];
for(int x = 0; x < 128 ; ++x) {
for(int x = 0; x < 128 ; x++) {
int lineOBJpix = lineOBJpixleft[x];
u16 a0 = READ16LE(sprites++);
u16 a1 = READ16LE(sprites++);
u16 a2 = READ16LE(sprites++);
++sprites;
sprites++;
if (lineOBJpix<=0)
continue;
@ -1146,8 +1163,8 @@ static inline void gfxDrawOBJWin(u32 *lineOBJWin)
a1 &= 0x3FFF;
}
u32 sizeX = 8<<(a1>>14);
u32 sizeY = sizeX;
int sizeX = 8<<(a1>>14);
int sizeY = sizeX;
if ((a0>>14) & 1)
{
@ -1168,7 +1185,7 @@ static inline void gfxDrawOBJWin(u32 *lineOBJWin)
if(a0 & 0x0100) {
int fieldX = sizeX;
u32 fieldY = sizeY;
int fieldY = sizeY;
if(a0 & 0x0200) {
fieldX <<= 1;
fieldY <<= 1;
@ -1176,7 +1193,7 @@ static inline void gfxDrawOBJWin(u32 *lineOBJWin)
if((sy+fieldY) > 256)
sy -= 256;
int t = VCOUNT - sy;
if(unsigned(t) < fieldY) {
if((t >= 0) && (t < fieldY)) {
int sx = (a1 & 0x1FF);
int startpix = 0;
if ((sx+fieldX)> 512)
@ -1186,23 +1203,25 @@ static inline void gfxDrawOBJWin(u32 *lineOBJWin)
if((sx < 240) || startpix) {
lineOBJpix-=8;
// int t2 = t - (fieldY >> 1);
int rot = ((a1 >> 9) & 0x1F) << 4;
int rot = (a1 >> 9) & 0x1F;
u16 *OAM = (u16 *)oam;
int dx = READ16LE(&OAM[3 + rot]);
int dx = READ16LE(&OAM[3 + (rot << 4)]);
if(dx & 0x8000)
dx |= 0xFFFF8000;
int dmx = READ16LE(&OAM[7 + rot]);
int dmx = READ16LE(&OAM[7 + (rot << 4)]);
if(dmx & 0x8000)
dmx |= 0xFFFF8000;
int dy = READ16LE(&OAM[11 + rot]);
int dy = READ16LE(&OAM[11 + (rot << 4)]);
if(dy & 0x8000)
dy |= 0xFFFF8000;
int dmy = READ16LE(&OAM[15 + rot]);
int dmy = READ16LE(&OAM[15 + (rot << 4)]);
if(dmy & 0x8000)
dmy |= 0xFFFF8000;
int realX = ((sizeX) << 7) - (fieldX >> 1)*dx + (dmx*(t - (fieldY>>1)));
int realY = ((sizeY) << 7) - (fieldX >> 1)*dy + (dmy*(t - (fieldY>>1)));
int realX = ((sizeX) << 7) - (fieldX >> 1)*dx - (fieldY>>1)*dmx
+ t * dmx;
int realY = ((sizeY) << 7) - (fieldX >> 1)*dy - (fieldY>>1)*dmy
+ t * dmy;
// u32 prio = (((a2 >> 10) & 3) << 25) | ((a0 & 0x0c00)<<6);
@ -1215,7 +1234,7 @@ static inline void gfxDrawOBJWin(u32 *lineOBJWin)
inc = sizeX >> 2;
else
c &= 0x3FE;
for(int x = 0; x < fieldX; ++x) {
for(int x = 0; x < fieldX; x++) {
if (x >= startpix)
lineOBJpix-=2;
if (lineOBJpix<0)
@ -1223,9 +1242,10 @@ static inline void gfxDrawOBJWin(u32 *lineOBJWin)
int xxx = realX >> 8;
int yyy = realY >> 8;
if(unsigned(xxx) < sizeX &&
unsigned(yyy) < sizeY && sx < 240){
if(xxx < 0 || xxx >= sizeX ||
yyy < 0 || yyy >= sizeY ||
sx >= 240) {
} else {
u32 color = vram[0x10000 + ((((c + (yyy>>3) * inc)<<5)
+ ((yyy & 7)<<3) + ((xxx >> 3)<<6) +
(xxx & 7))&0x7fff)];
@ -1246,7 +1266,7 @@ static inline void gfxDrawOBJWin(u32 *lineOBJWin)
if(DISPCNT & 0x40)
inc = sizeX >> 3;
// int palette = (a2 >> 8) & 0xF0;
for(int x = 0; x < fieldX; ++x) {
for(int x = 0; x < fieldX; x++) {
if (x >= startpix)
lineOBJpix-=2;
if (lineOBJpix<0)
@ -1258,9 +1278,10 @@ static inline void gfxDrawOBJWin(u32 *lineOBJWin)
// t == 0 || t == (sizeY-1)) {
// lineOBJ[sx] = 0x001F | prio;
// } else {
if(unsigned(xxx) < sizeX &&
unsigned(yyy) < sizeY && sx < 240){
if(xxx < 0 || xxx >= sizeX ||
yyy < 0 || yyy >= sizeY ||
sx >= 240) {
} else {
u32 color = vram[0x10000 + ((((c + (yyy>>3) * inc)<<5)
+ ((yyy & 7)<<2) + ((xxx >> 3)<<5) +
((xxx & 7)>>1))&0x7fff)];
@ -1285,9 +1306,9 @@ static inline void gfxDrawOBJWin(u32 *lineOBJWin)
if((sy+sizeY) > 256)
sy -= 256;
int t = VCOUNT - sy;
if(unsigned(t) < sizeY) {
if((t >= 0) && (t < sizeY)) {
int sx = (a1 & 0x1FF);
u32 startpix = 0;
int startpix = 0;
if ((sx+sizeX)> 512)
{
startpix=512-sx;
@ -1315,9 +1336,9 @@ static inline void gfxDrawOBJWin(u32 *lineOBJWin)
if(a1 & 0x1000)
xxx = 7;
// u32 prio = (((a2 >> 10) & 3) << 25) | ((a0 & 0x0c00)<<6);
for(u32 xx = 0; xx < sizeX; ++xx) {
for(int xx = 0; xx < sizeX; xx++) {
if (xx >= startpix)
--lineOBJpix;
lineOBJpix--;
if (lineOBJpix<0)
continue;
if(sx < 240) {
@ -1329,8 +1350,8 @@ static inline void gfxDrawOBJWin(u32 *lineOBJWin)
sx = (sx+1) & 511;
if(a1 & 0x1000) {
--xxx;
--address;
xxx--;
address--;
if(xxx == -1) {
address -= 56;
xxx = 7;
@ -1338,8 +1359,8 @@ static inline void gfxDrawOBJWin(u32 *lineOBJWin)
if(address < 0x10000)
address += 0x8000;
} else {
++xxx;
++address;
xxx++;
address++;
if(xxx == 8) {
address += 56;
xxx = 0;
@ -1368,10 +1389,9 @@ static inline void gfxDrawOBJWin(u32 *lineOBJWin)
// int palette = (a2 >> 8) & 0xF0;
if(a1 & 0x1000) {
xxx = 7;
int xx = sizeX - 1;
do{
if (xx >= (int)(startpix))
--lineOBJpix;
for(int xx = sizeX - 1; xx >= 0; xx--) {
if (xx >= startpix)
lineOBJpix--;
if (lineOBJpix<0)
continue;
if(sx < 240) {
@ -1386,27 +1406,26 @@ static inline void gfxDrawOBJWin(u32 *lineOBJWin)
}
}
sx = (sx+1) & 511;
--xxx;
xxx--;
if(!(xx & 1))
--address;
address--;
if(xxx == -1) {
xxx = 7;
address -= 28;
}
if(address < 0x10000)
address += 0x8000;
--xx;
}while(xx >= 0);
}
} else {
for(u32 xx = 0; xx < sizeX; ++xx) {
for(int xx = 0; xx < sizeX; xx++) {
if (xx >= startpix)
--lineOBJpix;
lineOBJpix--;
if (lineOBJpix<0)
continue;
if(sx < 240) {
u8 color = vram[address];
if(xx & 1) {
color >>= 4;
color = (color >> 4);
} else
color &= 0x0F;
@ -1415,9 +1434,9 @@ static inline void gfxDrawOBJWin(u32 *lineOBJWin)
}
}
sx = (sx+1) & 511;
++xxx;
xxx++;
if(xx & 1)
++address;
address++;
if(xxx == 8) {
address += 28;
xxx = 0;
@ -1439,7 +1458,7 @@ static inline u32 gfxIncreaseBrightness(u32 color, int coeff)
color &= 0xffff;
color = ((color << 16) | color) & 0x3E07C1F;
color += (((0x3E07C1F - color) * coeff) >> 4);
color = color + (((0x3E07C1F - color) * coeff) >> 4);
color &= 0x3E07C1F;
return (color >> 16) | color;
@ -1447,16 +1466,15 @@ static inline u32 gfxIncreaseBrightness(u32 color, int coeff)
static inline void gfxIncreaseBrightness(u32 *line, int coeff)
{
for(u32 x = 0; x < 240u; ++x) {
for(int x = 0; x < 240; x++) {
u32 color = *line;
int r = (color & 0x1F);
int g = ((color >> 5) & 0x1F);
int b = ((color >> 10) & 0x1F);
r += (((31 - r) * coeff) >> 4);
g += (((31 - g) * coeff) >> 4);
b += (((31 - b) * coeff) >> 4);
r = r + (((31 - r) * coeff) >> 4);
g = g + (((31 - g) * coeff) >> 4);
b = b + (((31 - b) * coeff) >> 4);
if(r > 31)
r = 31;
if(g > 31)
@ -1472,22 +1490,22 @@ static inline u32 gfxDecreaseBrightness(u32 color, int coeff)
color &= 0xffff;
color = ((color << 16) | color) & 0x3E07C1F;
color -= (((color * coeff) >> 4) & 0x3E07C1F);
color = color - (((color * coeff) >> 4) & 0x3E07C1F);
return (color >> 16) | color;
}
static inline void gfxDecreaseBrightness(u32 *line, int coeff)
{
for(u32 x = 0; x < 240u; ++x) {
for(int x = 0; x < 240; x++) {
u32 color = *line;
int r = (color & 0x1F);
int g = ((color >> 5) & 0x1F);
int b = ((color >> 10) & 0x1F);
r -= ((r * coeff) >> 4);
g -= ((g * coeff) >> 4);
b -= ((b * coeff) >> 4);
r = r - ((r * coeff) >> 4);
g = g - ((g * coeff) >> 4);
b = b - ((b * coeff) >> 4);
if(r < 0)
r = 0;
if(g < 0)
@ -1526,7 +1544,7 @@ static inline u32 gfxAlphaBlend(u32 color, u32 color2, int ca, int cb)
static inline void gfxAlphaBlend(u32 *ta, u32 *tb, int ca, int cb)
{
for(u32 x = 0; x < 240u; ++x) {
for(int x = 0; x < 240; x++) {
u32 color = *ta;
if(color < 0x80000000) {
int r = (color & 0x1F);
@ -1550,8 +1568,8 @@ static inline void gfxAlphaBlend(u32 *ta, u32 *tb, int ca, int cb)
*ta++ = (color & 0xFFFF0000) | (b << 10) | (g << 5) | r;
} else {
++ta;
++tb;
ta++;
tb++;
}
}
}

View File

@ -155,7 +155,7 @@ inline int codeTicksAccess16(u32 address) // THUMB NON SEQ
{
int addr = (address>>24)&15;
if (unsigned(addr - 0x08) <= (0x0D - 0x08))
if ((addr>=0x08) && (addr<=0x0D))
{
if (busPrefetchCount&0x1)
{
@ -167,16 +167,24 @@ inline int codeTicksAccess16(u32 address) // THUMB NON SEQ
busPrefetchCount = ((busPrefetchCount&0xFF)>>1) | (busPrefetchCount&0xFFFFFF00);
return memoryWaitSeq[addr]-1;
}
else
{
busPrefetchCount=0;
return memoryWait[addr];
}
}
else
{
busPrefetchCount = 0;
return memoryWait[addr];
}
busPrefetchCount = 0;
return memoryWait[addr];
}
inline int codeTicksAccess32(u32 address) // ARM NON SEQ
{
int addr = (address>>24)&15;
if (unsigned(addr - 0x08) <= (0x0D - 0x08))
if ((addr>=0x08) && (addr<=0x0D))
{
if (busPrefetchCount&0x1)
{
@ -188,16 +196,24 @@ inline int codeTicksAccess32(u32 address) // ARM NON SEQ
busPrefetchCount = ((busPrefetchCount&0xFF)>>1) | (busPrefetchCount&0xFFFFFF00);
return memoryWaitSeq[addr] - 1;
}
else
{
busPrefetchCount = 0;
return memoryWait32[addr];
}
}
else
{
busPrefetchCount = 0;
return memoryWait32[addr];
}
}
inline int codeTicksAccessSeq16(u32 address) // THUMB SEQ
{
int addr = (address>>24)&15;
if (unsigned(addr - 0x08) <= (0x0D - 0x08))
if ((addr>=0x08) && (addr<=0x0D))
{
if (busPrefetchCount&0x1)
{
@ -210,20 +226,26 @@ inline int codeTicksAccessSeq16(u32 address) // THUMB SEQ
busPrefetchCount=0;
return memoryWait[addr];
}
else
return memoryWaitSeq[addr];
}
else{
else
{
busPrefetchCount = 0;
return memoryWaitSeq[addr];
}
return memoryWaitSeq[addr];
}
inline int codeTicksAccessSeq32(u32 address) // ARM SEQ
{
int addr = (address>>24)&15;
if (unsigned(addr - 0x08) <= (0x0D - 0x08)){
if (busPrefetchCount&0x1){
if (busPrefetchCount&0x2){
if ((addr>=0x08) && (addr<=0x0D))
{
if (busPrefetchCount&0x1)
{
if (busPrefetchCount&0x2)
{
busPrefetchCount = ((busPrefetchCount&0xFF)>>2) | (busPrefetchCount&0xFFFFFF00);
return 0;
}
@ -231,12 +253,18 @@ inline int codeTicksAccessSeq32(u32 address) // ARM SEQ
return memoryWaitSeq[addr];
}
else
if (busPrefetchCount>0xFF){
if (busPrefetchCount>0xFF)
{
busPrefetchCount=0;
return memoryWait32[addr];
}
else
return memoryWaitSeq32[addr];
}
else
{
return memoryWaitSeq32[addr];
}
return memoryWaitSeq32[addr];
}

View File

@ -329,7 +329,7 @@ int main(int argc, char *argv[])
// Initialize font system
InitFreeType((u8*)font_ttf, font_ttf_size);
gameScreenPng = (u8 *)malloc(50*1024);
InitGUIThreads();
// store path app was loaded from

View File

@ -122,7 +122,7 @@ bool systemPauseOnFrame()
}
static u32 lastTime = 0;
#define RATE60HZ 166666.67f // 1/6 second or 166666.67 usec
#define RATE60HZ 166666.67 // 1/6 second or 166666.67 usec
void system10Frames(int rate)
{
@ -130,14 +130,14 @@ void system10Frames(int rate)
u32 diff = diff_usec(lastTime, time);
// expected diff - actual diff
u32 timeOff = ftou(RATE60HZ - utof(diff));
u32 timeOff = RATE60HZ - diff;
if(timeOff < 100000u)
if(timeOff > 0 && timeOff < 100000) // we're running ahead!
usleep(timeOff); // let's take a nap
else
timeOff = 0; // timeoff was not valid
int speed = int((RATE60HZ/utof(diff))*100.0f);
int speed = (RATE60HZ/diff)*100;
if (cartridgeType == 2) // GBA games require frameskipping
{
@ -157,7 +157,7 @@ void system10Frames(int rate)
else if(speed > 145)
systemFrameSkip -= 2;
else if(speed > 125)
--systemFrameSkip;
systemFrameSkip -= 1;
// correct invalid frame skip values
if(systemFrameSkip > 20)
@ -349,35 +349,19 @@ bool SaveBatteryOrState(char * filepath, int action, bool silent)
bool result = false;
int offset = 0;
int datasize = 0; // we need the actual size of the data written
int imgSize = 0; // image screenshot bytes written
int device;
if(!FindDevice(filepath, &device))
return 0;
// save screenshot - I would prefer to do this from gameScreenTex
if(action == FILE_SNAPSHOT && gameScreenTex2 != NULL)
if(action == FILE_SNAPSHOT && gameScreenPngSize > 0)
{
AllocSaveBuffer ();
IMGCTX pngContext = PNGU_SelectImageFromBuffer(savebuffer);
if (pngContext != NULL)
{
imgSize = PNGU_EncodeFromGXTexture(pngContext, vmode->fbWidth, vmode->efbHeight, gameScreenTex2, 0);
PNGU_ReleaseImageContext(pngContext);
}
if(imgSize > 0)
{
char screenpath[1024];
strncpy(screenpath, filepath, 1024);
screenpath[strlen(screenpath)-4] = 0;
sprintf(screenpath, "%s.png", screenpath);
SaveFile(screenpath, imgSize, silent);
}
FreeSaveBuffer ();
char screenpath[1024];
strncpy(screenpath, filepath, 1024);
screenpath[strlen(screenpath)-4] = 0;
sprintf(screenpath, "%s.png", screenpath);
SaveFile((char *)gameScreenPng, screenpath, gameScreenPngSize, silent);
}
AllocSaveBuffer();

View File

@ -36,7 +36,8 @@ int whichfb = 0; // Frame buffer toggle
static Mtx GXmodelView2D;
u8 * gameScreenTex = NULL; // a GX texture screen capture of the game
u8 * gameScreenTex2 = NULL; // a GX texture screen capture of the game (copy)
u8 * gameScreenPng = NULL;
int gameScreenPngSize = 0;
int screenheight = 480;
int screenwidth = 640;
@ -680,15 +681,6 @@ void TakeScreenshot()
GX_CopyTex(gameScreenTex, GX_FALSE);
GX_PixModeSync();
DCFlushRange(gameScreenTex, texSize);
#ifdef HW_RVL
if(gameScreenTex2) free(gameScreenTex2);
gameScreenTex2 = (u8 *)memalign(32, texSize);
if(gameScreenTex2 == NULL) return;
GX_CopyTex(gameScreenTex2, GX_FALSE);
GX_PixModeSync();
DCFlushRange(gameScreenTex2, texSize);
#endif
}
/****************************************************************************

View File

@ -34,7 +34,8 @@ extern bool CursorValid;
extern bool TiltScreen;
extern float TiltAngle;
extern u8 * gameScreenTex;
extern u8 * gameScreenTex2;
extern u8 * gameScreenPng;
extern int gameScreenPngSize;
extern u32 FrameTimer;
#endif