Phantasy Star II Hacking Questions

Discuss anything related to the Phantasy Star series

Phantasy Star II Hacking Questions

Postby lorenzo » Mon Feb 02, 2015 2:12 pm

Here you can ask any questions related to hacking Phantasy Star II. If you' re interested, grab a copy of the disassembly on RHDN. I also have a thread with all the links that you need:

http://www.pscave.com/forums/viewtopic.php?f=6&t=3415
lorenzo
Blastoid
Blastoid
 
Posts: 92
Joined: Thu Dec 25, 2014 12:57 am
Location: Italy

Re: Phantasy Star II Hacking Questions

Postby The PS Logo » Wed Feb 04, 2015 6:19 am

Is there enough empty space to add in 1 or 2 TP restoring items to the game?
Image
User avatar
The PS Logo
Blastoid
Blastoid
 
Posts: 104
Joined: Sun Sep 09, 2007 2:10 am

Re: Phantasy Star II Hacking Questions

Postby lorenzo » Wed Feb 04, 2015 10:36 am

Yeah, there are exactly two spots at the end of the InventoryData which have some data like name and meseta cost, but they were given no functionality. I labelled them Item_Unknown1 and Item_Unknown2 and they have ID's 0x7E and 0x7F respectively. Define the properties you want for the items you want here. Then go to the ps2.constants.asm file and the ID constants for these two items: they are ItemID_Unknown1 and ItemID_Unknown2. Simply replace them with the names you put in the InventoryData (for convenience of course, you're not forced to =) ). This is a way to have descriptive names instead of numbers so they are much easier to remember and use.

Now you need to add functionality to them. Go to the label ItemAction_UseEntry. This is the whole logic for the moment you select the USE command on the menu. Search for these lines of code a little down from that label:

Code: Select all
   cmpi.w   #ItemID_NeiSword, d0
   beq.w   NeiSword_ItemSelected
   cmpi.w   #ItemID_Teim, d0
   beq.w   Teim_ItemSelected
   cmpi.w   #ItemID_Visiphone, d0
   beq.w   Visiphone_ItemSelected


Add a compare instruction that tests if the items you created were used. So it could be something like

Code: Select all
   cmpi.w   #$7E, d0
   beq.w   MyItem_ItemSelected
   cmpi.w   #$7F, d0
   beq.w   MyItem2_ItemSelected


Replace the $7E and $7F with the ID you put for those two items. Give a name you want instead of MyItem_ItemSelected... It was an example of course. Since you said you wanted TP restoring items, you can have code branch to the ItemAction_Monomate routine and then add a check to see which item was used.

You need to add functionality for items used in battle as well. Go to the routine CommandUsed_Item which is the logic for the items used in battle. Whenever an item is chosen, the ID of that item will be put in a register as a variable for the technique process. Basically item use is the same as technique use, only the logic will slightly change according to which command was used. For your TP items, do the same as you did for the item use on the level (or map) screen. Have it branch to monomate and let it process the Res technique, but make sure you check which item was used in this case as well. I think I put comments explaining how HP value for your characters is affected. Do the same thing but with TP obviosuly.

Now you need to make these items accessible in some way. Here are the options available for where to include them:

- Initial equipment. This is the section dealing with this logic: CharInitialSetup. I added a small tutorial on how to change initial items.
- Stores. The start label for this part is StoreEquipItemArray
- Stealing. There's a table of possible items Shir can steal. Here's the starting label: StealItemArray
- Treasure Chests. Here's the table for the treasure chests: TreasureChestContentArray. The process for this is more involved if you want to add new treasure chests because you need edit the object table when loading a level.

I could've missed something. Let me know if it's not clear or you are having trouble.
lorenzo
Blastoid
Blastoid
 
Posts: 92
Joined: Thu Dec 25, 2014 12:57 am
Location: Italy

Re: Phantasy Star II Hacking Questions

Postby Parma Ham » Thu Feb 05, 2015 12:35 am

I've been trying to figure out how PS2 calculates the number of steps your party has to take before you enter a random battle. Apparently that's not how the game works:

Code: Select all
loc_117C6:
   jsr   (GenerateRandomNumber).l  ;PUT A PSEUDO-RANDOM NUMBER IN d0
   ...
   move.w    (enemy_data_buffer+$C).w, d1  ;PUT SOME VALUE IN d1 (HAVEN'T FIGURED OUT THE SIGNIFICANCE OF THIS YET)
   lsr.w           #3, d1   ;SHIFT THE VALUE IN d1 (I ASSUME WE'RE TRYING TO DIVIDE HERE)
   cmp.w   d1, d0   ;COMPARE THE LOW WORD IN d1 TO THE ONE IN d0
   bcc.s   +               ;IF d0 IS  >=  d1, THEN SKIP TO THE "+" LABEL AND DON'T ENTER A BATTLE
   ...
   move.b   #ScreenID_Battle, (game_screen).w   ;IF WE REACH THIS POINT, WE'LL ENTER A RANDOM BATTLE -- COMMENT THIS LINE OUT TO PREVENT RANDOM BATTLES FROM HAPPENING
+
   rts


So if I'm understanding this correctly, the possibility of entering a battle is calculated at random every time you take a step? So there's no step counter at all.
Last edited by Parma Ham on Thu Feb 12, 2015 10:07 pm, edited 1 time in total.
Parma Ham
 

Re: Phantasy Star II Hacking Questions

Postby lorenzo » Thu Feb 05, 2015 11:59 am

There's a flag which gets set when you move (either characters or jet scooter). This is done at location $FFFFCB0A. You can see this write to this address in the Obj_CharactersInLevel and Obj_JetScooter sections. When the code processes the random battles routine, it checks the value at this location: if it's 0, it returns, otherwise it will continue with the whole logic. Yeah, there's no step counter, but you can change the randomness inside this routine. The (enemy_data_buffer+$C).w is only used in this routine and, like you showed in the code snippet, it's compared to the RNG. Before the comparison, the value stored in (enemy_data_buffer+$C).w is divided by 8. Try to trace the value of this variable inside the routine.

I noticed that I didn't change one $FFFFCB0C.w to (enemy_data_buffer+$C).w. It's a little down from where the LevelScreen starts... The value is set to 0 to have the lowest chance of entering random battles from the moment you change map. However the value at this address is affected only in the random battle routine

I got some stuff figured out about the randomness of battles, but I put only a few comments in it, so I'll see if I can help with understanding some variable use or else, if possible.
lorenzo
Blastoid
Blastoid
 
Posts: 92
Joined: Thu Dec 25, 2014 12:57 am
Location: Italy

Re: Phantasy Star II Hacking Questions

Postby Parma Ham » Thu Feb 05, 2015 5:03 pm

.
Last edited by Parma Ham on Thu Feb 12, 2015 10:04 pm, edited 1 time in total.
Parma Ham
 

Re: Phantasy Star II Hacking Questions

Postby lorenzo » Thu Feb 05, 2015 10:09 pm

I put some comments regarding sound ID's used when you fall into pits or change map.

Code: Select all
   move.b   #$A5, (sound_to_play).w         ; play "Fell in pit" sound


The code around that line is where the logic of changing maps happens. You will see lines such as moving values to the level_index or something else related to them. The same goes for changing levels by going up or down the stairs.

It also helps if you start search from the LoadLevelData label and will see all level data loaded in different RAM addresses... Trace the values of these addresses and see how they are used. I know it's kind of long and tedious process, but it's the best way to get familiar with the engine.
lorenzo
Blastoid
Blastoid
 
Posts: 92
Joined: Thu Dec 25, 2014 12:57 am
Location: Italy

Re: Phantasy Star II Hacking Questions

Postby The PS Logo » Tue Mar 10, 2015 10:58 pm

Oh... uhhh... I'm not a hacker Wasn't aware this was for hackers only
Image
User avatar
The PS Logo
Blastoid
Blastoid
 
Posts: 104
Joined: Sun Sep 09, 2007 2:10 am


Return to Phantasy Star

Who is online

Users browsing this forum: No registered users and 8 guests