From 8f2e7413e5910c363355c06471d0fbb9e151e56a Mon Sep 17 00:00:00 2001 From: N0NameN0 Date: Tue, 10 Nov 2009 09:50:41 +0000 Subject: [PATCH] [CHG] Optimization in tile calculation i only modded DrawTile, if this mod is ok for all and fully tested we need to make this change to all functions the needs calculation like this. (drawpart, drawtilequad, etc...) --- GRRLIB/GRRLIB/GRRLIB_bmf.c | 2 ++ GRRLIB/GRRLIB/GRRLIB_render.c | 8 ++++---- GRRLIB/GRRLIB/grrlib.h | 3 +++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/GRRLIB/GRRLIB/GRRLIB_bmf.c b/GRRLIB/GRRLIB/GRRLIB_bmf.c index ffd7a7d..f2b5045 100644 --- a/GRRLIB/GRRLIB/GRRLIB_bmf.c +++ b/GRRLIB/GRRLIB/GRRLIB_bmf.c @@ -111,5 +111,7 @@ void GRRLIB_InitTileSet (GRRLIB_texImg *tex, tex->nbtileh = tex->h / tileh; tex->tilestart = tilestart; tex->tiledtex = true; + tex->ofnormaltexx = 1.0F/tex->nbtilew; + tex->ofnormaltexy = 1.0F/tex->nbtileh; GRRLIB_SetHandle( tex, 0, 0 ); } diff --git a/GRRLIB/GRRLIB/GRRLIB_render.c b/GRRLIB/GRRLIB/GRRLIB_render.c index 1d08102..e771129 100644 --- a/GRRLIB/GRRLIB/GRRLIB_render.c +++ b/GRRLIB/GRRLIB/GRRLIB_render.c @@ -177,10 +177,10 @@ void GRRLIB_DrawTile (const f32 xpos, const f32 ypos, const GRRLIB_texImg *tex, if (tex == NULL || tex->data == NULL) return ; // The 0.001f/x is the frame correction formula by spiffen - s1 = (( (frame %tex->nbtilew) ) /(f32)tex->nbtilew) +(0.001f /tex->w); - s2 = (( (frame %tex->nbtilew) +1) /(f32)tex->nbtilew) -(0.001f /tex->w); - t1 = (((int)(frame /tex->nbtilew) ) /(f32)tex->nbtileh) +(0.001f /tex->h); - t2 = (((int)(frame /tex->nbtilew) +1) /(f32)tex->nbtileh) -(0.001f /tex->h); + s1 = (frame % tex->nbtilew) * tex->ofnormaltexx; + s2 = s1 + tex->ofnormaltexx; + t1 = (int)(frame/tex->nbtilew) * tex->ofnormaltexy; + t2 = t1 + tex->ofnormaltexy; GX_InitTexObj(&texObj, tex->data, tex->tilew * tex->nbtilew, tex->tileh * tex->nbtileh, diff --git a/GRRLIB/GRRLIB/grrlib.h b/GRRLIB/GRRLIB/grrlib.h index 4a55208..f467739 100644 --- a/GRRLIB/GRRLIB/grrlib.h +++ b/GRRLIB/GRRLIB/grrlib.h @@ -115,6 +115,9 @@ typedef struct GRRLIB_texImg { uint nbtilew; /**< Number of tiles for the x axis. */ uint nbtileh; /**< Number of tiles for the y axis. */ uint tilestart; /**< Offset to tile starting position. */ + f32 ofnormaltexx; /**< Offset of normalized texture on x */ + f32 ofnormaltexy; /**< Offset of normalized texture on y */ + void *data; /**< Pointer to the texture data. */ } GRRLIB_texImg;