# The Legend of Zelda: Tears of the Kingdom (Switch, base game v0 + update 1.4.3 = v720896). In bring-up
# Nintendo EPD's engine (sead / agl / gsys, NintendoWare G3d2 / Ui2d / Vfx2, Havok), SDK 20.5.22, NVN; modules main + subsdk0 (NintendoSDK_movie) + sdk.
# subsdk0 and sdk are the same builds as Breath of the Wild 1.9.0's. Most RomFS files are zstd with dictionaries (*.zs; the dictionaries are Pack/ZsDic.pack.zs).
# Shaders: Shader/*.bfsha.zs (BNSH; material.bfsha holds most) and the layout shaders in Shader/ApplicationPackage.Nin_NX_NVN.release.sarc.zs.
# main imports nn::ro (loads NRO modules at run time). Values marked "Breath of the Wild's" are not measured for this game yet

# ---- Identity ----
title_id	0100F2C0115B6000
program_id	0100F2C0115B6000

# ---- App ----
name	The Legend of Zelda: Tears of the Kingdom
ipa	ZeldaTearsOfTheKingdom.ipa
app_category	public.app-category.adventure-games
# the virtual gamepad starts in the 3D layout (D-pad, right stick, L3 / R3): the right stick turns the camera
pad_layout	full

# ---- Versions ----
# 1.4.2 (v655360) has its own frame step sites in patches.py; it is packed from a profile derived from it (its own shaders: these tables were made from 1.4.3's files)
build	v720896	1.4.3	main=277178b7dba1b6d4949a84778d4abc58	subsdk0=f39f4c431234c72eb520cfdd1001bbcf	sdk=574284b40c06cf1821a44857939083be
build	v655360	1.4.2	main=5cb42b1cf25469fb0635fd046453d843	subsdk0=3308c1d216f788397d1451c8345a16cd	sdk=5cf080e800530a7f25bd528ec875c27b
package	v720896
shader_versions	v720896

# ---- Files ----
modules	main subsdk0 sdk
romfs_marker	Pack/ZsDic.pack.zs
zip_store	.zs:.bwav:.mc:.webm:.metallib

# ---- Memory ----
# The NPDM declares 24 MB of system resource, so IsVirtualAddressMemoryEnabled is true and the game's memory lives in the alias region (as Engage's, see 0100A6301214E000/game.tsv).
# The game also calls SetHeapSize(0x86000000) in nninitStartup (2.1 GB of the pool as its heap; a 2 GB heap region aborts there with 0xd401).
# What it can map is bounded by the pool less the heap (1.1 GB). The sdk build's node area is cut from ~1 GB to 62 MB (dm/tools/sdk_patches.py): measured on the Mac, the alias region is then used
# up to +1.75 GB on the Great Sky Island with 1.0 GB mapped. Without the cut it reached +2.25 GB at the first descent and the game took a memory shortage (MSF, a Blood Moon that puts Link back, issue #70).
# So 5 GB, the total proven on a phone (one reservation of at most 6 GB without the extended virtual addressing entitlement): 256 MB in front + 2.375 GB alias region + 256 MB stack region + 2.125 GB heap region
mem_reserve	0x140000000
mem_alias	0x98000000
mem_stack	0x10000000
app_pool	0xCD500000

# ---- Graphics ----
# Streamed textures are written by the CPU straight into pool memory (already in GPU layout) and published with nvnMemoryPoolFlushMappedRange (hle_nvn.c ft_add)
tex_flush_upload	on
# BC textures on GPUs without BC support (A15/A16 and older): decode them on the CPU into
# RGBA8 (nvn_bcdec.c). No effect on Macs and A19+ devices, which keep the GPU path.
tex_bc_cpu	on
render_cond	on
tex_dirty_upload	on
# 60 fps (30 on the Switch): the host decides each frame's step in whole vsyncs and holds the frame that long (rewriter stubs at FPSLocker's sites, patches.py FRAME_STEP);
# 30 when 60 does not hold, game time = real time. DM_FPS_TARGET=30 (Documents/env.txt on the iPhone) saves power, 0 = the game's own step. Until the host has decided a step
# (the first frames) the stub steps by the measured frame time
fps_target	60

# ---- Shader split (shader_split.py) ----
shader_groups	/Shader/ApplicationPackage=layout /Shader/=shader /Effect/=effect /UI/=layout
shader_note	Tears of the Kingdom shaders
