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

Author Topic: Disch FF1 Disassembly question  (Read 1363 times)

Chicken Knife

  • Sr. Member
  • ****
  • Posts: 316
    • View Profile
Disch FF1 Disassembly question
« on: February 27, 2020, 04:13:26 am »
Several months back I put out a minor rebalancing addendum hack for FF1 Restored. Something else just came to mind that I wanted to add to it. The other day I suffered the most recent of numerous TPKs from the War Mech / Death Machine enemy in the Sky Fortress and I came across the fact that the odds of the encounter were considerably boosted in the US version from 1/64 to 3/64, with a group of fighter enemies replacing the Death Machine in the 1/64 slot. IMO this is an enemy one should really have to grind for--not casually encounter and get that lovely TPK.

So I downloaded Disch's assembly in hopes of finding the location where encounter rates are stored. I was able to open all the .asm files in notepad++ so I browsed them. It's possible I missed it but I didn't locate any sections covering encounter rates. Several of the banks are stored as .dat files and when I open in a text editor it's all garbage. Can't seem to figure out how to actually review those.

Any input on reviewing the .dat files or from someone who happens to know where the encounter rate data is stored would be very helpful. Thank you!
« Last Edit: February 27, 2020, 04:27:38 am by Chicken Knife »

Cyneprepou4uk

  • Sr. Member
  • ****
  • Posts: 333
  • I am the baldest romhacker
    • View Profile
Re: Disch FF1 Disassembly question
« Reply #1 on: February 27, 2020, 07:14:49 am »
Open with hex editor maybe?
iromhacker.ru - NES ROM hacking tutorials for beginners. Please use Google Translate browser extension

Chicken Knife

  • Sr. Member
  • ****
  • Posts: 316
    • View Profile
Re: Disch FF1 Disassembly question
« Reply #2 on: February 27, 2020, 11:46:30 am »
All that does is pull the .dat information up in bytes as if I opened up a rom in a hex editor. It doesn't provide any of the disassembly information I'm looking for.
« Last Edit: February 27, 2020, 12:05:17 pm by Chicken Knife »

Cyneprepou4uk

  • Sr. Member
  • ****
  • Posts: 333
  • I am the baldest romhacker
    • View Profile
Re: Disch FF1 Disassembly question
« Reply #3 on: February 27, 2020, 11:51:20 am »
Maybe it shouldn't give you any information. Maybe it's just for including bytes from a file instead of writting a list of bytes in .asm
iromhacker.ru - NES ROM hacking tutorials for beginners. Please use Google Translate browser extension

Chicken Knife

  • Sr. Member
  • ****
  • Posts: 316
    • View Profile
Re: Disch FF1 Disassembly question
« Reply #4 on: February 27, 2020, 12:03:50 pm »
You may be correct about that. A lot of the material that comes in the disassembly seems to be there for recompiling purposes. I'll take another look through the asm files for the tables I need.

Disch

  • Hero Member
  • *****
  • Posts: 2784
  • NES Junkie
    • View Profile
Re: Disch FF1 Disassembly question
« Reply #5 on: February 27, 2020, 04:24:42 pm »
The data you're looking for is in bank 0F, around line 1357.  The 'lut_FormationWeight' table:

This data is stored at offset $3C59C in the ROM

Code: [Select]
lut_FormationWeight:
  .BYTE 0,0,0,0,0,0, 0,0,0,0,0,0    ; 12/64 chance of formation 0
  .BYTE 1,1,1,1,1,1, 1,1,1,1,1,1    ; 12/64
  .BYTE 2,2,2,2,2,2, 2,2,2,2,2,2    ; 12/64
  .BYTE 3,3,3,3,3,3, 3,3,3,3,3,3    ; 12/64
  .BYTE 4,4,4,4,4,4                 ;  6/64
  .BYTE 5,5,5,5,5,5                 ;  6/64
  .BYTE 6,6,6                       ;  3/64
  .BYTE 7                           ;  1/64

The table is 64 entries.  A number is pulled from the table "randomly".  Thus the more times a number exists in the table the higher the odds of you having that encounter.  Values 0-7 are valid because each domain has 8 different encounter patterns assigned to it.

Chicken Knife

  • Sr. Member
  • ****
  • Posts: 316
    • View Profile
Re: Disch FF1 Disassembly question
« Reply #6 on: February 27, 2020, 05:05:03 pm »
@Disch,

Thank you so much for chiming in! Yes, that table looks like it's part of what I'm looking for. But this looks like the general routine that is used for selecting the monster formation in every area. I don't want to make universal changes to the game--I'm only looking into tweaking the formation designations for the bridge area of the sky palace. If I mess around with this table, I feel like I'm going to change everything in all the areas.

I'm going to guess that there are map specific enemy formation designations saved somewhere where numbers 0-7 are assigned to each formation. If I located that for the bridge, I could exchange the 6 and 7 numbers and revert the Death Machine to the original Japanese probability of appearance.

As I've looked through your disassembly, I'm guessing that covering data for specific areas is outside the scope. If I were better at debugging I could probably find that myself but that's a work in progress. I'm focusing on asm study now and debugging will come next. I'm also planning to really study this disassembly of yours for an actual example of how routines in rpgs are handled by the programming.

Disch

  • Hero Member
  • *****
  • Posts: 2784
  • NES Junkie
    • View Profile
Re: Disch FF1 Disassembly question
« Reply #7 on: February 27, 2020, 06:21:57 pm »
Oooooh.  My bad.  :laugh:

Yeah you are correct about that affecting all areas.

So after looking at this, it looks like I didn't probably label this bin file!  The file that has the encounters is 0B_8000_unknown.bin.  I found this by looking at GetBattleFormation (in bank F), which swaps to BANK_DOMAINS (bank B) and reads from lut_Domains (defined in one of the headers as $8000).  So yeah this is not the clearest it could be.


(Note:  For the below explanation it might be easiest to look at this stuff in FFHackster, since that gives a decent visual representation of what's going on)

The way it works is there are different "domains", each domain is assigned 8 encounters.  The overworld is split into a large 8x8 grid, with each area being it's own domain.  All other maps have their own domain.

In addition to that, the overworld has 3 special domains (one for the oceans, and two for the rivers), but it just shoves the data for those in some of the towns, since towns don't have encounters.

The above mentioned bin file has 8 bytes for each domain.  The first $100 bytes are the encounters for the overworld, and following that are the encounters for all other maps.

The bridge data for warmech/death machine would be on Floor 5 of Sky Palace, which is offset $398:

Code: [Select]
C1 51 B5 A4 D2 50 56 D6

(There are only $80 battle formations, so values over $7F use "formation B".  IE:  $51 = $51 formation A, but $D1 = $51 formation B)

WarMech is encounter $56 formation A.  So if you want to make that a more rare encounter, you probably just want to swap those last two bytes.

Chicken Knife

  • Sr. Member
  • ****
  • Posts: 316
    • View Profile
Re: Disch FF1 Disassembly question
« Reply #8 on: February 27, 2020, 10:23:55 pm »
Thank you so much for finding that! I made the adjustments and then fought 40-50 encounters on that bridge. It would appear that reversing those bytes did the trick.

At some point in the next couple days, I'll update my FF Restored addendum patch.

Thanks again!