lorom header org $01F407 JSR setX_SetY_get0540 ; also sets A, X, and Y to 16-bit ASL BCS return ; branch if torch is already lit sec ror STA $0540,Y ; sets top bit. lights the torch? ldy $08 ; using Y instead of A here is what allows me to not ; care about overwriting Y. how's that for ; paradoxes?! bne .notZero STA $7EFB40,X .notZero LDY #$0ECA JSR common2 ASL CLC JSL Sound_GetFineSfxPan ORA #$2A STA $012E PLB ; 37 bytes ; org $01F464 LDA #$01 STA $18 LDA $7EC005 ; is possibly dark room? BEQ skipBrightChg1 ; branch if not LDX $045A ; get lit torch count INC $045A ; increment it CPX #$03 BCS skipBrightChg1 ; branch if originally >= 3 LDA $7EF34A ; is Lantern/Lamp possessed? BEQ clearSpot ; branch if not lda $0458 cmp #$01 ; was this room determined to be dark, have proper lit ; torch count, etc. upon entry? bne clearSpot ; branch if not, as we know we're above stricter ; original spotlight threshold of == 0. CPX #$02 ; we're using patch's more lenient threshold of < 3. ; will we be at 3 after the increment? BCC changeBright1 ; branch if not clearSpot: STZ $1D ; disable subscreen/overlay spotlight ; 39 bytes changeBright1: inx ; X = new lit torch count changeBright1b: JSR common3 ; set desired ambient room brightness skipBrightChg1: common4: LDA $0333 AND #$0F TAX PLA STA $04F0,X ; set starting torch timer (or zero it if reached ; from next function) STZ $0333 RTL ; 18 bytes return: SEP #$30 PLB PLA RTL ; 5 bytes setX_SetY_get0540: REP #$30 LDA $0333 AND #$000F ASL CLC ADC $0478 TAY LDA $0520,Y AND #$00FF TAX LDA $0540,Y rts ; 25 bytes ; total = 124 bytes versus 143 bytes original ; --------------------------------- org $01F4AC LDA #$00 ; here are 5 reordered Nintendo instructions PHA ; put 00h on stack instead of C0h or C1h. lets us reuse ; above skipBrightChg1 code from this function, which ; won't read the pulled A in vanilla anyway (nor do ; its callers). ; Going to be using data bank $00 PHB PHA PLB JSR setX_SetY_get0540 ASL LSR ; was "ASL" because MoN's disassembly has "ASL #2" here. ; fucking pseudo-instructions need to die a painful death. STA $0540, Y STA $7EFB40, X LDY #$0EC2 JSR common2 PLB ; 25 bytes ; org $01F4F2 LDA #$01 STA $18 LDA $7EC005 ; is possibly dark room? BEQ skipBrightChg2 ; branch if not LDX $045A ; get lit torch count BEQ skipBrightChg2 ; branch if already zero somehow DEX ; decrement it STX $045A ; store decremented lit torch count CPX #$03 BCS skipBrightChg2 ; branch if new count >= 3 LDA $7EF34A ; is Lantern/Lamp possessed? BEQ skipSpotLt ; branch if not. maybe go to "STA $1D" if stricter? lda $0458 cmp #$01 ; was this room determined to be dark, have proper lit ; torch count, etc. upon entry? beq storeSpotLt ; branch if so, as we're using patch's more lenient ; spotlight threshold of < 3. txa ; get new lit torch count again bne skipSpotLt ; branch if it doesn't meet stricter original value ; of == 0. inc ; 40 bytes doSpotLt: ; LDA #$01 storeSpotLt: STA $1D ; value of 1 enables subscreen/overlay spotlight skipSpotLt: JSR common3 ; set desired ambient room brightness skipBrightChg2: JMP common4 ; zero torch timer and do something else with it ; 8 bytes common3: LDA $02A1E5,X ; get a brightness reducer based on new lit torch count STA $7EC017 ; save target value. will be phased in. LDA #$0A STA $11 STZ $B0 RTS ; 15 bytes common2: AND #$3FFF TAX STX $08 PHX ; this and PLA pointless but harmless when called by torch ; extinguish JSR Dungeon_PrepOverlayDma LDY $0C LDA #$FFFF STA $1100, Y PLA SEP #$30 RTS ; 22 bytes ; total = 110 bytes versus 124 original ; ---------- org $01F746 Dungeon_PrepOverlayDma: org $0DBBD0 Sound_GetFineSfxPan: