News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: Secret of Mana, Turbo - Beta 191115  (Read 100937 times)

hmsong

  • Full Member
  • ***
  • Posts: 239
    • View Profile
Re: Secret of Mana, Turbo - Beta 190902
« Reply #280 on: September 07, 2019, 03:37:58 am »
Take your time.  You own this patch.  You decide pretty much everything. =)

Btw, I tried to follow what you told me about inputting Poison to Dark Force... and the only thing I was able to follow was that Dark Force code is 37 (which in hex is 25).

The original code for Blaze Wall and Dark Force are:

Code: [Select]
{11: Blaze Wall}
D0/2EE0: E085 9805 9805 A805 {Gfx}Elemental
D0/2EE8: 8D00 EA6A 0000 568F 8D00 EA6A 0000 568F {Gfx}Low
D0/2EF8: 8D00 146B 0000 718F 8D00 146B 0000 718F {Gfx}Mid
D0/2F08: 8D00 406B 0000 858F 8D00 406B 0000 858F {Gfx}High
D0/2F18: 81 Target
D0/2F19: 00 (UNUSED)
D0/2F1A: 20 Power
D0/2F1B: 4B Accuracy
D0/2F1C: 08 Element
D0/2F1D: 0040 Status Effect
D0/2F1F: 04 Cost

{25: Dark Force}
D0/33E0: 4A86 F906 F906 F906 {Gfx}Elemental
D0/33E8: 9700 466E E495 F794 9700 466E E495 F794 {Gfx}Low
D0/33F8: 9700 7C6E E495 6095 9700 7C6E E495 6095 {Gfx}Mid
D0/3408: 970E 7C6E E495 E495 970E 7C6E E495 E495 {Gfx}High
D0/3418: 81 Target
D0/3419: 00 (UNUSED)
D0/341A: 3D Power
D0/341B: 4B Accuracy
D0/341C: 10 Element
D0/341D: 0000 Status Effect
D0/341F: 02 Cost

Now, could you run through what you were saying again?  I wasn't able to follow.  Where is E801?  Or EBE5?  I think I sort of got...
Quote
Dark Force is the 38th spell. 38 -1 (since spell #1 is at offset 0), so 37 * 2 (each entry is 2 bytes) = 74, convert to hexadecimal = 0x4A, $C8E801 + 0x4A = $C8E84B,
But anything after that, I don't really get.  Or before that.  Using Blaze Wall and Dark Force as an example, could you please go over again?  I'm sorry that I am terrible at understanding these, but I am so lost.

After you do what you need to do first, of course.
« Last Edit: September 07, 2019, 03:52:04 am by hmsong »

zoolgremlin

  • RHDN Patreon Supporter!
  • Full Member
  • *****
  • Posts: 130
  • Steam Profile Name: keeperofcastlegreydusk
    • View Profile
Re: Secret of Mana, Turbo - Beta 190902
« Reply #281 on: September 08, 2019, 12:17:07 am »
@Queue  You made my whole week when you posted about the spell pointer table earlier.  I mapped out that table and the spell data table in Wordpad, so I could format it with a colour system to designate each Elemental.  I also used the info you gave to make Lunar Magic and Evil Gate into damage-only spells, instead of them using Square's crappy special algorithms.  What a blast... thank you so much.   :woot!:

I'm reading through all your old Posts to see what else you have requested help with, haven't got very far with that just yet, but I noticed your first Turbo post asking about bugs in Vanilla.  The only bug in Vanilla that I can think of, that hasn't already been mentioned or addressed, is something I was reminded of when searching the maps for issues.  I've known about this for years, but never seen any mention of it on the Internet.  Which I thought was very odd, surely I can't be the only person in the world who's run into this.   :huh:

It's exactly like the [Wind_Temple_Entrance_Trap], only in the Pure Land.  I'm gonna post a screenshot of it in the [Tidy_Maps] folder, even though this is not exactly a tidy maps issue, it's number 022.  Characters are standing on the exact spot.  It's in the long cave just before the Axe Beak battle arena.

That's all for now, will let you get on with things while I read through your other posts.   8)

Link again:  Secret of Mana Screenshots
« Last Edit: September 22, 2019, 02:07:29 pm by zoolgremlin »
If you try to fail, and succeed, what've you done?!

Queue

  • Full Member
  • ***
  • Posts: 211
    • View Profile
Re: Secret of Mana, Turbo - Beta 190908
« Reply #282 on: September 08, 2019, 03:45:55 pm »
Version 2019-09-08:
https://ufile.io/9jksebfj

Changes:
- Improved Magic\Magic_Recharging description
- Second attempt at Items\Farmable_Sword_Orb; adds an out-of-the-way new teleporter in the Mana Fortress (shouldn't be hard to find) to send you to a new room to fight the now functional unused enemy, which now can drop a Sword Orb
- Changed Items\Mana_Fortress_Rarity_Swap to no longer affect Turtlances
- Changed Miscellaneous\Day_Night_Cycle to no longer replace Eggplant Man with Metal Crab at night (since Metal Crab has a weapon orb)
- Implemented Graphics\Retouched_Characters; fixes some color issues with the Girl which also happens to improve Functional_Fashion; stamina recharge / poisoned status palettes haven't yet been adjusted to accommodate
- Implemented Bug_Fixes\Pure_Land_Cave_Trap
- Tidy Map treatment for:
-- Axe Beak's fight room
-- Mana Fortress A (first interior area)
-- Witch's Castle Monty Hall (interior room with three doors north)
-- Kakkara Desert (north, east and west exits; south not changed yet)
-- Ice Palace Library



Mr X, weapon charge being reset when a spell hits a character should be vanilla behavior. Might not be pleasant, but don't think that one counts as a bug.

I think what I hammered out for the Sword Orb is pretty neat, will be curious what you think of it. I used the single unused enemy (apparently there was one), wrote a new AI script for it (it essentially didn't have one) then did some sorta funky stuff to get it animating without looking too glitchy. I can likely polish up its AI and animations further, but I got it to a usable state, unless someone finds some outright bugs with it. I intentionally set it up to have weird rules to fight successfully; it might take some experimenting to figure out how to kill it instead of it despawning (the despawning animation is a glitchy looking mess at the moment). If it does the "splat" death animation it was successfully killed; if it flies apart in a cloud of glitchy graphics, it despawned.

zoolgremlin, thanks again for all the map screenshots, they've been extremely helpful. I wasn't aware of that sticky wall in the Pure Land tunnel; it's now fixed. It was a simple one thankfully: one of the diagonal wall tiles was the wrong type which looks just like the others but is a different "height" where it's intended to be used for a plateau after going up stairs, etc. Your characters could walk onto it, which changed their height and then they couldn't step back off of it down to the normal lower height (without a staircase or other height transitioning tile). I just had to change it to the normal angled corner piece. There was a similar but opposite tile issue in Axe Beak's room, where there was an unwalkable angled corner because they used the lower height version where it should have been the upper.

As for "backgrounds" those are just like any other map, but set to scroll at a weird rate as you move around, but they're essentially no different on the data side of things, so feel free to point out any graphical issue with them as well.

SpiffSpoo, I've wanted to turn Evil Gate into, say, Evil Saber, but sabers are a fairly hard coded mess, so I haven't gotten to it (lots of work for dubious result). Mana Magic is functionally the Dryad saber spell, so what I'd likely do, if I ever get to it, is put mana tapping on Evil Saber, so the sprite could bestow a means of gaining mana on the girl (even if it doesn't jive with game lore on element logic, etc.), and so the last element missing a saber spell would be accounted for. Oh right, also, since enemies can use Evil Gate, that's another reason I hadn't gotten to it yet; turning it into a buff would likely necessitate some AI changes.

I wonder if Sleep Flower being sleep + poison at the same time would be functional. I hope someone tries that; doubt it would be worth casting unless poison is changed to percentage health damage or something, but at least conceptually that sounds usable.

hmsong, thanks for the info on magic recharge timings with different spell animation varieties; that makes a very good argument for overhauling the recharge timings to compensate for the varied behavior.

I like what you're going for with your adjustments to spells; homogeny is super boring so I appreciate that you're not just overly normalizing everything, and conversely having a stand-out best is super boring... obviously it's a fine line to walk, sometimes the best result is when things aren't master planned (e.g. Terraria vs. Starbound, Destiny vs. Destiny 2, etc.; i.e. the master planned one being less compelling than the one that was haphazardly tuned). For some of the vanilla values, I suspect the reasoning was things like "the girl isn't an offensive caster, so if she's going to use attack magic it'll have an MP cost penalty" or "maybe the hardest enemies are weak to light magic so lucent beam will be extra costly" (whether or not enemy resists reflect this). I generally avoid rebalancing games I play (I like working within the constraints someone else comes up with) but sometimes it's unavoidable in the course of making other changes (which from me tend to be bug fixes, aesthetic or base gameplay mechanics in nature). My point being, I'll be happy to include what you do, but I don't really want to have too much input on the final values since I'll hopefully want to play using them.

I wholeheartedly agree with your reasoning on poison. It's boomerang 6, the Cobra Shuttle, that has poison. I usually keep that one for its novelty (and because the Nintendo Power art for it was a tomahawk; a boomeranging tomahawk seemed cool to 1994 me).

Most likely the chest issue in the Grand Palace you mention is due to the 3 enemy limit. Chests are an NPC, and in combat areas, the NPC limit is 3 (9 in non-combat areas like towns, which is primarily why towns have bad framerate). This is part of why I have Kethinov's Gaia's Navel chest off by default.



Okay, let's see if I can explain the next step in changing spells. I'm going to lay out some foundational explanations first.

- Addresses and Offsets

In computer terms, an address is a number that specifies the location of data. An offset is a number added to an address to determine the location of data.

In certain circumstances (especially for data within a file), the offset is the primary information you need to locate the data you want.

The SNES has a 24-bit address space, which means it understands numbers from 0x000000 to 0xFFFFFF, so offsets and addresses will only include 6 hexadecimal digits in this post (more typical with modern computing is 8 digit (4 bytes, 32-bit) or 16 digit (8 bytes, 64-bit) addresses).

Common SNES assembly syntax has $ denote a hexadecimal number and # denote a literal number (and often combines them as #$ to mean a literal hexadecimal number). In other domains of software, 0x usually denotes a hexadecimal number. The ZPS patcher the Turbo project uses has an atypical variation of SNES assembly syntax, where $ specifically denotes an address, and # specifically denotes a literal number, all numbers are hexadecimal, and #$ isn't recognized. The ZPS patcher also uses un-prefixed hexadecimal numbers for its RAW and COPY commands (e.g. RAW 00 10 ABCD 32 999999, etc., it strips out spaces).

I will be using $000000 (6 digits) to denote SNES memory addresses, 0x000000 (6 digits) to denote offsets within the ROM file, 0x00 or 0x0000 (2 or 4 digits) to denote hexadecimal numbers in general, and # only in ZPS code examples (if any).

When talking about file offsets or memory addresses for editing SNES ROMs, a file offset is going to be what number byte into a file the data is located at, and a memory address is going to be what address in SNES memory the current ROM is at. Secret of Mana is a HiROM game, meaning its ROM file, when mapped in the SNES address space, is at the values $C00000 to $FFFFFF; with a 4 MB ROM, which is 0x400000 bytes, file offset 0 (0x000000) corresponds to SNES memory address $C00000, 0x000001 to $C00001, and so on, up to 0x3FFFFF = $FFFFFF. If you edit byte 0x101000 in the Secret of Mana ROM, then load that ROM, that changed byte will be at memory address $D01000. The conversion is as straightforward as adding or subtracting 0xC00000.

The ZPS patcher expects all addresses to be specified in HiROM address form, so
Code: [Select]
@OFF $D01000
RAW 00
in the ZPS file will write the value 0x00 to file offset 0x101000 in the output ROM file.

- Byte Order Endianness

The SNES is a little-endian architecture, meaning if you have a 16-bit or 24-bit value, the byte order goes from lowest to highest, left to right. The ROM data 0x34 0x12, if used as a 16-bit value, will mean 0x1234. The address $C01020, will be 0x20 0x10 0xC0 in ROM data. This is only relevant for data that is read directly as a 16-bit or 24-bit value; data that is used one byte at a time will still effectively go in the order you expect.

See the Wikipedia article on Endianness for further info: https://en.wikipedia.org/wiki/Endianness

This will matter when hex editing a ROM by hand, or when specifying 16-bit or 24-bit numbers (such as addresses) using ZPS's RAW command.

When assembling instructions or using the ADR command, the ZPS syntax allows you to enter numbers in 16-bit or 24-bit form and puts the bytes in the correct order for you.

As an example, consider the status effect value in the spell data: 0x2000 is poison, but you had to type it as 0x00 0x20 due to that 16-bit value being stored in little-endian order.

- Banks

While the SNES has a 24-bit address space, most of its instructions don't accept full 24-bit addresses. Instead, most of its instructions only specify the lower 16-bits of a full 24-bit address, and use the same highest 8-bits when using an address. This current highest 8-bits is called the data bank (simply bank from here on).

So, if some code wants to read the value at $D01000, it might use
Code: [Select]
LDA $D01000but if the bank is set to 0xD0, it could use
Code: [Select]
LDA $1000and it would read the same byte. There's also an even shorter form where you only specify the lowest byte, but I won't cover that at this time as it won't be relevant.

Secret of Mana's code and data are split up all over the place in its ROM, but related code and or data is often located within the same 0x10000 range of bytes: within the same bank. For example, all enemy AI scripts are between file offsets 0x110000 and 0x11FFFF (addresses $D10000 and $D1FFFF), which is bank 0x11 (because the highest byte of the file offset corresponding to the data is 0x11). It would probably make more sense to call it bank 0xD1 because banks are more relevant for memory address than file offsets, but other people decided to number the banks based on the file offsets, so that's what we'll use here as well.

If I say X is located in bank 0x10 and Y is located in bank 0x11, I mean X is somewhere between 0x100000 and 0x10FFFF and Y is somewhere between 0x110000 and 0x11FFFF.

- Software Isn't Magic

The game has spell data in bank 0x10, starting at offset 0x102AA0 in 64 byte (0x40 byte) blocks of data that share a common layout.

You've noticed that in each 64 byte block, the last three bytes specify the status effect and mana cost, but that changing the status effect value didn't seem to do anything. This is because just because that data is there, doesn't mean some programming actually reads and uses it.

When you choose a spell to cast, the game executes some code that reads an address that specifies more code to execute that then may or may not read some of the spell data. A list of addresses that specify chunks of code is generally called a function table. When you cast a spell, the game uses the number of the spell to specify which entry in the function table (which entry in the list) to read; the entry itself is a 16-bit address that specifies the next phase of code to be executed to make the spell happen. All of the damage only spells have the same 16-bit address entry for the code that performs a "cast a damage only spell" and that code never reads the status effect value in the spell data. To make a spell do damage and apply a status effect, this address entry in the spell function table must be changed from "cast a damage only spell" to "cast a damage + status effect spell" which in vanilla is only Blaze Wall.

That paragraph isn't the most simple of explanations, so please go over it a few times in case it doesn't make sense on the first read.

- Making Magic

Okay, so the function table for spells is in bank 0x08, specifically at 0x08E801. It has 42 entries (because there are 42 spells) that are 2-bytes each. Each 2 bytes is a 16-bit address specifying the location of code that is also located in bank 0x08.

The first spell is Earth Slide, so the first entry in the spell function table is for the code that performs "cast a damage only spell" which is located at 0x08EA8B (memory address $C8EA8B). I've kept saying it's a list of 16-bit addresses; this means it's only the low 2 bytes of the address, so 0xEA8B. Because the SNES is little-endian, in the ROM, that 16-bit address is specified in little-endian order, so the bytes at 0x08E801 is 0x8B 0xEA. This is crucial to understand. For the sake of the changes you want, it doesn't matter why the code at 0x08EA8B is "cast a damage only spell"; it matters that you understand how the function table specifies that address value.

Blaze Wall is the 17th spell. Notice that while Earth Slide is the 1st spell, and the function table is at 0x08E801, the address + offset for the Earth Slide entry is 0x08E801 + 0. This is called zero-indexing (https://en.wikipedia.org/wiki/Zero-based_numbering). The first entry is 0, not 1. This is because, in programming, it's very common to have a list of things, but the first thing is zero distance from the beginning of a list. While you can count the entries however you want, the code that actually accesses the function table starts with the address of the table (0x08E801) then adds an offset relative to the spell's number. Every entry in the function table is a 16-bit address, so 2 bytes. That means the calculation is to take the spell's number (where Earth Slide is 0) and multiply it by two, then add it to the address of the table.



>> Continued two posts down. <<
« Last Edit: September 08, 2019, 09:41:15 pm by Queue »

hmsong

  • Full Member
  • ***
  • Posts: 239
    • View Profile
Re: Secret of Mana, Turbo - Beta 190908
« Reply #283 on: September 08, 2019, 09:37:26 pm »
Yikes.  I have some... experimenting to do.  Please continue.

Queue

  • Full Member
  • ***
  • Posts: 211
    • View Profile
Re: Secret of Mana, Turbo - Beta 190908
« Reply #284 on: September 08, 2019, 09:40:40 pm »
^^ Continued from two posts up. ^^



Blaze Wall is the 17th spell; that means its zero-based number is 16 (0x10). Multiplied by two is 32 (0x20). 0x08E801 + 0x20 = 0x08E821, which is the file offset of the 16-bit address, in little-endian order, of the code that is executed when you cast Blaze Wall ("cast a damage + status effect spell"). The bytes at 0x08E821 are 0xCA 0xEB, which is a 16-bit value is 0xEBCA, which is referring to 0x08EBCA ($C8EBCA).

If we wanted to add a status effect to Earth Slide, we'd want to change the value at 0x08E801 + 0x00 (0x08E801) from 0xEA8B to 0xEBCA. Rmember that the bytes are in little-endian order. In a hex editor, you'd change the byte at 0x08E801 from 0x8B to 0xCA, and the byte at 0x08E802 from 0xEA to 0xEB. In ZPS syntax, you'd use either:
Code: [Select]
@OFF $C8E801
RAW CAEB
or
Code: [Select]
@OFF $C8E801
ADR.16 $C8EBCA

The second one is clearer, avoids entering the address in little-endian order by hand, and clarifies the bank even if it isn't used (ADR.16 only stores the low 16-bits of the value and discards the bank value 8-bits).

In ZPS syntax, @OFF is how you specify where (specified as an SNES memory address which it subtracts 0xC00000 from to get the file offset) within the ROM you want to overwrite with new data.

Dark Force is the 38th spell. Zero-indexed, 37th, multiplied by two, 74, converted to hexadecimal 0x4A. 0x08E801 + 0x4A = 0x08E84B. 0x08E84B ($C8E84B) is the location of the entry in the function table for Dark Force, where you'll see the bytes are 0x8B 0xEA, the same as Earth Slide (both of them are damage-only spells). If you make the same change to this entry that I gave as an example for Earth Slide, it should add status effect capability to Dark Force.




There wasn't terribly much else but this wraps up (hopefully) the explanation. Don't hesitate to ask for clarifications.
« Last Edit: September 08, 2019, 09:45:59 pm by Queue »

hmsong

  • Full Member
  • ***
  • Posts: 239
    • View Profile
Re: Secret of Mana, Turbo - Beta 190908
« Reply #285 on: September 09, 2019, 03:30:52 am »
Aye.... Okay, I half-understood what you were saying, but not all the way (which means I'm still lost).  I get that 0x08E801 +<spell code x2> is the one you should look for.  But the code after that, I don't understand.

Specifically, you used Earth Slide as an example.  I get that 0x08E801 +<00 x2> = 0x08E801 (we'll call this the #S for now).  But how did you get 0x08EA8B?  Specifically, I did not understand:
Quote
Because the SNES is little-endian, in the ROM, that 16-bit address is specified in little-endian order, so the bytes at 0x08E801 is 0x8B 0xEA.

But I assume you just find the #S, and replace that with EA8B (for <only damage>) or EBCA (for <damage + status effect>?  So, if I wanted to make Dark Force into <damage + status effect>, then I do this?
Code: [Select]
@OFF $C8E84B
ADR.16 $C8EBCA

then do this to add poison:
Code: [Select]
@OFF $D0341D
RAW 2000

Or did I understand it wrong?
« Last Edit: September 09, 2019, 03:36:11 am by hmsong »

Queue

  • Full Member
  • ***
  • Posts: 211
    • View Profile
Re: Secret of Mana, Turbo - Beta 190908
« Reply #286 on: September 09, 2019, 04:07:55 am »
Quote from: hmsong
But how did you get 0x08EA8B?
In the unmodified ROM, at file offset 0x08E801 are the two bytes 0x8B and 0xEA; so that's where that value comes from. They're in little-endian order, so those two bytes are the 16-bit value 0xEA8B. Because I already know this is a table of function pointers, I know this is the 16-bit address for $C8EA8B, and because it's the function Earth Slide calls I know it's the "cast a damage only spell" function.

Knowing that Blaze Wall does both damage and a status effect, we look up the Blaze Wall entry in the table at 0x08E801 + 16 * 2, and copy its entry over a damage only spell's entry to change the damage only spell into a damage + status spell like Blaze Wall.

Quote from: hmsong
then I do this?
Code: [Select]
@OFF $C8E84B
ADR.16 $C8EBCA
then do this to add poison:
Code: [Select]
@OFF $D0341D
RAW 2000
Or did I understand it wrong?
The first code block should be correct, but the second has the byte endianness issue to take into account. Status effects are a 16-bit value, so poison is 0x2000. Which means you'll be manually reordering the bytes to 0x00 0x20. In ZPS syntax, you can manually order the bytes using RAW (RAW 00 20).

hmsong

  • Full Member
  • ***
  • Posts: 239
    • View Profile
Re: Secret of Mana, Turbo - Beta 190908
« Reply #287 on: September 09, 2019, 04:30:44 am »
Quote
The first code block should be correct, but the second has the byte endianness issue to take into account. Status effects are a 16-bit value, so poison is 0x2000. Which means you'll be manually reordering the bytes to 0x00 0x20. In ZPS syntax, you can manually order the bytes using RAW (RAW 00 20).

Hmm.  I applied:
Code: [Select]
@OFF $C8E84B
ADR.16 $C8EBCA

@OFF $D0341D
RAW 00 20

And I got Attack Down, instead of Poison.  Do I just play around with "RAW   00 20" until I figure something out?  Strangely, I'm looking at Fire Bouquet (which has Attack Down), and its status code (D0/2EDD) is 0000.  Any idea why it's 0000?

Or was I supposed to do:
Code: [Select]
@OFF $D0341D
RAW 00

@OFF $D0341E
RAW 20

Also, if I get things like M.Def Down (which is not displayed in the dialog box), how do I know that M.Def is down?
« Last Edit: September 09, 2019, 04:56:13 am by hmsong »

zoolgremlin

  • RHDN Patreon Supporter!
  • Full Member
  • *****
  • Posts: 130
  • Steam Profile Name: keeperofcastlegreydusk
    • View Profile
Re: Secret of Mana, Turbo - Beta 190908
« Reply #288 on: September 09, 2019, 05:05:49 am »
Hi, everyone.  Sorry not to have posted sooner about the latest discussion points.  I had an appointment to meet someone today and only got back from that 1.5 hours ago.  Four hours to get to and from a meeting point is not an ordinary part of my life, phew...   ::)

@Queue  Alrighty then!  I have noted what you said about backgrounds and there is a screenshot of what I saw in the folder with all the others (number 023).  The bit that looks wrong to me is between the blue lines.  Basically the tiles there appear discoloured, or in some way not part of the mountains.  Everything else seems normal.

Also, I saw the comment addressed to SpiffSpoo about Sleep Flower.  I am all set up to try adding Poison or other status effects to the Sleep Flower spell function, or one of the others like Speed Down, and will do so now to see what happens.  I have already noted from my own experimentation that taking out the Element bit in the spell data table makes any spell non-elemental by default, which I used on Energy Absorb and Magic Absorb, but that's getting way ahead of myself, the project, everyone watching/working on Turbo or their own mods... everything, really.  I'll come back to that sort of thing later.

In particular, I have followed the discussion between yourself and hmsong with great interest, and among other things I like the idea of making Poison (and possibly Engulf) do percentage-based damage.  I have also thought about further possibilities with altering spells, but before I start talking about those I should first wait, to see if anyone wants to know what I think.  The discussion is already pretty lively as it is, soooo... first I will try the Sleep Flower thing.  After that, I can come back and we'll see.

Thanks for the latest update, I had no idea there was an unused enemy in the game.  Way past  8)

Link again:  Secret of Mana Screenshots

EDIT:  Whoops, forgot to mention that the Boomerang/Javelin reset bug no longer happens for me.  So the [Boy_Dislikes_Nuts] fix appears to be dead-on target.
« Last Edit: September 25, 2019, 04:32:09 am by zoolgremlin »
If you try to fail, and succeed, what've you done?!

Mr X

  • Full Member
  • ***
  • Posts: 108
    • View Profile
Re: Secret of Mana, Turbo - Beta 190908
« Reply #289 on: September 09, 2019, 05:40:38 am »

Mr X, weapon charge being reset when a spell hits a character should be vanilla behavior. Might not be pleasant, but don't think that one counts as a bug.

I think what I hammered out for the Sword Orb is pretty neat, will be curious what you think of it. I used the single unused enemy (apparently there was one), wrote a new AI script for it (it essentially didn't have one) then did some sorta funky stuff to get it animating without looking too glitchy. I can likely polish up its AI and animations further, but I got it to a usable state, unless someone finds some outright bugs with it. I intentionally set it up to have weird rules to fight successfully; it might take some experimenting to figure out how to kill it instead of it despawning (the despawning animation is a glitchy looking mess at the moment). If it does the "splat" death animation it was successfully killed; if it flies apart in a cloud of glitchy graphics, it despawned.


I just tried the original SoM and the charge attack doesn't reset after I get attacked with offensive magic or defensive except dispel.

I like what you have done with the new enemy, really impressed me once again.
Spoiler:
The only two ways I have found to defeat them is through transforming them or using the evil gate to take out one at a time, if I use it on all they fly away/despawn. Looking forward the future updates of it. A very unusual enemy (in a good way), a snowman casting the most powerful fireball spell in the game, fits for a hidden enemy especially in a magical place like the mana fortress.
« Last Edit: September 09, 2019, 05:49:05 am by Mr X »

Queue

  • Full Member
  • ***
  • Posts: 211
    • View Profile
Re: Secret of Mana, Turbo - Beta 190908
« Reply #290 on: September 09, 2019, 06:18:37 am »
Quote from: hmsong
And I got Attack Down, instead of Poison.
Shoot, you got Attack Down because I gave you the wrong value for Blaze Wall. -_-
$C8EBCA is actually for Fire Bouquet, hence why the Attack Down.
$C8EBE5 should be the correct value for Blaze Wall.
Check 0x08E801 + 0x11 * 2 (that's Blaze Wall's entry in the table) and verify I got the correct bytes this time.
Quote from: hmsong
Strangely, I'm looking at Fire Bouquet (which has Attack Down), and its status code (D0/2EDD) is 0000.  Any idea why it's 0000?
Because Fire Bouquet doesn't use the Status Effect value from the spell data. The function it calls ($C8EBCA) just has Attack Down hardcoded as a secondary effect to damage.

zoolgremlin, dang, that background discoloring is a mix of mediocre tile art and a mediocre palette. It's technically as intended (watch the game's intro sequence to see the exact same view of the Mana Tree but with a nighttime palette and that band of forest to mountains transition looks a bit better despite being the same tiles). I suspect tweaking the color palette for that map would be the only way to try and improve it. It may be possible, but it'll depend on what else in that mana tree cutscene uses the colors I'd need to change.

Mr X, thanks for checking it. Guess I gotta get that figured out too then as I'm pretty sure that charge behavior changing wasn't intentional; I'd just been ignoring it since I thought it was normal.
Spoiler:
Hm, wouldn't have guessed you could nest spoilers.
Spoiler:
Here be dragons.
Spoiler:
You found my intended weakness for them. Also specifically not using Wall to try and protect yourself as bounced spells should despawn them is intentional. I actually tried to keep as much of the vanilla aspects of that unused enemy as possible, namely, it being a snowman and using something Fireball-y are vanilla traits of that enemy, for whatever reason. It's immune to melee because snowmen don't have a melee hitbox (though it also has astronomical defensive stats).

Almost everything about their animations is madness; their idle wiggling is actually the High Stepper idle animation, their up and down movement is... I think Moogle animations of some sort, and I'm not even positive on the leap, maybe a Moogle whip post leap or something. The reason they despawn is because one of the damaged animations is the Cannon Travel cannon fuse burning down and vanishing animation... I think, or something similar, and is related to the vanilla bug I fixed where a playable character could vaporize while Frostied if they wound up playing the Cannon Fuse or similar animation. Which all occurs because the Snowman has a tiny animation table (only 7 entries) so any animation number over 6 overflows into the animations that happen to come next in the ROM, namely Mana Fortress space laser, Cannon Travel cannon, High Stepper, NPC Moogles, player Moogles and player Pygmy Moogles. I'm going to need to relocate and properly flesh out their animation table to make things less glitchy.

Do you think the entrance was okay? I could've gone full super secret and hidden the entrance in a walk-through wall, or required a whip post jump into a wall, or something extreme like that, but settled on a nonchalant single tile in the hopes people would actually stumble on it without knowing it exists.

zoolgremlin

  • RHDN Patreon Supporter!
  • Full Member
  • *****
  • Posts: 130
  • Steam Profile Name: keeperofcastlegreydusk
    • View Profile
Re: Secret of Mana, Turbo - Beta 190908
« Reply #291 on: September 09, 2019, 06:54:50 am »
@Queue  Oh, you were still awake?!  I guess that was good for us, at least...  :D

I can confirm that the spell function for Acid Storm also does not use the Status Effect value, which is why the spell doesn't set Poison, but spell functions could presumably be changed if anyone knows how.  I don't, but again that's getting way ahead of, well... everything.

I can also confirm that changing Sleep Flower's spell pointer to that of Blaze Wall, and setting the Status Effect values to Unconscious and Poison, works just fine.  The spell will damage, and apply both statuses minus any immunities the target possesses.  Haven't tried it with SF's default pointer just yet, but I'm guessing the spell functions have no trouble trying to apply multiple statuses.  And possibly buffs/debuffs as well, although those are hardcoded as you mentioned.

Cheers for the info regarding the Mana Tree background, I will have another look at the one in the intro cutscene just to see the difference.
« Last Edit: September 26, 2019, 08:57:48 am by zoolgremlin »
If you try to fail, and succeed, what've you done?!

Mr X

  • Full Member
  • ***
  • Posts: 108
    • View Profile
Re: Secret of Mana, Turbo - Beta 190908
« Reply #292 on: September 09, 2019, 07:10:25 am »


Mr X, thanks for checking it. Guess I gotta get that figured out too then as I'm pretty sure that charge behavior changing wasn't intentional; I'd just been ignoring it since I thought it was normal.
Spoiler:
Hm, wouldn't have guessed you could nest spoilers.
Spoiler:
Here be dragons.
Spoiler:
You found my intended weakness for them. Also specifically not using Wall to try and protect yourself as bounced spells should despawn them is intentional. I actually tried to keep as much of the vanilla aspects of that unused enemy as possible, namely, it being a snowman and using something Fireball-y are vanilla traits of that enemy, for whatever reason. It's immune to melee because snowmen don't have a melee hitbox (though it also has astronomical defensive stats).

Almost everything about their animations is madness; their idle wiggling is actually the High Stepper idle animation, their up and down movement is... I think Moogle animations of some sort, and I'm not even positive on the leap, maybe a Moogle whip post leap or something. The reason they despawn is because one of the damaged animations is the Cannon Travel cannon fuse burning down and vanishing animation... I think, or something similar, and is related to the vanilla bug I fixed where a playable character could vaporize while Frostied if they wound up playing the Cannon Fuse or similar animation. Which all occurs because the Snowman has a tiny animation table (only 7 entries) so any animation number over 6 overflows into the animations that happen to come next in the ROM, namely Mana Fortress space laser, Cannon Travel cannon, High Stepper, NPC Moogles, player Moogles and player Pygmy Moogles. I'm going to need to relocate and properly flesh out their animation table to make things less glitchy.

Do you think the entrance was okay? I could've gone full super secret and hidden the entrance in a walk-through wall, or required a whip post jump into a wall, or something extreme like that, but settled on a nonchalant single tile in the hopes people would actually stumble on it without knowing it exists.

Spoiler:
Haha I tried first the wall strategy and they despawned upon that, then I tried the sprites luna spells the most underused spells in the game and transforming them worked, then later I was like "I a dumbass, why didnt I think of the evil gate"

Do enemies drops change if they get transformed?

Don't rush, you got the base set. Is it possible change the spells the enemies in general? I thought you intentionally left it to cast fireball. Not that I mind that, it's a secret enemy. But it could come in handy to make other enemies or bosses becoming a bit more interesting if individual stats/spells can be changed.

As for the location it's fine, it's not like you would miss a whole lot from these final orbs at current point and time anyway. If they become more powerful in the large future especially the sword then I would make it more of a secret like finding a spot to use a whip to get past a wall then teleport, or something along those lines. But as things are currently, it works just fine.

hmsong

  • Full Member
  • ***
  • Posts: 239
    • View Profile
Re: Secret of Mana, Turbo - Beta 190908
« Reply #293 on: September 09, 2019, 07:58:23 am »
Quote
Check 0x08E801 + 0x11 * 2 (that's Blaze Wall's entry in the table) and verify I got the correct bytes this time.

How do I "check" that?  Table?  If you're talking about hex 11, then yes that's Blaze Wall, but I don't really know where you got EBE5.

Having said that, I used it and it worked.  But sadly, I cannot apply to other spells, it seems.  I did the following:

Code: [Select]
' lava wave, damage + status effect
@OFF $C8E81D
ADR.16 $C8EBE5

' lava wave, + petrify
@OFF $D0341D
RAW 40 00

' dark force, damage + status effect
@OFF $C8E84B
ADR.16 $C8EBE5

' dark force, + poison
@OFF $D0341D
RAW 00 20

Dark Force's poison works just fine, but Lava Wave's petrify doesn't.  And I know I got the right code for petrify, since I tested it on Dark Force.  My best guess is that since both Dark Force and Lava Wave uses the same code (ADR.16   $C8EBE5), there is some sort of conflict.  So... can you help me resolve this issue?  I intend on putting more status effects on spells.

Mr X

  • Full Member
  • ***
  • Posts: 108
    • View Profile
Re: Secret of Mana, Turbo - Beta 190908
« Reply #294 on: September 09, 2019, 12:53:11 pm »
Found a bug, when I used the balloon magic on silktail it spawned the new enemy that you just added, I tried that on another enemy and it still happened. The snowman of doom is gonna rock your party if you face him that early like me, just run :laugh:

It happens also when you use a weapon that inflicts that status also. It seems to be related to that.

Edit: Oh shit that seems to happen with other statuses as well, be wary everyone if you will use a status spell or saber magic. I tried sleep flower that seems to be the only one not causing that.
« Last Edit: September 09, 2019, 01:08:04 pm by Mr X »

SpiffSpoo

  • Jr. Member
  • **
  • Posts: 78
  • Wark!
    • View Profile
Re: Secret of Mana, Turbo - Beta 190908
« Reply #295 on: September 09, 2019, 03:17:18 pm »
Since you/enemies can't have 2 status effects normally, would it be possible to have a priority in the spell to try and give one status effect first, and if that fails try for an other?  If not, or would take too much time, could the sleep effect be straight up changed to poison?

If a "leaf" saber could be coded in, making it give the poison status instead of MP drain would make sense, since MP drain was OP in SD3.

EDIT:
I should read things more carefully, saw the sleep flower addition above which is pretty cool. I don't remember enemies being able to have, for example, engulf and snowman at the same time.  Probably because I never actually tried.
« Last Edit: September 09, 2019, 03:23:17 pm by SpiffSpoo »
Wark!

Queue

  • Full Member
  • ***
  • Posts: 211
    • View Profile
Re: Secret of Mana, Turbo - Beta 190908
« Reply #296 on: September 09, 2019, 03:22:57 pm »
zoolgremlin, the spell functions can certainly be changed, but for that you need to understand at least some SNES assembly / machine code. A quick example using Fire Bouquet (and ZPS's ASM syntax, which is non-standard for 65816 ASM syntax):
At file offset 0x08EBD5 / SNES mem address $C8EBD5, which is in the middle of the Fire Bouquet function that starts at $C8EBCA is:
Code: [Select]
BDB0E1  LDA+X    $E1B0   ' Load [BUFF_EFFECTS, X]
293F    AND      #3F     ' Clear flags for Attack Up (#40) and Attack Down (#80)
0980    ORA      #80     ' Set flag for Attack Down (#80)
9DB0E1  STA+X    $E1B0   ' Store [BUFF_EFFECTS, X]
If you only wanted to change which stats it manipulates, you'd be changing the #3F and #80, and it helps if you understand bitwise AND and OR operations. If you wanted to do something completely different, then you have 10 bytes of space there, so it'd either need to be pretty simple and compact, or you'd need to put in a function call to code elsewhere.

It would also be possible to make the stat change spells pull data from the spell data tables rather than each having a hardcoded stat change in their individual function; then they could share a spell function and the stat changes could be data driven.

Fun fact: Speed Down has its own function, but it's identical to the function used by all the other "status effect only" spells. A fair guess would be that Speed Down was going to be the inverse of Speed Up instead of applying Tangled but got changed by copy/pasting the status effect only function in place of the Speed Down function, rather than just changing it to use the common function.

If I ever add other saber(s) it'd likely be by making Speed Down use the generic function and stealing the space of the Speed Down function to add code for the new saber spell's function (partly because immediately after the Speed Down function is all the other saber spell functions, so it'd be a good spot to put a new one.



Mr X, don't worry, I didn't think of Evil Gate either.
Quote from: Mr X
Do enemies drops change if they get transformed?
They do not. This is apparently the only thing I tested properly; they definitely drop the items I assigned to the new enemy. =P Transformed enemies have the drops and drop rate of the original monster; they override the art, animations and AI (because animations are heavily tied to AI), defensive stats (def, mdef, evasions). Not sure on level or neutral stats (str, int, etc.). Exp, health and gold should all be the base monster's.
Quote from: Mr X
Is it possible change the spells the enemies in general? I thought you intentionally left it to cast fireball.
Yes, though they're changed by changing an enemy's AI scripts. It's easy once you find the data to change, but uhm, I really need to figure out the proper way to get Enker's disassembly available to share; the original website is long gone, archive.org doesn't have the important parts of the original website, and RHDN's data crystal only has a fragment of the disassembly. Either Enker or someone else who added onto the disassembly I was given annotated all the AI scripts.
Quote from: Mr X
Found a bug, when I used the balloon magic on silktail it spawned the new enemy that you just added, I tried that on another enemy and it still happened.
Oh, uh, maybe the unused enemy didn't have his own AI, he was using the generic "has status effects" AI that any monster ends up using when afflicted; which I overwrote with the new enemy AI. Guess that needs to be relocated like their animation table. I really need to do a round of dedicated bug fixing it seems.



Quote from: hmsong
How do I "check" that?  Table?  If you're talking about hex 11, then yes that's Blaze Wall, but I don't really know where you got EBE5.
Oh, uhm, so this is where a hex editor (like HxD, https://mh-nexus.de/en/hxd/) comes in. I totally forgot to cover that. The reason I specified all of those file offsets even though that's not the format the ZPS patcher uses for addresses was to make looking in the ROM file with a hex editor easier. Using a hex editor (there are many hex editors, I just linked to one I know is good), open a Secret of Mana ROM (ideally in read-only mode so you don't accidentally make changes), and go to the file offset 0x08E801 (which is usually listed on the left side of most hex editor's UIs) either by scrolling down, or using the hex editor's "Goto..." function (often which uses the keyboard shortcut Ctrl+G).
Quote from: hmsong
I did the following:
Code: [Select]
' lava wave, damage + status effect
@OFF $C8E81D
ADR.16 $C8EBE5

' lava wave, + petrify
@OFF $D0341D
RAW 40 00

' dark force, damage + status effect
@OFF $C8E84B
ADR.16 $C8EBE5

' dark force, + poison
@OFF $D0341D
RAW 00 20
Dark Force's poison works just fine, but Lava Wave's petrify doesn't.
Code: [Select]
' lava wave, + petrify
@OFF $D0341D
RAW 40 00
appears to have the wrong address:
$D0341D is the address for Dark Force's status effect entry in the spell data tables. Lava Wave's data starts at $D02E5D, so you'll need to get the specific address for Lava Wave's status effect entry in there.



Quote from: SpiffSpoo
Since you/enemies can't have 2 status effects normally, would it be possible to have a priority in the spell to try and give one status effect first, and if that fails try for an other?  If not, or would take too much time, could the sleep effect be straight up changed to poison?

If a "leaf" saber could be coded in, making it give the poison status instead of MP drain would make sense, since MP drain was OP in SD3.
You can have multiple status effects in Secret of Mana, some conflict with each other... I think? but you're not simply limited to only one. It's Trials of Mana where you can only have one. Based on zoolgremlin's test it sounds like Sleep and Poison coexist fine.

It's unlikely I'd do a "Leaf Saber" since Mana Magic is Dryad's saber spell already.
« Last Edit: September 09, 2019, 03:28:42 pm by Queue »

SpiffSpoo

  • Jr. Member
  • **
  • Posts: 78
  • Wark!
    • View Profile
Re: Secret of Mana, Turbo - Beta 190908
« Reply #297 on: September 09, 2019, 03:31:29 pm »
You can have multiple status effects in Secret of Mana, some conflict with each other... I think? but you're not simply limited to only one. It's Trials of Mana where you can only have one. Based on zoolgremlin's test it sounds like Sleep and Poison coexist fine.

It's unlikely I'd do a "Leaf Saber" since Mana Magic is Dryad's saber spell already.

Makes sense. It always annoyed me that dryad had 1 real less spell for each character, but then again there is Shade and Lumina with only having access to 3 spells each.

On another note, has anyone looked into issues where parts of the music are cut out for a few seconds or sounds effects are cut off short?  Seems to only happen when there is a lot of action going on at once.
Wark!

Queue

  • Full Member
  • ***
  • Posts: 211
    • View Profile
Re: Secret of Mana, Turbo - Beta 190908
« Reply #298 on: September 09, 2019, 04:18:16 pm »
Quote from: SpiffSpoo
On another note, has anyone looked into issues where parts of the music are cut out for a few seconds or sounds effects are cut off short?
That's how the game's sound engine was designed. The Super Nintendo has 8 sound channels. Most games divide them up so that say, 4 channels are used for music and 4 for sounds (or 5 and 3, 6 and 2, etc.). Secret of Mana allows music to use all 8 channels with the caveat that sounds can temporarily steal some of those channels (to emit sound effects) which means parts of the music cut out while sound effects are playing. This let them make fancier music, since they weren't limiting themselves to the more typical less-than-8 channels for music. Unfortunately, some songs have important parts of their melody on channels most likely to be overridden by sounds.

I included Mop's Audio\SFX_Channel_Limit hack (Off by default) which restricts how much music can be overridden by sounds, but it's not a cure-all.

zoolgremlin

  • RHDN Patreon Supporter!
  • Full Member
  • *****
  • Posts: 130
  • Steam Profile Name: keeperofcastlegreydusk
    • View Profile
Re: Secret of Mana, Turbo - Beta 190908
« Reply #299 on: September 09, 2019, 05:18:27 pm »
Ah well, I thought I was done for the night, but my body decided it only needed, like, 4-5hrs sleep.  For some reason.  So one more post is okay, I guess, since I'm past the 1-week trial period.  There are quite a few points to respond to here, let's see if I can do this precisely...

@Queue  Much obliged for the info regarding spell functions, also I didn't know about a guy named Enker having done a disassembly of SoM.  I am going to read about bitwise ops and SNES assembly to better understand them, at some stage.  As well as ZPS's syntax.  That'll take quite a while, but it will certainly help.  10 bytes of space is not very much, indeed, but if it's free to use without conflict, good stuff.

I was pretty sure that Speed Down was pointing to a different function than Fire Bouquet, but hadn't yet confirmed it, or thought much about why.  On the face of it, that's not very sensible.  The descriptions for Speed Down and Speed Up in Vanilla are as follows:

Speed Down - Lowers Evade % and slows attack
Speed Up   - Raises Evade % and speeds attack

Soooo... right there is a hint, that the two spells were/might have been originally intended to operate as counterparts to each other.  As things stand in Vanilla, though, the game is basically being forced to lie to you.  According to Regrs, this is not the only instance of that, but I suppose that doesn't matter right now.  I did a bit of checking and, as far as I can tell, Speed Down does not lower Evade (the debuff bit and timer for that are not set by the spell function, but Tangle makes you walk slower so that's the "slows attack" part).  Speed Up only speeds attack in the vague sense that it gives you Hit Up, walking/running/attacking speeds do not seem affected in my observation.  I am of the opinion that Speed Down should be optionally capable of setting Hit Down & Evade Down, on top of Tangle which is only mildly debilitating.  But... whether to make Speed Up increase movement speed I don't know, since making it increase charge speed is already an option.  Mop's Ancient Cave project has a movespeed-increase option for Speed Up, if I remember correctly, but I'll let everyone decide for themselves the merit of that idea.  I have no strong opinion about it just now.

Link to Ancient Cave homepage:  Secret of Mana, Ancient Cave, by Mop

I like your idea of converting Speed Down's function for a new Saber, it looks like a very tidy way to fit in with the other Saber functions, which are all separate for some strange reason (different pointers per Saber, so logically different functions to be used, craaaaazy...).  Although, I actually like the Evil Gate spell, blame it on bad taste. It's only because of the animation and sound effect, not the Vanilla damage function for it.  That bit of the spell royally blows chunks!   :thumbsup:

If only there had been enough Shade/Lumina spell slots for both casters, <sigh>... (EDIT:  I really didn't think this throwaway Comment through far enough, did I?   ::))

By the way, it's quite conceivable that the Mana Tree background is not really worth fixing, if it isn't a straightforward issue.  I say that because you only see the sunrise version in Pure Land, for that one scene.  The nighttime one looks just fine.  But I'll leave it up to you as to whether it's worth fixing or not.  Thanks for your response...

@SpiffSpoo  From HHS on TASVideos, I have info about which status effects are incompatible with each other.  I will check to make sure it's all correct later on, but here's the info about that (copy/paste from the TAS forum):

- Petrify removes Tangle, Mire, Sleep, Frosty, Balloon, Barrel, and Engulf, cuts currHP by 50% each time inflicted
- Freeze removes Tangle, Mire, Sleep, Balloon, Poison, and Engulf
- Sleep removes Tangle, Mire, and Barrel
- Mire removes Tangle, Mire, and Barrel (A status defect that removes itself.  <sarcasm=TRUE>  Genius, Square...!! <sarcasm=FALSE>   >:()
- Moogle removes Balloon, Barrel, Transform, Poison, and Engulf
- Frosty, Petrify, and Pygmy all remove Transform
- Transform removes Tangle, Mire, Confuse, Balloon, Barrel, Poison, and Engulf
- Mire, Sleep, Frosty, Petrify, Balloon, Poison, and Engulf all remove Barrel
- Engulf removes Balloon, Barrel, and Poison
- Frosty, Petrify, Transform, and Moogle remove Poison


So, using your example of Engulf & Frosty (which you called "Snowman"), an enemy could indeed be inflicted with both at the same time, since neither of them cancel out the other.  (Sure fine design Square, you dopefishes!   :laugh:)  Whereas Petrify & Frosty can't coexist because Petrify removes Frosty.  Not that there would be much use to that latter example, it's just to demonstrate how the logic of status effects works in the code (at least apparently...?).

I forgot to check whether Poison and Sleep could coexist before trying it with Sleep Flower earlier, only checking after it actually worked.

Link to the TASVideos page I pulled the info from:  TASVideos Discussion:  Secret of Mana (page 18 of 30)

The posts aren't numbered, but HHS' info is very close to the top, it starts off with, "Here are some various things that I've found out."
Hope all that helps...  now back to my experimenting and reading.  Whew!  :)
« Last Edit: September 26, 2019, 09:16:49 am by zoolgremlin »
If you try to fail, and succeed, what've you done?!