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
99b0e4f
commit d3f34df
Showing
12 changed files
with
424 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,5 @@ | ||
|
||
����� | ||
����� | ||
����� | ||
� |
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,279 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using SonicRetro.SonLVL.API; | ||
using System.Drawing; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace GHZ | ||
{ | ||
public class GHZ : SonicBGScrollSaver.Level | ||
{ | ||
readonly BWL[] CloudScroll = new BWL[3]; | ||
int[] Horiz_Scroll_Buf; | ||
int Camera_X_pos; | ||
BWL Camera_BG2_X_pos, Camera_BG3_X_pos; | ||
BitmapBits levelimg, tmpimg; | ||
Bitmap bgimg = new Bitmap(1, 1); | ||
Color[] Pal_GHZCyc; | ||
short PalCycle_Timer, PalCycle_Frame; | ||
int Width, Height; | ||
|
||
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; | ||
levelimg = LevelData.DrawBackground(null, true, true, false, false); | ||
tmpimg = new BitmapBits(Math.Min(levelimg.Width, width), height); | ||
tmpimg.Bits.FastFill(0x31); | ||
Pal_GHZCyc = SonLVLColor.Load("Cycle - GHZ.bin", EngineVersion.S1).Select(a => a.RGBColor).ToArray(); | ||
Horiz_Scroll_Buf = new int[levelimg.Height]; | ||
Camera_X_pos = 0; | ||
Array.Clear(CloudScroll, 0, CloudScroll.Length); | ||
Camera_BG2_X_pos = 0; | ||
Camera_BG3_X_pos = 0; | ||
PalCycle_Timer = 0; | ||
PalCycle_Frame = 0; | ||
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; | ||
BWL d4 = (int)Camera_X_pos_diff << 8; | ||
d4.sl <<= 5; | ||
BWL d1 = d4.l; | ||
d4.sl <<= 1; | ||
d4.l += d1.l; | ||
Camera_BG3_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); | ||
int a1 = 0; | ||
int a2 = 0; | ||
CloudScroll[a2++].l += 0x10000; | ||
CloudScroll[a2++].l += 0xC000; | ||
CloudScroll[a2++].l += 0x8000; | ||
BWL d0 = CloudScroll[0].hw; | ||
d0.w += Camera_BG3_X_pos.hw; | ||
Horiz_Scroll_Buf.FastFill(d0.sw, 0, 0x20); | ||
a1 += 0x20; | ||
d0.w = CloudScroll[1].hw; | ||
d0.w += Camera_BG3_X_pos.hw; | ||
Horiz_Scroll_Buf.FastFill(d0.sw, a1, 0x10); | ||
a1 += 0x10; | ||
d0.w = CloudScroll[2].hw; | ||
d0.w += Camera_BG3_X_pos.hw; | ||
Horiz_Scroll_Buf.FastFill(d0.sw, a1, 0x10); | ||
a1 += 0x10; | ||
Horiz_Scroll_Buf.FastFill(Camera_BG3_X_pos.hsw, a1, 0x30); | ||
a1 += 0x30; | ||
Horiz_Scroll_Buf.FastFill(Camera_BG2_X_pos.hsw, a1, 0x28); | ||
a1 += 0x28; | ||
d0.w = Camera_BG2_X_pos.hw; | ||
BWL d2 = Camera_X_pos; | ||
d2.w -= d0.w; | ||
d2.ExtendL(); | ||
d2.sl <<= 8; | ||
d2.sl /= 0x68; | ||
d2.ExtendL(); | ||
d2.sl <<= 8; | ||
BWL d3 = d0.w; | ||
while (a1 < bmp.Height) | ||
{ | ||
Horiz_Scroll_Buf[a1++] = d3.sw; | ||
d3.Swap(); | ||
d3.l += d2.l; | ||
d3.Swap(); | ||
} | ||
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 UpdatePalette() | ||
{ | ||
if (--PalCycle_Timer == -1) | ||
{ | ||
PalCycle_Timer = 5; | ||
int frame = (PalCycle_Frame++ & 3) * 4; | ||
Array.Copy(Pal_GHZCyc, frame, LevelData.BmpPal.Entries, 0x28, 4); | ||
} | ||
} | ||
|
||
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("GreenHill")] | ||
[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,87 @@ | ||
<?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>{3ED2C63B-5883-498E-8271-DE3FA882A5A8}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>GHZ</RootNamespace> | ||
<AssemblyName>GHZ</AssemblyName> | ||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<TargetFrameworkProfile /> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>..\bin\Debug\GHZ\</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\GHZ\</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="GHZ.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="blocks.bin"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
<None Include="chunks.bin"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
<None Include="Cycle - GHZ.bin"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
<None Include="palette.bin"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
<None Include="layout.bin"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
<None Include="setup.ini"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
<None Include="Sonic.bin"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
<None Include="art.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.