Diamondback2010

Reverse Engineering Lego Super Mario

Recommended Posts

Hey all,

I started looking into reverse engineering the Super Mario products and would like to start a discussion about the topic.

As was brought up before, Mario uses the known Lego BLE protocol to communicate, so it's not really difficult to make that happen. My own implementation can talk with Mario and get the following info so far:

  • Game state changes
    • Idle
    • Game started
    • Goal reached
    • Time running out (15s left)
    • Time up
    • End-screen no longer visible (or something like that, happens 9s after Time Up/Goal reached)
  • Coin counts (Mario apparently has several different coin counters for different things)
    • Regular enemies
    • Double Jump enemies
    • Multi-jump/boss
    • Walking
    • Flying/Cloud
    • Turntable
    • ?-Box
    • Time Bonus
  • Pants-Type
  • Scanned Tag
  • Current surface type he's on

Interestingly enough, it appears that Mario doesn't notify me about special events like stars, mushrooms, etc. Does the official app display anything when you happen to get a star?

Now I'm looking into the barcodes. They consist of 5 colored stripes that repeat a bunch of times. There are (from what I can see so far) 8 colors (Red, Green, Blue, Yellow, Pink, Purple, Light Green, Light Blue).
So far, all my tags start with Red and Green, the remaining 3 stripes are different. Here's a list of what I have so far:

2020-08-03_18-25-10.png

 

Maybe you guys can share some other tags you already own, the goal of course is to find a pattern and decode them or even generate new tags.
At this point it's not known to me if Mario can recognize unknown but well formed tags and pass them via the BLE connection or if he will refuse to read them altogether.

The Internal ID columns represent what numbers Mario will send via BLE when the given tag is scanned, I suppose there is some connection between the color pattern and the number, but that's not a given a this point.

 

So yea, I was hoping to get some discussion going, trying to get some secrets out of him :)

 

Bonus footage, a little video of the data being sent by Mario, not overly exciting, but you can kind understand how it works... (Warning, quite technical)

https://www.dropbox.com/s/fy8nfec3vxofk1n/2020-08-03_18-38-24.mp4?dl=0

 

Edited by Diamondback2010

Share this post


Link to post
Share on other sites

Okay, after fiddling around for a bit and looking at some basic facts:

  • Colors don't repeat
  • There are at least 8 colors
  • There appears to be no checksum as a change of 1 changes only one column
  • Only three columns actually hold data (the other two are always the same)

I tried some basic encoding math and ended up with something that works.

The colors have an inherent order needed for encoding, the order is as follows:

  1. Blue
  2. Pink
  3. Yellow
  4. Purple
  5. Cyan
  6. Lime

Now, the trick here is, it's actually one color more than that, there's a (as of now) secret color between Pink and Yellow. I can't say what it is, but as soon as you assume 7 data colors, everything makes sense.

Decoding works like this:

Take the three data stripes (green and red are some sort of header or unused bytes or something), then take a look at the color list and pick the first appearing color from your data.

Example: Bob-Omb has colors: (Green, Red), Blue, Yellow, Cyan

So now, look up the "value" of the first color (Blue), it ends up as 0 as it's the first color of our list. As we used up the blue color, all the other color values shift by one.
The second color is Yellow, it used to have a value of 3 as it's the fourth color, however, due to Blue being removed, its value is now 2.
Last color is Cyan, which originally had a value of 5, but now due to shifting sits at 3.

That gives us overall 3 numbers for our stripes, 0(a), 2(b) and 3(c).
The final step is a specific formula to convert these values into the actual ID of the tag:

ID = 30a + 5b + c + 1 
In our case: 30 x 0 + 5 x 2 + 1 x 3 + 1 = 14

Share this post


Link to post
Share on other sites
1 hour ago, Diamondback2010 said:

So now, look up the "value" of the first color (Blue), it ends up as 0 as it's the first color of our list. As we used up the blue color, all the other color values shift by one.
The second color is Yellow, it used to have a value of 3 as it's the fourth color, however, due to Blue being removed, its value is now 2.
Last color is Cyan, which originally had a value of 5, but now due to shifting sits at 3.

That gives us overall 3 numbers for our stripes, 0(a), 2(b) and 3(c).
The final step is a specific formula to convert these values into the actual ID of the tag:

ID = 30a + 5b + c + 1 
In our case: 30 x 0 + 5 x 2 + 1 x 3 + 1 = 14

Awesome progress! Here are some more barcodes for reference. It looks to me like Spiny and Beetle have the same barcode (sorry it's a little blurry). 
D1vbahsh.jpg

Share this post


Link to post
Share on other sites

Images of all the barcodes can be found on Brickset: https://brickset.com/parts?query=Flat%20Tile%202X2,%20W/%20Sticker

Also I saw a video where someone printed their own barcodes so it's possible, but seems like color accuracy is critical.

Share this post


Link to post
Share on other sites

Hi guys,

isn't this something for the Mindstorms Forum as well? Sounds to me ... they have an awful lot of info over there ...

Just an idea.

Best and have fun!
Thorsten

Share this post


Link to post
Share on other sites
Posted (edited)

Hi guys,

I printed the page 2 of this pdf, and tried to use the bar codes with Mario. It seems to me that it recognised only the middle column, since it did nothing special on the others. But I think I have another problem : I used a laser printer, and the printed colors  are not well melted. Here are 2 photos of the printed King Boo's bar code, that I took with my microscope :

https://zupimages.net/viewer.php?id=21/01/eiw0.jpg

https://zupimages.net/viewer.php?id=21/01/74cr.jpg

 Did someone try to print that page ? Did it work well ?

 

 

Edited by Myosotis

Share this post


Link to post
Share on other sites
On 10/21/2020 at 8:01 PM, Szczepan said:

Here are all barcodes for Mario.

 

Hello,

Will there be available an Document update with the Barcodes introduced since August 2020 ?

 

Jo

Share this post


Link to post
Share on other sites

For some reason I thought the colors corresponded with the visible light spectrum, Red, Orange, Yellow, Green, Blue, Indigo, Violet, you know, Roy G. Biv

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.