Baserom re-factor of compass code

Scrolling fix
This commit is contained in:
aerinon
2020-11-03 10:17:46 -07:00
parent 4a4868bb5b
commit f62ba51469
6 changed files with 12 additions and 84 deletions

View File

@@ -24,7 +24,7 @@ from Fill import distribute_items_cutoff, distribute_items_staleness, distribute
from ItemList import generate_itempool, difficulties, fill_prizes
from Utils import output_path, parse_player_names
__version__ = '0.2.0.6-u'
__version__ = '0.2.0.7-u'
class EnemizerError(RuntimeError):
pass

67
Rom.py
View File

@@ -24,7 +24,7 @@ from EntranceShuffle import door_addresses, exit_ids
JAP10HASH = '03a63945398191337e896e5771f77173'
RANDOMIZERBASEHASH = '6904a4588b21d1674e1fa25e96da8339'
RANDOMIZERBASEHASH = '78947c3825898cac3ab57cbe44b50390'
class JsonRom(object):
@@ -635,10 +635,7 @@ def patch_rom(world, rom, player, team, enemized):
rom.write_byte(0x15270, 2)
sanctuary = world.get_region('Sanctuary', player)
rom.write_byte(0x1597b, sanctuary.dungeon.dungeon_id*2)
if compass_code_good(rom):
update_compasses(rom, world, player)
else:
logging.getLogger('').warning('Randomizer rom update! Compasses in crossed are borken')
update_compasses(rom, world, player)
# patch doors
if world.doorShuffle[player] == 'crossed':
@@ -2211,67 +2208,13 @@ def patch_shuffled_dark_sanc(world, rom, player):
rom.write_bytes(0x180262, [unknown_1, unknown_2, 0x00])
# 24B118 and 20BB32
compass_r_addr = 0x123118 # a9 90 24 8f 9a c7 7e
# compass_w_addr = 0x103b32 # e2 20 ad 0c 04 c9 00 d0
compass_w_addr = 0x103b53 # e2 20 ad 0c 04 c9 00 d0
def compass_code_good(rom):
if isinstance(rom, LocalRom):
# a990248f9ac77e
if rom.buffer[compass_r_addr] != 0xa9 or rom.buffer[compass_r_addr+1] != 0x90 or rom.buffer[compass_r_addr+2] != 0x24:
return False
if rom.buffer[compass_r_addr+3] != 0x8f or rom.buffer[compass_r_addr+4] != 0x9a or rom.buffer[compass_r_addr+5] != 0xc7:
return False
if rom.buffer[compass_w_addr] != 0xe2 or rom.buffer[compass_w_addr+1] != 0x20 or rom.buffer[compass_w_addr+2] != 0xad:
return False
if rom.buffer[compass_w_addr+3] != 0x0c or rom.buffer[compass_w_addr+4] != 0x04 or rom.buffer[compass_w_addr+5] != 0xc9:
return False
return True
def update_compasses(rom, world, player):
layouts = world.dungeon_layouts[player]
# cmp XX : bne escape
# cpy 32 : bne escape
# brl .itemCounts
# c9 02 d0 eastern
# nop #2
new_code = [0x07, 0xC0, 0x32, 0xD0, 0x03, 0x82, 0xB9, 0x01, 0xC9, 0x02, 0xD0, 0x10, 0xEA, 0xEA]
rom.write_bytes(compass_w_addr + 8, new_code)
# 05 06 07 08
# C9 00 D0 02 80 04 C9 02 D0 15 C0 32 D0 03 82 B3 01
# C9 XX D0 07 C0 32 D0 03 82 B9 01 C9 02 D0 10 EA EA
for name, builder in layouts.items():
digit_offset, sram_byte, write_offset, jmp_nop_flag, dungeon_id = compass_data[name]
digit1 = builder.location_cnt // 10
digit2 = builder.location_cnt % 10
rom.write_byte(compass_r_addr+digit_offset, 0x90+digit1)
rom.write_byte(compass_r_addr+digit_offset+7, 0x90+digit2)
# read compass count code
start_address = compass_r_addr+digit_offset+15
# -0x59 relative to compass_r_addr, +8000 because rom -120000 to get rid of high byte
jmp_address = compass_r_addr-0x118059
# lda $7ef4(sb); jmp $jmp_address
rom.write_bytes(start_address, [0xaf, sram_byte, 0xf4, 0x7e, 0x4c, jmp_address % 0x100, jmp_address // 0x100])
# write compass count code
write_address = compass_w_addr+write_offset
# 0x186 relative to compass_r_addr, +8000 because rom -100000 to get rid of high byte
jmp_address = compass_w_addr-0xf7e7a
# lda $7ef4(sb); inc; sta $7ef4(sb)
rom.write_bytes(write_address, [0xaf, sram_byte, 0xf4, 0x7e, 0x1a, 0x8f, sram_byte, 0xf4, 0x7e])
if jmp_nop_flag == 0:
rom.write_bytes(write_address+9, [0x4c, jmp_address % 0x100, jmp_address // 0x100]) # jmp $jmp_address
else:
for i in range(0, jmp_nop_flag):
rom.write_byte(write_address+9+i, 0xea) # nop
dungeon_id = compass_data[name][4]
rom.write_byte(0x187000 + dungeon_id//2, builder.location_cnt)
if builder.bk_provided:
rom.write_byte(compass_w_addr+6, dungeon_id)
rom.write_byte(0x186FFF, dungeon_id)
InconvenientDungeonEntrances = {'Turtle Rock': 'Turtle Rock Main',

View File

@@ -104,12 +104,6 @@ nop : stz $0dd0, X : rts
.not_in_ganons_tower
;org $208206
org $20820E
jsl MirrorCheckOverride2
;org $208270
org $20827C
jsl MirrorCheckOverride2
org $07a955 ; <- Bank07.asm : around 6564 (JP is a bit different) (STZ $05FC : STZ $05FD)
jsl BlockEraseFix
nop #2
@@ -131,11 +125,6 @@ nop #2 : jsl BlindAtticFix
org $028409
jsl SuctionOverworldFix
; also rando's hooks.asm line 1360
; 106e4e -> goes to a0ee4e
;org $a0ee8a ; <- 6FC4C - headsup_display.asm : 836 (LDA $7EF36E : AND.w #$00FF : ADD.w #$0007 : AND.w #$FFF8 : TAX)
org $a0eeab
jsl DrHudOverride
org $0ded04 ; <- rando's hooks.asm line 2192 - 6ED04 - equipment.asm : 1963 (REP #$30)
jsl DrHudDungeonItemsAdditions
;org $098638 ; rando's hooks.asm line 2192

View File

@@ -49,10 +49,6 @@ MirrorCheckOverride:
rtl
+ lda.l DRScroll : rtl
MirrorCheckOverride2:
lda $7ef353 : and #$02 : rtl
BlockEraseFix:
lda $7ef353 : and #$02 : beq +
stz $05fc : stz $05fd

View File

@@ -177,20 +177,20 @@ ScrollX: ;change the X offset variables
rts
LimitXCamera:
cmp #$0080 : !bge +
cmp #$0079 : !bge +
lda #$0000 : bra .end
+ cmp #$0181 : !blt +
lda #$0180
+ !sub #$0080
+ cmp #$0178 : !blt +
lda #$0178
+ !sub #$0078
.end rts
CheckRoomLayoutX:
jsr LoadRoomLayout ;switches to 8-bit
cmp #$04 : !blt .lock
cmp #$05 : bne +
lda $04 : cmp #$f8 : beq .lock
lda $06 : cmp #$ff : beq .lock
+ cmp #$06 : bne .free
lda $04 : cmp #$f8 : bne .lock
lda $06 : cmp #$ff : bne .lock
.free rep #$30 : clc : rts
.lock rep #$30 : sec : rts

Binary file not shown.