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

Author Topic: FF1 MMC5 Disassembly Updates  (Read 75783 times)

Vanya

  • Hero Member
  • *****
  • Posts: 1489
    • View Profile
Re: FF1 MMC5 Disassembly Updates
« Reply #400 on: July 26, 2019, 08:34:40 am »
Hey. My pc died again.
Mostly my own fault this time.
I think it might be time to get a new machine.

Good luck with the drain effect.

If you want to do any other spell effects, may I request a modern Barrier/Shell/Wall effect where it cuts physical and/or magical damage in half? Effectivity bytes could be 0 for physical, 1 for magical, and 2 for both.

Percentage damage spell effects like the Gravity spells would als be a great addition.

But I should ask, how much space is there for new spell effects?

Jiggers

  • Sr. Member
  • ****
  • Posts: 254
    • View Profile
Re: FF1 MMC5 Disassembly Updates
« Reply #401 on: July 26, 2019, 05:12:36 pm »
Drain effect works great, space wasn't an issue after all. Now just to remember to put the option into this project...!

I can look into doing those effects too, yeah!

I'll need to do a few things to my poison code as well, like having the character flash, and showing "Slain" when they die from it...

Bank C still has almost 900 free bytes!
I know exactly what I'm doing. I just don't know what effect it's going to have.

Vanya

  • Hero Member
  • *****
  • Posts: 1489
    • View Profile
Re: FF1 MMC5 Disassembly Updates
« Reply #402 on: July 31, 2019, 11:56:16 am »
Groovy!
I'm dying to get back into this project.
Grrrr... Stupid computer death crap.

Jiggers

  • Sr. Member
  • ****
  • Posts: 254
    • View Profile
Re: FF1 MMC5 Disassembly Updates
« Reply #403 on: August 19, 2019, 09:27:18 pm »
Here's something I'll add to this project once its working right:
Weapons having the ability to inflict ailments on enemies!

https://drive.google.com/open?id=1r8_sDoWdHwGeFNV0tbhVsvpICnxJdaAb

Here's the bank_C.asm file with all the code I've edited. There's a lot of other changes, not all of them documented well--I didn't expect this to need to be read by anyone else.

But there seems to be some difficulties in figuring out the proc rates? I can't find issues when I go through a debugger with it, but I don't have time to play through and test different combinations of weapon ailments, enemy resistances, weapon elements, and enemy elemental weakness/resistances... Apparently certain combinations of these make the proc rate super low, even if the player's base chance is set at #200 in the code.

Edit: It turns out due to the debugger not counting the header, and probably my own blindness, the wrong byte was being tested... and it turns out this all works!

To find the bits most important to the issue, look for "BNE @DoEnemyAilmentChance" and "STA btl_attacker_attackailment" (the one under "@SaveAilment:")

In this, the high 4 bits of the enemy's category are their resistance to weapon-inflicted ailments, while the low 4 bits are more what the original game uses categories for. So:

$8x = Enemy is resistant to Stone
$4x = Enemy is resistant to Confuse
$2x = Enemy is resistant to Stun
$1x = Enemy is resistant to Poison

Likewise, the weapon's category works the same, $8x being that it has a chance to inflict Stone on an enemy.

The original enemy vs. player chance calculations are there: Enemy starts with 100, it subtracts the player's magic defense, then rolls 0-200 and compares against that.

For players, they should have a base chance of #20 per hit, no chance if fighting Fiends or Chaos, and #1 if the enemy resists the weapon's ailment with their category high bits. Then it goes on to do the 0-200 roll and compare against that again.
« Last Edit: August 27, 2019, 11:58:57 pm by Jiggers »
I know exactly what I'm doing. I just don't know what effect it's going to have.

Vanya

  • Hero Member
  • *****
  • Posts: 1489
    • View Profile
Re: FF1 MMC5 Disassembly Updates
« Reply #404 on: September 04, 2019, 10:55:24 am »
Cool beans!!

I'm still in the same boat for now.
But I wanted to pop in and say you're doing amazing work between this and the dynamic patch.

Hopefully I'll be able to get back into this soon.
Still want to try to get those ice tiles working. :3

Jiggers

  • Sr. Member
  • ****
  • Posts: 254
    • View Profile
Re: FF1 MMC5 Disassembly Updates
« Reply #405 on: September 30, 2019, 03:19:52 am »
Yeah, same. Lost focus on what I was doing here, don't remember much... I think I broke battle system last tinkering. Good thing I didn't upload that!

SO HERE'S SOMETHING INTERESTING.

The Battle RNG... that 256 block of numbers 0-255 in a set, "random" order. Is only used 8 times by the battle code. Well... I say 8, honestly it might be 7. 8 times after I scrapped the stupid way FF1 tries to wake a character from sleep.

So here's what I noticed:

When trying to wake a character from stun, it grabs a byte from the RNG table and then does AND #03 to cut off everything but the last two bits. Which makes it a 25% chance that the last two bits of the number are 0.

Meanwhile, when trying to cure an enemy from confusion, it gets the RNG byte and then... does CMP #64 and checks if the number is below. Which is also a 25% chance.

Now I was doing some testing with the second way--using CMP #77--to try and wake characters from sleep. And me and the other person (mostly the other person) kind of went... "Hey... this really doesn't seem to be 30%." I swear it felt like trying to roll a number under #77 was harder than trying to roll a number whose last two bits are 0s.

I mean... statistically, its the same, isn't it? Getting 0-63 is the same chance as getting x0, x4, x8, xC out of the 16 possibilities... but with this game's RNG... IS IT??
I know exactly what I'm doing. I just don't know what effect it's going to have.

Cyneprepou4uk

  • Full Member
  • ***
  • Posts: 176
  • Самый лысый ромхакер
    • View Profile
Re: FF1 MMC5 Disassembly Updates
« Reply #406 on: September 30, 2019, 04:51:34 am »
Well, not all % are the same %. Personally I prefer to create my own counters. For example, if I need 25%, I make a counter from #00 to #03, and use #00 value for 25% chance. That way I'm sure that I will definitely get those 25% every 4 frames.

But if I do AND #03 on some random value, then I also get 25% chance from #00, but statistically it can be proved only by a large number of tryouts, coz it's not guaranteed that I will recieve #00 after AND within every 4 frames.

If I wanted to get 30%, I would make a #00-#09 counter and check for #00-#02, or better yet, make a check for 3 constant values with a similar interval between them, like #00, #03 and #06, in case I really wanted to calm my meticulous brain down  :angel:

Also, #77 is not 30%. #77 = 119 (120 if we take 0 into account as well). So 120 / 256 * 100% = 46%  :police:

I guess you've meant #4D (77, well, 78 in case with RNG), then it's correct for checking on #00-#4C.

September 30, 2019, 05:21:02 am - (Auto Merged - Double Posts are not allowed before 7 days.)
Here is an idea. FCEUX has a "random RAM initialization" option. Click on that, then pause emulator, open any ROM and run this code in Debugger.

LDX #00
loop:
LDA,X RAM
CMP #4D
BCS skip
INC counter
skip:
INX
BNE loop
RTS

Do a Reset while still being paused, then try again. See for yourself if it's really about 30% every time
« Last Edit: September 30, 2019, 07:11:03 am by Cyneprepou4uk »
I am the baldest romhacker
NES Romhacking Guide

Disch

  • Hero Member
  • *****
  • Posts: 2723
  • NES Junkie
    • View Profile
Re: FF1 MMC5 Disassembly Updates
« Reply #407 on: September 30, 2019, 10:49:06 am »
Quote
#77 = 119

#77 = 77

The # is immediate mode, not hexadecimal.  The '$' denotes hexadecimal

#$77 = 119

 :police:

Jiggers

  • Sr. Member
  • ****
  • Posts: 254
    • View Profile
Re: FF1 MMC5 Disassembly Updates
« Reply #408 on: September 30, 2019, 04:58:43 pm »
But if I do AND #03 on some random value, then I also get 25% chance from #00, but statistically it can be proved only by a large number of tryouts, coz it's not guaranteed that I will recieve #00 after AND within every 4 frames.

If I wanted to get 30%, I would make a #00-#09 counter and check for #00-#02, or better yet, make a check for 3 constant values with a similar interval between them, like #00, #03 and #06, in case I really wanted to calm my meticulous brain down  :angel:

Now that's an interesting way to do things...

On the topic of RNG, what really needs to be done next for this project is to re-do it so its not using up a 256 byte table. Fixed bank needs that space! But the Chaos Death routine needs to be tweaked as well, first...
I know exactly what I'm doing. I just don't know what effect it's going to have.

Cyneprepou4uk

  • Full Member
  • ***
  • Posts: 176
  • Самый лысый ромхакер
    • View Profile
Re: FF1 MMC5 Disassembly Updates
« Reply #409 on: September 30, 2019, 05:13:20 pm »
Disch, really? Since when does immediate addressing mode use decimal?  :police:

Is it disassembly files stuff? Never used it, so I'm not aware of small details
I am the baldest romhacker
NES Romhacking Guide

Disch

  • Hero Member
  • *****
  • Posts: 2723
  • NES Junkie
    • View Profile
Re: FF1 MMC5 Disassembly Updates
« Reply #410 on: September 30, 2019, 10:09:36 pm »
Disch, really? Since when does immediate addressing mode use decimal?  :police:

It can use dec/hex/bin in most/all assemblers

Code: [Select]
LDA #11         ; eleven
LDA #$0B        ; also eleven
LDA #%00001011  ; still eleven


; All 3 of the above will assemble to the exact same thing

Cyneprepou4uk

  • Full Member
  • ***
  • Posts: 176
  • Самый лысый ромхакер
    • View Profile
Re: FF1 MMC5 Disassembly Updates
« Reply #411 on: October 01, 2019, 04:22:55 am »
I see, thanks
I am the baldest romhacker
NES Romhacking Guide

Bregalad

  • Hero Member
  • *****
  • Posts: 2641
    • View Profile
Re: FF1 MMC5 Disassembly Updates
« Reply #412 on: October 02, 2019, 03:16:02 am »
#77 = 77

The # is immediate mode, not hexadecimal.  The '$' denotes hexadecimal

#$77 = 119

 :police:
My $2 :

The dollar $ sign indicating hexadecimal is rather a 6502-unique thing. The more common standard is using 0x prefix for hexadecimal, 0 prefix for octal and 0b prefix for binary. This probably comes from the C language, but is used by assemblers of other CPU families.

Jiggers

  • Sr. Member
  • ****
  • Posts: 254
    • View Profile
Re: FF1 MMC5 Disassembly Updates
« Reply #413 on: October 02, 2019, 11:41:55 pm »
Some updates: (as in updated to the git hub page thing!)
  • Weapons can have ailments with their own proc rates. So you could have a weapon that insta-kills every time, or a weapon that has a less than 1% chance to poison.
  • Regeneration has been re-worked a bit. I used some of the ideas and bits of code from Anomie's poison/regeneration stuff, after disassembling it to help someone else's hack implement it. It now does some proper division things instead of just bit-shifting max HP.
  • Enemies can now be poisoned! Untested.
  • Physical attacks: A long while back Disch asked me if I knew how to fix the bug where enemies could hit 1 out of 50 times and yet have 50 chances to inflict their ailment... I did something weird by shifting the whole thing to the end of the attack so they only had 1 chance; that's now put back in place to give them 1 chance per hit again.
  • Physical attacks: Player sprite will flash whether dead or not... since enemies shouldn't be even targeting dead players in the first place? I don't remember if that was possible in vanilla.
  • Physical attacks: Hit Rate and Hit Chance are now combined regardless if the defender is stunned or asleep.
  • Confused enemies: Enemy attack is half their strength, minimum of 1. Dust cloud is always white. No longer elemental. (Still basically the Fire spell though.)
  • Confused players: PLAYERS CAN NOW BE CONFUSED! Damage and crit rate are half, all other physical attack stuff is the same. A confused player cannot be controlled. If confused mid-round, they will attack instead of doing their original command.
  • Enemies who can cause confusion with their attacks are: Astos (he's good at trickery), Wizards (mindflayers), Tiamat (why not), and the Eye (makes it more interesting.) Kraken can also cause blindness with his inky tentacles.
  • Physical attacks: If an enemy's attack ailment is Sleep, they will not wake up sleeping characters. If an enemy's attack ailment is Confuse, they will not un-confuse confused characters. Otherwise, a physical hit will clear the ailments.
  • Enemies now flash when attacking or regenerating, so you know which ones did it. The mixed formation may flash the wrong small enemies. https://youtu.be/RD9esTdDEeQ
  • "Monsters" has been replaced by "Enemies" in the battle messages because Bikke's pirates are just misunderstood marshmallows.
  • Battle message boxes have been stretched out to allow for longer enemy names and such.
  • Exp up and GOLD now read "Exp earned.." and "Gold found.." while the boxes to the right now say "### Exp" and "### Gold" - https://cdn.discordapp.com/attachments/535538496547586060/631180099089334277/unknown.png
  • Battle menus have been re-done in order to properly draw the class's skill when pulling up the command menu.
  • Ward, Runic, and Chant are placeholders and bring up a "Coming soon..?" message. Kick may be replaced as well.
  • Thievery has been re-calculated to be similar to FF6's algorithms. Enemies now have 3 possible items: 2 common, 1 rare. It is possible to steal 1 common and 1 rare from the same enemy, but not both commons. It is a 50/50 between the common items, and a 1/8 chance to get the rare item, once stealing has been marked as a success.
  • Pressing Select (Flee) or Start (Fight) in the main battle command menu now displays different text to better explain what the choice is. Choosing Flee asks "Run away?", and choosing Fight asks "Charge!?"... both instead of the usual "Ready?" that pops up when all 4 player commands are input manually.
  • Re-did icon printing code to support custom ailment weights.
  • Inns and clinics now charge based on level, with price hikes at levels 16, 25, and 35. Inns are group's combined level * 5, then * 10, then * 15, then * 20. The group's combined level must reach 16 for the price to change; so 64. A single warrior at level 50 would be charged * 5 if the rest were dead. The clinic price is level * 50, then * 75, then * 125, then * 200. ... which is still half the price of a Phoenix Down.
  • Added a bit in the NaturalPose routine to set death or stone as the ONLY ailment, if a player has one of them.
  • Fixed Bug: Enemies that run away now properly remove their exp and gold from being given at the end of battle.
  • Fixed Bug: Treasure chests should open properly... again...
  • Fixed Bug: As noted by Anomie, "*Hit% should be applied even if asleep, and not clamped until after evade is Subtracted"; first part was done, but clamping now happens after evade is subtracted!


Bug: After battle crashed after using auto-target. This may have been due to corrupted RAM after loading save states while testing. Can't re-produce anymore.
« Last Edit: October 09, 2019, 01:18:48 am by Jiggers »
I know exactly what I'm doing. I just don't know what effect it's going to have.

Jiggers

  • Sr. Member
  • ****
  • Posts: 254
    • View Profile
Re: FF1 MMC5 Disassembly Updates
« Reply #414 on: October 11, 2019, 02:22:54 am »
Working on a few things... could use some feedback.

1.
Ailments! Right now the ailments are like so:

* Death, can't act, HP set to 0. Fixed with Phoenix Down, Life, Life 2
* Stone, can't act, HP frozen. Fixed with Soft.
* Poison, does 12.5% max HP (I think??) per turn. Fixed with Pure.
* Blind, can't hide, -40 to hit chance, -40 to evade. Fixed with Eyedrops, Lamp.
* Mute, can't use spells, items, or gear. Fixed with Voice (doesn't seem to wear off on its own.)
* Stun, can't act, 25% chance to recover. 25% damage boost to attacker.
* Sleep, can't act, 50% chance to recover (10% for enemies. Oops.)  25% damage boost to attacker. Fixed with Wakeup Bell, or getting hit.
* Confuse, can't choose action, 25% to recover. Fixed by getting hit.

Changes I'd make:
Paralysis: Allows choosing an action, but only a 50/50 chance to perform a turn. 50/50 chance its -40 to evade.
Sleep: 12.5% chance to recover for both players and enemies. Evasion is 0.
Mute: Allow at least items, but maybe not Gear? Perhaps a 12.5 chance to recover.

Thoughts on that would be good!

2. Skills! I'm happy with Stealing, but I hate Kick, and I don't know what to do for some of them.

Some ideas:
Fighter/Knight - Ward / Block / Hold / Watch - different names for the same thing: Take a defensive stance and guard a chosen character from harm. (Could possibly switch out "Guard" command with one of these words, too. Has to be 5 letters or less.)

Red Mage/Wizard - Runic - Uses their weapon to absorb enemy's magic, either stopping it from hurting the party, or just using it to refill their own HP/MP or something. I rarely used it in FF6 so I don't fully understand how it does stuff...

White/Black Mage/Wizard - Chant - Something something magic boost? Cast a random spell with no mana use at half effectivity?

Black Belt/Master - Focus? Parry? Build up strength, maybe beef up defenses and/or evasion for a round, then unleash a stronger attack on the next round, or add the enemy's damage dealt to their own attack and punch the enemy who hit them, like FF5's Counter...?

And the big one...

3. CONFUSION.

I'm almost there with this. This is the breakdown of it:

Confusion stops a character from being able to choose their action. If it was chosen, but then they got confused during the round, they will do their own thing.

There's a 25% chance to cure from it, to start. Getting hit by a physical attack - either another confused player character, or the enemy - will snap them out of it.

Then there's a 25% chance to physically attack a random enemy. (Auto-target is turned on, then turned off after, if its set to off.) If that didn't go through...

There's a 50/50 chance to attack another character physically. Or themselves. This one checks to make sure the other character is alive. If that didn't go through...

Then they try to do magic. There's 8 chances to cast a spell, first rolling 1-8 and checking available MP for a random spell level. If no MP is found for that level, another roll is done, 1-7, and so on, so over time its more likely a lower level spell will be chosen. Its possible that it can hit a spell level with 0 available MP 8 times in a row, at which point it just attacks another character physically.

If there IS mana, then the code will check if they know any spells for that level. If not, physically attacks another character. Else, randomly picks one of the 3 spells.

THEN there is a 50/50 chance to try to cast it with the target reversed. Which is where I'm having trouble getting things to work right. The idea is that Fire 2 will target the whole party, or Fire 1 will target a random character (who may or may not be dead; I didn't want to add in a check here because I like the thought of a confused character accidentally casting Life on someone who needed it and imagining the look on the player's face...)

So far it partially works, but I have to go through all the spells and make sure the message boxes are behaving, which they're not... Nor are the spells. Cure 2 does not hit one entity and "Defend lightning" darnit!  :P

I may put up a branch for testing this if people wanna help see what goober things the warriors do when confused.

This will also make Confusion real scary, because if the mages in the bottom can do random magic and seldom get hit to wake from it... oh boy.
I know exactly what I'm doing. I just don't know what effect it's going to have.