Language…
13 users online: Batata Douce, DanMario24YT, dotCoockie, Dzing, Edu X, Hammerer, kurtistrydiz, mathew, MegacesarCG, monkey03297,  Saphros, StarWolf3000, TheOrangeToad - Guests: 269 - Bots: 305
Users: 64,795 (2,378 active)
Latest user: mathew

Need some clearance on masking registers

I'm trying to make this really sweet death animation for a boss. It involves a masking window on the sprite layer that covers the boss. I'm using HDMA with a RAM table to udate the window size so it looks like the boss fades away. At first I tried just writing to the left/right limit registers (2126/2127). That did nothing, however, so I checked regs.txt, which said these registers can not be written to outside of a blank.
I made an HDMA routine for it, thinking that H-blank would do. It still does nothing, however.

Code:

Code
	REP #$20		; > A 16 bit
		LDA #$2500		;\ Register 2125, one register write once
		STA $4340		;/
		LDA #$A407		;\ Location of table within bank
		STA $4342		;/
		LDY #$7F		;\ Source bank
		STY $4344		;/
		SEP #$20		; > A 8 bit
		LDA #$10		;\ Enable HDMA on channel 4
		TSB $0D9F		;/

		REP #$20
		LDA #$2601		; Register 2126, two registers write once
		STA $4350
		LDA #$A410
		STA $4352
		LDY #$7F
		STY $4354
		SEP #$20
		LDA #$20
		TSB $0D9F

		LDA $D8,x
		CLC
		ADC #$10		; Start at this scanline
		STA $00
		LSR A
		STA $7FA407		;\ Scanline count
		STA $7FA409		;/
		LDA #$00		;\
		STA $7FA408		; | No window on these scanlines
		STA $7FA40A		;/

		LDA !StunTimer		;\
		EOR #$7F		; | Window height
		LSR A			; |
		STA $7FA40B		;/
		CLC : ADC $00
		STA $01
		LDA #$02		;\ Enable the window on these scanlines
		STA $7FA40C		;/
		LDA #$DF		;\
		SEC : SBC $01		; |
		STA $7FA40D		; | Disable the window for all scanlines below
		LDA #$00		; |
		STA $7FA40E		;/
		LDA #$00		;\ End table
		STA $7FA40F		;/

		LDA $00
		LSR A
		STA $7FA410
		STA $7FA413
		LDA #$00
		STA $7FA411
		STA $7FA412
		STA $7FA414
		STA $7FA415

		LDA $01
		SEC : SBC $00
		STA $7FA416
		LDA $E4,x		;\ Window left position
		STA $7FA417		;/
		CLC : ADC #$20		;\ Window width
		STA $7FA418		;/

		LDA #$DF
		SEC : SBC $01
		STA $7FA419
		LDA #$00
		STA $7FA41A
		STA $7FA41B
		STA $7FA41C		; > End table

		LDA #$10		;\
		STA $212E		; | Only mask the sprite layer
		STA $212F		;/


!StunTimer is what controls the size of the mask.

TL;DR: How do I write to 2126/2127?

allow shy guy emojis in post footers you cowards!
Masking window, there is a thing in the mario gimmicks patch called nsmb secret tunnels, I wonder if you can help me understand how to use it?
Originally posted by Von Fahrenheit
TL;DR: How do I write to 2126/2127?

youre doing it correctly (from what i can tell).

perhaps check in something like VSNES to see if your window is active. if it is, then it's a problem with your math

you may/may not want to mess with $212A/$212B as well (at least to see if it gives you anything different)
Originally posted by Ladida
Originally posted by Von Fahrenheit
TL;DR: How do I write to 2126/2127?

youre doing it correctly (from what i can tell).

perhaps check in something like VSNES to see if your window is active. if it is, then it's a problem with your math

you may/may not want to mess with $212A/$212B as well (at least to see if it gives you anything different)


I have confirmed the window is not active (I think). It doesn't mask anything, and if I check bit 0 in 2125 it masks everything. I did as you said and checked in vSNES, which told me that my HDMA is active, 2126 = FF, 2127 = 00. This is obviously not a proper window. Well, this is weird. Does SMW do anything with the masking registers to disable them? 2127 SHOULD equal 2126 + 0x20, which it doesn't. Do I need to make a patch for this?

EDIT: I noticed something else in vSNES; it says 2125 is clear. That's weird. In the savestate I loaded I set 2125 to 03 to see if that did anything different, and something obviously happened, since it hid the entire sprite layer for those scanlines. Also the entire screen turns black when after the HDMA finishes and I disable it. The game doesn't crash, the screen just turns black until the OW is reloaded.

allow shy guy emojis in post footers you cowards!
Originally posted by Von Fahrenheit
Does SMW do anything with the masking registers to disable them?

it writes to $2123-$2125 every frame using the values from $41-$43. however, hdma should overwrite this no problem

it is most definitely a problem with your math (whatever you're pulling with the sprite's X and Y position, plus whatever is in !stuntimer). i just did a simple static mask in levelasm similar to your code and it worked fine:

Code
REP #$20
LDA #$2504 : STA $4340
LDA #$A407 : STA $4342
LDY #$7F : STY $4344
SEP #$20
LDA #$10 : TSB $0D9F

LDA #$50 : STA $7FA407
LDA #$10 : STA $7FA40C
LDA #$20 : STA $7FA411
LDA #$00 : STA $7FA416

LDA #$00 : STA $7FA408
LDA #$02 : STA $7FA40D
LDA #$00 : STA $7FA412

LDA #$80 : STA $7FA40E
LDA #$88 : STA $7FA40F


so i guess you should mess around with your values
I tried your code, it did no good. I tried my own 4 registers write once routine; it did no good. I'm starting to think you can't do this from sprite routines? I have no idea why that would be, but it seems to be the case. Despite everything, nothing happens, and vSNES still tells me the following: 2125 = 00, 2126 = FF, 2127 = 00, 2128 = 00. This makes no sense to me; why does nothing happen!? I swear I'm gonna end up losing my hair over this. I still appreciate the help though, if you have any ideas as to why it might not work, I'd like to hear them.

allow shy guy emojis in post footers you cowards!
Originally posted by Von Fahrenheit
I tried your code, it did no good. I tried my own 4 registers write once routine; it did no good. I'm starting to think you can't do this from sprite routines?

did you try in levelasm? if it doesnt work there either then something else is up. are you sure nothing else is overwriting your hdma (aka do you have anything else running in the level that uses the dma channels, like a gradient or something)?

though i did use my code in a nonclean rom, so there's that. will retry later on when i have time
Hmm, I went through the Scene Viewer in vSNES and that tells me that my HDMA is active and writing very much correct values to 2125 through 2127. It also says that windowing is disabled. I guess this means SMW does something to disable windows specifically. And yeah, I do have another HDMA active, which handles sprite color math on. I'll try doing it from outside of the sprite routine though.

allow shy guy emojis in post footers you cowards!
as long as the sprite color math hdma isnt using channel 4 or 5 then it's ok

Originally posted by Von Fahrenheit
I guess this means SMW does something to disable windows specifically.

like i said before, it writes $41-$43 to $2123-$2125 in NMI, which is what vsnes is detecting. the hdma overwrites that, though vsnes won't detect that in the info tab. since vsnes says the hdma is active, you shouldnt worry
Originally posted by Ladida
as long as the sprite color math hdma isnt using channel 4 or 5 then it's ok

Originally posted by Von Fahrenheit
I guess this means SMW does something to disable windows specifically.

like i said before, it writes $41-$43 to $2123-$2125 in NMI, which is what vsnes is detecting. the hdma overwrites that, though vsnes won't detect that in the info tab. since vsnes says the hdma is active, you shouldnt worry


I tried doing it with levelASM now and that doesn't work either. It just does nothing. vSNES confirmed the coordinates are right, so what in the world am I doing wrong?

allow shy guy emojis in post footers you cowards!
post the savestate. i'll see what i can jimmy out of it
I put the savestate on my files. It's the only .zst file so it should be easy to find. Thanks a lot for your help so far, Ladida!

allow shy guy emojis in post footers you cowards!
apparently channnel 7 is active, and writing to $2126/7 (most likely for message box/keyhole/level end). since the channels run from 0 up, that means channel 7 is overwriting whatever you're doing in channel 4

have you tried disabling it?

(this explains why it worked for me: i had removed the windowing effects. derp. you were right-on when you asked if it was something smw was doing)
Now that I know what channel 7 was actually doing, I tried disabling it while my windowing HDMA is running on channel 4 and it works perfectly. You're such a big help!

allow shy guy emojis in post footers you cowards!
just glad we found the problem #thp{>_<1}