From 11403180dbac48b76c6e810a2a091fc78fd6ac82 Mon Sep 17 00:00:00 2001 From: rogerman Date: Wed, 21 Oct 2015 06:09:52 +0000 Subject: [PATCH] Windows Port: - Fix crashing bug with the OAM Viewer tool. - Improve the sprite drawing performance of the OAM Viewer tool. --- desmume/src/GPU.cpp | 251 +++++++++++++++++++++----------- desmume/src/GPU.h | 12 +- desmume/src/windows/oamView.cpp | 12 +- 3 files changed, 172 insertions(+), 103 deletions(-) diff --git a/desmume/src/GPU.cpp b/desmume/src/GPU.cpp index 560479bb0..9b0c1de2f 100644 --- a/desmume/src/GPU.cpp +++ b/desmume/src/GPU.cpp @@ -1577,6 +1577,7 @@ void GPUEngineBase::_LineExtRot(u16 *__restrict dstColorLine, const u16 lineInde /* if i understand it correct, and it fixes some sprite problems in chameleon shot */ /* we have a 15 bit color, and should use the pal entry bits as alpha ?*/ /* http://nocash.emubase.de/gbatek.htm#dsvideoobjs */ +template void GPUEngineBase::_RenderSpriteBMP(const u8 spriteNum, const u16 l, u16 *__restrict dst, const u32 srcadr, u8 *__restrict dst_alpha, u8 *__restrict typeTab, u8 *__restrict prioTab, const u8 prio, const size_t lg, size_t sprX, size_t x, const s32 xdir, const u8 alpha) { const u16 *__restrict bmpBuffer = (u16 *)MMU_gpu_map(srcadr); @@ -1585,41 +1586,57 @@ void GPUEngineBase::_RenderSpriteBMP(const u8 spriteNum, const u16 l, u16 *__res #ifdef ENABLE_SSE2 if (xdir == 1) { - const __m128i prio_vec128 = _mm_set1_epi8(prio); - - const size_t ssePixCount = lg - (lg % 16); - for (; i < ssePixCount; i += 16, x += 16, sprX += 16) + if (ISDEBUGRENDER) { - __m128i prioTab_vec128 = _mm_loadu_si128((__m128i *)(prioTab + sprX)); - const __m128i prioCompare = _mm_cmplt_epi8(prio_vec128, prioTab_vec128); + const size_t ssePixCount = lg - (lg % 8); + for (; i < ssePixCount; i += 8, x += 8, sprX += 8) + { + __m128i color_vec128 = _mm_loadu_si128((__m128i *)(bmpBuffer + x)); + const __m128i colorAlpha_vec128 = _mm_and_si128(color_vec128, _mm_set1_epi16(0x8000)); + const __m128i colorAlphaCompare = _mm_cmpeq_epi16(colorAlpha_vec128, _mm_set1_epi16(0x8000)); + color_vec128 = _mm_or_si128( _mm_and_si128(colorAlphaCompare, color_vec128), _mm_andnot_si128(colorAlphaCompare, _mm_loadu_si128((__m128i *)(dst + sprX))) ); + + _mm_storeu_si128((__m128i *)(dst + sprX), color_vec128); + } + } + else + { + const __m128i prio_vec128 = _mm_set1_epi8(prio); - __m128i colorLo_vec128 = _mm_loadu_si128((__m128i *)(bmpBuffer + x)); - __m128i colorHi_vec128 = _mm_loadu_si128((__m128i *)(bmpBuffer + x + 8)); - - const __m128i colorAlphaLo_vec128 = _mm_and_si128(colorLo_vec128, _mm_set1_epi16(0x8000)); - const __m128i colorAlphaHi_vec128 = _mm_and_si128(colorHi_vec128, _mm_set1_epi16(0x8000)); - - const __m128i colorAlphaLoCompare = _mm_cmpeq_epi16(colorAlphaLo_vec128, _mm_set1_epi16(0x8000)); - const __m128i colorAlphaHiCompare = _mm_cmpeq_epi16(colorAlphaHi_vec128, _mm_set1_epi16(0x8000)); - const __m128i colorAlphaPackedCompare = _mm_cmpeq_epi8( _mm_packs_epi16(colorAlphaLoCompare, colorAlphaHiCompare), _mm_set1_epi8(0xFF) ); - - const __m128i combinedPackedCompare = _mm_and_si128(prioCompare, colorAlphaPackedCompare); - const __m128i combinedLoCompare = _mm_cmpeq_epi16( _mm_unpacklo_epi8(combinedPackedCompare, _mm_setzero_si128()), _mm_set1_epi16(0x00FF) ); - const __m128i combinedHiCompare = _mm_cmpeq_epi16( _mm_unpackhi_epi8(combinedPackedCompare, _mm_setzero_si128()), _mm_set1_epi16(0x00FF) ); - - colorLo_vec128 = _mm_or_si128( _mm_and_si128(combinedLoCompare, colorLo_vec128), _mm_andnot_si128(combinedLoCompare, _mm_loadu_si128((__m128i *)(dst + sprX))) ); - colorHi_vec128 = _mm_or_si128( _mm_and_si128(combinedHiCompare, colorHi_vec128), _mm_andnot_si128(combinedHiCompare, _mm_loadu_si128((__m128i *)(dst + sprX + 8))) ); - const __m128i dstAlpha_vec128 = _mm_or_si128( _mm_and_si128(combinedPackedCompare, _mm_set1_epi8(alpha + 1)), _mm_andnot_si128(combinedPackedCompare, _mm_loadu_si128((__m128i *)(dst_alpha + sprX))) ); - const __m128i dstTypeTab_vec128 = _mm_or_si128( _mm_and_si128(combinedPackedCompare, _mm_set1_epi8(3)), _mm_andnot_si128(combinedPackedCompare, _mm_loadu_si128((__m128i *)(typeTab + sprX))) ); - prioTab_vec128 = _mm_or_si128( _mm_and_si128(combinedPackedCompare, prio_vec128), _mm_andnot_si128(combinedPackedCompare, prioTab_vec128) ); - const __m128i sprNum_vec128 = _mm_or_si128( _mm_and_si128(combinedPackedCompare, _mm_set1_epi8(spriteNum)), _mm_andnot_si128(combinedPackedCompare, _mm_loadu_si128((__m128i *)(this->_sprNum + sprX))) ); - - _mm_storeu_si128((__m128i *)(dst + sprX), colorLo_vec128); - _mm_storeu_si128((__m128i *)(dst + sprX + 8), colorHi_vec128); - _mm_storeu_si128((__m128i *)(dst_alpha + sprX), dstAlpha_vec128); - _mm_storeu_si128((__m128i *)(typeTab + sprX), dstTypeTab_vec128); - _mm_storeu_si128((__m128i *)(prioTab + sprX), prioTab_vec128); - _mm_storeu_si128((__m128i *)(this->_sprNum + sprX), sprNum_vec128); + const size_t ssePixCount = lg - (lg % 16); + for (; i < ssePixCount; i += 16, x += 16, sprX += 16) + { + __m128i prioTab_vec128 = _mm_loadu_si128((__m128i *)(prioTab + sprX)); + const __m128i prioCompare = _mm_cmplt_epi8(prio_vec128, prioTab_vec128); + + __m128i colorLo_vec128 = _mm_loadu_si128((__m128i *)(bmpBuffer + x)); + __m128i colorHi_vec128 = _mm_loadu_si128((__m128i *)(bmpBuffer + x + 8)); + + const __m128i colorAlphaLo_vec128 = _mm_and_si128(colorLo_vec128, _mm_set1_epi16(0x8000)); + const __m128i colorAlphaHi_vec128 = _mm_and_si128(colorHi_vec128, _mm_set1_epi16(0x8000)); + + const __m128i colorAlphaLoCompare = _mm_cmpeq_epi16(colorAlphaLo_vec128, _mm_set1_epi16(0x8000)); + const __m128i colorAlphaHiCompare = _mm_cmpeq_epi16(colorAlphaHi_vec128, _mm_set1_epi16(0x8000)); + const __m128i colorAlphaPackedCompare = _mm_cmpeq_epi8( _mm_packs_epi16(colorAlphaLoCompare, colorAlphaHiCompare), _mm_set1_epi8(0xFF) ); + + const __m128i combinedPackedCompare = _mm_and_si128(prioCompare, colorAlphaPackedCompare); + const __m128i combinedLoCompare = _mm_cmpeq_epi16( _mm_unpacklo_epi8(combinedPackedCompare, _mm_setzero_si128()), _mm_set1_epi16(0x00FF) ); + const __m128i combinedHiCompare = _mm_cmpeq_epi16( _mm_unpackhi_epi8(combinedPackedCompare, _mm_setzero_si128()), _mm_set1_epi16(0x00FF) ); + + colorLo_vec128 = _mm_or_si128( _mm_and_si128(combinedLoCompare, colorLo_vec128), _mm_andnot_si128(combinedLoCompare, _mm_loadu_si128((__m128i *)(dst + sprX))) ); + colorHi_vec128 = _mm_or_si128( _mm_and_si128(combinedHiCompare, colorHi_vec128), _mm_andnot_si128(combinedHiCompare, _mm_loadu_si128((__m128i *)(dst + sprX + 8))) ); + const __m128i dstAlpha_vec128 = _mm_or_si128( _mm_and_si128(combinedPackedCompare, _mm_set1_epi8(alpha + 1)), _mm_andnot_si128(combinedPackedCompare, _mm_loadu_si128((__m128i *)(dst_alpha + sprX))) ); + const __m128i dstTypeTab_vec128 = _mm_or_si128( _mm_and_si128(combinedPackedCompare, _mm_set1_epi8(3)), _mm_andnot_si128(combinedPackedCompare, _mm_loadu_si128((__m128i *)(typeTab + sprX))) ); + prioTab_vec128 = _mm_or_si128( _mm_and_si128(combinedPackedCompare, prio_vec128), _mm_andnot_si128(combinedPackedCompare, prioTab_vec128) ); + const __m128i sprNum_vec128 = _mm_or_si128( _mm_and_si128(combinedPackedCompare, _mm_set1_epi8(spriteNum)), _mm_andnot_si128(combinedPackedCompare, _mm_loadu_si128((__m128i *)(this->_sprNum + sprX))) ); + + _mm_storeu_si128((__m128i *)(dst + sprX), colorLo_vec128); + _mm_storeu_si128((__m128i *)(dst + sprX + 8), colorHi_vec128); + _mm_storeu_si128((__m128i *)(dst_alpha + sprX), dstAlpha_vec128); + _mm_storeu_si128((__m128i *)(typeTab + sprX), dstTypeTab_vec128); + _mm_storeu_si128((__m128i *)(prioTab + sprX), prioTab_vec128); + _mm_storeu_si128((__m128i *)(this->_sprNum + sprX), sprNum_vec128); + } } } #endif @@ -1629,17 +1646,28 @@ void GPUEngineBase::_RenderSpriteBMP(const u8 spriteNum, const u16 l, u16 *__res const u16 color = LE_TO_LOCAL_16(bmpBuffer[x]); //a cleared alpha bit suppresses the pixel from processing entirely; it doesnt exist - if ((color & 0x8000) && (prio < prioTab[sprX])) + if (ISDEBUGRENDER) { - dst[sprX] = color; - dst_alpha[sprX] = alpha+1; - typeTab[sprX] = OBJMode_Bitmap; - prioTab[sprX] = prio; - this->_sprNum[sprX] = spriteNum; + if (color & 0x8000) + { + dst[sprX] = color; + } + } + else + { + if ((color & 0x8000) && (prio < prioTab[sprX])) + { + dst[sprX] = color; + dst_alpha[sprX] = alpha+1; + typeTab[sprX] = OBJMode_Bitmap; + prioTab[sprX] = prio; + this->_sprNum[sprX] = spriteNum; + } } } } +template void GPUEngineBase::_RenderSprite256(const u8 spriteNum, const u16 l, u16 *__restrict dst, const u32 srcadr, const u16 *__restrict pal, u8 *__restrict dst_alpha, u8 *__restrict typeTab, u8 *__restrict prioTab, const u8 prio, const size_t lg, size_t sprX, size_t x, const s32 xdir, const u8 alpha) { for (size_t i = 0; i < lg; i++, ++sprX, x += xdir) @@ -1649,19 +1677,29 @@ void GPUEngineBase::_RenderSprite256(const u8 spriteNum, const u16 l, u16 *__res const u8 palette_entry = *src; //a zero value suppresses the pixel from processing entirely; it doesnt exist - if ((palette_entry > 0) && (prio < prioTab[sprX])) + if (ISDEBUGRENDER) { - const u16 color = LE_TO_LOCAL_16(pal[palette_entry]); - dst[sprX] = color; - dst_alpha[sprX] = 0xFF; - typeTab[sprX] = (alpha ? OBJMode_Transparent : OBJMode_Normal); - prioTab[sprX] = prio; - this->_sprNum[sprX] = spriteNum; + if (palette_entry > 0) + { + dst[sprX] = LE_TO_LOCAL_16(pal[palette_entry]); + } + } + else + { + if ((palette_entry > 0) && (prio < prioTab[sprX])) + { + dst[sprX] = LE_TO_LOCAL_16(pal[palette_entry]); + dst_alpha[sprX] = 0xFF; + typeTab[sprX] = (alpha ? OBJMode_Transparent : OBJMode_Normal); + prioTab[sprX] = prio; + this->_sprNum[sprX] = spriteNum; + } } } } -void GPUEngineBase::_RenderSprite16(const u16 l, u16 *__restrict dst, const u32 srcadr, const u16 *__restrict pal, u8 *__restrict dst_alpha, u8 *__restrict typeTab, u8 *__restrict prioTab, const u8 prio, const size_t lg, size_t sprX, size_t x, const s32 xdir, const u8 alpha) +template +void GPUEngineBase::_RenderSprite16(const u8 spriteNum, const u16 l, u16 *__restrict dst, const u32 srcadr, const u16 *__restrict pal, u8 *__restrict dst_alpha, u8 *__restrict typeTab, u8 *__restrict prioTab, const u8 prio, const size_t lg, size_t sprX, size_t x, const s32 xdir, const u8 alpha) { for (size_t i = 0; i < lg; i++, ++sprX, x += xdir) { @@ -1672,13 +1710,23 @@ void GPUEngineBase::_RenderSprite16(const u16 l, u16 *__restrict dst, const u32 const u8 palette_entry = (x & 1) ? palette >> 4 : palette & 0xF; //a zero value suppresses the pixel from processing entirely; it doesnt exist - if ((palette_entry > 0) && (prio < prioTab[sprX])) + if (ISDEBUGRENDER) { - const u16 color = LE_TO_LOCAL_16(pal[palette_entry]); - dst[sprX] = color; - dst_alpha[sprX] = 0xFF; - typeTab[sprX] = (alpha ? OBJMode_Transparent : OBJMode_Normal); - prioTab[sprX] = prio; + if (palette_entry > 0) + { + dst[sprX] = LE_TO_LOCAL_16(pal[palette_entry]); + } + } + else + { + if ((palette_entry > 0) && (prio < prioTab[sprX])) + { + dst[sprX] = LE_TO_LOCAL_16(pal[palette_entry]); + dst_alpha[sprX] = 0xFF; + typeTab[sprX] = (alpha ? OBJMode_Transparent : OBJMode_Normal); + prioTab[sprX] = prio; + this->_sprNum[sprX] = spriteNum; + } } } } @@ -1793,20 +1841,21 @@ u32 GPUEngineBase::_SpriteAddressBMP(const OAMAttributes &spriteInfo, const Spri } } -void GPUEngineBase::SpriteRender(const u16 lineIndex, u16 *__restrict dst, u8 *__restrict dst_alpha, u8 *__restrict typeTab, u8 *__restrict prioTab) +template +void GPUEngineBase::_SpriteRender(const u16 lineIndex, u16 *__restrict dst, u8 *__restrict dst_alpha, u8 *__restrict typeTab, u8 *__restrict prioTab) { if (this->_spriteRenderMode == SpriteRenderMode_Sprite1D) - this->_SpriteRenderPerform(lineIndex, dst, dst_alpha, typeTab, prioTab); + this->_SpriteRenderPerform(lineIndex, dst, dst_alpha, typeTab, prioTab); else - this->_SpriteRenderPerform(lineIndex, dst, dst_alpha, typeTab, prioTab); + this->_SpriteRenderPerform(lineIndex, dst, dst_alpha, typeTab, prioTab); } -void GPUEngineBase::SpriteRenderDebug(const u16 lineIndex, u16 *__restrict dst, u8 *__restrict dst_alpha, u8 *__restrict typeTab, u8 *__restrict prioTab) +void GPUEngineBase::SpriteRenderDebug(const u16 lineIndex, u16 *dst) { - this->SpriteRender(lineIndex, dst, dst_alpha, typeTab, prioTab); + this->_SpriteRender(lineIndex, dst, NULL, NULL, NULL); } -template +template void GPUEngineBase::_SpriteRenderPerform(const u16 lineIndex, u16 *__restrict dst, u8 *__restrict dst_alpha, u8 *__restrict typeTab, u8 *__restrict prioTab) { const IOREG_DISPCNT &DISPCNT = this->_IORegisterMap->DISPCNT; @@ -1939,13 +1988,23 @@ void GPUEngineBase::_SpriteRenderPerform(const u16 lineIndex, u16 *__restrict ds offset = (auxX&0x7) + ((auxX&0xFFF8)<<3) + ((auxY>>3)*sprSize.width*8) + ((auxY&0x7)*8); colour = src[offset]; - - if (colour && (prio < prioTab[sprX])) - { - dst[sprX] = LE_TO_LOCAL_16(pal[colour]); - dst_alpha[sprX] = 0xFF; - typeTab[sprX] = objMode; - prioTab[sprX] = prio; + + if (ISDEBUGRENDER) + { + if (colour) + { + dst[sprX] = LE_TO_LOCAL_16(pal[colour]); + } + } + else + { + if (colour && (prio < prioTab[sprX])) + { + dst[sprX] = LE_TO_LOCAL_16(pal[colour]); + dst_alpha[sprX] = 0xFF; + typeTab[sprX] = objMode; + prioTab[sprX] = prio; + } } } @@ -1985,12 +2044,22 @@ void GPUEngineBase::_SpriteRenderPerform(const u16 lineIndex, u16 *__restrict ds u16* mem = (u16*)MMU_gpu_map(srcadr + (offset<<1)); colour = LE_TO_LOCAL_16(*mem); - if ((colour & 0x8000) && (prio < prioTab[sprX])) + if (ISDEBUGRENDER) { - dst[sprX] = colour; - dst_alpha[sprX] = spriteInfo.PaletteIndex; - typeTab[sprX] = objMode; - prioTab[sprX] = prio; + if (colour & 0x8000) + { + dst[sprX] = colour; + } + } + else + { + if ((colour & 0x8000) && (prio < prioTab[sprX])) + { + dst[sprX] = colour; + dst_alpha[sprX] = spriteInfo.PaletteIndex; + typeTab[sprX] = objMode; + prioTab[sprX] = prio; + } } } @@ -2031,19 +2100,29 @@ void GPUEngineBase::_SpriteRenderPerform(const u16 lineIndex, u16 *__restrict ds // Get 4bits value from the readed 8bits if (auxX&1) colour >>= 4; else colour &= 0xF; - - if (colour && (prio_sprWin[sprX] = 1; - } - else + if (colour) { dst[sprX] = LE_TO_LOCAL_16(pal[colour]); - dst_alpha[sprX] = 0xFF; - typeTab[sprX] = objMode; - prioTab[sprX] = prio; + } + } + else + { + if (colour && (prio < prioTab[sprX])) + { + if (objMode == OBJMode_Window) + { + this->_sprWin[sprX] = 1; + } + else + { + dst[sprX] = LE_TO_LOCAL_16(pal[colour]); + dst_alpha[sprX] = 0xFF; + typeTab[sprX] = objMode; + prioTab[sprX] = prio; + } } } } @@ -2088,7 +2167,7 @@ void GPUEngineBase::_SpriteRenderPerform(const u16 lineIndex, u16 *__restrict ds if (spriteInfo.PaletteIndex == 0) continue; - this->_RenderSpriteBMP(i, lineIndex, dst, srcadr, dst_alpha, typeTab, prioTab, prio, lg, sprX, x, xdir, spriteInfo.PaletteIndex); + this->_RenderSpriteBMP(i, lineIndex, dst, srcadr, dst_alpha, typeTab, prioTab, prio, lg, sprX, x, xdir, spriteInfo.PaletteIndex); } else if (spriteInfo.PaletteMode == PaletteMode_1x256) //256 colors { @@ -2098,7 +2177,7 @@ void GPUEngineBase::_SpriteRenderPerform(const u16 lineIndex, u16 *__restrict ds srcadr = this->_sprMem + (spriteInfo.TileIndex<_sprBoundary) + ((y>>3)*sprSize.width*8) + ((y&0x7)*8); pal = (DISPCNT.ExOBJPalette_Enable) ? (u16 *)(MMU.ObjExtPal[this->_engineID][0]+(spriteInfo.PaletteIndex*ADDRESS_STEP_512B)) : this->_paletteOBJ; - this->_RenderSprite256(i, lineIndex, dst, srcadr, pal, dst_alpha, typeTab, prioTab, prio, lg, sprX, x, xdir, (objMode == OBJMode_Transparent)); + this->_RenderSprite256(i, lineIndex, dst, srcadr, pal, dst_alpha, typeTab, prioTab, prio, lg, sprX, x, xdir, (objMode == OBJMode_Transparent)); } else // 16 colors { @@ -2112,7 +2191,7 @@ void GPUEngineBase::_SpriteRenderPerform(const u16 lineIndex, u16 *__restrict ds } pal = this->_paletteOBJ + (spriteInfo.PaletteIndex << 4); - this->_RenderSprite16(lineIndex, dst, srcadr, pal, dst_alpha, typeTab, prioTab, prio, lg, sprX, x, xdir, (objMode == OBJMode_Transparent)); + this->_RenderSprite16(i, lineIndex, dst, srcadr, pal, dst_alpha, typeTab, prioTab, prio, lg, sprX, x, xdir, (objMode == OBJMode_Transparent)); } } } @@ -2840,7 +2919,7 @@ void GPUEngineA::_RenderLine_Layer(const u16 l, u16 *dstColorLine, const size_t //zero 06-may-09: I properly supported window color effects for backdrop, but I am not sure //how it interacts with this. I wish we knew why we needed this - this->SpriteRender(l, this->_sprColor, this->_sprAlpha, this->_sprType, this->_sprPrio); + this->_SpriteRender(l, this->_sprColor, this->_sprAlpha, this->_sprType, this->_sprPrio); this->_MosaicSpriteLine(l, this->_sprColor, this->_sprAlpha, this->_sprType, this->_sprPrio); for (size_t i = 0; i < GPU_FRAMEBUFFER_NATIVE_WIDTH; i++) @@ -3744,7 +3823,7 @@ void GPUEngineB::_RenderLine_Layer(const u16 l, u16 *dstColorLine, const size_t //zero 06-may-09: I properly supported window color effects for backdrop, but I am not sure //how it interacts with this. I wish we knew why we needed this - this->SpriteRender(l, this->_sprColor, this->_sprAlpha, this->_sprType, this->_sprPrio); + this->_SpriteRender(l, this->_sprColor, this->_sprAlpha, this->_sprType, this->_sprPrio); this->_MosaicSpriteLine(l, this->_sprColor, this->_sprAlpha, this->_sprType, this->_sprPrio); for (size_t i = 0; i < GPU_FRAMEBUFFER_NATIVE_WIDTH; i++) diff --git a/desmume/src/GPU.h b/desmume/src/GPU.h index 67aeffd97..1654d951a 100644 --- a/desmume/src/GPU.h +++ b/desmume/src/GPU.h @@ -1220,15 +1220,16 @@ protected: FORCEINLINE u16 _ColorEffectBlend(const u16 colA, const u16 colB, const TBlendTable *blendTable); FORCEINLINE FragmentColor _ColorEffectBlend(const FragmentColor colA, const FragmentColor colB); - void _RenderSpriteBMP(const u8 spriteNum, const u16 l, u16 *__restrict dst, const u32 srcadr, u8 *__restrict dst_alpha, u8 *__restrict typeTab, u8 *__restrict prioTab, const u8 prio, const size_t lg, size_t sprX, size_t x, const s32 xdir, const u8 alpha); - void _RenderSprite256(const u8 spriteNum, const u16 l, u16 *__restrict dst, const u32 srcadr, const u16 *__restrict pal, u8 *__restrict dst_alpha, u8 *__restrict typeTab, u8 *__restrict prioTab, const u8 prio, const size_t lg, size_t sprX, size_t x, const s32 xdir, const u8 alpha); - void _RenderSprite16(const u16 l, u16 *__restrict dst, const u32 srcadr, const u16 *__restrict pal, u8 *__restrict dst_alpha, u8 *__restrict typeTab, u8 *__restrict prioTab, const u8 prio, const size_t lg, size_t sprX, size_t x, const s32 xdir, const u8 alpha); + template void _RenderSpriteBMP(const u8 spriteNum, const u16 l, u16 *__restrict dst, const u32 srcadr, u8 *__restrict dst_alpha, u8 *__restrict typeTab, u8 *__restrict prioTab, const u8 prio, const size_t lg, size_t sprX, size_t x, const s32 xdir, const u8 alpha); + template void _RenderSprite256(const u8 spriteNum, const u16 l, u16 *__restrict dst, const u32 srcadr, const u16 *__restrict pal, u8 *__restrict dst_alpha, u8 *__restrict typeTab, u8 *__restrict prioTab, const u8 prio, const size_t lg, size_t sprX, size_t x, const s32 xdir, const u8 alpha); + template void _RenderSprite16(const u8 spriteNum, const u16 l, u16 *__restrict dst, const u32 srcadr, const u16 *__restrict pal, u8 *__restrict dst_alpha, u8 *__restrict typeTab, u8 *__restrict prioTab, const u8 prio, const size_t lg, size_t sprX, size_t x, const s32 xdir, const u8 alpha); void _RenderSpriteWin(const u8 *src, const bool col256, const size_t lg, size_t sprX, size_t x, const s32 xdir); bool _ComputeSpriteVars(const OAMAttributes &spriteInfo, const u16 l, SpriteSize &sprSize, s32 &sprX, s32 &sprY, s32 &x, s32 &y, s32 &lg, s32 &xdir); u32 _SpriteAddressBMP(const OAMAttributes &spriteInfo, const SpriteSize sprSize, const s32 y); - template void _SpriteRenderPerform(const u16 lineIndex, u16 *__restrict dst, u8 *__restrict dst_alpha, u8 *__restrict typeTab, u8 *__restrict prioTab); + template void _SpriteRender(const u16 lineIndex, u16 *__restrict dst, u8 *__restrict dst_alpha, u8 *__restrict typeTab, u8 *__restrict prioTab); + template void _SpriteRenderPerform(const u16 lineIndex, u16 *__restrict dst, u8 *__restrict dst_alpha, u8 *__restrict typeTab, u8 *__restrict prioTab); public: GPUEngineBase(); @@ -1293,8 +1294,7 @@ public: void UpdateVRAM3DUsageProperties_BGLayer(const size_t bankIndex, VRAM3DUsageProperties &outProperty); void UpdateVRAM3DUsageProperties_OBJLayer(const size_t bankIndex, VRAM3DUsageProperties &outProperty); - void SpriteRender(const u16 lineIndex, u16 *__restrict dst, u8 *__restrict dst_alpha, u8 *__restrict typeTab, u8 *__restrict prioTab); - void SpriteRenderDebug(const u16 lineIndex, u16 *__restrict dst, u8 *__restrict dst_alpha, u8 *__restrict typeTab, u8 *__restrict prioTab); + void SpriteRenderDebug(const u16 lineIndex, u16 *dst); template void RenderLayerBG(u16 *dstLineColor); NDSDisplayID GetDisplayByID() const; diff --git a/desmume/src/windows/oamView.cpp b/desmume/src/windows/oamView.cpp index 997d65d80..c09780b08 100644 --- a/desmume/src/windows/oamView.cpp +++ b/desmume/src/windows/oamView.cpp @@ -112,9 +112,6 @@ LRESULT OamView_OnPaint(HWND hwnd, oamview_struct *win, WPARAM wParam, LPARAM lP { HDC hdc; PAINTSTRUCT ps; - //_OAM_ _oam; - //_OAM_* oam = &_oam; - //SlurpOAM(oam,win->oam,win->num); struct MyOam { @@ -126,9 +123,6 @@ LRESULT OamView_OnPaint(HWND hwnd, oamview_struct *win, WPARAM wParam, LPARAM lP char text[80]; u16 bitmap[256*192]; - u8 bitmap_alpha[256*192]; - u8 type[256*192]; - u8 prio[256*192]; BITMAPV4HEADER bmi; u16 i; s16 x = 0, y = 0; @@ -148,9 +142,6 @@ LRESULT OamView_OnPaint(HWND hwnd, oamview_struct *win, WPARAM wParam, LPARAM lP for(i = 0; i < 256*192; ++i) { bitmap[i] = 0x7F0F; - bitmap_alpha[i] = 0; - type[i] = 0; - prio[i] = 4; } hdc = BeginPaint(hwnd, &ps); @@ -220,10 +211,9 @@ LRESULT OamView_OnPaint(HWND hwnd, oamview_struct *win, WPARAM wParam, LPARAM lP SetWindowText(GetDlgItem(hwnd, IDC_PROP1), ""); } - GPUEngineBase copy = *win->gpu; for(i = 0; i < 192; ++i) { - copy.SpriteRenderDebug(i, (u16*)(bitmap + i*256), bitmap_alpha + i*256, type + i*256, prio + i*256); + win->gpu->SpriteRenderDebug(i, (u16*)(bitmap + i*256)); } u32 width = dimm_int[(oam->attr1>>14)][(oam->attr0>>14)][0];