Mercurial > mm7
changeset 670:9824e2eeee30
fixed decorations animation
author | Gloval |
---|---|
date | Fri, 15 Mar 2013 01:51:51 +0400 |
parents | a5750c94b022 |
children | 2bb0e9da8302 |
files | LOD.cpp LOD.h PaletteManager.cpp Render.cpp Render.h Sprites.cpp Sprites.h mm7_2.cpp |
diffstat | 8 files changed, 338 insertions(+), 449 deletions(-) [+] |
line wrap: on
line diff
--- a/LOD.cpp Wed Mar 13 17:08:21 2013 +0600 +++ b/LOD.cpp Fri Mar 15 01:51:51 2013 +0400 @@ -227,140 +227,98 @@ //----- (004AC7C0) -------------------------------------------------------- int LODFile_Sprites::LoadSprite(const char *pContainerName, unsigned int uPaletteID) -{ signed int v3; // edi@1 - LODFile_Sprites *v4; // esi@1 - unsigned int v5; // eax@6 - signed int v6; // ecx@10 - Sprite *v7; // eax@11 - FILE *v8; // eax@12 - Sprite *v10; // edx@21 - int v11; // eax@21 - int v12; // eax@22 - unsigned __int8 v13; // zf@23 - unsigned __int8 v14; // sf@23 - LODSprite DstBuf; // [sp+Ch] [bp-3Ch]@12 - char *Str1; // [sp+34h] [bp-14h]@24 - LODSprite *v17; // [sp+38h] [bp-10h]@3 - int v18; // [sp+44h] [bp-4h]@12 + { + + FILE *sprite_file; // eax@12 + LODSprite temp_sprite_hdr; // [sp+Ch] [bp-3Ch]@12 + int i, sprite_indx; + + //find if already loaded + if ( pRenderer->pRenderD3D ) + { + for (i=0; i<uNumLoadedSprites;++i) + { + if (!(_strcmpi(pHardwareSprites[i].pName, pContainerName))) + return i; + } + } + else + { + for (i=0; i<uNumLoadedSprites;++i) + { + if (!(_strcmpi(pSpriteHeaders[i].pName, pContainerName))) + return i; + } + } + + if (uNumLoadedSprites == 1500 ) + return -1; + //if not loaded - load from file - auto a3 = uPaletteID; - v3 = 0; - v4 = this; - if ( pRenderer->pRenderD3D ) - { - if ( (signed int)this->uNumLoadedSprites > 0 ) - { - v17 = 0; - while ( _strcmpi(*(const char **)&v17->pName[(unsigned int)v4->pHardwareSprites], pContainerName) ) - { - ++v17; - ++v3; - if ( v3 >= (signed int)v4->uNumLoadedSprites ) - goto LABEL_6; - } - return v3; - } - } - else - { - if ( (signed int)this->uNumLoadedSprites > 0 ) - { - v17 = this->pSpriteHeaders; - while ( _strcmpi(v17->pName, pContainerName) ) - { - ++v17; - ++v3; - if ( v3 >= (signed int)v4->uNumLoadedSprites ) - goto LABEL_6; - } - return v3; - } - } -LABEL_6: - v5 = v4->uNumLoadedSprites; - if ( v5 == 1500 ) - return -1; - if ( pRenderer->pRenderD3D && v4->field_ECAC ) - { - if ( !v4->pHardwareSprites ) - { - v4->pHardwareSprites = (Sprite *)pAllocator->AllocNamedChunk(0, 0xEA60u, "hardSprites"); - v6 = 0; - do - { - v7 = &v4->pHardwareSprites[v6]; - ++v6; - v7->pName = 0; - v7->pTextureSurface = 0; - v7->pTexture = 0; - } - while ( v6 < 1500 ); - } - DstBuf.uHeight = 0; - DstBuf.uPaletteId = 0; - DstBuf.word_1A = 0; - DstBuf.pSpriteLines = 0; - DstBuf.pDecompressedBytes = 0; - v18 = 0; - v8 = FindContainer(pContainerName, 0); - if ( !v8 ) - { - v18 = -1; - //LODSprite::dtor(&DstBuf); - return -1; - } - fread(&DstBuf, 1u, 0x20u, v8); - v10 = v4->pHardwareSprites; - v11 = 5 * v4->uNumLoadedSprites; - v18 = -1; - pHardwareSprites[uNumLoadedSprites].uBufferWidth = DstBuf.uWidth; - pHardwareSprites[uNumLoadedSprites].uBufferHeight = DstBuf.uHeight; - pSpriteHeaders[uNumLoadedSprites].uWidth = DstBuf.uWidth; - pSpriteHeaders[uNumLoadedSprites].uHeight = DstBuf.uHeight; - //LODSprite::dtor(&DstBuf); - goto LABEL_29; - } - v12 = LoadSpriteFromFile( &v4->pSpriteHeaders[v5], pContainerName); - v4->pSpriteHeaders[v4->uNumLoadedSprites].word_1A = 0; - if ( v12 != -1 ) - { -LABEL_28: - v4->pSpriteHeaders[v4->uNumLoadedSprites].uPaletteId = pPaletteManager->LoadPalette( - v4->pSpriteHeaders[v4->uNumLoadedSprites].uPaletteId); -LABEL_29: + if ( pRenderer->pRenderD3D && field_ECAC ) + { + if ( !pHardwareSprites ) + { + pHardwareSprites = (Sprite *)pAllocator->AllocNamedChunk(0, 1500*sizeof(Sprite) , "hardSprites");//0xEA60u + for (i=0; i<1500;++i) + { + pHardwareSprites[i].pName=NULL; + pHardwareSprites[i].pTextureSurface=NULL; + pHardwareSprites[i].pTexture=NULL; + } + } + temp_sprite_hdr.uHeight = 0; + temp_sprite_hdr.uPaletteId = 0; + temp_sprite_hdr.word_1A = 0; + temp_sprite_hdr.pSpriteLines = 0; + temp_sprite_hdr.pDecompressedBytes = 0; + sprite_file = FindContainer(pContainerName, 0); + if ( !sprite_file ) + return -1; + fread(&temp_sprite_hdr, 1, sizeof(LODSprite), sprite_file); + pHardwareSprites[uNumLoadedSprites].uBufferWidth = temp_sprite_hdr.uWidth; + pHardwareSprites[uNumLoadedSprites].uBufferHeight = temp_sprite_hdr.uHeight; + pSpriteHeaders[uNumLoadedSprites].uWidth = temp_sprite_hdr.uWidth; + pSpriteHeaders[uNumLoadedSprites].uHeight = temp_sprite_hdr.uHeight; + } + else + { + sprite_indx = LoadSpriteFromFile( &pSpriteHeaders[uNumLoadedSprites], pContainerName); + pSpriteHeaders[uNumLoadedSprites].word_1A = 0; + + if ( sprite_indx != -1 ) + { + pSpriteHeaders[uNumLoadedSprites].uPaletteId = pPaletteManager->LoadPalette(pSpriteHeaders[uNumLoadedSprites].uPaletteId); + } + else + { + if ( uNumLoadedSprites<=0 ) + uNumLoadedSprites=0; + else + { + for (i=0; i<uNumLoadedSprites;++i) + { + if (!(_strcmpi(pSpriteHeaders[i].pName, "pending"))) + return i; + } + } + if ( LoadSpriteFromFile(&pSpriteHeaders[uNumLoadedSprites], "pending") == -1 ) + return -1; + pSpriteHeaders[uNumLoadedSprites].uPaletteId = pPaletteManager->LoadPalette(pSpriteHeaders[uNumLoadedSprites].uPaletteId); + } + } + if ( pRenderer->pRenderD3D ) - { - v4->pHardwareSprites[v4->uNumLoadedSprites].pName = (const char *)pAllocator->AllocNamedChunk( - v4->pHardwareSprites[v4->uNumLoadedSprites].pName, - 0x14u, - pContainerName); - strcpy((char *)pHardwareSprites[uNumLoadedSprites].pName, pContainerName); - v4->pHardwareSprites[v4->uNumLoadedSprites].uPaletteID = uPaletteID; - pRenderer->MoveSpriteToDevice(&pHardwareSprites[uNumLoadedSprites]); - } - ++v4->uNumLoadedSprites; - return v4->uNumLoadedSprites - 1; - } - v13 = v4->uNumLoadedSprites == 0; - v14 = (v4->uNumLoadedSprites & 0x80000000u) != 0; - v17 = 0; - if ( v14 | v13 ) - { -LABEL_27: - if ( LoadSpriteFromFile(&v4->pSpriteHeaders[v4->uNumLoadedSprites], "pending") == -1 ) - return -1; - goto LABEL_28; - } - Str1 = (char *)v4->pSpriteHeaders; - while ( _strcmpi(Str1, "pending") ) - { - v17 = (LODSprite *)((char *)v17 + 1); - Str1 += 40; - if ( (signed int)v17 >= (signed int)v4->uNumLoadedSprites ) - goto LABEL_27; - } - return (int)v17; -} + { + pHardwareSprites[uNumLoadedSprites].pName = (const char *)pAllocator->AllocNamedChunk(pHardwareSprites[uNumLoadedSprites].pName, 20, pContainerName); + strcpy((char *)pHardwareSprites[uNumLoadedSprites].pName, pContainerName); + pHardwareSprites[uNumLoadedSprites].uPaletteID = uPaletteID; + pRenderer->MoveSpriteToDevice(&pHardwareSprites[uNumLoadedSprites]); + } + ++uNumLoadedSprites; + return uNumLoadedSprites - 1; + + } //----- (004ACADA) -------------------------------------------------------- void LODFile_Sprites::ReleaseLostHardwareSprites()
--- a/LOD.h Wed Mar 13 17:08:21 2013 +0600 +++ b/LOD.h Fri Mar 15 01:51:51 2013 +0400 @@ -224,17 +224,17 @@ int _4ACC38(struct RenderBillboardTransform_local0 *a2, char a3); int _4AD2D1(struct RenderBillboardTransform_local0 *a2, int a3); - char pName[12]; - int uSpriteSize; - __int16 uWidth; - __int16 uHeight; - __int16 uPaletteId; - __int16 word_16; - __int16 uTexturePitch; - __int16 word_1A; - int uDecompressedSize; - struct LODSprite_stru0 *pSpriteLines; - void *pDecompressedBytes; + char pName[12]; //0 + int uSpriteSize; //C + __int16 uWidth; //10 + __int16 uHeight; //12 + __int16 uPaletteId; //14 + __int16 word_16; //16 + __int16 uTexturePitch; //18 + __int16 word_1A; //1a + int uDecompressedSize; //1c + struct LODSprite_stru0 *pSpriteLines; //20 + void *pDecompressedBytes; //24 }; #pragma pack(pop) @@ -272,7 +272,7 @@ unsigned int uOffsetToSubIndex; FILE *pOutputFileHandle;*/ struct LODSprite pSpriteHeaders[1500]; - unsigned int uNumLoadedSprites; + signed int uNumLoadedSprites; int field_ECA0; int field_ECA4; int field_ECA8;
--- a/PaletteManager.cpp Wed Mar 13 17:08:21 2013 +0600 +++ b/PaletteManager.cpp Fri Mar 15 01:51:51 2013 +0400 @@ -582,7 +582,7 @@ //----- (0048A300) -------------------------------------------------------- PaletteManager::PaletteManager(): - uNumTargetRBits(0), uNumTargetGBits(0),uNumTargetBBits(0) + uNumTargetRBits(0), uNumTargetGBits(0),uNumTargetBBits(0),_num_locked(0) { for (uint i = 0; i < 256; ++i) {
--- a/Render.cpp Wed Mar 13 17:08:21 2013 +0600 +++ b/Render.cpp Fri Mar 15 01:51:51 2013 +0400 @@ -9044,80 +9044,54 @@ } //----- (004A5048) -------------------------------------------------------- -HWLTexture *Render::MoveSpriteToDevice(Sprite *pSprite) -{ - Sprite *v2; // edi@1 - Render *v3; // ebx@1 - HWLTexture *result; // eax@1 - HWLTexture *v5; // esi@1 - //unsigned int v6; // ST18_4@2 - //RenderD3D *v7; // ecx@2 - Sprite *v8; // ebx@4 +bool Render::MoveSpriteToDevice( Sprite *pSprite ) + { + + HWLTexture *sprite_texture; // eax@1 unsigned __int16 *v9; // edx@5 LPVOID v10; // eax@5 - signed int v11; // ebx@5 - signed int v12; // ecx@6 - signed int v13; // edi@7 - HRESULT v14; // eax@10 DDSURFACEDESC2 Dst; // [sp+Ch] [bp-7Ch]@4 - v2 = pSprite; - v3 = this; - result = pD3DSprites.LoadTexture(pSprite->pName, pSprite->uPaletteID); - v5 = result; - if ( result ) - { - v3->_gpu_memory_used += 2 * result->uWidth * result->uHeight; - v2->uAreaX = result->field_30; - v2->uAreaY = result->field_34; - v2->uBufferWidth = result->field_18; - v2->uBufferHeight = result->field_1C; - v2->uAreaWidth = result->field_20; - v2->uAreaHeight = result->field_24; + sprite_texture = pD3DSprites.LoadTexture(pSprite->pName, pSprite->uPaletteID); + if ( sprite_texture ) + { + _gpu_memory_used += 2 * sprite_texture->uWidth * sprite_texture->uHeight; + pSprite->uAreaX = sprite_texture->uAreaX; + pSprite->uAreaY = sprite_texture->uAreaY; + pSprite->uBufferWidth = sprite_texture->uBufferWidth; + pSprite->uBufferHeight = sprite_texture->uBufferHeight; + pSprite->uAreaWidth = sprite_texture->uAreaWidth; + pSprite->uAreaHeight = sprite_texture->uAreaHeigth; //v6 = v3->uMinDeviceTextureDim; //v7 = v3->pRenderD3D; - if (!pRenderD3D->CreateTexture(result->uWidth, result->uHeight, &v2->pTextureSurface, &v2->pTexture, 1u, 0, uMinDeviceTextureDim)) + if (!pRenderD3D->CreateTexture(sprite_texture->uWidth, sprite_texture->uHeight, &pSprite->pTextureSurface, &pSprite->pTexture, 1u, 0, uMinDeviceTextureDim)) Abortf("HiScreen16::LoadTexture - D3Drend->CreateTexture() failed: %x", 0); //pSprite = v2->pTextureSurface; //pSprite = (Sprite *)pSprite->pName; //v8 = pSprite; - memset(&Dst, 0, 0x7Cu); + memset(&Dst, 0, sizeof(DDSURFACEDESC2)); Dst.dwSize = 124; - if ( LockSurface_DDraw4((IDirectDrawSurface4 *)v2->pTextureSurface, &Dst, DDLOCK_WAIT | DDLOCK_WRITEONLY) ) - { - v9 = v5->pPixels; - v10 = Dst.lpSurface; - v11 = 0; - if ( (signed int)v5->uHeight > 0 ) - { - v12 = (signed int)v5->uWidth >> 1; - do - { - v13 = 0; - if ( v12 > 0 ) + if ( LockSurface_DDraw4((IDirectDrawSurface4 *)pSprite->pTextureSurface, &Dst, DDLOCK_WAIT | DDLOCK_WRITEONLY) ) + { + v9 = sprite_texture->pPixels; + v10 = Dst.lpSurface; + for (int i=0; i<sprite_texture->uHeight; ++i) { - do - { - ++v13; + for (int j=0; j<sprite_texture->uWidth/2; ++j) + { *(int *)v10 = *(int *)v9; v9 += 2; v10 = (char *)v10 + 4; - } - while ( v13 < (signed int)v5->uWidth >> 1 ); + } + v10 = (char *)v10+Dst.lPitch-sprite_texture->uWidth*2; } - v12 = (signed int)v5->uWidth >> 1; - ++v11; - v10 = (char *)v10 + 4 * ((Dst.lPitch >> 2) - v12); - } - while ( v11 < (signed int)v5->uHeight ); - } - ErrD3D(v2->pTextureSurface->Unlock(0)); - } - free(v5->pPixels); - free(v5); - result = (HWLTexture *)1; - } - return result; + ErrD3D(pSprite->pTextureSurface->Unlock(0)); + } + free(sprite_texture->pPixels); + free(sprite_texture); + return true; + } + return false; } //----- (004A51CB) -------------------------------------------------------- @@ -11222,14 +11196,14 @@ fread(&uCompressedSize, 4, 1, pFile); auto pTex = new HWLTexture; - fread(&pTex->field_18, 4, 1, pFile); - fread(&pTex->field_1C, 4, 1, pFile); - fread(&pTex->field_20, 4, 1, pFile); - fread(&pTex->field_24, 4, 1, pFile); + fread(&pTex->uBufferWidth, 4, 1, pFile); + fread(&pTex->uBufferHeight, 4, 1, pFile); + fread(&pTex->uAreaWidth, 4, 1, pFile); + fread(&pTex->uAreaHeigth, 4, 1, pFile); fread(&pTex->uWidth, 4, 1, pFile); fread(&pTex->uHeight, 4, 1, pFile); - fread(&pTex->field_30, 4, 1, pFile); - fread(&pTex->field_34, 4, 1, pFile); + fread(&pTex->uAreaX, 4, 1, pFile); + fread(&pTex->uAreaY, 4, 1, pFile); pTex->pPixels = new unsigned __int16[pTex->uWidth * pTex->uHeight]; if (uCompressedSize)
--- a/Render.h Wed Mar 13 17:08:21 2013 +0600 +++ b/Render.h Fri Mar 15 01:51:51 2013 +0400 @@ -144,14 +144,14 @@ int field_C; int field_10; int field_14; - int field_18; - int field_1C; - int field_20; - int field_24; + int uBufferWidth; + int uBufferHeight; + int uAreaWidth; + int uAreaHeigth; unsigned int uWidth; unsigned int uHeight; - int field_30; - int field_34; + int uAreaX; + int uAreaY; unsigned __int16 *pPixels; }; #pragma pack(pop) @@ -334,7 +334,7 @@ void DrawProjectile(float srcX, float srcY, float a3, float a4, float dstX, float dstY, float a7, float a8, IDirect3DTexture2 *a9); void _4A4CC9(struct stru6_stru1_indoor_sw_billboard *a1, int a2); bool LoadTexture(const char *pName, unsigned int bMipMaps, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture); - HWLTexture *MoveSpriteToDevice(Sprite *pSprite); + bool MoveSpriteToDevice(Sprite *pSprite); void BeginScene(); void EndScene(); unsigned int _4A52F1(unsigned int this_, float a3);
--- a/Sprites.cpp Wed Mar 13 17:08:21 2013 +0600 +++ b/Sprites.cpp Fri Mar 15 01:51:51 2013 +0400 @@ -47,217 +47,180 @@ } //----- (0044D513) -------------------------------------------------------- -void SpriteFrameTable::InitializeSprite(unsigned int uSpriteID) -{ - //SpriteFrameTable *v2; // esi@1 - unsigned int v3; // ebx@3 - //char *v4; // edx@3 - //int v5; // eax@3 - SpriteFrame *v6; // ecx@5 - int v7; // eax@5 - __int16 v8; // ax@6 - //signed int v9; // edx@6 - //int v10; // ecx@6 - signed int v11; // edi@10 - __int16 v12; // ax@16 - int v13; // ecx@16 - size_t v14; // eax@19 - signed int v15; // edi@19 - __int16 v16; // ax@27 - int v17; // ecx@27 - signed int v18; // edi@29 - SpriteFrame *v19; // eax@30 - __int16 v20; // ax@45 - int v21; // ecx@45 - const char *v22; // [sp-8h] [bp-50h]@12 - const char *v23; // [sp-8h] [bp-50h]@21 - const char *v24; // [sp-8h] [bp-50h]@37 - const char *v25; // [sp-4h] [bp-4Ch]@12 - char *v26; // [sp-4h] [bp-4Ch]@21 - const char *v27; // [sp-4h] [bp-4Ch]@37 - char v28[3]; // [sp+9h] [bp-3Fh]@19 - char Str; // [sp+Ch] [bp-3Ch]@19 - char Size[20]; // [sp+2Ch] [bp-1Ch]@15 - char Source[4]; // [sp+40h] [bp-8h]@19 - int v32; // [sp+44h] [bp-4h]@19 - unsigned int uSpriteIDa; // [sp+50h] [bp+8h]@4 +void SpriteFrameTable::InitializeSprite( signed int uSpriteID ) + { + //SpriteFrameTable *v2; // esi@1 + unsigned int v3; // ebx@3 + //char *v4; // edx@3 + //int v5; // eax@3 + SpriteFrame *v6; // ecx@5 + int v7; // eax@5 + __int16 v8; // ax@6 + //signed int v9; // edx@6 + //int v10; // ecx@6 + signed int v11; // edi@10 + __int16 v12; // ax@16 + int v13; // ecx@16 + size_t v14; // eax@19 + signed int v15; // edi@19 + __int16 v16; // ax@27 + int v17; // ecx@27 + signed int v18; // edi@29 + SpriteFrame *v19; // eax@30 + __int16 v20; // ax@45 + int v21; // ecx@45 - //v2 = this; - if ( (signed int)uSpriteID <= (signed int)this->uNumSpriteFrames ) - { - if ( (uSpriteID & 0x80000000u) == 0 ) - { - v3 = uSpriteID; + char Str[32]; // [sp+Ch] [bp-3Ch]@19 + char sprite_name[20]; // [sp+2Ch] [bp-1Ch]@15 + char Source[4]; // [sp+40h] [bp-8h]@19 - auto uFlags = pSpriteSFrames[uSpriteID].uFlags; - if (uFlags & 0x7F) - { - pSpriteSFrames[uSpriteID].uFlags |= 0x80; - uSpriteIDa = 30 * uSpriteID + 12; - while ( 1 ) + //v2 = this; + if ( uSpriteID <= this->uNumSpriteFrames ) { - pSpriteSFrames[v3].uPaletteIndex = pPaletteManager->LoadPalette(pSpriteSFrames[uSpriteID].uPaletteID); - v6 = &pSpriteSFrames[uSpriteID]; - v7 = v6->uFlags; - if ( v7 & 0x10 ) - { - v8 = pSprites_LOD->LoadSprite(v6->pTextureName, v6->uPaletteID); - - for (uint i = 0; i < 8; ++i) - pSpriteSFrames[v3].pHwSpriteIDs[i] = v8; - goto LABEL_46; - } - if ( v7 & 0x10000 ) - { - v11 = 0; - do + if ( uSpriteID >= 0 ) { - switch ( v11 ) - { - case 3: - case 4: - case 5: - v25 = pSpriteSFrames[v3].pTextureName; - v22 = "%s4"; - goto LABEL_15; - case 2: - case 6: - v25 = pSpriteSFrames[v3].pTextureName; - v22 = "%s2"; - goto LABEL_15; - case 0: - case 1: - case 7: - v25 = pSpriteSFrames[v3].pTextureName; - v22 = "%s0"; -LABEL_15: - sprintf(Size, v22, v25); - break; - default: - break; - } - v12 = pSprites_LOD->LoadSprite(Size, pSpriteSFrames[v3].uPaletteID); - v13 = v11++ + uSpriteIDa; - *(short *)&pSpriteSFrames->pIconName[2 * v13] = v12; - } - while ( v11 < 8 ); - goto LABEL_46; - } - if ( !(v7 & 0x40) ) - break; - strcpy(Source, "stA"); - v32 = 0; - strcpy(&Str, v6->pTextureName); - v14 = strlen(&Str); - strcpy(&v28[v14], Source); - v15 = 0; - do - { - switch ( v15 ) - { - case 0: - v26 = pSpriteSFrames[v3].pTextureName; - v23 = "%s0"; - goto LABEL_26; - case 4: - v26 = &Str; - v23 = "%s4"; - goto LABEL_26; - case 3: - case 5: - v26 = &Str; - v23 = "%s3"; - goto LABEL_26; - case 2: - case 6: - v26 = pSpriteSFrames[v3].pTextureName; - v23 = "%s2"; - goto LABEL_26; - case 1: - case 7: - v26 = pSpriteSFrames[v3].pTextureName; - v23 = "%s1"; -LABEL_26: - sprintf(Size, v23, v26); - break; - default: - break; - } - v16 = pSprites_LOD->LoadSprite(Size, pSpriteSFrames[v3].uPaletteID); - v17 = v15++ + uSpriteIDa; - *(short *)&pSpriteSFrames->pIconName[2 * v17] = v16; - } - while ( v15 < 8 ); -LABEL_46: - if ( !(pSpriteSFrames[v3].uFlags & 1) ) - return; - uSpriteIDa += 30; - ++v3; + v3 = uSpriteID; + + auto uFlags = pSpriteSFrames[v3].uFlags; + if (!(uFlags & 0x0080)) //not loaded + { + pSpriteSFrames[v3].uFlags |= 0x80; //set loaded + while ( 1 ) + { + pSpriteSFrames[v3].uPaletteIndex = pPaletteManager->LoadPalette(pSpriteSFrames[v3].uPaletteID); + if ( uFlags & 0x10 ) //single frame per frame sequence + { + v8 = pSprites_LOD->LoadSprite(pSpriteSFrames[v3].pTextureName, pSpriteSFrames[v3].uPaletteID); + for (uint i = 0; i < 8; ++i) + { + + pSpriteSFrames[v3].pHwSpriteIDs[i] = v8; + } + + } + else if ( uFlags & 0x10000 ) + { + for (uint i = 0; i < 8; ++i) + { + switch ( i ) + { + case 3: + case 4: + case 5: + sprintf(sprite_name, "%s4", pSpriteSFrames[v3].pTextureName); + break; + case 2: + case 6: + sprintf(sprite_name, "%s2", pSpriteSFrames[v3].pTextureName); + break; + case 0: + case 1: + case 7: + sprintf(sprite_name, "%s0", pSpriteSFrames[v3].pTextureName); + break; + } + v12 = pSprites_LOD->LoadSprite(sprite_name, pSpriteSFrames[v3].uPaletteID); + + pSpriteSFrames[v3].pHwSpriteIDs[i]=v12; + } + + } + else if ( uFlags & 0x40 ) //part of monster fidgeting seq + { + strcpy(Source, "stA"); + strcpy(Str, pSpriteSFrames[v3].pTextureName); + v14 = strlen(Str); + strcpy(&Str[v14-3], Source); + for (uint i = 0; i < 8; ++i) + { + switch ( i ) + { + case 0: + sprintf(sprite_name, "%s0", pSpriteSFrames[v3].pTextureName); + break; + case 4: + sprintf(sprite_name, "%s4",&Str ); + break; + case 3: + case 5: + sprintf(sprite_name, "%s3",&Str ); + break; + case 2: + case 6: + sprintf(sprite_name, "%s2", pSpriteSFrames[v3].pTextureName); + break; + case 1: + case 7: + sprintf(sprite_name, "%s1", pSpriteSFrames[v3].pTextureName); + break; + } + v12 = pSprites_LOD->LoadSprite(sprite_name, pSpriteSFrames[v3].uPaletteID); + pSpriteSFrames[v3].pHwSpriteIDs[i]=v12; + } + } + + else + { + for (uint i = 0; i < 8; ++i) + + { + + if (((0x0100 << i) & pSpriteSFrames[v3].uFlags) ) //mirrors + { + switch ( i ) + { + case 1: + sprintf(sprite_name, "%s7", pSpriteSFrames[v3].pTextureName); + break; + case 2: + sprintf(sprite_name, "%s6", pSpriteSFrames[v3].pTextureName); + break; + case 3: + sprintf(sprite_name, "%s5", pSpriteSFrames[v3].pTextureName); + break; + case 4: + sprintf(sprite_name, "%s4", pSpriteSFrames[v3].pTextureName); + break; + + case 5: + sprintf(sprite_name, "%s3", pSpriteSFrames[v3].pTextureName); + break; + + case 6: + sprintf(sprite_name, "%s2", pSpriteSFrames[v3].pTextureName); + break; + case 7: + sprintf(sprite_name, "%s1", pSpriteSFrames[v3].pTextureName); + break; + } + } + else + { + sprintf(sprite_name, "%s%i", pSpriteSFrames[v3].pTextureName, i); + + } + v12 = pSprites_LOD->LoadSprite(sprite_name, pSpriteSFrames[v3].uPaletteID); + pSpriteSFrames[v3].pHwSpriteIDs[i]=v12; + + } + } + + if ( !(pSpriteSFrames[v3].uFlags & 1) ) + return; + ++v3; + } + } + } } - v18 = 0; - while ( 1 ) - { - v19 = &pSpriteSFrames[v3]; - if ( !((256 << v18) & v19->uFlags) ) - { - sprintf(Size, "%s%i", v19->pTextureName, v18); - goto LABEL_45; - } - if ( v18 == 1 ) - { - v27 = v19->pTextureName; - v24 = "%s7"; - goto LABEL_42; - } - if ( v18 == 2 ) - { - v27 = v19->pTextureName; - v24 = "%s6"; - goto LABEL_42; - } - if ( v18 == 3 ) - { - v27 = v19->pTextureName; - v24 = "%s5"; - goto LABEL_42; - } - if ( v18 == 5 ) - { - v27 = v19->pTextureName; - v24 = "%s3"; - goto LABEL_42; - } - if ( v18 == 6 ) - break; - if ( v18 == 7 ) - { - v27 = v19->pTextureName; - v24 = "%s1"; -LABEL_42: - sprintf(Size, v24, v27); - } -LABEL_45: - v20 = pSprites_LOD->LoadSprite(Size, pSpriteSFrames[v3].uPaletteID); - v21 = v18++ + uSpriteIDa; - *(short *)&pSpriteSFrames->pIconName[2 * v21] = v20; - if ( v18 >= 8 ) - goto LABEL_46; - } - v27 = v19->pTextureName; - v24 = "%s2"; - goto LABEL_42; - } } - } -} //----- (0044D813) -------------------------------------------------------- -unsigned int SpriteFrameTable::FastFindSprite(char *pSpriteName) -{ +signed int SpriteFrameTable::FastFindSprite( char *pSpriteName ) + { SpriteFrameTable *v2; // esi@1 int v3; // eax@1 - unsigned int result; // eax@2 + signed int result; // eax@2 v2 = this; BinarySearch(0, this->uNumEFrames, pSpriteName); @@ -511,14 +474,8 @@ } v2->uNumSpriteFrames = v4; v2->pSpriteSFrames = (SpriteFrame *)pAllocator->AllocNamedChunk(v2->pSpriteSFrames, 60 * v4, "S Frames"); - v2->pSpriteEFrames = (__int16 *)pAllocator->AllocNamedChunk( - v2->pSpriteEFrames, - 2 * v2->uNumSpriteFrames, - "E Frames"); - v2->pSpritePFrames = (SpriteFrame **)pAllocator->AllocNamedChunk( - v2->pSpritePFrames, - 4 * v2->uNumSpriteFrames, - "P Frames"); + v2->pSpriteEFrames = (__int16 *)pAllocator->AllocNamedChunk( v2->pSpriteEFrames, 2 * v2->uNumSpriteFrames, "E Frames"); + v2->pSpritePFrames = (SpriteFrame **)pAllocator->AllocNamedChunk( v2->pSpritePFrames, 4 * v2->uNumSpriteFrames, "P Frames"); if ( v2->pSpriteSFrames ) { v6 = File;
--- a/Sprites.h Wed Mar 13 17:08:21 2013 +0600 +++ b/Sprites.h Fri Mar 15 01:51:51 2013 +0400 @@ -3,20 +3,20 @@ /* 18 */ #pragma pack(push, 1) -struct Sprite +struct Sprite //28h { void Release(); - const char *pName; - int uPaletteID; - struct IDirectDrawSurface4 *pTextureSurface; - struct IDirect3DTexture2 *pTexture; - int uAreaX; - int uAreaY; - int uBufferWidth; - int uBufferHeight; - int uAreaWidth; - int uAreaHeight; + const char *pName; //0 + int uPaletteID; //4 + struct IDirectDrawSurface4 *pTextureSurface; //8 + struct IDirect3DTexture2 *pTexture; //ch + int uAreaX; //10h + int uAreaY; //14h + int uBufferWidth; //18h + int uBufferHeight; //1ch + int uAreaWidth; //20h + int uAreaHeight; //24h }; #pragma pack(pop) @@ -25,13 +25,13 @@ #pragma pack(push, 1) struct SpriteFrame { - char pIconName[12]; - char pTextureName[12]; - __int16 pHwSpriteIDs[8]; - int scale; - int uFlags; - __int16 uGlowRadius; - __int16 uPaletteID; + char pIconName[12]; + char pTextureName[12]; //c + __int16 pHwSpriteIDs[8]; //18h + int scale; //28h + int uFlags; //2c + __int16 uGlowRadius; //30 + __int16 uPaletteID; //32 __int16 uPaletteIndex; __int16 uAnimTime; __int16 uAnimLength; @@ -56,18 +56,18 @@ bool FromFileTxt(const char *Args); void ReleaseSFrames(); void ResetSomeSpriteFlags(); - void InitializeSprite(unsigned int uSpriteID); - unsigned int FastFindSprite(char *pSpriteName); + void InitializeSprite(signed int uSpriteID); + signed int FastFindSprite(char *pSpriteName); void BinarySearch(int a2, int a3, const char *pSpriteName); SpriteFrame *GetFrame(unsigned int uSpriteID, unsigned int uTime); SpriteFrame *GetFrameBy_x(unsigned int uSpriteID, signed int a3); - unsigned int uNumSpriteFrames; + signed int uNumSpriteFrames; unsigned int uNumEFrames;//field_4; int field_8; - struct SpriteFrame *pSpriteSFrames; - struct SpriteFrame **pSpritePFrames; - __int16 *pSpriteEFrames; + struct SpriteFrame *pSpriteSFrames; //0c + struct SpriteFrame **pSpritePFrames; //10h + __int16 *pSpriteEFrames; //14h }; #pragma pack(pop)
--- a/mm7_2.cpp Wed Mar 13 17:08:21 2013 +0600 +++ b/mm7_2.cpp Fri Mar 15 01:51:51 2013 +0400 @@ -10446,7 +10446,7 @@ } bool new_sky = false; -bool change_seasons = true; +bool change_seasons = false; //----- (00462C94) -------------------------------------------------------- bool MM_Main(const wchar_t *pCmdLine)