From 49afe7ca9b434f9410c9d6a3bbf07abfca83d85a Mon Sep 17 00:00:00 2001 From: spannerisms <32842036+spannerisms@users.noreply.github.com> Date: Sun, 20 Jun 2021 10:09:04 -0400 Subject: [PATCH 1/2] onemind --- LTTP_RND_GeneralBugfixes.asm | 5 +- dpadinvert.asm => controllerjank.asm | 89 +++++++++++++++++++++++++--- hooks.asm | 6 +- init.asm | 7 ++- tables.asm | 15 ++++- 5 files changed, 109 insertions(+), 13 deletions(-) rename dpadinvert.asm => controllerjank.asm (58%) diff --git a/LTTP_RND_GeneralBugfixes.asm b/LTTP_RND_GeneralBugfixes.asm index ff6eac4..6d773f2 100644 --- a/LTTP_RND_GeneralBugfixes.asm +++ b/LTTP_RND_GeneralBugfixes.asm @@ -91,6 +91,9 @@ db #$20, #$19, #$08, #$31 ; year/month/day ;!REG_MUSIC_CONTROL = $012C !REG_MUSIC_CONTROL_REQUEST = $012C +!ONEMIND_ID = $7F5072 +!ONEMIND_TIMER = $7F5073 + ;================================================================================ incsrc hooks.asm @@ -182,7 +185,7 @@ incsrc endingsequence.asm incsrc cuccostorm.asm incsrc compression.asm incsrc retro.asm -incsrc dpadinvert.asm +incsrc controllerjank.asm incsrc boots.asm incsrc events.asm incsrc fileselect.asm diff --git a/dpadinvert.asm b/controllerjank.asm similarity index 58% rename from dpadinvert.asm rename to controllerjank.asm index e030526..b3ecf79 100644 --- a/dpadinvert.asm +++ b/controllerjank.asm @@ -5,9 +5,31 @@ ; Filtered Joypad 1 Register: [AXLR | ????] ; Filtered Joypad 1 Register: [BYST | udlr] [AXLR | ????] !INVERT_DPAD = "$7F50CB" + InvertDPad: - LDA !INVERT_DPAD : BNE + : JMP .normal : + - DEC : BEQ .dpadOnly + LDA.l OneMindPlayerCount : BEQ .crowd_control + + LDA.l !ONEMIND_ID + AND.b #$03 + TAX + LDA.l .onemind_controller_offset, X + TAX + + LDA.w $4218,X : STA.w $00 + LDA.w $4219,X : STA.w $01 + + LDA #$80 : STA $4201 ; reset this so latch can read it, otherwise RNG breaks + + JML.l InvertDPadReturn + +.crowd_control + LDA !INVERT_DPAD : BNE + + + LDA $4218 : STA $00 + LDA $4219 : STA $01 + JML.l InvertDPadReturn + ++ DEC : BEQ .dpadOnly DEC : BEQ .buttonsOnly DEC : BEQ .invertBoth .swapSides @@ -45,8 +67,61 @@ JML.l InvertDPadReturn BIT.b #$03 : BEQ + : EOR.b #$03 : + ; swap left/right STA $01 JML.l InvertDPadReturn - .normal - LDA $4218 : STA $00 - LDA $4219 : STA $01 -JML.l InvertDPadReturn -;-------------------------------------------------------------------------------- \ No newline at end of file + +.onemind_controller_offset + db 0 ; player 0 - $4218 - joy1d1 + db 0 ; player 1 - $4218 - joy1d1 + db 2 ; player 2 - $421A - joy2d1 + db 6 ; player 3 - $421E - joy2d2 + db 2 ; player 4 - $421A - joy2d1 + db 6 ; player 5 - $421E - joy2d2 + + + +;-------------------------------------------------------------------------------- + +HandleOneMindController: + LDA.l OneMindPlayerCount + BEQ .no_onemind + + REP #$20 + + LDA.l !ONEMIND_TIMER + DEC + BPL .no_switch + + SEP #$20 + LDA.l !ONEMIND_ID + INC + CMP.l OneMindPlayerCount + BCC .no_wrap + + LDA.b #$01 ; reset to player 1 + +.no_wrap + STA.l !ONEMIND_ID + + REP #$20 + LDA.l OneMindTimer + +.no_switch + STA.l !ONEMIND_TIMER + + SEP #$20 + LDA.l !ONEMIND_ID + + CMP.b #$04 ; is it player 4 or 5? + BCC .no_multitap_switch + + STZ.w $4201 + +.no_multitap_switch + +.no_onemind + STZ.b $12 + + JML $008034 ; reset frame loop + + + + diff --git a/hooks.asm b/hooks.asm index 6bc8153..19e5532 100755 --- a/hooks.asm +++ b/hooks.asm @@ -14,6 +14,8 @@ dl Init_PostRAMClear org $008056 ; <- 56 - Bank00.asm : 77 JSL.l FrameHookAction ;-------------------------------------------------------------------------------- +org $00805D +JML HandleOneMindController ;================================================================================ ; NMI Hook @@ -48,8 +50,8 @@ ReturnCheckZSNES: ;-------------------------------------------------------------------------------- ;org $0083D9 ; <- 3D9 - Bank00.asm : 611 (LDA $4219 : STA $01) ;JSL.l InvertDPad : NOP -org $0083D4 ; <- 3D4 - Bank00.asm : 610 (LDA $4218 : STA $00) -JML.l InvertDPad : SKIP 6 +org $0083D1 ; <- 3D1 - Bank00.asm (STZ.w JOYPAD - useless instruction here) +JML.l InvertDPad : SKIP 9 InvertDPadReturn: ;-------------------------------------------------------------------------------- diff --git a/init.asm b/init.asm index 47a5726..340c4a9 100644 --- a/init.asm +++ b/init.asm @@ -40,8 +40,13 @@ Init_Primary: INX CPX #$15 : !BLT - .done - + + REP #$20 + LDA.l OneMindTimer : STA.l !ONEMIND_TIMER + SEP #$20 + LDA.b #$01 : STA $420D ; enable fastrom access on upper banks + STA.l !ONEMIND_ID LDA.b #$10 : STA $BC ; set default player sprite bank diff --git a/tables.asm b/tables.asm index 8095852..ead8c70 100644 --- a/tables.asm +++ b/tables.asm @@ -412,7 +412,16 @@ db #$02 ; #$02 - 2 Bows (default) ProgressiveBowReplacement: db #$47 ; #$47 - 20 Rupees (default) ;-------------------------------------------------------------------------------- -; 0x18009A - 0x18009F (unused) +; 0x18009A - 0x18009C one mind +;-------------------------------------------------------------------------------- +org $30809A ; PC 0x18009A +OneMindPlayerCount: +db 0 +org $30809B ; PC 0x18009B - 0x18009C +OneMindTimer: +dw 0 +;-------------------------------------------------------------------------------- +; 0x18009D - 0x18009F (unused) ;-------------------------------------------------------------------------------- org $3080A0 ; PC 0x1800A0 - 0x1800A4 Bugfix_MirrorlessSQToLW: @@ -1481,7 +1490,9 @@ dw #9999 ; Rupee Limit ; $7F5050 - $7F506F - Shop Block ; $7F5070 - Reserved for OneMind ; $7F5071 - Reserved for OneMind -; $7F5072 - $7F507D - Unused +; $7F5072 - OneMind player ID +; $7F5073 - $7F5074 - OneMind timer +; $7F5075 - $7F507D - Unused ; $7F507E - Clock Status ; $7F507F - Always Zero ; $7F5080 - $7F5083 - Clock Hours From be0389ffbb369116898a04cc5a6d66855ad880d8 Mon Sep 17 00:00:00 2001 From: spannerisms <32842036+spannerisms@users.noreply.github.com> Date: Thu, 24 Jun 2021 08:36:04 -0400 Subject: [PATCH 2/2] stats --- hooks.asm | 8 ++++++++ stats.asm | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/hooks.asm b/hooks.asm index 19e5532..f057e2d 100755 --- a/hooks.asm +++ b/hooks.asm @@ -2646,3 +2646,11 @@ JSL FastCreditsCutsceneTimer org $0EE773 JSL FastTextScroll : NOP + +;================================================================================ +org $01FFEE : JSL IncrementDamageTakenCounter_Eight ; overworld pit +org $079506 : JSL IncrementDamageTakenCounter_Eight ; underworld pit + +org $0780C6 : JSL IncrementDamageTakenCounter_Arb + +org $07B0B1 : JSL IncrementMagicUseCounter \ No newline at end of file diff --git a/stats.asm b/stats.asm index 0b0f433..637dfe2 100644 --- a/stats.asm +++ b/stats.asm @@ -360,6 +360,45 @@ IncrementBigChestCounter: + PLA RTL +;-------------------------------------------------------------------------------- +IncrementDamageTakenCounter_Eight: + STA.l $7EF36D + PHA : PHP + LDA !LOCK_STATS : BNE + + REP #$21 + LDA.l !DAMAGE_COUNTER + ADC.w #$0008 + STA.l !DAMAGECOUNTER ++ PLP + PLA +RTL + +IncrementDamageTakenCounter_Arb: + PHP + LDA !LOCK_STATS : BNE + + REP #$21 + LDA.b $00 + AND.b #$00FF + ADC.l !DAMAGE_COUNTER + STA.l !DAMAGE_COUNTER ++ PLP + + LDA.l $7EF36D +RTL + +IncrementMagicUseCounter: + STA.l $7EF36E + PHA : PHP + LDA !LOCK_STATS : BNE + + REP #$21 + LDA.b $00 + AND.b #$00FF + ADC.l !MAGIC_COUNTER + STA.l !MAGIC_COUNTER ++ PLP : PLA + +RTL + ;-------------------------------------------------------------------------------- !OW_MIRROR_COUNTER = "$7EF43A" IncrementOWMirror: