├── .gitattributes ├── .gitignore ├── README.md ├── RSDKv2 ├── Animation.cs ├── ArcContainer.cs ├── BackgroundLayout.cs ├── Bytecode.cs ├── DataFile.cs ├── GameConfig.cs ├── GraphicsImage.cs ├── Object.cs ├── Palette.cs ├── PaletteColour.cs ├── Properties │ └── AssemblyInfo.cs ├── RSDKv2.csproj ├── Reader.cs ├── SaveFiles.cs ├── Scene.cs ├── Script.cs ├── Setup.cs ├── StageConfig.cs ├── StringSet.cs ├── TextFont.cs ├── Tileconfig.cs ├── Tiles128x128.cs ├── Video.cs ├── Writer.cs └── packages.config ├── Sonic-CD-SaveED.sln ├── Sonic-CD-SaveED ├── AboutForm.Designer.cs ├── AboutForm.cs ├── AboutForm.resx ├── App.config ├── MainForm.Designer.cs ├── MainForm.cs ├── MainForm.resx ├── Program.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings ├── SLWSaveForm.Designer.cs ├── SLWSaveForm.cs ├── SLWSaveForm.resx ├── Sonic-CD-SaveED.csproj ├── Steam.cs └── sonic_CD.ico └── packages └── zlib.net.1.0.4.0 ├── lib └── zlib.net.dll └── zlib.net.1.0.4.0.nupkg /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | build/ 21 | bld/ 22 | bin/ 23 | [Bb]in/ 24 | [Oo]bj/ 25 | 26 | # Visual Studio 2015 cache/options directory 27 | .vs/ 28 | 29 | # MSTest test Results 30 | [Tt]est[Rr]esult*/ 31 | [Bb]uild[Ll]og.* 32 | 33 | # NUNIT 34 | *.VisualState.xml 35 | TestResult.xml 36 | 37 | # Build Results of an ATL Project 38 | [Dd]ebugPS/ 39 | [Rr]eleasePS/ 40 | dlldata.c 41 | 42 | # DNX 43 | project.lock.json 44 | artifacts/ 45 | 46 | *_i.c 47 | *_p.c 48 | *_i.h 49 | *.ilk 50 | *.obj 51 | *.pch 52 | *.pdb 53 | *.pgc 54 | *.pgd 55 | *.rsp 56 | *.sbr 57 | *.tlb 58 | *.tli 59 | *.tlh 60 | *.tmp 61 | *.tmp_proj 62 | *.log 63 | *.vspscc 64 | *.vssscc 65 | .builds 66 | *.pidb 67 | *.svclog 68 | *.scc 69 | 70 | # Chutzpah Test files 71 | _Chutzpah* 72 | 73 | # Visual C++ cache files 74 | ipch/ 75 | *.aps 76 | *.ncb 77 | *.opensdf 78 | *.sdf 79 | *.cachefile 80 | 81 | # Visual Studio profiler 82 | *.psess 83 | *.vsp 84 | *.vspx 85 | 86 | # TFS 2012 Local Workspace 87 | $tf/ 88 | 89 | # Guidance Automation Toolkit 90 | *.gpState 91 | 92 | # ReSharper is a .NET coding add-in 93 | _ReSharper*/ 94 | *.[Rr]e[Ss]harper 95 | *.DotSettings.user 96 | 97 | # JustCode is a .NET coding add-in 98 | .JustCode 99 | 100 | # TeamCity is a build add-in 101 | _TeamCity* 102 | 103 | # DotCover is a Code Coverage Tool 104 | *.dotCover 105 | 106 | # NCrunch 107 | _NCrunch_* 108 | .*crunch*.local.xml 109 | 110 | # MightyMoose 111 | *.mm.* 112 | AutoTest.Net/ 113 | 114 | # Web workbench (sass) 115 | .sass-cache/ 116 | 117 | # Installshield output folder 118 | [Ee]xpress/ 119 | 120 | # DocProject is a documentation generator add-in 121 | DocProject/buildhelp/ 122 | DocProject/Help/*.HxT 123 | DocProject/Help/*.HxC 124 | DocProject/Help/*.hhc 125 | DocProject/Help/*.hhk 126 | DocProject/Help/*.hhp 127 | DocProject/Help/Html2 128 | DocProject/Help/html 129 | 130 | # Click-Once directory 131 | publish/ 132 | 133 | # Publish Web Output 134 | *.[Pp]ublish.xml 135 | *.azurePubxml 136 | ## TODO: Comment the next line if you want to checkin your 137 | ## web deploy settings but do note that will include unencrypted 138 | ## passwords 139 | #*.pubxml 140 | 141 | *.publishproj 142 | 143 | # NuGet Packages 144 | *.nupkg 145 | # The packages folder can be ignored because of Package Restore 146 | **/packages/* 147 | # except build/, which is used as an MSBuild target. 148 | !**/packages/build/ 149 | # Uncomment if necessary however generally it will be regenerated when needed 150 | #!**/packages/repositories.config 151 | 152 | # Windows Azure Build Output 153 | csx/ 154 | *.build.csdef 155 | 156 | # Windows Store app package directory 157 | AppPackages/ 158 | 159 | # Visual Studio cache files 160 | # files ending in .cache can be ignored 161 | *.[Cc]ache 162 | # but keep track of directories ending in .cache 163 | !*.[Cc]ache/ 164 | 165 | # Others 166 | ClientBin/ 167 | [Ss]tyle[Cc]op.* 168 | ~$* 169 | *~ 170 | *.dbmdl 171 | *.dbproj.schemaview 172 | *.pfx 173 | *.publishsettings 174 | node_modules/ 175 | orleans.codegen.cs 176 | 177 | # RIA/Silverlight projects 178 | Generated_Code/ 179 | 180 | # Backup & report files from converting an old project file 181 | # to a newer Visual Studio version. Backup files are not needed, 182 | # because we have git ;-) 183 | _UpgradeReport_Files/ 184 | Backup*/ 185 | UpgradeLog*.XML 186 | UpgradeLog*.htm 187 | 188 | # SQL Server files 189 | *.mdf 190 | *.ldf 191 | 192 | # Business Intelligence projects 193 | *.rdl.data 194 | *.bim.layout 195 | *.bim_*.settings 196 | 197 | # Microsoft Fakes 198 | FakesAssemblies/ 199 | 200 | # Node.js Tools for Visual Studio 201 | .ntvs_analysis.dat 202 | 203 | # Visual Studio 6 build log 204 | *.plg 205 | 206 | # Visual Studio 6 workspace options file 207 | *.opt 208 | 209 | # LightSwitch generated files 210 | GeneratedArtifacts/ 211 | _Pvt_Extensions/ 212 | ModelManifest.xml 213 | 214 | # ============================================= # 215 | # Visual Studio / MonoDevelop / Rider generated # 216 | # ============================================= # 217 | [Ee]xported[Oo]bj/ 218 | /*.unityproj 219 | /*.booproj 220 | /.idea*/ 221 | 222 | # ============ # 223 | # OS generated # 224 | # ============ # 225 | .DS_Store* 226 | ._* 227 | .Spotlight-V100 228 | .Trashes 229 | ehthumbs.db 230 | [Tt]humbs.db 231 | [Dd]esktop.ini 232 | 233 | # Other 234 | Ignored/ -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SonicCD SaveEditor - By Rubberduckycooly and Beta Angel 2 | 3 | A save file editor for Sonic CD (2011)! 4 | 5 | This program can edit all the values used by the game to save progress and settings (it does not edit time attack data!) 6 | however, some values functions are unknown, but the program can modify them regardless... 7 | 8 | My Github: you're on it lol 9 | 10 | Beta Angel's Github: https://github.com/BetaAngel 11 | -------------------------------------------------------------------------------- /RSDKv2/Animation.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace RSDKv2 8 | { 9 | [Serializable] 10 | public class Animation : ICloneable 11 | { 12 | public object Clone() 13 | { 14 | return this.MemberwiseClone(); 15 | } 16 | /// 17 | /// a string to be added to the start of the path 18 | /// 19 | public string PathMod 20 | { 21 | get 22 | { 23 | return "..\\sprites\\"; 24 | } 25 | } 26 | 27 | /// 28 | /// if this is set then only allow one sheet (meaning it'll be used for Objects and not the player) 29 | /// 30 | public bool isObjectAni = false; 31 | 32 | /// 33 | /// a List of paths to the spritesheets, relative to "Data/Sprites" 34 | /// 35 | public List SpriteSheets = new List(); 36 | 37 | /// 38 | /// a list of the hitboxes that the animations can use 39 | /// 40 | public List CollisionBoxes = new List(); 41 | /// 42 | /// a list of Animations in the file 43 | /// 44 | public List Animations = new List(); 45 | 46 | [Serializable] 47 | public class sprAnimation : ICloneable 48 | { 49 | public object Clone() 50 | { 51 | return this.MemberwiseClone(); 52 | } 53 | [Serializable] 54 | public class sprFrame : ICloneable 55 | { 56 | public object Clone() 57 | { 58 | return this.MemberwiseClone(); 59 | } 60 | public struct HitBox 61 | { 62 | public short Left, Right, Top, Bottom; 63 | } 64 | 65 | public List HitBoxes = new List(); 66 | /// 67 | /// the spritesheet index 68 | /// 69 | public byte SpriteSheet = 0; 70 | /// 71 | /// the collision box 72 | /// 73 | public byte CollisionBox = 0; 74 | /// 75 | /// the delay of each frame before advancing to the next one in frames (always 256) 76 | /// 77 | public readonly short Delay = 256; 78 | /// 79 | /// the Xpos on the sheet 80 | /// 81 | public byte X = 0; 82 | /// 83 | /// the YPos on the sheet 84 | /// 85 | public byte Y = 0; 86 | /// 87 | /// the frame's width 88 | /// 89 | public byte Width = 0; 90 | /// 91 | /// the frame's height 92 | /// 93 | public byte Height = 0; 94 | /// 95 | /// the offsetX of the frame 96 | /// 97 | public SByte PivotX = 0; 98 | /// 99 | /// the offsetY of the frame 100 | /// 101 | public SByte PivotY = 0; 102 | 103 | public sprFrame() 104 | { 105 | 106 | } 107 | 108 | public sprFrame(Reader reader, Animation anim = null) 109 | { 110 | SpriteSheet = reader.ReadByte(); 111 | CollisionBox = reader.ReadByte(); 112 | X = reader.ReadByte(); 113 | Y = reader.ReadByte(); 114 | Width = reader.ReadByte(); 115 | Height = reader.ReadByte(); 116 | PivotX = reader.ReadSByte(); 117 | PivotY = reader.ReadSByte(); 118 | } 119 | 120 | public void Write(Writer writer) 121 | { 122 | writer.Write(SpriteSheet); 123 | writer.Write(CollisionBox); 124 | writer.Write(X); 125 | writer.Write(Y); 126 | writer.Write(Width); 127 | writer.Write(Height); 128 | writer.Write(PivotX); 129 | writer.Write(PivotY); 130 | } 131 | 132 | } 133 | 134 | /// 135 | /// the name of the animation 136 | /// 137 | public string AnimName; 138 | /// 139 | /// a list of frames in the animation 140 | /// 141 | public List Frames = new List(); 142 | /// 143 | /// what frame to loop back from 144 | /// 145 | public byte LoopIndex; 146 | /// 147 | /// the speed multiplyer of the animation 148 | /// 149 | public byte SpeedMultiplyer; 150 | /// 151 | /// the rotation style of the animation 152 | /// 153 | public byte RotationFlags; 154 | 155 | public sprAnimation() 156 | { 157 | 158 | } 159 | 160 | public sprAnimation(Reader reader, Animation anim = null) 161 | { 162 | AnimName = reader.ReadString(); 163 | short frameCount = reader.ReadByte(); 164 | SpeedMultiplyer = reader.ReadByte(); 165 | LoopIndex = reader.ReadByte(); 166 | RotationFlags = reader.ReadByte(); 167 | for (int i = 0; i < frameCount; ++i) 168 | { 169 | Frames.Add(new sprFrame(reader,anim)); 170 | } 171 | } 172 | 173 | public void Write(Writer writer) 174 | { 175 | writer.Write(AnimName); 176 | writer.Write((byte)Frames.Count); 177 | writer.Write(SpeedMultiplyer); 178 | writer.Write(LoopIndex); 179 | writer.Write(RotationFlags); 180 | for (int i = 0; i < Frames.Count; ++i) 181 | { 182 | Frames[i].Write(writer); 183 | } 184 | } 185 | 186 | public void NewFrame() 187 | { 188 | Frames.Add(new sprFrame()); 189 | } 190 | 191 | public void CloneFrame(int frame) 192 | { 193 | Frames.Add((sprFrame)Frames[frame].Clone()); 194 | } 195 | 196 | public void DeleteFrame(int frame) 197 | { 198 | if (Frames.Count > 0) 199 | { 200 | Frames.RemoveAt(frame); 201 | } 202 | } 203 | 204 | } 205 | 206 | [Serializable] 207 | public class sprHitbox 208 | { 209 | public SByte Left, Right, Top, Bottom; 210 | 211 | public sprHitbox() 212 | { 213 | 214 | } 215 | 216 | public sprHitbox(Reader reader) 217 | { 218 | Left = reader.ReadSByte(); 219 | Top = reader.ReadSByte(); 220 | Right = reader.ReadSByte(); 221 | Bottom = reader.ReadSByte(); 222 | } 223 | 224 | public void Write(Writer writer) 225 | { 226 | writer.Write(Left); 227 | writer.Write(Top); 228 | writer.Write(Right); 229 | writer.Write(Bottom); 230 | } 231 | } 232 | 233 | public Animation() 234 | { 235 | 236 | } 237 | 238 | public Animation(Reader reader) 239 | { 240 | int spriteSheetCount = reader.ReadByte(); 241 | for (int i = 0; i < spriteSheetCount; ++i) 242 | SpriteSheets.Add(reader.ReadString()); 243 | 244 | var animationCount = reader.ReadInt16(); 245 | for (int i = 0; i < animationCount; ++i) 246 | Animations.Add(new sprAnimation(reader)); 247 | 248 | int collisionBoxCount = reader.ReadByte(); 249 | for (int i = 0; i < collisionBoxCount; ++i) 250 | CollisionBoxes.Add(new sprHitbox(reader)); 251 | reader.Close(); 252 | } 253 | 254 | public void Write(Writer writer) 255 | { 256 | writer.Write((byte)SpriteSheets.Count); 257 | for (int i = 0; i < SpriteSheets.Count; ++i) 258 | { 259 | writer.WriteRSDKString(SpriteSheets[i]); 260 | } 261 | 262 | writer.Write((byte)Animations.Count); 263 | for (int i = 0; i < Animations.Count; ++i) 264 | { 265 | Animations[i].Write(writer); 266 | } 267 | 268 | writer.Write((byte)CollisionBoxes.Count); 269 | for (int i = 0; i < CollisionBoxes.Count; ++i) 270 | { 271 | CollisionBoxes[i].Write(writer); 272 | } 273 | writer.Close(); 274 | } 275 | 276 | public void NewAnimation() 277 | { 278 | sprAnimation a = new sprAnimation(); 279 | Animations.Add(a); 280 | } 281 | 282 | public void CloneAnimation(int anim) 283 | { 284 | sprAnimation a = new sprAnimation(); 285 | 286 | a.AnimName = Animations[anim].AnimName; 287 | byte FrameAmount = (byte)Animations[anim].Frames.Count; 288 | a.LoopIndex = Animations[anim].LoopIndex; 289 | a.SpeedMultiplyer = Animations[anim].SpeedMultiplyer; 290 | a.RotationFlags = Animations[anim].RotationFlags; 291 | 292 | a.Frames.Clear(); 293 | 294 | for (int i = 0; i < FrameAmount; i++) 295 | { 296 | a.Frames.Add((sprAnimation.sprFrame)Animations[anim].Frames[i].Clone()); 297 | } 298 | 299 | Animations.Add(a); 300 | } 301 | 302 | public void DeleteAnimation(int frame) 303 | { 304 | Animations.RemoveAt(frame); 305 | } 306 | 307 | public int GetAnimByName(string name) 308 | { 309 | for (int i = 0; i < Animations.Count; i++) 310 | { 311 | if (Animations[i].AnimName == name) 312 | { 313 | return i; 314 | } 315 | } 316 | Console.WriteLine("An anim with that name didn't exist! Name = " + name); 317 | return -1; 318 | } 319 | 320 | public void DeleteEndAnimation() 321 | { 322 | Animations.RemoveAt(Animations.Count - 1); 323 | } 324 | 325 | } 326 | } 327 | -------------------------------------------------------------------------------- /RSDKv2/ArcContainer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace RSDKv2 8 | { 9 | public class ArcContainer 10 | { 11 | 12 | public static readonly byte[] MAGIC = new byte[] { (byte)'A', (byte)'R', (byte)'C', (byte)'L' }; 13 | 14 | string FileName = "File"; 15 | 16 | public ArcContainer() 17 | { 18 | 19 | } 20 | 21 | public ArcContainer(Reader reader) 22 | { 23 | FileName = System.IO.Path.GetFileNameWithoutExtension(reader.GetFilename()); 24 | 25 | if (!reader.ReadBytes(4).SequenceEqual(MAGIC)) 26 | { 27 | Console.WriteLine("This isn't an ARC file! aborting!"); 28 | return; 29 | } 30 | 31 | ushort unknown = reader.ReadUInt16(); 32 | 33 | 34 | 35 | } 36 | 37 | public void Write(Writer writer) 38 | { 39 | 40 | } 41 | 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /RSDKv2/BackgroundLayout.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace RSDKv2 8 | { 9 | /* Background Layout */ 10 | public class BGLayout 11 | { 12 | public class ScrollInfo 13 | { 14 | /// 15 | /// how fast the line moves while the player is moving 16 | /// 17 | public byte RelativeSpeed; 18 | /// 19 | /// How fast the line moves without the player moving 20 | /// 21 | public byte ConstantSpeed; 22 | /// 23 | /// the draw order of the layer 24 | /// 25 | public byte DrawLayer; 26 | /// 27 | /// a special byte that tells the game what "behaviour" property the layer has 28 | /// 29 | public byte Behaviour; 30 | 31 | public ScrollInfo() 32 | { 33 | RelativeSpeed = 0; 34 | ConstantSpeed = 0; 35 | DrawLayer = 0; 36 | Behaviour = 0; 37 | } 38 | 39 | public ScrollInfo(byte r, byte c, byte d, byte b) 40 | { 41 | RelativeSpeed = r; 42 | ConstantSpeed = c; 43 | DrawLayer = d; 44 | Behaviour = b; 45 | } 46 | 47 | public ScrollInfo(Reader reader) 48 | { 49 | RelativeSpeed = reader.ReadByte(); 50 | ConstantSpeed = reader.ReadByte(); 51 | DrawLayer = reader.ReadByte(); 52 | Behaviour = reader.ReadByte(); 53 | } 54 | 55 | public void Write(Writer writer) 56 | { 57 | writer.Write(RelativeSpeed); 58 | writer.Write(ConstantSpeed); 59 | writer.Write(DrawLayer); 60 | writer.Write(Behaviour); 61 | } 62 | 63 | } 64 | 65 | public class BGLayer 66 | { 67 | /// 68 | /// the array of Chunks IDs for the Layer 69 | /// 70 | public ushort[][] MapLayout { get; set; } 71 | 72 | /// 73 | /// Layer Width 74 | /// 75 | public byte width = 0; 76 | /// 77 | /// Layer Height 78 | /// 79 | public byte height = 0; 80 | /// 81 | /// the draw order of the layer 82 | /// 83 | public byte DrawLayer; 84 | /// 85 | /// a special byte that tells the game what "behaviour" property the layer has 86 | /// 87 | public byte Behaviour; 88 | /// 89 | /// how fast the Layer moves while the player is moving 90 | /// 91 | public byte RelativeSpeed; 92 | /// 93 | /// how fast the layer moves while the player isn't moving 94 | /// 95 | public byte ConstantSpeed; 96 | 97 | public List LineIndexes = new List(); 98 | 99 | public BGLayer() 100 | { 101 | width = height = 1; 102 | DrawLayer = Behaviour = RelativeSpeed = ConstantSpeed = 0; 103 | 104 | MapLayout = new ushort[height][]; 105 | for (int m = 0; m < height; m++) 106 | { 107 | MapLayout[m] = new ushort[width]; 108 | } 109 | } 110 | 111 | public BGLayer(byte w, byte h) 112 | { 113 | width = w; 114 | height = h; 115 | Behaviour = DrawLayer = RelativeSpeed = ConstantSpeed = 0; 116 | 117 | MapLayout = new ushort[height][]; 118 | for (int m = 0; m < height; m++) 119 | { 120 | MapLayout[m] = new ushort[width]; 121 | } 122 | } 123 | 124 | public BGLayer(Reader reader) 125 | { 126 | width = reader.ReadByte(); 127 | height = reader.ReadByte(); 128 | RelativeSpeed = reader.ReadByte(); 129 | ConstantSpeed = reader.ReadByte(); 130 | DrawLayer = reader.ReadByte(); 131 | Behaviour = reader.ReadByte(); 132 | 133 | int j = 0; 134 | while (j < 1) 135 | { 136 | byte b; 137 | 138 | b = reader.ReadByte(); 139 | 140 | if (b == 255) 141 | { 142 | byte tmp2 = reader.ReadByte(); 143 | 144 | if (tmp2 == 255) 145 | { 146 | j = 1; 147 | } 148 | else 149 | { 150 | b = reader.ReadByte(); 151 | } 152 | } 153 | 154 | LineIndexes.Add(b); 155 | } 156 | 157 | byte[] buffer = new byte[2]; 158 | 159 | MapLayout = new ushort[height][]; 160 | for (int m = 0; m < height; m++) 161 | { 162 | MapLayout[m] = new ushort[width]; 163 | } 164 | for (int y = 0; y < height; y++) 165 | { 166 | for (int x = 0; x < width; x++) 167 | { 168 | reader.Read(buffer, 0, 2); //Read size 169 | MapLayout[y][x] = (ushort)(buffer[1] + (buffer[0] << 8)); 170 | } 171 | } 172 | } 173 | 174 | public void Write(Writer writer) 175 | { 176 | writer.Write(width); 177 | writer.Write(height); 178 | writer.Write(RelativeSpeed); 179 | writer.Write(ConstantSpeed); 180 | writer.Write(DrawLayer); 181 | writer.Write(Behaviour); 182 | 183 | for (int i = 0; i < LineIndexes.Count; i++) 184 | { 185 | writer.Write(LineIndexes[i]); 186 | } 187 | writer.Write(0xFF); 188 | 189 | for (int h = 0; h < height; h++) 190 | { 191 | for (int w = 0; w < width; w++) 192 | { 193 | writer.Write((byte)(MapLayout[h][w] >> 8)); 194 | writer.Write((byte)(MapLayout[h][w] & 0xff)); 195 | } 196 | } 197 | 198 | } 199 | 200 | } 201 | 202 | /// 203 | /// A list of Horizontal Line Scroll Values 204 | /// 205 | public List HLines = new List(); 206 | /// 207 | /// A list of Vertical Line Scroll Values 208 | /// 209 | public List VLines = new List(); 210 | /// 211 | /// A list of Background layers 212 | /// 213 | public List Layers = new List(); 214 | 215 | public BGLayout() 216 | { 217 | 218 | } 219 | 220 | public BGLayout(string filename) : this(new Reader(filename)) 221 | { 222 | 223 | } 224 | 225 | public BGLayout(System.IO.Stream stream) : this(new Reader(stream)) 226 | { 227 | 228 | } 229 | 230 | public BGLayout(Reader reader) 231 | { 232 | byte LayerCount = reader.ReadByte(); 233 | 234 | byte HLineCount = reader.ReadByte(); 235 | byte VLineCount = reader.ReadByte(); 236 | 237 | for (int i = 0; i < HLineCount; i++) 238 | { 239 | ScrollInfo p = new ScrollInfo(reader); 240 | HLines.Add(p); 241 | } 242 | 243 | for (int i = 0; i < VLineCount; i++) 244 | { 245 | ScrollInfo p = new ScrollInfo(reader); 246 | VLines.Add(p); 247 | } 248 | 249 | for (int i = 0; i < LayerCount; i++) 250 | { 251 | Layers.Add(new BGLayer(reader)); 252 | } 253 | 254 | reader.Close(); 255 | } 256 | 257 | public void Write(string filename) 258 | { 259 | using (Writer writer = new Writer(filename)) 260 | this.Write(writer); 261 | } 262 | 263 | public void Write(System.IO.Stream stream) 264 | { 265 | using (Writer writer = new Writer(stream)) 266 | this.Write(writer); 267 | } 268 | 269 | internal void Write(Writer writer) 270 | { 271 | writer.Write((byte)Layers.Count); 272 | writer.Write((byte)HLines.Count); 273 | writer.Write((byte)VLines.Count); 274 | 275 | for (int i = 0; i < HLines.Count; i++) 276 | { 277 | HLines[i].Write(writer); 278 | } 279 | 280 | for (int i = 0; i < VLines.Count; i++) 281 | { 282 | VLines[i].Write(writer); 283 | } 284 | 285 | for (int i = 0; i < Layers.Count; i++) 286 | { 287 | Layers[i].Write(writer); 288 | } 289 | 290 | writer.Close(); 291 | } 292 | } 293 | } 294 | -------------------------------------------------------------------------------- /RSDKv2/DataFile.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace RSDKv2 8 | { 9 | public class DataFile 10 | { 11 | public class DirInfo 12 | { 13 | /// 14 | /// the directory path 15 | /// 16 | public string Directory; 17 | /// 18 | /// the file offset for the directory 19 | /// 20 | public int Address; 21 | 22 | public DirInfo() 23 | { 24 | 25 | } 26 | 27 | public DirInfo(Reader reader) 28 | { 29 | byte ss = reader.ReadByte(); 30 | 31 | char buf = ','; 32 | string DecryptedString = ""; 33 | 34 | for (int i = 0; i < ss; i++) 35 | { 36 | byte b = reader.ReadByte(); 37 | int bufInt = (int)b; 38 | 39 | bufInt ^= 0xFF - ss; 40 | 41 | buf = (char)bufInt; 42 | DecryptedString = DecryptedString + buf; 43 | } 44 | Directory = DecryptedString; 45 | Console.WriteLine(Directory); 46 | Address = reader.ReadInt32(); 47 | } 48 | 49 | public void Write(Writer writer, bool SingleFile = false) 50 | { 51 | int ss = Directory.Length; 52 | writer.Write((byte)ss); 53 | 54 | string str = Directory; 55 | 56 | for (int i = 0; i < ss; i++) 57 | { 58 | int s = str[i]; 59 | writer.Write((byte)(s ^ (0xFF - ss))); 60 | } 61 | 62 | writer.Write(Address); 63 | if (SingleFile) writer.Close(); 64 | } 65 | 66 | public void Write(string dataFolder) 67 | { 68 | System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(Directory); 69 | if (!di.Exists) di.Create(); 70 | Writer writer = new Writer(dataFolder); 71 | writer.Write(Directory); 72 | writer.Write(Address); 73 | writer.Close(); 74 | } 75 | } 76 | 77 | public class FileInfo 78 | { 79 | /// 80 | /// the filename of the file 81 | /// 82 | public string FileName; 83 | /// 84 | /// the combined filename and directory of the file 85 | /// 86 | public string FullFileName; 87 | /// 88 | /// how many bytes the file contains 89 | /// 90 | public ulong fileSize; 91 | 92 | /// 93 | /// an array of bytes in the file 94 | /// 95 | public byte[] Filedata; 96 | 97 | /// 98 | /// what directory the file is in 99 | /// 100 | public ushort DirID = 0; 101 | 102 | int decryptKeyZ; 103 | int decryptKeyIndexZ; 104 | int decryptKeyIndex2; 105 | int decryptKeyIndex1; 106 | 107 | string decryptKey1 = "4RaS9D7KaEbxcp2o5r6t"; 108 | string decryptKey2 = "3tRaUxLmEaSn"; 109 | 110 | public FileInfo() 111 | { 112 | 113 | } 114 | 115 | public FileInfo(Reader reader) 116 | { 117 | byte ss = reader.ReadByte(); 118 | 119 | char buf = ','; 120 | string DecryptedString = ""; 121 | 122 | for (int i = 0; i < ss; i++) 123 | { 124 | byte b = reader.ReadByte(); 125 | int bufInt = b; 126 | 127 | bufInt ^= 0xFF; 128 | 129 | buf = (char)bufInt; 130 | DecryptedString = DecryptedString + buf; 131 | } 132 | 133 | FileName = DecryptedString; 134 | 135 | Console.WriteLine(FileName); 136 | 137 | fileSize = reader.ReadUInt32(); 138 | 139 | byte[] tmp = reader.ReadBytes(fileSize); 140 | int[] outbuf = new int[fileSize]; 141 | 142 | for (int i = 0; i < (int)fileSize; i++) 143 | { 144 | outbuf[i] = tmp[i]; 145 | } 146 | 147 | decryptKeyZ = ((int)fileSize & 0x1fc) >> 2; 148 | decryptKeyIndex2 = (decryptKeyZ % 9) + 1; 149 | decryptKeyIndex1 = (decryptKeyZ % decryptKeyIndex2) + 1; 150 | 151 | decryptKeyIndexZ = 0; 152 | 153 | for (int i = 0; i < (int)fileSize; i++) 154 | { 155 | outbuf[i] ^= decryptKey2[decryptKeyIndex2++] ^ decryptKeyZ; 156 | 157 | if (decryptKeyIndexZ == 1) // swap nibbles 158 | outbuf[i] = (outbuf[i] >> 4) | ((outbuf[i] & 0xf) << 4); 159 | 160 | outbuf[i] ^= decryptKey1[decryptKeyIndex1++]; 161 | 162 | if ((decryptKeyIndex1 <= 19) || (decryptKeyIndex2 <= 11)) 163 | { 164 | if (decryptKeyIndex1 > 19) 165 | { 166 | decryptKeyIndex1 = 1; 167 | decryptKeyIndexZ ^= 1; 168 | } 169 | if (decryptKeyIndex2 > 11) 170 | { 171 | decryptKeyIndex2 = 1; 172 | decryptKeyIndexZ ^= 1; 173 | } 174 | } 175 | else 176 | { 177 | decryptKeyZ++; 178 | decryptKeyZ &= 0x7F; 179 | 180 | if (decryptKeyIndexZ != 0) 181 | { 182 | decryptKeyIndex1 = (decryptKeyZ % 12) + 6; 183 | decryptKeyIndex2 = (decryptKeyZ % 5) + 4; 184 | decryptKeyIndexZ = 0; 185 | } 186 | else 187 | { 188 | decryptKeyIndexZ = 1; 189 | decryptKeyIndex1 = (decryptKeyZ % 15) + 3; 190 | decryptKeyIndex2 = (decryptKeyZ % 7) + 1; 191 | } 192 | } 193 | } 194 | Filedata = new byte[outbuf.Length]; 195 | for (int i = 0; i > 2; 227 | decryptKeyIndex2 = (decryptKeyZ % 9) + 1; 228 | decryptKeyIndex1 = (decryptKeyZ % decryptKeyIndex2) + 1; 229 | 230 | decryptKeyIndexZ = 0; 231 | 232 | int[] outbuf = new int[Filedata.Length]; 233 | 234 | for (int i = 0; i < (int)fileSize; i++) 235 | { 236 | outbuf[i] = Filedata[i]; 237 | } 238 | 239 | for (int i = 0; i < (int)fileSize; i++) 240 | { 241 | outbuf[i] ^= decryptKey1[decryptKeyIndex1++]; 242 | 243 | if (decryptKeyIndexZ == 1) // swap nibbles 244 | outbuf[i] = (outbuf[i] >> 4) | ((outbuf[i] & 0xf) << 4); 245 | 246 | outbuf[i] ^= decryptKey2[decryptKeyIndex2++] ^ decryptKeyZ; 247 | 248 | if ((decryptKeyIndex1 <= 19) || (decryptKeyIndex2 <= 11)) 249 | { 250 | if (decryptKeyIndex1 > 19) 251 | { 252 | decryptKeyIndex1 = 1; 253 | decryptKeyIndexZ ^= 1; 254 | } 255 | if (decryptKeyIndex2 > 11) 256 | { 257 | decryptKeyIndex2 = 1; 258 | decryptKeyIndexZ ^= 1; 259 | } 260 | } 261 | else 262 | { 263 | decryptKeyZ++; 264 | decryptKeyZ &= 0x7F; 265 | 266 | if (decryptKeyIndexZ != 0) 267 | { 268 | decryptKeyIndex1 = (decryptKeyZ % 12) + 6; 269 | decryptKeyIndex2 = (decryptKeyZ % 5) + 4; 270 | decryptKeyIndexZ = 0; 271 | } 272 | else 273 | { 274 | decryptKeyIndexZ = 1; 275 | decryptKeyIndex1 = (decryptKeyZ % 15) + 3; 276 | decryptKeyIndex2 = (decryptKeyZ % 7) + 1; 277 | } 278 | } 279 | } 280 | 281 | Filedata = new byte[outbuf.Length]; 282 | for (int i = 0; i < outbuf.Length; i++) 283 | { 284 | Filedata[i] = (byte)outbuf[i]; 285 | } 286 | 287 | writer.Write(fileSize); 288 | writer.Write(Filedata); 289 | } 290 | } 291 | 292 | public void Write(string Datadirectory) 293 | { 294 | string tmp = FullFileName.Replace(System.IO.Path.GetFileName(FullFileName), ""); 295 | string fullDir = Datadirectory + "\\" + tmp; 296 | System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(fullDir); 297 | if (!di.Exists) di.Create(); 298 | Writer writer = new Writer(fullDir + FileName); 299 | writer.Write(Filedata); 300 | writer.Close(); 301 | } 302 | } 303 | 304 | /// 305 | /// the "offset" for file loading I think? 306 | /// 307 | public int headerSize; 308 | 309 | /// 310 | /// a list of directories for the datafile 311 | /// 312 | public List Directories = new List(); 313 | /// 314 | /// the list of fileinfo data for the file 315 | /// 316 | public List Files = new List(); 317 | /** Sequentially, a file description block for every file stored inside the data file. */ 318 | 319 | public DataFile() 320 | { } 321 | 322 | public DataFile(string filepath) : this(new Reader(filepath)) 323 | { } 324 | 325 | public DataFile(Reader reader) 326 | { 327 | 328 | headerSize = reader.ReadInt32(); 329 | Console.WriteLine("Header Size = " + headerSize); 330 | 331 | int dircount = reader.ReadUInt16(); 332 | Console.WriteLine("Directory Count = " + dircount); 333 | 334 | Directories = new List(); 335 | 336 | for (int d = 0; d < dircount; d++) 337 | { 338 | Directories.Add(new DirInfo(reader)); 339 | } 340 | 341 | for (int d = 0; d < dircount; d++) 342 | { 343 | if ((d + 1) < Directories.Count()) 344 | { 345 | while (reader.Pos - headerSize < Directories[d + 1].Address && !reader.IsEof) 346 | { 347 | FileInfo f = new FileInfo(reader); 348 | f.FullFileName = Directories[d].Directory + f.FileName; 349 | Files.Add(f); 350 | } 351 | } 352 | else 353 | { 354 | while (!reader.IsEof) 355 | { 356 | FileInfo f = new FileInfo(reader); 357 | f.FullFileName = Directories[d].Directory + f.FileName; 358 | Files.Add(f); 359 | } 360 | } 361 | } 362 | } 363 | 364 | public void Write(Writer writer) 365 | { 366 | 367 | int DirHeaderSize = 0; 368 | 369 | writer.Write(DirHeaderSize); 370 | 371 | writer.Write((ushort)Directories.Count); 372 | 373 | for (int i = 0; i < Directories.Count; i++) 374 | { 375 | Directories[i].Write(writer); 376 | } 377 | 378 | DirHeaderSize = (int)writer.BaseStream.Position; 379 | 380 | var orderedFiles = Files.OrderBy(f => f.DirID).ToList(); 381 | 382 | int Dir = 0; 383 | 384 | Directories[Dir].Address = 0; 385 | 386 | for (int i = 0; i < Files.Count; i++) 387 | { 388 | if (Files[i].DirID == Dir) 389 | { 390 | Files[i].Write(writer); 391 | } 392 | else 393 | { 394 | Dir++; 395 | Directories[Dir].Address = (int)writer.BaseStream.Position - DirHeaderSize; 396 | Files[i].Write(writer); 397 | } 398 | } 399 | 400 | writer.BaseStream.Position = 0; 401 | 402 | writer.Write(DirHeaderSize); 403 | 404 | writer.Write((ushort)Directories.Count); 405 | 406 | for (int i = 0; i < Directories.Count; i++) 407 | { 408 | Directories[i].Write(writer); 409 | } 410 | 411 | writer.Close(); 412 | } 413 | 414 | public void WriteFile(int fileID) 415 | { 416 | Files[fileID].Write(""); 417 | } 418 | 419 | public void WriteFile(string fileName, string NewFileName) 420 | { 421 | foreach (FileInfo f in Files) 422 | { 423 | if (f.FileName == fileName) 424 | { 425 | f.Write(NewFileName); 426 | } 427 | } 428 | } 429 | 430 | } 431 | } 432 | -------------------------------------------------------------------------------- /RSDKv2/GameConfig.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace RSDKv2 8 | { 9 | public class GameConfig 10 | { 11 | 12 | public class Category 13 | { 14 | /// 15 | /// the list of stages in this category 16 | /// 17 | public List Scenes = new List(); 18 | 19 | public class SceneInfo 20 | { 21 | /// 22 | /// not entirely sure 23 | /// 24 | public byte Unknown; 25 | /// 26 | /// the folder of the scene 27 | /// 28 | public string SceneFolder = "Folder"; 29 | /// 30 | /// the scene's identifier (E.G Act1 or Act2) 31 | /// 32 | public string ActID = "1"; 33 | /// 34 | /// the scene name (shows up on the dev menu) 35 | /// 36 | public string Name = "Scene"; 37 | 38 | public SceneInfo() 39 | { 40 | SceneFolder = "Folder"; 41 | ActID = "1"; 42 | Name = "Stage"; 43 | Unknown = 0; 44 | } 45 | 46 | public SceneInfo(Reader reader) 47 | { 48 | SceneFolder = reader.ReadRSDKString(); 49 | ActID = reader.ReadRSDKString(); 50 | Name = reader.ReadRSDKString(); 51 | Unknown = reader.ReadByte(); 52 | Console.WriteLine("Name = " + Name + " ,Act ID = " + ActID + " ,Scene Folder = " + SceneFolder, " ,Unknown = " + Unknown); 53 | } 54 | 55 | public void Write(Writer writer) 56 | { 57 | writer.WriteRSDKString(SceneFolder); 58 | writer.WriteRSDKString(ActID); 59 | writer.WriteRSDKString(Name); 60 | writer.Write(Unknown); 61 | } 62 | } 63 | 64 | public Category() 65 | { 66 | 67 | } 68 | 69 | public Category(string filename) : this(new Reader(filename)) 70 | { 71 | 72 | } 73 | 74 | public Category(System.IO.Stream stream) : this(new Reader(stream)) 75 | { 76 | 77 | } 78 | 79 | public Category(Reader reader) 80 | { 81 | byte SceneCount = reader.ReadByte(); 82 | for (int i = 0; i < SceneCount; i++) 83 | { 84 | Scenes.Add(new SceneInfo(reader)); 85 | } 86 | } 87 | 88 | public void Write(string filename) 89 | { 90 | using (Writer writer = new Writer(filename)) 91 | this.Write(writer); 92 | } 93 | 94 | public void Write(System.IO.Stream stream) 95 | { 96 | using (Writer writer = new Writer(stream)) 97 | this.Write(writer); 98 | } 99 | 100 | public void Write(Writer writer) 101 | { 102 | writer.Write((byte)Scenes.Count); 103 | for (int i = 0; i < Scenes.Count; i++) 104 | { 105 | Scenes[i].Write(writer); 106 | } 107 | } 108 | 109 | } 110 | 111 | public class GlobalVariable 112 | { 113 | /// 114 | /// the name of the variable 115 | /// 116 | public string Name; 117 | /// 118 | /// the variable's value 119 | /// 120 | public int Value = 0; 121 | 122 | public GlobalVariable() 123 | { 124 | 125 | } 126 | 127 | public GlobalVariable(string name) 128 | { 129 | Name = name; 130 | } 131 | 132 | public GlobalVariable(Reader reader) 133 | { 134 | Name = reader.ReadString(); 135 | Console.WriteLine(Name); 136 | Value = reader.ReadInt32(); 137 | } 138 | 139 | public void Write(Writer writer) 140 | { 141 | writer.WriteRSDKString(Name); 142 | writer.Write(Value); 143 | } 144 | } 145 | 146 | /// 147 | /// the game name, appears on the window 148 | /// 149 | public string GameWindowText; 150 | /// 151 | /// i have no idea 152 | /// 153 | public string DataFileName; 154 | /// 155 | /// the string the appears in the about window 156 | /// 157 | public string GameDescriptionText; 158 | 159 | /// 160 | /// a unique name for each object in the script list 161 | /// 162 | public List ObjectsNames = new List(); 163 | /// 164 | /// the list of filepaths for the global objects 165 | /// 166 | public List ScriptPaths = new List(); 167 | /// 168 | /// the list of global SoundFX 169 | /// 170 | public List SoundFX = new List(); 171 | /// 172 | /// the list of global variable names and values 173 | /// 174 | public List GlobalVariables = new List(); 175 | /// 176 | /// the list of playerdata needed for players 177 | /// 178 | public List Players = new List(); 179 | /// 180 | /// the category list (stage list) 181 | /// 182 | public List Categories = new List(); 183 | 184 | public GameConfig() 185 | { 186 | Categories.Add(new Category()); //Menus 187 | Categories.Add(new Category()); //Stages 188 | Categories.Add(new Category()); //Special Stages 189 | Categories.Add(new Category()); //Bonus Stages 190 | } 191 | 192 | public GameConfig(string filename) : this(new Reader(filename)) 193 | { 194 | 195 | } 196 | 197 | public GameConfig(System.IO.Stream stream) : this(new Reader(stream)) 198 | { 199 | 200 | } 201 | 202 | public GameConfig(Reader reader) 203 | { 204 | GameWindowText = reader.ReadRSDKString(); 205 | DataFileName = reader.ReadRSDKString(); 206 | GameDescriptionText = reader.ReadRSDKString(); 207 | 208 | Console.WriteLine("Game Name: " + GameWindowText); 209 | Console.WriteLine("???: " + DataFileName); 210 | Console.WriteLine("Game Description: " + GameDescriptionText); 211 | 212 | this.ReadObjectData(reader); 213 | 214 | byte GlobalsAmount = reader.ReadByte(); 215 | 216 | for (int i = 0; i < GlobalsAmount; i++) 217 | { 218 | GlobalVariables.Add(new GlobalVariable(reader)); 219 | } 220 | 221 | this.ReadSFXData(reader); 222 | 223 | byte playerCount = reader.ReadByte(); 224 | for (int i = 0; i < playerCount; i++) 225 | { 226 | Players.Add(reader.ReadRSDKString()); 227 | } 228 | 229 | Categories.Add(new Category(reader)); //Menus 230 | Categories.Add(new Category(reader)); //Stages 231 | Categories.Add(new Category(reader)); //Special Stages 232 | Categories.Add(new Category(reader)); //Bonus Stages 233 | 234 | reader.Close(); 235 | } 236 | 237 | public void Write(string filename) 238 | { 239 | using (Writer writer = new Writer(filename)) 240 | this.Write(writer); 241 | } 242 | 243 | public void Write(System.IO.Stream stream) 244 | { 245 | using (Writer writer = new Writer(stream)) 246 | this.Write(writer); 247 | } 248 | 249 | public void Write(Writer writer) 250 | { 251 | writer.WriteRSDKString(GameWindowText); 252 | writer.WriteRSDKString(DataFileName); 253 | writer.WriteRSDKString(GameDescriptionText); 254 | 255 | this.WriteObjectData(writer); 256 | 257 | writer.Write((byte)GlobalVariables.Count); 258 | for (int i = 0; i < GlobalVariables.Count; i++) 259 | { 260 | GlobalVariables[i].Write(writer); 261 | } 262 | 263 | this.WriteSFXData(writer); 264 | 265 | writer.Write((byte)Players.Count); 266 | for (int i = 0; i < Players.Count; i++) 267 | { 268 | writer.Write(Players[i]); 269 | } 270 | 271 | for (int i = 0; i < 4; i++) 272 | { 273 | Categories[i].Write(writer); 274 | } 275 | 276 | writer.Close(); 277 | } 278 | 279 | internal void ReadObjectData(Reader reader) 280 | { 281 | byte objects_count = reader.ReadByte(); 282 | for (int i = 0; i < objects_count; ++i) 283 | { ObjectsNames.Add(reader.ReadRSDKString());} 284 | for (int i = 0; i < objects_count; ++i) 285 | { ScriptPaths.Add(reader.ReadRSDKString()); Console.WriteLine(ScriptPaths[i]); } 286 | } 287 | 288 | internal void WriteObjectData(Writer writer) 289 | { 290 | writer.Write((byte)ObjectsNames.Count); 291 | foreach (string name in ObjectsNames) 292 | writer.WriteRSDKString(name); 293 | foreach (string name in ScriptPaths) 294 | writer.WriteRSDKString(name); 295 | } 296 | 297 | internal void ReadSFXData(Reader reader) 298 | { 299 | byte SoundFX_count = reader.ReadByte(); 300 | for (int i = 0; i < SoundFX_count; ++i) 301 | { SoundFX.Add(reader.ReadString()); } 302 | } 303 | 304 | internal void WriteSFXData(Writer writer) 305 | { 306 | writer.Write((byte)SoundFX.Count); 307 | foreach (string wav in SoundFX) 308 | writer.Write(wav); 309 | } 310 | 311 | /*The Value For DevMenu is at: Line CA0, Column 0B*/ 312 | public void SetDevMenu() 313 | { 314 | for (int i = 0; i < GlobalVariables.Count; i++) 315 | { 316 | if (GlobalVariables[i].Name == "Options.DevMenuFlag") 317 | { 318 | if (GlobalVariables[i].Value == 1) 319 | { 320 | GlobalVariables[i].Value = 0; 321 | Console.WriteLine("DevMenu Deactivated!"); 322 | return; 323 | } 324 | else if (GlobalVariables[i].Value == 0) 325 | { 326 | GlobalVariables[i].Value = 1; 327 | Console.WriteLine("DevMenu Activated!"); 328 | return; 329 | } 330 | } 331 | } 332 | } 333 | 334 | } 335 | } 336 | -------------------------------------------------------------------------------- /RSDKv2/GraphicsImage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Drawing; 6 | using System.Drawing.Imaging; 7 | 8 | /* Yes, RSDKv2 has support for the .gfx format */ 9 | 10 | namespace RSDKv2 11 | { 12 | public class GraphicsImage 13 | { 14 | /// 15 | /// the data of the image layed out in a bitmap form for easy use 16 | /// 17 | public Bitmap gfxImage; 18 | /// 19 | /// the Image's palette 20 | /// 21 | public PaletteColour[] GFXpal = new PaletteColour[255]; 22 | /// 23 | /// the width of the image 24 | /// 25 | public ushort width; 26 | /// 27 | /// the height of the image 28 | /// 29 | public ushort height; 30 | /// 31 | /// the image data 32 | /// 33 | public byte[] data; 34 | 35 | public GraphicsImage() 36 | { 37 | 38 | } 39 | 40 | public GraphicsImage(string filename, bool dcGFX = false) : this(new Reader(filename), dcGFX) 41 | { 42 | 43 | } 44 | 45 | public GraphicsImage(System.IO.Stream stream, bool dcGFX = false) : this(new Reader(stream), dcGFX) 46 | { 47 | 48 | } 49 | 50 | public GraphicsImage(Reader reader, bool dcGFX = false) 51 | { 52 | 53 | if (dcGFX) 54 | { 55 | reader.ReadByte(); 56 | } 57 | 58 | width = (ushort)(reader.ReadByte() << 8); 59 | width |= reader.ReadByte(); 60 | 61 | height = (ushort)(reader.ReadByte() << 8); 62 | height |= reader.ReadByte(); 63 | 64 | // Create image 65 | gfxImage = new Bitmap(width, height, PixelFormat.Format8bppIndexed); 66 | 67 | ColorPalette cp = gfxImage.Palette; 68 | 69 | // Read & Process palette 70 | for (int i = 0; i < 255; i++) 71 | { 72 | GFXpal[i].R = reader.ReadByte(); 73 | GFXpal[i].G = reader.ReadByte(); 74 | GFXpal[i].B = reader.ReadByte(); 75 | cp.Entries[i] = Color.FromArgb(255, GFXpal[i].R, GFXpal[i].G, GFXpal[i].B); 76 | 77 | } 78 | gfxImage.Palette = cp; 79 | 80 | //Read Image Data 81 | byte[] buf = new byte[3]; 82 | bool finished = false; 83 | int cnt = 0; 84 | int loop = 0; 85 | 86 | data = new byte[(width * height) + 1]; 87 | 88 | while (!finished) 89 | { 90 | buf[0] = reader.ReadByte(); 91 | if (buf[0] == 255) 92 | { 93 | buf[1] = reader.ReadByte(); 94 | if (buf[1] == 255) 95 | { 96 | finished = true; 97 | break; 98 | } 99 | else 100 | { 101 | buf[2] = reader.ReadByte(); 102 | loop = 0; 103 | 104 | // Repeat value needs to decreased by one to decode 105 | // the graphics from the Dreamcast demo 106 | if (dcGFX) 107 | { buf[2]--; } 108 | 109 | while (loop < buf[2] && !reader.IsEof) 110 | { 111 | data[cnt++] = buf[1]; 112 | loop++; 113 | } 114 | } 115 | } 116 | else 117 | { 118 | data[cnt++] = buf[0]; 119 | } 120 | } 121 | 122 | Console.Write("file Length = " + reader.BaseStream.Length + " file pos = " + reader.Pos + " data remaining = " + (reader.BaseStream.Length - reader.Pos)); 123 | 124 | // Write data to image 125 | int pixel = 0; 126 | for (int h = 0; h < height; h++) 127 | { 128 | for (int w = 0; w < width; w++) 129 | { 130 | BitmapData ImgData = gfxImage.LockBits(new Rectangle(new Point(w, h), new Size(1, 1)), System.Drawing.Imaging.ImageLockMode.ReadWrite, System.Drawing.Imaging.PixelFormat.Format8bppIndexed); 131 | byte b = System.Runtime.InteropServices.Marshal.ReadByte(ImgData.Scan0); 132 | System.Runtime.InteropServices.Marshal.WriteByte(ImgData.Scan0, (data[pixel])); 133 | gfxImage.UnlockBits(ImgData); 134 | pixel++; 135 | } 136 | } 137 | 138 | reader.Close(); 139 | } 140 | 141 | public void ReDrawImage() 142 | { 143 | gfxImage = new Bitmap(width, height, PixelFormat.Format8bppIndexed); 144 | 145 | ColorPalette cp = gfxImage.Palette; 146 | 147 | // Read & Process palette 148 | for (int i = 0; i < 255; i++) 149 | { 150 | cp.Entries[i] = Color.FromArgb(255, GFXpal[i].R, GFXpal[i].G, GFXpal[i].B); 151 | } 152 | gfxImage.Palette = cp; 153 | 154 | // Write data to image 155 | int pixel = 0; 156 | for (int h = 0; h < height; h++) 157 | { 158 | for (int w = 0; w < width; w++) 159 | { 160 | BitmapData ImgData = gfxImage.LockBits(new Rectangle(new Point(w, h), new Size(1, 1)), System.Drawing.Imaging.ImageLockMode.ReadWrite, System.Drawing.Imaging.PixelFormat.Format8bppIndexed); 161 | byte b = System.Runtime.InteropServices.Marshal.ReadByte(ImgData.Scan0); 162 | System.Runtime.InteropServices.Marshal.WriteByte(ImgData.Scan0, (data[pixel])); 163 | gfxImage.UnlockBits(ImgData); 164 | pixel++; 165 | } 166 | } 167 | } 168 | 169 | public void export(string exportLocation, System.Drawing.Imaging.ImageFormat format) 170 | { 171 | gfxImage.Save(exportLocation, format); 172 | } 173 | 174 | public void importFromBitmap(Bitmap IMG) 175 | { 176 | gfxImage = IMG; 177 | width = (ushort)IMG.Width; 178 | height = (ushort)IMG.Height; 179 | } 180 | 181 | public void Write(string filename, bool dcGFX = false) 182 | { 183 | using (Writer writer = new Writer(filename)) 184 | this.Write(writer, dcGFX); 185 | } 186 | 187 | public void Write(System.IO.Stream stream, bool dcGFX = false) 188 | { 189 | using (Writer writer = new Writer(stream)) 190 | this.Write(writer, dcGFX); 191 | } 192 | 193 | public static byte Get8bppImagePixel(Bitmap bmp, Point location) 194 | { 195 | Color pixelRGB = bmp.GetPixel(location.X, location.Y); 196 | int pixel8bpp = Array.IndexOf(bmp.Palette.Entries, pixelRGB); 197 | return (byte)pixel8bpp; 198 | } 199 | 200 | public void Write(Writer writer, bool dcGFX = false, bool raw = false) 201 | { 202 | if (gfxImage == null) 203 | throw new Exception("Image is NULL"); 204 | 205 | if (gfxImage.Palette == null || gfxImage.Palette.Entries.Length == 0) 206 | throw new Exception("Only indexed images can be converted to GFX format."); 207 | 208 | if (gfxImage.Width > 65535) 209 | throw new Exception("GFX Images can't be wider than 65535 pixels"); 210 | 211 | if (gfxImage.Height > 65535) 212 | throw new Exception("GFX Images can't be higher than 65535 pixels"); 213 | 214 | int num_pixels = gfxImage.Width * gfxImage.Height; 215 | int[] pixels = new int[num_pixels]; //Pallete Indexes 216 | 217 | // Images can't contain index 255 218 | for (int x = 0; x < num_pixels; x++) 219 | { 220 | if (pixels[x] == 255) 221 | throw new Exception("Images to be converted to GFX format can't contain index 255."); 222 | } 223 | 224 | int pix = 0; 225 | if (raw) //get data from "data" array 226 | { 227 | for (int h = 0; h < height; h++) 228 | { 229 | for (int w = 0; w < width; w++) 230 | { 231 | pixels[pix] = data[pix]; 232 | pix++; 233 | } 234 | } 235 | } 236 | else //Get Data from Bitmap Class 237 | { 238 | for (int h = 0; h < gfxImage.Height; h++) 239 | { 240 | for (int w = 0; w < gfxImage.Width; w++) 241 | { 242 | pixels[pix++] = Get8bppImagePixel(gfxImage, new Point(w, h)); 243 | } 244 | } 245 | } 246 | 247 | if (dcGFX) 248 | { 249 | byte z = 0; 250 | writer.Write(z); 251 | } 252 | 253 | // Output width and height 254 | writer.Write((byte)(gfxImage.Width >> 8)); 255 | writer.Write((byte)(gfxImage.Width & 0xff)); 256 | 257 | writer.Write((byte)(gfxImage.Height >> 8)); 258 | writer.Write((byte)(gfxImage.Height & 0xff)); 259 | 260 | for (int i = 0; i < gfxImage.Palette.Entries.Length; i++) 261 | { 262 | GFXpal[i].R = gfxImage.Palette.Entries[i].R; 263 | GFXpal[i].G = gfxImage.Palette.Entries[i].G; 264 | GFXpal[i].B = gfxImage.Palette.Entries[i].B; 265 | } 266 | 267 | // Output palette 268 | for (int x = 0; x < 255; x++) 269 | { 270 | writer.Write(GFXpal[x].R); 271 | writer.Write(GFXpal[x].G); 272 | writer.Write(GFXpal[x].B); 273 | } 274 | 275 | // Output data 276 | int p = 0; 277 | int cnt = 0; 278 | 279 | for (int x = 0; x < num_pixels; x++) 280 | { 281 | if (pixels[x] != p && x > 0) 282 | { 283 | rle_write(writer, p, cnt, dcGFX); 284 | cnt = 0; 285 | } 286 | p = pixels[x]; 287 | cnt++; 288 | } 289 | 290 | rle_write(writer, p, cnt, dcGFX); 291 | 292 | // End of GFX file 293 | writer.Write((byte)0xFF); 294 | writer.Write((byte)0xFF); 295 | 296 | writer.Close(); 297 | } 298 | 299 | private static void rle_write(Writer file, int pixel, int count, bool dcGfx = false) 300 | { 301 | if (count <= 2) 302 | { 303 | for (int y = 0; y < count; y++) 304 | file.Write((byte)pixel); 305 | } 306 | else 307 | { 308 | while (count > 0) 309 | { 310 | file.Write((byte)0xFF); 311 | 312 | file.Write((byte)pixel); 313 | 314 | if (dcGfx) 315 | { 316 | file.Write((byte)((count > 253) ? 254 : (count + 1))); 317 | count -= 253; 318 | } 319 | else 320 | { 321 | file.Write((byte)((count > 254) ? 254 : count)); 322 | count -= 254; 323 | } 324 | } 325 | } 326 | } 327 | 328 | } 329 | } 330 | -------------------------------------------------------------------------------- /RSDKv2/Object.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace RSDKv2 8 | { 9 | public class Object 10 | { 11 | /// 12 | /// the Object's Name (used for entity list) 13 | /// 14 | public string Name 15 | { 16 | get; 17 | set; 18 | } 19 | /// 20 | /// The Type of the object 21 | /// 22 | public byte type; 23 | /// 24 | /// The Object's SubType/PropertyValue 25 | /// 26 | public byte subtype; 27 | /// 28 | /// The Object's X Position 29 | /// 30 | public short xPos; 31 | /// 32 | /// The Object's Y Position 33 | /// 34 | public short yPos; 35 | /// 36 | /// how to load the "attribute"? 37 | /// 38 | public static int cur_id = 0; 39 | /// 40 | /// the Index of the object in the loaded Object List 41 | /// 42 | public int id; 43 | 44 | public Object() 45 | { 46 | 47 | } 48 | 49 | public Object(byte type, byte subtype, short xPos, short yPos) : this(type, subtype, xPos, yPos, cur_id++) 50 | { 51 | } 52 | 53 | public Object(byte type, byte subtype, short xPos, short yPos, int id) 54 | { 55 | Name = "Unknown Object"; 56 | this.type = type; 57 | this.subtype = subtype; 58 | this.xPos = xPos; 59 | this.yPos = yPos; 60 | this.id = id; 61 | } 62 | 63 | public Object(byte type, byte subtype, short xPos, short yPos, int id, string name) 64 | { 65 | this.Name = name; 66 | this.type = type; 67 | this.subtype = subtype; 68 | this.xPos = xPos; 69 | this.yPos = yPos; 70 | this.id = id; 71 | } 72 | 73 | public Object(Reader reader) 74 | { 75 | cur_id++; 76 | id = cur_id; 77 | 78 | // Object type, 1 byte, unsigned 79 | type = reader.ReadByte(); 80 | // Object subtype, 1 byte, unsigned 81 | subtype = reader.ReadByte(); 82 | 83 | // X Position, 2 bytes, big-endian, signed 84 | xPos = (short)(reader.ReadSByte() << 8); 85 | xPos |= (short)reader.ReadByte(); 86 | 87 | // Y Position, 2 bytes, big-endian, signed 88 | yPos = (short)(reader.ReadSByte() << 8); 89 | yPos |= (short)reader.ReadByte(); 90 | 91 | Console.WriteLine(id + " Obj Values: Type: " + type + ", Subtype: " + subtype + ", Xpos = " + xPos + ", Ypos = " + yPos); 92 | } 93 | 94 | public void Write(Writer writer) 95 | { 96 | if (type > 255) 97 | throw new Exception("Cannot save as Type v2. Object type > 255"); 98 | 99 | if (subtype > 255) 100 | throw new Exception("Cannot save as Type v2. Object subtype > 255"); 101 | 102 | if (xPos < -32768 || xPos > 32767) 103 | throw new Exception("Cannot save as Type v2. Object X Position can't fit in 16-bits"); 104 | 105 | if (yPos < -32768 || yPos > 32767) 106 | throw new Exception("Cannot save as Type v2. Object Y Position can't fit in 16-bits"); 107 | 108 | writer.Write(type); 109 | writer.Write(subtype); 110 | 111 | writer.Write((byte)(xPos >> 8)); 112 | writer.Write((byte)(xPos & 0xFF)); 113 | 114 | writer.Write((byte)(yPos >> 8)); 115 | writer.Write((byte)(yPos & 0xFF)); 116 | 117 | Console.WriteLine(id + " Obj Values: Type: " + type + ", Subtype: " + subtype + ", Xpos = " + xPos + ", Ypos = " + yPos); 118 | } 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /RSDKv2/Palette.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.IO; 5 | 6 | 7 | namespace RSDKv2 8 | { 9 | public class Palette 10 | { 11 | /// 12 | /// how many colours for each row (always 16) 13 | /// 14 | public const int COLORS_PER_COLUMN = 0x10; 15 | 16 | /// 17 | /// an array of the colours 18 | /// 19 | public PaletteColour[][] Colors; 20 | 21 | public Palette(int pc = 2) 22 | { 23 | int palColumns = pc; 24 | 25 | Colors = new PaletteColour[palColumns][]; 26 | for (int i = 0; i < palColumns; i++) 27 | { 28 | Colors[i] = new PaletteColour[COLORS_PER_COLUMN]; 29 | for (int j = 0; j < COLORS_PER_COLUMN; ++j) 30 | { Colors[i][j] = new PaletteColour(); } 31 | } 32 | } 33 | 34 | public Palette(Reader r) 35 | { 36 | Read(r); 37 | } 38 | 39 | public Palette(Reader r, int palcols) 40 | { 41 | Read(r, palcols); 42 | } 43 | 44 | public void Read(Reader reader, int Columns) 45 | { 46 | int palColumns = Columns; 47 | 48 | Colors = new PaletteColour[palColumns][]; 49 | for (int i = 0; i < palColumns; i++) 50 | { 51 | Colors[i] = new PaletteColour[COLORS_PER_COLUMN]; 52 | for (int j = 0; j < COLORS_PER_COLUMN; ++j) 53 | { Colors[i][j] = new PaletteColour(reader); } 54 | } 55 | } 56 | 57 | public void Read(Reader reader) 58 | { 59 | int palColumns = ((int)reader.BaseStream.Length / 8) / 6; 60 | 61 | Colors = new PaletteColour[palColumns][]; 62 | for (int i = 0; i < palColumns; i++) 63 | { 64 | Colors[i] = new PaletteColour[COLORS_PER_COLUMN]; 65 | for (int j = 0; j < COLORS_PER_COLUMN; ++j) 66 | { Colors[i][j] = new PaletteColour(reader);} 67 | } 68 | } 69 | 70 | public void Write(string filename) 71 | { 72 | using (Writer writer = new Writer(filename)) 73 | this.Write(writer); 74 | } 75 | 76 | public void Write(System.IO.Stream stream) 77 | { 78 | using (Writer writer = new Writer(stream)) 79 | this.Write(writer); 80 | } 81 | 82 | internal void Write(Writer writer) 83 | { 84 | int palColumns = Colors.Length/16; 85 | Console.WriteLine(palColumns); 86 | foreach (PaletteColour[] column in Colors) 87 | if (column != null) 88 | foreach (PaletteColour color in column) 89 | { color.Write(writer);} 90 | } 91 | 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /RSDKv2/PaletteColour.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.IO; 7 | 8 | namespace RSDKv2 9 | { 10 | public class PaletteColour 11 | { 12 | 13 | /// 14 | /// Colour Red Value 15 | /// 16 | public byte R; 17 | /// 18 | /// Colour Green Value 19 | /// 20 | public byte G; 21 | /// 22 | /// Colour Blue Value 23 | /// 24 | public byte B; 25 | 26 | public PaletteColour(byte R = 0, byte G = 0, byte B = 0) 27 | { 28 | this.R = R; 29 | this.G = G; 30 | this.B = B; 31 | } 32 | 33 | internal PaletteColour(BinaryReader reader) 34 | { 35 | this.Read(reader); 36 | } 37 | 38 | internal void Read(BinaryReader reader) 39 | { 40 | R = reader.ReadByte(); 41 | G = reader.ReadByte(); 42 | B = reader.ReadByte(); 43 | } 44 | 45 | internal void Write(BinaryWriter writer) 46 | { 47 | writer.Write(R); 48 | writer.Write(G); 49 | writer.Write(B); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /RSDKv2/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("RSDKv2")] 9 | [assembly: AssemblyDescription("A library for interacting with the RSDKv2's file formats")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Rubberduckycooly")] 12 | [assembly: AssemblyProduct("RSDKv2")] 13 | [assembly: AssemblyCopyright("Copyright © Rubberduckycooly 2018")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("b41a3858-7e66-4755-9f50-94ea021155b6")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /RSDKv2/RSDKv2.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {B41A3858-7E66-4755-9F50-94EA021155B6} 8 | Library 9 | Properties 10 | RSDKv2 11 | RSDKv2 12 | v4.6.1 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | ..\packages\zlib.net.1.0.4.0\lib\zlib.net.dll 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /RSDKv2/Reader.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.IO; 7 | using zlib; 8 | 9 | namespace RSDKv2 10 | { 11 | public class Reader : BinaryReader 12 | { 13 | public Reader(Stream stream) : base(stream) 14 | { 15 | } 16 | 17 | public Reader(string file) : base(File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read)) 18 | { 19 | } 20 | 21 | public byte[] ReadBytes(long count) 22 | { 23 | if (count < 0 || count > Int32.MaxValue) 24 | throw new ArgumentOutOfRangeException("requested " + count + " bytes, while only non-negative int32 amount of bytes possible"); 25 | byte[] bytes = base.ReadBytes((int)count); 26 | if (bytes.Length < count) 27 | throw new EndOfStreamException("requested " + count + " bytes, but got only " + bytes.Length + " bytes"); 28 | return bytes; 29 | } 30 | 31 | public byte[] ReadBytes(ulong count) 32 | { 33 | if (count > Int32.MaxValue) 34 | throw new ArgumentOutOfRangeException("requested " + count + " bytes, while only non-negative int32 amount of bytes possible"); 35 | int cnt = (int)count; 36 | byte[] bytes = base.ReadBytes(cnt); 37 | if (bytes.Length < cnt) 38 | throw new EndOfStreamException("requested " + count + " bytes, but got only " + bytes.Length + " bytes"); 39 | return bytes; 40 | } 41 | 42 | public bool IsEof 43 | { 44 | get { return BaseStream.Position >= BaseStream.Length; } 45 | } 46 | 47 | public void Seek(long position, SeekOrigin org) 48 | { 49 | BaseStream.Seek(position, org); 50 | } 51 | 52 | public long Pos 53 | { 54 | get { return BaseStream.Position; } 55 | } 56 | 57 | public long Size 58 | { 59 | get { return BaseStream.Length; } 60 | } 61 | 62 | public uint ReadUInt32BE() 63 | { 64 | byte[] bytes = ReadBytes(4); 65 | Array.Reverse(bytes); 66 | return BitConverter.ToUInt32(bytes, 0); 67 | } 68 | 69 | public string GetFilename() 70 | { 71 | var fileStream = BaseStream as FileStream; 72 | return fileStream.Name; 73 | } 74 | 75 | public string ReadRSDKString() 76 | { 77 | return new UTF8Encoding().GetString(ReadBytes(this.ReadByte())); 78 | } 79 | 80 | public string ReadRSDKUnicodeString() 81 | { 82 | return new UnicodeEncoding().GetString(ReadBytes(this.ReadUInt16() * 2)); 83 | } 84 | 85 | public byte[] ReadCompressed() 86 | { 87 | uint compresed_size = this.ReadUInt32(); 88 | uint uncompressed_size = this.ReadUInt32BE(); 89 | using (MemoryStream outMemoryStream = new MemoryStream()) 90 | using (ZOutputStream decompress = new ZOutputStream(outMemoryStream)) 91 | { 92 | decompress.Write(this.ReadBytes(compresed_size - 4), 0, (int)compresed_size - 4); 93 | decompress.finish(); 94 | return outMemoryStream.ToArray(); 95 | } 96 | } 97 | 98 | public Reader GetCompressedStream() 99 | { 100 | return new Reader(new MemoryStream(this.ReadCompressed())); 101 | } 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /RSDKv2/SaveFiles.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.IO; 6 | 7 | namespace RSDKv2 8 | { 9 | public class SaveFiles 10 | { 11 | 12 | public class TimeAttackStageData 13 | { 14 | public class TimeAttackData 15 | { 16 | public int Minutes; 17 | public int Seconds; 18 | public int Milliseconds; 19 | 20 | public TimeAttackData() 21 | { 22 | 23 | } 24 | 25 | public TimeAttackData(int Offset) 26 | { 27 | //SaveRAM[Offset]; 28 | } 29 | } 30 | 31 | TimeAttackData[] Times = new TimeAttackData[3]; 32 | 33 | public TimeAttackStageData() 34 | { 35 | Times[0] = new TimeAttackData(); 36 | Times[1] = new TimeAttackData(); 37 | Times[2] = new TimeAttackData(); 38 | } 39 | 40 | public TimeAttackStageData(int Offset) 41 | { 42 | int BaseOffset = Offset; 43 | for (int i = Offset; Offset < BaseOffset + 3; Offset++) 44 | { 45 | Times[Offset - BaseOffset] = new TimeAttackData(Offset); 46 | } 47 | } 48 | } 49 | 50 | public static int FileSize 51 | { 52 | get 53 | { 54 | return 0x8000; 55 | } 56 | } 57 | 58 | public static int[] SaveRAM = new int[FileSize/4]; 59 | 60 | public int SaveFile = 0; 61 | public int TimeAttackStage = 0; 62 | public int TimeAttackPlace = 0; //0 to 2 63 | public int SaveFilePos 64 | { 65 | get 66 | { 67 | return (SaveFile * 0x20); 68 | } 69 | } 70 | 71 | /// 72 | /// what character you are 73 | /// 74 | public int CharacterID 75 | { 76 | get 77 | { 78 | return SaveRAM[(SaveFilePos + 0x00) / 4]; 79 | } 80 | set 81 | { 82 | SaveRAM[(SaveFilePos + 0x00) / 4] = value; 83 | } 84 | } 85 | /// 86 | /// how many lives you have 87 | /// 88 | public int Lives 89 | { 90 | get 91 | { 92 | return SaveRAM[(SaveFilePos + 0x04) / 4]; 93 | } 94 | set 95 | { 96 | SaveRAM[(SaveFilePos + 0x04) / 4] = value; 97 | } 98 | } 99 | /// 100 | /// current score 101 | /// 102 | public int Score 103 | { 104 | get 105 | { 106 | byte[] intBytes = BitConverter.GetBytes(SaveRAM[(SaveFilePos + 0x08) / 4]); 107 | return intBytes[0] + (intBytes[1] << 8) + (intBytes[2] << 16); 108 | } 109 | set 110 | { 111 | byte[] intBytes = BitConverter.GetBytes(value); 112 | SaveRAM[(SaveFilePos + 0x08) / 4] = intBytes[0] + (intBytes[1] << 8) + (intBytes[2] << 16); 113 | } 114 | } 115 | /// 116 | /// what zone the player is upto 117 | /// 118 | public int ZoneID 119 | { 120 | get 121 | { 122 | return SaveRAM[(SaveFilePos + 0x0C) / 4]; 123 | } 124 | set 125 | { 126 | SaveRAM[(SaveFilePos + 0x0C) / 4] = value; 127 | } 128 | } 129 | /// 130 | /// how many timestones are collected 131 | /// 132 | public int TimeStones 133 | { 134 | get 135 | { 136 | return SaveRAM[(SaveFilePos + 0x10) / 4]; 137 | } 138 | set 139 | { 140 | SaveRAM[(SaveFilePos + 0x10) / 4] = value; 141 | } 142 | } 143 | /// 144 | /// what special stage the user is upto 145 | /// 146 | public int SpecialZoneID 147 | { 148 | get 149 | { 150 | return SaveRAM[(SaveFilePos + 0x14) / 4]; 151 | } 152 | set 153 | { 154 | SaveRAM[(SaveFilePos + 0x14) / 4] = value; 155 | } 156 | } 157 | /// 158 | /// what stages have good futures 159 | /// 160 | public int GoodFutures 161 | { 162 | get 163 | { 164 | return SaveRAM[(SaveFilePos + 0x18) / 4]; 165 | } 166 | set 167 | { 168 | SaveRAM[(SaveFilePos + 0x18) / 4] = value; 169 | } 170 | } 171 | /// 172 | /// how many robo machines have been broken 173 | /// 174 | public int FuturesSaved 175 | { 176 | get 177 | { 178 | byte[] intBytes = BitConverter.GetBytes(SaveRAM[(SaveFilePos + 0x1C) / 4]); 179 | return intBytes[2] + (intBytes[3] << 8); 180 | } 181 | set 182 | { 183 | SaveRAM[(SaveFilePos + 0x1C) / 4] = value; 184 | } 185 | } 186 | 187 | //Global Vars 188 | /// 189 | /// if set to 0 the engine resets everything 190 | /// 191 | public int NewSave 192 | { 193 | get 194 | { 195 | return SaveRAM[0x80 / 4]; 196 | } 197 | set 198 | { 199 | SaveRAM[0x80 / 4] = value; 200 | } 201 | } 202 | /// 203 | /// how loud the music is 204 | /// 205 | public int MusVolume 206 | { 207 | get 208 | { 209 | return SaveRAM[0x84 / 4]; 210 | } 211 | set 212 | { 213 | SaveRAM[0x84 / 4] = value; 214 | } 215 | } 216 | /// 217 | /// how loud the SoundFX is 218 | /// 219 | public int SFXVolume 220 | { 221 | get 222 | { 223 | return SaveRAM[0x88 / 4]; 224 | } 225 | set 226 | { 227 | SaveRAM[0x88 / 4] = value; 228 | } 229 | } 230 | /// 231 | /// using CD or MD spindash style 232 | /// 233 | public int SpindashStyle 234 | { 235 | get 236 | { 237 | return SaveRAM[0x8C / 4]; 238 | } 239 | set 240 | { 241 | SaveRAM[0x8C / 4] = value; 242 | } 243 | } 244 | /// 245 | /// no idea 246 | /// 247 | public int unknown3 248 | { 249 | get 250 | { 251 | return SaveRAM[0x90 / 4]; 252 | } 253 | set 254 | { 255 | SaveRAM[0x90 / 4] = value; 256 | } 257 | } 258 | /// 259 | /// the screen filter 260 | /// 261 | public int Filter 262 | { 263 | get 264 | { 265 | return SaveRAM[0x94 / 4]; 266 | } 267 | set 268 | { 269 | SaveRAM[0x94 / 4] = value; 270 | } 271 | } 272 | /// 273 | /// JP or US OST? 274 | /// 275 | public int OSTStyle 276 | { 277 | get 278 | { 279 | byte[] intBytes = BitConverter.GetBytes(SaveRAM[0x98 / 4]); 280 | return intBytes[0]; 281 | } 282 | set 283 | { 284 | SaveRAM[0x98 / 4] = value; 285 | } 286 | } 287 | /// 288 | /// do we have tails unlocked? 289 | /// 290 | public bool TailsUnlocked 291 | { 292 | get 293 | { 294 | if (SaveRAM[0x9C / 4] == 7) 295 | { 296 | return true; 297 | } 298 | else 299 | { 300 | return false; 301 | } 302 | } 303 | set 304 | { 305 | if (value) 306 | { 307 | SaveRAM[0x9C / 4] = 7; 308 | } 309 | else 310 | { 311 | SaveRAM[0x9C / 4] = 0; 312 | } 313 | } 314 | } 315 | /// 316 | /// what zones are unlocked in time attack? 317 | /// 318 | public int TimeAttackUnlocks 319 | { 320 | get 321 | { 322 | return SaveRAM[0x9C / 4]; 323 | } 324 | set 325 | { 326 | SaveRAM[0x9C / 4] = value; 327 | } 328 | } 329 | 330 | 331 | public void SetTimeStone(int pos, bool Set) 332 | { 333 | if (Set) 334 | { 335 | TimeStones |= 1 << pos; 336 | } 337 | if (!Set) 338 | { 339 | TimeStones &= ~(1 << pos); 340 | } 341 | } 342 | 343 | public SaveFiles() 344 | { 345 | SaveFile = 1; 346 | } 347 | 348 | public SaveFiles(Stream stream) : this(new Reader(stream)) 349 | { 350 | } 351 | 352 | public SaveFiles(string file) : this(File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read)) 353 | { 354 | } 355 | 356 | internal SaveFiles(Reader reader) 357 | { 358 | SaveFile = 1; 359 | for (int i = 0; i < FileSize / 4; i++) 360 | { 361 | SaveRAM[i] = reader.ReadInt32(); 362 | } 363 | 364 | reader.Close(); 365 | } 366 | 367 | public void Write(string filename) 368 | { 369 | using (Writer writer = new Writer(filename)) 370 | this.Write(writer); 371 | } 372 | 373 | public void Write(System.IO.Stream stream) 374 | { 375 | using (Writer writer = new Writer(stream)) 376 | this.Write(writer); 377 | } 378 | 379 | public void Write(Writer writer) 380 | { 381 | for (int i = 0; i < SaveRAM.Length; i++) 382 | { 383 | writer.Write(SaveRAM[i]); 384 | } 385 | writer.Close(); 386 | } 387 | 388 | } 389 | } 390 | -------------------------------------------------------------------------------- /RSDKv2/Scene.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | /* 8 | This Loader uses code from the programs: "Retro Engine Map Viewer" and TaxEd by -- and Nextvolume respectivley 9 | */ 10 | 11 | namespace RSDKv2 12 | { 13 | public class Scene 14 | { 15 | /// 16 | /// the Stage Name (what the titlecard displays) 17 | /// 18 | public string Title = "Stage"; 19 | 20 | /// 21 | /// the array of Chunk IDs for the stage 22 | /// 23 | public ushort[][] MapLayout; 24 | 25 | /* Values for the "Display Bytes" */ 26 | /// 27 | /// Active Layer 0, does ??? 28 | /// 29 | public byte ActiveLayer0 = 1; //Usually BG Layer 30 | /// 31 | /// Active Layer 0, does ??? 32 | /// 33 | public byte ActiveLayer1 = 9; //Unknown 34 | /// 35 | /// Active Layer 0, does ??? 36 | /// 37 | public byte ActiveLayer2 = 0; //Usually Foreground (Map) Layer 38 | /// 39 | /// Active Layer 0, does ??? 40 | /// 41 | public byte ActiveLayer3 = 0; //Usually Foreground (Map) Layer 42 | /// 43 | /// The Midpoint Layer does ??? 44 | /// 45 | public byte Midpoint = 3; 46 | 47 | /// 48 | /// the starting X Boundary, it's always 0 though 49 | /// 50 | public int xBoundary1 51 | { 52 | get 53 | { 54 | return 0; 55 | } 56 | } 57 | /// 58 | /// the starting Y Boundary, it's always 0 though 59 | /// 60 | public int yBoundary1 61 | { 62 | get 63 | { 64 | return 0; 65 | } 66 | } 67 | /// 68 | /// the ending X Boundary, it's the value (in pixels) for the stage width 69 | /// 70 | public int xBoundary2 71 | { 72 | get 73 | { 74 | return width << 7; 75 | } 76 | } 77 | /// 78 | /// the ending Y Boundary, it's the value (in pixels) for the stage height 79 | /// 80 | public int yBoundary2 81 | { 82 | get 83 | { 84 | return height << 7; 85 | } 86 | } 87 | /// 88 | /// The water level for the stage, by default it will be below the stage, so it's kinda useless lol 89 | /// 90 | public int WaterLevel 91 | { 92 | get 93 | { 94 | return yBoundary2 + 128; 95 | } 96 | } 97 | 98 | 99 | //Byte 5: Stage.MidPoint 100 | //if it's 0 then nothing but the objects are drawn 101 | //if its 1 or 2 the tiles on high layer are drawn on the low layer 102 | // 3 is default 103 | // 4 or above draws tiles that are on the low layer on the high layer 104 | 105 | /// 106 | /// the list of objects in the stage 107 | /// 108 | public List objects = new List(); 109 | /// 110 | /// a list of names for each Object Type 111 | /// 112 | public List objectTypeNames = new List(); 113 | 114 | /// 115 | /// stage width (in chunks) 116 | /// 117 | public ushort width; 118 | /// 119 | /// stage height (in chunks) 120 | /// 121 | public ushort height; 122 | 123 | /// 124 | /// the Max amount of objects that can be in a single stage 125 | /// 126 | public int MaxObjectCount 127 | { 128 | get 129 | { 130 | return 1056; 131 | } 132 | } 133 | 134 | public Scene() 135 | { 136 | MapLayout = new ushort[1][]; 137 | MapLayout[0] = new ushort[1]; 138 | } 139 | 140 | public Scene(string filename) : this(new Reader(filename)) 141 | { 142 | 143 | } 144 | 145 | public Scene(System.IO.Stream stream) : this(new Reader(stream)) 146 | { 147 | 148 | } 149 | 150 | public Scene(Reader reader) 151 | { 152 | Title = reader.ReadRSDKString(); 153 | //Console.WriteLine(Title); 154 | byte[] buffer = new byte[5]; 155 | 156 | ActiveLayer0 = reader.ReadByte(); 157 | ActiveLayer1 = reader.ReadByte(); 158 | ActiveLayer2 = reader.ReadByte(); 159 | ActiveLayer3 = reader.ReadByte(); 160 | Midpoint = reader.ReadByte(); 161 | 162 | reader.Read(buffer, 0, 2); //Read size 163 | 164 | width = 0; height = 0; 165 | 166 | 167 | // Map width in 128 pixel units 168 | // In RSDKv2, it's one byte long 169 | width = buffer[0]; 170 | height = buffer[1]; 171 | 172 | MapLayout = new ushort[height][]; 173 | for (int i = 0; i < height; i++) 174 | { 175 | MapLayout[i] = new ushort[width]; 176 | } 177 | 178 | for (int y = 0; y < height; y++) 179 | { 180 | for (int x = 0; x < width; x++) 181 | { 182 | // 128x128 Block number is 16-bit 183 | // Big-Endian in RSDKv2 and RSDKv3 184 | reader.Read(buffer, 0, 2); //Read size 185 | MapLayout[y][x] = (ushort)(buffer[1] + (buffer[0] << 8)); 186 | } 187 | } 188 | 189 | 190 | // Read number of object types, Only RSDKv1 and RSDKv2 support this feature 191 | int ObjTypeCount = reader.ReadByte(); 192 | 193 | for (int n = 0; n < ObjTypeCount; n++) 194 | { 195 | string name = reader.ReadRSDKString(); 196 | 197 | objectTypeNames.Add(name); 198 | } 199 | // Read object data 200 | 201 | int ObjCount = 0; 202 | 203 | // 2 bytes, big-endian, unsigned 204 | ObjCount = reader.ReadByte() << 8; 205 | ObjCount |= reader.ReadByte(); 206 | 207 | Object.cur_id = 0; 208 | 209 | for (int n = 0; n < ObjCount; n++) 210 | { 211 | // Add object 212 | objects.Add(new Object(reader)); 213 | } 214 | reader.Close(); 215 | } 216 | 217 | public void Write(string filename) 218 | { 219 | using (Writer writer = new Writer(filename)) 220 | this.Write(writer); 221 | } 222 | 223 | public void Write(System.IO.Stream stream) 224 | { 225 | using (Writer writer = new Writer(stream)) 226 | Write(writer); 227 | } 228 | 229 | internal void Write(Writer writer) 230 | { 231 | //Checks To Make Sure the Data Is Valid For Saving 232 | 233 | if (width > 255) 234 | throw new Exception("Cannot save as Type v2. Width in tiles > 255"); 235 | 236 | if (height > 255) 237 | throw new Exception("Cannot save as Type v2. Height in tiles > 255"); 238 | 239 | int num_of_objects = objects.Count; 240 | 241 | if (num_of_objects >= MaxObjectCount) 242 | { 243 | Console.WriteLine("Object Count > Max Objects!"); 244 | return; 245 | } 246 | 247 | // Write zone name 248 | writer.WriteRSDKString(Title); 249 | 250 | // Write the five "display" bytes 251 | writer.Write(ActiveLayer0); 252 | writer.Write(ActiveLayer1); 253 | writer.Write(ActiveLayer2); 254 | writer.Write(ActiveLayer3); 255 | writer.Write(Midpoint); 256 | 257 | // Write width and height 258 | writer.Write((byte)width); 259 | writer.Write((byte)height); 260 | 261 | // Write tile map 262 | 263 | for (int h = 0; h < height; h++) 264 | { 265 | for (int w = 0; w < width; w++) 266 | { 267 | writer.Write((byte)(MapLayout[h][w] >> 8)); 268 | writer.Write((byte)(MapLayout[h][w] & 0xff)); 269 | } 270 | } 271 | 272 | // Write number of object type names 273 | int num_of_objtype_names = objectTypeNames.Count; 274 | 275 | writer.Write((byte)(num_of_objtype_names)); 276 | 277 | // Write object type names 278 | // Ignore first object type "Type zero", it is not stored. 279 | for (int n = 0; n < num_of_objtype_names; n++) 280 | { 281 | writer.WriteRSDKString(objectTypeNames[n]); 282 | } 283 | 284 | // Write number of objects 285 | writer.Write((byte)(num_of_objects >> 8)); 286 | writer.Write((byte)(num_of_objects & 0xFF)); 287 | 288 | objects = objects.OrderBy(o => o.id).ToList(); 289 | 290 | // Write object data 291 | for (int n = 0; n < num_of_objects; n++) 292 | { 293 | Object obj = objects[n]; 294 | 295 | obj.Write(writer); 296 | } 297 | writer.Close(); 298 | } 299 | 300 | } 301 | } 302 | -------------------------------------------------------------------------------- /RSDKv2/Setup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace RSDKv2 8 | { 9 | public class Setup 10 | { 11 | 12 | public int GameWidth; 13 | public int GameHeight; 14 | public int GameFPS; 15 | public bool Windowed; 16 | 17 | public Setup() 18 | { 19 | 20 | } 21 | 22 | public Setup(Reader reader) 23 | { 24 | GameWidth = reader.ReadInt32(); 25 | GameHeight = reader.ReadInt32(); 26 | GameFPS = reader.ReadInt32(); 27 | Windowed = reader.ReadBoolean(); 28 | } 29 | 30 | public void Write(Writer writer) 31 | { 32 | writer.Write(GameWidth); 33 | writer.Write(GameHeight); 34 | writer.Write(GameFPS); 35 | writer.Write(Windowed); 36 | } 37 | 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /RSDKv2/StageConfig.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace RSDKv2 8 | { 9 | public class StageConfig 10 | { 11 | /// 12 | /// the stageconfig palette (index 96-128) 13 | /// 14 | public Palette StagePalette = new Palette(); 15 | /// 16 | /// the list of Stage SoundFX paths 17 | /// 18 | public List SoundFX = new List(); 19 | /// 20 | /// a list of names for each script 21 | /// 22 | public List ObjectsNames = new List(); 23 | /// 24 | /// A list of the script filepaths for the stage-specific objects 25 | /// 26 | public List ScriptPaths = new List(); 27 | /// 28 | /// whether or not to load the global objects in this stage 29 | /// 30 | public bool LoadGlobalScripts = false; 31 | 32 | public StageConfig() 33 | { 34 | 35 | } 36 | 37 | public StageConfig(string filename) : this(new Reader(filename)) 38 | { 39 | 40 | } 41 | 42 | public StageConfig(System.IO.Stream stream) : this(new Reader(stream)) 43 | { 44 | 45 | } 46 | 47 | public StageConfig(Reader reader) 48 | { 49 | LoadGlobalScripts = reader.ReadBoolean(); 50 | 51 | StagePalette.Read(reader, 2); 52 | 53 | this.ReadObjectsNames(reader); 54 | 55 | this.ReadWAVConfiguration(reader); 56 | 57 | reader.Close(); 58 | 59 | } 60 | 61 | internal void ReadObjectsNames(Reader reader) 62 | { 63 | byte objects_count = reader.ReadByte(); 64 | 65 | Console.WriteLine(objects_count); 66 | for (int i = 0; i < objects_count; ++i) 67 | { ObjectsNames.Add(reader.ReadRSDKString()); } 68 | for (int i = 0; i < objects_count; ++i) 69 | { ScriptPaths.Add(reader.ReadRSDKString()); } 70 | } 71 | 72 | internal void WriteObjectsNames(Writer writer) 73 | { 74 | writer.Write((byte)ObjectsNames.Count); 75 | foreach (string name in ObjectsNames) 76 | writer.WriteRSDKString(name); 77 | foreach (string srcname in ScriptPaths) 78 | writer.WriteRSDKString(srcname); 79 | } 80 | 81 | internal void ReadWAVConfiguration(Reader reader) 82 | { 83 | byte SoundFX_count = reader.ReadByte(); 84 | 85 | for (int i = 0; i < SoundFX_count; ++i) 86 | { SoundFX.Add(reader.ReadString()); } 87 | } 88 | 89 | internal void WriteWAVConfiguration(Writer writer) 90 | { 91 | writer.Write((byte)SoundFX.Count); 92 | foreach (string wav in SoundFX) 93 | writer.Write(wav); 94 | } 95 | 96 | public void Write(string filename) 97 | { 98 | using (Writer writer = new Writer(filename)) 99 | this.Write(writer); 100 | } 101 | 102 | public void Write(System.IO.Stream stream) 103 | { 104 | using (Writer writer = new Writer(stream)) 105 | this.Write(writer); 106 | } 107 | 108 | public void Write(Writer writer) 109 | { 110 | writer.Write(LoadGlobalScripts); 111 | 112 | StagePalette.Write(writer); 113 | 114 | WriteObjectsNames(writer); 115 | 116 | WriteWAVConfiguration(writer); 117 | 118 | writer.Close(); 119 | 120 | } 121 | 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /RSDKv2/StringSet.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace RSDKv2 8 | { 9 | public class StringSet 10 | { 11 | string stringList = ""; 12 | 13 | public StringSet() 14 | { 15 | 16 | } 17 | 18 | public StringSet(Reader reader) 19 | { 20 | while(!reader.IsEof) 21 | { 22 | char c = (char)reader.ReadByte(); 23 | if (c != 0) 24 | { 25 | stringList += c; 26 | } 27 | } 28 | reader.Close(); 29 | } 30 | 31 | public void Write(Writer writer) 32 | { 33 | for (int i = 0; i < stringList.Length; i++) 34 | { 35 | writer.Write((byte)stringList[i]); 36 | writer.Write((byte)0); 37 | } 38 | } 39 | 40 | public string getString(string str) 41 | { 42 | if (stringList.Contains(str)) 43 | { 44 | return str; 45 | } 46 | else 47 | { 48 | return "STRING NOT FOUND!"; 49 | } 50 | } 51 | 52 | public void addString(string str) 53 | { 54 | stringList += str; 55 | } 56 | 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /RSDKv2/TextFont.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace RSDKv2 8 | { 9 | public class TextFont 10 | { 11 | 12 | public TextFont() 13 | { 14 | 15 | } 16 | 17 | public TextFont(Reader reader) 18 | { 19 | int result = 0; 20 | 21 | for (int i = 0; ; i += 5) 22 | { 23 | if (reader.IsEof) 24 | { 25 | break; 26 | } 27 | 28 | reader.ReadInt32(); 29 | 30 | reader.ReadUInt16(); 31 | reader.ReadUInt16(); 32 | reader.ReadUInt16(); 33 | reader.ReadUInt16(); 34 | 35 | reader.ReadByte(); 36 | byte b = reader.ReadByte(); 37 | if (b <= 0x80u) 38 | { 39 | //Combine it 40 | } 41 | else 42 | { 43 | //idk lol 44 | } 45 | 46 | byte b2 = reader.ReadByte(); 47 | reader.ReadByte(); 48 | 49 | if (b2 > 0x80u) 50 | { 51 | //Combine it 52 | } 53 | else 54 | { 55 | //idk lol 56 | } 57 | 58 | byte b3 = reader.ReadByte(); 59 | reader.ReadByte(); 60 | 61 | if (b3 > 0x80u) 62 | { 63 | //Combine it 64 | } 65 | else 66 | { 67 | //idk lol 68 | } 69 | 70 | reader.ReadByte(); //this do jack shit lmao 71 | result = reader.ReadByte(); //get reader pos? 72 | } 73 | } 74 | 75 | public void Write(Writer writer) 76 | { 77 | 78 | } 79 | 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /RSDKv2/Tileconfig.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Drawing; 6 | 7 | namespace RSDKv2 8 | { 9 | public class Tileconfig 10 | { 11 | /// 12 | /// 1024, one for each tile 13 | /// 14 | const int TILES_COUNT = 1024; 15 | 16 | /// 17 | /// A list of all the mask values on plane A 18 | /// 19 | public CollisionMask[] CollisionPath1 = new CollisionMask[TILES_COUNT]; 20 | /// 21 | /// A list of all the mask values on plane B 22 | /// 23 | public CollisionMask[] CollisionPath2 = new CollisionMask[TILES_COUNT]; 24 | 25 | public class CollisionMask 26 | { 27 | /// 28 | /// Collision position for each pixel 29 | /// 30 | public byte[] Collision = new byte[16]; //two Collision Values per read byte 31 | 32 | /// 33 | /// the collision flags for each "column" 34 | /// 35 | public bool[] HasCollision = new bool[16]; 36 | 37 | /// 38 | /// is the Mask A ceiling mask? 39 | /// 40 | public bool isCeiling; 41 | 42 | /// 43 | /// The Slope's angle 44 | /// 45 | public byte slopeAngle; 46 | /// 47 | /// How the player's physics react to the slope 48 | /// 49 | public byte physics; 50 | /// 51 | /// How much momentum is gained from the slope 52 | /// 53 | public byte momentum; 54 | /// 55 | /// Unknown 56 | /// 57 | public byte unknown; 58 | 59 | public CollisionMask() 60 | { 61 | Collision = new byte[16]; 62 | HasCollision = new bool[16]; 63 | slopeAngle = 0; 64 | physics = 0; 65 | momentum = 0; 66 | unknown = 0; 67 | isCeiling = false; 68 | } 69 | 70 | public CollisionMask(System.IO.Stream stream) : this(new Reader(stream)) { } 71 | 72 | internal CollisionMask(Reader reader) 73 | { 74 | 75 | byte ic = reader.ReadByte(); 76 | if (ic == 0) isCeiling = false; 77 | if (ic == 16) isCeiling = true; 78 | slopeAngle = reader.ReadByte(); 79 | physics = reader.ReadByte(); 80 | momentum = reader.ReadByte(); 81 | unknown = reader.ReadByte(); 82 | 83 | byte[] collision = reader.ReadBytes(8); 84 | 85 | int ActiveCollision = reader.ReadByte() << 8; 86 | ActiveCollision |= reader.ReadByte(); 87 | 88 | int i = 0; 89 | int i2 = 1; 90 | 91 | for (int c = 0; c < 8; c++) 92 | { 93 | Collision[i] = (byte)((collision[c] & 0xF0) >> 4); 94 | Collision[i2] = (byte)(collision[c] & 0x0F); 95 | i += 2; 96 | i2 += 2; 97 | } 98 | 99 | int b = 0; 100 | 101 | for (int ii = 0; ii < 16; ii++) 102 | { 103 | HasCollision[ii] = IsBitSet(ActiveCollision, b); 104 | b++; 105 | } 106 | 107 | } 108 | 109 | public void Write(Writer writer) 110 | { 111 | if (!isCeiling) writer.Write((byte)0); 112 | else if (isCeiling) writer.Write((byte)16); 113 | writer.Write(slopeAngle); 114 | writer.Write(physics); 115 | writer.Write(momentum); 116 | writer.Write(unknown); 117 | 118 | byte[] collision = new byte[8]; 119 | int CollisionActive = 0; 120 | 121 | int c = 0; 122 | 123 | for (int i = 0; i < 8; i++) 124 | { 125 | collision[i] = AddNibbles(Collision[c++], Collision[c++]); 126 | } 127 | 128 | for (int i = 0; i < 16; i++) 129 | { 130 | if (HasCollision[i]) 131 | { 132 | CollisionActive |= 1 << i; 133 | } 134 | if (!HasCollision[i]) 135 | { 136 | CollisionActive |= 0 << i; 137 | } 138 | } 139 | 140 | writer.Write(collision); //Write Collision Data 141 | 142 | writer.Write((byte)(CollisionActive >> 8)); //Write Collision Solidity byte 1 143 | writer.Write((byte)(CollisionActive & 0xff)); //Write Collision Solidity byte 1 144 | } 145 | 146 | public byte AddNibbles(byte a, byte b) 147 | { 148 | return (byte)((a & 0xF) << 4 | (b & 0xF)); 149 | } 150 | 151 | public bool IsBitSet(int b, int pos) 152 | { 153 | return (b & (1 << pos)) != 0; 154 | } 155 | 156 | public Bitmap DrawCMask(System.Drawing.Color bg, System.Drawing.Color fg, Bitmap tile = null) 157 | { 158 | Bitmap b; 159 | bool HasTile = false; 160 | if (tile == null) 161 | { b = new Bitmap(16, 16); } 162 | else 163 | { 164 | b = tile.Clone(new Rectangle(0, 0, tile.Width, tile.Height), System.Drawing.Imaging.PixelFormat.DontCare); 165 | HasTile = true; 166 | 167 | } 168 | 169 | if (!HasTile) 170 | { 171 | for (int h = 0; h < 16; h++) //Set the BG colour 172 | { 173 | for (int w = 0; w < 16; w++) 174 | { 175 | b.SetPixel(w, h, bg); 176 | } 177 | } 178 | } 179 | 180 | if (!isCeiling) 181 | { 182 | for (int w = 0; w < 16; w++) //Set the Active/Main (FG) colour 183 | { 184 | for (int h = 0; h < 16; h++) 185 | { 186 | if (Collision[w] <= h && HasCollision[w]) 187 | { 188 | b.SetPixel(w, h, fg); 189 | } 190 | } 191 | } 192 | } 193 | 194 | if (isCeiling) 195 | { 196 | for (int y = 0; y < 16; y++) //Set the Active/Main (FG) colour 197 | { 198 | for (int x = 0; x < 16; x++) //Set the Active/Main (FG) colour 199 | { 200 | b.SetPixel(x, y, bg); 201 | } 202 | } 203 | 204 | for (int w = 15; w > -1; w--) //Set the Active/Main (FG) colour 205 | { 206 | for (int h = 15; h > -1; h--) 207 | { 208 | if (Collision[w] >= h && HasCollision[w]) 209 | { 210 | b.SetPixel(w, h, fg); 211 | } 212 | } 213 | } 214 | } 215 | return b; 216 | } 217 | 218 | } 219 | 220 | public Tileconfig() 221 | { 222 | for (int i = 0; i < TILES_COUNT; ++i) 223 | { 224 | CollisionPath1[i] = new CollisionMask(); 225 | CollisionPath2[i] = new CollisionMask(); 226 | } 227 | } 228 | 229 | public Tileconfig(string filename) : this(new Reader(filename)) 230 | { 231 | 232 | } 233 | 234 | public Tileconfig(System.IO.Stream stream) : this(new Reader(stream)) 235 | { 236 | 237 | } 238 | 239 | private Tileconfig(Reader reader) 240 | { 241 | for (int i = 0; i < TILES_COUNT; ++i) 242 | { 243 | CollisionPath1[i] = new CollisionMask(reader); 244 | CollisionPath2[i] = new CollisionMask(reader); 245 | } 246 | reader.Close(); 247 | } 248 | 249 | public void Write(string filename) 250 | { 251 | Write(new Writer(filename)); 252 | } 253 | 254 | public void Write(System.IO.Stream s) 255 | { 256 | Write(new Writer(s)); 257 | } 258 | 259 | public void Write(Writer writer) 260 | { 261 | for (int i = 0; i < TILES_COUNT; ++i) 262 | { 263 | CollisionPath1[i].Write(writer); 264 | CollisionPath2[i].Write(writer); 265 | } 266 | writer.Close(); 267 | } 268 | 269 | } 270 | } 271 | -------------------------------------------------------------------------------- /RSDKv2/Tiles128x128.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Drawing; 6 | 7 | namespace RSDKv2 8 | { 9 | public class Tiles128x128 10 | { 11 | public class Tile128 12 | { 13 | public class Tile16 14 | { 15 | /// 16 | /// if tile is on the high or low layer 17 | /// 18 | public byte VisualPlane { get; set; } 19 | /// 20 | /// the flip value of the tile 21 | /// 22 | public byte Direction { get; set; } 23 | /// 24 | /// the Tile's index 25 | /// 26 | public ushort Tile16x16 { get; set; } 27 | /// 28 | /// the flags for Collision Path A 29 | /// 30 | public byte CollisionFlag0 { get; set; } 31 | /// 32 | /// the flags for Collision Path B 33 | /// 34 | public byte CollisionFlag1 { get; set; } 35 | } 36 | 37 | /// 38 | /// the list of 16x16Tiles in this chunk 39 | /// 40 | public Tile16[][] Mapping; 41 | public Tile128() 42 | { 43 | Mapping = new Tile16[8][]; 44 | for (int i = 0; i < 8; i++) 45 | { 46 | Mapping[i] = new Tile16[8]; 47 | } 48 | 49 | for (int y = 0; y < 8; y++) 50 | { 51 | for (int x = 0; x < 8; x++) 52 | { 53 | Mapping[y][x] = new Tile16(); 54 | } 55 | } 56 | 57 | } 58 | 59 | public Bitmap Render(Image tiles) 60 | { 61 | Bitmap retval = new Bitmap(128, 128); 62 | using (Graphics rg = Graphics.FromImage(retval)) 63 | { 64 | for (int y = 0; y < 8; y++) 65 | { 66 | for (int x = 0; x < 8; x++) 67 | { 68 | Rectangle destRect = new Rectangle(x * 16, y * 16, 16, 16); 69 | Rectangle srcRect = new Rectangle(0, Mapping[y][x].Tile16x16 * 16, 16, 16); 70 | using (Bitmap tile = new Bitmap(16, 16)) 71 | { 72 | using (Graphics tg = Graphics.FromImage(tile)) 73 | { 74 | tg.DrawImage(tiles, 0, 0, srcRect, GraphicsUnit.Pixel); 75 | } 76 | if (Mapping[y][x].Direction == 1) 77 | { 78 | tile.RotateFlip(RotateFlipType.RotateNoneFlipX); 79 | } 80 | else if (Mapping[y][x].Direction == 2) 81 | { 82 | tile.RotateFlip(RotateFlipType.RotateNoneFlipY); 83 | } 84 | else if (Mapping[y][x].Direction == 3) 85 | { 86 | tile.RotateFlip(RotateFlipType.RotateNoneFlipXY); 87 | } 88 | rg.DrawImage(tile, destRect); 89 | } 90 | } 91 | } 92 | } 93 | return retval; 94 | } 95 | } 96 | 97 | /// 98 | /// the list of chunks in the file 99 | /// 100 | public Tile128[] BlockList = new Tile128[512]; 101 | 102 | public Tiles128x128() 103 | { 104 | for (int i = 0; i < BlockList.Length; i++) 105 | { 106 | BlockList[i] = new Tile128(); 107 | } 108 | } 109 | 110 | public Tiles128x128(string filepath) : this(new Reader(filepath)) 111 | { 112 | 113 | } 114 | 115 | public Tiles128x128(System.IO.Stream strm) : this(new Reader(strm)) 116 | { 117 | 118 | } 119 | 120 | public Tiles128x128(Reader strm) 121 | { 122 | BlockList = new Tile128[512]; 123 | byte[] mappingEntry = new byte[3]; 124 | Tile128 currentBlock = new Tile128(); 125 | 126 | for (int c = 0; c < 512; c++) 127 | { 128 | for (int y = 0; y < 8; y++) 129 | { 130 | for (int x = 0; x < 8; x++) 131 | { 132 | strm.Read(mappingEntry, 0, mappingEntry.Length); 133 | mappingEntry[0] = (byte)(mappingEntry[0] - (mappingEntry[0] >> 6 << 6)); 134 | currentBlock.Mapping[y][x].VisualPlane = (byte)(mappingEntry[0] >> 4); 135 | mappingEntry[0] = (byte)(mappingEntry[0] - (mappingEntry[0] >> 4 << 4)); 136 | currentBlock.Mapping[y][x].Direction = (byte)(mappingEntry[0] >> 2); 137 | mappingEntry[0] = (byte)(mappingEntry[0] - (mappingEntry[0] >> 2 << 2)); 138 | currentBlock.Mapping[y][x].Tile16x16 = (ushort)((mappingEntry[0] << 8) + mappingEntry[1]); 139 | currentBlock.Mapping[y][x].CollisionFlag0 = (byte)(mappingEntry[2] >> 4); 140 | currentBlock.Mapping[y][x].CollisionFlag1 = (byte)(mappingEntry[2] - (mappingEntry[2] >> 4 << 4)); 141 | } 142 | } 143 | BlockList[c] = currentBlock; 144 | currentBlock = new Tile128(); 145 | } 146 | strm.Close(); 147 | } 148 | 149 | public void Write(string filename) 150 | { 151 | using (Writer writer = new Writer(filename)) 152 | this.Write(writer); 153 | } 154 | 155 | public void Write(System.IO.Stream stream) 156 | { 157 | using (Writer writer = new Writer(stream)) 158 | this.Write(writer); 159 | } 160 | 161 | internal void Write(Writer writer) 162 | { 163 | int[] mappingEntry = new int[3]; 164 | 165 | mappingEntry = new int[3]; 166 | 167 | for (int c = 0; c < 512; c++) 168 | { 169 | for (int y = 0; y < 8; y++) 170 | { 171 | for (int x = 0; x < 8; x++) 172 | { 173 | mappingEntry = new int[3]; 174 | mappingEntry[0] |= (byte)(BlockList[c].Mapping[y][x].Tile16x16 >> 8); //Put the first bit onto buffer[0] 175 | mappingEntry[0] = (byte)(mappingEntry[0] + (mappingEntry[0] >> 2 << 2)); 176 | mappingEntry[0] |= (BlockList[c].Mapping[y][x].Direction) << 2; //Put the Flip of the tile two bits in 177 | mappingEntry[0] = (byte)(mappingEntry[0] + (mappingEntry[0] >> 4 << 4)); 178 | mappingEntry[0] |= (BlockList[c].Mapping[y][x].VisualPlane) << 4; //Put the Layer of the tile four bits in 179 | mappingEntry[0] = (byte)(mappingEntry[0] + (mappingEntry[0] >> 6 << 6)); 180 | 181 | mappingEntry[1] = (byte)(BlockList[c].Mapping[y][x].Tile16x16); //Put the rest of the Tile16x16 Value into this buffer 182 | 183 | mappingEntry[2] = BlockList[c].Mapping[y][x].CollisionFlag1; //Colision Flag 1 is all bytes before bit 5 184 | mappingEntry[2] = mappingEntry[2] | BlockList[c].Mapping[y][x].CollisionFlag0 << 4; //Colision Flag 0 is all bytes after bit 4 185 | 186 | writer.Write((byte)mappingEntry[0]); 187 | writer.Write((byte)mappingEntry[1]); 188 | writer.Write((byte)mappingEntry[2]); 189 | } 190 | } 191 | } 192 | 193 | writer.Close(); 194 | } 195 | 196 | public Bitmap RenderChunk(int ChunkID, Bitmap Tiles) 197 | { 198 | Bitmap chunk = new Bitmap(128, 128); 199 | chunk = BlockList[ChunkID].Render(Tiles); 200 | return chunk; 201 | } 202 | 203 | public Tile128 Clone(int ChunkID) 204 | { 205 | Tile128 Copy = new Tile128(); 206 | for (int y = 0; y < 8; y++) 207 | { 208 | for (int x = 0; x < 8; x++) 209 | { 210 | Copy.Mapping[y][x].VisualPlane = BlockList[ChunkID].Mapping[y][x].VisualPlane; 211 | Copy.Mapping[y][x].Direction = BlockList[ChunkID].Mapping[y][x].Direction; 212 | Copy.Mapping[y][x].Tile16x16 = BlockList[ChunkID].Mapping[y][x].Tile16x16; 213 | Copy.Mapping[y][x].CollisionFlag0 = BlockList[ChunkID].Mapping[y][x].CollisionFlag0; 214 | Copy.Mapping[y][x].CollisionFlag1 = BlockList[ChunkID].Mapping[y][x].CollisionFlag1; 215 | } 216 | } 217 | return Copy; 218 | } 219 | 220 | } 221 | } 222 | -------------------------------------------------------------------------------- /RSDKv2/Video.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.IO; 5 | using System.Drawing; 6 | 7 | /* Taxman sure loves leaving support for fileformats in his code */ 8 | 9 | namespace RSDKv2 10 | { 11 | public class Video 12 | { 13 | 14 | /// 15 | /// the list of every frame 16 | /// 17 | public List Frames = new List(); 18 | 19 | /// 20 | /// How many frames the video contains 21 | /// 22 | public ushort VideoInfo; 23 | /// 24 | /// How Wide the frames are (in pixels) 25 | /// 26 | public ushort Width; 27 | /// 28 | /// how Tall the frames are (in pixels) 29 | /// 30 | public ushort Height; 31 | 32 | public class VideoFrame 33 | { 34 | /// 35 | /// How Wide this frame is (in pixels) 36 | /// 37 | ushort Width; 38 | /// 39 | /// how Tall this frame is (in pixels) 40 | /// 41 | ushort Height; 42 | 43 | /// 44 | /// the file offset to the next file(?) 45 | /// 46 | uint FilePos; 47 | 48 | /// 49 | /// extra bytes until "," is found 50 | /// 51 | List idkMan = new List(); 52 | 53 | //GIF VALUES 54 | /// 55 | /// ImageLeft value (from the gif format, ignored by RSDK) 56 | /// 57 | ushort ImageLeft; 58 | /// 59 | /// ImageTop value (from the gif format, ignored by RSDK) 60 | /// 61 | ushort ImageTop; 62 | /// 63 | /// ImageWidth value, should be the same as Main Width (from the gif format, ignored by RSDK) 64 | /// 65 | ushort ImageWidth; 66 | /// 67 | /// ImageHeight value, should be the same as Main Height (from the gif format, ignored by RSDK) 68 | /// 69 | ushort ImageHeight; 70 | /// 71 | /// whether the image is loaded via interlacing or not 72 | /// 73 | uint isInterlaced; 74 | /// 75 | /// various image flags 76 | /// 77 | byte PaletteType; 78 | /// 79 | /// whether or not the image has 128 or 256 colours 80 | /// 81 | bool FullPallete; 82 | 83 | /// 84 | /// the raw image data 85 | /// 86 | public byte[] ImageData; 87 | /// 88 | /// the raw (compressed) image data 89 | /// 90 | public byte[] CompressedImageData; 91 | int dataptr = 0; 92 | 93 | bool ExtendedCodeTable = false; 94 | 95 | /// 96 | /// the image codesize (used for image loading) 97 | /// 98 | int codesize 99 | { 100 | get 101 | { 102 | if (ExtendedCodeTable) 103 | { 104 | return 8; 105 | } 106 | else 107 | { 108 | return 7; 109 | } 110 | } 111 | } 112 | /// 113 | /// the image clearcode (used for image loading) 114 | /// 115 | int ClearCode 116 | { 117 | get 118 | { 119 | if (ExtendedCodeTable) 120 | { 121 | return 256; 122 | } 123 | else 124 | { 125 | return 128; 126 | } 127 | } 128 | } 129 | /// 130 | /// the image endcode (used for image loading) 131 | /// 132 | int EndCode 133 | { 134 | get 135 | { 136 | if (ExtendedCodeTable) 137 | { 138 | return 257; 139 | } 140 | else 141 | { 142 | return 129; 143 | } 144 | } 145 | } 146 | 147 | /// 148 | /// the palette for this frame 149 | /// 150 | public List FramePalette = new List(); 151 | 152 | int startOffset = 0; 153 | int endOffset = 0; 154 | 155 | public VideoFrame() 156 | { 157 | 158 | } 159 | 160 | public VideoFrame(ushort width, ushort height) 161 | { 162 | Width = width; 163 | Height = height; 164 | 165 | ImageData = new byte[Width * Height]; 166 | } 167 | 168 | public VideoFrame(Reader reader, ushort width, ushort height) 169 | { 170 | Width = width; 171 | Height = height; 172 | startOffset = (int)reader.Pos; 173 | ImageData = new byte[Width * Height]; 174 | 175 | FilePos = (uint)(reader.ReadByte() + (reader.ReadByte() << 8) + (reader.ReadByte() << 16) + (reader.ReadByte() << 24));//reader.ReadUInt32(); 176 | 177 | for (int i = 0; i < 128; i++) 178 | { 179 | Color c; 180 | byte r = reader.ReadByte(); //r 181 | byte g = reader.ReadByte(); //g 182 | byte b = reader.ReadByte(); //b 183 | c = Color.FromArgb(255, r, g, b); 184 | //Console.WriteLine("Colour " + i + " = " + c.R + " " + c.G + " " + c.B); 185 | FramePalette.Add(c); 186 | } 187 | 188 | bool Next = false; 189 | 190 | while (!Next) 191 | { 192 | byte tmp = reader.ReadByte(); 193 | idkMan.Add(tmp); 194 | //Console.WriteLine("idk lol = " + tmp); 195 | if (tmp == 44) { Next = true; } // AKA ',' 196 | } 197 | 198 | ImageLeft = reader.ReadUInt16(); 199 | ImageTop = reader.ReadUInt16(); 200 | ImageWidth = reader.ReadUInt16(); 201 | ImageHeight = reader.ReadUInt16(); 202 | 203 | PaletteType = reader.ReadByte(); 204 | 205 | //Console.WriteLine("Palette Type = " + PaletteType); 206 | 207 | isInterlaced = (uint)PaletteType << 25 >> 31; 208 | 209 | //Console.WriteLine("Interlaced? = " + isInterlaced); 210 | 211 | //Console.WriteLine("Use full Palette = " + (PaletteType >> 7)); 212 | 213 | FullPallete = PaletteType >> 7 == 1; 214 | 215 | if (FullPallete) // Use extra colours? 216 | { 217 | for (int i = 128; i < 256; i++) 218 | { 219 | Color c; 220 | byte r = reader.ReadByte(); //r 221 | byte g = reader.ReadByte(); //g 222 | byte b = reader.ReadByte(); //b 223 | c = Color.FromArgb(255, r, g, b); 224 | //Console.WriteLine("(Extra) Colour " + i + " = " + c.R + "," + c.G + "," + c.B); 225 | FramePalette.Add(c); 226 | } 227 | } 228 | 229 | ReadGIFData(reader); 230 | Console.WriteLine("Loaded Video Frame!"); 231 | //reader.BaseStream.Position = FilePos + 6; 232 | endOffset = (int)reader.Pos; 233 | } 234 | 235 | 236 | void outLine(byte[] buff) 237 | { 238 | for (int i = 0; i < Width; i++) 239 | { 240 | ImageData[dataptr++] = buff[i]; 241 | } 242 | } 243 | 244 | public void ReadGIFData(Reader reader) 245 | { 246 | //I have no idea how to load GIF data 247 | 248 | CompressedImageData = new byte[Width * Height + 1]; 249 | 250 | byte bitSize = reader.ReadByte(); 251 | ExtendedCodeTable = bitSize == 8; 252 | 253 | bool notEnd = true; 254 | 255 | int c = 0; 256 | 257 | while (notEnd) 258 | { 259 | byte BlockSize = reader.ReadByte(); 260 | byte clearCode = reader.ReadByte(); //just read the clearcode 261 | 262 | if (BlockSize == 0) 263 | { 264 | break; 265 | } 266 | 267 | if (!ExtendedCodeTable) 268 | { 269 | 270 | while ((c = reader.ReadByte()) != EndCode) 271 | { 272 | 273 | if (c == ClearCode) 274 | { 275 | //do clearcode shit 276 | 277 | while ((c = reader.ReadByte()) == ClearCode) 278 | { 279 | //skip 280 | } 281 | 282 | if (c == EndCode) 283 | { 284 | notEnd = false; 285 | break; 286 | } 287 | 288 | } 289 | else 290 | { 291 | //Process data 292 | } 293 | } 294 | } 295 | else 296 | { 297 | Console.WriteLine("wtf no"); 298 | break; 299 | //gonna haveta do special stuff for 256 colour images 300 | } 301 | } 302 | } 303 | 304 | 305 | } 306 | public Video(string filepath) : this(new Reader(filepath)) 307 | { 308 | 309 | } 310 | 311 | public Video(System.IO.Stream stream) : this(new Reader(stream)) 312 | { 313 | 314 | } 315 | 316 | public Video(Reader reader) 317 | { 318 | VideoInfo = reader.ReadUInt16(); 319 | 320 | Width = reader.ReadUInt16(); 321 | 322 | Height = reader.ReadUInt16(); 323 | 324 | Console.WriteLine("VideoInfo = " + VideoInfo); 325 | Console.WriteLine("Width = " + Width); 326 | Console.WriteLine("Height = " + Height); 327 | 328 | //GET IMAGE DATA LOADING 329 | for (int f = 0; f < VideoInfo; f++) 330 | { 331 | LoadVideoFrame(reader); 332 | } 333 | 334 | Console.WriteLine("Reader Position = " + reader.Pos + " FileSize = " + reader.BaseStream.Length + " Data Left = " + (reader.BaseStream.Length - reader.Pos)); 335 | reader.Close(); 336 | } 337 | 338 | void LoadVideoFrame(Reader reader) 339 | { 340 | Frames.Add(new VideoFrame(reader, Width, Height)); 341 | } 342 | 343 | public void Write(string filename) 344 | { 345 | using (Writer writer = new Writer(filename)) 346 | this.Write(writer); 347 | } 348 | 349 | public void Write(System.IO.Stream stream) 350 | { 351 | using (Writer writer = new Writer(stream)) 352 | this.Write(writer); 353 | } 354 | 355 | internal void Write(Writer writer) 356 | { 357 | 358 | writer.Close(); 359 | } 360 | 361 | } 362 | } 363 | -------------------------------------------------------------------------------- /RSDKv2/Writer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.IO; 7 | using zlib; 8 | 9 | namespace RSDKv2 10 | { 11 | public class Writer : BinaryWriter 12 | { 13 | public Writer(Stream stream) : base(stream) 14 | { 15 | } 16 | 17 | public Writer(string file) : base(File.Open(file, FileMode.Create, FileAccess.Write, FileShare.ReadWrite)) 18 | { 19 | } 20 | 21 | public bool IsEof 22 | { 23 | get { return BaseStream.Position >= BaseStream.Length; } 24 | } 25 | 26 | public void Seek(long position, SeekOrigin org) 27 | { 28 | BaseStream.Seek(position, org); 29 | } 30 | 31 | public long Pos 32 | { 33 | get { return BaseStream.Position; } 34 | } 35 | 36 | public long Size 37 | { 38 | get { return BaseStream.Length; } 39 | } 40 | 41 | public void WriteUInt32BE(uint val) 42 | { 43 | val = ((val >> 24) & 0xff) | ((val << 8) & 0xff0000) | ((val >> 8) & 0xff00) | ((val << 24) & 0xff000000); 44 | base.Write(val); 45 | } 46 | 47 | public void WriteRSDKString(string val) 48 | { 49 | base.Write((byte)val.Length); 50 | base.Write(new UTF8Encoding().GetBytes(val)); 51 | } 52 | 53 | public void WriteRSDKUnicodeString(string val) 54 | { 55 | base.Write((ushort)val.Length); 56 | base.Write(new UnicodeEncoding().GetBytes(val)); 57 | } 58 | 59 | public void WriteCompressed(byte[] bytes) 60 | { 61 | using (MemoryStream outMemoryStream = new MemoryStream()) 62 | using (ZOutputStream compress = new ZOutputStream(outMemoryStream, zlibConst.Z_DEFAULT_COMPRESSION)) { 63 | compress.Write(bytes, 0, bytes.Length); 64 | compress.finish(); 65 | 66 | byte[] data = outMemoryStream.ToArray(); 67 | this.Write((uint)data.Length + sizeof(uint)); 68 | this.WriteUInt32BE((uint)bytes.Length); 69 | this.Write(data); 70 | } 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /RSDKv2/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Sonic-CD-SaveED.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27703.2000 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sonic-CD-SaveED", "Sonic-CD-SaveED\Sonic-CD-SaveED.csproj", "{E9AF2D39-98CC-4EE6-BF10-5593747CB256}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RSDKv2", "RSDKv2\RSDKv2.csproj", "{B41A3858-7E66-4755-9F50-94EA021155B6}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Release|Any CPU = Release|Any CPU 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {E9AF2D39-98CC-4EE6-BF10-5593747CB256}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {E9AF2D39-98CC-4EE6-BF10-5593747CB256}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {E9AF2D39-98CC-4EE6-BF10-5593747CB256}.Release|Any CPU.ActiveCfg = Release|Any CPU 19 | {E9AF2D39-98CC-4EE6-BF10-5593747CB256}.Release|Any CPU.Build.0 = Release|Any CPU 20 | {B41A3858-7E66-4755-9F50-94EA021155B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {B41A3858-7E66-4755-9F50-94EA021155B6}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {B41A3858-7E66-4755-9F50-94EA021155B6}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {B41A3858-7E66-4755-9F50-94EA021155B6}.Release|Any CPU.Build.0 = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {01C12BDB-DBD6-40A5-B2C5-EFFF55E025EA} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /Sonic-CD-SaveED/AboutForm.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace Sonic_CD_SaveED 2 | { 3 | partial class AboutForm 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.label1 = new System.Windows.Forms.Label(); 32 | this.label2 = new System.Windows.Forms.Label(); 33 | this.label3 = new System.Windows.Forms.Label(); 34 | this.label4 = new System.Windows.Forms.Label(); 35 | this.label5 = new System.Windows.Forms.Label(); 36 | this.label6 = new System.Windows.Forms.Label(); 37 | this.SuspendLayout(); 38 | // 39 | // label1 40 | // 41 | this.label1.AutoSize = true; 42 | this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 20F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 43 | this.label1.Location = new System.Drawing.Point(92, 9); 44 | this.label1.Name = "label1"; 45 | this.label1.Size = new System.Drawing.Size(135, 39); 46 | this.label1.TabIndex = 0; 47 | this.label1.Text = "ABOUT"; 48 | // 49 | // label2 50 | // 51 | this.label2.AutoSize = true; 52 | this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 53 | this.label2.Location = new System.Drawing.Point(12, 62); 54 | this.label2.Name = "label2"; 55 | this.label2.Size = new System.Drawing.Size(117, 25); 56 | this.label2.TabIndex = 1; 57 | this.label2.Text = "Developers:"; 58 | // 59 | // label3 60 | // 61 | this.label3.AutoSize = true; 62 | this.label3.Location = new System.Drawing.Point(12, 96); 63 | this.label3.Name = "label3"; 64 | this.label3.Size = new System.Drawing.Size(125, 17); 65 | this.label3.TabIndex = 2; 66 | this.label3.Text = "Rubberduckycooly"; 67 | // 68 | // label4 69 | // 70 | this.label4.AutoSize = true; 71 | this.label4.Location = new System.Drawing.Point(12, 123); 72 | this.label4.Name = "label4"; 73 | this.label4.Size = new System.Drawing.Size(77, 17); 74 | this.label4.TabIndex = 3; 75 | this.label4.Text = "Beta Angel"; 76 | // 77 | // label5 78 | // 79 | this.label5.AutoSize = true; 80 | this.label5.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 81 | this.label5.Location = new System.Drawing.Point(12, 150); 82 | this.label5.Name = "label5"; 83 | this.label5.Size = new System.Drawing.Size(154, 25); 84 | this.label5.TabIndex = 4; 85 | this.label5.Text = "Special Thanks:"; 86 | // 87 | // label6 88 | // 89 | this.label6.AutoSize = true; 90 | this.label6.Location = new System.Drawing.Point(14, 184); 91 | this.label6.Name = "label6"; 92 | this.label6.Size = new System.Drawing.Size(324, 17); 93 | this.label6.TabIndex = 5; 94 | this.label6.Text = "SuperSonic16 - Adding Steam account file loading"; 95 | // 96 | // AboutForm 97 | // 98 | this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); 99 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 100 | this.ClientSize = new System.Drawing.Size(352, 235); 101 | this.Controls.Add(this.label6); 102 | this.Controls.Add(this.label5); 103 | this.Controls.Add(this.label4); 104 | this.Controls.Add(this.label3); 105 | this.Controls.Add(this.label2); 106 | this.Controls.Add(this.label1); 107 | this.Name = "AboutForm"; 108 | this.Text = "About"; 109 | this.ResumeLayout(false); 110 | this.PerformLayout(); 111 | 112 | } 113 | 114 | #endregion 115 | 116 | private System.Windows.Forms.Label label1; 117 | private System.Windows.Forms.Label label2; 118 | private System.Windows.Forms.Label label3; 119 | private System.Windows.Forms.Label label4; 120 | private System.Windows.Forms.Label label5; 121 | private System.Windows.Forms.Label label6; 122 | } 123 | } -------------------------------------------------------------------------------- /Sonic-CD-SaveED/AboutForm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | 11 | namespace Sonic_CD_SaveED 12 | { 13 | public partial class AboutForm : Form 14 | { 15 | public AboutForm() 16 | { 17 | InitializeComponent(); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Sonic-CD-SaveED/AboutForm.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /Sonic-CD-SaveED/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Sonic-CD-SaveED/MainForm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | using System.IO; 11 | 12 | namespace Sonic_CD_SaveED 13 | { 14 | public partial class Mainform : Form 15 | { 16 | 17 | public RSDKv2.SaveFiles SaveData; 18 | 19 | string Filepath; 20 | 21 | public Mainform() 22 | { 23 | InitializeComponent(); 24 | } 25 | 26 | void writeLineToConsole(string line) 27 | { 28 | Console.WriteLine(line); 29 | } 30 | 31 | private void listBox1_SelectedIndexChanged(object sender, EventArgs e) 32 | { 33 | if (SaveData != null) 34 | { 35 | SaveData.CharacterID = CharLB.SelectedIndex; 36 | } 37 | } 38 | 39 | private void Mainform_Load(object sender, EventArgs e) 40 | { 41 | 42 | } 43 | 44 | private void button1_Click(object sender, EventArgs e) 45 | { 46 | Console.WriteLine("Bag 'O Dicks!"); 47 | } 48 | 49 | private void listBox2_SelectedIndexChanged(object sender, EventArgs e) 50 | { 51 | if (SaveData != null) 52 | { 53 | SaveData.ZoneID = StageList.SelectedIndex; 54 | } 55 | } 56 | 57 | private void saveAsToolStripMenuItem_Click(object sender, EventArgs e) 58 | { 59 | SaveFileDialog dlg = new SaveFileDialog(); 60 | dlg.Filter = "Sonic CD Save File|Sdata.bin"; 61 | if (dlg.ShowDialog(this) == DialogResult.OK) 62 | { 63 | SaveData.Write(dlg.FileName); 64 | } 65 | } 66 | 67 | private void numericUpDown1_ValueChanged(object sender, EventArgs e) 68 | { 69 | if (SaveData != null) 70 | { 71 | SaveData.Lives = (int)LivesNUD.Value; 72 | } 73 | 74 | } 75 | 76 | private void saveToolStripMenuItem_Click(object sender, EventArgs e) 77 | { 78 | if (Filepath != null) 79 | { 80 | SaveData.Write(Filepath); 81 | } 82 | else 83 | { 84 | saveAsToolStripMenuItem_Click(this, e); 85 | } 86 | } 87 | 88 | private void openToolStripMenuItem_Click(object sender, EventArgs e) 89 | { 90 | OpenFileDialog dlg = new OpenFileDialog(); 91 | dlg.Filter = "Sonic CD Save File|Sdata.bin"; 92 | if (dlg.ShowDialog(this) == DialogResult.OK) 93 | { 94 | Filepath = dlg.FileName; 95 | SaveData = new RSDKv2.SaveFiles(dlg.FileName); 96 | RefreshUI(); 97 | } 98 | } 99 | 100 | void RefreshUI() 101 | { 102 | if (SaveData != null) 103 | { 104 | SoundtrackLB.SelectedIndex = SaveData.OSTStyle; 105 | SpindashLB.SelectedIndex = SaveData.SpindashStyle; 106 | FilterLB.SelectedIndex = SaveData.Filter; 107 | MusNUD.Value = SaveData.MusVolume; 108 | SFXNUD.Value = SaveData.SFXVolume; 109 | TailsUnlockBox.Checked = SaveData.TailsUnlocked; 110 | NewSaveCB.Checked = SaveData.NewSave != 0; 111 | 112 | MSPNUD.Value = SaveData.FuturesSaved; 113 | LivesNUD.Value = SaveData.Lives; 114 | StageList.SelectedIndex = SaveData.ZoneID; 115 | CharLB.SelectedIndex = SaveData.CharacterID; 116 | Score1NUD.Value = SaveData.Score; 117 | UnknownValueNUD.Value = SaveData.unknown3; 118 | //GF1NUD.Value = SaveData.GoodFutures; 119 | 120 | Timestone1.Checked = IsBitSet(SaveData.TimeStones, 0); 121 | Timestone2.Checked = IsBitSet(SaveData.TimeStones, 1); 122 | Timestone3.Checked = IsBitSet(SaveData.TimeStones, 2); 123 | Timestone4.Checked = IsBitSet(SaveData.TimeStones, 3); 124 | Timestone5.Checked = IsBitSet(SaveData.TimeStones, 4); 125 | Timestone6.Checked = IsBitSet(SaveData.TimeStones, 5); 126 | Timestone7.Checked = IsBitSet(SaveData.TimeStones, 6); 127 | } 128 | 129 | } 130 | 131 | private void SoundtrackLB_SelectedIndexChanged(object sender, EventArgs e) 132 | { 133 | if (SaveData != null) 134 | { 135 | SaveData.OSTStyle = SoundtrackLB.SelectedIndex; 136 | } 137 | } 138 | 139 | private void SpindashLB_SelectedIndexChanged(object sender, EventArgs e) 140 | { 141 | if (SaveData != null) 142 | { 143 | SaveData.SpindashStyle = SpindashLB.SelectedIndex; 144 | } 145 | } 146 | 147 | private void FilterLB_SelectedIndexChanged(object sender, EventArgs e) 148 | { 149 | if (SaveData != null) 150 | { 151 | SaveData.Filter = FilterLB.SelectedIndex; 152 | } 153 | } 154 | 155 | private void MusNUD_ValueChanged(object sender, EventArgs e) 156 | { 157 | if (SaveData != null) 158 | { 159 | SaveData.MusVolume = (int)MusNUD.Value; 160 | } 161 | } 162 | 163 | private void SFXNUD_ValueChanged(object sender, EventArgs e) 164 | { 165 | if (SaveData != null) 166 | { 167 | SaveData.SFXVolume = (int)SFXNUD.Value; 168 | } 169 | } 170 | 171 | private void TailsUnlockBox_CheckedChanged(object sender, EventArgs e) 172 | { 173 | if (SaveData != null) 174 | { 175 | SaveData.TailsUnlocked = TailsUnlockBox.Checked = !SaveData.TailsUnlocked; 176 | } 177 | } 178 | 179 | private void MSPNUD_ValueChanged(object sender, EventArgs e) 180 | { 181 | if (SaveData != null) 182 | { 183 | SaveData.FuturesSaved = (ushort)MSPNUD.Value; 184 | } 185 | } 186 | 187 | private void selectSave1ToolStripMenuItem_Click(object sender, EventArgs e) 188 | { 189 | if (SaveData != null) 190 | { 191 | SaveData.SaveFile = 0; 192 | RefreshUI(); 193 | } 194 | } 195 | 196 | private void selectSave2ToolStripMenuItem_Click(object sender, EventArgs e) 197 | { 198 | if (SaveData != null) 199 | { 200 | SaveData.SaveFile = 1; 201 | RefreshUI(); 202 | } 203 | } 204 | 205 | private void selectSave3ToolStripMenuItem_Click(object sender, EventArgs e) 206 | { 207 | if (SaveData != null) 208 | { 209 | SaveData.SaveFile = 2; 210 | RefreshUI(); 211 | } 212 | } 213 | 214 | private void selectSave4ToolStripMenuItem_Click(object sender, EventArgs e) 215 | { 216 | if (SaveData != null) 217 | { 218 | SaveData.SaveFile = 3; 219 | RefreshUI(); 220 | } 221 | } 222 | 223 | private void SaveUnknownNUD_ValueChanged(object sender, EventArgs e) 224 | { 225 | if (SaveData != null) 226 | { 227 | SaveData.Score = (int)Score1NUD.Value; 228 | } 229 | } 230 | 231 | private void GlobalUnkownNUD_ValueChanged(object sender, EventArgs e) 232 | { 233 | if (SaveData != null) 234 | { 235 | int i = 0; 236 | if (NewSaveCB.Checked) i = 1; 237 | SaveData.NewSave = i; 238 | } 239 | } 240 | 241 | private void GF1NUD_ValueChanged(object sender, EventArgs e) 242 | { 243 | if (SaveData != null) 244 | { 245 | SaveData.GoodFutures = (byte)GF1NUD.Value; 246 | } 247 | } 248 | 249 | public bool IsBitSet(int b, int pos) 250 | { 251 | return (b & (1 << pos)) != 0; 252 | } 253 | 254 | private void Timestone1_CheckedChanged(object sender, EventArgs e) 255 | { 256 | if (SaveData != null) 257 | { 258 | SaveData.SetTimeStone(0, Timestone1.Checked); 259 | RefreshUI(); 260 | } 261 | } 262 | 263 | private void Timestone2_CheckedChanged(object sender, EventArgs e) 264 | { 265 | if (SaveData != null) 266 | { 267 | SaveData.SetTimeStone(1, Timestone2.Checked); 268 | RefreshUI(); 269 | } 270 | } 271 | 272 | private void Timestone3_CheckedChanged(object sender, EventArgs e) 273 | { 274 | if (SaveData != null) 275 | { 276 | SaveData.SetTimeStone(2, Timestone3.Checked); 277 | RefreshUI(); 278 | } 279 | } 280 | 281 | private void Timestone4_CheckedChanged(object sender, EventArgs e) 282 | { 283 | if (SaveData != null) 284 | { 285 | SaveData.SetTimeStone(3, Timestone4.Checked); 286 | RefreshUI(); 287 | } 288 | } 289 | 290 | private void Timestone5_CheckedChanged(object sender, EventArgs e) 291 | { 292 | if (SaveData != null) 293 | { 294 | SaveData.SetTimeStone(4, Timestone5.Checked); 295 | RefreshUI(); 296 | } 297 | } 298 | 299 | private void Timestone6_CheckedChanged(object sender, EventArgs e) 300 | { 301 | if (SaveData != null) 302 | { 303 | SaveData.SetTimeStone(5, Timestone6.Checked); 304 | RefreshUI(); 305 | } 306 | } 307 | 308 | private void Timestone7_CheckedChanged(object sender, EventArgs e) 309 | { 310 | if (SaveData != null) 311 | { 312 | SaveData.SetTimeStone(6, Timestone7.Checked); 313 | RefreshUI(); 314 | } 315 | } 316 | 317 | private void AllTimestones_CheckedChanged(object sender, EventArgs e) 318 | { 319 | if (SaveData != null) 320 | { 321 | SaveData.SetTimeStone(0, AllTimestones.Checked); 322 | SaveData.SetTimeStone(1, AllTimestones.Checked); 323 | SaveData.SetTimeStone(2, AllTimestones.Checked); 324 | SaveData.SetTimeStone(3, AllTimestones.Checked); 325 | SaveData.SetTimeStone(4, AllTimestones.Checked); 326 | SaveData.SetTimeStone(5, AllTimestones.Checked); 327 | SaveData.SetTimeStone(6, AllTimestones.Checked); 328 | RefreshUI(); 329 | } 330 | } 331 | 332 | private void RGNUD_ValueChanged(object sender, EventArgs e) 333 | { 334 | if (SaveData != null) 335 | { 336 | //SaveData.RoboMachines = (ushort)RGNUD.Value; 337 | } 338 | } 339 | 340 | private void aboutToolStripMenuItem_Click(object sender, EventArgs e) 341 | { 342 | AboutForm frm = new AboutForm(); 343 | frm.ShowDialog(); 344 | } 345 | 346 | private void openFromSteamAccountToolStripMenuItem_Click(object sender, EventArgs e) 347 | { 348 | if (HedgeModManager.Steam.SteamLocation == null) 349 | HedgeModManager.Steam.Init(); 350 | var form = new HedgeModManager.SLWSaveForm(); 351 | form.ShowDialog(); 352 | if (!string.IsNullOrWhiteSpace(form.SID)) 353 | { 354 | //200940 355 | string path = Path.Combine(HedgeModManager.Steam.SteamLocation, "userdata", form.SID, "200940", "local"); 356 | if (!Directory.Exists(path)) 357 | { 358 | MessageBox.Show("Could not Find Sonic CD Data in user Profile!", "Data Not Forund", MessageBoxButtons.OK, MessageBoxIcon.Error); 359 | return; 360 | } 361 | path = Path.Combine(path, "Sdata.bin"); 362 | Filepath = path; 363 | SaveData = new RSDKv2.SaveFiles(path); 364 | RefreshUI(); 365 | } 366 | } 367 | 368 | private void NewSaveCB_CheckedChanged(object sender, EventArgs e) 369 | { 370 | int i = 0; 371 | if (NewSaveCB.Checked) i = 1; 372 | SaveData.NewSave = i; 373 | } 374 | 375 | private void NextSSBox_SelectedIndexChanged(object sender, EventArgs e) 376 | { 377 | if (NextSSBox.SelectedIndex < 0) NextSSBox.SelectedIndex = 0; 378 | SaveData.SpecialZoneID = NextSSBox.SelectedIndex; 379 | } 380 | 381 | private void UnknownValueNUD_ValueChanged(object sender, EventArgs e) 382 | { 383 | SaveData.unknown3 = (int)UnknownValueNUD.Value; 384 | } 385 | } 386 | } 387 | -------------------------------------------------------------------------------- /Sonic-CD-SaveED/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using System.Windows.Forms; 6 | 7 | namespace Sonic_CD_SaveED 8 | { 9 | static class Program 10 | { 11 | /// 12 | /// The main entry point for the application. 13 | /// 14 | [STAThread] 15 | static void Main() 16 | { 17 | Application.EnableVisualStyles(); 18 | Application.SetCompatibleTextRenderingDefault(false); 19 | Application.Run(new Mainform()); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Sonic-CD-SaveED/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Sonic CD Save Editor")] 9 | [assembly: AssemblyDescription("A Save Editor for Sonic CD (2011)")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Rubberduckycooly & Beta Angel")] 12 | [assembly: AssemblyProduct("Sonic CD Save Editor")] 13 | [assembly: AssemblyCopyright("Copyright © Rubberduckycooly & Beta Angel 2018")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("e9af2d39-98cc-4ee6-bf10-5593747cb256")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.1")] 36 | [assembly: AssemblyFileVersion("1.0.0.1")] 37 | -------------------------------------------------------------------------------- /Sonic-CD-SaveED/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Sonic_CD_SaveED.Properties 12 | { 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources 26 | { 27 | 28 | private static global::System.Resources.ResourceManager resourceMan; 29 | 30 | private static global::System.Globalization.CultureInfo resourceCulture; 31 | 32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 33 | internal Resources() 34 | { 35 | } 36 | 37 | /// 38 | /// Returns the cached ResourceManager instance used by this class. 39 | /// 40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 41 | internal static global::System.Resources.ResourceManager ResourceManager 42 | { 43 | get 44 | { 45 | if ((resourceMan == null)) 46 | { 47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Sonic_CD_SaveED.Properties.Resources", typeof(Resources).Assembly); 48 | resourceMan = temp; 49 | } 50 | return resourceMan; 51 | } 52 | } 53 | 54 | /// 55 | /// Overrides the current thread's CurrentUICulture property for all 56 | /// resource lookups using this strongly typed resource class. 57 | /// 58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 59 | internal static global::System.Globalization.CultureInfo Culture 60 | { 61 | get 62 | { 63 | return resourceCulture; 64 | } 65 | set 66 | { 67 | resourceCulture = value; 68 | } 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /Sonic-CD-SaveED/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /Sonic-CD-SaveED/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Sonic_CD_SaveED.Properties 12 | { 13 | 14 | 15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 18 | { 19 | 20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 21 | 22 | public static Settings Default 23 | { 24 | get 25 | { 26 | return defaultInstance; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Sonic-CD-SaveED/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Sonic-CD-SaveED/SLWSaveForm.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace HedgeModManager 2 | { 3 | partial class SLWSaveForm 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.label = new System.Windows.Forms.Label(); 32 | this.listView1 = new System.Windows.Forms.ListView(); 33 | this.Button_Install = new System.Windows.Forms.Button(); 34 | this.SuspendLayout(); 35 | // 36 | // label 37 | // 38 | this.label.AutoSize = true; 39 | this.label.Font = new System.Drawing.Font("Segoe UI", 17F); 40 | this.label.ForeColor = System.Drawing.SystemColors.MenuHighlight; 41 | this.label.Location = new System.Drawing.Point(71, 11); 42 | this.label.Name = "label"; 43 | this.label.Size = new System.Drawing.Size(332, 40); 44 | this.label.TabIndex = 3; 45 | this.label.Text = "Please select an account "; 46 | // 47 | // listView1 48 | // 49 | this.listView1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); 50 | this.listView1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224))))); 51 | this.listView1.Location = new System.Drawing.Point(16, 53); 52 | this.listView1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); 53 | this.listView1.Name = "listView1"; 54 | this.listView1.Size = new System.Drawing.Size(489, 303); 55 | this.listView1.TabIndex = 4; 56 | this.listView1.UseCompatibleStateImageBehavior = false; 57 | this.listView1.DrawItem += new System.Windows.Forms.DrawListViewItemEventHandler(this.ListView1_DrawItem); 58 | // 59 | // Button_Install 60 | // 61 | this.Button_Install.DialogResult = System.Windows.Forms.DialogResult.OK; 62 | this.Button_Install.FlatStyle = System.Windows.Forms.FlatStyle.System; 63 | this.Button_Install.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F); 64 | this.Button_Install.Location = new System.Drawing.Point(16, 364); 65 | this.Button_Install.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); 66 | this.Button_Install.Name = "Button_Install"; 67 | this.Button_Install.Size = new System.Drawing.Size(491, 43); 68 | this.Button_Install.TabIndex = 5; 69 | this.Button_Install.Text = "OK"; 70 | this.Button_Install.UseVisualStyleBackColor = true; 71 | this.Button_Install.Click += new System.EventHandler(this.Button_Install_Click); 72 | // 73 | // SLWSaveForm 74 | // 75 | this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); 76 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 77 | this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48))))); 78 | this.ClientSize = new System.Drawing.Size(523, 422); 79 | this.Controls.Add(this.Button_Install); 80 | this.Controls.Add(this.listView1); 81 | this.Controls.Add(this.label); 82 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; 83 | this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); 84 | this.MaximizeBox = false; 85 | this.MinimizeBox = false; 86 | this.Name = "SLWSaveForm"; 87 | this.Text = "Select Steam Account"; 88 | this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.SLWSaveForm_FormClosing); 89 | this.Load += new System.EventHandler(this.SLWSaveForm_Load); 90 | this.ResumeLayout(false); 91 | this.PerformLayout(); 92 | 93 | } 94 | 95 | #endregion 96 | 97 | private System.Windows.Forms.Label label; 98 | private System.Windows.Forms.ListView listView1; 99 | private System.Windows.Forms.Button Button_Install; 100 | } 101 | } -------------------------------------------------------------------------------- /Sonic-CD-SaveED/SLWSaveForm.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Win32; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.ComponentModel; 5 | using System.Data; 6 | using System.Drawing; 7 | using System.Drawing.Imaging; 8 | using System.IO; 9 | using System.Linq; 10 | using System.Net; 11 | using System.Text; 12 | using System.Threading; 13 | using System.Threading.Tasks; 14 | using System.Windows.Forms; 15 | 16 | namespace HedgeModManager 17 | { 18 | public partial class SLWSaveForm : Form 19 | { 20 | 21 | public Thread imageThread; 22 | public List SIDs = new List(); 23 | public string SID = ""; 24 | 25 | public SLWSaveForm() 26 | { 27 | InitializeComponent(); 28 | } 29 | 30 | public void GetAndApplyImages() 31 | { 32 | // WebClient for downloading data from Steam's servers 33 | var webClient = new WebClient(); 34 | 35 | foreach (string sid in SIDs) 36 | { 37 | // Gets the cached icon 38 | var image = Steam.GetCachedProfileImage(sid); 39 | if (image == null || ModifierKeys.HasFlag(Keys.Shift)) 40 | { 41 | // Downloads the icon 42 | image = DownloadSteamProfilePicture(webClient, sid); 43 | } 44 | 45 | if (image != null) 46 | Invoke(new Action(() => listView1.LargeImageList.Images.Add(sid, image))); 47 | } 48 | } 49 | 50 | 51 | public Bitmap DownloadSteamProfilePicture(WebClient webClient, string SID) 52 | { 53 | string url = "http://steamcommunity.com/profiles/" + SID; 54 | string PIURL = @"steamcommunity/public/images"; 55 | url = webClient.DownloadString(url); 56 | url = GetString(url.Substring(0, url.IndexOf(PIURL)).LastIndexOf('\"') - 1, url); 57 | return new Bitmap(new MemoryStream(webClient.DownloadData(url))); 58 | } 59 | 60 | private void SLWSaveForm_Load(object sender, EventArgs e) 61 | { 62 | // Sets up this ImageList 63 | listView1.LargeImageList = new ImageList() 64 | { 65 | ImageSize = new Size(64, 64), 66 | ColorDepth = ColorDepth.Depth32Bit 67 | }; 68 | 69 | // Checks if the Key and Value exists. 70 | if (Steam.SteamLocation != null) 71 | { 72 | // Checks if "loginusers.vdf" exists. 73 | if (File.Exists(Path.Combine(Steam.SteamLocation, "config\\loginusers.vdf"))) 74 | { 75 | // loginusers.vdf 76 | var file = Steam.VDFFile.ReadVDF(Path.Combine(Steam.SteamLocation, "config\\loginusers.vdf")); 77 | foreach (var pair in file.Array.Elements.ToList()) 78 | { 79 | // Adds ListViewItem 80 | var array = pair.Value as Steam.VDFFile.VDFArray; 81 | var lvi = new ListViewItem(array.Elements["PersonaName"].Value as string) 82 | { 83 | ImageKey = array.Name 84 | }; 85 | // Adds the SID to the SID list 86 | SIDs.Add(array.Name); 87 | listView1.Items.Add(lvi); 88 | } 89 | } 90 | // Gets the icons in another thread 91 | imageThread = new Thread(new ThreadStart(GetAndApplyImages)); 92 | imageThread.Start(); 93 | }else 94 | { 95 | Close(); 96 | } 97 | } 98 | 99 | private void SLWSaveForm_FormClosing(object sender, FormClosingEventArgs e) 100 | { 101 | if (imageThread.IsAlive) 102 | imageThread.Abort(); 103 | } 104 | 105 | private void Button_Install_Click(object sender, EventArgs e) 106 | { 107 | if (listView1.SelectedItems.Count == 1) 108 | { 109 | string sid = listView1.SelectedItems[0].ImageKey; 110 | SID = "" + (long.Parse(sid) & 0xFFFFFFFF); 111 | Close(); 112 | } 113 | } 114 | 115 | private void ListView1_DrawItem(object sender, DrawListViewItemEventArgs e) 116 | { 117 | e.DrawDefault = true; 118 | } 119 | 120 | public static string GetString(int location, string mainString) 121 | { 122 | string substr = mainString.Substring(location).Replace("\\\"", "%22"); 123 | if (!substr.Contains("\"")) 124 | return ""; 125 | else if (substr[0] == '\"') 126 | return substr.Substring(1, substr.IndexOf("\"", 2) - 1).Replace("%22", "\\\""); 127 | else 128 | return GetString(substr.IndexOf('\"'), substr).Replace("%22", "\\\""); 129 | } 130 | 131 | 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /Sonic-CD-SaveED/SLWSaveForm.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /Sonic-CD-SaveED/Sonic-CD-SaveED.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {E9AF2D39-98CC-4EE6-BF10-5593747CB256} 8 | WinExe 9 | Sonic_CD_SaveED 10 | Sonic-CD-SaveED 11 | v4.6.1 12 | 512 13 | true 14 | 15 | 16 | AnyCPU 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | AnyCPU 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | 34 | 35 | 36 | 37 | 38 | sonic_CD.ico 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | Form 56 | 57 | 58 | AboutForm.cs 59 | 60 | 61 | Form 62 | 63 | 64 | MainForm.cs 65 | 66 | 67 | 68 | 69 | Form 70 | 71 | 72 | SLWSaveForm.cs 73 | 74 | 75 | 76 | AboutForm.cs 77 | 78 | 79 | MainForm.cs 80 | 81 | 82 | ResXFileCodeGenerator 83 | Resources.Designer.cs 84 | Designer 85 | 86 | 87 | True 88 | Resources.resx 89 | 90 | 91 | SLWSaveForm.cs 92 | 93 | 94 | SettingsSingleFileGenerator 95 | Settings.Designer.cs 96 | 97 | 98 | True 99 | Settings.settings 100 | True 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | {b41a3858-7e66-4755-9f50-94ea021155b6} 112 | RSDKv2 113 | 114 | 115 | 116 | -------------------------------------------------------------------------------- /Sonic-CD-SaveED/Steam.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Win32; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Drawing; 5 | using System.IO; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | 10 | namespace HedgeModManager 11 | { 12 | public static class Steam 13 | { 14 | public static string SteamLocation; 15 | 16 | public static void Init() 17 | { 18 | // Gets Steam's Registry Key 19 | var key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Valve\\Steam"); 20 | // If null then try get it from the 64-bit Registry 21 | if (key == null) 22 | key = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64) 23 | .OpenSubKey("SOFTWARE\\Valve\\Steam"); 24 | // Checks if the Key and Value exists. 25 | if (key != null && key.GetValue("SteamPath") is string steamPath) 26 | SteamLocation = steamPath; 27 | } 28 | 29 | public static Image GetCachedProfileImage(string SID) 30 | { 31 | string filePath = Path.Combine(SteamLocation, "config/avatarcache/", SID + ".png"); 32 | if (File.Exists(filePath)) 33 | return Image.FromFile(filePath); 34 | return null; 35 | } 36 | 37 | public class VDFFile 38 | { 39 | public class VDFElement 40 | { 41 | public string Name; 42 | public string Value; 43 | public VDFElement Parent; 44 | } 45 | 46 | public class VDFArray : VDFElement 47 | { 48 | public Dictionary Elements = new Dictionary(); 49 | 50 | public VDFArray(string name) 51 | { 52 | Name = name; 53 | } 54 | } 55 | 56 | public VDFArray Array = null; 57 | 58 | protected VDFFile() 59 | { 60 | 61 | } 62 | 63 | // I know this is not how you read .vdf files. But it works for files that I need to read. 64 | public static VDFFile ReadVDF(string filePath) 65 | { 66 | var file = new VDFFile(); 67 | string buffer = ""; 68 | VDFArray mainArray = null; 69 | VDFArray lastArray = null; 70 | VDFArray currentArray = null; 71 | 72 | VDFElement element = null; 73 | using (var textReader = File.OpenText(filePath)) 74 | { 75 | while (textReader.Peek() != -1) 76 | { 77 | string line = textReader.ReadLine(); 78 | bool startReadingString = false; 79 | for (int i = 0; i < line.Length; ++i) 80 | { 81 | // Read String 82 | if (startReadingString) 83 | { 84 | if (line[i] == '\"') 85 | { 86 | startReadingString = false; 87 | if (element != null) 88 | { 89 | element.Value = buffer; 90 | buffer = ""; 91 | currentArray.Elements.Add(element.Name, element); 92 | element = null; 93 | } 94 | continue; 95 | } 96 | buffer += line[i]; 97 | continue; 98 | } 99 | 100 | switch (line[i]) 101 | { 102 | case '\"': 103 | if (buffer.Length != 0) 104 | { 105 | if (element == null) 106 | { 107 | element = new VDFElement(); 108 | element.Name = buffer; 109 | buffer = ""; 110 | } 111 | } 112 | startReadingString = true; 113 | break; 114 | case '{': 115 | if (mainArray == null) 116 | { 117 | mainArray = new VDFArray(buffer); 118 | currentArray = mainArray; 119 | buffer = ""; 120 | break; 121 | } 122 | var array = new VDFArray(buffer); 123 | lastArray = currentArray; 124 | currentArray.Elements.Add(array.Name, array); 125 | currentArray = array; 126 | buffer = ""; 127 | break; 128 | case '}': 129 | currentArray = lastArray; 130 | lastArray = mainArray; 131 | break; 132 | default: 133 | break; 134 | } 135 | } 136 | } 137 | } 138 | file.Array = mainArray; 139 | return file; 140 | } 141 | 142 | 143 | } 144 | } 145 | } 146 | -------------------------------------------------------------------------------- /Sonic-CD-SaveED/sonic_CD.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rubberduckycooly/SonicCD-SaveEditor/73189cd042250b84dee77fd78505baa74f1b0547/Sonic-CD-SaveED/sonic_CD.ico -------------------------------------------------------------------------------- /packages/zlib.net.1.0.4.0/lib/zlib.net.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rubberduckycooly/SonicCD-SaveEditor/73189cd042250b84dee77fd78505baa74f1b0547/packages/zlib.net.1.0.4.0/lib/zlib.net.dll -------------------------------------------------------------------------------- /packages/zlib.net.1.0.4.0/zlib.net.1.0.4.0.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rubberduckycooly/SonicCD-SaveEditor/73189cd042250b84dee77fd78505baa74f1b0547/packages/zlib.net.1.0.4.0/zlib.net.1.0.4.0.nupkg --------------------------------------------------------------------------------