Users browsing this thread: 1 Guest(s)
Learning Magic

#11
Posts: 763
Threads: 83
Thanks Received: 55
Thanks Given: 7
Joined: Apr 2015
Reputation: 22
Status
Obliviscence
Well, I may be tapping all of you for info over the next several months as I am beginning a major hack that has been in the planning process for something like 12 years. Having just now discovered this site I finally feel I have all the tools I need.

Thanks a ton for the disassemblies!
  Find
Quote  

#12
Posts: 3,970
Threads: 279
Thanks Received: 236
Thanks Given: 58
Joined: Oct 2011
Reputation: 65
Status
Tissue-aware
  Find
Quote  

#13
Posts: 763
Threads: 83
Thanks Received: 55
Thanks Given: 7
Joined: Apr 2015
Reputation: 22
Status
Obliviscence
Ok, so this is what I have so far... I think I need a little help understanding the accumulator and RAM operations.

Code:
C3/50A2:    85E0        STA $E0
C3/50A4:    20DD4E      JSR $4EDD
C3/50A7:    B90000      LDA $0000,Y
----------this is where my code starts-------------------------
C3/50AA:   8D0442      STA $4204  (Divider A)
C3/50AD:   A90C         LDA #$0C (12)
C3/50AF:   8D0542      STA $4205  (Divider B)
C3/50B2:   AD1642      LDA 4216    (MathValue Math coprocessor's result. Remainder for Divisions)
----------this is where my code ends-------------------------
C3/50XX:    8D0242      STA $4202
C3/50XX:    A936        LDA #$36
C3/50XX:    8D0342      STA $4203
C3/50XX:    7B          TDC
C3/50XX:    A5E0        LDA $E0
C3/50XX:    C220        REP #$20      (16 bit memory/accum.)
C3/50XX:    6D1642      ADC $4216
C3/50XX:    AA          TAX
C3/50XX:    E220        SEP #$20      (8 bit memory/accum.)
C3/50XX:    BD6E1A      LDA $1A6E,X
C3/50XX:    60          RTS

**I am overwriting Gogo's code, its not going to get used anyway.**

So what I am expecting to happen is for it to use the remainder of the actor/12 (#$0C) to determine what spell to look at, not the raw actor number. The result I am actually getting is all of my actors are seeing the same random magic percentages, when I scroll down the list in the menu and come back up, some of the values disappear, while others change value.

I'm still new to assembly code and I think I have some fundamental misunderstanding of the registers, accumulator, and RAM. Since the values change when I move around, does that mean the numbers aren't staying consistent in the accumulator, if so, why would that be? Also, $4216 in the RAM is used for both the product of multipliers and the remainder from division... this code uses both, so if I have values in $4202, $4203, $4204, and $4205; what number would I expect to see in $4216? And finally, what is the difference between "MathValue" and "MathValue!" ?
  Find
Quote  

#14
Posts: 290
Threads: 3
Thanks Received: 40
Thanks Given: 1
Joined: Apr 2012
Reputation: 9
Status
None
The first thing I see is that you're inserting more bytes than you're overwriting, which can cause a multitude of issues. This is likely what's causing you to see constantly changing values as you scroll up and down the magic list. I'm actually rather surprised you haven't seen a complete game crash yet.

What you'll need to do to insert code is, in this case, overwrite Gogo's code with a JSR (Jump to SubRoutine) to some free space, where you'd then write your custom function. Conveniently, the code you're overwriting is four bytes, which is the same size as a JSR. The free space in bank C3 starts at $C3F091 and continues to the end of the bank, or $C3FFFF. Don't forget the RTS (Return To Subroutine) at the end.

Secondly, it doesn't seem any operations are actually being performed on your data. All you're doing is loading data into the accumulator and storing it in RAM locations, but nothing's being done with it afterward. From what I could gather, you're trying to make one magic list shared amongst all the characters, is that right?

Quote:And finally, what is the difference between "MathValue" and "MathValue!" ?

No idea. What assembler are you using/where are you seeing that?


GET A SILK BAG FROM THE GRAVEYARD DUCK TO LIVE LONGER.

Brave New World
  Find
Quote  

#15
Posts: 763
Threads: 83
Thanks Received: 55
Thanks Given: 7
Joined: Apr 2015
Reputation: 22
Status
Obliviscence
(07-05-2012, 09:05 PM)Synchysi Wrote: The first thing I see is that you're inserting more bytes than you're overwriting, which can cause a multitude of issues. This is likely what's causing you to see constantly changing values as you scroll up and down the magic list. I'm actually rather surprised you haven't seen a complete game crash yet.

What you'll need to do to insert code is, in this case, overwrite Gogo's code with a JSR (Jump to SubRoutine) to some free space, where you'd then write your custom function. Conveniently, the code you're overwriting is four bytes, which is the same size as a JSR. The free space in bank C3 starts at $C3F091 and continues to the end of the bank, or $C3FFFF. Don't forget the RTS (Return To Subroutine) at the end.

The code immediately following this code is the code that populates Gogo's magic list, which is not accessible any longer, so I'm not changing the rom size. I'm not quite that newbish. However, I never looked to see if there was a jump into the middle of the code, which could now be off.

(07-05-2012, 09:05 PM)Synchysi Wrote: Secondly, it doesn't seem any operations are actually being performed on your data. All you're doing is loading data into the accumulator and storing it in RAM locations, but nothing's being done with it afterward. From what I could gather, you're trying to make one magic list shared amongst all the characters, is that right?

I am making all actors share the same 12 lists. I am using the RAM map which tells what each address was for. I guess I assumed that if I plugged in the divider values it would automatically put the results in the product/remainder address. Come to think of it, I did see a subroutine in the C2 bank dealing with multiplication and division... I just don't remember seeing it used here in the existing code.

  Find
Quote  

#16
Posts: 290
Threads: 3
Thanks Received: 40
Thanks Given: 1
Joined: Apr 2012
Reputation: 9
Status
None
(07-05-2012, 09:32 PM)Edrin Wrote:
(07-05-2012, 09:05 PM)Synchysi Wrote: The first thing I see is that you're inserting more bytes than you're overwriting, which can cause a multitude of issues. This is likely what's causing you to see constantly changing values as you scroll up and down the magic list. I'm actually rather surprised you haven't seen a complete game crash yet.

What you'll need to do to insert code is, in this case, overwrite Gogo's code with a JSR (Jump to SubRoutine) to some free space, where you'd then write your custom function. Conveniently, the code you're overwriting is four bytes, which is the same size as a JSR. The free space in bank C3 starts at $C3F091 and continues to the end of the bank, or $C3FFFF. Don't forget the RTS (Return To Subroutine) at the end.

The code immediately following this code is the code that populates Gogo's magic list, which is not accessible any longer, so I'm not changing the rom size. I'm not quite that newbish. However, I never looked to see if there was a jump into the middle of the code, which could now be off.

I'm seeing Gogo's code jump to a different place, then come back to that code block. What you replaced seems to be shared, while the code exclusive to Gogo is lower in the bank.

Code:
C3/50AC:    F017        BEQ $50C5     (Branch if it's Gogo)

jumps to...

Code:
C3/50C5:    64E1        STZ $E1       ($E1 = #$00)
C3/50C7:    7B          TDC           (A = #$0000)
C3/50C8:    A5E1        LDA $E1       (A = $E1)
C3/50CA:    C528        CMP $28
C3/50CC:    F014        BEQ $50E2
C3/50CE:    0A          ASL A
C3/50CF:    AA          TAX
C3/50D0:    B46D        LDY $6D,X
C3/50D2:    F00E        BEQ $50E2
C3/50D4:    B90000      LDA $0000,Y    (load character ID)
C3/50D7:    C90C        CMP #$0C
C3/50D9:    B007        BCS $50E2      (Branch if it's Gogo or higher)
C3/50DB:    20AE50      JSR $50AE
C3/50DE:    C9FF        CMP #$FF
C3/50E0:    F009        BEQ $50EB
C3/50E2:    E6E1        INC $E1
C3/50E4:    A5E1        LDA $E1
C3/50E6:    C904        CMP #$04
C3/50E8:    D0DD        BNE $50C7
C3/50EA:    7B          TDC
C3/50EB:    60          RTS

That then returns to the JSR it came from, wherever that may be. What you could do is change the BEQ above to JSR, then start your custom code at $C350C5.

Quote:
(07-05-2012, 09:05 PM)Synchysi Wrote: Secondly, it doesn't seem any operations are actually being performed on your data. All you're doing is loading data into the accumulator and storing it in RAM locations, but nothing's being done with it afterward. From what I could gather, you're trying to make one magic list shared amongst all the characters, is that right?

I am making all actors share the same 12 lists. I am using the RAM map which tells what each address was for. I guess I assumed that if I plugged in the divider values it would automatically put the results in the product/remainder address. Come to think of it, I did see a subroutine in the C2 bank dealing with multiplication and division... I just don't remember seeing it used here in the existing code.

How is you're trying to go about doing that? If I knew what you had in mind I might be able to help a bit better.


GET A SILK BAG FROM THE GRAVEYARD DUCK TO LIVE LONGER.

Brave New World
  Find
Quote  

#17
Posts: 763
Threads: 83
Thanks Received: 55
Thanks Given: 7
Joined: Apr 2015
Reputation: 22
Status
Obliviscence
(07-05-2012, 10:33 PM)Synchysi Wrote: I'm seeing Gogo's code jump to a different place, then come back to that code block. What you replaced seems to be shared, while the code exclusive to Gogo is lower in the bank.

Code:
C3/50AC:    F017        BEQ $50C5     (Branch if it's Gogo)

jumps to...

Code:
C3/50C5:    64E1        STZ $E1       ($E1 = #$00)
C3/50C7:    7B          TDC           (A = #$0000)
C3/50C8:    A5E1        LDA $E1       (A = $E1)
C3/50CA:    C528        CMP $28
C3/50CC:    F014        BEQ $50E2
C3/50CE:    0A          ASL A
C3/50CF:    AA          TAX
C3/50D0:    B46D        LDY $6D,X
C3/50D2:    F00E        BEQ $50E2
C3/50D4:    B90000      LDA $0000,Y    (load character ID)
C3/50D7:    C90C        CMP #$0C
C3/50D9:    B007        BCS $50E2      (Branch if it's Gogo or higher)
C3/50DB:    20AE50      JSR $50AE
C3/50DE:    C9FF        CMP #$FF
C3/50E0:    F009        BEQ $50EB
C3/50E2:    E6E1        INC $E1
C3/50E4:    A5E1        LDA $E1
C3/50E6:    C904        CMP #$04
C3/50E8:    D0DD        BNE $50C7
C3/50EA:    7B          TDC
C3/50EB:    60          RTS

That then returns to the JSR it came from, wherever that may be. What you could do is change the BEQ above to JSR, then start your custom code at $C350C5.

I took everything from C0C5 and up and moved it down a little to make the room, but, like you said, if something jumps into the middle of the block instead of the beginning, then that could be causing some display inconsistencies.

(07-05-2012, 10:33 PM)Synchysi Wrote: How is you're trying to go about doing that? If I knew what you had in mind I might be able to help a bit better.
Instead of using the actor # to determine the spell list offset, I want to use the remainder of the actor number divided by 12, which should only produce numbers 0-11. So actors 0 through 11(0B) use their own magic as always, actor 12(0C) would used the same magic list as actor 0 (0C/0C has a remainder of 0), actor 13(0D) would use the same magic list as actor 1 (0D/0C has a remainder of 1), etc... this should make every actor reuse the same twelve lists over and over again allowing me to put magic on Leo, for instance, and have it work, even if it is shared.

  Find
Quote  

#18
Posts: 763
Threads: 83
Thanks Received: 55
Thanks Given: 7
Joined: Apr 2015
Reputation: 22
Status
Obliviscence
Got it working, I just did the math directly to the accumulator rather than relying on the RAM values. I will post it once I get it changed in battle too in case anyone else is interested.
  Find
Quote  

#19
Posts: 763
Threads: 83
Thanks Received: 55
Thanks Given: 7
Joined: Apr 2015
Reputation: 22
Status
Obliviscence
Finally got Magic working 100%. Battle, Menu, Learning from espers and equips... the only hiccup I see is characters above actor 0B won't be able to uncurse the cursed shield, not really planning to fix it ATM. I overwrote Gogo's magic in order to make this. If anyone else is interested in putting magic on any character, let me know so I can make a patch out of it.

Actors above 0B will share the magic lists with one of the other characters. Notable actors who can now learn Magic:
-Gogo shares a magic list and learning with Terra.
-Umaro shares a magic list and learning with Locke.
-Bannon shares a magic list and learning with Cyan.
-Leo shares a magic list and learning with Shadow.
-Wedge shares a magic list and learning with Relm.
-Vicks shares a magic list and learning with Setzer.
-Kefka shares a magic list and learning with Sabin, Celes, Strago, Relm, or Setzer (depending on which instance of Kefka is used).
  Find
Quote  

#20
Posts: 2,769
Threads: 88
Thanks Received: 24
Thanks Given: 87
Joined: Jun 2009
Reputation: 25
Status
None
nice

this will actually help Nattak out


"Sometimes ninjas do wrong to each other, and in dat way the force of tha earf' comes around da moon - and at that presence, da dirt, it overshadows the grass, so you're like, I can't cut dis grass, there's no sun comin' through. So in order to enable each other the two fruits have to look each other in da eye and understand we can only be right, as da ripe is wrong, you know what I mean?"

-HNIC
Quote  



Forum Jump:

Users browsing this thread: 1 Guest(s)


Theme by Madsiur2017Custom Graphics by JamesWhite