<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
xmlns:rawvoice="http://www.rawvoice.com/rawvoiceRssModule/"
>

<channel>
	<title>KwartzLab Makerspace &#187; Natalie Silvanovich</title>
	<atom:link href="http://www.kwartzlab.ca/author/natalies/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.kwartzlab.ca</link>
	<description>Home of Kwartzlab Makerspace in Kitchener/Waterloo, Ontario</description>
	<lastBuildDate>Tue, 14 May 2013 18:32:47 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
<!-- podcast_generator="Blubrry PowerPress/4.0.7" -->
	<itunes:summary>Regular discussions with hackers, makers and artists at the Kwartzlab Makerspace. We talk about what projects people are working on, what events are coming up and how you can get involved.</itunes:summary>
	<itunes:author>kwartzlab</itunes:author>
	<itunes:explicit>no</itunes:explicit>
	<itunes:image href="http://www.kwartzlab.ca/wp-content/uploads/powerpress/light_box_logo.jpg" />
	<itunes:owner>
		<itunes:name>kwartzlab</itunes:name>
		<itunes:email>podcast@kwartzlab.ca</itunes:email>
	</itunes:owner>
	<managingEditor>podcast@kwartzlab.ca (kwartzlab)</managingEditor>
	<itunes:subtitle>A hackerspace radio show</itunes:subtitle>
	<itunes:keywords>kwartzlab, hackerspace, makerspace, diy, hardware, software, maker, hacker, artist, roundtable</itunes:keywords>
	<image>
		<title>KwartzLab Makerspace &#187; Natalie Silvanovich</title>
		<url>http://www.kwartzlab.ca/wp-content/uploads/powerpress/light_box_logo.jpg</url>
		<link>http://www.kwartzlab.ca</link>
	</image>
	<itunes:category text="Technology" />
	<itunes:category text="Arts" />
	<itunes:category text="Games &amp; Hobbies">
		<itunes:category text="Hobbies" />
	</itunes:category>
		<rawvoice:location>Kitchener, ON</rawvoice:location>
		<item>
		<title>Code Execution on a Tamagotchi</title>
		<link>http://www.kwartzlab.ca/2013/05/code-execution-tamagotchi/</link>
		<comments>http://www.kwartzlab.ca/2013/05/code-execution-tamagotchi/#comments</comments>
		<pubDate>Tue, 07 May 2013 04:34:16 +0000</pubDate>
		<dc:creator>Natalie Silvanovich</dc:creator>
				<category><![CDATA[Member Blogs]]></category>

		<guid isPermaLink="false">http://www.kwartzlab.ca/?p=3529</guid>
		<description><![CDATA[I achieved arbitrary code execution on a Tamagotchi using a bug in figure ROM processing. This capability should allow me to dump the Tamagotchi code ROM after some analysis, as well as allow me to &#8216;hack&#8217; my Tamagotchi using the full capabilities of the microprocessor. I mentioned in an earlier post that I saw some &#8216;freezing&#8217; behaviour [...]]]></description>
				<content:encoded><![CDATA[<p>I achieved arbitrary code execution on a Tamagotchi using a bug in figure ROM processing. This capability should allow me to dump the Tamagotchi code ROM after some analysis, as well as allow me to &#8216;hack&#8217; my Tamagotchi using the full capabilities of the microprocessor.</p>
<div id="attachment_3530" class="wp-caption aligncenter" style="width: 338px"><a href="http://www.kwartzlab.ca/2013/05/code-execution-tamagotchi/yay/" rel="attachment wp-att-3530"><img class="size-full wp-image-3530" alt="Hip hip horray!!" src="http://www.kwartzlab.ca/wp-content/uploads/2013/05/yay.png" width="328" height="320" /></a><p class="wp-caption-text">Hip hip hooray!!</p></div>
<p><span id="more-3529"></span></p>
<p>I mentioned in an <a href="http://www.kwartzlab.ca/2013/01/tama-go-rom-format/">earlier post</a> that I saw some &#8216;freezing&#8217; behaviour in the figure game functionality. Game logic is controlled in its entirety by a single bit &#8216;game code&#8217;, which I suspected was the index of a jump table containing all Tamagotchi functionality, and invalid game codes, especially those in the middle of the 0-255 range cause the Tamagotchi to freeze, requiring reset.</p>
<p>Looking into how 6502 (the Tamagotchi microcontroller architecture) works, I thought this might be a sign that the microcontroller was veering off into unexpected code.  Memory in 6502 is mapped into a single address space, and there&#8217;s no MMU or other memory protection. If unmapped memory is accessed, it returns 0 or some other garbage value. Invalid instructions do not cause a reset, but execute undefined behaviour taking a non-deterministic amount of time. This meant that freezing was unlikely to be due to an error being detected by the microcontroller (of course, it was possible that an error was being detected by the code on the microcontroller, and it handled the error by going into a tight loop, but this struck me as unlikely, as the Tamagotchi tends to handle detected errors by resetting). It also meant that exploiting a bug in 6502 should be reasonably forgiving,  as  if the PC ends up somewhere before the intended address, it will likely execute any garbage instructions in sequence, and end up at the right address anyhow.</p>
<p>My first thought was that maybe the invalid &#8220;game codes&#8221; corresponded to indexes outside of the jump table, so the microcontroller was jumping to addresses that were actually other data. Since LCD RAM is the only memory that can be controlled by a figure, I was hoping that maybe one of these values would cause a jump into LCD RAM. So   I filled up my LCD with a NOP slide and shell code and hoped.</p>
<div id="attachment_3531" class="wp-caption aligncenter" style="width: 624px"><a href="http://www.kwartzlab.ca/2013/05/code-execution-tamagotchi/s/" rel="attachment wp-att-3531"><img class=" wp-image-3531 " alt="Shellcode works better when and annoying Tamagotchi doesn't stand in front of it" src="http://www.kwartzlab.ca/wp-content/uploads/2013/05/s.jpg" width="614" height="614" /></a><p class="wp-caption-text">Shellcode works better when an annoying Tamagotchi doesn&#8217;t stand in front of it</p></div>
<p>I tried all 255 indexes, but none of them worked. I did notice two interesting things, though. First, the indexes in the middle of the range weren&#8217;t all invalid. Some of them showed valid screens, although these screens didn&#8217;t always work. This meant that I probably wasn&#8217;t jumping to an unintended address, but something else was happening to cause freezing, such as the stack wasn&#8217;t set up correctly for the jump. Secondly, the index 0xCC had some interesting behaviour. If bit 3 of the 68th byte in the LCD RAM was set, it played a repeated beeping, and would detect when the figure was removed, and return to the main screen. If this bit wasn&#8217;t set, it would play no sound, and freeze. Based on the sound, I guessed that this was the location the Tamagotchi jumps to when playing a sound when a key is pressed. So the logic would be &#8220;check if sound is enabled (probably based on an address on the stack), and if set play the sound and return to the address on the stack otherwise return to  a different address on the stack&#8221;. Except the stack was messed up, so it was checking the LCD RAM for the bit, and returning to the address where it started instead of the correct address.</p>
<p>I found this perplexing. Considering that this behavior confirmed that pointers to the LCD RAM were being put on the stack before the jump, I found it surprising that none of the  255 possibilities were causing code execution. Eventually, I suspected my shellcode might be wrong. Since I have no sample microcontroller to test code on, and don&#8217;t know the locations of the ports, I thought this was likely. My original code was supposed to flash the IR LED, but I moved to the less ambition jumping to reset (since practically nothing will reset a 6502 microcontroller, this would be a good indicator of code execution). I also checked my code with the SunPlus compiler. And found I was using entirely the wrong instruction set. With the right instruction to byte value mapping, the Tamagotchi reset on the third &#8220;game code&#8221; I tried, 0xd4.</p>
<p>Playing with different instructions, I found the code execution was very unreliable, especially when calling longer instructions like stores and loads. Eventually, I figured out that the Tamagotchi LCD does not use one contiguous piece of LCD RAM, but uses at least two separate pieces. Jumping to one of these locations immediately after starting execution made it much more reliable.</p>
<p>Below is an example of changing the LCD using stores and loads. The area circled in blue is the first code that gets executed, and the area circled in green is the code in the contiguous memory it jumps to. The white boxes (circled in red) are the contiguous pieces of memory, set to be white using STA. The entire row is part of the memory, but I only set one byte (four pixels) per row.</p>
<div id="attachment_3532" class="wp-caption aligncenter" style="width: 539px"><a href="http://www.kwartzlab.ca/2013/05/code-execution-tamagotchi/circles/" rel="attachment wp-att-3532"><img class=" wp-image-3532   " alt="Yes, I'm aware this is the lamest POC ever" src="http://www.kwartzlab.ca/wp-content/uploads/2013/05/circles.jpg" width="529" height="529" /></a><p class="wp-caption-text">Yes, I&#8217;m aware this is the lamest POC ever</p></div>
<p>For people trying this at home, the LCD RAM locations so far are:</p>
<p>Rows 1-7: 0x10cc-0&#215;1107</p>
<p>Rows 8-18: 0&#215;1120-0x117C</p>
<p>Row 17: 0x10B4-0x10CB</p>
<p>Row 18-31: ???</p>
<p>Next step: chain this together to dump the code!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kwartzlab.ca/2013/05/code-execution-tamagotchi/feed/</wfw:commentRss>
		<slash:comments>77</slash:comments>
		</item>
		<item>
		<title>Tamagotchi Sound (or Why Tamagotchi &#8220;Gangnam Style&#8221; is Techinically Infeasible)</title>
		<link>http://www.kwartzlab.ca/2013/03/tamagotchi-sound-or-why-tamagotchi-gangnam-style-techinically-infeasible/</link>
		<comments>http://www.kwartzlab.ca/2013/03/tamagotchi-sound-or-why-tamagotchi-gangnam-style-techinically-infeasible/#comments</comments>
		<pubDate>Mon, 04 Mar 2013 05:25:27 +0000</pubDate>
		<dc:creator>Natalie Silvanovich</dc:creator>
				<category><![CDATA[Member Blogs]]></category>

		<guid isPermaLink="false">http://www.kwartzlab.ca/?p=3429</guid>
		<description><![CDATA[I looked into the sound capabilities of Tamagotchi items. Unfortunately, while the hardware seems able to play a wide range of notes at different volumes, this functionality is not available through the figure. As I mentioned in my previous post, figure &#8216;items&#8217; are implemented using byte code with six byte instructions. One particular instruction, starting [...]]]></description>
				<content:encoded><![CDATA[<p>I looked into the sound capabilities of Tamagotchi items. Unfortunately, while the hardware seems able to play a wide range of notes at different volumes, this functionality is not available through the figure.</p>
<div id="attachment_3432" class="wp-caption aligncenter" style="width: 539px"><a href="http://www.kwartzlab.ca/2013/03/tamagotchi-sound-or-why-tamagotchi-gangnam-style-techinically-infeasible/img_00000334/" rel="attachment wp-att-3432"><img class=" wp-image-3432  " alt="IMG_00000334" src="http://www.kwartzlab.ca/wp-content/uploads/2013/03/IMG_00000334.jpg" width="529" height="529" /></a><p class="wp-caption-text">Tamagotchi Sound</p></div>
<p><span id="more-3429"></span></p>
<p>As I mentioned in my <a title="Tamagotchi Items" href="http://www.kwartzlab.ca/2013/02/tamagotchi-items/">previous post</a>, figure &#8216;items&#8217; are implemented using byte code with six byte instructions. One particular instruction, starting with 0xFEFF controls sound.</p>
<p>The first two bytes of the instruction are always the same, and are likely used to identify it, while the last three bytes are always zero (I checked all the figure dumps I have so far to check this). This leaves one byte to identify the sound. I tried changing this value, and found that it cause the Tamagotchi to play different complete sounds. For example, one value caused the Tamagotchi to beep once, while another code caused it to play &#8220;Yankee Doodle&#8221; in it&#8217;s entirety. Values 0-0&#215;30(ish) played sounds that the Tamagotchi normally plays while running, such as the reset noise and the call noise. Values 0&#215;30-0&#215;52 played a wealth of public-domain music, ranging from &#8220;Fur-Elise&#8221; to &#8220;La Cucaracha&#8221; to &#8220;The Turkey in the Straw&#8221;. After that, codes 0&#215;53-0x5f played a C-major scale. These are all the notes that are available for custom sound.</p>
<p>This is problematic in two ways. First, there are no sharps or flats, so a Tamagotchi figure can only play music that is playable on a major scale. This means that Tamagotchis are unable to dance to many popular tunes, including &#8220;Gangnam Style&#8221; and &#8220;The Macarena&#8221;. This isn&#8217;t a hardware limitation, as these notes are used in some of the complete songs the figure can play, but the functionality hasn&#8217;t been built into the figure.</p>
<p>The other difficulty is timing. The sound instruction does not contain any timing information. Instead, sound timing relies on the delays in image instructions. A sound instruction will not play until the delay in the pre-ceding image instruction is complete, and it will play until the next sound instruction is encountered (there may be several image delays in the mean time). If the sound is not yet complete, it will be interrupted, and not finish playing. There is no other way to change the timing of the sound.</p>
<p>This also means that there is no way to &#8216;hold&#8217; notes. I tried doing this by repeating notes with a very short delay, but there was no delay that would make the notes play cleanly without &#8220;buzzing&#8221; due to short breaks in the note. The sound is still reasonable, though. To decrease the delay, and get even better (but not perfect sound), I had the Tamagotchi load a one pixel image during delays, which reduced the inherent delay due to image loading, and the larger image was still visible, except in the one pixel.</p>
<p>This allowed me to create a music video starring my Tamagotchi, albeit one with limited notes and sound quality. A helpful member of <a href="http://www.pokemon-mini.net/">pmdev</a> suggested I do &#8220;Mad World&#8221;, as it can be played with only the notes available.</p>
<p><span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='640' height='390' src='http://www.youtube.com/embed/mkYEP0Tt0U4?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span></p>
<p>This song perfectly sums up the angst of being unable to dance &#8220;Gangnam Style&#8221;. All the more motivation to get code execution!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kwartzlab.ca/2013/03/tamagotchi-sound-or-why-tamagotchi-gangnam-style-techinically-infeasible/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Tamagotchi Items</title>
		<link>http://www.kwartzlab.ca/2013/02/tamagotchi-items/</link>
		<comments>http://www.kwartzlab.ca/2013/02/tamagotchi-items/#comments</comments>
		<pubDate>Mon, 25 Feb 2013 06:48:02 +0000</pubDate>
		<dc:creator>Natalie Silvanovich</dc:creator>
				<category><![CDATA[Member Blogs]]></category>

		<guid isPermaLink="false">http://www.kwartzlab.ca/?p=3380</guid>
		<description><![CDATA[The one feature of Tamagotchi figures I haven&#8217;t looked at yet is items. When a figure is attached, Tamagotchis can buy items at shops and use them. Items vary vastly in what they can do, from headphones that cause your Tamagotchi to dance around in headphones until you remove the figure to refrigerators that make [...]]]></description>
				<content:encoded><![CDATA[<p>The one feature of Tamagotchi figures I haven&#8217;t looked at yet is items. When a figure is attached, Tamagotchis can buy items at shops and use them. Items vary vastly in what they can do, from headphones that cause your Tamagotchi to dance around in headphones until you remove the figure to refrigerators that make your Tamagotchi less hungry when they eat from them to vacations that show a clip of your Tamagotchi seeing the sights.</p>
<div id="attachment_3381" class="wp-caption aligncenter" style="width: 490px"><a href="http://www.kwartzlab.ca/2013/02/tamagotchi-items/im-240/" rel="attachment wp-att-3381"><img class="size-full wp-image-3381 " alt="USA Tour Item" src="http://www.kwartzlab.ca/wp-content/uploads/2013/02/im-240.bmp" width="48" height="31" /></a><p class="wp-caption-text">I took my Tamagotchi to see the statue of Lincoln. What did you do for your Tamagotchi today?</p></div>
<p><span id="more-3380"></span> Fortunately, the second wave of Tamagotchi figures contain flash, instead of mask ROM, so I was able to program a figure directly.</p>
<div id="attachment_3383" class="wp-caption aligncenter" style="width: 539px"><a href="http://www.kwartzlab.ca/2013/02/tamagotchi-items/img_00000298/" rel="attachment wp-att-3383"><img class=" wp-image-3383" title="Wave Two Figure Base" alt="Wave Two Figure Base" src="http://www.kwartzlab.ca/wp-content/uploads/2013/02/IMG_00000298.jpg" width="529" height="529" /></a><p class="wp-caption-text">Ignore the wire, these can be reprogrammed without modification</p></div>
<p style="text-align: left">I attached wires to a Tamagotchi case, and used my Arduino to reprogram the flash.</p>
<p style="text-align: center"><a href="http://www.kwartzlab.ca/2013/02/tamagotchi-items/img_00000300/" rel="attachment wp-att-3384"><img class="aligncenter  wp-image-3384" alt="Flash Programmer" src="http://www.kwartzlab.ca/wp-content/uploads/2013/02/IMG_00000300.jpg" width="529" height="529" /></a></p>
<p style="text-align: left">This made testing the figure ROM format much easier, as the flash was much less finicky than my flash-simulation rig, and I could use the figure on any Tamagotchi, not just one with the lines broken out.</p>
<p style="text-align: left">After _much_ testing, I figured out that items are implemented using an interpreted byte code. Each &#8216;instruction&#8217; is 6 bytes long. The format is as follows:</p>
<table width="663" border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="text-align: left" valign="top" width="209"><strong>Byte</strong></td>
<td valign="top" width="454"><strong>Comment</strong></td>
</tr>
<tr>
<td valign="top" width="209">0</td>
<td valign="top" width="454">This byte contains the &#8216;address&#8217; of what is being loaded</p>
<ul>
<li>The number of the image to be loaded (starting with the first item image), for an image</li>
<li>The number of the sprite to be loaded for a sprite</li>
<li>0xFE for a sound</li>
</ul>
</td>
</tr>
<tr>
<td valign="top" width="209">1</td>
<td valign="top" width="454">This byte contains the type of what is being loaded. Why it isn&#8217;t at byte 0, I have no idea</p>
<ul>
<li>0&#215;80 for an image</li>
<li>0&#215;00 for the sprite</li>
<li>0xFF for a sound</li>
</ul>
</td>
</tr>
<tr>
<td valign="top" width="209">2</td>
<td valign="top" width="454">This byte contains data based on the type</p>
<ul>
<li>The sound code for a sound</li>
<li>The x co-ordinate of an image or sprite</li>
</ul>
</td>
</tr>
<tr>
<td valign="top" width="209">3</td>
<td valign="top" width="454">This byte contains data based on the type</p>
<ul>
<li>0&#215;00 for a sound</li>
<li>The y co-ordinate of an image or sprite</li>
</ul>
</td>
</tr>
<tr>
<td valign="top" width="209">4</td>
<td valign="top" width="454">This byte contains data based on the type</p>
<ul>
<li>0&#215;00 for a sound</li>
<li>Unknown (but used) for an image or sprite</li>
</ul>
</td>
</tr>
<tr>
<td style="text-align: left" valign="top" width="209">5</td>
<td valign="top" width="454">This byte contains data based on the type</p>
<ul>
<li>0&#215;00 for a sound</li>
<li>The amount of time an image or sprite will be displayed</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p style="text-align: left">This isn&#8217;t comprehensive, there are still a few functions I am not sure how to do. For example, some items will give the Tamagotchi points or make them less hungry. There are likely different types for these. That said, this info was enough to make my Tamagotchi do the Harlem Shake:</p>
<p><span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='640' height='390' src='http://www.youtube.com/embed/L8eQYCVnROA?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span></p>
<p style="text-align: left">The audio on the video is a bit off, though, and this is due to limitations on the audio capabilities of the bytecode format (but not that Tamagotchi hardware). I&#8217;ll explore this further in a future post.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kwartzlab.ca/2013/02/tamagotchi-items/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Tama-Go ROM Format</title>
		<link>http://www.kwartzlab.ca/2013/01/tama-go-rom-format/</link>
		<comments>http://www.kwartzlab.ca/2013/01/tama-go-rom-format/#comments</comments>
		<pubDate>Mon, 21 Jan 2013 04:23:24 +0000</pubDate>
		<dc:creator>Natalie Silvanovich</dc:creator>
				<category><![CDATA[Member Blogs]]></category>

		<guid isPermaLink="false">http://www.kwartzlab.ca/?p=3271</guid>
		<description><![CDATA[I&#8217;ve been continuing to work out the format of the Tama-Go figure ROM. Using the figure simulation circuit I set up in my last post, and a digital logic analyzer, I&#8217;ve determined the purpose of most of the data in the figure ROM. &#160; I started by looking at the game functionality.  It turns out that [...]]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve been continuing to work out the format of the Tama-Go figure ROM. Using the figure simulation circuit I set up in my last post, and a digital logic analyzer, I&#8217;ve determined the purpose of most of the data in the figure ROM.</p>
<div id="attachment_3272" class="wp-caption aligncenter" style="width: 241px"><a href="http://www.kwartzlab.ca/2013/01/tama-go-rom-format/format/" rel="attachment wp-att-3272"><img class="size-medium wp-image-3272" src="http://www.kwartzlab.ca/wp-content/uploads/2013/01/format-231x400.png" alt="" width="231" height="400" /></a><p class="wp-caption-text">No one say &#8216;cross talk&#8217; and maybe it won&#8217;t happen</p></div>
<p>&nbsp;</p>
<p><span id="more-3271"></span>I started by looking at the game functionality.  It turns out that the functionality is fairly simple, and a very limited amount of the game logic is controlled by data fetched from the figure. The majority of data is images. Near the beginning of the ROM is a pointer table which contains the locations of images used by games, shops, items and other figure functionality. The location of this table is in turn controlled by another pointer at the head of the ROM. The Tama-Go fetches images by first fetching an image pointer from the table, and then fetching the image.</p>
<p>When &#8220;GAME&#8221; is selected, the Tama-Go starts fetching the needed images from the figure as they are displayed. Interestingly, they are fetched exactly when they are show, and are fetched multiple times if they are displayed multiple times. This suggests that the Tama-Go does not store the images fetched from the figure, but writes them directly to the LCD.</p>
<p>Only two pieces of data appear to affect the logic behavior of the game. The first are the &#8220;commands&#8221; at  addresses 0&#215;18 and 0&#215;19 (note I&#8217;m using a M<strong>a</strong>metchi figure, this might differ for other figures). These appear to control what game logic the Tama-Go executes when the specific game is selected. It turns out that if these are altered, the Tama-Go can not only jump into different games, but any screen on the Tamagotchi, such as the meal screen, going to the park or taking a bath. If the back button (C) is pressed on any of these screens, the Tama-Go jumps back to the screen it would normally go back to after the current screen, not the figure screen. This suggests that essentially the Tamagotchi acts as a large switch statement or jump table, with no memory of where it has previously jumped to.</p>
<p>I went through some of the possible command values, and found that many of them caused the Tamagotchi to freeze up and require a reset. This is likely because the commands do not exist, or the device is not in the right state for them to work correctly. It might be possible to exploit one of these invalid commands to dump the code of the Tamagotchi, although the lack of debugging information would make it difficult.</p>
<p>Of course, these commands can be used to &#8216;cheat&#8217; at Tamagotchi. The video below shows this functionality used to &#8216;evolve&#8217; the Tamagotchi (make it get older).</p>
<p><span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='640' height='390' src='http://www.youtube.com/embed/dccig1h-K6s?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span></p>
<p>There is also a series of bytes that gets read at the very end of the game. This seems to be related to how many points the Tamagotchi is awarded for playing the game. The Tama-Go appears to read more data the higher the game score is, so my guess is it&#8217;s some sort of cumulative algorithm for calculating the points awarded from the game score. Randomly tampering with these values caused my Tamagotchi to be awarded an extremely large number of points (which was useful in testing item functionality), but I&#8217;m still not clear how the values translate to points exactly.</p>
<div id="attachment_3273" class="wp-caption aligncenter" style="width: 505px"><a href="http://www.kwartzlab.ca/2013/01/tama-go-rom-format/points/" rel="attachment wp-att-3273"><img class="size-full wp-image-3273" src="http://www.kwartzlab.ca/wp-content/uploads/2013/01/points.png" alt="" width="495" height="515" /></a><p class="wp-caption-text">83009250 points has got to be enough for any Tamagotchi</p></div>
<p>Next, I looked at the shop functionality of the figure. This was also quite simple. The entire store functionality appears to be in the Tama-Go&#8217;s internal ROM, and it just fetched the images. The only interesting value was the item price, which can be altered in the ROM. This would probably be more useful had I not just given my Tamagotchi infinite points.</p>
<p>Lastly, I tried using an item, and this was quite interesting. The Tama-Go fetches one byte of non-image data from the figure, from inside the expected segment before using an item, and then fetches more than 200 bytes of non-image data from near the end of the ROM (not the segment, the entire ROM) while the item is being used. This is so bizzare, I tested it several times to make sure it was actually what was happening, and I&#8217;m confident that it is.</p>
<p>What I suspect is happening is that the first byte is a command similar to the game commands, jumping to code that relies on both image data and other data from the figure, which it then fetches. I&#8217;m not sure what this &#8220;other data&#8221; is. It could be the location of the images on the screen, it could be audio data (items make sounds) or it could be some type of metadata related to the behavior of the item (for example, whether it gives points, or the probability of behaving a certain way for items that don&#8217;t do the same thing every time). As for why this information is at such a strange location, my only guess is that its used by all three characters in the figure, so it can&#8217;t be a part of any of their segments. But this is wild speculation.</p>
<p>A complete list of memory addresses I&#8217;ve identified is below:</p>
<table width="663" border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td valign="top" width="209"><strong>Address Range (inclusive)</strong></td>
<td valign="top" width="454"><strong>Comment</strong></td>
</tr>
<tr>
<td valign="top" width="209">0&#215;000001-0&#215;000003</td>
<td valign="top" width="454">Test command (detects if figure is properly attached)</td>
</tr>
<tr>
<td valign="top" width="209">0×000011-0×000013</td>
<td valign="top" width="454">Another test command, detects the ‘segment’ controlled by the jumper</td>
</tr>
<tr>
<td valign="top" width="209">0&#215;000013</td>
<td valign="top" width="454">Unknown, possibly version</td>
</tr>
<tr>
<td valign="top" width="209">0&#215;000014</td>
<td valign="top" width="454">Figure ID</td>
</tr>
<tr>
<td valign="top" width="209">0&#215;000015-0&#215;000017</td>
<td valign="top" width="454">Unknown</td>
</tr>
<tr>
<td valign="top" width="209">0&#215;000018-0&#215;000019</td>
<td valign="top" width="454">Game commands</td>
</tr>
<tr>
<td valign="top" width="209">0&#215;000020-000022</td>
<td valign="top" width="454">Pointer to background pointer (offset of 40 is added)</td>
</tr>
<tr>
<td valign="top" width="209">0&#215;000050-0&#215;000052</td>
<td valign="top" width="454">Walking sprite 1 pointer</td>
</tr>
<tr>
<td valign="top" width="209">0&#215;000053-0&#215;000055</td>
<td valign="top" width="454">Walking sprite 2 pointer</td>
</tr>
<tr>
<td valign="top" width="209">0&#215;000056-0&#215;000058</td>
<td valign="top" width="454">Happy sprite 1 pointer</td>
</tr>
<tr>
<td valign="top" width="209">0&#215;000059-0x00005B</td>
<td valign="top" width="454">Side smile sprite pointer</td>
</tr>
<tr>
<td valign="top" width="209">0x00005c-0x00005f</td>
<td valign="top" width="454">Jumping for joy sprite pointer</td>
</tr>
<tr>
<td valign="top" width="209">0&#215;000068-0x00006a</td>
<td valign="top" width="454">Jumping sprite pointer</td>
</tr>
<tr>
<td valign="top" width="209">0x00006e-0&#215;000070</td>
<td valign="top" width="454">Side walk sprite 1 pointer</td>
</tr>
<tr>
<td valign="top" width="209">0&#215;000071-0&#215;000073</td>
<td valign="top" width="454">Side walk sprite 2 pointer</td>
</tr>
<tr>
<td valign="top" width="209">0x00008c-0x00008f</td>
<td valign="top" width="454">Startled sprite image pointer</td>
</tr>
<tr>
<td valign="top" width="209">0x00009e-0x0000a0</td>
<td valign="top" width="454">After travel background pointer</td>
</tr>
<tr>
<td valign="top" width="209">0x0000a4-0x0000a6</td>
<td valign="top" width="454">Travel image 1 pointer</td>
</tr>
<tr>
<td valign="top" width="209">0x0000a7-0x0000a9</td>
<td valign="top" width="454">Travel image 2 pointer</td>
</tr>
<tr>
<td valign="top" width="209">0x0000aa-0x0000ac</td>
<td valign="top" width="454">Ready image pointer</td>
</tr>
<tr>
<td valign="top" width="209">0x0000ad-0x0000af</td>
<td valign="top" width="454">Go image pointer</td>
</tr>
<tr>
<td valign="top" width="209">0x0000b6-0x0000b8</td>
<td valign="top" width="454">Hip hop game name pointer</td>
</tr>
<tr>
<td valign="top" width="209">0x0000b9-0x0000bb</td>
<td valign="top" width="454">Speed runner game name pointer</td>
</tr>
<tr>
<td valign="top" width="209">0x0000BC-0x0000C7</td>
<td valign="top" width="454">Store front pointers</td>
</tr>
<tr>
<td valign="top" width="209">0x0000CE-0x0000D0</td>
<td valign="top" width="454">Background image pointer</td>
</tr>
<tr>
<td valign="top" width="209">0x0000d1-0x0000d3</td>
<td valign="top" width="454">Background image open pointer</td>
</tr>
<tr>
<td valign="top" width="209">0x0000D4-0x000000eb</td>
<td valign="top" width="454">Hip hop image pointers</td>
</tr>
<tr>
<td valign="top" width="209">0x0000F5-0x00011d</td>
<td valign="top" width="454">Speed runner image pointers</td>
</tr>
<tr>
<td valign="top" width="209">0&#215;000119-0x00011b</td>
<td valign="top" width="454">Pointer to large Speed Runner image</td>
</tr>
<tr>
<td valign="top" width="209">0x00011f-0&#215;000127</td>
<td valign="top" width="454">Read as loading images for item (maybe logic)</td>
</tr>
<tr>
<td valign="top" width="209">0&#215;000148-0&#215;000170</td>
<td valign="top" width="454">Item prices (note probably a broader range)</td>
</tr>
<tr>
<td valign="top" width="209">0x0001a1-0x0001d4</td>
<td valign="top" width="454">Read at the end of Hip Hop game, appear to be related to scoring, but I’m not sure how. Appears to read farther the better you do. Corrupting them corrupts score display</td>
</tr>
<tr>
<td valign="top" width="209">0x00021d-0x00024c</td>
<td valign="top" width="454">Read at the end of speed runner</td>
</tr>
<tr>
<td valign="top" width="209">0x0002a2-0x0002db</td>
<td valign="top" width="454">Pointers to shop item images</td>
</tr>
<tr>
<td valign="top" width="209">0&#215;000620- 0&#215;000629</td>
<td valign="top" width="454">Pointers to fun box images</td>
</tr>
<tr>
<td valign="top" width="209">0x0011bf</td>
<td valign="top" width="454">Fun box beginning</td>
</tr>
<tr>
<td valign="top" width="209">0&#215;001251-0x0012B6</td>
<td valign="top" width="454">Walking sprite 1 image</td>
</tr>
<tr>
<td valign="top" width="209">0x0012B7-0x00131C</td>
<td valign="top" width="454">Walking sprite 2 image</td>
</tr>
<tr>
<td valign="top" width="209">0x001A49-0x001AAE</td>
<td valign="top" width="454">Startled sprite image</td>
</tr>
<tr>
<td valign="top" width="209">0x00131d-0&#215;001382</td>
<td valign="top" width="454">Happy sprite 1 image</td>
</tr>
<tr>
<td valign="top" width="209">0&#215;001383-0x0013e8</td>
<td valign="top" width="454">Side smile sprite image</td>
</tr>
<tr>
<td valign="top" width="209">0x0013e9-0x00144e</td>
<td valign="top" width="454">Jumping for joy sprite image</td>
</tr>
<tr>
<td valign="top" width="209">0&#215;001581-0x0015e6</td>
<td valign="top" width="454">Jumping sprite image</td>
</tr>
<tr>
<td valign="top" width="209">0x00164d-0x0016b6</td>
<td valign="top" width="454">Side walk sprite 1 image</td>
</tr>
<tr>
<td valign="top" width="209">0x0016b3-0x00171c</td>
<td valign="top" width="454">Side walk sprite 2 image</td>
</tr>
<tr>
<td valign="top" width="209">0x001cad-0x001e24</td>
<td valign="top" width="454">After travel background pointer</td>
</tr>
<tr>
<td valign="top" width="209">0x001f99-0x00210e</td>
<td valign="top" width="454">Travel image 1</td>
</tr>
<tr>
<td valign="top" width="209">0x00210f-0&#215;002284</td>
<td valign="top" width="454">Travel image 2</td>
</tr>
<tr>
<td valign="top" width="209">0&#215;002285-0x0023fa</td>
<td valign="top" width="454">Ready image</td>
</tr>
<tr>
<td valign="top" width="209">0x0023fb-0&#215;002571</td>
<td valign="top" width="454">Go image</td>
</tr>
<tr>
<td valign="top" width="209">0x00285d-0x0028fa</td>
<td valign="top" width="454">Hip hop game name image</td>
</tr>
<tr>
<td valign="top" width="209">0x0028fb-0&#215;002998</td>
<td valign="top" width="454">Speed runner game name image</td>
</tr>
<tr>
<td valign="top" width="209">0&#215;002999-0x002b2d</td>
<td valign="top" width="454">Store front images</td>
</tr>
<tr>
<td valign="top" width="209">0x002BAA-0x002C14</td>
<td valign="top" width="454">Background image</td>
</tr>
<tr>
<td valign="top" width="209">0x002C15-0x002C7F</td>
<td valign="top" width="454">Background image open</td>
</tr>
<tr>
<td valign="top" width="209">0x002c80-0x002cf8</td>
<td valign="top" width="454">Hip hop images</td>
</tr>
<tr>
<td valign="top" width="209">0x002f6f-0x002fd3</td>
<td valign="top" width="454">Large speed runner image</td>
</tr>
<tr>
<td valign="top" width="209">0x002d8f-0x002fd5</td>
<td valign="top" width="454">Speed runner images</td>
</tr>
<tr>
<td valign="top" width="209">0&#215;003058-0&#215;003634</td>
<td valign="top" width="454">Item images</td>
</tr>
<tr>
<td valign="top" width="209">0&#215;009052-0x0090bc</td>
<td valign="top" width="454">Fun box images</td>
</tr>
<tr>
<td valign="top" width="209">0&#215;0022499-0x00226e5</td>
<td valign="top" width="454">Read while playing with fun box, not image data</td>
</tr>
</tbody>
</table>
<p>And a list of game codes I&#8217;ve tried so far:</p>
<table width="329" border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td valign="top" width="75"><strong>Code</strong></td>
<td valign="top" width="253"><strong>Description</strong></td>
</tr>
<tr>
<td valign="top" width="75">FF</td>
<td valign="top" width="253">A game with squares</td>
</tr>
<tr>
<td valign="top" width="75">FE</td>
<td valign="top" width="253">Coin game</td>
</tr>
<tr>
<td valign="top" width="75">FD</td>
<td valign="top" width="253">Dropping game (cradles)</td>
</tr>
<tr>
<td valign="top" width="75">FcC</td>
<td valign="top" width="253">“Sorry Nothing” screen</td>
</tr>
<tr>
<td valign="top" width="75">FB</td>
<td valign="top" width="253">Away screen (and egg hatching)</td>
</tr>
<tr>
<td valign="top" width="75">FA</td>
<td valign="top" width="253">Park</td>
</tr>
<tr>
<td valign="top" width="75">F0</td>
<td valign="top" width="253">Remodelling store</td>
</tr>
<tr>
<td valign="top" width="75">F9</td>
<td valign="top" width="253">Odd , piano, then aliens, then IR</td>
</tr>
<tr>
<td valign="top" width="75">F8</td>
<td valign="top" width="253">Ready screen, can escape</td>
</tr>
<tr>
<td valign="top" width="75">F7</td>
<td valign="top" width="253">Ready screen, no escape</td>
</tr>
<tr>
<td valign="top" width="75">F6</td>
<td valign="top" width="253">Park with Violetchi</td>
</tr>
<tr>
<td valign="top" width="75">F5</td>
<td valign="top" width="253">Long jump game (with everything!)</td>
</tr>
<tr>
<td valign="top" width="75">F4</td>
<td valign="top" width="253">Shoot the bug</td>
</tr>
<tr>
<td valign="top" width="75">F2/F3</td>
<td valign="top" width="253">Also pair of games</td>
</tr>
<tr>
<td valign="top" width="75">F1</td>
<td valign="top" width="253">Ready screen, can escape</td>
</tr>
<tr>
<td valign="top" width="75">EF</td>
<td valign="top" width="253">Crying, returns to game choice screen</td>
</tr>
<tr>
<td valign="top" width="75">EE</td>
<td valign="top" width="253">Contrast screen</td>
</tr>
<tr>
<td valign="top" width="75">ED</td>
<td valign="top" width="253">Sound screen</td>
</tr>
<tr>
<td valign="top" width="75">EC</td>
<td valign="top" width="253">Pause Tamagotchi</td>
</tr>
<tr>
<td valign="top" width="75">EB</td>
<td valign="top" width="253">Tamagotchi runs away</td>
</tr>
<tr>
<td valign="top" width="75">EA</td>
<td valign="top" width="253"> Evolve!</td>
</tr>
<tr>
<td valign="top" width="75">E9</td>
<td valign="top" width="253"> Bath</td>
</tr>
<tr>
<td valign="top" width="75">E8</td>
<td valign="top" width="253">Figure “See you next time” screen</td>
</tr>
<tr>
<td valign="top" width="75">E7</td>
<td valign="top" width="253">Figure “Welcome” screen</td>
</tr>
<tr>
<td valign="top" width="75">E6</td>
<td valign="top" width="253">Reset screen</td>
</tr>
<tr>
<td valign="top" width="75">E5</td>
<td valign="top" width="253">Book (friends, memory screen)</td>
</tr>
<tr>
<td valign="top" width="75">E4</td>
<td valign="top" width="253">IR screen</td>
</tr>
<tr>
<td valign="top" width="75">E3</td>
<td valign="top" width="253">Tama says no</td>
</tr>
<tr>
<td valign="top" width="75">E2</td>
<td valign="top" width="253">Discipline screen</td>
</tr>
<tr>
<td valign="top" width="75">E1</td>
<td valign="top" width="253">Game shop item figure screen</td>
</tr>
<tr>
<td valign="top" width="75">E0</td>
<td valign="top" width="253">Tama comes back in door</td>
</tr>
<tr>
<td valign="top" width="75">DF</td>
<td valign="top" width="253">Bath</td>
</tr>
<tr>
<td valign="top" width="75">DE</td>
<td valign="top" width="253">Meal / snack</td>
</tr>
<tr>
<td valign="top" width="75">DD</td>
<td valign="top" width="253">Stats</td>
</tr>
<tr>
<td valign="top" width="75">DC</td>
<td valign="top" width="253">Clock</td>
</tr>
<tr>
<td valign="top" width="75">DD</td>
<td valign="top" width="253">main screen</td>
</tr>
<tr>
<td valign="top" width="75">DA</td>
<td valign="top" width="253">escape free egg (hatched, so restart)</td>
</tr>
<tr>
<td valign="top" width="75">D9</td>
<td valign="top" width="253">reset, not lock (can change details)</td>
</tr>
<tr>
<td valign="top" width="75">D8</td>
<td valign="top" width="253">stuck (must reset)</td>
</tr>
<tr>
<td valign="top" width="75">D7/D6/D5</td>
<td valign="top" width="253">frozen</td>
</tr>
<tr>
<td valign="top" width="75">99</td>
<td valign="top" width="253"> screen reverse</td>
</tr>
<tr>
<td valign="top" width="75">98</td>
<td valign="top" width="253">bottom icons light up (and stuck)</td>
</tr>
<tr>
<td valign="top" width="75">97</td>
<td valign="top" width="253">frozen</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kwartzlab.ca/2013/01/tama-go-rom-format/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Reliably Simulating a Tama-Go</title>
		<link>http://www.kwartzlab.ca/2012/12/reliably-simulating-tama-go/</link>
		<comments>http://www.kwartzlab.ca/2012/12/reliably-simulating-tama-go/#comments</comments>
		<pubDate>Mon, 24 Dec 2012 07:05:26 +0000</pubDate>
		<dc:creator>Natalie Silvanovich</dc:creator>
				<category><![CDATA[Member Blogs]]></category>

		<guid isPermaLink="false">http://www.kwartzlab.ca/?p=3145</guid>
		<description><![CDATA[While I managed to partially simulate a Tama-Go figure a few months ago, I&#8217;ve been having problems with reliability ever since. After a few frames, the image would start &#8220;rolling&#8221; down the screen. I eventually figured out that this was due to timing issues (as usual) and used a board with a faster microcontroller to [...]]]></description>
				<content:encoded><![CDATA[<p>While I managed to partially simulate a Tama-Go figure a few months ago, I&#8217;ve been having problems with reliability ever since. After a few frames, the image would start &#8220;rolling&#8221; down the screen. I eventually figured out that this was due to timing issues (as usual) and used a board with a faster microcontroller to simulate the ROM so that it can run reliably for several hours.</p>
<p><div id="attachment_3146" class="wp-caption aligncenter" style="width: 410px"><a href="http://www.kwartzlab.ca/2012/12/reliably-simulating-tama-go/setup/" rel="attachment wp-att-3146"><img class="size-medium wp-image-3146" src="http://www.kwartzlab.ca/wp-content/uploads/2012/12/setup-400x300.jpg" alt="" width="400" height="300" /></a><p class="wp-caption-text">Set-up</p></div><br />
<span id="more-3145"></span></p>
<p>I originally simulated the ROM from a ChipKit Uno Board. While this sort of worked, I would see signs that the Tamagotchi was getting corrupt data after a few seconds. This made it difficult to &#8216;test&#8217; the Tamagotchi, as I couldn&#8217;t be confident that a test that didn&#8217;t work had been received correctly. After looking into several possible causes of the problem that people had suggested, including wires being too long, &#8216;noise&#8217; in the circuit and bugs in my simulation program, I decided to try rewriting the program for a faster board, hoping that the problem was due to a timing issue (and if it was due to a bug, I wouldn&#8217;t make the same mistake twice).</p>
<div id="attachment_3148" class="wp-caption aligncenter" style="width: 410px"><a href="http://www.kwartzlab.ca/2012/12/reliably-simulating-tama-go/wires-2/" rel="attachment wp-att-3148"><img class="size-medium wp-image-3148" src="http://www.kwartzlab.ca/wp-content/uploads/2012/12/wires1-400x217.jpg" alt="" width="400" height="217" /></a><p class="wp-caption-text">Wires too long? I have no idea how anyone could think such a thing &#8230;</p></div>
<p>I used an STM32F4 Discovery board,  which I had on hand from a giveaway (but&#8217;s it&#8217;s a pretty awesome board, well worth the ~$15 they&#8217;re going for these days). By default, the MCU runs at 8 MHz, but it can be cranked up to 166 MHz, certainly enough to keep up with any Tamagotchi.</p>
<p>After programming the board to simulate the Tamagotchi ROM, I found that it worked for roughly 10 reads, and then would stall. Eventually, I figured out what was different  about the reads that failed.</p>
<div id="attachment_3149" class="wp-caption aligncenter" style="width: 410px"><a href="http://www.kwartzlab.ca/2012/12/reliably-simulating-tama-go/signal/" rel="attachment wp-att-3149"><img class="size-medium wp-image-3149" src="http://www.kwartzlab.ca/wp-content/uploads/2012/12/signal-400x298.jpg" alt="" width="400" height="298" /></a><p class="wp-caption-text">Do you see it? Do you see it? Do you see it?</p></div>
<p>It turns out that after running SPI at ~600 kHz for several cycles, the Tamagotchi speeds up to 2.2 MHz. It seems to do this specifically when it is fetching pixels that will be displayed on the screen. This explains the behavior I was seeing with the ChipKit Uno, which has a maximum SPI speed of 2 MHz. Since it could almost keep up, it would take a few seconds before there were obvious errors.</p>
<p>I fixed this by tweaking the PLL settings to speed up the microcontroller on the discovery board (note that this required removing resistor 68 on the back of the board), after which it worked!</p>
<div id="attachment_3150" class="wp-caption aligncenter" style="width: 410px"><a href="http://www.kwartzlab.ca/2012/12/reliably-simulating-tama-go/ns/" rel="attachment wp-att-3150"><img class="size-medium wp-image-3150" src="http://www.kwartzlab.ca/wp-content/uploads/2012/12/ns-400x300.jpg" alt="" width="400" height="300" /></a><p class="wp-caption-text">It works!</p></div>
<p>A simulated figure doesn&#8217;t always have to return the same value for the same address, so I could make my Tamagotchi display an animation, which a real figure can&#8217;t do.</p>
<p><span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='640' height='390' src='http://www.youtube.com/embed/XubcXgB1WE0?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span></p>
<p>Since I can now test things reliably, I saw what happened when I extended the dimensions of the displayed image. While it does allow displaying images the size of the full screen, it rejects the image before it&#8217;s large enough to overflow LCD RAM (boo!).</p>
<p>It does let you do cool things, like displaying a picture of yourself holding a Tamagotchi on a Tamagotchi.</p>
<div id="attachment_3152" class="wp-caption aligncenter" style="width: 410px"><a href="http://www.kwartzlab.ca/2012/12/reliably-simulating-tama-go/tamanat/" rel="attachment wp-att-3152"><img class="size-medium wp-image-3152" src="http://www.kwartzlab.ca/wp-content/uploads/2012/12/tamanat-400x300.jpg" alt="" width="400" height="300" /></a><p class="wp-caption-text">That&#8217;s me!</p></div>
<p>Totally meta!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kwartzlab.ca/2012/12/reliably-simulating-tama-go/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Laser-Cut Coasters</title>
		<link>http://www.kwartzlab.ca/2012/08/laser-cut-coasters/</link>
		<comments>http://www.kwartzlab.ca/2012/08/laser-cut-coasters/#comments</comments>
		<pubDate>Mon, 20 Aug 2012 04:41:09 +0000</pubDate>
		<dc:creator>Natalie Silvanovich</dc:creator>
				<category><![CDATA[Member Blogs]]></category>

		<guid isPermaLink="false">http://www.kwartzlab.ca/?p=2820</guid>
		<description><![CDATA[I used the laser cutter to make a set of coasters with stylized pictures of  a couple whose wedding&#8217;s coming up. The pictures are etched in paint on plexiglass. I got a piece of 4mm thick plexiglass, and cut it into squares a bit larger than I wanted the coasters to be using the laser [...]]]></description>
				<content:encoded><![CDATA[<p>I used the laser cutter to make a set of coasters with stylized pictures of  a couple whose wedding&#8217;s coming up.</p>
<div id="attachment_2822" class="wp-caption aligncenter" style="width: 624px"><a href="http://www.kwartzlab.ca/2012/08/laser-cut-coasters/img-20120819-00050-2/" rel="attachment wp-att-2822"><img class=" wp-image-2822 " src="http://www.kwartzlab.ca/wp-content/uploads/2012/08/IMG-20120819-000501-1024x768.jpg" alt="Finished coasters" width="614" height="461" /></a><p class="wp-caption-text">The end result!</p></div>
<p>The pictures are etched in paint on plexiglass.</p>
<p><span id="more-2820"></span>I got a piece of 4mm thick plexiglass, and cut it into squares a bit larger than I wanted the coasters to be using the laser cutter (power 100, speed 5), and then I painted them black. After a previous disaster involving spray paint, I used acrylic crafting paint.</p>
<div id="attachment_2824" class="wp-caption aligncenter" style="width: 610px"><a href="http://www.kwartzlab.ca/2012/08/laser-cut-coasters/paint/" rel="attachment wp-att-2824"><img class="size-full wp-image-2824" src="http://www.kwartzlab.ca/wp-content/uploads/2012/08/paint.jpg" alt="" width="600" height="450" /></a><p class="wp-caption-text">It turns out layers of spray paint dissolve each other</p></div>
<p>Once the paint was dry, I etched the pictures in using the laser cutter. I started by converting photos to monochrome bitmaps, and importing them into the LaserCut software, but this led to pixelated-looking images.</p>
<div id="attachment_2825" class="wp-caption aligncenter" style="width: 624px"><a href="http://www.kwartzlab.ca/2012/08/laser-cut-coasters/img-20120819-00046/" rel="attachment wp-att-2825"><img class=" wp-image-2825 " src="http://www.kwartzlab.ca/wp-content/uploads/2012/08/IMG-20120819-00046-1024x768.jpg" alt="" width="614" height="461" /></a><p class="wp-caption-text">Too pixelated!</p></div>
<p>The image in the attempt above is also reversed, because I forgot that when engraving, black areas in the laser-cut software are the ones that get engraved (so turn white).</p>
<p><a href="http://agnesmakes.com/">Agnes</a> suggested smoothing out the pictures using Adobe Illustrator (CS), which improved the engraving substantially. We then imported the smoothed files using Corel, which can convert to the DXF format which is supported by the laser cutter. Afterwards, I figured out that Corel Draw supports similar smoothing features, so the rest of the images were smoothed and exported in Corel only.</p>
<p>I tested engraving these images using the laser settings that had worked with spray paint (speed = 300, power = 20), and it turned out well. The acrylic paint doesn&#8217;t seem to be that sensitive to the power setting of the laser. I found that so long as the power was in the right ballpark, the paint from the etched areas would come off when I washed the plexiglass with soap and water. This resulted in very clear etching.</p>
<div id="attachment_2826" class="wp-caption aligncenter" style="width: 410px"><a href="http://www.kwartzlab.ca/2012/08/laser-cut-coasters/img-20120818-00042/" rel="attachment wp-att-2826"><img class="size-medium wp-image-2826" src="http://www.kwartzlab.ca/wp-content/uploads/2012/08/IMG-20120818-00042-400x300.jpg" alt="" width="400" height="300" /></a><p class="wp-caption-text">It worked!</p></div>
<p>I then painted the backs of the coasters to add colour.</p>
<div id="attachment_2827" class="wp-caption aligncenter" style="width: 410px"><a href="http://www.kwartzlab.ca/2012/08/laser-cut-coasters/img-20120819-00044/" rel="attachment wp-att-2827"><img class="size-medium wp-image-2827" src="http://www.kwartzlab.ca/wp-content/uploads/2012/08/IMG-20120819-00044-400x300.jpg" alt="" width="400" height="300" /></a><p class="wp-caption-text">Painting!</p></div>
<p>&nbsp;</p>
<div id="attachment_2828" class="wp-caption aligncenter" style="width: 410px"><a href="http://www.kwartzlab.ca/2012/08/laser-cut-coasters/img-20120819-00043/" rel="attachment wp-att-2828"><img class="size-medium wp-image-2828" src="http://www.kwartzlab.ca/wp-content/uploads/2012/08/IMG-20120819-00043-400x300.jpg" alt="" width="400" height="300" /></a><p class="wp-caption-text">Before and after</p></div>
<p>I then used the laser cutter to trim around the edges, removing any paint I had dripped around the edges while painting.</p>
<p>I tried putting corkboard on the back of the coasters, but found that corkboard doesn&#8217;t cut well (and smells really bad) in the laser cutter, and it crumbled when I tried to cut it using scissors or a knife.  So I ended up cutting pieces of white acrylic and gluing them to the back with crazy glue.</p>
<div id="attachment_2829" class="wp-caption aligncenter" style="width: 410px"><a href="http://www.kwartzlab.ca/2012/08/laser-cut-coasters/stack/" rel="attachment wp-att-2829"><img class="size-medium wp-image-2829" src="http://www.kwartzlab.ca/wp-content/uploads/2012/08/stack-400x300.jpg" alt="" width="400" height="300" /></a><p class="wp-caption-text">Hey, it works</p></div>
<div id="attachment_2830" class="wp-caption aligncenter" style="width: 410px"><a href="http://www.kwartzlab.ca/2012/08/laser-cut-coasters/img-20120819-00051/" rel="attachment wp-att-2830"><img class="size-medium wp-image-2830" src="http://www.kwartzlab.ca/wp-content/uploads/2012/08/IMG-20120819-00051-400x300.jpg" alt="" width="400" height="300" /></a><p class="wp-caption-text">And we have coasters!</p></div>
<p>Now these coasters are ready to use. So if you see a couple that looks anything like the pictures, be sure not to ruin the surprise!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kwartzlab.ca/2012/08/laser-cut-coasters/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Simulating a Tama-Go Figure</title>
		<link>http://www.kwartzlab.ca/2012/06/simulating-tama-go-figure/</link>
		<comments>http://www.kwartzlab.ca/2012/06/simulating-tama-go-figure/#comments</comments>
		<pubDate>Mon, 25 Jun 2012 03:47:03 +0000</pubDate>
		<dc:creator>Natalie Silvanovich</dc:creator>
				<category><![CDATA[Member Blogs]]></category>

		<guid isPermaLink="false">http://www.kwartzlab.ca/?p=2591</guid>
		<description><![CDATA[I&#8217;ve been trying to simulate a Tama-Go figure ROM for awhile, so I can write my own Tamagotchi games, and hopefully find some way to dump the main ROM of a Tamagotchi. I tried to obtain compatible flash memory, but GeneralPlus (the maker of the low-power SPI ROM used in Tamagotchi figures) does not deal [...]]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve been trying to simulate a Tama-Go figure ROM for awhile, so I can write my own Tamagotchi games, and hopefully find some way to dump the main ROM of a Tamagotchi. I tried to obtain compatible flash memory, but GeneralPlus (the maker of the low-power SPI ROM used in Tamagotchi figures) does not deal in small quantities, and the closest match I could find wasn&#8217;t close enough to work properly. I also tried using SPI on my Arduino, but it wasn&#8217;t quite fast enough to keep up with the Tamagotchi, and the resistor on pin 13 caused problems detecting SPI clock. Finally, I ordered a ChipKit Uno32, a faster, PIC-based Arduino clone.</p>
<div id="attachment_2592" class="wp-caption aligncenter" style="width: 570px"><a href="http://www.kwartzlab.ca/2012/06/simulating-tama-go-figure/img-20120521-00006/" rel="attachment wp-att-2592"><img class=" wp-image-2592   " src="http://www.kwartzlab.ca/wp-content/uploads/2012/06/IMG-20120521-00006.jpg" alt="ChipKit Uno 32" width="560" height="420" /></a><p class="wp-caption-text">ChipKit Uno 32</p></div>
<p><span id="more-2591"></span>This board is fast enough to keep up with the Tama-Go, and uses jumpers for SPI slave mode, so the resistor on pin13 is avoided.</p>
<p>There are still some speed limitations when using this board&#8211; having it query external memory or devices, or even do a lot of math to determine the return value for an SPI command is out of the question, but it can return a reasonable number values that are included in code. It&#8217;s not possible to simulate the entire Tamagotchi ROM at once this way, as there&#8217;s not enough memory, but I hope I can simulate it bit-by-bit in order to determine the format (although I suspect I might run out of memory when doing the game portion).</p>
<p>I started by simulating a figure being attached to the Tamagotchi. When this happens, the Tamagotchi displays an object in the background (for example, a wardrobe that clothes come out of, if it&#8217;s a figure that&#8217;s a &#8216;clothing store&#8217;, or a table if the figure&#8217;s a &#8216;restaurant&#8217;). It also plays a song, and displays a screen with the figure character dancing if this is the first time this particular figure has been attached to the Tamagotchi.</p>
<p>Using the SPI functionality of the ChipKit Uno, I determined what memory address the Tamagotchi queries when a figure is first attached, and then modified the code to return the value at that memory address (which I got from the figure ROM dump I did awhile ago) after the first SPI command. Once this value was correct, the Tamagotchi started to make a second query, so I made the code return the value at that address after the second query, and so on. Unfortunately, a lot of this had to be done manually, although I used Python to generate some of the code.</p>
<p>Currently, I can simulate up to the background image being loaded. Details of the simulation are below</p>
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td valign="top" width="73"><strong>Query   </strong></td>
<td valign="top" width="113"><strong>Command</strong></td>
<td valign="top" width="104"><strong>Returned Values  </strong></td>
<td valign="top" width="348"><strong>Comment</strong></td>
</tr>
<tr>
<td valign="top" width="73">1</td>
<td valign="top" width="113">Read 0&#215;000001</td>
<td valign="top" width="104">0xaa 0&#215;55 0&#215;08</td>
<td valign="top" width="348">If this value is not exactly as shown (as far as I can tell), no more queries are received</td>
</tr>
<tr>
<td valign="top" width="73">2</td>
<td valign="top" width="113">Read 0&#215;000011</td>
<td valign="top" width="104">0xaa 0&#215;55</td>
<td valign="top" width="348">Returning these values has no visible effect, but Tamagotchi makes an additional query</td>
</tr>
<tr>
<td valign="top" width="73">3</td>
<td valign="top" width="113">Read 0&#215;000013</td>
<td valign="top" width="104">0&#215;03 0&#215;03 0&#215;03 0&#215;00 0&#215;00 0&#215;10 0&#215;03</td>
<td valign="top" width="348">Returning these values cause the figure to be visibly &#8216;detected&#8217;. If this is the first time it&#8217;s been detected, the new figure song plays, and the background for the dancing character is shown, but no character (the Tamagotchi is probably trying to load it, but getting back zeros). If the figure has been attached before, the &#8216;smoke&#8217; for when the background object is displayed appears, and the tone plays, but the device freezes before the wardrobe is displayed</td>
</tr>
<tr>
<td valign="top" width="73">4-13</td>
<td valign="top" width="113">Read 0&#215;20-0&#215;50</td>
<td valign="top" width="104">corresponding address values</td>
<td valign="top" width="348">Returning these values has no visible effect, but I suspect it is where the &#8216;dancing character&#8217; is loaded (which isn&#8217;t actually displayed, because I&#8217;ve loaded this &#8216;figure&#8217; before)</td>
</tr>
<tr>
<td valign="top" width="73">14</td>
<td valign="top" width="113">Read 0&#215;000001</td>
<td valign="top" width="104">0xaa 0&#215;55</td>
<td valign="top" width="348">A several second delay, probably checking that the figure is still attached</td>
</tr>
<tr>
<td valign="top" width="73">15</td>
<td valign="top" width="113">Read 0x0000CE</td>
<td valign="top" width="104">0x9a 0x2b 0&#215;00</td>
<td valign="top" width="348">The first two values are clearly a pointer to the background image (I tested this by changing the value, and it attempted to read the new value + 0&#215;10 next), not sure what the 0 is for</td>
</tr>
<tr>
<td valign="top" width="73">16</td>
<td valign="top" width="113">Read 0x002BAA</td>
<td valign="top" width="104">0&#215;11 0&#215;15</td>
<td valign="top" width="348">Image dimensions</td>
</tr>
<tr>
<td valign="top" width="73">17-</td>
<td valign="top" width="113"></td>
<td valign="top" width="104"></td>
<td valign="top" width="348">The image is read</td>
</tr>
</tbody>
</table>
<p>Next up is tampering with these values to see if I can cause any unexpected behavior.</p>
<p>The code for this is available <a href="https://github.com/natashenka/Tamagotchi-Hack">here</a>, and I&#8217;ve also uploaded a dissembler for two GeneralPlus instruction sets. You never know when you might need to disassemble a GeneralPlus binary, and it&#8217;s best to be prepared for these sort of things <img src='http://www.kwartzlab.ca/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kwartzlab.ca/2012/06/simulating-tama-go-figure/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Tama-Go Mask ROM Images</title>
		<link>http://www.kwartzlab.ca/2011/11/tama-go-mask-rom-images/</link>
		<comments>http://www.kwartzlab.ca/2011/11/tama-go-mask-rom-images/#comments</comments>
		<pubDate>Mon, 21 Nov 2011 05:00:28 +0000</pubDate>
		<dc:creator>Natalie Silvanovich</dc:creator>
				<category><![CDATA[Member Blogs]]></category>

		<guid isPermaLink="false">http://www.kwartzlab.ca/?p=2123</guid>
		<description><![CDATA[I dumped a Tama-Go mask ROM, pulled out of a Memetchi figure. I was able to recognize image data in the memory. I removed the ROM from a figure, soldered wires to the pads and used the Arduino SPI library to dump the memory. This was a very slow process (the data transfer rate was a few [...]]]></description>
				<content:encoded><![CDATA[<p>I dumped a Tama-Go mask ROM, pulled out of a Memetchi figure. I was able to recognize image data in the memory.</p>
<div id="attachment_2124" class="wp-caption aligncenter" style="width: 410px"><a href="http://www.kwartzlab.ca/2011/11/tama-go-mask-rom-images/rom3/" rel="attachment wp-att-2124"><img class="size-medium wp-image-2124" src="http://www.kwartzlab.ca/wp-content/uploads/2011/11/rom3-400x353.jpg" alt="" width="400" height="353" /></a><p class="wp-caption-text">ROM Dumping</p></div>
<p><span id="more-2123"></span></p>
<p>I removed the ROM from a figure, soldered wires to the pads and used the Arduino SPI library to dump the memory. This was a very slow process (the data transfer rate was a few hundred bytes per second running the library at max speed), and voltage dividers were needed to step down the voltage in order not to overload the memory. The first few attempts to dump memory resulted in heavily corrupted dumps, I suspect this was due to the Arduino having trouble reading data close to the input voltage threshold, as running the memory at a voltage closer to its maximum solved the problem.</p>
<p>The ROM dump contained many strings of 0&#215;55, 0xAA and 0xFF. I suspected that these represented strings of identical pixels, as the Tama-Go uses a four-shade greyscale display, so pixels would be represented as two bits, and four identical pixels would be represented as 10101010 (0xAA), 01010101 (0&#215;55), 11111111 (0xff) or 00000000 (0&#215;00). Looking through the binary, I found an instance where a string of 5&#8242;s was preceeded by two values which seemed reasonable for width and height, and the string was exactly long enough to provide data for an image with that width and height.</p>
<p>I wrote a script to decode this image, and after a few decoding accidents, extracted an image.</p>
<div id="attachment_2125" class="wp-caption aligncenter" style="width: 410px"><a href="http://www.kwartzlab.ca/2011/11/tama-go-mask-rom-images/decode/" rel="attachment wp-att-2125"><img class="size-medium wp-image-2125" src="http://www.kwartzlab.ca/wp-content/uploads/2011/11/decode-400x142.jpg" alt="" width="400" height="142" /></a><p class="wp-caption-text">They can&#039;t _always_ decode properly ...</p></div>
<p>&nbsp;</p>
<div id="attachment_2126" class="wp-caption aligncenter" style="width: 233px"><a href="http://www.kwartzlab.ca/2011/11/tama-go-mask-rom-images/ready/" rel="attachment wp-att-2126"><img class="size-full wp-image-2126" src="http://www.kwartzlab.ca/wp-content/uploads/2011/11/ready.jpg" alt="" width="223" height="145" /></a><p class="wp-caption-text">Success!</p></div>
<p>I wrote a longer script to dump all the images on the ROM.  There were about 7000 images, taking up about 60% of the 32MBit ROM.</p>
<p>These images give some interesting insight into how the Tama-Go works internally. For example, outside of user-generated data, text doesn&#8217;t appear to be stored as strings. All of the text displayed while using the figure was part of the images dumped.</p>
<div id="attachment_2127" class="wp-caption aligncenter" style="width: 820px"><a href="http://www.kwartzlab.ca/2011/11/tama-go-mask-rom-images/text/" rel="attachment wp-att-2127"><img class="size-full wp-image-2127" src="http://www.kwartzlab.ca/wp-content/uploads/2011/11/text.jpg" alt="" width="810" height="154" /></a><p class="wp-caption-text">Text Strings</p></div>
<p>Also, for every item in the game, there were images of every single Tamagotchi using it, for example, pictures of every Tamagotchi in the dress.</p>
<div id="attachment_2128" class="wp-caption aligncenter" style="width: 812px"><a href="http://www.kwartzlab.ca/2011/11/tama-go-mask-rom-images/dresst/" rel="attachment wp-att-2128"><img class="size-full wp-image-2128" src="http://www.kwartzlab.ca/wp-content/uploads/2011/11/dresst.jpg" alt="" width="802" height="574" /></a><p class="wp-caption-text">Tamagotchis in dresses</p></div>
<p>This makes me suspect that Tamagotchi programs aren&#8217;t very &#8216;smart&#8217;, and simply display bitmap images on the screen in sequence.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kwartzlab.ca/2011/11/tama-go-mask-rom-images/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Tama-Go Mask ROM</title>
		<link>http://www.kwartzlab.ca/2011/07/tama-go-mask-rom/</link>
		<comments>http://www.kwartzlab.ca/2011/07/tama-go-mask-rom/#comments</comments>
		<pubDate>Mon, 25 Jul 2011 02:43:06 +0000</pubDate>
		<dc:creator>Natalie Silvanovich</dc:creator>
				<category><![CDATA[Member Blogs]]></category>

		<guid isPermaLink="false">http://www.kwartzlab.ca/?p=1621</guid>
		<description><![CDATA[As a next step in trying to dump the Tamagotchi code, I&#8217;m trying to dump the mask ROM that comes in Tama-Go figures. After an hour or so of messing around with a signal analyser, I decided to take a look at the board. On the right is an unpopulated board for that Tamagotchi figure, the [...]]]></description>
				<content:encoded><![CDATA[<p>As a next step in trying to dump the Tamagotchi code, I&#8217;m trying to dump the mask ROM that comes in Tama-Go figures. After an hour or so of messing around with a signal analyser, I decided to take a look at the board.</p>
<div id="attachment_1624" class="wp-caption aligncenter" style="width: 694px"><a href="http://www.kwartzlab.ca/2011/07/tama-go-mask-rom/rom/" rel="attachment wp-att-1624"><img class="size-full wp-image-1624" alt="" src="http://www.kwartzlab.ca/wp-content/uploads/2011/07/ROM.jpg" width="684" height="297" /></a><p class="wp-caption-text">Mask ROM and Unpopulated Board</p></div>
<p><span id="more-1621"></span>On the right is an unpopulated board for that Tamagotchi figure, the blue areas are what was visible before I scraped the covering off the traces. Based on the position of the pads and the size of the rectangle for the die, I think it&#8217;s a <a href="http://www.generalplus.com/products/memory/datasheet/GPR26L160AV14_ds.pdf">GeneralPlus GPR26LXXX Low Voltage SPI ROM</a>, either the 8MB or the 16MB version.</p>
<div id="attachment_1627" class="wp-caption aligncenter" style="width: 410px"><a href="http://www.kwartzlab.ca/2011/07/tama-go-mask-rom/rom2/" rel="attachment wp-att-1627"><img class="size-medium wp-image-1627" alt="" src="http://www.kwartzlab.ca/wp-content/uploads/2011/07/rom2-400x146.jpg" width="400" height="146" /></a><p class="wp-caption-text">GeneralPlus MaskROMs</p></div>
<p>This means that the Tamagotchi figure pins are then as follows:</p>
<div id="attachment_1628" class="wp-caption aligncenter" style="width: 228px"><a href="http://www.kwartzlab.ca/2011/07/tama-go-mask-rom/pins/" rel="attachment wp-att-1628"><img class="size-full wp-image-1628" alt="" src="http://www.kwartzlab.ca/wp-content/uploads/2011/07/pins.jpg" width="218" height="231" /></a><p class="wp-caption-text">Tama-Go Pins</p></div>
<p>1, 4 and 8: <del>Ground/Jumper</del> Power/Jumper (Edited 2013/02/09)</p>
<p>2: Serial clock (C)</p>
<p>3: Serial data input (D)</p>
<p>5: <del>Power</del> Ground (Edited 2013/02/09)</p>
<p>6: Chip Select (SB)</p>
<p>7: Serial Data Output (Q)</p>
<p>I tried to confirm this by removing the PCB from the back of the die and taking a peek at the pads (yes, I realize now that they&#8217;re on the top).</p>
<div id="attachment_1629" class="wp-caption aligncenter" style="width: 410px"><a href="http://www.kwartzlab.ca/2011/07/tama-go-mask-rom/epoxy/" rel="attachment wp-att-1629"><img class="size-medium wp-image-1629" alt="" src="http://www.kwartzlab.ca/wp-content/uploads/2011/07/epoxy-400x300.jpg" width="400" height="300" /></a><p class="wp-caption-text">Silver glittery stuff everywhere!</p></div>
<p>It turns out that this is not a recommended technique.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kwartzlab.ca/2011/07/tama-go-mask-rom/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Tama-Go EEPROM</title>
		<link>http://www.kwartzlab.ca/2011/07/tama-go-eeprom/</link>
		<comments>http://www.kwartzlab.ca/2011/07/tama-go-eeprom/#comments</comments>
		<pubDate>Sun, 24 Jul 2011 15:55:12 +0000</pubDate>
		<dc:creator>Natalie Silvanovich</dc:creator>
				<category><![CDATA[Member Blogs]]></category>

		<guid isPermaLink="false">http://www.kwartzlab.ca/?p=1613</guid>
		<description><![CDATA[Tamagotchi boards contain an EEPROM mounted externally from the MCU, to save the game state so it can be restored if power is lost or the Tamagotchi crashes. I hoped that the instruction pointer would be cached as a part of the game state. Spoiler Alert: it isn&#8217;t. I soldered short leads to the EEPROM, and used [...]]]></description>
				<content:encoded><![CDATA[<p>Tamagotchi boards contain an EEPROM mounted externally from the MCU, to save the game state so it can be restored if power is lost or the Tamagotchi crashes.</p>
<div id="attachment_1614" class="wp-caption aligncenter" style="width: 410px"><a href="http://www.kwartzlab.ca/2011/07/tama-go-eeprom/eeprom/" rel="attachment wp-att-1614"><img class="size-medium wp-image-1614" src="http://www.kwartzlab.ca/wp-content/uploads/2011/07/eeprom-400x353.jpg" alt="" width="400" height="353" /></a><p class="wp-caption-text">Tama-Go EEPROM</p></div>
<p>I hoped that the instruction pointer would be cached as a part of the game state. Spoiler Alert: it isn&#8217;t.<span id="more-1613"></span></p>
<p>I soldered short leads to the EEPROM, and used the Arduino Wire library to read the memory using I2C. I found the library very easy to use, and the sample program required almost no modification to access the chip.</p>
<p>The contents of the EEPROM were minimal, and are identifiable as parts of the game state.</p>
<p><a href="http://www.kwartzlab.ca/2011/07/tama-go-eeprom/eeprom2/" rel="attachment wp-att-1615"><img class="aligncenter size-full wp-image-1615" src="http://www.kwartzlab.ca/wp-content/uploads/2011/07/eeprom2.jpg" alt="" width="564" height="280" /></a> I dumped the EEPROM a few times while playing the game to see the effect. I also tried overwriting the state, and saw the changes in the game.</p>
<p>Unfortunately, this means that the EEPROM stores a &#8216;game&#8217; type of state and not a &#8216;stack and registers&#8217; type of state, so probably won&#8217;t be useful in dumping the code from the MCU.</p>
<p>So, from here there are a few ways I could try to dump the code (listed in the order I plan on trying them):</p>
<p>1) Dump a figure mask ROM, and hope it contains code, pointers or something that could be tampered with to get code execution on the Tama-Go</p>
<p>2) Play around the the image formats supported over IR and through figures. I think it&#8217;s unlikely there&#8217;s any vulns in these, but it&#8217;s worth a shot.</p>
<p>3) Try harder to get a GeneralPlus eval board or the contents of the test program. Also, there are some SunPlus MCUs with pins and writable flash that contain a test program, maybe get one of those and dump it and hope the programs are similar.</p>
<p>4) Put the mask ROM under a microscope.</p>
<p>5) Learn about the glitching thing everybody&#8217;s always talking about.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kwartzlab.ca/2011/07/tama-go-eeprom/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
