Base ROM GFX Fixes and more

This commit is contained in:
codemann8
2024-04-18 09:17:17 -05:00
parent f3dc2b881e
commit 04baad9a5f
3 changed files with 88 additions and 66 deletions

6
Rom.py
View File

@@ -43,7 +43,7 @@ from source.enemizer.Enemizer import write_enemy_shuffle_settings
JAP10HASH = '03a63945398191337e896e5771f77173'
RANDOMIZERBASEHASH = '168c7d6e330a134e7565baedab79aa15'
RANDOMIZERBASEHASH = '59bea5ff31ed36e1235b897efade6595'
class JsonRom(object):
@@ -631,7 +631,7 @@ def patch_rom(world, rom, player, team, is_mystery=False):
from OverworldShuffle import can_reach_smith
if not can_reach_smith(world, player):
rom.write_byte(0x18005d, 0x01) # patch for deleting smith on S+Q
rom.write_byte(0x180043, 0x01) # patch for deleting smith on S+Q
# patch entrance/exits/holes
for region in world.regions:
@@ -1217,7 +1217,7 @@ def patch_rom(world, rom, player, team, is_mystery=False):
rom.initial_sram.set_starting_equipment(world, player)
rom.write_byte(0x18004A, 0x00 if world.mode[player] != 'inverted' else 0x01) # Inverted mode
rom.write_byte(0x180043, 0x00) # Hammer always breaks barrier
rom.write_byte(0x18005D, 0x00) # Hammer always breaks barrier
rom.write_byte(0x02AF79, 0xD0 if world.mode[player] != 'inverted' else 0xF0) # vortexes: Normal (D0=light to dark, F0=dark to light, 42 = both)
rom.write_byte(0x03A943, 0xD0 if world.mode[player] != 'inverted' else 0xF0) # Mirror: Normal (D0=Dark to Light, F0=light to dark, 42 = both)
rom.write_byte(0x03A96D, 0xF0 if world.mode[player] != 'inverted' else 0xD0) # Residual Portal: Normal (F0= Light Side, D0=Dark Side, 42 = both (Darth Vader))

View File

@@ -43,6 +43,9 @@ Overworld_LoadSpecialOverworld_RoomId:
org $84E8B4
Overworld_LoadSpecialOverworld:
org $84E96A
JSL OWSpecialReturnTriggerClear
org $82A9DA
JSL OWSkipPalettes
BCC OverworldHandleTransitions_change_palettes : NOP #4
@@ -151,8 +154,8 @@ jsl OWWorldCheck16 : nop
org $9bed95 ; < ? - palettes.asm:748 ()
jsl OWWorldCheck16 : nop
org $82b16e ; AND #$3F : ORA 7EF3CA
and #$7f : eor #$40 : nop #2
org $82B16C ; LDA $8A : AND #$3F : ORA 7EF3CA
JSL OWApplyWorld : BRA + : NOP #2 : +
org $89C3C4
jsl OWBonkDropPrepSprite : nop #2
@@ -225,6 +228,17 @@ OWMapWorldCheck16:
.return
rtl
}
OWApplyWorld:
{
LDX.b OverworldIndex
.fromScreen
LDA.l OWTileWorldAssoc,X : CMP.l CurrentWorld : BEQ .keepWorld ; if dest screen mismatches the current world
TXA : EOR.b #$40 : RTL
.keepWorld
TXA : RTL
}
OWWhirlpoolUpdate:
{
@@ -290,7 +304,7 @@ OWMirrorSpriteSkipDraw:
sec : rtl
.vanilla
LDA.w $0FC6 : CMP.b #$03 ; what we wrote over
LDA.w GfxChrHalfSlotVerify : CMP.b #$03 ; what we wrote over
RTL
}
OWLightWorldOrCrossed:
@@ -322,7 +336,7 @@ OWFluteCancel2:
}
OWSmithAccept:
{
lda FollowerIndicator : cmp.b #$07 : beq +
lda.l FollowerIndicator : cmp.b #$07 : beq +
cmp.b #$08 : beq +
clc : rtl
+ sec : rtl
@@ -359,7 +373,7 @@ LoadMapDarkOrMixed:
CMP.b #!FLAG_OW_MIXED : REP #$30 : BEQ .mixed
LDX.w #$03FE ; draw vanilla Dark World (what we wrote over)
.copy_next
LDA.w WorldMap_DarkWorldTilemap,X : STA.w $1000,X
LDA.w WorldMap_DarkWorldTilemap,X : STA.w GFXStripes,X
DEX : DEX : BPL .copy_next
BRL .end
.mixed
@@ -526,7 +540,7 @@ OWBonkDrops:
; JSLSpriteSFX_QueueSFX3WithPan
.load_item_and_mw
LDA 3,S : TAX : INX : LDA.w OWBonkPrizeData,X
LDA.b 3,S : TAX : INX : LDA.w OWBonkPrizeData,X
PHA : INX : LDA.w OWBonkPrizeData,X : BEQ +
; multiworld item
DEX : PLA ; A = item id; X = row + 3
@@ -579,11 +593,11 @@ OWBonkDrops:
PLA : BNE + ; S = FlagBitmask, X (row + 2)
TYX : JSL Sprite_IsOnscreen : BCC +
LDA.b IndoorsFlag : BEQ ++
LDA.l RoomDataWRAM[$0120].high : ORA 1,S : STA.l RoomDataWRAM[$0120].high
LDA.w $0400 : ORA 1,S : STA.w $0400
LDA.l RoomDataWRAM[$0120].high : ORA.b 1,S : STA.l RoomDataWRAM[$0120].high
LDA.w $0400 : ORA.b 1,S : STA.w $0400
BRA .increment_collection
++
LDX.b OverworldIndex : LDA.l OverworldEventDataWRAM,X : ORA 1,S : STA.l OverworldEventDataWRAM,X
LDX.b OverworldIndex : LDA.l OverworldEventDataWRAM,X : ORA.b 1,S : STA.l OverworldEventDataWRAM,X
.increment_collection
REP #$20
@@ -623,10 +637,13 @@ OWBonkDrops:
; sets bitmask flag, uses free RAM
PLA : STA.w SpriteSpawnStep,Y ; S = X (row + 2)
; sets MW player
PLX : INX : INX
LDA.w OWBonkPrizeData,X : STA.w SprItemMWPlayer,Y
; determines the initial spawn point of item
PLX : INX : INX : INX
INX
LDA.w SpritePosYLow,Y : SEC : SBC.w OWBonkPrizeData,X : STA.w SpritePosYLow,Y
LDA.w SpritePosYHigh,Y : SBC #$00 : STA.w SpritePosYHigh,Y
LDA.w SpritePosYHigh,Y : SBC.b #$00 : STA.w SpritePosYHigh,Y
BRA .return+2
@@ -661,7 +678,7 @@ OWBonkDropCollected:
LDA.l RoomDataWRAM[$0120].high : AND.b 3,S : BEQ .return ; S = Collected, FlagBitmask, X (row + 2)
SEC : RTS
+
LDX.b OverworldIndex : LDA.l OverworldEventDataWRAM,X : AND 3,S : BEQ .return ; S = Collected, FlagBitmask, X (row + 2)
LDX.b OverworldIndex : LDA.l OverworldEventDataWRAM,X : AND.b 3,S : BEQ .return ; S = Collected, FlagBitmask, X (row + 2)
SEC : RTS
.return
@@ -744,8 +761,8 @@ OWDetectSpecialTransition:
OWEdgeTransition:
{
LDA.l OWMode : ORA.l OWMode+1 : BEQ .unshuffled
LDY.w RandoOverworldTargetEdge : CPY.b #$7F
BEQ .unshuffled
LDY.w RandoOverworldTargetEdge : STZ.w RandoOverworldTargetEdge
CPY.b #$7F : BEQ .unshuffled
REP #$10
LDX.w RandoOverworldEdgeAddr
PHB : PHK : PLB
@@ -757,8 +774,7 @@ OWEdgeTransition:
.unshuffled
LDA.l Overworld_ActualScreenID,X : ORA.l CurrentWorld ; what we wrote over
TAX : LDA.l OWMode+1 : AND.b #!FLAG_OW_MIXED : BEQ .vanilla
LDA.l OWTileWorldAssoc,X : CMP.l CurrentWorld : BEQ .vanilla ; if dest screen mismatches the current world
TXA : EOR #$40 : RTL
JML OWApplyWorld_fromScreen
.vanilla
TXA : RTL
@@ -794,18 +810,18 @@ OWShuffle:
ldx.b OverworldIndex : lda.l OWTileWorldAssoc,X : eor.l CurrentWorld : beq +
; fake world, will treat this OW area as opposite world
txa : eor.b #$40 : tax
+ txa : and #$40 : !add.w OverworldSlotPosition : rep #$30 : and #$00ff : asl #3
+ txa : and.b #$40 : !ADD.w OverworldSlotPosition : rep #$30 : and.w #$00ff : asl #3
adc 1,S : tax
adc.b 1,S : tax
asl.w OverworldSlotPosition : pla
;x = offset to edgeoffsets table
sep #$20 : lda.l OWEdgeOffsets,x : and #$ff : beq .noTransition : pha ;get number of transitions
sep #$20 : lda.l OWEdgeOffsets,x : and.b #$ff : beq .noTransition : pha ;get number of transitions
;s1 = number of transitions left to check
inx : lda.l OWEdgeOffsets,x ;record id of first transition in table
;multiply ^ by 16, 16bytes per record
sta.w CPUMULTA : lda #16 : sta.w CPUMULTB ;wait 8 cycles
sta.w CPUMULTA : lda.b #16 : sta.w CPUMULTB ;wait 8 cycles
pla ;a = number of trans
rep #$20
and.w #$00ff
@@ -814,7 +830,7 @@ OWShuffle:
.nextTransition
pha
jsr OWSearchTransition_entry : bcs .newDestination
txa : !add.w #$0010 : tax
txa : !ADD.w #$0010 : tax
pla : dec : bne .nextTransition : bra .noTransition
.newDestination
@@ -836,8 +852,8 @@ OWSearchTransition:
;A-16 XY-16
lda.w TransitionDirection : bne + ;north
lda.l OWNorthEdges,x : dec
cmp.b LinkPosX : !bge .exitloop
lda.l OWNorthEdges+2,x : cmp.b LinkPosX : !blt .exitloop
cmp.b LinkPosX : !BGE .exitloop
lda.l OWNorthEdges+2,x : cmp.b LinkPosX : !BLT .exitloop
;MATCH
lda.l OWNorthEdges+14,x : tay ;y = record id of dest
lda.l OWNorthEdges+12,x ;a = current terrain
@@ -845,8 +861,8 @@ OWSearchTransition:
bra .matchfound
+ dec : bne + ;south
lda.l OWSouthEdges,x : dec
cmp.b LinkPosX : !bge .exitloop
lda.l OWSouthEdges+2,x : cmp.b LinkPosX : !blt .exitloop
cmp.b LinkPosX : !BGE .exitloop
lda.l OWSouthEdges+2,x : cmp.b LinkPosX : !BLT .exitloop
;MATCH
lda.l OWSouthEdges+14,x : tay ;y = record id of dest
lda.l OWSouthEdges+12,x ;a = current terrain
@@ -854,16 +870,16 @@ OWSearchTransition:
bra .matchfound
+ dec : bne + ; west
lda.l OWWestEdges,x : dec
cmp.b LinkPosY : !bge .exitloop
lda.l OWWestEdges+2,x : cmp.b LinkPosY : !blt .exitloop
cmp.b LinkPosY : !BGE .exitloop
lda.l OWWestEdges+2,x : cmp.b LinkPosY : !BLT .exitloop
;MATCH
lda.l OWWestEdges+14,x : tay ;y = record id of dest
lda.l OWWestEdges+12,x ;a = current terrain
ldx.w #OWEastEdges ;x = address of table
bra .matchfound
+ lda.l OWEastEdges,x : dec ;east
cmp.b LinkPosY : !bge .exitloop
lda.l OWEastEdges+2,x : cmp.b LinkPosY : !blt .exitloop
cmp.b LinkPosY : !BGE .exitloop
lda.l OWEastEdges+2,x : cmp.b LinkPosY : !BLT .exitloop
;MATCH
lda.l OWEastEdges+14,x : tay ;y = record id of dest
lda.l OWEastEdges+12,x ;a = current terrain
@@ -877,7 +893,7 @@ OWSearchTransition:
OWNewDestination:
{
tya : sta.w CPUMULTA : lda.b #16 : sta.w CPUMULTB ;wait 8 cycles
rep #$20 : txa : nop : !add.w CPUPRODUCT : tax ;a = offset to dest record
rep #$20 : txa : nop : !ADD.w CPUPRODUCT : tax ;a = offset to dest record
lda.w $0008,x : sta.b Scrap04 ;save dest OW slot/ID
ldy.b LinkPosY : lda.w TransitionDirection : dec #2 : bpl + : ldy.b LinkPosX : + sty.b Scrap06
@@ -888,21 +904,21 @@ OWNewDestination:
LDA.l OWMode : AND.w #$0007 : BEQ .noLayoutShuffle ;temporary fix until VRAM issues are solved
lda.w $0006,x : sta.b Scrap06 ;set coord
lda.w $000a,x : sta.b OverworldMap16Buffer ;VRAM
tya : and.w #$01ff : cmp.b 3,s : !blt .adjustMainAxis
dec : cmp.b 1,s : !bge .adjustMainAxis
inc : pha : lda.b Scrap06 : and.w #$fe00 : !add.b 1,s : sta.b Scrap06 : pla
tya : and.w #$01ff : cmp.b 3,s : !BLT .adjustMainAxis
dec : cmp.b 1,s : !BGE .adjustMainAxis
inc : pha : lda.b Scrap06 : and.w #$fe00 : !ADD.b 1,s : sta.b Scrap06 : pla
; adjust and set other VRAM addresses
lda.w $0006,x : pha : lda.b Scrap06 : !sub 1,s
lda.w $0006,x : pha : lda.b Scrap06 : !SUB 1,s
jsl DivideByTwoPreserveSign : jsl DivideByTwoPreserveSign : jsl DivideByTwoPreserveSign : jsl DivideByTwoPreserveSign : pha ; number of tiles
lda.w TransitionDirection : dec #2 : bmi +
pla : pea.w $0000 : bra ++ ;pla : asl #7 : pha : bra ++ ; y-axis shifts VRAM by increments of 0x80 (disabled for now)
+ pla : asl : pha ; x-axis shifts VRAM by increments of 0x02
++ lda.b OverworldMap16Buffer : !add 1,s : sta.b OverworldMap16Buffer : pla : pla
++ lda.b OverworldMap16Buffer : !ADD.b 1,s : sta.b OverworldMap16Buffer : pla : pla
.adjustMainAxis
LDA.b OverworldMap16Buffer : SEC : SBC #$0400 : AND #$0F00 : ASL : XBA : STA.b OverworldTilemapIndexY ; vram
LDA.b OverworldMap16Buffer : SEC : SBC #$0010 : AND #$003E : LSR : STA.b OverworldTilemapIndexX
LDA.b OverworldMap16Buffer : SEC : SBC.w #$0400 : AND.w #$0F00 : ASL : XBA : STA.b OverworldTilemapIndexY ; vram
LDA.b OverworldMap16Buffer : SEC : SBC.w #$0010 : AND.w #$003E : LSR : STA.b OverworldTilemapIndexX
.noLayoutShuffle
LDA.w $000F,X : AND.w #$00FF : STA.w RandoOverworldWalkDist ; position to walk to after transition (if non-zero)
@@ -920,47 +936,47 @@ OWNewDestination:
pla : pla : sep #$10 : ldy.w TransitionDirection
ldx.w OWCoordIndex,y : lda.b LinkPosY,x : and.w #$fe00 : pha
lda.b LinkPosY,x : and.w #$01ff : pha ;s1 = relative cur, s3 = ow cur
lda.b Scrap06 : and #$fe00 : !sub.b 3,s : pha ;set coord, s1 = ow diff, s3 = relative cur, s5 = ow cur
lda.b Scrap06 : and.w #$01ff : !sub.b 3,s : pha ;s1 = rel diff, s3 = ow diff, s5 = relative cur, s7 = ow cur
lda.b Scrap06 : and.w #$fe00 : !SUB.b 3,s : pha ;set coord, s1 = ow diff, s3 = relative cur, s5 = ow cur
lda.b Scrap06 : and.w #$01ff : !SUB.b 3,s : pha ;s1 = rel diff, s3 = ow diff, s5 = relative cur, s7 = ow cur
lda.b Scrap06 : sta.b LinkPosY,x : and.w #$fe00 : sta.b Scrap06 ;set coord
ldx.w OWBGIndex,y : lda.b BG2H,x : !add.b 1,s : adc.b 3,s : sta.b BG2H,x
ldx.w OWCameraIndex,y : lda.w CameraScrollN,x : !add.b 1,s : adc.b 3,s : sta.w CameraScrollN,x
ldx.w OWCameraIndex,y : lda.w CameraScrollS,x : !add.b 1,s : adc.b 3,s : sta.w CameraScrollS,x
ldx.w OWBGIndex,y : lda.b BG2H,x : !ADD.b 1,s : adc.b 3,s : sta.b BG2H,x
ldx.w OWCameraIndex,y : lda.w CameraScrollN,x : !ADD.b 1,s : adc.b 3,s : sta.w CameraScrollN,x
ldx.w OWCameraIndex,y : lda.w CameraScrollS,x : !ADD.b 1,s : adc.b 3,s : sta.w CameraScrollS,x
pla : jsl DivideByTwoPreserveSign : pha
ldx.w OWBGIndex,y : lda.b BG1H,x : !add.b 1,s : sta.b BG1H,x : pla
ldx.w OWBGIndex,y : lda.b BG1H,x : !add.b 1,s : sta.b BG1H,x : pla
ldx.w OWBGIndex,y : lda.b BG1H,x : !ADD.b 1,s : sta.b BG1H,x : pla
ldx.w OWBGIndex,y : lda.b BG1H,x : !ADD.b 1,s : sta.b BG1H,x : pla
pla : pla
;fix camera unlock
lda.b BG2H,x : !sub.b Scrap06 : bpl +
lda.b BG2H,x : !SUB.b Scrap06 : bpl +
pha : lda.b Scrap06 : sta.b BG2H,x
ldx.w OWCameraIndex,y : lda.w CameraScrollN,x : !sub.b 1,s : sta.w CameraScrollN,x
lda.w CameraScrollS,x : !sub.b 1,s : sta.w CameraScrollS,x : pla
ldx.w OWCameraIndex,y : lda.w CameraScrollN,x : !SUB.b 1,s : sta.w CameraScrollN,x
lda.w CameraScrollS,x : !SUB.b 1,s : sta.w CameraScrollS,x : pla
bra .adjustOppositeAxis
+ lda.b Scrap06 : ldx.w OWCameraRangeIndex,y : !add.w OWCameraRange,x : sta.b Scrap06
ldx.w OWBGIndex,y : !sub.b BG2H,x : bcs .adjustOppositeAxis
+ lda.b Scrap06 : ldx.w OWCameraRangeIndex,y : !ADD.w OWCameraRange,x : sta.b Scrap06
ldx.w OWBGIndex,y : !SUB.b BG2H,x : bcs .adjustOppositeAxis
pha : lda.b Scrap06 : sta.b BG2H,x
ldx.w OWCameraIndex,y : lda.w CameraScrollN,x : !add.b 1,s : sta.w CameraScrollN,x
lda.w CameraScrollS,x : !add.b 1,s : sta.w CameraScrollS,x : pla
ldx.w OWCameraIndex,y : lda.w CameraScrollN,x : !ADD.b 1,s : sta.w CameraScrollN,x
lda.w CameraScrollS,x : !ADD.b 1,s : sta.w CameraScrollS,x : pla
.adjustOppositeAxis
;opposite coord stuff
rep #$30 : lda OWOppDirectionOffset,y : and.w #$00ff : bit.w #$0080 : beq +
rep #$30 : lda.w OWOppDirectionOffset,y : and.w #$00ff : bit.w #$0080 : beq +
ora.w #$ff00 ;extend 8-bit negative to 16-bit negative
+ pha : cpy.w #$0002 : lda.w OverworldSlotPosition : !bge +
and.w #$00f0 : pha : lda.b Scrap04 : asl : and.w #$0070 : !sub.b 1,s : tax : pla : txa
!add 1,s : tax : pla : txa : asl : asl : asl : asl : asl : pha : bra ++
+ and.w #$000f : pha : lda.b Scrap04 : asl : and.w #$000f : !sub.b 1,s : !add.b 3,s
+ pha : cpy.w #$0002 : lda.w OverworldSlotPosition : !BGE +
and.w #$00f0 : pha : lda.b Scrap04 : asl : and.w #$0070 : !SUB.b 1,s : tax : pla : txa
!ADD.b 1,s : tax : pla : txa : asl : asl : asl : asl : asl : pha : bra ++
+ and.w #$000f : pha : lda.b Scrap04 : asl : and.w #$000f : !SUB.b 1,s : !ADD.b 3,s
sep #$10 : tax : phx : ldx.b #$0 : phx : rep #$10 : pla : plx : plx : pha
++ sep #$10 : ldx OWOppCoordIndex,y : lda.b LinkPosY,x : !add.b 1,s : sta.b LinkPosY,x ;set coord
ldx OWOppBGIndex,y : lda.b BG2H,x : !add.b 1,s : sta.b BG2H,x
ldx OWOppCameraIndex,y : lda.w CameraScrollN,x : !add.b 1,s : sta.w CameraScrollN,x
ldx OWOppCameraIndex,y : lda.w CameraScrollS,x : !add.b 1,s : sta.w CameraScrollS,x
ldx OWOppBGIndex,y : lda.b BG1H,x : !add.b 1,s : sta.b BG1H,x
lda.w TransitionDirection : asl : tax : lda.w CameraTargetN,x : !add.b 1,s : sta.w CameraTargetN,x : pla
++ sep #$10 : ldx.w OWOppCoordIndex,y : lda.b LinkPosY,x : !ADD.b 1,s : sta.b LinkPosY,x ;set coord
ldx.w OWOppBGIndex,y : lda.b BG2H,x : !ADD.b 1,s : sta.b BG2H,x
ldx.w OWOppCameraIndex,y : lda.w CameraScrollN,x : !ADD.b 1,s : sta.w CameraScrollN,x
ldx.w OWOppCameraIndex,y : lda.w CameraScrollS,x : !ADD.b 1,s : sta.w CameraScrollS,x
ldx.w OWOppBGIndex,y : lda.b BG1H,x : !ADD.b 1,s : sta.b BG1H,x
lda.w TransitionDirection : asl : tax : lda.w CameraTargetN,x : !ADD.b 1,s : sta.w CameraTargetN,x : pla
sep #$30 : lda.b Scrap04 : and.b #$3f : !add OWOppSlotOffset,y : asl : sta.w OverworldSlotPosition
sep #$30 : lda.b Scrap04 : and.b #$3f : !ADD.w OWOppSlotOffset,y : asl : sta.w OverworldSlotPosition
; crossed OW shuffle and terrain
ldx.b Scrap05 : ldy.b Scrap08 : jsr OWWorldTerrainUpdate
@@ -1186,6 +1202,12 @@ OWEndScrollTransition:
CMP.l Overworld_FinalizeEntryOntoScreen_Data,X ; what we wrote over
RTL
}
OWSpecialReturnTriggerClear:
{
STZ.b SubSubModule : STZ.b RoomIndex ; what we wrote over
STZ.w RandoOverworldTargetEdge
RTL
}
;Data
org $aaa000

Binary file not shown.