From c085be59afcb84c9cb5489c3fc4deffce4e5908f Mon Sep 17 00:00:00 2001 From: Bart Trzynadlowski Date: Mon, 20 Feb 2012 04:09:11 +0000 Subject: [PATCH] Further optimization/simplification of the 2D renderer's main loop. --- Src/Graphics/Render2D.cpp | 63 ++++++++++++--------------------------- 1 file changed, 19 insertions(+), 44 deletions(-) diff --git a/Src/Graphics/Render2D.cpp b/Src/Graphics/Render2D.cpp index 605e51d..2f950ae 100644 --- a/Src/Graphics/Render2D.cpp +++ b/Src/Graphics/Render2D.cpp @@ -624,51 +624,26 @@ void CRender2D::DrawTilemaps(UINT32 *destBottom, UINT32 *destTop) /* * Render and mix each line */ - if (clearBottom) - { - for (int y = 0; y < 384; y++) - { - // Draw one scanline from each layer - DrawLine(lineBuffer[0], 0, y, nameTableBase[0], pal[0]); - DrawLine(lineBuffer[1], 1, y, nameTableBase[1], pal[0]); - DrawLine(lineBuffer[2], 2, y, nameTableBase[2], pal[1]); - DrawLine(lineBuffer[3], 3, y, nameTableBase[3], pal[1]); - - // No bottom layer - memset(destBottom, 0, 496*sizeof(UINT32)); - - // Mix the layers in the correct order - for (int i = 0; i < 4; i++) - { - MixLine(dest[i], src[i], sortedLayerNum[i], y, sortedIsBottom[i], sortedHScrollTable[i], maskTableLine, sortedHFullScroll[i], sortedLineScrollMode[i]); - dest[i] += 496; // next line - } - - // Next line in mask table - maskTableLine += 2; - } - } - else - { - for (int y = 0; y < 384; y++) - { - // Draw one scanline from each layer - DrawLine(lineBuffer[0], 0, y, nameTableBase[0], pal[0]); - DrawLine(lineBuffer[1], 1, y, nameTableBase[1], pal[0]); - DrawLine(lineBuffer[2], 2, y, nameTableBase[2], pal[1]); - DrawLine(lineBuffer[3], 3, y, nameTableBase[3], pal[1]); - - // Mix the layers in the correct order - for (int i = 0; i < 4; i++) - { - MixLine(dest[i], src[i], sortedLayerNum[i], y, sortedIsBottom[i], sortedHScrollTable[i], maskTableLine, sortedHFullScroll[i], sortedLineScrollMode[i]); - dest[i] += 496; // next line - } - - // Next line in mask table - maskTableLine += 2; - } + if (clearBottom) // no bottom layer + memset(destBottom, 0, 496*384*sizeof(UINT32)); + for (int y = 0; y < 384; y++) + { + // Draw one scanline from each layer + DrawLine(lineBuffer[0], 0, y, nameTableBase[0], pal[0]); + DrawLine(lineBuffer[1], 1, y, nameTableBase[1], pal[0]); + DrawLine(lineBuffer[2], 2, y, nameTableBase[2], pal[1]); + DrawLine(lineBuffer[3], 3, y, nameTableBase[3], pal[1]); + + // Mix the layers in the correct order + for (int i = 0; i < 4; i++) + { + MixLine(dest[i], src[i], sortedLayerNum[i], y, sortedIsBottom[i], sortedHScrollTable[i], maskTableLine, sortedHFullScroll[i], sortedLineScrollMode[i]); + dest[i] += 496; // next line + } + + // Next line in mask table + maskTableLine += 2; } }