Skip to content

Commit d0c5132

Browse files
authored
fix map edge spacing after map collection (#262)
1 parent 920314d commit d0c5132

File tree

3 files changed

+65
-30
lines changed

3 files changed

+65
-30
lines changed
6 Bytes
Binary file not shown.

patches/src/map_progress_maintain.asm

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -114,34 +114,6 @@ mark_progress:
114114
activate_map_station_hook:
115115
LDA #$0001 : STA $0789 ; run hi-jacked instructions (set map flag)
116116

117-
phb
118-
pea $9090
119-
plb
120-
plb
121-
122-
; reveal specific tiles in other area maps (e.g. area transition arrows/letters)
123-
lda $1F5B
124-
asl
125-
tax ; X <- map_area * 2
126-
lda !map_reveal_tile_table, x
127-
tay ; Y <- [map_reveal_tile_table + map_area * 2]
128-
129-
.cross_area_reveal_loop:
130-
lda $0000,y
131-
beq .done_cross_area_reveal
132-
tax ; X <- address of word containing tile to reveal (relative to base at $702000 and $702700)
133-
lda $0002,y ; A <- bitmask of tile to reveal
134-
ora $702000,x
135-
sta $702000,x
136-
lda $0002,y
137-
ora $702700,x
138-
sta $702700,x
139-
iny : iny : iny : iny
140-
bra .cross_area_reveal_loop
141-
142-
.done_cross_area_reveal:
143-
plb
144-
145117
; now reveal the current area's map:
146118
lda $1F5B
147119
xba
@@ -152,14 +124,14 @@ activate_map_station_hook:
152124
bne .partial_only_loop
153125

154126
.loop:
155-
lda #$FFFF
127+
lda $829727, x
156128
sta $702000, x
157129
sta $702700, x
158130
inx
159131
inx
160132
dey
161133
bne .loop
162-
rtl
134+
bra .leave
163135

164136
.partial_only_loop:
165137
lda #$FFFF
@@ -175,7 +147,39 @@ activate_map_station_hook:
175147
inx
176148
dey
177149
bne .partial_only_loop
150+
.leave
151+
jsr cross_area_reveal
178152
rtl
153+
154+
cross_area_reveal:
155+
phb
156+
pea $9090
157+
plb
158+
plb
159+
160+
; reveal specific tiles in other area maps (e.g. area transition arrows/letters)
161+
lda $1F5B
162+
asl
163+
tax ; X <- map_area * 2
164+
lda !map_reveal_tile_table, x
165+
tay ; Y <- [map_reveal_tile_table + map_area * 2]
166+
167+
.cross_area_reveal_loop:
168+
lda $0000,y
169+
beq .done_cross_area_reveal
170+
tax ; X <- address of word containing tile to reveal (relative to base at $702000 and $702700)
171+
lda $0002,y ; A <- bitmask of tile to reveal
172+
ora $702000,x
173+
sta $702000,x
174+
lda $0002,y
175+
ora $702700,x
176+
sta $702700,x
177+
iny : iny : iny : iny
178+
bra .cross_area_reveal_loop
179+
180+
.done_cross_area_reveal:
181+
plb
182+
rts
179183

180184
hook_mark_tile_above:
181185
; run hi-jacked instruction (mark explored tile)

rust/maprando/src/patch.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,6 +1102,36 @@ impl Patcher<'_> {
11021102
Ok(())
11031103
}
11041104

1105+
fn write_area_bitmask(&mut self) -> Result<()> {
1106+
let addr = 0x829727;
1107+
1108+
for (room_idx, room) in self.game_data.room_geometry.iter().enumerate() {
1109+
let room_x = self.rom.read_u8(room.rom_address + 2)?;
1110+
let room_y = self.rom.read_u8(room.rom_address + 3)?;
1111+
let area = self.map.area[room_idx];
1112+
1113+
for y in 0..room.map.len() {
1114+
for x in 0..room.map[y].len() {
1115+
if (room.map[y][x] == 0 && room_idx != self.game_data.toilet_room_idx)
1116+
|| !self.map.room_mask[room_idx]
1117+
{
1118+
continue;
1119+
}
1120+
1121+
let (offset, bitmask) =
1122+
xy_to_explored_bit_ptr(room_x + x as isize, room_y + y as isize);
1123+
1124+
let bit_addr = addr + area * 0x100 + offset as usize;
1125+
let mut curr = self.rom.read_u8(snes2pc(bit_addr))?;
1126+
curr |= bitmask as isize;
1127+
self.rom.write_u8(snes2pc(bit_addr), curr)?;
1128+
}
1129+
}
1130+
}
1131+
1132+
Ok(())
1133+
}
1134+
11051135
fn fix_save_stations(&mut self) -> Result<()> {
11061136
let save_station_ptrs = vec![
11071137
0x44C5, 0x44D3, 0x44E1, 0x45CF, 0x45DD, 0x45EB, 0x45F9, 0x4607, 0x46D9, 0x46E7, 0x46F5,
@@ -3357,6 +3387,7 @@ pub fn make_rom(
33573387
patcher.apply_mother_brain_setup_asm()?;
33583388
patcher.apply_extra_setup_asm()?;
33593389
patcher.write_extra_room_data()?;
3390+
patcher.write_area_bitmask()?;
33603391

33613392
info!("CustomizeSettings: {customize_settings:?}");
33623393
customize_rom(

0 commit comments

Comments
 (0)