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

Author Topic: 2 Final Fantasy 1 NES programming/hacking related questions  (Read 4713 times)

Duke2go

  • Full Member
  • ***
  • Posts: 192
    • View Profile
    • Final Fantasy Reconstructed
2 Final Fantasy 1 NES programming/hacking related questions
« on: April 06, 2015, 09:32:33 pm »
I hope that I have not gone against the rules for posting here. As some might know, I'm working on the Final Fantasy Reconstructed project, and I've generated a lot of data in a very short time. I had the pleasure to finally experience Grond's Final Fantasy for the first time today, and I was very impressed. I was really surprised at the numerous similarities that I had actually unintentionally drawn without knowing it. Ever since I played Final Fantasy ++ I was impressed by the moving ocean in that game. Grond's Final Fantasy has the same basic look of the ocean that I included, that of FFIII JP, but there are still things that are contained within my base image that I like and want to keep, and are not present in Grond's game. Does anyone know how he was able to create the moving ocean/stream/ and apparently lava tiles? I have searched for the better part of the day and I can't find anything about it, although I seem to remember he acknowledged what program or utility he used to make that happen somewhere. So question 1 is can anyone help me or point me in the right direction so that I can accomplish this myself. The second question is much more simple. I would REALLY like to make the chests reflect that they have been opened. Is there ANY way to somehow do a type of if:then code where the closed lid sprites are automatically redirected to different open lid sprites when the chest has been opened? I managed to make the chests look a lot like FFIV's, and it pains me that they just sit there like stones after they've been opened. Disch offered some general advice about animating the ocean, but asked me to post the question to the board so that everyone could either possibly help or be helped. Thank you for any help that can assist me in making my ideal remake of my favorite NES RPG, if not game in general.
Tell my tale to those who ask. Tell it truly, the ill deeds along with the good, and let me be judged accordingly. The rest... is silence...

http://www.ffreconstructed.com/
https://www.facebook.com/finalfantasyreconstructed/

JCE3000GT

  • Sr. Member
  • ****
  • Posts: 433
    • View Profile
Re: 2 Final Fantasy 1 NES programming/hacking related questions
« Reply #1 on: April 06, 2015, 09:40:02 pm »
Just saw your PM and this post so I will post in here.  I just don't know much about NES and graphics separately and combined it gets worse.  LOL

Maybe Grond, Disch, or another well-known Final Fantasy I hacker could provide some insight?  Sorry wish I could help!

Disch

  • Hero Member
  • *****
  • Posts: 2744
  • NES Junkie
    • View Profile
Re: 2 Final Fantasy 1 NES programming/hacking related questions
« Reply #2 on: April 06, 2015, 10:21:07 pm »
Quote
Does anyone know how he was able to create the moving ocean/stream/ and apparently lava tiles?

This ultimately is a programming problem.  You have to write assembly code which will perform the animation, and inject it into your hack.

As far as assembly hacks go, if you have no prior programming experience, this probably isn't the best one to start with, but it also isn't the worst.  There's already a disassembly available that has all the out-of-combat code commented and organized, so hopefully that softens the difficulty a bit:

http://www.romhacking.net/documents/401/



But there's no getting around it.  To do this yourself you'll have to learn 6502 assembly and some basics about NES architecture.  You'll be writing code.


I did a hack like this way back when... it basically worked like this:

The game is in different areas of code for different sections.  So when you're on the overworld, the game is running one set of code, and when you're in standard maps, it's running another set.  What I did (since i just wanted to animate overworld water), was I got into the overworld game code, and at the start of every frame, had it JMP to some free space, where I would insert my animation routine.

The animation routine basically just read the pixel data from the PPU (via $2007 register reads), shifted them over, and wrote them back.  Conceptually it's very simple, it's just getting the details with PPU interaction right that's tricky.

I can get into more details if you want.  But I don't want to get ahead of myself.  If this didn't scare you away and you're willing to try it, then I'm certainly willing to help.  Just let me know.


Quote
I would REALLY like to make the chests reflect that they have been opened. Is there ANY way to somehow do a type of if:then code where the closed lid sprites are automatically redirected to different open lid sprites when the chest has been opened?

That is absolutely possible.  And as with the other question... the relevant code is all commented and explained how it all works in the above linked disassembly.

Normally when drawing tiles, the game just looks at the tile ID and draws it appropriately.  You'll have to change that so instead it:

1)  Checks the tile properties.  If it's not a treasure chest, draw it normally
2)  If it is a treasure check, check to see if that particular chest has been opened.  If not, draw it normally
3)  If it has been opened, draw a different tile.


It'd probably be easiest to dedicate a tile for each tileset to be the "open chest" -- much like the game does now with open doors.

And in fact... the open door code might be similar to what you want to do -- it's been a while since I've looked at it so I can't remember for sure -- but maybe you can look at that code to get some ideas.





EDIT:

Looking at the disassembly again:


The main overworld loop is in bank_0F.asm.  Ctrl+F for  "EnterOverworldLoop:"

Code: [Select]
  @Loop: 
    JSR WaitForVBlank_L        ; wait for VBlank
    LDA #>oam                  ; and do sprite DMA
    STA $4014

    JSR OverworldMovement      ; do any pending movement animations and whatnot
                               ;   also does any required map drawing and updates
                               ;   the scroll appropriately

The best spot to slip the animation code in there is between that STA and JSR.  That is, after the OAM update, but before the scroll is adjusted.
You can JSR to your own routine.

If you need some extra bytes to fit in your JSR, there's some unnecessarily long frame-counter incrementing code immediately after that which uses ADC and can be replaced with shorter INC commands to free up some space.


Looking for TC related drawing code now....




EDIT 2:

Also in bank_0F.asm, Ctrl+F for "RedrawDoor:"

This code does the actual tile redrawing, which you can probably recycle for redrawing the treasure chest when it is first opened.


I also found 'DrawMapRowCol:' which does the drawing of the treasure chest tiles normally -- but it doesn't look like you'll have to mess with that, as it just draws preloaded information.  The actual loading of that information is what you'd want to change... and that is...

..searches...

You'd want to mess with "PrepSMRowCol:" (same bank_0F.asm file -- most stuff is in that bank):

Code: [Select]
  @RowLoop:
    LDY #$00          ; zero Y for following index
    LDA (tmp), Y      ; read a tile from source
    TAY               ; put the tile in Y for a source index

    LDA tsa_ul,      Y  ;  copy TSA and attribute bytes to drawing buffer
    STA draw_buf_ul, X

Here the code uses Y as basically the tile it will draw.  What you would want to do, is not use the tile directly, but instead replace it with the "open TC" tile if that chest has already been opened.

Code is too tight in this routine so you'd probably have to JSR elsewhere to do the checks, but it shouldn't be THAT difficult.


Another routine in this bank, "TalkToSMTile" shows an example of how to check to see if a tile is a chest, and how to check to see if that chest has been opened.  You can use that for reference when writing your routine.
« Last Edit: April 06, 2015, 11:00:58 pm by Disch »

Duke2go

  • Full Member
  • ***
  • Posts: 192
    • View Profile
    • Final Fantasy Reconstructed
Re: 2 Final Fantasy 1 NES programming/hacking related questions
« Reply #3 on: April 07, 2015, 12:56:13 am »
Thank you both immensely!!! Especially for the extra effort from Disch. I had hoped to get some insight, but I think you might have given me enough that I can figure it out from this point, and if not, a good friend has more experience writing and editing code, so I'm sure between the two of us we can probably figure it out. I went through and applied some of the patches that I linked in another thread today and I'm going to probably put up a list tomorrow of what I've added to the base rom as far as bugfixes that might not have been available when the base was created. I've heard Grond is no longer active on the boards, but I would love to pick his brain about his projects. Thanks again guys. Have a great week.
Tell my tale to those who ask. Tell it truly, the ill deeds along with the good, and let me be judged accordingly. The rest... is silence...

http://www.ffreconstructed.com/
https://www.facebook.com/finalfantasyreconstructed/

Disch

  • Hero Member
  • *****
  • Posts: 2744
  • NES Junkie
    • View Profile
Re: 2 Final Fantasy 1 NES programming/hacking related questions
« Reply #4 on: April 07, 2015, 11:07:34 am »
Glad I was helpful.  Best of luck in your project!   :)


FWIW, I freaking love this stuff and don't at all mind giving help/guidance if you need it -- like if you get stuck or something or have other questions.

Chpexo

  • Hero Member
  • *****
  • Posts: 731
    • View Profile
.
« Reply #5 on: April 07, 2015, 06:30:59 pm »
.
« Last Edit: January 01, 2016, 10:13:02 am by Chpexo »

Disch

  • Hero Member
  • *****
  • Posts: 2744
  • NES Junkie
    • View Profile
Re: 2 Final Fantasy 1 NES programming/hacking related questions
« Reply #6 on: April 07, 2015, 06:44:44 pm »
Quote
Re: the animated CHR, you'll need to change the mapper of the game,

You do not.  FF1 hardware is completely capable of small CHR animations as-is.

Duke2go

  • Full Member
  • ***
  • Posts: 192
    • View Profile
    • Final Fantasy Reconstructed
Re: 2 Final Fantasy 1 NES programming/hacking related questions
« Reply #7 on: April 07, 2015, 11:55:03 pm »
Cool. Thank all of you again for the advice. I actually found the gamefaqs document while I was looking yesterday I believe and I linked it in another thread for others who are working on a FF1 hack of their own. Sorry, I should have mentioned that earlier within this thread. My cousin works with a lot of IT guys for the Coast Guard, so he is supposed to reach out to some of them for help. I really would like to learn how to do it on my own just for the sense of accomplishment, but if I can't do it, I will just have to ask for some more extensive help. So far I've really felt a lot of good feelings about doing this, even when I get stuck. I was much more apt to scrap the project in the beginning and start from a fresh version than I am now. Some of the patches that I applied from the gamefaqs document actually corrupted my game, and I think that has a lot to do with the fact that I started with Grond's rebalance hack rather than a clean FF1 rom. In the beginning, I was just going to change the looks of the main characters and enemies, but as I got into it I just felt like if I was going to update those looks, then maybe just maybe I would be able to update the levels and locations as well. Honestly, I also didn't know at that point how to implement a dash button or many of the things that Grond had already done.  Thank you again to Disch for the FFHackster utility because I wouldn't have been able to come anywhere near where I am at now without a LOT of learning programming and code. Its kind of a cheat, and I am learning my own liabilities and weaknesses, but I'm still learning a lot more than I knew at the beginning.
Tell my tale to those who ask. Tell it truly, the ill deeds along with the good, and let me be judged accordingly. The rest... is silence...

http://www.ffreconstructed.com/
https://www.facebook.com/finalfantasyreconstructed/

Disch

  • Hero Member
  • *****
  • Posts: 2744
  • NES Junkie
    • View Profile
Re: 2 Final Fantasy 1 NES programming/hacking related questions
« Reply #8 on: April 08, 2015, 03:07:24 am »
FWIW, if you have IRC, I hang out in #rom-hacking on espernet.  If you want a crash course on 6502 and NES architecture basics, you can pop in.  If I'm around I'll be happy to give mini lessons  (though a lot of times I'm idling/afk)

Duke2go

  • Full Member
  • ***
  • Posts: 192
    • View Profile
    • Final Fantasy Reconstructed
Re: 2 Final Fantasy 1 NES programming/hacking related questions
« Reply #9 on: April 08, 2015, 06:36:36 am »
Dude,

I am TOTALLY going to take you up on that. That's really one of the things that I'm so happy about while doing this, is that I'm actually LEARNING something. Whether its an old NES language or not, I'm still learning to do something that I didn't know before. Maybe we could walk through the chest opening idea together and then I could try to use that to make the moving ocean on my own, or whatever you have in mind. I certainly am not going to dictate how I learn something from someone who is willing to help me. Thank you again for being so cool to help an obviously new hacker like me. I really appreciate it. Have a great day.
Tell my tale to those who ask. Tell it truly, the ill deeds along with the good, and let me be judged accordingly. The rest... is silence...

http://www.ffreconstructed.com/
https://www.facebook.com/finalfantasyreconstructed/

Disch

  • Hero Member
  • *****
  • Posts: 2744
  • NES Junkie
    • View Profile
Re: 2 Final Fantasy 1 NES programming/hacking related questions
« Reply #10 on: April 08, 2015, 11:36:36 am »
Quote
Maybe we could walk through the chest opening idea together and then I could try to use that to make the moving ocean on my own,

This is actually a pretty good idea.  The chest opening one requires more overall changes, but is probably slightly easier since you can use more existing code... whereas the animation you pretty much have to write the code from scratch (and there are other constraints that I'll get into later).

Duke2go

  • Full Member
  • ***
  • Posts: 192
    • View Profile
    • Final Fantasy Reconstructed
Re: 2 Final Fantasy 1 NES programming/hacking related questions
« Reply #11 on: April 10, 2015, 01:08:56 am »
Sounds like an excellent plan to me buddy. I had a very unexpected visitor show up and spend a day/evening, so I hadn't had a chance to reply yet. I am incredibly interested in some tutoring, and my friend would like to learn as well if that is alright/possible. I will definitely keep an eye out for when you're online and thank you once again. Have a great weekend.

April 10, 2015, 07:01:35 am - (Auto Merged - Double Posts are not allowed before 7 days.)
I'm probably going to end up spliced into my last post, but I was able to input about 90% of the patches into a clean Final Fantasy rom from the Gamefaqs listings. I had a few issues with a couple of the patches (like somehow got into a never ending loop of 5 imps coming out of Coneria Inn). I was thinking of releasing an ips file that had all of the different patches already applied because the majority of the things are bug fixes. I figured that this would help the next wave of FF1 hackers to NOT have to do the same thing. What I was able to successfully apply was:

Caravan Landing Bug
Developed by anomie

House Bug
Developed separately by anomie and Paulygon

Party Order Sorting Bug
Developed by anomie

Magic Defense Bug
Offsets provided by anomie, explanation, analysis and proposed solution by AstralEsper

HEL2 Effectivity Bug
Developed by anomie

LOCK/LOK2 Bugs not stated but assumed by anomie


Weapon Data Bug
Developed by anomie and Paulygon, with info/disassembly from Alex Jackson


Running Bug
Developed by Alex Jackson

Mute Bug
Developed by anomie

Multiple Level-ups Bug
Developed by anomie

 Enemy Attack Bugs
Developed by Paulygon with info/disassembly and suggested fixes from Alex Jackson

Status Attack Bug
Developed by anomie

Target-All Caster Bug
Developed by anomie

Waking Bug
Developed by anomie, Reposted by Paulygon, Modification Explanation by AstralEsper

 Enemy Suicide Bug
Developed by anomie

Tile Message Byte Data
Developed by anomie

Dialogue Bugs
Developed by AstralEsper
Gaia Spring tiles
Old man Onrac
Sage Dialogue

Door Bug
Developed by anomie

Enemy Miscoloration
Developed by anomie

Black Belt Antheosis
Developed by anomie, with ideas from DragonAtma and AstralEsper

Respond Rate Default
Developed by anomie

Party Order Sorting Prevention
Developed by Paulygon, reposted by Grond

 Buy 10 in Item Shops
Developed by anomie

 Treasure Identification (Can’t hold [Item])
Developed by Zzonkmiles

Item Menu Order Adjustment
Developed by anomie with adjustment by AstralEsper

Potion-Stay Patch
Developed by anomie

 Magic Window Expansion
Developed by Grond

Improved Turn Order Algorithm
Developed by anomie, from observation by Lee Eric Kirwan and suggestion by beege_man

3. Weapon Elemental Enhancement (Note: This Patch Shifts the Evasion Bug Patch, which is required, and included according to Gamefaqs)
Developed by anomie


I'm going to try to implement the 6 letter character names patch too, but I'm a little gunshy after last time. There were a few patches that required zeroing out of code and some levels of hacking that I'm just not at right now. If anyone would like to team up and help to put in the rest of the bugfixes I would be happy to share credit for an ips patch that JUST implemented these changes. Like I said, this would save time with future hacks, and since I've already done most of the legwork, I figured I could give something back.

« Last Edit: April 10, 2015, 07:01:35 am by Duke2go »
Tell my tale to those who ask. Tell it truly, the ill deeds along with the good, and let me be judged accordingly. The rest... is silence...

http://www.ffreconstructed.com/
https://www.facebook.com/finalfantasyreconstructed/

Chpexo

  • Hero Member
  • *****
  • Posts: 731
    • View Profile
.
« Reply #12 on: April 10, 2015, 04:00:13 pm »
.
« Last Edit: January 01, 2016, 10:12:33 am by Chpexo »

Gideon Zhi

  • IRC Staff
  • Hero Member
  • *****
  • Posts: 3509
    • View Profile
    • Aeon Genesis
Re: 2 Final Fantasy 1 NES programming/hacking related questions
« Reply #13 on: April 10, 2015, 04:56:40 pm »
FWIW, if you have IRC, I hang out in #rom-hacking on espernet.  If you want a crash course on 6502 and NES architecture basics, you can pop in.  If I'm around I'll be happy to give mini lessons  (though a lot of times I'm idling/afk)

Is this place even still active at all? I'm in the channel all the time but it's one of the ones I keep minimized because it seemed like it was basically dead-ish 2-3 years ago.

Disch

  • Hero Member
  • *****
  • Posts: 2744
  • NES Junkie
    • View Profile
Re: 2 Final Fantasy 1 NES programming/hacking related questions
« Reply #14 on: April 10, 2015, 05:21:05 pm »
Quote
Is this place even still active at all? I'm in the channel all the time but it's one of the ones I keep minimized because it seemed like it was basically dead-ish 2-3 years ago.

It's not as active as it once was, but setz, DD, Leno, bbit, and a few others have been on there pretty regular.  *shrug*

Nightcrawler

  • Hero Member
  • *****
  • Posts: 5761
    • View Profile
    • Nightcrawler's Translation Corporation
Re: 2 Final Fantasy 1 NES programming/hacking related questions
« Reply #15 on: April 10, 2015, 06:17:27 pm »
You should probably hang out and do your tutoring in #ROMhacking.net instead. :P
TransCorp - Over 20 years of community dedication.
Dual Orb 2, Wozz, Emerald Dragon, Tenshi No Uta, Glory of Heracles IV SFC/SNES Translations

Disch

  • Hero Member
  • *****
  • Posts: 2744
  • NES Junkie
    • View Profile
Re: 2 Final Fantasy 1 NES programming/hacking related questions
« Reply #16 on: April 10, 2015, 09:37:15 pm »
Quote
You should probably hang out and do your tutoring in #ROMhacking.net instead.

You gotta understand, I've been in classic espernet #rom-hacking since the channel was founded -- back the days of DES, Tek, etc.  I think it even predates this site.

I guess I just have a familiarity with it.  =P



Anyway, @Duke2go:  Just to clarify, the official RHDN channel (that Nightcrawler linked to) is not where I am.  I'm on irc.esper.net in #rom-hacking.

And yeah you can totally bring a friend if you want.  I don't care.

JCE3000GT

  • Sr. Member
  • ****
  • Posts: 433
    • View Profile
Re: 2 Final Fantasy 1 NES programming/hacking related questions
« Reply #17 on: April 10, 2015, 09:52:10 pm »
You two are bring back the way back machine!  How long since I was on those channels.  What channel did ZD use all those years ago on esper.net?  It's been too long.