@@ -18,6 +18,7 @@ Bitmap_Z::~Bitmap_Z()
1818 Reset ();
1919}
2020
21+ #pragma dont_inline on
2122void Bitmap_Z::Init () {
2223 m_Flag = 0 ;
2324 Bitmap_Z::EnableFlag (0x14 );
@@ -27,16 +28,15 @@ void Bitmap_Z::Init() {
2728 m_SizeY = 0 ;
2829 m_TrueFormat = 0 ;
2930 m_UnkU8_0x31 = 4 ;
30- m_TexID = - 1 ;
31+ m_TexID = INVALID_TEXID ;
3132 m_Transp = -1 ;
3233 m_MipmapCount = 0 ;
3334 m_PrecalculatedSize = 0 ;
3435 m_PalFormat = PAL_8888;
3536}
36-
37- void Bitmap_Z::Invalidate () {
38- // stub
39- };
37+ // void Bitmap_Z::Invalidate() {
38+ // //stub
39+ // };
4040
4141void Bitmap_Z::Reset () {
4242 Invalidate ();
@@ -52,13 +52,26 @@ void Bitmap_Z::Reset() {
5252
5353 Init ();
5454}
55-
56- void Bitmap_Z::InitBmap (S32 m_Width , S32 m_Height , U8 m_Format, U8* m_Palette, U8 m_Datas )
55+ // far from complete
56+ void Bitmap_Z::InitBmap (S32 m_SizeX , S32 m_SizeY , U8 m_Format, U8* m_Palette, U8 unkBool )
5757{
58- // stub
58+ int lPaletteSize;
59+ int lBytePalleteSize;
60+ this ->m_SizeY = m_SizeY;
61+ this ->m_TexID = INVALID_TEXID;
62+ this ->m_SizeX = m_SizeX;
63+ this ->m_Format = m_Format;
64+ this ->m_TrueFormat = m_Format;
65+ this ->m_MipmapCount = 0 ;
66+ lPaletteSize = GetPalSize ();
67+ GetBytePerPixel ();
68+
69+ if (m_Format == BM_4 || m_Format == BM_8) {
70+ lBytePalleteSize = 4 * lPaletteSize;
71+ }
72+
5973}
6074
61- // far from matching
6275Float Bitmap_Z::GetBytePerPixel () {
6376 Float result; // st7
6477
@@ -87,25 +100,38 @@ Float Bitmap_Z::GetBytePerPixel() {
87100 result = 0.0 ;
88101 break ;
89102 default :
90- ExceptionFonc_Z (" FALSE" , " Bitmap_Z.cpp " , 117 , " Bitmap_Z::GetBytePerPixel" , 0 , 0 , 0 , 0 , 0 , 0 );
103+ ExceptionFonc_Z (" FALSE" , __FILE__, __LINE__ , " Bitmap_Z::GetBytePerPixel" , 0 , 0 , 0 , 0 , 0 , 0 );
91104 result = 0.0 ;
92105 break ;
93106 }
94107 return result;
95108}
96-
97- Float Bitmap_Z::GetDataSize ()
109+ S32 Bitmap_Z::GetDataSize ()
110+ {
111+ S32 lMipSize;
112+ S32 lDataSize;
113+ U8 lMipmapCount;
114+ lDataSize = (GetBytePerPixel () * ((Float)this ->m_SizeY * (Float)this ->m_SizeX ));
115+ lMipmapCount = this ->m_MipmapCount ;
116+ for ( lMipSize = lDataSize; lMipmapCount--; lMipSize += (lDataSize + 127 ) & ~127 )
117+ {
118+ lDataSize >>= 2 ;
119+ }
120+ return lMipSize;
121+ }
122+ // not matching. too lazy to fix for now
123+ S32 Bitmap_Z::GetPalSize ()
98124{
99- int dataSize; // eax
100- char mipmapCount; // cl
101- int mipSize; // edx
102-
103- dataSize = (GetBytePerPixel () * (this ->m_SizeX * this ->m_SizeY ));
104- mipmapCount = this ->m_MipmapCount ;
105- for ( mipSize = dataSize; mipmapCount; dataSize += (mipSize + 127 ) & 0xFFFFFF80 )// round up to nearest 128
125+ U8 palFormat = this ->m_PalFormat ;
126+ if ((palFormat >= PAL_ALPHA|PAL_565) && (palFormat != 9 && palFormat < 0x10 ))
127+ return 0 ;
128+ else
106129 {
107- mipSize / 4 ; // divide by 4
108- --mipmapCount;
130+ if (palFormat == PAL_565)
131+ return 256 ;
132+ else if (palFormat == PAL_3444)
133+ return 16 ;
109134 }
110- return dataSize ;
135+ ExceptionFonc_Z ( " FALSE " , __FILE__, __LINE__, " Bitmap_Z::GetPalSize " , 0 , 0 , 0 , 0 , 0 , 0 ) ;
111136}
137+ #pragma dont_inline off
0 commit comments