Author
|
Topic: FFIVET ASM Assistance (Read 2 times)
|
DarknessSavior
Guest
|
|
« on: January 03, 2008, 01:54:03 pm » |
|
I've been working on the physical limitations that FFIVET presents as far as Equipment display goes. I upped the fixed length limit from 8 to 10 (and I eventually want to throw a linebreak in there, raising it to 20, but that's not what I need help with). The routine is fairly simple once you look at it a bit. It will take a value from a table, do some math to it, and use that value to determine where to load from. Here's an example: $01/9023 A5 43 LDA $43 [$00:0143] A:A640 X:0064 Y:0033 D:0100 DB:7E S:02E3 P:eNvmxdIzcHC:0492 VC:136 00 FL:09 $01/9025 0A ASL A A:0016 X:0064 Y:0033 D:0100 DB:7E S:02E3 P:envmxdIzcHC:0524 VC:136 00 FL:09 $01/9026 0A ASL A A:002C X:0064 Y:0033 D:0100 DB:7E S:02E3 P:envmxdIzcHC:0538 VC:136 00 FL:09 $01/9027 0A ASL A A:0058 X:0064 Y:0033 D:0100 DB:7E S:02E3 P:envmxdIzcHC:0552 VC:136 00 FL:09 $01/9028 65 43 ADC $43 [$00:0143] A:00B0 X:0064 Y:0033 D:0100 DB:7E S:02E3 P:envmxdIzcHC:0566 VC:136 00 FL:09 $01/902A AA TAX A:00C6 X:0064 Y:0033 D:0100 DB:7E S:02E3 P:envmxdIzcHC:0598 VC:136 00 FL:09 16 is the value for "Darkness Sword", it grabs that, does that bit of math, and then the Y value (64 after those) is used to determine the location. However, that routine limits itself to the 9 spaces (8 characters and the icon for the item). So after talking to DMM, it was decided that simply turning that ADC into two extra ASL As would increase the amount to 32 per entry (though I can edit the fixed length routine to stop after the 10 or 20 characters, then skip to the next 32 character entry, get it?). It all works, wonderfully. However, for some strange reason, the weapons are loading one entry too high. For example, instead of Cecil starting with the "Dark Sword" he starts with the "Rune Staff", but it's stats are the same as the Dark Sword. Here's a screenshot to show: http://dsrh.hokuten.net/ffivexp1.pngIs there anything that could cause that (note, the items, weapons, armor, etc... they all use the SAME routine)? I'm kinda lost there. I checked a trace of the original, the expanded original, and the asm alterations. All the same. Edit: I forgot to show the edited code. $01/9023 A5 43 LDA $43 [$00:0143] A:A640 X:0164 Y:0030 D:0100 DB:7E S:02E3 P:eNvmxdIzcHC:0938 VC:122 00 FL:03 $01/9025 0A ASL A A:006E X:0164 Y:0030 D:0100 DB:7E S:02E3 P:envmxdIzcHC:0970 VC:122 00 FL:03 $01/9026 0A ASL A A:00DC X:0164 Y:0030 D:0100 DB:7E S:02E3 P:envmxdIzcHC:0984 VC:122 00 FL:03 $01/9027 0A ASL A A:01B8 X:0164 Y:0030 D:0100 DB:7E S:02E3 P:envmxdIzcHC:0998 VC:122 00 FL:03 $01/9028 0A ASL A A:0370 X:0164 Y:0030 D:0100 DB:7E S:02E3 P:envmxdIzcHC:1012 VC:122 00 FL:03 $01/9029 0A ASL A A:06E0 X:0164 Y:0030 D:0100 DB:7E S:02E3 P:envmxdIzcHC:1026 VC:122 00 FL:03 $01/902A AA TAX A:0DC0 X:0164 Y:0030 D:0100 DB:7E S:02E3 P:envmxdIzcHC:1040 VC:122 00 FL:03 Before someone jumps in and goes "The X values are different!" it's because it's loading the "Darkness Helm". ~DS
|
|
« Last Edit: January 03, 2008, 02:11:42 pm by DarknessSavior »
|
|
|
|
DaMarsMan
Guest
|
|
« Reply #1 on: January 03, 2008, 02:44:03 pm » |
|
Your original routine was doing ADC without a CLC before it. So it was 1 off. Jump to a different aread and do your math (don't overwrite code) then do a SEC and SBC #$0001.
|
|
|
|
DarknessSavior
Guest
|
|
« Reply #2 on: January 03, 2008, 03:26:03 pm » |
|
I'll try it, but it doesn't make sense to me. The ADC being off wouldn't affect the original weapon that's loaded (the 16, which is the number for Dark Sword), it would just make it be $01 off.
~DS
|
|
|
|
Disch
Guest
|
|
« Reply #3 on: January 03, 2008, 03:49:02 pm » |
|
I'm sure you must've made other edits besides what you posted here -- I'm wagering the error is in one of those areas, since what you show here is really straightforward and I don't see anything wrong with it.
The first thing that comes to my mind is your index is one off. From the looks of it, this would be the value at $00:0143. You said you're taking that value from a table? Perhaps you're taking the wrong value now?
|
|
|
|
DaMarsMan
Guest
|
|
« Reply #4 on: January 04, 2008, 08:56:56 am » |
|
I thought by one off you meant 1 character off. If it's a whole item index off then you got another problem.
|
|
|
|
Gemini
Guest
|
|
« Reply #5 on: January 04, 2008, 09:44:39 am » |
|
Just throw in the pointer system I gave you. :p
|
|
|
|
DaMarsMan
Guest
|
|
« Reply #6 on: January 04, 2008, 10:15:09 am » |
|
Forget about the ADC thing. Your calculations are correct unless your index is 16 per item. I'm pretty sure you made it 32 though. Basically your other value is off some. The LDA $XXXX,x that loads the characters with x. So just adjust that first constant number until it is the right value. Then, if the other items line up also you got it.
|
|
|
|
Kejardon
Guest
|
|
« Reply #7 on: January 04, 2008, 01:21:15 pm » |
|
Your original routine was doing ADC without a CLC before it. So it was 1 off. Jump to a different aread and do your math (don't overwrite code) then do a SEC and SBC #$0001.
So long as the number doesn't overflow during the ASL's, they'll clear carry for the ADC. I do stuff like that all the time to save a few bytes and cycles here and there. As for the problem though, Disch is most likely right. Glancing at the Japanese rom (I have no idea why I have it on my computer, but I do), you must at least be moving the name table and not just expanding it, since the space after it is taken. And if it only messes up on the weapon slot, then the problem would be in the code that gets the index number for the weapon.
|
|
|
|
DarknessSavior
Guest
|
|
« Reply #8 on: January 05, 2008, 11:54:46 am » |
|
Yeah, I moved the table into expanded space.
The only other thing I've done thus far, besides changing the math section of that routine, is change the routine for loading the items themselves, and only by one instruction.
Originally there was an LDA #$08 that would be stored somewhere to determine the length of each item. I changed it to LDA #$0A for 10 characters instead of 8. Other than that, I've done nothing.
And the strange thing still is, if this were a problem with my ASM, it would effect everything since it uses the same routine. It wouldn't just screw the weapons list up. >.>
Anyone else have any ideas?
~DS
|
|
|
|
Nightcrawler
Guest
|
|
« Reply #9 on: January 05, 2008, 12:28:51 pm » |
|
Anyone else have any ideas?
Yeah. Get down and dirty with a trace log and figure out what is supposed to happen and what is now happening after your modification. You need to learn to figure out your own bugs. It's a critical skill to successful ROMhacking. Make a trace log of the original game's routine and then make another one with your yours. Check some key code spots of your choosing and compare between the two. You'll find somewhere along the line your code causes a wrong value. When you find that, you can find the source of the problem. You may not even need a trace log. Just get a few key breakpoints and test on both original and modified versions of the ROM.
|
|
|
|
DaMarsMan
Guest
|
|
« Reply #10 on: January 05, 2008, 12:49:56 pm » |
|
Nightcrawler is right. We don't solve our own problems through critical thinking alone. We use trace files. They explain everything.
|
|
|
|
Tauwasser
Guest
|
|
« Reply #11 on: January 05, 2008, 03:43:12 pm » |
|
Umm... Did you try this: Break when it derives the length to go, then manually added that to your starting address of the item table and then read what it says there? Maybe your table pointer is off for some reason?
cYa,
Tauwasser
|
|
|
|
DarknessSavior
Guest
|
|
« Reply #12 on: January 07, 2008, 08:03:31 am » |
|
I figured it out. Always the stupidest simple solutions. :banghead: :banghead: :banghead:
I dumped the fixed item list using WindHex (yeah, I should've used one of the other tools. I usually do, but I felt lazy the day I did it. Never, ever again!). For some reason, it didn't include the blank entry between the last weapon and first piece of armor. Once I included that, everything worked just fine.
However, I'm still having the empty equipment space trouble. I figured out more about the routine and I found that the place where the first entry ($00) is should be blank for that to work correctly. That address is $227FE0 (SNES format), but when I try to use Geiger to go to that address, it takes me to $22FFE0. I threw in 32 spaces, and reloaded the game. Blank equipment spaces worked fine. However, when I saved the ROM, and tried it in ZSNES, it came up all screwed up again.
This time, it seems that it is an error caused by expansion. How do I go about fixing something like this? Should I try moving the item list location around until I find a space that won't be overwritten at reset?
~DS
|
|
|
|
Nightcrawler
Guest
|
|
« Reply #13 on: January 07, 2008, 09:35:00 am » |
|
$227FE0? Umm.. that's not mapped to the cartridge. You can't use that. You didn't relocate anything to that location as nothing from your ROM file will be mapped there. You can only use $228000 and above in that bank. Judging by the address you just posted, your game is LoROM and is mapped in 32K chunks from bank $00 onward at XX:8000. Long story short, that's an invalid address. Try using Lunar Address to help out figuring out where your relocated data actually is. Then, read a few mapper documents: http://www.romhacking.net/docs/193/http://www.romhacking.net/docs/173/It will probably be a bit overwhelming at first. Especially Anomie's document. But you'll catch on after working with it.
|
|
|
|
DaMarsMan
Guest
|
|
« Reply #14 on: January 07, 2008, 09:56:21 am » |
|
You should have started with your first index being the blank one. Then you wouldn't have to move this base index back like that. Anyways, I'm pretty sure you are looking for 22FFE0 so it will loop back around. I would suggest moving all your items up 1 index and just setting that to 228000. That's the way it should have been done in the first place.
|
|
|
|
|