mirror of
https://github.com/GRRLIB/GRRLIB.git
synced 2024-11-26 00:32:20 +00:00
Reduce variable scope
This commit is contained in:
parent
41506eab88
commit
d18e3d710c
3 changed files with 11 additions and 13 deletions
|
@ -35,21 +35,20 @@ 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 nbPalette, c/*, lineheight, usedcolors, highestcolor*/;
|
u8 c;
|
||||||
short int numcolpal/*, sizeover, sizeunder, sizeinner*/;
|
|
||||||
u16 nbPixels;
|
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];
|
||||||
//lineheight = my_bmf[5];
|
//u8 lineheight = my_bmf[5];
|
||||||
//sizeover = my_bmf[6];
|
//short int sizeover = my_bmf[6];
|
||||||
//sizeunder = my_bmf[7];
|
//short int sizeunder = my_bmf[7];
|
||||||
fontArray->tracking = my_bmf[8];
|
fontArray->tracking = my_bmf[8];
|
||||||
//sizeinner = my_bmf[9];
|
//short int sizeinner = my_bmf[9];
|
||||||
//usedcolors = my_bmf[10];
|
//u8 usedcolors = my_bmf[10];
|
||||||
//highestcolor = my_bmf[11];
|
//u8 highestcolor = my_bmf[11];
|
||||||
nbPalette = my_bmf[16];
|
u8 nbPalette = my_bmf[16];
|
||||||
numcolpal = 3 * nbPalette;
|
short int numcolpal = 3 * nbPalette;
|
||||||
fontArray->palette = (u32 *)calloc(nbPalette + 1, sizeof(u32));
|
fontArray->palette = (u32 *)calloc(nbPalette + 1, sizeof(u32));
|
||||||
for (i=0; i < numcolpal; i+=3) {
|
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);
|
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);
|
||||||
|
|
|
@ -71,7 +71,6 @@ void GRRLIB_PrintBMF (const f32 xpos, const f32 ypos,
|
||||||
const GRRLIB_bytemapFont *bmf,
|
const GRRLIB_bytemapFont *bmf,
|
||||||
const char *text, ...) {
|
const char *text, ...) {
|
||||||
uint i, size;
|
uint i, size;
|
||||||
u8 *pdata;
|
|
||||||
u8 x, y;
|
u8 x, y;
|
||||||
char tmp[1024];
|
char tmp[1024];
|
||||||
f32 xoff = xpos;
|
f32 xoff = xpos;
|
||||||
|
@ -84,7 +83,7 @@ void GRRLIB_PrintBMF (const f32 xpos, const f32 ypos,
|
||||||
|
|
||||||
for (i=0; i<size; i++) {
|
for (i=0; i<size; i++) {
|
||||||
pchar = &bmf->charDef[(u8)tmp[i]];
|
pchar = &bmf->charDef[(u8)tmp[i]];
|
||||||
pdata = pchar->data;
|
u8 *pdata = pchar->data;
|
||||||
for (y=0; y<pchar->height; y++) {
|
for (y=0; y<pchar->height; y++) {
|
||||||
for (x=0; x<pchar->width; x++) {
|
for (x=0; x<pchar->width; x++) {
|
||||||
if (*pdata) {
|
if (*pdata) {
|
||||||
|
|
|
@ -206,7 +206,6 @@ static RGBQUAD* GRRLIB_CreatePalette (const u8 *my_bmp, u32 Size) {
|
||||||
GRRLIB_texImg* GRRLIB_LoadTextureBMP (const u8 *my_bmp) {
|
GRRLIB_texImg* GRRLIB_LoadTextureBMP (const u8 *my_bmp) {
|
||||||
BITMAPFILEHEADER MyBitmapFileHeader;
|
BITMAPFILEHEADER MyBitmapFileHeader;
|
||||||
BITMAPINFOHEADER MyBitmapHeader;
|
BITMAPINFOHEADER MyBitmapHeader;
|
||||||
RGBQUAD *Palette;
|
|
||||||
u16 pal_ref;
|
u16 pal_ref;
|
||||||
u32 BufferSize;
|
u32 BufferSize;
|
||||||
s32 y, x, i;
|
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);
|
my_texture->data = memalign(32, MyBitmapHeader.biWidth * MyBitmapHeader.biHeight * 4);
|
||||||
if (my_texture->data != NULL && MyBitmapFileHeader.bfType == 0x4D42) {
|
if (my_texture->data != NULL && MyBitmapFileHeader.bfType == 0x4D42) {
|
||||||
|
RGBQUAD *Palette;
|
||||||
my_texture->w = MyBitmapHeader.biWidth;
|
my_texture->w = MyBitmapHeader.biWidth;
|
||||||
my_texture->h = MyBitmapHeader.biHeight;
|
my_texture->h = MyBitmapHeader.biHeight;
|
||||||
switch(MyBitmapHeader.biBitCount) {
|
switch(MyBitmapHeader.biBitCount) {
|
||||||
|
|
Loading…
Reference in a new issue