News:

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

Main Menu

[SM] Variable liquid behavior

Started by begrimed, February 01, 2014, 11:05:52 PM

Previous topic - Next topic

begrimed

I'd like to use FX2 (or layer1_2, whichever is the better option) to adjust certain aspects of liquid on a per-room basis. Things like tide size, tide speed, flow left speed for water, enable flow right and flow right speed. How would I go about doing this? Would it be limited to code in bank $8F? Can it be done without having to rewrite parts of the liquid behavior itself? I'd like to think it would be as easy as storing certain values to certain RAM addresses, but I'm not nearly proficient in ASM enough to make that determination or figure out how to do it myself yet. I looked over the RAM map, but nothing jumped out at me as directly controlling these things.

MetroidMst

Forgive me if I am wrong, but you can't you already do all that on a per-room basis already?

begrimed

Tides only have small and large size, flow left is on or off, but that's it. I'd love being able to get much more precise than that, and I'm sure other hackers could come up with some ballin' ideas. Rivers with very small and fast tides that flow left or right quickly, oceans with huge slow-moving tides, you get the idea.

Adding onto my original idea, a delay between tides going up and down would be nifty too.

Quote58

Could certainly be done on a per room basis using layer1_2. Unfortunately I'm kinda busy so I can't offer to help you out with that :/

Black Falcon

To clear things up, the layer1_2 setting has nothing really to do with layers. It is per-room code that runs once (Init code), whereas the FX2 code runs per room and every frame while being in game (Run code). This scheme can be seen many times throughout the ROM, like for enemies, projectiles, PLMs and other things.

On topic: Since you don't want a rewrite of the actual FX routine (which I'd suggest), only way of doing it would be the room's running code. Though for that you'd need to write the code by yourself for every preference you want in the room,
plus you have to consider to include existing FX2 code that's already in the game (like in Crateria Lake or Landing site).

For the former solution, one could make few tweaks that make the FX code check the first few BTS of a room (top left blocks).
Eg: With BTS 00, you set the tide size, with BTS 01 the tide speed etc.
Would be a lot easier this way, since most of the time they're solid and available in every room, since no one should ever make a room in where you can go to the very top left, because of the risk of getting out of bounds, causing errors (exception would be a ceiling with door blocks).


begrimed

I don't want to not rewrite the FX routine, I just assumed that it would be pretty hard to do, but using the first BTS blocks of a room to set liquid attributes indeed sounds awesome.

JAM

Quote from: Grime on February 01, 2014, 11:05:52 PM
Would it be limited to code in bank $8F?
Nope, if you'll use the code in bank $8F like:


JSL AnotherBank
RTS

AnotherBank:
org $C0FFEE ;example
... ;your code
RTL

As you see, only 5 bytes in bank $8F are used.

Layer1_2 and FX2 both can used for that (by the way, timer init in Darkholme was run by FX2). But... Layer1_2 code executes at first, then FX1 data, layout and other things are loaded and then FX2 will be executes every frame. That's why Layer1_2 is called FX0 in SMILE JX. Nothing will layering, as said above.

So, FX2 can be used to modify loaded FX1 and FX0 (and door ASM pointer too) to change FX1 pointer and thus alter the parameters.

P.JBoy

the $8F code can even be as small as 4 bytes if you're really desparate
...