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
1 parent
44097a0
commit d779117
Showing
13 changed files
with
441 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
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 @@ | ||
��������Q���A���A�E��Y�_������������A���AAQD�E�T�DTTDUUtEuUuEuWuWuWUWuwU�uwu����������Y���I���_��T_��U���U���UU��_U���_���_�QQ������E�DDUODEUTDEWTTEWUWUwUWuw_������_�QQ�������������������������O��DDTEUE�EuE�UuEEuuWEuuWUUuwUWuw�WuW�wwW�������Q��������������������Y���I���I���D�_�T�O�tADtDAtTEItDEIuDUEuEWTuEwTwWWUuWW_wWW_���������������������T��D��TD��DT�DT�DWT�EWTTWTDwtDEwWDUwDUuuTUuuuUuuu�wuw�wu�q�u����������������������������������D��DDI�TOIDTODEtADWDAEWEDUWuTUwutUuutWuwuW�wW�W_�W���������A���Q����T��D�D�T�O�D�_�T��T���������������O�D�D�T�T�T�UEu�WWu�WWu��������������������O���O��I��AY�IO��DO��EE��UOQAAQY��Y���Y�U���T�O�TODEUOTUuOTUu_ |
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,295 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using SonicRetro.SonLVL.API; | ||
using System.Drawing; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace MZ | ||
{ | ||
public class MZ : SonicBGScrollSaver.Level | ||
{ | ||
readonly int[] TempArray_LayerDef = new int[256]; | ||
int[] Horiz_Scroll_Buf; | ||
short Camera_X_pos, Camera_Y_pos; | ||
BWL Camera_BG_X_pos, Camera_BG2_X_pos, Camera_BG3_X_pos; | ||
BitmapBits[] levelimg; | ||
BitmapBits tmpimg; | ||
Bitmap bgimg = new Bitmap(1, 1); | ||
int Width, Height; | ||
int AnimTime, AnimFrame; | ||
|
||
public override void Init(int width, int height) | ||
{ | ||
Width = width; | ||
Height = height; | ||
LevelData.LoadGame("./setup.ini"); | ||
LevelData.LoadLevel("Level", true); | ||
LevelData.BmpPal.Entries[0] = LevelData.Palette[0][2, 0].RGBColor; | ||
int tilecount = LevelData.Tiles.Count; | ||
for (int i = 0; i < 6; i++) | ||
LevelData.Tiles.Add(new byte[0x20]); | ||
byte[] Art_MzTorch = Compression.Decompress("MZ Background Torch.bin", CompressionType.Uncompressed); | ||
levelimg = new BitmapBits[4]; | ||
for (int i = 0; i < 4; i++) | ||
{ | ||
for (int t = 0; t < 6; t++) | ||
Array.Copy(Art_MzTorch, ((i * 6) + t) * 0x20, LevelData.Tiles[tilecount + t], 0, 0x20); | ||
LevelData.UpdateTileArray(); | ||
LevelData.RedrawBlock(0x69, false); | ||
LevelData.RedrawBlock(0x6A, true); | ||
levelimg[i] = LevelData.DrawBackground(null, true, true, false, false); | ||
} | ||
tmpimg = new BitmapBits(Math.Min(levelimg[0].Width, width), height); | ||
Horiz_Scroll_Buf = new int[levelimg[0].Height]; | ||
Camera_X_pos = 0; | ||
Camera_BG_X_pos = 0; | ||
Camera_BG2_X_pos = 0; | ||
Camera_BG3_X_pos = 0; | ||
AnimTime = 1; | ||
AnimFrame = -1; | ||
UpdateAnimatedTiles(); | ||
UpdateScrolling(0, 0); | ||
} | ||
|
||
public override Bitmap GetBG() | ||
{ | ||
return bgimg; | ||
} | ||
|
||
public override void UpdateScrolling(short Camera_X_pos_diff, short Camera_Y_pos_diff) | ||
{ | ||
lock (bgimg) | ||
{ | ||
Camera_X_pos += Camera_X_pos_diff; | ||
Camera_Y_pos = (short)Math.Max(0, Camera_Y_pos + Camera_Y_pos_diff); | ||
if (Camera_Y_pos + Height > levelimg[AnimFrame].Height) | ||
Camera_Y_pos = (short)Math.Max(0, levelimg[AnimFrame].Height - Height); | ||
BWL d4 = (int)(Camera_X_pos_diff << 8); | ||
d4.sl <<= 6; | ||
Camera_BG3_X_pos.l += d4.l; | ||
d4.sl += d4.sl * 2; | ||
Camera_BG_X_pos.l += d4.l; | ||
d4 = (int)(Camera_X_pos_diff << 8); | ||
d4.sl <<= 7; | ||
Camera_BG2_X_pos.l += d4.l; | ||
BitmapBits bmp = new BitmapBits(levelimg[AnimFrame]); | ||
bmp.ScrollVertical(Camera_Y_pos); | ||
if (Height < bmp.Height) | ||
bmp = bmp.GetSection(0, 0, bmp.Width, Height); | ||
int a1 = 0; | ||
BWL d2 = Camera_X_pos; | ||
BWL d0 = d2.sw >> 2; | ||
d0.sw -= d2.sw; | ||
d0.ExtendL(); | ||
d0.sl <<= 3; | ||
d0.sl /= 5; | ||
d0.ExtendL(); | ||
d0.sl <<= 12; | ||
BWL d3 = (short)(d2.sw >> 1); | ||
for (int i = 0; i < 5; i++) | ||
{ | ||
TempArray_LayerDef[a1++] = d3.sw; | ||
d3.Swap(); | ||
d3.l += d0.l; | ||
d3.Swap(); | ||
} | ||
TempArray_LayerDef.FastFill(Camera_BG3_X_pos.hw, a1, 2); | ||
a1 += 2; | ||
TempArray_LayerDef.FastFill(Camera_BG2_X_pos.hw, a1, 9); | ||
a1 += 9; | ||
TempArray_LayerDef.FastFill(Camera_BG_X_pos.hw, a1, TempArray_LayerDef.Length - a1); | ||
int a2 = 0; | ||
d0.sw = Camera_Y_pos; | ||
d2.w = d0.w; | ||
d0.w &= 0x1F0; | ||
d0.sw >>= 4; | ||
a2 = d0.sw; | ||
a1 = 0; | ||
d2.w &= 0xF; | ||
d2.w = (ushort)(16 - d2.w); | ||
while (a1 < bmp.Height) | ||
{ | ||
Horiz_Scroll_Buf.FastFill(TempArray_LayerDef[a2++], a1, d2.w); | ||
a1 += d2.w; | ||
d2.w = (ushort)Math.Min(16, bmp.Height - a1); | ||
} | ||
bmp.ScrollHorizontal((int[])Horiz_Scroll_Buf.Clone()); | ||
if (Width < bmp.Width) | ||
bmp = bmp.GetSection(0, 0, Width, bmp.Height); | ||
tmpimg.DrawBitmapBounded(bmp, 0, tmpimg.Height - bmp.Height); | ||
bgimg = tmpimg.ToBitmap(LevelData.BmpPal); | ||
} | ||
} | ||
|
||
public override void UpdateAnimatedTiles() | ||
{ | ||
if (--AnimTime == 0) | ||
{ | ||
AnimTime = 7; | ||
AnimFrame = (AnimFrame + 1) & 3; | ||
} | ||
} | ||
|
||
public override void PlayMusic() | ||
{ | ||
SonicBGScrollSaver.Music.PlaySong(IniSerializer.Deserialize<MusicInfo>("setup.ini").Music); | ||
} | ||
} | ||
|
||
[StructLayout(LayoutKind.Explicit, Size = 4)] | ||
struct BWL | ||
{ | ||
[FieldOffset(0)] | ||
public byte b; | ||
[FieldOffset(0)] | ||
public sbyte sb; | ||
[FieldOffset(1)] | ||
public byte b1; | ||
[FieldOffset(1)] | ||
public sbyte sb1; | ||
[FieldOffset(2)] | ||
public byte b2; | ||
[FieldOffset(2)] | ||
public sbyte sb2; | ||
[FieldOffset(3)] | ||
public byte b3; | ||
[FieldOffset(3)] | ||
public sbyte sb3; | ||
[FieldOffset(0)] | ||
public ushort w; | ||
[FieldOffset(0)] | ||
public short sw; | ||
[FieldOffset(2)] | ||
public ushort hw; | ||
[FieldOffset(2)] | ||
public short hsw; | ||
[FieldOffset(0)] | ||
public uint l; | ||
[FieldOffset(0)] | ||
public int sl; | ||
|
||
public BWL(byte b) | ||
: this() | ||
{ | ||
this.b = b; | ||
} | ||
|
||
public BWL(sbyte sb) | ||
: this() | ||
{ | ||
this.sb = sb; | ||
} | ||
|
||
public BWL(byte b0, byte b1, byte b2, byte b3) | ||
: this() | ||
{ | ||
b = b0; | ||
this.b1 = b1; | ||
this.b2 = b2; | ||
this.b3 = b3; | ||
} | ||
|
||
public BWL(sbyte sb0, sbyte sb1, sbyte sb2, sbyte sb3) | ||
: this() | ||
{ | ||
sb = sb0; | ||
this.sb1 = sb1; | ||
this.sb2 = sb2; | ||
this.sb3 = sb3; | ||
} | ||
|
||
public BWL(ushort w) | ||
: this() | ||
{ | ||
this.w = w; | ||
} | ||
|
||
public BWL(short sw) | ||
: this() | ||
{ | ||
this.sw = sw; | ||
} | ||
|
||
public BWL(ushort w, ushort hw) | ||
: this() | ||
{ | ||
this.w = w; | ||
this.hw = hw; | ||
} | ||
|
||
public BWL(short sw, short hsw) | ||
: this() | ||
{ | ||
this.sw = sw; | ||
this.hsw = hsw; | ||
} | ||
|
||
public BWL(uint l) | ||
: this() | ||
{ | ||
this.l = l; | ||
} | ||
|
||
public BWL(int sl) | ||
: this() | ||
{ | ||
this.sl = sl; | ||
} | ||
|
||
public void Swap() | ||
{ | ||
ushort tmp = w; | ||
w = hw; | ||
hw = tmp; | ||
} | ||
|
||
public void ExtendW() | ||
{ | ||
sw = sb; | ||
} | ||
|
||
public void ExtendL() | ||
{ | ||
sl = sw; | ||
} | ||
|
||
public static implicit operator BWL(byte b) | ||
{ | ||
return new BWL(b); | ||
} | ||
|
||
public static implicit operator BWL(sbyte sb) | ||
{ | ||
return new BWL(sb); | ||
} | ||
|
||
public static implicit operator BWL(ushort w) | ||
{ | ||
return new BWL(w); | ||
} | ||
|
||
public static implicit operator BWL(short sw) | ||
{ | ||
return new BWL(sw); | ||
} | ||
|
||
public static implicit operator BWL(uint l) | ||
{ | ||
return new BWL(l); | ||
} | ||
|
||
public static implicit operator BWL(int sl) | ||
{ | ||
return new BWL(sl); | ||
} | ||
} | ||
|
||
internal class MusicInfo | ||
{ | ||
[System.ComponentModel.DefaultValue("Marble")] | ||
[IniName("music")] | ||
public string Music { get; set; } | ||
} | ||
} |
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,86 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="12.0" DefaultTargets="Build" 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>{7FE38515-5B1D-4526-86ED-3E144C96745F}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>MZ</RootNamespace> | ||
<AssemblyName>MZ</AssemblyName> | ||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>..\bin\Debug\MZ\</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\MZ\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="SonLVLAPI"> | ||
<HintPath>..\Dependencies\SonLVLAPI.dll</HintPath> | ||
<Private>False</Private> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Drawing" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="MZ.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\SonicBGScrollSaver\SonicBGScrollSaver.csproj"> | ||
<Project>{299a269c-28fe-4a88-ad98-1598973cf327}</Project> | ||
<Name>SonicBGScrollSaver</Name> | ||
<Private>False</Private> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="art.bin"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
<None Include="blocks.bin"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
<None Include="chunks.bin"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
<None Include="layout.bin"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
<None Include="palette.bin"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
<None Include="MZ Background Torch.bin"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
<None Include="setup.ini"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
<None Include="Sonic.bin"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
Oops, something went wrong.