Files
isaac-port/notes/items/parity_floors13.md
T

7.1 KiB

Floors on the 13x13 map: LevelGenerator for Repentance+ floors (floors13)

Repentance+ 1.9.7.17. Ported to isaac-classic (src/game/rooms/floor_generator.cpp: one generator; the Flash scan and LevelGenerator are its two growths, picked by stages.json generation is_level_generated; the map part by the Floor Grid option, stages.json floor_grid). Builds on parity_death_certificate.md's LevelGenerator notes.

Level::generate_dungeon 0x740e10

  • Generator seeded once (RoomDescriptor::Init(generator, _generationRNG.Next()), before the retry label 0x741760): every retry continues the same generator RNG.
  • Each try: blocked grid (+0x2b8) cleared (memset 0xa9), then LevelGenerator::block_cell 0x9b1910 (6,5) when not Greed/Greedier, not (stage 1-6 on the Ascent, game flag 0x1000000000000), stage type not 4/5, and (stage 6, or stage 5 with the Labyrinth), on the standard path (no challenge/daily, or challenge path type 3) with achievement 0x27b (or state 2 in a daily or debug): the cell above the start room (6,6), the photo door's side.
  • Start room: LevelGenerator_Room at (6,6), shape 1, size from 0xc5d380.
  • Generate(target, stage == 11, Labyrinth || challenge 21, stage == 12, &shapes, deadEnds, &start); shapes = every shape of the stage's type-1 rooms (CollectRooms over the difficulty window); bits 1-3 cleared under curse 0x80.
  • Fails: "generated level is not usable" (+0x393 flag) or "not enough dead ends (%d/%d)": the target +1 when the try count is > 9 and a multiple of 5 and below 64. place_special_rooms returning 0 also retries.

LevelGenerator details (0x9adbb0 ..)

  • Generate: flags +0x390 unk3 (XL), +0x391 unk2 (stage 11, unused here), +0x392 unk4 (Void); grid reset, boss room (+0x388) -1, boss count (+0x38c) 0; generate_rooms; update_dead_end_lists; while dead ends < numDeadEnds, up to 5 tries of LevelGenerator::add_dead_end 0x9af1e0 + update_dead_end_lists; dead ends selection-sorted by distance (+0x40) descending, the first farthest kept first (<=).
  • add_dead_end 0x9af1e0: rooms in index order, get_neighbor_candidates(room, unk 1), the first that can_place_room and count_neighbor_rooms(connect) < 2 is placed (no is_placement_valid).
  • get_neighbor_candidates 0x9b0b00 unk: a spot is allowed when its divisor draw hits, 1x1 rooms are not allowed, or unk != 0; the draw is always made.
  • generate_rooms 0x9b04d0: a candidate whose connect cell already touches >= 2 rooms is refused, unless XL or Void (+0x390 / +0x392) and Next() % 10 == 0 (then is_placement_valid as usual).
  • try_resize_room 0x9b1220 (GetNewEndRoom, DetermineBossRoom, place_boss_room): the room's 14 spots from its connect cell (+0x28) and direction (+0x20), the get_neighbor_candidates order (1x1 at connect; then ahead, connect, connect+across, ahead, ahead+across x5 L/2x2, connect closet, ahead long closet); each spot's door slot back to its parent (dir+2)&3, +4 for spots 2, 4, 6, 8, 10; spot 13's slot is read one past the array (local_c, the stack cookie: garbage in the exe; the port uses the base slot). A spot of the requested shape whose slot is in possibleDoors fits when every cell is on the grid and free or its own, and every slot onto another room is in possibleDoors, with fewer than 2 such rooms (a room with +0x44 set, a secret one, not counted). Then its old cells cleared, new ones set, cell/size/shape updated, neighbours updated.
  • DetermineBossRoom 0x9aed50: dead ends in order with distance > 1; on XL (+0x390) the 3 cells past the connect cell the way it grew must each be free or its own and have no other room beside them; try_resize_room; it becomes +0x388 and leaves the dead end list.
  • place_boss_room 0x9aef10 (shape, doors, force): DetermineBossRoom unless XL and a boss room was placed (and not forced); try_resize_room on +0x388; count +1, +0x388 = -1; on XL with count < 2: get_neighbor_candidates(boss, 0) shuffled, the first can_place_room / count < 2 / its source slot (+0x24) in doors is placed as a dead end (+0x3c), becomes +0x388 (the second boss room, resized by the next call), and the first room's door mask gains that slot.
  • block_room_area 0x9b1860: room cells + offsets 0xc35e9c: (0,0) (-1,0) (1,0) (0,-1) (0,1).
  • place_secret_room 0x9ae170: every free 13x13 cell not excluded and not blocked draws Next() % 5 + 10; for each neighbour (left, up, right, down) holding a room: its base slot (dir+2)&3 invalid for its shape -> -100, else one more neighbour; with neighbours and score >= 0: -3 unless > 2, -3 more unless > 1; best list (ties appended), drawn by Next() % n; a 1x1 room with +0x44 = 1 placed there.
  • Level::get_secret_room_excluded_cells 0x738d70 (was Console::Print): see db/names.tsv.

Level::place_special_rooms 0x739370: which rooms are required

GetRandomRoom (config first) then GetNewEndRoom (its shape and doors). return 0 (the floor retries) when none fits: the boss room(s) (place_boss_room), the first super secret room, the shop, the treasure room(s), the mirror room (subtype 0x22), the mineshaft entrance (0x1d), the Dark Room's extra room. The others (dice/sacrifice, library, curse, miniboss, challenge, arcade/chest, bedroom, planetarium) are skipped without a dead end. Normal rooms last (get_all_rooms order), each GetRandomRoom(type 1, its shape, difficulty min 1 if > 1 and (gen seed & 7) == 0, its door mask); the start room GetRoomByStageTypeAndVariant(0 or 16/17 on stage 11, 1, 2 or 0).

HasPhotoDoor 0x74f030 (the red room start-room rule)

Not Greed, not the Ascent's stages 1-6, stage type not 4/5, and stage 6, or stage 5 with the Labyrinth (curse 2). The port's XL floor is chapter + 1 with the second chapter's stage, so Depths I under the Labyrinth is the port's depths_ii (necropolis_ii, dank_depths_ii) floor, as is Depths II itself: red_rooms start_top_closed_stages' depths_ii / necropolis_ii / dank_depths_ii is right (checked in this pass; the Mausoleum/Gehenna II keys stay out).

Ported (isaac-classic)

  • Every map 13x13 (index row * 13 + column); the floor grows in its part of it (Floor Grid: Eternal Edition 10x8 from [5,3], Repentance+ 13x13 from [6,6]); Flash floors generate exactly as before (2400 reports compared).
  • Repentance+ rules: LevelGenerator growth with the Void/XL flags, dead ends [5, 6] (+XL, +1 beside a dimension, -3 rooms there), add_dead_end, the boss room by DetermineBossRoom/try_resize_room (an XL floor's second beside it, the Void's extra ones forced), block_room_area, super secret / shop / treasure and the other special rooms by GetNewEndRoom of a one-screen room drawn first (shop and treasure required; the shop and treasure left out past chapter 6 before taking a dead end), place_secret_room with get_secret_room_excluded_cells, the ultra secret room by try_place_room on the real grid (room placements' isolated spot), the Death Certificate dimension on the same class.
  • Left: the port's own special room odds and order after the treasure room (planetarium, dice, chest, bedroom come from stages.json room_placements after the engine's rooms, so they take the dead ends left), Luna's second super secret room, the Dark Room's extra special room, the normal rooms' 1-in-8 easy difficulty, the Ascent's generate_backwards.