Skip to content

Commit 5384e96

Browse files
committed
wip rng
1 parent a238f5f commit 5384e96

File tree

6 files changed

+30
-3
lines changed

6 files changed

+30
-3
lines changed

FF1Lib/FF1Lib.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
<ItemGroup>
5656
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
5757
<PackageReference Include="Patcher6502" Version="0.3.0" />
58-
<PackageReference Include="RomUtilities" Version="2.2.0" />
58+
<PackageReference Include="RomUtilities" Version="3.1.0" />
5959
</ItemGroup>
6060

6161
<ItemGroup>

FF1Lib/FF1Rom.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ public void Randomize(Blob seed, Flags flags, Preferences preferences)
106106
FixWarpBug(); // The warp bug must be fixed for magic level shuffle and spellcrafter
107107
SeparateUnrunnables();
108108
UpdateDialogs();
109+
MoveSmokeSpriteVariables();
109110

110111
flags = Flags.ConvertAllTriState(flags, rng);
111112

FF1Lib/Hacks.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,25 @@ public partial class FF1Rom : NesRom
4141
public const string BattleBoxUndrawFrames = "04"; // 2/3 normal (Must divide 12)
4242
public const string BattleBoxUndrawRows = "03";
4343

44+
public const int SmokeSpriteReplaceStart = 0x317E9;
45+
public const int SmokeSpriteReplaceEnd = 0x31A2C;
46+
47+
public void MoveSmokeSpriteVariables()
48+
{
49+
// This moves some temporary memory locations used to draw the smoke effect sprites
50+
// in battle to the same locations used to store attacker stats. These can overwrite
51+
// each other without issue, and it frees up some space for a few bytes of RNG state.
52+
var smokeSpriteCode = Get(SmokeSpriteReplaceStart, SmokeSpriteReplaceEnd - SmokeSpriteReplaceStart);
53+
54+
smokeSpriteCode.ReplaceInPlace(Blob.FromUShorts(new ushort[] { 0x68AF }), Blob.FromUShorts(new ushort[] { 0x686C }));
55+
smokeSpriteCode.ReplaceInPlace(Blob.FromUShorts(new ushort[] { 0x68B1 }), Blob.FromUShorts(new ushort[] { 0x686E }));
56+
smokeSpriteCode.ReplaceInPlace(Blob.FromUShorts(new ushort[] { 0x68B3 }), Blob.FromUShorts(new ushort[] { 0x6870 }));
57+
smokeSpriteCode.ReplaceInPlace(Blob.FromUShorts(new ushort[] { 0x68B4 }), Blob.FromUShorts(new ushort[] { 0x6871 }));
58+
smokeSpriteCode.ReplaceInPlace(Blob.FromUShorts(new ushort[] { 0x68B5 }), Blob.FromUShorts(new ushort[] { 0x6872 }));
59+
60+
Put(SmokeSpriteReplaceStart, smokeSpriteCode);
61+
}
62+
4463
// Required for npc quest item randomizing
4564
public void PermanentCaravan()
4665
{

FF1Lib/asm/LCG.asm

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
; Linear Congruential Generator (better random number generator)
2+
; https://en.wikipedia.org/wiki/Linear_congruential_generator
3+
; This is a simple but effective RNG with a much longer period than FF1's.
4+
5+
; A research paper on selecting good parameters for the multiplier:
6+
; https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.34.1024&rep=rep1&type=pdf
7+

FF1R/FF1R.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
</PropertyGroup>
1414

1515
<ItemGroup>
16-
<PackageReference Include="RomUtilities" Version="2.2.0" />
16+
<PackageReference Include="RomUtilities" Version="3.1.0" />
1717
</ItemGroup>
1818

1919
<ItemGroup>

FFR.Common/FFR.Common.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<ItemGroup>
44
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
5-
<PackageReference Include="RomUtilities" Version="2.2.0" />
5+
<PackageReference Include="RomUtilities" Version="3.1.0" />
66
</ItemGroup>
77

88
<ItemGroup>

0 commit comments

Comments
 (0)