Announcement

Collapse
No announcement yet.

Castlevania - Weapon Select

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

  • Castlevania - Weapon Select

    I was playing with Castlevania, and just thought of a way to hack it so you can select your weapon just pressing a button. The select button is unused, so its perfect for this. So, first I searched for the RAM address for the joypad. Here's what I found:

    F7: Joypad Address

    08, Up
    04, Down
    02, Left
    01, Right

    10, Start
    20, Select,
    40, B
    80, A

    An extract of my VirtuaNES cheat file:
    Code:
    #2 015B-01-08		Weapon - Dagger
    #2 015B-01-09		Weapon - Boomerang
    #2 015B-01-0A		Weapon - Devastator (It kills all enemies on screen)
    #2 015B-01-0B		Weapon - Bottle
    #2 015B-01-0C		Weapon - Red Axe
    #2 015B-01-0D		Weapon - Axe
    #2 015B-01-0E		Weapon - 1 up (Another clock)
    #2 015B-01-0F		Weapon - Clock


    Next thing to do was find a piece of code to replace with a JMP. I used a JMP instead of an JSR because the game crashed sometimes with it. The JMP seems to solve the problem. I maked a trace and I found a winner n_n:

    $C144: 9D 00 02 => 4C 3C BA Jump to BA3C
    1C154 9D 00 02 => 4C 3C BA

    Also I needed a bunch of 00s or FFs to write the new routine:

    $BA3C:
    1BA4C:

    Code:
    $BA3C:9D 00 02  STA $0200,X @ $02F0 = #$F4
    $BA3F:A9 20     LDA #$20
    $BA41:C5 F7     CMP $00F7 Compares F7 with 20 (value of Select button)
    $BA43:D0 11     BNE $BA56 If not equal branch to BA56
    $BA45:A9 00     LDA #$00
    $BA47:CD 5B 01  CMP $015B Compares 15B with 0 [COLOR="Red"][B]{*1}[/B][/COLOR]
    $BA4A:F0 0D     BEQ $BA59 If equal branch to BA59
    $BA4C:EE 5B 01  INC $015B Increase 15B by one
    $BA4F:A9 0F     LDA #$0F
    $BA51:CD 5B 01  CMP $015B Compare 15B with 0F [COLOR="Red"][B]{*2}[/B][/COLOR]
    $BA54:F0 03     BEQ $BA59 If equal branch to BA59
    $BA56:4C 47 C1  JMP $C147 Jump back to C147
    $BA59:A9 08     LDA #$08
    $BA5B:8D 5B 01  STA $015B Sets 15B to 08
    $BA5E:4C 47 C1  JMP $C147
    {*1}
    When you begin a new game you start without a weapon. So the value of 15b is 0. The first weapon (the dagger) has the 08 value. Any value between 00 and 08 is an useless buggie weapon (some values can freeze the game). So I had to set to 08 the value if you don't have a weapon to prevent that.

    {*2}
    The clock (0F) is the last weapon. Values beyond it are buggie weapons and some just freeze the game. So when you have the clock, if you press select, the count reverts to 08.

    With this routine everytime you press select, your weapon changes to the next one. The only problem I found is the speed of the weapon change. I have to slightly press the button, because It skips 3 or 4 weapons or all of them.

    Is there any way to alter the routine to slowdown the weapon select?.

    Thank you very much.

    Whipon. ñ_ñ
    Last edited by Whipon; 10-09-2007, 11:28:09 PM. Reason: corrected some little errors

  • #2
    Good idea Whipon!
    The Code Hut: http://codehut.gshi.org/

    Comment


    • #3
      Thank you

      I'm glad you're back, Tony. Long time no see you here n______n.
      Will you complete your Advanced Game Genie code making tips for Sega Genesis?. The "How to find controller cheats in the ROM" will be a very interesting info .
      Thanks again ñ.ñ

      Whipon.

      Comment


      • #4
        With this routine everytime you press select, your weapon changes to the next one. The only problem I found is the speed of the weapon change. I have to slightly press the button, because It skips 3 or 4 weapons or all of them.

        Is there any way to alter the routine to slowdown the weapon select?.
        Have you tried putting a STA $f7 (85 F7) after "$BA45:A9 00 LDA #$00" ? Or it maybe better to hijack the actual read joypad routine at c904.
        Pugsy's MAME Cheat Page : http://mamecheat.co.uk

        Comment


        • #5
          Whipon, the truthful answer is that I probably won't finish it anytime soon. I have a bunch of notes that need to be turned into a guide. Time consuming, and spare time is in short supply lately.

          A couple of those notes made it into this guide...

          http://www.angelfire.com/games2/code...racerGuide.txt

          It's good to see all the Genesis codes and info coming out of the GSHI forums lately.
          Last edited by Tony H; 10-11-2007, 07:51:46 PM.
          The Code Hut: http://codehut.gshi.org/

          Comment


          • #6
            Thanks a lot

            Well, I tried adding the STA F7, but i didn't notice any diference u___u

            Code:
            $BA3C:9D 00 02  STA $0200,X @ $02F0 = #$F4
            $BA3F:A9 20     LDA #$20
            $BA41:C5 F7     CMP $00F7 Compares F7 with 20 (value of Select button)
            $BA43:D0 11     BNE $BA56 If not equal branch to BA56
            $BA45:A9 00     LDA #$00
            $BA47:85 F7     STA F7
            (...)
            I'll try hijacking the read at c904 as suggested .

            ---

            Thanks Tony.
            I found a method (is a bit tedious) to find controller cheats in the roms. First you need to find the joypad ram address, then the value of each button and directions and finally, look for these values in the rom. I found new undocumented cheats for Demolition Man that way. And another ones that I cannot use, because I don't know where use them u___u.

            ---

            Thanks a lot again .

            Whipon.

            Comment


            • #7
              I don't know how you got on with hijacking the joypad code, just had a look at the rest of your code and although it won't be causing you that problem it's very wasteful and harder to read. There's too many branches and compares you'd be better using the bitwise AND + OR operators like so:-

              Code:
              $BA3C: 9D 00 02  STA $0200,X @ $02F0 = #$F4
              $BA3F: A9 20     LDA #$20
              $BA41: C5 F7     CMP $00F7 Compares F7 with 20 (value of Select button)
              $BA43: D0 0D     BNE $BA52
              
              $BA45: EE 5B 01  INC $015B 
              $BA48: AD 5B 01  LDA $015B 
              $BA4B: 09 08     ORA #$08
              $BA4D: 29 0F     AND #$0F
              $BA4F: 8D 5B 01  STA $015B    ;weapon will go in this sequence 9,A,B,C,D,E,F,8 
                                                          and repeat 
              $BA52: 4C 47 C1  JMP $C147
              Last edited by Pugsy; 10-13-2007, 05:44:42 AM.
              Pugsy's MAME Cheat Page : http://mamecheat.co.uk

              Comment


              • #8
                Thanks, Pugsy n.n

                Thank you very much. That simplified my routine a lot. But the speed of the weapon change its still too fast.
                I didn't tried the hijacking method yet. I'd try that tonight ,).

                Thanks again.
                Whipon.

                Comment


                • #9
                  Same result u___u

                  Well, I tried hijacking the read of F7:

                  Code:
                  $C904:55 F7 35 04 => 4C 3C BA EA
                  1C914 55 F7 35 04 => 4C 3C BA EA
                  
                  $BA3C:
                  1BA4C:
                  A9 20
                  C5 F7
                  D0 0D
                  EE 5B 01
                  AD 5B 01
                  09 08
                  29 0F
                  8D 5B 01
                  55 F7 35 04 Replaced instruction at $C904
                  4C 08 C9 JMP back to C908
                  Now the weapon change is faster than before. It seems this is a inevitable issue of this method.

                  Thanks again.

                  Whipon.

                  Comment


                  • #10
                    This system has some built-in prolonged button pressing code. Most games of this type have 1 value that reads out what button it continuing to be pressed, and another that reads the button for only 1 frame. I've been considering the effects of this particular type of code from time to time. Your coding was a little off, but it was close to the code that cancels out the prolonged button press. If you watch the memory viewer, while pressing select, $00F5 will blip with #20, instead of remaining at #20.

                    I identified the code responsible for this using this watch point configuration:
                    00F5 on Write
                    Condition: $00F5==#20&&A==#0

                    Your other coding placements were too fast because they ran either 2 or 4 times for every frame that select was pressed(as tested by breaking on #20 writes to F5, and then watching all writes to F5, combined with all executions of the other addresses used for recoding). The button counter I use is queried 1 time per frame, and relies on the value in A. It occurs after the 1-frame button press value is calculated, so that can be used to see if select was simply pressed, rather than changing weapons once for every frame that select remains pressed
                    .
                    Here's the coding that will work.
                    Code:
                    $C908: 4C 3C BA EA
                    1C918: 4C 3C BA EA
                    
                    $BA3C:
                    1BA4C:
                    95 F5 - STA $F5,X @ $01E5 = #$FF
                    94 F7 - STY $F7,X @ $01E7 = #$FF
                    C9 20 - CMP #$20
                    D0 0D - BNE $BA51
                    EE 5B 01 - INC $015B = #$09
                    AD 5B 01 - LDA $015B = #$09
                    09 08 - ORA #$08
                    29 0F - AND #$0F
                    8D 5B 01 - STA $015B = #$09
                    4C 0C C9 - JMP $C90C (This could also be an RTS, because that's what it jumps to next)
                    I can think of a more efficient bit of coding for this routine's jumping, but it's not that unoptimized, really.
                    This reality is mine. Go hallucinate your own.

                    Comment


                    • #11
                      Symply amazing =)

                      Originally posted by ugetab View Post
                      This system has some built-in prolonged button pressing code. Most games of this type have 1 value that reads out what button it continuing to be pressed, and another that reads the button for only 1 frame.
                      I didn't know that. In the future, making this type of hacking will be very easy, thanks to the help of both of you . I love Castlevania, and be able to select your weapon in game is great.

                      Now I'm having problems making a particular type of code:

                      I've seen in the game Solstice a code for multijumping. You can jump each time you press the A button, no matter if you're on the floor or not.

                      The code is:

                      SXUXYGAX
                      24BF 20 AD

                      It seems to replace a JSR Q with a LDA Q.

                      I've experimented with ram searchs in Castlevania, to look where the game checks if you're on the floor to disable that check so you can jump from nowhere. But It was futile. And I can't just using a super jump code, because you may get stuck in some areas of the game.

                      Thanks a lot again. This topic is a very very very interesting one .

                      whipon.

                      Comment


                      • #12
                        You plan on turning this into some kinda patch? Maybe post it on acmlm board and romhacking.net and see if anyone takes an interest in it. It's a pretty neat idea. Kinda like a debug mode.

                        Comment


                        • #13
                          ñ_ñ

                          I tought of a IPS patch. I'm registered at Romhacking.net.
                          But I'm not searching someone to make the work for me. I just need some tips to make the work myself .
                          Anyway the main purpouse is achieved. Thanks to the help of Pugsy and Ugetab I learned a new way of rom hacking: enable cheats by pressing a button. I've used the same procedure to select weapons in Gryzor. And to select items in the FF3 inventory.
                          The only problem I found until now is about some games that only have one joypad address. And that address is readed every frame. They have no address who read the buttons once per frame. An example fo this is Alien 3 or Bram Stoker's Dracula (NES).
                          Another thing I couldn't make is a super jump code for some games. Or a multi jumping code.
                          But, I'm still in the learning process. I expect to continue improving ñ_ñ.
                          C U.
                          Whipon.

                          Comment

                          Working...
                          X