uselop.blogg.se

Sega emulator controls
Sega emulator controls













  1. #Sega emulator controls full
  2. #Sega emulator controls software
  3. #Sega emulator controls code

Please note - the red boxes were added for illustrative purposes and don't appear in the demo ROM.Īfter testing this with various things, here's a chart I'm calling "why Sega Genesis programming will turn you into a crazy person": It's handy for verifying what exactly is sent during each cycle - see what I mean: Here's what the final product looks like: Move.b d0,(MEM_CONTROL_6_PRESSED) store pressed buttons Move.b d1,(MEM_CONTROL_6_HELD) store held buttons Move.b (MEM_CONTROL_6_HELD),d2 copy the last previously read buttons Move.b (a0),d0 get joypad data - x/y/z/modeĪnd.b #%00001111,d0 x/y/z/mode are in lowest 4 bits Move.b (MEM_CONTROL_1_6BUTTON),d0 save the valueīeq.w ExitReadJoypad zero means 3 button controller if this is a 3 button controller skip the remaining steps Move.b d0,(MEM_CONTROL_PRESSED) store pressed buttons Move.b d1,(MEM_CONTROL_HELD) store held buttons Move.b (MEM_CONTROL_HELD),d2 copy the last previously read buttonsĮor.b d2,d0 flip buttons being pressed now Not.b d0 flip bits so 0 means not pressed, and 1 means pressed Or.b d1,d0 merge values from both registers Lsl.b #2,d1 shift them so they are at the 2 highest bitsĪndi.b #%11000000,d1 Start/A in high 2 bits - clear others Move.b (a0),d0 get joypad data - C/B/DpadĪndi.b #%00111111,d0 C/B/Dpad in low 6 bits It now is a bit different than the original sample I found a few years ago.

#Sega emulator controls code

Move.b (a0),d0 copy controller data to d0Ĭmpi.b #%00110011,d0 00110011 = 3 button controllerĪnd now here's the new code to read the joypad. Lea CTRL_1_DATA,a0 load address to read controller 1 data

sega emulator controls

Let's start with some constants we'll need:

#Sega emulator controls full

I'll skip all the stuff to create the layout, you can download the full source somewhere on this page. You really just came here to see code I bet. Yeah, I know, this is just a spreadsheet view of the previous image. I created one because I'm not very smart and needed a dumbed-down version to help me understand this: There are many variations of this chart available, including from leaked Sega development manuals. After a short delay the controller flips back to cycle 0 so you better get what you need quickly. So you flip bit 7 to initiate another read cycle. For a 3 button controller game only the first two cycles are needed. There are 9 cycles supported but really only the first 7 are used. Flipping it from low to high initiates another read cycle. This is done by sending data out over cycles. Since the base Genesis controller has 8 buttons that means Sega had to account for handling >7 buttons from the beginning.

sega emulator controls

So there are 7 pins that transmit binary data. After reading several different sources, some with conflicting information, here's what I think the 9 pins on the Genesis controller port mean:

#Sega emulator controls software

I've always been more of a software guy than a hardware guy. I never even stopped to think about what the 9 pins on the Genesis controller even mean. At the end of writing this demo that copy 'n paste code was largely replaced. I found some sample code that worked and called it a day. The first thing I learned from this demo is that I really didn't understand how Genesis controllers communicated with the base unit. I guess that means the code for this little 6 button demo is a bit larger than it needs to be. You could even say It's Definitely not a Genesis Adventure Framework. Not an engine or a framework, just a random pile of minimally useful code. In case I decide to do another full-blown Genesis game I'd like to have a library of code that solves common problems. I have a secondary goal - determining whether any part of the Retail Clerk '89 code is reusable in other projects. As an extra bonus we'll try to detect whether a 6 or 3 button controller is attached.

sega emulator controls

So that's all this article & demo will be about - reading all 6 (really 8) buttons on a Genesis controller. It's not rocket science but it's not just testing the controller input for a couple extra values. That would have been kind of neat.Īfter looking into it I found that supporting 6 buttons isn't as easy as it sounds. Still, the X/Y/Z buttons could just mimic their A/B/C counterparts. Really it only needed 2 if I knew what I was doing before I started on it. It lacks 6 button support simply because the game only needs 3 buttons. It's not especially fun but I'm not sure that was ever my reason for making it. I recently finished this little Sega Genesis demo game called Retail Clerk '89.















Sega emulator controls