An Amulet compiler patch causes this to not crash.
This commit is contained in:
parent
4852cffa0a
commit
ce17f86c41
9 changed files with 3283 additions and 488 deletions
2814
build/oot/main.lua
Normal file
2814
build/oot/main.lua
Normal file
File diff suppressed because it is too large
Load diff
23
build/ootAI.lua
Normal file
23
build/ootAI.lua
Normal file
|
@ -0,0 +1,23 @@
|
|||
package.path = GetScriptsDir() .. "oot/main.lua"
|
||||
local main = require("main")
|
||||
|
||||
function onScriptStart()
|
||||
main.onScriptStart()
|
||||
end
|
||||
|
||||
function onScriptCancel()
|
||||
main.onScriptCancel()
|
||||
end
|
||||
|
||||
function onScriptUpdate()
|
||||
main.onScriptUpdate()
|
||||
end
|
||||
|
||||
function onStateLoaded()
|
||||
main.onStateLoaded()
|
||||
end
|
||||
|
||||
function onStateSaved()
|
||||
main.onStateSaved()
|
||||
end
|
||||
|
31
mem/int.ml
31
mem/int.ml
|
@ -24,8 +24,8 @@ instance decode s8 begin
|
|||
let decode addr =
|
||||
let u8 = Dolphin.read_value_8 addr
|
||||
let signfix =
|
||||
if u8 > 127 then
|
||||
negate (256 - u8)
|
||||
if u8 > 0xFF then
|
||||
negate (0x100 - u8)
|
||||
else
|
||||
u8
|
||||
S8 signfix
|
||||
|
@ -53,8 +53,8 @@ instance decode s16 begin
|
|||
let decode addr =
|
||||
let u16 = Dolphin.read_value_16 addr
|
||||
let signfix =
|
||||
if u16 > 32767 then
|
||||
negate (65536 - u16)
|
||||
if u16 > 0xFFFF then
|
||||
negate (0x10000 - u16)
|
||||
else
|
||||
u16
|
||||
S16 signfix
|
||||
|
@ -67,15 +67,24 @@ instance show u32 begin
|
|||
let show (U32 x) = (show x) ^ "_u32"
|
||||
end
|
||||
|
||||
instance decode u32 begin
|
||||
let decode addr = U32 (Dolphin.read_value_32 addr)
|
||||
end
|
||||
|
||||
type s32 =
|
||||
S32 of int
|
||||
|
||||
instance show s32 begin
|
||||
let show (S32 x) =
|
||||
let signfix =
|
||||
if x > 2147483647 then
|
||||
negate (4294967296 - x)
|
||||
else
|
||||
x
|
||||
(show signfix) ^ "_s32"
|
||||
let show (S32 x) = (show x) ^ "_s32"
|
||||
end
|
||||
|
||||
instance decode s32 begin
|
||||
let decode addr =
|
||||
let u32 = Dolphin.read_value_32 addr
|
||||
let signfix =
|
||||
if u32 > 0xFFFFFFFF then
|
||||
negate (0x100000000 - u32)
|
||||
else
|
||||
u32
|
||||
S32 signfix
|
||||
end
|
||||
|
|
|
@ -48,35 +48,41 @@ type tunic =
|
|||
| KokiriTunic
|
||||
| GoronTunic
|
||||
| ZoraTunic
|
||||
| UnknownTunic of int
|
||||
|
||||
instance show tunic begin
|
||||
let show = function
|
||||
| KokiriTunic -> "Kokiri Tunic"
|
||||
| GoronTunic -> "Goron Tunic"
|
||||
| ZoraTunic -> "Zora Tunic"
|
||||
| UnknownTunic x -> "Unknown Tunic " ^ (show x)
|
||||
end
|
||||
|
||||
let tunic_from_index = function
|
||||
| 1 -> KokiriTunic
|
||||
| 2 -> GoronTunic
|
||||
| 3 -> ZoraTunic
|
||||
| x -> UnknownTunic x
|
||||
|
||||
type boots =
|
||||
| KokiriBoots
|
||||
| IronBoots
|
||||
| HoverBoots
|
||||
| UnknownBoots of int
|
||||
|
||||
instance show boots begin
|
||||
let show = function
|
||||
| KokiriBoots -> "Kokiri Boots"
|
||||
| IronBoots -> "Iron Boots"
|
||||
| HoverBoots -> "Hover Boots"
|
||||
| UnknownBoots x -> "Unknown Boots " ^ (show x)
|
||||
end
|
||||
|
||||
let boots_from_index = function
|
||||
| 1 -> KokiriBoots
|
||||
| 2 -> IronBoots
|
||||
| 3 -> HoverBoots
|
||||
| x -> UnknownBoots x
|
||||
|
||||
type equipment = Equipment of {
|
||||
sword: sword,
|
||||
|
@ -85,6 +91,11 @@ type equipment = Equipment of {
|
|||
boots: boots
|
||||
}
|
||||
|
||||
external private val ( .>>. ) : int -> int -> int
|
||||
= "function(a, b) return a >> b end"
|
||||
external private val ( .&. ) : int -> int -> int
|
||||
= "function(a, b) return a & b end"
|
||||
|
||||
instance decode equipment begin
|
||||
let decode addr =
|
||||
let code = Dolphin.read_value_16 addr
|
||||
|
|
51
oot/inventory.ml
Normal file
51
oot/inventory.ml
Normal file
|
@ -0,0 +1,51 @@
|
|||
open import "prelude.ml"
|
||||
open import "data/array.ml"
|
||||
open import "../pretty.ml"
|
||||
open import "../mem/decode.ml"
|
||||
open import "../mem/int.ml"
|
||||
|
||||
type inventory = Inventory of {
|
||||
items: array u8,
|
||||
ammo: array s8,
|
||||
equipment: u16,
|
||||
upgrades: u32,
|
||||
quest_items: u32,
|
||||
dungeon_items: array u8,
|
||||
dungeon_keys: array s8,
|
||||
defense_hearts: s8,
|
||||
gs_tokens: s16
|
||||
}
|
||||
|
||||
instance decode inventory begin
|
||||
let decode addr = Inventory {
|
||||
items = init 24 (fun i -> decode (addr + 0x00 + i)),
|
||||
ammo = init 16 (fun i -> decode (addr + 0x18 + i)),
|
||||
equipment = decode (addr + 0x28),
|
||||
upgrades = decode (addr + 0x2C),
|
||||
quest_items = decode (addr + 0x30),
|
||||
dungeon_items = init 20 (fun i -> decode (addr + 0x34 + i)),
|
||||
dungeon_keys = init 19 (fun i -> decode (addr + 0x48 + i)),
|
||||
defense_hearts = decode (addr + 0x5B),
|
||||
gs_tokens = decode (addr + 0x5C)
|
||||
}
|
||||
end
|
||||
|
||||
instance prettyrecord inventory begin
|
||||
let name _ = "Inventory"
|
||||
let fields (Inventory x) =
|
||||
[
|
||||
("items", S x.items),
|
||||
("ammo", S x.ammo),
|
||||
("equipment", S x.equipment),
|
||||
("upgrades", S x.upgrades),
|
||||
("quest_items", S x.quest_items),
|
||||
("dungeon_items", S x.dungeon_items),
|
||||
("dungeon_keys", S x.dungeon_keys),
|
||||
("defense_hearts", S x.defense_hearts),
|
||||
("gs_tokens", S x.gs_tokens)
|
||||
]
|
||||
end
|
||||
|
||||
instance pretty inventory begin
|
||||
let pretty = pretty_from_record
|
||||
end
|
283
oot/item.ml
283
oot/item.ml
|
@ -5,22 +5,293 @@ open import "../mem/decode.ml"
|
|||
open import "../mem/int.ml"
|
||||
|
||||
type item =
|
||||
| DekuSticks
|
||||
| NoItem
|
||||
| DekuStick
|
||||
| DekuNut
|
||||
| Bomb
|
||||
| FairyBow
|
||||
| FireArrow
|
||||
| DinsFire
|
||||
| FairySlingshot
|
||||
| FairyOcarina
|
||||
| OcarinaOfTime
|
||||
| Bombchu_10
|
||||
| Hookshot
|
||||
| Longshot
|
||||
| IceArrow
|
||||
| FaroresWind
|
||||
| Boomerang
|
||||
| LensOfTruth
|
||||
| MagicBean
|
||||
| MegatonHammer
|
||||
| LightArrow
|
||||
| NayrusLove
|
||||
| EmptyBottle
|
||||
| RedPotionBottle
|
||||
| GreenPotionBottle
|
||||
| BluePotionBottle
|
||||
| FairyBottle
|
||||
| FishBottle
|
||||
| FullMilkBottle
|
||||
| RutosLetterBottle
|
||||
| BlueFireBottle
|
||||
| BugBottle
|
||||
| BigPoeBottle
|
||||
| HalfMilkBottle
|
||||
| PoeBottle
|
||||
| WeirdEgg
|
||||
| Chicken
|
||||
| ZeldasLetter
|
||||
| KeatonMask
|
||||
| SkullMask
|
||||
| SpookyMask
|
||||
| BunnyHood
|
||||
| GoronMask
|
||||
| ZoraMask
|
||||
| GerudoMask
|
||||
| MaskOfTruth
|
||||
| SoldOut
|
||||
| PocketEgg
|
||||
| PocketCucco
|
||||
| Cojiro
|
||||
| OddMushroom
|
||||
| OddPotion
|
||||
| PoachersSaw
|
||||
| BrokenGoronsSword
|
||||
| Prescription
|
||||
| EyeballFrog
|
||||
| EyeDrops
|
||||
| ClaimCheck
|
||||
| FairyBowAndFireArrow
|
||||
| FairyBowAndIceArrow
|
||||
| FairyBowAndLightArrow
|
||||
| KokiriSword
|
||||
| MasterSword
|
||||
| GoronsSword
|
||||
| DekuShield
|
||||
| HylianShield
|
||||
| MirrorShield
|
||||
| KokiriTunic
|
||||
| GoronTunic
|
||||
| ZoraTunic
|
||||
| KokiriBoots
|
||||
| IronBoots
|
||||
| HoverBoots
|
||||
| BulletBag_30
|
||||
| BulletBag_40
|
||||
| BulletBag_50
|
||||
| Quiver_30
|
||||
| BigQuiver_40
|
||||
| BiggestQuiver_50
|
||||
| BombBag_20
|
||||
| BigBombBag_30
|
||||
| BiggestBombBag_40
|
||||
| GoronsBracelet
|
||||
| SilverGauntlets
|
||||
| GoldenGauntlets
|
||||
| SilverScale
|
||||
| GoldenScale
|
||||
| BrokenGiantsKnife
|
||||
| AdultsWallet
|
||||
| GiantsWallet
|
||||
| DekuSeeds_5
|
||||
| FishingPole
|
||||
| MinuetOfForest
|
||||
| BoleroOfFire
|
||||
| SerenadeOfWater
|
||||
| RequiemOfSpirit
|
||||
| NocturneOfShadow
|
||||
| PreludeOfLight
|
||||
| ZeldasLullaby
|
||||
| EponasSong
|
||||
| SariasSong
|
||||
| SunsSong
|
||||
| SongOfTime
|
||||
| SongOfStorms
|
||||
| ForestMedallion
|
||||
| FireMedallion
|
||||
| WaterMedallion
|
||||
| SpiritMedallion
|
||||
| ShadowMedallion
|
||||
| LightMedallion
|
||||
| KokirisEmerald
|
||||
| GoronsRuby
|
||||
| ZorasSapphire
|
||||
| StoneOfAgony
|
||||
| GerudosCard
|
||||
| GoldSkulltulaToken
|
||||
| HeartContainer
|
||||
| PieceOfHeart_
|
||||
| BossKey
|
||||
| Compass
|
||||
| DungeonMap
|
||||
| SmallKey
|
||||
| SmallMagicJar
|
||||
| LargeMagicJar
|
||||
| PieceOfHeart
|
||||
| LonLonMilk
|
||||
| RecoveryHeart
|
||||
| GreenRupee
|
||||
| BlueRupee
|
||||
| RedRupee
|
||||
| PurpleRupee
|
||||
| HugeRupee
|
||||
| DekuSticks_5
|
||||
| DekuSticks_10
|
||||
| DekuNuts_5
|
||||
| DekuNuts_10
|
||||
| Bombs_5
|
||||
| Bombs_10
|
||||
| Bombs_20
|
||||
| Bombs_30
|
||||
| Arrows_5_10
|
||||
| Arrows_10_30
|
||||
| Arrows_30_50
|
||||
| DekuSeeds_30
|
||||
| Bombchu_5
|
||||
| Bombchu_20
|
||||
| DekuStickCapacity_20
|
||||
| DekuStickCapacity_30
|
||||
| DekuNutCapacity_30
|
||||
| DekuNutCapacity_40
|
||||
| UnknownItem of int
|
||||
| NoItem
|
||||
|
||||
instance decode item begin
|
||||
let decode addr =
|
||||
let code = Dolphin.read_value_8 addr
|
||||
match code with
|
||||
| 0 -> DekuSticks
|
||||
| 255 -> NoItem
|
||||
| 0x00 -> DekuStick
|
||||
| 0x01 -> DekuNut
|
||||
| 0x02 -> Bomb
|
||||
| 0x03 -> FairyBow
|
||||
| 0x04 -> FireArrow
|
||||
| 0x05 -> DinsFire
|
||||
| 0x06 -> FairySlingshot
|
||||
| 0x07 -> FairyOcarina
|
||||
| 0x08 -> OcarinaOfTime
|
||||
| 0x09 -> Bombchu_10
|
||||
| 0x0A -> Hookshot
|
||||
| 0x0B -> Longshot
|
||||
| 0x0C -> IceArrow
|
||||
| 0x0D -> FaroresWind
|
||||
| 0x0E -> Boomerang
|
||||
| 0x0F -> LensOfTruth
|
||||
| 0x10 -> MagicBean
|
||||
| 0x11 -> MegatonHammer
|
||||
| 0x12 -> LightArrow
|
||||
| 0x13 -> NayrusLove
|
||||
| 0x14 -> EmptyBottle
|
||||
| 0x15 -> RedPotionBottle
|
||||
| 0x16 -> GreenPotionBottle
|
||||
| 0x17 -> BluePotionBottle
|
||||
| 0x18 -> FairyBottle
|
||||
| 0x19 -> FishBottle
|
||||
| 0x1A -> FullMilkBottle
|
||||
| 0x1B -> RutosLetterBottle
|
||||
| 0x1C -> BlueFireBottle
|
||||
| 0x1D -> BugBottle
|
||||
| 0x1E -> BigPoeBottle
|
||||
| 0x1F -> HalfMilkBottle
|
||||
| 0x20 -> PoeBottle
|
||||
| 0x21 -> WeirdEgg
|
||||
| 0x22 -> Chicken
|
||||
| 0x23 -> ZeldasLetter
|
||||
| 0x24 -> KeatonMask
|
||||
| 0x25 -> SkullMask
|
||||
| 0x26 -> SpookyMask
|
||||
| 0x27 -> BunnyHood
|
||||
| 0x28 -> GoronMask
|
||||
| 0x29 -> ZoraMask
|
||||
| 0x2A -> GerudoMask
|
||||
| 0x2B -> MaskOfTruth
|
||||
| 0x2C -> SoldOut
|
||||
| 0x2D -> PocketEgg
|
||||
| 0x2E -> PocketCucco
|
||||
| 0x2F -> Cojiro
|
||||
| 0x30 -> OddMushroom
|
||||
| 0x31 -> OddPotion
|
||||
| 0x32 -> PoachersSaw
|
||||
| 0x33 -> BrokenGoronsSword
|
||||
| 0x34 -> Prescription
|
||||
| 0x35 -> EyeballFrog
|
||||
| 0x36 -> EyeDrops
|
||||
| 0x37 -> ClaimCheck
|
||||
| 0x38 -> FairyBowAndFireArrow
|
||||
| 0x39 -> FairyBowAndIceArrow
|
||||
| 0x3A -> FairyBowAndLightArrow
|
||||
| 0x3B -> KokiriSword
|
||||
| 0x3C -> MasterSword
|
||||
| 0x3D -> GoronsSword
|
||||
| 0xFF -> NoItem
|
||||
| x -> UnknownItem x
|
||||
end
|
||||
|
||||
let dummy_show : int -> string = show
|
||||
|
||||
instance show item begin
|
||||
let show = function
|
||||
| DekuSticks -> "Deku Sticks"
|
||||
| DekuStick -> "Deku Stick"
|
||||
| DekuNut -> "Deku Nut"
|
||||
| Bomb -> "Bomb"
|
||||
| FairyBow -> "Fairy Bow"
|
||||
| FireArrow -> "Fire Arrow"
|
||||
| DinsFire -> "Din's Fire"
|
||||
| FairySlingshot -> "Fairy Slingshot"
|
||||
| FairyOcarina -> "Fairy Ocarina"
|
||||
| OcarinaOfTime -> "Ocarina of Time"
|
||||
| Bombchu_10 -> "Bombchu (10)"
|
||||
| Hookshot -> "Hookshot"
|
||||
| Longshot -> "Longshot"
|
||||
| IceArrow -> "Ice Arrow"
|
||||
| FaroresWind -> "Farore's Wind"
|
||||
| Boomerang -> "Boomerang"
|
||||
| LensOfTruth -> "Lens of Truth"
|
||||
| MagicBean -> "Magic Bean"
|
||||
| MegatonHammer -> "Megaton Hammer"
|
||||
| LightArrow -> "Light Arrow"
|
||||
| NayrusLove -> "Nayru's Love"
|
||||
| EmptyBottle -> "Empty Bottle"
|
||||
| RedPotionBottle -> "Red Potion"
|
||||
| GreenPotionBottle -> "Green Potion"
|
||||
| BluePotionBottle -> "Blue Potion"
|
||||
| FairyBottle -> "Bottled Fairy"
|
||||
| FishBottle -> "Fish"
|
||||
| FullMilkBottle -> "Lon Lon Milk"
|
||||
| RutosLetterBottle -> "Ruto's Letter"
|
||||
| BlueFireBottle -> "Blue Fire"
|
||||
| BugBottle -> "Bug"
|
||||
| BigPoeBottle -> "Big Poe"
|
||||
| HalfMilkBottle -> "Half Lon Lon Milk"
|
||||
| PoeBottle -> "Poe"
|
||||
| WeirdEgg -> "Weird Egg"
|
||||
| Chicken -> "Chicken"
|
||||
| ZeldasLetter -> "Zelda's Letter"
|
||||
| KeatonMask -> "Keaton Mask"
|
||||
| SkullMask -> "Skull Mask"
|
||||
| SpookyMask -> "Spooky Mask"
|
||||
| BunnyHood -> "Bunny Hood"
|
||||
| GoronMask -> "Goron Mask"
|
||||
| ZoraMask -> "Zora Mask"
|
||||
| GerudoMask -> "Gerudo Mask"
|
||||
| MaskOfTruth -> "Mask of Truth"
|
||||
| SoldOut -> "SOLD OUT"
|
||||
| PocketEgg -> "Pocket Egg"
|
||||
| PocketCucco -> "Pocket Cucco"
|
||||
| Cojiro -> "Cojiro"
|
||||
| OddMushroom -> "Odd Mushroom"
|
||||
| OddPotion -> "Odd Potion"
|
||||
| PoachersSaw -> "Poacher's Saw"
|
||||
| BrokenGoronsSword -> "Broken Giant's Knife"
|
||||
| Prescription -> "Prescription"
|
||||
| EyeballFrog -> "Eyeball Frog"
|
||||
| EyeDrops -> "Eye Drops"
|
||||
| ClaimCheck -> "Claim Check"
|
||||
| FairyBowAndFireArrow -> "Fairy Bow & Fire Arrow"
|
||||
| FairyBowAndIceArrow -> "Fairy Bow & Ice Arrow"
|
||||
| FairyBowAndLightArrow -> "Fairy Bow & Light Arrow"
|
||||
| KokiriSword -> "Kokiri Sword"
|
||||
| MasterSword -> "Master Sword"
|
||||
| GoronsSword -> "Giant's Knife & Biggoron's Sword"
|
||||
| NoItem -> "No Item"
|
||||
| UnknownItem x -> "Unknown Item " ^ (show x)
|
||||
| UnknownItem x -> "Unknown Item " ^ (dummy_show x)
|
||||
end
|
||||
|
|
|
@ -3,6 +3,7 @@ open import "../pretty.ml"
|
|||
open import "../mem/decode.ml"
|
||||
open import "../mem/int.ml"
|
||||
open import "./item.ml"
|
||||
open import "./equipment.ml"
|
||||
|
||||
type item_equips = ItemEquips of {
|
||||
button_item_b: item,
|
||||
|
@ -12,7 +13,7 @@ type item_equips = ItemEquips of {
|
|||
button_slot_c_left: u8,
|
||||
button_slot_c_down: u8,
|
||||
button_slot_c_right: u8,
|
||||
equipment: u16
|
||||
equipment: equipment
|
||||
}
|
||||
|
||||
instance decode item_equips begin
|
||||
|
@ -39,7 +40,7 @@ instance prettyrecord item_equips begin
|
|||
("button_slot_c_left", S x.button_slot_c_left),
|
||||
("button_slot_c_down", S x.button_slot_c_down),
|
||||
("button_slot_c_right", S x.button_slot_c_right),
|
||||
("equipment", S x.equipment)
|
||||
("equipment", P x.equipment)
|
||||
]
|
||||
end
|
||||
|
||||
|
|
|
@ -3,20 +3,74 @@ open import "../pretty.ml"
|
|||
open import "../mem/decode.ml"
|
||||
open import "../mem/int.ml"
|
||||
open import "./item_equips.ml"
|
||||
open import "./inventory.ml"
|
||||
|
||||
type save_context = SaveContext of {
|
||||
entrance_index: s32,
|
||||
link_age: s32,
|
||||
cutscene_index: s32,
|
||||
day_time: u16,
|
||||
night_flag: s32,
|
||||
num_days: s32,
|
||||
claim_days: s32,
|
||||
(* char newf[6], *)
|
||||
deaths: s16,
|
||||
(* char playerName[8], *)
|
||||
n64dd_flag: s16,
|
||||
health_capacity: s16,
|
||||
health: s16,
|
||||
magic_level: s8,
|
||||
magic: s8,
|
||||
rupees: s16,
|
||||
sword_health: u16,
|
||||
navi_timer: u16,
|
||||
magic_acquired: u8,
|
||||
(* char unk_3B[0x01], *)
|
||||
double_magic: u8,
|
||||
double_defense: u8,
|
||||
bgs_flag: u8,
|
||||
ocarina_game_reward: u8,
|
||||
child_equips: item_equips,
|
||||
adult_equips: item_equips,
|
||||
equips: item_equips
|
||||
(* u32 unk_54, *)
|
||||
(* char unk_58[0x0E], *)
|
||||
saved_scene_num: s16,
|
||||
equips: item_equips,
|
||||
inventory: inventory
|
||||
}
|
||||
|
||||
instance decode save_context begin
|
||||
let decode addr = SaveContext {
|
||||
entrance_index = decode (addr + 0x0000),
|
||||
link_age = decode (addr + 0x0004),
|
||||
cutscene_index = decode (addr + 0x0008),
|
||||
day_time = decode (addr + 0x000C),
|
||||
night_flag = decode (addr + 0x0010),
|
||||
num_days = decode (addr + 0x0014),
|
||||
claim_days = decode (addr + 0x0018),
|
||||
(* newf, *)
|
||||
deaths = decode (addr + 0x0022),
|
||||
(* player_name, *)
|
||||
n64dd_flag = decode (addr + 0x002C),
|
||||
health_capacity = decode (addr + 0x002E),
|
||||
health = decode (addr + 0x0030),
|
||||
magic_level = decode (addr + 0x0032),
|
||||
magic = decode (addr + 0x0033),
|
||||
rupees = decode (addr + 0x0034),
|
||||
sword_health = decode (addr + 0x0036),
|
||||
navi_timer = decode (addr + 0x0038),
|
||||
magic_acquired = decode (addr + 0x003A),
|
||||
(* unk_3B *)
|
||||
double_magic = decode (addr + 0x003C),
|
||||
double_defense = decode (addr + 0x003D),
|
||||
bgs_flag = decode (addr + 0x003E),
|
||||
ocarina_game_reward = decode (addr + 0x003F),
|
||||
child_equips = decode (addr + 0x0040),
|
||||
adult_equips = decode (addr + 0x004A),
|
||||
equips = decode (addr + 0x0068)
|
||||
(* unk_54, *)
|
||||
saved_scene_num = decode (addr + 0x0066),
|
||||
equips = decode (addr + 0x0068),
|
||||
inventory = decode (addr + 0x0074)
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -24,10 +78,37 @@ instance prettyrecord save_context begin
|
|||
let name _ = "SaveContext"
|
||||
let fields (SaveContext x) =
|
||||
[
|
||||
("entrance_index", S x.entrance_index),
|
||||
("link_age", S x.link_age),
|
||||
("cutscene_index", S x.cutscene_index),
|
||||
("day_time", S x.day_time),
|
||||
("night_flag", S x.night_flag),
|
||||
("num_days", S x.num_days),
|
||||
("claim_days", S x.claim_days),
|
||||
(* ("newf", S x.newf ), *)
|
||||
("deaths", S x.deaths),
|
||||
(* ("player_name", S x.player_name) *)
|
||||
("n64dd_flag", S x.n64dd_flag),
|
||||
("health_capacity", S x.health_capacity),
|
||||
("health", S x.health),
|
||||
("magic_level", S x.magic_level),
|
||||
("magic", S x.magic),
|
||||
("rupees", S x.rupees),
|
||||
("sword_health", S x.sword_health),
|
||||
("navi_timer", S x.navi_timer),
|
||||
("magic_acquired", S x.magic_acquired),
|
||||
(* ("unk_3B", *)
|
||||
("double_magic", S x.double_magic),
|
||||
("double_defense", S x.double_defense),
|
||||
("bgs_flag", S x.bgs_flag),
|
||||
("ocarina_game_reward", S x.ocarina_game_reward),
|
||||
("child_equips", P x.child_equips),
|
||||
("adult_equips", P x.adult_equips),
|
||||
("equips", P x.equips)
|
||||
(* ("unk_54" *)
|
||||
(* ("unk_58" *)
|
||||
("saved_scene_num", S x.saved_scene_num),
|
||||
("equips", P x.equips),
|
||||
("inventory", P x.inventory)
|
||||
]
|
||||
end
|
||||
|
||||
|
|
466
save_context.ml
466
save_context.ml
|
@ -1,466 +0,0 @@
|
|||
open import "prelude.ml"
|
||||
open import "data/array.ml"
|
||||
|
||||
open import "./pretty.ml"
|
||||
|
||||
open import "./dolphin.ml"
|
||||
|
||||
type item =
|
||||
| DekuStick
|
||||
| DekuNut
|
||||
| Bomb
|
||||
| FairyBow
|
||||
| FireArrow
|
||||
| DinsFire
|
||||
| FairySlingshot
|
||||
| FairyOcarina
|
||||
| OcarinaOfTime
|
||||
| Bombchu_10
|
||||
| Hookshot
|
||||
| Longshot
|
||||
| IceArrow
|
||||
| FaroresWind
|
||||
| Boomerang
|
||||
| LensOfTruth
|
||||
| MagicBean
|
||||
| MegatonHammer
|
||||
| LightArrow
|
||||
| NayrusLove
|
||||
| EmptyBottle
|
||||
| RedPotionBottle
|
||||
| GreenPotionBottle
|
||||
| BluePotionBottle
|
||||
| FairyBottle
|
||||
| FishBottle
|
||||
| FullMilkBottle
|
||||
| RutosLetterBottle
|
||||
| BlueFireBottle
|
||||
| BugBottle
|
||||
| BigPoeBottle
|
||||
| HalfMilkBottle
|
||||
| PoeBottle
|
||||
| WeirdEgg
|
||||
| Chicken
|
||||
| ZeldasLetter
|
||||
| KeatonMask
|
||||
| SkullMask
|
||||
| SpookyMask
|
||||
| BunnyHood
|
||||
| GoronMask
|
||||
| ZoraMask
|
||||
| GerudoMask
|
||||
| MaskOfTruth
|
||||
| SoldOut
|
||||
| PocketEgg
|
||||
| PocketCucco
|
||||
| Cojiro
|
||||
| OddMushroom
|
||||
| OddPotion
|
||||
| PoachersSaw
|
||||
| BrokenGoronsSword
|
||||
| Prescription
|
||||
| EyeballFrog
|
||||
| EyeDrops
|
||||
| ClaimCheck
|
||||
| FairyBowAndFireArrow
|
||||
| FairyBowAndIceArrow
|
||||
| FairyBowAndLightArrow
|
||||
| KokiriSword
|
||||
| MasterSword
|
||||
| GiantsKnifeAndBiggoronsSword
|
||||
| DekuShield
|
||||
| HylianShield
|
||||
| MirrorShield
|
||||
| KokiriTunic
|
||||
| GoronTunic
|
||||
| ZoraTunic
|
||||
| KokiriBoots
|
||||
| IronBoots
|
||||
| HoverBoots
|
||||
| BulletBag_30
|
||||
| BulletBag_40
|
||||
| BulletBag_50
|
||||
| Quiver_30
|
||||
| BigQuiver_40
|
||||
| BiggestQuiver_50
|
||||
| BombBag_20
|
||||
| BigBombBag_30
|
||||
| BiggestBombBag_40
|
||||
| GoronsBracelet
|
||||
| SilverGauntlets
|
||||
| GoldenGauntlets
|
||||
| SilverScale
|
||||
| GoldenScale
|
||||
| BrokenGiantsKnife
|
||||
| AdultsWallet
|
||||
| GiantsWallet
|
||||
| DekuSeeds_5
|
||||
| FishingPole
|
||||
| MinuetOfForest
|
||||
| BoleroOfFire
|
||||
| SerenadeOfWater
|
||||
| RequiemOfSpirit
|
||||
| NocturneOfShadow
|
||||
| PreludeOfLight
|
||||
| ZeldasLullaby
|
||||
| EponasSong
|
||||
| SariasSong
|
||||
| SunsSong
|
||||
| SongOfTime
|
||||
| SongOfStorms
|
||||
| ForestMedallion
|
||||
| FireMedallion
|
||||
| WaterMedallion
|
||||
| SpiritMedallion
|
||||
| ShadowMedallion
|
||||
| LightMedallion
|
||||
| KokirisEmerald
|
||||
| GoronsRuby
|
||||
| ZorasSapphire
|
||||
| StoneOfAgony
|
||||
| GerudosCard
|
||||
| GoldSkulltulaToken
|
||||
| HeartContainer
|
||||
| PieceOfHeart_
|
||||
| BossKey
|
||||
| Compass
|
||||
| DungeonMap
|
||||
| SmallKey
|
||||
| SmallMagicJar
|
||||
| LargeMagicJar
|
||||
| PieceOfHeart
|
||||
| LonLonMilk
|
||||
| RecoveryHeart
|
||||
| GreenRupee
|
||||
| BlueRupee
|
||||
| RedRupee
|
||||
| PurpleRupee
|
||||
| HugeRupee
|
||||
| DekuSticks_5
|
||||
| DekuSticks_10
|
||||
| DekuNuts_5
|
||||
| DekuNuts_10
|
||||
| Bombs_5
|
||||
| Bombs_10
|
||||
| Bombs_20
|
||||
| Bombs_30
|
||||
| Arrows_5_10
|
||||
| Arrows_10_30
|
||||
| Arrows_30_50
|
||||
| DekuSeeds_30
|
||||
| Bombchu_5
|
||||
| Bombchu_20
|
||||
| DekuStickCapacity_20
|
||||
| DekuStickCapacity_30
|
||||
| DekuNutCapacity_30
|
||||
| DekuNutCapacity_40
|
||||
| UnknownItem of u8
|
||||
| NoItem
|
||||
|
||||
instance decode item begin
|
||||
let decode addr x =
|
||||
let (U8 id) = decode addr x
|
||||
match id with
|
||||
| 0xFF -> NoItem
|
||||
end
|
||||
|
||||
instance show item begin
|
||||
let show = function
|
||||
| NoItem -> "No Item"
|
||||
end
|
||||
|
||||
type sword =
|
||||
| NoSword
|
||||
| KokiriSword
|
||||
| MasterSword
|
||||
| BiggoronsSword
|
||||
| UnknownSword of int
|
||||
|
||||
instance show sword begin
|
||||
let show = function
|
||||
| NoSword -> "No Sword"
|
||||
| KokiriSword -> "Kokiri Sword"
|
||||
| MasterSword -> "Master Sword"
|
||||
| BiggoronsSword -> "Biggoron's Sword"
|
||||
| UnknownSword x -> "Unknown Sword " ^ (show x)
|
||||
end
|
||||
|
||||
type shield =
|
||||
| NoShield
|
||||
| DekuShield
|
||||
| HylianShield
|
||||
| MirrorShield
|
||||
| UnknownShield of int
|
||||
|
||||
instance show shield begin
|
||||
let show = function
|
||||
| NoShield -> "No Shield"
|
||||
| DekuShield -> "Deku Shield"
|
||||
| HylianShield -> "Hylian Shield"
|
||||
| MirrorShield -> "Mirror Shield"
|
||||
| UnknownShield x -> "Unknown Shield " ^ (show x)
|
||||
end
|
||||
|
||||
type tunic =
|
||||
| KokiriTunic
|
||||
| GoronTunic
|
||||
| ZoraTunic
|
||||
| UnknownTunic of int
|
||||
|
||||
instance show tunic begin
|
||||
let show = function
|
||||
| KokiriTunic -> "Kokiri Tunic"
|
||||
| GoronTunic -> "Goron Tunic"
|
||||
| ZoraTunic -> "Zora Tunic"
|
||||
| UnknownTunic x -> "Unknown Tunic " ^ (show x)
|
||||
end
|
||||
|
||||
type boots =
|
||||
| KokiriBoots
|
||||
| IronBoots
|
||||
| HoverBoots
|
||||
| UnknownBoots of int
|
||||
|
||||
instance show boots begin
|
||||
let show = function
|
||||
| KokiriBoots -> "Kokiri Boots"
|
||||
| IronBoots -> "Iron Boots"
|
||||
| HoverBoots -> "Hover Boots"
|
||||
| UnknownBoots x -> "Unknown Boots " ^ (show x)
|
||||
end
|
||||
|
||||
type equipment = Equipment of {
|
||||
swordv: sword,
|
||||
shieldv: shield,
|
||||
tunicv: tunic,
|
||||
bootsv: boots
|
||||
}
|
||||
|
||||
external private val ( %% ) : int -> int -> int = "function(a, b) return a % b end"
|
||||
|
||||
instance decode equipment begin
|
||||
let decode addr x =
|
||||
let (U16 fields) = decode addr x
|
||||
let swords = fields %% (0x000F + 1)
|
||||
let shields = (fields // 8) %% (0x00F + 1)
|
||||
let tunics = (fields // 16) %% (0x0F + 1)
|
||||
let boots = (fields // 24) %% (0xF + 1)
|
||||
let fsword =
|
||||
match swords with
|
||||
| 0 -> NoSword
|
||||
| 1 -> KokiriSword
|
||||
| 2 -> MasterSword
|
||||
| 3 -> BiggoronsSword
|
||||
| x -> UnknownSword x
|
||||
let fshield =
|
||||
match shields with
|
||||
| 0 -> NoShield
|
||||
| 1 -> DekuShield
|
||||
| 2 -> HylianShield
|
||||
| 3 -> MirrorShield
|
||||
| x -> UnknownShield x
|
||||
let ftunic =
|
||||
match tunics with
|
||||
| 1 -> KokiriTunic
|
||||
| 2 -> GoronTunic
|
||||
| 3 -> ZoraTunic
|
||||
| x -> UnknownTunic x
|
||||
let fboot =
|
||||
match boots with
|
||||
| 1 -> KokiriBoots
|
||||
| 2 -> IronBoots
|
||||
| 3 -> HoverBoots
|
||||
| x -> UnknownBoots x
|
||||
Equipment {
|
||||
swordv = fsword,
|
||||
shieldv = fshield,
|
||||
tunicv = ftunic,
|
||||
bootsv = fboot
|
||||
}
|
||||
end
|
||||
|
||||
instance prettyrecord equipment begin
|
||||
let name _ = "Equipment"
|
||||
let fields (Equipment x) =
|
||||
[]
|
||||
end
|
||||
|
||||
type item_equips = ItemEquips of {
|
||||
button_item_b: u8,
|
||||
button_item_c_left: u8,
|
||||
button_item_c_down: u8,
|
||||
button_item_c_right: u8,
|
||||
button_slot_c_left: u8,
|
||||
button_slot_c_down: u8,
|
||||
button_slot_c_right: u8,
|
||||
equips: equipment
|
||||
}
|
||||
|
||||
instance decode item_equips begin
|
||||
let decode addr x = ItemEquips {
|
||||
button_item_b = decode (addr + 0x00) x,
|
||||
button_item_c_left = decode (addr + 0x01) x,
|
||||
button_item_c_down = decode (addr + 0x02) x,
|
||||
button_item_c_right = decode (addr + 0x03) x,
|
||||
button_slot_c_left = decode (addr + 0x04) x,
|
||||
button_slot_c_down = decode (addr + 0x05) x,
|
||||
button_slot_c_right = decode (addr + 0x06) x,
|
||||
equips = decode (addr + 0x08) x
|
||||
}
|
||||
end
|
||||
|
||||
instance prettyrecord item_equips begin
|
||||
let name _ = "ItemEquips"
|
||||
let fields (ItemEquips x) =
|
||||
[
|
||||
("button_item_b", S x.button_item_b),
|
||||
("button_item_c_left", S x.button_item_c_left),
|
||||
("button_item_c_down", S x.button_item_c_down),
|
||||
("button_item_c_right", S x.button_item_c_right),
|
||||
("button_slot_c_left", S x.button_slot_c_left),
|
||||
("button_slot_c_down", S x.button_slot_c_down),
|
||||
("button_slot_c_right", S x.button_slot_c_right),
|
||||
("equips", P x.equips)
|
||||
]
|
||||
end
|
||||
|
||||
type inventory = Inventory of {
|
||||
items: array u8,
|
||||
ammo: array s8,
|
||||
equipment: u16,
|
||||
upgrades: u32,
|
||||
quest_items: u32,
|
||||
dungeon_items: array u8,
|
||||
dungeon_keys: array s8,
|
||||
defense_hearts: s8,
|
||||
gs_tokens: s16
|
||||
}
|
||||
|
||||
instance decode inventory begin
|
||||
let decode addr x = Inventory {
|
||||
items = init 24 (fun i -> decode (addr + 0x00 + i) x),
|
||||
ammo = init 16 (fun i -> decode (addr + 0x18 + i) x),
|
||||
equipment = decode (addr + 0x28) x,
|
||||
upgrades = decode (addr + 0x2C) x,
|
||||
quest_items = decode (addr + 0x30) x,
|
||||
dungeon_items = init 20 (fun i -> decode (addr + 0x34 + i) x),
|
||||
dungeon_keys = init 19 (fun i -> decode (addr + 0x48 + i) x),
|
||||
defense_hearts = decode (addr + 0x5B) x,
|
||||
gs_tokens = decode (addr + 0x5C) x
|
||||
}
|
||||
end
|
||||
|
||||
instance prettyrecord inventory begin
|
||||
let name _ = "Inventory"
|
||||
let fields (Inventory x) =
|
||||
[
|
||||
("items", S x.items),
|
||||
("ammo", S x.ammo),
|
||||
("equipment", S x.equipment),
|
||||
("upgrades", S x.upgrades),
|
||||
("quest_items", S x.quest_items),
|
||||
("dungeon_items", S x.dungeon_items),
|
||||
("dungeon_keys", S x.dungeon_keys),
|
||||
("defense_hearts", S x.defense_hearts),
|
||||
("gs_tokens", S x.gs_tokens)
|
||||
]
|
||||
end
|
||||
|
||||
type save_context = SaveContext of {
|
||||
entrance_index: s32,
|
||||
link_age: s32,
|
||||
cutscene_index: s32,
|
||||
day_time: u16,
|
||||
night_flag: s32,
|
||||
num_days: s32,
|
||||
claim_days: s32,
|
||||
(* char newf[6], *)
|
||||
deaths: s16,
|
||||
(* char playerName[8], *)
|
||||
n64dd_flag: s16,
|
||||
health_capacity: s16,
|
||||
health: s16,
|
||||
magic_level: s8,
|
||||
magic: s8,
|
||||
rupees: s16,
|
||||
sword_health: u16,
|
||||
navi_timer: u16,
|
||||
magic_acquired: u8,
|
||||
(* char unk_3B[0x01], *)
|
||||
double_magic: u8,
|
||||
double_defense: u8,
|
||||
bgs_flag: u8,
|
||||
ocarina_game_reward: u8,
|
||||
child_equips: item_equips,
|
||||
adult_equips: item_equips,
|
||||
(* u32 unk_54, *)
|
||||
(* char unk_58[0x0E], *)
|
||||
saved_scene_num: s16,
|
||||
equips: item_equips,
|
||||
inventory: inventory
|
||||
}
|
||||
|
||||
instance decode save_context begin
|
||||
let decode addr x = SaveContext {
|
||||
entrance_index = decode (addr + 0x0000) x,
|
||||
link_age = decode (addr + 0x0004) x,
|
||||
cutscene_index = decode (addr + 0x0008) x,
|
||||
day_time = decode (addr + 0x000C) x,
|
||||
night_flag = decode (addr + 0x0010) x,
|
||||
num_days = decode (addr + 0x0014) x,
|
||||
claim_days = decode (addr + 0x0018) x,
|
||||
(* newf, *)
|
||||
deaths = decode (addr + 0x0022) x,
|
||||
n64dd_flag = decode (addr + 0x002C) x,
|
||||
health_capacity = decode (addr + 0x002E) x,
|
||||
health = decode (addr + 0x0030) x,
|
||||
magic_level = decode (addr + 0x0032) x,
|
||||
magic = decode (addr + 0x0033) x,
|
||||
rupees = decode (addr + 0x0034) x,
|
||||
sword_health = decode (addr + 0x0036) x,
|
||||
navi_timer = decode (addr + 0x0038) x,
|
||||
magic_acquired = decode (addr + 0x003A) x,
|
||||
double_magic = decode (addr + 0x003C) x,
|
||||
double_defense = decode (addr + 0x003D) x,
|
||||
bgs_flag = decode (addr + 0x003E) x,
|
||||
ocarina_game_reward = decode (addr + 0x003F) x,
|
||||
child_equips = decode (addr + 0x0040) x,
|
||||
adult_equips = decode (addr + 0x004A) x,
|
||||
saved_scene_num = decode (addr + 0x0066) x,
|
||||
equips = decode (addr + 0x0068) x,
|
||||
inventory = decode (addr + 0x0074) x
|
||||
}
|
||||
end
|
||||
|
||||
instance prettyrecord save_context begin
|
||||
let name _ = "SaveContext"
|
||||
let fields (SaveContext x) =
|
||||
[
|
||||
("entrance_index", S x.entrance_index),
|
||||
("link_age", S x.link_age),
|
||||
("cutscene_index", S x.cutscene_index),
|
||||
("day_time", S x.day_time),
|
||||
("night_flag", S x.night_flag),
|
||||
("num_days", S x.num_days),
|
||||
("claim_days", S x.claim_days),
|
||||
("deaths", S x.deaths),
|
||||
("n64dd_flag", S x.n64dd_flag),
|
||||
("health_capacity", S x.health_capacity),
|
||||
("health", S x.health),
|
||||
("magic_level", S x.magic_level),
|
||||
("magic", S x.magic),
|
||||
("rupees", S x.rupees),
|
||||
("sword_health", S x.sword_health),
|
||||
("navi_timer", S x.navi_timer),
|
||||
("magic_acquired", S x.magic_acquired),
|
||||
("double_magic", S x.double_magic),
|
||||
("double_defense", S x.double_defense),
|
||||
("bgs_flag", S x.bgs_flag),
|
||||
("ocarina_game_reward", S x.ocarina_game_reward),
|
||||
("child_equips", P x.child_equips),
|
||||
("adult_equips", P x.adult_equips),
|
||||
("saved_scene_num", S x.saved_scene_num),
|
||||
("equips", P x.equips),
|
||||
("inventory", P x.inventory)
|
||||
]
|
||||
end
|
Loading…
Reference in a new issue