Skip to content

Commit

Permalink
Scale down PINBALL2.MID font.
Browse files Browse the repository at this point in the history
  • Loading branch information
MaikelChan committed Oct 31, 2021
1 parent d91c7be commit 2470dfb
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
5 changes: 5 additions & 0 deletions SpaceCadetPinball/GroupData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,7 @@ void DatFile::Finalize()
else
{
// PINBALL2.MID is an alternative font provided in 3DPB data
// Scaled down because it is too large for top text box

auto file = pinball::make_path_name("PINBALL2.MID");
auto fileHandle = fopen(file.c_str(), "rb");
Expand All @@ -459,7 +460,11 @@ void DatFile::Finalize()
fread(rcData, 1, fileSize, fileHandle);
fclose(fileHandle);

auto groupId = Groups.back()->GroupId + 1u;
AddMsgFont(rcData, "pbmsg_ft", true);

for (auto i = groupId; i < Groups.size(); i++)
Groups[i]->GetBitmap(0)->ScaleIndexed(0.84f, 0.84f);
}

delete[] rcData;
Expand Down
32 changes: 32 additions & 0 deletions SpaceCadetPinball/gdrv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,38 @@ gdrv_bitmap8::~gdrv_bitmap8()
}
}

void gdrv_bitmap8::ScaleIndexed(float scaleX, float scaleY)
{
if (!IndexedBmpPtr)
{
assertm(false, "Scaling non-indexed bitmap");
return;
}

int newWidht = static_cast<int>(Width * scaleX), newHeight = static_cast<int>(Height * scaleY);
if (Width == newWidht && Height == newHeight)
return;

auto newIndBuf = new char[newHeight * newWidht];
for (int dst = 0, y = 0; y < newHeight; y++)
{
for (int x = 0; x < newWidht; x++, dst++)
{
auto px = static_cast<int>(x / scaleX);
auto py = static_cast<int>(y / scaleY);
newIndBuf[dst] = IndexedBmpPtr[(py * IndexedStride) + px];
}
}

Stride = IndexedStride = Width = newWidht;
Height = newHeight;

delete IndexedBmpPtr;
IndexedBmpPtr = newIndBuf;
delete BmpBufPtr1;
BmpBufPtr1 = new ColorRgba[Stride * Height];
}

int gdrv::display_palette(ColorRgba* plt)
{
const uint32_t sysPaletteColors[]
Expand Down
1 change: 1 addition & 0 deletions SpaceCadetPinball/gdrv.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ struct gdrv_bitmap8
gdrv_bitmap8(int width, int height, bool indexed);
gdrv_bitmap8(const struct dat8BitBmpHeader& header);
~gdrv_bitmap8();
void ScaleIndexed(float scaleX, float scaleY);
ColorRgba* BmpBufPtr1;
char* IndexedBmpPtr;
int Width;
Expand Down

0 comments on commit 2470dfb

Please sign in to comment.