Skip to content

Instantly share code, notes, and snippets.

@sinsinpub
Created August 3, 2022 11:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sinsinpub/41cbe35735607972478d95eebb24de8c to your computer and use it in GitHub Desktop.
Save sinsinpub/41cbe35735607972478d95eebb24de8c to your computer and use it in GitHub Desktop.
Lua password bulder for NES 1943: The Battle of Midway / FC 1943: The Battle of Valhalla
-- Continue password generator for `1943: The Battle of Valhalla` (Midway)
-- Input 6 arguments: stage[1,23] atk[1,6] def[1,6] energy[1,6] weapon[1,6] wtime[1,6]
-- Based on http://rapla.html.xdomain.jp/data/data4/1943fc/pas.html
stagebosses = {
[1] = "RIKAKU (Tone)", [2] = "KAKU (Kaga)",
[3] = "AYAKO (Mori)", [4] = "KAKUSI (Fuso)",
[5] = "KYOSHU (Akagi)", [6] = "GANRYO (T4HB Hiryu)",
[7] = "CHOKO (Ise)", [8] = "ROSHUKU (Hiryu)",
[9] = "AYAKO 2 (Composer)", [10] = "KAYU (Mutsu)",
[11] = "BUNSHU (Ki-67 Hiryu)", [12] = "CHOJIN (Yamashiro)",
[13] = "RIJU (Souryu)", [14] = "AYAKO 3 (Renzan/Fugaku)",
[15] = "RYOFU (Nagato)", [16] = "TOTAKU (TOUBIN, Yamato's decoy)",
-- Extra missions
[17] = "KAKU (Kaga)", [18] = "AYAKO",
[19] = "CHOKO (Ise)", [20] = "AYAKO 2",
[21] = "CHOJIN (Yamashiro)", [22] = "RYOFU (Nagato)",
[23] = "AYAKO x3",
-- Not able to start from mission 24
[24] = "TOTAKU (Real Yamato)",
}
stgchars = {
"0","7","E","L","S","Z","I","P",
"W","3","A","H","U","5","K","F",
"1","6","8","D","M","R","T",nil
}
atkdefchars = {
{ "3","A","H","I","P","W" },
{ "2","9","G","N","O","V" },
{ "1","8","F","M","T","U" },
{ "0","7","E","L","S","Z" },
{ "4","B","C","J","Q","X" },
{ "6",nil,"D","K","R","Y" }
}
entwptchars = {
{ "I","D","8","3","Y","T" },
{ "0","J","E","9","4","Z" },
{ "V","Q","L","G","B","O" },
{ "U","P","K","F","A","5" },
{ "W","X","R","S","M","N" },
{ "H","C","6","7","1","2" }
}
wtmchars = {
"1","G","O","W","N","9"
}
chksumchars = {
[8] = "7", [9] = "3", [10] = "A", [11] = "N",
[12] = "X", [13] = "P", [14] = "D", [15] = "8",
[16] = "G", [17] = "S", [18] = "Q", [19] = "J",
[20] = "E", [21] = "F", [22] = "M", [23] = "R",
[24] = "K", [25] = "L", [26] = "Z", [27] = "0",
[28] = "5", [29] = "U"
}
totalstatsbystg = {
8, 8, 9, 10, 11, 12, 14, 15,
16, 17, 19, 20, 21, 22, 23, 24,
26, 27, 27, 28, 28, 29, 29, 31
}
function getarg(n, m)
local v = tonumber(arg[n] or 1)
if v < 1 then v = 1 end
if v > m then v = m end
return v
end
stg = getarg(1, 24)
atk = getarg(2, 6)
def = getarg(3, 6)
ent = getarg(4, 6)
wpt = getarg(5, 6)
wtm = getarg(6, 6)
totalstats = atk + def + ent + wpt + wtm
expectedstats = totalstatsbystg[stg]
if not stgchars[stg] then result = "Invalid mission"
elseif not atkdefchars[atk][def] then result = "Invalid powerups"
elseif not chksumchars[totalstats] or totalstats ~= expectedstats then
result = "Powerup checksum mismatch"
elseif not result then
result = stgchars[stg]..atkdefchars[atk][def]..entwptchars[ent][wpt]
..wtmchars[wtm]..chksumchars[totalstats]
end
print("Mission "..stg..": "..stagebosses[stg])
print("Powerups: "..atk..def..ent..wpt..wtm)
print("Checksum: "..totalstats.."/"..expectedstats)
print("Password: "..result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment