mirror of
https://github.com/AdAstra-LD/DS-Pokemon-Rom-Editor.git
synced 2026-09-09 19:55:18 -05:00
Minor refactor + added missing Designer.cs
This commit is contained in:
@@ -229,17 +229,17 @@ namespace System.IO {
|
||||
return temp;
|
||||
}
|
||||
|
||||
public UInt16 ReadUInt16() {
|
||||
const int size = sizeof(UInt16);
|
||||
public ushort ReadUInt16() {
|
||||
const int size = sizeof(ushort);
|
||||
FillBuffer(size, size);
|
||||
return BitConverter.ToUInt16(buffer, 0);
|
||||
}
|
||||
|
||||
public UInt16[] ReadUInt16s(int count) {
|
||||
const int size = sizeof(UInt16);
|
||||
UInt16[] temp;
|
||||
public ushort[] ReadUInt16s(int count) {
|
||||
const int size = sizeof(ushort);
|
||||
ushort[] temp;
|
||||
|
||||
temp = new UInt16[count];
|
||||
temp = new ushort[count];
|
||||
FillBuffer(size * count, size);
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
|
||||
@@ -904,7 +904,7 @@ namespace LibNDSFormats.NSBMD
|
||||
/// </summary>
|
||||
private static void ParseNsbmdObject(EndianBinaryReader reader, NSBMDObject nsbmdObject, float modelscale)
|
||||
{
|
||||
UInt16 v = reader.ReadUInt16();
|
||||
ushort v = reader.ReadUInt16();
|
||||
Int16 divide = reader.ReadInt16();
|
||||
divide = (short)NSBMDGlRenderer.Sign(divide, 16);
|
||||
int unknown = v >> 12 & 0xf;
|
||||
|
||||
@@ -1046,7 +1046,7 @@ namespace LibNDSFormats.NSBMD {
|
||||
/// <summary>
|
||||
/// Convert texel.
|
||||
/// </summary>
|
||||
private bool convert_4x4texel(uint[] tex, int width, int height, UInt16[] data, RGBA[] pal, RGBA[] rgbaOut) {
|
||||
private bool convert_4x4texel(uint[] tex, int width, int height, ushort[] data, RGBA[] pal, RGBA[] rgbaOut) {
|
||||
int w = width / 4;
|
||||
int h = height / 4;
|
||||
|
||||
@@ -1055,9 +1055,9 @@ namespace LibNDSFormats.NSBMD {
|
||||
for (int x = 0; x < w; x++) {
|
||||
int index = y * w + x;
|
||||
UInt32 t = tex[index];
|
||||
UInt16 d = data[index];
|
||||
UInt16 addr = (ushort)(d & 0x3fff);
|
||||
UInt16 mode = (ushort)((d >> 14) & 3);
|
||||
ushort d = data[index];
|
||||
ushort addr = (ushort)(d & 0x3fff);
|
||||
ushort mode = (ushort)((d >> 14) & 3);
|
||||
|
||||
// traverse every texel in the 4x4 texels
|
||||
for (int r = 0; r < 4; r++)
|
||||
@@ -1125,9 +1125,9 @@ namespace LibNDSFormats.NSBMD {
|
||||
for (int i = 0; i < (tex.Length + 1) / 4; ++i)
|
||||
list1.Add(Utils.Read4BytesAsUInt32(tex, i * 4));
|
||||
|
||||
var list2 = new List<UInt16>();
|
||||
var list2 = new List<ushort>();
|
||||
for (int i = 0; i < (data.Length + 1) / 2; ++i)
|
||||
list2.Add(Utils.Read2BytesAsUInt16(data, i * 2));
|
||||
list2.Add(Utils.Read2BytesAsushort(data, i * 2));
|
||||
var b = convert_4x4texel(list1.ToArray(), width, height, list2.ToArray(), pal, rgbaOut);
|
||||
}
|
||||
|
||||
@@ -1229,13 +1229,13 @@ namespace LibNDSFormats.NSBMD {
|
||||
// Direct Color Texture
|
||||
case 7:
|
||||
for (int j = 0; j < pixelnum; j++) {
|
||||
//UInt16 p = (ushort)(mat.texdata[j * 2] + (mat.texdata[j * 2 + 1] << 8));
|
||||
//ushort p = (ushort)(mat.texdata[j * 2] + (mat.texdata[j * 2 + 1] << 8));
|
||||
//image[j].R = (byte)(((p >> 0) & 0x1f) << 3);
|
||||
//image[j].G = (byte)(((p >> 5) & 0x1f) << 3);
|
||||
//image[j].B = (byte)(((p >> 10) & 0x1f) << 3);
|
||||
//image[j].A = (byte)(((p & 0x8000) != 0) ? 0xff : 0);
|
||||
image[j] = RGBA.fromColor(Tinke.Convertir.BGR555(mat.texdata[j * 2], mat.texdata[j * 2 + 1]));
|
||||
UInt16 p = (ushort)(mat.texdata[j * 2] + (mat.texdata[j * 2 + 1] << 8));
|
||||
ushort p = (ushort)(mat.texdata[j * 2] + (mat.texdata[j * 2 + 1] << 8));
|
||||
image[j].A = (byte)(((p & 0x8000) != 0) ? 0xff : 0);
|
||||
}
|
||||
break;
|
||||
@@ -1425,13 +1425,13 @@ namespace LibNDSFormats.NSBMD {
|
||||
// Direct Color Texture
|
||||
case 7:
|
||||
for (int j = 0; j < pixelnum; j++) {
|
||||
//UInt16 p = (ushort)(mat.texdata[j * 2] + (mat.texdata[j * 2 + 1] << 8));
|
||||
//ushort p = (ushort)(mat.texdata[j * 2] + (mat.texdata[j * 2 + 1] << 8));
|
||||
//image[j].R = (byte)(((p >> 0) & 0x1f) << 3);
|
||||
//image[j].G = (byte)(((p >> 5) & 0x1f) << 3);
|
||||
//image[j].B = (byte)(((p >> 10) & 0x1f) << 3);
|
||||
//image[j].A = (byte)(((p & 0x8000) != 0) ? 0xff : 0);
|
||||
image[j] = RGBA.fromColor(Tinke.Convertir.BGR555(mat.texdata[j * 2], mat.texdata[j * 2 + 1]));
|
||||
UInt16 p = (ushort)(mat.texdata[j * 2] + (mat.texdata[j * 2 + 1] << 8));
|
||||
ushort p = (ushort)(mat.texdata[j * 2] + (mat.texdata[j * 2 + 1] << 8));
|
||||
image[j].A = (byte)(((p & 0x8000) != 0) ? 0xff : 0);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace NSMBe4
|
||||
Color[] pal = new Color[data.Length / 2];
|
||||
for (int i = 0; i < pal.Length; i++)
|
||||
{
|
||||
pal[i] = NSMBTileset.fromRGB15(ii.readUShort());
|
||||
pal[i] = NSMBTileset.fromRGB15(ii.ReadUInt16());
|
||||
}
|
||||
return pal;
|
||||
}
|
||||
|
||||
@@ -329,7 +329,7 @@ namespace LibNDSFormats.NSBTX
|
||||
stream.Seek(mat.paloffset, SeekOrigin.Begin);
|
||||
for (j = 0; j < palentry; j++)
|
||||
{
|
||||
UInt16 p = reader.ReadUInt16();
|
||||
ushort p = reader.ReadUInt16();
|
||||
rgbq[j].R = (byte)(((p >> 0) & 0x1f) << 3); // red
|
||||
rgbq[j].G = (byte)(((p >> 5) & 0x1f) << 3); // green
|
||||
rgbq[j].B = (byte)(((p >> 10) & 0x1f) << 3); // blue
|
||||
|
||||
@@ -116,7 +116,7 @@ namespace NSMBe4
|
||||
return pos;
|
||||
}
|
||||
|
||||
public ushort readUShort()
|
||||
public ushort ReadUInt16()
|
||||
{
|
||||
pos += 2;
|
||||
return (ushort)(array[pos - 2 + origin] | array[pos - 1 + origin] << 8);
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace NSMBe4
|
||||
for (uint y = 0; y < h / 4; y++)
|
||||
for (uint x = 0; x < w / 4; x++)
|
||||
{
|
||||
ushort palDat = f5data.readUShort();
|
||||
ushort palDat = f5data.ReadUInt16();
|
||||
ushort palOffs = (ushort)((palDat & 0x3FFF) * 2);
|
||||
ushort mode = (ushort)((palDat >> 14) & 3);
|
||||
|
||||
|
||||
@@ -798,7 +798,7 @@ namespace NSMBe4
|
||||
while (eObjIndexFile.available(4) && obj < Objects.Length)
|
||||
{
|
||||
Objects[obj] = new ObjectDef(this);
|
||||
int offset = eObjIndexFile.readUShort();
|
||||
int offset = eObjIndexFile.ReadUInt16();
|
||||
Objects[obj].width = eObjIndexFile.readByte();
|
||||
Objects[obj].height = eObjIndexFile.readByte();
|
||||
|
||||
|
||||
@@ -117,8 +117,8 @@ namespace NSMBe4.NSBMD
|
||||
bool hasFormat5 = false;
|
||||
for (int i = 0; i < textures.Length; i++)
|
||||
{
|
||||
int offset = 8 * str.readUShort();
|
||||
ushort param = str.readUShort();
|
||||
int offset = 8 * str.ReadUInt16();
|
||||
ushort param = str.ReadUInt16();
|
||||
int format = (param >> 10) & 7;
|
||||
|
||||
if (format == 5)
|
||||
@@ -171,8 +171,8 @@ namespace NSMBe4.NSBMD
|
||||
|
||||
for (int i = 0; i < palettes.Length; i++)
|
||||
{
|
||||
int offset = 8 * str.readUShort() + palDataOffset + blockStart;
|
||||
str.readUShort();
|
||||
int offset = 8 * str.ReadUInt16() + palDataOffset + blockStart;
|
||||
str.ReadUInt16();
|
||||
palettes[i] = new PaletteDef();
|
||||
palettes[i].offs = offset;
|
||||
}
|
||||
@@ -531,7 +531,7 @@ namespace NSMBe4.NSBMD
|
||||
}
|
||||
er.Close();
|
||||
}
|
||||
public bool convert_4x4texel(uint[] tex, int width, int height, UInt16[] data, Color[] pal, ImageTexeler.LockBitmap rgbaOut)
|
||||
public bool convert_4x4texel(uint[] tex, int width, int height, ushort[] data, Color[] pal, ImageTexeler.LockBitmap rgbaOut)
|
||||
{
|
||||
int w = width / 4;
|
||||
int h = height / 4;
|
||||
@@ -542,9 +542,9 @@ namespace NSMBe4.NSBMD
|
||||
{
|
||||
int index = y * w + x;
|
||||
UInt32 t = tex[index];
|
||||
UInt16 d = data[index];
|
||||
UInt16 addr = (ushort)(d & 0x3fff);
|
||||
UInt16 mode = (ushort)((d >> 14) & 3);
|
||||
ushort d = data[index];
|
||||
ushort addr = (ushort)(d & 0x3fff);
|
||||
ushort mode = (ushort)((d >> 14) & 3);
|
||||
|
||||
// traverse every texel in the 4x4 texels
|
||||
for (int r = 0; r < 4; r++)
|
||||
@@ -621,9 +621,9 @@ namespace NSMBe4.NSBMD
|
||||
for (int i = 0; i < (tex.Length + 1) / 4; ++i)
|
||||
list1.Add(LibNDSFormats.Utils.Read4BytesAsUInt32(tex, i * 4));
|
||||
|
||||
var list2 = new List<UInt16>();
|
||||
var list2 = new List<ushort>();
|
||||
for (int i = 0; i < (data.Length + 1) / 2; ++i)
|
||||
list2.Add(LibNDSFormats.Utils.Read2BytesAsUInt16(data, i * 2));
|
||||
list2.Add(LibNDSFormats.Utils.Read2BytesAsushort(data, i * 2));
|
||||
var b = convert_4x4texel(list1.ToArray(), width, height, list2.ToArray(), pal, rgbaOut);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,12 +42,12 @@ namespace LibNDSFormats {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read 2 Bytes as UInt16
|
||||
/// Read 2 Bytes as ushort
|
||||
/// </summary>
|
||||
/// <param name="bytes">Byte array.</param>
|
||||
/// <param name="s">Offset in array.</param>
|
||||
/// <returns>2 Bytes as UInt16.</returns>
|
||||
public static UInt16 Read2BytesAsUInt16(byte[] bytes, int offset) {
|
||||
/// <returns>2 Bytes as ushort.</returns>
|
||||
public static ushort Read2BytesAsushort(byte[] bytes, int offset) {
|
||||
int result = 0;
|
||||
for (int i = 0; i < 2; ++i)
|
||||
result |= bytes[offset + i] << (8 * (i));
|
||||
|
||||
@@ -59,8 +59,8 @@ namespace NarcAPI {
|
||||
bw.Write(0x0100FFFE); // Constant
|
||||
fileSizeOffset = (uint)bw.BaseStream.Position;
|
||||
bw.Write((UInt32)0x0);
|
||||
bw.Write((UInt16)16);
|
||||
bw.Write((UInt16)3);
|
||||
bw.Write((ushort)16);
|
||||
bw.Write((ushort)3);
|
||||
// Write FATB Section
|
||||
bw.Write(0x46415442); // "BTAF"
|
||||
bw.Write((UInt32)(0xC + Elements.Length * 8)); // FATB Size
|
||||
|
||||
8153
DS_Map/Properties/PokePics.Designer.cs
generated
Normal file
8153
DS_Map/Properties/PokePics.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
5
DS_Map/Properties/Resources.Designer.cs
generated
5
DS_Map/Properties/Resources.Designer.cs
generated
@@ -9,9 +9,8 @@
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace DSPRE.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Classe di risorse fortemente tipizzata per la ricerca di stringhe localizzate e così via.
|
||||
/// </summary>
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace DSPRE.ROMFiles {
|
||||
id = PokeDatabase.ScriptEditor.movementsDictIDName.First(x => x.Value.Equals(nameParts[0], StringComparison.InvariantCultureIgnoreCase)).Key;
|
||||
} catch (InvalidOperationException) {
|
||||
try {
|
||||
id = UInt16.Parse(nameParts[0], NumberStyles.HexNumber, CultureInfo.InvariantCulture);
|
||||
id = ushort.Parse(nameParts[0], NumberStyles.HexNumber, CultureInfo.InvariantCulture);
|
||||
} catch (FormatException) {
|
||||
string details;
|
||||
if (wholeLine.Contains('@') && wholeLine.Contains('#')) {
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace DSPRE.ROMFiles {
|
||||
} catch (InvalidOperationException) {
|
||||
|
||||
try {
|
||||
id = UInt16.Parse(nameParts[0], NumberStyles.HexNumber, CultureInfo.InvariantCulture);
|
||||
id = ushort.Parse(nameParts[0], NumberStyles.HexNumber, CultureInfo.InvariantCulture);
|
||||
} catch {
|
||||
string details;
|
||||
if (wholeLine.Contains('@') && wholeLine.Contains('#')) {
|
||||
@@ -161,7 +161,7 @@ namespace DSPRE.ROMFiles {
|
||||
} else if (nameParts[i + 1].Equals("Camera", StringComparison.InvariantCultureIgnoreCase)) {
|
||||
cmdParams.Add(BitConverter.GetBytes((ushort)241));
|
||||
} else {
|
||||
cmdParams.Add(BitConverter.GetBytes(UInt16.Parse(nameParts[i + 1].Substring(indexOfSpecialCharacter + 1), style)));
|
||||
cmdParams.Add(BitConverter.GetBytes(ushort.Parse(nameParts[i + 1].Substring(indexOfSpecialCharacter + 1), style)));
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
|
||||
@@ -279,8 +279,8 @@ namespace DSPRE.ROMFiles {
|
||||
private byte[] ToByteArray(List<string> msgSource) {
|
||||
MemoryStream newData = new MemoryStream();
|
||||
using (BinaryWriter writer = new BinaryWriter(newData)) {
|
||||
writer.Write((UInt16)msgSource.Count);
|
||||
writer.Write((UInt16)initialKey);
|
||||
writer.Write((ushort)msgSource.Count);
|
||||
writer.Write((ushort)initialKey);
|
||||
|
||||
int key = (initialKey * 0x2FD) & 0xFFFF;
|
||||
int key2 = 0;
|
||||
@@ -303,11 +303,11 @@ namespace DSPRE.ROMFiles {
|
||||
int[] currentString = EncodeString(msgSource[i], i, stringSize[i]);
|
||||
|
||||
for (int j = 0; j < stringSize[i] - 1; j++) {
|
||||
writer.Write((UInt16)(currentString[j] ^ key));
|
||||
writer.Write((ushort)(currentString[j] ^ key));
|
||||
key += 0x493D;
|
||||
key &= 0xFFFF;
|
||||
}
|
||||
writer.Write((UInt16)(0xFFFF ^ key));
|
||||
writer.Write((ushort)(0xFFFF ^ key));
|
||||
}
|
||||
}
|
||||
return newData.ToArray();
|
||||
|
||||
@@ -814,7 +814,7 @@ namespace DSPRE {
|
||||
System.Xml.Linq.XDocument xmldoc = System.Xml.Linq.XDocument.Load(new FileStream(of.FileName, FileMode.Open));
|
||||
|
||||
foreach (var node in xmldoc.Root.Elements("scriptcommand")) {
|
||||
ushort commandID = UInt16.Parse(node.Attribute("ID").Value, System.Globalization.NumberStyles.HexNumber);
|
||||
ushort commandID = ushort.Parse(node.Attribute("ID").Value, System.Globalization.NumberStyles.HexNumber);
|
||||
string targetROM = node.Element("ROM").Value;
|
||||
string targetLang = node.Element("lang").Value;
|
||||
string commandName = node.Element("name").Value;
|
||||
|
||||
Reference in New Issue
Block a user