modname "mod_aio_gex"
modversion "6.0.0"
modauthor "Jonaeru / Atari-Dude"

# ==========================================================================
# mod_aio_gex
#
# DERIVED WORK - NOT ORIGINAL. Generated by tools/aio/layout.py from
# the Perfect Dark All in One 6.0 distribution (pd-aio-6.0), for the fojo
# modloader. It carries mod_gex's level data and textures.
#
# Left out of this mod: the 167 C* / 69 G* models and 3 sequences every pack ships (see mod_aio_characters).
#
# Every credit and revision-history line from the source modconfig(s) is
# reproduced below unaltered. The level, model and texture work is the
# original authors'.
# ==========================================================================

# --- begin text carried over verbatim from pd-aio-6.0/mod_gex/modconfig.txt ---
# GoldenEye X Multiplayer Mod for All in One Mod v10
# Author: Jonaeru / Atari-Dude

# GoldenEye X by Wreck
# http://n64vault.com/pd-multi-levels:goldeneye-x

# Paradox by TimEh
# http://n64vault.com/ge-multi-levels:paradox-1-1

# Rogue Control Center by EternallyAries
# https://n64vault.com/ge-multi-levels:rogue-control-center

# Grand Library by EternallyAries

# Revision History
# v3: Added models for coexistence with Perfect Dark Plus Mod (September 1, 2024)
#     - CtestchrZ (Dr. Caroll Body/Head File)
#     - Pttb_boxZ (Dr. Caroll Hand File)
#     - PchrflashbangZ (Skedar Hand File)
#     - PdoorconsoleZ (Skedar Body/Head File)
#     - CheadgreyZ (Joanna Dark (JP version))
#     - Gm16Z (AR53 (AR33))
#     - Gmp5kZ (DMC (D5K))
#     - GskorpionZ (KLO1313 (KLOBB))
# v4: Renamed Skedar, Dr. Carroll Models (November 3, 2024)
#     CtestchrZ -> Ccarroll2Z
#     Pttb_boxZ -> Cskedar2Z
#     PchrflashbangZ -> Ghand_carollZ
#     PdoorconsoleZ -> Ghand_skedarZ
# v5: Fixed incorrectly displayed textures. Thank you so much, Atari-Dude. (November 29, 2024)
#     Added the model "Pdd_grateZ" (Train floor panel)
# v6: Added Cliff Base and Archive BZ from GoldenEye X 6a (January 26, 2025)
# v7: Removed Archives settings (February 8, 2025)
# v8: Extend stage table for GoldenEye X, and fix level IDs accordingly (March 1, 2025)
# v9: Replaced Skedar and Dr. Carroll Models last version by Wreck. Thank you so much, Wreck. (April 10, 2025)
#     Merged Atari-Dude mod files. Skedar model texture conflict resolved. Thank you so much, Atari-Dude.
# v10: Merged Atari-Dude mod files (July 20, 2025)

# Playable:
# - Temple
# - Complex
# - Caves
# - Library
# - Basement
# - Stack
# - Facility
# - Bunker
# - Archives
# - Caverns (broken water texture)
# - Egyptian
# - Facility BZ
# - Frigate
# - Archives BZ
# - Archives 1F (from GE-X 5e)
# - Streets
# - Train
# - Cradle
# - Aztec
# - Labyrinth
# - Icicle Pyramid
# - Ciff Base (broken water texture)

# Bunker
# --- end carried-over text ---

# --- stage declarations from tools/aio/stages/mod_aio_gex.txt (fojo-authored), re-slugged by slugmod ---
# --------------------------------------------------------------------------
# NOTE ON STAGE OWNERSHIP - read before adding stages here.
#
# A stage block is what claims a stage for this mod: modConfigParseStage
# writes g_ModStageNums[stagenum] = modnum (port/src/mod.c:1530), and both
# bg geometry texture loading (src/game/bg.c:3050) and the active-mod file
# search (port/src/romdata.c) key off that. On a stage this mod does NOT
# claim, its bgdata and its textures are not consulted at all.
#
# This mod ships level data that belongs to 63 stage(s) by vanilla file
# mapping, of which 3 are claimed by a stage block below. The stage
# blocks below claim 4 stage(s) in total. The 60 unclaimed stages are
# listed here so that the decision to claim them is a deliberate one -
# claiming a stage another mounted mod also claims is a silent
# last-write-wins:
#   0x5  STAGE_EXTRA1
#   0x6  STAGE_EXTRA2
#   0x7  STAGE_EXTRA3
#   0x8  STAGE_EXTRA4
#   0x9  STAGE_MAIANSOS
#   0xa  STAGE_EXTRA5
#   0xb  STAGE_EXTRA6
#   0xc  STAGE_EXTRA7
#   0xd  STAGE_EXTRA8
#   0xe  STAGE_EXTRA9
#   0xf  STAGE_EXTRA10
#   0x11  STAGE_EXTRA12
#   0x12  STAGE_EXTRA13
#   0x13  STAGE_EXTRA14
#   0x15  STAGE_EXTRA15
#   0x16  STAGE_WAR
#   0x17  STAGE_MP_RAVINE
#   0x19  STAGE_ESCAPE
#   0x1f  STAGE_MP_COMPLEX
#   0x20  STAGE_MP_G5BUILDING
#   0x22  STAGE_EXTRACTION
#   0x23  STAGE_TEST_RUN
#   0x25  STAGE_MP_TEMPLE
#   0x28  STAGE_28
#   0x29  STAGE_MP_PIPES
#   0x32  STAGE_MP_SKEDAR
#   0x34  STAGE_ATTACKSHIP
#   0x36  STAGE_TEST_LEN
#   0x39  STAGE_MP_BASE
#   0x3a  STAGE_TEST_MP2
#   0x3b  STAGE_MP_AREA52
#   0x3c  STAGE_MP_WAREHOUSE
#   0x3d  STAGE_MP_CARPARK
#   0x3e  STAGE_TEST_MP6
#   0x3f  STAGE_TEST_MP7
#   0x40  STAGE_TEST_MP8
#   0x41  STAGE_MP_RUINS
#   0x42  STAGE_MP_SEWERS
#   0x43  STAGE_MP_FELICITY
#   0x44  STAGE_MP_FORTRESS
#   0x45  STAGE_MP_VILLA
#   0x46  STAGE_TEST_MP14
#   0x47  STAGE_MP_GRID
#   0x48  STAGE_TEST_MP16
#   0x4a  STAGE_TEST_MP18
#   0x4b  STAGE_TEST_MP19
#   0x4c  STAGE_TEST_MP20
#   0x4e  STAGE_TEST_OLD
#   0x50  STAGE_TEST_LAM
#   0x51  STAGE_EXTRA16
#   0x52  STAGE_EXTRA17
#   0x53  STAGE_EXTRA18
#   0x54  STAGE_EXTRA19
#   0x55  STAGE_EXTRA20
#   0x56  STAGE_EXTRA21
#   0x57  STAGE_EXTRA22
#   0x58  STAGE_EXTRA23
#   0x59  STAGE_EXTRA24
#   0x5a  STAGE_EXTRA25
#   0x5b  STAGE_EXTRA26
# --------------------------------------------------------------------------

stage "gex_mp6" {
  # Bunker. bg_mp6.seg is a 512-byte stub, so the geometry is bg_tra's; the
  # level is the mp6 pads and setup on top of it. Was `stage 0x10` (the row
  # AIO parked it on); now the loader places it and every row-keyed value it
  # needs travels with it, so the row no longer matters.
  bgfile "bgdata/bg_tra_aio_gex.seg"
  tilesfile "bgdata/bg_tra_tiles_aio_gexZ"
  padsfile "bgdata/bg_mp6_pads_aio_gexZ"
  mpsetupfile "Ump_setupmp6_aio_gexZ"
  kind mp
  arenaname "Bunker"
  # from AIO's STAGE_EXTRA11 row: lang.c:226, pdmain.c:190, env.c:185
  langbank MP6
  allocation "-ml0 -me0 -mgfx200 -mvtx200 -ma400"
  env {
    near 15
    far 20000
    distfade 0 0 0
    sky 0x000000
    suns none
    clouds 0 5000 0 0x1e1e1e
    water 0 -5000 0 0x000000
    cloudsheight 0
    transparency 0
  }
}

# Facility BZ
stage "gex_mp17" {
  # Facility BZ. bg_mp17.seg is a 512-byte stub, so the geometry is bg_mp5's;
  # the level is the mp17 pads and setup on top of it. Was `stage 0x49`
  # (STAGE_TEST_MP17, the row AIO parked it on); now the loader places it.
  bgfile "bgdata/bg_mp5_aio_gex.seg"
  tilesfile "bgdata/bg_mp5_tiles_aio_gexZ"
  padsfile "bgdata/bg_mp17_pads_aio_gexZ"
  mpsetupfile "Ump_setupmp17_aio_gexZ"
  kind mp
  arenaname "Facility BZ"
  # from AIO's STAGE_TEST_MP17 row: lang.c:213 MP17, pdmain.c:166; its env
  # row is N64-only (env.c:174) so on PC it ran the default sky, as here
  langbank MP17
  allocation "-ml0 -me0 -mgfx200 -mvtx200 -ma400"
}

# Train
stage "gex_cryp" {
  # Train. bg_cryp.seg is a 512-byte stub, so the geometry is bg_run's; the
  # level is the cryp pads and setup on top of it. Was `stage 0x07` (the row
  # AIO parked it on); now the loader places it.
  bgfile "bgdata/bg_run_aio_gex.seg"
  tilesfile "bgdata/bg_run_tiles_aio_gexZ"
  padsfile "bgdata/bg_cryp_pads_aio_gexZ"
  mpsetupfile "Ump_setupcryp_aio_gexZ"
  kind mp
  arenaname "Train"
  # from AIO's STAGE_EXTRA3 row: lang.c:218 CRYP, pdmain.c:182; no env row
  langbank CRYP
  allocation "-ml0 -me0 -mgfx200 -mvtx200 -ma400"
}

# Archives 1F (from GE-X 5e)
stage "STAGE_TEST_SILO" {
  bgfile "bgdata/bg_silo_aio_gex.seg"
  tilesfile "bgdata/bg_silo_tiles_aio_gexZ"
  padsfile "bgdata/bg_silo_pads_aio_gexZ"
  # All three geometry keys are redirected to the silo set, which this mod
  # ships; Ump_setupsiloZ (12 spawns, 4 case points, 5 hills) ships here too.
  # Not in g_MpArenas_Vanilla and not in g_SoloStages, so it is unreachable
  # until something lists it. The mod supplies a complete MP setup, so list it.
  kind mp
  arenaname "Archives 1F"
  # lifted 2026-09-20 (lift-out/lift.py rule 3d): langbank lang.c:213 (STAGE_TEST_SILO -> LANGBANK_SILO); allocation pdmain.c:164 (STAGE_TEST_SILO)
  langbank SILO
  allocation "-ml0 -me0 -mgfx200 -mvtx200 -ma400"
}


# --------------------------------------------------------------------------
# STAGE DECLARATIONS ADDED WITH THE SLUG CONVERSION
#
# Every file in this mod now carries the mod's slug in its name and its path,
# and every manifest entry declares `source: self`. That is what stops two
# mods claiming one relative path - and it also means the loose-file walk no
# longer hands this mod's geometry to a stage row the mod never declared. A
# row this mod was dressing by path alone draws vanilla from here on unless
# it is declared below: modConfigParseStage writing g_ModStageNums[stagenum]
# is the only thing that makes this mod's level data and textures reachable
# (port/src/mod.c:2436).
#
# One block per row whose whole vanilla file set is the level this mod ships
# - bg, tiles, pads and setup all name the same level, so bg_mp8.seg is
# STAGE_TEST_MP8's own geometry and STAGE_TEST_MP8 is declared. Rows that
# merely reuse that geometry are NOT declared here; nor is a row two mods
# both ship the primary geometry for. Both sets are listed, with counts, in
# stage-extra-rows.md at the umbrella root.
#
# Only keys this mod actually ships are named. A key left out keeps the stage
# row's vanilla file, which is what it resolved to before.
#
# Twenty of these rows now carry `kind mp` and an `arenaname` - see the
# COMBAT SIMULATOR REGISTRATION block immediately below, which is where the
# names came from and what the list becomes. STAGE_TEST_RUN is deliberately
# not one of them; it ships no mpsetupfile.
# --------------------------------------------------------------------------


# --------------------------------------------------------------------------
# COMBAT SIMULATOR REGISTRATION
#
# catherine: "now I'd like to register these mp arenas in the combat
# simulator. the friendly strings can just be best guess (slug or nickname if
# we have it)".
#
# TEN OF THE TWENTY ARE RENAMES, NOT NEW ROWS. mpArenasRebuild
# (src/game/mplayer/setup.c:256-261) looks each registered stagenum up in
# g_MpArenas_Vanilla first; a hit writes `arenaname` into that row's
# customname and appends nothing, because appending would list the stage
# twice. Ten of these rows ARE vanilla Combat Simulator arenas whose geometry
# this mod replaces, so the vanilla names go away and the GoldenEye X names
# take their place:
#
#   STAGE_MP_SKEDAR     "Skedar"    -> "Temple"
#   STAGE_MP_PIPES      "Pipes"     -> "Aztec"
#   STAGE_MP_SEWERS     "Sewers"    -> "Basement"
#   STAGE_MP_WAREHOUSE  "Warehouse" -> "Library"
#   STAGE_MP_RUINS      "Ruins"     -> "Caverns"
#   STAGE_MP_AREA52     "Area 52"   -> "Caves"
#   STAGE_MP_FORTRESS   "Fortress"  -> "Stack"
#   STAGE_MP_CARPARK    "Car Park"  -> "Facility"
#   STAGE_MP_TEMPLE     "Temple"    -> "Archives"
#   STAGE_MP_FELICITY   "Felicity"  -> "Egyptian"
#
# That is not a naming choice. On those ten rows bgfile/tilesfile/padsfile/
# mpsetupfile all point at this mod's level, so the vanilla arena is not
# reachable any more whatever the row is called. Six vanilla arenas are left
# untouched: Ravine, G5 Building, Grid, Base, Villa, Complex.
#
# The other ten APPEND. Combined with the four blocks at the top of this file
# that already had `kind mp`, this mod contributes 14 appended rows.
#
# WHERE THE NAMES CAME FROM. This mod ships no L* lang file of its own, so the
# pack's names live in mod_aio_stages' LmpmenuE_aio (1173, 5-byte header, raw
# deflate; 496 slots) - 48 of those slots are rewritten against
# src/assets/ntsc-final/lang/mpmenu.json, and the rewritten block at
# L_MPMENU_296..338 is the GoldenEye X / Zelda / Dark Noon / Goldfinger arena
# names. Which name goes with which stagenum is not guessable from that block
# alone, so it was read out of the pack's own shipped binary,
# PD_AIO_March_2026/pd.exe:
#
#   - its arena table at file offset 0x215440 - 75 rows of
#     {s16 stagenum, u8 requirefeature, u16 langid}, ending on the Random row
#     (stagenum 1, L_MPMENU_136), with the vanilla 16 at the front in vanilla
#     order. The four blocks at the top of this file are rows 39, 43, 45 and
#     48 of it and agree exactly: 0x10 Bunker, 0x49 Facility BZ, 0x07 Train,
#     0x14 Archives 1F.
#   - its stage table at file offset 0x217ec0 - 88 rows of
#     sizeof(stagetableentry)==60, giving stagenum -> bg/tiles/pads/mpsetup
#     file ids. The pack extended that table for GoldenEye X, so a GEX level
#     usually sits on a STAGE_EXTRA* stagenum whose bg file id is the same one
#     the vanilla row uses. That file id is the join: bg_oat is this mod's
#     bg_oat_gex.seg, the pack's stagenum 0x0b also reads bg_oat, and the
#     pack calls 0x0b "Temple" - so bg_oat_gex.seg is GoldenEye X's Temple,
#     whatever row it is declared on here.
#
# The 22 names this resolves to are exactly the 22 in the "# Playable:" list
# carried over from the source modconfig above, which is the cross-check.
#
# FOUR ARE SLUG PLACEHOLDERS, PENDING A HUMAN PASS. The pack lists no arena at
# all for bg_cat, bg_len and bg_old - no row of its arena table reaches
# stagenum 0x28, 0x36 or 0x4e - and its bg_mp7 row (0x3f) is named "Valley",
# which README.txt credits to Dark Noon; mod_dark_noon ships its own,
# different bg_mp7.seg (different md5), so "Valley" is not this mod's level.
# Those four get a lowercase slug with a `_gex` marker - cat_gex, len_gex,
# old_gex, mp7_gex - the same convention the aio pass settled on. A slug reads
# as provisional in the menu, which is the point. They are named after the
# geometry file rather than after the vanilla level of that row on purpose:
# the vanilla level is NOT what is in there.
#
# DO NOT DELETE AN `arenaname` TO TIDY IT AWAY. A `kind mp` row with no
# arenaname draws NULL, not a fallback name. modConfigParseStage records the
# stage with the langid argument HARD-CODED 0 (port/src/mod.c:2615) and no
# modconfig key sets it; mpArenasRebuild copies that into the appended
# mparena, and the menu does `if (customname) return customname; return
# langGet(name)` (src/game/mplayer/setup.c:532-535). langGet(0) is bank 0
# index 0, g_LangFiles[0] is 0 (src/game/lang.c:75), so bank 0 is never loaded
# and it returns NULL. The string is the only thing keeping that path from
# being taken. Rename them; do not remove them.
#
# THE MEMORY BUDGET, PER ROW. g_StageAllocations8Mb (src/lib/main.c:90) is
# keyed by stagenum. Checked all twenty: nineteen have their own row, which is
# the difference from the aio pass - these are real arena rows, not
# STAGE_EXTRA* ones. Two to watch:
#
#   STAGE_EXTRA16 has NO row. It falls off the end onto the terminator,
#   `-ml0 -me0 -mgfx120 -mvtx98 -ma300`, the smallest budget in the table, and
#   an `allocation` key cannot fix it - mod.c:2534 refuses it for a stage with
#   no row there and says so in the log.
#
#   STAGE_TEST_LEN has a row, but it is `-ml0 -me0 -mgfx120 -mvtx98 -ma300` -
#   the same smallest budget. Its setup is the largest of the twenty at 19
#   spawns.
#
#   The other eighteen are `-mgfx200 -mvtx200 -ma400` (the vanilla arena
#   budget) except STAGE_28 and STAGE_TEST_OLD, which are
#   `-ml0 -me0 -mgfx120 -mvtx98 -ma400`.
#
# IF ONE OF THESE FALLS OVER, LOOK THERE FIRST. Never played: there is no
# cmake and no SDL2 in this workspace, so nothing below was built or run.
#
# STAGENUMS. All twenty are <= 0x7f, the highest being STAGE_EXTRA16 at 0x51.
# g_MpSetup.stagenum is persisted in 7 bits (mplayer.c:4692 write, :4615 read)
# with no clamp on the way back, so a stagenum over 127 would come back
# truncated. None of these can hit that.
#
# Every block names the stage by its STAGE_* spelling, never a bare number.
# `stage <n>` numerically is a STAGENUM, not a g_Stages row index, and the
# name form resolves through stageGetIndexByName (mod.c:2411) and cannot be
# read the wrong way.
#
# Spawn counts below are read out of each Ump_setup*_gexZ by walking the intro
# list the way src/game/mplayer/scenarios.c:851 does. The method was checked
# against mod_aio_stages' Ump_setuparch_aioZ, which the Suburb block there
# records as "12 spawns, 4 case points, 6 hills"; the walk reads exactly that.
# No block below has an empty setup - the lowest is 12 spawns.
# --------------------------------------------------------------------------

# row 0x0f, stagenum 0x23 - run
# NOT DECLARED `kind mp`, on purpose. It is the one block here with no
# mpsetupfile: this mod ships no Ump_setuprun_gexZ, so there is nothing to
# override the stage row's vanilla Ump_setuprunZ with, and the geometry it
# does ship is a GoldenEye X level whose spawn pads are not the vanilla run
# setup's. Listing it would put an arena in the menu with spawns that belong
# to a different map. It stays a geometry-only declaration.
stage "STAGE_TEST_RUN" {
  bgfile "bgdata/bg_run_aio_gex.seg"
  tilesfile "bgdata/bg_run_tiles_aio_gexZ"
  padsfile "bgdata/bg_run_pads_aio_gexZ"
  # lifted 2026-09-20 (lift-out/lift.py rule 3d): langbank lang.c:155 (STAGE_TEST_RUN -> LANGBANK_RUN); allocation pdmain.c:150 (STAGE_TEST_RUN); env env.c:123 (STAGE_TEST_RUN nofog)
  langbank RUN
  allocation "-ml0 -me0 -mgfx200 -mvtx200 -ma400"
  env {
    near 15
    far 10000
    distfade 0 0 0
    sky 0x000000
    suns none
    clouds 0 5000 0 0x3a1100
    water 0 0 0 0x000000
    cloudsheight 0
    transparency 1
  }
}

# row 0x11, stagenum 0x25 - jun
# GoldenEye X "Archives". Pack name: its arena table gives stagenum 0x08
# L_MPMENU_299 "Archives", and the pack's stage row 0x08 reads bg_jun -
# this mod's bg_jun_gex.seg.
# Ump_setupjun_gexZ: 12 spawns, 4 case points, 5 hills.
# RENAME: 0x25 is in g_MpArenas_Vanilla, so this overwrites the "Temple"
# row rather than adding one.
stage "gex_jun" {
  bgfile "bgdata/bg_jun_aio_gex.seg"
  tilesfile "bgdata/bg_jun_tiles_aio_gexZ"
  padsfile "bgdata/bg_jun_pads_aio_gexZ"
  mpsetupfile "Ump_setupjun_aio_gexZ"
  kind mp
  arenaname "Archives"
  # lifted 2026-09-20 (lift-out/lift.py rule 3a): langbank lang.c:219 (STAGE_EXTRA4 -> LANGBANK_JUN); allocation pdmain.c:183 (STAGE_EXTRA4)
  langbank JUN
  allocation "-ml0 -me0 -mgfx200 -mvtx200 -ma400"
}

# row 0x14, stagenum 0x28 - cat
# PLACEHOLDER NAME. The pack lists no arena on stagenum 0x28 and no row of
# its arena table reads bg_cat, so it never names this level. Slugged after
# the geometry file, not after vanilla STAGE_28, because the vanilla level
# is not what is in there.
# Ump_setupcat_gexZ: 13 spawns, 4 case points, 5 hills.
# APPEND. Allocation row exists: -ml0 -me0 -mgfx120 -mvtx98 -ma400.
stage "STAGE_28" {
  bgfile "bgdata/bg_cat_aio_gex.seg"
  tilesfile "bgdata/bg_cat_tiles_aio_gexZ"
  padsfile "bgdata/bg_cat_pads_aio_gexZ"
  mpsetupfile "Ump_setupcat_aio_gexZ"
  kind mp
  arenaname "Arctic Mine"   # was "Snow Cavern?"; row 0x57 STAGE_EXTRA27; only mod_gex ships bg_cat
  # lifted 2026-09-20 (lift-out/lift.py rule 3d): langbank lang.c:180 (STAGE_28 -> LANGBANK_DAM); allocation pdmain.c:162 (STAGE_28)
  langbank DAM
  allocation "-ml0 -me0 -mgfx120 -mvtx98 -ma400"
}

# row 0x15, stagenum 0x29 - crad
# GoldenEye X "Aztec". Pack name: arena table stagenum 0x0a L_MPMENU_313
# "Aztec", stage row 0x0a reads bg_crad. mod_goldfinger_64 also ships a
# bg_crad.seg, a different file, which the pack lists separately as "Mall"
# on 0x57; this is the GoldenEye X one.
# Ump_setupcrad_gexZ: 12 spawns, 4 case points, 4 hills.
# RENAME: overwrites the vanilla "Pipes" row.
stage "gex_crad" {
  bgfile "bgdata/bg_crad_aio_gex.seg"
  tilesfile "bgdata/bg_crad_tiles_aio_gexZ"
  padsfile "bgdata/bg_crad_pads_aio_gexZ"
  mpsetupfile "Ump_setupcrad_aio_gexZ"
  kind mp
  arenaname "Aztec"
  # lifted 2026-09-20 (lift-out/lift.py rule 3a): langbank lang.c:220 (STAGE_EXTRA5 -> LANGBANK_CRAD); allocation pdmain.c:184 (STAGE_EXTRA5)
  langbank CRAD
  allocation "-ml0 -me0 -mgfx200 -mvtx200 -ma400"
}

# row 0x1e, stagenum 0x32 - oat
# GoldenEye X "Temple". Pack name: arena table stagenum 0x0b L_MPMENU_133
# "Temple", stage row 0x0b reads bg_oat.
# Ump_setupoat_gexZ: 12 spawns, 4 case points, 5 hills.
# RENAME: overwrites the vanilla "Skedar" row.
stage "gex_oat" {
  bgfile "bgdata/bg_oat_aio_gex.seg"
  tilesfile "bgdata/bg_oat_tiles_aio_gexZ"
  padsfile "bgdata/bg_oat_pads_aio_gexZ"
  mpsetupfile "Ump_setupoat_aio_gexZ"
  kind mp
  arenaname "Temple"
  # lifted 2026-09-20 (lift-out/lift.py rule 3a): langbank lang.c:221 (STAGE_EXTRA6 -> LANGBANK_OAT); allocation pdmain.c:185 (STAGE_EXTRA6); env env.c:73 (STAGE_EXTRA6 fog, 'Temple')
  langbank OAT
  allocation "-ml0 -me0 -mgfx200 -mvtx200 -ma400"
  env {
    fog 996 1000
    near 10
    far 6000
    distfade 0 0 0
    sky 0x181818
    suns none
    clouds 1 10000 0 0x787878
    water 0 -1000 0 0x000000
    cloudsheight 0
  }
}

# row 0x22, stagenum 0x36 - len
# PLACEHOLDER NAME. No row of the pack's arena table reaches stagenum 0x36
# or reads bg_len, so the pack never names this level.
# Ump_setuplen_gexZ: 19 spawns, 3 case points, 5 hills - the largest setup
# of the twenty, and the only one with three case points rather than four.
# APPEND. WATCH THE BUDGET: its g_StageAllocations8Mb row is
# -ml0 -me0 -mgfx120 -mvtx98 -ma300, the smallest in the table.
stage "STAGE_TEST_LEN" {
  bgfile "bgdata/bg_len_aio_gex.seg"
  tilesfile "bgdata/bg_len_tiles_aio_gexZ"
  padsfile "bgdata/bg_len_pads_aio_gexZ"
  mpsetupfile "Ump_setuplen_aio_gexZ"
  kind mp
  arenaname "Courtyard"   # was "Village Well?"; row 0x5a STAGE_EXTRA30; only mod_gex ships bg_len
  # lifted 2026-09-20 (lift-out/lift.py rule 3d): langbank lang.c:171 (STAGE_TEST_LEN -> LANGBANK_LEN); allocation pdmain.c:176 (STAGE_TEST_LEN); env env.c:112 (STAGE_TEST_LEN nofog)
  langbank LEN
  allocation "-ml0 -me0 -mgfx120 -mvtx98 -ma300"
  env {
    near 15
    far 10000
    distfade 0 0 0
    sky 0x304010
    suns none
    clouds 0 5000 0 0xffffff
    water 0 0 0 0x000000
    cloudsheight 0
    transparency 0
  }
}

# row 0x2b, stagenum 0x3b - mp3
# GoldenEye X "Caves". Pack name: arena table stagenum 0x0d L_MPMENU_306
# "Caves", stage row 0x0d reads bg_mp3. (The pack also has a second "Caves"
# on 0x3e/bg_mp6 - that one is Perfect Dark Plus's updated Caves and ships
# in mod_allinone, not here.)
# Ump_setupmp3_gexZ: 12 spawns, 4 case points, 4 hills.
# RENAME: overwrites the vanilla "Area 52" row.
stage "gex_mp3" {
  bgfile "bgdata/bg_mp3_aio_gex.seg"
  tilesfile "bgdata/bg_mp3_tiles_aio_gexZ"
  padsfile "bgdata/bg_mp3_pads_aio_gexZ"
  mpsetupfile "Ump_setupmp3_aio_gexZ"
  kind mp
  arenaname "Caves"
  # lifted 2026-09-20 (lift-out/lift.py rule 3a): langbank lang.c:223 (STAGE_EXTRA8 -> LANGBANK_MP3); allocation pdmain.c:187 (STAGE_EXTRA8); env env.c:182 (STAGE_EXTRA8 nofog, 'Caves')
  langbank MP3
  allocation "-ml0 -me0 -mgfx200 -mvtx200 -ma400"
  env {
    near 15
    far 10000
    distfade 0 0 0
    sky 0x000008
    suns none
    clouds 1 4500 0 0x46c7ba
    water 0 -5000 0 0x000000
    cloudsheight 0
    transparency 0
  }
}

# row 0x2c, stagenum 0x3c - mp4
# GoldenEye X "Library". Pack name: arena table stagenum 0x0e L_MPMENU_303
# "Library", stage row 0x0e reads bg_mp4.
# Ump_setupmp4_gexZ: 12 spawns, 4 case points, 6 hills.
# RENAME: overwrites the vanilla "Warehouse" row.
stage "gex_mp4" {
  bgfile "bgdata/bg_mp4_aio_gex.seg"
  tilesfile "bgdata/bg_mp4_tiles_aio_gexZ"
  padsfile "bgdata/bg_mp4_pads_aio_gexZ"
  mpsetupfile "Ump_setupmp4_aio_gexZ"
  kind mp
  arenaname "Library"
  # lifted 2026-09-20 (lift-out/lift.py rule 3a): langbank lang.c:224 (STAGE_EXTRA9 -> LANGBANK_MP4); allocation pdmain.c:188 (STAGE_EXTRA9); env env.c:183 (STAGE_EXTRA9 nofog, 'Library')
  langbank MP4
  allocation "-ml0 -me0 -mgfx200 -mvtx200 -ma400"
  env {
    near 15
    far 10000
    distfade 0 0 0
    sky 0x020000
    suns none
    clouds 1 5000 0 0x82aac8
    water 0 -5000 0 0x000000
    cloudsheight 0
    transparency 0
  }
}

# row 0x2d, stagenum 0x3d - mp5
# GoldenEye X "Facility". Pack name: arena table stagenum 0x0f L_MPMENU_311
# "Facility", stage row 0x0f reads bg_mp5. The "Facility BZ" block at the
# top of this file redirects to the same bg_mp5_gex.seg on purpose - BZ is
# the same geometry with a different setup.
# Ump_setupmp5_gexZ: 12 spawns, 4 case points, 5 hills.
# RENAME: overwrites the vanilla "Car Park" row.
stage "gex_mp5" {
  bgfile "bgdata/bg_mp5_aio_gex.seg"
  tilesfile "bgdata/bg_mp5_tiles_aio_gexZ"
  padsfile "bgdata/bg_mp5_pads_aio_gexZ"
  mpsetupfile "Ump_setupmp5_aio_gexZ"
  kind mp
  arenaname "Facility"
  # lifted 2026-09-20 (lift-out/lift.py rule 3a): langbank lang.c:225 (STAGE_EXTRA10 -> LANGBANK_MP5); allocation pdmain.c:189 (STAGE_EXTRA10); env env.c:184 (STAGE_EXTRA10 nofog, 'Facility')
  langbank MP5
  allocation "-ml0 -me0 -mgfx200 -mvtx200 -ma400"
  env {
    near 15
    far 10000
    distfade 0 0 0
    sky 0x000000
    suns none
    clouds 1 5500 0 0x64c886
    water 0 -5000 0 0x000000
    cloudsheight 0
    transparency 0
  }
}

# row 0x2f, stagenum 0x3f - mp7
# PLACEHOLDER NAME. The pack does name an arena on stagenum 0x3f -
# L_MPMENU_321 "Valley" - but README.txt credits Valley to Dark Noon and
# mod_dark_noon ships its own bg_mp7.seg with a different md5. No
# GoldenEye X group row reads bg_mp7, so the pack does not name THIS file.
# Ump_setupmp7_gexZ: 19 spawns, 4 case points, 4 hills.
# APPEND.
stage "STAGE_TEST_MP7" {
  bgfile "bgdata/bg_mp7_aio_gex.seg"
  tilesfile "bgdata/bg_mp7_tiles_aio_gexZ"
  padsfile "bgdata/bg_mp7_pads_aio_gexZ"
  mpsetupfile "Ump_setupmp7_aio_gexZ"
  kind mp
  arenaname "Frost Valley"   # was "Snowy Grove?"; row 0x5b STAGE_EXTRA31; dark_noon's mp7 is Valley
  # lifted 2026-09-20 (lift-out/lift.py rule 3d): langbank lang.c:198 (STAGE_TEST_MP7 -> LANGBANK_MP7); allocation pdmain.c:153 (STAGE_TEST_MP7); env env.c:160 (STAGE_TEST_MP7 nofog, 'Valley')
  langbank MP7
  allocation "-ml0 -me0 -mgfx200 -mvtx200 -ma400"
  env {
    near 10
    far 14096
    distfade 0 0 0
    sky 0x110015
    suns none
    clouds 0 3000 0 0x3a1100
    water 0 0 0 0x000000
    cloudsheight 0
    transparency 0
  }
}

# row 0x30, stagenum 0x40 - mp8
# GoldenEye X "Cliff Base". Pack name: arena table stagenum 0x40
# L_MPMENU_323 "Cliff Base", stage row 0x40 reads bg_mp8. The carried-over
# "# Playable:" list above flags it "(broken water texture)".
# Ump_setupmp8_gexZ: 12 spawns, 4 case points, 6 hills.
# APPEND.
stage "STAGE_TEST_MP8" {
  bgfile "bgdata/bg_mp8_aio_gex.seg"
  tilesfile "bgdata/bg_mp8_tiles_aio_gexZ"
  padsfile "bgdata/bg_mp8_pads_aio_gexZ"
  mpsetupfile "Ump_setupmp8_aio_gexZ"
  kind mp
  arenaname "Cliff Base"
  # lifted 2026-09-20 (lift-out/lift.py rule 3d): langbank lang.c:199 (STAGE_TEST_MP8 -> LANGBANK_MP8); allocation pdmain.c:154 (STAGE_TEST_MP8); env env.c:161 (STAGE_TEST_MP8 nofog, 'Cliff Base')
  langbank MP8
  allocation "-ml0 -me0 -mgfx200 -mvtx200 -ma400"
  env {
    near 15
    far 10000
    distfade 0 0 0
    sky 0x000000
    suns none
    clouds 0 5000 0 0xffffff
    water 0 -5000 0 0x000000
    cloudsheight 0
    transparency 0
  }
}

# row 0x31, stagenum 0x41 - mp9
# GoldenEye X "Caverns". Pack name: arena table stagenum 0x11 L_MPMENU_305
# "Caverns", stage row 0x11 reads bg_mp9. The carried-over "# Playable:"
# list above flags it "(broken water texture)".
# Ump_setupmp9_gexZ: 12 spawns, 4 case points, 6 hills.
# RENAME: overwrites the vanilla "Ruins" row.
stage "gex_mp9" {
  bgfile "bgdata/bg_mp9_aio_gex.seg"
  tilesfile "bgdata/bg_mp9_tiles_aio_gexZ"
  padsfile "bgdata/bg_mp9_pads_aio_gexZ"
  mpsetupfile "Ump_setupmp9_aio_gexZ"
  kind mp
  arenaname "Caverns"
  # lifted 2026-09-20 (lift-out/lift.py rule 3a): langbank lang.c:227 (STAGE_EXTRA12 -> LANGBANK_MP9); allocation pdmain.c:191 (STAGE_EXTRA12); env env.c:74 (STAGE_EXTRA12 fog, 'Caverns')
  langbank MP9
  allocation "-ml0 -me0 -mgfx200 -mvtx200 -ma400"
  env {
    fog 993 1000
    near 10
    far 6000
    distfade 0 0 0
    sky 0x080008
    suns none
    clouds 0 5000 0 0xffffff
    water 0 -3000 0 0x00ffff
    cloudsheight 0
  }
}

# row 0x32, stagenum 0x42 - mp10
# GoldenEye X "Basement". Pack name: arena table stagenum 0x12
# L_MPMENU_302 "Basement", stage row 0x12 reads bg_mp10.
# Ump_setupmp10_gexZ: 12 spawns, 4 case points, 5 hills.
# RENAME: overwrites the vanilla "Sewers" row.
stage "gex_mp10" {
  bgfile "bgdata/bg_mp10_aio_gex.seg"
  tilesfile "bgdata/bg_mp10_tiles_aio_gexZ"
  padsfile "bgdata/bg_mp10_pads_aio_gexZ"
  mpsetupfile "Ump_setupmp10_aio_gexZ"
  kind mp
  arenaname "Basement"
  # lifted 2026-09-20 (lift-out/lift.py rule 3a): langbank lang.c:228 (STAGE_EXTRA13 -> LANGBANK_MP10); allocation pdmain.c:192 (STAGE_EXTRA13)
  langbank MP10
  allocation "-ml0 -me0 -mgfx200 -mvtx200 -ma400"
}

# row 0x33, stagenum 0x43 - mp11
# GoldenEye X "Egyptian". Pack name: arena table stagenum 0x13
# L_MPMENU_312 "Egyptian", stage row 0x13 reads bg_mp11.
# mod_goldfinger_64 also ships a bg_mp11.seg, a different file, which the
# pack lists separately as "Junkyard" on 0x55.
# Ump_setupmp11_gexZ: 12 spawns, 4 case points, 5 hills.
# RENAME: overwrites the vanilla "Felicity" row.
stage "gex_mp11" {
  bgfile "bgdata/bg_mp11_aio_gex.seg"
  tilesfile "bgdata/bg_mp11_tiles_aio_gexZ"
  padsfile "bgdata/bg_mp11_pads_aio_gexZ"
  mpsetupfile "Ump_setupmp11_aio_gexZ"
  kind mp
  arenaname "Egyptian"
  # lifted 2026-09-20 (lift-out/lift.py rule 3a): langbank lang.c:229 (STAGE_EXTRA14 -> LANGBANK_MP11); allocation pdmain.c:193 (STAGE_EXTRA14); env env.c:75 (STAGE_EXTRA14 fog, 'Egyptian')
  langbank MP11
  allocation "-ml0 -me0 -mgfx200 -mvtx200 -ma400"
  env {
    fog 996 1000
    near 10
    far 20000
    distfade 3000 10000 1500
    sky 0x103060
    suns none
    clouds 1 5000 0 0xffffff
    water 0 -5000 0 0x000000
    cloudsheight 0
  }
}

# row 0x34, stagenum 0x44 - mp12
# GoldenEye X "Stack". Pack name: arena table stagenum 0x15 L_MPMENU_309
# "Stack", stage row 0x15 reads bg_mp12. (The pack has a second "Stack" on
# 0x3a/bg_mp2 - Perfect Dark Plus's updated Stack, in mod_allinone.)
# Ump_setupmp12_gexZ: 12 spawns, 4 case points, 5 hills.
# RENAME: overwrites the vanilla "Fortress" row.
stage "gex_mp12" {
  bgfile "bgdata/bg_mp12_aio_gex.seg"
  tilesfile "bgdata/bg_mp12_tiles_aio_gexZ"
  padsfile "bgdata/bg_mp12_pads_aio_gexZ"
  mpsetupfile "Ump_setupmp12_aio_gexZ"
  kind mp
  arenaname "Stack"
  # lifted 2026-09-20 (lift-out/lift.py rule 3a): langbank lang.c:230 (STAGE_EXTRA15 -> LANGBANK_MP12); allocation pdmain.c:194 (STAGE_EXTRA15)
  langbank MP12
  allocation "-ml0 -me0 -mgfx200 -mvtx200 -ma400"
}

# row 0x36, stagenum 0x46 - mp14
# GoldenEye X "Streets". Pack name: arena table stagenum 0x46
# L_MPMENU_315 "Streets", stage row 0x46 reads bg_mp14.
# Ump_setupmp14_gexZ: 12 spawns, 4 case points, 5 hills.
# APPEND.
stage "STAGE_TEST_MP14" {
  bgfile "bgdata/bg_mp14_aio_gex.seg"
  tilesfile "bgdata/bg_mp14_tiles_aio_gexZ"
  padsfile "bgdata/bg_mp14_pads_aio_gexZ"
  mpsetupfile "Ump_setupmp14_aio_gexZ"
  kind mp
  arenaname "Streets"
  # lifted 2026-09-20 (lift-out/lift.py rule 3d): langbank lang.c:205 (STAGE_TEST_MP14 -> LANGBANK_MP14); allocation pdmain.c:155 (STAGE_TEST_MP14); env env.c:76 (STAGE_TEST_MP14 fog, 'Streets (Fixed far from 7500 to 20000, clouds_height from 25 to 0)')
  langbank MP14
  allocation "-ml0 -me0 -mgfx200 -mvtx200 -ma400"
  env {
    fog 996 1000
    near 10
    far 20000
    distfade 5000 6000 1000
    sky 0x101820
    suns none
    clouds 1 5000 0 0xe1af64
    water 0 -1000 0 0x000000
    cloudsheight 0
  }
}

# row 0x38, stagenum 0x48 - mp16
# GoldenEye X "Archives BZ". Pack name: arena table stagenum 0x48
# L_MPMENU_322 "Archives BZ", stage row 0x48 reads bg_mp16. Added in the
# source mod's v6, "Added Cliff Base and Archive BZ from GoldenEye X 6a".
# Ump_setupmp16_gexZ: 12 spawns, 4 case points, 6 hills.
# APPEND.
stage "STAGE_TEST_MP16" {
  bgfile "bgdata/bg_mp16_aio_gex.seg"
  tilesfile "bgdata/bg_mp16_tiles_aio_gexZ"
  padsfile "bgdata/bg_mp16_pads_aio_gexZ"
  mpsetupfile "Ump_setupmp16_aio_gexZ"
  kind mp
  arenaname "Archives BZ"
  # lifted 2026-09-20 (lift-out/lift.py rule 3d): langbank lang.c:207 (STAGE_TEST_MP16 -> LANGBANK_MP16); allocation pdmain.c:156 (STAGE_TEST_MP16); env env.c:172 (STAGE_TEST_MP16 nofog)
  langbank MP16
  allocation "-ml0 -me0 -mgfx200 -mvtx200 -ma400"
  env {
    near 15
    far 20000
    distfade 0 0 0
    sky 0x000000
    suns none
    clouds 0 5000 0 0x1e1e1e
    water 0 -5000 0 0x000000
    cloudsheight 0
    transparency 0
  }
}

# row 0x3a, stagenum 0x4a - mp18
# GoldenEye X "Cradle". Pack name: arena table stagenum 0x4a L_MPMENU_304
# "Cradle", stage row 0x4a reads bg_mp18.
# Ump_setupmp18_gexZ: 12 spawns, 4 case points, 5 hills.
# APPEND.
stage "STAGE_TEST_MP18" {
  bgfile "bgdata/bg_mp18_aio_gex.seg"
  tilesfile "bgdata/bg_mp18_tiles_aio_gexZ"
  padsfile "bgdata/bg_mp18_pads_aio_gexZ"
  mpsetupfile "Ump_setupmp18_aio_gexZ"
  kind mp
  arenaname "Cradle"
  # lifted 2026-09-20 (lift-out/lift.py rule 3d): langbank lang.c:209 (STAGE_TEST_MP18 -> LANGBANK_MP18); allocation pdmain.c:158 (STAGE_TEST_MP18); env env.c:77 (STAGE_TEST_MP18 fog, 'Cradle')
  langbank MP18
  allocation "-ml0 -me0 -mgfx200 -mvtx200 -ma400"
  env {
    fog 996 1000
    near 10
    far 9500
    distfade 3333 4444 800
    sky 0x6080a0
    suns none
    clouds 1 5000 0 0xffff00
    water 0 -10000 0 0x000000
    cloudsheight 0
  }
}

# row 0x3b, stagenum 0x4b - mp19
# GoldenEye X "Labyrinth". Pack name: arena table stagenum 0x4b
# L_MPMENU_301 "Labyrinth", stage row 0x4b reads bg_mp19.
# Ump_setupmp19_gexZ: 12 spawns, 4 case points, 5 hills.
# APPEND.
stage "STAGE_TEST_MP19" {
  bgfile "bgdata/bg_mp19_aio_gex.seg"
  tilesfile "bgdata/bg_mp19_tiles_aio_gexZ"
  padsfile "bgdata/bg_mp19_pads_aio_gexZ"
  mpsetupfile "Ump_setupmp19_aio_gexZ"
  kind mp
  arenaname "Labyrinth"
  # lifted 2026-09-20 (lift-out/lift.py rule 3d): langbank lang.c:210 (STAGE_TEST_MP19 -> LANGBANK_MP19); allocation pdmain.c:159 (STAGE_TEST_MP19); env env.c:78 (STAGE_TEST_MP19 fog, 'Labyrinth')
  langbank MP19
  allocation "-ml0 -me0 -mgfx200 -mvtx200 -ma400"
  env {
    fog 996 1000
    near 10
    far 6000
    distfade 0 0 0
    sky 0x103060
    suns none
    clouds 1 5000 0 0xffffff
    water 0 -1000 0 0x000000
    cloudsheight 0
  }
}

# row 0x4c, stagenum 0x51 - ark
# "Runway". Pack name: arena table stagenum 0x51 L_MPMENU_327 "Runway",
# under the pack's "Bonus" group header (L_MPMENU_326); the pack's stage
# row 0x51 reads bg_ark, and of the five mods in PD_AIO_March_2026 this is
# the only one shipping a bg_ark.seg, so the row is fed from here.
# README.txt: "Runway and Control setups based on StupidMarioBros1Fan's GE
# setups". Not in the carried-over "# Playable:" list, which covers only
# the 22 GoldenEye X arenas.
# Ump_setupark_gexZ: 15 spawns, 4 case points, 6 hills.
# APPEND. WATCH THE BUDGET: this is the one row of the twenty with NO
# g_StageAllocations8Mb row (src/lib/main.c:90 has none for any
# STAGE_EXTRA*), so it takes the table terminator's
# -ml0 -me0 -mgfx120 -mvtx98 -ma300 and an `allocation` key is refused
# (mod.c:2534).
stage "gex_ark" {
  bgfile "bgdata/bg_ark_aio_gex.seg"
  tilesfile "bgdata/bg_ark_tiles_aio_gexZ"
  padsfile "bgdata/bg_ark_pads_aio_gexZ"
  mpsetupfile "Ump_setupark_aio_gexZ"
  kind mp
  arenaname "Runway"
  # lifted 2026-09-20 (lift-out/lift.py rule 3a): langbank lang.c:231 (STAGE_EXTRA16 -> LANGBANK_ARK); allocation pdmain.c:195 (STAGE_EXTRA16); env env.c:80 (STAGE_EXTRA16 fog, 'Runway (Fixed far from 15000 to 30000, clouds_height from 30 to 0)')
  langbank ARK
  allocation "-ml0 -me0 -mgfx110 -mgfxtra80 -mvtx100 -ma700"
  env {
    fog 996 1000
    near 10
    far 30000
    distfade 6000 8000 800
    sky 0x103040
    suns area51
    clouds 1 5000 0 0x191919
    water 0 0 0 0x000000
    cloudsheight 0
  }
}


# --------------------------------------------------------------------------
# MODEL SCALES
#
# Ported from jonaeru's GoldenEye X build (github.com/jonaeru/perfect_dark,
# branch allinone-latest). That tree carries a second full copy of
# g_ModelStates called g_GexModelStates, 443 rows, at
# src/game/modeldata/general.c:854, under `#ifndef PLATFORM_N64`. Diffed
# against the vanilla table in the same file it is 19 rows different, every
# one of them `scale 0x1000 -> 0x0199`, and not one `file` field differs.
# Those 19 rows are what this block reproduces. The work is jonaeru's; only
# the mechanism is ours.
#
# WHY IT IS NEEDED AT ALL. objInitWithModelDef gives every prop
# g_ModelStates[modelnum].scale * (1/4096) (src/game/propobj.c:2129) and that
# is the only scale the renderer has for it. A stage mod that replaces a
# vanilla prop MODEL does not replace the vanilla row of that table, so it
# inherits a scale chosen for a model it is not shipping. Measured over the
# files in this basedir, 78 of 128 replaced prop models differ from the
# vanilla model they replace by more than 50% of its size.
#
# WHY WE DO NOT NEED A SECOND TABLE. modConfigParseModelStates
# (port/src/mod.c:1175) already writes g_ModelStates[n].scale per mod,
# modCacheAllConfigs caches the result per mod, and modSwitch memcpys the
# right one in (port/src/mod.c:3516). No shipped modconfig had ever declared
# a ModelStates block, so this is the first exercise of it.
#
# THE LITERAL IS NOT 0.1, AND THE NEAR MISSES ARE SILENT.
# modConfigParseModelStates stores (u16)(scale * 4096.0f) - a truncation
# toward zero, not a round (port/src/mod.c:1222). Measured with strtof and
# the same cast:
#   0.09985            -> 408.9856  -> 408  = 0x0198   WRONG, and silent
#   0.099853515625     -> 409.0     -> 409  = 0x0199   what we want
#   0.1                -> 409.6001  -> 409  = 0x0199   right answer, by luck
# 0.099853515625 is exactly 409/4096. It is a dyadic rational with a 9-bit
# significand, so strtof returns it exactly, multiplying it by 4096.0f is an
# exact power-of-two scaling, and the cast has nothing to round away. It is
# the only literal in that list that is true rather than lucky.
#
# ALL 19 ARE MODELS THIS MOD SHIPS A REPLACEMENT FOR. Checked against
# mod_gex_stages_filetable.json: every one of the 19 has a `replaces` entry
# here (Pa51_crate1Z -> Pa51_crate1_gexZ, and so on). Nothing was dropped,
# and nothing was added. Declaring a scale for a model this mod does NOT
# replace would shrink a *vanilla* prop in these stages by 10x, which is a
# new bug rather than a fix.
#
# 0x0199 IS NOT AN ODD NUMBER FOR THIS TABLE. 152 rows of vanilla
# g_ModelStates already carry 0x0199; 281 carry 0x1000. The port moves these
# 19 from the one common value to the other.
#
# A BAD VALUE HERE COSTS EVERYTHING AFTER IT. modConfigParseModelStates
# returns NULL on a malformed model id, a missing brace or a scale <= 0;
# modConfigLoad then sets success = false and breaks out of its parse loop
# (port/src/mod.c:3015-3025). There is no rollback, so what has already been
# applied stays applied and everything further down the file is abandoned.
# That is why this block sits LAST: a typo here cannot cost the 25 stage
# declarations above it. Keep it last, and do not hand-edit a value without
# re-reading that path.
#
# RE-PARSING IS SAFE. `Scale` assigns, it does not accumulate, and
# modConfigLoad memcpys g_ModelStatesOriginal back over g_ModelStates before
# every parse (port/src/mod.c:2906). The block is skipped outright while
# g_MainIsBooting is set, so the boot-time passes do nothing; the pass that
# takes is modCacheAllConfigs, which mainProc calls after mainInit has
# cleared the flag (port/src/pdmain.c:344, :353).
#
# Comment is `#` to end of line, `{` and `}` are their own tokens, the model
# id goes through strtol(base 0) so 0x… is read as hex, and `Scale` is
# matched case-insensitively. Do not put a comma in here: `,` is a token
# separator (port/src/utils.c:12).
# --------------------------------------------------------------------------

ModelStates {
  0x0020 { Scale 0.099853515625 }   # Pa51_crate1Z         -> Pa51_crate1_gexZ
  0x0022 { Scale 0.099853515625 }   # Pa51_crate3Z         -> Pa51_crate3_gexZ
  0x0024 { Scale 0.099853515625 }   # Pa51_unexp1Z         -> Pa51_unexp1_gexZ
  0x0051 { Scale 0.099853515625 }   # Pdd_hovmotoZ         -> Pdd_hovmoto_gexZ
  0x0052 { Scale 0.099853515625 }   # Pdd_hovtruckZ        -> Pdd_hovtruck_gexZ
  0x0079 { Scale 0.099853515625 }   # Psk_under_generatorZ -> Psk_under_generator_gexZ
  0x00b1 { Scale 0.099853515625 }   # PquadpodZ            -> Pquadpod_gexZ
  0x00c1 { Scale 0.099853515625 }   # Pmulti_ammo_crateZ   -> Pmulti_ammo_crate_gexZ
  0x00e2 { Scale 0.099853515625 }   # PbarrelZ             -> Pbarrel_gexZ
  0x0155 { Scale 0.099853515625 }   # PgoodstationZ        -> Pgoodstation_gexZ
  0x0175 { Scale 0.099853515625 }   # Pmisc_crateZ         -> Pmisc_crate_gexZ
  0x0187 { Scale 0.099853515625 }   # Paf1_doorbig2Z       -> Paf1_doorbig2_gexZ
  0x0188 { Scale 0.099853515625 }   # Paf1_phoneZ          -> Paf1_phone_gexZ
  0x0189 { Scale 0.099853515625 }   # Paf1_cargodoorZ      -> Paf1_cargodoor_gexZ
  0x018c { Scale 0.099853515625 }   # Psk_templecolumn4Z   -> Psk_templecolumn4_gexZ
  0x018d { Scale 0.099853515625 }   # PcorehatchZ          -> Pcorehatch_gexZ
  0x018e { Scale 0.099853515625 }   # Pa51grateZ           -> Pa51grate_gexZ
  0x0192 { Scale 0.099853515625 }   # Ppelagicdoor2Z       -> Ppelagicdoor2_gexZ
  0x01af { Scale 0.099853515625 }   # Paf1_innerdoorZ      -> Paf1_innerdoor_gexZ
}


# =========================================================================
# Levels this pack ships that had no stage row of their own.
#
# Before the stage space was rowed out these had nowhere to go: the rows
# naming their bg files were already claimed, and claiming one anyway is
# how two packs end up fighting over a level. Each block below names its
# level instead of a row and takes a free STAGE_EXTRA row from the
# allocator, so nothing here contests anything.
#
# ARENA NAMES ARE PLACEHOLDERS in the house form <level>_<pack>, the same
# as cat_gex and crash_site_aio above. Nobody has booted these to see what
# they are. Renaming one is a single string.
#
# Kept at the end of the file on purpose: a bad value in a stage block
# aborts the whole modconfig with no rollback, so a mistake here can only
# cost what is below it.
# =========================================================================

stage "gex_arec" {
  bgfile "bgdata/bg_arec_aio_gex.seg"
  tilesfile "bgdata/bg_arec_tiles_aio_gexZ"
  padsfile "bgdata/bg_arec_pads_aio_gexZ"
  mpsetupfile "Ump_setuparec_aio_gexZ"
  kind mp
  arenaname "Frigate"
  # lifted 2026-09-20 (lift-out/lift.py rule 3a): langbank lang.c:216 (STAGE_EXTRA1 -> LANGBANK_AREC); allocation pdmain.c:180 (STAGE_EXTRA1)
  langbank AREC
  allocation "-ml0 -me0 -mgfx200 -mvtx200 -ma400"
}

stage "gex_lam" {
  bgfile "bgdata/bg_lam_aio_gex.seg"
  tilesfile "bgdata/bg_lam_tiles_aio_gexZ"
  padsfile "bgdata/bg_lam_pads_aio_gexZ"
  mpsetupfile "Ump_setuplam_aio_gexZ"
  kind mp
  arenaname "Grand Library"   # was "Stack?"; row 0x28 STAGE_TEST_LAM; EternallyAries, credited in gex's modconfig
  # lifted 2026-09-20 (lift-out/lift.py rule 3d/none): langbank stem bank (no source row); LAM exists as LANGBANK_LAM; allocation default for kind mp (no pdmain.c row)
  langbank LAM
  allocation "-ml0 -me0 -mgfx200 -mvtx200 -ma400"
}

stage "gex_lee" {
  bgfile "bgdata/bg_lee_aio_gex.seg"
  tilesfile "bgdata/bg_lee_tiles_aio_gexZ"
  padsfile "bgdata/bg_lee_pads_aio_gexZ"
  mpsetupfile "Ump_setuplee_aio_gexZ"
  kind mp
  arenaname "Control"
  # lifted 2026-09-20 (lift-out/lift.py rule 3a): langbank lang.c:232 (STAGE_EXTRA17 -> LANGBANK_LEE); allocation pdmain.c:196 (STAGE_EXTRA17)
  langbank LEE
  allocation "-ml0 -me0 -mgfx110 -mgfxtra80 -mvtx100 -ma700"
}

stage "gex_mp13" {
  bgfile "bgdata/bg_mp13_aio_gex.seg"
  tilesfile "bgdata/bg_mp13_tiles_aio_gexZ"
  padsfile "bgdata/bg_mp13_pads_aio_gexZ"
  mpsetupfile "Ump_setupmp13_aio_gexZ"
  kind mp
  arenaname "Rogue"
  # lifted 2026-09-20 (lift-out/lift.py rule 3a): langbank lang.c:242 (STAGE_EXTRA24 -> LANGBANK_MP13); allocation pdmain.c:206 (STAGE_EXTRA24); env env.c:81 (STAGE_EXTRA24 fog, 'Rogue (Same as Caverns)')
  langbank MP13
  allocation "-ml0 -me0 -mgfx200 -mvtx200 -ma400"
  env {
    fog 993 1000
    near 10
    far 6000
    distfade 0 0 0
    sky 0x080008
    suns none
    clouds 0 5000 0 0xffffff
    water 0 -3000 0 0x00ffff
    cloudsheight 0
  }
}

stage "gex_mp2" {
  bgfile "bgdata/bg_mp2_aio_gex.seg"
  tilesfile "bgdata/bg_mp2_tiles_aio_gexZ"
  padsfile "bgdata/bg_mp2_pads_aio_gexZ"
  mpsetupfile "Ump_setupmp2_aio_gexZ"
  kind mp
  arenaname "Icicle Pyramid"
  # lifted 2026-09-20 (lift-out/lift.py rule 3a): langbank lang.c:222 (STAGE_EXTRA7 -> LANGBANK_MP2); allocation pdmain.c:186 (STAGE_EXTRA7); env env.c:181 (STAGE_EXTRA7 nofog, 'Icicle Pyramid')
  langbank MP2
  allocation "-ml0 -me0 -mgfx200 -mvtx200 -ma400"
  env {
    near 15
    far 20000
    distfade 0 0 0
    sky 0x2020ff
    suns none
    clouds 1 10000 0 0x8860d0
    water 0 -5000 0 0x000000
    cloudsheight 0
    transparency 0
  }
}

stage "gex_mp20" {
  bgfile "bgdata/bg_mp20_aio_gex.seg"
  tilesfile "bgdata/bg_mp20_tiles_aio_gexZ"
  padsfile "bgdata/bg_mp20_pads_aio_gexZ"
  mpsetupfile "Ump_setupmp20_aio_gexZ"
  kind mp
  arenaname "Citadel"
  # lifted 2026-09-20 (lift-out/lift.py rule 3c*): langbank lang.c:211 (STAGE_TEST_MP20 -> LANGBANK_MP20); allocation pdmain.c:160 (STAGE_TEST_MP20); env env.c:79 (STAGE_TEST_MP20 fog, 'Citadel')
  langbank MP20
  allocation "-ml0 -me0 -mgfx200 -mvtx200 -ma400"
  env {
    fog 996 1000
    near 10
    far 10000
    distfade 0 0 0
    sky 0x08040c
    suns none
    clouds 1 7500 0 0x403444
    water 0 -1000 0 0x000000
    cloudsheight 0
  }
}

stage "gex_ref" {
  bgfile "bgdata/bg_ref_aio_gex.seg"
  tilesfile "bgdata/bg_ref_tiles_aio_gexZ"
  padsfile "bgdata/bg_ref_pads_aio_gexZ"
  mpsetupfile "Ump_setupref_aio_gexZ"
  kind mp
  arenaname "Complex"
  # lifted 2026-09-20 (lift-out/lift.py rule 3a): langbank lang.c:217 (STAGE_EXTRA2 -> LANGBANK_REF); allocation pdmain.c:181 (STAGE_EXTRA2); env env.c:72 (STAGE_EXTRA2 fog, 'Complex')
  langbank REF
  allocation "-ml0 -me0 -mgfx200 -mvtx200 -ma400"
  env {
    fog 996 1000
    near 10
    far 5000
    distfade 0 0 0
    sky 0x280000
    suns none
    clouds 1 10000 0 0xdc0014
    water 0 -1000 0 0x000000
    cloudsheight 0
  }
}

stage "gex_sev" {
  bgfile "bgdata/bg_sev_aio_gex.seg"
  tilesfile "bgdata/bg_sev_tiles_aio_gexZ"
  padsfile "bgdata/bg_sev_pads_aio_gexZ"
  mpsetupfile "Ump_setupsev_aio_gexZ"
  kind mp
  arenaname "Void"   # was "Holodeck?"; row 0x5c STAGE_EXTRA32; only mod_gex ships bg_sev
  # lifted 2026-09-20 (lift-out/lift.py rule 3d/none): langbank stem bank (no source row); SEV exists as LANGBANK_SEV; allocation default for kind mp (no pdmain.c row)
  langbank SEV
  allocation "-ml0 -me0 -mgfx200 -mvtx200 -ma400"
}

stage "gex_stat" {
  bgfile "bgdata/bg_stat_aio_gex.seg"
  tilesfile "bgdata/bg_stat_tiles_aio_gexZ"
  padsfile "bgdata/bg_stat_pads_aio_gexZ"
  mpsetupfile "Ump_setupstat_aio_gexZ"
  kind mp
  arenaname "Paradox"
  # lifted 2026-09-20 (lift-out/lift.py rule 3a): langbank lang.c:243 (STAGE_EXTRA25 -> LANGBANK_STAT); allocation pdmain.c:207 (STAGE_EXTRA25)
  langbank STAT
  allocation "-ml0 -me0 -mgfx120 -mvtx200 -ma400"
}


# --- stage blocks added 2026-10-10 from jonaeru/perfect_dark @ d3e4205 (stagetable.c rows, g_MpArenas names, env.c/lang.c/pdmain.c params) for levels the 6.0 pack ships that the parked config never declared; pack attribution in aio6-stage-proposals.txt ---
stage "gex_residence" {
  bgfile "bgdata/bg_old_aio_gex.seg"
  tilesfile "bgdata/bg_old_tiles_aio_gexZ"
  padsfile "bgdata/bg_old_pads_aio_gexZ"
  mpsetupfile "Ump_setupold_aio_gexZ"
  kind mp
  arenaname "Residence"
  # from jonaeru @ d3e4205: row 0x5d STAGE_EXTRA33 (Additional); arena name L_MPMENU in the AIO LmpmenuE bank
  langbank OLD   # lang.c:248
  allocation "-ml0 -me0 -mgfx200 -mvtx200 -ma400"   # pdmain.c:202
  # env env.c:185 (nofog, 'Residence (Same as Area 52 (MP))')
  env {
    near 15
    far 10000
    distfade 0 0 0
    sky 0x000008
    suns none
    clouds 1 4500 0 0x46c7ba
    water 0 -5000 0 0x000000
    cloudsheight 0
    transparency 0
  }
}


