øAslickproductions.org/forum/index.php?PHPSESSID=5f0fck550j2m4m2fpbtkj2vkm1&topic=1239.msg12488e:/My Web Sites/Slick Productions - FFIV Message Board/slickproductions.org/forum/index18c4-2.htmlslickproductions.org/forum/index.php?PHPSESSID=5f0fck550j2m4m2fpbtkj2vkm1&topic=1239.0e:/My Web Sites/Slick Productions - FFIV Message Board/slickproductions.org/forum/index18c4-2.html.zxðjg^ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÈ…¬2êOKtext/htmlISO-8859-1gzip0|Ö2êÿÿÿÿÿÿÿÿTue, 10 Mar 2020 10:41:11 GMT0ó°° ®0®P®€§²ð®ïjg^ÿÿÿÿÿÿÿÿ‡#2ê FF2us disassembly and a hello

Author Topic: FF2us disassembly and a hello  (Read 5991 times)

Displacer

  • FF4 Hacker
  • *
  • Posts: 27
    • View Profile
FF2us disassembly and a hello
« on: October 04, 2009, 03:27:18 PM »
Hi all! Decided to give disassembling ff2 a go. I'm pretty good with 6502 code from my commodore days, so I just need to learn the new stuff from the 65816 processor. Going good so far, I wondered if someone could check the first few lines I've worked on to make sure I'm getting a good grasp on things. This is from bank 0 of ff2 v1.1:

Code: [Select]
00/8000: 78           SEI
00/8001: 18           CLC
00/8002: FB           XCE           ;Set native 65816 mode
00/8003: C2 10        REP #$10      ;%10000, 16 bit xy registers
00/8005: E2 20        SEP #$20      ;%100000, 8 bit Accumulator
00/8007: 9C 0D 42     STZ $420D     :Set 3.58 MHz speed?
00/800A: 9C 0B 42     STZ $420B
00/800D: 9C 0C 42     STZ $420C
00/8010: A9 8F        LDA #$8F      ;%10001111
00/8012: 8D 00 21     STA $2100     ;Blank Screen, set full brightness
00/8015: A9 00        LDA #$00
00/8017: 8D 00 42     STA $4200
00/801A: A9 00        LDA #$00
00/801C: EB           XBA
00/801D: A9 00        LDA #$00
00/801F: 48           PHA
00/8020: AB           PLB           ;Set data bank to 0
00/8021: A2 00 06     LDX #$0600
00/8024: DA           PHX
00/8025: 2B           PLD           ;Set direct page (zero page) to $0600
00/8026: A2 FF 02     LDX #$02FF
00/8029: 9A           TXS           ;Set stack to $02FF

Also does anyone know the differences between v1.0 and v1.1?

Dragonsbrethren

  • Forum Overlord
  • *
  • Posts: 1,820
    • View Profile
    • Dragonsbrethren Industries
Re: FF2us disassembly and a hello
« Reply #1 on: October 04, 2009, 03:53:32 PM »
Revision 1.1 fixed a number of timer-related bugs in the battle engine, which could cause crashes.

Phoenix

  • FF4 Hacker
  • *
  • Posts: 456
    • View Profile
    • Phoenix Hacks
Re: FF2us disassembly and a hello
« Reply #2 on: October 04, 2009, 06:03:53 PM »
Welcome to the forum! If you're looking into the assembly, you might find Zyrthofar's documents useful. He's already disassembled and commented some of the ROM. You can download a zip of them here.

Displacer

  • FF4 Hacker
  • *
  • Posts: 27
    • View Profile
Re: FF2us disassembly and a hello
« Reply #3 on: October 04, 2009, 06:28:11 PM »
Thanks, unfortunately its not helpful. I already have a complete disassembly and I'm currently separating valid code from data. I'm doing it bank by bank instead of as a whole. Its a nice start as far as it goes, but I'm already further along than whats in there.

One thing I can't seem to find is how often is the NMI triggered? I know from commodore hardware it was called 60 times per second (as per the jiffy clock), but I can't find any info on how often this is called, or what clock cycle its running off of. I know where the NMI routine is, its at $9085 in bank 0.

Dragonsbrethren

  • Forum Overlord
  • *
  • Posts: 1,820
    • View Profile
    • Dragonsbrethren Industries
Re: FF2us disassembly and a hello
« Reply #4 on: October 05, 2009, 04:05:08 AM »
The NTSC SNES and SFC are also 60 times per second. I believe the PAL SNES is 50, which I suppose doesn't really matter with this game.

Displacer

  • FF4 Hacker
  • *
  • Posts: 27
    • View Profile
Re: FF2us disassembly and a hello
« Reply #5 on: October 05, 2009, 08:08:33 AM »
Yea, I kind of guessed that since the one thing I did find is the NMI is triggered during V BLANK, and since ntsc is 60hz...
Anyway thanks for the info!

Displacer

  • FF4 Hacker
  • *
  • Posts: 27
    • View Profile
Re: FF2us disassembly and a hello
« Reply #6 on: October 06, 2009, 11:45:37 AM »
Making some progress. In case its not known the first data block is transferred to the SPC-700 during initial setup. The data block that's transferred starts at $8687 in bank 04, and if I'm reading it correctly is #$11A9 in length.

I'm not sure if this block is SPC-700 code, or sound data yet, but I would assume since its sent during initialization that its code.

Displacer

  • FF4 Hacker
  • *
  • Posts: 27
    • View Profile
Re: FF2us disassembly and a hello
« Reply #7 on: October 07, 2009, 08:39:28 AM »
Yep, its code. Looks like the main sound handler, its loaded to $800 in bank 0 in the SPC-700 .

Not going to disassemble it at the moment, I'm still learning one new processor and related hardware...

Dragonsbrethren

  • Forum Overlord
  • *
  • Posts: 1,820
    • View Profile
    • Dragonsbrethren Industries
Re: FF2us disassembly and a hello
« Reply #8 on: October 08, 2009, 06:48:52 AM »
Great to see your progress here, hopefully this game's code ends up as well-documented as the rest of it. Just a question, will this be a compilable disassembly, or just a reference, like the ones we have for FF6? I'm guessing the latter, given the amount of work involved for the former (I tried to make a compilable 01 bank...didn't get very far). I don't think I can provide much help, about the only thing I've looked into at all is the main menu, and that was only what printed the text, nothing else of the menus.

Speaking of the 01 bank, FF4's is completely compatible with every other version (you can drop the entire bank in, and the game will play perfectly), so it might be a good idea to disassemble that one instead of/in addition to FF2us's. That way the extra menus are all documented as well.

Displacer

  • FF4 Hacker
  • *
  • Posts: 27
    • View Profile
Re: FF2us disassembly and a hello
« Reply #9 on: October 08, 2009, 08:03:37 AM »
For now I'm just doing a commented disassembly. It wouldn't be too hard to convert it to a compilable version so I'll probably do that after I'm finished with this.

I'll tell you this would be a lot easier if I could do it in ida, its taking forever because I have to format the data banks by hand. I'm still formatting the first block sent to the SPC-700. Speaking of that there is a second and possibly third block sent after the first one.  Don't have a clue yet what they are but I will after I finish up the first block.

Displacer

  • FF4 Hacker
  • *
  • Posts: 27
    • View Profile
Re: FF2us disassembly and a hello
« Reply #10 on: October 09, 2009, 10:15:03 AM »
Well it looks like its transferring more than 3 blocks of data to the SPC-700. Its using a neat little trick I didn't pick up on since I'm not used to 16 bit indirect addressing. Anyway the trick is reusing code with a BRA instruction. I won't go into the details but I'll comment it well in the disassembly. It looks like it may transfer the entire remainder of bank 4, but I won't be sure until I go through each and every block because at the start of each block of data there is a header of sorts, the length of the block and the address in the SPC-700 its destined for. It loops through the code until it finds a zero length block in a header, then exits the routine. Soooo I have to separate every single block because they are all of different length until I find the zero block length terminator.

Displacer

  • FF4 Hacker
  • *
  • Posts: 27
    • View Profile
Re: FF2us disassembly and a hello
« Reply #11 on: October 10, 2009, 09:25:04 PM »
I'm up to the 7th block. I'm thinking these are the songs and sound effects. The sizes vary from 0x20 bytes to over 0x1000, with the exception of the first block they all look like data. After I get them all separated I'll post their location and sizes.

Anyway formatting these takes a lot of time so its going to be awhile...

Displacer

  • FF4 Hacker
  • *
  • Posts: 27
    • View Profile
Re: FF2us disassembly and a hello
« Reply #12 on: December 15, 2009, 07:49:16 PM »
In case you're wondering, yes I'm still working on this. I'm still bogged down with separating data blocks from code in bank 4

bond697

  • FF4 Archivist
  • *
  • Posts: 624
  • Gender: Male
  • is NOT a spoony bard!
    • View Profile
    • The FF4 Reference Book
Re: FF2us disassembly and a hello
« Reply #13 on: December 16, 2009, 07:31:54 PM »
i was just thinking about this yesterday, wondering if you were still working on it.  glad to hear there's still progress.
The FF4 Reference Book - Now with new hosting!

Displacer

  • FF4 Hacker
  • *
  • Posts: 27
    • View Profile
Re: FF2us disassembly and a hello
« Reply #14 on: February 27, 2011, 06:56:36 PM »
Sorry it's been awhile, but I am back working on this. Just found the title background, it's in bank 8 starting at $C000 and is #$2000 bytes long, transferred at start up to VRAM. Might already be known but just posting since I'm still separating out data blocks