update nugets & code optimization

This commit is contained in:
2024-06-11 08:11:40 +02:00
parent 79d9eed045
commit 3615fc109a
58 changed files with 337 additions and 290 deletions

View File

@@ -93,7 +93,7 @@ public class MIO0
public static byte[] mio0_decode(byte[] mio0_buf) public static byte[] mio0_decode(byte[] mio0_buf)
{ {
MIO0_Header head = new MIO0_Header(); MIO0_Header head = new();
uint bytes_written = 0; uint bytes_written = 0;
int bit_idx = 0; int bit_idx = 0;
int comp_idx = 0; int comp_idx = 0;

View File

@@ -9,7 +9,7 @@ public class TextureFormats
{ {
public static Bitmap createColorTexture(Color color) public static Bitmap createColorTexture(Color color)
{ {
Bitmap tex = new Bitmap(1, 1); Bitmap tex = new(1, 1);
Graphics.FromImage(tex).Clear(color); Graphics.FromImage(tex).Clear(color);
return tex; return tex;
} }
@@ -306,7 +306,7 @@ public class TextureFormats
public static Bitmap decode1BPP(byte[] data, int width, int height) public static Bitmap decode1BPP(byte[] data, int width, int height)
{ {
Bitmap tex = new Bitmap(width, height); Bitmap tex = new(width, height);
if (data.Length >= (width * height) / 8) // Sanity Check if (data.Length >= (width * height) / 8) // Sanity Check
{ {
int len = (width * height) / 8; int len = (width * height) / 8;
@@ -332,7 +332,7 @@ public class TextureFormats
{ {
Console.WriteLine("Texture size = (" + width + "x" + height + ")"); Console.WriteLine("Texture size = (" + width + "x" + height + ")");
Console.WriteLine("data.Length = (" + data.Length + ")"); Console.WriteLine("data.Length = (" + data.Length + ")");
Bitmap tex = new Bitmap(width, height); Bitmap tex = new(width, height);
if (data.Length >= width * height * 4) // Sanity Check if (data.Length >= width * height * 4) // Sanity Check
{ {
@@ -358,7 +358,7 @@ public class TextureFormats
public static Bitmap decodeRGBA16(byte[] data, int width, int height) public static Bitmap decodeRGBA16(byte[] data, int width, int height)
{ {
Bitmap tex = new Bitmap(width, height); Bitmap tex = new(width, height);
if (data.Length >= width * height * 2) // Sanity Check if (data.Length >= width * height * 2) // Sanity Check
{ {
BitmapData bitmapData = tex.LockBits(new Rectangle(0, 0, width, height), BitmapData bitmapData = tex.LockBits(new Rectangle(0, 0, width, height),
@@ -385,7 +385,7 @@ public class TextureFormats
public static Bitmap decodeIA16(byte[] data, int width, int height) public static Bitmap decodeIA16(byte[] data, int width, int height)
{ {
Bitmap tex = new Bitmap(width, height); Bitmap tex = new(width, height);
if (data.Length >= width * height * 2) // Sanity Check if (data.Length >= width * height * 2) // Sanity Check
{ {
BitmapData bitmapData = tex.LockBits(new Rectangle(0, 0, width, height), BitmapData bitmapData = tex.LockBits(new Rectangle(0, 0, width, height),
@@ -410,7 +410,7 @@ public class TextureFormats
public static Bitmap decodeIA8(byte[] data, int width, int height) public static Bitmap decodeIA8(byte[] data, int width, int height)
{ {
Bitmap tex = new Bitmap(width, height); Bitmap tex = new(width, height);
if (data.Length >= width * height) // Sanity Check if (data.Length >= width * height) // Sanity Check
{ {
BitmapData bitmapData = tex.LockBits(new Rectangle(0, 0, width, height), BitmapData bitmapData = tex.LockBits(new Rectangle(0, 0, width, height),
@@ -435,7 +435,7 @@ public class TextureFormats
} }
public static Bitmap decodeIA4(byte[] data, int width, int height) public static Bitmap decodeIA4(byte[] data, int width, int height)
{ {
Bitmap tex = new Bitmap(width, height); Bitmap tex = new(width, height);
if (data.Length >= (width * height) / 2) // Sanity Check if (data.Length >= (width * height) / 2) // Sanity Check
{ {
@@ -469,7 +469,7 @@ public class TextureFormats
} }
public static Bitmap decodeI8(byte[] data, int width, int height) public static Bitmap decodeI8(byte[] data, int width, int height)
{ {
Bitmap tex = new Bitmap(width, height); Bitmap tex = new(width, height);
if (data.Length >= width * height) // Sanity Check if (data.Length >= width * height) // Sanity Check
{ {
@@ -496,7 +496,7 @@ public class TextureFormats
} }
public static Bitmap decodeI4(byte[] data, int width, int height) public static Bitmap decodeI4(byte[] data, int width, int height)
{ {
Bitmap tex = new Bitmap(width, height); Bitmap tex = new(width, height);
if (data.Length >= (width * height) / 2) // Sanity Check if (data.Length >= (width * height) / 2) // Sanity Check
{ {
@@ -531,7 +531,7 @@ public class TextureFormats
public static Bitmap decodeCI4(byte[] data, int width, int height, ushort[] palette) public static Bitmap decodeCI4(byte[] data, int width, int height, ushort[] palette)
{ {
Bitmap tex = new Bitmap(width, height); Bitmap tex = new(width, height);
if (data.Length >= (width * height) / 2) // Sanity Check if (data.Length >= (width * height) / 2) // Sanity Check
{ {
@@ -565,7 +565,7 @@ public class TextureFormats
public static Bitmap decodeCI8(byte[] data, int width, int height, ushort[] palette) public static Bitmap decodeCI8(byte[] data, int width, int height, ushort[] palette)
{ {
Bitmap tex = new Bitmap(width, height); Bitmap tex = new(width, height);
if (data.Length >= width * height) // Sanity Check if (data.Length >= width * height) // Sanity Check
{ {

View File

@@ -15,8 +15,7 @@ public class CustomAsmArea
{ {
get get
{ {
if (config == null) config ??= new CustomAsmAreaConfig();
config = new CustomAsmAreaConfig();
return config; return config;
} }
} }

View File

@@ -8,7 +8,7 @@ public class CustomAsmBank
{ {
public CustomAsmBankConfig Config { get; } public CustomAsmBankConfig Config { get; }
[JsonIgnore] [JsonIgnore]
public List<CustomAsmArea> Areas { get; } = new List<CustomAsmArea>(); public List<CustomAsmArea> Areas { get; } = [];
public CustomAsmBank() : this(new CustomAsmBankConfig()) public CustomAsmBank() : this(new CustomAsmBankConfig())
{ {

View File

@@ -9,7 +9,7 @@ public class CustomAsmBankConfig
public static int DefaultRomStartAddress { get; internal set; } = 0x1206000; public static int DefaultRomStartAddress { get; internal set; } = 0x1206000;
public static int DefaultRamStartAddress { get; internal set; } = 0x406000; public static int DefaultRamStartAddress { get; internal set; } = 0x406000;
public List<CustomAsmAreaConfig> Areas { get; } = new List<CustomAsmAreaConfig>(); public List<CustomAsmAreaConfig> Areas { get; } = [];
public int MaxLength { get; set; } = -1; public int MaxLength { get; set; } = -1;
[JsonProperty] [JsonProperty]
public int Length { get; internal set; } = -1; public int Length { get; internal set; } = -1;

View File

@@ -12,7 +12,7 @@ namespace SM64Lib.Behaviors;
public class Behavior public class Behavior
{ {
private readonly Dictionary<CustomAsmAreaConfig, BehaviorscriptCommand> knownCustomAsmCommands = new Dictionary<CustomAsmAreaConfig, BehaviorscriptCommand>(); private readonly Dictionary<CustomAsmAreaConfig, BehaviorscriptCommand> knownCustomAsmCommands = [];
[JsonProperty] [JsonProperty]
public BehaviorConfig Config { get; private set; } public BehaviorConfig Config { get; private set; }
@@ -20,7 +20,7 @@ public class Behavior
public Behaviorscript Script { get; private set; } public Behaviorscript Script { get; private set; }
public int CollisionPointer { get; set; } public int CollisionPointer { get; set; }
public bool EnableCollisionPointer { get; set; } public bool EnableCollisionPointer { get; set; }
public List<int> BehaviorAddressDestinations { get; set; } = new List<int>(); public List<int> BehaviorAddressDestinations { get; set; } = [];
[JsonIgnore] [JsonIgnore]
public long Length public long Length
@@ -72,7 +72,7 @@ public class Behavior
{ {
if (Script != null) if (Script != null)
Script.Close(); Script.Close();
Script = new Behaviorscript(); Script = [];
} }
public bool Read(BinaryData data, int address) public bool Read(BinaryData data, int address)
@@ -154,7 +154,7 @@ public class Behavior
if (cmdStartLoop is not null) if (cmdStartLoop is not null)
iInsert = cmdStartLoopIndex; iInsert = cmdStartLoopIndex;
else else
iInsert = (int)Script.Count - 2; iInsert = Script.Count - 2;
} }
if (knownCustomAsmCommands.ContainsKey(link.CustomAsmAreaConfig)) if (knownCustomAsmCommands.ContainsKey(link.CustomAsmAreaConfig))

View File

@@ -11,7 +11,7 @@ namespace SM64Lib.Behaviors;
public class BehaviorBank public class BehaviorBank
{ {
public BehaviorBankConfig Config { get; private set; } public BehaviorBankConfig Config { get; private set; }
public List<Behavior> Behaviors { get; } = new List<Behavior>(); public List<Behavior> Behaviors { get; } = [];
[JsonIgnore] [JsonIgnore]
public long Length public long Length
@@ -36,8 +36,10 @@ public class BehaviorBank
private void ReadBank(SegmentedBank seg, int offset, bool isVanilla) private void ReadBank(SegmentedBank seg, int offset, bool isVanilla)
{ {
var data = new BinaryStreamData(seg.Data); var data = new BinaryStreamData(seg.Data)
data.Position = offset; {
Position = offset
};
ReadBank(data, isVanilla, seg.Length, (sbyte)seg.BankID); ReadBank(data, isVanilla, seg.Length, (sbyte)seg.BankID);
} }
@@ -69,7 +71,7 @@ public class BehaviorBank
void readBehavior(BehaviorConfig config) void readBehavior(BehaviorConfig config)
{ {
int bankOffset; int bankOffset;
Behavior behav = new Behavior(config); Behavior behav = new(config);
if (isVanilla) if (isVanilla)
{ {
@@ -108,8 +110,10 @@ public class BehaviorBank
{ {
var addressUpdates = new Dictionary<int, int>(); var addressUpdates = new Dictionary<int, int>();
var segStartAddress = seg.BankAddress | offset; var segStartAddress = seg.BankAddress | offset;
var data = new BinaryStreamData(seg.Data); var data = new BinaryStreamData(seg.Data)
data.Position = offset; {
Position = offset
};
if (Behaviors.Any()) if (Behaviors.Any())
{ {

View File

@@ -6,7 +6,7 @@ namespace SM64Lib.Behaviors;
public class BehaviorBankConfig public class BehaviorBankConfig
{ {
public bool IsVanilla { get; set; } = true; public bool IsVanilla { get; set; } = true;
public List<BehaviorConfig> BehaviorConfigs { get; } = new List<BehaviorConfig>(); public List<BehaviorConfig> BehaviorConfigs { get; } = [];
[JsonProperty(nameof(Enabled))] [JsonProperty(nameof(Enabled))]
private bool enabled = false; private bool enabled = false;

View File

@@ -17,7 +17,7 @@ public class BehaviorConfig
public string Name { get; set; } = string.Empty; public string Name { get; set; } = string.Empty;
public int FixedLength { get; set; } = -1; public int FixedLength { get; set; } = -1;
public int ExpectedLength { get; set; } = -1; public int ExpectedLength { get; set; } = -1;
public List<CustomAsmAreaLinkOptions> CustomAsmLinks { get; } = new List<CustomAsmAreaLinkOptions>(); public List<CustomAsmAreaLinkOptions> CustomAsmLinks { get; } = [];
public BehaviorParamsInfo ParamsInfo { get; } = new BehaviorParamsInfo(); public BehaviorParamsInfo ParamsInfo { get; } = new BehaviorParamsInfo();
public Behavior FindBehavior() public Behavior FindBehavior()

View File

@@ -6,5 +6,5 @@ public class BehaviorParamInfo
{ {
public string Name { get; set; } = string.Empty; public string Name { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty; public string Description { get; set; } = string.Empty;
public List<BehaviorParamValue> Values { get; } = new List<BehaviorParamValue>(); public List<BehaviorParamValue> Values { get; } = [];
} }

View File

@@ -98,7 +98,7 @@ public class Behaviorscript : BehaviorscriptCommandCollection
public BehaviorscriptCommand FirstOfType(BehaviorscriptCommandTypes cmdType) public BehaviorscriptCommand FirstOfType(BehaviorscriptCommandTypes cmdType)
{ {
return (BehaviorscriptCommand)this.FirstOrDefault(n => n.CommandType == cmdType); return this.FirstOrDefault(n => n.CommandType == cmdType);
} }
} }

View File

@@ -6,8 +6,7 @@ namespace SM64Lib.Configuration;
public class CollisionBasicConfig public class CollisionBasicConfig
{ {
private List<byte> collisionTypesWithParams = new List<byte>() private List<byte> collisionTypesWithParams = [4, 14, 44, 36, 37, 39, 45];
{ 4, 14, 44, 36, 37, 39, 45 };
[JsonProperty("CollisionTypesWithParamsV2", ObjectCreationHandling = ObjectCreationHandling.Replace)] [JsonProperty("CollisionTypesWithParamsV2", ObjectCreationHandling = ObjectCreationHandling.Replace)]
public List<byte> CollisionTypesWithParams public List<byte> CollisionTypesWithParams

View File

@@ -14,7 +14,7 @@ public class CustomModelConfig
[JsonConverter(typeof(UniquieIDStringJsonConverter))] [JsonConverter(typeof(UniquieIDStringJsonConverter))]
public UniquieID ID { get; set; } = new(); public UniquieID ID { get; set; } = new();
public string Name { get; set; } = string.Empty; public string Name { get; set; } = string.Empty;
public List<int> CollisionPointerDestinations { get; private set; } = new List<int>(); public List<int> CollisionPointerDestinations { get; private set; } = [];
public CustomModel FindModel() public CustomModel FindModel()
{ {

View File

@@ -5,5 +5,5 @@ namespace SM64Lib.Configuration;
public class LevelAreaConfig public class LevelAreaConfig
{ {
public string AreaName { get; set; } public string AreaName { get; set; }
public Dictionary<short, string> ScrollingNames { get; set; } = new Dictionary<short, string>(); public Dictionary<short, string> ScrollingNames { get; set; } = [];
} }

View File

@@ -7,7 +7,7 @@ public class LevelConfig
public string LevelName { get; set; } public string LevelName { get; set; }
public bool EnableLocalObjectBank { get; set; } = false; public bool EnableLocalObjectBank { get; set; } = false;
public ObjectModelConfig LocalObjectBank { get; set; } = new ObjectModelConfig(); public ObjectModelConfig LocalObjectBank { get; set; } = new ObjectModelConfig();
public Dictionary<byte, LevelAreaConfig> AreaConfigs { get; private set; } = new Dictionary<byte, LevelAreaConfig>(); public Dictionary<byte, LevelAreaConfig> AreaConfigs { get; private set; } = [];
public LevelAreaConfig GetLevelAreaConfig(byte areaID) public LevelAreaConfig GetLevelAreaConfig(byte areaID)
{ {

View File

@@ -4,5 +4,5 @@ namespace SM64Lib.Configuration;
public class MusicConfiguration public class MusicConfiguration
{ {
public List<string> SqeuenceNames { get; private set; } = new List<string>(); public List<string> SqeuenceNames { get; private set; } = [];
} }

View File

@@ -4,7 +4,7 @@ namespace SM64Lib.Configuration;
public class ObjectModelConfig public class ObjectModelConfig
{ {
public Dictionary<int, CustomModelConfig> CustomObjectConfigs { get; private set; } = new Dictionary<int, CustomModelConfig>(); public Dictionary<int, CustomModelConfig> CustomObjectConfigs { get; private set; } = [];
public CustomModelConfig GetCustomObjectConfig(int id) public CustomModelConfig GetCustomObjectConfig(int id)
{ {

View File

@@ -13,7 +13,7 @@ namespace SM64Lib.Configuration;
public class RomConfig public class RomConfig
{ {
// Levels // Levels
public Dictionary<byte, LevelConfig> LevelConfigs { get; } = new Dictionary<byte, LevelConfig>(); public Dictionary<byte, LevelConfig> LevelConfigs { get; } = [];
// Global Banks // Global Banks
[JsonProperty("GlobalObjectBankConfig")] [JsonProperty("GlobalObjectBankConfig")]
@@ -33,14 +33,14 @@ public class RomConfig
// Other // Other
public ScrollTexConfig ScrollTexConfig { get; set; } = new ScrollTexConfig(); public ScrollTexConfig ScrollTexConfig { get; set; } = new ScrollTexConfig();
public ObjectBankDataListCollection ObjectBankInfoData { get; } = new ObjectBankDataListCollection(); public ObjectBankDataListCollection ObjectBankInfoData { get; } = [];
public NPCConfig NPCConfig { get; } = new NPCConfig(); public NPCConfig NPCConfig { get; } = new NPCConfig();
public CollisionBasicConfig CollisionBaseConfig { get; } = new CollisionBasicConfig(); public CollisionBasicConfig CollisionBaseConfig { get; } = new CollisionBasicConfig();
/// <summary> /// <summary>
/// Contains custom configuration that isn't used by SM64Lib. E.g. Extra Object Combos. /// Contains custom configuration that isn't used by SM64Lib. E.g. Extra Object Combos.
/// </summary> /// </summary>
public Dictionary<string, string> CustomConfigs { get; } = new Dictionary<string, string>(); public Dictionary<string, string> CustomConfigs { get; } = [];
// F e a t u r e s // F e a t u r e s

View File

@@ -27,10 +27,7 @@ public abstract class BinaryData : IDisposable
{ {
get get
{ {
if (_writer is null) _writer ??= new BinaryWriter(BaseStream);
{
_writer = new BinaryWriter(BaseStream);
}
return _writer; return _writer;
} }
@@ -40,10 +37,7 @@ public abstract class BinaryData : IDisposable
{ {
get get
{ {
if (_reader is null) _reader ??= new BinaryReader(BaseStream);
{
_reader = new BinaryReader(BaseStream);
}
return _reader; return _reader;
} }

View File

@@ -19,7 +19,7 @@ public class FilePathsConfiguration
// F I E L D S // F I E L D S
private readonly Dictionary<string, string> dic = new Dictionary<string, string>(); private readonly Dictionary<string, string> dic = [];
// P R O P E R T I E S // P R O P E R T I E S

View File

@@ -13,11 +13,11 @@ public class Geolayout
[JsonProperty] [JsonProperty]
private int IndexForGeopointers = -1; private int IndexForGeopointers = -1;
public Geolayoutscript Geolayoutscript { get; set; } = new Geolayoutscript(); public Geolayoutscript Geolayoutscript { get; set; } = [];
public CameraPresets CameraPreset { get; set; } = CameraPresets.OpenCamera; public CameraPresets CameraPreset { get; set; } = CameraPresets.OpenCamera;
public EnvironmentEffects EnvironmentEffect { get; set; } = default; public EnvironmentEffects EnvironmentEffect { get; set; } = default;
public List<int> GeopointerOffsets { get; set; } = new List<int>(); public List<int> GeopointerOffsets { get; set; } = [];
public List<Geopointer> Geopointers { get; set; } = new List<Geopointer>(); public List<Geopointer> Geopointers { get; set; } = [];
public int NewGeoOffset { get; set; } = 0; public int NewGeoOffset { get; set; } = 0;
public bool Closed { get; set; } = false; public bool Closed { get; set; } = false;
public ObjectShadow ObjectShadow { get; set; } = new ObjectShadow(); public ObjectShadow ObjectShadow { get; set; } = new ObjectShadow();
@@ -54,7 +54,7 @@ public class Geolayout
private List<Geopointer> GetGeopointersFromGeolayoutScript(Geolayoutscript script) private List<Geopointer> GetGeopointersFromGeolayoutScript(Geolayoutscript script)
{ {
List<Geopointer> geopointers = new List<Geopointer>(); List<Geopointer> geopointers = [];
int geolayoutCommandIndex = 0; int geolayoutCommandIndex = 0;
var curMdlScale = System.Numerics.Vector3.One; var curMdlScale = System.Numerics.Vector3.One;
var curMdlOffset = System.Numerics.Vector3.Zero; var curMdlOffset = System.Numerics.Vector3.Zero;
@@ -157,7 +157,7 @@ public class Geolayout
Geolayoutscript.Clear(); Geolayoutscript.Clear();
Geopointers.Clear(); Geopointers.Clear();
GeopointerOffsets.Clear(); GeopointerOffsets.Clear();
Geolayoutscript = new Geolayoutscript(); Geolayoutscript = [];
ObjectShadow = new ObjectShadow(); ObjectShadow = new ObjectShadow();
CameraFrustrum = new CameraFrustrum(); CameraFrustrum = new CameraFrustrum();
} }

View File

@@ -161,10 +161,12 @@ namespace SM64Lib.Geolayout.Script
public static Vector3 GetOffset(ref GeolayoutCommand command) public static Vector3 GetOffset(ref GeolayoutCommand command)
{ {
command.Position = 2; command.Position = 2;
var value = new Vector3(); var value = new Vector3
value.X = command.ReadInt16(); {
value.Y = command.ReadInt16(); X = command.ReadInt16(),
value.Z = command.ReadInt16(); Y = command.ReadInt16(),
Z = command.ReadInt16()
};
command.Position = 0; command.Position = 0;
return value; return value;
} }
@@ -204,9 +206,11 @@ namespace SM64Lib.Geolayout.Script
public static Vector3 GetOffset(ref GeolayoutCommand command) public static Vector3 GetOffset(ref GeolayoutCommand command)
{ {
command.Position = 2; command.Position = 2;
var value = new Vector3(); var value = new Vector3
value.X = command.ReadInt16(); {
value.Y = command.ReadInt16(); X = command.ReadInt16(),
Y = command.ReadInt16()
};
command.Position += 2; command.Position += 2;
value.Z = command.ReadInt16(); value.Z = command.ReadInt16();
command.Position = 0; command.Position = 0;

View File

@@ -9,7 +9,7 @@ namespace SM64Lib.Geolayout.Script;
public class Geolayoutscript : GeolayoutCommandCollection public class Geolayoutscript : GeolayoutCommandCollection
{ {
public List<int> GeopointerOffsets = new List<int>(); public List<int> GeopointerOffsets = [];
public Geolayoutscript() public Geolayoutscript()
{ {
@@ -43,8 +43,10 @@ public class Geolayoutscript : GeolayoutCommandCollection
GeopointerOffsets.Clear(); GeopointerOffsets.Clear();
if (segBank is null) if (segBank is null)
return; return;
var data = new BinaryStreamData(segBank.Data); var data = new BinaryStreamData(segBank.Data)
data.Position = offset; {
Position = offset
};
var tb = new List<byte>(); var tb = new List<byte>();
GeolayoutCommandTypes cb = default; GeolayoutCommandTypes cb = default;
int subNodeIndex = 0; int subNodeIndex = 0;

View File

@@ -28,9 +28,9 @@ public abstract class Level
internal LevelscriptCommand LastGobCmdSegLoad { get; set; } = null; internal LevelscriptCommand LastGobCmdSegLoad { get; set; } = null;
internal LevelscriptCommand LastLobCmdSegLoad { get; set; } = null; internal LevelscriptCommand LastLobCmdSegLoad { get; set; } = null;
[JsonIgnore] [JsonIgnore]
internal Dictionary<byte, ObjectBankData> MyObjectBanks { get; private set; } = new Dictionary<byte, ObjectBankData>(); internal Dictionary<byte, ObjectBankData> MyObjectBanks { get; private set; } = [];
public Levelscript Levelscript { get; set; } = new Levelscript(); public Levelscript Levelscript { get; set; } = [];
public List<LevelArea> Areas { get; private set; } = new List<LevelArea>(); public List<LevelArea> Areas { get; private set; } = [];
public ushort LevelID { get; set; } = 0; public ushort LevelID { get; set; } = 0;
public LevelBG Background { get; private set; } = new LevelBG(); public LevelBG Background { get; private set; } = new LevelBG();
public bool ActSelector { get; set; } = false; public bool ActSelector { get; set; } = false;
@@ -217,7 +217,7 @@ public abstract class Level
public LevelscriptCommand GetDefaultPositionCmd() public LevelscriptCommand GetDefaultPositionCmd()
{ {
return (LevelscriptCommand)Levelscript.FirstOrDefault(n => n.CommandType == LevelscriptCommandTypes.DefaultPosition); return Levelscript.FirstOrDefault(n => n.CommandType == LevelscriptCommandTypes.DefaultPosition);
} }
public void ChangeObjectBankData(byte bankID, ObjectBankData newObd) public void ChangeObjectBankData(byte bankID, ObjectBankData newObd)

View File

@@ -21,15 +21,15 @@ public abstract class LevelArea
// A u t o P r o p e r t i e s // A u t o P r o p e r t i e s
public SpecialBoxList SpecialBoxes { get; private set; } = new SpecialBoxList(); public SpecialBoxList SpecialBoxes { get; private set; } = [];
public List<ManagedScrollingTexture> ScrollingTextures { get; private set; } = new List<ManagedScrollingTexture>(); public List<ManagedScrollingTexture> ScrollingTextures { get; private set; } = [];
public List<LevelscriptCommand> Objects { get; private set; } = new List<LevelscriptCommand>(); public List<LevelscriptCommand> Objects { get; private set; } = [];
public List<LevelscriptCommand> MacroObjects { get; private set; } = new List<LevelscriptCommand>(); public List<LevelscriptCommand> MacroObjects { get; private set; } = [];
public List<LevelscriptCommand> Warps { get; private set; } = new List<LevelscriptCommand>(); public List<LevelscriptCommand> Warps { get; private set; } = [];
public List<LevelscriptCommand> WarpsForGame { get; private set; } = new List<LevelscriptCommand>(); public List<LevelscriptCommand> WarpsForGame { get; private set; } = [];
public ShowMessage ShowMessage { get; private set; } = new ShowMessage(); public ShowMessage ShowMessage { get; private set; } = new ShowMessage();
public AreaBG Background { get; private set; } = new AreaBG(); public AreaBG Background { get; private set; } = new AreaBG();
public LevelscriptCommandCollection Levelscript { get; set; } = new LevelscriptCommandCollection(); public LevelscriptCommandCollection Levelscript { get; set; } = [];
public Geolayout.Geolayout Geolayout { get; set; } = new Geolayout.Geolayout(SM64Lib.Geolayout.Geolayout.NewScriptCreationMode.None); public Geolayout.Geolayout Geolayout { get; set; } = new Geolayout.Geolayout(SM64Lib.Geolayout.Geolayout.NewScriptCreationMode.None);
public Geolayout.TerrainTypes TerrainType { get; set; } = SM64Lib.Geolayout.TerrainTypes.NoramlA; public Geolayout.TerrainTypes TerrainType { get; set; } = SM64Lib.Geolayout.TerrainTypes.NoramlA;
public byte BGMusic { get; set; } = 0; public byte BGMusic { get; set; } = 0;
@@ -80,7 +80,7 @@ public abstract class LevelArea
{ {
if (cmd.CommandType == LevelscriptCommandTypes.AreaCollision) if (cmd.CommandType == LevelscriptCommandTypes.AreaCollision)
{ {
CollisionPointerRet = Convert.ToInt32(clAreaCollision.GetAreaCollision((LevelscriptCommand)cmd)); CollisionPointerRet = Convert.ToInt32(clAreaCollision.GetAreaCollision(cmd));
} }
} }
@@ -96,7 +96,7 @@ public abstract class LevelArea
{ {
if (cmd.CommandType == LevelscriptCommandTypes.AreaCollision) if (cmd.CommandType == LevelscriptCommandTypes.AreaCollision)
{ {
clAreaCollision.SetAreaCollision((LevelscriptCommand)cmd, Convert.ToUInt32(value)); clAreaCollision.SetAreaCollision(cmd, Convert.ToUInt32(value));
} }
} }
} }

View File

@@ -42,7 +42,7 @@ public class LevelManager : ILevelManager
lvl.Closed = false; lvl.Closed = false;
// Lade Levelscript // Lade Levelscript
lvl.Levelscript = new Levelscript(); lvl.Levelscript = [];
lvl.Levelscript.Read(rommgr, Convert.ToInt32(segAddress)); lvl.Levelscript.Read(rommgr, Convert.ToInt32(segAddress));
// Erstelle Areas / Lade Einstellungen // Erstelle Areas / Lade Einstellungen
@@ -57,9 +57,11 @@ public class LevelManager : ILevelManager
{ {
case LevelscriptCommandTypes.StartArea: case LevelscriptCommandTypes.StartArea:
AreaOnFly = true; AreaOnFly = true;
tArea = new RMLevelArea(); tArea = new RMLevelArea
tArea.AreaID = clStartArea.GetAreaID(c); {
tArea.GeolayoutOffset = clStartArea.GetSegGeolayoutAddr(c); // - bank0x19.BankAddress + bank0x19.RomStart AreaID = clStartArea.GetAreaID(c),
GeolayoutOffset = clStartArea.GetSegGeolayoutAddr(c) // - bank0x19.BankAddress + bank0x19.RomStart
};
tArea.Geolayout.Read(rommgr, Convert.ToInt32(tArea.GeolayoutOffset)); tArea.Geolayout.Read(rommgr, Convert.ToInt32(tArea.GeolayoutOffset));
break; break;
case LevelscriptCommandTypes.EndOfArea: case LevelscriptCommandTypes.EndOfArea:
@@ -490,9 +492,9 @@ public class LevelManager : ILevelManager
uint curFirstBank0xEOffset = 0; uint curFirstBank0xEOffset = 0;
// Add Objects and Warps to new Levelscript // Add Objects and Warps to new Levelscript
lvlScript0E = new Levelscript(); lvlScript0E = [];
firstBank0xE = rommgr.SetSegBank(0xE, Convert.ToInt32(curOff), 0); firstBank0xE = rommgr.SetSegBank(0xE, Convert.ToInt32(curOff), 0);
areaobjwarpoffsetdic = new Dictionary<byte, uint>(); areaobjwarpoffsetdic = [];
foreach (LevelArea a in lvl.Areas) foreach (LevelArea a in lvl.Areas)
{ {
areaobjwarpoffsetdic.Add(a.AreaID, (uint)(firstBank0xE.BankAddress + curFirstBank0xEOffset)); areaobjwarpoffsetdic.Add(a.AreaID, (uint)(firstBank0xE.BankAddress + curFirstBank0xEOffset));
@@ -574,7 +576,7 @@ public class LevelManager : ILevelManager
if (!foundCmdShowMsg && tArea.ShowMessage.Enabled) if (!foundCmdShowMsg && tArea.ShowMessage.Enabled)
{ {
var cmdShowMsg = new LevelscriptCommand($"30 04 00 {tArea.ShowMessage.DialogID.ToString("X2")}"); var cmdShowMsg = new LevelscriptCommand($"30 04 00 {tArea.ShowMessage.DialogID.ToString("X2")}");
cmdsToInsertAt.Add((LevelscriptCommand)c, cmdShowMsg); cmdsToInsertAt.Add(c, cmdShowMsg);
} }
foundCmdShowMsg = false; foundCmdShowMsg = false;
@@ -585,44 +587,44 @@ public class LevelManager : ILevelManager
case LevelscriptCommandTypes.AreaMusic: case LevelscriptCommandTypes.AreaMusic:
{ {
clAreaMusic.SetMusicID((LevelscriptCommand)c, lvl.Areas[CurrentAreaIndex].BGMusic); clAreaMusic.SetMusicID(c, lvl.Areas[CurrentAreaIndex].BGMusic);
break; break;
} }
case LevelscriptCommandTypes.AreaMusicSimple: case LevelscriptCommandTypes.AreaMusicSimple:
{ {
clAreaMusicSimple.SetMusicID((LevelscriptCommand)c, lvl.Areas[CurrentAreaIndex].BGMusic); clAreaMusicSimple.SetMusicID(c, lvl.Areas[CurrentAreaIndex].BGMusic);
break; break;
} }
case LevelscriptCommandTypes.Tarrain: case LevelscriptCommandTypes.Tarrain:
{ {
clTerrian.SetTerrainType((LevelscriptCommand)c, (byte)lvl.Areas[CurrentAreaIndex].TerrainType); clTerrian.SetTerrainType(c, (byte)lvl.Areas[CurrentAreaIndex].TerrainType);
break; break;
} }
case LevelscriptCommandTypes.LoadRomToRam: case LevelscriptCommandTypes.LoadRomToRam:
{ {
var switchExpr2 = clLoadRomToRam.GetSegmentedID((LevelscriptCommand)c); var switchExpr2 = clLoadRomToRam.GetSegmentedID(c);
switch (switchExpr2) switch (switchExpr2)
{ {
case 0xE: // Bank 0xE case 0xE: // Bank 0xE
clLoadRomToRam.SetRomStart((LevelscriptCommand)c, firstBank0xE.RomStart); clLoadRomToRam.SetRomStart(c, firstBank0xE.RomStart);
clLoadRomToRam.SetRomEnd((LevelscriptCommand)c, firstBank0xE.RomEnd); clLoadRomToRam.SetRomEnd(c, firstBank0xE.RomEnd);
break; break;
case 0xA: case 0xA:
cmdBgSegLoad = (LevelscriptCommand)c; cmdBgSegLoad = c;
break; break;
case 0x7: case 0x7:
if (lvl.LastGobCmdSegLoad == c) if (lvl.LastGobCmdSegLoad == c)
{ {
cmdGobSegLoad = (LevelscriptCommand)c; cmdGobSegLoad = c;
} }
break; break;
case 0x9: case 0x9:
if (lvl.LastLobCmdSegLoad == c) if (lvl.LastLobCmdSegLoad == c)
{ {
cmdLobSegLoad = (LevelscriptCommand)c; cmdLobSegLoad = c;
} }
break; break;
} }
@@ -634,12 +636,12 @@ public class LevelManager : ILevelManager
{ {
if ((bool)tArea?.ShowMessage.Enabled && !foundCmdShowMsg) if ((bool)tArea?.ShowMessage.Enabled && !foundCmdShowMsg)
{ {
clShowDialog.SetDialogID((LevelscriptCommand)c, tArea.ShowMessage.DialogID); clShowDialog.SetDialogID(c, tArea.ShowMessage.DialogID);
foundCmdShowMsg = true; foundCmdShowMsg = true;
} }
else else
{ {
cmdsToRemove.Add((LevelscriptCommand)c); cmdsToRemove.Add(c);
} }
break; break;
@@ -647,14 +649,14 @@ public class LevelManager : ILevelManager
case LevelscriptCommandTypes.JumpToSegAddr: case LevelscriptCommandTypes.JumpToSegAddr:
{ {
int bankID = clJumpToSegAddr.GetSegJumpAddr((LevelscriptCommand)c) >> 24; int bankID = clJumpToSegAddr.GetSegJumpAddr(c) >> 24;
switch (bankID) switch (bankID)
{ {
case 0x7: case 0x7:
cmdGobJump = (LevelscriptCommand)c; cmdGobJump = c;
break; break;
case 0x9: case 0x9:
cmdLobJump = (LevelscriptCommand)c; cmdLobJump = c;
break; break;
} }
break; break;
@@ -666,7 +668,7 @@ public class LevelManager : ILevelManager
foreach (var e in areaobjwarpindextoinsertdic.OrderByDescending(n => n.Value)) foreach (var e in areaobjwarpindextoinsertdic.OrderByDescending(n => n.Value))
{ {
uint segStartAddr = areaobjwarpoffsetdic[e.Key]; uint segStartAddr = areaobjwarpoffsetdic[e.Key];
lvl.Levelscript.Insert(e.Value, new LevelscriptCommand(new byte[] { 0x6, 8, 0, 0, Convert.ToByte((long)(segStartAddr >> 24) & (long)0xFF), Convert.ToByte((long)(segStartAddr >> 16) & (long)0xFF), Convert.ToByte((long)(segStartAddr >> 8) & (long)0xFF), Convert.ToByte((long)segStartAddr & (long)0xFF) })); lvl.Levelscript.Insert(e.Value, new LevelscriptCommand(new byte[] { 0x6, 8, 0, 0, Convert.ToByte(segStartAddr >> 24 & (long)0xFF), Convert.ToByte(segStartAddr >> 16 & (long)0xFF), Convert.ToByte(segStartAddr >> 8 & (long)0xFF), Convert.ToByte(segStartAddr & (long)0xFF) }));
} }
// Lösche Commands // Lösche Commands

View File

@@ -41,7 +41,7 @@ public class SM64EditorLevelManager : ILevelManager
lvl.Closed = false; lvl.Closed = false;
// Lade Levelscript // Lade Levelscript
lvl.Levelscript = new Levelscript(); lvl.Levelscript = [];
lvl.Levelscript.Read(rommgr, Convert.ToInt32(segAddress)); lvl.Levelscript.Read(rommgr, Convert.ToInt32(segAddress));
// Erstelle Areas / Lade Einstellungen // Erstelle Areas / Lade Einstellungen
@@ -59,8 +59,7 @@ public class SM64EditorLevelManager : ILevelManager
{ {
AreaOnFly = true; AreaOnFly = true;
tArea = new SM64ELevelArea(); tArea = new SM64ELevelArea();
if (firstArea is null) firstArea ??= tArea;
firstArea = tArea;
tArea.AreaID = clStartArea.GetAreaID(c); tArea.AreaID = clStartArea.GetAreaID(c);
tArea.GeolayoutOffset = clStartArea.GetSegGeolayoutAddr(c); tArea.GeolayoutOffset = clStartArea.GetSegGeolayoutAddr(c);
tArea.Geolayout.Read(rommgr, Convert.ToInt32(tArea.GeolayoutOffset)); tArea.Geolayout.Read(rommgr, Convert.ToInt32(tArea.GeolayoutOffset));

View File

@@ -167,10 +167,8 @@ public class Levelscript : LevelscriptCommandCollection
} }
else else
{ {
if (fs is null) fs ??= new FileStream(rommgr.RomFile, FileMode.Open, FileAccess.Read);
fs = new FileStream(rommgr.RomFile, FileMode.Open, FileAccess.Read); brfs ??= new BinaryReader(fs);
if (brfs is null)
brfs = new BinaryReader(fs);
s = fs; s = fs;
br = brfs; br = brfs;
} }

View File

@@ -113,10 +113,12 @@ namespace SM64Lib.Levels.Script
public static Vector3 GetPosition(LevelscriptCommand Command) public static Vector3 GetPosition(LevelscriptCommand Command)
{ {
Command.Position = 4; Command.Position = 4;
var Pos = new Vector3(); var Pos = new Vector3
Pos.X = Command.ReadInt16(); {
Pos.Y = Command.ReadInt16(); X = Command.ReadInt16(),
Pos.Z = Command.ReadInt16(); Y = Command.ReadInt16(),
Z = Command.ReadInt16()
};
Command.Position = 0; Command.Position = 0;
return Pos; return Pos;
} }
@@ -133,10 +135,12 @@ namespace SM64Lib.Levels.Script
public static Vector3 GetRotation(LevelscriptCommand Command) public static Vector3 GetRotation(LevelscriptCommand Command)
{ {
Command.Position = 10; Command.Position = 10;
var Rot = new Vector3(); var Rot = new Vector3
Rot.X = Command.ReadInt16(); {
Rot.Y = Command.ReadInt16(); X = Command.ReadInt16(),
Rot.Z = Command.ReadInt16(); Y = Command.ReadInt16(),
Z = Command.ReadInt16()
};
Command.Position = 0; Command.Position = 0;
return Rot; return Rot;
} }
@@ -153,11 +157,13 @@ namespace SM64Lib.Levels.Script
public static ObjBParams GetParams(LevelscriptCommand Command) public static ObjBParams GetParams(LevelscriptCommand Command)
{ {
Command.Position = 16; Command.Position = 16;
var Params = new ObjBParams(); var Params = new ObjBParams
Params.BParam1 = Command.ReadByte(); {
Params.BParam2 = Command.ReadByte(); BParam1 = Command.ReadByte(),
Params.BParam3 = Command.ReadByte(); BParam2 = Command.ReadByte(),
Params.BParam4 = Command.ReadByte(); BParam3 = Command.ReadByte(),
BParam4 = Command.ReadByte()
};
Command.Position = 0; Command.Position = 0;
return Params; return Params;
} }
@@ -498,10 +504,12 @@ namespace SM64Lib.Levels.Script
public static Vector3 GetPosition(LevelscriptCommand Command) public static Vector3 GetPosition(LevelscriptCommand Command)
{ {
Command.Position = 6; Command.Position = 6;
var value = new Vector3(); var value = new Vector3
value.X = Command.ReadInt16(); {
value.Y = Command.ReadInt16(); X = Command.ReadInt16(),
value.Z = Command.ReadInt16(); Y = Command.ReadInt16(),
Z = Command.ReadInt16()
};
Command.Position = 0; Command.Position = 0;
return value; return value;
} }

View File

@@ -37,8 +37,10 @@ public class SpecialBoxList : List<SpecialBox>
while (SwapInts.SwapUInt16(br.ReadUInt16()) != 0xFFFF) while (SwapInts.SwapUInt16(br.ReadUInt16()) != 0xFFFF)
{ {
s.Position += 0x2; s.Position += 0x2;
var tbox = new SpecialBox(); var tbox = new SpecialBox
tbox.Type = Type; {
Type = Type
};
int lastpos = (int)(s.Position + 0x4); int lastpos = (int)(s.Position + 0x4);
s.Position = SwapInts.SwapInt32(br.ReadInt32()) - 0x19000000 + Levelscriptstart; s.Position = SwapInts.SwapInt32(br.ReadInt32()) - 0x19000000 + Levelscriptstart;

View File

@@ -4,8 +4,8 @@ namespace SM64Lib.Model.Collision;
public class ColMesh public class ColMesh
{ {
public VertexList Vertices { get; set; } = new VertexList(); public VertexList Vertices { get; set; } = [];
public TriangleList Triangles { get; set; } = new TriangleList(); public TriangleList Triangles { get; set; } = [];
public ColMesh[] SplitMesh() public ColMesh[] SplitMesh()
{ {
@@ -21,8 +21,10 @@ public class ColMesh
var curVertCopies = new Dictionary<Vertex, Vertex>(); var curVertCopies = new Dictionary<Vertex, Vertex>();
foreach (Triangle t in mesh.Triangles) foreach (Triangle t in mesh.Triangles)
{ {
var newTri = new Triangle(); var newTri = new Triangle
newTri.CollisionType = t.CollisionType; {
CollisionType = t.CollisionType
};
for (int i = 0, loopTo = t.ColParams.Length - 1; i <= loopTo; i++) for (int i = 0, loopTo = t.ColParams.Length - 1; i <= loopTo; i++)
newTri.ColParams[i] = t.ColParams[i]; newTri.ColParams[i] = t.ColParams[i];
for (int i = 0, loopTo1 = t.Vertices.Length - 1; i <= loopTo1; i++) for (int i = 0, loopTo1 = t.Vertices.Length - 1; i <= loopTo1; i++)
@@ -34,10 +36,12 @@ public class ColMesh
} }
else else
{ {
var newVert = new Vertex(); var newVert = new Vertex
newVert.X = v.X; {
newVert.Y = v.Y; X = v.X,
newVert.Z = v.Z; Y = v.Y,
Z = v.Z
};
curMesh.Vertices.Add(newVert); curMesh.Vertices.Add(newVert);
curVertCopies.Add(v, newVert); curVertCopies.Add(v, newVert);
newTri.Vertices[i] = newVert; newTri.Vertices[i] = newVert;

View File

@@ -17,7 +17,7 @@ public class CollisionMap : IToObject3D
private int _Length = 0; private int _Length = 0;
public ColMesh Mesh { get; set; } = new ColMesh(); public ColMesh Mesh { get; set; } = new ColMesh();
public List<BoxData> SpecialBoxes { get; set; } = new List<BoxData>(); public List<BoxData> SpecialBoxes { get; set; } = [];
public void FromRom(string FileName, int RomOffset, CollisionBasicConfig config) public void FromRom(string FileName, int RomOffset, CollisionBasicConfig config)
{ {
@@ -171,8 +171,10 @@ public class CollisionMap : IToObject3D
var cs = colSettings.GetEntry(dicMatNames[f.Material]); var cs = colSettings.GetEntry(dicMatNames[f.Material]);
if (!cs.IsNonSolid) if (!cs.IsNonSolid)
{ {
var t = new Triangle(); var t = new Triangle
t.CollisionType = cs.CollisionType; {
CollisionType = cs.CollisionType
};
t.ColParams[0] = cs.CollisionParam1; t.ColParams[0] = cs.CollisionParam1;
t.ColParams[1] = cs.CollisionParam2; t.ColParams[1] = cs.CollisionParam2;
for (int i = 0, loopTo = Math.Min(f.Points.Count - 1, 2); i <= loopTo; i++) for (int i = 0, loopTo = Math.Min(f.Points.Count - 1, 2); i <= loopTo; i++)
@@ -185,10 +187,12 @@ public class CollisionMap : IToObject3D
} }
else else
{ {
v = new Vertex(); v = new Vertex
v.X = General.KeepInInt16Range(General.Round(curVert.X * ObjSettings.Scaling)); {
v.Y = General.KeepInInt16Range(General.Round(curVert.Y * ObjSettings.Scaling)); X = General.KeepInInt16Range(General.Round(curVert.X * ObjSettings.Scaling)),
v.Z = General.KeepInInt16Range(General.Round(curVert.Z * ObjSettings.Scaling)); Y = General.KeepInInt16Range(General.Round(curVert.Y * ObjSettings.Scaling)),
Z = General.KeepInInt16Range(General.Round(curVert.Z * ObjSettings.Scaling))
};
Mesh.Vertices.Add(v); Mesh.Vertices.Add(v);
dicVertices.Add(curVert, v); dicVertices.Add(curVert, v);
} }

View File

@@ -8,7 +8,7 @@ namespace SM64Lib.Model.Collision;
public class CollisionSettings public class CollisionSettings
{ {
public List<Entry> Entries { get; private set; } = new List<Entry>(); public List<Entry> Entries { get; private set; } = [];
public async Task Load(string fileName) public async Task Load(string fileName)
{ {
@@ -48,8 +48,10 @@ public class CollisionSettings
} }
} }
var ne = new Entry(); var ne = new Entry
ne.MaterialName = matName; {
MaterialName = matName
};
Entries.Add(ne); Entries.Add(ne);
return ne; return ne;
} }

View File

@@ -80,13 +80,13 @@ public class Fast3DParser
case CommandTypes.ClearGeometryMode: case CommandTypes.ClearGeometryMode:
{ {
curGeometryMode = curGeometryMode & ~F3D_CLEARGEOMETRYMODE.GetGeometryMode(cmd); curGeometryMode &= ~F3D_CLEARGEOMETRYMODE.GetGeometryMode(cmd);
break; break;
} }
case CommandTypes.SetGeometryMode: case CommandTypes.SetGeometryMode:
{ {
curGeometryMode = curGeometryMode | F3D_CLEARGEOMETRYMODE.GetGeometryMode(cmd); curGeometryMode |= F3D_CLEARGEOMETRYMODE.GetGeometryMode(cmd);
break; break;
} }
@@ -362,10 +362,12 @@ public class Fast3DParser
{ {
try try
{ {
var mat = new Material(); var mat = new Material
mat.Wrap = new System.Numerics.Vector2(curTexWrapT, curTexWrapS); {
mat.Scale = curTexScale; Wrap = new System.Numerics.Vector2(curTexWrapT, curTexWrapS),
mat.Color = curColor; Scale = curTexScale,
Color = curColor
};
var seg = GetSegBank(rommgr, curTexSegAddr, AreaID); var seg = GetSegBank(rommgr, curTexSegAddr, AreaID);
if (seg is null) if (seg is null)
return; return;

View File

@@ -53,9 +53,9 @@ public class ConvertResult
public States State { get; set; } = States.Successfully; public States State { get; set; } = States.Successfully;
public uint PtrStart { get; set; } = 0; public uint PtrStart { get; set; } = 0;
public uint PtrVertex { get; set; } = 0; public uint PtrVertex { get; set; } = 0;
public List<SM64Lib.Geolayout.Geopointer> PtrGeometry { get; private set; } = new List<SM64Lib.Geolayout.Geopointer>(); public List<SM64Lib.Geolayout.Geopointer> PtrGeometry { get; private set; } = [];
public List<SM64Lib.Levels.ScrolTex.ManagedScrollingTexture> ScrollingCommands { get; private set; } = new List<SM64Lib.Levels.ScrolTex.ManagedScrollingTexture>(); public List<SM64Lib.Levels.ScrolTex.ManagedScrollingTexture> ScrollingCommands { get; private set; } = [];
public Dictionary<short, string> ScrollingNames { get; private set; } = new Dictionary<short, string>(); public Dictionary<short, string> ScrollingNames { get; private set; } = [];
public MemoryStream Data { get; private set; } = new MemoryStream(); public MemoryStream Data { get; private set; } = new MemoryStream();
public enum States public enum States
@@ -205,7 +205,7 @@ public class Fast3DWriter
public sbyte[] indexList = new sbyte[2049]; public sbyte[] indexList = new sbyte[2049];
public List<FinalVertexData> FinalVertexData { get; private set; } = new List<FinalVertexData>(); public List<FinalVertexData> FinalVertexData { get; private set; } = [];
public short VertexDataCount public short VertexDataCount
{ {
@@ -264,7 +264,7 @@ public class Fast3DWriter
} }
public int StartIndex { get; set; } = 0; public int StartIndex { get; set; } = 0;
public List<FvGroup> FinalVertexGroups { get; private set; } = new List<FvGroup>(); public List<FvGroup> FinalVertexGroups { get; private set; } = [];
public bool EnableVertexColors public bool EnableVertexColors
{ {
@@ -344,17 +344,17 @@ public class Fast3DWriter
} }
} }
private List<Vertex> verts = new List<Vertex>(); private List<Vertex> verts = [];
private List<Normal> norms = new List<Normal>(); private List<Normal> norms = [];
private List<VertexColor> vertexColors = new List<VertexColor>(); private List<VertexColor> vertexColors = [];
private List<TexCord> uvs = new List<TexCord>(); private List<TexCord> uvs = [];
private List<Material> materials = new List<Material>(); private List<Material> materials = [];
private List<Pilz.S3DFileParser.Material> ignoreFacesWithMaterial = new List<Pilz.S3DFileParser.Material>(); private List<Pilz.S3DFileParser.Material> ignoreFacesWithMaterial = [];
private Dictionary<Pilz.S3DFileParser.Material, Material> materialBindings = new Dictionary<Pilz.S3DFileParser.Material, Material>(); private Dictionary<Pilz.S3DFileParser.Material, Material> materialBindings = [];
private List<VertexGroupList> vertexGroups = new List<VertexGroupList>(); private List<VertexGroupList> vertexGroups = [];
private List<FinalVertexData> finalVertData = new List<FinalVertexData>(); private List<FinalVertexData> finalVertData = [];
private List<TextureEntry> textureBank = new List<TextureEntry>(); private List<TextureEntry> textureBank = [];
private List<ScrollTex> scrollTexts = new List<ScrollTex>(); private List<ScrollTex> scrollTexts = [];
private Material currentMaterial; private Material currentMaterial;
private int currentFace = 0; private int currentFace = 0;
private const byte GEOLAYER_SOLID = 1; private const byte GEOLAYER_SOLID = 1;
@@ -365,7 +365,7 @@ public class Fast3DWriter
private byte[] defaultColor = new byte[24]; private byte[] defaultColor = new byte[24];
private ConvertSettings settings = null; private ConvertSettings settings = null;
private SM64Lib.Data.BinaryData impdata = null; private SM64Lib.Data.BinaryData impdata = null;
private ConvertResult conRes = new ConvertResult(); private ConvertResult conRes = new();
private readonly byte[] ColtypesWithParams = new byte[] { 14, 44, 36, 37, 39, 45 }; private readonly byte[] ColtypesWithParams = new byte[] { 14, 44, 36, 37, 39, 45 };
private uint CurSegAddress private uint CurSegAddress
@@ -506,8 +506,8 @@ public class Fast3DWriter
private void processMaterialColorAlpha(float alpha, Material mat) private void processMaterialColorAlpha(float alpha, Material mat)
{ {
mat.Color = mat.Color & 0xFFFFFF00U; mat.Color &= 0xFFFFFF00U;
mat.Color = mat.Color | Convert.ToByte(Convert.ToInt64(0xFF * alpha) & 0xFF); mat.Color |= Convert.ToByte(Convert.ToInt64(0xFF * alpha) & 0xFF);
if (alpha < 1.0F) if (alpha < 1.0F)
{ {
mat.Type = MaterialType.ColorTransparent; mat.Type = MaterialType.ColorTransparent;
@@ -672,15 +672,12 @@ public class Fast3DWriter
} }
// Create & Add texture entry // Create & Add texture entry
if (entry is null) entry ??= new TextureEntry()
{ {
entry = new TextureEntry() Width = mat.TexWidth,
{ Height = mat.TexHeight,
Width = mat.TexWidth, OriginalImage = img
Height = mat.TexHeight, };
OriginalImage = img
};
}
// Load Texture from File // Load Texture from File
var bmp = new Bitmap(img); var bmp = new Bitmap(img);
@@ -2104,7 +2101,7 @@ public class Fast3DWriter
var dlsToCreate = new List<DisplaylistProps>(); var dlsToCreate = new List<DisplaylistProps>();
var dicMatDlIDs = new Dictionary<Material, int>(); var dicMatDlIDs = new Dictionary<Material, int>();
ProcessObject3DModel(model); ProcessObject3DModel(model);
conRes.PtrStart = Convert.ToUInt32((long)CurSegAddress | impdata.Position); conRes.PtrStart = Convert.ToUInt32(CurSegAddress | impdata.Position);
importStart = Convert.ToUInt32(impdata.Position); importStart = Convert.ToUInt32(impdata.Position);
// Write default color // Write default color
@@ -2136,7 +2133,7 @@ public class Fast3DWriter
removeDuplicateVertices(settings.ReduceVertLevel); removeDuplicateVertices(settings.ReduceVertLevel);
// Write vertices // Write vertices
conRes.PtrVertex = Convert.ToUInt32((long)CurSegAddress | impdata.Position); conRes.PtrVertex = Convert.ToUInt32(CurSegAddress | impdata.Position);
startVerts = Convert.ToUInt32(impdata.Position); startVerts = Convert.ToUInt32(impdata.Position);
foreach (VertexGroupList mp in vertexGroups) foreach (VertexGroupList mp in vertexGroups)
{ {
@@ -2163,8 +2160,7 @@ public class Fast3DWriter
dlProp = dl; dlProp = dl;
} }
if (dlProp is null) dlProp ??= new DisplaylistProps(newLayerID);
dlProp = new DisplaylistProps(newLayerID);
dlProp.Layer = layerID; dlProp.Layer = layerID;
if (!dlsToCreate.Contains(dlProp)) if (!dlsToCreate.Contains(dlProp))

View File

@@ -8,7 +8,7 @@ namespace SM64Lib.Model.Fast3D.DisplayLists;
public class DisplayList public class DisplayList
{ {
public DisplayListScript Script { get; private set; } = new DisplayListScript(); public DisplayListScript Script { get; private set; } = [];
public Geopointer GeoPointer { get; set; } = null; public Geopointer GeoPointer { get; set; } = null;
// Public Property Data As Stream = Nothing // Public Property Data As Stream = Nothing

View File

@@ -13,8 +13,8 @@ namespace SM64Lib.Model.Fast3D;
public class TextureFormatSettings public class TextureFormatSettings
{ {
public List<Entry> Entries { get; private set; } = new List<Entry>(); public List<Entry> Entries { get; private set; } = [];
public List<DisplaylistProps> CustomDisplayLists { get; private set; } = new List<DisplaylistProps>(); public List<DisplaylistProps> CustomDisplayLists { get; private set; } = [];
public async Task Load(string fileName) public async Task Load(string fileName)
{ {
@@ -69,8 +69,10 @@ public class TextureFormatSettings
} }
} }
var ne = new Entry(); var ne = new Entry
ne.MaterialName = matName; {
MaterialName = matName
};
Entries.Add(ne); Entries.Add(ne);
return ne; return ne;
} }

View File

@@ -97,10 +97,12 @@ public static class TextureManager
break; break;
case TextureConverters.NConvert: case TextureConverters.NConvert:
{ {
var arguments = new List<string>(); var arguments = new List<string>
arguments.Add("-out png"); {
arguments.Add($"-resize {result.Width} {result.Height}"); "-out png",
arguments.Add("-overwrite"); $"-resize {result.Width} {result.Height}",
"-overwrite"
};
var sourceFilePath = Path.GetTempFileName(); var sourceFilePath = Path.GetTempFileName();
using (var fs = new FileStream(sourceFilePath, FileMode.Create, FileAccess.ReadWrite)) using (var fs = new FileStream(sourceFilePath, FileMode.Create, FileAccess.ReadWrite))

View File

@@ -127,7 +127,7 @@ public class ObjectModel
public class SaveResult public class SaveResult
{ {
public int CollisionPointer { get; set; } = -1; public int CollisionPointer { get; set; } = -1;
public List<Geopointer> GeoPointers { get; set; } = new List<Geopointer>(); public List<Geopointer> GeoPointers { get; set; } = [];
public long Length { get; set; } = 0; public long Length { get; set; } = 0;
} }
} }

View File

@@ -6,7 +6,7 @@ namespace SM64Lib.Music;
public class InstrumentSetList public class InstrumentSetList
{ {
public List<byte> Sets { get; private set; } = new List<byte>(); public List<byte> Sets { get; private set; } = [];
public int Count public int Count
{ {

View File

@@ -5,7 +5,7 @@ namespace SM64Lib.Music;
public class MusicSequence public class MusicSequence
{ {
private InstrumentSetList _InstrumentSets = new InstrumentSetList(); private InstrumentSetList _InstrumentSets = new();
public byte[] BinaryData { get; set; } = Array.Empty<byte>(); public byte[] BinaryData { get; set; } = Array.Empty<byte>();
public string Name { get; set; } = ""; public string Name { get; set; } = "";

View File

@@ -15,7 +15,7 @@ public class ItemBoxContentManager
public ItemBoxContentManager() public ItemBoxContentManager()
{ {
ContentTable = new ItemBoxContentTable(); ContentTable = [];
} }
public ItemBoxContentManager(ItemBoxContentTable table) public ItemBoxContentManager(ItemBoxContentTable table)
@@ -66,7 +66,7 @@ public class ItemBoxContentManager
rom.Position = 0x7C8E2; rom.Position = 0x7C8E2;
address = Convert.ToUInt32(rom.ReadUInt16()) << 16; address = Convert.ToUInt32(rom.ReadUInt16()) << 16;
rom.Position = 0x7C8E6; rom.Position = 0x7C8E6;
address = address | rom.ReadUInt16(); address |= rom.ReadUInt16();
return address; return address;
} }
@@ -230,8 +230,10 @@ public class ItemBoxContentManager
foreach (string line in File.ReadAllLines(fileName)) foreach (string line in File.ReadAllLines(fileName))
{ {
var vals = line.Split(','); var vals = line.Split(',');
var entry = new ItemBoxContentEntry(); var entry = new ItemBoxContentEntry
entry.ID = Convert.ToByte(vals[0].Trim(), 16); {
ID = Convert.ToByte(vals[0].Trim(), 16)
};
vals[1] = vals[1].Trim(); vals[1] = vals[1].Trim();
entry.BParam1 = Convert.ToByte(vals[1].Substring(0, 2), 16); entry.BParam1 = Convert.ToByte(vals[1].Substring(0, 2), 16);
entry.BParam2 = Convert.ToByte(vals[1].Substring(2, 2), 16); entry.BParam2 = Convert.ToByte(vals[1].Substring(2, 2), 16);

View File

@@ -14,10 +14,10 @@ namespace SM64Lib.Objects.ModelBanks;
public class CustomModelBank public class CustomModelBank
{ {
public ObjectModelConfig Config { get; private set; } = new ObjectModelConfig(); public ObjectModelConfig Config { get; private set; } = new ObjectModelConfig();
public List<CustomModel> Models { get; private set; } = new List<CustomModel>(); public List<CustomModel> Models { get; private set; } = [];
public SegmentedBank CurSeg { get; private set; } = null; public SegmentedBank CurSeg { get; private set; } = null;
public bool NeedToSave { get; set; } = false; public bool NeedToSave { get; set; } = false;
public Levelscript Levelscript { get; private set; } = new Levelscript(); public Levelscript Levelscript { get; private set; } = [];
[JsonIgnore] [JsonIgnore]
public int Length public int Length
@@ -159,15 +159,16 @@ public class CustomModelBank
// Parse Levelscript & Load Models // Parse Levelscript & Load Models
for (int i = 0, loopTo = Levelscript.Count - 1; i <= loopTo; i++) for (int i = 0, loopTo = Levelscript.Count - 1; i <= loopTo; i++)
{ {
LevelscriptCommand cmd = (LevelscriptCommand)Levelscript[i]; LevelscriptCommand cmd = Levelscript[i];
switch (cmd.CommandType) switch (cmd.CommandType)
{ {
case LevelscriptCommandTypes.LoadPolygonWithGeo: case LevelscriptCommandTypes.LoadPolygonWithGeo:
var obj = new CustomModel() { Config = config.GetCustomObjectConfig(i) }; var obj = new CustomModel
{
// Load Model ID & Geolayout Offset Config = config.GetCustomObjectConfig(i), // Load Model ID & Geolayout Offset
obj.ModelID = clLoadPolygonWithGeo.GetModelID(cmd); ModelID = clLoadPolygonWithGeo.GetModelID(cmd)
};
int geoAddr = clLoadPolygonWithGeo.GetSegAddress(cmd); int geoAddr = clLoadPolygonWithGeo.GetSegAddress(cmd);
obj.GeolayoutBankOffset = geoAddr & 0xFFFFFF; obj.GeolayoutBankOffset = geoAddr & 0xFFFFFF;

View File

@@ -11,7 +11,7 @@ namespace SM64Lib.Objects.ObjectBanks;
public class CustomObjectCollection public class CustomObjectCollection
{ {
public List<CustomObject> CustomObjects { get; } = new List<CustomObject>(); public List<CustomObject> CustomObjects { get; } = [];
public void TakeoverProperties(RomManager rommgr) public void TakeoverProperties(RomManager rommgr)
{ {

View File

@@ -12,13 +12,13 @@ namespace SM64Lib.Objects.ObjectBanks;
public class CustomObjectExportData public class CustomObjectExportData
{ {
public List<CustomObject> CustomObjects { get; set; } = new List<CustomObject>(); public List<CustomObject> CustomObjects { get; set; } = [];
[JsonConverter(typeof(ComplexDictionarJsonConverter<CustomModelConfig, CustomModel>))] [JsonConverter(typeof(ComplexDictionarJsonConverter<CustomModelConfig, CustomModel>))]
public Dictionary<CustomModelConfig, CustomModel> CustomModels { get; set; } = new Dictionary<CustomModelConfig, CustomModel>(); public Dictionary<CustomModelConfig, CustomModel> CustomModels { get; set; } = [];
[JsonConverter(typeof(ComplexDictionarJsonConverter<BehaviorConfig, Behavior>))] [JsonConverter(typeof(ComplexDictionarJsonConverter<BehaviorConfig, Behavior>))]
public Dictionary<BehaviorConfig, Behavior> Behaviors { get; set; } = new Dictionary<BehaviorConfig, Behavior>(); public Dictionary<BehaviorConfig, Behavior> Behaviors { get; set; } = [];
[JsonConverter(typeof(ComplexDictionarJsonConverter<CustomAsmAreaConfig, CustomAsmArea>))] [JsonConverter(typeof(ComplexDictionarJsonConverter<CustomAsmAreaConfig, CustomAsmArea>))]
public Dictionary<CustomAsmAreaConfig, CustomAsmArea> CustomAsmAreas { get; set; } = new Dictionary<CustomAsmAreaConfig, CustomAsmArea>(); public Dictionary<CustomAsmAreaConfig, CustomAsmArea> CustomAsmAreas { get; set; } = [];
public EmbeddedFilesContainer EmbeddedFiles { get; set; } public EmbeddedFilesContainer EmbeddedFiles { get; set; }
public PatchScript Script { get; set; } public PatchScript Script { get; set; }
} }

View File

@@ -10,13 +10,13 @@ namespace SM64Lib.Objects.ObjectBanks;
public class CustomObjectImport : CustomObjectExport public class CustomObjectImport : CustomObjectExport
{ {
[JsonIgnore] [JsonIgnore]
public Dictionary<CustomModelConfig, CustomModelBank> DestModelBanks { get; } = new Dictionary<CustomModelConfig, CustomModelBank>(); public Dictionary<CustomModelConfig, CustomModelBank> DestModelBanks { get; } = [];
[JsonIgnore] [JsonIgnore]
public CustomAsmBank DestCustomAsmBank { get; set; } = null; public CustomAsmBank DestCustomAsmBank { get; set; } = null;
[JsonIgnore] [JsonIgnore]
public BehaviorBank DestBehaviorBank { get; set; } = null; public BehaviorBank DestBehaviorBank { get; set; } = null;
[JsonIgnore] [JsonIgnore]
public List<CustomObject> IgnoreCustomObjects { get; } = new List<CustomObject>(); public List<CustomObject> IgnoreCustomObjects { get; } = [];
[JsonIgnore] [JsonIgnore]
public bool OverwriteExistingObjecs { get; set; } = true; public bool OverwriteExistingObjecs { get; set; } = true;
} }

View File

@@ -5,8 +5,8 @@ namespace SM64Lib.Objects.ObjectBanks.Data;
public class ObjectBankData public class ObjectBankData
{ {
public string Name { get; set; } public string Name { get; set; }
public List<string> Objects { get; private set; } = new List<string>(); public List<string> Objects { get; private set; } = [];
public List<ObjectBankDataCommand> Commands { get; private set; } = new List<ObjectBankDataCommand>(); public List<ObjectBankDataCommand> Commands { get; private set; } = [];
public ObjectBankData() public ObjectBankData()
{ {

View File

@@ -23,7 +23,7 @@ public class PatchProfile
/// A list with scripts. /// A list with scripts.
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public List<PatchScript> Scripts { get; set; } = new List<PatchScript>(); public List<PatchScript> Scripts { get; set; } = [];
/// <summary> /// <summary>
/// The version of this profile. /// The version of this profile.
/// </summary> /// </summary>

View File

@@ -10,6 +10,6 @@ public class PatchScriptExecuteParams
public RomManager RomManager { get; set; } public RomManager RomManager { get; set; }
public EmbeddedFilesContainer EmbeddedFiles { get; set; } public EmbeddedFilesContainer EmbeddedFiles { get; set; }
public string ProfilePath { get; set; } public string ProfilePath { get; set; }
public Dictionary<string, object> OtherParameters { get; set; } = new(); public Dictionary<string, object> OtherParameters { get; set; } = [];
public IWin32Window WindowOwner { get; set; } public IWin32Window WindowOwner { get; set; }
} }

View File

@@ -121,8 +121,10 @@ public class PatchingManager
public PatchScript XElementToScript(XElement element) public PatchScript XElementToScript(XElement element)
{ {
var script = new PatchScript(); var script = new PatchScript
script.Script = element.Value; {
Script = element.Value
};
foreach (XAttribute attr in element.Attributes()) foreach (XAttribute attr in element.Attributes())
{ {
var switchExpr = attr.Name; var switchExpr = attr.Name;
@@ -238,7 +240,7 @@ public class PatchingManager
CompilationOptions compilationOptions; CompilationOptions compilationOptions;
Compilation compilation = null; Compilation compilation = null;
SyntaxTree syntaxTree = null; SyntaxTree syntaxTree = null;
Dictionary<string, MetadataReference> references = new(); Dictionary<string, MetadataReference> references = [];
EmitResult resultEmit = null; EmitResult resultEmit = null;
Assembly resultAssembly = null; Assembly resultAssembly = null;

View File

@@ -64,22 +64,22 @@ public class RomManager
// F i e l d s // F i e l d s
private readonly Dictionary<byte, SegmentedBank> segBankList = new Dictionary<byte, SegmentedBank>(); private readonly Dictionary<byte, SegmentedBank> segBankList = [];
private readonly Dictionary<byte, Dictionary<byte, SegmentedBank>> areaSegBankList = new Dictionary<byte, Dictionary<byte, SegmentedBank>>(); private readonly Dictionary<byte, Dictionary<byte, SegmentedBank>> areaSegBankList = [];
private Dictionary<string, RomVersion> dicUpdatePatches = new Dictionary<string, RomVersion>(); private Dictionary<string, RomVersion> dicUpdatePatches = [];
private RomVersion myProgramVersion = new RomVersion(); private RomVersion myProgramVersion = new();
private readonly List<ushort> levelIDsToReset = new List<ushort>(); private readonly List<ushort> levelIDsToReset = [];
private readonly List<Text.TextGroup> myTextGroups = new List<Text.TextGroup>(); private readonly List<Text.TextGroup> myTextGroups = [];
private string myGameName = null; private string myGameName = null;
private bool programVersion_loadedVersion = false; private bool programVersion_loadedVersion = false;
// P r o p e r t i e s // P r o p e r t i e s
public LevelInfoDataTabelList LevelInfoData { get; private set; } = new LevelInfoDataTabelList(); public LevelInfoDataTabelList LevelInfoData { get; private set; } = [];
public LevelList Levels { get; private set; } = new LevelList(); public LevelList Levels { get; private set; } = [];
public string RomFile { get; set; } = string.Empty; public string RomFile { get; set; } = string.Empty;
public bool IsSM64EditorMode { get; private set; } = false; public bool IsSM64EditorMode { get; private set; } = false;
public MusicList MusicList { get; private set; } = new MusicList(); public MusicList MusicList { get; private set; } = [];
public CustomModelBank GlobalModelBank { get; private set; } = new CustomModelBank(); public CustomModelBank GlobalModelBank { get; private set; } = new CustomModelBank();
public CustomAsmBank GlobalCustomAsmBank { get; private set; } = null; public CustomAsmBank GlobalCustomAsmBank { get; private set; } = null;
public BehaviorBank GlobalBehaviorBank { get; private set; } = null; public BehaviorBank GlobalBehaviorBank { get; private set; } = null;
@@ -347,8 +347,10 @@ public class RomManager
{ {
if (myGameName is null) if (myGameName is null)
{ {
var fs = new BinaryRom(this, FileAccess.Read); var fs = new BinaryRom(this, FileAccess.Read)
fs.Position = 0x20; {
Position = 0x20
};
myGameName = Encoding.ASCII.GetString(fs.Read(0x14)).Trim(); myGameName = Encoding.ASCII.GetString(fs.Read(0x14)).Trim();
fs.Close(); fs.Close();
} }
@@ -358,8 +360,10 @@ public class RomManager
set set
{ {
var fs = new BinaryRom(this, FileAccess.Write); var fs = new BinaryRom(this, FileAccess.Write)
fs.Position = 0x20; {
Position = 0x20
};
foreach (byte b in Encoding.ASCII.GetBytes(value)) foreach (byte b in Encoding.ASCII.GetBytes(value))
fs.Write(b); fs.Write(b);
while (fs.Position < 0x34) while (fs.Position < 0x34)
@@ -381,12 +385,14 @@ public class RomManager
public RomSpaceInfo GetRomSpaceInfo() public RomSpaceInfo GetRomSpaceInfo()
{ {
var info = new RomSpaceInfo(); var info = new RomSpaceInfo
info.MaxAvailableSpace = 0x4000000 - 0x1210000; {
info.UsedLevelsSpace = Levels.Length; MaxAvailableSpace = 0x4000000 - 0x1210000,
info.UsedMusicSpace = MusicList.Length; UsedLevelsSpace = Levels.Length,
info.UsedGlobalBehaviorSpace = GlobalBehaviorBank.Length; UsedMusicSpace = MusicList.Length,
info.UsedGlobalModelsSpace = GlobalModelBank is object ? GlobalModelBank.Length : 0; UsedGlobalBehaviorSpace = GlobalBehaviorBank.Length,
UsedGlobalModelsSpace = GlobalModelBank is object ? GlobalModelBank.Length : 0
};
return info; return info;
} }
@@ -539,8 +545,10 @@ public class RomManager
private void WriteVersion(RomVersion newVersion) private void WriteVersion(RomVersion newVersion)
{ {
myProgramVersion = newVersion; myProgramVersion = newVersion;
var fs = new BinaryRom(this, FileAccess.ReadWrite); var fs = new BinaryRom(this, FileAccess.ReadWrite)
fs.Position = 0x1201FF8; {
Position = 0x1201FF8
};
fs.Write(newVersion.DevelopmentStage << 24 | newVersion.DevelopmentBuild); fs.Write(newVersion.DevelopmentStage << 24 | newVersion.DevelopmentBuild);
fs.WriteByte(Convert.ToByte(newVersion.Version.Major)); fs.WriteByte(Convert.ToByte(newVersion.Version.Major));
fs.WriteByte(Convert.ToByte(newVersion.Version.Minor)); fs.WriteByte(Convert.ToByte(newVersion.Version.Minor));
@@ -551,8 +559,10 @@ public class RomManager
private RomVersion LoadVersion() private RomVersion LoadVersion()
{ {
var fs = new BinaryRom(this, FileAccess.Read); var fs = new BinaryRom(this, FileAccess.Read)
fs.Position = 0x1201FF8; {
Position = 0x1201FF8
};
int devInfo = fs.ReadInt32(); int devInfo = fs.ReadInt32();
byte major = fs.ReadByte(); byte major = fs.ReadByte();
byte minor = fs.ReadByte(); byte minor = fs.ReadByte();
@@ -655,7 +665,7 @@ public class RomManager
table.NeedToSave = false; table.NeedToSave = false;
if (prof is Text.Profiles.TextTableGroupInfo) if (prof is Text.Profiles.TextTableGroupInfo)
{ {
needUpdateChecksum = needUpdateChecksum | ((Text.Profiles.TextTableGroupInfo)prof).Segmented.BankAddress == 0x80245000U; needUpdateChecksum |= ((Text.Profiles.TextTableGroupInfo)prof).Segmented.BankAddress == 0x80245000U;
} }
else if (prof is Text.Profiles.TextArrayGroupInfo) else if (prof is Text.Profiles.TextArrayGroupInfo)
{ {
@@ -716,23 +726,23 @@ public class RomManager
try try
{ {
#endif #endif
switch (segID) switch (segID)
{ {
case 0x19: case 0x19:
if (IsSM64EditorMode) if (IsSM64EditorMode)
lvl = new SM64ELevel(ldi.ID, ldi.Index, this); lvl = new SM64ELevel(ldi.ID, ldi.Index, this);
else else
lvl = new RMLevel(RomConfig.GetLevelConfig(ldi.ID), this); lvl = new RMLevel(RomConfig.GetLevelConfig(ldi.ID), this);
LevelManager.LoadLevel(lvl, this, ldi.ID, offset); LevelManager.LoadLevel(lvl, this, ldi.ID, offset);
lvl.LastRomOffset = curLvlSeg.RomStart; // Original Level lvl.LastRomOffset = curLvlSeg.RomStart; // Original Level
break; break;
default: default:
lvl = null; lvl = null;
// Dim mgr As New OriginalLevelManager // Dim mgr As New OriginalLevelManager
// lvl = New OriginalLevel // lvl = New OriginalLevel
// mgr.LoadLevel(lvl, Me, ldi.ID, offset) // mgr.LoadLevel(lvl, Me, ldi.ID, offset)
break; break;
} }
#if !DEBUG #if !DEBUG
} }
catch (Exception) catch (Exception)
@@ -788,13 +798,16 @@ public class RomManager
/// </summary> /// </summary>
public void LoadGlobalModelBank() public void LoadGlobalModelBank()
{ {
var fs = new BinaryRom(this, FileAccess.Read); var fs = new BinaryRom(this, FileAccess.Read)
{
// Read Bank Addres & Length from Rom // Read Bank Addres & Length from Rom
fs.Position = 0x120FFF0; Position = 0x120FFF0
var seg = new SegmentedBank(0x7); };
seg.RomStart = fs.ReadInt32(); var seg = new SegmentedBank(0x7)
seg.RomEnd = fs.ReadInt32(); {
RomStart = fs.ReadInt32(),
RomEnd = fs.ReadInt32()
};
if (seg.RomStart != 0x1010101 && seg.RomStart > -1) if (seg.RomStart != 0x1010101 && seg.RomStart > -1)
{ {
// Set Segmented Bank // Set Segmented Bank
@@ -1010,8 +1023,10 @@ public class RomManager
} }
} }
var br = new BinaryRom(this, FileAccess.Read); var br = new BinaryRom(this, FileAccess.Read)
br.Position = 0x1200000; {
Position = 0x1200000
};
long tCheckData = br.ReadInt64(); long tCheckData = br.ReadInt64();
br.Close(); br.Close();
IsSM64EditorMode = new[] { 0x800800001900001C, 0x800800000E0000C4 }.Contains((ulong)tCheckData); IsSM64EditorMode = new[] { 0x800800001900001C, 0x800800000E0000C4 }.Contains((ulong)tCheckData);
@@ -1179,7 +1194,7 @@ public class RomManager
} }
else else
{ {
sbl = new Dictionary<byte, SegmentedBank>(); sbl = [];
areaSegBankList.Add((byte)AreaID, sbl); areaSegBankList.Add((byte)AreaID, sbl);
} }
} }

View File

@@ -4,7 +4,7 @@ namespace SM64Lib;
public static class RomManagerInstances public static class RomManagerInstances
{ {
private static readonly List<RomManager> romManagers = new List<RomManager>(); private static readonly List<RomManager> romManagers = [];
public static IEnumerable<RomManager> CurrentInstances public static IEnumerable<RomManager> CurrentInstances
{ {

View File

@@ -44,8 +44,8 @@
<DefineConstants>TRACE;RelMono</DefineConstants> <DefineConstants>TRACE;RelMono</DefineConstants>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.9.2" /> <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.10.0" />
<PackageReference Include="Microsoft.CodeAnalysis.VisualBasic" Version="4.9.2" /> <PackageReference Include="Microsoft.CodeAnalysis.VisualBasic" Version="4.10.0" />
<PackageReference Include="Microsoft.VisualBasic" Version="10.3.0" /> <PackageReference Include="Microsoft.VisualBasic" Version="10.3.0" />
<PackageReference Include="Pilz.Cryptography" Version="2.0.1" /> <PackageReference Include="Pilz.Cryptography" Version="2.0.1" />
<PackageReference Include="Pilz.IO" Version="2.0.0" /> <PackageReference Include="Pilz.IO" Version="2.0.0" />

View File

@@ -4,5 +4,5 @@ namespace SM64Lib.Text.Profiles;
public class TextArrayGroupInfo : TextGroupInfo public class TextArrayGroupInfo : TextGroupInfo
{ {
public List<TextArrayItemInfo> Texts { get; set; } = new List<TextArrayItemInfo>(); public List<TextArrayItemInfo> Texts { get; set; } = [];
} }

View File

@@ -9,8 +9,8 @@ namespace SM64Lib.Text.Profiles;
public class TextProfileInfo public class TextProfileInfo
{ {
public string Name { get; set; } public string Name { get; set; }
public List<TextTableGroupInfo> TextTableGroups { get; set; } = new List<TextTableGroupInfo>(); public List<TextTableGroupInfo> TextTableGroups { get; set; } = [];
public List<TextArrayGroupInfo> TextArrayGroups { get; set; } = new List<TextArrayGroupInfo>(); public List<TextArrayGroupInfo> TextArrayGroups { get; set; } = [];
public TextGroupInfo GetGroup(string name) public TextGroupInfo GetGroup(string name)
{ {

View File

@@ -15,7 +15,7 @@ public class TextTableGroupInfo : TextGroupInfo
public TextTableDialogDataInfo DialogData { get; set; } = new TextTableDialogDataInfo(); public TextTableDialogDataInfo DialogData { get; set; } = new TextTableDialogDataInfo();
[JsonIgnore] [JsonIgnore]
[Browsable(false)] [Browsable(false)]
public List<string> ItemDescriptionsList { get; set; } = new List<string>(); public List<string> ItemDescriptionsList { get; set; } = [];
[Editor(typeof(MultilineStringEditor), typeof(UITypeEditor))] [Editor(typeof(MultilineStringEditor), typeof(UITypeEditor))]
public string ItemDescriptions public string ItemDescriptions

View File

@@ -183,8 +183,10 @@ public class Trajectories : List<Trajectory>
data.Position = addr - (int)addrToSubstract + 0x1200000; data.Position = addr - (int)addrToSubstract + 0x1200000;
for (int i = 1, loopTo = count; i <= loopTo; i++) for (int i = 1, loopTo = count; i <= loopTo; i++)
{ {
var trajectory = new Trajectory(); var trajectory = new Trajectory
trajectory.Name = name; {
Name = name
};
trajectory.Read(data, (uint)(data.Position)); trajectory.Read(data, (uint)(data.Position));
Add(trajectory); Add(trajectory);
} }
@@ -212,14 +214,14 @@ public class Trajectories : List<Trajectory>
data.Position = 0xCCA6E; data.Position = 0xCCA6E;
addr = data.ReadUInt16() << 16; addr = data.ReadUInt16() << 16;
data.Position = 0xCCA76; data.Position = 0xCCA76;
addr = addr | data.ReadUInt16(); addr |= data.ReadUInt16();
AddTrajectory(data, addr, TrajectoryName.RacingPenguin); AddTrajectory(data, addr, TrajectoryName.RacingPenguin);
// Snowman's Bottom // Snowman's Bottom
data.Position = 0xABC9E; data.Position = 0xABC9E;
addr = data.ReadUInt16() << 16; addr = data.ReadUInt16() << 16;
data.Position = 0xABCA6; data.Position = 0xABCA6;
addr = addr | data.ReadUInt16(); addr |= data.ReadUInt16();
AddTrajectory(data, addr, TrajectoryName.SnowmansBottom); AddTrajectory(data, addr, TrajectoryName.SnowmansBottom);
// Platform on Tracks Behavior (B.Param 2 = 0 - 8) // Platform on Tracks Behavior (B.Param 2 = 0 - 8)
@@ -235,42 +237,42 @@ public class Trajectories : List<Trajectory>
addr = data.ReadUInt16() << 16; addr = data.ReadUInt16() << 16;
data.Position = 0xA9ABC + 2; data.Position = 0xA9ABC + 2;
var val3 = data.ReadUInt16(); var val3 = data.ReadUInt16();
addr = addr | val3; addr |= val3;
AddTrajectory(data, addr, TrajectoryName.MetalBallsGenerators_BParam2_00); AddTrajectory(data, addr, TrajectoryName.MetalBallsGenerators_BParam2_00);
// Metal Balls Generators - B.Param 2 = 01 // Metal Balls Generators - B.Param 2 = 01
data.Position = 0xA9AD4 + 2; data.Position = 0xA9AD4 + 2;
addr = data.ReadUInt16() << 16; addr = data.ReadUInt16() << 16;
data.Position = 0xA9ADC + 2; data.Position = 0xA9ADC + 2;
addr = addr | data.ReadUInt16(); addr |= data.ReadUInt16();
AddTrajectory(data, addr, TrajectoryName.MetalBallsGenerators_BParam2_01); AddTrajectory(data, addr, TrajectoryName.MetalBallsGenerators_BParam2_01);
// Metal Balls Generators - B.Param 2 = 02 // Metal Balls Generators - B.Param 2 = 02
data.Position = 0xA9AF4 + 2; data.Position = 0xA9AF4 + 2;
addr = data.ReadUInt16() << 16; addr = data.ReadUInt16() << 16;
data.Position = 0xA9AFC + 2; data.Position = 0xA9AFC + 2;
addr = addr | data.ReadUInt16(); addr |= data.ReadUInt16();
AddTrajectory(data, addr, TrajectoryName.MetalBallsGenerators_BParam2_02); AddTrajectory(data, addr, TrajectoryName.MetalBallsGenerators_BParam2_02);
// Mini-Metal Ball Generator - B.Param 2 = 03 // Mini-Metal Ball Generator - B.Param 2 = 03
data.Position = 0xA9B1C + 2; data.Position = 0xA9B1C + 2;
addr = data.ReadUInt16() << 16; addr = data.ReadUInt16() << 16;
data.Position += 2; data.Position += 2;
addr = addr | data.ReadUInt16(); addr |= data.ReadUInt16();
AddTrajectory(data, addr, TrajectoryName.MiniMetalBallGenerator_BParam2_03); AddTrajectory(data, addr, TrajectoryName.MiniMetalBallGenerator_BParam2_03);
// Mini-Metal Ball Generator - B.Param 2 = 04 // Mini-Metal Ball Generator - B.Param 2 = 04
data.Position = 0xA9B1C + 2; data.Position = 0xA9B1C + 2;
addr = data.ReadUInt16() << 16; addr = data.ReadUInt16() << 16;
data.Position += 2; data.Position += 2;
addr = addr | data.ReadUInt16(); addr |= data.ReadUInt16();
AddTrajectory(data, addr, TrajectoryName.MiniMetalBallGenerator_BParam2_04); AddTrajectory(data, addr, TrajectoryName.MiniMetalBallGenerator_BParam2_04);
// Mips the Rabbit // Mips the Rabbit
data.Position = 0xB3816; data.Position = 0xB3816;
addr = data.ReadUInt16() << 16; addr = data.ReadUInt16() << 16;
data.Position += 6; data.Position += 6;
addr = addr | data.ReadUInt16(); addr |= data.ReadUInt16();
data.Position = 0xB371E; data.Position = 0xB371E;
ushort numOfPaths = data.ReadUInt16(); ushort numOfPaths = data.ReadUInt16();
AddTrajectory(data, addr, TrajectoryName.MipsTheRabbit, numOfPaths); AddTrajectory(data, addr, TrajectoryName.MipsTheRabbit, numOfPaths);

View File

@@ -7,7 +7,7 @@ namespace SM64Lib.Trajectorys;
public class Trajectory public class Trajectory
{ {
public List<Vector3> Points { get; private set; } = new List<Vector3>(); public List<Vector3> Points { get; private set; } = [];
public bool NeedToSave { get; set; } = false; public bool NeedToSave { get; set; } = false;
public TrajectoryName Name { get; set; } = TrajectoryName.None; public TrajectoryName Name { get; set; } = TrajectoryName.None;
@@ -46,10 +46,12 @@ public class Trajectory
if ((ulong)data.ReadInt64() != 0xFFFFFFFFFFFFFFFF) if ((ulong)data.ReadInt64() != 0xFFFFFFFFFFFFFFFF)
{ {
data.Position -= 6; data.Position -= 6;
var point = new Vector3(); var point = new Vector3
point.X = data.ReadInt16(); {
point.Y = data.ReadInt16(); X = data.ReadInt16(),
point.Z = data.ReadInt16(); Y = data.ReadInt16(),
Z = data.ReadInt16()
};
Points.Add(point); Points.Add(point);
} }
else else