Forums

Sega Master System / Mark III / Game Gear
SG-1000 / SC-3000 / SF-7000 / OMV
Home - Forums - Games - Scans - Maps - Cheats - Credits
Music - Videos - Development - Hacks - Translations - Homebrew

View topic - Does anyone have a hack of teddy boy that reverses the buttons?

Reply to topic
Author Message
  • Joined: 07 Nov 2018
  • Posts: 42
  • Location: Brazil
Reply with quote
Does anyone have a hack of teddy boy that reverses the buttons?
Post Posted: Thu May 07, 2020 12:24 am
Not feeling like asking such a noob question on "development", those guys are for real. Anyone got that? I figured someone must have done it by now, the game being so fast paced and the buttons are fricking swapped
  View user's profile Send private message Visit poster's website
  • Joined: 01 Apr 2005
  • Posts: 250
  • Location: Almere, The Netherlands
Reply with quote
Post Posted: Sat May 09, 2020 1:52 pm
There was recently a homebrew released that also had the buttons swapped. Very annoying.
Come to think of it. I could perhaps create an adapter with a switch so that I can reverse the buttons manually!
  View user's profile Send private message Visit poster's website
  • Joined: 05 Sep 2013
  • Posts: 3827
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Sat May 09, 2020 2:22 pm
or you can do a small hack using this code
  View user's profile Send private message Visit poster's website
  • Joined: 07 Nov 2018
  • Posts: 42
  • Location: Brazil
Reply with quote
Post Posted: Sun May 10, 2020 9:50 pm
sverx wrote
or you can do a small hack using this code


Been reading that for a long time now and completely clueless. Can you hook me up with an asm patch? Pretty please?
  View user's profile Send private message Visit poster's website
  • Joined: 05 Sep 2013
  • Posts: 3827
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Tue May 12, 2020 4:42 pm
that's just a short and quick way to reverse two bits in a byte, that is what you want to do with the state of the two buttons

bitmask is %00110000 ($30) for the first player, for instance
  View user's profile Send private message Visit poster's website
  • Joined: 07 Nov 2018
  • Posts: 42
  • Location: Brazil
Reply with quote
Post Posted: Tue May 12, 2020 10:07 pm
sverx wrote
that's just a short and quick way to reverse two bits in a byte, that is what you want to do with the state of the two buttons

bitmask is %00110000 ($30) for the first player, for instance


Please just hook me up with an IPS patch I have no clue how to do hex editing
  View user's profile Send private message Visit poster's website
  • Joined: 05 Sep 2013
  • Posts: 3827
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Wed May 13, 2020 3:28 pm
that's not hex editing, that's asm code

you need to find where in the code it reads the buttons and 'inject' that part

of course you need to know asm before
  View user's profile Send private message Visit poster's website
  • Joined: 07 Nov 2018
  • Posts: 42
  • Location: Brazil
Reply with quote
Post Posted: Wed May 13, 2020 8:13 pm
I don't
  View user's profile Send private message Visit poster's website
  • Joined: 27 Jun 2020
  • Posts: 212
Reply with quote
Post Posted: Sat Jun 27, 2020 12:40 pm
Would be easy to just switch the buttons out on the controller , switch the wires for button 1 and 2 , 5 seconds of soldering :)
  View user's profile Send private message
  • Joined: 22 Apr 2018
  • Posts: 530
Reply with quote
Post Posted: Sat Jun 27, 2020 5:33 pm
I think with a soldering iron you can build an adapter that does this without hacking apart any of your original Sega hardware:

https://www.l-com.com/d-sub-plastic-pcb-jumper-box-db9-male-female?gclid=EAIaIQo...

NOTE: please be careful doing something like this, connecting the wrong pins can destroy your hardware easily!

Simply wire one side's pin 6 to the other side's pin 9 and vice versa, and every other pin to the same-numbered pin on the other side, and I believe it should allow you to play these "reversed" games on unmodified original hardware.

Of course if it's instead an emulator, you might look into game-specific settings/profiles that allow you to remap buttons for that game without affecting other games. Many emulators support this, though some still do not.

edit: fancier solderless solutions are available too prefabricated though the prices seem a bit steep to me, e.g. https://www.viewpointusa.com/product/breakout-boards/9-pin-breakout-interface/ — you will need to separately purchase or construct two patch wires for the "crossed-over" signals though. Perhaps like these? https://www.gigaparts.com/3-female-to-female-jumper-wires-strip-of-40-wires.html...

edit 2: you will likely need to get a Sega/Atari 9-pin controller extension cord to connect this due to the physical differences between the console's connector and "standard" DE-9. I have used several brands in the past for similar projects, including these: https://www.amazon.com/Retro-Bit-Sega-Genesis-Controller-Extension-Cable/dp/B008...

You may have to use a razor to "shave" some excess plastic from around the extension cord connector at the end where you will plug in a breakout box. It depends on the precise dimensions of the breakout box and the extension though (some combinations don't need modification)
  View user's profile Send private message
  • Joined: 22 Apr 2018
  • Posts: 530
Reply with quote
Post Posted: Sat Jun 27, 2020 6:51 pm
It looks as though patching Teddy Boy Blues (J) [!].sms to swap the A & B buttons should actually be fairly trivial. This game's input routines either read the player 1 port, or read the player 2 port and then normalize player 2 input to have the same bit layout as player 1 input (this is very common, arguably the Sega hardware design here is just flawed!) and then jump to a common location in either case. To patch it a injected an "input button swizzler" routine at 0x8000 (first obviously unused address, increasing ROM size from 32KB to 48KB) and jump to that instead, and at the end of the patch routine jump to where the input routines would have jumped. The jumps at the ends of those input routines are overwritten with a jump to the swizzler.

Input routine patching: overwrite two bytes at 0x02BE with hex 00 80, overwrite two bytes at 0x02CD with hex 00 80. Originally in each case these should have been 23 03, indicating the address of the post-input code (0x0323).

Swizzler: enlarge ROM to 48KB by appending 00 bytes from 0x8000 through 0xBFFF. Then overwrite the 16 bytes at 0x8000 with hex 47 CB 60 20 02 EE 30 CB 68 20 02 EE 30 C3 23 03. Note the last two bytes match what was overwritten in the input routines.

Probably there are cleaner ways to swizzle, this is what I used though. I think if it were disassembled it would be like this, ignoring the existing code and data in the ROM:

;; <existing ROM data omitted here from 0x0000 .. 0x02BC>

.org 0x02BD
   jp swizzler

;; <existing ROM data omitted here from 0x02C0 .. 0x02CB>

.org 0x02CC
   jp swizzler

;; <existing ROM data omitted here from 0x02CF .. 0x7FFF>

.org 0x8000
swizzler:
   ld b, a
   bit 4, b
   jr nz, TL_not_connected
   xor 0x30
TL_not_connected:
   bit 5, b
   jr nz, TR_not_connected
   xor 0x30
TR_not_connected:
   jp 0x0323

;; <NUL bytes omitted here from 0x8010 .. 0xBFFF>


I've also attached this in IPS format. Apply it to:

32K 'Teddy Boy Blues (J) [!].sms'
Checking for export header with matching CRC... NO
sha256:42de9fc6028da76b4991ba81b3a666c9ae303e269d8f55c715f6518dcadb8773 Teddy Boy Blues (J) [!].sms
sha1:fb61c04f30c83733fdbf503b16e17aa8086932df Teddy Boy Blues (J) [!].sms
md5:de5d6c9e1349844b74f53caaf2af680b Teddy Boy Blues (J) [!].sms
mekacrc:BBE8D843FF8FF6BE Teddy Boy Blues (J) [!].sms
crc32:316727dd Teddy Boy Blues (J) [!].sms

  View user's profile Send private message
  • Joined: 22 Apr 2018
  • Posts: 530
Reply with quote
Post Posted: Thu Sep 03, 2020 5:23 pm
Here's an equivalent patch in IPS format for the US and European release. The only differences in the patch for this version are that the addresses changed.

edit: updated the patch to fix the checksum in the export header.

Apply this to:

32K 'Teddy Boy (UE) [!].sms'
Checking for export header with matching CRC... YES
sha256:dc0525958743bb2e725df0413297bcc6b1b4b744e47f397eb88037aa5157b3aa Teddy Boy (UE) [!].sms
sha1:6ae39718703dbf7126f71387ce24ad956710a315 Teddy Boy (UE) [!].sms
md5:66baea0a42353ffd3f131586e0c9c4d4 Teddy Boy (UE) [!].sms
mekacrc:C57A94919D619509 Teddy Boy (UE) [!].sms
crc32:2728faa3 Teddy Boy (UE) [!].sms

  View user's profile Send private message
  • Joined: 05 Sep 2013
  • Posts: 3827
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Fri Sep 04, 2020 11:33 am
I can't believe you didn't simply use the code here to swap the buttons :(
  View user's profile Send private message Visit poster's website
  • Joined: 22 Apr 2018
  • Posts: 530
Reply with quote
Post Posted: Fri Sep 04, 2020 3:49 pm
sverx wrote
I can't believe you didn't simply use the code here to swap the buttons :(


Wow, that's nice and short! I somehow failed to see that code at all before, but it's an improvement over what I wrote. It should be easy to switch to that version, just by changing a few bytes in the IPS. Only difference is I would probably still jump from the end instead of RET for simpler integration into the existing program. Feel free to upload fixed patches that do it that way instead

edit: actually you'd also need to ensure C isn't used by the code being patched to, and pre-load it with the correct value. Not a huge deal. I instead chose to only use registers I knew were "safe" from examining very few following instructions: A, B and flags. I also avoided the stack for no good reason - I'm just too used to patching other games at points before they configure SP I guess.
  View user's profile Send private message
  • Joined: 05 Sep 2013
  • Posts: 3827
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Fri Sep 04, 2020 4:37 pm
yeah in your case that would be

ld b,a          ; save value into B
and 0x30        ; check mask
ld a,b          ; restore value (this doesn't affect flags)
jp pe,0x0323    ; if Parity flag is EVEN we don't need any flip
xor 0x30        ; if not, we are flipping the bits
jp 0x0323       ; done
  View user's profile Send private message Visit poster's website
  • Joined: 22 Apr 2018
  • Posts: 530
Reply with quote
Post Posted: Sun Sep 06, 2020 8:16 pm
sverx wrote
yeah in your case that would be

ld b,a          ; save value into B
and 0x30        ; check mask
ld a,b          ; restore value (this doesn't affect flags)
jp pe,0x0323    ; if Parity flag is EVEN we don't need any flip
xor 0x30        ; if not, we are flipping the bits
jp 0x0323       ; done


Thanks! New patches attached to this reply use your code. The patch routine became four bytes shorter in each case

  View user's profile Send private message
  • Joined: 05 Sep 2013
  • Posts: 3827
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Mon Sep 07, 2020 9:22 am
also, looking at the Teddy Boy (UE) ROM, it seems there's a block of unused bytes at $7BB8->$7FEF so you might put your patch code somewhere there (I would use location $7FE0 for instance) and keep the ROM at 32 KB size.
  View user's profile Send private message Visit poster's website
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14741
  • Location: London
Reply with quote
Post Posted: Mon Sep 07, 2020 9:56 am
Put an SDSC header at $7fe0 if there's space... there seems to be plenty of unused space (FFFF0000 pattern) at the end of the ROM.
  View user's profile Send private message Visit poster's website
  • Joined: 05 Sep 2013
  • Posts: 3827
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Mon Sep 07, 2020 9:59 am
I don't get what's the point of having an SDSC header - unless you want the patched ROM to be clearly marked as such...
  View user's profile Send private message Visit poster's website
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14741
  • Location: London
Reply with quote
Post Posted: Mon Sep 07, 2020 10:00 am
Credit and an explanation about what it is. Clearly marking it as a hack rather than some unknown new variant...
  View user's profile Send private message Visit poster's website
Reply to topic



Back to the top of this page

Back to SMS Power!