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

78 lines
5.2 KiB
Markdown

# Blue rooms (GridRooms -16, room type 28) and Blue Key (trinket 150 / 0x96)
Ported to isaac-classic (branch of the items parity sweep): room index BLUE_ROOM_INDEX 167, the blue_rooms trait.
## Opening a door: GridEntity_Door::TryUnlock 0x710480
- Room::update_door_transitions 0x7f01c0 calls TryUnlock(door, player, 0) for a locked door (variant 1-5) of a cleared
room when the player is under 60 units from it and moving its way; keys are not needed to get there.
- Variant 1 into type 0x1b with get_secret_exit_kind 3 (the Mausoleum's flesh door) returns before Blue Key.
- Variant 1 (DOOR_LOCKED: key doors, coin doors with _doorFlags & 1 = arcades) or 2 (DOOR_LOCKED_DOUBLE, chest and
dice rooms) and HasTrinket(0x96): isForce = 1 and the blue mark. Forced: no key used (TryUseKey skipped, golden key
irrelevant), no coin (AddCoins(-1) skipped), _isUnlockedByPlayer = 1, a double lock opens at once (the state-3 first
key step needs isForce == 0). Sound as unforced: 0x9c for a key door, 0x2d for a coin door.
- Look: when UpdateAnimation chose "GoldenKeyOpen" it plays "KeyOpen" instead; while "KeyOpen" plays its layer "Key"
(string at 0xb1ce2c) is colorized (0.4, 0.6, 1.0, 1.0).
- Then GetRoomByIdx(_targetRoomIdx)->Flags |= 0x40000 (the blue room mark), if the room has data.
## The mark (RoomDescriptor Flags 0x40000)
- GridEntity_Door::Update 0x70c5c0: a door whose target room is marked colorizes its "Background" layer
(0.8, 1.1, 1.8, 0.8).
- Room::render_grid_entity_light 0x80c810 (door case, not a secret exit door, not in a stage-35 Home room): a marked
target's door gets the light sprite coloured (0.3, 0.6, 1.0, 1.0) at 0.7 scale instead of its plain light.
- Level::ChangeRoom 0x73fc80: after a room is entered, for each of its 8 door entities (Room +0x724..0x744) the room
the door leads into (door +0x394) loses the mark. So the mark lasts only while Isaac stays in the room he opened the
door from: the blue room (whose doors lead to both rooms) clears it, and so does any room beside the target.
## Entering: Game::StartRoomTransition 0x6fd7c0
At 0x6fdb57: animation 0 (a door walk), target dimension < 0 or the current one, then
`prepare_blue_room(currentRoomIdx, roomIndex, direction)` (pushes at 0x6fdb6c); true replaces roomIndex with -16.
## Level::prepare_blue_room 0x74d4a0
- Fails (plain transition) for direction -1, a source room index < 0 (a room off the map), or an unmarked target.
- The descriptor (Level +0x17744; a static dummy when _currentDimensionIdx >= 3) is reset to a fresh one, its
ListIndex kept, GridIndex -16.
- RNG: seed = the target's DecorationSeed, shifts 5, 27, 28 (0x1b, 0x1c). Seeds::Init3 0x428940 draws three times
(the blue room's own seeds).
- Direction 0 or 2 (left, right): one Next; (seed & 3) != 0 -> shape 6 (2x1), else 7 (IIH long closet). AllowedDoors 5
(LEFT0 | RIGHT0).
- Direction 1 or 3: RandomInt(4) != 0 -> shape 4 (1x2), else 5 (IIV). AllowedDoors 10 (UP0 | DOWN0).
- RoomConfig::GetRandomRoom(Next(), reduceWeight 0, stage 0 (special rooms), type 0x1c, shape, variants all,
difficulty 1..10, &AllowedDoors, subtype -1, mode -1); none -> again with Next() and shape 0xd (CollectRooms 0x82ce40:
13 matches any shape); none -> fail.
- doors[direction] = target, doors[opposite] = source (case 0: [0] target, [2] source, ...).
- 00.special rooms.stb has 25 type-28 rooms, all difficulty 1: variants 0-9 shape 4 (UP0/DOWN0), 10-11 shape 5, 12-22
shape 6 (LEFT0/RIGHT0), 23-24 shape 7; weights 1 (0.5 for 8, 10, 11, 18, 23, 24).
## In the blue room
- Level::load_room 0x73e0a0: a descriptor door to a negative index (or a cell off the room map) gets no target, so a
blue room before a room off the map (the Downpour/Dross secret exit, -10) is a dead end.
- GridEntity_Door::SetRoomTypes 0x710fa0: in room -16 every door is variant 8 (never locked, never hidden).
- Room::LoadBackdropGraphics 0x7f1380: room -16 always backdrop 13 (Blue Womb: rocks_bluewomb, grid_pit_bluewomb,
door_01_bluewombdoor); -8 backdrop 27 (Blue Secret).
- Room::PlayMusic 0x7eb1b0: type 28 has no case of its own: the stage's music.
- Leaving: ChangeRoom's previous index is -16 (< 0), so the entered room's door is GetTargetSlot 0x73da40 /
Level::get_door_slot 0x73d9b0 on the side across from the exit, for the cell the blue room's door named.
- The descriptor is rebuilt on every prepare, so a blue room is never revisited (and the mark is gone once inside).
## Clear award: Room::SpawnClearAward 0x7fb250
In the normal-room branch, after Contract from Below's count and Glyph of Balance, when the room descriptor's
GridIndex is -16 and FirstTrinketOwner(0x96) exists, the award count is multiplied by GetTrinketMultiplier(0x96)
(before Deep Pockets adds RandomInt(3)).
## Other Blue Key reads
- Entity_Player::GetTearHitParams 0x7bf6c0 tests collectible 0x96 (Blue Key's id is also COLLECTIBLE 150 = Tough Love
in that enum): not the trinket.
## Not ported (look only)
- The Rebirth renderer has no colorize (coloroffset.fs: mix(rgb, dot(rgb, lum) * Colorize.rgb, Colorize.a)), so the
door "Background" tint and the blue "Key" layer of KeyOpen are not drawn (the blue door light is); and the port has
no Blue Womb door (door_01_bluewombdoor) for backdrop 13 yet (the Blue Womb floor lacks it too).