;Note: Check 81FE, 817B, 81A4, 81DB. Bits for 1987. What sets 1987? Seems to come from 1983/1985 but those are always 00 as far as I see. ;X-ray scope and powerbombs set them somehow and require them to display properly. I'm going to be lazy and not bother figuring out all the details of them. ;Visor glow is hardcoded to FX A 28 and 2A. See 91/D849 lorom org $888000 PHP SEP #$30 LDY #$00 LDX $1986 BEQ + ;Default: ;Summary: Main screen 1-2-sprites, Subscreen 3. Add subscreen (layer 3) to everything else. STZ $60 ;v STZ $61 ;v STZ $62 ;Layers to mask with windows LDA #$13 STA $69 ;Main screen layers LDA #$04 STA $6B ;Subscreen layers STZ $6C ;Mainscreen Window masking STZ $6D ;Subscreen Window masking LDA #$02 STA $6E ;Color addition rules ; LDA #$33 ; STA $71 ;Color addition layers JSR (FX_Table,X) STA $71 + LDA $1987 BPL + JSR Option1_1987 BRA ++ + ASL BPL + JSR Option2_1987 BRA ++ + ASL BPL + JSR Option3_1987 BRA ++ + ASL BPL ++ JSR Option4_1987 ++ PLP FX_00: ;bad x-ray scope (due to skipping default setup?) FX_02: ;Normal FX ;FX_20: FX_0E: RTS FX_Table: DW FX_00, FX_02, FX_04, FX_06, FX_08, FX_0A, FX_0C, FX_0E DW FX_10, FX_12, FX_14, FX_16, FX_18, FX_1A, FX_1C, FX_1E DW FX_20, FX_22, FX_24, FX_26, FX_28, FX_2A, FX_2C, FX_2E DW FX_30, FX_32, FX_34 FX_20: ;Windowing for PiratePuzzle. I am relatively confident this will work as I intend it to now. ;Layer 1 and sprites on mainscreen, BG3 and sprites on subscreen. Sprites do not contribute to color math on left part of screen, they do on right part of screen. ;Window 1 affects sprites (62 = 02), mask sprites on subscreen (6D = 10) ;Use priority 0 sprites and BG3. LDY #$08 ;This might fix powerbombs? LDA #$00 ;Left window edge STA $63 LDA #$5F ;Right window edge STA $64 LDA #$02 STA $62 LDA #$10 STA $6D INC ;LDA #$11 STA $69 LDA #$14 STA $6B LDA #$21 ;I don't *think* this is necessary... but let's be safe ; STA $71 RTS FX_04: ;no bg ;Summary: Main screen 1 and sprites, subscreen 3. Layer 2 is unused. LDA #$11 STA $69 ; LDA #$04 ; STA $6B LDA #$33 RTS FX_06: ;liquid/fog drawn behind Sprite Layer, L1 FG out of water is transparent ;Summary: Main screen 1-2-sprites, subscreen 3-sprites. Add subscreen (layer 3+sprites) to layers 1-2-3 and backdrop. LDA #$14 STA $6B LDA #$27 ; STA $71 RTS FX_08: ;liquid/fog drawn behind Layer 1 and Sprite Layer ;Summary: Main screen 1-2-sprites, subscreen 3-sprites. Add subscreen to layer 2 and backdrop. LDA #$14 STA $6B LDA #$22 ; STA $71 RTS FX_0A: ;liquid/fog drawn behind Layer 1 only -- USED for spores ;Summary: Add subscreen to layer 2, sprites, backdrop. LDA #$32 ; STA $71 RTS FX_0C: ;liquid/fog drawn behind all ;Summary: Average fixed color to layer 2, sprites, backdrop. Does not set fixed color. STZ $6E LDA #$A2 ; STA $71 RTS FX_10: ;liquid/fog drawn behind enemies only FX_12: ;liquid/fog drawn behind enemies only ;Summary: Enable Window 1 on BG3 and Color, enable subscreen masking on BG3. Um, ok, but it's not set to do anything... LDA #$02 STA $61 LDA #$20 STA $62 LDA #$04 STA $6D FX_Cheated: LDA #$33 RTS FX_18: ;USED for normal water FX_1E: ;seemingly normal, liquid/fog drawn over all -- USED for lava/acid FX_30: ;seeminly normal -- USED for fog ;Summary: Do color math on Layer 3 and backdrop. Main screen layer 3, subscreen layer 1-2 sprites. Interesting way of getting around sprite palette math limitation LDY #$02 LDA $84 AND #$30 ;Check IRQs EOR #$30 ;If there is not a specific H/V set up, branch. This is almost the first code run every frame, so there's always the status bar IRQ set up and this never branches? BNE FX_Cheated ;tricksy branching to save bytes LDA #$13 STA $6B LDA #$04 STA $69 LDA #$24 RTS FX_16: ;darkens liquid, transparent layer 2 drawn over Layer 1 and Samus -- USED for Maridian waterfall rooms ;Summary: Main screen 1-sprites, subscreen 2-3. Subtract subscreen from 1-sprites-backdrop. LDY #$04 LDA #$11 STA $69 LDA #$06 STA $6B LDA #$B1 ; STA $71 RTS FX_1A: ;wacky transparencies -- possible interesting uses ;Summary: Main screen 1-3-sprites, subscreen 2. Add subscreen to 1-3-sprites-backdrop. LDY #$04 LDA #$15 STA $69 LDA #$02 STA $6B LDA #$35 ; STA $71 RTS FX_1C: ;wacky transparencies -- darker ;Summary: Main screen 1-3-sprites, subscreen 2. Average subscreen to 1-3-sprites. LDA #$15 STA $69 LDA #$02 STA $6B LDA #$55 ; STA $71 RTS FX_26: ;ugly darkness ;Summary: Average subscreen onto everything. LDA #$77 ; STA $71 RTS FX_28: ;dark room, no liquid/fog, no visor glow ;Summary: Subtract fixed color from 1-2-sprites-backdrop. Set fixed color to rgb 5-0-0 (out of 32). STZ $6E BIT $1987 BMI FX_14 ;BMI + LDA #$25 STA $74 LDA #$40 FX_Cheat2: ;MUST. SAVE. BYTES. STA $75 LDA #$80 STA $76 ;+ FX_14: ;darkens liquid -- USED for Maridian water FX_22: ;seemingly normal, liquid/fog drawn over all ;Summary: Subtract colors instead of add colors. FX_2E: ;darkens liquid, liquid/fog drawn behind enemies ;Summary: Subtract subscreen (assumably) from 1-2-sprites-backdrop. LDA #$B3 ; STA $71 RTS FX_2A: ;darker room, no liquid/fog, no visor glow ;Summary: Subtract fixed color from 1-2-sprites-backdrop. Set fixed color to rgb 6-2-0 (out of 32) STZ $6E BIT $1987 BMI FX_22 LDA #$26 STA $74 LDA #$42 BRA FX_Cheat2 FX_2C: ;no liquid/fog drawn ;Summary: Add fixed color instead of subscreen. STZ $6E LDA #$33 RTS FX_32: ;darkens liquid, draws liquid/fog behind enemies and Layer 1 ;Summary: Set subcreen to 3-INVALIDHARDWAREBIT, subtract subscreen from 2-sprites-backdrop. LDA #$44 STA $6B LDA #$B2 ; STA $71 RTS FX_34: ;liquid/fog drawn behind enemies only ;Summary: Normal. LDY #$06 LDA #$33 RTS FX_24: ;24 - no liquid/fog drawn ;Summary: Enable Window 1 on BG3 and Color, enable main screen masking on 1-2-sprites, subscreen masking on 3. Add fixed color, but do not do color math outside of window 1. ; LDA #$00 ; STA $60 LDA #$02 STA $61 LDA #$20 STA $62 ; LDA #$13 ; STA $69 ; LDA #$04 ; STA $6B LDA #$13 STA $6C LDA #$04 STA $6D LDA #$10 STA $6E LDA #$33 ; STA $71 RTS Option2_1987: LDA #$C8 STA $60 ;Enable window 1 on BG2, window 2 on BG1 and BG2 LDA #$08 STA $61 ;Enable window 2 on BG3 LDA #$80 STA $62 ;Enable window 2 on color LDA #$13 STA $69 ;Sprites and layer 1-2 on main screen LDA #$04 STA $6B ;layer 3 on subscreen LDA #$03 STA $6C ;layer 1-2 masked on main screen LDA #$04 STA $6D ;layer 3 masked on subscreen LDA #$22 STA $6E ;Add or subtract subscreen, prevent color math inside color window LDA $71 AND #$80 ORA #$73 STA $71 ;Preserve addition/subtraction, divide color result by 2, color math on 1-2-3-sprites-backdrop RTS Option3_1987: STZ $60 LDA #$08 STA $61 ;Enable window 2 on BG3 LDA #$80 STA $62 ;Enable window 2 on color LDA #$13 STA $69 ;Sprites and layer 1-2 on main screen LDA #$04 STA $6B ;Layer 3 on subscreen LDA #$03 STA $6C ;layer 1-2 masked on main screen LDA #$04 STA $6D ;layer 3 masked on subscreen LDA #$22 STA $6E ;Add or subtract subscreen, prevent color math inside color window LDA $71 AND #$80 ORA #$61 STA $71 ;Preserve addition/subtraction, divide color result by 2, color math on 1-backdrop REP #$20 LDA $079B CMP #$CEFB ;Check for breakable Maridia tube room SEP #$20 BNE + LDA #$11 STA $69 ;Sprites and layer 1 on main screen if Maridia tube room + RTS Option4_1987: STZ $60 LDA #$08 STA $61 ;Enable window 2 on BG3 LDA #$80 STA $62 ;Enable window 2 on color LDA #$13 STA $69 ;Sprites and layer 1-2 on main screen STZ $6B ;Layer 3 on oh wait not really. No subscreen LDA #$03 STA $6C ;layer 1-2 masked on main screen LDA #$04 STA $6D ;layer 3 masked on subscreen LDA #$20 STA $6E ;Fixed color, prevent color math inside color window LDA #$B3 STA $71 ;Subtract color, color math on layer 1-2-sprite-backdrop RTS ;I think this is for powerbombs? Option1_1987: ; REP #$30 ; LDA $079B ; CMP #$A66A ;Check for gold statue room (the entrance to Tourian) ; SEP #$30 ; BNE + ; LDY #$06 ;+ LDA #$08 STA $61 ;Enable window 2 on BG3 LDA #$80 STA $62 ;Enable window 2 on color LDA #$02 STA $6E ;Normal color math, use subscreen STZ $6C ;No main screen masking TYX JSR (UnknownTable,X) ; $40211 IN ROM STA $6B RTS UnknownTable: DW UnkOption1, UnkOption2, UnkOption3, UnkOption4, PiratePuzzleFix UnkOption1: UnkOption2: STZ $60 LDA #$37 STA $71 ;Add color to 1-2-3-sprites-backdrop LDA #$04 STA $6D ;Subscreen mask 3 LDA #$13 STA $69 ;Main screen 1-2-sprites LDA #$04 ;Subscreen 3 RTS UnkOption3: LDA #$80 STA $60 ;Enable window 2 on BG2 LDA #$37 STA $71 ;Add color to 1-2-3-sprites-backdrop LDA #$06 STA $6D ;Subscreen mask 2-3 LDA #$11 STA $69 ;Main screen 1-sprites LDA #$06 ;Subscreen 2-3 RTS UnkOption4: STZ $60 LDA #$31 STA $71 ;Add color to 1-sprites-backdrop LDA #$04 STA $6D ;Subscreen mask 3 LDA #$13 STA $69 ;Main screen 1-2-sprites LDA #$04 ;Subscreen 3 RTS PiratePuzzleFix: LDA #$04 STA $6D RTS print pc