Author Topic: kof98 ratio  (Read 32289 times)

Offline bankbank

  • Newbies
  • *
  • Posts: 32
  • Karma: +3/-0
kof98 ratio
« on: September 03, 2021, 08:23:44 AM »
just beginning this hack. need to analyze the aes version since that p rom is unencrypted.
found this memory map: https://www.chibiakumas.com/68000/neogeo.php
so we can see there
Code: [Select]
BIOS_P1STATUS $10FD94 (byte) Controller 1 statusin MAME debugger I use the command "wp 10FD94,1,rw,wpdata!=00" (if leaving off the wpdata!=00 it will always trigger, I only want it to trigger when I press a button)
so after I pressed button 1 (start didn't trigger the wp), I see "stopped at watchpoint reading 0010 from 0010FD94 (PC=C185E4)
so I know that 0x0010FD94 is probably where the game will store player 1's input. and now I have a PC to check out in ghidra for some decompilation.

Offline bankbank

  • Newbies
  • *
  • Posts: 32
  • Karma: +3/-0
Re: kof98 ratio
« Reply #1 on: September 03, 2021, 08:54:39 AM »
so I stopped at that watchpoint and got a PC for me to disassemble in ghidra. when I got to that address in ghidra and pressed 'd', it was disassembling incorrectly offset by 1. 68k CPU is big-endian and I was importing it as such, so I guess when MAME runs the game kof98h it runs it as little endian. not exactly sure what the exact explanation is, but anyway I used this program to swap endianness
http://forum.arcadecontrols.com/index.php?topic=93984.0

and now the file can be disassembled properly. so now I will combine the input watchpoint with ghidra to determine what code is run when a player presses a button to select a character. that's where the injection will go of new code to check if the player has enough points to take that character.

note that the below screenshot is of the PC stopped at vblank - it's not the area of code I'm interested in modifying right now.
« Last Edit: September 03, 2021, 08:56:04 AM by bankbank »

Offline bankbank

  • Newbies
  • *
  • Posts: 32
  • Karma: +3/-0
Re: kof98 ratio
« Reply #2 on: September 04, 2021, 02:00:42 AM »
I found the timer address for kof98, it's a word at 0x1085d0

and I found it in kof98h romset, which is aes and not encrypted. so now I can remove most of this timer code, giving me a nice section of free code I can play with.

Offline bankbank

  • Newbies
  • *
  • Posts: 32
  • Karma: +3/-0
Re: kof98 ratio
« Reply #3 on: September 04, 2021, 04:11:51 AM »
ok, we're making progress. I NOP'd 3 instructions, netting 6 bytes to be used later. there's likely more timer-related code that I could remove later, if need be.

so that's one goal complete:
Quote
*remove EX mode (auto-selection at start)
*remove timer
*remove Omega Rugal
*implement ratio selection via table
*implement points/cost text (using CREDITS 0X) text draw function
*remove random select
« Last Edit: September 04, 2021, 04:13:37 AM by bankbank »

Offline bankbank

  • Newbies
  • *
  • Posts: 32
  • Karma: +3/-0
Re: kof98 ratio
« Reply #4 on: September 04, 2021, 11:43:37 AM »
so one of my goals is to remove EX mode. I had the choice of either A) selecting it immediately for the player OR B) allow the player to select it like they would normally, but just remove the joystick controls to change the mode. I went with A cus it seems like a waste to have a toggle for something that can't be toggled. and my first try worked perfectly. I simply NOP'd the beq at 284d6. so as soon as a player enters, the default mode is chosen for them.

Offline dink

  • Administrator
  • *****
  • Posts: 5142
  • Karma: +459/-1
  • pie? I nearly bought one!
Re: kof98 ratio
« Reply #5 on: September 04, 2021, 12:36:52 PM »
I enjoy following your progress, very cool

best regards,
- dink

Offline bankbank

  • Newbies
  • *
  • Posts: 32
  • Karma: +3/-0
Re: kof98 ratio
« Reply #6 on: September 05, 2021, 01:17:21 AM »
I enjoy following your progress, very cool

thank you! hopefully people will find this effort to be informative and maybe it can help others get into the exciting world of romhacking.

now I'm digging into the character IDs and the cursor. as you may or may not know, KOF98 has a whole bunch of alternate versions of characters that are accessed by holding start prior to selecting. on the 3 "orochi" characters, their icon changes when you hold start, but for the other 9 "old versions", their icon does not change. as well, on the AES home version only, the boss character omega rugal is selectable using this method. one of the rules of the game under the 'ratio' system is that omega rugal is banned, so I would like to remove him completely from the game if possible. https://srk.shib.live/w/The_King_of_Fighters_%2798/FAQ

the omega rugal exclusion should be easy, but the more significant challenge I'm facing is that the normal/old versions of characters play differently and at least some are different in the points cost. so I need to see how the game categorizes them and make sure that the respective costs are able to be read.

after a little while I came across this piece of code and it seems to correspond with the ex/orochi characters:

Offline bankbank

  • Newbies
  • *
  • Posts: 32
  • Karma: +3/-0
Re: kof98 ratio
« Reply #7 on: September 05, 2021, 11:56:01 AM »
well as I said previously I expected to be able to return to the timer function - this code is actually initialization and not only for timer but also for other things like an aspect of random select. so I chopped out 34 bytes, which I will need for at least one purpose but hopefully I will have room for a second as well.

I'm going to be writing my new code at the end of the file, where they put FF padding to fill up the ROM. there's tons of space there, and I need to have lots of space to write my spaghetti! because I'm jumping a certain distance, basically from about 25% into the ROM to around the last 15%, I need to write out the full address I'm jumping to. so I'll need 6 or 8 bytes for that, and I only had 4 to replace at the injection site of where the player presses a button to select a character. so what I'm doing is putting code in the timer initialization area which will jump to my free code writing area at the end. and I can use 4 bytes to jump from button press to timer initialization area.

if I still have room left over after doing that, I will put the points initialization code in the initialization timer area - it's a perfect fit. I need to call this only once at the beginning of character select to give both players 20 points. so we'll see what happens, I'm playing with vasm now.

Offline Kev

  • FBNeo Dev
  • ******
  • Posts: 320
  • Karma: +2000/-0
  • Definitely the best Kev
Re: kof98 ratio
« Reply #8 on: September 06, 2021, 08:16:38 AM »
This is a really interesting thread!

Offline bankbank

  • Newbies
  • *
  • Posts: 32
  • Karma: +3/-0
Re: kof98 ratio
« Reply #9 on: September 18, 2021, 09:23:15 AM »
This is a really interesting thread!

thanks for the feedback!

sorry I haven't been posting here lately, got busy with IRL stuff. tonight I finally finished the first "phase" of the mod - the points/cost system is fully functional and working properly.

https://youtu.be/WeNB-TDCYAU

the next phase, and the one that could potentially take just as long or longer than the actual points/cost system, is hacking the text to display how many points each player has and to draw the cost for the characters at each player's cursor.

I have to say that writing the 68000 ASM code for the points/cost injection was really satisfying. there were a lot of little complications too - like for example, because this cost list does not have a zero cost character, I had to make it so that upon a player's second character pick, they temporarily had to lose 2 points. otherwise, a player could spend all 20 of their points on characters one and two and put the game into a softlock state. it's possible that players will find this frustrating or unintuitive when the game states that they have X points and they're only able to spend X-2 points, but that's the only way I can think about doing it.

also, I have decided to change the labeling of the mod. I would love any feedback on this point. well after finishing my mvc2 ratio mod I thought about what the 'ratio' actually meant and I don't necessarily think it is an appropriate label. the translation of the Chinese title of the points/cost list is
Quote
restricted points system character points table
right now I've changed it to POINTS MOD (title) and POINTS SYSTEM (during gameplay), but I'd love to hear any other ideas. alternatives I thought of are 'COST MOD' and 'POINTS BATTLE'.

edit: added the Chinese cost list
« Last Edit: September 18, 2021, 09:27:20 AM by bankbank »

Offline bankbank

  • Newbies
  • *
  • Posts: 32
  • Karma: +3/-0
Re: kof98 ratio
« Reply #10 on: September 25, 2021, 01:01:19 PM »
https://www.youtube.com/watch?v=9QMLZ4qLO7I

well, it's pretty much done. the only thing left to hack is the roulette function. so in this game, you can choose to have up to 3 of your character slots as 'roulette'. if you do so, that/those slots will randomize before each battle. from my preliminary analysis, the game does the initial character select randomization with different code than the randomization at the 'order select' screen. so that's two hacks rather than one, thanks SNK!

so in summation, thus far it's been 3 hacks:
1) initialization, give both players 20 points each (0x14)
2) points/cost restriction system via table
3) overwriting of text to display the points and cost

and #4 will be the two roulette hacks.

Offline Kev

  • FBNeo Dev
  • ******
  • Posts: 320
  • Karma: +2000/-0
  • Definitely the best Kev
Re: kof98 ratio
« Reply #11 on: October 01, 2021, 09:08:43 AM »
That is very cool work. Looking forward to what you do next!

Offline dink

  • Administrator
  • *****
  • Posts: 5142
  • Karma: +459/-1
  • pie? I nearly bought one!
Re: kof98 ratio
« Reply #12 on: October 01, 2021, 09:20:48 AM »
bankbank, when you are completely done with your kof98 hack, we will add to fbneo if you like :)

best regards,
- dink

Offline bankbank

  • Newbies
  • *
  • Posts: 32
  • Karma: +3/-0
Re: kof98 ratio
« Reply #13 on: October 25, 2021, 06:40:29 AM »
here it is folks, the completed kof98 ratio hack:
http://bankbank.net/kof98ratio.zip
IPS patch should be applied to file '242-pn1.p1' from kof98h.zip
when you run kof98h in FBNeo it should give you a warning that the CRC is different from what it expected - ratio is 9171669D, original is 61AC868A

notes:
A) I hacked kof98h binary instead of kof98 because kof98 is encrypted. I should have forced myself to get better at C and write a decrypt/re-encrypt program, but I didn't! it should hopefully not make any difference, and if it does, I can port the hack to kof98 set.
B) I didn't set up the roulette to adhere to the points system, so it's just disabled. it seemed really complicated. sorry!

so one neat thing to take note of this that, for the alternate versions of characters you select by holding start, in vanilla KoF98 there is no visual feedback on most of them - only the Orochi characters change their portrait when start is held. but with this mod, everyone except for Ryo (who has the same cost in alt and regular) will display visual feedback when start is held on them.

I'm very hype to watch people playing this hack!
« Last Edit: October 25, 2021, 08:36:12 AM by JacKc »

Offline dink

  • Administrator
  • *****
  • Posts: 5142
  • Karma: +459/-1
  • pie? I nearly bought one!
Re: kof98 ratio
« Reply #14 on: October 25, 2021, 02:12:07 PM »
Hi bankbank,
Congrats on the release!
I would like to add this hack to FBNeo - is that OK with you?
If yes, please tell me what you would like the name of your hack to be called in the game list :)

best regards,
- dink