-
Notifications
You must be signed in to change notification settings - Fork 3
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
46 changed files
with
10,028 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,20 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 2012 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "s2prototype", "s2prototype\s2prototype.csproj", "{5E2B7BF4-6F4C-4DCC-93A8-DAA31AF01848}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{5E2B7BF4-6F4C-4DCC-93A8-DAA31AF01848}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{5E2B7BF4-6F4C-4DCC-93A8-DAA31AF01848}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{5E2B7BF4-6F4C-4DCC-93A8-DAA31AF01848}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{5E2B7BF4-6F4C-4DCC-93A8-DAA31AF01848}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |
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,140 @@ | ||
| ||
namespace IntelOrca.Sonic | ||
{ | ||
class Animation | ||
{ | ||
private byte[][] mScripts; | ||
private int mIndex; | ||
private int mNextIndex; | ||
private int mFrame; | ||
private int mFrameDuration; | ||
private int mFrameValue; | ||
|
||
public Animation() | ||
{ | ||
} | ||
|
||
public Animation(byte[][] scripts) | ||
{ | ||
mScripts = scripts; | ||
} | ||
|
||
public void Update() | ||
{ | ||
if (mIndex != mNextIndex) { | ||
mNextIndex = mIndex; | ||
mFrame = 0; | ||
mFrameDuration = 0; | ||
} | ||
|
||
if (mScripts == null) | ||
return; | ||
|
||
if (mIndex >= mScripts.Length) | ||
return; | ||
|
||
byte[] animationScript = mScripts[mIndex]; | ||
mFrameDuration--; | ||
if (mFrameDuration >= 0) | ||
return; | ||
|
||
mFrameDuration = animationScript[0]; | ||
ProcessScript(animationScript); | ||
} | ||
|
||
private void ProcessScript(byte[] animationScript) | ||
{ | ||
byte asf = animationScript[mFrame + 1]; | ||
switch (asf) { | ||
case 0xFF: | ||
mFrameValue = animationScript[1]; | ||
mFrame = 0; | ||
break; | ||
case 0xFE: | ||
mFrame -= animationScript[mFrame + 2]; | ||
mFrameValue = animationScript[mFrame + 1]; | ||
mFrame++; | ||
break; | ||
case 0xFD: | ||
mIndex = animationScript[mFrame + 2]; | ||
break; | ||
default: | ||
mFrameValue = asf; | ||
mFrame++; | ||
break; | ||
} | ||
} | ||
|
||
public byte[][] Scripts | ||
{ | ||
get | ||
{ | ||
return mScripts; | ||
} | ||
set | ||
{ | ||
mScripts = value; | ||
} | ||
} | ||
|
||
public int Index | ||
{ | ||
get | ||
{ | ||
return mIndex; | ||
} | ||
set | ||
{ | ||
mIndex = value; | ||
} | ||
} | ||
|
||
public int NextIndex | ||
{ | ||
get | ||
{ | ||
return mNextIndex; | ||
} | ||
set | ||
{ | ||
mNextIndex = value; | ||
} | ||
} | ||
|
||
public int Frame | ||
{ | ||
get | ||
{ | ||
return mFrame; | ||
} | ||
set | ||
{ | ||
mFrame = value; | ||
} | ||
} | ||
|
||
public int FrameDuration | ||
{ | ||
get | ||
{ | ||
return mFrameDuration; | ||
} | ||
set | ||
{ | ||
mFrameDuration = value; | ||
} | ||
} | ||
|
||
public int FrameValue | ||
{ | ||
get | ||
{ | ||
return mFrameValue; | ||
} | ||
set | ||
{ | ||
mFrameValue = value; | ||
} | ||
} | ||
} | ||
} |
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,6 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> | ||
</startup> | ||
</configuration> |
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,91 @@ | ||
using Microsoft.Xna.Framework; | ||
|
||
namespace IntelOrca.Sonic | ||
{ | ||
class Camera | ||
{ | ||
private int mX; | ||
private int mY; | ||
// private int mPartialX; | ||
// private int mPartialY; | ||
private int mBiasY; | ||
private int mScrollDelayX; | ||
|
||
public Camera() | ||
{ | ||
} | ||
|
||
public Rectangle GetViewBounds(Rectangle visibleRegion, int width, int height) | ||
{ | ||
Rectangle cameraView = new Rectangle(mX - (width / 2), mY - (height / 2), width, height); | ||
|
||
// Ensure minimum position | ||
if (cameraView.X < visibleRegion.X) | ||
cameraView.X = visibleRegion.X; | ||
if (cameraView.Y < visibleRegion.Y) | ||
cameraView.Y = visibleRegion.Y; | ||
|
||
// Ensure maximum position | ||
if (cameraView.X + cameraView.Width > visibleRegion.X + visibleRegion.Width) | ||
cameraView.X = visibleRegion.X + visibleRegion.Width - width; | ||
if (cameraView.Y + cameraView.Height > visibleRegion.Y + visibleRegion.Height) | ||
cameraView.Y = visibleRegion.Y + visibleRegion.Height - height; | ||
|
||
// Check if still unhandled | ||
if (cameraView.Width > visibleRegion.Width) | ||
cameraView.X = -((visibleRegion.Width - cameraView.Width) / 2); | ||
if (cameraView.Height > visibleRegion.Height) | ||
cameraView.Y = -((visibleRegion.Height - cameraView.Height) / 2); | ||
|
||
return cameraView; | ||
} | ||
|
||
public int X | ||
{ | ||
get | ||
{ | ||
return mX; | ||
} | ||
set | ||
{ | ||
mX = value; | ||
} | ||
} | ||
|
||
public int Y | ||
{ | ||
get | ||
{ | ||
return mY; | ||
} | ||
set | ||
{ | ||
mY = value; | ||
} | ||
} | ||
|
||
public int BiasY | ||
{ | ||
get | ||
{ | ||
return mBiasY; | ||
} | ||
set | ||
{ | ||
mBiasY = value; | ||
} | ||
} | ||
|
||
public int ScrollDelayX | ||
{ | ||
get | ||
{ | ||
return mScrollDelayX; | ||
} | ||
set | ||
{ | ||
mScrollDelayX = value; | ||
} | ||
} | ||
} | ||
} |
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,92 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace IntelOrca.Sonic | ||
{ | ||
struct ControllerState | ||
{ | ||
private int mButtons; | ||
|
||
public ControllerState GetNewDown(ControllerState mLastControlState) | ||
{ | ||
ControllerState state = new ControllerState(); | ||
state.mButtons = mButtons & ~mLastControlState.mButtons; | ||
return state; | ||
} | ||
|
||
public void Set(int alterMask, bool state) | ||
{ | ||
if (state) | ||
mButtons |= alterMask; | ||
else | ||
mButtons &= ~alterMask; | ||
} | ||
|
||
public bool Up | ||
{ | ||
get | ||
{ | ||
return ((mButtons & 1) != 0); | ||
} | ||
} | ||
|
||
public bool Down | ||
{ | ||
get | ||
{ | ||
return ((mButtons & 2) != 0); | ||
} | ||
} | ||
|
||
public bool Left | ||
{ | ||
get | ||
{ | ||
return ((mButtons & 4) != 0); | ||
} | ||
} | ||
|
||
public bool Right | ||
{ | ||
get | ||
{ | ||
return ((mButtons & 8) != 0); | ||
} | ||
} | ||
|
||
public bool Start | ||
{ | ||
get | ||
{ | ||
return ((mButtons & 16) != 0); | ||
} | ||
} | ||
|
||
public bool A | ||
{ | ||
get | ||
{ | ||
return ((mButtons & 32) != 0); | ||
} | ||
} | ||
|
||
public bool B | ||
{ | ||
get | ||
{ | ||
return ((mButtons & 64) != 0); | ||
} | ||
} | ||
|
||
public bool C | ||
{ | ||
get | ||
{ | ||
return ((mButtons & 128) != 0); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.