Announcement

Collapse
No announcement yet.

Button activators ("Jokers") for systems with no 'If, Then' code type?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Button activators ("Jokers") for systems with no 'If, Then' code type?

    I realize that in many cases, this would require a new routine to be written (unless you don't mind hijacking an existing routine and overwriting functionality/remapping buttons), but I'd like to know how one makes a joker for such systems as NES, SNES, etc, in which we have no code types other than simple writes.

    I'm also interested in any information on common values for different button presses, as there generally are for systems like PSX, PS2, N64, etc.

    Not having jokers is a constant source of irritation in hacking retro systems, and I think if we nailed down a decent way of making them, we could do a lot more in general.
    I may be lazy, but I can...zzzZZZzzzZZZzzzZZZ...

  • #2
    Do you mean like my tetris up code?

    I don't remember how I found it, but I found the routine that checks for button presses, and simply hijacked where it looks for the up button and wrote a new routine that alters the position of the falling piece in the puzzle. Take a look. At $8926, I overwrote two lines with a jump to an unused location. Then, I executed the lines I overwrote and made the jumps accordingly so no functionality was missing. Then, I continued with the routine for moving the piece up, and finally jumped back to where I began.

    Looking back, I maybe could have used less lines by making it a subroutine, but I wrote this one a while back.

    I attached an fceux cht file so you don't have to do all of the copy/pasting.

    Code:
    GGXAVOPX
    EGXANPLA
    NYXEEPES
    XTXEOOPK
    PXKYENNN
    LEKYONNY
    ENKYXNNY
    LEKYUNNY
    GKKYKNNN
    LNKYSNNY
    OEKYVNNN
    SXKYNNNY
    VUKNENNY
    PXKNONUN
    AEKNXNNN
    ENKNUNNY
    AEKNKNNN
    SXKNSNNY
    PKKNVNNL
    PXKNNNNN
    ENSYONNY
    ZESYXNNY
    VKSYUNNY
    PKSYKNNY
    GKSYSNNN
    ZXSYVNNN
    OESYNNNN
    Attached Files
    Please put all complaints in writing and submit them here.

    Above link not working? Try here.

    Comment


    • #3
      Cool; thanks for the info

      Did you ever make a map of what values it expected per button/button combo?
      I may be lazy, but I can...zzzZZZzzzZZZzzzZZZ...

      Comment


      • #4
        Here's an explanation without having to open an emulator.

        Code:
        00:8924:A5 B6     LDA $00B6 = #$00
        00:8926:4C C0 FF  JMP $FFC0    <- Jump to new location
        00:8929:EA        NOP
        00:892A:A5 B5     LDA $00B5 = #$00
        ...
        01:FFC0:29 03     AND #$03  <- Overwritten instruction (Check for left or right)
        01:FFC2:F0 03     BEQ $FFC7 <- If no left or right, continue by branching over the jump
        01:FFC4:4C 73 89  JMP $8973 <- else jump to the routine for left/right
        01:FFC7:A5 B6     LDA $00B6  <- Get the current button press
        01:FFC9:29 08     AND #$08  <- Check for Up Button
        01:FFCB:F0 08     BEQ $FFD5  <- if no up button, branch to the end
        01:FFCD:A5 41     LDA $0041 <- get current height of piece
        01:FFCF:29 FF     AND #$FF  <- Check to see if it's at the top
        01:FFD1:F0 02     BEQ $FFD5  <- If so, branch to the end
        01:FFD3:C6 41     DEC $0041 <- else, move the piece up
        01:FFD5:4C 2A 89  JMP $892A  <- go back to original code
        Button values are a bitfield.
        $00F7 (bin) 0000 0000 = ABSeSt UDLR

        so a value of 0x80 would be button A, or 0x44 would be down and B, or 0xC1 would be A + B + Right, and so on.
        Last edited by rimsky82; 05-16-2011, 11:33:14 AM. Reason: Added Buton Map
        Please put all complaints in writing and submit them here.

        Above link not working? Try here.

        Comment


        • #5
          Ah, interesting. So, for individual buttons:

          0x80 = A
          0x40 = B
          0x20 = Select
          0x10 = Start
          0x08 = Up
          0x04 = Down
          0x02 = Left
          0x01 = Right

          ...and combinations are addition operations. Very similar to PSX or N64.

          Is there any consistency in this system, among other NES games? It would be nice to determine either one vastly consistent button value set, or several very common sets, and write a quick guide to hacking jokers for NES (then move on to SNES, etc); something similar to this, perhaps:

          http://GameHacking.org/?s=faqs&id=10
          I may be lazy, but I can...zzzZZZzzzZZZzzzZZZ...

          Comment


          • #6
            Code:
            01:FFC9:29 08     AND #$08  <- Check for Up Button
            01:FFCF:29 FF     AND #$FF  <- Check to see if it's at the top
            Is there any reason that a CMP was not used here or was it just preference? Just wondering if doing the AND method of comparison does anything different in the big picture. Also with the value FF compared to the top of the screen is it because when reaching the top of the screen Y (0) would wrap to FF and compare true for the branch (I would assume 0 would be used as the comparison value but again just picking your brain )?
            Last edited by Abystus; 05-16-2011, 01:56:00 PM.
            Not taking any requests at this time.

            Bored? Watch some of my hacks here.

            Comment


            • #7
              Originally posted by abystus View Post
              Code:
              01:FFC9:29 08     AND #$08  <- Check for Up Button
              01:FFCF:29 FF     AND #$FF  <- Check to see if it's at the top
              Is there any reason that a CMP was not used here or was it just preference? Just wondering if doing the AND method of comparison does anything different in the big picture. Also with the value FF compared to the top of the screen is it because when reaching the top of the screen Y (0) would wrap to FF and compare true for the branch?
              If I used a CMP for the up btn, then it would have to be the up button alone. With the AND, the player could also be pressing any of the other buttons. However the second could have used a CMP, I guess, but makes the same result (yet opposite) as far as the zero flag goes anyway.

              Its not actually a screenYpos, but the position within the puzzle. If I didn't have that check, the piece would rise above the puzzle bounds and glitch the game.

              Now that I think about it, the AND FF was pointless, since I was checking for a zero byte anyway. Have to remember I made this code after starting out... heh.
              Please put all complaints in writing and submit them here.

              Above link not working? Try here.

              Comment


              • #8
                Originally posted by rimsky82 View Post
                If I used a CMP for the up btn, then it would have to be the up button alone. With the AND, the player could also be pressing any of the other buttons. However the second could have used a CMP, I guess, but makes the same result (yet opposite) as far as the zero flag goes anyway.

                Its not actually a screenYpos, but the position within the puzzle. If I didn't have that check, the piece would rise above the puzzle bounds and glitch the game.

                Now that I think about it, the AND FF was pointless, since I was checking for a zero byte anyway. Have to remember I made this code after starting out... heh.
                Ah good point I wasn't taking in account for multiple buttons pressed at the same time which a compare would completely ignore. Also I noticed the instruction you replaced used an AND instead of a compare anyways so no points off for following the original flow of code. I've never been a friend of bitwise operations for the most part however I can now see the method to their madness and may attempt to use them more in the future.
                Not taking any requests at this time.

                Bored? Watch some of my hacks here.

                Comment


                • #9
                  SNES button values from Megaman X found by dcx2 at wiird

                  00 = NO button press
                  01 = Start
                  02 = Select
                  04 = R
                  08 = L
                  10 = X
                  20 = A
                  40 = Y
                  80 = B
                  lee4 Does Not Accept Codes Requests !
                  When lee4 asks a question it does not mean lee4 will look at your game
                  *How to create and use SegaCD codes >click here<*
                  >)

                  Comment


                  • #10
                    Sweet; good to know.

                    Hopefully we can cross reference a few more games for both NES and SNES, and get a baseline.
                    I may be lazy, but I can...zzzZZZzzzZZZzzzZZZ...

                    Comment


                    • #11
                      Originally posted by lee4 View Post
                      SNES button values from Megaman X found by dcx2 at wiird

                      00 = NO button press
                      01 = Start
                      02 = Select
                      04 = R
                      08 = L
                      10 = X
                      20 = A
                      40 = Y
                      80 = B
                      Maybe these values change by developer as trying the above values in searches while holding the various buttons did not produce any results in MK2. I would assume for testing/protocol purposes on their end developers would try to make all their games follow the same control input layout. I may test this on another Capcom game when I get home from work to see if there is any pattern.
                      Last edited by Abystus; 05-17-2011, 02:15:13 PM.
                      Not taking any requests at this time.

                      Bored? Watch some of my hacks here.

                      Comment


                      • #12
                        I was thinking of this myself, perhaps trying various Capcom games would net the same results where maybe nintendo developed games might be a different set. If this is the case we would have to make a table with different developers and their button values. I also remember some emulator or a plugin that I think it was DarkSerge who told me about it years ago that has code support like the PSX/N64 GS.
                        Spoiler Alert! Click to view...

                        THE BAD GUY!!!!!!

                        Comment


                        • #13
                          To find button addresses and values what I do is use a debugger. For example for the NES I put a breakpoint on read on 0x4016 and find where the register writes to. Nintendo games from what I have seen use the same values for all their games. Other companies may use different values. I wonder if it is possible to add support for jokers to retro emulators is one of those things that is really needed.

                          Comment


                          • #14
                            those values from Megaman X are for game-in button mapping.


                            I did my own testing

                            Here from SNES9X emulator universal values and addess will be different each game.

                            Example

                            Street Fighter 2 Turbo Button Register Activator (2-byte mode) [SNES9X]
                            P1_____A7A6
                            7E00A6:0000

                            0000 = NO Buttons
                            0010 = R
                            0020 = L
                            0040 = X
                            0080 = A
                            0100 = Right
                            0200 = Left
                            0400 = Down
                            0800 = Up
                            1000 = Start
                            2000 = Select
                            4000 = Y
                            8000 = B
                            lee4 Does Not Accept Codes Requests !
                            When lee4 asks a question it does not mean lee4 will look at your game
                            *How to create and use SegaCD codes >click here<*
                            >)

                            Comment


                            • #15
                              Streets of Rage 3 on the Gens210mk1 emulator

                              FFF704
                              00 = no button
                              01 = up
                              02 = down
                              04 = left
                              08 = right
                              10 = B
                              20 = C
                              40 = A
                              80 = Start

                              FFF706
                              E0 = no button
                              E1 = Z
                              E2 = Y
                              E4 = X
                              E8 = Mode (6 buttons)
                              lee4 Does Not Accept Codes Requests !
                              When lee4 asks a question it does not mean lee4 will look at your game
                              *How to create and use SegaCD codes >click here<*
                              >)

                              Comment

                              Working...
                              X