****************************************************
* PART 16: ANATOMY OF THE CODE:  FINAL FANTASY III *
****************************************************

<16.1> Introduction-----------------------------------------------------------   

I have done most of my code-creating work with the Final Fantasy III game
by Squaresoft.  What follows is the results of lots and lots and lots of 
guessing.


<16.2> Memory Address Positions-----------------------------------------------   

* Positions 6 and 7:
	Alter these positions in a pre-existing code to change its effect
slightly.  Sometimes, you can end up with an entirely different code
by changing the sixth character, however.
	The most common values for these positions are D, 0, 6, and A for
position 7 and D, F, 4, 7 for position 6.

EX:       CE17-77D6  Learn spells at 5x rate
          CE17-7DD6  Gain every 4th rage on the right hand side of
                      Gau's list after one battle; screw up configuration
		
          59A3-846D  Enables entire Veldt cycle, plus some bosses
          59A3-8FDD  Only run into enemies from Kefka's Tower on the Veldt.
	    
* Positions 3 and 4:
     A good way to create codes is to take a common ending (-XXXX) and a
     constant value (first 2 characters -- AA seems to work well for a
     constant) and experiment by changing the third and fourth characters.

     AA00-54D8  Mimic enemies' last action
     AA88-54D8  Changes battle music
     AA23-54D8  16,777,216 experience pts. per fight
     AA2D-54D8  Act weirdly in battle

     ENDINGS TO TRY:  
     ---------------
        IN BATTLE:   -54D8, -54DB, -E4D8, -E4DB, -8D68, -84D8, -84DB,
                     -77D6, -E7D6, -57D6, -54A6, -54D6, -EFDB, -E768.
        ON MENU:     -5F63, -5D03, -5DAE, -EF63, -8F63
        ON MAP:      -740D, -74AD, -746D, -770D, -77AD
	
* Position 5:
   This is usually 7, 5, 8, or E.  Changing this to one of the other three
   characters from a pre-existing code will usually create a new, different
   code.  THIS METHOD IS OFTEN OVERLOOKED AND CAN RESULT IN SOME GREAT NEW
   CODES!!  I found the Enemy Spells Code (**00-8D68) this way.

* Position 8:
   Changing this will alter the broad area of the game which your code
   affects:

                               ------------------------------------------
                               D, F, 4, 7 = Affects the map screen &
                                             walkabout graphics for
                                             characters
                               0, 9, 1, 5 = Miscellaneous (varies greatly)
                               6, B, C, 8 = Affects mechanics of battle;
                                              what happens after battle;
                                              menu screens in battle
                               A, 2, 3, E = Affects out-of-battle menu 
                                              screens (e.g. equip, item,
                                              stores)

     Try changing the 8th digit to another in its group for a new code
     which affects the same area of the game.

     Example:     2624-EFD8   Glitchy menu screen in battle
                  2624-EFDB   Cast any spell on any target


<16.3> Disassembling a Code---------------------------------------------------   

Let's take the code xx00-8D68, which replaces Strago's Lores with various
attacks from the game.

We can learn a number of things from this code:

1.  The memory address at which the commands for executing Strago's
    Lores are kept:
    xx00-8D68 ---> straight hex xx44-B08B ---> memory address 025042:xx

    Look at this memory address in a Hex Editor and you will see that it is
    set to "8B".  This is because 8Bh (139) is the index number for the
    "Condemned" spell, the first spell on Strago's list.

2.  The spells are stored in a certain order, and each spell in the game has 
    an index number.  Replacing xx with that index number will result in 
    Strago's lore list starting with that numbered spell and including the 
    next 23.
      Example:  Index number of "oFire     " = DD (00h,   0 dec)
                                "oIce	   " = DF (01h,   1 dec)
                                "oBolt     " = D4 (02h,   2 dec)
                                "Condemned " = 68 (8Bh, 139 dec) 
                                "Absolute 0" = 88 (BBh, 187 dec)
                                "Engulf    " = 29 (D5h, 213 dec)
                                "Imp Song  " = C7 (A3h, 163 dec)
                                "Fallen One" = AD (C0h, 192 dec).

3.   ANALYSIS OF THE CODE:
     Positions 1 & 2:  xx sets the value for the memory address 025042h.
     Position 8:  The "8" tells the code to affect the part of the ROM
                  that controls battle, or the results of a battle
     Position 3:  The "0" directs the code pointer to the MAGIC-TYPE MENU
                  area of the memory.
     Positions 4 & 5:  These zero in on the LORE menu in the memory.
     Positions 6 & 7:  These affect the addresses that tell the game HOW
                       to handle the selection of a Lore (cast a spell).
                       Changing these can result in different things
                       happening when you select a Lore (e.g., execute a
                       physical attack, screw up battle, black out game).