Jump to content
IGNORED

rom hacks to support 2 buttons with genesis controllers


RevEng

Recommended Posts

Just read INPT1 for button C just like you read INPT4 for the other button. No need to dump paddle ports.

Then it won't work, because the Booster Grip asks for a reversed bit. :(

Yep, I just realized this in attempting to add support to Stella. I couldn't figure out why the code wasn't working, until I realized the logic is reversed. Once I did that, the sample programs work fine.

Link to comment
Share on other sites

  • 3 weeks later...

Both pause/reset and HERO are excellent suggestions. Unfortunately both require some work with rom disassembly which means I can't quickly knock them out... I'm no Nukey!

 

I have a homebrew I'm presently working on, but I have definite plans to work on the suggestions in this thread when I'm procrastinating.

 

I recently thought I had Sea Hawk all wrapped up, but it turns out that the fire/bomb decision happens in some timing critical code. The surgery needs to match cyclewise or else the screen gets pooched. [shakes fist]

Link to comment
Share on other sites

H.E.R.O. 2 button support. non-tested though...

 

 

Hero(2button).bin

 

 

A pause button is a little more involved because H.E.R.O. is a well written game. Free bytes are harder to come by.

 

Nukey made a routine to check for the pause on a 7800 or a 2600 (using the color switch) as well. I modded it a little bit. This is a lot longer then Nukey's original routine, but adds detection for the color switch in either position.

 

Some people leave their 2600 with the color switch in the B&W position, because not many games use it. Turning on the game might start it in pause mode. A simple fix is to read what position the switch is in at power up. Then the opposite position will become the pause.

 

Anyhow if you free up enough bytes you can pop this in. Or just use Nukey's original one as it saves some bytes.

 

 

START:
   sei
   ldx    $D0                      ; thanks to Nukey Shay for code on how to detect
   cpx    #$2C                     ; if a 7800 or 2600 is being used, so that a pause
   bne    .not7800                 ; switch can be implemented for both systems...
   ldx    $D1
   cpx    #$A9
   bne    .not7800
   sec                             ; 7800, bit 7 is 1
   .byte  $24                      ; BIT opcode, skip 1 byte
.not7800:
   clc                             ; 2600, bit 7 is 0
   .byte  $2C ; BIT opcode         ; skip 2 bytes, preserve the carry
Reset:
   asl    saveSwitches             ; move 7800 detection into carry
   cld
   ldx    #0
   txa
.loopClear:
   dex
   txs
   pha
   bne    .loopClear

   lda    SWCHB
   and    #$08                     ; 0000 1000  keep (initial) state of color/BW switch for the 2600
   ror                             ; 7800/2600  detection >> bit 7, color/BW switch >> bit 2
   ora    #$3B                     ; 0011 1011  carry is clear from the AND and ROR,
   adc    #1                       ; so through addition move color/BW setting to bit 6,
   and    #%11000000               ; BIT opcode can be used later to test bits 6 & 7...
   sta    saveSwitches             ; bit 7 is 7800/2600 flag, bit 6 holds initial position of 2600 color/BW switch
                                   ; bit 5 will hold the flag for the pause button


Mainloop:


;put whatever code you like here. If it becomes too far
;to use a branch (to the code for Reset) then take:
;
;   bcc    Reset
;
;and change it to:
;
;   bcs    .noReset
;   jmp    Reset
;.noReset:


;reading the switch...
;check reset, pause switch
   lda    SWCHB
   cmp    debouncer
   beq    .noChange
   sta    debouncer
   lsr
   bcc    Reset                    ; reset takes priority over pause
;reset not pressed
   ldx    saveSwitches
   bit    saveSwitches             ; test for 7800/2600 console, and initial state of color/bw switch (for 2600)
   bpl    .detected2600
;7800 console, check pause switch
   and    #$04
   bne    .noChange
   txa
   eor    #$20                     ; flip pause flag, as 7800 has a double grounded switch, only high in transition
   bne    .updateSwitch            ; always branch, as bit 7 always set for 7800

.detected2600
   bvs    .bwIs2600Pause
   eor    #$04                     ; invert color/bw switch... if 2600 was powered on with switch at B&W position
.bwIs2600Pause:
   and    #$04
   bne    .noPause
.pause:
   txa
   ora    #$20                     ; set pause
   bne    .updateSwitch            ; always branch

.noPause:
   txa
   and    #$DF                     ; clear pause
.updateSwitch:
   sta    saveSwitches
.noChange:



;when you come to a place in your code that is done/not done depending on the pause switch:
   lda    saveSwitches
   and    #$20
   bne    .pauseBeingUsed
;skip some no-pause code here, whatever it is
;(updating score, sound, etc...)
.pauseBeingUsed:

 

 

Also (off topic) I just notice that the forum software likes gobbling up PercentageZero. That is % followed by 0. :lol:

Link to comment
Share on other sites

Thanks! The hack is confirmed as working great! It's much quicker to drop that dynamite and run now!

 

I've updated my first post and added an attributed link to your post above.

 

The forum eating the %0 is annoying... I suspect its an SQL anti-hack filter getting in the way.

 

One way to get around it is to realize it eats the % and the next 2 chars if they start with 0. So if you want to output %001, you would type %%00001. Also be aware that a post preview will strip your escaping efforts.

 

If the % notation isn't important, it's probably easier just to switch the offending code to hex notation, as I believe you probably did. :P

Link to comment
Share on other sites

I have an original Sega branded 6 button Genesis controller and it works just fine.

 

Any chance Kung-Fu Master can be hacked to work like this?

 

Looks doable (is that even a word?). Is anyone working on this?

 

Also the Genesis buttons used in H.E.R.O, they were buttons B & C on the Genesis controller, correct?

 

 

 

Looking at the instruction manual for Kung Fu Master, how about this scheme:

 

button B = punch, button C = kick

 

* No firebuttons (these remain unchanged from original) *

 

Up - jump

Down - squat

Left - move left

Right - move right

 

 

* button B (punch) *

 

High Left Punch:

- button B (while facing left)

- button B & left

- button B & left & up

 

Low Left Punch:

- button B & down (while facing left)

- button B & down & left

 

 

High Right Punch:

- button B (while facing right)

- button B & right

- button B & right & up

 

Low Right Punch:

- button B & down (while facing right)

- button B & down & right

 

 

* button C (kick) *

 

High Left Kick:

- button C (while facing left)

- button C & left

- button C & left & up

 

Low Left Kick:

- button C & down (while facing left)

- button C & down & left

 

 

High Right Kick:

- button C (while facing right)

- button C & right

- button C & right & up

 

Low Right Kick:

- button C & down (while facing right)

- button C & down & right

 

 

 

When button B and C are pressed simultaneously, button B (punch) would win. Since this is a 2 player game, INPT3 has to be checked for P1 as well.

 

Anyhow is this what you were looking for? If yes, and also if no one else has started it, then I could take a stab at it. It might take a week or so though, depending on my time.

Link to comment
Share on other sites

I have an original Sega branded 6 button Genesis controller and it works just fine.

 

Any chance Kung-Fu Master can be hacked to work like this?

 

Looks doable (is that even a word?). Is anyone working on this?

 

Also the Genesis buttons used in H.E.R.O, they were buttons B & C on the Genesis controller, correct?

 

 

 

Looking at the instruction manual for Kung Fu Master, how about this scheme:

 

button B = punch, button C = kick

 

* No firebuttons (these remain unchanged from original) *

 

Up - jump

Down - squat

Left - move left

Right - move right

 

 

* button B (punch) *

 

High Left Punch:

- button B (while facing left)

- button B & left

- button B & left & up

 

Low Left Punch:

- button B & down (while facing left)

- button B & down & left

 

 

High Right Punch:

- button B (while facing right)

- button B & right

- button B & right & up

 

Low Right Punch:

- button B & down (while facing right)

- button B & down & right

 

 

* button C (kick) *

 

High Left Kick:

- button C (while facing left)

- button C & left

- button C & left & up

 

Low Left Kick:

- button C & down (while facing left)

- button C & down & left

 

 

High Right Kick:

- button C (while facing right)

- button C & right

- button C & right & up

 

Low Right Kick:

- button C & down (while facing right)

- button C & down & right

 

 

 

When button B and C are pressed simultaneously, button B (punch) would win. Since this is a 2 player game, INPT3 has to be checked for P1 as well.

 

Anyhow is this what you were looking for? If yes, and also if no one else has started it, then I could take a stab at it. It might take a week or so though, depending on my time.

that sounds perfect.

 

any chance you could post the fixed/edited code if you get it figured out? I'd love to start playing with this stuff too, but with an un-commented code, I wouldn't even know where to begin.

Link to comment
Share on other sites

I have an original Sega branded 6 button Genesis controller and it works just fine.

 

Any chance Kung-Fu Master can be hacked to work like this?

 

Looks doable (is that even a word?). Is anyone working on this?

 

Also the Genesis buttons used in H.E.R.O, they were buttons B & C on the Genesis controller, correct?

It's all yours as far as I'm concerned! :thumbsup:

 

And yes, B & C were the buttons in H.E.R.O.

Link to comment
Share on other sites

Okay guys, here's the first try. Disassembly included:

 

Edit: please see post 50 below for newest version. The newest version fixes quite a few bugs.

 

 

Here's what I did:

 

- The joystick and firebuttons are being checked in bank 1. All new changes to the code were made strictly in bank 1 (for easier debugging). The exception is #$82 is switched for #$02 being loaded into Vblank in bank 1. I'm not sure this is necessary as H.E.R.O. seemed just fine.

- 78 bytes were freed up. The new code I wrote takes 77 bytes so far. No illegal opcodes were used (that I remember).

- Techniques for freeing bytes were all the standard ones; changing jumps to branches, moving stuff around to save some branches, and eliminating redundant and duplicate code.

- BRK was used in bank 1 to save bytes. The break routine does bankswitching back to bank 0.

- Anything that I felt could cause a bug I noted at the top of the disassembly.

- Somewhere along the way I decided pressing punch & down was invalid. I'm not sure why I did this, but I had a few pieces of paper in front of me and I think I was looking at an old one :lol: I'll see how this code turns out first, and then decide if this is okay or not.

 

 

 

 

It seems that in KFM register $DA holds the reflect/no reflect for the current player. This made it easy to check the direction the player is facing when a firebutton is pressed. KFM begins by going through a loop that searches for pressed joystick directions. If none was found then it would continue on without branching. New code was inserted at this spot to check the firebuttons. The scenario is a player presses a button but not a direction. Either a high kick or high punch will now be done in the direction the player is facing when just buttons B or C are pressed.

 

 

Now too backtrack just a little, in the original KFM it would branch if a direction was found in the "direction checking" loop. It would then check for UP (Jump) being pressed, and branch if it was. If UP wasn't being pressed it would then check the firebutton. If the firebutton was not pressed then it would branch to walk or squat the character only. If it didn't branch, then a kick or jump was happening.

 

 

The 2nd part of the new code was to replace the firebutton checking. It now checks both firebuttons, and updates the kicks and punches with a "black box" theory in mind. I'm trying to check a few extra conditions, and substitute in an appropriate value for the X register that the original routine would have done.

 

 

Anyhow does this work on real hardware at all? It sure doesn't in Stella.

Link to comment
Share on other sites

Okay guys, here's the first try. Disassembly included:

 

 

 

Anyhow does this work on real hardware at all? It sure doesn't in Stella.

It works in the internal SVN version of Stella, when you add the 'Sega Genesis' virtual controller to the left port. So I would guess you've made the modifications correctly.

Link to comment
Share on other sites

It works right if you're pressing the direction pad. If you're just pressing the button alone you'll get one kick/punch and the next button presses do nothing until you press the d-pad again.

Maybe you can get a copy of the pre-release Stella to help with testing. If not, I'm happy to keep testing.

Link to comment
Share on other sites

Bakasama, Moon Patrol sounds like a worthy addition! I'll add it to my to-do list, unless someone wants to tackle it first. icon_smile.gif

@All_Harmony_users: there's an updated beta bios that has a workaround for using Genesis pads with the Harmony menu! With the new bios you just hold down the fire button while you turn on the Atari, and the menu will work.

Link to comment
Share on other sites

It works right if you're pressing the direction pad. If you're just pressing the button alone you'll get one kick/punch and the next button presses do nothing until you press rhe d-pad again.

 

Maybe you can get a copy of the pre-release Stella to help with testing. If not, I'm happy to keep testing.

 

Thank you for testing it. I'll have to dig deeper this weekend to find what's going on there. If you can keep testing these on real hardware it'd be much appreciated as my Stelladaptor and Genesis controller are in another city. I'm hoping to get them back in about a month if things go well.

 

 

Moon Patrol would be a good candidate, but I'll leave that one for you RevEng. I actually started disassembling Double Dragon a few days ago after doing most of the work on Kung Fu Master. Not much to show, I haven't even disassembled the last 2 banks yet. There a shitload of pointer tables so far that have been keeping me busy. I made an excel sheet to speed it up, but it still takes time. First impressions are the code looks a lot more loose then Kung Fu Master, and should be easier to make space. However, that is without looking at the other 2 banks yet though. :ponder:

 

 

I'll try fixing KFM this weekend. That's first priority over Double Dragon. Also Stephena if youread this would you be kind enough to send a pre-version of Stella? I don't know if it'll work with my joystick, but I could at least use the debugger to enter directions and follow the code through that way.

 

 

 

Jeff

  • Like 1
Link to comment
Share on other sites

I'll try fixing KFM this weekend. That's first priority over Double Dragon. Also Stephena if youread this would you be kind enough to send a pre-version of Stella? I don't know if it'll work with my joystick, but I could at least use the debugger to enter directions and follow the code through that way.

What system are you using (Linux, OSX, Windows), and what version (32 or 64 bit)?

Link to comment
Share on other sites

I'll try fixing KFM this weekend. That's first priority over Double Dragon. Also Stephena if youread this would you be kind enough to send a pre-version of Stella? I don't know if it'll work with my joystick, but I could at least use the debugger to enter directions and follow the code through that way.

What system are you using (Linux, OSX, Windows), and what version (32 or 64 bit)?

Windows 32 bit please. Thanks Stephena!! :)

Link to comment
Share on other sites

I'll try fixing KFM this weekend. That's first priority over Double Dragon. Also Stephena if youread this would you be kind enough to send a pre-version of Stella? I don't know if it'll work with my joystick, but I could at least use the debugger to enter directions and follow the code through that way.

What system are you using (Linux, OSX, Windows), and what version (32 or 64 bit)?

Windows 32 bit please. Thanks Stephena!! :)

OK, here it is: Stella-3.1_test5-windows.zip

 

Keep in mind:

 

1) Some of this is alpha-level code.

2) The debugger disassembly isn't complete for more esoteric ROMs (basic carts with no extra RAM should be fine).

3) This is on my personal space at work, so please don't post the link elsewhere.

Link to comment
Share on other sites

Version 2 of Kung Fu Master. Stephena's trial version of Stella was very useful. However I could only use the punch button as I don't have a Genesis controller where I live right now. I have a usb playstation type controller, and the kick button doesn't map to it.

 

 

I fixed the game logic so that punch & down will now do a low punch. I also fixed the rom so that you can do multiple punches. Can anyone do a trial run on real hardware for this new rom? Specifically:

 

1. Do all the combinations now work? (see the list of planned moves in post #36 above)

 

i.e. for a high left kick either of these combinations should work:

- button C (while facing left)

- button C & left

- button C & left & up

 

2. Do the controls work for both player 1 and 2?

 

3. Can the firebuttons be used to do multiple punches and kicks now?

 

 

 

Edit: version 3 attached now!! This version fixes the boss dying quick bug.

 

KungFuMaster(2button)Ver3.zip

 

Testing would be much appreciated. Providing there are no more bugs I'd call this one finished.

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...