Compare commits

...

29 Commits

Author SHA1 Message Date
elasota
e539b93de9 Adjust MSI package dir 2020-05-10 20:13:53 -04:00
elasota
f952b1c63a Add MSI installer project 2020-05-10 20:04:58 -04:00
elasota
44c32a06ab EOL fix 2020-05-10 20:04:10 -04:00
elasota
e1f9e86c56 EOL fix 2020-05-10 20:03:59 -04:00
elasota
231c4b411f Update docs in line with flattenmov's new behavior 2020-05-09 23:50:34 -04:00
elasota
9ddaec8add Fix Compact Pro extractor data corruption 2020-05-09 23:11:39 -04:00
elasota
e9d65697f3 Add some missing defs, change flattenmov to use triplets 2020-05-09 23:11:16 -04:00
elasota
ebb6d7608e Add unpacktool 2020-05-09 21:05:58 -04:00
elasota
b849d23f4e Update readme 2020-05-02 16:08:52 -04:00
elasota
62d9766ee0 Add close box support to floating windows 2020-05-02 02:59:19 -04:00
elasota
e546c05ea0 Fix scroll bar SetMin/SetMax not working correctly 2020-05-02 02:14:52 -04:00
elasota
3b7858f96a Add support for map window resize in editor 2020-05-02 01:51:32 -04:00
elasota
92c4878492 Fix scaling behavior when the window size doesn't divide evenly into the pixel scale 2020-04-26 01:56:55 -04:00
elasota
e2127038ef Add fullscreen keybind to docs 2020-04-25 21:22:22 -04:00
elasota
cea0a72ebc Remove more obsolete API 2020-04-25 21:22:09 -04:00
elasota
3c5dd5f562 Manually pass dx/dy instead of using ddx/ddy, should improve interpolation somewhat 2020-04-25 18:54:56 -04:00
elasota
5bb6b074f0 Scale quads after rendering to a screen texture instead of scaling directly. Fixes discontinuities in room editor and menu edges. 2020-04-25 16:35:34 -04:00
elasota
ea217285c0 Decrease scale granularity to 2.0 2020-04-25 00:53:43 -04:00
elasota
cd4e0ae8de Use Fant filter to resize to intermediate resolutions. 2020-04-25 00:51:44 -04:00
elasota
c357ca2b7c Fix artifacts if a resize reordered the saved maps of an item.
(Happens in Slumberland if resizing the window from 1600x900 to 800x600 in the second room, then picking up the cuckoo.)
2020-04-25 00:50:28 -04:00
elasota
b5a3db860f Update license 2020-04-23 21:41:19 -04:00
elasota
69e3fb3023 Handle Quit event more gracefully 2020-04-18 05:51:39 -04:00
elasota
94f26d0be1 Redraw grease on room lighting change. Fixes regression where grease would not be visible after turning lights on. 2020-04-18 05:23:40 -04:00
elasota
d893b356f1 Fix dynamic indexes desynchronizing on resolution change (fixes Slumberland boombox switch not working if you change resolution on the screen with the switch) 2020-04-18 00:42:45 -04:00
elasota
c3f3fb4621 Override alt-enter behavior, use borderless fullscreen instead of exclusive fullscreen. This should fix the game breaking when bringing up the open file dialog in fullscreen.
(Note that this doesn't handle resolution changes yet)
2020-04-18 00:18:20 -04:00
elasota
0335dd7786 Fix alt-enter 2020-04-06 03:34:31 -04:00
elasota
ffd9d9cc1f Keep level editor windows in screen bounds 2020-04-05 22:31:22 -04:00
elasota
f46ae55d62 Merge branch 'resizable' 2020-04-05 18:38:05 -04:00
elasota
5c1aacc268 Fix memory corruption on victory screen 2020-04-05 18:36:27 -04:00
131 changed files with 8930 additions and 867 deletions

6
.gitignore vendored
View File

@@ -24,3 +24,9 @@
Packaged/*
DebugData/*
ReleasePkg/*
InstallerPackages/*
*.msi
*.wixpdb
*.wixobj
ReleasePackageInstaller/obj/*
ReleasePackageInstaller/bin/*

View File

@@ -21,4 +21,10 @@ Distributed under the MIT license (See rapidjson/license.txt)
zlib:
(C) 1995-2017 Jean-loup Gailly and Mark Adler
Distributed under zlib license (See zlib/README)
Distributed under zlib license (See zlib/README)
The Unarchiver:
Copyright (C) 2006-2013 Dag Ågren
Distributed under the LGPLv2 license (See unpacktool/LICENSE.txt)

View File

@@ -43,6 +43,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MakeTimestamp", "MakeTimest
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "flattenmov", "flattenmov\flattenmov.vcxproj", "{89F8D13E-F216-4B67-8DE9-7F842D349E94}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unpacktool", "unpacktool\unpacktool.vcxproj", "{A778D062-DE76-49F6-8D05-EB26852DD605}"
EndProject
Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "ReleasePackageInstaller", "ReleasePackageInstaller\ReleasePackageInstaller.wixproj", "{D26BD501-28A7-4849-8130-FB5EA0A2B82F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
@@ -129,6 +133,14 @@ Global
{89F8D13E-F216-4B67-8DE9-7F842D349E94}.Debug|x64.Build.0 = Debug|x64
{89F8D13E-F216-4B67-8DE9-7F842D349E94}.Release|x64.ActiveCfg = Release|x64
{89F8D13E-F216-4B67-8DE9-7F842D349E94}.Release|x64.Build.0 = Release|x64
{A778D062-DE76-49F6-8D05-EB26852DD605}.Debug|x64.ActiveCfg = Debug|x64
{A778D062-DE76-49F6-8D05-EB26852DD605}.Debug|x64.Build.0 = Debug|x64
{A778D062-DE76-49F6-8D05-EB26852DD605}.Release|x64.ActiveCfg = Release|x64
{A778D062-DE76-49F6-8D05-EB26852DD605}.Release|x64.Build.0 = Release|x64
{D26BD501-28A7-4849-8130-FB5EA0A2B82F}.Debug|x64.ActiveCfg = Debug|x64
{D26BD501-28A7-4849-8130-FB5EA0A2B82F}.Debug|x64.Build.0 = Debug|x64
{D26BD501-28A7-4849-8130-FB5EA0A2B82F}.Release|x64.ActiveCfg = Release|x64
{D26BD501-28A7-4849-8130-FB5EA0A2B82F}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@@ -94,9 +94,9 @@ void GpAppEnvironment::Render()
GpAppInterface_Get()->PL_Render(m_displayDriver);
}
void GpAppEnvironment::AdjustRequestedResolution(unsigned int &width, unsigned int &height)
bool GpAppEnvironment::AdjustRequestedResolution(uint32_t &physicalWidth, uint32_t &physicalHeight, uint32_t &virtualWidth, uint32_t &virtualheight, float &pixelScaleX, float &pixelScaleY)
{
GpAppInterface_Get()->PL_AdjustRequestedResolution(width, height);
return GpAppInterface_Get()->PL_AdjustRequestedResolution(physicalWidth, physicalHeight, virtualWidth, virtualheight, pixelScaleX, pixelScaleY);
}
void GpAppEnvironment::SetDisplayDriver(IGpDisplayDriver *displayDriver)
@@ -175,6 +175,10 @@ void GpAppEnvironment::DispatchSystemCall(PortabilityLayer::HostSuspendCallID ca
m_applicationState = ApplicationState_TimedSuspend;
m_delaySuspendTicks = args[0].m_uint;
break;
case PortabilityLayer::HostSuspendCallID_CallOnVOSThread:
args[0].m_functionPtr(static_cast<const PortabilityLayer::HostSuspendCallArgument*>(args[1].m_constPointer), static_cast<PortabilityLayer::HostSuspendCallArgument*>(args[2].m_pointer));
m_applicationState = ApplicationState_Running;
break;
default:
assert(false);
}

View File

@@ -28,7 +28,7 @@ public:
GpDisplayDriverTickStatus_t Tick(IGpFiber *vosFiber);
void Render();
void AdjustRequestedResolution(unsigned int &width, unsigned int &height);
bool AdjustRequestedResolution(uint32_t &physicalWidth, uint32_t &physicalHeight, uint32_t &virtualWidth, uint32_t &virtualheight, float &pixelScaleX, float &pixelScaleY);
void SetDisplayDriver(IGpDisplayDriver *displayDriver);
void SetAudioDriver(IGpAudioDriver *audioDriver);

View File

@@ -13,6 +13,8 @@
#include <assert.h>
extern GpWindowsGlobals g_gpWindowsGlobals;
class GpDirectoryCursor_Win32 final : public PortabilityLayer::HostDirectoryCursor
{
public:
@@ -307,6 +309,7 @@ bool GpFileSystem_Win32::PromptSaveFile(PortabilityLayer::VirtualDirectory_t vir
ofn.nMaxFile = MAX_PATH;
ofn.lpstrInitialDir = baseDir;
ofn.Flags = OFN_EXPLORER | OFN_NOCHANGEDIR | OFN_OVERWRITEPROMPT;
ofn.hwndOwner = g_gpWindowsGlobals.m_hwnd;
if (!GetSaveFileNameW(&ofn))
return false;
@@ -387,6 +390,7 @@ bool GpFileSystem_Win32::PromptOpenFile(PortabilityLayer::VirtualDirectory_t vir
ofn.nMaxFile = MAX_PATH;
ofn.lpstrInitialDir = baseDir;
ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST;
ofn.hwndOwner = g_gpWindowsGlobals.m_hwnd;
if (!GetOpenFileNameW(&ofn))
return false;

View File

@@ -28,9 +28,9 @@ namespace
static_cast<GpAppEnvironment*>(context)->Render();
}
void AdjustRequestedResolution(void *context, unsigned int &width, unsigned int &height)
bool AdjustRequestedResolution(void *context, uint32_t &physicalWidth, uint32_t &physicalHeight, uint32_t &virtualWidth, uint32_t &virtualheight, float &pixelScaleX, float &pixelScaleY)
{
static_cast<GpAppEnvironment*>(context)->AdjustRequestedResolution(width, height);
return static_cast<GpAppEnvironment*>(context)->AdjustRequestedResolution(physicalWidth, physicalHeight, virtualWidth, virtualheight, pixelScaleX, pixelScaleY);
}
}

View File

@@ -24,7 +24,7 @@ extern "C" __declspec(dllimport) IGpAudioDriver *GpDriver_CreateAudioDriver_XAud
extern "C" __declspec(dllimport) IGpDisplayDriver *GpDriver_CreateDisplayDriver_D3D11(const GpDisplayDriverProperties &properties);
extern "C" __declspec(dllimport) IGpInputDriver *GpDriver_CreateInputDriver_XInput(const GpInputDriverProperties &properties);
static void PostMouseEvent(IGpVOSEventQueue *eventQueue, GpMouseEventType_t eventType, GpMouseButton_t button, int32_t x, int32_t y)
static void PostMouseEvent(IGpVOSEventQueue *eventQueue, GpMouseEventType_t eventType, GpMouseButton_t button, int32_t x, int32_t y, float pixelScaleX, float pixelScaleY)
{
if (GpVOSEvent *evt = eventQueue->QueueEvent())
{
@@ -35,6 +35,12 @@ static void PostMouseEvent(IGpVOSEventQueue *eventQueue, GpMouseEventType_t even
mEvent.m_x = x;
mEvent.m_y = y;
mEvent.m_eventType = eventType;
if (pixelScaleX != 1.0f)
mEvent.m_x = static_cast<int32_t>(static_cast<float>(x) / pixelScaleX);
if (pixelScaleY != 1.0f)
mEvent.m_y = static_cast<int32_t>(static_cast<float>(y) / pixelScaleX);
}
}
@@ -291,7 +297,7 @@ static void PostKeyboardEvent(IGpVOSEventQueue *eventQueue, GpKeyboardInputEvent
}
}
static void TranslateWindowsMessage(const MSG *msg, IGpVOSEventQueue *eventQueue)
static void TranslateWindowsMessage(const MSG *msg, IGpVOSEventQueue *eventQueue, float pixelScaleX, float pixelScaleY)
{
WPARAM wParam = msg->wParam;
LPARAM lParam = msg->lParam;
@@ -299,40 +305,40 @@ static void TranslateWindowsMessage(const MSG *msg, IGpVOSEventQueue *eventQueue
switch (msg->message)
{
case WM_LBUTTONDOWN:
PostMouseEvent(eventQueue, GpMouseEventTypes::kDown, GpMouseButtons::kLeft, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
PostMouseEvent(eventQueue, GpMouseEventTypes::kDown, GpMouseButtons::kLeft, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), pixelScaleX, pixelScaleY);
break;
case WM_LBUTTONUP:
PostMouseEvent(eventQueue, GpMouseEventTypes::kUp, GpMouseButtons::kLeft, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
PostMouseEvent(eventQueue, GpMouseEventTypes::kUp, GpMouseButtons::kLeft, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), pixelScaleX, pixelScaleY);
break;
case WM_MBUTTONDOWN:
PostMouseEvent(eventQueue, GpMouseEventTypes::kDown, GpMouseButtons::kMiddle, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
PostMouseEvent(eventQueue, GpMouseEventTypes::kDown, GpMouseButtons::kMiddle, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), pixelScaleX, pixelScaleY);
break;
case WM_MBUTTONUP:
PostMouseEvent(eventQueue, GpMouseEventTypes::kUp, GpMouseButtons::kMiddle, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
PostMouseEvent(eventQueue, GpMouseEventTypes::kUp, GpMouseButtons::kMiddle, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), pixelScaleX, pixelScaleY);
break;
case WM_RBUTTONDOWN:
PostMouseEvent(eventQueue, GpMouseEventTypes::kDown, GpMouseButtons::kRight, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
PostMouseEvent(eventQueue, GpMouseEventTypes::kDown, GpMouseButtons::kRight, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), pixelScaleX, pixelScaleY);
break;
case WM_RBUTTONUP:
PostMouseEvent(eventQueue, GpMouseEventTypes::kUp, GpMouseButtons::kRight, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
PostMouseEvent(eventQueue, GpMouseEventTypes::kUp, GpMouseButtons::kRight, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), pixelScaleX, pixelScaleY);
break;
case WM_XBUTTONDOWN:
if (GET_XBUTTON_WPARAM(wParam) == XBUTTON1)
PostMouseEvent(eventQueue, GpMouseEventTypes::kDown, GpMouseButtons::kX1, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
PostMouseEvent(eventQueue, GpMouseEventTypes::kDown, GpMouseButtons::kX1, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), pixelScaleX, pixelScaleY);
else if (GET_XBUTTON_WPARAM(wParam) == XBUTTON2)
PostMouseEvent(eventQueue, GpMouseEventTypes::kDown, GpMouseButtons::kX2, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
PostMouseEvent(eventQueue, GpMouseEventTypes::kDown, GpMouseButtons::kX2, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), pixelScaleX, pixelScaleY);
break;
case WM_XBUTTONUP:
if (GET_XBUTTON_WPARAM(wParam) == XBUTTON1)
PostMouseEvent(eventQueue, GpMouseEventTypes::kUp, GpMouseButtons::kX1, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
PostMouseEvent(eventQueue, GpMouseEventTypes::kUp, GpMouseButtons::kX1, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), pixelScaleX, pixelScaleY);
else if (GET_XBUTTON_WPARAM(wParam) == XBUTTON2)
PostMouseEvent(eventQueue, GpMouseEventTypes::kUp, GpMouseButtons::kX2, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
PostMouseEvent(eventQueue, GpMouseEventTypes::kUp, GpMouseButtons::kX2, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), pixelScaleX, pixelScaleY);
break;
case WM_MOUSEMOVE:
PostMouseEvent(eventQueue, GpMouseEventTypes::kMove, GpMouseButtons::kNone, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
PostMouseEvent(eventQueue, GpMouseEventTypes::kMove, GpMouseButtons::kNone, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), pixelScaleX, pixelScaleY);
break;
case WM_MOUSELEAVE:
PostMouseEvent(eventQueue, GpMouseEventTypes::kLeave, GpMouseButtons::kNone, 0, 0);
PostMouseEvent(eventQueue, GpMouseEventTypes::kLeave, GpMouseButtons::kNone, 0, 0, pixelScaleX, pixelScaleY);
break;
case WM_KEYDOWN:
case WM_SYSKEYDOWN:
@@ -373,6 +379,12 @@ static void TranslateWindowsMessage(const MSG *msg, IGpVOSEventQueue *eventQueue
PostKeyboardEvent(eventQueue, keyEventType, subset, key, (lParam & 0xffff));
}
break;
case WM_QUIT:
{
if (GpVOSEvent *evt = eventQueue->QueueEvent())
evt->m_eventType = GpVOSEventTypes::kQuit;
}
break;
default:
break;
}
@@ -388,6 +400,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
g_gpWindowsGlobals.m_cmdLine = lpCmdLine;
g_gpWindowsGlobals.m_nCmdShow = nCmdShow;
g_gpWindowsGlobals.m_baseDir = GpFileSystem_Win32::GetInstance()->GetBasePath();
g_gpWindowsGlobals.m_hwnd = nullptr;
g_gpWindowsGlobals.m_createFiberFunc = GpFiber_Win32::Create;
g_gpWindowsGlobals.m_loadCursorFunc = GpCursor_Win32::Load;

View File

@@ -7,6 +7,7 @@
<ClCompile>
<AdditionalIncludeDirectories>$(SolutionDir)Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<ConformanceMode>true</ConformanceMode>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup />

View File

@@ -52,6 +52,14 @@ const CompileJob kCompileJobs[] =
drawQuadDefs,
"PSMain",
"ps_4_0"
},
{
L"ShaderSrc\\ScaleQuadP.hlsl",
L"GpDisplayDriver_D3D11\\CompiledShaders\\ScaleQuadP_D3D11.cpp",
"g_scaleQuadP_D3D11",
drawQuadDefs,
"PSMain",
"ps_4_0"
}
};

View File

@@ -79,4 +79,18 @@ copy /Y GliderProData\ConvertedMovies\*.mov.gpa Packaged\Houses\
attrib +R Packaged\Houses\*
mkdir InstallerPackages
mkdir InstallerPackages\DefaultHouses
mkdir InstallerPackages\HousePack1
mkdir InstallerPackages\LooseDocumentation
copy /Y Packaged\Houses\* InstallerPackages\HousePack1\
del /Q InstallerPackages\HousePack1\Slumberland.*
del /Q "InstallerPackages\HousePack1\Demo House.*"
copy /Y Packaged\Houses\Slumberland.* InstallerPackages\DefaultHouses
copy /Y "Packaged\Houses\Demo House.*" InstallerPackages\DefaultHouses
copy /Y Documentation\* InstallerPackages\LooseDocumentation\
del /Q InstallerPackages\LooseDocumentation\readme.txt
pause

View File

@@ -1,55 +1,57 @@
Aerofoil is a third-party port of Glider PRO
Thank you for trying Aerofoil!
Aerofoil is (c)2019-2020 Eric Lasota
Glider PRO is (c)1994-2000 Casady & Greene, Inc., written by John Calhoun
Aerofoil is not maintained by, supported by, endorsed by, or otherwise associated with the authors and publishers of Glider PRO.
IMPORTANT: Aerofoil is not maintained by, supported by, endorsed by, or
otherwise associated with the authors and publishers of Glider PRO.
Please do not contact any of them regarding issues related to Aerofoil.
If you have an issue with Aerofoil, please post an issue to the Aerofoil issue tracker on GitHub:
If you have an issue with Aerofoil, please post an issue to the Aerofoil
issue tracker on GitHub:
https://github.com/elasota/Aerofoil/issues
Requires Windows 8 and the Visual Studio 2017 redistributable runtime.
Please see this page for more info:
https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads
XInput gamepads are supported. Other gamepads may be supported via third-party software that maps them to XInput (i.e. PS4 gamepads are supported via DS4Windows)
Some shortcuts:
- While in-game, Ctrl-S saves the game. You can then reload the game from the main menu.
IN-GAME SHORTCUT COMMANDS
-------------------------------------------------------------------------------
- Ctrl-S saves the game. You can reload a saved game from the main menu.
- Ctrl-Q quits the game.
- Alt-Enter toggles full screen.
GAMEPAD SUPPORT
-------------------------------------------------------------------------------
XInput gamepads are supported. Other gamepads may be supported via third-party
software that maps them to XInput (i.e. PS4 gamepads are supported via DS4Windows)
LEGAL NOTICES
-------------------------------------------------------------------------------
Aerofoil is (c)2019-2020 Eric Lasota
Based on Glider PRO (c)1994-2000 Casady & Greene, Inc., written by John Calhoun
Distributed under the terms of the GNU General Public License version 2 (see license_gplv2.txt)
Aerofoil uses the following third-party software:
-------------------------------------------------------------------------------
Open Sans font:
(c)2011 Google
Distributed under the Apache License (see license_apache.txt)
-------------------------------------------------------------------------------
stb_image_write:
Created by Sean Barrett
-------------------------------------------------------------------------------
LIBICONV:
Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc.
Distributed under the LGPLv2 license (See license_lgplv2.txt)
-------------------------------------------------------------------------------
RapidJSON:
Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.
Distributed under the MIT license (See license_rapidjson.txt)
-------------------------------------------------------------------------------
zlib:
(C) 1995-2017 Jean-loup Gailly and Mark Adler
@@ -74,9 +76,17 @@ zlib:
jloup@gzip.org madler@alumni.caltech.edu
-------------------------------------------------------------------------------
FreeType:
Portions of this software are copyright (c)2020 The FreeType Project (www.freetype.org). All rights reserved.
Portions of this software are copyright (c)2020 The FreeType Project (www.freetype.org).
All rights reserved.
Distributed under the GPLv2 license (see license_gplv2.txt)
The Unarchiver:
The "unpacktool" utility is heavily based on code from The Unarchiver.
Copyright (C) 2006-2013 Dag Ågren
Distributed under the LGPLv2 license (See license_lgplv2.txt)

View File

@@ -1,16 +1,26 @@
If you want to import an existing third-party Glider PRO house to Aerofoil, a few steps are required.
First, you need to generate a timestamp file. Use the "MakeTimestamp" utility to dump the current time to a timestamp file.
You need to convert the file into Aerofoil's "triplet" format, which consists of a metadata file (extension .gpf), and file forks (.gpd for data, .gpr for resources). How you get these depends on the input format:
- For MacBinary files (.bin), use the "bin2gp" utility
- For BinHex files (.hqx), use the "hqx2gp" utility
- For StuffIt (.sit) and Compact Pro (.cpt) archives, use the "unpacktool" utility to extract the contents in triplet format. The "unpacktool" utility should support any most vintage StuffIt archives made with StuffIt Deluxe 6 or lower.
Second, you need to extract the house data from the original archive. Most existing Glider PRO houses are in StuffIt! archives (.sit extension), which can be difficult to extract. There is a utility called The Unarchiver for macOS which appears to support it. An alternative is to extract the file on an actual vintage Mac.
(NOTE: ".sea" files are self-extracting archives, typically StuffIt or Compact Pro archives with the self-extractor program in the resources. These will always be distributed in a fork-grouping container like MacBinary or BinHex. For cases like these, you need to split the self-extracting archive using "bin2gp" or "hqx2gp" and then pass the ".sea.gpd" file (which contains the archive data) to "unpacktool" to decompress it.)
The next step depends on whether or not the house has custom resources. If the house doesn't have custom resources, then add a ".gpd" extension to the house and use the FTagData utility to generate a corresponding ".gpf" metadata file, using the timestamp you generated in the first step. You need to specify "gliH" as the file type ID and "ozm5" as the file creator ID.
Once you've done that, if the house has custom resources (i.e. a .gpr file), you need to convert it to an Aerofoil resource archive, which you can do using the "gpr2gpa" tool.
If the house does have custom resources, then you need to get the resource data somehow, and you still need to generate the metadata. There are a few options there:
- If extracting the file generated a separate file containing the resource data, which I think is what happens when extracting files on macOS, then you can use the resource file directly, and handle the other steps the same as you would if it didn't have custom resources.
- If you can get the house into MacBinary format, then you can use the "bin2gp" utility to convert it to .gpf, .gpd, and .gpr files.
- If you can get the house into BinHex4 (.hqx) format, then you can use the "hqx2gp" utility to convert it to .gpf, .gpd, and .gpr files.
gpr2gpa's PICT converter may not support all PICT encodings. If you find a house with custom PICT resources that isn't supported, please submit a sample to Aerofoil's issue tracker.
Once you have a .gpr file of the raw Mac-format resource data, you need to convert it to Aerofoil's ZIP-based resource archive format and convert the internal resources out of Mac-specific formats. Use the "gpr2gpa" utility to do this.
gpr2gpa's PICT converter may not support all PICT encodings. If you find a house with custom PICT resources that isn't supported, please submit a sample to Aerofoil's issue tracker.
Converting QuickTime movies for displaying on in-game TVs is a bit more complex. First, you need to convert the movie to a sequence of BMP images, which you can do with third-party tools such as FFMPEG. Second, you need to create a JSON file containing the movie metadata, which looks like this, for example:
{
"frameRateNumerator" : 8,
"frameRateDenominator" : 1
}
Once you've done that, create a ZIP archive where the path of the JSON file is "muvi\0.json" and the frames are "PICT\<frame number>.bmp", where <frame number> is the frame number, starting with 1 as the first frame, and name that the same as the house name, but with a ".mov.gpa" extension.
Next, you need to create a metadata file for the movie, which should have a ".mov.gpf" extension. You can create the metadata file using the "FTagData" utility, using a timestamp file created with the "MakeTimestamp" utility.
Some old QuickTime movies contain movie tracking information in the movie resource fork, in which case you need to merge them into the data for modern utilities to read them. You can use the "flattenmov" tool to do this: Pass it the data (.gpd) and resource (.gpr) data files for a movie, and it will merge them into a single .mov file.

View File

@@ -7,6 +7,7 @@
#include "PLAppleEvents.h"
#include "AppEventHandler.h"
#include "DialogManager.h"
#include "Externs.h"
#include "House.h"
@@ -168,12 +169,38 @@ PLError_t MyGotRequiredParams (const AppleEvent *theAE)
PLErrors::kInvalidParameter;
}
class SystemEventHandlerImpl : public PortabilityLayer::IAppEventHandler
{
public:
void OnQuit() override;
static SystemEventHandlerImpl *GetInstance();
private:
static SystemEventHandlerImpl ms_instance;
};
void SystemEventHandlerImpl::OnQuit()
{
quitting = true;
}
SystemEventHandlerImpl *SystemEventHandlerImpl::GetInstance()
{
return &ms_instance;
}
SystemEventHandlerImpl SystemEventHandlerImpl::ms_instance;
//-------------------------------------------------------------- SetUpAppleEvents
// Initializes all handlers, etc. for dealing with Apple Events.
void SetUpAppleEvents (void)
{
PLError_t theErr;
PortabilityLayer::AppEventHandler::SetInstance(SystemEventHandlerImpl::GetInstance());
openAppAEUPP = NewAEEventHandlerProc(DoOpenAppAE);
openDocAEUPP = NewAEEventHandlerProc(DoOpenDocAE);

View File

@@ -59,6 +59,7 @@ void NilSavedMaps (void)
}
savedMaps[i].where = -1;
savedMaps[i].who = -1;
savedMaps[i].component = -1;
}
numSavedMaps = 0;
}
@@ -69,7 +70,7 @@ void NilSavedMaps (void)
// room that it obscured so that, should the player get the object,<2C>
// it can be made to "disappear".
short BackUpToSavedMap (Rect *theRect, SInt16 where, SInt16 who)
short BackUpToSavedMap (Rect *theRect, SInt16 where, SInt16 who, SInt16 component)
{
Rect mapRect;
PLError_t theErr;
@@ -89,6 +90,7 @@ short BackUpToSavedMap (Rect *theRect, SInt16 where, SInt16 who)
savedMaps[numSavedMaps].where = where;
savedMaps[numSavedMaps].who = who;
savedMaps[numSavedMaps].component = component;
numSavedMaps++;
return (numSavedMaps - 1); // return array index
@@ -99,7 +101,7 @@ short BackUpToSavedMap (Rect *theRect, SInt16 where, SInt16 who)
// a slot in the pixmap array for the object. It re-copies the background<6E>
// and is needed when the lights in the room go on or off.
SInt16 ReBackUpSavedMap (Rect *theRect, SInt16 where, SInt16 who)
SInt16 ReBackUpSavedMap (Rect *theRect, SInt16 where, SInt16 who, SInt16 component)
{
Rect mapRect;
short i, foundIndex;
@@ -108,7 +110,7 @@ SInt16 ReBackUpSavedMap (Rect *theRect, SInt16 where, SInt16 who)
for (i = 0; i < numSavedMaps; i++)
{
if ((savedMaps[i].where == where) && (savedMaps[i].who == who))
if ((savedMaps[i].where == where) && (savedMaps[i].who == who) && (savedMaps[i].component == component))
{
foundIndex = i;
mapRect = *theRect;
@@ -124,7 +126,7 @@ SInt16 ReBackUpSavedMap (Rect *theRect, SInt16 where, SInt16 who)
}
}
return BackUpToSavedMap(theRect, where, who);
return BackUpToSavedMap(theRect, where, who, component);
}
//-------------------------------------------------------------- RemoveFromSavedMap
@@ -179,14 +181,14 @@ SInt16 RemoveFromSavedMap (SInt16 index)
// This copies the saved background swatch to the screen - effectively<6C>
// covering up or "erasing" the object.
void RestoreFromSavedMap (short where, short who, Boolean doSparkle)
void RestoreFromSavedMap (SInt16 where, SInt16 who, SInt16 component, Boolean doSparkle)
{
Rect mapRect, bounds;
short i;
for (i = 0; i < numSavedMaps; i++)
{
if ((savedMaps[i].where == where) && (savedMaps[i].who == who) &&
if ((savedMaps[i].where == where) && (savedMaps[i].who == who) && (savedMaps[i].component == component) &&
(savedMaps[i].map != nil))
{
mapRect = savedMaps[i].dest;
@@ -384,7 +386,7 @@ void AddCandleFlame (SInt16 where, SInt16 who, SInt16 h, SInt16 v)
QOffsetRect(&src, 2, 0);
}
QSetRect(&bounds, 0, 0, 16, 15 * kNumCandleFlames);
savedNum = BackUpToSavedMap(&bounds, where, who);
savedNum = BackUpToSavedMap(&bounds, where, who, kCandleFlameComponent);
if (savedNum != -1)
{
BackUpFlames(&src, savedNum);
@@ -471,7 +473,7 @@ void AddTikiFlame (short where, short who, short h, short v)
}
QOffsetRect(&src, h, v);
QSetRect(&bounds, 0, 0, 8, 10 * kNumTikiFlames);
savedNum = BackUpToSavedMap(&bounds, where, who);
savedNum = BackUpToSavedMap(&bounds, where, who, kTikiFlamesComponent);
if (savedNum != -1)
{
BackUpTikiFlames(&src, savedNum);
@@ -560,7 +562,7 @@ void AddBBQCoals (short where, short who, short h, short v)
}
QOffsetRect(&src, h, v);
QSetRect(&bounds, 0, 0, 32, 9 * kNumBBQCoals);
savedNum = BackUpToSavedMap(&bounds, where, who);
savedNum = BackUpToSavedMap(&bounds, where, who, kBBQCoalsComponent);
if (savedNum != -1)
{
BackUpBBQCoals(&src, savedNum);
@@ -644,7 +646,7 @@ void AddPendulum (SInt16 where, SInt16 who, SInt16 h, SInt16 v)
clockFrame = 10;
QSetRect(&bounds, 0, 0, 32, 28 * kNumPendulums);
savedNum = BackUpToSavedMap(&bounds, where, who);
savedNum = BackUpToSavedMap(&bounds, where, who, kPendulumComponent);
if (savedNum != -1)
{
QSetRect(&src, 0, 0, 32, 28);
@@ -745,7 +747,7 @@ void AddStar (short where, short who, short h, short v)
QOffsetRect(&src, h, v);
QSetRect(&bounds, 0, 0, 32, 31 * 6);
savedNum = BackUpToSavedMap(&bounds, where, who);
savedNum = BackUpToSavedMap(&bounds, where, who, kStarComponent);
if (savedNum != -1)
{
BackUpStar(&src, savedNum);

View File

@@ -17,6 +17,8 @@
#include "IGpDisplayDriver.h"
#include "WindowManager.h"
#include <algorithm>
#define kSwitchDepthAlert 130
#define kSetMemoryAlert 180
#define kLowMemoryAlert 181
@@ -344,8 +346,28 @@ public:
HandleResolutionChange(prevWidth, prevHeight, newWidth, newHeight);
}
void AdjustRequestedResolution(uint32_t &width, uint32_t &height) override
void AdjustRequestedResolution(uint32_t &physicalWidth, uint32_t &physicalHeight, uint32_t &virtualWidth, uint32_t &virtualHeight, float &pixelScaleX, float &pixelScaleY) override
{
if (physicalWidth < 640)
physicalWidth = 640;
if (physicalHeight < 480)
physicalHeight = 480;
double xMul = static_cast<double>(physicalWidth) / 640;
double yMul = static_cast<double>(physicalHeight) / 480;
double granularity = 2.0;
xMul = floor(xMul * granularity) / granularity;
yMul = floor(yMul * granularity) / granularity;
double minMul = std::max<double>(1.0, std::min(xMul, yMul));
virtualWidth = physicalWidth / minMul;
virtualHeight = physicalHeight / minMul;
pixelScaleX = static_cast<float>(minMul);
pixelScaleY = static_cast<float>(minMul);
}
static GpAppResolutionChangeHandler ms_instance;

View File

@@ -17,6 +17,7 @@
#include "House.h"
#include "InputManager.h"
#include "ObjectEdit.h"
#include "Rect2i.h"
#include "WindowManager.h"
@@ -30,6 +31,7 @@ void HandleIdleTask (void);
void IncrementMode (void);
long lastUp, incrementModeTime;
UInt32 doubleTime;
Point lastWhere;
@@ -66,7 +68,7 @@ short BitchAboutColorDepth (void)
void HandleMouseEvent (const GpMouseInputEvent &theEvent, uint32_t tick)
{
WindowPtr whichWindow;
long menuChoice, newSize;
long menuChoice;
short thePart, hDelta, vDelta;
Boolean isDoubleClick;
Point evtPoint = Point::Create(theEvent.m_x, theEvent.m_y);
@@ -108,11 +110,11 @@ void HandleMouseEvent (const GpMouseInputEvent &theEvent, uint32_t tick)
}
break;
case RegionIDs::kExpand:
case RegionIDs::kResize:
if (whichWindow == mapWindow)
{
newSize = GrowWindow(mapWindow, evtPoint, &thisMac.gray);
ResizeMapWindow(LoWord(newSize), HiWord(newSize));
PortabilityLayer::Vec2i newSize = TrackResize(mapWindow, evtPoint, 47, 35, &thisMac.gray);
ResizeMapWindow(newSize.m_x, newSize.m_y);
}
break;
@@ -440,6 +442,22 @@ void HandleSplashResolutionChange(void)
//DumpScreenOn(&justRoomsRect);
}
void KeepWindowInBounds(Window *window)
{
if (!window)
return;
PortabilityLayer::Rect2i windowRect = PortabilityLayer::WindowManager::GetInstance()->GetWindowFullRect(window);
int32_t topNudge = std::max<int32_t>(kScoreboardTall - windowRect.Top(), 0);
int32_t bottomNudge = std::min<int32_t>(thisMac.fullScreen.bottom - windowRect.Bottom(), 0);
int32_t leftNudge = std::max<int32_t>(-windowRect.Left(), 0);
int32_t rightNudge = std::min<int32_t>(thisMac.fullScreen.right - windowRect.Right(), 0);
window->m_wmX += leftNudge + rightNudge;
window->m_wmY += topNudge + bottomNudge;
}
void HandleEditorResolutionChange(void)
{
FlushResolutionChange();
@@ -461,6 +479,10 @@ void HandleEditorResolutionChange(void)
if (mapWindow)
PortabilityLayer::WindowManager::GetInstance()->PutWindowBehind(mapWindow, PortabilityLayer::WindowManager::GetInstance()->GetPutInFrontSentinel());
KeepWindowInBounds(mainWindow);
KeepWindowInBounds(toolsWindow);
KeepWindowInBounds(mapWindow);
}
//-------------------------------------------------------------- HandleIdleTask

View File

@@ -16,6 +16,7 @@ namespace PortabilityLayer
class ResourceArchive;
class ScanlineMask;
class ResTypeID;
struct RGBAColor;
}
#define kPreferredDepth 8
@@ -222,7 +223,7 @@ void GetLocalWindowRect (WindowPtr, Rect *);
//void FlagWindowFloating (WindowPtr);
//Boolean IsWindowFloating (WindowPtr);
void OpenMessageWindow (const PLPasStr&);
void SetMessageWindowMessage (StringPtr);
void SetMessageWindowMessage (StringPtr msg, const PortabilityLayer::RGBAColor &color);
void CloseMessageWindow (void);
void CloseThisWindow (WindowPtr *);

View File

@@ -621,3 +621,10 @@ static const Boolean kFaceLeft = FALSE; // Conflicts with GP input driver
#define kDemoLength 6702
#define kGamepadDeadzone 4096 // Out of 32768
#define kDefaultComponent 0
#define kCandleFlameComponent 1
#define kTikiFlamesComponent 1
#define kBBQCoalsComponent 1
#define kPendulumComponent 1
#define kStarComponent 1

View File

@@ -23,10 +23,10 @@ void CloseCoordWindow (void);
void ToggleCoordinateWindow (void);
void NilSavedMaps (void); // --- DynamicMaps.c
SInt16 BackUpToSavedMap (Rect *, SInt16, SInt16);
SInt16 ReBackUpSavedMap (Rect *, SInt16, SInt16);
SInt16 BackUpToSavedMap (Rect *theRect, SInt16 where, SInt16 who, SInt16 component);
SInt16 ReBackUpSavedMap (Rect *theRect, SInt16 where, SInt16 who, SInt16 component);
SInt16 RemoveFromSavedMap(SInt16);
void RestoreFromSavedMap (SInt16, SInt16, Boolean);
void RestoreFromSavedMap (SInt16 where, SInt16 who, SInt16 component, Boolean doSparkle);
void AddSparkle (Rect *);
void AddFlyingPoint (Rect *, SInt16, SInt16, SInt16);
Boolean ReBackUpFlames (SInt16, SInt16, SInt16, SInt16);

View File

@@ -241,6 +241,7 @@ typedef struct
DrawSurface *map;
short where;
short who;
short component;
} savedType, *savedPtr;
typedef struct

View File

@@ -25,7 +25,7 @@ public:
void PL_HostFontHandler_SetInstance(PortabilityLayer::HostFontHandler *instance) override;
void PL_HostVOSEventQueue_SetInstance(PortabilityLayer::HostVOSEventQueue *instance) override;
void PL_InstallHostSuspendHook(PortabilityLayer::HostSuspendHook_t hook, void *context) override;
void PL_AdjustRequestedResolution(unsigned int &width, unsigned int &height) override;
bool PL_AdjustRequestedResolution(uint32_t &physicalWidth, uint32_t &physicalHeight, uint32_t &virtualWidth, uint32_t &virtualheight, float &pixelScaleX, float &pixelScaleY) override;
};
@@ -80,13 +80,16 @@ void GpAppInterfaceImpl::PL_InstallHostSuspendHook(PortabilityLayer::HostSuspend
PortabilityLayer::InstallHostSuspendHook(hook, context);
}
void GpAppInterfaceImpl::PL_AdjustRequestedResolution(unsigned int &width, unsigned int &height)
bool GpAppInterfaceImpl::PL_AdjustRequestedResolution(uint32_t &physicalWidth, uint32_t &physicalHeight, uint32_t &virtualWidth, uint32_t &virtualheight, float &pixelScaleX, float &pixelScaleY)
{
uint32_t w32 = width;
uint32_t h32 = height;
PortabilityLayer::DisplayDeviceManager::GetInstance()->GetResolutionChangeHandler()->AdjustRequestedResolution(w32, h32);
width = w32;
height = h32;
PortabilityLayer::DisplayDeviceManager::IResolutionChangeHandler *handler = PortabilityLayer::DisplayDeviceManager::GetInstance()->GetResolutionChangeHandler();
if (!handler)
return false;
handler->AdjustRequestedResolution(physicalWidth, physicalHeight, virtualWidth, virtualheight, pixelScaleX, pixelScaleY);
return true;
}

View File

@@ -213,7 +213,7 @@ short AddGrease (short where, short who, short h, short v,
QOffsetRect(&src, h, v);
QSetRect(&bounds, 0, 0, 32, 27 * 4);
savedNum = BackUpToSavedMap(&bounds, where, who);
savedNum = BackUpToSavedMap(&bounds, where, who, kDefaultComponent);
if (savedNum != -1)
{
BackupGrease (&src, savedNum, isRight);
@@ -332,5 +332,5 @@ void RemapGreaseSavedMap(SInt16 removedItem, SInt16 substituteItem)
grease[i].mapNum = removedItem;
return;
}
}
}
}

View File

@@ -17,6 +17,7 @@
#include "FileManager.h"
#include "HostFileSystem.h"
#include "House.h"
#include "PLStandardColors.h"
#include "PLTimeTaggedVOSEvent.h"
#include "RectUtils.h"
#include "ResourceManager.h"
@@ -730,7 +731,7 @@ void ConvertHouseVer1To2 (void)
NumToString((long)i, roomStr);
GetLocalizedString(14, message);
PasStringConcat(message, roomStr);
SetMessageWindowMessage(message);
SetMessageWindowMessage(message, StdColors::Black());
SpinCursor(1);
ForceThisRoom(i);

View File

@@ -8,8 +8,10 @@
#include "PLNumberFormatting.h"
#include "PLStringCompare.h"
#include "PLStandardColors.h"
#include "Externs.h"
#include "ObjectEdit.h"
#include "PLStandardColors.h"
#include "RectUtils.h"
@@ -739,9 +741,8 @@ void LopOffExtraRooms (void)
newSize = sizeof(houseType) + (sizeof(roomType) * (long)r);
if (SetHandleSize(thisHouse.StaticCast<void>(), newSize) != PLErrors::kNone) // resize house handle (shrink)
{
ForeColor(redColor);
GetLocalizedString(16, message);
SetMessageWindowMessage(message);
SetMessageWindowMessage(message, StdColors::Red());
}
(*thisHouse)->nRooms -= count;
numberRooms = (*thisHouse)->nRooms;
@@ -772,21 +773,17 @@ void ValidateRoomNumbers (void)
((*thisHouse)->rooms[i].floor < -7))
{
(*thisHouse)->rooms[i].suite = kRoomIsEmpty;
ForeColor(redColor);
GetLocalizedString(17, message);
SetMessageWindowMessage(message);
SetMessageWindowMessage(message, StdColors::Red());
houseErrors++;
ForeColor(blackColor);
}
if (((*thisHouse)->rooms[i].suite >= 128) ||
((*thisHouse)->rooms[i].suite < 0))
{
(*thisHouse)->rooms[i].suite = kRoomIsEmpty;
ForeColor(redColor);
GetLocalizedString(18, message);
SetMessageWindowMessage(message);
SetMessageWindowMessage(message, StdColors::Red());
houseErrors++;
ForeColor(blackColor);
}
}
}
@@ -885,11 +882,9 @@ void KeepAllObjectsLegal (void)
{
if (!KeepObjectLegal())
{
ForeColor(redColor);
GetLocalizedString(19, message);
SetMessageWindowMessage(message);
SetMessageWindowMessage(message, StdColors::Red());
houseErrors++;
ForeColor(blackColor);
DelayTicks(60);
}
}
@@ -923,10 +918,8 @@ void CheckForStaircasePairs (void)
neighbor = GetNeighborRoomNumber(kNorthRoom);
if (neighbor == kRoomIsEmpty)
{
ForeColor(redColor);
GetLocalizedString(20, message);
SetMessageWindowMessage(message);
ForeColor(blackColor);
SetMessageWindowMessage(message, StdColors::Red());
DelayTicks(60);
}
else
@@ -940,10 +933,8 @@ void CheckForStaircasePairs (void)
}
if (!hasStairs)
{
ForeColor(redColor);
GetLocalizedString(21, message);
SetMessageWindowMessage(message);
ForeColor(blackColor);
SetMessageWindowMessage(message, StdColors::Red());
DelayTicks(60);
}
}
@@ -954,10 +945,8 @@ void CheckForStaircasePairs (void)
neighbor = GetNeighborRoomNumber(kSouthRoom);
if (neighbor == kRoomIsEmpty)
{
ForeColor(redColor);
GetLocalizedString(22, message);
SetMessageWindowMessage(message);
ForeColor(blackColor);
SetMessageWindowMessage(message, StdColors::Red());
DelayTicks(60);
}
else
@@ -971,10 +960,8 @@ void CheckForStaircasePairs (void)
}
if (!hasStairs)
{
ForeColor(redColor);
GetLocalizedString(23, message);
SetMessageWindowMessage(message);
ForeColor(blackColor);
SetMessageWindowMessage(message, StdColors::Red());
DelayTicks(60);
}
}
@@ -1004,19 +991,19 @@ void CheckHouseForProblems (void)
SpinCursor(3);
GetLocalizedString(25, message);
SetMessageWindowMessage(message);
SetMessageWindowMessage(message, StdColors::Black());
WrapBannerAndTrailer();
if (isHouseChecks)
{
SpinCursor(3);
GetLocalizedString(26, message);
SetMessageWindowMessage(message);
SetMessageWindowMessage(message, StdColors::Black());
ValidateNumberOfRooms();
if (houseErrors != 0)
{
GetLocalizedString(27, message);
SetMessageWindowMessage(message);
SetMessageWindowMessage(message, StdColors::Black());
DelayTicks(60);
houseErrors = 0;
}
@@ -1032,9 +1019,7 @@ void CheckHouseForProblems (void)
NumToString((long)houseErrors, message);
GetLocalizedString(28, message2);
PasStringConcat(message, message2);
ForeColor(redColor);
SetMessageWindowMessage(message);
ForeColor(blackColor);
SetMessageWindowMessage(message, StdColors::Red());
DelayTicks(45);
}
}
@@ -1053,9 +1038,7 @@ void CheckHouseForProblems (void)
NumToString((long)houseErrors, message);
GetLocalizedString(29, message2);
PasStringConcat(message, message2);
ForeColor(redColor);
SetMessageWindowMessage(message);
ForeColor(blackColor);
SetMessageWindowMessage(message, StdColors::Red());
DelayTicks(60);
}
}
@@ -1070,9 +1053,7 @@ void CheckHouseForProblems (void)
NumToString((long)houseErrors, message);
GetLocalizedString(30, message2);
PasStringConcat(message, message2);
ForeColor(blueColor);
SetMessageWindowMessage(message);
ForeColor(blackColor);
SetMessageWindowMessage(message, StdColors::Blue());
DelayTicks(45);
}
}
@@ -1087,9 +1068,7 @@ void CheckHouseForProblems (void)
NumToString((long)houseErrors, message);
GetLocalizedString(31, message2);
PasStringConcat(message, message2);
ForeColor(blueColor);
SetMessageWindowMessage(message);
ForeColor(blackColor);
SetMessageWindowMessage(message, StdColors::Blue());
DelayTicks(45);
}
}
@@ -1104,9 +1083,7 @@ void CheckHouseForProblems (void)
NumToString((long)houseErrors, message);
GetLocalizedString(32, message2);
PasStringConcat(message, message2);
ForeColor(redColor);
SetMessageWindowMessage(message);
ForeColor(blackColor);
SetMessageWindowMessage(message, StdColors::Red());
DelayTicks(60);
}
}
@@ -1116,16 +1093,14 @@ void CheckHouseForProblems (void)
SpinCursor(3);
houseErrors = 0;
GetLocalizedString(33, message);
SetMessageWindowMessage(message);
SetMessageWindowMessage(message, StdColors::Black());
KeepAllObjectsLegal();
if (houseErrors != 0)
{
NumToString((long)houseErrors, message);
GetLocalizedString(34, message2);
PasStringConcat(message, message2);
ForeColor(redColor);
SetMessageWindowMessage(message);
ForeColor(blackColor);
SetMessageWindowMessage(message, StdColors::Red());
DelayTicks(60);
}
}
@@ -1142,10 +1117,8 @@ void CheckHouseForProblems (void)
SpinCursor(3);
if (CountStarsInHouse() < 1)
{
ForeColor(redColor);
GetLocalizedString(35, message);
SetMessageWindowMessage(message);
ForeColor(blackColor);
SetMessageWindowMessage(message, StdColors::Red());
DelayTicks(60);
}
}

View File

@@ -769,7 +769,7 @@ void HandleRewards (gliderPtr thisGlider, hotPtr who)
{
PlayPrioritySound(kBeepsSound, kBeepsPriority);
RestoreFromSavedMap(thisRoomNumber,
masterObjects[whoLinked].objectNum, false);
masterObjects[whoLinked].objectNum, kDefaultComponent, false);
AddFlyingPoint(&bounds, 100, thisGlider->hVel / 2, thisGlider->vVel / 2);
thisGlider->hVel /= 4;
thisGlider->vVel /= 4;
@@ -785,7 +785,7 @@ void HandleRewards (gliderPtr thisGlider, hotPtr who)
{
PlayPrioritySound(kBuzzerSound, kBuzzerPriority);
RestoreFromSavedMap(thisRoomNumber,
masterObjects[whoLinked].objectNum, false);
masterObjects[whoLinked].objectNum, kDefaultComponent, false);
AddFlyingPoint(&bounds, 300, thisGlider->hVel / 2, thisGlider->vVel / 2);
thisGlider->hVel /= 4;
thisGlider->vVel /= 4;
@@ -801,7 +801,7 @@ void HandleRewards (gliderPtr thisGlider, hotPtr who)
{
PlayPrioritySound(kDingSound, kDingPriority);
RestoreFromSavedMap(thisRoomNumber,
masterObjects[whoLinked].objectNum, false);
masterObjects[whoLinked].objectNum, kDefaultComponent, false);
AddFlyingPoint(&bounds, 500, thisGlider->hVel / 2, thisGlider->vVel / 2);
thisGlider->hVel /= 4;
thisGlider->vVel /= 4;
@@ -817,7 +817,7 @@ void HandleRewards (gliderPtr thisGlider, hotPtr who)
{
PlayPrioritySound(kCuckooSound, kCuckooPriority);
RestoreFromSavedMap(thisRoomNumber,
masterObjects[whoLinked].objectNum, false);
masterObjects[whoLinked].objectNum, kDefaultComponent, false);
StopPendulum(thisRoomNumber, masterObjects[whoLinked].objectNum);
AddFlyingPoint(&bounds, 1000, thisGlider->hVel / 2, thisGlider->vVel / 2);
thisGlider->hVel /= 4;
@@ -834,7 +834,7 @@ void HandleRewards (gliderPtr thisGlider, hotPtr who)
{
PlayPrioritySound(kEnergizeSound, kEnergizePriority);
RestoreFromSavedMap(thisRoomNumber,
masterObjects[whoLinked].objectNum, false);
masterObjects[whoLinked].objectNum, kDefaultComponent, false);
AddSparkle(&bounds);
thisGlider->hVel /= 2;
thisGlider->vVel /= 2;
@@ -853,7 +853,7 @@ void HandleRewards (gliderPtr thisGlider, hotPtr who)
{
PlayPrioritySound(kEnergizeSound, kEnergizePriority);
RestoreFromSavedMap(thisRoomNumber,
masterObjects[whoLinked].objectNum, false);
masterObjects[whoLinked].objectNum, kDefaultComponent, false);
AddSparkle(&bounds);
thisGlider->hVel /= 2;
thisGlider->vVel /= 2;
@@ -875,7 +875,7 @@ void HandleRewards (gliderPtr thisGlider, hotPtr who)
{
PlayPrioritySound(kEnergizeSound, kEnergizePriority);
RestoreFromSavedMap(thisRoomNumber,
masterObjects[whoLinked].objectNum, false);
masterObjects[whoLinked].objectNum, kDefaultComponent, false);
AddSparkle(&bounds);
thisGlider->hVel /= 2;
thisGlider->vVel /= 2;
@@ -903,7 +903,7 @@ void HandleRewards (gliderPtr thisGlider, hotPtr who)
{
PlayPrioritySound(kEnergizeSound, kEnergizePriority);
RestoreFromSavedMap(thisRoomNumber,
masterObjects[whoLinked].objectNum, false);
masterObjects[whoLinked].objectNum, kDefaultComponent, false);
AddSparkle(&bounds);
thisGlider->hVel /= 2;
thisGlider->vVel /= 2;
@@ -936,7 +936,7 @@ void HandleRewards (gliderPtr thisGlider, hotPtr who)
{
PlayPrioritySound(kEnergizeSound, kEnergizePriority);
RestoreFromSavedMap(thisRoomNumber,
masterObjects[whoLinked].objectNum, false);
masterObjects[whoLinked].objectNum, kDefaultComponent, false);
AddSparkle(&bounds);
StopStar(thisRoomNumber, masterObjects[whoLinked].objectNum);
numStarsRemaining--;
@@ -959,7 +959,7 @@ void HandleRewards (gliderPtr thisGlider, hotPtr who)
{
PlayPrioritySound(kEnergizeSound, kEnergizePriority);
RestoreFromSavedMap(thisRoomNumber,
masterObjects[whoLinked].objectNum, false);
masterObjects[whoLinked].objectNum, kDefaultComponent, false);
AddSparkle(&bounds);
thisGlider->hVel /= 2;
thisGlider->vVel /= 2;
@@ -1050,12 +1050,12 @@ void HandleSwitches (hotPtr who)
case kFoil:
case kStar:
case kHelium:
RestoreFromSavedMap(roomLinked, objectLinked, true);
RestoreFromSavedMap(roomLinked, objectLinked, kDefaultComponent, true);
AddSparkle(&bounds);
break;
case kCuckoo:
RestoreFromSavedMap(roomLinked, objectLinked, true);
RestoreFromSavedMap(roomLinked, objectLinked, kDefaultComponent, true);
StopPendulum(roomLinked, objectLinked);
break;

View File

@@ -32,7 +32,7 @@
void DrawOnSplash (DrawSurface *surface);
void SetPaletteToGrays (void);
void HardDrawMainWindow (void);
void KeepWindowInBounds(Window *window);
CTabHandle theCTab;
PixMapHandle thePMap;
@@ -207,6 +207,8 @@ void OpenMainWindow (void)
whichRoom = GetFirstRoomNumber();
CopyRoomToThisRoom(whichRoom);
ReflectCurrentRoom(false);
KeepWindowInBounds(mainWindow);
}
else
{

View File

@@ -35,11 +35,12 @@
void LoadGraphicPlus (DrawSurface *, short, const Rect &);
void RedrawMapContents (void);
void LiveHScrollAction (ControlHandle, short);
void LiveVScrollAction (ControlHandle, short);
void LiveHScrollAction (PortabilityLayer::Widget *theControl, int thePart);
void LiveVScrollAction (PortabilityLayer::Widget *theControl, int thePart);
Boolean QueryNewRoom (void);
void CreateNailOffscreen (void);
void KillNailOffscreen (void);
void KeepWindowInBounds (Window *window);
Rect nailSrcRect, activeRoomRect, wasActiveRoomRect;
Rect mapHScrollRect, mapVScrollRect, mapCenterRect;
@@ -294,6 +295,29 @@ void RedrawMapContents (void)
}
#endif
//-------------------------------------------------------------- UpdateMapWindow
void DrawMapResizeBox(void)
{
DrawSurface *surface = &mapWindow->m_surface;
const Rect windowRect = surface->m_port.GetRect();
Rect growBoxRect = Rect::Create(windowRect.bottom - 14, windowRect.right - 14, windowRect.bottom, windowRect.right);
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(204, 204, 204, 255));
surface->FillRect(growBoxRect);
surface->SetForeColor(StdColors::Black());
surface->FillRect(Rect::Create(growBoxRect.top + 2, growBoxRect.left + 2, growBoxRect.top + 3, growBoxRect.left + 6));
surface->FillRect(Rect::Create(growBoxRect.top + 3, growBoxRect.left + 2, growBoxRect.top + 6, growBoxRect.left + 3));
surface->FillRect(Rect::Create(growBoxRect.top + 8, growBoxRect.left + 11, growBoxRect.top + 12, growBoxRect.left + 12));
surface->FillRect(Rect::Create(growBoxRect.top + 11, growBoxRect.left + 8, growBoxRect.top + 12, growBoxRect.left + 11));
for (int i = 0; i < 7; i++)
surface->FillRect(Rect::Create(growBoxRect.top + 3 + i, growBoxRect.left + 3 + i, growBoxRect.top + 5 + i, growBoxRect.left + 5 + i));
}
//-------------------------------------------------------------- UpdateMapWindow
void UpdateMapWindow (void)
@@ -310,6 +334,8 @@ void UpdateMapWindow (void)
SetPortWindowPort(mapWindow);
// PL_NotYetImplemented_TODO("Resize")
RedrawMapContents();
DrawMapResizeBox();
#endif
}
@@ -338,12 +364,12 @@ void ResizeMapWindow (short newH, short newV)
SizeWindow(mapWindow, mapWindowRect.right, mapWindowRect.bottom, true);
mapHScroll->SetMax(kMaxNumRoomsH - mapRoomsWide);
mapHScroll->SetPosition(Point::Create(0, mapWindowRect.bottom - kMapScrollBarWidth + 1));
mapHScroll->SetPosition(Point::Create(-1, mapWindowRect.bottom - kMapScrollBarWidth + 1));
mapHScroll->Resize(mapWindowRect.right - kMapScrollBarWidth + 3, kMapScrollBarWidth);
mapLeftRoom = mapHScroll->GetState();
mapVScroll->SetMax(kMaxNumRoomsV - mapRoomsHigh);
mapVScroll->SetPosition(Point::Create(mapWindowRect.right - kMapScrollBarWidth + 1, 0));
mapVScroll->SetPosition(Point::Create(mapWindowRect.right - kMapScrollBarWidth + 1, -1));
mapVScroll->Resize(kMapScrollBarWidth, mapWindowRect.bottom - kMapScrollBarWidth + 3);
mapTopRoom = mapVScroll->GetState();
@@ -365,7 +391,7 @@ void OpenMapWindow (void)
mapRoomsWide * kMapRoomWidth + kMapScrollBarWidth - 1,
mapRoomsHigh * kMapRoomHeight + kMapScrollBarWidth - 1);
const uint16_t windowStyle = PortabilityLayer::WindowStyleFlags::kTitleBar | PortabilityLayer::WindowStyleFlags::kResizable | PortabilityLayer::WindowStyleFlags::kMiniBar | PortabilityLayer::WindowStyleFlags::kCloseBox;;
const uint16_t windowStyle = PortabilityLayer::WindowStyleFlags::kTitleBar | PortabilityLayer::WindowStyleFlags::kResizable | PortabilityLayer::WindowStyleFlags::kMiniBar | PortabilityLayer::WindowStyleFlags::kCloseBox;
PortabilityLayer::WindowDef wdef = PortabilityLayer::WindowDef::Create(mapWindowRect, windowStyle, false, 0, 0, PSTR("Map"));
@@ -430,6 +456,8 @@ void OpenMapWindow (void)
CenterMapOnRoom(thisRoom->suite, thisRoom->floor);
UpdateMapWindow();
KeepWindowInBounds(mapWindow);
}
UpdateMapCheckmark(true);

View File

@@ -301,9 +301,9 @@ void DrawARoomsObjects (short neighbor, Boolean redraw)
if (SectRect(&itsRect, &testRect, &whoCares))
{
if (redraw)
legit = ReBackUpSavedMap(&itsRect, localNumbers[neighbor], i);
legit = ReBackUpSavedMap(&itsRect, localNumbers[neighbor], i, kDefaultComponent);
else
legit = BackUpToSavedMap(&itsRect, localNumbers[neighbor], i);
legit = BackUpToSavedMap(&itsRect, localNumbers[neighbor], i, kDefaultComponent);
if (legit != -1)
DrawRedClock(&itsRect);
}
@@ -315,9 +315,9 @@ void DrawARoomsObjects (short neighbor, Boolean redraw)
if (SectRect(&itsRect, &testRect, &whoCares))
{
if (redraw)
legit = ReBackUpSavedMap(&itsRect, localNumbers[neighbor], i);
legit = ReBackUpSavedMap(&itsRect, localNumbers[neighbor], i, kDefaultComponent);
else
legit = BackUpToSavedMap(&itsRect, localNumbers[neighbor], i);
legit = BackUpToSavedMap(&itsRect, localNumbers[neighbor], i, kDefaultComponent);
if (legit != -1)
DrawBlueClock(&itsRect);
}
@@ -329,9 +329,9 @@ void DrawARoomsObjects (short neighbor, Boolean redraw)
if (SectRect(&itsRect, &testRect, &whoCares))
{
if (redraw)
legit = ReBackUpSavedMap(&itsRect, localNumbers[neighbor], i);
legit = ReBackUpSavedMap(&itsRect, localNumbers[neighbor], i, kDefaultComponent);
else
legit = BackUpToSavedMap(&itsRect, localNumbers[neighbor], i);
legit = BackUpToSavedMap(&itsRect, localNumbers[neighbor], i, kDefaultComponent);
if (legit != -1)
DrawYellowClock(&itsRect);
}
@@ -343,9 +343,9 @@ void DrawARoomsObjects (short neighbor, Boolean redraw)
if (SectRect(&itsRect, &testRect, &whoCares))
{
if (redraw)
legit = ReBackUpSavedMap(&itsRect, localNumbers[neighbor], i);
legit = ReBackUpSavedMap(&itsRect, localNumbers[neighbor], i, kDefaultComponent);
else
legit = BackUpToSavedMap(&itsRect, localNumbers[neighbor], i);
legit = BackUpToSavedMap(&itsRect, localNumbers[neighbor], i, kDefaultComponent);
if (legit != -1)
{
DrawCuckoo(&itsRect);
@@ -369,9 +369,9 @@ void DrawARoomsObjects (short neighbor, Boolean redraw)
if (SectRect(&itsRect, &testRect, &whoCares))
{
if (redraw)
legit = ReBackUpSavedMap(&itsRect, localNumbers[neighbor], i);
legit = ReBackUpSavedMap(&itsRect, localNumbers[neighbor], i, kDefaultComponent);
else
legit = BackUpToSavedMap(&itsRect, localNumbers[neighbor], i);
legit = BackUpToSavedMap(&itsRect, localNumbers[neighbor], i, kDefaultComponent);
if (legit != -1)
DrawSimplePrizes(thisObject.what, &itsRect);
}
@@ -435,9 +435,9 @@ void DrawARoomsObjects (short neighbor, Boolean redraw)
if (SectRect(&itsRect, &testRect, &whoCares))
{
if (redraw)
legit = ReBackUpSavedMap(&itsRect, localNumbers[neighbor], i);
legit = ReBackUpSavedMap(&itsRect, localNumbers[neighbor], i, kDefaultComponent);
else
legit = BackUpToSavedMap(&itsRect, localNumbers[neighbor], i);
legit = BackUpToSavedMap(&itsRect, localNumbers[neighbor], i, kDefaultComponent);
if (legit != -1)
DrawFoil(&itsRect);
}
@@ -453,9 +453,9 @@ void DrawARoomsObjects (short neighbor, Boolean redraw)
if (SectRect(&itsRect, &testRect, &whoCares))
{
if (redraw)
legit = ReBackUpSavedMap(&itsRect, localNumbers[neighbor], i);
legit = ReBackUpSavedMap(&itsRect, localNumbers[neighbor], i, kDefaultComponent);
else
legit = BackUpToSavedMap(&itsRect, localNumbers[neighbor], i);
legit = BackUpToSavedMap(&itsRect, localNumbers[neighbor], i, kDefaultComponent);
if (legit != -1)
{
if (redraw)
@@ -953,15 +953,12 @@ void DrawARoomsObjects (short neighbor, Boolean redraw)
}
}
if (!redraw) // set up links
for (n = 0; n < numMasterObjects; n++)
{
for (n = 0; n < numMasterObjects; n++)
{
if ((masterObjects[n].objectNum == i) &&
(masterObjects[n].roomNum == localNumbers[neighbor]))
masterObjects[n].dynaNum = dynamicNum;
}
if ((masterObjects[n].objectNum == i) &&
(masterObjects[n].roomNum == localNumbers[neighbor]))
masterObjects[n].dynaNum = dynamicNum;
}
}
}

View File

@@ -17,6 +17,7 @@
#include "ObjectEdit.h"
#include "Objects.h"
#include "Play.h"
#include "PLStandardColors.h"
#include "RectUtils.h"
#include "ResourceManager.h"
#include "Room.h"
@@ -812,10 +813,8 @@ void AddObjectPairing (void)
GetLocalizedString(45, message);
OpenMessageWindow(message);
ForeColor(blueColor);
GetLocalizedString(46, message);
SetMessageWindowMessage(message);
ForeColor(blackColor);
SetMessageWindowMessage(message, StdColors::Blue());
DelayTicks(60);
CloseMessageWindow();
}
@@ -843,10 +842,8 @@ void AddObjectPairing (void)
GetLocalizedString(45, message);
OpenMessageWindow(message);
ForeColor(blueColor);
GetLocalizedString(46, message);
SetMessageWindowMessage(message);
ForeColor(blackColor);
SetMessageWindowMessage(message, StdColors::Blue());
DelayTicks(60);
CloseMessageWindow();
}
@@ -874,10 +871,8 @@ void AddObjectPairing (void)
GetLocalizedString(45, message);
OpenMessageWindow(message);
ForeColor(blueColor);
GetLocalizedString(47, message);
SetMessageWindowMessage(message);
ForeColor(blackColor);
SetMessageWindowMessage(message, StdColors::Blue());
DelayTicks(60);
CloseMessageWindow();
}
@@ -905,10 +900,8 @@ void AddObjectPairing (void)
GetLocalizedString(45, message);
OpenMessageWindow(message);
ForeColor(blueColor);
GetLocalizedString(47, message);
SetMessageWindowMessage(message);
ForeColor(blackColor);
SetMessageWindowMessage(message, StdColors::Blue());
DelayTicks(60);
CloseMessageWindow();
}
@@ -936,10 +929,8 @@ void AddObjectPairing (void)
GetLocalizedString(45, message);
OpenMessageWindow(message);
ForeColor(blueColor);
GetLocalizedString(48, message);
SetMessageWindowMessage(message);
ForeColor(blackColor);
SetMessageWindowMessage(message, StdColors::Blue());
DelayTicks(60);
CloseMessageWindow();
}
@@ -967,10 +958,8 @@ void AddObjectPairing (void)
GetLocalizedString(45, message);
OpenMessageWindow(message);
ForeColor(blueColor);
GetLocalizedString(48, message);
SetMessageWindowMessage(message);
ForeColor(blackColor);
SetMessageWindowMessage(message, StdColors::Blue());
DelayTicks(60);
CloseMessageWindow();
}
@@ -998,10 +987,8 @@ void AddObjectPairing (void)
GetLocalizedString(45, message);
OpenMessageWindow(message);
ForeColor(blueColor);
GetLocalizedString(49, message);
SetMessageWindowMessage(message);
ForeColor(blackColor);
SetMessageWindowMessage(message, StdColors::Blue());
DelayTicks(60);
CloseMessageWindow();
}
@@ -1029,10 +1016,8 @@ void AddObjectPairing (void)
GetLocalizedString(45, message);
OpenMessageWindow(message);
ForeColor(blueColor);
GetLocalizedString(49, message);
SetMessageWindowMessage(message);
ForeColor(blackColor);
SetMessageWindowMessage(message, StdColors::Blue());
DelayTicks(60);
CloseMessageWindow();
}
@@ -1061,10 +1046,8 @@ void AddObjectPairing (void)
GetLocalizedString(45, message);
OpenMessageWindow(message);
ForeColor(blueColor);
GetLocalizedString(50, message);
SetMessageWindowMessage(message);
ForeColor(blackColor);
SetMessageWindowMessage(message, StdColors::Blue());
DelayTicks(60);
CloseMessageWindow();
}
@@ -1093,10 +1076,8 @@ void AddObjectPairing (void)
GetLocalizedString(45, message);
OpenMessageWindow(message);
ForeColor(blueColor);
GetLocalizedString(51, message);
SetMessageWindowMessage(message);
ForeColor(blackColor);
SetMessageWindowMessage(message, StdColors::Blue());
DelayTicks(60);
CloseMessageWindow();
}

View File

@@ -50,6 +50,10 @@ void ResetLocale (Boolean soft)
{
RemoveSavedMapsNotInRoom(localNumbers[kCentralRoom]);
ZeroDinahsNotInRoom(localNumbers[kCentralRoom]);
// Clear all dinah indexes, they'll be remapped
for (int i = 0; i < numMasterObjects; i++)
masterObjects[i].dynaNum = -1;
}
else
{
@@ -428,9 +432,10 @@ void RedrawRoomLighting (void)
{
DrawRoomBackground(localNumbers[kCentralRoom], kCentralRoom, roomV);
DrawARoomsObjects(kCentralRoom, true);
RedrawAllGrease();
DrawLighting();
UpdateOutletsLighting(localNumbers[kCentralRoom], numLights);
if (numNeighbors > 3)
DrawFloorSupport();
RestoreWorkMap();

View File

@@ -888,6 +888,8 @@ void FrameDisplayIcon (Dialog *theDialog, const PortabilityLayer::RGBAColor &col
surface->FrameRect(theRect);
InsetRect(&theRect, 1, 1);
surface->FrameRect(theRect);
surface->SetForeColor(StdColors::Black());
}
//-------------------------------------------------------------- DisplayUpdate
@@ -898,9 +900,7 @@ void DisplayUpdate (Dialog *theDialog)
SetDialogItemValue(theDialog, kDoColorFadeItem, (short)wasFade);
ForeColor(redColor);
FrameDisplayIcon(theDialog, StdColors::Red());
ForeColor(blackColor);
FrameDialogItemC(theDialog, kBorder1Item, kRedOrangeColor8);
FrameDialogItemC(theDialog, kBorder2Item, kRedOrangeColor8);
FrameDialogItemC(theDialog, kBorder3Item, kRedOrangeColor8);
@@ -1055,7 +1055,6 @@ void DoDisplayPrefs (void)
case kDispDefault:
FrameDisplayIcon(prefDlg, StdColors::White());
ForeColor(blackColor);
DisplayDefaults();
DisplayUpdate(prefDlg);
break;

View File

@@ -61,6 +61,7 @@ void FrameSelectedTool (DrawSurface *);
void DrawToolName (DrawSurface *);
void DrawToolTiles (DrawSurface *);
void SwitchToolModes (short);
void KeepWindowInBounds (Window *window);
Rect toolsWindowRect, toolSrcRect, toolTextRect;
@@ -134,7 +135,7 @@ void FrameSelectedTool (DrawSurface *surface)
InsetRect(&theRect, 1, 1);
surface->FrameRect(theRect);
ForeColor(blackColor);
surface->SetForeColor(StdColors::Black());
}
#endif
@@ -350,6 +351,8 @@ void OpenToolsWindow (void)
SwitchToolModes(toolMode);
toolSelected = kSelectTool;
KeepWindowInBounds(toolsWindow);
}
UpdateToolsCheckmark(true);

View File

@@ -136,7 +136,7 @@ void OpenMessageWindow (const PLPasStr &title)
// For the above message window, this function displays a string of text<78>
// in the center of the window.
void SetMessageWindowMessage (StringPtr message)
void SetMessageWindowMessage (StringPtr message, const PortabilityLayer::RGBAColor &color)
{
Rect mssgWindowRect;
@@ -150,7 +150,7 @@ void SetMessageWindowMessage (StringPtr message)
surface->FillRect(mssgWindowRect);
const Point textPoint = Point::Create(mssgWindowRect.left, mssgWindowRect.bottom - 6);
surface->SetForeColor(StdColors::Black());
surface->SetForeColor(color);
surface->DrawString(textPoint, message, true);
}
}

View File

@@ -3,6 +3,8 @@
#include "EGpDisplayDriverType.h"
#include "GpDisplayDriverTickStatus.h"
#include <stdint.h>
struct IGpDisplayDriver;
struct IGpFiber;
struct IGpVOSEventQueue;
@@ -11,7 +13,7 @@ struct GpDisplayDriverProperties
{
typedef GpDisplayDriverTickStatus_t (*TickFunc_t)(void *context, IGpFiber *vosFiber);
typedef void(*RenderFunc_t)(void *context);
typedef void(*AdjustRequestedResolutionFunc_t)(void *context, unsigned int &width, unsigned int &height);
typedef bool(*AdjustRequestedResolutionFunc_t)(void *context, uint32_t &physicalWidth, uint32_t &physicalHeight, uint32_t &virtualWidth, uint32_t &virtualheight, float &pixelScaleX, float &pixelScaleY);
EGpDisplayDriverType m_type;

View File

@@ -251,6 +251,7 @@ namespace GpVOSEventTypes
kMouseInput,
kGamepadInput,
kVideoResolutionChanged,
kQuit
};
}

View File

@@ -21,9 +21,10 @@ struct GpWindowsGlobals
HINSTANCE m_hPrevInstance;
LPCSTR m_cmdLine;
LPCWSTR m_baseDir;
HWND m_hwnd;
int m_nCmdShow;
IGpFiber *(*m_createFiberFunc)(LPVOID fiber);
IGpCursor_Win32 *(*m_loadCursorFunc)(const wchar_t *path);
void (*m_translateWindowsMessageFunc)(const MSG *msg, IGpVOSEventQueue *eventQueue);
void (*m_translateWindowsMessageFunc)(const MSG *msg, IGpVOSEventQueue *eventQueue, float pixelScaleX, float pixelScaleY);
};

View File

@@ -25,4 +25,6 @@ public:
virtual void UpdatePalette(const void *paletteData) = 0;
virtual void SetBackgroundColor(uint8_t r, uint8_t g, uint8_t b, uint8_t a) = 0;
virtual void RequestToggleFullScreen(uint32_t timestamp) = 0;
};

View File

@@ -1,8 +1,8 @@
static unsigned char gs_shaderData[] = {
68, 88, 66, 67, 96, 46, 192, 91, 73, 216, 92, 145, 77, 166, 215,
215, 59, 255, 4, 67, 1, 0, 0, 0, 240, 2, 0, 0, 5, 0,
68, 88, 66, 67, 75, 29, 59, 91, 67, 226, 130, 211, 218, 1, 246,
35, 4, 77, 147, 90, 1, 0, 0, 0, 4, 3, 0, 0, 5, 0,
0, 0, 52, 0, 0, 0, 224, 0, 0, 0, 56, 1, 0, 0, 108,
1, 0, 0, 116, 2, 0, 0, 82, 68, 69, 70, 164, 0, 0, 0,
1, 0, 0, 136, 2, 0, 0, 82, 68, 69, 70, 164, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 28, 0, 0,
0, 0, 4, 255, 255, 0, 137, 0, 0, 122, 0, 0, 0, 92, 0,
0, 0, 2, 0, 0, 0, 4, 0, 0, 0, 4, 0, 0, 0, 255,
@@ -23,33 +23,34 @@ static unsigned char gs_shaderData[] = {
78, 44, 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, 83, 86, 95, 84, 65, 82, 71, 69,
84, 0, 171, 171, 83, 72, 68, 82, 0, 1, 0, 0, 64, 0, 0,
0, 64, 0, 0, 0, 88, 24, 0, 4, 0, 112, 16, 0, 0, 0,
84, 0, 171, 171, 83, 72, 68, 82, 20, 1, 0, 0, 64, 0, 0,
0, 69, 0, 0, 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, 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, 2, 1, 0, 0, 0, 27, 0, 0, 5, 50, 0,
16, 0, 0, 0, 0, 0, 70, 16, 16, 0, 1, 0, 0, 0, 54,
0, 0, 8, 194, 0, 16, 0, 0, 0, 0, 0, 2, 64, 0, 0,
0, 104, 0, 0, 2, 1, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 45, 0, 0, 7, 242, 0, 16, 0, 0,
0, 0, 0, 70, 14, 16, 0, 0, 0, 0, 0, 70, 126, 16, 0,
0, 0, 0, 0, 54, 0, 0, 8, 226, 0, 16, 0, 0, 0, 0,
0, 2, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 45, 0, 0, 7, 242, 0, 16, 0, 0,
0, 0, 0, 70, 14, 16, 0, 0, 0, 0, 0, 70, 126, 16, 0,
1, 0, 0, 0, 54, 0, 0, 5, 114, 32, 16, 0, 0, 0, 0,
0, 70, 2, 16, 0, 0, 0, 0, 0, 54, 0, 0, 5, 130, 32,
16, 0, 0, 0, 0, 0, 1, 64, 0, 0, 0, 0, 128, 63, 62,
0, 0, 1, 83, 84, 65, 84, 116, 0, 0, 0, 9, 0, 0, 0,
1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 1, 0, 0,
0, 0, 0, 0, 0, 0, 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, 45, 0, 0, 7, 242, 0, 16, 0, 0, 0, 0, 0, 70, 14,
16, 0, 0, 0, 0, 0, 70, 126, 16, 0, 0, 0, 0, 0, 54,
0, 0, 8, 226, 0, 16, 0, 0, 0, 0, 0, 2, 64, 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, 4, 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, 0, 0, 0, 0, 0, 0,
0, 45, 0, 0, 7, 242, 0, 16, 0, 0, 0, 0, 0, 70, 14,
16, 0, 0, 0, 0, 0, 70, 126, 16, 0, 1, 0, 0, 0, 54,
0, 0, 5, 114, 32, 16, 0, 0, 0, 0, 0, 70, 2, 16, 0,
0, 0, 0, 0, 54, 0, 0, 5, 130, 32, 16, 0, 0, 0, 0,
0, 1, 64, 0, 0, 0, 0, 128, 63, 62, 0, 0, 1, 83, 84,
65, 84, 116, 0, 0, 0, 8, 0, 0, 0, 1, 0, 0, 0, 0,
0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 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, 2, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 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,
};
namespace GpBinarizedShaders

View File

@@ -1,49 +1,46 @@
static unsigned char gs_shaderData[] = {
68, 88, 66, 67, 181, 133, 124, 121, 179, 141, 64, 216, 166, 21, 153,
10, 33, 21, 80, 169, 1, 0, 0, 0, 152, 2, 0, 0, 5, 0,
0, 0, 52, 0, 0, 0, 224, 0, 0, 0, 56, 1, 0, 0, 108,
1, 0, 0, 28, 2, 0, 0, 82, 68, 69, 70, 164, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 28, 0, 0,
0, 0, 4, 255, 255, 0, 137, 0, 0, 122, 0, 0, 0, 92, 0,
0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0,
107, 0, 0, 0, 2, 0, 0, 0, 5, 0, 0, 0, 4, 0, 0,
0, 255, 255, 255, 255, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0,
0, 0, 115, 117, 114, 102, 97, 99, 101, 83, 97, 109, 112, 108, 101,
114, 0, 115, 117, 114, 102, 97, 99, 101, 84, 101, 120, 116, 117, 114,
101, 0, 77, 105, 99, 114, 111, 115, 111, 102, 116, 32, 40, 82, 41,
32, 72, 76, 83, 76, 32, 83, 104, 97, 100, 101, 114, 32, 67, 111,
109, 112, 105, 108, 101, 114, 32, 49, 48, 46, 49, 0, 171, 171, 73,
83, 71, 78, 80, 0, 0, 0, 2, 0, 0, 0, 8, 0, 0, 0,
56, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0,
0, 0, 0, 0, 0, 15, 0, 0, 0, 68, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 1, 0, 0, 0, 3,
3, 0, 0, 83, 86, 95, 80, 79, 83, 73, 84, 73, 79, 78, 0,
84, 69, 88, 67, 79, 79, 82, 68, 0, 171, 171, 171, 79, 83, 71,
78, 44, 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, 83, 86, 95, 84, 65, 82, 71, 69,
84, 0, 171, 171, 83, 72, 68, 82, 168, 0, 0, 0, 64, 0, 0,
0, 42, 0, 0, 0, 90, 0, 0, 3, 0, 96, 16, 0, 0, 0,
68, 88, 66, 67, 196, 70, 6, 103, 19, 68, 64, 241, 205, 255, 73,
188, 120, 217, 29, 231, 1, 0, 0, 0, 116, 2, 0, 0, 5, 0,
0, 0, 52, 0, 0, 0, 176, 0, 0, 0, 8, 1, 0, 0, 60,
1, 0, 0, 248, 1, 0, 0, 82, 68, 69, 70, 116, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 28, 0, 0,
0, 0, 4, 255, 255, 0, 137, 0, 0, 75, 0, 0, 0, 60, 0,
0, 0, 2, 0, 0, 0, 5, 0, 0, 0, 4, 0, 0, 0, 255,
255, 255, 255, 0, 0, 0, 0, 1, 0, 0, 0, 9, 0, 0, 0,
115, 117, 114, 102, 97, 99, 101, 84, 101, 120, 116, 117, 114, 101, 0,
77, 105, 99, 114, 111, 115, 111, 102, 116, 32, 40, 82, 41, 32, 72,
76, 83, 76, 32, 83, 104, 97, 100, 101, 114, 32, 67, 111, 109, 112,
105, 108, 101, 114, 32, 49, 48, 46, 49, 0, 171, 73, 83, 71, 78,
80, 0, 0, 0, 2, 0, 0, 0, 8, 0, 0, 0, 56, 0, 0,
0, 0, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 0, 0,
0, 0, 15, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 3, 0, 0, 0, 1, 0, 0, 0, 3, 3, 0, 0,
83, 86, 95, 80, 79, 83, 73, 84, 73, 79, 78, 0, 84, 69, 88,
67, 79, 79, 82, 68, 0, 171, 171, 171, 79, 83, 71, 78, 44, 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, 83, 86, 95, 84, 65, 82, 71, 69, 84, 0, 171,
171, 83, 72, 68, 82, 180, 0, 0, 0, 64, 0, 0, 0, 45, 0,
0, 0, 88, 24, 0, 4, 0, 112, 16, 0, 0, 0, 0, 0, 85,
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,
2, 1, 0, 0, 0, 69, 0, 0, 9, 242, 0, 16, 0, 0, 0,
0, 0, 70, 16, 16, 0, 1, 0, 0, 0, 70, 126, 16, 0, 0,
0, 0, 0, 0, 96, 16, 0, 0, 0, 0, 0, 54, 0, 0, 5,
18, 32, 16, 0, 0, 0, 0, 0, 10, 0, 16, 0, 0, 0, 0,
0, 54, 0, 0, 5, 98, 32, 16, 0, 0, 0, 0, 0, 6, 17,
16, 0, 1, 0, 0, 0, 54, 0, 0, 5, 130, 32, 16, 0, 0,
0, 0, 0, 1, 64, 0, 0, 0, 0, 128, 63, 62, 0, 0, 1,
83, 84, 65, 84, 116, 0, 0, 0, 5, 0, 0, 0, 1, 0, 0,
0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
2, 1, 0, 0, 0, 27, 0, 0, 5, 50, 0, 16, 0, 0, 0,
0, 0, 70, 16, 16, 0, 1, 0, 0, 0, 54, 0, 0, 8, 194,
0, 16, 0, 0, 0, 0, 0, 2, 64, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 45, 0, 0,
7, 242, 0, 16, 0, 0, 0, 0, 0, 70, 14, 16, 0, 0, 0,
0, 0, 70, 126, 16, 0, 0, 0, 0, 0, 54, 0, 0, 5, 114,
32, 16, 0, 0, 0, 0, 0, 70, 2, 16, 0, 0, 0, 0, 0,
54, 0, 0, 5, 130, 32, 16, 0, 0, 0, 0, 0, 1, 64, 0,
0, 0, 0, 128, 63, 62, 0, 0, 1, 83, 84, 65, 84, 116, 0,
0, 0, 6, 0, 0, 0, 1, 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, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 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, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 3, 0, 0, 0, 0, 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,
};
namespace GpBinarizedShaders

View File

@@ -0,0 +1,101 @@
static unsigned char gs_shaderData[] = {
68, 88, 66, 67, 232, 177, 184, 42, 191, 44, 237, 186, 185, 1, 42,
67, 157, 207, 200, 70, 1, 0, 0, 0, 116, 5, 0, 0, 5, 0,
0, 0, 52, 0, 0, 0, 52, 1, 0, 0, 140, 1, 0, 0, 192,
1, 0, 0, 248, 4, 0, 0, 82, 68, 69, 70, 248, 0, 0, 0,
1, 0, 0, 0, 132, 0, 0, 0, 2, 0, 0, 0, 28, 0, 0,
0, 0, 4, 255, 255, 0, 137, 0, 0, 208, 0, 0, 0, 92, 0,
0, 0, 2, 0, 0, 0, 5, 0, 0, 0, 4, 0, 0, 0, 255,
255, 255, 255, 0, 0, 0, 0, 1, 0, 0, 0, 9, 0, 0, 0,
107, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0,
0, 0, 115, 117, 114, 102, 97, 99, 101, 84, 101, 120, 116, 117, 114,
101, 0, 83, 83, 99, 97, 108, 101, 81, 117, 97, 100, 80, 105, 120,
101, 108, 67, 111, 110, 115, 116, 97, 110, 116, 115, 0, 107, 0, 0,
0, 1, 0, 0, 0, 156, 0, 0, 0, 16, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 180, 0, 0, 0, 0, 0, 0, 0, 16,
0, 0, 0, 2, 0, 0, 0, 192, 0, 0, 0, 0, 0, 0, 0,
100, 120, 100, 121, 95, 85, 110, 117, 115, 101, 100, 0, 1, 0, 3,
0, 1, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 77, 105,
99, 114, 111, 115, 111, 102, 116, 32, 40, 82, 41, 32, 72, 76, 83,
76, 32, 83, 104, 97, 100, 101, 114, 32, 67, 111, 109, 112, 105, 108,
101, 114, 32, 49, 48, 46, 49, 0, 73, 83, 71, 78, 80, 0, 0,
0, 2, 0, 0, 0, 8, 0, 0, 0, 56, 0, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 15,
0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3, 0, 0, 0, 1, 0, 0, 0, 3, 3, 0, 0, 83, 86, 95,
80, 79, 83, 73, 84, 73, 79, 78, 0, 84, 69, 88, 67, 79, 79,
82, 68, 0, 171, 171, 171, 79, 83, 71, 78, 44, 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, 83, 86, 95, 84, 65, 82, 71, 69, 84, 0, 171, 171, 83, 72,
68, 82, 48, 3, 0, 0, 64, 0, 0, 0, 204, 0, 0, 0, 89,
0, 0, 4, 70, 142, 32, 0, 0, 0, 0, 0, 1, 0, 0, 0,
88, 24, 0, 4, 0, 112, 16, 0, 0, 0, 0, 0, 85, 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, 2, 5,
0, 0, 0, 51, 0, 0, 11, 50, 0, 16, 0, 0, 0, 0, 0,
70, 128, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 64, 0,
0, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 0, 0, 0, 0,
0, 0, 50, 0, 0, 14, 194, 0, 16, 0, 0, 0, 0, 0, 6,
132, 32, 128, 65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
63, 0, 0, 0, 63, 6, 20, 16, 0, 1, 0, 0, 0, 52, 0,
0, 10, 194, 0, 16, 0, 0, 0, 0, 0, 166, 14, 16, 0, 0,
0, 0, 0, 2, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 50, 0, 16,
0, 0, 0, 0, 0, 70, 0, 16, 0, 0, 0, 0, 0, 230, 10,
16, 0, 0, 0, 0, 0, 65, 0, 0, 5, 194, 0, 16, 0, 0,
0, 0, 0, 166, 14, 16, 0, 0, 0, 0, 0, 27, 0, 0, 5,
50, 0, 16, 0, 1, 0, 0, 0, 230, 10, 16, 0, 0, 0, 0,
0, 65, 0, 0, 5, 194, 0, 16, 0, 0, 0, 0, 0, 6, 4,
16, 0, 0, 0, 0, 0, 0, 0, 0, 8, 50, 0, 16, 0, 0,
0, 0, 0, 230, 10, 16, 128, 65, 0, 0, 0, 0, 0, 0, 0,
70, 0, 16, 0, 0, 0, 0, 0, 27, 0, 0, 5, 50, 0, 16,
0, 2, 0, 0, 0, 230, 10, 16, 0, 0, 0, 0, 0, 14, 32,
0, 8, 50, 0, 16, 0, 0, 0, 0, 0, 70, 0, 16, 0, 0,
0, 0, 0, 70, 128, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0,
54, 0, 0, 5, 66, 0, 16, 0, 1, 0, 0, 0, 1, 64, 0,
0, 0, 0, 0, 0, 54, 0, 0, 5, 194, 0, 16, 0, 2, 0,
0, 0, 86, 9, 16, 0, 1, 0, 0, 0, 45, 0, 0, 7, 242,
0, 16, 0, 3, 0, 0, 0, 70, 15, 16, 0, 2, 0, 0, 0,
70, 126, 16, 0, 0, 0, 0, 0, 45, 0, 0, 7, 242, 0, 16,
0, 4, 0, 0, 0, 134, 15, 16, 0, 2, 0, 0, 0, 70, 126,
16, 0, 0, 0, 0, 0, 54, 0, 0, 5, 130, 0, 16, 0, 1,
0, 0, 0, 26, 0, 16, 0, 2, 0, 0, 0, 45, 0, 0, 7,
242, 0, 16, 0, 2, 0, 0, 0, 198, 10, 16, 0, 1, 0, 0,
0, 70, 126, 16, 0, 0, 0, 0, 0, 45, 0, 0, 7, 242, 0,
16, 0, 1, 0, 0, 0, 70, 10, 16, 0, 1, 0, 0, 0, 70,
126, 16, 0, 0, 0, 0, 0, 56, 0, 0, 7, 114, 0, 16, 0,
4, 0, 0, 0, 6, 0, 16, 0, 0, 0, 0, 0, 70, 2, 16,
0, 4, 0, 0, 0, 56, 0, 0, 7, 114, 0, 16, 0, 3, 0,
0, 0, 6, 0, 16, 0, 0, 0, 0, 0, 70, 2, 16, 0, 3,
0, 0, 0, 0, 0, 0, 11, 82, 0, 16, 0, 0, 0, 0, 0,
6, 1, 16, 128, 65, 0, 0, 0, 0, 0, 0, 0, 2, 64, 0,
0, 0, 0, 128, 63, 0, 0, 0, 0, 0, 0, 128, 63, 0, 0,
0, 0, 50, 0, 0, 9, 114, 0, 16, 0, 2, 0, 0, 0, 6,
0, 16, 0, 0, 0, 0, 0, 70, 2, 16, 0, 2, 0, 0, 0,
70, 2, 16, 0, 3, 0, 0, 0, 56, 0, 0, 7, 114, 0, 16,
0, 2, 0, 0, 0, 86, 5, 16, 0, 0, 0, 0, 0, 70, 2,
16, 0, 2, 0, 0, 0, 50, 0, 0, 9, 178, 0, 16, 0, 0,
0, 0, 0, 6, 0, 16, 0, 0, 0, 0, 0, 70, 8, 16, 0,
1, 0, 0, 0, 70, 8, 16, 0, 4, 0, 0, 0, 50, 0, 0,
9, 114, 32, 16, 0, 0, 0, 0, 0, 166, 10, 16, 0, 0, 0,
0, 0, 70, 3, 16, 0, 0, 0, 0, 0, 70, 2, 16, 0, 2,
0, 0, 0, 54, 0, 0, 5, 130, 32, 16, 0, 0, 0, 0, 0,
1, 64, 0, 0, 0, 0, 128, 63, 62, 0, 0, 1, 83, 84, 65,
84, 116, 0, 0, 0, 26, 0, 0, 0, 5, 0, 0, 0, 0, 0,
0, 0, 2, 0, 0, 0, 15, 0, 0, 0, 0, 0, 0, 0, 0,
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, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 4,
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
{
const unsigned char *g_scaleQuadP_D3D11[2] = { gs_shaderData, gs_shaderData + sizeof(gs_shaderData) };
};

View File

@@ -1,4 +1,3 @@
#define _CRT_SECURE_NO_WARNINGS
#include "GpApplicationName.h"
#include "GpDisplayDriverD3D11.h"
#include "GpDisplayDriverSurfaceD3D11.h"
@@ -23,6 +22,7 @@ namespace GpBinarizedShaders
extern const unsigned char *g_drawQuadV_D3D11[2];
extern const unsigned char *g_drawQuadPaletteP_D3D11[2];
extern const unsigned char *g_drawQuadRGBP_D3D11[2];
extern const unsigned char *g_scaleQuadP_D3D11[2];
extern const unsigned char *g_drawQuad15BitP_D3D11[2];
}
@@ -56,6 +56,7 @@ LRESULT CALLBACK WinProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
switch (message)
{
case WM_DESTROY:
case WM_CLOSE:
{
PostQuitMessage(0);
return 0;
@@ -173,7 +174,10 @@ bool ResizeD3DWindow(HWND hWnd, DWORD &windowWidth, DWORD &windowHeight, LONG de
GetClientRect(hWnd, &windowRect);
windowRect.right = windowRect.left + desiredWidth;
windowRect.bottom = windowRect.top + desiredHeight;
if (!AdjustWindowRect(&windowRect, windowStyle, menus != nullptr))
LONG_PTR style = GetWindowLongPtrA(hWnd, GWL_STYLE);
if (!AdjustWindowRect(&windowRect, static_cast<DWORD>(style), menus != nullptr))
return false;
SetWindowPos(hWnd, HWND_TOP, windowRect.left, windowRect.top, windowRect.right - windowRect.left, windowRect.bottom - windowRect.top, SWP_NOZORDER | SWP_NOMOVE);
@@ -196,7 +200,7 @@ bool GpDisplayDriverD3D11::DetachSwapChain()
return true;
}
bool GpDisplayDriverD3D11::InitBackBuffer()
bool GpDisplayDriverD3D11::InitBackBuffer(uint32_t virtualWidth, uint32_t virtualHeight)
{
m_swapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), reinterpret_cast<LPVOID*>(m_backBufferTexture.GetMutablePtr()));
@@ -209,16 +213,61 @@ bool GpDisplayDriverD3D11::InitBackBuffer()
rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
rtvDesc.Texture2D.MipSlice = 0;
m_backBufferRTV = nullptr;
if (m_device->CreateRenderTargetView(m_backBufferTexture, &rtvDesc, m_backBufferRTV.GetMutablePtr()) != S_OK)
return false;
}
DXGI_FORMAT vbbFormat = DXGI_FORMAT_R8G8B8A8_UNORM_SRGB;
{
D3D11_TEXTURE2D_DESC vbbTextureDesc;
vbbTextureDesc.Width = static_cast<UINT>(virtualWidth);
vbbTextureDesc.Height = static_cast<UINT>(virtualHeight);
vbbTextureDesc.MipLevels = 1;
vbbTextureDesc.ArraySize = 1;
vbbTextureDesc.Format = vbbFormat;
vbbTextureDesc.SampleDesc.Count = 1;
vbbTextureDesc.SampleDesc.Quality = 0;
vbbTextureDesc.Usage = D3D11_USAGE_DEFAULT;
vbbTextureDesc.BindFlags = (D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET);
vbbTextureDesc.CPUAccessFlags = 0;
vbbTextureDesc.MiscFlags = 0;
m_virtualScreenTexture = nullptr;
if (m_device->CreateTexture2D(&vbbTextureDesc, nullptr, m_virtualScreenTexture.GetMutablePtr()) != S_OK)
return false;
}
{
D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
rtvDesc.Format = vbbFormat;
rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
rtvDesc.Texture2D.MipSlice = 0;
m_virtualScreenTextureRTV = nullptr;
if (m_device->CreateRenderTargetView(m_virtualScreenTexture, &rtvDesc, m_virtualScreenTextureRTV.GetMutablePtr()) != S_OK)
return false;
}
{
D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
srvDesc.Format = vbbFormat;
srvDesc.ViewDimension = D3D_SRV_DIMENSION_TEXTURE2D;
srvDesc.Texture2D.MipLevels = 1;
srvDesc.Texture2D.MostDetailedMip = 0;
m_virtualScreenTextureSRV = nullptr;
if (m_device->CreateShaderResourceView(m_virtualScreenTexture, &srvDesc, m_virtualScreenTextureSRV.GetMutablePtr()) != S_OK)
return false;
}
return true;
}
bool GpDisplayDriverD3D11::InitResources()
bool GpDisplayDriverD3D11::InitResources(uint32_t virtualWidth, uint32_t virtualHeight)
{
if (!InitBackBuffer())
if (!InitBackBuffer(virtualWidth, virtualHeight))
return false;
// Quad vertex constant buffer
@@ -283,15 +332,30 @@ bool GpDisplayDriverD3D11::InitResources()
return false;
}
{
D3D11_BUFFER_DESC bufferDesc;
bufferDesc.ByteWidth = sizeof(ScaleQuadPixelConstants);
bufferDesc.Usage = D3D11_USAGE_DYNAMIC;
bufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
bufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
bufferDesc.MiscFlags = 0;
bufferDesc.StructureByteStride = 0;
if (m_device->CreateBuffer(&bufferDesc, nullptr, m_scaleQuadPixelConstantBuffer.GetMutablePtr()) != S_OK)
return false;
}
const GpShaderCodeBlob drawQuadVBlob = GetBinarizedShader(GpBinarizedShaders::g_drawQuadV_D3D11);
const GpShaderCodeBlob drawQuadPalettePBlob = GetBinarizedShader(GpBinarizedShaders::g_drawQuadPaletteP_D3D11);
const GpShaderCodeBlob drawQuadRGBPBlob = GetBinarizedShader(GpBinarizedShaders::g_drawQuadRGBP_D3D11);
const GpShaderCodeBlob drawQuad15BitPBlob = GetBinarizedShader(GpBinarizedShaders::g_drawQuad15BitP_D3D11);
const GpShaderCodeBlob scaleQuadPBlob = GetBinarizedShader(GpBinarizedShaders::g_scaleQuadP_D3D11);
m_device->CreateVertexShader(drawQuadVBlob.m_data, drawQuadVBlob.m_size, nullptr, m_drawQuadVertexShader.GetMutablePtr());
m_device->CreatePixelShader(drawQuadPalettePBlob.m_data, drawQuadPalettePBlob.m_size, nullptr, m_drawQuadPalettePixelShader.GetMutablePtr());
m_device->CreatePixelShader(drawQuadRGBPBlob.m_data, drawQuadRGBPBlob.m_size, nullptr, m_drawQuadRGBPixelShader.GetMutablePtr());
m_device->CreatePixelShader(drawQuad15BitPBlob.m_data, drawQuad15BitPBlob.m_size, nullptr, m_drawQuad15BitPixelShader.GetMutablePtr());
m_device->CreatePixelShader(scaleQuadPBlob.m_data, scaleQuadPBlob.m_size, nullptr, m_scaleQuadPixelShader.GetMutablePtr());
// Quad input layout
{
@@ -399,17 +463,18 @@ GpDisplayDriverTickStatus_t GpDisplayDriverD3D11::PresentFrameAndSync()
{
SynchronizeCursors();
m_deviceContext->ClearRenderTargetView(m_backBufferRTV, m_bgColor);
m_deviceContext->ClearRenderTargetView(m_virtualScreenTextureRTV, m_bgColor);
ID3D11RenderTargetView *const rtv = m_backBufferRTV;
m_deviceContext->OMSetRenderTargets(1, &rtv, nullptr);
//ID3D11RenderTargetView *const rtv = m_backBufferRTV;
ID3D11RenderTargetView *const vsRTV = m_virtualScreenTextureRTV;
m_deviceContext->OMSetRenderTargets(1, &vsRTV, nullptr);
{
D3D11_VIEWPORT viewport;
viewport.TopLeftX = 0;
viewport.TopLeftY = 0;
viewport.Width = static_cast<FLOAT>(m_windowWidth);
viewport.Height = static_cast<FLOAT>(m_windowHeight);
viewport.Width = static_cast<FLOAT>(m_windowWidthVirtual);
viewport.Height = static_cast<FLOAT>(m_windowHeightVirtual);
viewport.MinDepth = 0.0f;
viewport.MaxDepth = 1.0f;
@@ -418,6 +483,8 @@ GpDisplayDriverTickStatus_t GpDisplayDriverD3D11::PresentFrameAndSync()
m_properties.m_renderFunc(m_properties.m_renderFuncContext);
ScaleVirtualScreen();
DXGI_PRESENT_PARAMETERS presentParams;
ZeroMemory(&presentParams, sizeof(presentParams));
@@ -535,6 +602,105 @@ GpDisplayDriverTickStatus_t GpDisplayDriverD3D11::PresentFrameAndSync()
return GpDisplayDriverTickStatuses::kOK;
}
void GpDisplayDriverD3D11::ScaleVirtualScreen()
{
{
D3D11_VIEWPORT viewport;
viewport.TopLeftX = 0;
viewport.TopLeftY = 0;
viewport.Width = static_cast<FLOAT>(m_windowWidthPhysical);
viewport.Height = static_cast<FLOAT>(m_windowHeightPhysical);
viewport.MinDepth = 0.0f;
viewport.MaxDepth = 1.0f;
m_deviceContext->RSSetViewports(1, &viewport);
}
ID3D11Buffer *vbPtr = m_quadVertexBuffer;
UINT vbStride = sizeof(float) * 2;
UINT zero = 0;
ID3D11RenderTargetView *const rtv = m_backBufferRTV;
m_deviceContext->OMSetRenderTargets(1, &rtv, nullptr);
//m_deviceContext->OMSetDepthStencilState(m_drawQuadDepthStencilState, 0);
{
const float twoDivWidth = 2.0f / static_cast<float>(m_windowWidthPhysical);
const float negativeTwoDivHeight = -2.0f / static_cast<float>(m_windowHeightPhysical);
// Use the scaled virtual width instead of the physical width to correctly handle cases where the window boundary is in the middle of a pixel
float fWidth = static_cast<float>(m_windowWidthVirtual) * m_pixelScaleX;
float fHeight = static_cast<float>(m_windowHeightVirtual) * m_pixelScaleY;
DrawQuadVertexConstants vConstantsData;
vConstantsData.m_ndcOriginX = twoDivWidth - 1.0f;
vConstantsData.m_ndcOriginY = negativeTwoDivHeight + 1.0f;
vConstantsData.m_ndcWidth = fWidth * twoDivWidth;
vConstantsData.m_ndcHeight = fHeight * negativeTwoDivHeight;
vConstantsData.m_surfaceDimensionX = static_cast<float>(m_windowWidthVirtual);
vConstantsData.m_surfaceDimensionY = static_cast<float>(m_windowHeightVirtual);
D3D11_MAPPED_SUBRESOURCE mappedVConstants;
if (m_deviceContext->Map(m_drawQuadVertexConstantBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedVConstants) == S_OK)
{
memcpy(mappedVConstants.pData, &vConstantsData, sizeof(vConstantsData));
m_deviceContext->Unmap(m_drawQuadVertexConstantBuffer, 0);
}
ScaleQuadPixelConstants pConstantsData;
pConstantsData.m_dx = static_cast<float>(static_cast<double>(m_windowWidthVirtual) / static_cast<double>(m_windowWidthPhysical));
pConstantsData.m_dy = static_cast<float>(static_cast<double>(m_windowHeightVirtual) / static_cast<double>(m_windowHeightPhysical));
D3D11_MAPPED_SUBRESOURCE mappedPConstants;
if (m_deviceContext->Map(m_scaleQuadPixelConstantBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedPConstants) == S_OK)
{
memcpy(mappedPConstants.pData, &pConstantsData, sizeof(pConstantsData));
m_deviceContext->Unmap(m_scaleQuadPixelConstantBuffer, 0);
}
}
m_deviceContext->IASetVertexBuffers(0, 1, &vbPtr, &vbStride, &zero);
m_deviceContext->IASetIndexBuffer(m_quadIndexBuffer, DXGI_FORMAT_R16_UINT, 0);
m_deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
m_deviceContext->IASetInputLayout(m_drawQuadInputLayout);
ID3D11Buffer *vsConstants = m_drawQuadVertexConstantBuffer;
m_deviceContext->VSSetShader(m_drawQuadVertexShader, nullptr, 0);
m_deviceContext->VSSetConstantBuffers(0, 1, &vsConstants);
ID3D11SamplerState *samplerStates[] =
{
m_nearestNeighborSamplerState,
};
m_deviceContext->PSSetSamplers(0, sizeof(samplerStates) / sizeof(samplerStates[0]), samplerStates);
ID3D11ShaderResourceView *psResourceViews[] =
{
m_virtualScreenTextureSRV,
};
ID3D11Buffer *psConstants = m_scaleQuadPixelConstantBuffer;
m_deviceContext->PSSetShader(m_scaleQuadPixelShader, nullptr, 0);
m_deviceContext->PSSetShaderResources(0, sizeof(psResourceViews) / sizeof(psResourceViews[0]), psResourceViews);
m_deviceContext->PSSetConstantBuffers(0, 1, &psConstants);
m_deviceContext->DrawIndexed(6, 0, 0);
ID3D11ShaderResourceView *unbindPSResourceViews[] =
{
0,
};
m_deviceContext->PSSetShaderResources(0, sizeof(unbindPSResourceViews) / sizeof(unbindPSResourceViews[0]), unbindPSResourceViews);
ID3D11Buffer *clearBuffer = nullptr;
m_deviceContext->PSSetConstantBuffers(0, 1, &clearBuffer);
}
void GpDisplayDriverD3D11::SynchronizeCursors()
{
HCURSOR replacementCursor = nullptr;
@@ -587,7 +753,7 @@ void GpDisplayDriverD3D11::ChangeToCursor(HCURSOR cursor)
if (m_mouseIsInClientArea)
::SetCursor(cursor);
SetClassLongPtrW(m_hwnd, GCLP_HCURSOR, reinterpret_cast<LONG_PTR>(cursor));
SetClassLongPtrW(m_osGlobals->m_hwnd, GCLP_HCURSOR, reinterpret_cast<LONG_PTR>(cursor));
}
void GpDisplayDriverD3D11::ChangeToStandardCursor(EGpStandardCursor_t cursor)
@@ -607,6 +773,105 @@ void GpDisplayDriverD3D11::ChangeToStandardCursor(EGpStandardCursor_t cursor)
}
}
void GpDisplayDriverD3D11::BecomeFullScreen(LONG &windowStyle)
{
assert(!m_isFullScreen);
RECT windowRect;
if (!GetWindowRect(m_osGlobals->m_hwnd, &windowRect))
return; // ???
HMONITOR monitor = MonitorFromRect(&windowRect, MONITOR_DEFAULTTONULL);
if (!monitor)
{
// If the window is off-screen, use the primary monitor
monitor = MonitorFromRect(&windowRect, MONITOR_DEFAULTTOPRIMARY);
}
else
{
// Otherwise, use the nearest
monitor = MonitorFromRect(&windowRect, MONITOR_DEFAULTTONEAREST);
}
if (!monitor)
return; // No monitor?
MONITORINFO monitorInfo;
monitorInfo.cbSize = sizeof(monitorInfo);
if (!GetMonitorInfoA(monitor, &monitorInfo))
return;
m_windowModeRevertRect = windowRect;
SetWindowLongPtr(m_osGlobals->m_hwnd, GWL_STYLE, WS_VISIBLE | WS_POPUP);
SetWindowPos(m_osGlobals->m_hwnd, HWND_TOP, monitorInfo.rcMonitor.left, monitorInfo.rcMonitor.top, monitorInfo.rcMonitor.right - monitorInfo.rcMonitor.left, monitorInfo.rcMonitor.bottom - monitorInfo.rcMonitor.top, SWP_FRAMECHANGED);
m_isFullScreen = true;
windowStyle = (WS_VISIBLE | WS_POPUP);
}
void GpDisplayDriverD3D11::BecomeWindowed(LONG &windowStyle)
{
assert(m_isFullScreen);
RECT revertRect = m_windowModeRevertRect;
HMONITOR monitor = MonitorFromRect(&m_windowModeRevertRect, MONITOR_DEFAULTTONULL);
if (!monitor)
{
// If the window is off-screen, use the primary monitor
monitor = MonitorFromRect(&revertRect, MONITOR_DEFAULTTOPRIMARY);
if (!monitor)
return;
MONITORINFO monitorInfo;
monitorInfo.cbSize = sizeof(monitorInfo);
if (!GetMonitorInfoA(monitor, &monitorInfo))
return;
RECT monitorRect = monitorInfo.rcWork;
LONG monitorWidth = monitorRect.right - monitorRect.left;
LONG monitorHeight = monitorRect.bottom - monitorRect.top;
LONG revertHeight = revertRect.bottom - revertRect.top;
LONG revertWidth = revertRect.right - revertRect.left;
if (revertWidth > monitorWidth)
revertWidth = monitorWidth;
if (revertHeight > monitorHeight)
revertHeight = monitorHeight;
revertRect.bottom = revertRect.top + revertHeight;
revertRect.right = revertRect.right + revertWidth;
LONG xDelta = 0;
if (revertRect.right > monitorRect.right)
xDelta = monitorRect.right - revertRect.right;
else if (revertRect.left < monitorRect.left)
xDelta = monitorRect.left - revertRect.left;
LONG yDelta = 0;
if (revertRect.bottom > monitorRect.bottom)
yDelta = monitorRect.bottom - revertRect.bottom;
else if (revertRect.top < monitorRect.top)
yDelta = monitorRect.top - revertRect.top;
revertRect.left = revertRect.left + xDelta;
revertRect.top = revertRect.top + yDelta;
revertRect.bottom = revertRect.top + revertHeight;
revertRect.right = revertRect.right + revertWidth;
}
SetWindowLongPtr(m_osGlobals->m_hwnd, GWL_STYLE, WS_VISIBLE | WS_OVERLAPPEDWINDOW);
SetWindowPos(m_osGlobals->m_hwnd, HWND_TOP, revertRect.left, revertRect.top, revertRect.right - revertRect.left, revertRect.bottom - revertRect.top, SWP_FRAMECHANGED);
m_isFullScreen = false;
windowStyle = (WS_VISIBLE | WS_OVERLAPPEDWINDOW);
}
void GpDisplayDriverD3D11::Run()
{
WNDCLASSEX wc;
@@ -633,16 +898,16 @@ void GpDisplayDriverD3D11::Run()
HMENU menus = NULL;
// TODO: Fix the resolution here
RECT wr = { 0, 0, m_windowWidth, m_windowHeight };
RECT wr = { 0, 0, m_windowWidthPhysical, m_windowHeightPhysical };
AdjustWindowRect(&wr, windowStyle, menus != NULL);
m_hwnd = CreateWindowExW(NULL, L"GPD3D11WindowClass", GP_APPLICATION_NAME_W L" (Direct3D 11)", WS_OVERLAPPEDWINDOW, 300, 300, wr.right - wr.left, wr.bottom - wr.top, NULL, menus, m_osGlobals->m_hInstance, NULL);
m_osGlobals->m_hwnd = CreateWindowExW(NULL, L"GPD3D11WindowClass", GP_APPLICATION_NAME_W L" (Direct3D 11)", WS_OVERLAPPEDWINDOW, 300, 300, wr.right - wr.left, wr.bottom - wr.top, NULL, menus, m_osGlobals->m_hInstance, NULL);
ShowWindow(m_hwnd, m_osGlobals->m_nCmdShow);
ShowWindow(m_osGlobals->m_hwnd, m_osGlobals->m_nCmdShow);
StartD3DForWindow(m_hwnd, m_swapChain, m_device, m_deviceContext);
StartD3DForWindow(m_osGlobals->m_hwnd, m_swapChain, m_device, m_deviceContext);
InitResources();
InitResources(m_windowWidthVirtual, m_windowHeightVirtual);
LARGE_INTEGER lastTimestamp;
memset(&lastTimestamp, 0, sizeof(lastTimestamp));
@@ -654,9 +919,6 @@ void GpDisplayDriverD3D11::Run()
{
DispatchMessage(&msg);
if (msg.message == WM_QUIT)
break;
else
{
if (msg.message == WM_MOUSEMOVE)
{
@@ -669,7 +931,7 @@ void GpDisplayDriverD3D11::Run()
tme.cbSize = sizeof(tme);
tme.dwFlags = TME_LEAVE;
tme.hwndTrack = m_hwnd;
tme.hwndTrack = m_osGlobals->m_hwnd;
tme.dwHoverTime = HOVER_DEFAULT;
TrackMouseEvent(&tme);
}
@@ -677,38 +939,56 @@ void GpDisplayDriverD3D11::Run()
else if (msg.message == WM_MOUSELEAVE)
m_mouseIsInClientArea = false;
m_osGlobals->m_translateWindowsMessageFunc(&msg, m_properties.m_eventQueue);
m_osGlobals->m_translateWindowsMessageFunc(&msg, m_properties.m_eventQueue, m_pixelScaleX, m_pixelScaleY);
}
}
else
{
if (m_isFullScreen != m_isFullScreenDesired)
{
if (m_isFullScreenDesired)
BecomeFullScreen(windowStyle);
else
BecomeWindowed(windowStyle);
}
RECT clientRect;
GetClientRect(m_hwnd, &clientRect);
GetClientRect(m_osGlobals->m_hwnd, &clientRect);
unsigned int desiredWidth = clientRect.right - clientRect.left;
unsigned int desiredHeight = clientRect.bottom - clientRect.top;
if (clientRect.right - clientRect.left != m_windowWidth || clientRect.bottom - clientRect.top != m_windowHeight)
if (clientRect.right - clientRect.left != m_windowWidthPhysical || clientRect.bottom - clientRect.top != m_windowHeightPhysical)
{
uint32_t prevWidth = m_windowWidth;
uint32_t prevHeight = m_windowHeight;
uint32_t prevWidth = m_windowWidthPhysical;
uint32_t prevHeight = m_windowHeightPhysical;
uint32_t virtualWidth = m_windowWidthVirtual;
uint32_t virtualHeight = m_windowHeightVirtual;
float pixelScaleX = 1.0f;
float pixelScaleY = 1.0f;
m_properties.m_adjustRequestedResolutionFunc(m_properties.m_adjustRequestedResolutionFuncContext, desiredWidth, desiredHeight);
bool resizedOK = ResizeD3DWindow(m_hwnd, m_windowWidth, m_windowHeight, desiredWidth, desiredHeight, windowStyle, menus);
resizedOK = resizedOK && DetachSwapChain();
resizedOK = resizedOK && ResizeSwapChain(m_swapChain, m_windowWidth, m_windowHeight);
resizedOK = resizedOK && InitBackBuffer();
if (!resizedOK)
break; // Critical video driver error, exit
if (GpVOSEvent *resizeEvent = m_properties.m_eventQueue->QueueEvent())
if (m_properties.m_adjustRequestedResolutionFunc(m_properties.m_adjustRequestedResolutionFuncContext, desiredWidth, desiredHeight, virtualWidth, virtualHeight, pixelScaleX, pixelScaleY))
{
resizeEvent->m_eventType = GpVOSEventTypes::kVideoResolutionChanged;
resizeEvent->m_event.m_resolutionChangedEvent.m_prevWidth = prevWidth;
resizeEvent->m_event.m_resolutionChangedEvent.m_prevHeight = prevHeight;
resizeEvent->m_event.m_resolutionChangedEvent.m_newWidth = m_windowWidth;
resizeEvent->m_event.m_resolutionChangedEvent.m_newHeight = m_windowHeight;
bool resizedOK = ResizeD3DWindow(m_osGlobals->m_hwnd, m_windowWidthPhysical, m_windowHeightPhysical, desiredWidth, desiredHeight, windowStyle, menus);
resizedOK = resizedOK && DetachSwapChain();
resizedOK = resizedOK && ResizeSwapChain(m_swapChain, m_windowWidthPhysical, m_windowHeightPhysical);
resizedOK = resizedOK && InitBackBuffer(virtualWidth, virtualHeight);
if (!resizedOK)
break; // Critical video driver error, exit
m_windowWidthVirtual = virtualWidth;
m_windowHeightVirtual = virtualHeight;
m_pixelScaleX = pixelScaleX;
m_pixelScaleY = pixelScaleY;
if (GpVOSEvent *resizeEvent = m_properties.m_eventQueue->QueueEvent())
{
resizeEvent->m_eventType = GpVOSEventTypes::kVideoResolutionChanged;
resizeEvent->m_event.m_resolutionChangedEvent.m_prevWidth = prevWidth;
resizeEvent->m_event.m_resolutionChangedEvent.m_prevHeight = prevHeight;
resizeEvent->m_event.m_resolutionChangedEvent.m_newWidth = m_windowWidthVirtual;
resizeEvent->m_event.m_resolutionChangedEvent.m_newHeight = m_windowHeightVirtual;
}
}
}
@@ -731,9 +1011,9 @@ void GpDisplayDriverD3D11::Shutdown()
void GpDisplayDriverD3D11::GetDisplayResolution(unsigned int *width, unsigned int *height, GpPixelFormat_t *pixelFormat)
{
if (width)
*width = m_windowWidth;
*width = m_windowWidthVirtual;
if (height)
*height = m_windowHeight;
*height = m_windowHeightVirtual;
if (pixelFormat)
*pixelFormat = GpPixelFormats::k8BitStandard;
}
@@ -754,8 +1034,8 @@ void GpDisplayDriverD3D11::DrawSurface(IGpDisplayDriverSurface *surface, int32_t
//m_deviceContext->OMSetDepthStencilState(m_drawQuadDepthStencilState, 0);
{
const float twoDivWidth = 2.0f / static_cast<float>(m_windowWidth);
const float negativeTwoDivHeight = -2.0f / static_cast<float>(m_windowHeight);
const float twoDivWidth = 2.0f / static_cast<float>(m_windowWidthVirtual);
const float negativeTwoDivHeight = -2.0f / static_cast<float>(m_windowHeightVirtual);
DrawQuadVertexConstants constantsData;
constantsData.m_ndcOriginX = static_cast<float>(x) * twoDivWidth - 1.0f;
@@ -900,6 +1180,16 @@ void GpDisplayDriverD3D11::SetBackgroundColor(uint8_t r, uint8_t g, uint8_t b, u
m_bgColor[3] = static_cast<float>(a) / 255.0f;
}
void GpDisplayDriverD3D11::RequestToggleFullScreen(uint32_t timestamp)
{
// Alt-Enter gets re-sent after a full-screen toggle, so we ignore toggle requests until half a second has seconds have elapsed
if (timestamp > m_lastFullScreenToggleTimeStamp + 30)
{
m_isFullScreenDesired = !m_isFullScreenDesired;
m_lastFullScreenToggleTimeStamp = timestamp;
}
}
GpDisplayDriverD3D11 *GpDisplayDriverD3D11::Create(const GpDisplayDriverProperties &properties)
{
void *storage = malloc(sizeof(GpDisplayDriverD3D11));
@@ -912,8 +1202,12 @@ GpDisplayDriverD3D11 *GpDisplayDriverD3D11::Create(const GpDisplayDriverProperti
GpDisplayDriverD3D11::GpDisplayDriverD3D11(const GpDisplayDriverProperties &properties)
: m_properties(properties)
, m_frameTimeAccumulated(0)
, m_windowWidth(640)
, m_windowHeight(480)
, m_windowWidthPhysical(640)
, m_windowHeightPhysical(480)
, m_windowWidthVirtual(640)
, m_windowHeightVirtual(480)
, m_pixelScaleX(1.0f)
, m_pixelScaleY(1.0f)
, m_vosFiber(nullptr)
, m_osGlobals(static_cast<GpWindowsGlobals*>(properties.m_osGlobals))
, m_pendingCursor(nullptr)
@@ -921,8 +1215,12 @@ GpDisplayDriverD3D11::GpDisplayDriverD3D11(const GpDisplayDriverProperties &prop
, m_currentStandardCursor(EGpStandardCursors::kArrow)
, m_pendingStandardCursor(EGpStandardCursors::kArrow)
, m_mouseIsInClientArea(false)
, m_isFullScreen(false)
, m_isFullScreenDesired(false)
, m_lastFullScreenToggleTimeStamp(0)
{
memset(&m_syncTimeBase, 0, sizeof(m_syncTimeBase));
memset(&m_windowModeRevertRect, 0, sizeof(m_windowModeRevertRect));
QueryPerformanceFrequency(&m_QPFrequency);

View File

@@ -48,6 +48,8 @@ public:
void SetBackgroundColor(uint8_t r, uint8_t g, uint8_t b, uint8_t a) override;
void RequestToggleFullScreen(uint32_t timestamp) override;
static GpDisplayDriverD3D11 *Create(const GpDisplayDriverProperties &properties);
private:
@@ -63,6 +65,13 @@ private:
float m_unused[2];
};
struct ScaleQuadPixelConstants
{
float m_dx;
float m_dy;
float m_unused[2];
};
struct CompactedPresentHistoryItem
{
LARGE_INTEGER m_timestamp;
@@ -73,14 +82,18 @@ private:
~GpDisplayDriverD3D11();
bool DetachSwapChain();
bool InitBackBuffer();
bool InitResources();
bool InitBackBuffer(uint32_t virtualWidth, uint32_t virtualHeight);
bool InitResources(uint32_t virtualWidth, uint32_t virtualHeight);
GpDisplayDriverTickStatus_t PresentFrameAndSync();
void ScaleVirtualScreen();
void SynchronizeCursors();
void ChangeToCursor(HCURSOR cursor);
void ChangeToStandardCursor(EGpStandardCursor_t cursor);
void BecomeFullScreen(LONG &windowStyle);
void BecomeWindowed(LONG &windowStyle);
GpComPtr<IDXGISwapChain1> m_swapChain;
GpComPtr<ID3D11Device> m_device;
GpComPtr<ID3D11DeviceContext> m_deviceContext;
@@ -91,7 +104,9 @@ private:
GpComPtr<ID3D11PixelShader> m_drawQuadPalettePixelShader;
GpComPtr<ID3D11PixelShader> m_drawQuad15BitPixelShader;
GpComPtr<ID3D11PixelShader> m_drawQuadRGBPixelShader;
GpComPtr<ID3D11PixelShader> m_scaleQuadPixelShader;
GpComPtr<ID3D11Buffer> m_drawQuadVertexConstantBuffer;
GpComPtr<ID3D11Buffer> m_scaleQuadPixelConstantBuffer;
GpComPtr<ID3D11DepthStencilState> m_drawQuadDepthStencilState;
GpComPtr<ID3D11SamplerState> m_nearestNeighborSamplerState;
GpComPtr<ID3D11Texture1D> m_paletteTexture;
@@ -100,6 +115,10 @@ private:
GpComPtr<ID3D11Texture2D> m_backBufferTexture;
GpComPtr<ID3D11RenderTargetView> m_backBufferRTV;
GpComPtr<ID3D11Texture2D> m_virtualScreenTexture;
GpComPtr<ID3D11RenderTargetView> m_virtualScreenTextureRTV;
GpComPtr<ID3D11ShaderResourceView> m_virtualScreenTextureSRV;
GpRingBuffer<CompactedPresentHistoryItem, 60> m_presentHistory;
GpDisplayDriverProperties m_properties;
@@ -108,11 +127,20 @@ private:
UINT m_expectedSyncDelta;
bool m_isResettingSwapChain;
bool m_isFullScreen;
bool m_isFullScreenDesired;
RECT m_windowModeRevertRect;
uint32_t m_lastFullScreenToggleTimeStamp;
LONGLONG m_frameTimeAccumulated;
LONGLONG m_frameTimeSliceSize;
DWORD m_windowWidth;
DWORD m_windowHeight;
DWORD m_windowWidthPhysical; // Physical resolution is the resolution of the actual window
DWORD m_windowHeightPhysical;
DWORD m_windowWidthVirtual; // Virtual resolution is the resolution reported to teh game
DWORD m_windowHeightVirtual;
float m_pixelScaleX;
float m_pixelScaleY;
IGpCursor_Win32 *m_activeCursor;
IGpCursor_Win32 *m_pendingCursor;
@@ -126,7 +154,6 @@ private:
HCURSOR m_arrowCursor;
HCURSOR m_waitCursor;
HCURSOR m_ibeamCursor;
HWND m_hwnd;
float m_bgColor[4];
};

View File

@@ -127,6 +127,7 @@
<ClCompile Include="CompiledShaders\DrawQuadPaletteP_D3D11.cpp" />
<ClCompile Include="CompiledShaders\DrawQuadRGBP_D3D11.cpp" />
<ClCompile Include="CompiledShaders\DrawQuadV_D3D11.cpp" />
<ClCompile Include="CompiledShaders\ScaleQuadP_D3D11.cpp" />
<ClCompile Include="GpDisplayDriverD3D11.cpp" />
<ClCompile Include="GpDisplayDriverFactoryD3D11.cpp" />
<ClCompile Include="GpDisplayDriverSurfaceD3D11.cpp" />

View File

@@ -39,6 +39,9 @@
<ClCompile Include="CompiledShaders\DrawQuadV_D3D11.cpp">
<Filter>Source Files\CompiledShaders</Filter>
</ClCompile>
<ClCompile Include="CompiledShaders\ScaleQuadP_D3D11.cpp">
<Filter>Source Files\CompiledShaders</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="GpDisplayDriverD3D11.h">

View File

@@ -1,19 +0,0 @@
GlidePort copyright (c)2019 Eric Lasota
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -1,17 +1,339 @@
Aerofoil is (c)2019-2020 Eric Lasota
Based on Glider PRO by John Calhoun
Aerofoil is made available under the following dual-license terms:
- You may use any portion of the Aerofoil project's source code under the
conditions of the GNU General Public License version 2, as published in the
included LICENSE-GPL2.txt file.
- If you obtain a license to use the Glider PRO source code under terms other
than the terms of the GNU General Public License version 2, or if you do not
require a license (i.e. because you hold the copyright), or if you are are
permitted to use Glider PRO's source code under different terms for any
other reason, you may use any new source code and modifications in the
Aerofoil source code under the conditions of the MIT license, as published
in the included LICENSE-MIT.txt file.
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.

View File

@@ -49,7 +49,7 @@ static const uint16_t mac_roman_2uni[128] = {
};
namespace MacRoman
{
{
uint16_t ToUnicode(uint8_t character)
{
if (character < 0x80)
@@ -57,7 +57,7 @@ namespace MacRoman
else
return mac_roman_2uni[character - 0x80];
}
bool FromUnicode(uint8_t &outChar, uint16_t codePoint)
{
if (codePoint < 0x80)

View File

@@ -1,6 +1,7 @@
mkdir ReleasePkg\Aerofoil
mkdir ReleasePkg\Aerofoil\Packaged
mkdir ReleasePkg\Aerofoil\Resources
mkdir ReleasePkg\Aerofoil\Tools
copy /Y x64\Release\Aerofoil.exe ReleasePkg\Aerofoil
copy /Y x64\Release\GpAudioDriver_XAudio2.dll ReleasePkg\Aerofoil
@@ -9,6 +10,14 @@ copy /Y x64\Release\GpInputDriver_XInput.dll ReleasePkg\Aerofoil
copy /Y x64\Release\FreeType.dll ReleasePkg\Aerofoil
copy /Y x64\Release\GpApp.dll ReleasePkg\Aerofoil
copy /Y x64\Release\flattenmov.exe ReleasePkg\Aerofoil\Tools
copy /Y x64\Release\bin2gp.exe ReleasePkg\Aerofoil\Tools
copy /Y x64\Release\hqx2bin.exe ReleasePkg\Aerofoil\Tools
copy /Y x64\Release\hqx2gp.exe ReleasePkg\Aerofoil\Tools
copy /Y x64\Release\MakeTimestamp.exe ReleasePkg\Aerofoil\Tools
copy /Y x64\Release\FTagData.exe ReleasePkg\Aerofoil\Tools
copy /Y x64\Release\gpr2gpa.exe ReleasePkg\Aerofoil\Tools
copy /Y x64\Release\unpacktool.exe ReleasePkg\Aerofoil\Tools
xcopy /I /E /Y /K Packaged ReleasePkg\Aerofoil\Packaged
xcopy /I /E /Y /K Resources ReleasePkg\Aerofoil\Resources

View File

@@ -0,0 +1,16 @@
#include "AppEventHandler.h"
namespace PortabilityLayer
{
IAppEventHandler *AppEventHandler::ms_instance;
IAppEventHandler *AppEventHandler::GetInstance()
{
return ms_instance;
}
void AppEventHandler::SetInstance(IAppEventHandler *instance)
{
ms_instance = instance;
}
}

View File

@@ -0,0 +1,19 @@
#pragma once
namespace PortabilityLayer
{
struct IAppEventHandler
{
virtual void OnQuit() = 0;
};
class AppEventHandler
{
public:
static IAppEventHandler *GetInstance();
static void SetInstance(IAppEventHandler *instance);
private:
static IAppEventHandler *ms_instance;
};
}

View File

@@ -15,7 +15,7 @@ namespace PortabilityLayer
struct IResolutionChangeHandler
{
virtual void OnResolutionChanged(uint32_t prevWidth, uint32_t prevHeight, uint32_t newWidth, uint32_t newHeight) = 0;
virtual void AdjustRequestedResolution(uint32_t &width, uint32_t &height) = 0;
virtual void AdjustRequestedResolution(uint32_t &physicalWidth, uint32_t &physicalHeight, uint32_t &virtualWidth, uint32_t &virtualheight, float &pixelScaleX, float &pixelScaleY) = 0;
};
virtual void Init() = 0;

View File

@@ -6,6 +6,7 @@
#include "MacFileMem.h"
#include "PLPasStr.h"
#include "PLErrorCodes.h"
#include "PLSysCalls.h"
#include "ResTypeID.h"
#include "HostSystemServices.h"
@@ -184,7 +185,7 @@ namespace PortabilityLayer
bool FileManagerImpl::PromptOpenFile(VirtualDirectory_t dirID, char *path, size_t &outPathLength, size_t pathCapacity)
{
return PortabilityLayer::HostFileSystem::GetInstance()->PromptOpenFile(dirID, path, outPathLength, pathCapacity);
return PLSysCalls::PromptOpenFile(dirID, path, outPathLength, pathCapacity);
}
FileManagerImpl *FileManagerImpl::GetInstance()

View File

@@ -46,7 +46,7 @@ public:
virtual void PL_HostVOSEventQueue_SetInstance(PortabilityLayer::HostVOSEventQueue *instance) = 0;
virtual void PL_InstallHostSuspendHook(PortabilityLayer::HostSuspendHook_t hook, void *context) = 0;
virtual void PL_AdjustRequestedResolution(unsigned int &width, unsigned int &height) = 0;
virtual bool PL_AdjustRequestedResolution(uint32_t &physicalWidth, uint32_t &physicalHeight, uint32_t &virtualWidth, uint32_t &virtualheight, float &pixelScaleX, float &pixelScaleY) = 0;
};
GP_APP_DLL_EXPORT_API GpAppInterface *GpAppInterface_Get();

View File

@@ -12,6 +12,7 @@ namespace PortabilityLayer
int32_t m_int;
size_t m_size;
void *m_pointer;
const void *m_constPointer;
const void *m_constPointer;
void (*m_functionPtr)(const HostSuspendCallArgument *args, HostSuspendCallArgument *returnValue);
};
}

View File

@@ -9,6 +9,7 @@ namespace PortabilityLayer
HostSuspendCallID_Unknown,
HostSuspendCallID_Delay,
HostSuspendCallID_CallOnVOSThread,
};
}

View File

@@ -110,20 +110,57 @@ short FindWindow(Point point, WindowPtr *window)
bool TrackGoAway(WindowPtr window, Point point)
{
PL_NotYetImplemented();
return false;
PortabilityLayer::WindowManager *wm = PortabilityLayer::WindowManager::GetInstance();
return wm->HandleCloseBoxClick(window, point);
}
Int32 GrowWindow(WindowPtr window, Point start, Rect *size)
PortabilityLayer::Vec2i TrackResize(WindowPtr window, Point start, uint16_t minWidth, uint16_t minHeight, Rect *size)
{
PL_NotYetImplemented();
return 0;
}
PortabilityLayer::WindowManager *wm = PortabilityLayer::WindowManager::GetInstance();
bool TrackBox(WindowPtr window, Point point, int part)
{
PL_NotYetImplemented();
return false;
const Rect baseRect = window->m_surface.m_port.GetRect();
const PortabilityLayer::Vec2i baseSize = PortabilityLayer::Vec2i(baseRect.Width(), baseRect.Height());
const PortabilityLayer::Vec2i basePoint = PortabilityLayer::Vec2i(start.h, start.v);
PortabilityLayer::Vec2i currentTarget = baseSize;
wm->SetResizeInProgress(window, baseSize);
for (;;)
{
TimeTaggedVOSEvent evt;
if (WaitForEvent(&evt, 1))
{
if (evt.m_vosEvent.m_eventType == GpVOSEventTypes::kMouseInput)
{
const GpMouseInputEvent &mouseEvt = evt.m_vosEvent.m_event.m_mouseInputEvent;
const PortabilityLayer::Vec2i nextPoint = PortabilityLayer::Vec2i(mouseEvt.m_x, mouseEvt.m_y);
PortabilityLayer::Vec2i requestedSize = baseSize + nextPoint - basePoint;
if (requestedSize.m_x < static_cast<int32_t>(minWidth))
requestedSize.m_x = minWidth;
if (requestedSize.m_y < static_cast<int32_t>(minHeight))
requestedSize.m_y = minHeight;
if (requestedSize != currentTarget)
{
currentTarget = requestedSize;
wm->SetResizeInProgress(window, currentTarget);
}
if (mouseEvt.m_button == GpMouseButtons::kLeft && mouseEvt.m_eventType == GpMouseEventTypes::kUp)
{
wm->ClearResizeInProgress();
return requestedSize;
}
}
}
}
return PortabilityLayer::Vec2i(0, 0);
}
WindowPtr GetNewCWindow(int resID, void *storage, WindowPtr behind)

View File

@@ -26,6 +26,7 @@ namespace PortabilityLayer
struct MMHandleBlock;
class IOStream;
class Widget;
struct Vec2i;
}
typedef uint8_t Boolean;
@@ -208,7 +209,7 @@ namespace RegionIDs
kContent,
kTitleBar,
kClose,
kExpand,
kResize,
};
}
@@ -235,8 +236,7 @@ void Delay(int ticks, UInt32 *endTickCount);
short FindWindow(Point point, WindowPtr *window); // Translates global coordinates to window coordinates, returns a region ID
bool TrackGoAway(WindowPtr window, Point point); // Returns true if the close box was actually clicked (?)
Int32 GrowWindow(WindowPtr window, Point start, Rect *size);
bool TrackBox(WindowPtr window, Point point, int part); // Returns true if grow/shrink box was clicked (part corresponds to type)
PortabilityLayer::Vec2i TrackResize(WindowPtr window, Point start, uint16_t minWidth, uint16_t minHeight, Rect *size);
WindowPtr GetNewCWindow(int resID, void *storage, WindowPtr behind);
void SizeWindow(WindowPtr window, int width, int height, Boolean addToUpdateRegion);

View File

@@ -54,18 +54,6 @@ void EndUpdate(WindowPtr graf)
graf->m_surface.m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);
}
PLError_t GetIconSuite(Handle *suite, short resID, IconSuiteFlags flags)
{
PL_NotYetImplemented();
return PLErrors::kNone;
}
PLError_t PlotIconSuite(Rect *rect, Handle iconSuite)
{
PL_NotYetImplemented();
return PLErrors::kNone;
}
void SetRect(Rect *rect, short left, short top, short right, short bottom)
{
rect->left = left;
@@ -218,71 +206,6 @@ static void PlotLine(PortabilityLayer::QDState *qdState, DrawSurface *surface, c
surface->m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);
}
namespace
{
static bool SystemColorToRGBAColor(SystemColorID color, PortabilityLayer::RGBAColor &rgbaColor)
{
switch (color)
{
default:
return false;
case whiteColor:
rgbaColor.r = rgbaColor.g = rgbaColor.b = 255;
break;
case blackColor:
rgbaColor.r = rgbaColor.g = rgbaColor.b = 0;
break;
case yellowColor:
rgbaColor.r = rgbaColor.g = 255;
rgbaColor.b = 0;
break;
case magentaColor:
rgbaColor.r = rgbaColor.b = 255;
rgbaColor.g = 0;
break;
case redColor:
rgbaColor.r = 255;
rgbaColor.g = rgbaColor.b = 0;
break;
case cyanColor:
rgbaColor.g = rgbaColor.b = 255;
rgbaColor.r = 0;
break;
case greenColor:
rgbaColor.g = 255;
rgbaColor.r = rgbaColor.b = 0;
break;
case blueColor:
rgbaColor.b = 255;
rgbaColor.r = rgbaColor.g = 0;
break;
}
rgbaColor.a = 255;
return true;
}
}
void ForeColor(SystemColorID color)
{
PortabilityLayer::RGBAColor rgbaColor;
if (SystemColorToRGBAColor(color, rgbaColor))
{
PortabilityLayer::QDState *qdState = PortabilityLayer::QDManager::GetInstance()->GetState();
qdState->SetForeColor(rgbaColor);
}
}
void BackColor(SystemColorID color)
{
PortabilityLayer::RGBAColor rgbaColor;
if (SystemColorToRGBAColor(color, rgbaColor))
{
PortabilityLayer::QDState *qdState = PortabilityLayer::QDManager::GetInstance()->GetState();
qdState->SetBackColor(rgbaColor);
}
}
void GetForeColor(RGBColor *color)
{
const PortabilityLayer::RGBAColor foreColor = PortabilityLayer::QDManager::GetInstance()->GetState()->GetForeColor();

View File

@@ -11,35 +11,6 @@ namespace PortabilityLayer
struct Dialog;
enum IconSuiteFlags
{
svAllLargeData = 1,
};
enum TextFlags
{
bold = 1,
};
enum SystemFontID
{
systemFont = 0, // System font
applFont = 1, // Application font
};
enum SystemColorID
{
whiteColor = 1,
blackColor,
yellowColor,
magentaColor,
redColor,
cyanColor,
greenColor,
blueColor,
};
enum CopyBitsMode
{
srcCopy,
@@ -99,14 +70,9 @@ void SetPortDialogPort(Dialog *dialog);
void EndUpdate(WindowPtr graf);
PLError_t GetIconSuite(Handle *suite, short resID, IconSuiteFlags flags);
PLError_t PlotIconSuite(Rect *rect, Handle iconSuite);
void SetRect(Rect *rect, short left, short top, short right, short bottom);
int TextWidth(const PLPasStr &str, int firstChar1Based, int length);
void ForeColor(SystemColorID color);
void BackColor(SystemColorID color);
void GetForeColor(RGBColor *color);
void ClipRect(const Rect *rect);

View File

@@ -213,6 +213,30 @@ namespace PortabilityLayer
DrawControl(m_window->GetDrawSurface());
}
void ScrollBarWidget::SetMin(int32_t v)
{
m_min = v;
if (m_state < m_min)
SetState(m_min);
else
{
RefreshGrip();
DrawControl(m_window->GetDrawSurface());
}
}
void ScrollBarWidget::SetMax(int32_t v)
{
m_max = v;
if (m_state > m_max)
SetState(m_max);
else
{
RefreshGrip();
DrawControl(m_window->GetDrawSurface());
}
}
int16_t ScrollBarWidget::Capture(const Point &pos, WidgetUpdateCallback_t callback)
{
int part = ResolvePart(pos);

View File

@@ -21,6 +21,9 @@ namespace PortabilityLayer
void SetState(int16_t state) override;
void OnStateChanged() override;
void SetMin(int32_t v) override;
void SetMax(int32_t v) override;
int16_t Capture(const Point &pos, WidgetUpdateCallback_t callback) override;
int ResolvePart(const Point &point) const override;

View File

@@ -1,4 +1,5 @@
#include "PLCore.h"
#include "AppEventHandler.h"
#include "PLEventQueue.h"
#include "PLKeyEncoding.h"
#include "PLMovies.h"
@@ -6,7 +7,10 @@
#include "PLTimeTaggedVOSEvent.h"
#include "DisplayDeviceManager.h"
#include "GpVOSEvent.h"
#include "IGpDisplayDriver.h"
#include "InputManager.h"
#include "HostDisplayDriver.h"
#include "HostFileSystem.h"
#include "HostSuspendCallArgument.h"
#include "HostSuspendHook.h"
#include "HostVOSEventQueue.h"
@@ -66,6 +70,20 @@ static void TranslateKeyboardInputEvent(const GpVOSEvent &vosEventBase, uint32_t
if (vosEvent.m_eventType == GpKeyboardInputEventTypes::kUp || vosEvent.m_eventType == GpKeyboardInputEventTypes::kDown)
inputManager->ApplyKeyboardEvent(vosEvent);
// Special handling of alt-enter, redirect to display driver
if (vosEventBase.m_eventType == GpKeyboardInputEventTypes::kDown &&
vosEventBase.m_event.m_keyboardInputEvent.m_keyIDSubset == GpKeyIDSubsets::kSpecial &&
vosEventBase.m_event.m_keyboardInputEvent.m_key.m_specialKey == GpKeySpecials::kEnter)
{
const KeyDownStates *keyStates = inputManager->GetKeys();
if (keyStates->m_special.Get(GpKeySpecials::kLeftAlt) || keyStates->m_special.Get(GpKeySpecials::kRightAlt))
{
IGpDisplayDriver *dd = PortabilityLayer::HostDisplayDriver::GetInstance();
if (dd)
dd->RequestToggleFullScreen(timestamp);
}
}
if (TimeTaggedVOSEvent *evt = queue->Enqueue())
*evt = TimeTaggedVOSEvent::Create(vosEventBase, timestamp);
}
@@ -118,6 +136,14 @@ static void TranslateVOSEvent(const GpVOSEvent *vosEvent, uint32_t timestamp, Po
case GpVOSEventTypes::kVideoResolutionChanged:
TranslateVideoResolutionChangedEvent(vosEvent->m_event.m_resolutionChangedEvent);
break;
case GpVOSEventTypes::kQuit:
if (TimeTaggedVOSEvent *evt = queue->Enqueue())
*evt = TimeTaggedVOSEvent::Create(*vosEvent, timestamp);
if (PortabilityLayer::IAppEventHandler *appHandler = PortabilityLayer::AppEventHandler::GetInstance())
appHandler->OnQuit();
break;
}
}
@@ -149,4 +175,63 @@ namespace PLSysCalls
AnimationManager::GetInstance()->TickPlayers(ticks);
}
}
static void PromptOpenFileCallback(const PortabilityLayer::HostSuspendCallArgument *args, PortabilityLayer::HostSuspendCallArgument *returnValue)
{
bool result = PortabilityLayer::HostFileSystem::GetInstance()->PromptOpenFile(static_cast<PortabilityLayer::VirtualDirectory_t>(args[0].m_int), static_cast<char*>(args[1].m_pointer), *static_cast<size_t*>(args[2].m_pointer), args[3].m_uint);
returnValue->m_uint = (result ? 1 : 0);
}
bool PromptOpenFile(PortabilityLayer::VirtualDirectory_t dirID, char *path, size_t &outPathLength, size_t pathCapacity)
{
PortabilityLayer::HostSuspendCallArgument cbArgs[4];
cbArgs[0].m_int = static_cast<int32_t>(dirID);
cbArgs[1].m_pointer = path;
cbArgs[2].m_pointer = &outPathLength;
cbArgs[3].m_size = pathCapacity;
PortabilityLayer::HostSuspendCallArgument cbReturnValue;
PortabilityLayer::HostSuspendCallArgument dispatchArgs[3];
dispatchArgs[0].m_functionPtr = PromptOpenFileCallback;
dispatchArgs[1].m_constPointer = cbArgs;
dispatchArgs[2].m_pointer = &cbReturnValue;
PortabilityLayer::SuspendApplication(PortabilityLayer::HostSuspendCallID_CallOnVOSThread, dispatchArgs, nullptr);
return cbReturnValue.m_uint != 0;
}
static void PromptSaveFileCallback(const PortabilityLayer::HostSuspendCallArgument *args, PortabilityLayer::HostSuspendCallArgument *returnValue)
{
bool result = PortabilityLayer::HostFileSystem::GetInstance()->PromptSaveFile(
static_cast<PortabilityLayer::VirtualDirectory_t>(args[0].m_int),
static_cast<char*>(args[1].m_pointer),
*static_cast<size_t*>(args[2].m_pointer),
args[3].m_uint,
static_cast<const char*>(args[4].m_constPointer));
returnValue->m_uint = (result ? 1 : 0);
}
bool PromptSaveFile(PortabilityLayer::VirtualDirectory_t virtualDirectory, char *path, size_t &outPathLength, size_t pathCapacity, const char *initialFileName)
{
PortabilityLayer::HostSuspendCallArgument cbArgs[5];
cbArgs[0].m_int = static_cast<int32_t>(virtualDirectory);
cbArgs[1].m_pointer = path;
cbArgs[2].m_pointer = &outPathLength;
cbArgs[3].m_size = pathCapacity;
cbArgs[3].m_constPointer = initialFileName;
PortabilityLayer::HostSuspendCallArgument cbReturnValue;
PortabilityLayer::HostSuspendCallArgument dispatchArgs[3];
dispatchArgs[0].m_functionPtr = PromptSaveFileCallback;
dispatchArgs[1].m_constPointer = cbArgs;
dispatchArgs[2].m_pointer = &cbReturnValue;
PortabilityLayer::SuspendApplication(PortabilityLayer::HostSuspendCallID_CallOnVOSThread, dispatchArgs, nullptr);
return cbReturnValue.m_uint != 0;
}
}

View File

@@ -1,8 +1,12 @@
#pragma once
#include <stdint.h>
#include "VirtualDirectory.h"
#include <stdint.h>
namespace PLSysCalls
{
{
void Sleep(uint32_t ticks);
bool PromptOpenFile(PortabilityLayer::VirtualDirectory_t dirID, char *path, size_t &outPathLength, size_t pathCapacity);
bool PromptSaveFile(PortabilityLayer::VirtualDirectory_t virtualDirectory, char *path, size_t &outPathLength, size_t pathCapacity, const char *initialFileName);
}

View File

@@ -146,6 +146,7 @@
<ClInclude Include="AEHandlerDesc.h" />
<ClInclude Include="AEManager.h" />
<ClInclude Include="AntiAliasTable.h" />
<ClInclude Include="AppEventHandler.h" />
<ClInclude Include="ArrayTools.h" />
<ClInclude Include="BinarySearch.h" />
<ClInclude Include="BinHex4.h" />
@@ -230,6 +231,7 @@
<ClInclude Include="PLUnalignedPtr.h" />
<ClInclude Include="PLWidgets.h" />
<ClInclude Include="TextPlacer.h" />
<ClInclude Include="UTF16.h" />
<ClInclude Include="UTF8.h" />
<ClInclude Include="ZipFileProxy.h" />
<ClInclude Include="SimpleImage.h" />
@@ -303,6 +305,7 @@
<ClCompile Include="..\stb\stb_image_write.c" />
<ClCompile Include="AEManager.cpp" />
<ClCompile Include="AntiAliasTable.cpp" />
<ClCompile Include="AppEventHandler.cpp" />
<ClCompile Include="BinHex4.cpp" />
<ClCompile Include="BitmapImage.cpp" />
<ClCompile Include="ByteSwap.cpp" />
@@ -386,6 +389,7 @@
<ClCompile Include="SimpleGraphic.cpp" />
<ClCompile Include="PLHandle.cpp" />
<ClCompile Include="TextPlacer.cpp" />
<ClCompile Include="UTF16.cpp" />
<ClCompile Include="UTF8.cpp" />
<ClCompile Include="WindowDef.cpp" />
<ClCompile Include="WindowManager.cpp" />

View File

@@ -483,6 +483,12 @@
<ClInclude Include="ArrayTools.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="AppEventHandler.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="UTF16.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="CFileStream.cpp">
@@ -758,5 +764,11 @@
<ClCompile Include="TextPlacer.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="AppEventHandler.cpp">
<Filter>Header Files</Filter>
</ClCompile>
<ClCompile Include="UTF16.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,57 @@
#include "UTF16.h"
namespace PortabilityLayer
{
bool UTF16Processor::DecodeCodePoint(const uint16_t *characters, size_t availableCharacters, size_t &outCharactersDigested, uint32_t &outCodePoint)
{
if (availableCharacters <= 0)
return false;
if ((characters[0] & 0xff80) == 0x00)
{
outCharactersDigested = 1;
outCodePoint = characters[0];
return true;
}
if (characters[0] <= 0xd7ff || characters[0] >= 0xe000)
{
outCharactersDigested = 1;
outCodePoint = characters[0];
return true;
}
// Surrogate pair
if (characters[0] >= 0xdc00 || availableCharacters < 2)
return false;
if (characters[1] < 0xdc00 || characters[1] >= 0xe000)
return false;
uint16_t highBits = (characters[0] & 0x3ff);
uint16_t lowBits = (characters[1] & 0x3ff);
outCharactersDigested = 2;
outCodePoint = (highBits << 10) + lowBits + 0x10000;
return true;
}
void UTF16Processor::EncodeCodePoint(uint16_t *characters, size_t &outCharactersEmitted, uint32_t codePoint)
{
if (codePoint <= 0xd7ff || codePoint >= 0xe000)
{
outCharactersEmitted = 1;
characters[0] = static_cast<uint16_t>(codePoint);
return;
}
uint32_t codePointBits = (codePoint - 0x10000) & 0xfffff;
uint16_t lowBits = (codePointBits & 0x3ff);
uint16_t highBits = ((codePointBits >> 10) & 0x3ff);
outCharactersEmitted = 2;
characters[0] = (0xd800 + highBits);
characters[1] = (0xdc00 + lowBits);
}
}

13
PortabilityLayer/UTF16.h Normal file
View File

@@ -0,0 +1,13 @@
#pragma once
#include <stdint.h>
namespace PortabilityLayer
{
class UTF16Processor
{
public:
static bool DecodeCodePoint(const uint16_t *characters, size_t availableCharacters, size_t &outCharactersDigested, uint32_t &outCodePoint);
static void EncodeCodePoint(uint16_t *characters, size_t &outCharactersEmitted, uint32_t codePoint);
};
}

View File

@@ -14,6 +14,7 @@
#include "QDManager.h"
#include "QDPixMap.h"
#include "PLTimeTaggedVOSEvent.h"
#include "Rect2i.h"
#include "Vec2i.h"
#include "WindowDef.h"
@@ -31,6 +32,8 @@ namespace PortabilityLayer
virtual void GetChromePadding(const WindowImpl *window, uint16_t padding[WindowChromeSides::kCount]) const = 0;
virtual void RenderChrome(WindowImpl *window, DrawSurface *surface, WindowChromeSide_t chromeSide) const = 0;
virtual bool GetChromeInteractionZone(const WindowImpl *window, const Vec2i &point, RegionID_t &outRegion) const = 0;
virtual bool GetChromeRegionRect(const WindowImpl *window, RegionID_t region, Rect2i &outRect) const = 0;
virtual void UpdateRegionChromeState(const WindowImpl *window, RegionID_t region, const void *data) const = 0;
};
template<class T>
@@ -49,6 +52,8 @@ namespace PortabilityLayer
void GetChromePadding(const WindowImpl *window, uint16_t padding[WindowChromeSides::kCount]) const override;
void RenderChrome(WindowImpl *window, DrawSurface *surface, WindowChromeSide_t chromeSide) const override;
bool GetChromeInteractionZone(const WindowImpl *window, const Vec2i &point, RegionID_t &outRegion) const override;
bool GetChromeRegionRect(const WindowImpl *window, RegionID_t region, Rect2i &outRect) const override;
void UpdateRegionChromeState(const WindowImpl *window, RegionID_t region, const void *data) const override;
};
class GenericWindowChromeTheme final : public WindowChromeThemeSingleton<GenericWindowChromeTheme>
@@ -57,6 +62,8 @@ namespace PortabilityLayer
void GetChromePadding(const WindowImpl *window, uint16_t padding[WindowChromeSides::kCount]) const override;
void RenderChrome(WindowImpl *window, DrawSurface *surface, WindowChromeSide_t chromeSide) const override;
bool GetChromeInteractionZone(const WindowImpl *window, const Vec2i &point, RegionID_t &outRegion) const override;
bool GetChromeRegionRect(const WindowImpl *window, RegionID_t region, Rect2i &outRect) const override;
void UpdateRegionChromeState(const WindowImpl *window, RegionID_t region, const void *data) const override;
private:
void RenderChromeTop(WindowImpl *window, DrawSurface *surface) const;
@@ -69,6 +76,10 @@ namespace PortabilityLayer
void RenderChromeBottomMini(WindowImpl *window, DrawSurface *surface) const;
void RenderChromeRightMini(WindowImpl *window, DrawSurface *surface) const;
static Rect GetCloseBoxRectInTopChrome();
static Rect GetCloseBoxRectInTopChromeMini();
void RenderChromeCloseBox(DrawSurface *surface, const Rect &windowRect, bool isClicked) const;
static const int kDarkGray = 85;
static const int kMidGray = 187;
@@ -96,6 +107,8 @@ namespace PortabilityLayer
void GetChromePadding(uint16_t padding[WindowChromeSides::kCount]) const;
void GetChromeDimensions(int width, int height, Rect dimensions[WindowChromeSides::kCount]) const;
bool GetChromeInteractionZone(const Vec2i &point, RegionID_t &outRegion) const;
bool GetChromeRegionRect(RegionID_t region, Rect2i &outRect) const;
void UpdateRegionChromeState(RegionID_t region, const void *data) const;
bool IsBorderless() const;
uint16_t GetStyleFlags() const;
@@ -118,6 +131,7 @@ namespace PortabilityLayer
{
public:
WindowManagerImpl();
~WindowManagerImpl();
Window *CreateWindow(const WindowDef &windowDef) override;
void ResizeWindow(Window *window, int width, int height) override;
@@ -128,7 +142,12 @@ namespace PortabilityLayer
void FindWindow(const Point &point, Window **outWindow, short *outRegion) const override;
void DestroyWindow(Window *window) override;
void DragWindow(Window *window, const Point &startPoint, const Rect &constraintRect) override;
bool HandleCloseBoxClick(Window *window, const Point &startPoint) override;
void SetWindowTitle(Window *window, const PLPasStr &title) override;
Rect2i GetWindowFullRect(Window *window) const override;
void SetResizeInProgress(Window *window, const PortabilityLayer::Vec2i &size) override;
void ClearResizeInProgress() override;
void RenderFrame(IGpDisplayDriver *displayDriver) override;
@@ -142,9 +161,16 @@ namespace PortabilityLayer
void RenderWindow(WindowImpl *window, IGpDisplayDriver *displayDriver);
void DetachWindow(Window *window);
void ResetResizeInProgressSurfaces();
WindowImpl *m_windowStackTop;
WindowImpl *m_windowStackBottom;
Rect2i m_resizeInProgressRect;
DrawSurface m_resizeInProgressHorizontalBar;
DrawSurface m_resizeInProgressVerticalBar;
bool m_isResizeInProgress;
static WindowManagerImpl ms_instance;
static uint8_t ms_putInFrontSentinel;
@@ -175,6 +201,15 @@ namespace PortabilityLayer
return false;
}
bool SimpleBoxChromeTheme::GetChromeRegionRect(const WindowImpl *window, RegionID_t region, Rect2i &outRect) const
{
return false;
}
void SimpleBoxChromeTheme::UpdateRegionChromeState(const WindowImpl *window, RegionID_t region, const void *data) const
{
}
void SimpleBoxChromeTheme::RenderChrome(WindowImpl *window, DrawSurface *surface, WindowChromeSide_t chromeSide) const
{
surface->SetForeColor(StdColors::Black());
@@ -217,26 +252,92 @@ namespace PortabilityLayer
const DrawSurface *surface = window->GetDrawSurface();
const Rect rect = (*surface->m_port.GetPixMap())->m_rect;
const int32_t w = rect.Width();
const int32_t h = rect.Height();
if (window->GetStyleFlags() & WindowStyleFlags::kMiniBar)
{
if (point.m_x >= 0 && point.m_x < rect.Width() && point.m_y < 0 && point.m_y >= -13)
if (point.m_x >= 0 && point.m_x < w && point.m_y < 0 && point.m_y >= -13)
{
if (window->GetStyleFlags() & WindowStyleFlags::kCloseBox)
{
uint16_t padding[WindowChromeSides::kCount];
GetChromePadding(window, padding);
const Rect closeBoxRect = GetCloseBoxRectInTopChromeMini();
const Vec2i topChromePos = Vec2i(point.m_x + padding[WindowChromeSides::kLeft], point.m_y + padding[WindowChromeSides::kTop]);
if (closeBoxRect.Contains(Point::Create(topChromePos.m_x, topChromePos.m_y)))
{
outRegion = RegionIDs::kClose;
return true;
}
}
outRegion = RegionIDs::kTitleBar;
return true;
}
}
else
{
if (point.m_x >= 0 && point.m_x < rect.Width() && point.m_y < 0 && point.m_y >= -17)
if (point.m_x >= 0 && point.m_x < w && point.m_y < 0 && point.m_y >= -17)
{
outRegion = RegionIDs::kTitleBar;
return true;
}
}
if (window->GetStyleFlags() & WindowStyleFlags::kResizable)
{
if (point.m_x >= w - 14 && point.m_x < w && point.m_y >= h - 14 && point.m_y < h)
{
outRegion = RegionIDs::kResize;
return true;
}
}
return false;
}
bool GenericWindowChromeTheme::GetChromeRegionRect(const WindowImpl *window, RegionID_t region, Rect2i &outRect) const
{
if (region == RegionIDs::kClose)
{
if (window->GetStyleFlags() & WindowStyleFlags::kCloseBox)
{
if (window->GetStyleFlags() & WindowStyleFlags::kMiniBar)
{
uint16_t padding[WindowChromeSides::kCount];
GetChromePadding(window, padding);
const Rect closeBoxRect = GetCloseBoxRectInTopChromeMini();
outRect = Rect2i(closeBoxRect.top - padding[WindowChromeSides::kTop], closeBoxRect.left - padding[WindowChromeSides::kLeft],
closeBoxRect.bottom - padding[WindowChromeSides::kTop], closeBoxRect.right - padding[WindowChromeSides::kLeft]);
return true;
}
}
}
return false;
}
void GenericWindowChromeTheme::UpdateRegionChromeState(const WindowImpl *window, RegionID_t region, const void *data) const
{
if (region == RegionIDs::kClose)
{
const bool state = *static_cast<const bool*>(data);
if (window->GetStyleFlags() & WindowStyleFlags::kCloseBox)
{
if (window->GetStyleFlags() & WindowStyleFlags::kMiniBar)
{
DrawSurface *topChromeSurface = window->GetChromeSurface(WindowChromeSides::kTop);
RenderChromeCloseBox(topChromeSurface, GetCloseBoxRectInTopChromeMini(), state);
}
}
}
}
void GenericWindowChromeTheme::RenderChrome(WindowImpl *window, DrawSurface *surface, WindowChromeSide_t chromeSide) const
{
if (window->GetStyleFlags() & WindowStyleFlags::kMiniBar)
@@ -304,6 +405,9 @@ namespace PortabilityLayer
surface->FillRect(Rect::Create(rect.top + 1, rect.left + 1, rect.top + 2, rect.right - 2));
surface->FillRect(Rect::Create(rect.bottom - 1, rect.right - 5, rect.bottom, rect.right - 4));
if (window->GetStyleFlags() & WindowStyleFlags::kCloseBox)
RenderChromeCloseBox(surface, rect, false);
surface->SetForeColor(StdColors::Black());
surface->SetSystemFont(12, PortabilityLayer::FontFamilyFlags::FontFamilyFlag_Bold);
int32_t ascender = surface->MeasureFontAscender();
@@ -402,6 +506,9 @@ namespace PortabilityLayer
surface->FillRect(Rect::Create(rect.top + 1, rect.left + 1, rect.bottom - 2, rect.left + 2));
surface->FillRect(Rect::Create(rect.top + 1, rect.left + 1, rect.top + 2, rect.right - 2));
if (window->GetStyleFlags() & WindowStyleFlags::kCloseBox)
RenderChromeCloseBox(surface, rect, false);
surface->SetForeColor(StdColors::Black());
surface->SetApplicationFont(10, PortabilityLayer::FontFamilyFlags::FontFamilyFlag_Bold);
int32_t ascender = surface->MeasureFontAscender();
@@ -439,6 +546,45 @@ namespace PortabilityLayer
surface->FillRect(rect);
}
Rect GenericWindowChromeTheme::GetCloseBoxRectInTopChrome()
{
return GetCloseBoxRectInTopChromeMini(); // Temp, maybe... I don't think this is ever actually used
}
Rect GenericWindowChromeTheme::GetCloseBoxRectInTopChromeMini()
{
int boxDimensions = 8;
return Rect::Create(2, 2, 2 + boxDimensions, 2 + boxDimensions);
}
void GenericWindowChromeTheme::RenderChromeCloseBox(DrawSurface *surface, const Rect &chromeRect, bool isClicked) const
{
const Rect closeBoxRect = GetCloseBoxRectInTopChromeMini();
if (isClicked)
{
surface->SetForeColor(StdColors::Black());
surface->FillRect(closeBoxRect);
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(kDarkGray, kDarkGray, kDarkGray, 255));
surface->FillRect(Rect::Create(closeBoxRect.top + 1, closeBoxRect.left + 1, closeBoxRect.bottom - 1, closeBoxRect.right - 1));
}
else
{
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(kDarkGray, kDarkGray, kDarkGray, 255));
surface->FillRect(closeBoxRect);
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(kMidGray, kMidGray, kMidGray, 255));
surface->FillRect(Rect::Create(closeBoxRect.top + 1, closeBoxRect.left + 1, closeBoxRect.bottom, closeBoxRect.right));
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(kDarkGray, kDarkGray, kDarkGray, 255));
surface->FillRect(Rect::Create(closeBoxRect.top + 2, closeBoxRect.left + 2, closeBoxRect.bottom - 1, closeBoxRect.right - 1));
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(kLightGray, kLightGray, kLightGray, 255));
surface->FillRect(Rect::Create(closeBoxRect.top + 2, closeBoxRect.left + 2, closeBoxRect.bottom - 2, closeBoxRect.right - 2));
}
}
//---------------------------------------------------------------------------
WindowImpl::WindowImpl()
: m_windowAbove(nullptr)
@@ -588,6 +734,22 @@ namespace PortabilityLayer
return m_chromeTheme->GetChromeInteractionZone(this, point, outRegion);
}
bool WindowImpl::GetChromeRegionRect(RegionID_t region, Rect2i &outRect) const
{
if (!m_chromeTheme)
return false;
return m_chromeTheme->GetChromeRegionRect(this, region, outRect);
}
void WindowImpl::UpdateRegionChromeState(RegionID_t region, const void *data) const
{
if (!m_chromeTheme)
return;
m_chromeTheme->UpdateRegionChromeState(this, region, data);
}
bool WindowImpl::IsBorderless() const
{
return (m_styleFlags & WindowStyleFlags::kBorderless) != 0;
@@ -612,6 +774,12 @@ namespace PortabilityLayer
WindowManagerImpl::WindowManagerImpl()
: m_windowStackTop(nullptr)
, m_windowStackBottom(nullptr)
, m_resizeInProgressRect(Rect2i(0, 0, 0, 0))
, m_isResizeInProgress(false)
{
}
WindowManagerImpl::~WindowManagerImpl()
{
}
@@ -792,11 +960,123 @@ namespace PortabilityLayer
}
}
bool WindowManagerImpl::HandleCloseBoxClick(Window *window, const Point &startPoint)
{
bool isInBounds = false;
const Vec2i windowCoord = Vec2i(window->m_wmX, window->m_wmY);
Rect2i closeBoxRect;
if (!static_cast<WindowImpl*>(window)->GetChromeRegionRect(RegionIDs::kClose, closeBoxRect))
return false;
{
const Vec2i relativeCoord = Vec2i(startPoint.h, startPoint.v) - windowCoord;
const bool coordIsInBounds = closeBoxRect.Contains(relativeCoord);
if (coordIsInBounds != isInBounds)
{
const bool state = coordIsInBounds;
isInBounds = coordIsInBounds;
static_cast<WindowImpl*>(window)->UpdateRegionChromeState(RegionIDs::kClose, &state);
}
}
for (;;)
{
TimeTaggedVOSEvent evt;
if (WaitForEvent(&evt, 1))
{
if (evt.m_vosEvent.m_eventType == GpVOSEventTypes::kMouseInput)
{
const GpMouseInputEvent &mouseEvent = evt.m_vosEvent.m_event.m_mouseInputEvent;
const Vec2i relativeCoord = Vec2i(mouseEvent.m_x, mouseEvent.m_y) - windowCoord;
const bool coordIsInBounds = closeBoxRect.Contains(relativeCoord);
if (coordIsInBounds != isInBounds)
{
const bool state = coordIsInBounds;
isInBounds = coordIsInBounds;
static_cast<WindowImpl*>(window)->UpdateRegionChromeState(RegionIDs::kClose, &state);
}
if (mouseEvent.m_eventType == GpMouseEventTypes::kUp)
break;
}
}
}
if (isInBounds)
{
const bool state = false;
static_cast<WindowImpl*>(window)->UpdateRegionChromeState(RegionIDs::kClose, &state);
}
return isInBounds;
}
void WindowManagerImpl::SetWindowTitle(Window *window, const PLPasStr &title)
{
static_cast<WindowImpl*>(window)->SetTitle(title);
}
Rect2i WindowManagerImpl::GetWindowFullRect(Window *window) const
{
WindowImpl *windowImpl = static_cast<WindowImpl*>(window);
uint16_t padding[WindowChromeSides::kCount];
windowImpl->GetChromePadding(padding);
const Rect portRect = windowImpl->m_surface.m_port.GetRect();
return Rect2i(window->m_wmY - padding[WindowChromeSides::kTop], window->m_wmX - padding[WindowChromeSides::kLeft], window->m_wmY + portRect.Height() + padding[WindowChromeSides::kBottom], window->m_wmX + portRect.Width() + padding[WindowChromeSides::kRight]);
}
void WindowManagerImpl::SetResizeInProgress(Window *window, const PortabilityLayer::Vec2i &size)
{
ResetResizeInProgressSurfaces();
m_isResizeInProgress = true;
if (!m_resizeInProgressHorizontalBar.Init(Rect::Create(0, 0, 3, size.m_x + 4), GpPixelFormats::k8BitStandard))
{
m_resizeInProgressHorizontalBar.SetForeColor(StdColors::Black());
m_resizeInProgressHorizontalBar.FillRect(Rect::Create(0, 0, 3, size.m_x + 4));
m_resizeInProgressHorizontalBar.SetForeColor(StdColors::White());
m_resizeInProgressHorizontalBar.FillRect(Rect::Create(1, 1, 2, size.m_x + 3));
}
else
{
m_isResizeInProgress = false;
return;
}
if (!m_resizeInProgressVerticalBar.Init(Rect::Create(0, 0, size.m_y, 3), GpPixelFormats::k8BitStandard))
{
m_resizeInProgressVerticalBar.SetForeColor(StdColors::Black());
m_resizeInProgressVerticalBar.FillRect(Rect::Create(0, 0, size.m_y, 1));
m_resizeInProgressVerticalBar.FillRect(Rect::Create(0, 2, size.m_y, 3));
m_resizeInProgressVerticalBar.SetForeColor(StdColors::White());
m_resizeInProgressVerticalBar.FillRect(Rect::Create(0, 1, size.m_y, 2));
}
else
{
m_isResizeInProgress = false;
return;
}
const PortabilityLayer::Vec2i topLeft = PortabilityLayer::Vec2i(window->m_wmX, window->m_wmY);
m_resizeInProgressRect = PortabilityLayer::Rect2i(topLeft, topLeft + size);
}
void WindowManagerImpl::ClearResizeInProgress()
{
ResetResizeInProgressSurfaces();
m_isResizeInProgress = false;
}
void WindowManagerImpl::RenderFrame(IGpDisplayDriver *displayDriver)
{
PortabilityLayer::DisplayDeviceManager *dd = PortabilityLayer::DisplayDeviceManager::GetInstance();
@@ -809,6 +1089,17 @@ namespace PortabilityLayer
RenderWindow(window, displayDriver);
window = window->GetWindowAbove();
}
if (m_isResizeInProgress)
{
m_resizeInProgressHorizontalBar.PushToDDSurface(displayDriver);
m_resizeInProgressVerticalBar.PushToDDSurface(displayDriver);
displayDriver->DrawSurface(m_resizeInProgressHorizontalBar.m_ddSurface, m_resizeInProgressRect.m_topLeft.m_x - 2, m_resizeInProgressRect.m_topLeft.m_y - 2, m_resizeInProgressRect.Right() - m_resizeInProgressRect.Left() + 4, 3);
displayDriver->DrawSurface(m_resizeInProgressHorizontalBar.m_ddSurface, m_resizeInProgressRect.m_topLeft.m_x - 2, m_resizeInProgressRect.m_bottomRight.m_y - 1, m_resizeInProgressRect.Right() - m_resizeInProgressRect.Left() + 4, 3);
displayDriver->DrawSurface(m_resizeInProgressVerticalBar.m_ddSurface, m_resizeInProgressRect.m_topLeft.m_x - 2, m_resizeInProgressRect.m_topLeft.m_y, 3, m_resizeInProgressRect.Bottom() - m_resizeInProgressRect.Top());
displayDriver->DrawSurface(m_resizeInProgressVerticalBar.m_ddSurface, m_resizeInProgressRect.m_bottomRight.m_x - 1, m_resizeInProgressRect.m_topLeft.m_y, 3, m_resizeInProgressRect.Bottom() - m_resizeInProgressRect.Top());
}
}
void WindowManagerImpl::HandleScreenResolutionChange(uint32_t prevWidth, uint32_t prevHeight, uint32_t newWidth, uint32_t newHeight)
@@ -888,6 +1179,15 @@ namespace PortabilityLayer
impl->SetWindowBelow(nullptr);
}
void WindowManagerImpl::ResetResizeInProgressSurfaces()
{
m_resizeInProgressHorizontalBar.~DrawSurface();
m_resizeInProgressVerticalBar.~DrawSurface();
new (&m_resizeInProgressHorizontalBar) DrawSurface();
new (&m_resizeInProgressVerticalBar) DrawSurface();
}
Window *WindowManagerImpl::GetPutInFrontSentinel() const
{
return reinterpret_cast<Window*>(&ms_putInFrontSentinel);

View File

@@ -14,6 +14,8 @@ struct Window;
namespace PortabilityLayer
{
struct WindowDef;
struct Rect2i;
struct Vec2i;
class WindowManager
{
@@ -28,7 +30,12 @@ namespace PortabilityLayer
virtual void FindWindow(const Point &point, Window **outWindow, short *outRegion) const = 0;
virtual void DestroyWindow(Window *window) = 0;
virtual void DragWindow(Window *window, const Point &startPoint, const Rect &constraintRect) = 0;
virtual bool HandleCloseBoxClick(Window *window, const Point &startPoint) = 0;
virtual void SetWindowTitle(Window *window, const PLPasStr &title) = 0;
virtual Rect2i GetWindowFullRect(Window *window) const = 0;
virtual void SetResizeInProgress(Window *window, const PortabilityLayer::Vec2i &size) = 0;
virtual void ClearResizeInProgress() = 0;
virtual void RenderFrame(IGpDisplayDriver *displayDriver) = 0;

View File

@@ -1,10 +1,11 @@
Aerofoil is a collection of porting infrastructure to run Glider PRO.
Aerofoil is a project to port Glider PRO to other systems.
It's divided into a few parts:
- PortabilityLayer: A static library that supports interaction with various vintage Mac-specific formats and API calls. Some parts are capable of running by themselves, others require the support of drivers.
- Aerofoil: This is the base application. It loads drivers and loads the application.
- GpDisplayDriver_D3D11: Direct3D 11 display driver.
- GpAudioDriver_XAudio2: XAudio2 audio driver.
- GpInputDriver_XInput: XInput gamepad driver.
- GpApp: Glider PRO application DLL.
@@ -12,16 +13,11 @@ Other parts:
- CompileShadersD3D11: Compiles D3D11 shaders into C++ files containing the compiled shader data.
- ConvertColorCursors: Extracts color cursors and icons from the application resources and dumps them to .CUR and .ICO files. Required because Windows has no API for creating color cursors at runtime.
- GliderProData: Glider PRO resource sources.
- ApplicationResourcePatches: Modified resources (used to change config dialogs).
- hqx2bin: Converts BinHex to MacBinary (not really used any more)
- hqx2gp: Converts BinHex to .gpr, .gpd, and .gpf (resource fork data, data fork data, and Finder data, respectively)
- gpr2gpa: Converts Macintosh resource files to a .gpa (a ZIP archive containing the resources in more common formats)
- FTagData: Copies a data-only file to a .gpd and creates a .gpf for it
- PictChecker: Experimental app that extracts all of the PICT resources from all of the houses and dumps them to PNG. Used to verify that the PICT loader works.
- MacRomanConverter: Micro-library that converts the Mac Roman character set to Unicode.
Aerofoil is intended to be primarily a straight port, retaining most of the look and feel of the original.
Planned additions:
- 32-bit color support (mainly matters for houses that have higher-resolution PICT resources)
- Resolution changes while the game is running
- Bring back the gray-to-color intro fade that was removed in later versions
- Gamepad support
- unpacktool: A utility for extracting vintage StuffIt and Compact Pro archives.

View File

@@ -1,339 +1,346 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.
{\rtf1\ansi\deff0\nouicompat{\fonttbl{\f0\fnil\fcharset0 Lucida Console;}}
{\*\generator Riched20 10.0.18362}\viewkind4\uc1
\pard\f0\fs14\lang1033 GNU GENERAL PUBLIC LICENSE\par
Version 2, June 1991\par
\par
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,\par
\pard\tx6210 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\par
\pard Everyone is permitted to copy and distribute verbatim copies\par
of this license document, but changing it is not allowed.\par
\par
Preamble\par
\par
The licenses for most software are designed to take away your\par
freedom to share and change it. By contrast, the GNU General Public\par
License is intended to guarantee your freedom to share and change free\par
software--to make sure the software is free for all its users. This\par
General Public License applies to most of the Free Software\par
Foundation's software and to any other program whose authors commit to\par
using it. (Some other Free Software Foundation software is covered by\par
the GNU Lesser General Public License instead.) You can apply it to\par
your programs, too.\par
\par
When we speak of free software, we are referring to freedom, not\par
price. Our General Public Licenses are designed to make sure that you\par
have the freedom to distribute copies of free software (and charge for\par
this service if you wish), that you receive source code or can get it\par
if you want it, that you can change the software or use pieces of it\par
in new free programs; and that you know you can do these things.\par
\par
To protect your rights, we need to make restrictions that forbid\par
anyone to deny you these rights or to ask you to surrender the rights.\par
These restrictions translate to certain responsibilities for you if you\par
distribute copies of the software, or if you modify it.\par
\par
For example, if you distribute copies of such a program, whether\par
gratis or for a fee, you must give the recipients all the rights that\par
you have. You must make sure that they, too, receive or can get the\par
source code. And you must show them these terms so they know their\par
rights.\par
\par
We protect your rights with two steps: (1) copyright the software, and\par
(2) offer you this license which gives you legal permission to copy,\par
distribute and/or modify the software.\par
\par
Also, for each author's protection and ours, we want to make certain\par
that everyone understands that there is no warranty for this free\par
software. If the software is modified by someone else and passed on, we\par
want its recipients to know that what they have is not the original, so\par
that any problems introduced by others will not reflect on the original\par
authors' reputations.\par
\par
Finally, any free program is threatened constantly by software\par
patents. We wish to avoid the danger that redistributors of a free\par
program will individually obtain patent licenses, in effect making the\par
program proprietary. To prevent this, we have made it clear that any\par
patent must be licensed for everyone's free use or not licensed at all.\par
\par
The precise terms and conditions for copying, distribution and\par
modification follow.\par
\par
GNU GENERAL PUBLIC LICENSE\par
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION\par
\par
0. This License applies to any program or other work which contains\par
a notice placed by the copyright holder saying it may be distributed\par
under the terms of this General Public License. The "Program", below,\par
refers to any such program or work, and a "work based on the Program"\par
means either the Program or any derivative work under copyright law:\par
that is to say, a work containing the Program or a portion of it,\par
either verbatim or with modifications and/or translated into another\par
language. (Hereinafter, translation is included without limitation in\par
the term "modification".) Each licensee is addressed as "you".\par
\par
Activities other than copying, distribution and modification are not\par
covered by this License; they are outside its scope. The act of\par
running the Program is not restricted, and the output from the Program\par
is covered only if its contents constitute a work based on the\par
Program (independent of having been made by running the Program).\par
Whether that is true depends on what the Program does.\par
\par
1. You may copy and distribute verbatim copies of the Program's\par
source code as you receive it, in any medium, provided that you\par
conspicuously and appropriately publish on each copy an appropriate\par
copyright notice and disclaimer of warranty; keep intact all the\par
notices that refer to this License and to the absence of any warranty;\par
and give any other recipients of the Program a copy of this License\par
along with the Program.\par
\par
You may charge a fee for the physical act of transferring a copy, and\par
you may at your option offer warranty protection in exchange for a fee.\par
\par
2. You may modify your copy or copies of the Program or any portion\par
of it, thus forming a work based on the Program, and copy and\par
distribute such modifications or work under the terms of Section 1\par
above, provided that you also meet all of these conditions:\par
\par
a) You must cause the modified files to carry prominent notices\par
stating that you changed the files and the date of any change.\par
\par
b) You must cause any work that you distribute or publish, that in\par
whole or in part contains or is derived from the Program or any\par
part thereof, to be licensed as a whole at no charge to all third\par
parties under the terms of this License.\par
\par
c) If the modified program normally reads commands interactively\par
when run, you must cause it, when started running for such\par
interactive use in the most ordinary way, to print or display an\par
announcement including an appropriate copyright notice and a\par
notice that there is no warranty (or else, saying that you provide\par
a warranty) and that users may redistribute the program under\par
these conditions, and telling the user how to view a copy of this\par
License. (Exception: if the Program itself is interactive but\par
does not normally print such an announcement, your work based on\par
the Program is not required to print an announcement.)\par
\par
These requirements apply to the modified work as a whole. If\par
identifiable sections of that work are not derived from the Program,\par
and can be reasonably considered independent and separate works in\par
themselves, then this License, and its terms, do not apply to those\par
sections when you distribute them as separate works. But when you\par
distribute the same sections as part of a whole which is a work based\par
on the Program, the distribution of the whole must be on the terms of\par
this License, whose permissions for other licensees extend to the\par
entire whole, and thus to each and every part regardless of who wrote it.\par
\par
Thus, it is not the intent of this section to claim rights or contest\par
your rights to work written entirely by you; rather, the intent is to\par
exercise the right to control the distribution of derivative or\par
collective works based on the Program.\par
\par
In addition, mere aggregation of another work not based on the Program\par
with the Program (or with a work based on the Program) on a volume of\par
a storage or distribution medium does not bring the other work under\par
the scope of this License.\par
\par
3. You may copy and distribute the Program (or a work based on it,\par
under Section 2) in object code or executable form under the terms of\par
Sections 1 and 2 above provided that you also do one of the following:\par
\par
a) Accompany it with the complete corresponding machine-readable\par
source code, which must be distributed under the terms of Sections\par
1 and 2 above on a medium customarily used for software interchange; or,\par
\par
b) Accompany it with a written offer, valid for at least three\par
years, to give any third party, for a charge no more than your\par
cost of physically performing source distribution, a complete\par
machine-readable copy of the corresponding source code, to be\par
distributed under the terms of Sections 1 and 2 above on a medium\par
customarily used for software interchange; or,\par
\par
c) Accompany it with the information you received as to the offer\par
to distribute corresponding source code. (This alternative is\par
allowed only for noncommercial distribution and only if you\par
received the program in object code or executable form with such\par
an offer, in accord with Subsection b above.)\par
\par
The source code for a work means the preferred form of the work for\par
making modifications to it. For an executable work, complete source\par
code means all the source code for all modules it contains, plus any\par
associated interface definition files, plus the scripts used to\par
control compilation and installation of the executable. However, as a\par
special exception, the source code distributed need not include\par
anything that is normally distributed (in either source or binary\par
form) with the major components (compiler, kernel, and so on) of the\par
operating system on which the executable runs, unless that component\par
itself accompanies the executable.\par
\par
If distribution of executable or object code is made by offering\par
access to copy from a designated place, then offering equivalent\par
access to copy the source code from the same place counts as\par
distribution of the source code, even though third parties are not\par
compelled to copy the source along with the object code.\par
\par
4. You may not copy, modify, sublicense, or distribute the Program\par
except as expressly provided under this License. Any attempt\par
otherwise to copy, modify, sublicense or distribute the Program is\par
void, and will automatically terminate your rights under this License.\par
However, parties who have received copies, or rights, from you under\par
this License will not have their licenses terminated so long as such\par
parties remain in full compliance.\par
\par
5. You are not required to accept this License, since you have not\par
signed it. However, nothing else grants you permission to modify or\par
distribute the Program or its derivative works. These actions are\par
prohibited by law if you do not accept this License. Therefore, by\par
modifying or distributing the Program (or any work based on the\par
Program), you indicate your acceptance of this License to do so, and\par
all its terms and conditions for copying, distributing or modifying\par
the Program or works based on it.\par
\par
6. Each time you redistribute the Program (or any work based on the\par
Program), the recipient automatically receives a license from the\par
original licensor to copy, distribute or modify the Program subject to\par
these terms and conditions. You may not impose any further\par
restrictions on the recipients' exercise of the rights granted herein.\par
You are not responsible for enforcing compliance by third parties to\par
this License.\par
\par
7. If, as a consequence of a court judgment or allegation of patent\par
infringement or for any other reason (not limited to patent issues),\par
conditions are imposed on you (whether by court order, agreement or\par
otherwise) that contradict the conditions of this License, they do not\par
excuse you from the conditions of this License. If you cannot\par
distribute so as to satisfy simultaneously your obligations under this\par
License and any other pertinent obligations, then as a consequence you\par
may not distribute the Program at all. For example, if a patent\par
license would not permit royalty-free redistribution of the Program by\par
all those who receive copies directly or indirectly through you, then\par
the only way you could satisfy both it and this License would be to\par
refrain entirely from distribution of the Program.\par
\par
If any portion of this section is held invalid or unenforceable under\par
any particular circumstance, the balance of the section is intended to\par
apply and the section as a whole is intended to apply in other\par
circumstances.\par
\par
It is not the purpose of this section to induce you to infringe any\par
patents or other property right claims or to contest validity of any\par
such claims; this section has the sole purpose of protecting the\par
integrity of the free software distribution system, which is\par
implemented by public license practices. Many people have made\par
generous contributions to the wide range of software distributed\par
through that system in reliance on consistent application of that\par
system; it is up to the author/donor to decide if he or she is willing\par
to distribute software through any other system and a licensee cannot\par
impose that choice.\par
\par
This section is intended to make thoroughly clear what is believed to\par
be a consequence of the rest of this License.\par
\par
8. If the distribution and/or use of the Program is restricted in\par
certain countries either by patents or by copyrighted interfaces, the\par
original copyright holder who places the Program under this License\par
may add an explicit geographical distribution limitation excluding\par
those countries, so that distribution is permitted only in or among\par
countries not thus excluded. In such case, this License incorporates\par
the limitation as if written in the body of this License.\par
\par
9. The Free Software Foundation may publish revised and/or new versions\par
of the General Public License from time to time. Such new versions will\par
be similar in spirit to the present version, but may differ in detail to\par
address new problems or concerns.\par
\par
Each version is given a distinguishing version number. If the Program\par
specifies a version number of this License which applies to it and "any\par
later version", you have the option of following the terms and conditions\par
either of that version or of any later version published by the Free\par
Software Foundation. If the Program does not specify a version number of\par
this License, you may choose any version ever published by the Free Software\par
Foundation.\par
\par
10. If you wish to incorporate parts of the Program into other free\par
programs whose distribution conditions are different, write to the author\par
to ask for permission. For software which is copyrighted by the Free\par
Software Foundation, write to the Free Software Foundation; we sometimes\par
make exceptions for this. Our decision will be guided by the two goals\par
of preserving the free status of all derivatives of our free software and\par
of promoting the sharing and reuse of software generally.\par
\par
NO WARRANTY\par
\par
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY\par
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN\par
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES\par
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED\par
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\par
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS\par
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE\par
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,\par
REPAIR OR CORRECTION.\par
\par
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\par
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR\par
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,\par
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING\par
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED\par
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY\par
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER\par
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE\par
POSSIBILITY OF SUCH DAMAGES.\par
\par
END OF TERMS AND CONDITIONS\par
\par
How to Apply These Terms to Your New Programs\par
\par
If you develop a new program, and you want it to be of the greatest\par
possible use to the public, the best way to achieve this is to make it\par
free software which everyone can redistribute and change under these terms.\par
\par
To do so, attach the following notices to the program. It is safest\par
to attach them to the start of each source file to most effectively\par
convey the exclusion of warranty; and each file should have at least\par
the "copyright" line and a pointer to where the full notice is found.\par
\par
<one line to give the program's name and a brief idea of what it does.>\par
Copyright (C) <year> <name of author>\par
\par
This program is free software; you can redistribute it and/or modify\par
it under the terms of the GNU General Public License as published by\par
the Free Software Foundation; either version 2 of the License, or\par
(at your option) any later version.\par
\par
This program is distributed in the hope that it will be useful,\par
but WITHOUT ANY WARRANTY; without even the implied warranty of\par
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\par
GNU General Public License for more details.\par
\par
You should have received a copy of the GNU General Public License along\par
with this program; if not, write to the Free Software Foundation, Inc.,\par
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\par
\par
Also add information on how to contact you by electronic and paper mail.\par
\par
If the program is interactive, make it output a short notice like this\par
when it starts in an interactive mode:\par
\par
Gnomovision version 69, Copyright (C) year name of author\par
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\par
This is free software, and you are welcome to redistribute it\par
under certain conditions; type `show c' for details.\par
\par
The hypothetical commands `show w' and `show c' should show the appropriate\par
parts of the General Public License. Of course, the commands you use may\par
be called something other than `show w' and `show c'; they could even be\par
mouse-clicks or menu items--whatever suits your program.\par
\par
You should also get your employer (if you work as a programmer) or your\par
school, if any, to sign a "copyright disclaimer" for the program, if\par
necessary. Here is a sample; alter the names:\par
\par
Yoyodyne, Inc., hereby disclaims all copyright interest in the program\par
`Gnomovision' (which makes passes at compilers) written by James Hacker.\par
\par
<signature of Ty Coon>, 1 April 1989\par
Ty Coon, President of Vice\par
\par
This General Public License does not permit incorporating your program into\par
proprietary programs. If your program is a subroutine library, you may\par
consider it more useful to permit linking proprietary applications with the\par
library. If this is what you want to do, use the GNU Lesser General\par
Public License instead of this License.\par
\par
}

View File

@@ -0,0 +1,167 @@
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="Aerofoil" Language="1033" Version="0.2.2.0" Manufacturer="The Aerofoil Project" UpgradeCode="2ae0587c-2a5f-4299-b5a8-e6cfed7cd84c">
<Package InstallerVersion="301" Compressed="yes" InstallScope="perMachine">
</Package>
<Icon Id="icon.ico" SourceFile="$(var.Aerofoil.ProjectDir)\ConvertedResources\Large128.ico" />
<Property Id="ARPPRODUCTICON" Value="icon.ico" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate CompressionLevel="high" EmbedCab="yes" />
<Directory Id="TARGETDIR" Name="SourceDir">
<!-- Installation directory -->
<Directory Id="ProgramFiles64Folder">
<Directory Id="AEROFOILPRODUCTDIR" Name="Aerofoil">
<Directory Id="AEROFOILRESOURCESDIR" Name="Resources" />
<Directory Id="AEROFOILPACKAGEDDIR" Name="Packaged">
<Directory Id="AEROFOILHOUSESDIR" Name="Houses" />
<Directory Id="AEROFOILWINCURSORSDIR" Name="WinCursors" />
</Directory>
<Directory Id="AEROFOILDOCUMENTATIONDIR" Name="Documentation" />
<Directory Id="AEROFOILTOOLSDIR" Name="Tools" />
</Directory>
</Directory>
<!-- Start menu -->
<Directory Id="ProgramMenuFolder">
<Directory Id="ApplicationProgramsFolder" Name="Aerofoil"/>
</Directory>
</Directory>
<DirectoryRef Id="AEROFOILPRODUCTDIR">
<Component Id="Aerofoil.exe" Guid="*">
<File Id="Aerofoil.exe" Source="$(var.Aerofoil.TargetPath)" KeyPath="yes" Checksum="yes"/>
</Component>
<Component Id="FreeType.dll" Guid="*">
<File Id="FreeType.dll" Source="$(var.FreeType.TargetPath)" KeyPath="yes" Checksum="yes"/>
</Component>
<Component Id="GpApp.dll" Guid="*">
<File Id="GpApp.dll" Source="$(var.GpApp.TargetPath)" KeyPath="yes" Checksum="yes"/>
</Component>
<Component Id="GpAudioDriver_XAudio2.dll" Guid="*">
<File Id="GpAudioDriver_XAudio2.dll" Source="$(var.GpAudioDriver_XAudio2.TargetPath)" KeyPath="yes" Checksum="yes"/>
</Component>
<Component Id="GpDisplayDriver_D3D11.dll" Guid="*">
<File Id="GpDisplayDriver_D3D11.dll" Source="$(var.GpDisplayDriver_D3D11.TargetPath)" KeyPath="yes" Checksum="yes"/>
</Component>
<Component Id="GpInputDriver_XInput.dll" Guid="*">
<File Id="GpInputDriver_XInput.dll" Source="$(var.GpInputDriver_XInput.TargetPath)" KeyPath="yes" Checksum="yes"/>
</Component>
</DirectoryRef>
<DirectoryRef Id="AEROFOILPACKAGEDDIR">
<Component Id="ApplicationResources" Guid="*">
<File Id="ApplicationResources.gpa" Source="$(var.PackagedDataDir)\ApplicationResources.gpa" KeyPath="yes" Checksum="yes"/>
</Component>
</DirectoryRef>
<DirectoryRef Id="AEROFOILTOOLSDIR">
<Component Id="bin2gp.exe" Guid="*">
<File Id="bin2gp.exe" Source="$(var.bin2gp.TargetPath)" KeyPath="yes" Checksum="yes"/>
</Component>
<Component Id="flattenmov.exe" Guid="*">
<File Id="flattenmov.exe" Source="$(var.flattenmov.TargetPath)" KeyPath="yes" Checksum="yes"/>
</Component>
<Component Id="FTagData.exe" Guid="*">
<File Id="FTagData.exe" Source="$(var.FTagData.TargetPath)" KeyPath="yes" Checksum="yes"/>
</Component>
<Component Id="gpr2gpa.exe" Guid="*">
<File Id="gpr2gpa.exe" Source="$(var.gpr2gpa.TargetPath)" KeyPath="yes" Checksum="yes"/>
</Component>
<Component Id="hqx2bin.exe" Guid="*">
<File Id="hqx2bin.exe" Source="$(var.hqx2bin.TargetPath)" KeyPath="yes" Checksum="yes"/>
</Component>
<Component Id="hqx2gp.exe" Guid="*">
<File Id="hqx2gp.exe" Source="$(var.hqx2gp.TargetPath)" KeyPath="yes" Checksum="yes"/>
</Component>
<Component Id="MakeTimestamp.exe" Guid="*">
<File Id="MakeTimestamp.exe" Source="$(var.MakeTimestamp.TargetPath)" KeyPath="yes" Checksum="yes"/>
</Component>
<Component Id="unpacktool.exe" Guid="*">
<File Id="unpacktool.exe" Source="$(var.unpacktool.TargetPath)" KeyPath="yes" Checksum="yes"/>
</Component>
</DirectoryRef>
<DirectoryRef Id="AEROFOILDOCUMENTATIONDIR">
<Component Id="readme.txt" Guid="*">
<File Id="readme.txt" Source="$(var.DocumentationDataDir)\readme.txt" KeyPath="yes" Checksum="yes"/>
</Component>
</DirectoryRef>
<DirectoryRef Id="ApplicationProgramsFolder">
<Component Id="StartMenuShortcuts" Guid="*">
<Shortcut Id="ApplicationStartMenuShortcut"
Name="Aerofoil"
Description="Aerofoil"
Target="[#Aerofoil.exe]"
WorkingDirectory="AEROFOILPRODUCTDIR"/>
<Shortcut Id="ReadMeStartMenuShortcut"
Name="Aerofoil Documentation"
Description="Aerofoil Documentation"
Target="[#readme.txt]"
WorkingDirectory="AEROFOILDOCUMENTATIONDIR"/>
<RemoveFolder Id="CleanUpShortCut" Directory="ApplicationProgramsFolder" On="uninstall"/>
<RegistryValue Root="HKCU" Key="Software\AerofoilProject\Aerofoil" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
</Component>
</DirectoryRef>
<Feature Id="AerofoilApplication" Title="Glider PRO Game Data" Level="1" Display="expand">
<ComponentRef Id="Aerofoil.exe" />
<ComponentRef Id="FreeType.dll" />
<ComponentRef Id="GpApp.dll" />
<ComponentRef Id="GpAudioDriver_XAudio2.dll" />
<ComponentRef Id="GpDisplayDriver_D3D11.dll" />
<ComponentRef Id="GpInputDriver_XInput.dll" />
<ComponentRef Id="bin2gp.exe" />
<ComponentRef Id="flattenmov.exe" />
<ComponentRef Id="FTagData.exe" />
<ComponentRef Id="gpr2gpa.exe" />
<ComponentRef Id="hqx2bin.exe" />
<ComponentRef Id="hqx2gp.exe" />
<ComponentRef Id="MakeTimestamp.exe" />
<ComponentRef Id="unpacktool.exe" />
<ComponentRef Id="ApplicationResources" />
<ComponentRef Id="readme.txt" />
<ComponentGroupRef Id="WinCursorsComponentGroup"/>
<ComponentGroupRef Id="DefaultHousesComponentGroup"/>
<ComponentGroupRef Id="ResourcesComponentGroup"/>
<ComponentGroupRef Id="LooseDocumentationComponentGroup"/>
<ComponentRef Id="StartMenuShortcuts" />
<Feature Id="HousePack1Feature" Title="Additional Houses" Level="1">
<ComponentGroupRef Id="HousePack1ComponentGroup" />
</Feature>
</Feature>
<WixVariable Id="WixUILicenseRtf" Value="$(var.ProjectDir)\LICENSE.rtf"/>
<DirectoryRef Id="TARGETDIR">
<Merge Id="VCRedist" SourceFile="C:\Program Files (x86)\Common Files\Merge Modules\Microsoft_VC140_CRT_x64.msm" DiskId="1" Language="0" />
</DirectoryRef>
<Feature Id="VCRedist" Title="Microsoft Visual C++ 2017 Runtime" AllowAdvertise="no" Display="hidden" Level="1">
<MergeRef Id="VCRedist" />
</Feature>
<Property Id="WIXUI_INSTALLDIR" Value="AEROFOILPRODUCTDIR" />
<UI>
<UIRef Id="WixUI_Mondo" />
<Publish Dialog="ExitDialog" Control="Finish" Event="DoAction" Value="LaunchApplication">WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed</Publish>
</UI>
<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="Read the Aerofoil documentation" />
<Property Id="WixShellExecTarget" Value="[#readme.txt]" />
<CustomAction Id="LaunchApplication" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="yes" />
</Product>
</Wix>

View File

@@ -0,0 +1,223 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" InitialTargets="EnsureWixToolsetInstalled" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x64</Platform>
<ProductVersion>3.10</ProductVersion>
<ProjectGuid>d26bd501-28a7-4849-8130-fb5ea0a2b82f</ProjectGuid>
<SchemaVersion>2.0</SchemaVersion>
<OutputName>Aerofoil-installpkg</OutputName>
<OutputType>Package</OutputType>
<InstallerPlatform>x64</InstallerPlatform>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
<OutputPath>$(SolutionDir)ReleasePkg\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<DefineConstants>Debug</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
<OutputPath>$(SolutionDir)ReleasePkg\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
</PropertyGroup>
<ItemGroup>
<Compile Include="Product.wxs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Aerofoil\Aerofoil.vcxproj">
<Name>Aerofoil</Name>
<Project>{0e383ef0-cef7-4733-87c6-5ac9844aa1ef}</Project>
<Private>True</Private>
<DoNotHarvest>True</DoNotHarvest>
<RefProjectOutputGroups>Binaries;Content;Satellites</RefProjectOutputGroups>
<RefTargetDir>INSTALLFOLDER</RefTargetDir>
</ProjectReference>
<ProjectReference Include="..\bin2gp\bin2gp.vcxproj">
<Name>bin2gp</Name>
<Project>{d7bfe702-0667-4155-9b0b-2a54df9ae60b}</Project>
<Private>True</Private>
<DoNotHarvest>True</DoNotHarvest>
<RefProjectOutputGroups>Binaries;Content;Satellites</RefProjectOutputGroups>
<RefTargetDir>INSTALLFOLDER</RefTargetDir>
</ProjectReference>
<ProjectReference Include="..\flattenmov\flattenmov.vcxproj">
<Name>flattenmov</Name>
<Project>{89f8d13e-f216-4b67-8de9-7f842d349e94}</Project>
<Private>True</Private>
<DoNotHarvest>True</DoNotHarvest>
<RefProjectOutputGroups>Binaries;Content;Satellites</RefProjectOutputGroups>
<RefTargetDir>INSTALLFOLDER</RefTargetDir>
</ProjectReference>
<ProjectReference Include="..\FreeType\FreeType.vcxproj">
<Name>FreeType</Name>
<Project>{487216d8-16ba-4b4c-b5bf-43feedfee03a}</Project>
<Private>True</Private>
<DoNotHarvest>True</DoNotHarvest>
<RefProjectOutputGroups>Binaries;Content;Satellites</RefProjectOutputGroups>
<RefTargetDir>INSTALLFOLDER</RefTargetDir>
</ProjectReference>
<ProjectReference Include="..\FTagData\FTagData.vcxproj">
<Name>FTagData</Name>
<Project>{a8fcdc5e-729c-4a80-bf9f-b669c52b2ae3}</Project>
<Private>True</Private>
<DoNotHarvest>True</DoNotHarvest>
<RefProjectOutputGroups>Binaries;Content;Satellites</RefProjectOutputGroups>
<RefTargetDir>INSTALLFOLDER</RefTargetDir>
</ProjectReference>
<ProjectReference Include="..\GpApp\GpApp.vcxproj">
<Name>GpApp</Name>
<Project>{6233c3f2-5781-488e-b190-4fa8836f5a77}</Project>
<Private>True</Private>
<DoNotHarvest>True</DoNotHarvest>
<RefProjectOutputGroups>Binaries;Content;Satellites</RefProjectOutputGroups>
<RefTargetDir>INSTALLFOLDER</RefTargetDir>
</ProjectReference>
<ProjectReference Include="..\GpAudioDriver_XAudio2\GpAudioDriver_XAudio2.vcxproj">
<Name>GpAudioDriver_XAudio2</Name>
<Project>{e3bdc783-8646-433e-adf0-8b6390d36669}</Project>
<Private>True</Private>
<DoNotHarvest>True</DoNotHarvest>
<RefProjectOutputGroups>Binaries;Content;Satellites</RefProjectOutputGroups>
<RefTargetDir>INSTALLFOLDER</RefTargetDir>
</ProjectReference>
<ProjectReference Include="..\GpDisplayDriver_D3D11\GpDisplayDriver_D3D11.vcxproj">
<Name>GpDisplayDriver_D3D11</Name>
<Project>{ffc961ac-55b4-4a38-a83e-06ae98f59acc}</Project>
<Private>True</Private>
<DoNotHarvest>True</DoNotHarvest>
<RefProjectOutputGroups>Binaries;Content;Satellites</RefProjectOutputGroups>
<RefTargetDir>INSTALLFOLDER</RefTargetDir>
</ProjectReference>
<ProjectReference Include="..\GpInputDriver_XInput\GpInputDriver_XInput.vcxproj">
<Name>GpInputDriver_XInput</Name>
<Project>{17b96f07-ef92-47cd-95a5-8e6ee38ab564}</Project>
<Private>True</Private>
<DoNotHarvest>True</DoNotHarvest>
<RefProjectOutputGroups>Binaries;Content;Satellites</RefProjectOutputGroups>
<RefTargetDir>INSTALLFOLDER</RefTargetDir>
</ProjectReference>
<ProjectReference Include="..\gpr2gpa\gpr2gpa.vcxproj">
<Name>gpr2gpa</Name>
<Project>{27b7ca46-ed23-45c2-bf5f-0c126d81aebf}</Project>
<Private>True</Private>
<DoNotHarvest>True</DoNotHarvest>
<RefProjectOutputGroups>Binaries;Content;Satellites</RefProjectOutputGroups>
<RefTargetDir>INSTALLFOLDER</RefTargetDir>
</ProjectReference>
<ProjectReference Include="..\hqx2bin\hqx2bin.vcxproj">
<Name>hqx2bin</Name>
<Project>{45b1b18c-c846-4044-9206-74f58dfc5e88}</Project>
<Private>True</Private>
<DoNotHarvest>True</DoNotHarvest>
<RefProjectOutputGroups>Binaries;Content;Satellites</RefProjectOutputGroups>
<RefTargetDir>INSTALLFOLDER</RefTargetDir>
</ProjectReference>
<ProjectReference Include="..\hqx2gp\hqx2gp.vcxproj">
<Name>hqx2gp</Name>
<Project>{5fde4822-c771-46a5-b6b2-fd12bace86bf}</Project>
<Private>True</Private>
<DoNotHarvest>True</DoNotHarvest>
<RefProjectOutputGroups>Binaries;Content;Satellites</RefProjectOutputGroups>
<RefTargetDir>INSTALLFOLDER</RefTargetDir>
</ProjectReference>
<ProjectReference Include="..\MakeTimestamp\MakeTimestamp.vcxproj">
<Name>MakeTimestamp</Name>
<Project>{9023df2f-a33d-485a-b13d-0973348b2f9b}</Project>
<Private>True</Private>
<DoNotHarvest>True</DoNotHarvest>
<RefProjectOutputGroups>Binaries;Content;Satellites</RefProjectOutputGroups>
<RefTargetDir>INSTALLFOLDER</RefTargetDir>
</ProjectReference>
<ProjectReference Include="..\unpacktool\unpacktool.vcxproj">
<Name>unpacktool</Name>
<Project>{a778d062-de76-49f6-8d05-eb26852dd605}</Project>
<Private>True</Private>
<DoNotHarvest>True</DoNotHarvest>
<RefProjectOutputGroups>Binaries;Content;Satellites</RefProjectOutputGroups>
<RefTargetDir>INSTALLFOLDER</RefTargetDir>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<WixExtension Include="WixUtilExtension">
<HintPath>$(WixExtDir)\WixUtilExtension.dll</HintPath>
<Name>WixUtilExtension</Name>
</WixExtension>
<WixExtension Include="WixUIExtension">
<HintPath>$(WixExtDir)\WixUIExtension.dll</HintPath>
<Name>WixUIExtension</Name>
</WixExtension>
</ItemGroup>
<Import Project="$(WixTargetsPath)" Condition=" '$(WixTargetsPath)' != '' " />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets" Condition=" '$(WixTargetsPath)' == '' AND Exists('$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets') " />
<Target Name="EnsureWixToolsetInstalled" Condition=" '$(WixTargetsImported)' != 'true' ">
<Error Text="The WiX Toolset v3.11 (or newer) build tools must be installed to build this project. To download the WiX Toolset, see http://wixtoolset.org/releases/" />
</Target>
<PropertyGroup>
<PreBuildEvent />
</PropertyGroup>
<PropertyGroup>
<DefineConstants>
ResourcesDataDir=$(SolutionDir)\Resources;
DocumentationDataDir=$(SolutionDir)\Documentation;
WinCursorsDataDir=$(SolutionDir)\Packaged\WinCursors;
HousesDataDir=$(SolutionDir)\Packaged\Houses;
PackagedDataDir=$(SolutionDir)\Packaged;
</DefineConstants>
</PropertyGroup>
<Target Name="BeforeBuild">
<ItemGroup>
<HarvestDirectory Include="$(SolutionDir)\Packaged\WinCursors">
<DirectoryRefId>AEROFOILWINCURSORSDIR</DirectoryRefId>
<SuppressRootDirectory>true</SuppressRootDirectory>
<SuppressCom>true</SuppressCom>
<SuppressRegistry>true</SuppressRegistry>
<ComponentGroupName>WinCursorsComponentGroup</ComponentGroupName>
<AutogenerateGuids>true</AutogenerateGuids>
<PreprocessorVariable>var.WinCursorsDataDir</PreprocessorVariable>
</HarvestDirectory>
<HarvestDirectory Include="$(SolutionDir)\Resources">
<DirectoryRefId>AEROFOILRESOURCESDIR</DirectoryRefId>
<SuppressRootDirectory>true</SuppressRootDirectory>
<SuppressCom>true</SuppressCom>
<SuppressRegistry>true</SuppressRegistry>
<ComponentGroupName>ResourcesComponentGroup</ComponentGroupName>
<AutogenerateGuids>true</AutogenerateGuids>
<PreprocessorVariable>var.ResourcesDataDir</PreprocessorVariable>
</HarvestDirectory>
<HarvestDirectory Include="$(SolutionDir)\InstallerPackages\DefaultHouses">
<DirectoryRefId>AEROFOILHOUSESDIR</DirectoryRefId>
<SuppressRootDirectory>true</SuppressRootDirectory>
<SuppressCom>true</SuppressCom>
<SuppressRegistry>true</SuppressRegistry>
<ComponentGroupName>DefaultHousesComponentGroup</ComponentGroupName>
<AutogenerateGuids>true</AutogenerateGuids>
<PreprocessorVariable>var.HousesDataDir</PreprocessorVariable>
</HarvestDirectory>
<HarvestDirectory Include="$(SolutionDir)\InstallerPackages\HousePack1">
<DirectoryRefId>AEROFOILHOUSESDIR</DirectoryRefId>
<SuppressRootDirectory>true</SuppressRootDirectory>
<SuppressCom>true</SuppressCom>
<SuppressRegistry>true</SuppressRegistry>
<ComponentGroupName>HousePack1ComponentGroup</ComponentGroupName>
<AutogenerateGuids>true</AutogenerateGuids>
<PreprocessorVariable>var.HousesDataDir</PreprocessorVariable>
</HarvestDirectory>
<HarvestDirectory Include="$(SolutionDir)\InstallerPackages\LooseDocumentation">
<DirectoryRefId>AEROFOILDOCUMENTATIONDIR</DirectoryRefId>
<SuppressRootDirectory>true</SuppressRootDirectory>
<SuppressCom>true</SuppressCom>
<SuppressRegistry>true</SuppressRegistry>
<ComponentGroupName>LooseDocumentationComponentGroup</ComponentGroupName>
<AutogenerateGuids>true</AutogenerateGuids>
<PreprocessorVariable>var.DocumentationDataDir</PreprocessorVariable>
</HarvestDirectory>
</ItemGroup>
</Target>
<!--
To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Wix.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -9,14 +9,16 @@ struct SDrawQuadPixelOutput
float4 color : SV_TARGET;
};
float3 SamplePixel(int2 texCoord)
{
uint surfaceColor = surfaceTexture.Load(int3(texCoord, 0)).r;
return paletteTexture.Load(int2(surfaceColor, 0)).rgb;
}
SDrawQuadPixelOutput PSMain(SDrawQuadPixelInput input)
{
int2 texCoord = input.texCoord.xy;
uint surfaceColor = surfaceTexture.Load(int3(texCoord, 0)).r;
float3 paletteColor = paletteTexture.Load(int2(surfaceColor, 0)).rgb;
SDrawQuadPixelOutput result;
result.color = float4(paletteColor.rgb, 1.0);
result.color = float4(SamplePixel(int2(floor(input.texCoord.xy))), 1.0);
return result;
}

View File

@@ -1,7 +1,7 @@
#include "DrawQuad.h"
SamplerState surfaceSampler : register(s0);
Texture2D<float> surfaceTexture : register(t0);
Texture2D<float3> surfaceTexture : register(t0);
struct SDrawQuadPixelOutput
{
@@ -10,9 +10,9 @@ struct SDrawQuadPixelOutput
SDrawQuadPixelOutput PSMain(SDrawQuadPixelInput input)
{
float surfaceColor = surfaceTexture.Sample(surfaceSampler, input.texCoord.xy).r;
float3 surfaceColor = surfaceTexture.Load(int3(input.texCoord.xy, 0)).rgb;
SDrawQuadPixelOutput result;
result.color = float4(surfaceColor, input.texCoord.x, input.texCoord.y, 1.0);
result.color = float4(surfaceColor, 1.0);
return result;
}

47
ShaderSrc/ScaleQuadP.hlsl Normal file
View File

@@ -0,0 +1,47 @@
#include "DrawQuad.h"
SamplerState surfaceSampler : register(s0);
Texture2D<float3> surfaceTexture : register(t0);
cbuffer SScaleQuadPixelConstants : register(b0)
{
float4 dxdy_Unused;
};
struct SDrawQuadPixelOutput
{
float4 color : SV_TARGET;
};
float3 SamplePixel(int2 coord)
{
return surfaceTexture.Load(int3(coord, 0)).rgb;
}
SDrawQuadPixelOutput PSMain(SDrawQuadPixelInput input)
{
float dx = dxdy_Unused.x;
float dy = dxdy_Unused.y;
float2 pixelTopLeftCoord = max(0.0, input.texCoord.xy - float2(dx, dy) * 0.5);
float2 pixelBottomRightCoord = pixelTopLeftCoord + min(float2(1.0, 1.0), float2(dx, dy));
int2 topLeftCoordInteger = int2(floor(pixelTopLeftCoord));
int2 bottomRightCoordInteger = int2(floor(pixelBottomRightCoord));
float2 interpolators = saturate((pixelBottomRightCoord - float2(bottomRightCoordInteger)) / float2(dx, dy));
float3 topLeftColor = SamplePixel(topLeftCoordInteger);
float3 topRightColor = SamplePixel(int2(bottomRightCoordInteger.x, topLeftCoordInteger.y));
float3 bottomLeftColor = SamplePixel(int2(topLeftCoordInteger.x, bottomRightCoordInteger.y));
float3 bottomRightColor = SamplePixel(bottomRightCoordInteger);
float3 topColor = (1.0 - interpolators.x) * topLeftColor + interpolators.x * topRightColor;
float3 bottomColor = (1.0 - interpolators.x) * bottomLeftColor + interpolators.x * bottomRightColor;
float3 interpolatedColor = (1.0 - interpolators.y) * topColor + interpolators.y * bottomColor;
SDrawQuadPixelOutput result;
result.color = float4(interpolatedColor, 1.0);
return result;
}

View File

@@ -1,4 +1,3 @@
#define _CRT_SECURE_NO_WARNINGS
#include "MacBinary2.h"
#include "MacFileMem.h"
#include "CFileStream.h"
@@ -8,24 +7,56 @@
#include <stdio.h>
uint8_t *ReadEntireFile(const char *path, uint32_t &szOut)
{
FILE *f = fopen(path, "rb");
if (!f)
{
fprintf(stderr, "Could not open input file '%s'", path);
return nullptr;
}
PortabilityLayer::CFileStream stream(f, true, false, true);
PortabilityLayer::UFilePos_t sz = stream.Size();
uint8_t *buffer = new uint8_t[sz];
stream.Read(buffer, sz);
stream.Close();
szOut = static_cast<uint32_t>(sz);
return buffer;
}
int main(int argc, const char **argv)
{
if (argc != 3)
if (argc != 4)
{
fprintf(stderr, "Usage: flattenmov <input.bin> <output.mov>");
fprintf(stderr, "Usage: flattenmov <input.gpd> <input.gpr> <output.mov>");
return -1;
}
FILE *f = fopen(argv[1], "rb");
PortabilityLayer::CFileStream inStream(f, true, false, true);
uint32_t dataSize, resSize;
uint8_t *dataFork = ReadEntireFile(argv[1], dataSize);
uint8_t *resFork = ReadEntireFile(argv[2], resSize);
PortabilityLayer::MacFileMem *memFile = PortabilityLayer::MacBinary2::ReadBin(&inStream);
inStream.Close();
if (!dataFork || !resFork)
return -1;
const uint8_t *dataBytes = memFile->DataFork();
PortabilityLayer::MacFileInfo mfi;
mfi.m_dataForkSize = dataSize;
mfi.m_resourceForkSize = resSize;
mfi.m_commentSize = 0;
PortabilityLayer::MacFileMem memFile(dataFork, resFork, nullptr, mfi);
delete[] dataFork;
delete[] resFork;
const uint8_t *dataBytes = memFile.DataFork();
if (dataBytes[0] == 0 && dataBytes[1] == 0 && dataBytes[2] == 0 && dataBytes[3] == 0)
{
uint32_t mdatSize = memFile->FileInfo().m_dataForkSize;
uint32_t mdatSize = memFile.FileInfo().m_dataForkSize;
uint8_t mdatSizeEncoded[4];
mdatSizeEncoded[0] = ((mdatSize >> 24) & 0xff);
mdatSizeEncoded[1] = ((mdatSize >> 16) & 0xff);
@@ -34,7 +65,7 @@ int main(int argc, const char **argv)
PortabilityLayer::ResourceFile *rf = PortabilityLayer::ResourceFile::Create();
PortabilityLayer::MemReaderStream resStream(memFile->ResourceFork(), memFile->FileInfo().m_resourceForkSize);
PortabilityLayer::MemReaderStream resStream(memFile.ResourceFork(), memFile.FileInfo().m_resourceForkSize);
rf->Load(&resStream);
const PortabilityLayer::ResourceCompiledTypeList *typeList = rf->GetResourceTypeList(PortabilityLayer::ResTypeID('moov'));
@@ -48,7 +79,12 @@ int main(int argc, const char **argv)
break;
}
FILE *outF = fopen(argv[2], "wb");
FILE *outF = fopen(argv[3], "wb");
if (!outF)
{
fprintf(stderr, "Could not open output file '%s'", argv[3]);
return -1;
}
fwrite(mdatSizeEncoded, 1, 4, outF);
fwrite(dataBytes + 4, 1, mdatSize - 4, outF);
@@ -59,8 +95,14 @@ int main(int argc, const char **argv)
}
else
{
FILE *outF = fopen(argv[2], "wb");
fwrite(dataBytes, 1, memFile->FileInfo().m_dataForkSize, outF);
FILE *outF = fopen(argv[3], "wb");
if (!outF)
{
fprintf(stderr, "Could not open output file '%s'", argv[3]);
return -1;
}
fwrite(dataBytes, 1, memFile.FileInfo().m_dataForkSize, outF);
fclose(outF);
}

View File

@@ -1,5 +1,3 @@
#define _CRT_SECURE_NO_WARNINGS
#include "BMPFormat.h"
#include "CFileStream.h"
#include "CombinedTimestamp.h"

View File

@@ -0,0 +1,62 @@
#include "ArchiveDescription.h"
ArchiveCompressedChunkDesc::ArchiveCompressedChunkDesc()
: m_filePosition(0)
, m_uncompressedSize(0)
, m_compressedSize(0)
, m_compressionMethod(CompressionMethods::kUnknown)
{
}
ArchiveItem::ArchiveItem()
: m_isDirectory(false)
, m_children(nullptr)
{
}
ArchiveItem::ArchiveItem(ArchiveItem &&other)
: m_isDirectory(other.m_isDirectory)
, m_fileNameUTF8(other.m_fileNameUTF8)
, m_macProperties(other.m_macProperties)
, m_dataForkDesc(other.m_dataForkDesc)
, m_resourceForkDesc(other.m_resourceForkDesc)
, m_commentDesc(other.m_commentDesc)
, m_children(other.m_children)
{
other.m_children = nullptr;
}
ArchiveItem::ArchiveItem(const ArchiveItem &other)
: m_isDirectory(other.m_isDirectory)
, m_fileNameUTF8(other.m_fileNameUTF8)
, m_macProperties(other.m_macProperties)
, m_dataForkDesc(other.m_dataForkDesc)
, m_resourceForkDesc(other.m_resourceForkDesc)
, m_commentDesc(other.m_commentDesc)
, m_children(other.m_children ? (new ArchiveItemList(*(other.m_children))) : nullptr)
{
}
ArchiveItem::~ArchiveItem()
{
if (m_children)
delete m_children;
}
ArchiveItemList::ArchiveItemList()
{
}
ArchiveItemList::ArchiveItemList(ArchiveItemList &&other)
: m_items(std::move(other.m_items))
{
}
ArchiveItemList::ArchiveItemList(const ArchiveItemList &other)
: m_items(other.m_items)
{
}
ArchiveItemList::~ArchiveItemList()
{
}

View File

@@ -0,0 +1,71 @@
#pragma once
#include "MacFileInfo.h"
#include <vector>
#include <stdint.h>
namespace CompressionMethods
{
enum CompressionMethod
{
kNone,
kUnknown,
kStuffItRLE90,
kStuffItLZW,
kStuffItHuffman,
kStuffItLZAH,
kStuffItFixedHuffman,
kStuffItMW,
kStuffIt13,
kStuffIt14,
kStuffItArsenic,
kCompactProRLE,
kCompactProLZHRLE,
};
}
typedef CompressionMethods::CompressionMethod CompressionMethod_t;
struct ArchiveItemList;
struct ArchiveCompressedChunkDesc
{
ArchiveCompressedChunkDesc();
uint64_t m_filePosition;
size_t m_uncompressedSize;
size_t m_compressedSize;
CompressionMethod_t m_compressionMethod;
};
struct ArchiveItem
{
ArchiveItem();
ArchiveItem(ArchiveItem &&other);
ArchiveItem(const ArchiveItem &other);
~ArchiveItem();
bool m_isDirectory;
std::vector<uint8_t> m_fileNameUTF8;
PortabilityLayer::MacFileProperties m_macProperties;
ArchiveCompressedChunkDesc m_dataForkDesc;
ArchiveCompressedChunkDesc m_resourceForkDesc;
ArchiveCompressedChunkDesc m_commentDesc;
ArchiveItemList *m_children;
};
struct ArchiveItemList
{
public:
ArchiveItemList();
ArchiveItemList(ArchiveItemList &&other);
ArchiveItemList(const ArchiveItemList &other);
~ArchiveItemList();
std::vector<ArchiveItem> m_items;
};

218
unpacktool/BWT.cpp Normal file
View File

@@ -0,0 +1,218 @@
#include "BWT.h"
#include <stdlib.h>
#include <string.h>
// Inverse BWT
void CalculateInverseBWT(uint32_t *transform,uint8_t *block,int blocklen)
{
int counts[256]={0},cumulativecounts[256];
for(int i=0;i<blocklen;i++) counts[block[i]]++;
int total=0;
for(int i=0;i<256;i++)
{
cumulativecounts[i]=total;
total+=counts[i];
counts[i]=0;
}
for(int i=0;i<blocklen;i++)
{
transform[cumulativecounts[block[i]]+counts[block[i]]]=i;
counts[block[i]]++;
}
}
void UnsortBWT(uint8_t *dest,uint8_t *src,int blocklen,int firstindex,uint32_t *transform)
{
CalculateInverseBWT(transform,src,blocklen);
int transformindex=firstindex;
for(int i=0;i<blocklen;i++)
{
transformindex=transform[transformindex];
dest[i]=src[transformindex];
}
}
void UnsortST4(uint8_t *dest,uint8_t *src,int blocklen,int firstindex,uint32_t *transform)
{
int counts[256];
for(int i=0;i<256;i++) counts[i]=0;
int *array2=static_cast<int*>(calloc(sizeof(int),256*256));
for(int i=0;i<blocklen;i++) counts[src[i]]++;
int total=0;
for(int i=0;i<256;i++)
{
int count=counts[i];
counts[i]=total;
for(int j=0;j<count;j++) array2[(src[total+j]<<8)|i]++;
total+=count;
}
uint8_t *bitvec=dest;
memset(bitvec,0,(blocklen+7)/8);
int array3[256];
for(int i=0;i<256;i++) array3[i]=-1;
uint32_t counts2[256];
memcpy(counts2,counts,sizeof(counts));
total=0;
for(int i=0;i<0x10000;i++)
{
int count=array2[i];
for(int j=0;j<count;j++)
{
int byte=src[total+j];
if(array3[byte]!=total)
{
array3[byte]=total;
int x=counts[byte];
bitvec[x>>3]|=1<<(x&7);
}
counts[byte]++;
}
total+=count;
}
for(int i=0;i<256;i++) array3[i]=0;
int index=0;
for(int i=0;i<blocklen;i++)
{
if(bitvec[i/8]&(1<<(i&7))) index=i;
int byte=src[i];
if(index<array3[byte])
{
transform[i]=(array3[byte]-1)|0x800000;
}
else
{
transform[i]=counts2[byte];
array3[byte]=i+1;
}
counts2[byte]++;
transform[i]|=byte<<24;
}
index=firstindex;
uint32_t tval=transform[firstindex];
for(int i=0;i<blocklen;i++)
{
if(tval&0x800000)
{
index=transform[tval&0x7fffff]&0x7fffff;
transform[tval&0x7fffff]++;
}
else
{
transform[index]++;
index=tval&0x7fffff;
}
tval=transform[index];
dest[i]=tval>>24;
}
free(array2);
}
/*void UnsortBWTStuffItX(uint8_t *dest,int blocklen,int firstindex,uint8_t *src,uint32_t *transform)
{
int counts[256]={0};
for(int i=0;i<blocklen;i++)
{
transform[i]=counts[src[i]];
counts[src[i]]++;
}
int total=0;
for(int i=0;i<256;i++)
{
int oldtotal=total;
total+=counts[i];
counts[i]=oldtotal;
}
int index=firstindex;
for(int i=blocklen-1;i>=0;i--)
{
dest[i]=src[index];
index=transform[index]+counts[src[index]];
}
}*/
// MTF Decoder
void ResetMTFDecoder(MTFState *self)
{
for(int i=0;i<256;i++) self->table[i]=i;
}
int DecodeMTF(MTFState *self,int symbol)
{
int res=self->table[symbol];
for(int i=symbol;i>0;i--) self->table[i]=self->table[i-1];
self->table[0]=res;
return res;
}
void DecodeMTFBlock(uint8_t *block,int blocklen)
{
MTFState mtf;
ResetMTFDecoder(&mtf);
for(int i=0;i<blocklen;i++) block[i]=DecodeMTF(&mtf,block[i]);
}
void DecodeM1FFNBlock(uint8_t *block,int blocklen,int order)
{
MTFState mtf;
ResetMTFDecoder(&mtf);
int lasthead=order-1;
for(int i=0;i<blocklen;i++)
{
int symbol=block[i];
block[i]=mtf.table[symbol];
if(symbol==0)
{
lasthead=0;
}
else if(symbol==1)
{
if(lasthead>=order)
{
int val=mtf.table[1];
mtf.table[1]=mtf.table[0];
mtf.table[0]=val;
}
}
else
{
int val=mtf.table[symbol];
for(int i=symbol;i>1;i--) mtf.table[i]=mtf.table[i-1];
mtf.table[1]=val;
}
lasthead++;
}
}

21
unpacktool/BWT.h Normal file
View File

@@ -0,0 +1,21 @@
#ifndef __BWT_H__
#define __BWT_H__
#include <stdint.h>
void CalculateInverseBWT(uint32_t *transform, uint8_t *block, int blocklen);
void UnsortBWT(uint8_t *dest, uint8_t *src, int blocklen, int firstindex, uint32_t *transformbuf);
void UnsortST4(uint8_t *dest, uint8_t *src, int blocklen, int firstindex, uint32_t *transformbuf);
typedef struct MTFState
{
int table[256];
} MTFState;
void ResetMTFDecoder(MTFState *self);
int DecodeMTF(MTFState *self, int symbol);
void DecodeMTFBlock(uint8_t *block, int blocklen);
void DecodeM1FFNBlock(uint8_t *block, int blocklen, int order);
#endif

208
unpacktool/CRC.cpp Normal file
View File

@@ -0,0 +1,208 @@
#include "CRC.h"
uint32_t XADCRC(uint32_t prevcrc, uint8_t byte, const uint32_t *table)
{
return table[(prevcrc^byte) & 0xff] ^ (prevcrc >> 8);
}
uint32_t XADCalculateCRC(uint32_t prevcrc, const uint8_t *buffer, int length, const uint32_t *table)
{
uint32_t crc = prevcrc;
for (int i = 0; i < length; i++) crc = XADCRC(crc, buffer[i], table);
return crc;
}
uint64_t XADCRC64(uint64_t prevcrc, uint8_t byte, const uint64_t *table)
{
return table[(prevcrc^byte) & 0xff] ^ (prevcrc >> 8);
}
uint64_t XADCalculateCRC64(uint64_t prevcrc, const uint8_t *buffer, int length, const uint64_t *table)
{
uint64_t crc = prevcrc;
for (int i = 0; i < length; i++) crc = XADCRC64(crc, buffer[i], table);
return crc;
}
int XADUnReverseCRC16(int val)
{
val = ((val >> 8) & 0x00FF) | ((val & 0x00FF) << 8);
return val;
}
const uint32_t XADCRCTable_a001[256] =
{
0x00000000,0x0000c0c1,0x0000c181,0x00000140,0x0000c301,0x000003c0,0x00000280,0x0000c241,
0x0000c601,0x000006c0,0x00000780,0x0000c741,0x00000500,0x0000c5c1,0x0000c481,0x00000440,
0x0000cc01,0x00000cc0,0x00000d80,0x0000cd41,0x00000f00,0x0000cfc1,0x0000ce81,0x00000e40,
0x00000a00,0x0000cac1,0x0000cb81,0x00000b40,0x0000c901,0x000009c0,0x00000880,0x0000c841,
0x0000d801,0x000018c0,0x00001980,0x0000d941,0x00001b00,0x0000dbc1,0x0000da81,0x00001a40,
0x00001e00,0x0000dec1,0x0000df81,0x00001f40,0x0000dd01,0x00001dc0,0x00001c80,0x0000dc41,
0x00001400,0x0000d4c1,0x0000d581,0x00001540,0x0000d701,0x000017c0,0x00001680,0x0000d641,
0x0000d201,0x000012c0,0x00001380,0x0000d341,0x00001100,0x0000d1c1,0x0000d081,0x00001040,
0x0000f001,0x000030c0,0x00003180,0x0000f141,0x00003300,0x0000f3c1,0x0000f281,0x00003240,
0x00003600,0x0000f6c1,0x0000f781,0x00003740,0x0000f501,0x000035c0,0x00003480,0x0000f441,
0x00003c00,0x0000fcc1,0x0000fd81,0x00003d40,0x0000ff01,0x00003fc0,0x00003e80,0x0000fe41,
0x0000fa01,0x00003ac0,0x00003b80,0x0000fb41,0x00003900,0x0000f9c1,0x0000f881,0x00003840,
0x00002800,0x0000e8c1,0x0000e981,0x00002940,0x0000eb01,0x00002bc0,0x00002a80,0x0000ea41,
0x0000ee01,0x00002ec0,0x00002f80,0x0000ef41,0x00002d00,0x0000edc1,0x0000ec81,0x00002c40,
0x0000e401,0x000024c0,0x00002580,0x0000e541,0x00002700,0x0000e7c1,0x0000e681,0x00002640,
0x00002200,0x0000e2c1,0x0000e381,0x00002340,0x0000e101,0x000021c0,0x00002080,0x0000e041,
0x0000a001,0x000060c0,0x00006180,0x0000a141,0x00006300,0x0000a3c1,0x0000a281,0x00006240,
0x00006600,0x0000a6c1,0x0000a781,0x00006740,0x0000a501,0x000065c0,0x00006480,0x0000a441,
0x00006c00,0x0000acc1,0x0000ad81,0x00006d40,0x0000af01,0x00006fc0,0x00006e80,0x0000ae41,
0x0000aa01,0x00006ac0,0x00006b80,0x0000ab41,0x00006900,0x0000a9c1,0x0000a881,0x00006840,
0x00007800,0x0000b8c1,0x0000b981,0x00007940,0x0000bb01,0x00007bc0,0x00007a80,0x0000ba41,
0x0000be01,0x00007ec0,0x00007f80,0x0000bf41,0x00007d00,0x0000bdc1,0x0000bc81,0x00007c40,
0x0000b401,0x000074c0,0x00007580,0x0000b541,0x00007700,0x0000b7c1,0x0000b681,0x00007640,
0x00007200,0x0000b2c1,0x0000b381,0x00007340,0x0000b101,0x000071c0,0x00007080,0x0000b041,
0x00005000,0x000090c1,0x00009181,0x00005140,0x00009301,0x000053c0,0x00005280,0x00009241,
0x00009601,0x000056c0,0x00005780,0x00009741,0x00005500,0x000095c1,0x00009481,0x00005440,
0x00009c01,0x00005cc0,0x00005d80,0x00009d41,0x00005f00,0x00009fc1,0x00009e81,0x00005e40,
0x00005a00,0x00009ac1,0x00009b81,0x00005b40,0x00009901,0x000059c0,0x00005880,0x00009841,
0x00008801,0x000048c0,0x00004980,0x00008941,0x00004b00,0x00008bc1,0x00008a81,0x00004a40,
0x00004e00,0x00008ec1,0x00008f81,0x00004f40,0x00008d01,0x00004dc0,0x00004c80,0x00008c41,
0x00004400,0x000084c1,0x00008581,0x00004540,0x00008701,0x000047c0,0x00004680,0x00008641,
0x00008201,0x000042c0,0x00004380,0x00008341,0x00004100,0x000081c1,0x00008081,0x00004040,
};
const uint32_t XADCRCReverseTable_1021[256] =
{
0x00000000,0x00002110,0x00004220,0x00006330,0x00008440,0x0000a550,0x0000c660,0x0000e770,
0x00000881,0x00002991,0x00004aa1,0x00006bb1,0x00008cc1,0x0000add1,0x0000cee1,0x0000eff1,
0x00003112,0x00001002,0x00007332,0x00005222,0x0000b552,0x00009442,0x0000f772,0x0000d662,
0x00003993,0x00001883,0x00007bb3,0x00005aa3,0x0000bdd3,0x00009cc3,0x0000fff3,0x0000dee3,
0x00006224,0x00004334,0x00002004,0x00000114,0x0000e664,0x0000c774,0x0000a444,0x00008554,
0x00006aa5,0x00004bb5,0x00002885,0x00000995,0x0000eee5,0x0000cff5,0x0000acc5,0x00008dd5,
0x00005336,0x00007226,0x00001116,0x00003006,0x0000d776,0x0000f666,0x00009556,0x0000b446,
0x00005bb7,0x00007aa7,0x00001997,0x00003887,0x0000dff7,0x0000fee7,0x00009dd7,0x0000bcc7,
0x0000c448,0x0000e558,0x00008668,0x0000a778,0x00004008,0x00006118,0x00000228,0x00002338,
0x0000ccc9,0x0000edd9,0x00008ee9,0x0000aff9,0x00004889,0x00006999,0x00000aa9,0x00002bb9,
0x0000f55a,0x0000d44a,0x0000b77a,0x0000966a,0x0000711a,0x0000500a,0x0000333a,0x0000122a,
0x0000fddb,0x0000dccb,0x0000bffb,0x00009eeb,0x0000799b,0x0000588b,0x00003bbb,0x00001aab,
0x0000a66c,0x0000877c,0x0000e44c,0x0000c55c,0x0000222c,0x0000033c,0x0000600c,0x0000411c,
0x0000aeed,0x00008ffd,0x0000eccd,0x0000cddd,0x00002aad,0x00000bbd,0x0000688d,0x0000499d,
0x0000977e,0x0000b66e,0x0000d55e,0x0000f44e,0x0000133e,0x0000322e,0x0000511e,0x0000700e,
0x00009fff,0x0000beef,0x0000dddf,0x0000fccf,0x00001bbf,0x00003aaf,0x0000599f,0x0000788f,
0x00008891,0x0000a981,0x0000cab1,0x0000eba1,0x00000cd1,0x00002dc1,0x00004ef1,0x00006fe1,
0x00008010,0x0000a100,0x0000c230,0x0000e320,0x00000450,0x00002540,0x00004670,0x00006760,
0x0000b983,0x00009893,0x0000fba3,0x0000dab3,0x00003dc3,0x00001cd3,0x00007fe3,0x00005ef3,
0x0000b102,0x00009012,0x0000f322,0x0000d232,0x00003542,0x00001452,0x00007762,0x00005672,
0x0000eab5,0x0000cba5,0x0000a895,0x00008985,0x00006ef5,0x00004fe5,0x00002cd5,0x00000dc5,
0x0000e234,0x0000c324,0x0000a014,0x00008104,0x00006674,0x00004764,0x00002454,0x00000544,
0x0000dba7,0x0000fab7,0x00009987,0x0000b897,0x00005fe7,0x00007ef7,0x00001dc7,0x00003cd7,
0x0000d326,0x0000f236,0x00009106,0x0000b016,0x00005766,0x00007676,0x00001546,0x00003456,
0x00004cd9,0x00006dc9,0x00000ef9,0x00002fe9,0x0000c899,0x0000e989,0x00008ab9,0x0000aba9,
0x00004458,0x00006548,0x00000678,0x00002768,0x0000c018,0x0000e108,0x00008238,0x0000a328,
0x00007dcb,0x00005cdb,0x00003feb,0x00001efb,0x0000f98b,0x0000d89b,0x0000bbab,0x00009abb,
0x0000754a,0x0000545a,0x0000376a,0x0000167a,0x0000f10a,0x0000d01a,0x0000b32a,0x0000923a,
0x00002efd,0x00000fed,0x00006cdd,0x00004dcd,0x0000aabd,0x00008bad,0x0000e89d,0x0000c98d,
0x0000267c,0x0000076c,0x0000645c,0x0000454c,0x0000a23c,0x0000832c,0x0000e01c,0x0000c10c,
0x00001fef,0x00003eff,0x00005dcf,0x00007cdf,0x00009baf,0x0000babf,0x0000d98f,0x0000f89f,
0x0000176e,0x0000367e,0x0000554e,0x0000745e,0x0000932e,0x0000b23e,0x0000d10e,0x0000f01e,
};
const uint32_t XADCRCTable_edb88320[256] =
{
0x00000000,0x77073096,0xee0e612c,0x990951ba,0x076dc419,0x706af48f,0xe963a535,0x9e6495a3,
0x0edb8832,0x79dcb8a4,0xe0d5e91e,0x97d2d988,0x09b64c2b,0x7eb17cbd,0xe7b82d07,0x90bf1d91,
0x1db71064,0x6ab020f2,0xf3b97148,0x84be41de,0x1adad47d,0x6ddde4eb,0xf4d4b551,0x83d385c7,
0x136c9856,0x646ba8c0,0xfd62f97a,0x8a65c9ec,0x14015c4f,0x63066cd9,0xfa0f3d63,0x8d080df5,
0x3b6e20c8,0x4c69105e,0xd56041e4,0xa2677172,0x3c03e4d1,0x4b04d447,0xd20d85fd,0xa50ab56b,
0x35b5a8fa,0x42b2986c,0xdbbbc9d6,0xacbcf940,0x32d86ce3,0x45df5c75,0xdcd60dcf,0xabd13d59,
0x26d930ac,0x51de003a,0xc8d75180,0xbfd06116,0x21b4f4b5,0x56b3c423,0xcfba9599,0xb8bda50f,
0x2802b89e,0x5f058808,0xc60cd9b2,0xb10be924,0x2f6f7c87,0x58684c11,0xc1611dab,0xb6662d3d,
0x76dc4190,0x01db7106,0x98d220bc,0xefd5102a,0x71b18589,0x06b6b51f,0x9fbfe4a5,0xe8b8d433,
0x7807c9a2,0x0f00f934,0x9609a88e,0xe10e9818,0x7f6a0dbb,0x086d3d2d,0x91646c97,0xe6635c01,
0x6b6b51f4,0x1c6c6162,0x856530d8,0xf262004e,0x6c0695ed,0x1b01a57b,0x8208f4c1,0xf50fc457,
0x65b0d9c6,0x12b7e950,0x8bbeb8ea,0xfcb9887c,0x62dd1ddf,0x15da2d49,0x8cd37cf3,0xfbd44c65,
0x4db26158,0x3ab551ce,0xa3bc0074,0xd4bb30e2,0x4adfa541,0x3dd895d7,0xa4d1c46d,0xd3d6f4fb,
0x4369e96a,0x346ed9fc,0xad678846,0xda60b8d0,0x44042d73,0x33031de5,0xaa0a4c5f,0xdd0d7cc9,
0x5005713c,0x270241aa,0xbe0b1010,0xc90c2086,0x5768b525,0x206f85b3,0xb966d409,0xce61e49f,
0x5edef90e,0x29d9c998,0xb0d09822,0xc7d7a8b4,0x59b33d17,0x2eb40d81,0xb7bd5c3b,0xc0ba6cad,
0xedb88320,0x9abfb3b6,0x03b6e20c,0x74b1d29a,0xead54739,0x9dd277af,0x04db2615,0x73dc1683,
0xe3630b12,0x94643b84,0x0d6d6a3e,0x7a6a5aa8,0xe40ecf0b,0x9309ff9d,0x0a00ae27,0x7d079eb1,
0xf00f9344,0x8708a3d2,0x1e01f268,0x6906c2fe,0xf762575d,0x806567cb,0x196c3671,0x6e6b06e7,
0xfed41b76,0x89d32be0,0x10da7a5a,0x67dd4acc,0xf9b9df6f,0x8ebeeff9,0x17b7be43,0x60b08ed5,
0xd6d6a3e8,0xa1d1937e,0x38d8c2c4,0x4fdff252,0xd1bb67f1,0xa6bc5767,0x3fb506dd,0x48b2364b,
0xd80d2bda,0xaf0a1b4c,0x36034af6,0x41047a60,0xdf60efc3,0xa867df55,0x316e8eef,0x4669be79,
0xcb61b38c,0xbc66831a,0x256fd2a0,0x5268e236,0xcc0c7795,0xbb0b4703,0x220216b9,0x5505262f,
0xc5ba3bbe,0xb2bd0b28,0x2bb45a92,0x5cb36a04,0xc2d7ffa7,0xb5d0cf31,0x2cd99e8b,0x5bdeae1d,
0x9b64c2b0,0xec63f226,0x756aa39c,0x026d930a,0x9c0906a9,0xeb0e363f,0x72076785,0x05005713,
0x95bf4a82,0xe2b87a14,0x7bb12bae,0x0cb61b38,0x92d28e9b,0xe5d5be0d,0x7cdcefb7,0x0bdbdf21,
0x86d3d2d4,0xf1d4e242,0x68ddb3f8,0x1fda836e,0x81be16cd,0xf6b9265b,0x6fb077e1,0x18b74777,
0x88085ae6,0xff0f6a70,0x66063bca,0x11010b5c,0x8f659eff,0xf862ae69,0x616bffd3,0x166ccf45,
0xa00ae278,0xd70dd2ee,0x4e048354,0x3903b3c2,0xa7672661,0xd06016f7,0x4969474d,0x3e6e77db,
0xaed16a4a,0xd9d65adc,0x40df0b66,0x37d83bf0,0xa9bcae53,0xdebb9ec5,0x47b2cf7f,0x30b5ffe9,
0xbdbdf21c,0xcabac28a,0x53b39330,0x24b4a3a6,0xbad03605,0xcdd70693,0x54de5729,0x23d967bf,
0xb3667a2e,0xc4614ab8,0x5d681b02,0x2a6f2b94,0xb40bbe37,0xc30c8ea1,0x5a05df1b,0x2d02ef8d,
};
const uint64_t XADCRCTable_c96c5795d7870f42[256] =
{
0x0000000000000000,0xb32e4cbe03a75f6f,0xf4843657a840a05b,0x47aa7ae9abe7ff34,
0x7bd0c384ff8f5e33,0xc8fe8f3afc28015c,0x8f54f5d357cffe68,0x3c7ab96d5468a107,
0xf7a18709ff1ebc66,0x448fcbb7fcb9e309,0x0325b15e575e1c3d,0xb00bfde054f94352,
0x8c71448d0091e255,0x3f5f08330336bd3a,0x78f572daa8d1420e,0xcbdb3e64ab761d61,
0x7d9ba13851336649,0xceb5ed8652943926,0x891f976ff973c612,0x3a31dbd1fad4997d,
0x064b62bcaebc387a,0xb5652e02ad1b6715,0xf2cf54eb06fc9821,0x41e11855055bc74e,
0x8a3a2631ae2dda2f,0x39146a8fad8a8540,0x7ebe1066066d7a74,0xcd905cd805ca251b,
0xf1eae5b551a2841c,0x42c4a90b5205db73,0x056ed3e2f9e22447,0xb6409f5cfa457b28,
0xfb374270a266cc92,0x48190ecea1c193fd,0x0fb374270a266cc9,0xbc9d3899098133a6,
0x80e781f45de992a1,0x33c9cd4a5e4ecdce,0x7463b7a3f5a932fa,0xc74dfb1df60e6d95,
0x0c96c5795d7870f4,0xbfb889c75edf2f9b,0xf812f32ef538d0af,0x4b3cbf90f69f8fc0,
0x774606fda2f72ec7,0xc4684a43a15071a8,0x83c230aa0ab78e9c,0x30ec7c140910d1f3,
0x86ace348f355aadb,0x3582aff6f0f2f5b4,0x7228d51f5b150a80,0xc10699a158b255ef,
0xfd7c20cc0cdaf4e8,0x4e526c720f7dab87,0x09f8169ba49a54b3,0xbad65a25a73d0bdc,
0x710d64410c4b16bd,0xc22328ff0fec49d2,0x85895216a40bb6e6,0x36a71ea8a7ace989,
0x0adda7c5f3c4488e,0xb9f3eb7bf06317e1,0xfe5991925b84e8d5,0x4d77dd2c5823b7ba,
0x64b62bcaebc387a1,0xd7986774e864d8ce,0x90321d9d438327fa,0x231c512340247895,
0x1f66e84e144cd992,0xac48a4f017eb86fd,0xebe2de19bc0c79c9,0x58cc92a7bfab26a6,
0x9317acc314dd3bc7,0x2039e07d177a64a8,0x67939a94bc9d9b9c,0xd4bdd62abf3ac4f3,
0xe8c76f47eb5265f4,0x5be923f9e8f53a9b,0x1c4359104312c5af,0xaf6d15ae40b59ac0,
0x192d8af2baf0e1e8,0xaa03c64cb957be87,0xeda9bca512b041b3,0x5e87f01b11171edc,
0x62fd4976457fbfdb,0xd1d305c846d8e0b4,0x96797f21ed3f1f80,0x2557339fee9840ef,
0xee8c0dfb45ee5d8e,0x5da24145464902e1,0x1a083bacedaefdd5,0xa9267712ee09a2ba,
0x955cce7fba6103bd,0x267282c1b9c65cd2,0x61d8f8281221a3e6,0xd2f6b4961186fc89,
0x9f8169ba49a54b33,0x2caf25044a02145c,0x6b055fede1e5eb68,0xd82b1353e242b407,
0xe451aa3eb62a1500,0x577fe680b58d4a6f,0x10d59c691e6ab55b,0xa3fbd0d71dcdea34,
0x6820eeb3b6bbf755,0xdb0ea20db51ca83a,0x9ca4d8e41efb570e,0x2f8a945a1d5c0861,
0x13f02d374934a966,0xa0de61894a93f609,0xe7741b60e174093d,0x545a57dee2d35652,
0xe21ac88218962d7a,0x5134843c1b317215,0x169efed5b0d68d21,0xa5b0b26bb371d24e,
0x99ca0b06e7197349,0x2ae447b8e4be2c26,0x6d4e3d514f59d312,0xde6071ef4cfe8c7d,
0x15bb4f8be788911c,0xa6950335e42fce73,0xe13f79dc4fc83147,0x521135624c6f6e28,
0x6e6b8c0f1807cf2f,0xdd45c0b11ba09040,0x9aefba58b0476f74,0x29c1f6e6b3e0301b,
0xc96c5795d7870f42,0x7a421b2bd420502d,0x3de861c27fc7af19,0x8ec62d7c7c60f076,
0xb2bc941128085171,0x0192d8af2baf0e1e,0x4638a2468048f12a,0xf516eef883efae45,
0x3ecdd09c2899b324,0x8de39c222b3eec4b,0xca49e6cb80d9137f,0x7967aa75837e4c10,
0x451d1318d716ed17,0xf6335fa6d4b1b278,0xb199254f7f564d4c,0x02b769f17cf11223,
0xb4f7f6ad86b4690b,0x07d9ba1385133664,0x4073c0fa2ef4c950,0xf35d8c442d53963f,
0xcf273529793b3738,0x7c0979977a9c6857,0x3ba3037ed17b9763,0x888d4fc0d2dcc80c,
0x435671a479aad56d,0xf0783d1a7a0d8a02,0xb7d247f3d1ea7536,0x04fc0b4dd24d2a59,
0x3886b22086258b5e,0x8ba8fe9e8582d431,0xcc0284772e652b05,0x7f2cc8c92dc2746a,
0x325b15e575e1c3d0,0x8175595b76469cbf,0xc6df23b2dda1638b,0x75f16f0cde063ce4,
0x498bd6618a6e9de3,0xfaa59adf89c9c28c,0xbd0fe036222e3db8,0x0e21ac88218962d7,
0xc5fa92ec8aff7fb6,0x76d4de52895820d9,0x317ea4bb22bfdfed,0x8250e80521188082,
0xbe2a516875702185,0x0d041dd676d77eea,0x4aae673fdd3081de,0xf9802b81de97deb1,
0x4fc0b4dd24d2a599,0xfceef8632775faf6,0xbb44828a8c9205c2,0x086ace348f355aad,
0x34107759db5dfbaa,0x873e3be7d8faa4c5,0xc094410e731d5bf1,0x73ba0db070ba049e,
0xb86133d4dbcc19ff,0x0b4f7f6ad86b4690,0x4ce50583738cb9a4,0xffcb493d702be6cb,
0xc3b1f050244347cc,0x709fbcee27e418a3,0x3735c6078c03e797,0x841b8ab98fa4b8f8,
0xadda7c5f3c4488e3,0x1ef430e13fe3d78c,0x595e4a08940428b8,0xea7006b697a377d7,
0xd60abfdbc3cbd6d0,0x6524f365c06c89bf,0x228e898c6b8b768b,0x91a0c532682c29e4,
0x5a7bfb56c35a3485,0xe955b7e8c0fd6bea,0xaeffcd016b1a94de,0x1dd181bf68bdcbb1,
0x21ab38d23cd56ab6,0x9285746c3f7235d9,0xd52f0e859495caed,0x6601423b97329582,
0xd041dd676d77eeaa,0x636f91d96ed0b1c5,0x24c5eb30c5374ef1,0x97eba78ec690119e,
0xab911ee392f8b099,0x18bf525d915feff6,0x5f1528b43ab810c2,0xec3b640a391f4fad,
0x27e05a6e926952cc,0x94ce16d091ce0da3,0xd3646c393a29f297,0x604a2087398eadf8,
0x5c3099ea6de60cff,0xef1ed5546e415390,0xa8b4afbdc5a6aca4,0x1b9ae303c601f3cb,
0x56ed3e2f9e224471,0xe5c372919d851b1e,0xa26908783662e42a,0x114744c635c5bb45,
0x2d3dfdab61ad1a42,0x9e13b115620a452d,0xd9b9cbfcc9edba19,0x6a978742ca4ae576,
0xa14cb926613cf817,0x1262f598629ba778,0x55c88f71c97c584c,0xe6e6c3cfcadb0723,
0xda9c7aa29eb3a624,0x69b2361c9d14f94b,0x2e184cf536f3067f,0x9d36004b35545910,
0x2b769f17cf112238,0x9858d3a9ccb67d57,0xdff2a94067518263,0x6cdce5fe64f6dd0c,
0x50a65c93309e7c0b,0xe388102d33392364,0xa4226ac498dedc50,0x170c267a9b79833f,
0xdcd7181e300f9e5e,0x6ff954a033a8c131,0x28532e49984f3e05,0x9b7d62f79be8616a,
0xa707db9acf80c06d,0x14299724cc279f02,0x5383edcd67c06036,0xe0ada17364673f59,
};

16
unpacktool/CRC.h Normal file
View File

@@ -0,0 +1,16 @@
#pragma once
#include <stdint.h>
uint32_t XADCRC(uint32_t prevcrc, uint8_t byte, const uint32_t *table);
uint32_t XADCalculateCRC(uint32_t prevcrc, const uint8_t *buffer, int length, const uint32_t *table);
uint64_t XADCRC64(uint64_t prevcrc, uint8_t byte, const uint64_t *table);
uint64_t XADCalculateCRC64(uint64_t prevcrc, const uint8_t *buffer, int length, const uint64_t *table);
int XADUnReverseCRC16(int val);
extern const uint32_t XADCRCTable_a001[256];
extern const uint32_t XADCRCReverseTable_1021[256];
extern const uint32_t XADCRCTable_edb88320[256];
extern const uint64_t XADCRCTable_c96c5795d7870f42[256];

View File

@@ -0,0 +1,379 @@
#include "CSInputBuffer.h"
#include "IFileReader.h"
#include <stdlib.h>
#include <string.h>
// Allocation and management
CSInputBuffer *CSInputBufferAlloc(IFileReader *parent, int size)
{
CSInputBuffer *self = static_cast<CSInputBuffer*>(malloc(sizeof(CSInputBuffer) + size));
if (!self) return NULL;
self->parent = parent;
self->startoffs = parent->GetPosition();
self->eof = false;
self->buffer = (uint8_t *)&self[1];
self->bufsize = size;
self->bufbytes = 0;
self->currbyte = 0;
self->bits = 0;
self->numbits = 0;
return self;
}
CSInputBuffer *CSInputBufferAllocWithBuffer(const uint8_t *buffer, int length, IFileReader::FilePos_t startoffs)
{
CSInputBuffer *self = static_cast<CSInputBuffer*>(malloc(sizeof(CSInputBuffer)));
if (!self) return NULL;
self->parent = NULL;
self->startoffs = -startoffs;
self->eof = true;
self->buffer = (uint8_t *)buffer; // Since eof is set, the buffer won't be written to.
self->bufsize = length;
self->bufbytes = length;
self->currbyte = 0;
self->bits = 0;
self->numbits = 0;
return self;
}
CSInputBuffer *CSInputBufferAllocEmpty()
{
CSInputBuffer *self = static_cast<CSInputBuffer*>(malloc(sizeof(CSInputBuffer)));
if (!self) return NULL;
self->parent = NULL;
self->startoffs = 0;
self->eof = true;
self->buffer = NULL;
self->bufsize = 0;
self->bufbytes = 0;
self->currbyte = 0;
self->bits = 0;
self->numbits = 0;
return self;
}
void CSInputBufferFree(CSInputBuffer *self)
{
free(self);
}
void CSInputSetMemoryBuffer(CSInputBuffer *self, uint8_t *buffer, int length, IFileReader::FilePos_t startoffs)
{
self->eof = true;
self->startoffs = -startoffs;
self->buffer = buffer;
self->bufsize = length;
self->bufbytes = length;
self->currbyte = 0;
self->bits = 0;
self->numbits = 0;
}
// Buffer and file positioning
void CSInputRestart(CSInputBuffer *self)
{
CSInputSeekToFileOffset(self, self->startoffs);
}
void CSInputFlush(CSInputBuffer *self)
{
self->currbyte = self->bufbytes = 0;
self->bits = 0;
self->numbits = 0;
}
void CSInputSynchronizeFileOffset(CSInputBuffer *self)
{
CSInputSeekToFileOffset(self, CSInputFileOffset(self));
}
void CSInputSeekToFileOffset(CSInputBuffer *self, IFileReader::FilePos_t offset)
{
self->parent->SeekStart(offset);
self->eof = false;
CSInputFlush(self);
}
void CSInputSeekToBufferOffset(CSInputBuffer *self, IFileReader::FilePos_t offset)
{
CSInputSeekToFileOffset(self, offset + self->startoffs);
}
void CSInputSetStartOffset(CSInputBuffer *self, IFileReader::FilePos_t offset)
{
self->startoffs = offset;
}
IFileReader::FilePos_t CSInputBufferOffset(CSInputBuffer *self)
{
return CSInputFileOffset(self) - self->startoffs;
}
IFileReader::FilePos_t CSInputFileOffset(CSInputBuffer *self)
{
if (self->parent) return self->parent->GetPosition() - self->bufbytes + self->currbyte;
else return self->currbyte;
}
IFileReader::FilePos_t CSInputBufferBitOffset(CSInputBuffer *self)
{
return CSInputBufferOffset(self) * 8 - (self->numbits & 7);
}
// Byte reading
void _CSInputFillBuffer(CSInputBuffer *self)
{
int left = _CSInputBytesLeftInBuffer(self);
if (left >= 0) memmove(self->buffer, self->buffer + self->currbyte, left);
else
{
self->parent->SeekCurrent(-left);
left = 0;
}
int actual = self->parent->Read(self->buffer + left, self->bufsize - left);
if (actual == 0) self->eof = true;
self->bufbytes = left + actual;
self->currbyte = 0;
}
// Bitstream reading
// TODO: clean up and/or make faster
bool _CSInputFillBits(CSInputBuffer *self)
{
_CSInputCheckAndFillBuffer(self);
int numbytes = (32 - self->numbits) >> 3;
int left = _CSInputBytesLeftInBuffer(self);
if (numbytes > left) numbytes = left;
int startoffset = self->numbits >> 3;
// int shift=24-self->numbits;
// for(int i=0;i<numbytes;i++)
// {
// self->bits|=_CSInputPeekByteWithoutEOF(self,i+startoffset)<<shift;
// shift-=8;
// }
switch (numbytes)
{
case 4:
self->bits =
(_CSInputPeekByteWithoutEOF(self, startoffset) << 24) |
(_CSInputPeekByteWithoutEOF(self, startoffset + 1) << 16) |
(_CSInputPeekByteWithoutEOF(self, startoffset + 2) << 8) |
_CSInputPeekByteWithoutEOF(self, startoffset + 3);
break;
case 3:
self->bits |= (
(_CSInputPeekByteWithoutEOF(self, startoffset) << 16) |
(_CSInputPeekByteWithoutEOF(self, startoffset + 1) << 8) |
(_CSInputPeekByteWithoutEOF(self, startoffset + 2) << 0)
) << (8 - self->numbits);
break;
case 2:
self->bits |= (
(_CSInputPeekByteWithoutEOF(self, startoffset) << 8) |
(_CSInputPeekByteWithoutEOF(self, startoffset + 1) << 0)
) << (16 - self->numbits);
break;
case 1:
self->bits |= _CSInputPeekByteWithoutEOF(self, startoffset) << (24 - self->numbits);
break;
}
self->numbits += numbytes * 8;
return true;
}
bool _CSInputFillBitsLE(CSInputBuffer *self)
{
_CSInputCheckAndFillBuffer(self);
int numbytes = (32 - self->numbits) >> 3;
int left = _CSInputBytesLeftInBuffer(self);
if (numbytes > left) numbytes = left;
int startoffset = self->numbits >> 3;
for (int i = 0; i < numbytes; i++)
{
self->bits |= _CSInputPeekByteWithoutEOF(self, i + startoffset) << self->numbits;
self->numbits += 8;
}
return true;
}
bool CSInputNextBit(CSInputBuffer *self, unsigned int &bit)
{
if (!CSInputPeekBitString(self, 1, bit))
return false;
return CSInputSkipPeekedBits(self, 1);
}
bool CSInputNextBitLE(CSInputBuffer *self, unsigned int &bit)
{
if (!CSInputPeekBitStringLE(self, 1, bit))
return false;
return CSInputSkipPeekedBitsLE(self, 1);
}
bool CSInputNextBitString(CSInputBuffer *self, int numbits, unsigned int &bits)
{
if (numbits == 0)
{
bits = 0;
return true;
}
if (!CSInputPeekBitString(self, numbits, bits))
return false;
return CSInputSkipPeekedBits(self, numbits);
}
bool CSInputNextBitStringLE(CSInputBuffer *self, int numbits, unsigned int &bits)
{
if (numbits == 0)
{
bits = 0;
return true;
}
if (!CSInputPeekBitStringLE(self, numbits, bits))
return false;
if (!CSInputSkipPeekedBitsLE(self, numbits))
return false;
return true;
}
bool CSInputNextLongBitString(CSInputBuffer *self, int numbits, unsigned int &bits)
{
if (numbits <= 25)
return CSInputNextBitString(self, numbits, bits);
else
{
int rest = numbits - 25;
unsigned int readBits;
if (!CSInputNextBitString(self, 25, readBits))
return false;
readBits <<= rest;
unsigned int moreBits;
if (!CSInputNextBitString(self, rest, moreBits))
return false;
bits = (readBits | moreBits);
return true;
}
}
bool CSInputNextLongBitStringLE(CSInputBuffer *self, int numbits, unsigned int &bits)
{
if (numbits <= 25)
return CSInputNextBitStringLE(self, numbits, bits);
else
{
int rest = numbits - 25;
unsigned int readBits;
if (!CSInputNextBitStringLE(self, 25, readBits))
return false;
unsigned int moreBits;
if (!CSInputNextBitStringLE(self, rest, moreBits))
return false;
bits = (readBits | (moreBits << 25));
return true;
}
}
bool CSInputSkipBits(CSInputBuffer *self, int numbits)
{
if (numbits <= self->numbits)
return CSInputSkipPeekedBits(self, numbits);
else
{
int skipbits = numbits - (self->numbits & 7);
CSInputSkipToByteBoundary(self);
CSInputSkipBytes(self, skipbits >> 3);
if (skipbits & 7)
{
unsigned int scratch;
if (!CSInputNextBitString(self, skipbits & 7, scratch))
return false;
}
return true;
}
}
bool CSInputSkipBitsLE(CSInputBuffer *self, int numbits)
{
if (numbits <= self->numbits)
return CSInputSkipPeekedBitsLE(self, numbits);
else
{
int skipbits = numbits - (self->numbits & 7);
CSInputSkipToByteBoundary(self);
CSInputSkipBytes(self, skipbits >> 3);
if (skipbits & 7)
{
unsigned int scratch;
if (!CSInputNextBitStringLE(self, skipbits & 7, scratch))
return false;
}
return true;
}
}
bool CSInputOnByteBoundary(CSInputBuffer *self)
{
return (self->numbits & 7) == 0;
}
bool CSInputSkipToByteBoundary(CSInputBuffer *self)
{
self->bits = 0;
self->numbits = 0;
return true;
}
bool CSInputSkipTo16BitBoundary(CSInputBuffer *self)
{
if (!CSInputSkipToByteBoundary(self))
return false;
if (CSInputBufferOffset(self) & 1)
{
if (!CSInputSkipBytes(self, 1))
return false;
}
return true;
}

232
unpacktool/CSInputBuffer.h Normal file
View File

@@ -0,0 +1,232 @@
#pragma once
#include <stdint.h>
#include "UPByteSwap.h"
#include "IFileReader.h"
struct IFileReader;
struct CSInputBuffer
{
IFileReader *parent;
IFileReader::FilePos_t startoffs;
bool eof;
uint8_t *buffer;
unsigned int bufsize, bufbytes, currbyte;
uint32_t bits;
unsigned int numbits;
};
// Allocation and management
CSInputBuffer *CSInputBufferAlloc(IFileReader *parent, int size);
CSInputBuffer *CSInputBufferAllocWithBuffer(const uint8_t *buffer, int length, IFileReader::FilePos_t startoffs);
CSInputBuffer *CSInputBufferAllocEmpty();
void CSInputBufferFree(CSInputBuffer *self);
void CSInputSetMemoryBuffer(CSInputBuffer *self, uint8_t *buffer, int length, size_t startoffs);
static inline IFileReader *CSInputHandle(CSInputBuffer *self)
{
return self->parent;
}
// Buffer and file positioning
void CSInputRestart(CSInputBuffer *self);
void CSInputFlush(CSInputBuffer *self);
void CSInputSynchronizeFileOffset(CSInputBuffer *self);
void CSInputSeekToFileOffset(CSInputBuffer *self, IFileReader::FilePos_t offset);
void CSInputSeekToBufferOffset(CSInputBuffer *self, IFileReader::FilePos_t offset);
void CSInputSetStartOffset(CSInputBuffer *self, IFileReader::FilePos_t offset);
IFileReader::FilePos_t CSInputBufferOffset(CSInputBuffer *self);
IFileReader::FilePos_t CSInputFileOffset(CSInputBuffer *self);
IFileReader::FilePos_t CSInputBufferBitOffset(CSInputBuffer *self);
void _CSInputFillBuffer(CSInputBuffer *self);
// Byte reading
#define CSInputBufferLookAhead 4
static inline int _CSInputBytesLeftInBuffer(CSInputBuffer *self)
{
return self->bufbytes - self->currbyte;
}
static inline void _CSInputCheckAndFillBuffer(CSInputBuffer *self)
{
if (!self->eof&&_CSInputBytesLeftInBuffer(self) <= CSInputBufferLookAhead) _CSInputFillBuffer(self);
}
static inline bool CSInputSkipBytes(CSInputBuffer *self, int num)
{
self->currbyte += num;
return true;
}
static inline int _CSInputPeekByteWithoutEOF(CSInputBuffer *self, int offs)
{
return self->buffer[self->currbyte + offs];
}
static inline bool CSInputPeekByte(CSInputBuffer *self, int offs, int &byte)
{
_CSInputCheckAndFillBuffer(self);
if (offs >= _CSInputBytesLeftInBuffer(self))
{
byte = -1;
return true;
}
byte = _CSInputPeekByteWithoutEOF(self, offs);
return true;
}
static inline bool CSInputNextByte(CSInputBuffer *self, int &byte)
{
if (!CSInputPeekByte(self, 0, byte))
return false;
if (!CSInputSkipBytes(self, 1))
return false;
return true;
}
static inline bool CSInputAtEOF(CSInputBuffer *self, bool &isEOF)
{
_CSInputCheckAndFillBuffer(self);
isEOF = _CSInputBytesLeftInBuffer(self) <= 0;
return true;
}
// Bitstream reading
bool _CSInputFillBits(CSInputBuffer *self);
bool _CSInputFillBitsLE(CSInputBuffer *self);
bool CSInputNextBit(CSInputBuffer *self, unsigned int &bit);
bool CSInputNextBitLE(CSInputBuffer *self, unsigned int &bit);
bool CSInputNextBitString(CSInputBuffer *self, int numbits, unsigned int &bits);
bool CSInputNextBitStringLE(CSInputBuffer *self, int numbits, unsigned int &bits);
bool CSInputNextLongBitString(CSInputBuffer *self, int numbits, unsigned int &bits);
bool CSInputNextLongBitStringLE(CSInputBuffer *self, int numbits, unsigned int &bits);
bool CSInputSkipBits(CSInputBuffer *self, int numbits);
bool CSInputSkipBitsLE(CSInputBuffer *self, int numbits);
bool CSInputOnByteBoundary(CSInputBuffer *self);
bool CSInputSkipToByteBoundary(CSInputBuffer *self);
bool CSInputSkipTo16BitBoundary(CSInputBuffer *self);
static inline unsigned int CSInputBitsLeftInBuffer(CSInputBuffer *self)
{
_CSInputCheckAndFillBuffer(self);
return _CSInputBytesLeftInBuffer(self) * 8 + (self->numbits & 7);
}
static inline bool _CSInputCheckAndFillBits(CSInputBuffer *self, int numbits)
{
if (static_cast<unsigned int>(numbits) > self->numbits)
return _CSInputFillBits(self);
return true;
}
static inline bool _CSInputCheckAndFillBitsLE(CSInputBuffer *self, int numbits)
{
if (static_cast<unsigned int>(numbits) > self->numbits)
return _CSInputFillBitsLE(self);
return true;
}
static inline bool CSInputPeekBitString(CSInputBuffer *self, int numbits, unsigned int &bits)
{
if (numbits == 0)
{
bits = 0;
return true;
}
if (!_CSInputCheckAndFillBits(self, numbits))
return false;
bits = self->bits >> (32 - numbits);
return true;
}
static inline bool CSInputPeekBitStringLE(CSInputBuffer *self, int numbits, unsigned int &bits)
{
if (numbits == 0)
{
bits = 0;
return true;
}
if (!_CSInputCheckAndFillBitsLE(self, numbits))
return false;
bits = self->bits&((1 << numbits) - 1);
return true;
}
static inline bool CSInputSkipPeekedBits(CSInputBuffer *self, int numbits)
{
int numbytes = (numbits - (self->numbits & 7) + 7) >> 3;
CSInputSkipBytes(self, numbytes);
if (_CSInputBytesLeftInBuffer(self) < 0)
return false;
self->bits <<= numbits;
self->numbits -= numbits;
return true;
}
static inline bool CSInputSkipPeekedBitsLE(CSInputBuffer *self, int numbits)
{
int numbytes = (numbits - (self->numbits & 7) + 7) >> 3;
CSInputSkipBytes(self, numbytes);
if (_CSInputBytesLeftInBuffer(self) < 0)
return false;
self->bits >>= numbits;
self->numbits -= numbits;
return true;
}
// Multibyte reading
#define CSInputNextValueImpl(type,name,conv) \
static inline type name(CSInputBuffer *self) \
{ \
_CSInputCheckAndFillBuffer(self); \
type val=conv(self->buffer+self->currbyte); \
CSInputSkipBytes(self,sizeof(type)); \
return val; \
}
CSInputNextValueImpl(int16_t, CSInputNextInt16LE, ParseInt16LE)
CSInputNextValueImpl(int32_t, CSInputNextInt32LE, ParseInt32LE)
CSInputNextValueImpl(uint16_t, CSInputNextUInt16LE, ParseUInt16LE)
CSInputNextValueImpl(uint32_t, CSInputNextUInt32LE, ParseUInt32LE)
CSInputNextValueImpl(int16_t, CSInputNextInt16BE, ParseInt16BE)
CSInputNextValueImpl(int32_t, CSInputNextInt32BE, ParseInt32BE)
CSInputNextValueImpl(uint16_t, CSInputNextUInt16BE, ParseUInt16BE)
CSInputNextValueImpl(uint32_t, CSInputNextUInt32BE, ParseUInt32BE)

View File

@@ -0,0 +1,129 @@
#include "CompactProLZHDecompressor.h"
#include "CSInputBuffer.h"
#include "PrefixCode.h"
CompactProLZHDecompressor::CompactProLZHDecompressor(int blocksize)
: LZSSDecompressor(8192)
, literalcode(nullptr)
, lengthcode(nullptr)
, offsetcode(nullptr)
, blocksize(blocksize)
, blockcount(0)
, blockstart(0)
{
}
CompactProLZHDecompressor::~CompactProLZHDecompressor()
{
delete literalcode;
delete lengthcode;
delete offsetcode;
}
bool CompactProLZHDecompressor::resetLZSSHandle()
{
blockcount = blocksize;
blockstart = 0;
return true;
}
bool CompactProLZHDecompressor::nextLiteralOrOffset(int *offset, int *length, int &result)
{
if (blockcount >= blocksize)
{
if (blockstart)
{
// Don't let your bad implementations leak into your file formats, people!
if (!CSInputSkipToByteBoundary(input))
return false;
if ((CSInputBufferOffset(input) - blockstart) & 1)
{
if (!CSInputSkipBytes(input, 3))
return false;
}
else
{
if (!CSInputSkipBytes(input, 2))
return false;
}
}
delete literalcode;
delete lengthcode;
delete offsetcode;
literalcode = lengthcode = offsetcode = nullptr;
literalcode = allocAndParseCodeOfSize(256);
if (!literalcode)
return false;
lengthcode = allocAndParseCodeOfSize(64);
if (!lengthcode)
return false;
offsetcode = allocAndParseCodeOfSize(128);
if (!offsetcode)
return false;
blockcount = 0;
blockstart = CSInputBufferOffset(input);
}
unsigned int nextBit;
if (!CSInputNextBit(input, nextBit))
return false;
if (nextBit)
{
blockcount += 2;
return CSInputNextSymbolUsingCode(input, literalcode, result);
}
else
{
blockcount += 3;
if (!CSInputNextSymbolUsingCode(input, lengthcode, *length))
return false;
int offsetSym;
if (!CSInputNextSymbolUsingCode(input, offsetcode, offsetSym))
return false;
unsigned int offsetBits;
if (!CSInputNextBitString(input, 6, offsetBits))
return false;
*offset = offsetSym << 6;
*offset |= offsetBits;
result = XADLZSSMatch;
return true;
}
result = XADLZSSEnd;
return true;
}
XADPrefixCode *CompactProLZHDecompressor::allocAndParseCodeOfSize(int size)
{
int numbytes;
if (!CSInputNextByte(input, numbytes))
return nullptr;
if (numbytes * 2 > size)
return nullptr;
std::vector<int> codelengths;
codelengths.resize(size);
for (int i = 0; i < numbytes; i++)
{
int val;
if (!CSInputNextByte(input, val))
return nullptr;
codelengths[2 * i] = val >> 4;
codelengths[2 * i + 1] = val & 0x0f;
}
for (int i = numbytes * 2; i < size; i++) codelengths[i] = 0;
return XADPrefixCode::prefixCodeWithLengths(codelengths.data(), size, 15, true);
}

View File

@@ -0,0 +1,23 @@
#pragma once
#include "LZSSDecompressor.h"
#include "IFileReader.h"
class XADPrefixCode;
class CompactProLZHDecompressor : public LZSSDecompressor
{
public:
explicit CompactProLZHDecompressor(int blocksize);
~CompactProLZHDecompressor();
private:
bool nextLiteralOrOffset(int *offset, int *length, int &result) override;
bool resetLZSSHandle() override;
XADPrefixCode *allocAndParseCodeOfSize(int size);
XADPrefixCode *literalcode, *lengthcode, *offsetcode;
int blocksize, blockcount;
IFileReader::FilePos_t blockstart;
};

View File

@@ -0,0 +1,53 @@
#include "CompactProLZHRLEDecompressor.h"
#include "CompactProRLEDecompressor.h"
#include "CompactProLZHDecompressor.h"
#include "DecompressorProxyReader.h"
CompactProLZHRLEDecompressor::CompactProLZHRLEDecompressor(int blockSize)
: m_proxyReader(nullptr)
, m_proxyInput(nullptr)
, m_lzhDecompressor(nullptr)
, m_rleDecompressor(nullptr)
, m_blockSize(blockSize)
{
}
CompactProLZHRLEDecompressor::~CompactProLZHRLEDecompressor()
{
delete m_rleDecompressor;
delete m_lzhDecompressor;
delete m_proxyReader;
CSInputBufferFree(m_proxyInput);
}
bool CompactProLZHRLEDecompressor::Reset(CSInputBuffer *input, size_t compressedSize, size_t decompressedSize)
{
delete m_rleDecompressor;
delete m_lzhDecompressor;
delete m_proxyReader;
CSInputBufferFree(m_proxyInput);
m_rleDecompressor = nullptr;
m_lzhDecompressor = nullptr;
m_proxyReader = nullptr;
m_proxyInput = nullptr;
m_lzhDecompressor = nullptr;
m_proxyReader = nullptr;
m_lzhDecompressor = new CompactProLZHDecompressor(m_blockSize);
m_proxyReader = new DecompressorProxyReader(m_lzhDecompressor);
// FIXME maybe: This is a really stupid workaround to compensate for the decompressor not actually supporting EOFs, and the fact that we don't know the intermediate size
m_proxyInput = CSInputBufferAlloc(m_proxyReader, 1);
m_rleDecompressor = new CompactProRLEDecompressor();
if (!m_lzhDecompressor->Reset(input, compressedSize, 0))
return false;
if (!m_rleDecompressor->Reset(m_proxyInput, 0, decompressedSize))
return false;
return true;
}
bool CompactProLZHRLEDecompressor::ReadBytes(void *dest, size_t numBytes)
{
return m_rleDecompressor->ReadBytes(dest, numBytes);
}

View File

@@ -0,0 +1,26 @@
#pragma once
#include "IDecompressor.h"
#include "PrefixCode.h"
struct IFileReader;
class IDecompressor;
class CompactProLZHDecompressor;
class CompactProRLEDecompressor;
class CompactProLZHRLEDecompressor : public IDecompressor
{
public:
explicit CompactProLZHRLEDecompressor(int blockSize);
~CompactProLZHRLEDecompressor();
bool Reset(CSInputBuffer *input, size_t compressedSize, size_t decompressedSize) override;
bool ReadBytes(void *dest, size_t numBytes) override;
private:
IFileReader *m_proxyReader;
CSInputBuffer *m_proxyInput;
IDecompressor *m_lzhDecompressor;
IDecompressor *m_rleDecompressor;
int m_blockSize;
};

View File

@@ -0,0 +1,213 @@
#include "CompactProParser.h"
#include "IFileReader.h"
#include "UPByteSwap.h"
#include "PLBigEndian.h"
#include "CRC.h"
#include "ArchiveDescription.h"
#include "StringCommon.h"
#include <stdint.h>
bool CompactProParser::Check(IFileReader &reader)
{
uint8_t bytes[8];
if (!reader.SeekStart(0))
return false;
if (!reader.ReadExact(bytes, sizeof(bytes)))
return false;
if (bytes[0] != 1)
return false;
uint32_t offset = ParseUInt32BE(bytes + 4);
if (offset > reader.FileSize() - 7)
return false;
if (!reader.SeekStart(offset))
return false;
uint8_t buf[256];
if (!reader.ReadExact(buf, 4))
return false;
uint32_t correctcrc = ParseUInt32BE(buf);
uint32_t crc = 0xffffffff;
if (!reader.ReadExact(buf, 3))
return false;
crc = XADCalculateCRC(crc, buf, 3, XADCRCTable_edb88320);
int numentries = ParseUInt16BE(buf);
int commentsize = buf[2];
if (!reader.ReadExact(buf, commentsize))
return false;
crc = XADCalculateCRC(crc, buf, commentsize, XADCRCTable_edb88320);
for (int i = 0; i < numentries; i++)
{
uint8_t namelen;
if (!reader.ReadExact(&namelen, 1))
return false;
crc = XADCRC(crc, namelen, XADCRCTable_edb88320);
if (!reader.ReadExact(buf, namelen & 0x7f))
return false;
crc = XADCalculateCRC(crc, buf, namelen & 0x7f, XADCRCTable_edb88320);
int metadatasize;
if (namelen & 0x80)
metadatasize = 2;
else
metadatasize = 45;
if (!reader.ReadExact(buf, metadatasize))
return false;
crc = XADCalculateCRC(crc, buf, metadatasize, XADCRCTable_edb88320);
}
if (crc == correctcrc)
return true;
return false;
}
struct CompactProArchiveHeader
{
uint8_t m_marker;
uint8_t m_volume;
BEUInt16_t m_xmagic;
BEUInt32_t m_catalogOffset;
};
struct CompactProCatalogHeader
{
BEUInt32_t m_headerCRC;
BEUInt16_t m_numEntries;
uint8_t m_commentLength;
};
struct CompactProCatalogFileEntry
{
uint8_t m_volume;
BEUInt32_t m_fileOffset;
uint8_t m_fileType[4];
uint8_t m_fileCreator[4];
BEUInt32_t m_creationDate;
BEUInt32_t m_modificationDate;
BEUInt16_t m_finderFlags;
BEUInt32_t m_crc;
BEUInt16_t m_flags;
BEUInt32_t m_resUncompressedSize;
BEUInt32_t m_dataUncompressedSize;
BEUInt32_t m_resCompressedSize;
BEUInt32_t m_dataCompressedSize;
};
ArchiveItemList *CompactProParser::Parse(IFileReader &reader)
{
if (!reader.SeekStart(0))
return nullptr;
CompactProArchiveHeader arcHeader;
if (!reader.ReadExact(&arcHeader, sizeof(arcHeader)))
return nullptr;
if (!reader.SeekStart(arcHeader.m_catalogOffset))
return nullptr;
CompactProCatalogHeader catHeader;
if (!reader.ReadExact(&catHeader, sizeof(catHeader)))
return nullptr;
if (!reader.SeekCurrent(catHeader.m_commentLength))
return nullptr;
return ParseDirectory(catHeader.m_numEntries, reader);
}
ArchiveItemList *CompactProParser::ParseDirectory(uint32_t numEntries, IFileReader &reader)
{
ArchiveItemList itemList;
for (uint32_t itemIndex = 0; itemIndex < numEntries; itemIndex++)
{
itemList.m_items.push_back(ArchiveItem());
ArchiveItem &item = itemList.m_items.back();
uint8_t nameLengthAndDirFlag;
if (!reader.ReadExact(&nameLengthAndDirFlag, 1))
return nullptr;
uint8_t nameLength = (nameLengthAndDirFlag & 0x7f);
uint8_t fname[127];
if (!reader.ReadExact(fname, nameLength))
return nullptr;
StringCommon::ConvertMacRomanFileName(item.m_fileNameUTF8, fname, nameLength);
if (nameLengthAndDirFlag & 0x80)
{
BEUInt16_t numChildrenBE;
if (!reader.ReadExact(&numChildrenBE, sizeof(numChildrenBE)))
return nullptr;
uint16_t numChildren = numChildrenBE;
if (numChildren > numEntries - itemIndex)
return nullptr;
item.m_isDirectory = true;
ArchiveItemList *children = ParseDirectory(numChildren, reader);
if (!children)
return nullptr;
item.m_children = children;
numEntries -= numChildren;
}
else
{
CompactProCatalogFileEntry fileEntry;
if (!reader.ReadExact(&fileEntry, sizeof(fileEntry)))
return nullptr;
if (fileEntry.m_resUncompressedSize)
{
item.m_resourceForkDesc.m_compressedSize = fileEntry.m_resCompressedSize;
item.m_resourceForkDesc.m_uncompressedSize = fileEntry.m_resUncompressedSize;
item.m_resourceForkDesc.m_filePosition = fileEntry.m_fileOffset;
item.m_resourceForkDesc.m_compressionMethod = (fileEntry.m_flags & 2) ? CompressionMethods::kCompactProLZHRLE : CompressionMethods::kCompactProRLE;
}
if (fileEntry.m_dataUncompressedSize)
{
item.m_dataForkDesc.m_compressedSize = fileEntry.m_dataCompressedSize;
item.m_dataForkDesc.m_uncompressedSize = fileEntry.m_dataUncompressedSize;
item.m_dataForkDesc.m_filePosition = fileEntry.m_fileOffset + fileEntry.m_resCompressedSize;
item.m_dataForkDesc.m_compressionMethod = (fileEntry.m_flags & 4) ? CompressionMethods::kCompactProLZHRLE : CompressionMethods::kCompactProRLE;
}
item.m_macProperties.m_creationDate = fileEntry.m_creationDate;
item.m_macProperties.m_modifiedDate = fileEntry.m_modificationDate;
memcpy(item.m_macProperties.m_fileCreator, fileEntry.m_fileCreator, 4);
memcpy(item.m_macProperties.m_fileType, fileEntry.m_fileType, 4);
item.m_macProperties.m_finderFlags = fileEntry.m_finderFlags;
}
}
return new ArchiveItemList(std::move(itemList));
}

View File

@@ -0,0 +1,15 @@
#pragma once
#include "IArchiveParser.h"
#include <stdint.h>
class CompactProParser : public IArchiveParser
{
public:
bool Check(IFileReader &reader) override;
ArchiveItemList *Parse(IFileReader &reader) override;
private:
ArchiveItemList *ParseDirectory(uint32_t numEntries, IFileReader &reader);
};

View File

@@ -0,0 +1,112 @@
#include "CompactProRLEDecompressor.h"
#include "CSInputBuffer.h"
CompactProRLEDecompressor::CompactProRLEDecompressor()
: input(nullptr)
, saved(0)
, repeat(0)
, halfescaped(false)
{
}
CompactProRLEDecompressor::~CompactProRLEDecompressor()
{
}
bool CompactProRLEDecompressor::Reset(CSInputBuffer *input, size_t compressedSize, size_t decompressedSize)
{
saved = 0;
repeat = 0;
halfescaped = false;
this->input = input;
return true;
}
bool CompactProRLEDecompressor::ReadBytes(void *dest, size_t numBytes)
{
uint8_t *destBytes = static_cast<uint8_t*>(dest);
while (numBytes)
{
if (!EmitOneByte(*destBytes))
return false;
numBytes--;
destBytes++;
}
return true;
}
bool CompactProRLEDecompressor::EmitOneByte(uint8_t &b)
{
if (repeat)
{
repeat--;
b = saved;
return true;
}
int byte;
if (halfescaped)
{
byte = 0x81;
halfescaped = false;
}
else
{
if (!CSInputNextByte(input, byte))
return false;
}
if (byte == 0x81)
{
if (!CSInputNextByte(input, byte))
return false;
if (byte == 0x82)
{
if (!CSInputNextByte(input, byte))
return false;
if (byte != 0)
{
repeat = byte - 2; // ?
b = saved;
return true;
}
else
{
repeat = 1;
saved = 0x82;
b = 0x81;
return true;
}
}
else
{
if (byte == 0x81)
{
halfescaped = true;
saved = 0x81;
b = saved;
return true;
}
else
{
repeat = 1;
saved = byte;
b = 0x81;
return true;
}
}
}
else
{
saved = byte;
b = saved;
return true;
}
}

View File

@@ -0,0 +1,20 @@
#pragma once
#include "IDecompressor.h"
class CompactProRLEDecompressor : public IDecompressor
{
public:
CompactProRLEDecompressor();
~CompactProRLEDecompressor();
bool Reset(CSInputBuffer *input, size_t compressedSize, size_t decompressedSize);
bool ReadBytes(void *dest, size_t numBytes);
public:
CSInputBuffer *input;
int saved, repeat;
bool halfescaped;
bool EmitOneByte(uint8_t &b);
};

View File

@@ -0,0 +1,45 @@
#include "DecompressorProxyReader.h"
#include "IDecompressor.h"
DecompressorProxyReader::DecompressorProxyReader(IDecompressor *decompressor)
: m_decompressor(decompressor)
, m_currentPosition(0)
{
}
size_t DecompressorProxyReader::Read(void *buffer, size_t sz)
{
if (!m_decompressor->ReadBytes(buffer, sz))
return 0;
m_currentPosition += sz;
return sz;
}
size_t DecompressorProxyReader::FileSize() const
{
return 0;
}
bool DecompressorProxyReader::SeekStart(FilePos_t pos)
{
return pos == m_currentPosition;
}
bool DecompressorProxyReader::SeekCurrent(FilePos_t pos)
{
return pos == 0;
}
bool DecompressorProxyReader::SeekEnd(FilePos_t pos)
{
return false;
}
IFileReader::FilePos_t DecompressorProxyReader::GetPosition() const
{
return m_currentPosition;
}

View File

@@ -0,0 +1,22 @@
#pragma once
#include "IFileReader.h"
class IDecompressor;
class DecompressorProxyReader final : public IFileReader
{
public:
explicit DecompressorProxyReader(IDecompressor *decompressor);
size_t Read(void *buffer, size_t sz) override;
size_t FileSize() const override;
bool SeekStart(FilePos_t pos) override;
bool SeekCurrent(FilePos_t pos) override;
bool SeekEnd(FilePos_t pos) override;
FilePos_t GetPosition() const override;
private:
FilePos_t m_currentPosition;
IDecompressor *m_decompressor;
};

View File

@@ -0,0 +1,11 @@
#pragma once
struct IFileReader;
struct ArchiveItemList;
class IArchiveParser
{
public:
virtual bool Check(IFileReader &reader) = 0;
virtual ArchiveItemList *Parse(IFileReader &reader) = 0;
};

View File

@@ -0,0 +1,13 @@
#pragma once
#include <stdint.h>
struct CSInputBuffer;
class IDecompressor
{
public:
virtual ~IDecompressor() { }
virtual bool Reset(CSInputBuffer *input, size_t compressedSize, size_t decompressedSize) = 0;
virtual bool ReadBytes(void *dest, size_t numBytes) = 0;
};

22
unpacktool/IFileReader.h Normal file
View File

@@ -0,0 +1,22 @@
#pragma once
#include <stdint.h>
struct IFileReader
{
public:
typedef int64_t FilePos_t;
typedef uint64_t UFilePos_t;
virtual size_t Read(void *buffer, size_t sz) = 0;
virtual size_t FileSize() const = 0;
virtual bool SeekStart(FilePos_t pos) = 0;
virtual bool SeekCurrent(FilePos_t pos) = 0;
virtual bool SeekEnd(FilePos_t pos) = 0;
virtual FilePos_t GetPosition() const = 0;
inline bool ReadExact(void *buffer, size_t sz)
{
return this->Read(buffer, sz) == sz;
}
};

Some files were not shown because too many files have changed in this diff Show More