Banner
Views: 778,986,809
Time:
16 users online: autisticsceptile1993,  bebn legg, chickaDEE Magazine, Christian07, dfade, DPBOX, Green Jerry, MarkVD100,  Meirdent,  musicalman, SiameseTwins,  Tahixham, The Hacking Yoshi, TheMorganah, TomCube, Zandro - Guests: 55 - Bots: 205 Users: 40,840 (1,676 active)
Latest: GoldenWarrior
Tip: Linear levels aren't necessarily a bad thing. After all, most official Mario levels are fairly linear.Not logged in.
Comprehensive HDMA Tutorial
Forum Index - SMW Hacking - SMW Hacking Help - Tutorials - Comprehensive HDMA Tutorial
Pages: « 1 2 3 4 5 »
In level.asm,and other HDMA codes like:

Underwater
Lava
Desert
3D

What code should use??
Whatever you need for your level.

But I have a question:
Should it be inserted in Levelcode or LevelInit?
I have copied the example HDMA Kaijyuu has given in B) into LevelCode, to check if it inserts, but it doesn't.
I inserted it in level 15, but the only thing happening, is that the BG of LVL 105 is flickering in all colours..
LVL 15 is completely unaffected, but xkas isn't giving me an error message or something.
Do I have to insert anything else before that?

--------------------
Your layout has been removed.
This is probarly a bump... *BUMP*
But how do I fix, the first few frames when entering a level, the HDMA doesn't appear?

--------------------
Your layout has been removed.
Well, if you're using LevelASM, make sure the level init runs your HDMA code too.

If you're using a generator, there isn't an easy fix.
is horizontal HDMA possible???

--------------------
Your layout has been removed.
That's the only thing possible with HDMA, actually. It stands for "Horizontal Direct Memory Access", after all.

However, if you mean something like a left-to-right-gradient, no, that won't work with HDMA.

--------------------


 
Would it work with windowing and color math?

--------------------
I own a community of TF2 servers!

ASMT - A new revolutionary ASM system, aka 65c816 ASseMbly Thing
SMWCP - SMW Central Presents a Product- tion long name

frog

http://esolangs.org/wiki/MarioLANG
Windowing only lets you hide/show layers, sprites and color math. It'll work if you want one of those, but not anything like gradients or scrolling.
OMG THAT IS WAY TOO HARD TO USE CODES LIKE THAT MAKE A EASYER NOOBS AND BAN ME FOREVER SO FUCK U
AND PLEASE DONT IP BAN ME THINK U
You know the desert effect code for Levelasm??
Anybody could explain me??
Gradient or wavy effects?

You should be able to make your own gradient if you read the tutorial. However wavy effects would be HARD. (Depending on what you're trying.)

--------------------
I own a community of TF2 servers!

ASMT - A new revolutionary ASM system, aka 65c816 ASseMbly Thing
SMWCP - SMW Central Presents a Product- tion long name

frog

http://esolangs.org/wiki/MarioLANG
I think he means wavy. Can anyone make a a lava effect for me???
Wavy and red?

--------------------
Your layout has been removed.

Originally posted by Brady.R
OMG THAT IS WAY TOO HARD TO USE CODES LIKE THAT MAKE A EASYER NOOBS AND BAN ME FOREVER SO FUCK U
AND PLEASE DONT IP BAN ME THINK U

Huh? Rephrase that please.
Though, i think you mean:
Originally posted by Brady.R
Hey everybody, ASM is for noobs and i want to get IP banned

am i right?

@Kevinskie555: Uhm, that is really hard, and this is not the requests section. you can request it here

Can color gradients also be used in the foreground? i tried, and it only gave me black =(



I might put some sort of signature here once. I guess.
Color gradients can be used anywhere. Layer 1,2,3,4,OBJ.
However, you will have to set the value to register $2131 ($40 in SMW)

Example to only affect layer2:

LDA #$02
STA $40

if this does not work use $2131 instead of $40.

Format as follows:
76543210
abcdefgh
a = 0 for Addition, 1 for Subtraction
b = 1/2 Enable
c = Back Enable
d = Object Enable
efgh = Enable BG 4, 3, 2, 1

02 = 10 in binary = g0 = Layer 2 only.



If any questions, feel free to ask.
Code
levelinit6:

	REP #$20	; 16 bit A
	LDA #$0F42	; one reg write twice, indirect
	STA $4340	; $210F - layer 2 horizontal scroll register
	LDA #$B600	; low and high bytes of source address
	STA $4342	;
	SEP #$20	; 8 bit A
	LDA #$7F	; set bank
	STA $4344	;
	STA $4347	; set indirect bank too
	LDA #$10  	; enable channel 4
	TSB $0D9F	; 


	LDA #$00	; setup indirect addressing
	STA $00		; target address: $7FB600
	LDA #$B6
	STA $01
	LDA #$7F
	STA $02

	LDX #$09	; loop 10 (decimal) times

LVL6_LOOP6:

	LDY #$17	; loop 24 (decimal) times
LVL6_LOOP7:
	LDA LVL6_HDMA4,y;
	STA [$00],y	; upload table to RAM
	DEY
	BPL LVL6_LOOP7

	REP #$20	; 16 bit A
	LDA $00		; load low/high byte of target address
	CLC
	ADC #$0018	; add 18
	STA $00		; store back
	SEP #$20	; 8 bit A

	DEX
	BPL LVL6_LOOP6	; loop again if needed

	LDA #$00	; add in terminator byte
	STA [$00]

	JMP level6	; jump to remaining code

;;;;;;;;

level6:

	REP #$20	; 16 bit A

	LDX #$0E	; update scroll values
LVL6_LOOP8:
	LDA $1E		; layer 2 x
	CLC
	ADC LVL6_HDMA2,x; add in offset
	STA $7FB710,x	; store to HDMA table
	DEX
	DEX
	BPL LVL6_LOOP8	; loop 8 times

	SEP #$20	; 8 bit A

	LDX #$15	; reset these scanline counts
	LDA #$04
LVL6_8:
	STA $7FB600,x
	DEX
	DEX
	DEX
	BPL LVL6_8

	STZ $00		; set this scratch to 00
	
	LDA $14		; frame counter
	LSR		; /2
	AND #$03	; mod 4
	CLC
	ADC $20		; add in layer 2 y
LVL6_7:
	CMP #$04	; check if below 4
	BCC LVL6_6	; continue if so
	SBC #$04	; subtract 4 until it is
	INC $00		; increment scratch
	BRA LVL6_7	; loop
LVL6_6:
	SEC		; 
	SBC #$04	; flip
	EOR #$FF
	INC A
	STA $01		; store to scratch for later

	LDA $14		; frame counter
	LSR		; /8
	LSR
	LSR
	CLC
	ADC $00		; add in additional from layer 2's y
	AND #$07	; mod 8
	STA $00		; store to scratch
	ASL		; x3
	CLC
	ADC $00
	TAX		; stick in x
	LDA $01		; get scanline count
	STA $7FB600,x	; set scanline count
	STX $4342	; set table offset

        RTS


LVL6_HDMA2:		; holds how much to offset layer 2's horizontal scrolling by. 2 byte width
db $00,$00,$FF,$FF,$FE,$FF,$FF,$FF,$00,$00,$01,$00,$02,$00,$01,$00


LVL6_HDMA4:		; holds initial HDMA settings for layer 2
db $04,$10,$B7		; first byte = scanline count, second byte = low byte of address, third = high byte
db $04,$12,$B7
db $04,$14,$B7
db $04,$16,$B7
db $04,$18,$B7
db $04,$1A,$B7
db $04,$1C,$B7
db $04,$1E,$B7


If you've already read the main tutorial, the comments should explain everything decently well.

This should be a good example of indirect HDMA (and a couple ASM tricks as a bonus).


Important things to note:
Changing the scanline counts and starting address of the table produced the "rising" effect. Each scanline count in the table is by default 4, but as time passes the top one's scanline count decreases. When it hits 0, that part of the table is then skipped by setting a new starting address. This continues until a full loop is made, thus producing the effect with minimal processing time.

The loop at LVL6_7 might seem complex at first, but it's really just simple division. It would be faster to use the division registers (most of the time), but I'll let you look those up in regs.txt if you want to improve this routine.

Storing to $4342 does not take effect until the next frame. Thus we don't have to double buffer the table or do this in a v-blank to avoid obvious glitches.
Not that it doesn't glitch because of the lack of double buffering... You might want to fix that, but unless your BG is comprised of vertical lines I doubt anyone will notice.




As always, feel free to ask if something doesn't quite make sense to you, and please ask here rather than a PM :P.

EDIT: Added a JMP to level6 after the init code. I suspect most people put their level init code in levelinitcode.asm, so that will make it obvious that level6: has to be run during the init too.
Just one question, can these be used in Level ASM if you apply the HDMAv3.3 ASM hack via xkas.exe?

--------------------
Your layout has been removed.
Yes, they can. HDMA v3.3 isn't really needed though - If I recall correctly, it even has some bugs of its own.

--------------------


 
Pros and cons of HDMA 3.3 are discussed here, for anyone interested.

If it gets fixed, I'll definitely add a link to it. There are some issues with HDMA in SMW because Nintendo (gasp!) didn't really expect people to be reverse engineering their game (or at least didn't care), and it fixes most of 'em.
Hey Kaijyuu... if I have well understood you code, it's like:
Indirect
RAM                                                       RAM
scanline count + pointer [updating]       value depending on layer X/Y position [updating]

I find my method (the one you can see in my numerous PMs :p) a bit easier (and faster?):
Indirect
ROM                                                         RAM
scanline count + pointer [frame depending] value depending on layer X/Y position [updating]

What's your opinion about this?


Also, I didn't understand how you avoid the "changing table glitch" without double-buffering...



--------------------
Originally posted by SL
Hey Kaijyuu... if I have well understood you code, it's like:
Indirect
RAM                                                       RAM
scanline count + pointer [updating]       value depending on layer X/Y position [updating]

I find my method (the one you can see in my numerous PMs :p) a bit easier (and faster?):
Indirect
ROM                                                         RAM
scanline count + pointer [frame depending] value depending on layer X/Y position [updating]

What's your opinion about this?

The indirect table can go in ROM or RAM, it doesn't matter. I stuck it in RAM here because I changed it a lot to produce the effect. Were I to not modify it in-game, I probably would've left it in ROM.


Quote
Also, I didn't understand how you avoid the "changing table glitch" without double-buffering...


I didn't avoid it, actually. It still happens, It's just that the glitch here is mostly unnoticeable.

Difficult to explain exactly why it's not noticeable... The scanline count that is changed is near the top of the screen. However, levelasm code is done near the middle of the screen. Both have to be done at the same time for a noticeable glitch to occur, otherwise you just have a small one like here, where I think all that happens is a single scanline is skipped.
Pages: « 1 2 3 4 5 »
Forum Index - SMW Hacking - SMW Hacking Help - Tutorials - Comprehensive HDMA Tutorial

The purpose of this site is not to distribute copyrighted material, but to honor one of our favourite games.

Copyright © 2005 - 2019 - SMW Central
Legal Information - Privacy Policy - Link To Us


Total queries: 7

Menu

Follow Us On

  • YouTube
  • Twitch
  • Twitter

Affiliates

  • Talkhaus
  • SMBX Community
  • GTx0
  • Super Luigi Bros
  • ROMhacking.net
  • MFGG
  • Gaming Reinvented