From ba5a0f304498eedaf436cf03ccf0b0a675738cac Mon Sep 17 00:00:00 2001 From: Muzychenko Andrey <33288308+k4zmu2a@users.noreply.github.com> Date: Wed, 29 Sep 2021 10:08:45 +0300 Subject: [PATCH] Compressed and encoded embedded 3DPB font. Exposed ImGui function for decompressing embedded data. --- CMakeLists.txt | 2 ++ SpaceCadetPinball/EmbeddedData.cpp | 46 ++++++++++++++++++++++++++++++ SpaceCadetPinball/EmbeddedData.h | 8 ++++++ SpaceCadetPinball/imgui.h | 3 ++ SpaceCadetPinball/imgui_draw.cpp | 13 +++++++++ SpaceCadetPinball/score.cpp | 20 ++++++------- 6 files changed, 82 insertions(+), 10 deletions(-) create mode 100644 SpaceCadetPinball/EmbeddedData.cpp create mode 100644 SpaceCadetPinball/EmbeddedData.h diff --git a/CMakeLists.txt b/CMakeLists.txt index fd3585c..97d88ce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,8 @@ endforeach() set(SOURCE_FILES SpaceCadetPinball/control.cpp SpaceCadetPinball/control.h + SpaceCadetPinball/EmbeddedData.cpp + SpaceCadetPinball/EmbeddedData.h SpaceCadetPinball/fullscrn.cpp SpaceCadetPinball/fullscrn.h SpaceCadetPinball/gdrv.cpp diff --git a/SpaceCadetPinball/EmbeddedData.cpp b/SpaceCadetPinball/EmbeddedData.cpp new file mode 100644 index 0000000..9ed514e --- /dev/null +++ b/SpaceCadetPinball/EmbeddedData.cpp @@ -0,0 +1,46 @@ +#include "EmbeddedData.h" + +#if 1 +// File: './PB_MSGFT.bin' (21702 bytes) +// Exported using binary_to_compressed_c.cpp +const char EmbeddedData::PB_MSGFT_bin_compressed_data_base85[5380 + 1] = + "7])#######>s+cc'/###Y[fi'.Y`+V*KI@%CtjT%QRR8%D[eW$G$^m&MQ>3'QK#n&FnJm&Vp:0(SWPN'SgYn&E09q%`sYn&V9B6&Z#dn&Hnj5&8uhV$Q?p2'L0K6&;@@<$SA`.2EIes$" + "RTp6&A.MZ#?@R8%]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8g$&g5x9f$nwTWJ']jk=-3^^m2vZ8@(#O,W8$Gj9DZRV49/J=P;" + "``a;&#pbJ28k)eAA`/s+j&BH>:oB&&g1<-N:md$bSYm8#u^7).4H0&q3n0#B[G&#" + "%baa*`3t,;Nm>v]^JtC(mC:/%*WN7:aarL7;f[=-XbnHbSm`I&Z?ap7[pZ@1dIa:8FZkL:p,kRM^$lf%92@v&mCeA-XHFK&t/c9BBP)CZSu>*(]G8l#>aDL'k$XRf2Nn-8V8*lb`69FF3N@uNe+.AYXS9ALPSV/-Y$record_labeled(fieldName) + fullscrn::GetResolution(); - auto dimensions = reinterpret_cast(loader::loader_table->field( dimensionsId, - FieldTypes::ShortArray)); + auto dimensions = reinterpret_cast(loader::loader_table->field(dimensionsId, + FieldTypes::ShortArray)); if (!dimensions) { memory::free(score); @@ -73,7 +69,9 @@ void score::load_msg_font_3DPB(LPCSTR lpName) { if (strcmp(lpName, "pbmsg_ft") != 0) return; - auto rcData = reinterpret_cast(PB_MSGFT_bin); + + auto rcData = reinterpret_cast(ImFontAtlas::DecompressCompressedBase85Data( + EmbeddedData::PB_MSGFT_bin_compressed_data_base85)); auto fontp = memory::allocate(); msg_fontp = fontp; @@ -98,6 +96,7 @@ void score::load_msg_font_3DPB(LPCSTR lpName) { memory::free(msg_fontp); msg_fontp = nullptr; + IM_FREE(rcData); return; } @@ -141,6 +140,7 @@ void score::load_msg_font_3DPB(LPCSTR lpName) } memory::free(tmpCharBur); + IM_FREE(rcData); if (charInd != 128) unload_msg_font(); } @@ -207,7 +207,7 @@ void score::erase(scoreStruct* score, int blitFlag) score->OffsetX, score->OffsetY); else - gdrv::fill_bitmap(&render::vscreen, score->Width, score->Height, score->OffsetX, score->OffsetY, 0); + gdrv::fill_bitmap(&render::vscreen, score->Width, score->Height, score->OffsetX, score->OffsetY, 0); } } @@ -246,7 +246,7 @@ void score::update(scoreStruct* score) else gdrv::copy_bitmap(&render::vscreen, width, height, x, y, bmp, 0, 0); } - } + } } }