mirror of
https://github.com/GRRLIB/GRRLIB.git
synced 2024-11-22 15:02:20 +00:00
Reduce some variables scope
This commit is contained in:
parent
a99985657a
commit
f28cbc3e94
3 changed files with 9 additions and 11 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
Copyright (c) 2009-2019 The GRRLIB Team
|
Copyright (c) 2009-2020 The GRRLIB Team
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -35,8 +35,6 @@ THE SOFTWARE.
|
||||||
GRRLIB_bytemapFont* GRRLIB_LoadBMF (const u8 my_bmf[] ) {
|
GRRLIB_bytemapFont* GRRLIB_LoadBMF (const u8 my_bmf[] ) {
|
||||||
GRRLIB_bytemapFont *fontArray = (struct GRRLIB_bytemapFont *)malloc(sizeof(GRRLIB_bytemapFont));
|
GRRLIB_bytemapFont *fontArray = (struct GRRLIB_bytemapFont *)malloc(sizeof(GRRLIB_bytemapFont));
|
||||||
u32 i, j = 1;
|
u32 i, j = 1;
|
||||||
u8 c;
|
|
||||||
u16 nbPixels;
|
|
||||||
|
|
||||||
if (fontArray != NULL && my_bmf[0]==0xE1 && my_bmf[1]==0xE6 && my_bmf[2]==0xD5 && my_bmf[3]==0x1A) {
|
if (fontArray != NULL && my_bmf[0]==0xE1 && my_bmf[1]==0xE6 && my_bmf[2]==0xD5 && my_bmf[3]==0x1A) {
|
||||||
fontArray->version = my_bmf[4];
|
fontArray->version = my_bmf[4];
|
||||||
|
@ -61,15 +59,15 @@ GRRLIB_bytemapFont* GRRLIB_LoadBMF (const u8 my_bmf[] ) {
|
||||||
memset(fontArray->charDef, 0, 256 * sizeof(GRRLIB_bytemapChar));
|
memset(fontArray->charDef, 0, 256 * sizeof(GRRLIB_bytemapChar));
|
||||||
j++;
|
j++;
|
||||||
for (i=0; i < fontArray->nbChar; i++) {
|
for (i=0; i < fontArray->nbChar; i++) {
|
||||||
c = my_bmf[++j];
|
const u8 c = my_bmf[++j];
|
||||||
fontArray->charDef[c].width = my_bmf[++j];
|
fontArray->charDef[c].width = my_bmf[++j];
|
||||||
fontArray->charDef[c].height = my_bmf[++j];
|
fontArray->charDef[c].height = my_bmf[++j];
|
||||||
fontArray->charDef[c].relx = my_bmf[++j];
|
fontArray->charDef[c].relx = my_bmf[++j];
|
||||||
fontArray->charDef[c].rely = my_bmf[++j];
|
fontArray->charDef[c].rely = my_bmf[++j];
|
||||||
fontArray->charDef[c].kerning = my_bmf[++j];
|
fontArray->charDef[c].kerning = my_bmf[++j];
|
||||||
nbPixels = fontArray->charDef[c].width * fontArray->charDef[c].height;
|
const u16 nbPixels = fontArray->charDef[c].width * fontArray->charDef[c].height;
|
||||||
fontArray->charDef[c].data = (u8 *)malloc(nbPixels);
|
fontArray->charDef[c].data = (u8 *)malloc(nbPixels);
|
||||||
if (nbPixels && fontArray->charDef[c].data) {
|
if (nbPixels > 0 && fontArray->charDef[c].data != NULL) {
|
||||||
memcpy(fontArray->charDef[c].data, &my_bmf[++j], nbPixels);
|
memcpy(fontArray->charDef[c].data, &my_bmf[++j], nbPixels);
|
||||||
j += (nbPixels - 1);
|
j += (nbPixels - 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
Copyright (c) 2009-2017 The GRRLIB Team
|
Copyright (c) 2009-2020 The GRRLIB Team
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -55,7 +55,7 @@ int GRRLIB_LoadFile(const char* filename, u8* *data) {
|
||||||
fseek(fd, 0, SEEK_SET);
|
fseek(fd, 0, SEEK_SET);
|
||||||
|
|
||||||
// Grab some memory in which to store the file
|
// Grab some memory in which to store the file
|
||||||
if ( !(*data = malloc(len)) ) {
|
if ( (*data = malloc(len)) == NULL ) {
|
||||||
fclose(fd);
|
fclose(fd);
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
@ -103,10 +103,10 @@ GRRLIB_texImg* GRRLIB_LoadTextureFromFile(const char *filename) {
|
||||||
* @return bool true=everything worked, false=problems occurred.
|
* @return bool true=everything worked, false=problems occurred.
|
||||||
*/
|
*/
|
||||||
bool GRRLIB_ScrShot(const char* filename) {
|
bool GRRLIB_ScrShot(const char* filename) {
|
||||||
IMGCTX pngContext;
|
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
IMGCTX pngContext = PNGU_SelectImageFromDevice(filename);
|
||||||
|
|
||||||
if ( (pngContext = PNGU_SelectImageFromDevice(filename)) ) {
|
if ( pngContext != NULL ) {
|
||||||
ret = PNGU_EncodeFromEFB( pngContext,
|
ret = PNGU_EncodeFromEFB( pngContext,
|
||||||
rmode->fbWidth, rmode->efbHeight,
|
rmode->fbWidth, rmode->efbHeight,
|
||||||
0 );
|
0 );
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
Copyright (c) 2009-2019 The GRRLIB Team
|
Copyright (c) 2009-2020 The GRRLIB Team
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|
Loading…
Reference in a new issue