Dizzy611 / DancingMadFF6

An MSU-1 modification for Final Fantasy 6
Other
27 stars 1 forks source link

ExHiROM mod breaks some of the instructions #71

Closed edale2 closed 6 years ago

edale2 commented 6 years ago

This was posted by Madsiur over on the Qhimm Forums:

Nice work on advancing the Beta to an almost final stage!

I tested the mod on a FF6 ExHiROM mod (RotDS more specifically) and the ExHiROM mapping break some instructions more specifically the way you coded JMLs and such. As an example JML 18FA72 will work but an ExHiROM cart or ROM will require it to be JML D8FA72 in order to jump at the same place. I'm not sure if there is an advantage to use first notation but while it work on regular HiROM + FastROM carts and ROM, it breaks on ExHiROM carts / ROMs.

I got the mod working by changing all bank bytes of all problematic instructions, what is to check are JML, JSL, LDA XXXXXX, etc. In vanilla FF3us, all instructions use the HiROM notation for banks.

I'll try to fiddle with the fadeout NMI code soon, I know you tried stuff but I'll try a few things, somebody will get it right eventually! ;)

This is beyond what I know anything about, so passing it along.

edale2 commented 6 years ago

RotDS = http://rotds.webs.com/

I think.

edale2 commented 6 years ago

Basically using HiROM notation for long instructions (bank number + 0xC00000) will make the mod work on every FF6 carts and roms possible, regular FF6 ROM type (HiROM + FastROM) or expanded 6MB ROM type (ExHiROM). I don't fully understand the technicalities underlying the mapping differences between both rom types but I tested both versions on debugger emulator and made a fix after seeing the JML instruction not jumping where it should.

Since he coded this with an ASM file it could even be something not wanted in the first place but that was working with vanilla FF6 ROM type. As I said no instruction in FF6 use absolute bank notation, it's all in HiROM notation.

Still don't understand what he's talking about, lol. But more info!

Dizzy611 commented 6 years ago

I get the jist of what he's saying at least. I'll attempt the change myself when I get time. My only concern is whether or not that notation will cause issues on the actual hardware, but tbh I doubt it will

On Sat, Mar 17, 2018, 11:01 PM edale2 notifications@github.com wrote:

Basically using HiROM notation for long instructions (bank number + 0xC00000) will make the mod work on every FF6 carts and roms possible, regular FF6 ROM type (HiROM + FastROM) or expanded 6MB ROM type (ExHiROM). I don't fully understand the technicalities underlying the mapping differences between both rom types but I tested both versions on debugger emulator and made a fix after seeing the JML instruction not jumping where it should.

Since he coded this with an ASM file it could even be something not wanted in the first place but that was working with vanilla FF6 ROM type. As I said no instruction in FF6 use absolute bank notation, it's all in HiROM notation.

Still don't understand what he's talking about, lol. But more info!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Insidious611/DancingMadFF6/issues/71#issuecomment-373969233, or mute the thread https://github.com/notifications/unsubscribe-auth/AASag_sSC0F3AxNr-YjH91245biQz5THks5tfc4MgaJpZM4Su_ge .

DieKatzchen commented 6 years ago

I'd be willing to test it on my hardware.

edale2 commented 6 years ago

Good news! To answer his concern, all ASM instructions in vanilla FF6 code use HiROM notation, as an example there is never something like JSL 186040 but always JSL D86040. Same goes for all instructions requiring a bank byte (3 bytes offset).

So sayeth Madsuir.

Dizzy611 commented 6 years ago

Okay so, here's the problem I'm having ATM. The $18FA72 thing is not something I'm hardcoding, but something created by the way the wla-dx assembler works. Specifically, we're looking here:

.BANK 18
.ORG $FA72
.SECTION "MSU" SIZE 1422 OVERWRITE

Another problem is that it's not "$18FA72", it's "$12FA72", the bank number is in decimal.

So if I add C0 to that, we get D2 or decimal 210.

Which ends up with this:

$ make
Cleaning up...
Creating linker directives...
Assembling...
Pass 1...
ff3msu.asm:101: DIRECTIVE_ERROR: ROM banks == 48, selected bank 210.
ff3msu.asm:101: ERROR: Couldn't parse ".BANK".

If I were to instead use "D8", I get this:

Cleaning up...
Creating linker directives...
Assembling...
Pass 1...
ff3msu.asm:101: DIRECTIVE_ERROR: .BANK number must be zero or positive.
ff3msu.asm:101: ERROR: Couldn't parse ".BANK".
make: *** [Makefile:37: ff3msu.obj] Error 1

I'm sure there's something simple here I'm missing but I don't know of any way to actually make wla-dx use the kind of notation Madsiur is talking about.

Dizzy611 commented 6 years ago

Ok, I figured it out.

What you do is at the beginning of the file, after you set up the ROM mapping, you do either .BASE $80 or .BASE $C0 to use fastrom/hirom notation. This adds that number to whatever banks you need.

So using ".BASE $C0" fixed my code afaict. Jumps are now going to $D2xxxx instead of $12xxxx in bsnes-plus.

If the people who want to test could please test the ff3msu.ips in commit 6b81b9d0d91efccd0be6c4daef0dfa73de7ed691 I'd be grateful.

Will make a Hotfix Three release once I'm sure this isn't breaking anything for anyone.

DieKatzchen commented 6 years ago

Will test on my sd2snes this week.

edale2 commented 6 years ago

Surprised you put this on the master branch, instead of creating a new one.

Dizzy611 commented 6 years ago

Ehh, I was considering it but it's such a small change codewise that it's almost not worth the overhead of a new branch. It's easy as hell to revert if needbe.

Dizzy611 commented 6 years ago

Any updates on testing of this fix?

Dizzy611 commented 6 years ago

For now I'm closing this unless someone notices issues, as my own testing has shown this bug to be squashed without any negative consequences.