-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
311 additions
and
46 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
; { "technology": "Simple Tile Compression 0", "extension": "stc0compr" } | ||
|
||
.memorymap | ||
defaultslot 0 | ||
slotsize $4000 | ||
slot 0 $0000 | ||
.endme | ||
|
||
.rombankmap | ||
bankstotal 1 | ||
banksize $4000 | ||
banks 1 | ||
.endro | ||
|
||
.bank 0 slot 0 | ||
|
||
.org 0 | ||
ld hl,data | ||
ld de,$4000 | ||
call stc0_decompress | ||
ret ; ends the test | ||
|
||
.block "decompressor" | ||
.include "../decompressors/stc0_decomp.asm" | ||
.endb | ||
|
||
data: .incbin "data.stc0compr" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
#include <cstdint> | ||
|
||
extern "C" __declspec(dllexport) const char* getName() | ||
{ | ||
return "Simple Tile Compressor Zero"; | ||
} | ||
|
||
extern "C" __declspec(dllexport) const char* getExt() | ||
{ | ||
return "stc0compr"; | ||
} | ||
|
||
extern "C" __declspec(dllexport) int compressTiles( | ||
const uint8_t* pSource, | ||
const uint32_t numTiles, | ||
uint8_t* pDestination, | ||
const uint32_t destinationLength) | ||
{ | ||
if (destinationLength < numTiles * 40 + 1) | ||
{ | ||
return 0; | ||
} | ||
// please give me more space for the data (up to 40 bytes per tile needed worst case scenario, plus 1 byte terminator) | ||
|
||
uint8_t lastValue = 0; | ||
uint8_t values[4]; | ||
int finalSize = 0; | ||
|
||
for (unsigned int tileNumber = 0; tileNumber < numTiles; tileNumber++) | ||
{ | ||
// loop over all tiles | ||
for (unsigned char i = 0; i < 8; i++) | ||
{ | ||
// loop over all the 8 rows of the tile | ||
unsigned char mask = 0b00000000; | ||
bool lastValid = false; | ||
unsigned char valuesCount = 0; | ||
|
||
if (pSource[0] == 0x00) | ||
{ | ||
mask |= 0b10000000; | ||
} | ||
else if (pSource[0] == 0xFF) | ||
{ | ||
mask |= 0b11000000; | ||
} | ||
else | ||
{ | ||
mask |= 0b01000000; // raw | ||
lastValid = true; | ||
lastValue = pSource[0]; | ||
values[valuesCount++] = pSource[0]; | ||
} | ||
|
||
if (pSource[1] == 0x00) | ||
{ | ||
mask |= 0b00100000; | ||
} | ||
else if (pSource[1] == 0xFF) | ||
{ | ||
mask |= 0b00110000; | ||
} | ||
else if (!lastValid || | ||
pSource[1] != lastValue) | ||
{ | ||
mask |= 0b00010000; // raw | ||
lastValid = true; | ||
lastValue = pSource[1]; | ||
values[valuesCount++] = pSource[1]; | ||
} | ||
|
||
if (pSource[2] == 0x00) | ||
{ | ||
mask |= 0b00001000; | ||
} | ||
else if (pSource[2] == 0xFF) | ||
{ | ||
mask |= 0b00001100; | ||
} | ||
else if (!lastValid || | ||
pSource[2] != lastValue) | ||
{ | ||
mask |= 0b00000100; // raw | ||
lastValid = true; | ||
lastValue = pSource[2]; | ||
values[valuesCount++] = pSource[2]; | ||
} | ||
|
||
if (pSource[3] == 0x00) | ||
{ | ||
mask |= 0b00000010; | ||
} | ||
else if (pSource[3] == 0xFF) | ||
{ | ||
mask |= 0b00000011; | ||
} | ||
else if (!lastValid || | ||
pSource[3] != lastValue) | ||
{ | ||
mask |= 0b00000001; // raw | ||
lastValid = true; | ||
lastValue = pSource[3]; | ||
values[valuesCount++] = pSource[3]; | ||
} | ||
|
||
*pDestination++ = mask; // write mask byte | ||
|
||
for (unsigned char j = 0; j < valuesCount; j++) | ||
{ | ||
*pDestination++ = values[j]; // dump uncompressed values | ||
} | ||
|
||
finalSize += 1 + valuesCount; // add this to finalSize | ||
|
||
pSource += 4; // skip to next 4 bytes | ||
} | ||
} | ||
|
||
*pDestination = 0x00; // end of data | ||
finalSize++; | ||
|
||
return finalSize; // report size to caller | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<ItemGroup Label="ProjectConfigurations"> | ||
<ProjectConfiguration Include="Debug|Win32"> | ||
<Configuration>Debug</Configuration> | ||
<Platform>Win32</Platform> | ||
</ProjectConfiguration> | ||
<ProjectConfiguration Include="Release|Win32"> | ||
<Configuration>Release</Configuration> | ||
<Platform>Win32</Platform> | ||
</ProjectConfiguration> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClCompile Include="gfxcomp_stc0.cpp" /> | ||
</ItemGroup> | ||
<PropertyGroup Label="Globals"> | ||
<ProjectGuid>{eb4e5423-ca2c-4020-8796-438e218ff0e0}</ProjectGuid> | ||
<Keyword>Win32Proj</Keyword> | ||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion> | ||
</PropertyGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> | ||
<ConfigurationType>DynamicLibrary</ConfigurationType> | ||
<PlatformToolset>v143</PlatformToolset> | ||
<WholeProgramOptimization>true</WholeProgramOptimization> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> | ||
<ConfigurationType>DynamicLibrary</ConfigurationType> | ||
<PlatformToolset>v143</PlatformToolset> | ||
</PropertyGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> | ||
<ImportGroup Label="ExtensionSettings"> | ||
</ImportGroup> | ||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets"> | ||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
</ImportGroup> | ||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets"> | ||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
</ImportGroup> | ||
<PropertyGroup Label="UserMacros" /> | ||
<PropertyGroup> | ||
<_ProjectFileVersion>11.0.60610.1</_ProjectFileVersion> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||
<IntDir>$(SolutionDir)$(Configuration)\$(ProjectName)\</IntDir> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||
<IntDir>$(SolutionDir)$(Configuration)\$(ProjectName)\</IntDir> | ||
</PropertyGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||
<ClCompile> | ||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
<WarningLevel>Level4</WarningLevel> | ||
<TreatWarningAsError>true</TreatWarningAsError> | ||
<Optimization>Disabled</Optimization> | ||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> | ||
<MultiProcessorCompilation>true</MultiProcessorCompilation> | ||
</ClCompile> | ||
<Link> | ||
<TargetMachine>MachineX86</TargetMachine> | ||
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers> | ||
<ImportLibrary>$(IntermediateOutputPath)$(TargetName).lib</ImportLibrary> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||
<ClCompile> | ||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
<WarningLevel>Level4</WarningLevel> | ||
<TreatWarningAsError>true</TreatWarningAsError> | ||
<WholeProgramOptimization>true</WholeProgramOptimization> | ||
<MultiProcessorCompilation>true</MultiProcessorCompilation> | ||
</ClCompile> | ||
<Link> | ||
<OptimizeReferences>true</OptimizeReferences> | ||
<EnableCOMDATFolding>true</EnableCOMDATFolding> | ||
<TargetMachine>MachineX86</TargetMachine> | ||
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers> | ||
<ImportLibrary>$(IntermediateOutputPath)$(TargetName).lib</ImportLibrary> | ||
<SubSystem>Windows</SubSystem> | ||
<LinkTimeCodeGeneration>UseFastLinkTimeCodeGeneration</LinkTimeCodeGeneration> | ||
<TreatLinkerWarningAsErrors>true</TreatLinkerWarningAsErrors> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | ||
<ImportGroup Label="ExtensionTargets"> | ||
</ImportGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.