Skip to content

Commit 666cb20

Browse files
create frames debug update
1 parent 95182dc commit 666cb20

File tree

7 files changed

+66
-71
lines changed

7 files changed

+66
-71
lines changed

PPMLib/FodyWeavers.xsd

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,6 @@
1717
<xs:documentation>A list of assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks.</xs:documentation>
1818
</xs:annotation>
1919
</xs:element>
20-
<xs:element minOccurs="0" maxOccurs="1" name="ExcludeRuntimeAssemblies" type="xs:string">
21-
<xs:annotation>
22-
<xs:documentation>A list of (.NET Core) runtime assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks</xs:documentation>
23-
</xs:annotation>
24-
</xs:element>
25-
<xs:element minOccurs="0" maxOccurs="1" name="IncludeRuntimeAssemblies" type="xs:string">
26-
<xs:annotation>
27-
<xs:documentation>A list of (.NET Core) runtime assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks.</xs:documentation>
28-
</xs:annotation>
29-
</xs:element>
3020
<xs:element minOccurs="0" maxOccurs="1" name="Unmanaged32Assemblies" type="xs:string">
3121
<xs:annotation>
3222
<xs:documentation>A list of unmanaged 32 bit assembly names to include, delimited with line breaks.</xs:documentation>
@@ -53,11 +43,6 @@
5343
<xs:documentation>Controls if .pdbs for reference assemblies are also embedded.</xs:documentation>
5444
</xs:annotation>
5545
</xs:attribute>
56-
<xs:attribute name="IncludeRuntimeReferences" type="xs:boolean">
57-
<xs:annotation>
58-
<xs:documentation>Controls if (.NET Core) runtime assemblies are also embedded.</xs:documentation>
59-
</xs:annotation>
60-
</xs:attribute>
6146
<xs:attribute name="DisableCompression" type="xs:boolean">
6247
<xs:annotation>
6348
<xs:documentation>Embedded assemblies are compressed by default, and uncompressed when they are loaded. You can turn compression off with this option.</xs:documentation>
@@ -88,16 +73,6 @@
8873
<xs:documentation>A list of assembly names to include from the default action of "embed all Copy Local references", delimited with |.</xs:documentation>
8974
</xs:annotation>
9075
</xs:attribute>
91-
<xs:attribute name="ExcludeRuntimeAssemblies" type="xs:string">
92-
<xs:annotation>
93-
<xs:documentation>A list of (.NET Core) runtime assembly names to exclude from the default action of "embed all Copy Local references", delimited with |</xs:documentation>
94-
</xs:annotation>
95-
</xs:attribute>
96-
<xs:attribute name="IncludeRuntimeAssemblies" type="xs:string">
97-
<xs:annotation>
98-
<xs:documentation>A list of (.NET Core) runtime assembly names to include from the default action of "embed all Copy Local references", delimited with |.</xs:documentation>
99-
</xs:annotation>
100-
</xs:attribute>
10176
<xs:attribute name="Unmanaged32Assemblies" type="xs:string">
10277
<xs:annotation>
10378
<xs:documentation>A list of unmanaged 32 bit assembly names to include, delimited with |.</xs:documentation>

PPMLib/PPMFile.cs

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -133,16 +133,17 @@ public void Parse(byte[] bytes)
133133

134134
}
135135

136-
public void Create(string authorName, ulong authorId, List<PPMFrame> frames, byte[] audio, bool ignoreMetadata = false)
136+
public static PPMFile Create(string authorName, ulong authorId, List<PPMFrame> frames, byte[] audio, bool ignoreMetadata = false)
137137
{
138-
FrameCount = (ushort)(frames.Count - 1);
139-
FormatVersion = 0x24;
138+
var file = new PPMFile();
139+
file.FrameCount = (ushort)(frames.Count - 1);
140+
file.FormatVersion = 0x24;
140141

141142
if (!ignoreMetadata)
142143
{
143-
RootAuthor = new PPMAuthor(authorName, authorId);
144-
ParentAuthor = new PPMAuthor(authorName, authorId);
145-
CurrentAuthor = new PPMAuthor(authorName, authorId);
144+
file.RootAuthor = new PPMAuthor(authorName, authorId);
145+
file.ParentAuthor = new PPMAuthor(authorName, authorId);
146+
file.CurrentAuthor = new PPMAuthor(authorName, authorId);
146147

147148
string mac6 = string.Join("", BitConverter.GetBytes(authorId).Take(3).Reverse().Select(t => t.ToString("X2")));
148149
var asm = Assembly.GetEntryAssembly().GetName().Version;
@@ -174,8 +175,8 @@ public void Create(string authorName, ulong authorId, List<PPMFrame> frames, byt
174175
}
175176
rawfn[16] = rawfn[17] = 0;
176177

177-
ParentFilename = new PPMFilename(rawfn);
178-
CurrentFilename = new PPMFilename(rawfn);
178+
file.ParentFilename = new PPMFilename(rawfn);
179+
file.CurrentFilename = new PPMFilename(rawfn);
179180

180181
var ByteRootFileFragment = new byte[8];
181182
for (int i = 0; i < 3; i++)
@@ -190,44 +191,46 @@ public void Create(string authorName, ulong authorId, List<PPMFrame> frames, byt
190191
+ byte.Parse("" + _13str[2 * (i - 3) + 1], System.Globalization.NumberStyles.HexNumber));
191192
}
192193

193-
RootFileFragment = new PPMFileFragment(ByteRootFileFragment);
194+
file.RootFileFragment = new PPMFileFragment(ByteRootFileFragment);
194195

195-
Timestamp = new PPMTimestamp((uint)((dt - new DateTime(2000, 1, 1, 0, 0, 0)).TotalSeconds));
196-
Thumbnail = new PPMThumbnail(new byte[0x600]);
197-
ThumbnailFrameIndex = 0;
196+
file.Timestamp = new PPMTimestamp((uint)((dt - new DateTime(2000, 1, 1, 0, 0, 0)).TotalSeconds));
197+
file.Thumbnail = new PPMThumbnail(new byte[0x600]);
198+
file.ThumbnailFrameIndex = 0;
198199
}
199200
// write the audio data
200201

201202
uint animDataSize = (uint)(8 + 4 * frames.Count);
202203

203-
FrameOffsetTableSize = (ushort)(4 * frames.Count);
204-
AnimationFlags = BitConverter.ToUInt16(BitConverter.GetBytes(0x00430000), 0);
204+
file.AnimationFlags = 0x43;
205+
file.FrameOffsetTableSize = (ushort)(4 * frames.Count);
206+
file.AnimationFlags = BitConverter.ToUInt16(BitConverter.GetBytes(0x00430000), 0);
205207

206-
Frames = new PPMFrame[frames.Count];
208+
file.Frames = new PPMFrame[frames.Count];
207209
//SoundEffectFlags = new byte[frames.Count];
208210

209211
for (int i = 0; i < frames.Count; i++)
210212
{
211213

212-
Frames[i] = frames[i];
214+
file.Frames[i] = frames[i];
213215

214216

215-
animDataSize += (uint)Frames[i].ToByteArray().Length;
217+
animDataSize += (uint)file.Frames[i].ToByteArray().Length;
216218
}
217219
while ((animDataSize & 0x3) != 0) animDataSize++;
218-
AnimationDataSize = animDataSize;
220+
file.AnimationDataSize = animDataSize;
219221

220-
Audio = new PPMAudio();
221-
Audio.SoundData.RawBGM = audio;
222-
Audio.SoundHeader.BGMTrackSize = (uint)Audio.SoundData.RawBGM.Length;
223-
Audio.SoundHeader.SE1TrackSize = 0;
224-
Audio.SoundHeader.SE2TrackSize = 0;
225-
Audio.SoundHeader.SE2TrackSize = 0;
226-
SoundDataSize = (uint)Audio.SoundData.RawBGM.Length;
227-
228-
Audio.SoundHeader.CurrentFramespeed = 0;
229-
Audio.SoundHeader.RecordingBGMFramespeed = 0;
230-
222+
file.Audio = new PPMAudio();
223+
file.Audio.SoundData.RawBGM = audio;
224+
file.Audio.SoundHeader.BGMTrackSize = (uint)file.Audio.SoundData.RawBGM.Length;
225+
file.Audio.SoundHeader.SE1TrackSize = 0;
226+
file.Audio.SoundHeader.SE2TrackSize = 0;
227+
file.Audio.SoundHeader.SE2TrackSize = 0;
228+
file.SoundDataSize = (uint)file.Audio.SoundData.RawBGM.Length;
229+
230+
file.Audio.SoundHeader.CurrentFramespeed = 0;
231+
file.Audio.SoundHeader.RecordingBGMFramespeed = 0;
232+
233+
return file;
231234
}
232235

233236
public void Save(string fn)
@@ -243,7 +246,7 @@ public void Save(string fn)
243246
w.Write(SoundDataSize);
244247
w.Write(FrameCount);
245248
w.Write((ushort)0x0024);
246-
w.Write(IsLocked);
249+
w.Write((ushort)(IsLocked ? 1 : 0));
247250
w.Write(ThumbnailFrameIndex);
248251
w.Write(Encoding.Unicode.GetBytes(RootAuthor.Name.PadRight(11, '\0')));
249252
w.Write(Encoding.Unicode.GetBytes(ParentAuthor.Name.PadRight(11, '\0')));
@@ -259,7 +262,7 @@ public void Save(string fn)
259262
w.Write(Thumbnail.Buffer);
260263

261264
w.Write(FrameOffsetTableSize);
262-
w.Write((ushort)0); // 0x06A2
265+
w.Write((uint)0); // 0x06A2
263266
w.Write(AnimationFlags);
264267

265268
// Calculate frame offsets & write frame data
@@ -268,6 +271,7 @@ public void Save(string fn)
268271
for (int i = 0; i < Frames.Length; i++)
269272
{
270273
lst.Add(Frames[i].ToByteArray());
274+
//MessageBox.Show(offset.ToString());
271275
w.Write(offset);
272276
offset += (uint)lst[i].Length;
273277
}

PPMLib/PPMFrame.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.Diagnostics;using System.Drawing;using System.Windows.Forms;

namespace PPMLib{public class PPMFrame{

 private PPMLayer _layer1 = new PPMLayer();private PPMLayer _layer2 = new PPMLayer();private PaperColor _paperColor;private Bitmap _frame = new Bitmap(256, 192);private int _animationIndex;public byte _firstByteHeader;public int _translateX;public int _translateY;

 /// <summary>
 /// Overwrite frame data
 /// </summary>
 /// <param name="prev">Frame data to apply</param>
 public void Overwrite(PPMFrame prev) // Just use current frame
 {
 if ((_firstByteHeader & 0x80) != 0)
 {
 return;
 } 
 // < There is NOT a mistake anywhere 
 int ld0 = ((_translateX >= 0) ? (_translateX >> 3) : 0);
 int pi0 = (_translateX >= 0) ? 0 : ((-_translateX) >> 3);
 byte del = (byte)(_translateX >= 0 ? (_translateX & 7) : (((byte)(_translateX)) & 7)); 
 byte ndel = (byte)(8 - del);
 byte alpha = (byte)((1 << (8 - del)) - 1);
 byte nalpha = (byte)~alpha;
 int pi, ld;
 if (_translateX >= 0) 
 {
 for (int y = 0; y < 192; y++)
 {
 if (y < _translateY) continue;
 if (y - _translateY >= 192) break;
 ld = (y << 5) + ld0;
 pi = ((y - _translateY) << 5) + pi0;
 Layer1[ld] ^= (byte)(prev.Layer1[pi] & alpha);
 Layer2[ld++] ^= (byte)(prev.Layer2[pi] & alpha);
 while ((ld & 31) < 31)
 {
 Layer1[ld] ^= (byte)(((prev.Layer1[pi] & nalpha) >> ndel) | ((prev.Layer1[pi + 1] & alpha) << del));
 Layer2[ld] ^= (byte)(((prev.Layer2[pi] & nalpha) >> ndel) | ((prev.Layer2[pi + 1] & alpha) << del)); 
 ld++; pi++;
 }
 Layer1[ld] ^= (byte)((prev.Layer1[pi] & nalpha) | (prev.Layer1[pi + 1] & alpha));
 Layer2[ld] ^= (byte)((prev.Layer2[pi] & nalpha) | (prev.Layer2[pi + 1] & alpha)); 
 }
 }
 else
 {
 for (ushort y = 0; y < 192; y++)
 {
 if (y < _translateY) continue;
 if (y - _translateY >= 192) break;
 ld = (y << 5) + ld0;
 pi = ((y - _translateY) << 5) + pi0;
 while ((pi & 31) < 31)
 {
 Layer1[ld] ^= (byte)(((prev.Layer1[pi] & nalpha) >> ndel) | ((prev.Layer1[pi + 1] & alpha) << del));
 Layer2[ld] ^= (byte)(((prev.Layer2[pi] & nalpha) >> ndel) | ((prev.Layer2[pi + 1] & alpha) << del));
 ld++; pi++;
 }
 Layer1[ld] ^= (byte)(prev.Layer1[pi] & nalpha);
 Layer2[ld] ^= (byte)(prev.Layer2[pi] & nalpha);
 }
 }
 }

 public PPMFrame CreateDiff0(PPMFrame prev)
3+
using System.Diagnostics;using System.Drawing;

namespace PPMLib{public class PPMFrame{

 private PPMLayer _layer1 = new PPMLayer();private PPMLayer _layer2 = new PPMLayer();private PaperColor _paperColor;private Bitmap _frame = new Bitmap(256, 192);private int _animationIndex;public byte _firstByteHeader;public int _translateX;public int _translateY;

 /// <summary>
 /// Overwrite frame data
 /// </summary>
 /// <param name="prev">Frame data to apply</param>
 public void Overwrite(PPMFrame prev) // Just use current frame
 {
 if ((_firstByteHeader & 0x80) != 0)
 {
 return;
 } 
 // < There is NOT a mistake anywhere 
 int ld0 = ((_translateX >= 0) ? (_translateX >> 3) : 0);
 int pi0 = (_translateX >= 0) ? 0 : ((-_translateX) >> 3);
 byte del = (byte)(_translateX >= 0 ? (_translateX & 7) : (((byte)(_translateX)) & 7)); 
 byte ndel = (byte)(8 - del);
 byte alpha = (byte)((1 << (8 - del)) - 1);
 byte nalpha = (byte)~alpha;
 int pi, ld;
 if (_translateX >= 0) 
 {
 for (int y = 0; y < 192; y++)
 {
 if (y < _translateY) continue;
 if (y - _translateY >= 192) break;
 ld = (y << 5) + ld0;
 pi = ((y - _translateY) << 5) + pi0;
 Layer1[ld] ^= (byte)(prev.Layer1[pi] & alpha);
 Layer2[ld++] ^= (byte)(prev.Layer2[pi] & alpha);
 while ((ld & 31) < 31)
 {
 Layer1[ld] ^= (byte)(((prev.Layer1[pi] & nalpha) >> ndel) | ((prev.Layer1[pi + 1] & alpha) << del));
 Layer2[ld] ^= (byte)(((prev.Layer2[pi] & nalpha) >> ndel) | ((prev.Layer2[pi + 1] & alpha) << del)); 
 ld++; pi++;
 }
 Layer1[ld] ^= (byte)((prev.Layer1[pi] & nalpha) | (prev.Layer1[pi + 1] & alpha));
 Layer2[ld] ^= (byte)((prev.Layer2[pi] & nalpha) | (prev.Layer2[pi + 1] & alpha)); 
 }
 }
 else
 {
 for (ushort y = 0; y < 192; y++)
 {
 if (y < _translateY) continue;
 if (y - _translateY >= 192) break;
 ld = (y << 5) + ld0;
 pi = ((y - _translateY) << 5) + pi0;
 while ((pi & 31) < 31)
 {
 Layer1[ld] ^= (byte)(((prev.Layer1[pi] & nalpha) >> ndel) | ((prev.Layer1[pi + 1] & alpha) << del));
 Layer2[ld] ^= (byte)(((prev.Layer2[pi] & nalpha) >> ndel) | ((prev.Layer2[pi + 1] & alpha) << del));
 ld++; pi++;
 }
 Layer1[ld] ^= (byte)(prev.Layer1[pi] & nalpha);
 Layer2[ld] ^= (byte)(prev.Layer2[pi] & nalpha);
 }
 }
 }

 public PPMFrame CreateDiff0(PPMFrame prev)
44
{
55
var frame = new PPMFrame();
66
frame._firstByteHeader = _firstByteHeader;

PPMLib/PPMLib.csproj

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<Import Project="..\packages\Costura.Fody.5.0.2\build\Costura.Fody.props" Condition="Exists('..\packages\Costura.Fody.5.0.2\build\Costura.Fody.props')" />
3+
<Import Project="..\packages\Costura.Fody.3.3.3\build\Costura.Fody.props" Condition="Exists('..\packages\Costura.Fody.3.3.3\build\Costura.Fody.props')" />
44
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
55
<PropertyGroup>
66
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -37,8 +37,8 @@
3737
<Prefer32Bit>false</Prefer32Bit>
3838
</PropertyGroup>
3939
<ItemGroup>
40-
<Reference Include="Costura, Version=5.0.2.0, Culture=neutral, processorArchitecture=MSIL">
41-
<HintPath>..\packages\Costura.Fody.5.0.2\lib\netstandard1.0\Costura.dll</HintPath>
40+
<Reference Include="Costura, Version=3.3.3.0, Culture=neutral, PublicKeyToken=9919ef960d84173d, processorArchitecture=MSIL">
41+
<HintPath>..\packages\Costura.Fody.3.3.3\lib\net40\Costura.dll</HintPath>
4242
</Reference>
4343
<Reference Include="FFMpegCore, Version=3.0.0.0, Culture=neutral, processorArchitecture=MSIL">
4444
<HintPath>..\packages\FFMpegCore.4.0.0\lib\netstandard2.0\FFMpegCore.dll</HintPath>
@@ -217,7 +217,6 @@
217217
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
218218
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll</HintPath>
219219
</Reference>
220-
<Reference Include="System.Windows.Forms" />
221220
<Reference Include="System.Xml.Linq" />
222221
<Reference Include="System.Data.DataSetExtensions" />
223222
<Reference Include="Microsoft.CSharp" />
@@ -263,12 +262,12 @@
263262
<None Include="packages.config" />
264263
</ItemGroup>
265264
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
266-
<Import Project="..\packages\Fody.6.3.0\build\Fody.targets" Condition="Exists('..\packages\Fody.6.3.0\build\Fody.targets')" />
265+
<Import Project="..\packages\Fody.4.2.1\build\Fody.targets" Condition="Exists('..\packages\Fody.4.2.1\build\Fody.targets')" />
267266
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
268267
<PropertyGroup>
269268
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
270269
</PropertyGroup>
271-
<Error Condition="!Exists('..\packages\Fody.6.3.0\build\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.6.3.0\build\Fody.targets'))" />
272-
<Error Condition="!Exists('..\packages\Costura.Fody.5.0.2\build\Costura.Fody.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Costura.Fody.5.0.2\build\Costura.Fody.props'))" />
270+
<Error Condition="!Exists('..\packages\Fody.4.2.1\build\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.4.2.1\build\Fody.targets'))" />
271+
<Error Condition="!Exists('..\packages\Costura.Fody.3.3.3\build\Costura.Fody.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Costura.Fody.3.3.3\build\Costura.Fody.props'))" />
273272
</Target>
274273
</Project>

0 commit comments

Comments
 (0)