diff --git a/patches/ips/map_progress_maintain.ips b/patches/ips/map_progress_maintain.ips index ddb13f22c..899f8658c 100644 Binary files a/patches/ips/map_progress_maintain.ips and b/patches/ips/map_progress_maintain.ips differ diff --git a/patches/src/map_progress_maintain.asm b/patches/src/map_progress_maintain.asm index 7552d365f..867a05261 100644 --- a/patches/src/map_progress_maintain.asm +++ b/patches/src/map_progress_maintain.asm @@ -114,34 +114,6 @@ mark_progress: activate_map_station_hook: LDA #$0001 : STA $0789 ; run hi-jacked instructions (set map flag) - phb - pea $9090 - plb - plb - - ; reveal specific tiles in other area maps (e.g. area transition arrows/letters) - lda $1F5B - asl - tax ; X <- map_area * 2 - lda !map_reveal_tile_table, x - tay ; Y <- [map_reveal_tile_table + map_area * 2] - -.cross_area_reveal_loop: - lda $0000,y - beq .done_cross_area_reveal - tax ; X <- address of word containing tile to reveal (relative to base at $702000 and $702700) - lda $0002,y ; A <- bitmask of tile to reveal - ora $702000,x - sta $702000,x - lda $0002,y - ora $702700,x - sta $702700,x - iny : iny : iny : iny - bra .cross_area_reveal_loop - -.done_cross_area_reveal: - plb - ; now reveal the current area's map: lda $1F5B xba @@ -152,14 +124,14 @@ activate_map_station_hook: bne .partial_only_loop .loop: - lda #$FFFF + lda $829727, x sta $702000, x sta $702700, x inx inx dey bne .loop - rtl + bra .leave .partial_only_loop: lda #$FFFF @@ -175,7 +147,39 @@ activate_map_station_hook: inx dey bne .partial_only_loop +.leave + jsr cross_area_reveal rtl + + cross_area_reveal: + phb + pea $9090 + plb + plb + + ; reveal specific tiles in other area maps (e.g. area transition arrows/letters) + lda $1F5B + asl + tax ; X <- map_area * 2 + lda !map_reveal_tile_table, x + tay ; Y <- [map_reveal_tile_table + map_area * 2] + +.cross_area_reveal_loop: + lda $0000,y + beq .done_cross_area_reveal + tax ; X <- address of word containing tile to reveal (relative to base at $702000 and $702700) + lda $0002,y ; A <- bitmask of tile to reveal + ora $702000,x + sta $702000,x + lda $0002,y + ora $702700,x + sta $702700,x + iny : iny : iny : iny + bra .cross_area_reveal_loop + +.done_cross_area_reveal: + plb + rts hook_mark_tile_above: ; run hi-jacked instruction (mark explored tile) diff --git a/rust/maprando/src/patch.rs b/rust/maprando/src/patch.rs index 69f414e28..349a400da 100644 --- a/rust/maprando/src/patch.rs +++ b/rust/maprando/src/patch.rs @@ -1102,6 +1102,36 @@ impl Patcher<'_> { Ok(()) } + fn write_area_bitmask(&mut self) -> Result<()> { + let addr = 0x829727; + + for (room_idx, room) in self.game_data.room_geometry.iter().enumerate() { + let room_x = self.rom.read_u8(room.rom_address + 2)?; + let room_y = self.rom.read_u8(room.rom_address + 3)?; + let area = self.map.area[room_idx]; + + for y in 0..room.map.len() { + for x in 0..room.map[y].len() { + if (room.map[y][x] == 0 && room_idx != self.game_data.toilet_room_idx) + || !self.map.room_mask[room_idx] + { + continue; + } + + let (offset, bitmask) = + xy_to_explored_bit_ptr(room_x + x as isize, room_y + y as isize); + + let bit_addr = addr + area * 0x100 + offset as usize; + let mut curr = self.rom.read_u8(snes2pc(bit_addr))?; + curr |= bitmask as isize; + self.rom.write_u8(snes2pc(bit_addr), curr)?; + } + } + } + + Ok(()) + } + fn fix_save_stations(&mut self) -> Result<()> { let save_station_ptrs = vec![ 0x44C5, 0x44D3, 0x44E1, 0x45CF, 0x45DD, 0x45EB, 0x45F9, 0x4607, 0x46D9, 0x46E7, 0x46F5, @@ -3357,6 +3387,7 @@ pub fn make_rom( patcher.apply_mother_brain_setup_asm()?; patcher.apply_extra_setup_asm()?; patcher.write_extra_room_data()?; + patcher.write_area_bitmask()?; info!("CustomizeSettings: {customize_settings:?}"); customize_rom(