From d18e3d710ce8982a15678137623e582444056c5d Mon Sep 17 00:00:00 2001 From: Crayon2000 Date: Sat, 10 Jun 2017 16:46:18 -0400 Subject: [PATCH] Reduce variable scope --- GRRLIB/GRRLIB/GRRLIB_bmf.c | 19 +++++++++---------- GRRLIB/GRRLIB/GRRLIB_print.c | 3 +-- GRRLIB/GRRLIB/GRRLIB_texEdit.c | 2 +- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/GRRLIB/GRRLIB/GRRLIB_bmf.c b/GRRLIB/GRRLIB/GRRLIB_bmf.c index 2c6e59d..596289d 100644 --- a/GRRLIB/GRRLIB/GRRLIB_bmf.c +++ b/GRRLIB/GRRLIB/GRRLIB_bmf.c @@ -35,21 +35,20 @@ THE SOFTWARE. GRRLIB_bytemapFont* GRRLIB_LoadBMF (const u8 my_bmf[] ) { GRRLIB_bytemapFont *fontArray = (struct GRRLIB_bytemapFont *)malloc(sizeof(GRRLIB_bytemapFont)); u32 i, j = 1; - u8 nbPalette, c/*, lineheight, usedcolors, highestcolor*/; - short int numcolpal/*, sizeover, sizeunder, sizeinner*/; + u8 c; u16 nbPixels; if (fontArray != NULL && my_bmf[0]==0xE1 && my_bmf[1]==0xE6 && my_bmf[2]==0xD5 && my_bmf[3]==0x1A) { fontArray->version = my_bmf[4]; - //lineheight = my_bmf[5]; - //sizeover = my_bmf[6]; - //sizeunder = my_bmf[7]; + //u8 lineheight = my_bmf[5]; + //short int sizeover = my_bmf[6]; + //short int sizeunder = my_bmf[7]; fontArray->tracking = my_bmf[8]; - //sizeinner = my_bmf[9]; - //usedcolors = my_bmf[10]; - //highestcolor = my_bmf[11]; - nbPalette = my_bmf[16]; - numcolpal = 3 * nbPalette; + //short int sizeinner = my_bmf[9]; + //u8 usedcolors = my_bmf[10]; + //u8 highestcolor = my_bmf[11]; + u8 nbPalette = my_bmf[16]; + short int numcolpal = 3 * nbPalette; fontArray->palette = (u32 *)calloc(nbPalette + 1, sizeof(u32)); for (i=0; i < numcolpal; i+=3) { fontArray->palette[j++] = ((((my_bmf[i+17]<<2)+3)<<24) | (((my_bmf[i+18]<<2)+3)<<16) | (((my_bmf[i+19]<<2)+3)<<8) | 0xFF); diff --git a/GRRLIB/GRRLIB/GRRLIB_print.c b/GRRLIB/GRRLIB/GRRLIB_print.c index 8dc3305..54d8ef4 100644 --- a/GRRLIB/GRRLIB/GRRLIB_print.c +++ b/GRRLIB/GRRLIB/GRRLIB_print.c @@ -71,7 +71,6 @@ void GRRLIB_PrintBMF (const f32 xpos, const f32 ypos, const GRRLIB_bytemapFont *bmf, const char *text, ...) { uint i, size; - u8 *pdata; u8 x, y; char tmp[1024]; f32 xoff = xpos; @@ -84,7 +83,7 @@ void GRRLIB_PrintBMF (const f32 xpos, const f32 ypos, for (i=0; icharDef[(u8)tmp[i]]; - pdata = pchar->data; + u8 *pdata = pchar->data; for (y=0; yheight; y++) { for (x=0; xwidth; x++) { if (*pdata) { diff --git a/GRRLIB/GRRLIB/GRRLIB_texEdit.c b/GRRLIB/GRRLIB/GRRLIB_texEdit.c index 0313dd7..d855165 100644 --- a/GRRLIB/GRRLIB/GRRLIB_texEdit.c +++ b/GRRLIB/GRRLIB/GRRLIB_texEdit.c @@ -206,7 +206,6 @@ static RGBQUAD* GRRLIB_CreatePalette (const u8 *my_bmp, u32 Size) { GRRLIB_texImg* GRRLIB_LoadTextureBMP (const u8 *my_bmp) { BITMAPFILEHEADER MyBitmapFileHeader; BITMAPINFOHEADER MyBitmapHeader; - RGBQUAD *Palette; u16 pal_ref; u32 BufferSize; s32 y, x, i; @@ -234,6 +233,7 @@ GRRLIB_texImg* GRRLIB_LoadTextureBMP (const u8 *my_bmp) { my_texture->data = memalign(32, MyBitmapHeader.biWidth * MyBitmapHeader.biHeight * 4); if (my_texture->data != NULL && MyBitmapFileHeader.bfType == 0x4D42) { + RGBQUAD *Palette; my_texture->w = MyBitmapHeader.biWidth; my_texture->h = MyBitmapHeader.biHeight; switch(MyBitmapHeader.biBitCount) {