Skip to content

Commit 479ef02

Browse files
committed
line endings
1 parent bfd5e77 commit 479ef02

3 files changed

Lines changed: 112 additions & 112 deletions

File tree

FF1Lib/ItemLists.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.Linq;
44
namespace FF1Lib
@@ -78,10 +78,10 @@ public static class ItemLists
7878
.Where(x => x >= Item.Gold10 && x <= Item.Gold65000)
7979
.ToList();
8080

81-
public static readonly IReadOnlyCollection<Item> AllMagicItem =
82-
new List<Item> {
83-
Item.WhiteShirt, Item.BlackShirt, Item.HealHelm, Item.ZeusGauntlets,
84-
Item.PowerGauntlets, Item.LightAxe, Item.HealRod, Item.MageRod,
81+
public static readonly IReadOnlyCollection<Item> AllMagicItem =
82+
new List<Item> {
83+
Item.WhiteShirt, Item.BlackShirt, Item.HealHelm, Item.ZeusGauntlets,
84+
Item.PowerGauntlets, Item.LightAxe, Item.HealRod, Item.MageRod,
8585
Item.Defense, Item.WizardRod, Item.ThorHammer, Item.BaneSword
8686
};
8787

FF1Lib/ItemMagic.cs

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
66
using RomUtilities;
7-
using System.Diagnostics;
8-
9-
namespace FF1Lib
10-
{
11-
public partial class FF1Rom : NesRom
12-
{
13-
public const int GearTextOffset = 0x2B9BD;
14-
public const int GearTextSize = 8;
15-
private const int MagicBitOffset = 0x3;
16-
private int WeaponStart = (byte)ItemLists.AllWeapons.ElementAt(0);
7+
using System.Diagnostics;
8+
9+
namespace FF1Lib
10+
{
11+
public partial class FF1Rom : NesRom
12+
{
13+
public const int GearTextOffset = 0x2B9BD;
14+
public const int GearTextSize = 8;
15+
private const int MagicBitOffset = 0x3;
16+
private int WeaponStart = (byte)ItemLists.AllWeapons.ElementAt(0);
1717
private int ArmourStart = (byte)ItemLists.AllArmor.ElementAt(0);
18-
19-
private List<String> SpellNames = new List<String> { // must be 7 characters long each, add spaces if needed, can rename items with each spell by changing this
20-
"CURE ", "HARM ", "FOG ", "RUSE ", "FIRE ", "SLEP ", "LOCK ", "LIT ", "LAMP ", "MUTE ", "ALIT ",
21-
"INVS ", "ICE ", "DARK ", "TMPR ", "SLOW ", "CUR2 ", "HRM2 ", "AFIR ", "HEAL ", "FIR2 ", "HOLD ",
22-
"LIT2 ", "LOK2 ", "PURE ", "FEAR ", "AICE ", "AMUT ", "SLP2 ", "FAST ", "CONF ", "ICE2 ", "CUR3 ",
23-
"LIFE ", "HRM3 ", "HEL2 ", "FIR3 ", "BANE ", "WARP ", "SLO2 ", "SOFT ", "EXIT ", "FOG2 ", "INV2 ",
24-
"LIT3 ", "RUB ", "QAKE ", "STUN ", "CUR4 ", "HRM4 ", "ARUB ", "HEL3 ", "ICE3 ", "BRAK ", "SABR ",
18+
19+
private List<String> SpellNames = new List<String> { // must be 7 characters long each, add spaces if needed, can rename items with each spell by changing this
20+
"CURE ", "HARM ", "FOG ", "RUSE ", "FIRE ", "SLEP ", "LOCK ", "LIT ", "LAMP ", "MUTE ", "ALIT ",
21+
"INVS ", "ICE ", "DARK ", "TMPR ", "SLOW ", "CUR2 ", "HRM2 ", "AFIR ", "HEAL ", "FIR2 ", "HOLD ",
22+
"LIT2 ", "LOK2 ", "PURE ", "FEAR ", "AICE ", "AMUT ", "SLP2 ", "FAST ", "CONF ", "ICE2 ", "CUR3 ",
23+
"LIFE ", "HRM3 ", "HEL2 ", "FIR3 ", "BANE ", "WARP ", "SLO2 ", "SOFT ", "EXIT ", "FOG2 ", "INV2 ",
24+
"LIT3 ", "RUB ", "QAKE ", "STUN ", "CUR4 ", "HRM4 ", "ARUB ", "HEL3 ", "ICE3 ", "BRAK ", "SABR ",
2525
"BLND ", "LIF2 ", "FADE ", "WALL ", "XFER ", "NUKE ", "STOP ", "ZAP ", "XXXX "};
2626

2727
// Remove all out of battle only spells
28-
private readonly List<byte> SpellsToRemove = new List<byte> {38, 40, 41, 33, 56 }; // Warp, Soft, Exit, Life, Life 2
28+
private readonly List<byte> SpellsToRemove = new List<byte> {38, 40, 41, 33, 56 }; // Warp, Soft, Exit, Life, Life 2
2929

30-
private void WriteItemSpellData(MagicSpell Spell, Item item)
30+
private void WriteItemSpellData(MagicSpell Spell, Item item)
3131
{
3232
// Set the spell an item casts
33-
var output = Spell.Data.ToHex().Remove(2);
34-
var offset = WeaponOffset + 0x8 * Math.Min((byte)item - WeaponStart,ArmourStart - WeaponStart) + 0x4 * Math.Max(0, (byte)item - ArmourStart) + MagicBitOffset;
33+
var output = Spell.Data.ToHex().Remove(2);
34+
var offset = WeaponOffset + 0x8 * Math.Min((byte)item - WeaponStart,ArmourStart - WeaponStart) + 0x4 * Math.Max(0, (byte)item - ArmourStart) + MagicBitOffset;
3535
Put(offset, Blob.FromHex(output));
3636

3737
// if the item is the Defense, overwrite the last character in the name, otherwise, keep the icon there.
3838
output = Spell.Name.ToHex().Remove(12) + (item == Item.Defense ? "FF" : "");
3939
offset = GearTextOffset + ((byte)item > (byte)Item.Ribbon ? 1 : 0) + GearTextSize * ((byte)item - WeaponStart);
40-
Put(offset, Blob.FromHex(output));
41-
}
40+
Put(offset, Blob.FromHex(output));
41+
}
4242

4343
public void CastableItemTargeting()
4444
{
@@ -73,28 +73,28 @@ public void CastableItemTargeting()
7373
PutInBank(0x1F, 0xC265, CreateLongJumpTableEntry(0x0F, 0x8AD0));
7474
PutInBank(0x0F, 0x8AD0, Blob.FromHex("85808681C0FFD008A9D68580A9968581A91060"));
7575
}
76-
77-
public void ShuffleItemMagic(MT19337 rng)
78-
{
76+
77+
public void ShuffleItemMagic(MT19337 rng)
78+
{
7979
CastableItemTargeting(); // make items able to target a single enemy or party member
8080

81-
// Reusing MagicSpell from Magic.cs
82-
List<byte> SpellIndex = new List<byte>();
83-
var Spells = SpellNames.Select((text, i) => new MagicSpell // creat a list of all spells
84-
{
85-
Data = Blob.FromInts(new int[1] { i+1 }), // spells are 1 based
86-
Index = (byte)i,
87-
Name = FF1Text.TextToBytes(text),
88-
}).ToList();
89-
81+
// Reusing MagicSpell from Magic.cs
82+
List<byte> SpellIndex = new List<byte>();
83+
var Spells = SpellNames.Select((text, i) => new MagicSpell // creat a list of all spells
84+
{
85+
Data = Blob.FromInts(new int[1] { i+1 }), // spells are 1 based
86+
Index = (byte)i,
87+
Name = FF1Text.TextToBytes(text),
88+
}).ToList();
89+
9090
Spells.RemoveAll(spell => SpellsToRemove.Contains(spell.Index)); // Remove the spells specified in SpellsToRemove
9191
Spells.Shuffle(rng); // Shuffle all spells remaining, then assign to each item that can cast a spell
9292

9393
foreach (var item in Spells.Zip(ItemLists.AllMagicItem, (s, i) => new { Spell = s, Item = i }))
9494
{
9595
WriteItemSpellData(item.Spell, item.Item);
96-
}
96+
}
9797

98-
}
99-
}
100-
}
98+
}
99+
}
100+
}

FF1Lib/OverworldMap.cs

Lines changed: 63 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.Diagnostics;
4-
using System.Linq;
5-
using RomUtilities;
6-
7-
namespace FF1Lib
3+
using System.Diagnostics;
4+
using System.Linq;
5+
using RomUtilities;
6+
7+
namespace FF1Lib
88
{
99
public struct MapEdit
1010
{
1111
public byte X { get; set; }
1212
public byte Y { get; set; }
1313
public byte Tile { get; set; }
14-
}
15-
16-
public class OverworldMap
14+
}
15+
16+
public class OverworldMap
1717
{
1818
private readonly FF1Rom _rom;
1919
public OverworldMap(FF1Rom rom, IMapEditFlags flags)
@@ -92,7 +92,7 @@ public OverworldMap(FF1Rom rom, IMapEditFlags flags)
9292
public const byte ForestBottomRight = 0x25;
9393
public const byte ForestBottomLeft = 0x23;
9494
public const byte DockBottomMid = 0x78;
95-
public const byte DockRightMid = 0x1F;
95+
public const byte DockRightMid = 0x1F;
9696

9797
public static List<MapEdit> OnracDock =
9898
new List<MapEdit>
@@ -110,9 +110,9 @@ public OverworldMap(FF1Rom rom, IMapEditFlags flags)
110110
{
111111
new MapEdit{X = 208, Y = 90, Tile = DockBottomMid},
112112
new MapEdit{X = 209, Y = 90, Tile = DockBottomMid}
113-
};
114-
public static List<MapEdit> ConeriaToDwarves =
115-
new List<MapEdit>
113+
};
114+
public static List<MapEdit> ConeriaToDwarves =
115+
new List<MapEdit>
116116
{
117117
new MapEdit{X = 124, Y = 138, Tile = MountainBottomLeft},
118118
new MapEdit{X = 124, Y = 139, Tile = GrassTile},
@@ -151,38 +151,38 @@ public OverworldMap(FF1Rom rom, IMapEditFlags flags)
151151
new MapEdit{X = 102, Y = 162, Tile = MountainBottomMid},
152152
new MapEdit{X = 103, Y = 162, Tile = MountainBottomRight}
153153
};
154-
public List<List<MapEdit>> MapEditsToApply = new List<List<MapEdit>>();
155-
156-
const int bankStart = 0x4000;
157-
158-
public List<List<byte>> GetCompressedMapRows()
159-
{
160-
161-
var pointers = _rom.Get(bankStart, 512).ToUShorts().Select(x => x - bankStart);
162-
var mapRows = pointers.Select(x =>
163-
{
164-
var mapRow = _rom.Get(x, 256).ToBytes();
165-
var result = new List<byte>();
166-
var index = 0;
167-
while (index < 256 && mapRow[index] != 255)
168-
{
169-
result.Add(mapRow[index]);
170-
index++;
171-
}
172-
result.Add(mapRow[index]);
173-
return result;
154+
public List<List<MapEdit>> MapEditsToApply = new List<List<MapEdit>>();
155+
156+
const int bankStart = 0x4000;
157+
158+
public List<List<byte>> GetCompressedMapRows()
159+
{
160+
161+
var pointers = _rom.Get(bankStart, 512).ToUShorts().Select(x => x - bankStart);
162+
var mapRows = pointers.Select(x =>
163+
{
164+
var mapRow = _rom.Get(x, 256).ToBytes();
165+
var result = new List<byte>();
166+
var index = 0;
167+
while (index < 256 && mapRow[index] != 255)
168+
{
169+
result.Add(mapRow[index]);
170+
index++;
171+
}
172+
result.Add(mapRow[index]);
173+
return result;
174174
}).ToList();
175-
return mapRows;
176-
}
177-
175+
return mapRows;
176+
}
177+
178178
public List<List<byte>> DecompressMapRows(List<List<byte>> compressedRows)
179-
{
180-
var mapRows = new List<List<byte>>();
179+
{
180+
var mapRows = new List<List<byte>>();
181181
var run = 0;
182182
foreach (var compressedRow in compressedRows)
183183
{
184-
byte tile = 0;
185-
var row = new List<byte>();
184+
byte tile = 0;
185+
var row = new List<byte>();
186186
var tileIndex = 0;
187187
while (row.Count() < 256)
188188
{
@@ -213,10 +213,10 @@ public List<List<byte>> DecompressMapRows(List<List<byte>> compressedRows)
213213
tileIndex++;
214214
}
215215
mapRows.Add(row);
216-
}
217-
return mapRows;
218-
}
219-
216+
}
217+
return mapRows;
218+
}
219+
220220
public void DebugWriteDecompressedMap(List<List<byte>> decompressedRows)
221221
{
222222
foreach (var row in decompressedRows)
@@ -226,9 +226,9 @@ public void DebugWriteDecompressedMap(List<List<byte>> decompressedRows)
226226
Debug.Write($"{tile:X2}");
227227
}
228228
Debug.Write("\n");
229-
}
230-
}
231-
229+
}
230+
}
231+
232232
public void ApplyMapEdits()
233233
{
234234
var compresedMap = GetCompressedMapRows();
@@ -240,24 +240,24 @@ public void ApplyMapEdits()
240240
}
241241
var recompressedMap = CompressMapRows(editedMap);
242242
PutCompressedMapRows(recompressedMap);
243-
}
243+
}
244244

245245
public List<List<byte>> ApplyMapEdits(List<List<byte>> decompressedRows, List<MapEdit> mapEdits)
246-
{
246+
{
247247
foreach (var mapEdit in mapEdits)
248248
{
249249
decompressedRows[mapEdit.Y][mapEdit.X] = mapEdit.Tile;
250250
}
251-
return decompressedRows;
252-
}
251+
return decompressedRows;
252+
}
253253

254254
public List<List<byte>> CompressMapRows(List<List<byte>> decompressedRows)
255-
{
255+
{
256256
var outputMap = new List<List<byte>>();
257257
foreach (var row in decompressedRows)
258258
{
259-
var outputRow = new List<byte>();
260-
byte tile = 0;
259+
var outputRow = new List<byte>();
260+
byte tile = 0;
261261
byte runCount = 1;
262262
if (row.Distinct().Count() == 1)
263263
{
@@ -284,24 +284,24 @@ public List<List<byte>> CompressMapRows(List<List<byte>> decompressedRows)
284284
outputRow.Add(0xFF);
285285
outputMap.Add(outputRow);
286286
}
287-
return outputMap;
288-
}
289-
287+
return outputMap;
288+
}
289+
290290
public void PutCompressedMapRows(List<List<byte>> compressedRows)
291-
{
292-
var pointerBase = 0x4000;
293-
var outputBase = 0x4200;
291+
{
292+
var pointerBase = 0x4000;
293+
var outputBase = 0x4200;
294294
var outputOffset = 0;
295295
for (int i = 0; i < compressedRows.Count; i++)
296296
{
297297
var outputRow = compressedRows[i];
298298
_rom.Put(pointerBase + i * 2, Blob.FromUShorts(new ushort[] { (ushort)(outputBase + pointerBase + outputOffset) }));
299-
_rom.Put(outputBase + outputOffset, outputRow.ToArray());
299+
_rom.Put(outputBase + outputOffset, outputRow.ToArray());
300300
outputOffset += outputRow.Count;
301301
}
302302

303303
if (outputOffset > 0x4000)
304304
throw new InvalidOperationException("Modified map was too large to recompress and fit into a single bank.");
305-
}
306-
}
307-
}
305+
}
306+
}
307+
}

0 commit comments

Comments
 (0)