We've just updated MediaWiki and its underlying software. If anything doesn't look or work quite right, please mention it to us. --RanAS

Useful HDMA Codes

From SnesLab
Jump to: navigation, search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

These are some HDMA/PPU effects that can be useful to generate unique effects and also be used as a base to generate other combinations. Because it was designed to be used on Super Mario World's RAM mirrors, it may not work on all SNES games without additional code modification.

$0D9B is the $420C mirror.

Inverse Colors

by Ladida

;inverse colors (except status bar)
;messes up sprite priorities D:
;also, dont use message boxes

LDA.b #%10100000	;color subtraction, backdrop color math
STA $40
STA $2131
STZ $2121		;color 00
LDA #$FF		;set
STA $2122		;color
LDA #$7F		;to
STA $2122		;white (7FFF)

REP #$10
LDX #$2C01
STX $4350
LDX.w #MAINSUB
STX $4352
SEP #$10
LDA.b #MAINSUB>>16
STA $4354

LDA #$20
TSB $0D9F
RTS

MAINSUB:
db $25,%00000100,%00011011
db $80,%00000000,%00011111
db $00

Translucent Color Window

by Ladida

;n0ice translucent color window
;wiiqwertyuiop made one but lost the code so i had to make my own code, rrrrr
;some of the code is still his, specifically the hdma
;the window affects everything, including sprites (all palettes) :D
;sprite priorities may be messed up though, lol
;use in levelasm or whatever
;by ladida
;a

STZ $212C		;nothing on main screen
LDA.b #%00011111	;everything on sub screen
STA $212D
LDA.b #%00100000	;backdrop color math enable
STA $40
STA $2131

;LDA.b #%00100000	;enable color window 1
STA $43
STA $2125

STZ $2121
LDA #$BD : STA $2122	;window color low byte (SNES)
LDA #$08 : STA $2122	;window color high byte (SNES)

LDA.b #%01000010	;add in subscreen
STA $44			;also clip to black outside window
STA $2130		;(that just disables the color outside the window)

REP #$10
LDX #$2601		;two regs write once, regs [21]26 and [21]27
STX $4350
LDX.w #.DATA
STX $4352
LDA.b #.DATA>>16
STA $4354
SEP #$10

LDA #$20		;channel 5
TSB $0D9F
RTS

.DATA
db $80 : db $01 : db $00	;scanline : left window : right window
db $50 : db $50 : db $A0	
db $01 : db $01 : db $00	;if left window > right window, terminate window
db $00