Author Topic: Question about how button presses are handled in CPS2/CPS3 games?  (Read 5531 times)

Offline Pasky

  • New Member
  • *
  • Posts: 9
  • Karma: +0/-0
Hi, I'm looking to write a plugin that will display player input while the emulator is running.  I've tried looking through the source but have no idea where to start.  I'm curious how games like Super Street Fighter 2: Turbo handle button presses.  Like what value is set when a button is pressed so I can look for that value in memory and display an input.  Is there a particular source file I should be looking at?  Thanks.

I found this in d_cps2.cpp:

Code: [Select]

static struct BurnInputInfo Cps2FightingInputList[] = {
{"P1 Coin"          , BIT_DIGITAL  , CpsInp020+4, "p1 coin"   },
{"P1 Start"         , BIT_DIGITAL  , CpsInp020+0, "p1 start"  },
{"P1 Up"            , BIT_DIGITAL  , CpsInp001+3, "p1 up"     },
{"P1 Down"          , BIT_DIGITAL  , CpsInp001+2, "p1 down"   },
{"P1 Left"          , BIT_DIGITAL  , CpsInp001+1, "p1 left"   },
{"P1 Right"         , BIT_DIGITAL  , CpsInp001+0, "p1 right"  },
{"P1 Weak Punch"    , BIT_DIGITAL  , CpsInp001+4, "p1 fire 1" },
{"P1 Medium Punch"  , BIT_DIGITAL  , CpsInp001+5, "p1 fire 2" },
{"P1 Strong Punch"  , BIT_DIGITAL  , CpsInp001+6, "p1 fire 3" },
{"P1 Weak Kick"     , BIT_DIGITAL  , CpsInp011+0, "p1 fire 4" },
{"P1 Medium Kick"   , BIT_DIGITAL  , CpsInp011+1, "p1 fire 5" },
{"P1 Strong Kick"   , BIT_DIGITAL  , CpsInp011+2, "p1 fire 6" },

{"P2 Coin"          , BIT_DIGITAL  , CpsInp020+5, "p2 coin"   },
{"P2 Start"         , BIT_DIGITAL  , CpsInp020+1, "p2 start"  },
{"P2 Up"            , BIT_DIGITAL  , CpsInp000+3, "p2 up"     },
{"P2 Down"          , BIT_DIGITAL  , CpsInp000+2, "p2 down"   },
{"P2 Left"          , BIT_DIGITAL  , CpsInp000+1, "p2 left"   },
{"P2 Right"         , BIT_DIGITAL  , CpsInp000+0, "p2 right"  },
{"P2 Weak Punch"    , BIT_DIGITAL  , CpsInp000+4, "p2 fire 1" },
{"P2 Medium Punch"  , BIT_DIGITAL  , CpsInp000+5, "p2 fire 2" },
{"P2 Strong Punch"  , BIT_DIGITAL  , CpsInp000+6, "p2 fire 3" },
{"P2 Weak Kick"     , BIT_DIGITAL  , CpsInp011+4, "p2 fire 4" },
{"P2 Medium Kick"   , BIT_DIGITAL  , CpsInp011+5, "p2 fire 5" },
{"P2 Strong Kick"   , BIT_DIGITAL  , CpsInp020+6, "p2 fire 6" },

{"Reset"            , BIT_DIGITAL  , &CpsReset  , "reset"     },
{"Diagnostic"       , BIT_DIGITAL  , CpsInp021+1, "diag"      },
{"Service"          , BIT_DIGITAL  , CpsInp021+2, "service"   },
};

STDINPUTINFO(Cps2Fighting)


However, I can't seem to find where CPSINPxxx is defined or STDINPUTINFO().  I'm not very proficient in C++ so this is daunting for me :).

Also, is there any variable, perhaps a pointer that points to allocated memory for the CPS2 rom?  I'm trying to find a static position in the memory of the emulator where the rom is stored so I can always find the address associated with the button press values.

If I had to make an educated guess I'd say its (cps2_crpt.cpp):

Code: [Select]
#if 0
UINT16 *rom = (UINT16 *)memory_region(REGION_CPU1);
int length = memory_region_length(REGION_CPU1);
UINT16 *dec = auto_malloc(length);
int i;
#endif

Either *rom or *dec pointer that points to where the rom memory begins?  Am I correct?  Or is this allocating memory to decrypt the rom?


Sorry if I'm not being clear enough, hope someone understands what I am trying to say.
« Last Edit: February 16, 2010, 02:15:16 AM by Pasky »

Offline CaptainCPS

  • FBNeo Dev
  • ******
  • Posts: 1513
  • Karma: +127/-0
  • FB Alpha Team
    • CaptainCPS's Home
Re: Question about how button presses are handled in CPS2/CPS3 games?
« Reply #1 on: February 17, 2010, 10:32:10 AM »
There has been moments when I been taking a look at the input interface in FBA, and right now (since I haven't taken a look to it long time) I can tell you I think its somewhere around src\burner\ or src\burner\win32\ , but I could be wrong, youre looking for CPS specific stuff so probably is not even there

If I have some time to help you out with this I will post you back, atm I'm working with other FBA stuff and It would be difficult for me to work on all these things at same time ^^.

SeeYaa!
 :biggrin:
« Last Edit: February 17, 2010, 10:34:58 AM by CaptainCPS-X »

Offline Pasky

  • New Member
  • *
  • Posts: 9
  • Karma: +0/-0
Re: Question about how button presses are handled in CPS2/CPS3 games?
« Reply #2 on: March 22, 2010, 11:12:37 AM »
Anyone have an idea?  I've looked and still can't find anything.  I'm also interested in how replay input is stored in replay files.  =/