Skip to content

Commit 61a4e88

Browse files
committed
Add archived files
1 parent 5b6580f commit 61a4e88

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+10028
-0
lines changed

s2prototype.sln

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 2012
4+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "s2prototype", "s2prototype\s2prototype.csproj", "{5E2B7BF4-6F4C-4DCC-93A8-DAA31AF01848}"
5+
EndProject
6+
Global
7+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
8+
Debug|Any CPU = Debug|Any CPU
9+
Release|Any CPU = Release|Any CPU
10+
EndGlobalSection
11+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
12+
{5E2B7BF4-6F4C-4DCC-93A8-DAA31AF01848}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
13+
{5E2B7BF4-6F4C-4DCC-93A8-DAA31AF01848}.Debug|Any CPU.Build.0 = Debug|Any CPU
14+
{5E2B7BF4-6F4C-4DCC-93A8-DAA31AF01848}.Release|Any CPU.ActiveCfg = Release|Any CPU
15+
{5E2B7BF4-6F4C-4DCC-93A8-DAA31AF01848}.Release|Any CPU.Build.0 = Release|Any CPU
16+
EndGlobalSection
17+
GlobalSection(SolutionProperties) = preSolution
18+
HideSolutionNode = FALSE
19+
EndGlobalSection
20+
EndGlobal

s2prototype/Animation.cs

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+

2+
namespace IntelOrca.Sonic
3+
{
4+
class Animation
5+
{
6+
private byte[][] mScripts;
7+
private int mIndex;
8+
private int mNextIndex;
9+
private int mFrame;
10+
private int mFrameDuration;
11+
private int mFrameValue;
12+
13+
public Animation()
14+
{
15+
}
16+
17+
public Animation(byte[][] scripts)
18+
{
19+
mScripts = scripts;
20+
}
21+
22+
public void Update()
23+
{
24+
if (mIndex != mNextIndex) {
25+
mNextIndex = mIndex;
26+
mFrame = 0;
27+
mFrameDuration = 0;
28+
}
29+
30+
if (mScripts == null)
31+
return;
32+
33+
if (mIndex >= mScripts.Length)
34+
return;
35+
36+
byte[] animationScript = mScripts[mIndex];
37+
mFrameDuration--;
38+
if (mFrameDuration >= 0)
39+
return;
40+
41+
mFrameDuration = animationScript[0];
42+
ProcessScript(animationScript);
43+
}
44+
45+
private void ProcessScript(byte[] animationScript)
46+
{
47+
byte asf = animationScript[mFrame + 1];
48+
switch (asf) {
49+
case 0xFF:
50+
mFrameValue = animationScript[1];
51+
mFrame = 0;
52+
break;
53+
case 0xFE:
54+
mFrame -= animationScript[mFrame + 2];
55+
mFrameValue = animationScript[mFrame + 1];
56+
mFrame++;
57+
break;
58+
case 0xFD:
59+
mIndex = animationScript[mFrame + 2];
60+
break;
61+
default:
62+
mFrameValue = asf;
63+
mFrame++;
64+
break;
65+
}
66+
}
67+
68+
public byte[][] Scripts
69+
{
70+
get
71+
{
72+
return mScripts;
73+
}
74+
set
75+
{
76+
mScripts = value;
77+
}
78+
}
79+
80+
public int Index
81+
{
82+
get
83+
{
84+
return mIndex;
85+
}
86+
set
87+
{
88+
mIndex = value;
89+
}
90+
}
91+
92+
public int NextIndex
93+
{
94+
get
95+
{
96+
return mNextIndex;
97+
}
98+
set
99+
{
100+
mNextIndex = value;
101+
}
102+
}
103+
104+
public int Frame
105+
{
106+
get
107+
{
108+
return mFrame;
109+
}
110+
set
111+
{
112+
mFrame = value;
113+
}
114+
}
115+
116+
public int FrameDuration
117+
{
118+
get
119+
{
120+
return mFrameDuration;
121+
}
122+
set
123+
{
124+
mFrameDuration = value;
125+
}
126+
}
127+
128+
public int FrameValue
129+
{
130+
get
131+
{
132+
return mFrameValue;
133+
}
134+
set
135+
{
136+
mFrameValue = value;
137+
}
138+
}
139+
}
140+
}

s2prototype/App.config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
5+
</startup>
6+
</configuration>

s2prototype/Camera.cs

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
using Microsoft.Xna.Framework;
2+
3+
namespace IntelOrca.Sonic
4+
{
5+
class Camera
6+
{
7+
private int mX;
8+
private int mY;
9+
// private int mPartialX;
10+
// private int mPartialY;
11+
private int mBiasY;
12+
private int mScrollDelayX;
13+
14+
public Camera()
15+
{
16+
}
17+
18+
public Rectangle GetViewBounds(Rectangle visibleRegion, int width, int height)
19+
{
20+
Rectangle cameraView = new Rectangle(mX - (width / 2), mY - (height / 2), width, height);
21+
22+
// Ensure minimum position
23+
if (cameraView.X < visibleRegion.X)
24+
cameraView.X = visibleRegion.X;
25+
if (cameraView.Y < visibleRegion.Y)
26+
cameraView.Y = visibleRegion.Y;
27+
28+
// Ensure maximum position
29+
if (cameraView.X + cameraView.Width > visibleRegion.X + visibleRegion.Width)
30+
cameraView.X = visibleRegion.X + visibleRegion.Width - width;
31+
if (cameraView.Y + cameraView.Height > visibleRegion.Y + visibleRegion.Height)
32+
cameraView.Y = visibleRegion.Y + visibleRegion.Height - height;
33+
34+
// Check if still unhandled
35+
if (cameraView.Width > visibleRegion.Width)
36+
cameraView.X = -((visibleRegion.Width - cameraView.Width) / 2);
37+
if (cameraView.Height > visibleRegion.Height)
38+
cameraView.Y = -((visibleRegion.Height - cameraView.Height) / 2);
39+
40+
return cameraView;
41+
}
42+
43+
public int X
44+
{
45+
get
46+
{
47+
return mX;
48+
}
49+
set
50+
{
51+
mX = value;
52+
}
53+
}
54+
55+
public int Y
56+
{
57+
get
58+
{
59+
return mY;
60+
}
61+
set
62+
{
63+
mY = value;
64+
}
65+
}
66+
67+
public int BiasY
68+
{
69+
get
70+
{
71+
return mBiasY;
72+
}
73+
set
74+
{
75+
mBiasY = value;
76+
}
77+
}
78+
79+
public int ScrollDelayX
80+
{
81+
get
82+
{
83+
return mScrollDelayX;
84+
}
85+
set
86+
{
87+
mScrollDelayX = value;
88+
}
89+
}
90+
}
91+
}

s2prototype/ControllerState.cs

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace IntelOrca.Sonic
8+
{
9+
struct ControllerState
10+
{
11+
private int mButtons;
12+
13+
public ControllerState GetNewDown(ControllerState mLastControlState)
14+
{
15+
ControllerState state = new ControllerState();
16+
state.mButtons = mButtons & ~mLastControlState.mButtons;
17+
return state;
18+
}
19+
20+
public void Set(int alterMask, bool state)
21+
{
22+
if (state)
23+
mButtons |= alterMask;
24+
else
25+
mButtons &= ~alterMask;
26+
}
27+
28+
public bool Up
29+
{
30+
get
31+
{
32+
return ((mButtons & 1) != 0);
33+
}
34+
}
35+
36+
public bool Down
37+
{
38+
get
39+
{
40+
return ((mButtons & 2) != 0);
41+
}
42+
}
43+
44+
public bool Left
45+
{
46+
get
47+
{
48+
return ((mButtons & 4) != 0);
49+
}
50+
}
51+
52+
public bool Right
53+
{
54+
get
55+
{
56+
return ((mButtons & 8) != 0);
57+
}
58+
}
59+
60+
public bool Start
61+
{
62+
get
63+
{
64+
return ((mButtons & 16) != 0);
65+
}
66+
}
67+
68+
public bool A
69+
{
70+
get
71+
{
72+
return ((mButtons & 32) != 0);
73+
}
74+
}
75+
76+
public bool B
77+
{
78+
get
79+
{
80+
return ((mButtons & 64) != 0);
81+
}
82+
}
83+
84+
public bool C
85+
{
86+
get
87+
{
88+
return ((mButtons & 128) != 0);
89+
}
90+
}
91+
}
92+
}

0 commit comments

Comments
 (0)