Jump to content
RevEng

2-button games in bB - using sega genesis pads with the 2600

Recommended Posts

I threw together a quick little bB demo program that demonstrates how to read the B and C buttons on the Sega Genesis controller.

Why bother? 3rd party genesis pads can be had cheaply and they work without mods on the 2600, making them a popular choice for those of us that like gamepads. On top of that, they're trivial to support in your code.

2buttonread.bas
2buttonread.bas.bin

The program shows a red screen if the genesis controller was NOT detected, or a light-blue one if it WAS detected. Then pressing the B and C buttons will show up on the controller on the screen.

If anyone wants to see more proof-of-concepts, take a look at my 2-button hack thread which has a homebrew contribution from our very own batari.

[edit]

It seems that some types of Genesis controllers don't like the way bB handles VBLANK. Do the following for improved compatibility...

Copy over "std_kernel.asm" from your bB includes directory over to your project directory. Then take this section of code (search for "VBLANK")...

LDA #%11000010
sta WSYNC
STA VBLANK

...and change it to...

LDA #%01000010 ; *change top bit to 0, so paddle caps don't discharge*
sta WSYNC
STA VBLANK

After that, rebuild your game, and it should work with all genesis controllers.


  • Like 2

Share this post


Link to post
Share on other sites

Yeah, stella is a sticking point. I'm kind of hoping that the 2-button hack thread prods Stephen into updating stella.

As a workaround until he does, you can skip the detection stuff in my demo. Then just use "INPT5" instead of "INPT1" as you're working, which will use the second joysick's button instead. This maps to "f" by default in stella.

Then when you're ready to test on real hardware, just search and replace INPT5 with INPT1 and rebuild.

Share this post


Link to post
Share on other sites

Yeah, stella is a sticking point. I'm kind of hoping that the 2-button hack thread prods Stephen into updating stella.

 

As a workaround until he does, you can skip the detection stuff in my demo. Then just use "INPT5" instead of "INPT1" as you're working, which will use the second joysick's button instead. This maps to "f" by default in stella.

 

Then when you're ready to test on real hardware, just search and replace INPT5 with INPT1 and rebuild.

OK, I did that and mapped the second joystick fire button to another button on my USB controller:

 

post-13-126689231148_thumb.jpg

 

Now I have two working fire buttons!

 

Thanks.

Share this post


Link to post
Share on other sites

No problem. Glad to help!

 

If anybody has any more questions on the genesis controllers, feel free to post them here.

Share this post


Link to post
Share on other sites

Yeah, stella is a sticking point. I'm kind of hoping that the 2-button hack thread prods Stephen into updating stella.

 

As a workaround until he does, you can skip the detection stuff in my demo. Then just use "INPT5" instead of "INPT1" as you're working, which will use the second joysick's button instead. This maps to "f" by default in stella.

 

Then when you're ready to test on real hardware, just search and replace INPT5 with INPT1 and rebuild.

I am still working on Stella, but I've had to take a break for the last few weeks due to exhaustion from other things. Not to mention that I'm just now starting to watch the Farscape box set I bought before Christmas (yes, I don't normally get to watch a movie until 2 months after I buy it). And as I'm finding the series extremely addictive, I still haven't gotten back to Stella. :)

 

There are quite a few fixes already in what will become Stella 3.1. However, I've torn out the old disassembler and integrated Distella, and it's all still a WIP. And I can't do a new release until it's back to the same functionality as before. However, I see no reason why a new controller can't be added to Stella.

 

As to the new controller, I have a few questions (probably already answered in this thread, but better to ask again for clarity):

 

1) It uses the normal joystick directions, correct?

 

2) There are two buttons, one the normal joystick button, and the other INPT5?

 

3) What should I name this new 'controller' (Stella identifies controllers by name, so I have to call it something).

Share this post


Link to post
Share on other sites

Take your time Stephen. Having a burned out Stella maintainer won't help anyone!

 

As to the new controller, I have a few questions (probably already answered in this thread, but better to ask again for clarity):

 

1) It uses the normal joystick directions, correct?

 

2) There are two buttons, one the normal joystick button, and the other INPT5?

 

3) What should I name this new 'controller' (Stella identifies controllers by name, so I have to call it something).

1) correct

 

2) 2 buttons. One the normal joystick button, the other is INPT1. Yes, the paddle1 line. The INPT5 suggestion to RT was just a workaround for testing.

 

3) "sega genesis compatible" or similar will do, I think.

Share this post


Link to post
Share on other sites

Take your time Stephen. Having a burned out Stella maintainer won't help anyone!

 

As to the new controller, I have a few questions (probably already answered in this thread, but better to ask again for clarity):

 

1) It uses the normal joystick directions, correct?

 

2) There are two buttons, one the normal joystick button, and the other INPT5?

 

3) What should I name this new 'controller' (Stella identifies controllers by name, so I have to call it something).

1) correct

 

2) 2 buttons. One the normal joystick button, the other is INPT1. Yes, the paddle1 line. The INPT5 suggestion to RT was just a workaround for testing.

 

3) "sega genesis compatible" or similar will do, I think.

OK, I just got this added to Stella. It took a little longer than I expected, as I was basing the code on the BoosterGrip stuff. What I didn't realize at first is that the logic is reversed compared to a BoosterGrip. I had to bypass your autodetection, and then I noticed the button was always being pressed. Once I reversed the logic, the autodetect and button works fine. I've tested with several of the 2-button ROMs, and everything is working fine so far.

 

I might be able to provide some test builds of Stella with this enabled, but keep in mind that other parts of the code (particularly the disassembler) are not completely working yet.

  • Like 1

Share this post


Link to post
Share on other sites

I added this to the bB page:

 

http://www.randomterrain.com/atari-2600-memories-batari-basic-commands.html#2buttons

 

I'll update it when the new version of Stella is released.

You can update it. The latest released version of Stella supports genesis controller emulation. :)

Thanks. Is there something special you have to do to make the first program work in Stella as if you have the Sega controller hooked up?

Edited by Random Terrain

Share this post


Link to post
Share on other sites

Got the answer:

 

You have to use the 'Genesis' controller with this ROM. To do so, go to Options -> Game Properties -> Controller, and set 'P0 Controller' to 'Sega Genesis'. Click OK, and then restart the ROM. The first button is tied to the normal joystick button, so it will be the Space key, left Control, or whatever you have that mapped to. The second button is tied to the BoosterGrip 'booster' button, which by default is the '5' key. This can be remapped if you like.

Share this post


Link to post
Share on other sites

The point is that the extra button works in programs without modifying any hardware. If you have a Sega pad and a 2600-compatable console, you are good to go.

 

BTW computers can read a Gemini stick's paddle without using the wye cable (IIRC, it reads as the second paddle). Is this true for the 2600 as well? If so, a stick+fire+paddle game should be possible to create.

Share this post


Link to post
Share on other sites

I'm not sure if gravedigging is frowned on or not, but I've been trying this. Works great in Stella without any modification necessary to the kernel--RevEng must have built this mod into bB somewhere.

 

I have a few questions, though.

 

First off, I have a Genesis controller that I got off of eBay... I think. I've never owned a Sega console, so I know very little about its authenticity. It has the Sega logo on it, but it feels light and flimsy. It has 6 buttons, a Mode bumper in the upper right, a Start button, and the directional buttons. When I plug it in with the 2 button demo running on my Harmony (I selected the game with the joystick, then plugged in the controller, as instructed), the only button that gets any response is the B button. The screen remains colored red and I don't get any second button response.

 

post-34988-0-28388300-1413836515_thumb.jpg

 

It's possible I got a broken controller or some cheap knock-off that was manufactured wrong or a later generation controller that isn't wired the same. In any case, I need a working controller. The link given in the OP doesn't work anymore, so does anyone know where I could get a reasonably-priced Genesis controller that is guaranteed to work correctly?

 

Secondly, I'm a little puzzled as to how this code works. It sets the lowest bit of an arbitrary variable to 1 if INT1{7} is 1:

 genesispad=genesispad & $fe
 if INPT1{7} then genesispad=genesispad | 1

But then just a little ways down it checks if the lowest bit is 1 AND INPT1{7} is 0:

 if genesispad{0} && !INPT1{7} then pfpixel 26 6 on

How can it be both? How could genesispad{0} have gotten set to 1 from INTP1{7} being true, then just a few lines later, genesispad{0} is 1 and INTP1{7} is 0?

 

Nevermind. I just realized that the genesispad bit is set at the start of the program, not in the loop. Sily me! But then, if you need to select the game with the joystick but have the gamepad plugged in when the game begins, how do you make that swap in time?

 

Finally, does this work for both first and second controllers, or the first controller only?

Edited by Cybearg

Share this post


Link to post
Share on other sites

I'm not sure if gravedigging is frowned on or not, but I've been trying this. Works great in Stella without any modification necessary to the kernel--RevEng must have built this mod into bB somewhere.

 

I have a few questions, though.

 

First off, I have a Genesis controller that I got off of eBay... I think. I've never owned a Sega console, so I know very little about its authenticity. It has the Sega logo on it, but it feels light and flimsy. It has 6 buttons, a Mode bumper in the upper right, a Start button, and the directional buttons. When I plug it in with the 2 button demo running on my Harmony (I selected the game with the joystick, then plugged in the controller, as instructed), the only button that gets any response is the B button. The screen remains colored red and I don't get any second button response.

 

attachicon.gifIMG_20141020_151357_363.jpg

 

It's possible I got a broken controller or some cheap knock-off that was manufactured wrong or a later generation controller that isn't wired the same. In any case, I need a working controller. The link given in the OP doesn't work anymore, so does anyone know where I could get a reasonably-priced Genesis controller that is guaranteed to work correctly?

 

Secondly, I'm a little puzzled as to how this code works. It sets the lowest bit of an arbitrary variable to 1 if INT1{7} is 1:

 genesispad=genesispad & $fe
 if INPT1{7} then genesispad=genesispad | 1

But then just a little ways down it checks if the lowest bit is 1 AND INPT1{7} is 0:

 if genesispad{0} && !INPT1{7} then pfpixel 26 6 on

How can it be both? How could genesispad{0} have gotten set to 1 from INTP1{7} being true, then just a few lines later, genesispad{0} is 1 and INTP1{7} is 0?

 

Nevermind. I just realized that the genesispad bit is set at the start of the program, not in the loop. Sily me! But then, if you need to select the game with the joystick but have the gamepad plugged in when the game begins, how do you make that swap in time?

 

Finally, does this work for both first and second controllers, or the first controller only?

Well, as you know I programmed Princess Rescue to take advantage of the C button on the Genesis Controller. I'm trying to remember how I tested it on my Harmony cart while it was in production. I was able to do so, but you must have that Genesis controller plugged in before you select the game in the menu because it'll do the check right away and set a bit flag if you have a Genesis controller plugged in or not. It detects it through the INPT1{7} read. It's high if there is a Genesis controller and low when there isn't. All I can offer right now is do some trial and error. Try running the Harmony cart with the Genesis controller plugged in before power up. If that doesn't work, use a standard Atari joystick and then when you're in the menu, try swapping out with a Genesis controller and see if that helps. I believe INPT{7} is the pot read of Paddle controller 1. Because it's high when the Genesis controller is plugged in on power up, the Harmony cart reads that you have a possible paddle control for the menu. If you have a game like Princess Rescue that you can plug right into your Atari 2600, that'd be the best thing to try. If you get 2 button support (B & C) and all directionals, then the controller works fine. Remeber, C button is fire/run. Right now, I'm remaking my portable Atari 2600 with a bigger screen and 2 button support, but I want to directly wire up that second button as a C button for games like Princess Rescue without the Genesis controller circuitry, which means INPT1{7} would have to be high on power up, however I still have 2 external joystick ports that I want to use in case I want to do 2 player games, so I'm going to have to add a 2nd button on/off switch to be able to keep backwards compatibility and not stick INPT1{7} as high all the time for 2+ player paddle games.

 

Extra note: In theory it should also work on the 2nd joystick port as well, but because that will use INPT3{7} to detect it (in theory), you'll have to program that accordingly, just like you would on the first joystick detection routine.

Edited by Sprybug
  • Like 1

Share this post


Link to post
Share on other sites

The Harmony menu works with both paddles and joysticks. It gets confused if you have a Genesis gamepad plugged in because button C is read via a paddle input.

 

However, there is a way to make it so the Harmony menu is not confused:

  1. Press and hold B on the gamepad
  2. Turn the power on your Atari
  3. Wait until the Harmony shows the list of games
  4. Release button B

At this point you can move amongst the directories and select a game as normal. Use button B to start the game or enter directories.

  • Like 1

Share this post


Link to post
Share on other sites

Well now it's not reading my gamepad at all. Thanks for the tips on how to get it to work, but first and foremost, I need a gamepad that isn't a knock-off piece of junk.

 

Anywhere I can get a compatible Genesis controller for a reasonable price?

Share this post


Link to post
Share on other sites

Well now it's not reading my gamepad at all. Thanks for the tips on how to get it to work, but first and foremost, I need a gamepad that isn't a knock-off piece of junk.

 

Anywhere I can get a compatible Genesis controller for a reasonable price?

Do you have a local video game shop that deals in new and old school? I'm lucky to have one of those around here. It's where I finally ended up getting a real Genesis controller for about $6. I got some new 3rd party ones from ebay and they didn't work at all on my Atari 2600.

Share this post


Link to post
Share on other sites

It looks like the el-cheapo one is still at dealextreme, but the URL changed. Beware that it takes a very long time to ship, though.

 

Also, the bB mod isn't included, as it would interfere with games that use paddles. The mod isn't required for all controllers, just some of them that don't recover fast enough from having their power removed.

Share this post


Link to post
Share on other sites

Do you have a local video game shop that deals in new and old school? I'm lucky to have one of those around here. It's where I finally ended up getting a real Genesis controller for about $6. I got some new 3rd party ones from ebay and they didn't work at all on my Atari 2600.

Afraid I don't and yeah, that's what I got. See the image earlier in this thread.

 

It looks like the el-cheapo one is still at dealextreme, but the URL changed. Beware that it takes a very long time to ship, though.

 

Also, the bB mod isn't included, as it would interfere with games that use paddles. The mod isn't required for all controllers, just some of them that don't recover fast enough from having their power removed.

So that might not work for the 2600 without being physically modded? That won't do... I want something that will work out of the box so I know that my game can work out of the box (with a Genesis controller). Any proven-working options? What about the official Sega Genesis controllers? 3-button or 6-button?

Edited by Cybearg

Share this post


Link to post
Share on other sites

I'm talking about the mod to the bB file mentioned in my first post, not a physical mod.

 

The cheap pads I linked to were one of two different types I developed all of my 2600 2-button hacks on. No hardware work required.

Share this post


Link to post
Share on other sites

I'm talking about the mod to the bB file mentioned in my first post, not a physical mod.

 

The cheap pads I linked to were one of two different types I developed all of my 2600 2-button hacks on. No hardware work required.

Well awesome, then! Noted about the mod.

 

Can't beat 5 bucks for a controller with free shipping. At that price, they're practically paying you to take them off their hands.

Edited by Cybearg

Share this post


Link to post
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.

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...