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 - Decoding Game Gear Columns link protocol

Reply to topic
Author Message
  • Joined: 25 Jul 2007
  • Posts: 731
  • Location: Melbourne, Australia
Reply with quote
Decoding Game Gear Columns link protocol
Post Posted: Wed Aug 04, 2021 12:51 pm
As a learning exercise, I have been working on decoding the Columns 2 player communication and having trouble working out the messages that are sent during gameplay.

These are the notes I have so far


PC1 (Pin 2) is set as output and pulled low.
PC3 (Pin 4) is set as input and pulled high, when the other Game Gear is linked and powered on it pulls this pin low and enables Versus mode on the start screen.

Player selects Versus mode and presses start,
PC0 (Pin 1) is pulled low
PC1 (Pin 2) is pulled high
Master GG sends serial data at 4800 baud, 0xF8 0x02

Slave GG pulls PC2 low
Slave GG pulls PC3 high
Slave GG sends serial data at 4800 baud, 0xFF 0x01 0x00 0x00 0x00

Master GG sends serial data at 4800 baud, 0xFF 0x01 0x00 0x00 0x00

Master selects Original or Flash mode
PC0 (Pin 1) is pulled high
PC1 (Pin 2) is pulled low
Master GG sends serial data at 4800 baud, 0xF8 0x02 (Original) or 0xF8 0x03 (Flash)

Slave GG pulls PC2 high
Slave GG pulls PC3 low

Master GG sends serial data at 4800 baud, 0xF4 0x01 0xFB 0x00 (Original) or 0xF4 0x01 0xF3 0x03 (Flash)

Slave GG sends serial data at 4800 baud, 0xF4 0x01 0xFB 0x00 (Original) or 0xF4 0x01 0xF3 0x03 (Flash)

Master GG sends serial data at 4800 baud as gameplay options are selected:
Number of matches (Original), master (default 3)
3: 0xF6 0x00
5: 0xF6 0x01
7: 0xF6 0x02
Minutes each match (Flash), master (default 3)
3: 0xF5 0x00
4: 0xF5 0x01
5: 0xF5 0x02
6: 0xF5 0x03
7: 0xF5 0x04
8: 0xF5 0x05
9: 0xF5 0x06

Difficulty master/slave (default Normal)
Easy: 0xF4 0x00
Normal: 0xF4 0x01
Hard: 0xF4 0x02

Block Height (Original) master/slave (default 0)
0: 0xFB 0x00
1: 0xFB 0x01
2: 0xFB 0x02
3: 0xFB 0x03
4: 0xFB 0x04
5: 0xFB 0x05
6: 0xFB 0x06
7: 0xFB 0x07
8: 0xFB 0x08
9: 0xFB 0x09
Block Height (Flash) master/slave (default 5)
2: 0xF3 0x00
3: 0xF3 0x01
4: 0xF3 0x02
5: 0xF3 0x03
6: 0xF3 0x04
7: 0xF3 0x05
8: 0xF3 0x06
9: 0xF3 0x07

Begin Game:

(3 blocks column 1, bottom)
0xFD 0x78 0xFD 0x91 0xFD 0x92 0xFD 0x93 0xFD 0x94 0xFD 0x95
(3 blocks column 2, bottom)
0xFD 0x90 0xFD 0x79 0xFD 0x92 0xFD 0x93 0xFD 0x94 0xFD 0x95
(3 blocks column 3, bottom)
0xFD 0x90 0xFD 0x91 0xFD 0x7A 0xFD 0x93 0xFD 0x94 0xFD 0x95
(3 blocks column 3, 4th line)
0xFD 0x90 0xFD 0x91 0xFD 0x62 0xFD 0x93 0xFD 0x94 0xFD 0x95
(3 blocks column 3, 7th line)
0xFD 0x90 0xFD 0x91 0xFD 0x4A 0xFD 0x93 0xFD 0x94 0xFD 0x95


So for example, each side will send a message similar to


(3 blocks column 3, bottom)
0xFD 0x90 0xFD 0x91 0xFD 0x7A 0xFD 0x93 0xFD 0x94 0xFD 0x95


In this case that would be if the player simply dropped the first set of 3 blocks straight down to the bottom of the screen (column 3) at the start of the match. The message sent then causes a shadow pattern of the same three blocks to appear on the opponent screen. The last three pairs of bytes don't seem to change, but the first three do and I can't find the pattern to decode them.

I imagine looking at the source code available would fill in some of the blanks but I'm no good at reading ASM.

Help appreciated if you have any ideas.
  View user's profile Send private message
  • Joined: 05 Sep 2013
  • Posts: 3827
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Wed Aug 04, 2021 5:57 pm
wild guess - the status of the 6 buttons?

0xFD : header that means - next byte is the info for one button
0x90-0x95 : some button not pressed
0x78-0x7D : some button pressed
  View user's profile Send private message Visit poster's website
  • Joined: 25 Jul 2007
  • Posts: 731
  • Location: Melbourne, Australia
Reply with quote
Post Posted: Thu Aug 05, 2021 12:44 am
Those bytes are only sent once each time a player places the 3 blocks on the bottom rows. It wouldn't make sense for the opposing player to know the button status of his opponent, also the only information updated on the opponents side is a shadow copy of the other players block layout, so it can only really contain info about the block structures (Tetris on Game Boy by comparison simply sends a line height of the opposing player).
  View user's profile Send private message
  • Joined: 05 Sep 2013
  • Posts: 3827
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Thu Aug 05, 2021 10:40 am
oh OK I didn't know how the Column game looks in VS mode

so my next guess is that it's the status of the 6 columns
it could just be the number of the empty blocks from top of each column, multiplied by 6, plus the number of the column itself (0 to 5), or something similar.
  View user's profile Send private message Visit poster's website
  • Joined: 25 Jul 2007
  • Posts: 731
  • Location: Melbourne, Australia
Reply with quote
Post Posted: Thu Aug 05, 2021 11:29 am
Actually, you are probably close, I figured out the pattern was there the whole time I just missed it.

Each byte pair represents a column from left to right.

Column 1 (empty)
0xFD 0x90


Column 2 (empty)
0xFD 0x91


Column 3 (empty)
0xFD 0x92


Column 4 (empty)
0xFD 0x93


Column 5 (empty)
0xFD 0x94


Column 6 (empty)
0xFD 0x95


in byte values these correspond to


10010000
10010001
10010010
10010011
10010100
10010101


you can see the first 3 LSB are the column number, the remaining 5 bits represent the rows in that column. For some reason, it decreases in value by 0x8 for every block in the column.

eg: column 1 would start empty with 0x90, then 0x78, 0x60, 0x48 as each set of 3 blocks stack to the top.
  View user's profile Send private message
  • Joined: 05 Sep 2013
  • Posts: 3827
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Thu Aug 05, 2021 12:16 pm
oh it's even easier than what I had imagined, it's just using the first 5 bits for the height and the next 3 for the column number - you don't even need a div/mod, you just right shift 3 times.
  View user's profile Send private message Visit poster's website
  • Joined: 25 Jul 2007
  • Posts: 731
  • Location: Melbourne, Australia
Reply with quote
Post Posted: Thu Aug 05, 2021 12:32 pm
yes, but why decrement the column value instead of increment it I wonder?
  View user's profile Send private message
  • Joined: 05 Sep 2013
  • Posts: 3827
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Thu Aug 05, 2021 2:18 pm
it's just counting the empty blocks above instead of the occupied blocks below, likely.
  View user's profile Send private message Visit poster's website
  • Joined: 25 Jul 2007
  • Posts: 731
  • Location: Melbourne, Australia
Reply with quote
Post Posted: Fri Aug 06, 2021 3:17 am
Would that be more efficient somehow? or is it likely arbitrary.
  View user's profile Send private message
  • Joined: 05 Sep 2013
  • Posts: 3827
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Fri Aug 06, 2021 9:03 am
it hardly makes any difference in efficiency I guess, so I presume it's just arbitrary. Maybe it matches how the heights are stored in memory by the game?
  View user's profile Send private message Visit poster's website
  • Site Admin
  • Joined: 08 Jul 2001
  • Posts: 8651
  • Location: Paris, France
Reply with quote
Post Posted: Sat Aug 07, 2021 4:13 pm
djbass wrote

I imagine looking at the source code available would fill in some of the blanks but I'm no good at reading ASM.


For those interested, we have full sources for Columns:
https://www.smspower.org/Development/Columns-GG
  View user's profile Send private message Visit poster's website
  • Joined: 25 Jul 2007
  • Posts: 731
  • Location: Melbourne, Australia
Reply with quote
Post Posted: Mon Aug 09, 2021 3:55 am
Thanks Bock, I'm aware of the source, I just don't know how to read ASM.

Fortunately, between hardware analysis and Calindro's Emulicious, I was able to decode everything.
  View user's profile Send private message
Reply to topic



Back to the top of this page

Back to SMS Power!