Skip to content

Commit 0798b3c

Browse files
committed
lots of Bitmap_Z stuff
1 parent 2b0e393 commit 0798b3c

File tree

2 files changed

+56
-26
lines changed

2 files changed

+56
-26
lines changed

src/Engine/Bitmap_Z.cpp

Lines changed: 48 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Bitmap_Z::~Bitmap_Z()
1818
Reset();
1919
}
2020

21+
#pragma dont_inline on
2122
void 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

4141
void 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
6275
Float 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

src/Engine/includes/Bitmap_Z.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#include "ResourceObject_Z.h"
44
#include "Types_Z.h"
55

6+
#define INVALID_TEXID -1
7+
68
enum BmFormat_Z
79
{
810
BM_4 = 0x01 , // 4 Bits Indexed RGB
@@ -46,18 +48,20 @@ class Bitmap_Z : public ResourceObject_Z
4648
virtual ~Bitmap_Z();
4749
virtual void Load(void* a1);
4850
virtual void Clean();
49-
void InitBmap(S32 m_Width, S32 m_Height, U8 m_Format, U8* m_Palette, U8 m_Datas);
51+
void InitBmap(S32 m_SizeX, S32 m_SizeY, U8 m_Format, U8* m_Palette, U8 unkBool);
5052
void EnableFlag(S16 i_Flag) {m_Flag|=i_Flag;}
53+
S32 GetFormat() {return m_Format;}
5154
void Reset();
5255
void Invalidate();
5356
Float GetBytePerPixel();
54-
Float GetDataSize();
57+
S32 GetPalSize();
58+
S32 GetDataSize();
5559
private:
5660
void* m_Datas;
5761
void* m_Palette;
5862
S16 m_TexID;
59-
U32 m_SizeX;
60-
U32 m_SizeY;
63+
S32 m_SizeX;
64+
S32 m_SizeY;
6165
U32 m_PrecalculatedSize;
6266
U8 m_Format;
6367
U8 m_TrueFormat;

0 commit comments

Comments
 (0)