Skip to content

Commit 3734a48

Browse files
authored
Merge pull request #180 from FiendsOfTheElements/dev
Merge dev to master (2.3.0)
2 parents c79602b + 82e6932 commit 3734a48

39 files changed

+1582
-473
lines changed

.circleci/config.yml

Lines changed: 117 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
defaults: &defaults
2+
working_directory: ~/ff1randomizer
3+
docker:
4+
- image: circleci/node:8
5+
16
version: 2
27
jobs:
38
build:
@@ -6,44 +11,134 @@ jobs:
611
- image: microsoft/aspnetcore-build:2.0
712
steps:
813
- checkout
9-
1014
- run:
11-
name: compile
15+
name: publish
1216
command: |
1317
cd FF1RandomizerOnline
1418
if [ "${CIRCLE_BRANCH}" == "master" ]; then
1519
dotnet publish -c Release
20+
git rev-parse HEAD > bin/Release/netcoreapp2.0/publish/version.txt
1621
else
1722
dotnet publish -c Debug
23+
git rev-parse HEAD > bin/Debug/netcoreapp2.0/publish/version.txt
1824
fi
25+
- persist_to_workspace:
26+
root: ~/ff1randomizer
27+
paths: FF1RandomizerOnline
1928

29+
dockerize_production:
30+
<<: *defaults
31+
steps:
2032
- setup_remote_docker
33+
- attach_workspace:
34+
at: ~/ff1randomizer
2135
- run:
22-
name: Install Docker client
36+
name: docker
2337
command: |
24-
set -x
25-
VER="17.03.0-ce"
26-
curl -L -o /tmp/docker-$VER.tgz https://download.docker.com/linux/static/stable/x86_64/docker-$VER.tgz
27-
tar -xz -C /tmp -f /tmp/docker-$VER.tgz
28-
mv /tmp/docker/* /usr/bin
38+
cd FF1RandomizerOnline && \
39+
docker login -u $DOCKER_USER -p $DOCKER_PASS && \
40+
docker build -t entroper/finalfantasyrandomizer:latest -f Dockerfile . && \
41+
docker push entroper/finalfantasyrandomizer:latest
42+
43+
dockerize_beta:
44+
<<: *defaults
45+
steps:
46+
- setup_remote_docker
47+
- attach_workspace:
48+
at: ~/ff1randomizer
2949
- run:
3050
name: docker
3151
command: |
3252
cd FF1RandomizerOnline && \
33-
if [ "${CIRCLE_BRANCH}" == "dev" ]; then
34-
docker login -u $DOCKER_USER -p $DOCKER_PASS && \
35-
docker build -t entroper/finalfantasyrandomizer:beta -f Dockerfile.beta . && \
36-
docker push entroper/finalfantasyrandomizer:beta
37-
elif [ "${CIRCLE_BRANCH}" == "master" ]; then
38-
docker login -u $DOCKER_USER -p $DOCKER_PASS && \
39-
docker build -t entroper/finalfantasyrandomizer:latest -f Dockerfile . && \
40-
docker push entroper/finalfantasyrandomizer:latest
41-
fi
53+
docker login -u $DOCKER_USER -p $DOCKER_PASS && \
54+
docker build -t entroper/finalfantasyrandomizer:beta -f Dockerfile.debug . && \
55+
docker push entroper/finalfantasyrandomizer:beta
56+
57+
dockerize_alpha:
58+
<<: *defaults
59+
steps:
60+
- setup_remote_docker
61+
- attach_workspace:
62+
at: ~/ff1randomizer
63+
- run:
64+
name: docker
65+
command: |
66+
cd FF1RandomizerOnline && \
67+
docker login -u $DOCKER_USER -p $DOCKER_PASS && \
68+
docker build -t entroper/finalfantasyrandomizer:alpha -f Dockerfile.debug . && \
69+
docker push entroper/finalfantasyrandomizer:alpha
70+
71+
deploy:
72+
<<: *defaults
73+
steps:
74+
- checkout
4275
- run:
4376
name: deploy
4477
command: |
45-
if [ "${CIRCLE_BRANCH}" == "dev" ] || [ "${CIRCLE_BRANCH}" == "master" ]; then
46-
mkdir -p ~/.ssh && \
47-
cp .ssh/known_hosts ~/.ssh/known_hosts && \
48-
ssh [email protected] "./deployff1r.sh $CIRCLE_BRANCH"
49-
fi
78+
mkdir -p ~/.ssh && \
79+
cp .ssh/known_hosts ~/.ssh/known_hosts && \
80+
ssh [email protected] "./deployff1r.sh master"
81+
82+
deploy_beta:
83+
<<: *defaults
84+
steps:
85+
- checkout
86+
- run:
87+
name: deploy
88+
command: |
89+
mkdir -p ~/.ssh && \
90+
cp .ssh/known_hosts ~/.ssh/known_hosts && \
91+
ssh [email protected] "./deployff1r.sh dev"
92+
93+
deploy_alpha:
94+
<<: *defaults
95+
steps:
96+
- checkout
97+
- run:
98+
name: deploy
99+
command: |
100+
mkdir -p ~/.ssh && \
101+
cp .ssh/known_hosts ~/.ssh/known_hosts && \
102+
ssh [email protected] "./deployff1r.sh alpha"
103+
104+
workflows:
105+
version: 2
106+
main:
107+
jobs:
108+
- build
109+
- dockerize_production:
110+
requires:
111+
- build
112+
filters:
113+
branches:
114+
only: master
115+
- dockerize_beta:
116+
requires:
117+
- build
118+
filters:
119+
branches:
120+
only: dev
121+
- dockerize_alpha:
122+
requires:
123+
- build
124+
filters:
125+
branches:
126+
only: alpha
127+
- deploy_production:
128+
requires:
129+
- dockerize_production
130+
filters:
131+
branches:
132+
only: master
133+
- deploy_beta:
134+
requires:
135+
- dockerize_beta
136+
filters:
137+
branches:
138+
only: dev
139+
- deploy_alpha:
140+
requires:
141+
- dockerize_alpha
142+
filters:
143+
branches:
144+
only: alpha

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ end_of_line = crlf
1313
indent_size = 2
1414
indent_style = space
1515

16-
[*.{js}]
16+
[*.{js,json}]
1717
indent_size = 4
1818
indent_style = tab
1919
end_of_line = lf

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,3 +237,7 @@ _Pvt_Extensions
237237

238238
# ROM files -- never check these in
239239
*.nes
240+
241+
# Archives
242+
*.zip
243+
*.tar.gz

FF1Lib/Enemies.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public partial class FF1Rom : NesRom
2323

2424
public void ShuffleEnemyFormations(MT19337 rng)
2525
{
26-
//intra-zone shuffle, does not change which formations are in zomes.
26+
// intra-zone shuffle, does not change which formations are in zomes.
2727
var oldFormations = Get(FormationFrequencyOffset, FormationFrequencySize * FormationFrequencyCount).Chunk(FormationFrequencySize);
2828
var newFormations = Get(FormationFrequencyOffset, FormationFrequencySize * FormationFrequencyCount).Chunk(FormationFrequencySize);
2929
Blob WarMech = new byte[]{ 0x56 };
@@ -38,7 +38,6 @@ public void ShuffleEnemyFormations(MT19337 rng)
3838
newFormations[i][2] = lowFormations[2][0];
3939
newFormations[i][3] = lowFormations[3][0];
4040

41-
4241
var shuffleFormations = newFormations[i].SubBlob(1, 6).Chunk(1); // get formations 2-8
4342
shuffleFormations.Shuffle(rng);
4443
if (shuffleFormations.Contains(WarMech)) //preserve WarMech's formation 7 status
@@ -51,6 +50,7 @@ public void ShuffleEnemyFormations(MT19337 rng)
5150
}
5251

5352
}
53+
5454
Put(FormationFrequencyOffset, newFormations.SelectMany(formation => formation.ToBytes()).ToArray());
5555
}
5656
public void ShuffleEnemyScripts(MT19337 rng, bool AllowUnsafePirates)

FF1Lib/EnemyFormations.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public enum FinalFormation
2222
private const int BossFormationCount = 13; // Lichx2, Karyx2, Krakenx2, Tiamatx2, Chaos, Vampire, Astos, Pirates, Garland
2323
private const int VanillaUnrunnableCount = 13; // 13 of the Vanilla normal formations are unrunnable.
2424
private const int ChaosFormationIndex = 123; // Index of Chaos battle that preceeds The End
25+
private const int WarMECHFormationIndex = 86;
2526

2627
// Formation Data Offsets ripped straight from Disch's variables.inc
2728
private const byte TypeOffset = 0x00; // battle type (high 4 bits)
@@ -63,6 +64,14 @@ public void ShuffleSurpriseBonus(MT19337 rng)
6364
Put(FormationsOffset, formations.SelectMany(formation => formation.ToBytes()).ToArray());
6465
}
6566

67+
public void MakeWarMECHUnrunnable()
68+
{
69+
// This needs to be called after ShuffleUnrunnable, otherwise it will shuffle away this unrunnability.
70+
Blob warMECHFormation = Get(FormationsOffset + FormationSize * WarMECHFormationIndex, FormationSize);
71+
warMECHFormation[UnrunnableOffset] |= 0x01;
72+
Put(FormationsOffset + FormationSize * WarMECHFormationIndex, warMECHFormation);
73+
}
74+
6675
public void TransformFinalFormation(FinalFormation formation)
6776
{
6877
Blob finalBattle = Get(FormationsOffset + ChaosFormationIndex * FormationSize, FormationSize);

FF1Lib/FF1Lib.csproj

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,15 @@
1717
<ItemGroup>
1818
<None Remove="presets\beginner.json" />
1919
<None Remove="presets\default.json" />
20+
<None Remove="presets\finals.json" />
2021
<None Remove="presets\full-npc.json" />
2122
<None Remove="presets\improved-vanilla.json" />
2223
<None Remove="presets\normal-npc.json" />
24+
<None Remove="presets\ro16.json" />
25+
<None Remove="presets\ro8.json" />
26+
<None Remove="presets\semifinals.json" />
2327
<None Remove="presets\tournament.json" />
28+
<None Remove="version.txt" />
2429
</ItemGroup>
2530

2631
<ItemGroup>
@@ -33,6 +38,9 @@
3338
<Content Include="presets\default.json">
3439
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
3540
</Content>
41+
<Content Include="presets\finals.json">
42+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
43+
</Content>
3644
<Content Include="presets\full-npc.json">
3745
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
3846
</Content>
@@ -42,9 +50,21 @@
4250
<Content Include="presets\normal-npc.json">
4351
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
4452
</Content>
53+
<Content Include="presets\ro16.json">
54+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
55+
</Content>
56+
<Content Include="presets\ro8.json">
57+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
58+
</Content>
59+
<Content Include="presets\semifinals.json">
60+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
61+
</Content>
4562
<Content Include="presets\tournament.json">
4663
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
4764
</Content>
65+
<Content Include="version.txt">
66+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
67+
</Content>
4868
</ItemGroup>
4969

5070
<ItemGroup>

FF1Lib/FF1Rom.cs

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66
using RomUtilities;
77
using System.Collections;
88
using System.IO;
9+
using System.Security.Cryptography;
910

1011
namespace FF1Lib
1112
{
1213
// ReSharper disable once InconsistentNaming
1314
public partial class FF1Rom : NesRom
1415
{
15-
public const string Version = "2.2.1";
16+
public const string Version = "2.3.0";
1617

1718
public const int RngOffset = 0x7F100;
1819
public const int RngSize = 256;
@@ -310,14 +311,22 @@ public void Randomize(Blob seed, Flags flags)
310311
}
311312

312313
var itemText = ReadText(ItemTextPointerOffset, ItemTextPointerBase, ItemTextPointerCount);
314+
// var dialogueText = ReadText(DialogueTextPointerOffset, DialogueTextPointerBase, DialogueTextPointerCount);
313315
FixVanillaRibbon(itemText);
314316
ExpGoldBoost(flags.ExpBonus, flags.ExpMultiplier);
315317
ScalePrices(flags.PriceScaleFactor, flags.ExpMultiplier, flags.VanillaStartingGold, itemText, rng);
316318

319+
320+
if (flags.WarMECHMode != WarMECHMode.Vanilla)
321+
{
322+
WarMECHNpc(flags.WarMECHMode, rng, maps);
323+
}
324+
317325
overworldMap.ApplyMapEdits();
318326
WriteMaps(maps);
319327

320328
WriteText(itemText, ItemTextPointerOffset, ItemTextPointerBase, ItemTextOffset, UnusedGoldItems);
329+
// WriteText(dialogueText, DialogueTextPointerOffset, DialogueTextPointerBase, DialogueTextOffset);
321330

322331
if (flags.EnemyScaleFactor > 1)
323332
{
@@ -334,6 +343,8 @@ public void Randomize(Blob seed, Flags flags)
334343
EnableCanalBridge();
335344
}
336345

346+
SetProgressiveScaleMode(flags.ProgressiveScaleMode);
347+
337348
// We have to do "fun" stuff last because it alters the RNG state.
338349
RollCredits(rng);
339350

@@ -450,7 +461,7 @@ private void ExtraTrackingAndInitCode()
450461
PutInBank(0x0F, 0x8800, Blob.FromHex("A000B186C902F005C908F00160A018B186301BC8B1863016C8B1863011C8B186300CA026B1861869010AA0209186A01CB186301AC8B1863015C8B1863010C8B186300BA026B186186901A022918660"));
451462

452463
// Copyright overhaul, see 0F_8960_DrawSeedAndFlags.asm
453-
PutInBank(0x0F, 0x8960, Blob.FromHex("A9238D0620A9208D0620A200BD00898D0720E8E060D0F560"));
464+
PutInBank(0x0F, 0x8980, Blob.FromHex("A9238D0620A9208D0620A200BD00898D0720E8E080D0F560"));
454465

455466
// Fast Battle Boxes
456467
PutInBank(0x0F, 0x8A00, Blob.FromHex("A940858AA922858BA91E8588A969858960"));
@@ -467,6 +478,13 @@ private void ExtraTrackingAndInitCode()
467478
// Change INT to MDEF in the Status screen
468479
Put(0x388F5, Blob.FromHex("968D8E8F"));
469480
Data[0x38DED] = 0x25;
481+
482+
//Key Items + Progressive Scaling
483+
PutInBank(0x0F, 0x9000, Blob.FromHex("A200AD2160F001E8AD2260F001E8AD2560F001E8AD2A60F001E8AD2B60F001E8AD2C60F001E8AD2E60F001E8AD3060F001E8AD0060F001E8AD1260F001E8AD0460F001E8AD0860F001E8AD0C60D001E8AD2360D007AD0A622902F001E8AD2460D007AD05622902F001E8AD2660D007AD08622902F001E8AD2760D007AD09622902F001E8AD2860D007AD0B622902F001E8AD2960D007AD14622901D001E8AD2D60D007AD0E622902F001E8AD2F60D007AD13622903F001E88EB86060"));
484+
PutInBank(0x1F, 0xCFCB, CreateLongJumpTableEntry(0x0F, 0x9100));
485+
//Division routine
486+
PutInBank(0x0F, 0x90C0, Blob.FromHex("8A48A9008513A210261026112613A513C5129004E512851326102611CAD0EDA513851268AA60"));
487+
// Progressive scaling also writes to 0x9100 approaching 200 bytes, begin next Put at 0x9200.
470488
}
471489

472490
public void MakeSpaceIn1F()
@@ -517,15 +535,35 @@ public void WriteSeedAndFlags(string version, string seed, string flags)
517535
Put(0x38486, Blob.FromHex("20FCFE60"));
518536

519537
// DrawSeedAndFlags LongJump
520-
PutInBank(0x1F, 0xFEFC, CreateLongJumpTableEntry(0x0F, 0x8960));
538+
PutInBank(0x1F, 0xFEFC, CreateLongJumpTableEntry(0x0F, 0x8980));
521539

522-
// Put the new string data in a known location.
523-
PutInBank(0x0F, 0x8900, Blob.Concat(new Blob[]
540+
var sha = File.Exists("version.txt") ? File.ReadAllText("version.txt").Trim() : "development";
541+
Blob hash;
542+
if (sha == "development")
543+
{
544+
hash = FF1Text.TextToCopyrightLine("DEVELOPMENT VERSION");
545+
}
546+
else
524547
{
548+
var hasher = SHA256.Create();
549+
hash = hasher.ComputeHash(Encoding.ASCII.GetBytes($"{seed}_{flags}_{sha}"));
550+
551+
var hashpart = BitConverter.ToUInt64(hash, 0);
552+
hash = Blob.FromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");
553+
for (int i = 13; i < 19; i++)
554+
{
555+
// 0xD4 through 0xDF are good symbols to use.
556+
hash[i] = (byte)(0xD4 + hashpart % 12);
557+
hashpart /= 12;
558+
}
559+
}
560+
561+
// Put the new string data in a known location.
562+
PutInBank(0x0F, 0x8900, Blob.Concat(
525563
FF1Text.TextToCopyrightLine("Final Fantasy Randomizer " + version),
526564
FF1Text.TextToCopyrightLine("Seed " + seed),
527565
FF1Text.TextToCopyrightLine(flags),
528-
}));
566+
hash));
529567
}
530568

531569
public void ShuffleRng(MT19337 rng)

0 commit comments

Comments
 (0)