-
Notifications
You must be signed in to change notification settings - Fork 0
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
4 changed files
with
204 additions
and
0 deletions.
There are no files selected for viewing
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,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// Allgemeine Informationen über eine Assembly werden über die folgenden | ||
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, | ||
// die einer Assembly zugeordnet sind. | ||
[assembly: AssemblyTitle("Snes8BppPlanar")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("Snes8BppPlanar")] | ||
[assembly: AssemblyCopyright("Copyright © 2023")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly | ||
// für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von | ||
// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen. | ||
[assembly: ComVisible(false)] | ||
|
||
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird | ||
[assembly: Guid("8d10bcbc-15a3-4324-a68e-e45241c6e11a")] | ||
|
||
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: | ||
// | ||
// Hauptversion | ||
// Nebenversion | ||
// Buildnummer | ||
// Revision | ||
// | ||
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden, | ||
// indem Sie "*" wie unten gezeigt eingeben: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
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,96 @@ | ||
using System; | ||
using System.Drawing; | ||
using CharactorLib.Common; | ||
using CharactorLib.Format; | ||
|
||
namespace Snes8BppPlanar | ||
{ | ||
public class Snes8BppPlanarFormat : FormatBase | ||
{ | ||
public Snes8BppPlanarFormat() | ||
{ | ||
base.FormatText = "[8][8]"; | ||
base.Name = "8BPP SNES Planar"; | ||
base.Extension = "smc,sfc,fig"; | ||
|
||
base.ColorBit = 8; | ||
base.ColorNum = 256; | ||
base.Width = 128; | ||
base.Height = 128; | ||
base.CharWidth = 8; | ||
base.CharHeight = 8; | ||
|
||
base.Readonly = false; | ||
base.IsSupportMirror = true; | ||
base.IsSupportRotate = true; | ||
base.IsCompressed = false; | ||
base.EnableAdf = true; | ||
|
||
base.Author = "ikari_01"; | ||
base.Url = "https://sd2snes.de"; | ||
} | ||
|
||
/* offsets into SNES bitplanes per tile */ | ||
byte[] PlaneOffset = { 0x00, 0x01, 0x10, 0x11, 0x20, 0x21, 0x30, 0x31 }; | ||
|
||
/* bytemap: contains image data in YYCHR internal format */ | ||
/* data: contains image data in source format (ROM) */ | ||
|
||
/* convert from source format (ROM) to YYCHR graphics, one tile at a time */ | ||
public override void ConvertMemToChr(Byte[] data, int addr, Bytemap bytemap, int px, int py) | ||
{ | ||
for (int x = 0; x < CharWidth; x++) | ||
{ | ||
for (int y = 0; y < CharHeight; y++) | ||
{ | ||
byte pixel = 0x00; | ||
|
||
/* gather bits from bitplanes and combine into pixel */ | ||
for (int b = 0; b < ColorBit; b++) | ||
{ | ||
byte tmp = data[addr + PlaneOffset[b] + 2 * y]; | ||
tmp &= (byte)(1 << (CharWidth - 1 - x)); | ||
tmp >>= CharWidth - 1 - x; | ||
tmp <<= b; | ||
pixel |= tmp; | ||
} | ||
|
||
/* get pixel address for requested coordinates in YYCHR bitmap */ | ||
Point p = base.GetAdvancePixelPoint(px + x, py + y); | ||
int bytemapAddr = bytemap.GetPointAddress(p.X, p.Y); | ||
|
||
/* write pixel to YYCHR bitmap */ | ||
bytemap.Data[bytemapAddr] = pixel; | ||
} | ||
} | ||
} | ||
|
||
/* convert from YYCHR graphics to source format (ROM), one tile at a time */ | ||
public override void ConvertChrToMem(Byte[] data, int addr, Bytemap bytemap, int px, int py) | ||
{ | ||
for (int x = 0; x < CharWidth; x++) | ||
{ | ||
/* mask to substitute pixel in ROM data */ | ||
byte mask = (byte)~(1 << (CharWidth - 1 - x)); | ||
for (int y = 0; y < CharHeight; y++) | ||
{ | ||
/* read pixel from YYCHR bitmap */ | ||
Point p = base.GetAdvancePixelPoint(px + x, py + y); | ||
int bytemapAddr = bytemap.GetPointAddress(p.X, p.Y); | ||
byte pixel = bytemap.Data[bytemapAddr]; | ||
for (int b = 0; b < ColorBit; b++) | ||
{ | ||
/* scatter bits from pixel across ROM bitplanes */ | ||
int tileAddr = addr + PlaneOffset[b] + 2 * y; | ||
byte orig = (byte)(data[tileAddr] & mask); | ||
byte bit = (byte)(pixel & (1 << b)); | ||
bit >>= b; | ||
bit <<= (7 - x); | ||
orig |= bit; | ||
data[tileAddr] = orig; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
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,47 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{8D10BCBC-15A3-4324-A68E-E45241C6E11A}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>Snes8BppPlanar</RootNamespace> | ||
<AssemblyName>Snes8BppPlanar</AssemblyName> | ||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<Deterministic>true</Deterministic> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="CharactorLib, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> | ||
<SpecificVersion>False</SpecificVersion> | ||
<HintPath>.\CharactorLib.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Drawing" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Snes8BppPlanar.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.6.33815.320 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Snes8BppPlanar", "Snes8BppPlanar.csproj", "{8D10BCBC-15A3-4324-A68E-E45241C6E11A}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{8D10BCBC-15A3-4324-A68E-E45241C6E11A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{8D10BCBC-15A3-4324-A68E-E45241C6E11A}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{8D10BCBC-15A3-4324-A68E-E45241C6E11A}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{8D10BCBC-15A3-4324-A68E-E45241C6E11A}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {A5D04AF4-BB3B-4125-A3DA-9BAD5B7B36C4} | ||
EndGlobalSection | ||
EndGlobal |