mirror of
https://github.com/XProger/OpenLara.git
synced 2025-08-02 19:27:50 +02:00
#407 32X use 2px texturing, aligned gLightmap address optimization
This commit is contained in:
@@ -91,6 +91,8 @@
|
|||||||
#define USE_DIV_TABLE
|
#define USE_DIV_TABLE
|
||||||
#define CPU_BIG_ENDIAN
|
#define CPU_BIG_ENDIAN
|
||||||
#define ROM_READ
|
#define ROM_READ
|
||||||
|
#define TEX_2PX
|
||||||
|
#define ALIGNED_LIGHTMAP
|
||||||
|
|
||||||
#define MODE13
|
#define MODE13
|
||||||
#define FRAME_WIDTH 320
|
#define FRAME_WIDTH 320
|
||||||
|
@@ -6,8 +6,12 @@
|
|||||||
|
|
||||||
Level level;
|
Level level;
|
||||||
|
|
||||||
#ifndef MODEHW
|
#ifdef __32X__
|
||||||
IWRAM_DATA uint8 gLightmap[256 * 32]; // IWRAM 8k
|
extern uint8 gLightmap[256 * 32]; // SDRAM 8k at 0x6000000
|
||||||
|
#else
|
||||||
|
#ifndef MODEHW
|
||||||
|
IWRAM_DATA uint8 gLightmap[256 * 32]; // IWRAM 8k
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
EWRAM_DATA ItemObj items[MAX_ITEMS];
|
EWRAM_DATA ItemObj items[MAX_ITEMS];
|
||||||
|
@@ -192,6 +192,9 @@
|
|||||||
.incbin "src-md/m68k.bin" /* all 68000 code & data, compiled to 0x880800/0xFF0000 */
|
.incbin "src-md/m68k.bin" /* all 68000 code & data, compiled to 0x880800/0xFF0000 */
|
||||||
|
|
||||||
.data
|
.data
|
||||||
|
.global _gLightmap
|
||||||
|
_gLightmap:
|
||||||
|
.space 256 * 32
|
||||||
|
|
||||||
!-----------------------------------------------------------------------
|
!-----------------------------------------------------------------------
|
||||||
! Primary Vector Base Table
|
! Primary Vector Base Table
|
||||||
|
@@ -340,6 +340,21 @@ extern "C" void rasterizeFT_c(uint16* pixel, const VertexLink* L, const VertexLi
|
|||||||
}
|
}
|
||||||
|
|
||||||
width >>= 1;
|
width >>= 1;
|
||||||
|
|
||||||
|
#ifdef TEX_2PX
|
||||||
|
dtdx <<= 1;
|
||||||
|
|
||||||
|
while (width--)
|
||||||
|
{
|
||||||
|
uint8 indexA = ft_lightmap[gTile[(t & 0xFF00) | (t >> 24)]];
|
||||||
|
t += dtdx;
|
||||||
|
|
||||||
|
*(uint16*)ptr = indexA | (indexA << 8);
|
||||||
|
|
||||||
|
ptr += 2;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
width >>= 1;
|
||||||
while (width--)
|
while (width--)
|
||||||
{
|
{
|
||||||
uint8 indexA = ft_lightmap[gTile[(t & 0xFF00) | (t >> 24)]];
|
uint8 indexA = ft_lightmap[gTile[(t & 0xFF00) | (t >> 24)]];
|
||||||
@@ -355,6 +370,7 @@ extern "C" void rasterizeFT_c(uint16* pixel, const VertexLink* L, const VertexLi
|
|||||||
|
|
||||||
ptr += 2;
|
ptr += 2;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
pixel += VRAM_WIDTH;
|
pixel += VRAM_WIDTH;
|
||||||
@@ -445,6 +461,11 @@ extern "C" void rasterizeGT_c(uint16* pixel, const VertexLink* L, const VertexLi
|
|||||||
Lh -= h;
|
Lh -= h;
|
||||||
Rh -= h;
|
Rh -= h;
|
||||||
|
|
||||||
|
#ifdef ALIGNED_LIGHTMAP
|
||||||
|
Lg |= intptr_t(gLightmap);
|
||||||
|
Rg |= intptr_t(gLightmap);
|
||||||
|
#endif
|
||||||
|
|
||||||
while (h--)
|
while (h--)
|
||||||
{
|
{
|
||||||
int32 x1 = Lx >> 16;
|
int32 x1 = Lx >> 16;
|
||||||
@@ -470,7 +491,13 @@ extern "C" void rasterizeGT_c(uint16* pixel, const VertexLink* L, const VertexLi
|
|||||||
|
|
||||||
if (intptr_t(ptr) & 1)
|
if (intptr_t(ptr) & 1)
|
||||||
{
|
{
|
||||||
*ptr++ = gLightmap[(g >> 8 << 8) | gTile[(t & 0xFF00) | (t >> 24)]];
|
#ifdef ALIGNED_LIGHTMAP
|
||||||
|
const uint8* LMAP = (uint8*)(g >> 8 << 8);
|
||||||
|
uint8 indexA = LMAP[gTile[(t & 0xFF00) | (t >> 24)]];
|
||||||
|
#else
|
||||||
|
uint8 indexA = gLightmap[(g >> 8 << 8) | gTile[(t & 0xFF00) | (t >> 24)]];
|
||||||
|
#endif
|
||||||
|
*ptr++ = indexA;
|
||||||
t += dtdx;
|
t += dtdx;
|
||||||
g += dgdx >> 1;
|
g += dgdx >> 1;
|
||||||
width--;
|
width--;
|
||||||
@@ -479,15 +506,34 @@ extern "C" void rasterizeGT_c(uint16* pixel, const VertexLink* L, const VertexLi
|
|||||||
if (width & 1)
|
if (width & 1)
|
||||||
{
|
{
|
||||||
uint32 tmp = Rt - dtdx;
|
uint32 tmp = Rt - dtdx;
|
||||||
ptr[width - 1] = gLightmap[(Rg >> 8 << 8) | gTile[(tmp & 0xFF00) | (tmp >> 24)]];
|
#ifdef ALIGNED_LIGHTMAP
|
||||||
|
const uint8* LMAP = (uint8*)(Rg >> 8 << 8);
|
||||||
|
uint8 indexA = LMAP[gTile[(tmp & 0xFF00) | (tmp >> 24)]];
|
||||||
|
#else
|
||||||
|
uint8 indexA = gLightmap[(Rg >> 8 << 8) | gTile[(tmp & 0xFF00) | (tmp >> 24)]];
|
||||||
|
#endif
|
||||||
|
ptr[width - 1] = indexA;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ALIGNED_LIGHTMAP
|
|
||||||
g += intptr_t(gLightmap);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
width >>= 1;
|
width >>= 1;
|
||||||
|
|
||||||
|
#ifdef TEX_2PX
|
||||||
|
dtdx <<= 1;
|
||||||
|
|
||||||
|
while (width--)
|
||||||
|
{
|
||||||
|
#ifdef ALIGNED_LIGHTMAP
|
||||||
|
const uint8* LMAP = (uint8*)(g >> 8 << 8);
|
||||||
|
uint8 indexA = LMAP[gTile[(t & 0xFF00) | (t >> 24)]];
|
||||||
|
#else
|
||||||
|
uint8 indexA = gLightmap[(g >> 8 << 8) | gTile[(t & 0xFF00) | (t >> 24)]];
|
||||||
|
#endif
|
||||||
|
*(uint16*)ptr = indexA | (indexA << 8);
|
||||||
|
ptr += 2;
|
||||||
|
t += dtdx;
|
||||||
|
g += dgdx;
|
||||||
|
}
|
||||||
|
#else
|
||||||
while (width--)
|
while (width--)
|
||||||
{
|
{
|
||||||
#ifdef ALIGNED_LIGHTMAP
|
#ifdef ALIGNED_LIGHTMAP
|
||||||
@@ -514,6 +560,7 @@ extern "C" void rasterizeGT_c(uint16* pixel, const VertexLink* L, const VertexLi
|
|||||||
|
|
||||||
ptr += 2;
|
ptr += 2;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
pixel += VRAM_WIDTH;
|
pixel += VRAM_WIDTH;
|
||||||
@@ -635,6 +682,24 @@ extern "C" void rasterizeFTA_c(uint16* pixel, const VertexLink* L, const VertexL
|
|||||||
}
|
}
|
||||||
|
|
||||||
width >>= 1;
|
width >>= 1;
|
||||||
|
|
||||||
|
#ifdef TEX_2PX
|
||||||
|
dtdx <<= 1;
|
||||||
|
|
||||||
|
while (width--)
|
||||||
|
{
|
||||||
|
uint8 indexA = gTile[(t & 0xFF00) | (t >> 24)];
|
||||||
|
t += dtdx;
|
||||||
|
|
||||||
|
if (indexA)
|
||||||
|
{
|
||||||
|
indexA = ft_lightmap[indexA];
|
||||||
|
*(uint16*)ptr = indexA | (indexA << 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
ptr += 2;
|
||||||
|
}
|
||||||
|
#else
|
||||||
while (width--)
|
while (width--)
|
||||||
{
|
{
|
||||||
uint8 indexA = gTile[(t & 0xFF00) | (t >> 24)];
|
uint8 indexA = gTile[(t & 0xFF00) | (t >> 24)];
|
||||||
@@ -662,6 +727,7 @@ extern "C" void rasterizeFTA_c(uint16* pixel, const VertexLink* L, const VertexL
|
|||||||
|
|
||||||
ptr += 2;
|
ptr += 2;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
pixel += VRAM_WIDTH;
|
pixel += VRAM_WIDTH;
|
||||||
|
Reference in New Issue
Block a user