mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-09-23 14:53:52 +00:00
Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
24f43b973a | ||
|
649d78a61b | ||
|
836fc95f4a | ||
|
5b95fd8c6b | ||
|
b55a508686 | ||
|
47291cbf1d | ||
|
01e6ff4f5d | ||
|
d828eacd38 | ||
|
b37b0a4f8a |
@@ -28,3 +28,9 @@ The Unarchiver:
|
|||||||
Copyright (C) 2006-2013 Dag Ågren
|
Copyright (C) 2006-2013 Dag Ågren
|
||||||
|
|
||||||
Distributed under the LGPLv2 license (See unpacktool/LICENSE.txt)
|
Distributed under the LGPLv2 license (See unpacktool/LICENSE.txt)
|
||||||
|
|
||||||
|
|
||||||
|
MACE Audio decoder:
|
||||||
|
Copyright (c) 2002 Laszlo Torok <torokl@alpha.dfmk.hu>
|
||||||
|
|
||||||
|
Distributed under the LGPLv2 license (See macedec.cpp comments)
|
||||||
|
@@ -1,3 +1,5 @@
|
|||||||
|
rmdir /S /Q Packaged
|
||||||
|
|
||||||
mkdir Packaged
|
mkdir Packaged
|
||||||
mkdir Packaged\Houses
|
mkdir Packaged\Houses
|
||||||
mkdir Packaged\WinCursors
|
mkdir Packaged\WinCursors
|
||||||
|
@@ -90,3 +90,11 @@ The "unpacktool" utility is heavily based on code from The Unarchiver.
|
|||||||
Copyright (C) 2006-2013 Dag Ågren
|
Copyright (C) 2006-2013 Dag Ågren
|
||||||
|
|
||||||
Distributed under the LGPLv2 license (See license_lgplv2.txt)
|
Distributed under the LGPLv2 license (See license_lgplv2.txt)
|
||||||
|
|
||||||
|
|
||||||
|
FFmpeg:
|
||||||
|
|
||||||
|
The "gpr2gpa" tool uses MACE decompression code from FFmpeg.
|
||||||
|
Copyright (c) 2002 Laszlo Torok <torokl@alpha.dfmk.hu>
|
||||||
|
|
||||||
|
Distributed under the LGPLv2 license (See license_lgplv2.txt)
|
||||||
|
@@ -144,7 +144,7 @@ void DoAboutFramework (void)
|
|||||||
|
|
||||||
surface->DrawString(Point::Create(horizontalOffset, verticalPoint + spacing * 16), PSTR("For more information, please see the accompanying documentation."), blackColor, font);
|
surface->DrawString(Point::Create(horizontalOffset, verticalPoint + spacing * 16), PSTR("For more information, please see the accompanying documentation."), blackColor, font);
|
||||||
|
|
||||||
surface->DrawString(Point::Create(horizontalOffset, windowRect.bottom - 16), PSTR("Build: " __TIMESTAMP__ " " ABOUT_DIALOG_CONFIGURATION_TAG), blackColor, fontLight);
|
surface->DrawString(Point::Create(horizontalOffset, windowRect.bottom - 16), PSTR("Build: " __DATE__ " " __TIME__ " " ABOUT_DIALOG_CONFIGURATION_TAG), blackColor, fontLight);
|
||||||
|
|
||||||
DrawDefaultButton(dialog);
|
DrawDefaultButton(dialog);
|
||||||
|
|
||||||
|
@@ -62,17 +62,17 @@ void DrawBanner (Point *topLeft)
|
|||||||
topLeft->v = wholePage.top;
|
topLeft->v = wholePage.top;
|
||||||
partPage = wholePage;
|
partPage = wholePage;
|
||||||
partPage.bottom = partPage.top + 190;
|
partPage.bottom = partPage.top + 190;
|
||||||
LoadScaledGraphic(workSrcMap, kBannerPageTopPICT, &partPage);
|
LoadScaledGraphicCustom(workSrcMap, kBannerPageTopPICT, &partPage);
|
||||||
|
|
||||||
partPage = wholePage;
|
partPage = wholePage;
|
||||||
partPage.top = partPage.bottom - 30;
|
partPage.top = partPage.bottom - 30;
|
||||||
mapBounds = partPage;
|
mapBounds = partPage;
|
||||||
ZeroRectCorner(&mapBounds);
|
ZeroRectCorner(&mapBounds);
|
||||||
theErr = CreateOffScreenGWorld(&tempMap, &mapBounds, kPreferredPixelFormat);
|
theErr = CreateOffScreenGWorld(&tempMap, &mapBounds, kPreferredPixelFormat);
|
||||||
LoadGraphic(tempMap, kBannerPageBottomPICT);
|
LoadGraphicCustom(tempMap, kBannerPageBottomPICT);
|
||||||
|
|
||||||
theErr = CreateOffScreenGWorld(&tempMask, &mapBounds, GpPixelFormats::kBW1);
|
theErr = CreateOffScreenGWorld(&tempMask, &mapBounds, GpPixelFormats::kBW1);
|
||||||
LoadGraphic(tempMask, kBannerPageBottomMask);
|
LoadGraphicCustom(tempMask, kBannerPageBottomMask);
|
||||||
|
|
||||||
CopyMask((BitMap *)*GetGWorldPixMap(tempMap),
|
CopyMask((BitMap *)*GetGWorldPixMap(tempMap),
|
||||||
(BitMap *)*GetGWorldPixMap(tempMask),
|
(BitMap *)*GetGWorldPixMap(tempMask),
|
||||||
@@ -232,10 +232,10 @@ void DisplayStarsRemaining(void)
|
|||||||
NumToString((long)numStarsRemaining, theStr);
|
NumToString((long)numStarsRemaining, theStr);
|
||||||
|
|
||||||
if (numStarsRemaining < 2)
|
if (numStarsRemaining < 2)
|
||||||
LoadScaledGraphic(surface, kStarRemainingPICT, &bounds);
|
LoadScaledGraphicCustom(surface, kStarRemainingPICT, &bounds);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LoadScaledGraphic(surface, kStarsRemainingPICT, &bounds);
|
LoadScaledGraphicCustom(surface, kStarsRemainingPICT, &bounds);
|
||||||
const Point textPoint = Point::Create(bounds.left + 102 - (appFont->MeasurePStr(theStr) / 2), bounds.top + 23);
|
const Point textPoint = Point::Create(bounds.left + 102 - (appFont->MeasurePStr(theStr) / 2), bounds.top + 23);
|
||||||
ColorText(surface, textPoint, theStr, 4L, appFont);
|
ColorText(surface, textPoint, theStr, 4L, appFont);
|
||||||
}
|
}
|
||||||
|
@@ -88,9 +88,9 @@ void DoPause (void)
|
|||||||
QSetRect(&bounds, 0, 0, 214, 54);
|
QSetRect(&bounds, 0, 0, 214, 54);
|
||||||
CenterRectInRect(&bounds, &houseRect);
|
CenterRectInRect(&bounds, &houseRect);
|
||||||
if (isEscPauseKey)
|
if (isEscPauseKey)
|
||||||
LoadScaledGraphic(surface, kEscPausePictID, &bounds);
|
LoadScaledGraphicCustom(surface, kEscPausePictID, &bounds);
|
||||||
else
|
else
|
||||||
LoadScaledGraphic(surface, kTabPausePictID, &bounds);
|
LoadScaledGraphicCustom(surface, kTabPausePictID, &bounds);
|
||||||
|
|
||||||
const KeyDownStates *theKeys = nullptr;
|
const KeyDownStates *theKeys = nullptr;
|
||||||
|
|
||||||
|
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
#define GP_BUILD_VERSION_MAJOR 1
|
#define GP_BUILD_VERSION_MAJOR 1
|
||||||
#define GP_BUILD_VERSION_MINOR 0
|
#define GP_BUILD_VERSION_MINOR 0
|
||||||
#define GP_BUILD_VERSION_UPDATE 0
|
#define GP_BUILD_VERSION_UPDATE 1
|
||||||
|
|
||||||
#define GP_APPLICATION_VERSION_STRING "1.0.0"
|
#define GP_APPLICATION_VERSION_STRING "1.0.1"
|
||||||
#define GP_APPLICATION_COPYRIGHT_STRING "2020 Eric Lasota"
|
#define GP_APPLICATION_COPYRIGHT_STRING "2020 Eric Lasota"
|
||||||
#define GP_APPLICATION_WEBSITE_STRING "https://github.com/elasota/Aerofoil"
|
#define GP_APPLICATION_WEBSITE_STRING "https://github.com/elasota/Aerofoil"
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
static unsigned char gs_shaderData[] = {
|
static unsigned char gs_shaderData[] = {
|
||||||
68, 88, 66, 67, 123, 171, 231, 206, 83, 178, 250, 149, 189, 168, 129,
|
68, 88, 66, 67, 22, 132, 178, 62, 124, 31, 180, 122, 2, 1, 47,
|
||||||
29, 12, 186, 195, 194, 1, 0, 0, 0, 24, 9, 0, 0, 5, 0,
|
236, 0, 128, 56, 7, 1, 0, 0, 0, 240, 7, 0, 0, 5, 0,
|
||||||
0, 0, 52, 0, 0, 0, 172, 2, 0, 0, 4, 3, 0, 0, 56,
|
0, 0, 52, 0, 0, 0, 172, 2, 0, 0, 4, 3, 0, 0, 56,
|
||||||
3, 0, 0, 156, 8, 0, 0, 82, 68, 69, 70, 112, 2, 0, 0,
|
3, 0, 0, 116, 7, 0, 0, 82, 68, 69, 70, 112, 2, 0, 0,
|
||||||
1, 0, 0, 0, 180, 0, 0, 0, 3, 0, 0, 0, 28, 0, 0,
|
1, 0, 0, 0, 180, 0, 0, 0, 3, 0, 0, 0, 28, 0, 0,
|
||||||
0, 0, 4, 255, 255, 0, 137, 0, 0, 72, 2, 0, 0, 124, 0,
|
0, 0, 4, 255, 255, 0, 137, 0, 0, 72, 2, 0, 0, 124, 0,
|
||||||
0, 0, 2, 0, 0, 0, 4, 0, 0, 0, 4, 0, 0, 0, 255,
|
0, 0, 2, 0, 0, 0, 4, 0, 0, 0, 4, 0, 0, 0, 255,
|
||||||
@@ -54,13 +54,13 @@ static unsigned char gs_shaderData[] = {
|
|||||||
1, 0, 0, 0, 8, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0,
|
1, 0, 0, 0, 8, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0,
|
||||||
0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 15, 0,
|
0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 15, 0,
|
||||||
0, 0, 83, 86, 95, 84, 65, 82, 71, 69, 84, 0, 171, 171, 83,
|
0, 0, 83, 86, 95, 84, 65, 82, 71, 69, 84, 0, 171, 171, 83,
|
||||||
72, 68, 82, 92, 5, 0, 0, 64, 0, 0, 0, 87, 1, 0, 0,
|
72, 68, 82, 52, 4, 0, 0, 64, 0, 0, 0, 13, 1, 0, 0,
|
||||||
89, 0, 0, 4, 70, 142, 32, 0, 0, 0, 0, 0, 3, 0, 0,
|
89, 0, 0, 4, 70, 142, 32, 0, 0, 0, 0, 0, 3, 0, 0,
|
||||||
0, 88, 24, 0, 4, 0, 112, 16, 0, 0, 0, 0, 0, 68, 68,
|
0, 88, 24, 0, 4, 0, 112, 16, 0, 0, 0, 0, 0, 68, 68,
|
||||||
0, 0, 88, 16, 0, 4, 0, 112, 16, 0, 1, 0, 0, 0, 85,
|
0, 0, 88, 16, 0, 4, 0, 112, 16, 0, 1, 0, 0, 0, 85,
|
||||||
85, 0, 0, 98, 16, 0, 3, 50, 16, 16, 0, 1, 0, 0, 0,
|
85, 0, 0, 98, 16, 0, 3, 50, 16, 16, 0, 1, 0, 0, 0,
|
||||||
101, 0, 0, 3, 242, 32, 16, 0, 0, 0, 0, 0, 104, 0, 0,
|
101, 0, 0, 3, 242, 32, 16, 0, 0, 0, 0, 0, 104, 0, 0,
|
||||||
2, 4, 0, 0, 0, 65, 0, 0, 5, 50, 0, 16, 0, 0, 0,
|
2, 3, 0, 0, 0, 65, 0, 0, 5, 50, 0, 16, 0, 0, 0,
|
||||||
0, 0, 70, 16, 16, 0, 1, 0, 0, 0, 27, 0, 0, 5, 50,
|
0, 0, 70, 16, 16, 0, 1, 0, 0, 0, 27, 0, 0, 5, 50,
|
||||||
0, 16, 0, 0, 0, 0, 0, 70, 0, 16, 0, 0, 0, 0, 0,
|
0, 16, 0, 0, 0, 0, 0, 70, 0, 16, 0, 0, 0, 0, 0,
|
||||||
54, 0, 0, 8, 194, 0, 16, 0, 0, 0, 0, 0, 2, 64, 0,
|
54, 0, 0, 8, 194, 0, 16, 0, 0, 0, 0, 0, 2, 64, 0,
|
||||||
@@ -93,68 +93,48 @@ static unsigned char gs_shaderData[] = {
|
|||||||
0, 0, 0, 55, 0, 0, 12, 242, 0, 16, 0, 0, 0, 0, 0,
|
0, 0, 0, 55, 0, 0, 12, 242, 0, 16, 0, 0, 0, 0, 0,
|
||||||
6, 0, 16, 0, 0, 0, 0, 0, 70, 14, 16, 0, 1, 0, 0,
|
6, 0, 16, 0, 0, 0, 0, 0, 70, 14, 16, 0, 1, 0, 0,
|
||||||
0, 2, 64, 0, 0, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0,
|
0, 2, 64, 0, 0, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0,
|
||||||
128, 63, 0, 0, 128, 63, 57, 0, 0, 8, 18, 0, 16, 0, 1,
|
128, 63, 0, 0, 128, 63, 29, 0, 0, 7, 18, 0, 16, 0, 1,
|
||||||
0, 0, 0, 10, 128, 32, 0, 0, 0, 0, 0, 2, 0, 0, 0,
|
0, 0, 0, 1, 64, 0, 0, 0, 0, 0, 0, 58, 0, 16, 0,
|
||||||
1, 64, 0, 0, 0, 0, 0, 0, 31, 0, 4, 3, 10, 0, 16,
|
0, 0, 0, 0, 13, 0, 4, 3, 10, 0, 16, 0, 1, 0, 0,
|
||||||
0, 1, 0, 0, 0, 29, 0, 0, 10, 114, 0, 16, 0, 1, 0,
|
0, 57, 0, 0, 8, 18, 0, 16, 0, 1, 0, 0, 0, 10, 128,
|
||||||
0, 0, 2, 64, 0, 0, 28, 46, 77, 59, 28, 46, 77, 59, 28,
|
32, 0, 0, 0, 0, 0, 2, 0, 0, 0, 1, 64, 0, 0, 0,
|
||||||
46, 77, 59, 0, 0, 0, 0, 70, 2, 16, 0, 0, 0, 0, 0,
|
0, 0, 0, 16, 0, 0, 10, 34, 0, 16, 0, 1, 0, 0, 0,
|
||||||
56, 0, 0, 10, 114, 0, 16, 0, 2, 0, 0, 0, 70, 2, 16,
|
70, 2, 16, 0, 0, 0, 0, 0, 2, 64, 0, 0, 154, 153, 153,
|
||||||
0, 0, 0, 0, 0, 2, 64, 0, 0, 82, 184, 78, 65, 82, 184,
|
62, 154, 153, 25, 63, 205, 204, 204, 61, 0, 0, 0, 0, 0, 0,
|
||||||
78, 65, 82, 184, 78, 65, 0, 0, 0, 0, 47, 0, 0, 5, 114,
|
0, 9, 66, 0, 16, 0, 1, 0, 0, 0, 10, 128, 32, 128, 65,
|
||||||
0, 16, 0, 3, 0, 0, 0, 70, 2, 16, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 1, 64, 0, 0,
|
||||||
56, 0, 0, 10, 114, 0, 16, 0, 3, 0, 0, 0, 70, 2, 16,
|
0, 0, 128, 63, 56, 0, 0, 8, 34, 0, 16, 0, 1, 0, 0,
|
||||||
0, 3, 0, 0, 0, 2, 64, 0, 0, 85, 85, 213, 62, 85, 85,
|
0, 26, 0, 16, 0, 1, 0, 0, 0, 10, 128, 32, 0, 0, 0,
|
||||||
213, 62, 85, 85, 213, 62, 0, 0, 0, 0, 25, 0, 0, 5, 114,
|
0, 0, 2, 0, 0, 0, 50, 0, 0, 9, 226, 0, 16, 0, 1,
|
||||||
0, 16, 0, 3, 0, 0, 0, 70, 2, 16, 0, 3, 0, 0, 0,
|
0, 0, 0, 6, 9, 16, 0, 0, 0, 0, 0, 166, 10, 16, 0,
|
||||||
50, 0, 0, 15, 114, 0, 16, 0, 3, 0, 0, 0, 70, 2, 16,
|
1, 0, 0, 0, 86, 5, 16, 0, 1, 0, 0, 0, 55, 32, 0,
|
||||||
0, 3, 0, 0, 0, 2, 64, 0, 0, 61, 10, 135, 63, 61, 10,
|
9, 114, 0, 16, 0, 0, 0, 0, 0, 6, 0, 16, 0, 1, 0,
|
||||||
135, 63, 61, 10, 135, 63, 0, 0, 0, 0, 2, 64, 0, 0, 174,
|
0, 0, 150, 7, 16, 0, 1, 0, 0, 0, 70, 2, 16, 0, 0,
|
||||||
71, 97, 189, 174, 71, 97, 189, 174, 71, 97, 189, 0, 0, 0, 0,
|
0, 0, 0, 47, 0, 0, 5, 114, 0, 16, 0, 0, 0, 0, 0,
|
||||||
55, 0, 0, 9, 114, 0, 16, 0, 1, 0, 0, 0, 70, 2, 16,
|
70, 2, 16, 0, 0, 0, 0, 0, 56, 0, 0, 10, 114, 0, 16,
|
||||||
0, 1, 0, 0, 0, 70, 2, 16, 0, 2, 0, 0, 0, 70, 2,
|
0, 0, 0, 0, 0, 70, 2, 16, 0, 0, 0, 0, 0, 2, 64,
|
||||||
16, 0, 3, 0, 0, 0, 16, 0, 0, 10, 130, 0, 16, 0, 1,
|
0, 0, 102, 102, 230, 63, 102, 102, 230, 63, 102, 102, 230, 63, 0,
|
||||||
0, 0, 0, 70, 2, 16, 0, 1, 0, 0, 0, 2, 64, 0, 0,
|
0, 0, 0, 25, 0, 0, 5, 114, 0, 16, 0, 0, 0, 0, 0,
|
||||||
154, 153, 153, 62, 154, 153, 25, 63, 205, 204, 204, 61, 0, 0, 0,
|
70, 2, 16, 0, 0, 0, 0, 0, 56, 0, 0, 10, 114, 0, 16,
|
||||||
0, 0, 0, 0, 9, 18, 0, 16, 0, 2, 0, 0, 0, 10, 128,
|
0, 1, 0, 0, 0, 86, 5, 16, 0, 0, 0, 0, 0, 2, 64,
|
||||||
32, 128, 65, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 1,
|
0, 0, 150, 246, 160, 189, 43, 199, 117, 63, 40, 177, 243, 60, 0,
|
||||||
64, 0, 0, 0, 0, 128, 63, 56, 0, 0, 8, 130, 0, 16, 0,
|
0, 0, 0, 50, 0, 0, 12, 114, 0, 16, 0, 1, 0, 0, 0,
|
||||||
1, 0, 0, 0, 58, 0, 16, 0, 1, 0, 0, 0, 10, 128, 32,
|
6, 0, 16, 0, 0, 0, 0, 0, 2, 64, 0, 0, 87, 203, 136,
|
||||||
0, 0, 0, 0, 0, 2, 0, 0, 0, 50, 0, 0, 9, 114, 0,
|
63, 86, 131, 197, 60, 225, 104, 227, 58, 0, 0, 0, 0, 70, 2,
|
||||||
16, 0, 1, 0, 0, 0, 70, 2, 16, 0, 1, 0, 0, 0, 6,
|
16, 0, 1, 0, 0, 0, 50, 0, 0, 12, 114, 32, 16, 0, 0,
|
||||||
0, 16, 0, 2, 0, 0, 0, 246, 15, 16, 0, 1, 0, 0, 0,
|
0, 0, 0, 166, 10, 16, 0, 0, 0, 0, 0, 2, 64, 0, 0,
|
||||||
29, 0, 0, 10, 114, 0, 16, 0, 2, 0, 0, 0, 2, 64, 0,
|
5, 9, 34, 60, 158, 151, 129, 60, 194, 240, 119, 63, 0, 0, 0,
|
||||||
0, 230, 174, 37, 61, 230, 174, 37, 61, 230, 174, 37, 61, 0, 0,
|
0, 70, 2, 16, 0, 1, 0, 0, 0, 54, 0, 0, 5, 130, 32,
|
||||||
0, 0, 70, 2, 16, 0, 1, 0, 0, 0, 56, 0, 0, 10, 114,
|
16, 0, 0, 0, 0, 0, 58, 0, 16, 0, 0, 0, 0, 0, 62,
|
||||||
0, 16, 0, 3, 0, 0, 0, 70, 2, 16, 0, 1, 0, 0, 0,
|
0, 0, 1, 83, 84, 65, 84, 116, 0, 0, 0, 32, 0, 0, 0,
|
||||||
2, 64, 0, 0, 145, 131, 158, 61, 145, 131, 158, 61, 145, 131, 158,
|
3, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 15, 0, 0,
|
||||||
61, 0, 0, 0, 0, 0, 0, 0, 10, 114, 0, 16, 0, 1, 0,
|
0, 4, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0,
|
||||||
0, 0, 70, 2, 16, 0, 1, 0, 0, 0, 2, 64, 0, 0, 174,
|
|
||||||
71, 97, 61, 174, 71, 97, 61, 174, 71, 97, 61, 0, 0, 0, 0,
|
|
||||||
56, 0, 0, 10, 114, 0, 16, 0, 1, 0, 0, 0, 70, 2, 16,
|
|
||||||
0, 1, 0, 0, 0, 2, 64, 0, 0, 110, 167, 114, 63, 110, 167,
|
|
||||||
114, 63, 110, 167, 114, 63, 0, 0, 0, 0, 47, 0, 0, 5, 114,
|
|
||||||
0, 16, 0, 1, 0, 0, 0, 70, 2, 16, 0, 1, 0, 0, 0,
|
|
||||||
56, 0, 0, 10, 114, 0, 16, 0, 1, 0, 0, 0, 70, 2, 16,
|
|
||||||
0, 1, 0, 0, 0, 2, 64, 0, 0, 154, 153, 25, 64, 154, 153,
|
|
||||||
25, 64, 154, 153, 25, 64, 0, 0, 0, 0, 25, 0, 0, 5, 114,
|
|
||||||
0, 16, 0, 1, 0, 0, 0, 70, 2, 16, 0, 1, 0, 0, 0,
|
|
||||||
55, 0, 0, 9, 114, 0, 16, 0, 0, 0, 0, 0, 70, 2, 16,
|
|
||||||
0, 2, 0, 0, 0, 70, 2, 16, 0, 3, 0, 0, 0, 70, 2,
|
|
||||||
16, 0, 1, 0, 0, 0, 21, 0, 0, 1, 29, 0, 0, 7, 18,
|
|
||||||
0, 16, 0, 1, 0, 0, 0, 1, 64, 0, 0, 0, 0, 0, 0,
|
|
||||||
58, 0, 16, 0, 0, 0, 0, 0, 13, 0, 4, 3, 10, 0, 16,
|
|
||||||
0, 1, 0, 0, 0, 54, 0, 0, 5, 242, 32, 16, 0, 0, 0,
|
|
||||||
0, 0, 70, 14, 16, 0, 0, 0, 0, 0, 62, 0, 0, 1, 83,
|
|
||||||
84, 65, 84, 116, 0, 0, 0, 42, 0, 0, 0, 4, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 2, 0, 0, 0, 22, 0, 0, 0, 4, 0, 0,
|
|
||||||
0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0,
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 4, 0, 0,
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0,
|
||||||
0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
0, 3, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace GpBinarizedShaders
|
namespace GpBinarizedShaders
|
||||||
|
@@ -544,7 +544,7 @@ bool GpDisplayDriverD3D11::InitResources(uint32_t virtualWidth, uint32_t virtual
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DXGI_FORMAT paletteTextureFormat = DXGI_FORMAT_R8G8B8A8_UNORM_SRGB;
|
DXGI_FORMAT paletteTextureFormat = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||||
|
|
||||||
// Palette texture
|
// Palette texture
|
||||||
{
|
{
|
||||||
|
@@ -93,7 +93,7 @@ GpDisplayDriverSurfaceD3D11 *GpDisplayDriverSurfaceD3D11::Create(ID3D11Device *d
|
|||||||
dxgiFormat = DXGI_FORMAT_R16_UINT;
|
dxgiFormat = DXGI_FORMAT_R16_UINT;
|
||||||
break;
|
break;
|
||||||
case GpPixelFormats::kRGB32:
|
case GpPixelFormats::kRGB32:
|
||||||
dxgiFormat = DXGI_FORMAT_R8G8B8A8_UNORM_SRGB;
|
dxgiFormat = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||||
break;
|
break;
|
||||||
case GpPixelFormats::kRGB24: // RGB24 is not supported as a surface format (PL must convert it)
|
case GpPixelFormats::kRGB24: // RGB24 is not supported as a surface format (PL must convert it)
|
||||||
default:
|
default:
|
||||||
|
@@ -347,6 +347,61 @@ void DrawSurface::DrawStringWrap(const Point &point, const Rect &constrainRect,
|
|||||||
m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);
|
m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct ErrorDiffusionWorkPixel
|
||||||
|
{
|
||||||
|
int16_t m_16[3];
|
||||||
|
uint8_t m_8[3];
|
||||||
|
};
|
||||||
|
|
||||||
|
static ErrorDiffusionWorkPixel ApplyErrorDiffusion(int16_t *errorDiffusionCurrentRow, uint8_t r, uint8_t g, uint8_t b, size_t col, size_t numCols)
|
||||||
|
{
|
||||||
|
ErrorDiffusionWorkPixel result;
|
||||||
|
|
||||||
|
const uint8_t rgb[] = { r, g, b };
|
||||||
|
|
||||||
|
for (size_t i = 0; i < 3; i++)
|
||||||
|
{
|
||||||
|
const int16_t targetColorMul16 = static_cast<int16_t>(rgb[i]) * 16 + errorDiffusionCurrentRow[col * 3 + i];
|
||||||
|
const int16_t targetColorRounded = (targetColorMul16 + 8) >> 4;
|
||||||
|
|
||||||
|
result.m_16[i] = targetColorRounded;
|
||||||
|
result.m_8[i] = static_cast<uint8_t>(std::max<int16_t>(std::min<int16_t>(targetColorRounded, 255), 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void RedistributeError(int16_t *errorDiffusionNextRow, int16_t *errorDiffusionCurrentRow, int16_t targetR, int16_t targetG, int16_t targetB, int16_t actualR, int16_t actualG, int16_t actualB, size_t col, size_t numCols)
|
||||||
|
{
|
||||||
|
int16_t rDiff = targetR - actualR;
|
||||||
|
int16_t gDiff = targetG - actualG;
|
||||||
|
int16_t bDiff = targetB - actualB;
|
||||||
|
|
||||||
|
errorDiffusionNextRow += col * 3;
|
||||||
|
errorDiffusionCurrentRow += col * 3;
|
||||||
|
|
||||||
|
if (col > 0)
|
||||||
|
{
|
||||||
|
errorDiffusionNextRow[-3] += rDiff * 3;
|
||||||
|
errorDiffusionNextRow[-2] += gDiff * 3;
|
||||||
|
errorDiffusionNextRow[-1] += bDiff * 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
errorDiffusionNextRow[0] += rDiff * 5;
|
||||||
|
errorDiffusionNextRow[1] += gDiff * 5;
|
||||||
|
errorDiffusionNextRow[2] += bDiff * 5;
|
||||||
|
|
||||||
|
if (col < numCols - 1)
|
||||||
|
{
|
||||||
|
errorDiffusionCurrentRow[3] += rDiff * 7;
|
||||||
|
errorDiffusionCurrentRow[4] += gDiff * 7;
|
||||||
|
errorDiffusionCurrentRow[5] += bDiff * 7;
|
||||||
|
|
||||||
|
errorDiffusionNextRow[3] += rDiff * 1;
|
||||||
|
errorDiffusionNextRow[4] += gDiff * 1;
|
||||||
|
errorDiffusionNextRow[5] += bDiff * 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void DrawSurface::DrawPicture(THandle<BitmapImage> pictHdl, const Rect &bounds)
|
void DrawSurface::DrawPicture(THandle<BitmapImage> pictHdl, const Rect &bounds)
|
||||||
{
|
{
|
||||||
@@ -478,6 +533,8 @@ void DrawSurface::DrawPicture(THandle<BitmapImage> pictHdl, const Rect &bounds)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PortabilityLayer::MemoryManager *memManager = PortabilityLayer::MemoryManager::GetInstance();
|
||||||
|
|
||||||
const uint32_t imageDataOffset = fileHeader.m_imageDataStart;
|
const uint32_t imageDataOffset = fileHeader.m_imageDataStart;
|
||||||
|
|
||||||
if (imageDataOffset > bmpSize)
|
if (imageDataOffset > bmpSize)
|
||||||
@@ -520,8 +577,31 @@ void DrawSurface::DrawPicture(THandle<BitmapImage> pictHdl, const Rect &bounds)
|
|||||||
{
|
{
|
||||||
const uint8_t *currentSourceRow = firstSourceRow;
|
const uint8_t *currentSourceRow = firstSourceRow;
|
||||||
uint8_t *currentDestRow = firstDestRow;
|
uint8_t *currentDestRow = firstDestRow;
|
||||||
|
|
||||||
|
int16_t *errorDiffusionBuffer = nullptr;
|
||||||
|
int16_t *errorDiffusionNextRow = nullptr;
|
||||||
|
int16_t *errorDiffusionCurrentRow = nullptr;
|
||||||
|
|
||||||
|
if (bpp == 16 || bpp == 24)
|
||||||
|
{
|
||||||
|
errorDiffusionBuffer = static_cast<int16_t*>(memManager->Alloc(sizeof(int16_t) * numCopyCols * 2 * 3));
|
||||||
|
if (!errorDiffusionBuffer)
|
||||||
|
return;
|
||||||
|
|
||||||
|
errorDiffusionNextRow = errorDiffusionBuffer;
|
||||||
|
errorDiffusionCurrentRow = errorDiffusionBuffer + numCopyCols * 3;
|
||||||
|
|
||||||
|
memset(errorDiffusionNextRow, 0, sizeof(int16_t) * numCopyCols * 3);
|
||||||
|
}
|
||||||
|
|
||||||
for (uint32_t row = 0; row < numCopyRows; row++)
|
for (uint32_t row = 0; row < numCopyRows; row++)
|
||||||
{
|
{
|
||||||
|
if (errorDiffusionBuffer)
|
||||||
|
{
|
||||||
|
std::swap(errorDiffusionCurrentRow, errorDiffusionNextRow);
|
||||||
|
memset(errorDiffusionNextRow, 0, sizeof(int16_t) * numCopyCols * 3);
|
||||||
|
}
|
||||||
|
|
||||||
assert(currentSourceRow >= imageDataStart && currentSourceRow <= imageDataStart + inDataSize);
|
assert(currentSourceRow >= imageDataStart && currentSourceRow <= imageDataStart + inDataSize);
|
||||||
|
|
||||||
if (bpp == 1)
|
if (bpp == 1)
|
||||||
@@ -599,7 +679,14 @@ void DrawSurface::DrawPicture(THandle<BitmapImage> pictHdl, const Rect &bounds)
|
|||||||
const unsigned int xg = (g << 5) | (g >> 2);
|
const unsigned int xg = (g << 5) | (g >> 2);
|
||||||
const unsigned int xb = (b << 5) | (b >> 2);
|
const unsigned int xb = (b << 5) | (b >> 2);
|
||||||
|
|
||||||
currentDestRow[destColIndex] = stdPalette->MapColorLUT(PortabilityLayer::RGBAColor::Create(xr, xg, xb, 255));
|
ErrorDiffusionWorkPixel wp = ApplyErrorDiffusion(errorDiffusionCurrentRow, xr, xg, xb, col, numCopyCols);
|
||||||
|
|
||||||
|
uint8_t colorIndex = stdPalette->MapColorLUT(PortabilityLayer::RGBAColor::Create(wp.m_8[0], wp.m_8[1], wp.m_8[2], 255));
|
||||||
|
PortabilityLayer::RGBAColor resultColor = stdPalette->GetColors()[colorIndex];
|
||||||
|
|
||||||
|
RedistributeError(errorDiffusionNextRow, errorDiffusionCurrentRow, wp.m_16[0], wp.m_16[1], wp.m_16[2], resultColor.r, resultColor.g, resultColor.b, col, numCopyCols);
|
||||||
|
|
||||||
|
currentDestRow[destColIndex] = colorIndex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -633,11 +720,14 @@ void DrawSurface::DrawPicture(THandle<BitmapImage> pictHdl, const Rect &bounds)
|
|||||||
const size_t srcColIndex = col + firstSourceCol;
|
const size_t srcColIndex = col + firstSourceCol;
|
||||||
const size_t destColIndex = col + firstDestCol;
|
const size_t destColIndex = col + firstDestCol;
|
||||||
|
|
||||||
const unsigned int b = currentSourceRow[srcColIndex * 3 + 0];
|
ErrorDiffusionWorkPixel wp = ApplyErrorDiffusion(errorDiffusionCurrentRow, currentSourceRow[srcColIndex * 3 + 2], currentSourceRow[srcColIndex * 3 + 1], currentSourceRow[srcColIndex * 3 + 0], col, numCopyCols);
|
||||||
const unsigned int g = currentSourceRow[srcColIndex * 3 + 1];
|
|
||||||
const unsigned int r = currentSourceRow[srcColIndex * 3 + 2];
|
|
||||||
|
|
||||||
currentDestRow[destColIndex] = stdPalette->MapColorLUT(PortabilityLayer::RGBAColor::Create(r, g, b, 255));
|
uint8_t colorIndex = stdPalette->MapColorLUT(PortabilityLayer::RGBAColor::Create(wp.m_8[0], wp.m_8[1], wp.m_8[2], 255));
|
||||||
|
PortabilityLayer::RGBAColor resultColor = stdPalette->GetColors()[colorIndex];
|
||||||
|
|
||||||
|
RedistributeError(errorDiffusionNextRow, errorDiffusionCurrentRow, wp.m_16[0], wp.m_16[1], wp.m_16[2], resultColor.r, resultColor.g, resultColor.b, col, numCopyCols);
|
||||||
|
|
||||||
|
currentDestRow[destColIndex] = colorIndex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -645,6 +735,9 @@ void DrawSurface::DrawPicture(THandle<BitmapImage> pictHdl, const Rect &bounds)
|
|||||||
currentSourceRow -= sourcePitch;
|
currentSourceRow -= sourcePitch;
|
||||||
currentDestRow += destPitch;
|
currentDestRow += destPitch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (errorDiffusionBuffer)
|
||||||
|
memManager->Release(errorDiffusionBuffer);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@@ -29,5 +29,7 @@ SDrawQuadPixelOutput PSMain(SDrawQuadPixelInput input)
|
|||||||
if (result.color.a <= 0.0)
|
if (result.color.a <= 0.0)
|
||||||
discard;
|
discard;
|
||||||
|
|
||||||
|
result.color.rgb = AppleRGBToSRGBLinear(result.color.rgb);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@@ -47,13 +47,24 @@ float4 ApplyFlicker(int2 coordinate, int startThreshold, int endThreshold, float
|
|||||||
|
|
||||||
float4 ApplyDesaturation(float desaturation, float4 color)
|
float4 ApplyDesaturation(float desaturation, float4 color)
|
||||||
{
|
{
|
||||||
|
// This is intentionally done in gamma space
|
||||||
if (desaturation == 0.0)
|
if (desaturation == 0.0)
|
||||||
return color;
|
return color;
|
||||||
|
|
||||||
float3 srgbColor = LinearToSRGB(color.rgb);
|
float grayLevel = dot(color.rgb, float3(3.0, 6.0, 1.0) / 10.0);
|
||||||
float grayLevel = dot(srgbColor, float3(3.0, 6.0, 1.0) / 10.0);
|
|
||||||
|
|
||||||
srgbColor = srgbColor * (1.0 - desaturation) + float3(grayLevel, grayLevel, grayLevel) * desaturation;
|
color.rgb = color.rgb * (1.0 - desaturation) + float3(grayLevel, grayLevel, grayLevel) * desaturation;
|
||||||
|
return color;
|
||||||
return float4(SRGBToLinear(srgbColor), color.a);
|
}
|
||||||
|
|
||||||
|
float3 AppleRGBToSRGBLinear(float3 color)
|
||||||
|
{
|
||||||
|
color = pow(saturate(color), 1.8);
|
||||||
|
|
||||||
|
float3 result;
|
||||||
|
result = color.r * float3(1.06870538834699, 0.024110476735, 0.00173499822713);
|
||||||
|
result += color.g * float3(-0.07859532843279, 0.96007030899244, 0.02974755969275);
|
||||||
|
result += color.b * float3(0.00988984558395, 0.01581936633364, 0.96851741859153);
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
@@ -22,14 +22,29 @@
|
|||||||
|
|
||||||
#include "WindowsUnicodeToolShim.h"
|
#include "WindowsUnicodeToolShim.h"
|
||||||
|
|
||||||
|
#include "macedec.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
|
||||||
|
enum AudioCompressionCodecID
|
||||||
|
{
|
||||||
|
AudioCompressionCodecID_VariableRate = -2,
|
||||||
|
AudioCompressionCodecID_FixedRate = -1,
|
||||||
|
AudioCompressionCodecID_Uncompressed = 0,
|
||||||
|
AudioCompressionCodecID_TwoToOne = 1,
|
||||||
|
AudioCompressionCodecID_EightToOne = 2,
|
||||||
|
AudioCompressionCodecID_ThreeToOne = 3,
|
||||||
|
AudioCompressionCodecID_SixToOne = 4,
|
||||||
|
};
|
||||||
|
|
||||||
struct PlannedEntry
|
struct PlannedEntry
|
||||||
{
|
{
|
||||||
std::vector<uint8_t> m_contents;
|
std::vector<uint8_t> m_uncompressedContents;
|
||||||
|
std::vector<uint8_t> m_compressedContents;
|
||||||
|
|
||||||
std::string m_name;
|
std::string m_name;
|
||||||
bool m_isDirectory;
|
bool m_isDirectory;
|
||||||
|
|
||||||
@@ -205,7 +220,7 @@ void ConvertToMSDOSTimestamp(const PortabilityLayer::CombinedTimestamp &ts, uint
|
|||||||
msdosDate = day | (month << 5) | (yearsSince1980 << 9);
|
msdosDate = day | (month << 5) | (yearsSince1980 << 9);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExportZipFile(const char *path, const std::vector<PlannedEntry> &entries, const PortabilityLayer::CombinedTimestamp &ts)
|
void ExportZipFile(const char *path, std::vector<PlannedEntry> &entries, const PortabilityLayer::CombinedTimestamp &ts)
|
||||||
{
|
{
|
||||||
FILE *outF = fopen_utf8(path, "wb");
|
FILE *outF = fopen_utf8(path, "wb");
|
||||||
if (!outF)
|
if (!outF)
|
||||||
@@ -221,20 +236,27 @@ void ExportZipFile(const char *path, const std::vector<PlannedEntry> &entries, c
|
|||||||
|
|
||||||
std::vector<PortabilityLayer::ZipCentralDirectoryFileHeader> cdirRecords;
|
std::vector<PortabilityLayer::ZipCentralDirectoryFileHeader> cdirRecords;
|
||||||
|
|
||||||
|
// Why does OMP require signed indexes? When do I ever want negative iterations? Uggghh.
|
||||||
|
int numEntries = entries.size();
|
||||||
|
|
||||||
|
#pragma omp parallel for
|
||||||
|
for (int i = 0; i < numEntries; i++)
|
||||||
|
{
|
||||||
|
PlannedEntry &entry = entries[i];
|
||||||
|
|
||||||
|
if (entry.m_uncompressedContents.size() > 0)
|
||||||
|
{
|
||||||
|
if (!TryDeflate(entry.m_uncompressedContents, entry.m_compressedContents))
|
||||||
|
entry.m_compressedContents.resize(0);
|
||||||
|
|
||||||
|
if (entry.m_compressedContents.size() >= entry.m_uncompressedContents.size())
|
||||||
|
entry.m_compressedContents.resize(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (const PlannedEntry &entry : entries)
|
for (const PlannedEntry &entry : entries)
|
||||||
{
|
{
|
||||||
std::vector<uint8_t> compressed;
|
bool isCompressed = entry.m_compressedContents.size() != 0;
|
||||||
|
|
||||||
if (entry.m_contents.size() != 0)
|
|
||||||
{
|
|
||||||
if (!TryDeflate(entry.m_contents, compressed))
|
|
||||||
compressed.resize(0);
|
|
||||||
|
|
||||||
if (compressed.size() >= entry.m_contents.size())
|
|
||||||
compressed.resize(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isCompressed = compressed.size() != 0;
|
|
||||||
|
|
||||||
PortabilityLayer::ZipCentralDirectoryFileHeader cdirHeader;
|
PortabilityLayer::ZipCentralDirectoryFileHeader cdirHeader;
|
||||||
|
|
||||||
@@ -252,11 +274,11 @@ void ExportZipFile(const char *path, const std::vector<PlannedEntry> &entries, c
|
|||||||
else if (isCompressed)
|
else if (isCompressed)
|
||||||
cdirHeader.m_versionRequired = PortabilityLayer::ZipConstants::kCompressedRequiredVersion;
|
cdirHeader.m_versionRequired = PortabilityLayer::ZipConstants::kCompressedRequiredVersion;
|
||||||
|
|
||||||
if (entry.m_contents.size() > 0)
|
if (entry.m_uncompressedContents.size() > 0)
|
||||||
cdirHeader.m_crc = crc32(0, &entry.m_contents[0], static_cast<uint32_t>(entry.m_contents.size()));
|
cdirHeader.m_crc = crc32(0, &entry.m_uncompressedContents[0], static_cast<uint32_t>(entry.m_uncompressedContents.size()));
|
||||||
|
|
||||||
cdirHeader.m_compressedSize = static_cast<uint32_t>(isCompressed ? compressed.size() : entry.m_contents.size());
|
cdirHeader.m_compressedSize = static_cast<uint32_t>(isCompressed ? entry.m_compressedContents.size() : entry.m_uncompressedContents.size());
|
||||||
cdirHeader.m_uncompressedSize = static_cast<uint32_t>(entry.m_contents.size());
|
cdirHeader.m_uncompressedSize = static_cast<uint32_t>(entry.m_uncompressedContents.size());
|
||||||
cdirHeader.m_fileNameLength = static_cast<uint32_t>(entry.m_name.size());
|
cdirHeader.m_fileNameLength = static_cast<uint32_t>(entry.m_name.size());
|
||||||
cdirHeader.m_extraFieldLength = 0;
|
cdirHeader.m_extraFieldLength = 0;
|
||||||
cdirHeader.m_commentLength = 0;
|
cdirHeader.m_commentLength = 0;
|
||||||
@@ -286,9 +308,9 @@ void ExportZipFile(const char *path, const std::vector<PlannedEntry> &entries, c
|
|||||||
fwrite(entry.m_name.c_str(), 1, entry.m_name.size(), outF);
|
fwrite(entry.m_name.c_str(), 1, entry.m_name.size(), outF);
|
||||||
|
|
||||||
if (isCompressed)
|
if (isCompressed)
|
||||||
fwrite(&compressed[0], 1, compressed.size(), outF);
|
fwrite(&entry.m_compressedContents[0], 1, entry.m_compressedContents.size(), outF);
|
||||||
else if (entry.m_contents.size() > 0)
|
else if (entry.m_uncompressedContents.size() > 0)
|
||||||
fwrite(&entry.m_contents[0], 1, entry.m_contents.size(), outF);
|
fwrite(&entry.m_uncompressedContents[0], 1, entry.m_uncompressedContents.size(), outF);
|
||||||
}
|
}
|
||||||
|
|
||||||
long cdirPos = ftell(outF);
|
long cdirPos = ftell(outF);
|
||||||
@@ -620,7 +642,8 @@ bool BMPDumperContext::Export(std::vector<uint8_t> &outData) const
|
|||||||
|
|
||||||
VectorAppend(outData, reinterpret_cast<const uint8_t*>(&infoHeader), sizeof(infoHeader));
|
VectorAppend(outData, reinterpret_cast<const uint8_t*>(&infoHeader), sizeof(infoHeader));
|
||||||
|
|
||||||
VectorAppend(outData, reinterpret_cast<const uint8_t*>(colorTable), sizeof(PortabilityLayer::BitmapColorTableEntry) * numColors);
|
if (bpp < 16)
|
||||||
|
VectorAppend(outData, reinterpret_cast<const uint8_t*>(colorTable), sizeof(PortabilityLayer::BitmapColorTableEntry) * numColors);
|
||||||
|
|
||||||
for (size_t i = 0; i < postCTabPaddingSize; i++)
|
for (size_t i = 0; i < postCTabPaddingSize; i++)
|
||||||
outData.push_back(0);
|
outData.push_back(0);
|
||||||
@@ -715,6 +738,49 @@ void PadAlignWave(std::vector<uint8_t> &outWAV)
|
|||||||
outWAV.push_back(0);
|
outWAV.push_back(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DecompressSound(int compressionID, int channelCount, const void *sndData, size_t numFrames, std::vector<uint8_t> &decompressed)
|
||||||
|
{
|
||||||
|
if (compressionID == AudioCompressionCodecID_ThreeToOne)
|
||||||
|
{
|
||||||
|
if (channelCount != 1)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Unsupported MACE decode channel layout\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stderr, "Unimplemented audio codec\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (compressionID = AudioCompressionCodecID_SixToOne)
|
||||||
|
{
|
||||||
|
if (channelCount != 1)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Unsupported MACE decode channel layout\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
MaceChannelDecState state;
|
||||||
|
memset(&state, 0, sizeof(state));
|
||||||
|
|
||||||
|
const uint8_t *packets = static_cast<const uint8_t*>(sndData);
|
||||||
|
for (size_t i = 0; i < numFrames; i++)
|
||||||
|
{
|
||||||
|
uint8_t samples[6];
|
||||||
|
DecodeMACE6(&state, packets[i], samples);
|
||||||
|
|
||||||
|
for (int s = 0; s < 6; s++)
|
||||||
|
decompressed.push_back(samples[s]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Unknown audio compression format\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool ImportSound(std::vector<uint8_t> &outWAV, const void *inData, size_t inSize)
|
bool ImportSound(std::vector<uint8_t> &outWAV, const void *inData, size_t inSize)
|
||||||
{
|
{
|
||||||
// Glider PRO has a hard-coded expectation that the sound will have exactly 20 bytes of prefix.
|
// Glider PRO has a hard-coded expectation that the sound will have exactly 20 bytes of prefix.
|
||||||
@@ -732,6 +798,56 @@ bool ImportSound(std::vector<uint8_t> &outWAV, const void *inData, size_t inSize
|
|||||||
uint8_t m_baseFrequency;
|
uint8_t m_baseFrequency;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct ExtHeader
|
||||||
|
{
|
||||||
|
BEUInt32_t m_samplePtr;
|
||||||
|
BEUInt32_t m_channelCount;
|
||||||
|
BEFixed32_t m_sampleRate;
|
||||||
|
BEUInt32_t m_loopStart;
|
||||||
|
BEUInt32_t m_loopEnd;
|
||||||
|
uint8_t m_encoding;
|
||||||
|
uint8_t m_baseFrequency;
|
||||||
|
BEUInt32_t m_numSamples;
|
||||||
|
BEUInt16_t m_sampleRateExponentAndSign;
|
||||||
|
BEUInt32_t m_sampleRateFractionHigh;
|
||||||
|
BEUInt32_t m_sampleRateFractionLow;
|
||||||
|
BEUInt32_t m_markerPtr;
|
||||||
|
BEUInt32_t m_instrumentPtr;
|
||||||
|
BEUInt32_t m_recordingDevicesPtr;
|
||||||
|
BEUInt16_t m_sampleSize;
|
||||||
|
uint8_t m_reserved[14];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct CmpHeader
|
||||||
|
{
|
||||||
|
BEUInt32_t m_samplePtr;
|
||||||
|
BEUInt32_t m_channelCount;
|
||||||
|
BEFixed32_t m_sampleRate;
|
||||||
|
BEUInt32_t m_loopStart;
|
||||||
|
BEUInt32_t m_loopEnd;
|
||||||
|
uint8_t m_encoding;
|
||||||
|
uint8_t m_baseFrequency;
|
||||||
|
BEUInt32_t m_numFrames;
|
||||||
|
BEUInt16_t m_sampleRateExponentAndSign;
|
||||||
|
BEUInt32_t m_sampleRateFractionHigh;
|
||||||
|
BEUInt32_t m_sampleRateFractionLow;
|
||||||
|
BEUInt32_t m_markerPtr;
|
||||||
|
BEUInt32_t m_format;
|
||||||
|
uint8_t m_reserved1[4];
|
||||||
|
|
||||||
|
BEUInt32_t m_stateVars;
|
||||||
|
BEUInt32_t m_leftOverSamples;
|
||||||
|
BEInt16_t m_compressionID;
|
||||||
|
BEUInt16_t m_packetSize;
|
||||||
|
BEUInt16_t m_synthesizerID;
|
||||||
|
BEUInt16_t m_sampleSize;
|
||||||
|
};
|
||||||
|
|
||||||
|
const int hs = sizeof(CmpHeader);
|
||||||
|
|
||||||
|
GP_STATIC_ASSERT(sizeof(ExtHeader) == 64);
|
||||||
|
GP_STATIC_ASSERT(sizeof(CmpHeader) == 64);
|
||||||
|
|
||||||
if (inSize < hardCodedPrefixSize)
|
if (inSize < hardCodedPrefixSize)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -744,12 +860,76 @@ bool ImportSound(std::vector<uint8_t> &outWAV, const void *inData, size_t inSize
|
|||||||
BufferHeader header;
|
BufferHeader header;
|
||||||
memcpy(&header, sndBufferData, sizeof(header));
|
memcpy(&header, sndBufferData, sizeof(header));
|
||||||
|
|
||||||
sndBufferData += sizeof(header);
|
std::vector<uint8_t> decompressedSound;
|
||||||
inSize -= sizeof(header);
|
|
||||||
|
|
||||||
uint32_t dataLength = header.m_length;
|
uint32_t dataLength = 0;
|
||||||
if (dataLength > inSize)
|
if (header.m_encoding == 0xfe)
|
||||||
return false;
|
{
|
||||||
|
if (inSize < sizeof(CmpHeader))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
CmpHeader cmpHeader;
|
||||||
|
memcpy(&cmpHeader, sndBufferData, sizeof(cmpHeader));
|
||||||
|
|
||||||
|
sndBufferData += sizeof(ExtHeader);
|
||||||
|
inSize -= sizeof(ExtHeader);
|
||||||
|
|
||||||
|
if (!DecompressSound(cmpHeader.m_compressionID, cmpHeader.m_channelCount, sndBufferData, cmpHeader.m_numFrames, decompressedSound))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
dataLength = decompressedSound.size();
|
||||||
|
if (decompressedSound.size() > 0)
|
||||||
|
sndBufferData = &decompressedSound[0];
|
||||||
|
}
|
||||||
|
else if (header.m_encoding == 0xff)
|
||||||
|
{
|
||||||
|
if (inSize < sizeof(ExtHeader))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
ExtHeader extHeader;
|
||||||
|
memcpy(&extHeader, sndBufferData, sizeof(extHeader));
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
uint64_t sampleRateFraction = (static_cast<uint64_t>(static_cast<uint32_t>(extHeader.m_sampleRateFractionHigh)) << 32) | static_cast<uint32_t>(extHeader.m_sampleRateFractionLow);
|
||||||
|
uint16_t sampleRateExponentAndSign = extHeader.m_sampleRateExponentAndSign;
|
||||||
|
|
||||||
|
int32_t sampleRateExponent = static_cast<int32_t>(sampleRateExponentAndSign & 0x7fff) - 16447;
|
||||||
|
|
||||||
|
double sampleRate = static_cast<double>(sampleRateFraction) * pow(2.0, sampleRateExponent);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
uint16_t bitsPerSample = extHeader.m_sampleSize;
|
||||||
|
|
||||||
|
if (bitsPerSample != 8)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Sound had unexpected bit rate\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (extHeader.m_channelCount != 1)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Sound had unexpected channel count\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
dataLength = extHeader.m_numSamples * extHeader.m_channelCount * bitsPerSample / 8;
|
||||||
|
|
||||||
|
sndBufferData += sizeof(ExtHeader);
|
||||||
|
inSize -= sizeof(ExtHeader);
|
||||||
|
|
||||||
|
if (dataLength > inSize)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dataLength = header.m_length;
|
||||||
|
|
||||||
|
sndBufferData += sizeof(header);
|
||||||
|
inSize -= sizeof(header);
|
||||||
|
|
||||||
|
if (dataLength > inSize)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t sampleRate = header.m_sampleRate.m_intPart;
|
uint32_t sampleRate = header.m_sampleRate.m_intPart;
|
||||||
if (static_cast<int>(header.m_sampleRate.m_fracPart) >= 0x8000)
|
if (static_cast<int>(header.m_sampleRate.m_fracPart) >= 0x8000)
|
||||||
@@ -1106,8 +1286,8 @@ bool ApplyPatch(const std::vector<uint8_t> &patchFileContents, std::vector<Plann
|
|||||||
}
|
}
|
||||||
|
|
||||||
entry->m_isDirectory = false;
|
entry->m_isDirectory = false;
|
||||||
entry->m_contents.clear();
|
entry->m_uncompressedContents.clear();
|
||||||
ReadFileToVector(f, entry->m_contents);
|
ReadFileToVector(f, entry->m_uncompressedContents);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1147,7 +1327,6 @@ bool ApplyPatch(const std::vector<uint8_t> &patchFileContents, std::vector<Plann
|
|||||||
|
|
||||||
int ConvertSingleFile(const char *resPath, const PortabilityLayer::CombinedTimestamp &ts, FILE *patchF, const char *outPath)
|
int ConvertSingleFile(const char *resPath, const PortabilityLayer::CombinedTimestamp &ts, FILE *patchF, const char *outPath)
|
||||||
{
|
{
|
||||||
|
|
||||||
FILE *inF = fopen_utf8(resPath, "rb");
|
FILE *inF = fopen_utf8(resPath, "rb");
|
||||||
if (!inF)
|
if (!inF)
|
||||||
{
|
{
|
||||||
@@ -1216,7 +1395,7 @@ int ConvertSingleFile(const char *resPath, const PortabilityLayer::CombinedTimes
|
|||||||
|
|
||||||
entry.m_name = resName;
|
entry.m_name = resName;
|
||||||
|
|
||||||
if (ImportPICT(entry.m_contents, resData, resSize))
|
if (ImportPICT(entry.m_uncompressedContents, resData, resSize))
|
||||||
contents.push_back(entry);
|
contents.push_back(entry);
|
||||||
else
|
else
|
||||||
fprintf(stderr, "Failed to import PICT res %i\n", static_cast<int>(res.m_resID));
|
fprintf(stderr, "Failed to import PICT res %i\n", static_cast<int>(res.m_resID));
|
||||||
@@ -1229,7 +1408,7 @@ int ConvertSingleFile(const char *resPath, const PortabilityLayer::CombinedTimes
|
|||||||
|
|
||||||
entry.m_name = resName;
|
entry.m_name = resName;
|
||||||
|
|
||||||
if (ImportSound(entry.m_contents, resData, resSize))
|
if (ImportSound(entry.m_uncompressedContents, resData, resSize))
|
||||||
contents.push_back(entry);
|
contents.push_back(entry);
|
||||||
}
|
}
|
||||||
else if (typeList.m_resType == indexStringTypeID)
|
else if (typeList.m_resType == indexStringTypeID)
|
||||||
@@ -1240,7 +1419,7 @@ int ConvertSingleFile(const char *resPath, const PortabilityLayer::CombinedTimes
|
|||||||
|
|
||||||
entry.m_name = resName;
|
entry.m_name = resName;
|
||||||
|
|
||||||
if (ImportIndexedString(entry.m_contents, resData, resSize))
|
if (ImportIndexedString(entry.m_uncompressedContents, resData, resSize))
|
||||||
contents.push_back(entry);
|
contents.push_back(entry);
|
||||||
}
|
}
|
||||||
else if (typeList.m_resType == ditlTypeID)
|
else if (typeList.m_resType == ditlTypeID)
|
||||||
@@ -1251,7 +1430,7 @@ int ConvertSingleFile(const char *resPath, const PortabilityLayer::CombinedTimes
|
|||||||
|
|
||||||
entry.m_name = resName;
|
entry.m_name = resName;
|
||||||
|
|
||||||
if (ImportDialogItemTemplate(entry.m_contents, resData, resSize))
|
if (ImportDialogItemTemplate(entry.m_uncompressedContents, resData, resSize))
|
||||||
contents.push_back(entry);
|
contents.push_back(entry);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1262,9 +1441,9 @@ int ConvertSingleFile(const char *resPath, const PortabilityLayer::CombinedTimes
|
|||||||
sprintf_s(resName, "%s/%i.bin", resTag.m_id, static_cast<int>(res.m_resID));
|
sprintf_s(resName, "%s/%i.bin", resTag.m_id, static_cast<int>(res.m_resID));
|
||||||
|
|
||||||
entry.m_name = resName;
|
entry.m_name = resName;
|
||||||
entry.m_contents.resize(res.GetSize());
|
entry.m_uncompressedContents.resize(res.GetSize());
|
||||||
|
|
||||||
memcpy(&entry.m_contents[0], resData, resSize);
|
memcpy(&entry.m_uncompressedContents[0], resData, resSize);
|
||||||
|
|
||||||
contents.push_back(entry);
|
contents.push_back(entry);
|
||||||
}
|
}
|
||||||
@@ -1344,7 +1523,7 @@ int ConvertDirectory(const std::string &basePath, const PortabilityLayer::Combin
|
|||||||
int PrintUsage()
|
int PrintUsage()
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Usage: gpr2gpa <input.gpr> <input.ts> <output.gpa> [patch.json]\n");
|
fprintf(stderr, "Usage: gpr2gpa <input.gpr> <input.ts> <output.gpa> [patch.json]\n");
|
||||||
fprintf(stderr, " gpr2gpa <input dir>\* <input.ts>\n");
|
fprintf(stderr, " gpr2gpa <input dir>\\* <input.ts>\n");
|
||||||
fprintf(stderr, " gpr2gpa <input dir>/* <input.ts>\n");
|
fprintf(stderr, " gpr2gpa <input dir>/* <input.ts>\n");
|
||||||
fprintf(stderr, " gpr2gpa * <input.ts>\n");
|
fprintf(stderr, " gpr2gpa * <input.ts>\n");
|
||||||
return -1;
|
return -1;
|
||||||
|
@@ -106,6 +106,7 @@
|
|||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<OpenMPSupport>true</OpenMPSupport>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
@@ -126,6 +127,7 @@
|
|||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<OpenMPSupport>true</OpenMPSupport>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
@@ -155,6 +157,10 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="gpr2gpa.cpp" />
|
<ClCompile Include="gpr2gpa.cpp" />
|
||||||
|
<ClCompile Include="macedec.cpp" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="macedec.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
@@ -18,5 +18,13 @@
|
|||||||
<ClCompile Include="gpr2gpa.cpp">
|
<ClCompile Include="gpr2gpa.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="macedec.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="macedec.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
238
gpr2gpa/macedec.cpp
Normal file
238
gpr2gpa/macedec.cpp
Normal file
@@ -0,0 +1,238 @@
|
|||||||
|
/*
|
||||||
|
* MACE decoder
|
||||||
|
* Based on FFmpeg MACE decoder
|
||||||
|
* Copyright (c) 2002 Laszlo Torok <torokl@alpha.dfmk.hu>
|
||||||
|
*
|
||||||
|
* FFmpeg is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* FFmpeg is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with FFmpeg; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Adapted to libavcodec by Francois Revol <revol@free.fr>
|
||||||
|
* (removed 68k REG stuff, changed types, added some statics and consts,
|
||||||
|
* libavcodec api, context stuff, interlaced stereo out).
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
#include "macedec.h"
|
||||||
|
|
||||||
|
static const int16_t MACEtab1[] = {-13, 8, 76, 222, 222, 76, 8, -13};
|
||||||
|
|
||||||
|
static const int16_t MACEtab3[] = {-18, 140, 140, -18};
|
||||||
|
|
||||||
|
static const int16_t MACEtab2[][4] = {
|
||||||
|
{ 37, 116, 206, 330}, { 39, 121, 216, 346},
|
||||||
|
{ 41, 127, 225, 361}, { 42, 132, 235, 377},
|
||||||
|
{ 44, 137, 245, 392}, { 46, 144, 256, 410},
|
||||||
|
{ 48, 150, 267, 428}, { 51, 157, 280, 449},
|
||||||
|
{ 53, 165, 293, 470}, { 55, 172, 306, 490},
|
||||||
|
{ 58, 179, 319, 511}, { 60, 187, 333, 534},
|
||||||
|
{ 63, 195, 348, 557}, { 66, 205, 364, 583},
|
||||||
|
{ 69, 214, 380, 609}, { 72, 223, 396, 635},
|
||||||
|
{ 75, 233, 414, 663}, { 79, 244, 433, 694},
|
||||||
|
{ 82, 254, 453, 725}, { 86, 265, 472, 756},
|
||||||
|
{ 90, 278, 495, 792}, { 94, 290, 516, 826},
|
||||||
|
{ 98, 303, 538, 862}, { 102, 316, 562, 901},
|
||||||
|
{ 107, 331, 588, 942}, { 112, 345, 614, 983},
|
||||||
|
{ 117, 361, 641, 1027}, { 122, 377, 670, 1074},
|
||||||
|
{ 127, 394, 701, 1123}, { 133, 411, 732, 1172},
|
||||||
|
{ 139, 430, 764, 1224}, { 145, 449, 799, 1280},
|
||||||
|
{ 152, 469, 835, 1337}, { 159, 490, 872, 1397},
|
||||||
|
{ 166, 512, 911, 1459}, { 173, 535, 951, 1523},
|
||||||
|
{ 181, 558, 993, 1590}, { 189, 584, 1038, 1663},
|
||||||
|
{ 197, 610, 1085, 1738}, { 206, 637, 1133, 1815},
|
||||||
|
{ 215, 665, 1183, 1895}, { 225, 695, 1237, 1980},
|
||||||
|
{ 235, 726, 1291, 2068}, { 246, 759, 1349, 2161},
|
||||||
|
{ 257, 792, 1409, 2257}, { 268, 828, 1472, 2357},
|
||||||
|
{ 280, 865, 1538, 2463}, { 293, 903, 1606, 2572},
|
||||||
|
{ 306, 944, 1678, 2688}, { 319, 986, 1753, 2807},
|
||||||
|
{ 334, 1030, 1832, 2933}, { 349, 1076, 1914, 3065},
|
||||||
|
{ 364, 1124, 1999, 3202}, { 380, 1174, 2088, 3344},
|
||||||
|
{ 398, 1227, 2182, 3494}, { 415, 1281, 2278, 3649},
|
||||||
|
{ 434, 1339, 2380, 3811}, { 453, 1398, 2486, 3982},
|
||||||
|
{ 473, 1461, 2598, 4160}, { 495, 1526, 2714, 4346},
|
||||||
|
{ 517, 1594, 2835, 4540}, { 540, 1665, 2961, 4741},
|
||||||
|
{ 564, 1740, 3093, 4953}, { 589, 1818, 3232, 5175},
|
||||||
|
{ 615, 1898, 3375, 5405}, { 643, 1984, 3527, 5647},
|
||||||
|
{ 671, 2072, 3683, 5898}, { 701, 2164, 3848, 6161},
|
||||||
|
{ 733, 2261, 4020, 6438}, { 766, 2362, 4199, 6724},
|
||||||
|
{ 800, 2467, 4386, 7024}, { 836, 2578, 4583, 7339},
|
||||||
|
{ 873, 2692, 4786, 7664}, { 912, 2813, 5001, 8008},
|
||||||
|
{ 952, 2938, 5223, 8364}, { 995, 3070, 5457, 8739},
|
||||||
|
{ 1039, 3207, 5701, 9129}, { 1086, 3350, 5956, 9537},
|
||||||
|
{ 1134, 3499, 6220, 9960}, { 1185, 3655, 6497, 10404},
|
||||||
|
{ 1238, 3818, 6788, 10869}, { 1293, 3989, 7091, 11355},
|
||||||
|
{ 1351, 4166, 7407, 11861}, { 1411, 4352, 7738, 12390},
|
||||||
|
{ 1474, 4547, 8084, 12946}, { 1540, 4750, 8444, 13522},
|
||||||
|
{ 1609, 4962, 8821, 14126}, { 1680, 5183, 9215, 14756},
|
||||||
|
{ 1756, 5415, 9626, 15415}, { 1834, 5657, 10057, 16104},
|
||||||
|
{ 1916, 5909, 10505, 16822}, { 2001, 6173, 10975, 17574},
|
||||||
|
{ 2091, 6448, 11463, 18356}, { 2184, 6736, 11974, 19175},
|
||||||
|
{ 2282, 7037, 12510, 20032}, { 2383, 7351, 13068, 20926},
|
||||||
|
{ 2490, 7679, 13652, 21861}, { 2601, 8021, 14260, 22834},
|
||||||
|
{ 2717, 8380, 14897, 23854}, { 2838, 8753, 15561, 24918},
|
||||||
|
{ 2965, 9144, 16256, 26031}, { 3097, 9553, 16982, 27193},
|
||||||
|
{ 3236, 9979, 17740, 28407}, { 3380, 10424, 18532, 29675},
|
||||||
|
{ 3531, 10890, 19359, 31000}, { 3688, 11375, 20222, 32382},
|
||||||
|
{ 3853, 11883, 21125, 32767}, { 4025, 12414, 22069, 32767},
|
||||||
|
{ 4205, 12967, 23053, 32767}, { 4392, 13546, 24082, 32767},
|
||||||
|
{ 4589, 14151, 25157, 32767}, { 4793, 14783, 26280, 32767},
|
||||||
|
{ 5007, 15442, 27452, 32767}, { 5231, 16132, 28678, 32767},
|
||||||
|
{ 5464, 16851, 29957, 32767}, { 5708, 17603, 31294, 32767},
|
||||||
|
{ 5963, 18389, 32691, 32767}, { 6229, 19210, 32767, 32767},
|
||||||
|
{ 6507, 20067, 32767, 32767}, { 6797, 20963, 32767, 32767},
|
||||||
|
{ 7101, 21899, 32767, 32767}, { 7418, 22876, 32767, 32767},
|
||||||
|
{ 7749, 23897, 32767, 32767}, { 8095, 24964, 32767, 32767},
|
||||||
|
{ 8456, 26078, 32767, 32767}, { 8833, 27242, 32767, 32767},
|
||||||
|
{ 9228, 28457, 32767, 32767}, { 9639, 29727, 32767, 32767}
|
||||||
|
};
|
||||||
|
|
||||||
|
static const int16_t MACEtab4[][2] = {
|
||||||
|
{ 64, 216}, { 67, 226}, { 70, 236}, { 74, 246},
|
||||||
|
{ 77, 257}, { 80, 268}, { 84, 280}, { 88, 294},
|
||||||
|
{ 92, 307}, { 96, 321}, { 100, 334}, { 104, 350},
|
||||||
|
{ 109, 365}, { 114, 382}, { 119, 399}, { 124, 416},
|
||||||
|
{ 130, 434}, { 136, 454}, { 142, 475}, { 148, 495},
|
||||||
|
{ 155, 519}, { 162, 541}, { 169, 564}, { 176, 590},
|
||||||
|
{ 185, 617}, { 193, 644}, { 201, 673}, { 210, 703},
|
||||||
|
{ 220, 735}, { 230, 767}, { 240, 801}, { 251, 838},
|
||||||
|
{ 262, 876}, { 274, 914}, { 286, 955}, { 299, 997},
|
||||||
|
{ 312, 1041}, { 326, 1089}, { 341, 1138}, { 356, 1188},
|
||||||
|
{ 372, 1241}, { 388, 1297}, { 406, 1354}, { 424, 1415},
|
||||||
|
{ 443, 1478}, { 462, 1544}, { 483, 1613}, { 505, 1684},
|
||||||
|
{ 527, 1760}, { 551, 1838}, { 576, 1921}, { 601, 2007},
|
||||||
|
{ 628, 2097}, { 656, 2190}, { 686, 2288}, { 716, 2389},
|
||||||
|
{ 748, 2496}, { 781, 2607}, { 816, 2724}, { 853, 2846},
|
||||||
|
{ 891, 2973}, { 930, 3104}, { 972, 3243}, { 1016, 3389},
|
||||||
|
{ 1061, 3539}, { 1108, 3698}, { 1158, 3862}, { 1209, 4035},
|
||||||
|
{ 1264, 4216}, { 1320, 4403}, { 1379, 4599}, { 1441, 4806},
|
||||||
|
{ 1505, 5019}, { 1572, 5244}, { 1642, 5477}, { 1715, 5722},
|
||||||
|
{ 1792, 5978}, { 1872, 6245}, { 1955, 6522}, { 2043, 6813},
|
||||||
|
{ 2134, 7118}, { 2229, 7436}, { 2329, 7767}, { 2432, 8114},
|
||||||
|
{ 2541, 8477}, { 2655, 8854}, { 2773, 9250}, { 2897, 9663},
|
||||||
|
{ 3026, 10094}, { 3162, 10546}, { 3303, 11016}, { 3450, 11508},
|
||||||
|
{ 3604, 12020}, { 3765, 12556}, { 3933, 13118}, { 4108, 13703},
|
||||||
|
{ 4292, 14315}, { 4483, 14953}, { 4683, 15621}, { 4892, 16318},
|
||||||
|
{ 5111, 17046}, { 5339, 17807}, { 5577, 18602}, { 5826, 19433},
|
||||||
|
{ 6086, 20300}, { 6358, 21205}, { 6642, 22152}, { 6938, 23141},
|
||||||
|
{ 7248, 24173}, { 7571, 25252}, { 7909, 26380}, { 8262, 27557},
|
||||||
|
{ 8631, 28786}, { 9016, 30072}, { 9419, 31413}, { 9839, 32767},
|
||||||
|
{ 10278, 32767}, { 10737, 32767}, { 11216, 32767}, { 11717, 32767},
|
||||||
|
{ 12240, 32767}, { 12786, 32767}, { 13356, 32767}, { 13953, 32767},
|
||||||
|
{ 14576, 32767}, { 15226, 32767}, { 15906, 32767}, { 16615, 32767}
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct {
|
||||||
|
const int16_t *tab1; const int16_t *tab2; int stride;
|
||||||
|
} tabs[] = {
|
||||||
|
{MACEtab1, &MACEtab2[0][0], 4},
|
||||||
|
{MACEtab3, &MACEtab4[0][0], 2},
|
||||||
|
{MACEtab1, &MACEtab2[0][0], 4}
|
||||||
|
};
|
||||||
|
|
||||||
|
static uint8_t CompactOutput(int16_t v)
|
||||||
|
{
|
||||||
|
return ((v >> 8) & 0xff) ^ 0x80;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MACE version of av_clip_int16(). We have to do this to keep binary
|
||||||
|
* identical output to the binary decoder.
|
||||||
|
*/
|
||||||
|
static inline int16_t mace_broken_clip_int16(int n)
|
||||||
|
{
|
||||||
|
if (n > 32767)
|
||||||
|
return 32767;
|
||||||
|
else if (n < -32768)
|
||||||
|
return -32767;
|
||||||
|
else
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int16_t read_table(MaceChannelDecState *chd, uint8_t val, int tab_idx)
|
||||||
|
{
|
||||||
|
int16_t current;
|
||||||
|
|
||||||
|
if (val < tabs[tab_idx].stride)
|
||||||
|
current = tabs[tab_idx].tab2[((chd->index & 0x7f0) >> 4) * tabs[tab_idx].stride + val];
|
||||||
|
else
|
||||||
|
current = - 1 - tabs[tab_idx].tab2[((chd->index & 0x7f0) >> 4)*tabs[tab_idx].stride + 2*tabs[tab_idx].stride-val-1];
|
||||||
|
|
||||||
|
if (( chd->index += tabs[tab_idx].tab1[val]-(chd->index >> 5) ) < 0)
|
||||||
|
chd->index = 0;
|
||||||
|
|
||||||
|
return current;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void chomp3(MaceChannelDecState *chd, uint8_t *output, uint8_t val, int tab_idx)
|
||||||
|
{
|
||||||
|
|
||||||
|
int16_t current = read_table(chd, val, tab_idx);
|
||||||
|
|
||||||
|
current = mace_broken_clip_int16(current + chd->level);
|
||||||
|
|
||||||
|
chd->level = current - (current >> 3);
|
||||||
|
*output = CompactOutput(current);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void chomp6(MaceChannelDecState *chd, uint8_t *output, uint8_t val, int tab_idx)
|
||||||
|
{
|
||||||
|
int16_t current = read_table(chd, val, tab_idx);
|
||||||
|
|
||||||
|
if ((chd->previous ^ current) >= 0) {
|
||||||
|
chd->factor = std::min<int32_t>(chd->factor + 506, 32767);
|
||||||
|
} else {
|
||||||
|
if (chd->factor - 314 < -32768)
|
||||||
|
chd->factor = -32767;
|
||||||
|
else
|
||||||
|
chd->factor -= 314;
|
||||||
|
}
|
||||||
|
|
||||||
|
current = mace_broken_clip_int16(current + chd->level);
|
||||||
|
|
||||||
|
chd->level = (current*chd->factor) >> 15;
|
||||||
|
current >>= 1;
|
||||||
|
|
||||||
|
output[0] = CompactOutput(chd->previous + chd->prev2 -
|
||||||
|
((chd->prev2-current) >> 2));
|
||||||
|
output[1] = CompactOutput(chd->previous + current +
|
||||||
|
((chd->prev2-current) >> 2));
|
||||||
|
chd->prev2 = chd->previous;
|
||||||
|
chd->previous = current;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DecodeMACE3(MaceChannelDecState *chd, uint8_t pkt, uint8_t *output)
|
||||||
|
{
|
||||||
|
uint8_t val[3] = { pkt & 7 , (pkt >> 3) & 3, pkt >> 5 };
|
||||||
|
|
||||||
|
for (int l = 0; l < 3; l++)
|
||||||
|
{
|
||||||
|
chomp3(chd, output, val[l], l);
|
||||||
|
output++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DecodeMACE6(MaceChannelDecState *chd, uint8_t pkt, uint8_t *output)
|
||||||
|
{
|
||||||
|
uint8_t val[3] = {pkt >> 5, (pkt >> 3) & 3, pkt & 7 };
|
||||||
|
|
||||||
|
for (int l = 0; l < 3; l++)
|
||||||
|
{
|
||||||
|
chomp6(chd, output, val[l], l);
|
||||||
|
output += 2;
|
||||||
|
}
|
||||||
|
}
|
11
gpr2gpa/macedec.h
Normal file
11
gpr2gpa/macedec.h
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
struct MaceChannelDecState
|
||||||
|
{
|
||||||
|
int16_t index, factor, prev2, previous, level;
|
||||||
|
};
|
||||||
|
|
||||||
|
void DecodeMACE3(MaceChannelDecState *chd, uint8_t pkt, uint8_t *output);
|
||||||
|
void DecodeMACE6(MaceChannelDecState *chd, uint8_t pkt, uint8_t *output);
|
Reference in New Issue
Block a user