diff --git a/LTTP_RND_GeneralBugfixes.asm b/LTTP_RND_GeneralBugfixes.asm index 90a02c9..1850433 100644 --- a/LTTP_RND_GeneralBugfixes.asm +++ b/LTTP_RND_GeneralBugfixes.asm @@ -44,7 +44,10 @@ dw !ROM_VERSION_HIGH !MS_GOT = "$7F5031" -!REDRAW = "$7F5000" +;!REDRAW = "$7F5000" +!SPRITE_REDRAW = "$7E0790" ; 16 bytes +!SPRITE_OAM = "$7EC025" ; 16 bytes +!SPRITE_DYNAMIC_OAM = "$7EC035" ; 16 bytes !GANON_WARP_CHAIN = "$7F5032"; !TILE_UPLOAD_BUFFER = "$7EA180"; @@ -97,6 +100,7 @@ function hexto555(h) = ((((h&$FF)/8)<<10)|(((h>>8&$FF)/8)<<5)|(((h>>16&$FF)/8)<< !FLAG_OW_MIXED = $04 !FLAG_OW_CROSSED = $02 +!FLAG_OW_BONKDROP = $02 incsrc hooks.asm incsrc treekid.asm @@ -513,6 +517,9 @@ Attract_DecompressStoryGfx: org $00E529 LoadSelectScreenGfx: +org $00E784 +LoadCommonSprites_in_file_select: + org $00F945 PrepDungeonExit: @@ -527,6 +534,9 @@ Module_PreDungeon: org $028296 .setAmbientSfx +org $828AD9 +Underworld_SetBossOrSancMusicUponEntry: + org $02A0A8 Dungeon_SaveRoomData: @@ -536,6 +546,9 @@ Dungeon_SaveRoomData_justKeys: org $02A4E3 Overworld_ActualScreenID: +org $02A9F3 +OverworldHandleTransitions_change_palettes: + org $02B861 Dungeon_SaveRoomQuadrantData: @@ -545,12 +558,18 @@ CalculateTransitionLanding: org $02C176 Overworld_FinalizeEntryOntoScreen_Data: +org $82C3F2 +OverworldLoadScreensPaletteSet_long: + org $02D9B9 Underworld_LoadSpawnEntrance: org $02E99D FluteMenu_LoadTransport: +org $02FD6D +LoadGearPalettes_link: + org $02FD8A ; 17D8A - Bank0E.asm: 3732 Note: Different bank LoadGearPalettes_bunny: @@ -617,6 +636,9 @@ Sprite_PrepAndDrawSingleLargeLong: org $06DC00 Sprite_PrepAndDrawSingleSmallLong: +org $06E41C +Sprite_PrepOAMCoordLong: + org $06EA18 Sprite_ApplySpeedTowardsPlayerLong: @@ -656,14 +678,17 @@ Ancilla_ReceiveItem: org $08C505 Ancilla_ReceiveItem_objectFinished: -org $08CE93 -Ancilla_BreakTowerSeal_draw_single_crystal: +org $08CE2E +GTCutscene_AnimateCrystals_NoRotate: + +org $08CEB6 +GTCutscene_DrawSingleCrystal_SkipCrystal: org $08CEC3 -Ancilla_BreakTowerSeal_stop_spawning_sparkles: +GTCutscene_DrawSingleCrystal_SkipSparkle: org $08CF59 -BreakTowerSeal_ExecuteSparkles: +GTCutscene_SparkleALot: org $08F710 Ancilla_SetOam_XY_Long: @@ -829,6 +854,9 @@ DiggingGameGuy_AttemptPrizeSpawn: org $1EDE28 Sprite_GetEmptyBottleIndex: ; this is totally in sprite_bees.asm +org $1EDE8A +GoldBee_SpawnSelf: + org $1EF4E7 Sprite_PlayerCantPassThrough: ;================================================================================ diff --git a/bookofmudora.asm b/bookofmudora.asm index 0e2f335..b120b56 100644 --- a/bookofmudora.asm +++ b/bookofmudora.asm @@ -5,13 +5,12 @@ LoadLibraryItemGFX: LDA.l LibraryItem_Player : STA !MULTIWORLD_SPRITEITEM_PLAYER_ID %GetPossiblyEncryptedItem(LibraryItem, SpriteItemValues) STA $0E80, X ; Store item type - JSL.l PrepDynamicTile -RTL + JML RequestSlottedTile ;-------------------------------------------------------------------------------- DrawLibraryItemGFX: PHA LDA $0E80, X ; Retrieve stored item type - JSL.l DrawDynamicTile + JSL.l DrawSlottedTile PLA RTL ;-------------------------------------------------------------------------------- @@ -25,27 +24,23 @@ RTL ;================================================================================ ; Randomize Bonk Keys ;-------------------------------------------------------------------------------- -!REDRAW = "$7F5000" -;-------------------------------------------------------------------------------- LoadBonkItemGFX: LDA.b #$08 : STA $0F50, X ; thing we wrote over LoadBonkItemGFX_inner: - LDA.b #$00 : STA !REDRAW JSR LoadBonkItem_Player : STA !MULTIWORLD_SPRITEITEM_PLAYER_ID JSR LoadBonkItem - JSL.l PrepDynamicTile -RTL + JML RequestSlottedTile ;-------------------------------------------------------------------------------- DrawBonkItemGFX: PHA - LDA !REDRAW : BEQ .skipInit ; skip init if already ready - JSL.l LoadBonkItemGFX_inner - BRA .done ; don't draw on the init frame + LDA.w !SPRITE_REDRAW, X : BEQ .skipInit ; skip init if already ready + JSL.l LoadBonkItemGFX_inner + LDA.w !SPRITE_REDRAW, X : CMP.b #$02 : BEQ .skipInit + BRA .done ; don't draw on the init frame .skipInit - - JSR LoadBonkItem - JSL.l DrawDynamicTileNoShadow + JSR LoadBonkItem + JSL DrawSlottedTile .done PLA @@ -69,7 +64,7 @@ RTL LoadBonkItem: LDA $A0 ; check room ID - only bonk keys in 2 rooms so we're just checking the lower byte CMP #115 : BNE + ; Desert Bonk Key - LDA.l BonkKey_Desert + LDA.l BonkKey_Desert BRA ++ + : CMP #140 : BNE + ; GTower Bonk Key LDA.l BonkKey_GTower @@ -85,7 +80,7 @@ LoadBonkItem_Player: LDA.l BonkKey_Desert_Player BRA ++ + : CMP #140 : BNE + ; GTower Bonk Key - LDA.l BonkKey_GTower_Player + LDA.l BonkKey_GTower_Player BRA ++ + LDA.b #$00 diff --git a/bugfixes.asm b/bugfixes.asm index 8555c5e..32764e2 100644 --- a/bugfixes.asm +++ b/bugfixes.asm @@ -200,6 +200,27 @@ LDA $1B : BNE + + RTL +;-------------------------------------------------------------------------------- +; Fix losing VRAM gfx when using quake +PostNMIUpdateBGCharHalf: + STA.w $420B : SEP #$10 ; what we wrote over + LDA.w $0116 : CMP.b #$46 : BNE .return ; checks to see if this is the last VRAM write + LDA.b $5D : CMP.b #$08 : BCC + : CMP.b #$0A+1 : BCS + ; skip if we're mid-medallion + RTL + + JSL HeartPieceSetRedraw ; set redraw flag for items +.return +RTL + +; Force redraws of items following map checks +PostOverworldGfxLoad: + INC.b $11 : STZ.b $13 ; what we wrote over + JSL HeartPieceSetRedraw +RTL +PostUnderworldMap: + JSL HeartPieceSetRedraw + LDA.l $7EC229 ; what we wrote over +RTL + ;-------------------------------------------------------------------------------- FixJingleGlitch: LDA.b $11 diff --git a/catfish.asm b/catfish.asm index ee55c48..7429cb7 100644 --- a/catfish.asm +++ b/catfish.asm @@ -1,25 +1,23 @@ ;================================================================================ ; Randomize Catfish ;-------------------------------------------------------------------------------- -!HEART_REDRAW = "$7F5000" LoadCatfishItemGFX: LDA.l CatfishItem_Player : STA !MULTIWORLD_SPRITEITEM_PLAYER_ID - LDA.l $1DE185 ; location randomizer writes catfish item to - JML PrepDynamicTile + LDA.l $1DE185 ; location randomizer writes catfish item to + JML RequestSlottedTile ;-------------------------------------------------------------------------------- DrawThrownItem: LDA $8A : CMP.b #$81 : BNE .catfish .zora - LDA.b #$01 : STA !HEART_REDRAW - LDA.l $1DE1C3 ; location randomizer writes zora item to + LDA.l $1DE1C3 ; location randomizer writes zora item to BRA .draw .catfish - LDA.l $1DE185 ; location randomizer writes catfish item to + LDA.l $1DE185 ; location randomizer writes catfish item to .draw - JML DrawDynamicTile + JML DrawSlottedTile ;-------------------------------------------------------------------------------- MarkThrownItem: PHA @@ -27,12 +25,12 @@ MarkThrownItem: LDA $8A : CMP.b #$81 : BNE .catfish .zora - JSL.l ItemSet_ZoraKing + JSL.l ItemSet_ZoraKing LDA ZoraItem_Player : STA !MULTIWORLD_ITEM_PLAYER_ID BRA .done .catfish - JSL.l ItemSet_Catfish + JSL.l ItemSet_Catfish LDA CatfishItem_Player : STA !MULTIWORLD_ITEM_PLAYER_ID .done diff --git a/darkworldspawn.asm b/darkworldspawn.asm index ba1b31a..97dbc2b 100644 --- a/darkworldspawn.asm +++ b/darkworldspawn.asm @@ -10,12 +10,14 @@ DoWorldFix: LDA InvertedMode : BEQ + JMP DoWorldFix_Inverted + - LDA FollowerIndicator : CMP #$04 : BEQ .aga1Alive ; if old man following, skip mirror/aga check LDA.l Bugfix_MirrorlessSQToLW : BEQ .skip_mirror_check - LDA MirrorEquipment : AND #$02 : BEQ .noMirror ; check if we have the mirror + LDA FollowerIndicator : CMP #$04 : BNE + ; if old man following, skip mirror/aga check + LDA.l OldManRetrievalWorld + BRA .noMirror + + LDA MirrorEquipment : AND #$02 : BEQ .noMirror ; check if we have the mirror .skip_mirror_check ; alt entrance point LDA ProgressIndicator : CMP.b #$03 : BCS .done ; check if agahnim 1 is alive - .aga1Alive + .setLightWorld LDA #$00 .noMirror STA CurrentWorld ; set flag to light world @@ -54,14 +56,18 @@ JMP DoWorldFix_skip_mirror_check RTL ;================================================================================ DoWorldFix_Inverted: - LDA FollowerIndicator : CMP #$04 : BEQ .aga1Alive ; if old man following, skip mirror/aga check LDA.l Bugfix_MirrorlessSQToLW : BEQ .skip_mirror_check - LDA.l MirrorEquipment : AND #$02 : BEQ .noMirror ; check if we have the mirror + LDA FollowerIndicator : CMP #$04 : BNE + ; if old man following, skip mirror/aga check + LDA.l OldManRetrievalWorld + BRA .setWorld + + LDA.l MirrorEquipment : AND #$02 : BEQ .noMirror ; check if we have the mirror .skip_mirror_check ; alt entrance point LDA ProgressIndicator : CMP.b #$03 : BCS .done ; check if agahnim 1 is alive .noMirror - .aga1Alive - LDA #$40 : STA CurrentWorld ; set flag to dark world + .setDarkWorld + LDA #$40 + .setWorld + STA CurrentWorld ; set flag to dark world LDA.l SmithDeleteOnSave : BEQ .transform LDA FollowerIndicator CMP #$07 : BEQ .clear ; clear frog @@ -129,17 +135,23 @@ RefreshRainAmmo: + CMP.b #$03 : BNE + ; Uncle %SetMinimum(CurrentMagic,MagicFiller,RainDeathRefillMagic_Uncle) %SetMinimum(BombsEquipment,BombsFiller,RainDeathRefillBombs_Uncle) - %SetMinimum(CurrentArrows,ArrowsFiller,RainDeathRefillArrows_Uncle) - BRA .done + LDA.l ArrowMode : BEQ ++ + LDA.l BowEquipment : BEQ +++ + ++ %SetMinimum(CurrentArrows,ArrowsFiller,RainDeathRefillArrows_Uncle) + +++ BRA .done + CMP.b #$02 : BNE + ; Cell %SetMinimum(CurrentMagic,MagicFiller,RainDeathRefillMagic_Cell) %SetMinimum(BombsEquipment,BombsFiller,RainDeathRefillBombs_Cell) - %SetMinimum(CurrentArrows,ArrowsFiller,RainDeathRefillArrows_Cell) + LDA.l ArrowMode : BEQ ++ + LDA.l BowEquipment : BEQ .done + ++ %SetMinimum(CurrentArrows,ArrowsFiller,RainDeathRefillArrows_Cell) BRA .done + CMP.b #$04 : BNE + ; Mantle %SetMinimum(CurrentMagic,MagicFiller,RainDeathRefillMagic_Mantle) %SetMinimum(BombsEquipment,BombsFiller,RainDeathRefillBombs_Mantle) - %SetMinimum(CurrentArrows,ArrowsFiller,RainDeathRefillArrows_Mantle) + LDA.l ArrowMode : BEQ ++ + LDA.l BowEquipment : BEQ .done + ++ %SetMinimum(CurrentArrows,ArrowsFiller,RainDeathRefillArrows_Mantle) + .done RTL diff --git a/doorrando/bugfix/kholdstare_shell_collision.asm b/doorrando/bugfix/kholdstare_shell_collision.asm new file mode 100644 index 0000000..cfbf7a4 --- /dev/null +++ b/doorrando/bugfix/kholdstare_shell_collision.asm @@ -0,0 +1,51 @@ +pushpc + +org $9E9463 +JSL CheckKholdShellCoordinates +BCC Sprite_A3_KholdstareShell_link_not_close +BRA Sprite_A3_KholdstareShell_link_close +NOP #13 + +Sprite_A3_KholdstareShell_link_close = $9E9478 +Sprite_A3_KholdstareShell_link_not_close = $9E9480 + +pullpc + +CheckKholdShellCoordinates: + +LDA.w $0D30, X +XBA +LDA.w $0D10, X ; full 16 bit X coordinate of sprite + +REP #$21 +SBC.w #$0020 +CMP.b $22 +BCS .not_colliding + +ADC.w #$0040 +CMP.b $22 +BCC .not_colliding + +SEP #$20 +LDA.w $0D20, X +XBA +LDA.w $0D00, X ; full 16 bit Y coordinate of sprite + +REP #$21 +SBC.w #$001F ; could go to 27 and let link squeeze in at Lanmo 2 (please adjust the following one) +CMP.b $20 +BCS .not_colliding + +ADC.w #$0037 +CMP.b $20 +BCC .not_colliding + +SEP #$20 ; collision detected +SEC +RTL + +.not_colliding +SEP #$30 +CLC +RTL + diff --git a/doorrando/doorrando.asm b/doorrando/doorrando.asm index 2a2ff56..08bdccd 100644 --- a/doorrando/doorrando.asm +++ b/doorrando/doorrando.asm @@ -41,6 +41,11 @@ DRScroll: db 0 OffsetTable: dw -8, 8 +org $A78010 +DRVersionInfo: +dw $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000 + +org $A78020 incsrc normal.asm incsrc scroll.asm @@ -53,6 +58,7 @@ incsrc math.asm incsrc hudadditions.asm incsrc dr_lobby.asm incsrc entrance_fixes.asm +incsrc bugfix/kholdstare_shell_collision.asm warnpc $A79C00 incsrc doortables.asm diff --git a/doorrando/doortables.asm b/doorrando/doortables.asm index abdd13e..1ae843a 100644 --- a/doorrando/doortables.asm +++ b/doorrando/doortables.asm @@ -693,4 +693,6 @@ dw $ffff SanctuaryDarkWorld: dw $ffff OldManDarkWorld: -dw $ffff \ No newline at end of file +dw $ffff +OldManRetrievalWorld: +dw $0000 \ No newline at end of file diff --git a/doorrando/drhooks.asm b/doorrando/drhooks.asm index b74c8a3..ac189a5 100644 --- a/doorrando/drhooks.asm +++ b/doorrando/drhooks.asm @@ -44,6 +44,8 @@ org $8293d1 ; <- 113d1 - Bank02.asm : 3683 (ADD $20 : STA $20 BRANCH_IOTA) jsl StraightStairsFix : nop org $829396 ; <- 11396 - Bank02.asm : 3641 (LDA $01C322, X) jsl StraightStairLayerFix +org $82c06d ; <- Bank02.asm : 9874 (LDX $0418, CMP.b #$02) +jsl DoorToStraight : nop org $82c092 ; STA $0020, Y : LDX #$00 jsl DoorToInroom : nop org $82c0f8 ; CMP $02C034, X @@ -190,10 +192,9 @@ JSL.l Underworld_DoorDown_Entry : CPX #$FF BEQ + : db $80, $1C ; BRA $028B04 NOP #6 : + -org $82C3F2 ; <- Bank02.asm:10521 Unused call -Underworld_DoorDown_Call: -org $82C3F3 -dw $8AD9 ; address of Bank02.asm:2085 +org $82FD00 ; unreachable code +Underworld_SetBossOrSancMusicUponEntry_long: +JSR Underworld_SetBossOrSancMusicUponEntry : RTL org $81AA90 JSL BigKeyDoorCheck : NOP @@ -212,9 +213,16 @@ bcs .normal rts .normal -; fixes an issue with edges -> normal doors (bombable, dashable, keydoor) -org $82C06A -JSL TransitionCalculateLanding_Fix : NOP #2 - org $82C157 JSL AlwaysPushThroughFDoors + +; Modified from OWR - will need to remove once merged +; org $85AF75 +; Sprite_6C_MirrorPortal: +; JSL FixOvalFadeOutMirror : NOP #2 ; LDA $7EF3CA : BNE $05AFDF +; org $85AFDF +; Sprite_6C_MirrorPortal_missing_mirror: + +org $80E766 +JML ConditionalLoadCommonSprites_Do3To4Low : NOP #2 +LoadCommonSprites_Prep3To4Low: diff --git a/doorrando/edges.asm b/doorrando/edges.asm index b7d11f1..62290ac 100644 --- a/doorrando/edges.asm +++ b/doorrando/edges.asm @@ -1,9 +1,7 @@ ; defines ; Ram usage -EdgeToNormalFlag = $7E1200 HorzEdge: - LDA.b #$00 : STA.l EdgeToNormalFlag cpy #$ff : beq + jsr DetectWestEdge : ldy #$02 : bra ++ + jsr DetectEastEdge @@ -18,7 +16,6 @@ HorzEdge: + clc : rts VertEdge: - LDA.b #$00 : STA.l EdgeToNormalFlag cpy #$ff : beq + jsr DetectNorthEdge : bra ++ + jsr DetectSouthEdge @@ -62,7 +59,6 @@ LoadEdgeRoomVert: lda $04 : and #$80 : bne .edge lda $04 : sta $01 ; load up flags in $01 and #$03 : cmp #$03 : beq .inroom - LDA.b #$01 : STA.l EdgeToNormalFlag ldy #$01 : jsr ShiftVariablesMainDir jsr PrepScrollToNormal bra .scroll @@ -302,22 +298,6 @@ DetectEastEdge: ldx #$08 .end txa : rts - -TransitionCalculateLanding_Fix: - LDA.l EdgeToNormalFlag : BEQ + - LDX.w $0418 : CPX.b #$01 : BNE + - LDA.b $20 : SBC #$08 : STA.b $20 - + PHK : PEA.w .jslrtsreturn-1 - PEA.w $02802C - JML CalculateTransitionLanding - .jslrtsreturn - LDX.w $0418 : CPX.b #$01 : BNE .zero ; the LDX is vanilla and needs to always run - LDA.l EdgeToNormalFlag : BEQ + - LDA.b $20 : ADC #$08 : STA.b $20 - .zero LDA.b #$00 : STA.l EdgeToNormalFlag - + JSL DoorToStraight -RTL - AlwaysPushThroughFDoors: PHA : AND.b #$F0 : CMP.b #$F0 : BNE + PLA : RTL diff --git a/doorrando/entrance_fixes.asm b/doorrando/entrance_fixes.asm index 7052972..1f540e9 100644 --- a/doorrando/entrance_fixes.asm +++ b/doorrando/entrance_fixes.asm @@ -12,9 +12,17 @@ ; 2) Draw over what vanilla just drew ; 3) Hijack the door tile type routine ; and replace the vanilla value with that of solid collision + +; For door dection free RAM at $19EE-$19FF has been co-opted to door each drawn doors position and type bytes +; 19EE is for the "current" door for the IdentifyBlockedEntrance routine +; The array at 19F0 is for the collision routine to retrieve that information as it is no longer +; available by that point ;=================================================================================================== pushpc +org $01B0E6 + JSL StoreDoorInfo + org $01892F DoorDrawJankMove: JML PrepDoorDraw @@ -30,9 +38,17 @@ warnpc $018939 org $01BF43 JSL AdjustEscapeDoorCollision +org $01C132 ; ADC.w #$0040 : TAX : LDA.b $00 + JSL AdjustEscapeDoorCollision_LowEntrance : NOP #2 + pullpc ;=================================================================================================== +StoreDoorInfo: + STA.w $1980,X + LDA.b $00 : STA.w $19F0,X + TXA +RTL PrepDoorDraw: ; first off, we need this routine to return to our jank hook @@ -43,6 +59,8 @@ PrepDoorDraw: ; Much easier to just tell you to look at $01890D in the disassembly ; and you should understand the vanilla program flow we need to reject PEA.w DoorDrawJankMove_return-1 + LDA.b $00 + STA.w $19EE ; for current routine ; copy vanilla code (but fast rom) LDA.l $8186F0,X @@ -103,6 +121,9 @@ AdjustEscapeDoorGraphics: ORA.w #$4000 ; horizontally flip STA.l $7E2000+$104,X + JSR IdentifySwampEntrance + BCS .fix_swamp_entrance_alternate + ; the state of the A, X, and Y registers is irrelevant when we exit ; they're all subsequently loaded with new values RTL @@ -133,29 +154,18 @@ AdjustEscapeDoorGraphics: STA.l $7E2000+$102,X ORA.w #$4000 ; horizontally flip STA.l $7E2000+$104,X + RTL .fix_swamp_entrance LDY.w $0460 ; get door index LDX.w $19A0-2,Y ; get tilemap index - ; row 0 - LDA.w #$9DfC - STA.l $7E2000+$000,X - STA.l $7E2000+$002,X - STA.l $7E2000+$004,X - STA.l $7E2000+$006,X - - ; row 1 + ; row 1 - outer section LDA.w #$0908 STA.l $7E2000+$080,X ORA.w #$4000 ; horizontally flip STA.l $7E2000+$086,X - LDA.w #$14E8 - STA.l $7E2000+$082,X - ORA.w #$4000 ; horizontally flip - STA.l $7E2000+$084,X - ; row 2 LDA.w #$0918 STA.l $7E2000+$100,X @@ -167,6 +177,20 @@ AdjustEscapeDoorGraphics: ORA.w #$4000 ; horizontally flip STA.l $7E2000+$104,X +.fix_swamp_entrance_alternate + ; row 0 + LDA.w #$9DFC + STA.l $7E2000+$000,X + STA.l $7E2000+$002,X + STA.l $7E2000+$004,X + STA.l $7E2000+$006,X + + ; row 1 - mid section + LDA.w #$14E8 + STA.l $7E2000+$082,X + ORA.w #$4000 ; horizontally flip + STA.l $7E2000+$084,X + ; row 3 LDA.w #$A82C STA.l $7E2000+$180,X @@ -210,15 +234,15 @@ BlockedEntrance: AdjustEscapeDoorCollision: LSR ; vanilla shift +AdjustEscapeDoorCollisionShared: ; save our parameters ; but one or both of these may not be necessary depending on how you detect these doors ; all that matters is that after identifying blockage, we have: ; Y is the same as what we entered with ; X has A>>1, for whatever A entered with PHA - LDA.w $1980, Y ; grab door info (type) - AND.w #$00FF - STA.b $0A ; store in temporary variable + LDA.w $19F0, Y ; grab door info (type, position) + STA.w $19EE ; store in temporary variable JSR IdentifyBlockedEntrance PLX ; this is a TAX in vanilla, just have X pull A instead @@ -235,11 +259,14 @@ AdjustEscapeDoorCollision: RTL +AdjustEscapeDoorCollision_LowEntrance: + ADC.w #$0040 ; vanilla add + JMP AdjustEscapeDoorCollisionShared + ;=================================================================================================== ; Enter with: -; $0A containing the door information: position and type bytes -; which should be from $1980, Y or [$B7], Y depending on where in the door process we are +; $19EE containing the door information: position and type bytes ; Exit with: ; carry clear - leave door alone ; carry set - block door @@ -262,9 +289,8 @@ IdentifyBlockedEntrance: - INX #2 LDA.l RemoveRainDoorsRoom, X : CMP.w #$FFFF : BEQ .leave_alone CMP $A0 : BNE - - LDA.b $0A - CMP.w #$000A : BCC .continue - CMP.w #$0014 : BCS .continue + LDA.l RainDoorMatch, X + CMP.w $19EE : BNE .leave_alone BRA .block_door .continue BRA - diff --git a/doorrando/gfx.asm b/doorrando/gfx.asm index 94cb884..08ae228 100644 --- a/doorrando/gfx.asm +++ b/doorrando/gfx.asm @@ -92,4 +92,13 @@ OverridePaletteHeader: lda.l PaletteTable, x iny : rtl + rep #$20 : iny : lda [$0D], Y ; what we wrote over -rtl \ No newline at end of file +rtl + +Sprite_ConditionalPrepOAMCoord: + LDA.w $0E20,X : CMP.b #$62 : BNE .notMasterSword + LDA.w $0D90,X : BNE .specialCutscene + .notMasterSword + JML Sprite_PrepOAMCoordLong ; what we wrote over + .specialCutscene + SEC ; this prevents MasterSword sprite from drawing if it is a special cutscene +RTL \ No newline at end of file diff --git a/doorrando/hudadditions.asm b/doorrando/hudadditions.asm index 2e56f00..4b3facb 100644 --- a/doorrando/hudadditions.asm +++ b/doorrando/hudadditions.asm @@ -16,7 +16,7 @@ HudAdditions: + JSL HexToDec_fast .skip LDA #$207F : STA !GOAL_DRAW_ADDRESS+2 : STA !GOAL_DRAW_ADDRESS+4 - PLA : PHA : CMP.w #100 : !BLT + + LDA.b 1,S : CMP.w #100 : !BLT + LDX.b $05 : TXA : ORA.w #$2490 : STA !GOAL_DRAW_ADDRESS+2 ; draw 100's digit + PLA : CMP.w #10 : !BLT + LDX.b $06 : TXA : ORA.w #$2490 : STA !GOAL_DRAW_ADDRESS+4 ; draw 10's digit diff --git a/doorrando/normal.asm b/doorrando/normal.asm index 72c9512..6fcb7e5 100644 --- a/doorrando/normal.asm +++ b/doorrando/normal.asm @@ -1,6 +1,6 @@ WarpLeft: lda.l DRMode : beq .end - lda $040c : cmp.b #$ff : beq .end + JSR CheckIfCave : BCS .end lda $20 : ldx $aa jsr CalcIndex !add #$06 : ldy #$01 ; offsets in A, Y @@ -11,7 +11,7 @@ WarpLeft: WarpRight: lda.l DRMode : beq .end - lda $040c : cmp.b #$ff : beq .end + JSR CheckIfCave : BCS .end lda $20 : ldx $aa jsr CalcIndex !add #$12 : ldy #$ff ; offsets in A, Y @@ -22,7 +22,7 @@ WarpRight: WarpUp: lda.l DRMode : beq .end - lda $040c : cmp.b #$ff : beq .end + JSR CheckIfCave : BCS .end lda $22 : ldx $a9 jsr CalcIndex ldy #$02 ; offsets in A, Y @@ -40,7 +40,7 @@ endmacro WarpDown: lda.l DRMode : beq .end - lda $040c : cmp.b #$ff : beq .end + JSR CheckIfCave : BCS .end lda $22 : ldx $a9 jsr CalcIndex !add #$0c : ldy #$ff ; offsets in A, Y @@ -79,6 +79,14 @@ Cleanup: lda $ef rts +; carry set if cave, clear otherwise +CheckIfCave: + REP #$30 + LDA.b $A2 : CMP.w #$00E1 : BCS .invalid + SEP #$30 : CLC : RTS + .invalid + SEP #$30 : SEC : RTS + ;A needs be to the low coordinate, x needs to be either 0 for left,upper or non-zero for right,down ; This sets A (00,02,04) and stores half that at $04 for later use, (src door) CalcIndex: ; A->low byte of Link's Coord, X-> Link's quadrant, DoorOffset x 2 -> A, DoorOffset -> $04 (vert/horz agnostic) @@ -364,8 +372,7 @@ DoorToStraight: lda $a0 : cmp #$51 : bne .skip lda #$04 : sta $4e .skip pla - ; the ldx $0418 is now taken care of by TransitionCalculateLanding_Fix - .end cmp #$02 ;what we wrote over + .end LDX.w $0418 : CMP.b #$02 ; what we wrote over rtl } @@ -405,7 +412,7 @@ StraightStairsTrapDoor: .animateTraps lda #$05 : sta $11 inc $0468 : stz $068e : stz $0690 - ++ JSL Underworld_DoorDown_Call : rtl + ++ JML Underworld_SetBossOrSancMusicUponEntry_long + JML Dungeon_ApproachFixedColor ; what we wrote over } @@ -426,7 +433,7 @@ HandleSpecialDoorLanding: { HandleIncomingDoorState: PHA LDA.l DRMode : BEQ .noDoor - PLA : PHA : AND.b #$FA : CMP.b #$80 : bne .noDoor + LDA.b 1,S : AND.b #$FA : CMP.b #$80 : bne .noDoor .setDoorState LDA.w $0418 : AND.b #$02 : BNE + : INC @@ -434,7 +441,7 @@ HandleSpecialDoorLanding: { .noDoor PLA - CMP #$34 : bne + ; inroom stairs - PHA : LDA #$26 : STA $045E : PLA + CMP.b #$34 : BNE + ; inroom stairs + PHA : LDA.b #$26 : STA.w $045E : PLA + RTL } diff --git a/doorrando/overrides.asm b/doorrando/overrides.asm index bac5ee9..d955e0a 100644 --- a/doorrando/overrides.asm +++ b/doorrando/overrides.asm @@ -123,9 +123,18 @@ BlindZeldaDespawnFix: PLA : PLA : PEA.w SpritePrep_BlindMaiden_despawn_follower-1 : RTL + PLA : PLA : PEA.w SpritePrep_BlindMaiden_kill_the_girl-1 : RTL - BigKeyDoorCheck: CPY.w #$001E : BNE + ; skip if it isn't a BK door LDA.l DRFlags : AND #$0400 : BNE + ; skip if the flag is set - bk doors can be double-sided PLA : PEA.w RoomDraw_OneSidedShutters_South_onesided_shutter_or_big_key_door-1 + LDA.w #$0000 : RTL + +; FixOvalFadeOutMirror: +; LDA.b $10 : CMP.b #$0F : BEQ .skip_activation +; LDA.l InvertedMode : BNE + +; LDA.l CurrentWorld : BNE .skip_activation +; RTL +; + LDA.l CurrentWorld : BEQ .skip_activation +; RTL +; .skip_activation +; PLA : PLA : PLA : JML Sprite_6C_MirrorPortal_missing_mirror diff --git a/doorrando/spiral.asm b/doorrando/spiral.asm index 4ce37e2..a0c0ae7 100644 --- a/doorrando/spiral.asm +++ b/doorrando/spiral.asm @@ -1,24 +1,28 @@ RecordStairType: { pha lda.l DRMode : beq .norm - lda $040c : cmp #$ff : beq .norm + REP #$30 : LDA.b $A2 : CMP.w #$00E1 : BCS .norm + CMP #$00DF : BEQ .norm + SEP #$30 lda $0e cmp #$25 : bcc ++ ; don't record straight staircases sta $045e ++ pla : bra + - .norm pla : sta $a0 + .norm SEP #$30 : pla : sta $a0 + lda $063d, x rtl } SpiralWarp: { lda.l DRMode : beq .abort ; abort if not DR - lda $040c : cmp.b #$ff : beq .abort ; abort if not in dungeon + REP #$30 : LDA.b $A2 : CMP.w #$00E1 : BCS .abort + CMP #$00DF : BEQ .abort + SEP #$30 lda $045e : cmp #$5e : beq .gtg ; abort if not spiral - intended room is in A! cmp #$5f : beq .gtg cmp #$26 : beq .inroom .abort - stz $045e : lda $a2 : and #$0f : rtl ; clear,run hijacked code and get out + SEP #$30 : stz $045e : lda $a2 : and.b #$0f : rtl ; clear,run hijacked code and get out .inroom jsr InroomStairsWarp lda $a2 : and #$0f ; this is the code we are hijacking @@ -97,6 +101,11 @@ StairCleanup: { rts } +LookupSpiralOffset_long: + PHB : PHK : PLB + JSR LookupSpiralOffset + PLB : RTL + ;Sets the offset in A LookupSpiralOffset: { ;where link currently is in $a2: quad in a8 & #$03 diff --git a/elder.asm b/elder.asm index 5c4a6a6..43b6a1e 100644 --- a/elder.asm +++ b/elder.asm @@ -1,6 +1,6 @@ NewElderCode: { -LDA $8A : CMP #$1B : BEQ .newCodeContinue +LDA $8A : AND.b #$3F : CMP #$1B : BEQ .newCodeContinue ;Restore Jump we can keep the RTL so JML JML $05F0CD .newCodeContinue @@ -12,7 +12,7 @@ JSR Elder_Code PLB RTL - +} Elder_Draw: { @@ -60,7 +60,7 @@ RTL LDA.l GoalCounter CMP.l GoalItemRequirement : !BLT + SEP #$20 - JSL.l ActivateGoal + JSL ActivateTriforceCutscene + .dont_show @@ -69,3 +69,158 @@ RTL LDA.b $1A : LSR #5 : AND.b #$01 : STA.w $0DC0, X RTS } + +;-------------------------------------------------------------------------------- +; Triforce (Pedestal) Cutscene +;-------------------------------------------------------------------------------- +ActivateTriforceCutscene: + ; despawn other sprites + LDY.b #$0F + - LDA.w $0E20,Y : CMP.b #$16 : BNE + + CPY.b #$00 : BEQ .next + ; move Murahdahla to slot 0 for draw priority reasons + LDA.w $0E20,Y : STA.w $0E20 + LDA.w $0D00,Y : STA.w $0D00 + LDA.w $0D10,Y : STA.w $0D10 + LDA.w $0D20,Y : STA.w $0D20 + LDA.w $0D30,Y : STA.w $0D30 + LDA.w $0D40,Y : STA.w $0D40 + LDA.w $0F50,Y : STA.w $0F50 + LDA.w $0E40,Y : STA.w $0E40 + LDA.w $0E60,Y : STA.w $0E60 + LDA.w $0DD0,Y : STA.w $0DD0 + LDA.b #$02 : STA.w $0F20 + + LDA.b #$00 : STA.w $0DD0,Y + .next + DEY : BPL - + + LDA.b #$62 ; MasterSword Sprite + JSL Sprite_SpawnDynamically + + ; set up coords + LDA.b $22 : STA.w $0D10,Y + LDA.b $23 : STA.w $0D30,Y + LDA.b $20 : CLC : ADC.b #$08 : STA.w $0D00,Y + LDA.b $21 : ADC.b #$00 : STA.w $0D20,Y + + LDA.b #$01 : STA.w $0D90,Y ; our indicator this is a special cutscene sprite + INC : STA.b $2F ; makes Link face downward + + ; reset modules + LDA.b $1B : BEQ + + LDA.b #$07 + BRA ++ + + LDA.b #$09 + ++ STA.b $10 + STZ.b $11 : STZ.b $B0 +RTL + +pushpc + org $058928 + MasterSword_InPedestal_DoCutscene: + org $0589B1 + MasterSword_ConditionalHandleReceipt_DoReceipt: + + org $0588DF + JSL MasterSword_CheckIfPulled : PLX : NOP #2 + db $90 ; BCC instead of BEQ + org $05890E + JSL MasterSword_ConditionalActivateCutscene + org $05895F + JSL MasterSword_ConditionalGrabPose : NOP + org $058994 + JSL MasterSword_ConditionalGrabPose : NOP + org $058D1C + JML MasterSword_SpawnPendantProp_ChangePalette + MasterSword_SpawnPendantProp_ChangePalette_return: + org $0589A3 + JSL MasterSword_ConditionalHandleReceipt : NOP #2 +pullpc + +MasterSword_CheckIfPulled: + CPX.b #$80 : BEQ + + - CLC : RTL ; not on pedestal screen, continue with cutscene + + LDA.l $7EF280,X : AND.b #$40 ; what we wrote over + BEQ - : SEC : RTL + +MasterSword_ConditionalActivateCutscene: + LDA.w $0D90,X : BNE .specialCutscene + JML Sprite_CheckDamageToPlayerSameLayerLong ; what we wrote over + .specialCutscene + LDA.b #$02 : STA.w $02DA ; Link's 2-hands-up pose + STA.b $EE ; draw Link on top + LDA.b #$6A : JSL RequestSlottedTile ; draw Triforce piece in VRAM + PLA : PLA : PLA : JML MasterSword_InPedestal_DoCutscene ; do cutscene + +MasterSword_ConditionalGrabPose: + PHA + LDA.w $0D90,X : BNE .specialCutscene + PLA + STA.w $0377 : LDA.b #$01 ; what we wrote over + RTL + .specialCutscene + PLA + LDA.b #$01 +RTL + +MasterSword_SpawnPendantProp_ChangePalette: + STA.w $0D40,Y : PLX ; what we wrote over + LDA.w $0D90,X : BNE .specialCutscene + BRA .done + .specialCutscene + LDA.b #$08 : STA.w $0F50,Y ; change palette + LDA.b #$02 : STA.w $0F20,Y ; change layer +.done +JML MasterSword_SpawnPendantProp_ChangePalette_return + +MasterSword_ConditionalHandleReceipt: + LDA.w $0D90,X : BNE .specialCutscene + LDX.b $8A : LDA.l $7EF280,X ; what we wrote over + RTL + .specialCutscene + PLA : PLA : PEA.w MasterSword_ConditionalHandleReceipt_DoReceipt-1 + LDA.b 4,S : TAX + LDY.b #$6A + RTL + +pushpc + org $058AB6 + MasterSword_SpawnLightWell: + org $058AD0 + MasterSword_SpawnLightFountain: + org $058B62 + MasterSword_SpawnLightBeam: + + org $058941 + JSL MasterSword_ConditionalSpawnLightWell : NOP #2 + MasterSword_SpawnLightWell_return: + org $058952 + JSL MasterSword_ConditionalSpawnLightFountain : NOP #2 + MasterSword_SpawnLightFountain_return: + org $058B64 + JSL MasterSword_ConditionalSpawnLightBeam : NOP #2 +pullpc + +MasterSword_ConditionalSpawnLightWell: + INC.w $0D80,X ; part of what we wrote over + LDA.w $0D90,X : BNE .specialCutscene + PLA : PLA : PLA : PEA.w MasterSword_SpawnLightWell_return-1 + JML MasterSword_SpawnLightWell ; part of what we wrote over + .specialCutscene + RTL + +MasterSword_ConditionalSpawnLightFountain: + INC.w $0D80,X ; part of what we wrote over + LDA.w $0D90,X : BNE .specialCutscene + PLA : PLA : PLA : PEA.w MasterSword_SpawnLightFountain_return-1 + JML MasterSword_SpawnLightFountain ; part of what we wrote over + .specialCutscene + RTL + +MasterSword_ConditionalSpawnLightBeam: + LDA.w $0D90,X : BNE .specialCutscene + LDA.b #$62 : JSL Sprite_SpawnDynamically ; what we wrote over + RTL + .specialCutscene + LDY.b #$FF + RTL diff --git a/flute.asm b/flute.asm index 7128602..33f9985 100644 --- a/flute.asm +++ b/flute.asm @@ -7,12 +7,13 @@ SpawnHauntedGroveItem: LDA.l HauntedGroveItem_Player : STA !MULTIWORLD_SPRITEITEM_PLAYER_ID %GetPossiblyEncryptedItem(HauntedGroveItem, HeartPieceOutdoorValues) - JSL.l PrepDynamicTile - + LDA.b #$EB STA $7FFE00 JSL Sprite_SpawnDynamically + LDA.b #$01 : STA.w !SPRITE_REDRAW, Y + LDX.b #$00 LDA $2F : CMP.b #$04 : BEQ + : INX : + diff --git a/goalitem.asm b/goalitem.asm index aeb9f05..f047ed2 100644 --- a/goalitem.asm +++ b/goalitem.asm @@ -110,28 +110,64 @@ BRA .all_dungeons ;-------------------------------------------------------------------------------- -GetRequiredCrystalsForTower: - BEQ + : JSL.l BreakTowerSeal_ExecuteSparkles : + ; thing we wrote over - LDA.l NumberOfCrystalsRequiredForTower : CMP.b #$00 : BNE + : JML.l Ancilla_BreakTowerSeal_stop_spawning_sparkles : + - LDA.l NumberOfCrystalsRequiredForTower : CMP.b #$01 : BNE + : JML.l Ancilla_BreakTowerSeal_draw_single_crystal : + - LDA.l NumberOfCrystalsRequiredForTower : DEC #2 : TAX -JML.l GetRequiredCrystalsForTower_continue +GTCutscene_CrystalMasks: +db %00000000 ; 0 crystals +db %10000000 ; BIT INDEX DIAGRAM +db %00010010 ; 0 +db %00010101 ; 5 1 +db %10010101 ; 7 +db %10110110 ; 4 2 +db %00111111 ; 3 +db %10111111 ; 7 crystals ;-------------------------------------------------------------------------------- -GetRequiredCrystalsInX: - LDA.l NumberOfCrystalsRequiredForTower : CMP.b #$00 : BNE + - TAX - RTL - + +GTCutscene_ConditionalAnimateCrystals: + PHX : PHX + LDA.l NumberOfCrystalsRequiredForTower : TAX : LDA.l GTCutscene_CrystalMasks,X + PLX + - LSR : DEX : BPL - + PLX : BCC .skip_crystal - TXA +.draw_crystal + LDA.b $11 : BEQ + : JML.l GTCutscene_AnimateCrystals_NoRotate ; what we wrote over + + JML.l GTCutscene_AnimateCrystals_NextCrystal+4 -- CMP.l NumberOfCrystalsRequiredForTower : BCC + - SBC.l NumberOfCrystalsRequiredForTower ; carry guaranteed set - BRA - +.skip_crystal + JML.l GTCutscene_DrawSingleCrystal-3 +;-------------------------------------------------------------------------------- +GTCutscene_ConditionalDrawSingleCrystal: + LDA.w $06FA : BEQ .draw_crystal : STZ.w $06FA + LDA.l NumberOfCrystalsRequiredForTower : TAX + LDA.l GTCutscene_CrystalMasks,X : AND.b #$80 : BEQ .skip_crystal +.draw_crystal + LDX.w $0FA0 : PHY ; what we wrote over + JML.l GTCutscene_DrawSingleCrystal+4 +.skip_crystal + JML.l GTCutscene_DrawSingleCrystal_SkipCrystal +;-------------------------------------------------------------------------------- +GTCutscene_AnimateCrystals_Prep: + BEQ + : JSL.l GTCutscene_SparkleALot : + ; thing we wrote over + LDA.l NumberOfCrystalsRequiredForTower : BNE + + JML.l GTCutscene_DrawSingleCrystal_SkipSparkle + + CMP.b #$01 : BNE + + JML.l GTCutscene_DrawSingleCrystal + + INC.w $06FA ; some free ram OWR also uses + JML.l GTCutscene_AnimateCrystals_NextCrystal-2 +;-------------------------------------------------------------------------------- +GTCutscene_ActivateSparkle_SelectCrystal: + LDA.l NumberOfCrystalsRequiredForTower : BNE + + TAX : RTL + + TXA - + INC : CMP.l NumberOfCrystalsRequiredForTower : BNE + - LDA.b #$08 - + : DEC : TAX + - CMP.l NumberOfCrystalsRequiredForTower : BCC + + SBC.l NumberOfCrystalsRequiredForTower : BRA - ; carry guaranteed set + + + PHY : TAY + LDA.l NumberOfCrystalsRequiredForTower : TAX : LDA.l GTCutscene_CrystalMasks,X + LDX.b #$FF + - LSR : INX : BCC + + DEY + + BPL - + PLY RTL ;-------------------------------------------------------------------------------- CheckEnoughCrystalsForGanon: diff --git a/heartpieces.asm b/heartpieces.asm index 123e1ff..5faae3a 100644 --- a/heartpieces.asm +++ b/heartpieces.asm @@ -49,28 +49,27 @@ HeartContainerGet: BRA HeartPieceGet_skipLoad ;-------------------------------------------------------------------------------- -!REDRAW = "$7F5000" DrawHeartPieceGFX: PHP JSL.l Sprite_IsOnscreen : BCC .offscreen PHA : PHY - LDA !REDRAW : BEQ .skipInit ; skip init if already ready - JSL.l HeartPieceSpritePrep - JMP .done ; don't draw on the init frame + LDA.w !SPRITE_REDRAW, X : BEQ .skipInit ; skip init if already ready + JSL.l HeartPieceSpritePrep + LDA.w !SPRITE_REDRAW, X : CMP.b #$02 : BEQ .skipInit + BRA .done ; don't draw on the init frame .skipInit LDA $0E80, X ; Retrieve stored item type - + .skipLoad - - JSL.l DrawDynamicTile - - CMP #$03 : BNE + - PHA : LDA $0E60, X : ORA.b #$20 : STA $0E60, X : PLA - + - - JSL.l Sprite_DrawShadowLong + JSL DrawSlottedTile : BCS .done + ; draw shadow + CMP #$03 : BNE + + INC.b $00 : INC.b $00 : INC.b $00 : INC.b $00 ; move narrow sprite shadow over 4 pixels + PHA : LDA $0E60, X : ORA.b #$20 : STA $0E60, X : PLA + + + JSL.l Sprite_DrawShadowLong .done PLY : PLA @@ -78,20 +77,17 @@ DrawHeartPieceGFX: PLP RTL ;-------------------------------------------------------------------------------- -!REDRAW = "$7F5000" DrawHeartContainerGFX: PHP JSL.l Sprite_IsOnscreen : BCC DrawHeartPieceGFX_offscreen PHA : PHY - LDA !REDRAW : BEQ .skipInit ; skip init if already ready - JSL.l HeartContainerSpritePrep - BRA DrawHeartPieceGFX_done ; don't draw on the init frame + LDA.w !SPRITE_REDRAW, X : BEQ .skipInit ; skip init if already ready + JSL.l HeartContainerSpritePrep + BRA DrawHeartPieceGFX_done ; don't draw on the init frame .skipInit - LDA $0E80, X ; Retrieve stored item type - - BRA DrawHeartPieceGFX_skipLoad + BRA DrawHeartPieceGFX_skipInit ;-------------------------------------------------------------------------------- HeartContainerSound: LDA !MULTIWORLD_ITEM_PLAYER_ID : BNE + @@ -129,12 +125,18 @@ RTL RTL ;-------------------------------------------------------------------------------- HeartUpgradeSpawnDecision: ; this should return #$00 to make the hp spawn - LDA !FORCE_HEART_SPAWN : BEQ .normal_behavior + LDA !FORCE_HEART_SPAWN : BEQ .bonk_prize_check DEC : STA !FORCE_HEART_SPAWN LDA #$00 RTL - + .bonk_prize_check + PHX + LDA 2,S : TAX : LDA.w $0ED0, X : BEQ .normal_behavior-1 + PLX + LDA.b #$00 +RTL + PLX .normal_behavior LDA OverworldEventDataWRAM, X RTL @@ -154,34 +156,28 @@ RTL LDA OverworldEventDataWRAM, X : ORA.b #$40 : STA OverworldEventDataWRAM, X RTL ;-------------------------------------------------------------------------------- -!REDRAW = "$7F5000" HeartPieceSpritePrep: PHA LDA ServerRequestMode : BEQ + : : + - LDA #$01 : STA !REDRAW - LDA $5D : CMP #$14 : BEQ .skip ; skip if we're mid-mirror - - LDA #$00 : STA !REDRAW + LDA.b #$01 : STA.w !SPRITE_REDRAW, X JSL.l HeartPieceGetPlayer : STA !MULTIWORLD_SPRITEITEM_PLAYER_ID JSL.l LoadHeartPieceRoomValue ; load item type STA $0E80, X ; Store item type - JSL.l PrepDynamicTile + JSL.l RequestSlottedTile .skip PLA RTL ;-------------------------------------------------------------------------------- -!REDRAW = "$7F5000" HeartContainerSpritePrep: PHA - LDA #$00 : STA !REDRAW JSL.l HeartPieceGetPlayer : STA !MULTIWORLD_SPRITEITEM_PLAYER_ID JSL.l LoadHeartContainerRoomValue ; load item type STA $0E80, X ; Store item type - JSL.l PrepDynamicTile + JSL.l RequestSlottedTile PLA RTL @@ -196,7 +192,8 @@ LoadHeartPieceRoomValue: .done RTL ;-------------------------------------------------------------------------------- -!REDRAW = "$7F5000" +!DynamicDropGFXSlotCount_UW = (FreeUWGraphics_end-FreeUWGraphics)>>1 +!DynamicDropGFXSlotCount_OW = (FreeOWGraphics_end-FreeOWGraphics)>>1 HPItemReset: PHA LDA !MULTIWORLD_ITEM_PLAYER_ID : BNE .skip @@ -206,7 +203,14 @@ HPItemReset: .skip PLA .done - PHA : LDA #$01 : STA !REDRAW : PLA + PHA : PHY + LDY.b #$0F + - LDA.w $0DD0,Y : BEQ + + LDA.w !SPRITE_REDRAW, Y : CMP.b #$02 : BNE + + ; attempt redraw of any sprite using the overflow slot + LDA.b #$01 : STA.w !SPRITE_REDRAW, Y + + DEY : BPL - + PLY : PLA RTL ;-------------------------------------------------------------------------------- MaybeMarkDigSpotCollected: @@ -221,6 +225,7 @@ MaybeMarkDigSpotCollected: RTL ;-------------------------------------------------------------------------------- HeartPieceSpawnDelayFix: + JSL Sprite_DrawRippleIfInWater ; Fix the delay when spawning a HeartPiece sprite JSL.l Sprite_CheckIfPlayerPreoccupied : BCS + ; what we moved from $05F037 JSL.l Sprite_CheckDamageToPlayerSameLayerLong : RTL ; what we wrote over @@ -266,6 +271,9 @@ LoadIndoorValue: ++ %GetPossiblyEncryptedItem(HeartPiece_Graveyard_Warp, HeartPieceIndoorValues) JMP .done + + CMP.w #288 : BNE + + LDA.l OWBonkPrizeTable[42].loot + JMP .done + CMP.w #294 : BNE + %GetPossiblyEncryptedItem(HeartPiece_Mire_Warp, HeartPieceIndoorValues) JMP .done @@ -639,6 +647,9 @@ HeartPieceGetPlayer: ++ LDA HeartPiece_Graveyard_Warp_Player BRL .done + + CMP.w #288 : BNE + + LDA.l OWBonkPrizeTable[$2A].mw_player + BRL .done + CMP.w #294 : BNE + LDA HeartPiece_Mire_Warp_Player BRL .done @@ -663,21 +674,21 @@ HeartPieceGetPlayer: LDA EtherItem_Player BRL .done + CMP.w #$05 : BNE + - LDA.w $0ED0,X : CMP.w #$0010 : BNE ++ + LDA.w $0ED0,X : AND.w #$00FF : CMP.w #$0010 : BNE ++ LDA.l OWBonkPrizeTable[$01].mw_player BRL .done ++ LDA HeartPiece_Mountain_Warp_Player BRL .done + CMP.w #$0A : BNE + - LDA.w $0ED0,X : CMP.w #$0010 : BNE ++ + LDA.w $0ED0,X : AND.w #$00FF : CMP.w #$0010 : BNE ++ LDA.l OWBonkPrizeTable[$02].mw_player BRL .done ++ LDA.l OWBonkPrizeTable[$03].mw_player BRL .done + CMP.w #$10 : BNE + - LDA.w $0ED0,X : CMP.w #$0010 : BNE ++ + LDA.w $0ED0,X : AND.w #$00FF : CMP.w #$0010 : BNE ++ LDA.l OWBonkPrizeTable[$04].mw_player BRL .done ++ @@ -690,28 +701,28 @@ HeartPieceGetPlayer: LDA.l OWBonkPrizeTable[$07].mw_player BRL .done + CMP.w #$13 : BNE + - LDA.w $0ED0,X : CMP.w #$0010 : BNE ++ + LDA.w $0ED0,X : AND.w #$00FF : CMP.w #$0010 : BNE ++ LDA.l OWBonkPrizeTable[$08].mw_player BRL .done ++ LDA.l OWBonkPrizeTable[$09].mw_player BRL .done + CMP.w #$15 : BNE + - LDA.w $0ED0,X : CMP.w #$0010 : BNE ++ + LDA.w $0ED0,X : AND.w #$00FF : CMP.w #$0010 : BNE ++ LDA.l OWBonkPrizeTable[$0A].mw_player BRL .done ++ LDA.l OWBonkPrizeTable[$0B].mw_player BRL .done + CMP.w #$18 : BNE + - LDA.w $0ED0,X : CMP.w #$0010 : BNE ++ + LDA.w $0ED0,X : AND.w #$00FF : CMP.w #$0010 : BNE ++ LDA.l OWBonkPrizeTable[$0C].mw_player BRL .done ++ LDA.l OWBonkPrizeTable[$0D].mw_player BRL .done + CMP.w #$1A : BNE + - LDA.w $0ED0,X : CMP.w #$0010 : BNE ++ + LDA.w $0ED0,X : AND.w #$00FF : CMP.w #$0010 : BNE ++ LDA.l OWBonkPrizeTable[$0E].mw_player BRL .done ++ @@ -730,7 +741,7 @@ HeartPieceGetPlayer: LDA HeartPiece_Maze_Player BRL .done + CMP.w #$2A : BNE + - LDA.w $0ED0,X : CMP.w #$0010 : BNE ++ + LDA.w $0ED0,X : AND.w #$00FF : CMP.w #$0010 : BNE ++ LDA.l OWBonkPrizeTable[$14].mw_player BRL .done ++ CMP.w #$0008 : BNE ++ @@ -743,7 +754,7 @@ HeartPieceGetPlayer: LDA.l OWBonkPrizeTable[$16].mw_player BRL .done + CMP.w #$2E : BNE + - LDA.w $0ED0,X : CMP.w #$0010 : BNE ++ + LDA.w $0ED0,X : AND.w #$00FF : CMP.w #$0010 : BNE ++ LDA.l OWBonkPrizeTable[$17].mw_player BRL .done ++ @@ -757,7 +768,7 @@ HeartPieceGetPlayer: LDA BombosItem_Player BRL .done + CMP.w #$32 : BNE + - LDA.w $0ED0,X : CMP.w #$0010 : BNE ++ + LDA.w $0ED0,X : AND.w #$00FF : CMP.w #$0010 : BNE ++ LDA.l OWBonkPrizeTable[$19].mw_player BRL .done ++ @@ -770,7 +781,7 @@ HeartPieceGetPlayer: LDA HeartPiece_Swamp_Player BRL .done + CMP.w #$42 : BNE + - LDA.w $0ED0,X : CMP.w #$0010 : BNE ++ + LDA.w $0ED0,X : AND.w #$00FF : CMP.w #$0010 : BNE ++ LDA.l OWBonkPrizeTable[$1B].mw_player BRL .done ++ @@ -780,14 +791,14 @@ HeartPieceGetPlayer: LDA HeartPiece_Cliffside_Player BRL .done + CMP.w #$51 : BNE + - LDA.w $0ED0,X : CMP.w #$0010 : BNE ++ + LDA.w $0ED0,X : AND.w #$00FF : CMP.w #$0010 : BNE ++ LDA.l OWBonkPrizeTable[$1C].mw_player BRL .done ++ LDA.l OWBonkPrizeTable[$1D].mw_player BRL .done + CMP.w #$54 : BNE + - LDA.w $0ED0,X : CMP.w #$0010 : BNE ++ + LDA.w $0ED0,X : AND.w #$00FF : CMP.w #$0010 : BNE ++ LDA.l OWBonkPrizeTable[$1E].mw_player BRL .done ++ CMP.w #$0008 : BNE ++ @@ -797,7 +808,7 @@ HeartPieceGetPlayer: LDA.l OWBonkPrizeTable[$20].mw_player BRL .done + CMP.w #$55 : BNE + - LDA.w $0ED0,X : CMP.w #$0010 : BNE ++ + LDA.w $0ED0,X : AND.w #$00FF : CMP.w #$0010 : BNE ++ LDA.l OWBonkPrizeTable[$21].mw_player BRL .done ++ @@ -807,7 +818,7 @@ HeartPieceGetPlayer: LDA.l OWBonkPrizeTable[$23].mw_player BRL .done + CMP.w #$5B : BNE + - LDA.w $0ED0,X : CMP.w #$0010 : BNE ++ + LDA.w $0ED0,X : AND.w #$00FF : CMP.w #$0010 : BNE ++ LDA.l OWBonkPrizeTable[$24].mw_player BRL .done ++ @@ -820,7 +831,7 @@ HeartPieceGetPlayer: LDA HeartPiece_Digging_Player BRL .done + CMP.w #$6E : BNE + - LDA.w $0ED0,X : CMP.w #$0010 : BNE ++ + LDA.w $0ED0,X : AND.w #$00FF : CMP.w #$0010 : BNE ++ LDA.l OWBonkPrizeTable[$26].mw_player BRL .done ++ CMP.w #$0008 : BNE ++ @@ -844,3 +855,37 @@ HeartPieceGetPlayer: PLY RTL } +;-------------------------------------------------------------------------------- +HeartPieceSetRedraw: + PHY + LDY.b #$0F + .next + LDA.w $0DD0,Y : BEQ ++ + LDA.w $0E20,Y : CMP.b #$EB : BEQ + ; heart piece + CMP.b #$E4 : BEQ + ; enemy key drop + CMP.b #$3B : BEQ + ; bonk item (book/key) + CMP.b #$E5 : BEQ + ; enemy big key drop + CMP.b #$E7 : BEQ + ; mushroom item + CMP.b #$E9 : BEQ + ; powder item + BRA ++ + + LDA.b #$01 : STA.w !SPRITE_REDRAW,Y + ++ DEY : BPL .next + PLY +RTL +HeartPieceGetRedraw: + PHY + LDY.b #$0F + .next + LDA.w $0DD0,Y : BEQ ++ + LDA.w $0E20,Y : CMP.b #$EB : BEQ + ; heart piece + CMP.b #$E4 : BEQ + ; enemy key drop + CMP.b #$3B : BEQ + ; bonk item (book/key) + CMP.b #$E5 : BEQ + ; enemy big key drop + CMP.b #$E7 : BEQ + ; mushroom item + CMP.b #$E9 : BEQ + ; powder item + BRA ++ + + LDA.w !SPRITE_REDRAW,Y : BEQ ++ + PLY : SEC : RTL + ++ DEY : BPL .next + PLY +CLC : RTL diff --git a/hooks.asm b/hooks.asm index 26f1187..a878eeb 100755 --- a/hooks.asm +++ b/hooks.asm @@ -36,6 +36,9 @@ org $00821B ; <- 21B - Bank00.asm : 329 (LDA $13 : STA $2100) JML.l PostNMIHookAction : NOP PostNMIHookReturn: ;-------------------------------------------------------------------------------- +org $008F6C +JSL PostNMIUpdateBGCharHalf : NOP +;-------------------------------------------------------------------------------- ;================================================================================ ; Anti-ZSNES Hook @@ -499,16 +502,21 @@ JSL.l CheckEnoughCrystalsForTower NOP #4 db #$90 ; BCC ;-------------------------------------------------------------------------------- -org $08CE0C ; <- 44E0C - ancilla_break_tower_seal.asm : 168 (BEQ #$03 : JSR BreakTowerSeal_ExecuteSparkles : LDX.b #$06) -JML.l GetRequiredCrystalsForTower -NOP #3 -GetRequiredCrystalsForTower_continue: +org $08CE0C ; <- 44E0C - ancilla_break_tower_seal.asm : 168 (BEQ #$03 : JSR GTCutscene_SparkleALot : LDX.b #$06) +JML.l GTCutscene_AnimateCrystals_Prep : NOP +LDX.b #$05 +GTCutscene_AnimateCrystals_NextCrystal: +JML.l GTCutscene_ConditionalAnimateCrystals +;-------------------------------------------------------------------------------- +org $08CE93 +GTCutscene_DrawSingleCrystal: +JML.l GTCutscene_ConditionalDrawSingleCrystal ;-------------------------------------------------------------------------------- org $08CF19 ; <- 44F19 - ancilla_break_tower_seal.asm : 336 (TXA : AND.b #$07 : TAX) -JSL.l GetRequiredCrystalsInX +JSL.l GTCutscene_ActivateSparkle_SelectCrystal ;-------------------------------------------------------------------------------- org $08CFC9 ; <- 44FC9 - ancilla_break_tower_seal.asm : 414 (RTS) -db #$6B +RTL ;-------------------------------------------------------------------------------- ;================================================================================ @@ -971,6 +979,9 @@ JSL.l ChestPrep NOP #3 db $90 ; !BCC .cantOpen ;-------------------------------------------------------------------------------- +org $008A9D +JSL ConditionalPushBlockTransfer : NOP + org $00D531 ; 5531 - Bank00.asm:3451 (LDY.b #$5D) JML.l GetAnimatedSpriteGfxFile @@ -981,9 +992,15 @@ org $00D557 ; 5557 - Bank00.asm:3486 (LDA $00 : ADC $D469, X) JSL.l GetAnimatedSpriteBufferPointer NOP +org $05FA50 +JSL Sprite_ConditionalPrepOAMCoord + org $0799F7 ; 399F7 - Bank07.asm:4107 (JSL AddReceivedItem) JSL.l AddReceivedItemExpanded +org $08C505 +JSL Ancilla22_ItemReceipt_ContinueB : NOP #2 + org $098605 ; 48605 - ancilla_init.asm:709 (TYA : STA $02E4 : PHX) JML.l Multiworld_AddReceivedItem_notCrystal NOP @@ -995,10 +1012,6 @@ LDA.w AddReceivedItemExpanded_item_target_addr+1, X org $09861F ; 4861F - ancilla_init.asm:724 (LDA .item_values, Y) LDA.w AddReceivedItemExpanded_item_values, Y -org $098624 ; 48624 - ancilla_init.asm:728 (TYA : ASL A : TAX) -JSL.l UpdateInventoryLocationExpanded -BRA + : NOP #18 : + - org $0986AA ; 486AA - ancilla_init.asm:848 (LDA .item_masks, X) LDA.w AddReceivedItemExpanded_item_masks, X @@ -1058,6 +1071,10 @@ JSL HandleBombAbsorbtion ;org $09873F ; <- 04873F - ancilla_init.asm : 960 (ADC [$00] : STA [$00] ) ;JSL.l AddToStock ;-------------------------------------------------------------------------------- +org $02EB18 +JSL PostOverworldGfxLoad +org $18BD55 +JSL PostUnderworldMap ;================================================================================ ; Kholdstare Shell Fix @@ -1313,7 +1330,7 @@ NOP #5 ;-------------------------------------------------------------------------------- org $05EE5F ; <- 2EE5F - sprite_mushroom.asm : 30 JSL.l LoadMushroom -NOP +BRA + : NOP #7 : + ;-------------------------------------------------------------------------------- org $05EE78 ; <- 2EE78 - sprite_mushroom.asm : 58 JSL.l DrawMushroom @@ -1360,6 +1377,8 @@ org $07A303 ; 3A303 - Bank07.asm : 5622 org $07A3A2 ; 3A3A2 - Bank07.asm : 5720 - JSL DiggingGameGuy_AttemptPrizeSpawn JSL.l SpawnShovelItem BRA _Bank07_5726 +org $1DFDAC +JSL.l SpawnShovelGamePrize org $07A3AB ; 3A3AB - Bank07.asm : 5726 - LDA.b #$12 : JSR Player_DoSfx2 _Bank07_5726: ;org $07A381 ; 3A381 - Bank07.asm : 5693 - ORA $035B @@ -2315,7 +2334,7 @@ JSL.l HeartPieceSpawnDelayFix org $05F08A ; <- 2F08A - sprite_heart_upgrades.asm : 324 - (LDA $7EF36B : INC A : AND.b #$03 : STA $7EF36B : BNE .got_4_piecese) item determination JSL.l HeartPieceGet BCS $18 ; reinsert the near branch that appears midway through what we overrode -NOP #22 +BRA + : NOP #20 : + ;-------------------------------------------------------------------------------- org $06C0B0 ; <- 340B0 - sprite prep JSL.l HeartPieceSpritePrep @@ -2525,6 +2544,10 @@ JSL Overworld_MosaicDarkWorldChecks : NOP org $05CC58 ; <- Bank05.asm:1307 (LDA $040A : CMP.b #$18) JSL PsychoSolder_MusicCheck NOP #1 +; +org $06F96A +JSL PsychoSolder_MusicCheck +NOP #1 ;-------------------------------------------------------------------------------- org $02B13A ; <- Bank02.asm:7647 dl Overworld_FinishMirrorWarp diff --git a/init.asm b/init.asm index 36bb4b5..888986f 100644 --- a/init.asm +++ b/init.asm @@ -10,6 +10,7 @@ Init_Primary: LDX #$00 ; initalize our ram - STA $7EC025, X + STA $7EC035, X STA $7F5000, X INX CPX #$10 : !BLT - diff --git a/inventory.asm b/inventory.asm index 98f771a..8acedde 100644 --- a/inventory.asm +++ b/inventory.asm @@ -969,8 +969,7 @@ LoadPowder: LDA.l WitchItem_Player : STA !MULTIWORLD_SPRITEITEM_PLAYER_ID %GetPossiblyEncryptedItem(WitchItem, SpriteItemValues) STA $0DA0, Y ; Store item type - JSL.l PrepDynamicTile - STA $7F505E + LDA.b #$01 : STA.w !SPRITE_REDRAW, Y LDA #$00 STA $7F505F STA $7F5060 @@ -994,21 +993,16 @@ RTL ;-------------------------------------------------------------------------------- ; DrawPowder: ;-------------------------------------------------------------------------------- -!REDRAW = "$7F5000" -;-------------------------------------------------------------------------------- DrawPowder: LDA $02DA : BNE .defer ; defer if link is buying a potion - LDA.l !REDRAW : BEQ + + LDA.w !SPRITE_REDRAW, X : BEQ + LDA.l WitchItem_Player : STA !MULTIWORLD_SPRITEITEM_PLAYER_ID LDA $0DA0, X ; Retrieve stored item type - JSL.l PrepDynamicTile - LDA #$00 : STA.l !REDRAW ; reset redraw flag - BRA .defer + JML RequestSlottedTile + ; this fights with the shopkeep code, so had to move the powder draw there when potion shop is custom - LDA !SHOP_TYPE : CMP.b #$FF : BNE .defer - LDA $0DA0, X ; Retrieve stored item type - JSL.l DrawDynamicTile + LDA $0DA0, X ; Retrieve stored item type + JML DrawSlottedTile .defer RTL ;-------------------------------------------------------------------------------- @@ -1019,19 +1013,12 @@ RTL LoadMushroom: LDA.b #$00 : STA $0DC0, X ; thing we wrote over .justGFX - ;LDA MushroomItem - ;JSL.l PrepDynamicTile - PHA - LDA #$01 : STA !REDRAW - LDA $5D : CMP #$14 : BEQ .skip ; skip if we're mid-mirror - - LDA #$00 : STA !REDRAW LDA.l MushroomItem_Player : STA !MULTIWORLD_SPRITEITEM_PLAYER_ID %GetPossiblyEncryptedItem(MushroomItem, SpriteItemValues) STA $0E80, X ; Store item type - JSL.l PrepDynamicTile + JSL.l RequestSlottedTile .skip PLA @@ -1041,19 +1028,18 @@ RTL ;-------------------------------------------------------------------------------- ; DrawMushroom: ;-------------------------------------------------------------------------------- -!REDRAW = "$7F5000" -;-------------------------------------------------------------------------------- DrawMushroom: PHA : PHY - LDA !REDRAW : BEQ .skipInit ; skip init if already ready - JSL.l LoadMushroom_justGFX - BRA .done ; don't draw on the init frame + LDA.w !SPRITE_REDRAW, X : BEQ .skipInit ; skip init if already ready + JSL.l LoadMushroom_justGFX + LDA.w !SPRITE_REDRAW, X : CMP.b #$02 : BEQ .skipInit + BRA .done ; don't draw on the init frame .skipInit LDA $0E80, X ; Retrieve stored item type - JSL.l DrawDynamicTile + JSL.l DrawSlottedTile - .done + .done PLY : PLA RTL ;-------------------------------------------------------------------------------- @@ -1147,10 +1133,12 @@ RTL ;-------------------------------------------------------------------------------- ; SpawnShovelItem: ;-------------------------------------------------------------------------------- -!REDRAW = "$7F5000" +SpawnShovelGamePrize: + JSL Sprite_SpawnDynamically ; thing we wrote over + LDA.b #$01 : STA.w !SPRITE_REDRAW, Y +RTL +;-------------------------------------------------------------------------------- SpawnShovelItem: - LDA.b #$01 : STA !REDRAW - LDA $03FC : BEQ + JSL DiggingGameGuy_AttemptPrizeSpawn JMP .skip diff --git a/invertedmaps.asm b/invertedmaps.asm index e99ed36..348e228 100644 --- a/invertedmaps.asm +++ b/invertedmaps.asm @@ -153,17 +153,19 @@ LDA.l WarningFlags : AND #$0020 : BEQ + : JMP .spiral_mimic_ledge .spiral_mimic_ledge LDA #$00E3 : STA $2BDC : STA $2BDE : STA $2BE0 : STA $2BE2 STA $2BE4 : STA $2BE6 : STA $2BE8 : STA $2BEA -LDA #$014E : STA $2C5C : STA $2C5E : STA $2C64 -LDA #$0139 : STA $2C60 : STA $2C66 -LDA #$014B : STA $2C68 : STA $2C62 -LDA #$014E : STA $2C6A -LDA #$0152 : STA $2CDC : STA $2CDE : STA $2CE4 : STA $2CEA -LDA #$016B : STA $2CE0 : STA $2CE6 -LDA #$0182 : STA $2CE2 : STA $2CE8 +LDA #$014E : STA $2C5C : STA $2C5E : STA $2C64 : STA $2C66 + STA $2C68 : STA $2C6A +LDA #$0139 : STA $2C60 +LDA #$014B : STA $2C62 +LDA #$0152 : STA $2CDC : STA $2CDE : STA $2CE4 : STA $2CE6 + STA $2CE8 : STA $2CEA +LDA #$016B : STA $2CE0 +LDA #$0182 : STA $2CE2 LDA #$022E : STA $2D5C : STA $2D5E : STA $2D60 : STA $2D62 STA $2D64 : STA $2D66 : STA $2D68 : STA $2D6A -LDA #$0230 : STA $2DDC : STA $2DDE : STA $2DE0 : STA $2DE2 - STA $2DE4 : STA $2DE6 : STA $2DE8 : STA $2DEA +LDA #$0230 : STA $2DDC : STA $2DDE : STA $2DE0 : STA $2DE6 + STA $2DE8 : STA $2DEA +LDA #$02A6 : STA $2DE2 : STA $2DE4 ; remove portal LDA #$0034 : STA $3D4A diff --git a/keydrop/dynamic_si_vram.asm b/keydrop/dynamic_si_vram.asm index 56edbce..f84309c 100644 --- a/keydrop/dynamic_si_vram.asm +++ b/keydrop/dynamic_si_vram.asm @@ -1,77 +1,217 @@ ; where we shove the decompressed graphics to send to WRAM -DynamicDropGFX = $7EF500 +DynamicDropGFX = $7ECC00 ; this will just count from 0 to 4 to determine which slot we're using ; we're expecting 5 items max per room, and order is irrelevant ; we just need to keep track of where they go DynamicDropGFXIndex = $7E1E70 +!DynamicDropGFXSlotCount_UW = (FreeUWGraphics_end-FreeUWGraphics)>>1 +!DynamicDropGFXSlotCount_OW = (FreeOWGraphics_end-FreeOWGraphics)>>1 ; this will keep track of the above for each item SprItemGFX = $7E0780 -; this is the item requested and a flag -DynamicDropRequest = $7E1E71 -DynamicDropQueue = $7E1E72 +; this is the item requested and a flag (we anticipate no more than 3 requests to be active, but built to support 8) +DynamicDropRequest = $7E1E71 ; bitfield indicating which request slot to process +DynamicDropQueue = $7E1E72 ; 0x08 bytes, occupies 1 byte for each slot in the request queue (loot id at first, but stores GFX index) ; Come in with ; A = item receipt ID -; X = slot -RequestStandingItemVRAMSlot: - STA.w DynamicDropQueue - LDA.b #$01 - STA.w DynamicDropRequest +; X = sprite slot +RequestSlottedTile: + PHX : PHY - LDA.w DynamicDropGFXIndex - INC - CMP.b #$05 : BCC .fine + PHA + LDA.b #$01 : STA.w !SPRITE_REDRAW, X + JSL Sprite_IsOnscreen : BCC ++ + ; skip sending the request if busy with other things + LDA.b $11 : CMP.b #$21 : BCS ++ ; skip if OW is loading Map16 GFX ; TODO: Figure out how to allow submodule 22, check DMA status instead + LDA.b $5D : CMP.b #$14 : BEQ ++ ; skip if we're mid-mirror + LDA.b $1B : BEQ + ; OW current doesn't occupy any slots that medallion gfx do + CMP.b #$08 : BCC + : CMP.b #$0A+1 : BCS + ; skip if we're mid-medallion + ++ PLA : JMP .return + + - LDA.b #$00 + LDA.w $0E20, X : CMP.b #$C0 : BNE + ; if catfish + TYX + + CMP.b #$52 : BNE + ; if zora + TYX + + -.fine - STA.w DynamicDropGFXIndex - STA.w SprItemGFX,X + LDA.b 1,S : JSL.l GetSpritePalette : STA.w $0F50, X ; setup the palette + PLA + + ; gfx that are already present, use that instead of a new slot + CMP.b #$34 : BCC + : CMP.b #$36+1 : BCS + ; if rupees, use animated rupee OAM slot + LDA.b $1B : BEQ ++ + LDA.b #!DynamicDropGFXSlotCount_UW + BRA +++ + ++ LDA.b #!DynamicDropGFXSlotCount_OW + +++ INC : STA.w SprItemGFX,X + JMP .success + + CMP.b #$A0 : BCC + : CMP.b #$AF+1 : BCS + ; if key, use key OAM slot + LDY.b $5D : CPY.b #$19 : BCC ++ : CPY.b #$1A+1 : BCS ++ ; if getting tablet item, don't use key slot + BRA + + ++ + LDA.b $1B : BEQ ++ + LDA.b #!DynamicDropGFXSlotCount_UW + BRA +++ + ++ LDA.b #!DynamicDropGFXSlotCount_OW + +++ INC : INC : STA.w SprItemGFX,X + JMP .success + + CMP.b #$B5 : BNE + ; if good bee, use bee OAM slot + LDA.b $1B : BEQ ++ + LDA.b #!DynamicDropGFXSlotCount_UW + BRA +++ + ++ LDA.b #!DynamicDropGFXSlotCount_OW + +++ INC : INC : INC : STA.w SprItemGFX,X + JMP .success + + CMP.b #$B2 : BNE + ; if fairy, use fairy OAM slot + LDA.b $1B : BEQ ++ + LDA.b #!DynamicDropGFXSlotCount_UW + BRA +++ + ++ LDA.b #!DynamicDropGFXSlotCount_OW + +++ INC : INC : STA.w SprItemGFX,X + JMP .success + + CMP.b #$B1 : BNE + ; if apple, use apple OAM slot + LDA.b $1B : BEQ ++ + LDA.b #!DynamicDropGFXSlotCount_UW + BRA +++ + ++ LDA.b #!DynamicDropGFXSlotCount_OW + +++ INC : INC : INC : STA.w SprItemGFX,X + JMP .success + + CMP.b #$6A : BNE + ; if triforce, use cutscene OAM slot + PHA + LDA.b $1B : BEQ ++ + LDA.b #!DynamicDropGFXSlotCount_UW + BRA +++ + ++ LDA.b #!DynamicDropGFXSlotCount_OW + +++ INC : STA.w SprItemGFX,X + JMP .initRequest ; don't jump to end, we need the TF GFX to draw at $E7 + + + PHA + LDA.w DynamicDropGFXIndex + INC + PHX + LDX.b $1B : BEQ + + CMP.b #!DynamicDropGFXSlotCount_UW : BCC .setIndex + BRA ++ + + CMP.b #!DynamicDropGFXSlotCount_OW : BCC .setIndex + ++ LDA.b #$00 + + .setIndex + PLX + STA.w DynamicDropGFXIndex + STA.w SprItemGFX,X + PHX + ; loop thru other sprites, check if any use the same gfx slot + LDY.b #$0F + - TYA : CMP 1,S : BEQ + ; don't check self + LDA.w $0DD0,Y : BEQ + + LDA.w !SPRITE_REDRAW, Y : BNE + + LDA.w SprItemGFX,Y : CMP.w DynamicDropGFXIndex : BNE + + LDA.w $0E20,Y ; don't need E5 enemy big key drop and E9 powder item + CMP.b #$EB : BEQ ++ ; heart piece + CMP.b #$E4 : BEQ ++ ; enemy drop + CMP.b #$3B : BEQ ++ ; bonk item + CMP.b #$E7 : BEQ ++ ; mushroom + BRA + + ++ + ; slot already in use, use overflow slot + LDA.b #$02 : STA.w !SPRITE_REDRAW, X + LDA.b $1B : BEQ ++ + LDA.b #!DynamicDropGFXSlotCount_UW + BRA +++ + ++ LDA.b #!DynamicDropGFXSlotCount_OW + +++ STA.w SprItemGFX,X + PLX : PLA : BRA .return + + DEY : BPL - + PLX + + .initRequest + PHX + LDY.b #$00 + LDA.w DynamicDropRequest + - LSR : INY : BCS - + CPY.b #$08 : BCC + + ; all request slots occupied, exit without drawing + PLX : PLA + LDY.b #$FE ; indicate failure + BRA .return + + TYX + LDA.b #$00 : SEC + - ROL : DEX : BNE - + DEY ; y = slot index, a = new request bit flag + ORA.w DynamicDropRequest + STA.w DynamicDropRequest + PLX + PLA + STA.w DynamicDropQueue,Y ; decompress graphics - PHX - LDX.w DynamicDropQueue + PHX : PHY REP #$20 LDA.w #DynamicDropGFX-$7E9000 - STA.l !TILE_UPLOAD_OFFSET_OVERRIDE + TYX : BEQ + + - CLC : ADC.w #$0080 : DEX : BNE - + + STA.l !TILE_UPLOAD_OFFSET_OVERRIDE SEP #$20 - LDA.w DynamicDropQueue + LDA.w DynamicDropQueue,Y JSL.l GetSpriteID JSL.l GetAnimatedSpriteTile_variable SEP #$30 - PLX + PLY : PLX + LDA.w DynamicDropQueue,Y : PHA ; we want A to return the loot id + LDA.w SprItemGFX,X : STA.w DynamicDropQueue,Y + PLA + .success + STZ.w !SPRITE_REDRAW, X + .return + PLY : PLX RTL - ;=================================================================================================== TransferPotGFX: SEP #$10 REP #$20 - LDX.w DynamicDropRequest + LDA.w DynamicDropRequest : AND.w #$00FF BEQ .no - STZ.w DynamicDropRequest + .next + LDY.b #$00 + - INY : LSR : BCC - - LDA.w DynamicDropGFXIndex + PHY + LDA.w #$0000 + - ROL : DEY : BNE - + PLY + DEY ; y = slot index, a = request bit flag + + EOR.w DynamicDropRequest : STA.w DynamicDropRequest + + LDA.w DynamicDropQueue,Y ASL TAX - LDA.l FreeUWGraphics,X - STA.w $2116 + LDA.b $1B : AND.w #$00FF : BEQ + + LDA.l FreeUWGraphics,X + BRA ++ + + LDA.l FreeOWGraphics,X + ++ STA.w $2116 ; calculate bottom row now CLC : ADC.w #$0200>>1 : PHA LDX.b #$7E : STX.w $4314 - LDA.w #DynamicDropGFX : STA.w $4302 + LDA.w #DynamicDropGFX + CPY.b #$00 : BEQ + + - CLC : ADC.w #$0080 : DEY : BNE - + + STA.w $4302 LDX.b #$80 : STX.w $2115 LDA.w #$1801 : STA.w $4300 @@ -86,6 +226,9 @@ TransferPotGFX: STA.w $2116 STY.w $420B + LDA.w DynamicDropRequest : AND.w #$00FF + BNE .next + .no RTL @@ -94,60 +237,133 @@ FreeUWGraphics: dw $8800>>1 dw $8840>>1 dw $8980>>1 - dw $9CA0>>1 - dw $9DC0>>1 - -; dw $8800>>1 -; dw $8840>>1 -; dw $8980>>1 -; dw $9960>>1 # Arghuss Splash apparently -; dw $9C00>>1 + dw $9960>>1 ; Arghuss Splash apparently + dw $9C00>>1 ; dw $9CA0>>1 -; dw $9DC0>>1 + dw $9DC0>>1 + ; add new slots above this line +.end + dw $0000 ; overflow slot, intentionally blank + dw $9CE0>>1 ; Triforce + ; above this line, add slots that we want to draw to specific slots + +FreeOWGraphics: + dw $8180>>1 ; Push Block + ;dw $8800>>1 ; Shovel Dirt + dw $9960>>1 ; Arghuss/Zora Splash + dw $9C00>>1 ; Heart Piece + ;dw $9CA0>>1 ; Apple + ;dw $9DC0>>1 ; Whirlpool + ; add new slots above this line +.end + dw $0000 ; overflow slot, intentionally blank + dw $9CE0>>1 ; Triforce + ; above this line, add slots that we want to draw to specific slots ;=================================================================================================== - -DrawPotItem: +; Come in with +; A = item receipt ID +; X = sprite slot +; Returns with Carry flag set if gfx drawing was skipped +DrawSlottedTile: + PHA + ; TODO: allow drawing if gfx are not using a VRAM slot that changes during medallion + LDA.b $5D : CMP.b #$08 : BCC + : CMP.b #$0A+1 : BCS + ; skip if we're mid-medallion + PLA : SEC : RTL + + + PLA + STA.b $07 ; store loot ID temporarily, will get overwritten in Sprite_DrawMultiple_quantity_preset call JSL.l IsNarrowSprite : BCS .narrow + ; TODO: Instead of loading the whole fixed 16 bytes from DynamicOAMTile**_** into !SPRITE_DYNAMIC_OAM + ; Do something more like how DrawDynamicTile does it + ; Then we won't need all the separate DynamicOAMTile**_** tables .full LDA.b #$01 : STA $06 LDA #$0C : JSL.l OAM_AllocateFromRegionC LDA #$02 : PHA REP #$20 - LDA.w #DynamicOAMTile_full - BRA .draw + LDA.b $1B : AND.w #$00FF : BEQ + + LDA.w #DynamicOAMTileUW_full + BRA .transfer + + LDA.w #DynamicOAMTileOW_full + BRA .transfer .narrow LDA.b #$02 : STA $06 LDA #$10 : JSL.l OAM_AllocateFromRegionC LDA #$03 : PHA - REP #$20 - LDA.w #DynamicOAMTile_thin - .draw - PHB : PHK : PLB - + REP #$20 + LDA.b $1B : AND.w #$00FF : BEQ + + LDA.w #DynamicOAMTileUW_thin + BRA .transfer + + LDA.w #DynamicOAMTileOW_thin + .transfer STA.b $08 LDA.w SprItemGFX,X AND.w #$00FF ASL : ASL : ASL : ASL ADC.b $08 STA.b $08 - SEP #$20 - STZ.b $07 + PHK : PLY : STY.b $0A + LDY #$7E : PHB : PHY : PLB - LDA.b #$00 : STA.l !SKIP_EOR - JSL Sprite_DrawMultiple_quantity_preset + ; transfer fixed table data into WRAM + LDY.b #$0E + - LDA.b [$08],Y : STA.w !SPRITE_DYNAMIC_OAM,Y + DEY : DEY : BPL - - LDA.b $90 : CLC : ADC.b #$08 : STA.b $90 - INC.b $92 - INC.b $92 + LDA.w SprItemFlags, X : AND.w #$00FF : BNE .draw + LDA.b $06 : LSR : BCC + + ; full + LDA.w #$0000 + STA.w !SPRITE_DYNAMIC_OAM : STA.w !SPRITE_DYNAMIC_OAM+2 + BRA .draw + + ; narrow + LDA.w $0E20, X : AND.w #$00FF : CMP.w #$003B : BEQ .draw ; bonk item + LDA.b $A0 : CMP.w #$0120 : BNE + + LDA.b $1B : BNE .draw ; good bee statue + + + ; TODO: Figure out how to target bottle vendor fish item better than this + LDA.b $8A : AND.w #$00FF : CMP.w #$0018 : BNE + + LDA.b $1B : BEQ .draw ; bottle vendor key + + + LDA.w #$0004 + STA.w !SPRITE_DYNAMIC_OAM : STA.w !SPRITE_DYNAMIC_OAM+8 + .draw + ; special handling + LDY.b $07 : CPY.b #$B2 : BNE + ; fairy + LDA.b $1A : AND.w #$0020 : BEQ ++ ; alternate every 32 frames + LDA.w !SPRITE_DYNAMIC_OAM+4 : CLC : ADC.w #$02 ; use other fairy GFX + STA.w !SPRITE_DYNAMIC_OAM+4 + ++ LDA.b $1A : SEC : SBC.w #$10 : AND.w #$0020 : BEQ + ; alternate every 32 frames + LDA.w !SPRITE_DYNAMIC_OAM+2 : SEC : SBC.w #$02 ; move fairy up 2 pixels + STA.w !SPRITE_DYNAMIC_OAM+2 + + CPY.b #$B5 : BNE + ; good bee + LDA.b $1A : AND.w #$0020 : BEQ ++ ; alternate every 32 frames + LDA.w !SPRITE_DYNAMIC_OAM+12 : SEC : SBC.w #$10 ; use other fairy GFX + STA.w !SPRITE_DYNAMIC_OAM+12 + ++ LDA.b $1A : SEC : SBC.w #$10 : AND.w #$0020 : BEQ + ; alternate every 32 frames + LDA.w !SPRITE_DYNAMIC_OAM+10 : SEC : SBC.w #$02 ; move fairy up 2 pixels + STA.w !SPRITE_DYNAMIC_OAM+10 + + + + LDA.w #!SPRITE_DYNAMIC_OAM : STA.b $08 + SEP #$20 + STZ.b $07 + LDA.b #$00 : STA.l !SKIP_EOR + JSL Sprite_DrawMultiple_quantity_preset PLB + + LDA.b $90 : CLC : ADC.b #$08 : STA.b $90 + INC.b $92 : INC.b $92 + PLA + CLC RTL -DynamicOAMTile_thin: +DynamicOAMTileUW_thin: dw 0, 0 : db $40, $00, $20, $00 dw 0, 8 : db $50, $00, $20, $00 @@ -157,13 +373,32 @@ DynamicOAMTile_thin: dw 0, 0 : db $4C, $00, $20, $00 dw 0, 8 : db $5C, $00, $20, $00 - dw 0, 0 : db $E5, $00, $20, $00 - dw 0, 8 : db $F5, $00, $20, $00 + dw 0, 0 : db $CB, $00, $20, $00 + dw 0, 8 : db $DB, $00, $20, $00 + + dw 0, 0 : db $E0, $00, $20, $00 + dw 0, 8 : db $F0, $00, $20, $00 dw 0, 0 : db $EE, $00, $20, $00 dw 0, 8 : db $FE, $00, $20, $00 -DynamicOAMTile_full: + ; add new slots above this line + + dw 0, 0 : db $E3, $00, $20, $00 ; overflow slot + dw 0, 8 : db $F3, $00, $20, $00 + + ; above this line, add slots that we want to draw to specific slots + + dw 0, 0 : db $0B, $00, $20, $00 ; animated rupees slot + dw 0, 8 : db $1B, $00, $20, $00 + + dw 0, 0 : db $6B, $00, $20, $00 ; key + dw 0, 8 : db $7B, $00, $20, $00 + + dw 0, 0 : db $7C, $00, $20, $00 ; good bee + dw 0, 8 : db $F4, $00, $20, $00 + +DynamicOAMTileUW_full: dw -4, -1 : db $40, $00, $20, $02 dd 0, 0 @@ -173,8 +408,113 @@ DynamicOAMTile_full: dw -4, -1 : db $4C, $00, $20, $02 dd 0, 0 - dw -4, -1 : db $E5, $00, $20, $02 + dw -4, -1 : db $CB, $00, $20, $02 + dd 0, 0 + + dw -4, -1 : db $E0, $00, $20, $02 dd 0, 0 dw -4, -1 : db $EE, $00, $20, $02 - dd 0, 0 \ No newline at end of file + dd 0, 0 + + ; add new rotating slots above this line + + dw -4, -1 : db $A0, $00, $20, $02 ; overflow slot + dd 0, 0 + + dw -4, -1 : db $E7, $00, $20, $02 ; triforce + dd 0, 0 + + ; above this line, add slots that we want to draw to specific slots + + dw -4, -1 : db $EA, $00, $20, $02 ; fairy + dd 0, 0 + + dw -4, -1 : db $E5, $00, $20, $02 ; apple + dd 0, 0 + +DynamicOAMTileOW_thin: + dw 0, 0 : db $0C, $00, $20, $00 + dw 0, 8 : db $1C, $00, $20, $00 + + ; dw 0, 0 : db $40, $00, $20, $00 + ; dw 0, 8 : db $50, $00, $20, $00 + + dw 0, 0 : db $CB, $00, $20, $00 + dw 0, 8 : db $DB, $00, $20, $00 + + dw 0, 0 : db $E0, $00, $20, $00 + dw 0, 8 : db $F0, $00, $20, $00 + + ;dw 0, 0 : db $E5, $00, $20, $00 + ;dw 0, 8 : db $F5, $00, $20, $00 + + ;dw 0, 0 : db $EE, $00, $20, $00 + ;dw 0, 8 : db $FE, $00, $20, $00 + + ; add new slots above this line + + dw 0, 0 : db $E3, $00, $20, $00 ; overflow slot + dw 0, 8 : db $F3, $00, $20, $00 + + ; above this line, add slots that we want to draw to specific slots + + dw 0, 0 : db $0B, $00, $20, $00 ; animated rupees slot + dw 0, 8 : db $1B, $00, $20, $00 + + dw 0, 0 : db $6B, $00, $20, $00 ; key + dw 0, 8 : db $7B, $00, $20, $00 + + dw 0, 0 : db $7C, $00, $20, $00 ; good bee + dw 0, 8 : db $F4, $00, $20, $00 + +DynamicOAMTileOW_full: + dw 0, 0 : db $0C, $00, $20, $02 + dd 0, 0 + + ; dw 0, 0 : db $40, $00, $20, $02 + ; dd 0, 0 + + dw 0, 0 : db $CB, $00, $20, $02 + dd 0, 0 + + dw 0, 0 : db $E0, $00, $20, $02 + dd 0, 0 + + ;dw 0, 0 : db $E5, $00, $20, $02 + ;dd 0, 0 + + ;dw 0, 0 : db $EE, $00, $20, $02 + ;dd 0, 0 + + ; add new slots above this line + + dw 0, 0 : db $A0, $00, $20, $02 ; overflow slot + dd 0, 0 + + dw 0, 0 : db $E7, $00, $20, $02 ; triforce + dd 0, 0 + + ; above this line, add slots that we want to draw to specific slots + + dw 0, 0 : db $EA, $00, $20, $02 ; fairy + dd 0, 0 + + dw 0, 0 : db $E5, $00, $20, $02 ; apple + dd 0, 0 + +ConditionalPushBlockTransfer: + LDA.b $1B : BNE + + LDA.b #$0F ; don't transfer push block when on the OW + BRA .return-3 + + + LDA.b #$1F : STA.w $420B ; what we wrote over + .return +RTL + +pushpc +; fix Arghuss/Zora splash graphics +org $068595 + db $E7, $E7, $E7, $E7, $E7, $C0, $C0 +pullpc + diff --git a/keydrop/standing_items.asm b/keydrop/standing_items.asm index ad17f63..f32f9b9 100644 --- a/keydrop/standing_items.asm +++ b/keydrop/standing_items.asm @@ -9,6 +9,10 @@ org $829C25 org $89C2BB JSL ClearSpriteData +; underworld -> overworld transition +org $8282D1 + JSL ClearSpriteData2 + org $89C327 JSL LoadSpriteData @@ -71,6 +75,8 @@ org $868283 Sprite_SpawnSecret_NotRandomBush: org $86828A Sprite_SpawnSecret_SpriteSpawnDynamically: +org $8682A5 +Sprite_SpawnSecret_SetCoords: org $86d23a Sprite_DrawAbsorbable: org $9eff81 @@ -254,6 +260,12 @@ SaveMajorItemDrop: LDA.w #$0018 : BRA .substitute + CPY.w #$0031 : BNE + ; 10 pack bombs LDA.w #$0019 : BRA .substitute + + CPY.w #$00B1 : BNE + ; Apples + LDA.w #$001A : BRA .substitute + + CPY.w #$00B0 : BNE + ; Bee Trap + LDA.w #$001B : BRA .substitute + + CPY.w #$00B5 : BNE + ; Good Bee + LDA.w #$001C : BRA .substitute + STA $0B9C ; indicates we should use the key routines or a substitute RTL .substitute @@ -303,6 +315,7 @@ RTS ClearSpriteData: STZ.b $02 : STZ.b $03 ; what we overrode + .shared: PHX LDA #$00 : LDX #$00 .loop @@ -312,6 +325,10 @@ ClearSpriteData: PLX RTL +ClearSpriteData2: + LDA.b #$82 : STA.b $99 + JMP ClearSpriteData_shared + ; Runs during sprite load of the room LoadSpriteData: INY : INY @@ -353,7 +370,7 @@ RevealSpriteDrop: LDY.w $0CBA, X : BEQ .no_forced_drop RTL .no_forced_drop - PLA : PLA ; remove the JSL reswamturn lower 16 bits + PLA : PLA ; remove the JSL return lower 16 bits PEA.w $06F996-1 ; change return address to .no_forced_drop of (Sprite_DoTheDeath) RTL @@ -364,7 +381,7 @@ RevealSpriteDrop2: LDY.w $0CBA, X : BEQ .no_forced_drop RTL .no_forced_drop - PLA : PLA ; remove the JSL reswamturn lower 16 bits + PLA : PLA ; remove the JSL return lower 16 bits PEA.w $06E3CE-1 ; change return address to .no_forced_drop of (Sprite_DoTheDeath) RTL @@ -372,7 +389,7 @@ BitFieldMasks: dw $8000, $4000, $2000, $1000, $0800, $0400, $0200, $0100 dw $0080, $0040, $0020, $0010, $0008, $0004, $0002, $0001 -; Runs during Sprite_E4_SmallKey and duning Sprite_E5_BigKey spawns +; Runs during Sprite_E4_SmallKey and during Sprite_E5_BigKey spawns ShouldSpawnItem: LDA $048E : CMP.b #$87 : BNE + ; check for hera basement cage LDA $A8 : AND.b #$03 : CMP.b #$02 : BNE + ; we're not in that quadrant @@ -427,53 +444,59 @@ SpriteKeyPrep: LDA.w SpawnedItemMWPlayer : STA SprItemMWPlayer, X LDA.w SpawnedItemFlag : STA SprItemFlags, X : BEQ + LDA.l SpawnedItemID : STA $0E80, X - PHA - JSL.l GetSpritePalette : STA $0F50, X ; setup the palette - PLA CMP #$24 : BNE ++ ; + JSL.l GetSpritePalette : STA.w $0F50, X ; setup the palette LDA $A0 : CMP.b #$80 : BNE + LDA SpawnedItemFlag : BNE + LDA #$24 ; it's the big key drop? - ++ JSL RequestStandingItemVRAMSlot + ++ JSL RequestSlottedTile + PLA RTL SpriteKeyDrawGFX: - JSL Sprite_DrawRippleIfInWater - PHA - LDA $0E80, X - CMP.b #$24 : BNE + - LDA $A0 : CMP #$80 : BNE ++ - LDA SpawnedItemFlag : BNE ++ - LDA #$24 : BRA + - ++ PLA - PHK : PEA.w .jslrtsreturn-1 - PEA.w $068014 ; an rtl address - 1 in Bank06 - JML Sprite_DrawAbsorbable - .jslrtsreturn - RTL - + JSL DrawPotItem - CMP #$03 : BNE + - PHA : LDA $0E60, X : ORA.b #$20 : STA $0E60, X : PLA - + JSL.l Sprite_DrawShadowLong - PLA : RTL + JSL Sprite_DrawRippleIfInWater + PHA + LDA.w !SPRITE_REDRAW, X : BEQ + + LDA $0E80, X + JSL RequestSlottedTile + LDA.w !SPRITE_REDRAW, X : CMP.b #$02 : BEQ + + BRA .skipDraw + + LDA $0E80, X + CMP.b #$24 : BNE + + LDA $A0 : CMP #$80 : BNE ++ + LDA SpawnedItemFlag : BNE ++ + LDA #$24 : BRA + + ++ PLA + PHK : PEA.w .jslrtsreturn-1 + PEA.w $068014 ; an rtl address - 1 in Bank06 + JML Sprite_DrawAbsorbable + .jslrtsreturn + RTL + + JSL DrawSlottedTile : BCS .skipDraw + ; draw shadow + CMP #$03 : BNE + + PHA : LDA $0E60, X : ORA.b #$20 : STA $0E60, X : PLA + + JSL.l Sprite_DrawShadowLong + .skipDraw + PLA + RTL KeyGet: - LDA CurrentSmallKeys ; what we wrote over - PHA - LDA.l StandingItemsOn : BNE + - PLA : RTL - + LDY $0E80, X - LDA SprItemIndex, X : STA SpawnedItemIndex - LDA SprItemFlags, X : STA SpawnedItemFlag - LDA $A0 : CMP #$87 : BNE + ;check for hera cage - LDA SpawnedItemFlag : BNE + ; if it came from a pot, it's fine - JSR ShouldKeyBeCountedForDungeon : BCC ++ + LDA CurrentSmallKeys ; what we wrote over + PHA + LDA.l StandingItemsOn : BNE + + PLA : RTL + + LDY $0E80, X + LDA SprItemIndex, X : STA SpawnedItemIndex + LDA SprItemFlags, X : STA SpawnedItemFlag + LDA $A0 : CMP #$87 : BNE + ;check for hera cage + LDA SpawnedItemFlag : BNE + ; if it came from a pot, it's fine + JSR ShouldKeyBeCountedForDungeon : BCC ++ JSL CountChestKeyLong - ++ PLA : RTL - + STY $00 - LDA SprItemMWPlayer, X : STA !MULTIWORLD_ITEM_PLAYER_ID : BNE .receive - PHX + ++ PLA : RTL + + STY $00 + LDA SprItemMWPlayer, X : STA !MULTIWORLD_ITEM_PLAYER_ID : BNE .receive + PHX LDA $040C : CMP #$FF : BNE + LDA $00 : CMP.b #$AF : BNE .skip LDA CurrentGenericKeys : INC : STA CurrentGenericKeys @@ -486,10 +509,10 @@ KeyGet: ++ PLX : PLA : RTL + CMP.b #$AF : beq .countIt ; universal key CMP.b #$24 : beq .countIt ; small key for this dungeon - .skip PLX - .receive - JSL $0791b3 ; Player_HaltDashAttackLong - JSL.l Link_ReceiveItem + .skip PLX + .receive + JSL $0791b3 ; Player_HaltDashAttackLong + JSL.l Link_ReceiveItem PLA : DEC : RTL KeyTable: @@ -540,7 +563,10 @@ SubstitionTable: db $DB ; RED RUPEE - 0x16 db $E2 ; ARROW REFILL 10 - 0x17 db $DD ; BOMB REFILL 4 - 0x18 - db $DE ; BOMB REFILL 8 - 0x19 + db $DE ; BOMB REFILL 8 - 0x19 + db $AC ; APPLES - 0x1A + db $79 ; BEE TRAP - 0x1B + db $79 ; GOOD BEE - 0x1C SubstituteSpriteId: @@ -558,6 +584,22 @@ RTS CheckSprite_Spawn: JSR SubstituteSpriteId + CPY.b #$1C : BNE + ; good bee handling + JSL Sprite_SpawnDynamically + BMI .check + PHX + TYX : JSL.l Sprite_LoadProperties + PLX + JSL.l GoldBee_SpawnSelf_SetProperties + PLA : PLA : PLA ; pop the return address + PHX : LDX.b #$03 + JML Sprite_SpawnSecret_SetCoords + + CPY.b #$1A : BCC + ; all other non-normal pot sprite spawns + JSL Sprite_SpawnDynamically + BMI .check + LDA.b #$10 : STA.b $0D ; lets the outside code treat this sprite like a Stal (most normal table values) + RTL + + JSL Sprite_SpawnDynamically BMI .check RTL @@ -609,6 +651,32 @@ SetTheSceneFix: JSL LoadCommonSprites_long RTL +pushpc +org $868072 +JSL SetBottleVendorKey : NOP #4 +pullpc +SetBottleVendorKey: + LDA.w $0E20,Y : CMP.b #$E4 : BNE + + ; small key from bottle vendor + LDA.b #$AF : STA.w $0E80,Y + LDA.b #$01 : STA.w !SPRITE_REDRAW, Y + BRA .shift + + CMP.b #$DE : BEQ .return + CMP.b #$E2 : BEQ .return + ; shift narrow sprite to left by 4 + .shift + LDA.b $00 : CLC : ADC.b #$04 : STA.w $0D10,Y ; what we wrote over +.return +RTL + +ConditionalLoadCommonSprites_Do3To4Low: + LDA.b $10 : CMP.b #$01 : BEQ + ; what we wrote over + CMP.b #$0E : BEQ ++ + JML LoadCommonSprites_Prep3To4Low + + JML LoadCommonSprites_in_file_select +++ LDA.b #$50 : STA.w $2117 ; skip over some DMA bytes +JML Sound_LoadLightWorldSongBank-1 ; just some RTS in Bank 00 + incsrc dynamic_si_vram.asm ;=================================================================================================== diff --git a/msu.asm b/msu.asm index 7048d1d..f6bfbe0 100644 --- a/msu.asm +++ b/msu.asm @@ -376,8 +376,15 @@ CheckMusicLoadRequest: ; Fade out music if we're changing tracks on a stair transition ;-------------------------------------------------------------------------------- SpiralStairsPreCheck: - REP #$20 ; thing we wrote over - LDA.l DRMode : BNE .done ; exit if door rando enabled + LDA.l DRMode : BEQ + ; if door rando enabled + JSL LookupSpiralOffset_long + REP #$30 : AND.w #$00FF : ASL #2 : TAX + LDA.l SpiralTable,X + SEP #$10 : TAX : CPX.b #$07 : BNE .done ; check if hera boss + JSL CheckHeraBossDefeated : BCS .done + LDX.b #$F1 : STX !REG_MUSIC_CONTROL_REQUEST + BRA .done + + REP #$20 ; thing we wrote over LDA $A0 CMP.w #$000C : BNE + LDA !REG_CURRENT_MSU_TRACK : AND.w #$00FF : CMP.w #59 : BNE .done @@ -407,8 +414,11 @@ SpiralStairsPreCheck: ; Change music on stair transition (ToH/GT) ;-------------------------------------------------------------------------------- SpiralStairsPostCheck: - LDA.l DRMode : BNE .done ; exit if door rando enabled - LDA $A0 + LDA.l DRMode : BEQ + ; if door rando enabled + LDA.b $A2 : CMP.w #$0007 : BNE .done + LDX.b #$16 : STX !REG_MUSIC_CONTROL_REQUEST + BRA .done + + LDA $A0 CMP.w #$000C : BNE + ; Ganon's tower entrance LDX $0130 : CPX.b #$F1 : BNE .done ; Check that we were fading out diff --git a/multiworld.asm b/multiworld.asm index aeb3d65..ba82d71 100644 --- a/multiworld.asm +++ b/multiworld.asm @@ -240,7 +240,10 @@ Multiworld_MasterSword_GrantToPlayer: LDA PedestalSword_Player : STA !MULTIWORLD_ITEM_PLAYER_ID PLP : PLA - JSL Link_ReceiveItem ; thing we wrote over + CPY.b #$6A : BEQ + + JSL Link_ReceiveItem ; thing we wrote over + RTL + + JSL ActivateGoal RTL } diff --git a/music.asm b/music.asm index a7b6e9b..71adc06 100644 --- a/music.asm +++ b/music.asm @@ -210,6 +210,6 @@ Underworld_DoorDown_Entry: ; ; A=16bit XY=8bit CheckHeraBossDefeated: -LDA RoomDataWRAM[$08].high : AND.w #$00FF : BEQ + +LDA RoomDataWRAM[$07].high : AND.w #$00FF : BEQ + SEC : RTL + CLC : RTL diff --git a/newhud.asm b/newhud.asm index affb90a..f9915eb 100644 --- a/newhud.asm +++ b/newhud.asm @@ -94,7 +94,7 @@ NewDrawHud: ;================================================================================ ; Draw Dungeon Compass Counts ;================================================================================ - LDA.l CompassMode : AND #$003F : BEQ + ; skip if CompassMode is 0. + LDA.l CompassMode : AND #$000F : BEQ + ; skip if CompassMode is 0. JSL.l DrawDungeonCompassCounts ; compasses.asm + diff --git a/newitems.asm b/newitems.asm index 2651b4d..2fd9e74 100755 --- a/newitems.asm +++ b/newitems.asm @@ -44,7 +44,7 @@ ; #$B2 - Fairy ; #$B3 - Chicken ; #$B4 - Big Magic -; #$B5 - 5 Arrows +; #$B5 - Good Bee ; #$B6 - Progressive Bomb ; #$B7 - Progressive Cane ; #$FE - Server Request (Asychronous Chest) @@ -85,6 +85,12 @@ GetAnimatedSpriteGfxFile: CMP.b #$48 : BNE + LDY.b #$60 : JML GetAnimatedSpriteGfxFile_return + + CMP.b #$4B : BNE + + LDY.b #$50 : JML GetAnimatedSpriteGfxFile_return + + + CMP.b #$4C : BNE + + LDY.b #$5E : JML GetAnimatedSpriteGfxFile_return + + CMP.b #$24 : !BGE + LDY.b #$5B : JML GetAnimatedSpriteGfxFile_return @@ -124,6 +130,9 @@ dw $09F0 ; Null-Item dw $09C0 ; Clock dw $0A20 ; Triforce dw $0A50 ; Power Star +dw $09F0 ; Chicken +dw $09C0 ; Fairy ($09F0 if using uncompressed version) +dw $0988 ; Apple GetAnimatedSpriteBufferPointer: ;PHB : PHK : PLB @@ -178,7 +187,11 @@ ProcessEventItems: LDA GoalCounter : INC : STA GoalCounter CMP GoalItemRequirement : !BLT ++ LDA TurnInGoalItems : AND.w #$00FF : BNE ++ - JSL.l ActivateGoal + SEP #$20 ; set 8-bit accumulator + LDA.b $8A : CMP.b #$80 : BNE +++ + LDA.b $23 : BNE +++ + JSL.l ActivateGoal + +++ ++ SEP #$20 ; set 8-bit accumulator LDX.b #$01 : BRA .done @@ -322,7 +335,10 @@ AddReceivedItemExpandedGetItem: + CMP.b #$65 : BNE + ; Progressive Bow JMP .done + CMP.b #$6A : BNE + ; Goal Collectable (Single/Triforce) - JSL.l ActivateGoal + LDA.b $8A : CMP.b #$80 : BNE ++ + LDA.b $23 : BNE ++ + JSL.l ActivateGoal + ++ JMP .done + CMP.b #$6B : BNE + ; Goal Collectable (Multi/Power Star) BRA .multi_collect @@ -333,7 +349,11 @@ AddReceivedItemExpandedGetItem: LDA.l GoalCounter : INC : STA.l GoalCounter CMP.w GoalItemRequirement : !BLT ++ LDA.l TurnInGoalItems : AND.w #$00FF : BNE ++ + SEP #$20 ; set 8-bit accumulator + LDA.b $8A : CMP.b #$80 : BNE +++ + LDA.b $23 : BNE +++ JSL.l ActivateGoal + +++ ++ SEP #$20 ; set 8-bit accumulator JMP .done @@ -427,18 +447,23 @@ AddReceivedItemExpandedGetItem: LDA.b #$FF : STA.w $0B58,Y ; allows them to expire ++ JMP .done + CMP.b #$B3 : BNE + ; Chicken - LDA.b #$0B : JSL Sprite_SpawnDynamically : BMI .done + LDA.b #$0B : JSL Sprite_SpawnDynamically : BMI ++ LDA $22 : CLC : ADC.b #$03 : AND.b #$F8 : STA $0D10,Y LDA $23 : ADC.b #$00 : STA $0D30,Y ; round X to nearest 8 LDA.b $20 : SEC : SBC.b #$08 : STA.w $0D00,Y LDA.b $21 : SBC.b #$00 : STA.w $0D20,Y ; move up 8 pixels LDA.b $EE : STA.w $0F20,Y ; spawns on same layer as link - BRA .done + ++ BRA .done + CMP.b #$B4 : BNE + ; Big Magic LDA.b #$80 : STA MagicFiller ; fill magic BRA .done - + CMP.b #$B5 : BNE + ; 5 Arrows - LDA.b #$05 : STA ArrowsFiller ; add 5 arrows + + CMP.b #$B5 : BNE + ; Good Bee + LDA.b #$79 : JSL Sprite_SpawnDynamically : BMI .done + LDA $22 : CLC : ADC.b #$03 : AND.b #$F8 : STA $0D10,Y + LDA $23 : ADC.b #$00 : STA $0D30,Y ; round X to nearest 8 + LDA $20 : STA $0D00, Y : LDA $21 : STA $0D20, Y + LDA.b $EE : STA.w $0F20,Y ; spawns on same layer as link + JSL GoldBee_SpawnSelf_SetProperties BRA .done + CMP.b #$B6 : BNE + ; Bomb Upgrade LDA #$01 : STA InfiniteBombsModifier ; infinite bombs @@ -647,7 +672,7 @@ AddReceivedItemExpanded: db -4 ; Fairy db -4 ; Chicken db -4 ; Big Magic - db -4 ; 5 Arrows + db -4 ; Good Bee db -4 ; Bomb Upgrade db -4 ; Cane Upgrade db -4, -4, -4, -4, -4, -4, -4, -4 ; Unused @@ -695,7 +720,7 @@ AddReceivedItemExpanded: db 0 ; Fairy db 0 ; Chicken db 4 ; Big Magic - db 0 ; 5 Arrows + db 0 ; Good Bee db 0 ; Bomb Upgrade db 4 ; Cane Upgrade db 0, 0, 0, 0, 0, 0, 0, 0 ; Unused @@ -748,7 +773,7 @@ AddReceivedItemExpanded: db $47 ; Fairy db $47 ; Chicken db $3B ; Big Magic - db $02 ; 5 Arrows + db $47 ; Good Bee db $13 ; Bomb Upgrade db $07 ; Cane Upgrade db $49, $49, $49, $49, $49, $49, $49, $49 ; Unused @@ -795,7 +820,7 @@ AddReceivedItemExpanded: db $02 ; Fairy db $02 ; Chicken db $00 ; Big Magic - db $02 ; 5 Arrows + db $02 ; Good Bee db $02 ; Bomb Upgrade db $00 ; Cane Upgrade db $02, $02, $02, $02, $02, $02, $02, $02 ; Unused @@ -843,7 +868,7 @@ AddReceivedItemExpanded: db 1 ; Fairy db 1 ; Chicken db 4 ; Big Magic - db 2 ; 5 Arrows + db 1 ; Good Bee db 5 ; Bomb Upgrade db 5 ; Cane Upgrade db 4, 4, 4, 4, 4, 4, 4, 4 ; Unused @@ -892,7 +917,7 @@ AddReceivedItemExpanded: dw $F36A ; Fairy dw $F36A ; Chicken dw $F373 ; Big Magic - dw $F376 ; 5 Arrows + dw $F36A ; Good Bee dw $F38F ; Bomb Upgrade dw $F38F ; Cane Upgrade dw $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A ; Unused @@ -943,7 +968,7 @@ AddReceivedItemExpanded: db $FF ; Fairy db $FF ; Chicken db $80 ; Big Magic - db $05 ; 5 Arrows + db $FF ; Good Bee db $FF ; Bomb Upgrade db $FF ; Cane Upgrade db $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Unused @@ -1036,7 +1061,7 @@ Link_ReceiveItemAlternatesExpanded: db -1 ; Fairy db -1 ; Chicken db -1 ; Big Magic - db -1 ; 5 Arrows + db -1 ; Good Bee db -1 ; Bomb Upgrade db -1 ; Cane Upgrade db -1, -1, -1, -1, -1, -1, -1, -1 ; Unused @@ -1275,22 +1300,12 @@ ChestPrep: SEC RTL ;-------------------------------------------------------------------------------- -UpdateInventoryLocationExpanded: -{ - REP #$30 - TYA : AND #$00FF : ASL A : TAX - - ; Tells what inventory location to write to. - LDA.w AddReceivedItemExpanded_item_target_addr, X : STA $00 - - SEP #$30 - - LDA.b #$7E : STA $02 - - LDA.w AddReceivedItemExpanded_item_values, Y - JSL ItemDowngradeFix - RTL -} +Ancilla22_ItemReceipt_ContinueB: + CMP.b #$6A : BNE .return + JSL ActivateTriforceCutscene + .return + STZ.w $0C4A,X : STZ.w $0FC1 ; what we wrote over +RTL ;-------------------------------------------------------------------------------- ; Set a flag in SRAM if we pick up a compass in its own dungeon with HUD compass ; counts on diff --git a/owrando.asm b/owrando.asm index 09fe010..d74718d 100644 --- a/owrando.asm +++ b/owrando.asm @@ -11,9 +11,11 @@ OWMode: dw 0 OWFlags: dw 0 -org $aa8010 OWReserved: dw 0 +org $aa8010 +OWVersionInfo: +dw $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000 ;Hooks org $02a929 @@ -45,6 +47,10 @@ Overworld_LoadSpecialOverworld_RoomId: org $04E8B4 Overworld_LoadSpecialOverworld: +org $02A9DA +JSL OWSkipPalettes +BCC OverworldHandleTransitions_change_palettes : NOP #4 + org $07982A Link_ResetSwimmingState: @@ -157,6 +163,14 @@ and #$7f : eor #$40 : nop #2 org $06AD4C jsl.l OWBonkDrops : nop #4 +org $1EDE6F +jsl.l OWBonkGoodBeeDrop : bra + +GoldBee_SpawnSelf_SetProperties: +phb : lda.b #$1E : pha : plb ; switch to bank 1E + jsr GoldBee_SpawnSelf+12 +plb : rtl +nop #3 ++ ;Code org $aa8800 @@ -230,6 +244,19 @@ OWWhirlpoolEnd: RTL } +OWDestroyItemSprites: +{ + PHX : LDX.b #$0F + .nextSprite + LDA.w $0E20,X + CMP.b #$D8 : BCC .continue + CMP.b #$EC : BCS .continue + .killSprite ; need to kill sprites from D8 to EB on screen transition + STZ.w $0DD0,X + .continue + DEX : BPL .nextSprite + PLX : RTL +} OWMirrorSpriteOnMap: { lda.w $1ac0,x : bit.b #$f0 : beq .continue @@ -395,13 +422,127 @@ LoadMapDarkOrMixed: dw $0400+$0210 ; bottom right } +OWBonkGoodBeeDrop: +{ + LDA.l OWFlags+1 : AND.b #!FLAG_OW_BONKDROP : BNE .shuffled + .vanilla ; what we wrote over + STZ.w $0DD0,X + LDA.l BottleContentsOne : ORA.l BottleContentsTwo + ORA.l BottleContentsThree : ORA.l BottleContentsFour + RTL + .shuffled + LDA.w $0DD0,X : BNE + + JMP .return+1 + + PHY : TXY + LDA.l RoomDataWRAM[$0120].high : AND.b #$02 : PHA : BNE + ; check if collected + LDA.b #$1B : STA $12F ; JSL Sound_SetSfx3PanLong ; seems that when you bonk, there is a pending bonk sfx, so we clear that out and replace with reveal secret sfx + + + LDA.l OWBonkPrizeTable[42].mw_player : BEQ + ; multiworld item + LDA.l OWBonkPrizeTable[42].loot + JMP .spawn_item + + + + .determine_type ; S = Collected + LDA.l OWBonkPrizeTable[42].loot ; A = item id + CMP.b #$B0 : BNE + + LDA.b #$79 : JMP .sprite_transform ; transform to bees + + CMP.b #$42 : BNE + + JSL.l Sprite_TransmuteToBomb ; transform a heart to bomb, vanilla behavior + JMP .mark_collected + + CMP.b #$34 : BNE + + LDA.b #$D9 : JMP .sprite_transform ; transform to single rupee + + CMP.b #$35 : BNE + + LDA.b #$DA : JMP .sprite_transform ; transform to blue rupee + + CMP.b #$36 : BNE + + LDA.b #$DB : BRA .sprite_transform ; transform to red rupee + + CMP.b #$27 : BNE + + LDA.b #$DC : BRA .sprite_transform ; transform to 1 bomb + + CMP.b #$28 : BNE + + LDA.b #$DD : BRA .sprite_transform ; transform to 4 bombs + + CMP.b #$31 : BNE + + LDA.b #$DE : BRA .sprite_transform ; transform to 8 bombs + + CMP.b #$45 : BNE + + LDA.b #$DF : BRA .sprite_transform ; transform to small magic + + CMP.b #$B4 : BNE + + LDA.b #$E0 : BRA .sprite_transform ; transform to big magic + + CMP.b #$B5 : BNE + + LDA.b #$79 : JSL.l OWBonkSpritePrep + JSL.l GoldBee_SpawnSelf_SetProperties ; transform to good bee + BRA .mark_collected + + CMP.b #$44 : BNE + + LDA.b #$E2 : BRA .sprite_transform ; transform to 10 arrows + + CMP.b #$B1 : BNE + + LDA.b #$AC : BRA .sprite_transform ; transform to apples + + CMP.b #$B2 : BNE + + LDA.b #$E3 : BRA .sprite_transform ; transform to fairy + + CMP.b #$B3 : BNE .spawn_item + INX : INX : LDA.l OWBonkPrizeTable[42].vert_offset + CLC : ADC.b #$08 : PHA + LDA.w $0D00,Y : SEC : SBC.b 1,S : STA.w $0D00,Y + LDA.w $0D20,Y : SBC.b #$00 : STA.w $0D20,Y : PLX + LDA.b #$0B : SEC ; BRA .sprite_transform ; transform to chicken + + .sprite_transform + JSL.l OWBonkSpritePrep + + .mark_collected ; S = Collected + PLA : BNE + + LDA.l RoomDataWRAM[$0120].high : ORA.b #$02 : STA.l RoomDataWRAM[$0120].high + + REP #$20 + LDA.l TotalItemCounter : INC : STA.l TotalItemCounter + SEP #$20 + + BRA .return + + ; spawn itemget item + .spawn_item ; A = item id ; Y = bonk sprite slot ; S = Collected + PLX : BEQ + : LDA.b #$00 : STA.w $0DD0,Y : BRA .return + + PHA + + LDA.b #$01 : STA !FORCE_HEART_SPAWN + + LDA.b #$EB : STA.l $7FFE00 + JSL Sprite_SpawnDynamically+15 ; +15 to skip finding a new slot, use existing sprite + + LDA.b #$01 : STA.w !SPRITE_REDRAW,Y + + PLA : STA.w $0E80,Y + + ; affects the rate the item moves in the Y/X direction + LDA.b #$00 : STA.w $0D40,Y + LDA.b #$0A : STA.w $0D50,Y + + LDA.b #$1A : STA.w $0F80,Y ; amount of force (gives height to the arch) + LDA.b #$FF : STA.w $0B58,Y ; stun timer + LDA.b #$30 : STA.w $0F10,Y ; aux delay timer 4 ?? dunno what that means + + LDA.b #$00 : STA.w $0F20,Y ; layer the sprite is on + + ; sets the tile type that is underneath the sprite, water + TYX : LDA.b #$09 : STA.l $7FF9C2,X ; TODO: Figure out how to get the game to set this + + ; sets OW event bitmask flag, uses free RAM + LDA.l OWBonkPrizeTable[42].flag : STA.w $0ED0,Y + + ; determines the initial spawn point of item + LDA.w $0D00,Y : SEC : SBC.l OWBonkPrizeTable[42].vert_offset : STA.w $0D00,Y + LDA.w $0D20,Y : SBC #$00 : STA.w $0D20,Y + + .return + PLY + LDA #$08 ; makes original good bee not spawn + RTL +} + ; Y = sprite slot index of bonk sprite OWBonkDrops: { CMP.b #$D8 : BEQ + RTL - + LDA.l OWFlags+1 : AND.b #!FLAG_OW_CROSSED : BNE + + + LDA.l OWFlags+1 : AND.b #!FLAG_OW_BONKDROP : BNE + JSL.l Sprite_TransmuteToBomb : RTL + + LDA.w $0DD0,Y : BNE + + RTL + ; loop thru rando bonk table to find match @@ -439,7 +580,7 @@ OWBonkDrops: + CMP.b #$34 : BNE + LDA.b #$D9 : CLC : JMP .sprite_transform ; transform to single rupee + CMP.b #$35 : BNE + - LDA.b #$DA : CLC : BRA .sprite_transform ; transform to blue rupee + LDA.b #$DA : CLC : JMP .sprite_transform ; transform to blue rupee + CMP.b #$36 : BNE + LDA.b #$DB : CLC : BRA .sprite_transform ; transform to red rupee + CMP.b #$27 : BNE + @@ -453,7 +594,9 @@ OWBonkDrops: + CMP.b #$B4 : BNE + LDA.b #$E0 : CLC : BRA .sprite_transform ; transform to big magic + CMP.b #$B5 : BNE + - LDA.b #$E1 : CLC : BRA .sprite_transform ; transform to 5 arrows + LDA.b #$79 : JSL.l OWBonkSpritePrep + JSL.l GoldBee_SpawnSelf_SetProperties ; transform to good bee + BRA .mark_collected + CMP.b #$44 : BNE + LDA.b #$E2 : CLC : BRA .sprite_transform ; transform to 10 arrows + CMP.b #$B1 : BNE + @@ -468,42 +611,37 @@ OWBonkDrops: LDA.b #$0B : SEC ; BRA .sprite_transform ; transform to chicken .sprite_transform - STA.w $0E20,Y - TYX : JSL.l Sprite_LoadProperties - BEQ + - ; these are sprite properties that make it fall out of the tree to the east - LDA #$30 : STA $0F80,Y ; amount of force (related to speed) - LDA #$10 : STA $0D50,Y ; eastward rate of speed - LDA #$FF : STA $0B58,Y ; expiration timer - + + JSL.l OWBonkSpritePrep .mark_collected ; S = Collected, FlagBitmask, X (row + 2) PLA : BNE + ; S = FlagBitmask, X (row + 2) + TYX : JSL Sprite_IsOnscreen : BCC + LDX.b $8A : LDA.l OverworldEventDataWRAM,X : ORA 1,S : STA.l OverworldEventDataWRAM,X REP #$20 - LDA.l TotalItemCounter : INC : STA.l TotalItemCounter + LDA.l TotalItemCounter : INC : STA.l TotalItemCounter SEP #$20 + JMP .return ; spawn itemget item .spawn_item ; A = item id ; Y = tree sprite slot ; S = Collected, FlagBitmask, X (row + 2) PLX : BEQ + : LDA.b #$00 : STA.w $0DD0,Y : JMP .return ; S = FlagBitmask, X (row + 2) - + LDA 2,S : TAX : INX : INX - LDA.w OWBonkPrizeData,X : STA.l !MULTIWORLD_SPRITEITEM_PLAYER_ID - DEX + + PHA - LDA.b #$01 : STA !REDRAW + LDA.b #$01 : STA !FORCE_HEART_SPAWN - LDA.b #$EB - STA.l $7FFE00 + LDA.b #$EB : STA.l $7FFE00 JSL Sprite_SpawnDynamically+15 ; +15 to skip finding a new slot, use existing sprite + LDA.b #$01 : STA.w !SPRITE_REDRAW,Y + + PLA : STA.w $0E80,Y + ; affects the rate the item moves in the Y/X direction LDA.b #$00 : STA.w $0D40,Y LDA.b #$0A : STA.w $0D50,Y - LDA.b #$20 : STA.w $0F80,Y ; amount of force (gives height to the arch) + LDA.b #$1A : STA.w $0F80,Y ; amount of force (gives height to the arch) LDA.b #$FF : STA.w $0B58,Y ; stun timer LDA.b #$30 : STA.w $0F10,Y ; aux delay timer 4 ?? dunno what that means @@ -511,23 +649,35 @@ OWBonkDrops: ; sets OW event bitmask flag, uses free RAM PLA : STA.w $0ED0,Y ; S = X (row + 2) - + ; determines the initial spawn point of item PLX : INX : INX : INX LDA.w $0D00,Y : SEC : SBC.w OWBonkPrizeData,X : STA.w $0D00,Y LDA.w $0D20,Y : SBC #$00 : STA.w $0D20,Y - LDA.b #$01 : STA !REDRAW : STA !FORCE_HEART_SPAWN - PLB : RTL .return PLA : PLA : PLB : RTL } +; A = SpriteID, Y = Sprite Slot Index, X = free/overwritten +OWBonkSpritePrep: +{ + STA.w $0E20,Y + TYX : JSL.l Sprite_LoadProperties + BEQ + + ; these are sprite properties that make it fall out of the tree to the east + LDA #$30 : STA $0F80,Y ; amount of force (related to speed) + LDA #$10 : STA $0D50,Y ; eastward rate of speed + LDA #$FF : STA $0B58,Y ; expiration timer + + RTL +} + org $aa9000 OWDetectEdgeTransition: { + JSL OWDestroyItemSprites STZ.w $06FC LDA.l OWMode : ORA.l OWMode+1 : BEQ .vanilla JSR OWShuffle @@ -721,31 +871,33 @@ OWNewDestination: { tya : sta $4202 : lda #16 : sta $4203 ;wait 8 cycles rep #$20 : txa : nop : !add $4216 : tax ;a = offset to dest record - lda.w $0006,x : sta $06 ;set coord lda.w $0008,x : sta $04 ;save dest OW slot/ID - lda.w $000a,x : sta $84 ;VRAM - + ldy $20 : lda $418 : dec #2 : bpl + : ldy $22 : + sty $06 + ;;22 e0 e2 61c 61e - X ;;20 e6 e8 618 61a - Y ;keep current position if within incoming gap lda.w $0000,x : and #$01ff : pha : lda.w $0002,x : and #$01ff : pha - ldy $20 : lda $418 : dec #2 : bpl + : ldy $22 - + tya : and #$01ff : cmp 3,s : !blt .adjustMainAxis - dec : cmp 1,s : !bge .adjustMainAxis - inc : pha : lda $06 : and #$fe00 : !add 1,s : sta $06 : pla + LDA.l OWMode : AND.w #$0007 : BEQ .noLayoutShuffle ;temporary fix until VRAM issues are solved + lda.w $0006,x : sta $06 ;set coord + lda.w $000a,x : sta $84 ;VRAM + tya : and #$01ff : cmp 3,s : !blt .adjustMainAxis + dec : cmp 1,s : !bge .adjustMainAxis + inc : pha : lda $06 : and #$fe00 : !add 1,s : sta $06 : pla - ; adjust and set other VRAM addresses - lda.w $0006,x : pha : lda $06 : !sub 1,s - jsl DivideByTwoPreserveSign : jsl DivideByTwoPreserveSign : jsl DivideByTwoPreserveSign : jsl DivideByTwoPreserveSign : pha ; number of tiles - lda $418 : dec #2 : bmi + - pla : pea $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 $84 : !add 1,s : sta $84 : pla : pla + ; adjust and set other VRAM addresses + lda.w $0006,x : pha : lda $06 : !sub 1,s + jsl DivideByTwoPreserveSign : jsl DivideByTwoPreserveSign : jsl DivideByTwoPreserveSign : jsl DivideByTwoPreserveSign : pha ; number of tiles + lda $418 : dec #2 : bmi + + pla : pea $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 $84 : !add 1,s : sta $84 : pla : pla - .adjustMainAxis - LDA $84 : SEC : SBC #$0400 : AND #$0F00 : ASL : XBA : STA $88 ; vram - LDA $84 : SEC : SBC #$0010 : AND #$003E : LSR : STA $86 + .adjustMainAxis + LDA $84 : SEC : SBC #$0400 : AND #$0F00 : ASL : XBA : STA $88 ; vram + LDA $84 : SEC : SBC #$0010 : AND #$003E : LSR : STA $86 + .noLayoutShuffle LDA.w $000F,X : AND.w #$00FF : STA.w $06FC ; position to walk to after transition (if non-zero) LDY.w #$0000 @@ -805,8 +957,12 @@ OWNewDestination: ; crossed OW shuffle and terrain ldx $05 : ldy $08 : jsr OWWorldTerrainUpdate + + ldx $8a : lda $05 : sta $8a : stx $05 ; $05 is prev screen id, $8a is dest screen - lda $05 : sta $8a + jsr OWGfxUpdate + + lda $8a rep #$30 : rts } OWLoadSpecialArea: @@ -846,17 +1002,17 @@ OWWorldTerrainUpdate: ; x = owid of destination screen, y = 1 for land to water, lda #$38 : sta $012f ; play sfx - #$3b is an alternative ; toggle bunny mode - lda MoonPearlEquipment : bne .nobunny - lda.l InvertedMode : bne .inverted + lda MoonPearlEquipment : beq + : jmp .nobunny + + lda.l InvertedMode : bne .inverted lda CurrentWorld : bra + .inverted lda CurrentWorld : eor #$40 + and #$40 : beq .nobunny - LDA.w $0703 : BEQ + ; check if forced transition - CPY.b #$03 : BEQ .end_forced_whirlpool - LDA.b #$17 : STA.b $5D - LDA.b #$01 : STA.w $02E0 : STA.b $56 - LDA.w $0703 : BRA .end_forced_edge + CPY.b #$03 : BEQ ++ + LDA.b #$17 : STA.b $5D + LDA.b #$01 : STA.w $02E0 : STA.b $56 + LDA.w $0703 : JSR OWLoadGearPalettes : BRA .end_forced_edge + ++ JSR OWLoadGearPalettes : BRA .end_forced_whirlpool + CPY.b #$01 : BEQ .auto ; check if going from land to water CPY.b #$02 : BEQ .to_bunny_reset_swim ; bunny state if swimming to land @@ -875,8 +1031,8 @@ OWWorldTerrainUpdate: ; x = owid of destination screen, y = 1 for land to water, STZ.b $5D PLX BRA .to_pseudo_bunny - .whirlpool - PLX : RTS + .whirlpool + PLX : JMP OWLoadGearPalettes .to_bunny_reset_swim LDA.b $5D : CMP.b #$04 : BNE .to_bunny ; check if swimming JSL Link_ResetSwimmingState @@ -885,7 +1041,7 @@ OWWorldTerrainUpdate: ; x = owid of destination screen, y = 1 for land to water, LDA.b #$17 : STA.b $5D .to_pseudo_bunny LDA.b #$01 : STA.w $02E0 : STA.b $56 - RTS + JMP OWLoadGearPalettes .nobunny lda $5d : cmp #$17 : bne + ; retain current state unless bunny @@ -934,6 +1090,68 @@ OWWorldTerrainUpdate: ; x = owid of destination screen, y = 1 for land to water, .return RTS } +OWGfxUpdate: +{ + REP #$20 : LDA.l OWMode : AND.w #$0207 : BEQ .is_only_mixed : SEP #$20 + ;;;;PLA : AND.b #$3F : BEQ .leaving_woods + LDA.b $8A : AND.b #$3F : BEQ .entering_woods + ;LDA.b $05 : JSL OWSkipPalettes : BCS .skip_palettes + LDA.b $8A : JSR OWDetermineScreensPaletteSet + CPX.w $0AB3 : BEQ .skip_palettes ; check if next screen's palette is different + LDA $00 : PHA + JSL OverworldLoadScreensPaletteSet_long ; loading correct OW palette + PLA : STA $00 + .leaving_woods + .entering_woods + .is_only_mixed + .skip_palettes + SEP #$20 +} +OWLoadGearPalettes: +{ + PHX : PHY : LDA $00 : PHA + LDA.w $02E0 : BEQ + + JSL LoadGearPalettes_bunny + BRA .return + + + JSL LoadGearPalettes_link + .return + PLA : STA $00 : PLY : PLX + RTS +} +OWDetermineScreensPaletteSet: ; A = OWID to check +{ + LDX.b #$02 + PHA : AND.b #$3F + CMP.b #$03 : BEQ .death_mountain + CMP.b #$05 : BEQ .death_mountain + CMP.b #$07 : BEQ .death_mountain + LDX.b #$00 + .death_mountain + PLA : PHX : TAX : LDA.l OWTileWorldAssoc,X : BEQ + + PLX : INX : RTS + + PLX : RTS +} +OWSkipPalettes: +{ + STA.b $05 ; A = previous screen, also stored in $05 + ; only skip mosaic if OWR Layout or Crossed + PHP : REP #$20 : LDA.l OWMode : AND.w #$0207 : BEQ .vanilla : PLP + ; checks to see if going to from any DM screens + ;LDA.b $05 : JSR OWDetermineScreensPaletteSet : TXA : AND.b #$FE : STA $04 + ;LDA.b $8A : JSR OWDetermineScreensPaletteSet : TXA : AND.b #$FE + ;CMP.b $04 : BNE .skip_palettes + BRA .vanilla+1 + + .vanilla + PLP + LDA.b $05 : AND.b #$3F : BEQ .skip_palettes ; what we + LDA.b $8A : AND.b #$BF : BNE .change_palettes ; wrote over, kinda + .skip_palettes + SEC : RTL ; mosaic transition occurs + .change_palettes + CLC : RTL +} OWAdjustExitPosition: { LDA.w $06FC : CMP.b #$60 : BEQ .stone_bridge @@ -1287,7 +1505,7 @@ dw $0c78, $0ce3, $006b, $0cad, $3434, $0000, $0000, $001b dw $0ce4, $0d33, $004f, $0d0b, $3434, $0000, $0001, $001c dw $0d34, $0db8, $0084, $0d76, $3434, $0000, $0000, $001d dw $0ea8, $0f20, $0078, $0ee4, $3a3a, $0000, $0000, $001e -dw $0f70, $0fa8, $0038, $0f8c, $3a3a, $0000, $0000, $001f +dw $0f78, $0fa8, $0030, $0f90, $3a3a, $0000, $0000, $001f dw $0f18, $0f18, $0000, $0f18, $3b3b, $0000, $0000, $0020 dw $0fc8, $0fc8, $0000, $0fc8, $3b3b, $0000, $0000, $0021 dw $0e28, $0fb8, $0190, $0ef0, $3c3c, $0000, $0000, $0022 @@ -1362,7 +1580,7 @@ dw $0c78, $0ce3, $006b, $0cad, $3333, $0000, $0000, $001c dw $0ce4, $0d33, $004f, $0d0b, $3333, $0000, $0001, $001d dw $0d34, $0db8, $0084, $0d76, $3333, $0000, $0000, $001e dw $0ea8, $0f20, $0078, $0ee4, $3039, $0000, $0000, $001f -dw $0f70, $0fa8, $0038, $0f8c, $3039, $0000, $0000, $0020 +dw $0f78, $0fa8, $0030, $0f90, $3039, $0000, $0000, $0020 dw $0f18, $0f18, $0000, $0f18, $3a3a, $0000, $0000, $0021 dw $0fc8, $0fc8, $0000, $0fc8, $3a3a, $0000, $0000, $0022 dw $0e28, $0fb8, $0190, $0ef0, $3b3b, $0000, $0000, $0023 @@ -1539,6 +1757,7 @@ db $6e, $8c, $10, $35, $00, $10 db $6e, $90, $08, $b0, $00, $10 db $6e, $a4, $04, $b1, $00, $10 db $74, $4e, $10, $b1, $00, $1c +db $ff, $00, $02, $b5, $00, $08 ; temporary fix - murahdahla replaces one of the bonk tree prizes ; so we copy the sprite table here and update the pointer diff --git a/shopkeeper.asm b/shopkeeper.asm index e87c788..89491d5 100644 --- a/shopkeeper.asm +++ b/shopkeeper.asm @@ -4,7 +4,6 @@ ;-------------------------------------------------------------------------------- !BIGRAM = "$7EC900"; ;-------------------------------------------------------------------------------- -!SPRITE_OAM = "$7EC025" ; A = Tile ID macro UploadOAM(dest) PHA : PHP @@ -770,8 +769,6 @@ RTS ;-------------------------------------------------------------------------------- ;!SHOP_TYPE = "$7F5051" ;!SHOP_INVENTORY = "$7F5052" -!SPRITE_OAM = "$7EC025" -!REDRAW = "$7F5000" Shopkeeper_DrawItems: PHB : PHK : PLB PHX : PHY @@ -787,14 +784,6 @@ Shopkeeper_DrawItems: + CMP.b #$01 : BNE + : ++ JSR.w Shopkeeper_DrawNextItem + - LDA $A0 : CMP.b #$09 : BNE + ; render powder slot if potion shop - LDA !REDRAW : BNE + ; if not redrawing - LDA $02DA : BNE + ; if not buying item - LDA $7F505E : BEQ + ; if potion slot filled - LDA $0ABF : BEQ + ; haven't left the room - LDA NpcFlags+1 : AND.b #$20 : BNE + - LDX.b #$0C : LDY.b #$03 : JSR.w Shopkeeper_DrawNextItem - + PLY : PLX PLB RTS @@ -820,14 +809,59 @@ Shopkeeper_DrawNextItem: SEP #$20 ; set 8-bit accumulator PLY + STZ $0E ; $0E will be used temporarily to store a non-zero value if VRAM slot is in OAM1 PHX : LDA #0 : XBA : TXA : LSR #2 : TAX : LDA.l !SHOP_INVENTORY_DISGUISE, X : PLX : CMP #$0 : BNE ++ - LDA.l !SHOP_INVENTORY, X ; get item palette + LDA.l !SHOP_INVENTORY, X ++ - CMP.b #$2E : BNE + : BRA .potion - + CMP.b #$2F : BNE + : BRA .potion - + CMP.b #$30 : BEQ .potion + CMP.b #$2E : BNE + : JMP .potion + + CMP.b #$2F : BNE + : JMP .potion + + CMP.b #$30 : BNE + : JMP .potion + + CMP.b #$B1 : BNE + : BRA .apple + + CMP.b #$B2 : BNE + : BRA .fairy + + CMP.b #$B5 : BNE + : BRA .goodbee + + CMP.b #$34 : BCC + : CMP.b #$36+1 : BCS + + BRA .rupee + + .normal LDA.w .tile_indices, Y : BRA + ; get item gfx index + .rupee + LDA.b #$0B ; rupee is #$0B because it's already there in VRAM + STA.b $0E + BRA .vramLoc + .fairy + REP #$20 + LDA.b $1A : SEC : SBC.w #$10 : AND.w #$0020 : BEQ ++ ; alternate every 32 frames + LDA.l !SPRITE_OAM+2 : SEC : SBC.w #$02 ; move fairy up 2 pixels + STA.l !SPRITE_OAM+2 + ++ + SEP #$20 + LDA.b $1A : AND.b #$20 : BEQ ++ ; alternate every 32 frames + LDA.b #$EC ; use other fairy GFX + STA.b $0E + BRA .vramLoc + ++ + LDA.b #$EA ; fairy is #$EA/EC because it's already there in VRAM + STA.b $0E + BRA .vramLoc + .goodbee + REP #$20 + LDA.b $1A : SEC : SBC.w #$10 : AND.w #$0020 : BEQ ++ ; alternate every 32 frames + LDA.l !SPRITE_OAM+2 : SEC : SBC.w #$02 ; move bee up 2 pixels + STA.l !SPRITE_OAM+2 + ++ + SEP #$20 + LDA.b $1A : AND.b #$20 : BEQ ++ ; alternate every 32 frames + LDA.b #$D4 ; use other bee GFX + STA.b $0E + BRA .vramLoc + ++ + LDA.b #$E4 ; good bee is #$E4/D4 because it's already there in VRAM + STA.b $0E + BRA .vramLoc + .apple + LDA.b #$E5 ; apple is #$E5 because it's already there in VRAM + STA.b $0E + BRA .vramLoc .potion LDA.b #$C0 ; potion is #$C0 because it's already there in VRAM + @@ -839,6 +873,7 @@ Shopkeeper_DrawNextItem: XBA AND #$FE + .vramLoc STA.l !SPRITE_OAM+4 PHX : LDA #0 : XBA : TXA : LSR #2 : TAX : LDA.l !SHOP_INVENTORY_DISGUISE, X : PLX : CMP #$0 : BNE ++ @@ -846,11 +881,13 @@ Shopkeeper_DrawNextItem: ++ JSL.l GetSpritePalette : STA.l !SPRITE_OAM+5 - LDA.w .tile_indices, Y : AND.b #$01 : BEQ +; get tile index sheet + LDA.b $0E : BNE .oam1 ; item uses VRAM in OAM1 + LDA.w .tile_indices, Y : AND.b #$01 : BEQ ++ ; get tile index sheet + .oam1 LDA.l !SPRITE_OAM+5 ORA.b #$1 STA.l !SPRITE_OAM+5 - + + ++ LDA.b #$00 : STA.l !SPRITE_OAM+6 @@ -867,6 +904,10 @@ Shopkeeper_DrawNextItem: LDA.b #$00 STA.l !SPRITE_OAM+7 JSR.w PrepNarrowLower + LDA.b $0E : AND.b #$0F : CMP.b #$04 : BNE + + ; special exception for bee gfx, need top tile to be blank + LDA.b #$7C : STA.l !SPRITE_OAM+4 + + LDA.b #$02 ++ PHX : PHA : LDA !SCRATCH_TEMP_X : TAX : PLA : JSR.w RequestItemOAM : PLX diff --git a/stats.asm b/stats.asm index e2031f7..84736ad 100644 --- a/stats.asm +++ b/stats.asm @@ -7,8 +7,7 @@ ;-------------------------------------------------------------------------------- IncrementBonkCounter: LDA StatsLocked : BNE + - LDA BonkCounter : INC - CMP.b #100 : BEQ + ; decimal 100 + LDA BonkCounter : INC : BEQ + ; overflow STA BonkCounter + RTL @@ -328,9 +327,7 @@ RTL IndoorTileTransitionCounter: JMP StatTransitionCounter ;-------------------------------------------------------------------------------- -!REDRAW = "$7F5000" IndoorSubtileTransitionCounter: - LDA.b #$01 : STA !REDRAW ; set redraw flag for items STZ $0646 ; stuff we wrote over STZ $0642 JMP StatTransitionCounter diff --git a/tables.asm b/tables.asm index b862e3e..417c7cd 100644 --- a/tables.asm +++ b/tables.asm @@ -1510,8 +1510,9 @@ dw #9999 ; Rupee Limit ; $2F8000 - $2F83FF - RNG Block ;================================================================================ ; $7EC025 - $7EC034 - Item OAM Table +; $7EC035 - $7EC044 - Dynamic Item OAM Table ;================================================================================ -; $7F5000 - Redraw Flag +; $7F5000 - FREE (Old Global Redraw Flag) ; $7F5001 - Flipper Softlock Possible ; $7F5002 - L/R Rotate ; $7F5003 - HexToDec 1st Digit diff --git a/tablets.asm b/tablets.asm index 3d49304..5c7929e 100644 --- a/tablets.asm +++ b/tablets.asm @@ -34,7 +34,6 @@ SpawnTabletItem: JSL.l HeartPieceGetPlayer : STA !MULTIWORLD_SPRITEITEM_PLAYER_ID JSL.l LoadOutdoorValue PHA - JSL.l PrepDynamicTile LDA.b #$01 : STA !FORCE_HEART_SPAWN : STA !SKIP_HEART_SAVE JSL.l SetTabletItem @@ -42,6 +41,8 @@ SpawnTabletItem: LDA.b #$EB STA $7FFE00 JSL Sprite_SpawnDynamically + + LDA.b #$01 : STA.w !SPRITE_REDRAW, Y PLA : STA $0E80, Y ; Store item type LDA $22 : STA $0D10, Y diff --git a/utilities.asm b/utilities.asm index d0e6d5f..68cc11b 100644 --- a/utilities.asm +++ b/utilities.asm @@ -155,11 +155,11 @@ RTL ;Bx db $2C ; Bee Trap - db $4A ; Apples - db $4A ; Fairy - db $4A ; Chicken + db $4D ; Apples + db $4C ; Fairy + db $4B ; Chicken db $3B ; Big Magic - db $02 ; 5 Arrows + db $4A ; Good Bee db $13 ; Bomb Upgrade db $07 ; Cane Upgrade db $49, $49, $49, $49, $49, $49, $49, $49 ; Unused @@ -302,11 +302,11 @@ RTL db $08, $08, $08, $08, $08, $08, $08, $08, $08, $08, $08, $08, $08, $08, $08, $08 ; Free Big Key db $08, $08, $08, $08, $08, $08, $08, $08, $08, $08, $08, $08, $08, $08, $08, $08 ; Free Small Key db $04 ; Bee Trap - db $08 ; Apples + db $02 ; Apples db $08 ; Fairy - db $08 ; Chicken + db $02 ; Chicken db $08 ; Big Magic - db $04 ; 5 Arrows + db $04 ; Good Bee db $F7 ; Bomb Upgrade db $0A ; Cane Upgrade db $08, $08, $08, $08, $08, $08, $08, $08 ; Unused @@ -377,7 +377,7 @@ IsNarrowSprite: LDX.b #$00 ; set index counter to 0 ;---- - - CPX.b #$2A : !BGE .false ; finish if we've done the whole list + CPX.b #(.smallSprites_end-.smallSprites) : !BGE .false ; finish if we've done the whole list CMP.l .smallSprites, X : BNE + ; skip to next if we don't match ;-- SEC ; set true state @@ -400,7 +400,8 @@ RTL db $15, $18, $24, $2A, $34, $35, $36, $42 db $43, $45, $59, $A0, $A1, $A2, $A3, $A4 db $A5, $A6, $A7, $A8, $A9, $AA, $AB, $AC - db $AD, $AE, $AF, $B4, $B7, $FF, $FF, $FF + db $AD, $AE, $AF, $B4, $B5, $B7 + .smallSprites_end } ;-------------------------------------------------------------------------------- @@ -424,9 +425,10 @@ PrepDynamicTile: + TXA JSR.w LoadDynamicTileOAMTable - JSL.l GetSpriteID ; convert loot id to sprite id - JSL.l GetAnimatedSpriteTile_variable - LDA.b #$00 : STA !MULTIWORLD_SPRITEITEM_PLAYER_ID + CMP.b #$34 : BCC + : CMP.b #$36+1 : BCS + : BRA ++ ; if rupees, don't draw to OAM + + JSL.l GetSpriteID ; convert loot id to sprite id + JSL.l GetAnimatedSpriteTile_variable + ++ LDA.b #$00 : STA !MULTIWORLD_SPRITEITEM_PLAYER_ID PLY : PLX : PLA RTL ;-------------------------------------------------------------------------------- @@ -435,8 +437,6 @@ RTL ; LoadDynamicTileOAMTable ; in: A - Loot ID ;-------------------------------------------------------------------------------- 20/847B -!SPRITE_OAM = "$7EC025" -;-------------------------------------------------------------------------------- LoadDynamicTileOAMTable: PHA : PHP @@ -446,7 +446,11 @@ LoadDynamicTileOAMTable: STA.l !SPRITE_OAM+2 LDA.w #$0200 : STA.l !SPRITE_OAM+6 SEP #$20 ; set 8-bit accumulator - LDA.b #$24 : STA.l !SPRITE_OAM+4 + LDA $01,s + CMP.b #$34 : BCC + : CMP.b #$36+1 : BCS + ; if rupees, use animated gfx already in OAM + LDA.b #$0B : BRA ++ + + LDA.b #$24 + ++ STA.l !SPRITE_OAM+4 LDA $01,s @@ -458,11 +462,16 @@ LoadDynamicTileOAMTable: BRA .done .narrow - REP #$20 ; set 16-bit accumulator + LDA $02,s + CMP.b #$34 : BCC + : CMP.b #$36+1 : BCS + ; if rupees, use animated gfx already in OAM + REP #$20 + LDA.w #$1B00 : BRA ++ + + REP #$20 + LDA.w #$3400 + ++ STA.l !SPRITE_OAM+11 LDA.w #$0000 : STA.l !SPRITE_OAM+7 STA.l !SPRITE_OAM+14 LDA.w #$0800 : STA.l !SPRITE_OAM+9 - LDA.w #$3400 : STA.l !SPRITE_OAM+11 .done PLP : PLA @@ -476,7 +485,6 @@ RTS ;-------------------------------------------------------------------------------- ; This wastes two OAM slots if you don't want a shadow - fix later - I wrote "fix later" over a year ago and it's still not fixed (Aug 6, 2017) - lol (May 25th, 2019) ;-------------------------------------------------------------------------------- 2084B8 -!SPRITE_OAM = "$7EC025" !SKIP_EOR = "$7F5008" ;-------------------------------------------------------------------------------- DrawDynamicTile: diff --git a/zoraking.asm b/zoraking.asm index 020d805..d8517a8 100644 --- a/zoraking.asm +++ b/zoraking.asm @@ -4,7 +4,7 @@ LoadZoraKingItemGFX: LDA.l ZoraItem_Player : STA !MULTIWORLD_SPRITEITEM_PLAYER_ID LDA.l $1DE1C3 ; location randomizer writes zora item to - JML.l PrepDynamicTile + JML RequestSlottedTile ;-------------------------------------------------------------------------------- JumpToSplashItemTarget: LDA $0D90, X