News:

Don't forget to visit the main site! There's lots of helpful docs, patches, and more!

Main Menu

[SM] Layer 3 custom haze woes

Started by monktroid, April 15, 2017, 07:57:03 AM

Previous topic - Next topic

monktroid

Quote from: Quote58 on April 25, 2017, 08:09:47 PM
I took a look at the output of effect tool a while back and it's really not as good a reference point as the asm file smiley provided. I'm not saying you can't translate the code from effect tool, but it would be more efficient to work with the routines already in super Metroid.

You're right of course, I should do more homework. It feels like I've already done an obscene amount. I've learnt a lot of languages over the years but I had no idea ASM was gonna be so tough (though, to be fair, I've chosen a relatively complex aspect of a fully finished commercial product as my starting project so it's hardly all that surprising!)

Yeah, I switched off FX1 stuff and set bg to $0000 and added layer 2.  The fish ain't biting.  I'mma go read through smileUser's stuff and see if I can get me head around it.  I think I learnt a lot from playing around with the wobblyVertical stuff from the effect tool any case.

monktroid

#26
I've mostly figured SmileUser's code out now.

One small question about SmileUser's HDMA sample (see previous page)

regarding the following:


Loop:
DW #$0001 : DW IndirTable
DW $85B4 : DL Rotate
DW $85EC : DW #Loop


1) I don't really understand why DW #$0001 is followed by DW IndirTable.  I get that IndirTable is the dynamic object containing all the scanlines and pointers to the variables that the table1 function is iterating over; I just don't get what it has to do with DW #$0001.

2) line 3, why is $85EC supplied "DW #Loop" rather than "DW Loop"?  Does "DW #Loop" signify a callback (ie. IOW a pointer to the function) and "DW Loop" signify that the return value of "Loop" is stored to DW. Or Vice Versa, or something else?

in Pseudo code terms:

function Loop() { ... }

// A) Loop is called and DW is supplied the return value from Loop
var DW = Loop()

// B) Loop isn't called and DW is supplied a pointer to Loop
var DW = Loop

// C) something else?


Quote58

2) loop isn't a pointer to a function, it's an address that is used by the function at 85EC, which is basically a GOTO(argument), which in the case of the code using this table means it will go execute the command at the address given by the instruction list. $85EC contains the code: LDA $0000,y : TAY : RTS, which means it uses the argument as an index into bank $88, and then gives that back to the function as the next instruction value. So it's pretty much a BRA for the instruction list. As for it using #, that's just for the compiler so it knows to use the direct value of the label address, not the value at that address.

Smiley

1) The DW is used to tell how many frames to display that table for (=how many frames until it goes to the next instruction in the list.) Set the value higher and the waves will update slower.

monktroid

Guys, you are awesome. I get it and I got my code working with the SM registers.if i ever finish this hack, I'll be sure to add you to the credits!

monktroid

Hey smile user,

Any idea how to shut that wobble effect off when samus leaves a room? I can do it with the haze hack i've written but it seems to just crash the game trying the same tests...

thanks again for your help!

Quote58

The effect shouldn't continue after you leave the room since it's using layer1_2, which is activated during room transitions (right before FX) along with all the other hdma stuff being reset. Are you using a different hijack?

monktroid

Maybe I'm missing a trick! to boot the jack I found i needed to actually wire it to something - from what I can tell it won't just run from the point that smileuser sets it.  As a test, i've got it initialising off the room setup for the bottom-left room adjacent to landing site:

org $8F91D3
JMP INIT_WOBBLE  ; * original location expects RTS so used JMP here rather than JSL.

;;; WOBBLE ;;;
org $8FEA00
INIT_WOBBLE:
   ...


thus you run the game and all is good until you move to the room immediately to its right or below.

Quote58

if you input the pointer (ea00) into the level1_2 pointer box for the room in smile, it should run once as the room loads along with various other setup routines. Is your code using the HDMA routine in the game, or your own? The one in the game should only be active until the next room transition.

Smiley

The code I posted is the exact code I used in SMChallenge. If you apply it to your rom as-is and set a room's layer1_2 / layer0 / Setup ASM pointer (same thing, just has different names in different versions of SMILE) to $EA00, then that room, and only that room, gets the wavy effects.

monktroid

Quote from: SMILEuser96 on May 11, 2017, 04:48:38 PM
The code I posted is the exact code I used in SMChallenge. If you apply it to your rom as-is and set a room's layer1_2 / layer0 / Setup ASM pointer (same thing, just has different names in different versions of SMILE) to $EA00, then that room, and only that room, gets the wavy effects.


ahhhhhhhhhhh, ok, thanks. Guess I've been dumb then haha!

monktroid

#36
and as if by magic:

https://youtu.be/xPwo33LvxZw

benox50

Using Main ASM pointer or Setup ASM pointer is one of the best way to integrate custom code per room, it doesnt really interfere with anything since SM rarely use those. The only downfall is that its in 8F, but Smiley told me it can be relocated easily so its not that big of a deal.