øAslickproductions.org/forum/index.php?PHPSESSID=5f0fck550j2m4m2fpbtkj2vkm1&topic=1992.0e:/My Web Sites/Slick Productions - FFIV Message Board/slickproductions.org/forum/index03ef.htmlslickproductions.org/forum/index.php?PHPSESSID=5f0fck550j2m4m2fpbtkj2vkm1&board=8.140e:/My Web Sites/Slick Productions - FFIV Message Board/slickproductions.org/forum/index03ef.html.zxÁ%h^ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÈà•¤ÓñOKtext/htmlISO-8859-1gzip8:ÖÓñÿÿÿÿÿÿÿÿTue, 10 Mar 2020 23:58:18 GMT0ó°° ®0®P®€§²ð®Á%h^ÿÿÿÿÿÿÿÿ:"Óñ FF6 isn't the only poorly coded game...

Author Topic: FF6 isn't the only poorly coded game...  (Read 2118 times)

LightPhoenix

  • FF5 Hacker
  • *
  • Posts: 130
    • View Profile
FF6 isn't the only poorly coded game...
« on: December 27, 2014, 04:23:48 PM »
Normally, FF6 is touted as one of the shoddier coded games out there, and with good reason (likely a poor compiler).  However, if you're ever looking at the code for CT, you'll be routinely presented with such gems as this:

Code: [Select]
$C1/BB53 20 60 BC    JSR $BC60

$C1/BC60 80 7E       BRA $BCE0

$C1/BCE0 60          RTS

I think we should all take a moment to appreciate this pinnacle of assembly coding.   :laugh:

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: FF6 isn't the only poorly coded game...
« Reply #1 on: December 27, 2014, 06:16:22 PM »
...How do you even make that mistake? The only thing i can imagine is that there may have been a function there originally, but then they decided to axe it for a reason.

JCE3000GT

  • Master of FF4
  • *
  • Posts: 1,429
  • Gender: Male
  • Vladof
    • View Profile
    • BlitzKrieg Innovations
Re: FF6 isn't the only poorly coded game...
« Reply #2 on: December 27, 2014, 06:27:16 PM »
Is that something left over from the Japanese sample cart?

LightPhoenix

  • FF5 Hacker
  • *
  • Posts: 130
    • View Profile
Re: FF6 isn't the only poorly coded game...
« Reply #3 on: December 27, 2014, 09:12:14 PM »
I haven't spend a whole lot of time with CT, so I'm wary of saying exactly what is going on.  However, my primary guess is that whatever compiler they used was not very good.  There's a fair bit of stuff in the ROM that is coded strangely, or the assembly is so poor that it should have been caught.

Another possibility is, based on the code, it appears that they might have wanted to do more with the game and either didn't get around to it or scrapped it.  It's possible this is some remnant of those plans.  I haven't fully analyzed the code this snippet comes from yet.

Digitsie

  • Mom Bomb
  • *
  • Posts: 105
    • View Profile
Re: FF6 isn't the only poorly coded game...
« Reply #4 on: December 27, 2014, 09:26:55 PM »
I think this might give context to the weirdness that is Chrono Trigger:

http://www.gamefaqs.com/boards/563538-chrono-trigger/65153020


dn

  • Ymir
  • *
  • Posts: 14
    • View Profile
Re: FF6 isn't the only poorly coded game...
« Reply #5 on: December 28, 2014, 10:06:19 AM »
Yeah. I wouldn't be surprised if there's still some NASIR code in CT, seeing as he's credited for SD2. Frankly surprised CT runs at all if that's the case.

LightPhoenix

  • FF5 Hacker
  • *
  • Posts: 130
    • View Profile
Re: FF6 isn't the only poorly coded game...
« Reply #6 on: December 30, 2014, 09:21:12 PM »
Came across another beauty I wanted to share:

Code: [Select]
$FD/AF85 C9 5A       CMP #$5A               
$FD/AF87 B0 4E       BCS $AFD7
$FD/AF89 80 4C       BRA $AFD7

Tenkarider

  • Guard Leader
  • *
  • Posts: 50
    • View Profile
Re: FF6 isn't the only poorly coded game...
« Reply #7 on: December 30, 2014, 10:07:08 PM »
Who wrote that must be a...


Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: FF6 isn't the only poorly coded game...
« Reply #8 on: December 30, 2014, 11:27:28 PM »
Came across another beauty I wanted to share:

Code: [Select]
$FD/AF85 C9 5A       CMP #$5A               
$FD/AF87 B0 4E       BCS $AFD7
$FD/AF89 80 4C       BRA $AFD7

Alright, now there is no excuse for that! Now you mentioned compiler's earlier, do you mean a person who failed at their job, or do you mean a machine tried to compile all of this code?

Mauron

  • Wing Raptor
  • *
  • Posts: 6
    • View Profile
Re: FF6 isn't the only poorly coded game...
« Reply #9 on: January 02, 2015, 02:37:07 AM »
I was looking at the second snippet, and it seems that it relates to loading item names for battle - disabling the BRA would include weapon names.

I haven't found where the first snippet is called from, but using my best guess to disassemble it, it looks like it was messing with the current PC's weapon and the inventory.

It seems you've found some of the removed switch weapon in battle function. I wonder if the rest of the code is lying around somewhere.

LightPhoenix

  • FF5 Hacker
  • *
  • Posts: 130
    • View Profile
Re: FF6 isn't the only poorly coded game...
« Reply #10 on: January 02, 2015, 05:37:11 PM »
Quote
Alright, now there is no excuse for that! Now you mentioned compiler's earlier, do you mean a person who failed at their job, or do you mean a machine tried to compile all of this code?

I mean the program that changed it from C (or whatever high-level language) to assembly.  For example, there's a switch/case for when a damaging tech is called to determine the damage formula to use (for those curious, it starts at C1/E0F5).  Normally this will be a CMP/BNE to jump to the next case.  However, some of them (not all of them) are instead CMP/BEQ/JMP for no apparent reason.  I suspect this would be an example of compiler shenanigans. 

Quote
I was looking at the second snippet, and it seems that it relates to loading item names for battle - disabling the BRA would include weapon names.  I haven't found where the first snippet is called from, but using my best guess to disassemble it, it looks like it was messing with the current PC's weapon and the inventory.  It seems you've found some of the removed switch weapon in battle function. I wonder if the rest of the code is lying around somewhere.

That would be interesting.  I'm trying to decode some of the double/triple tech code (it's a mess, to say the least).  I think the part I'm looking at is the "perform an action" part of the code, but I"m only looking at a slice so I can't be sure.  It's called twice, at C1/CE2A and C1/F012.  There's a bunch of small code snippets in FD that C1 utilizes.

Mauron

  • Wing Raptor
  • *
  • Posts: 6
    • View Profile
Re: FF6 isn't the only poorly coded game...
« Reply #11 on: January 02, 2015, 10:08:51 PM »
I found this little snippet today.

Code: [Select]
$C1/17A1 AD E6 95 LDA $95E6  [$7E:95E6]
$C1/17A4 F0 0B BEQ $0B    [$17B1]
$C1/17A6 F0 0E BEQ $0E    [$17B6]

It looks like some of the code and data for the weapon switch function is gone... I'm tempted to try and restore it now.

I haven't done too much with the tech code, but I have done plenty with tech data - depending on what you're doing, I may be able to help.

LightPhoenix

  • FF5 Hacker
  • *
  • Posts: 130
    • View Profile
Re: FF6 isn't the only poorly coded game...
« Reply #12 on: January 03, 2015, 05:39:15 PM »
Thanks, it's not overly complicated, it's just all over the place, so getting it organized in my head is a bit of a challenge.  I'm not really working on anything, just looking at it as a little diversion from FF5/FF6 hacking.  One of my "dream projects" would be doing a CT hack, but the idea I have in mind would require significant amounts of complex hacking, so it's more a lark than a serious project.

noisecross

  • FF5 Hacker
  • *
  • Posts: 146
    • View Profile
Re: FF6 isn't the only poorly coded game...
« Reply #13 on: January 05, 2015, 03:51:47 AM »
I am with LightPhoenix in these pieces of assembly looks pretty much like binary generated by a compiler with no optimizations working. It may be also produced by snippets or macros used with few care by the programmers.

If the code works and the game doesn't need storage or efficiency, is faster and cheaper having programmers using tools which generate this poor code than having a team of assembly experts.

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: FF6 isn't the only poorly coded game...
« Reply #14 on: January 05, 2015, 09:24:01 PM »
I am with LightPhoenix in these pieces of assembly looks pretty much like binary generated by a compiler with no optimizations working. It may be also produced by snippets or macros used with few care by the programmers.

If the code works and the game doesn't need storage or efficiency, is faster and cheaper having programmers using tools which generate this poor code than having a team of assembly experts.

Something like that could explain why Zelda 64's event programming is such a mess (You get the Fire Medallion Three Times!! And every other Medallion twice). And also why some actors can't be used outside of their natural setting.