PC Henshin

Revision for “PC Henshin” created on May 24, 2017 @ 15:01:11

Title
PC Henshin
Content
The PC-Henshin is universal mod-less region converter for Turbografx-16 and PC Engine consoles. It allows Hucard games to be played on Turbografx-16 and Turbochip games to be played on PC Engine. [toc] <h1>Specifications</h1> <h1>Compatibility</h1> <h2>Consoles</h2> <h1><span id="TheConversion_8211PC_Engine_to_Turbografx-16">The Conversion – PC Engine to Turbografx-16</span></h1> Connector issues solved, the conversion to allow PC Engine games to run on Turbografx-16 is quite simple. All that need to be done is to reverse the pin order of the databus. Ignore the CPLD for now, the CPLD is not even soldered on for PC Engine to Turbografx-16 conversion. <figure id="attachment_472" class="wp-caption aligncenter"><a href="https://i0.wp.com/db-electronics.ca/wp-content/uploads/2016/02/PC-Henshin_1410A02.jpg" rel="lightbox[714]"><img class="size-large wp-image-472" src="https://i0.wp.com/db-electronics.ca/wp-content/uploads/2016/02/PC-Henshin_1410A02.jpg?resize=800%2C518" sizes="(max-width: 800px) 100vw, 800px" srcset="https://i0.wp.com/db-electronics.ca/wp-content/uploads/2016/02/PC-Henshin_1410A02.jpg?resize=1024%2C663 1024w, https://i0.wp.com/db-electronics.ca/wp-content/uploads/2016/02/PC-Henshin_1410A02.jpg?resize=300%2C194 300w, https://i0.wp.com/db-electronics.ca/wp-content/uploads/2016/02/PC-Henshin_1410A02.jpg?resize=768%2C497 768w, https://i0.wp.com/db-electronics.ca/wp-content/uploads/2016/02/PC-Henshin_1410A02.jpg?w=2280 2280w" alt="PC Henshin Schematic" width="784" height="508" data-attachment-id="472" data-permalink="http://db-electronics.ca/pc-henshin_1410a02/" data-orig-file="https://i0.wp.com/db-electronics.ca/wp-content/uploads/2016/02/PC-Henshin_1410A02.jpg?fit=2550%2C1650" data-orig-size="2550,1650" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="pc-henshin_1410a02" data-image-description="" data-medium-file="https://i0.wp.com/db-electronics.ca/wp-content/uploads/2016/02/PC-Henshin_1410A02.jpg?fit=300%2C194" data-large-file="https://i0.wp.com/db-electronics.ca/wp-content/uploads/2016/02/PC-Henshin_1410A02.jpg?fit=1024%2C663" /></a><figcaption class="wp-caption-text">PC Henshin Schematic</figcaption></figure> <h1><span id="TheConversion_8211_Turbografx-16_to_PC_Engine">The Conversion – Turbografx-16 to PC Engine</span></h1> The conversion process to allow Turbografx-16 games to run on PC Engine is more complex because Turbografx-16 games (most of them) check which region hardware they are running on. Therefore, you can’t simply reverse the pin order of the databus – you actually have to trick the game into thinking it is running on Turbografx-16 hardware. <h2><span id="Region_Check_Code">Region Check Code</span></h2> My good friend, Ishiyakazuo, wrote a scanning tool which analyzed all Turbografx-16 roms in the goodset to identify similar biinary data – our hope was that similar data could indicate boiler plate region check code handed down by NEC to Turbografx-16 developers. One would assume that whatever code is performing the region check, even without being familiar with TG-16’s CPU, would look a little something like this: <pre> test regionBit beq gameCode bra infiniteLoop</pre> As luck would have it, we found the following code in ALL roms: 0x78 0x54 0xA9 0xFF 0x53 0x01 0xAD 0x00 0x10 0x29 0x80 I’ll leave it to the reader to figure it out as an exercise in HuC6280 assembly. But essentially, you can draw the following conclusions from disassembling this code and analyzing all ROMs: <ul> <li>We only need to detect the first 7 bytes of the pattern since this pattern exists NOWHERE else in any game</li> <li>To fool the region check, we can simply replace the final 0x80 by a 0x00</li> </ul> <h3>Method</h3> Ishikazuo, with a bit of assistance from myself, wrote a VHDL state machine which looks for the 7 byte pattern discussed aboved. The console’s #OE signal is routed through a CPLD, when the 7 byte pattern is detected, the state machine counts the bytes until we reach where the 0x80 should be. At that point, we simply prevent #OE from reaching the HuCard and instead we drive 0x00 on the databus. Sounds pretty straightforward – and really, it’s basically a glorified Game Genie with only 1 function. <a href="https://github.com/db-electronics/PCHenshin/blob/master/PCHenshin.vhd" target="_blank" rel="noopener noreferrer">PC Henshin VHDL on Github</a> <h3>One Hurdle</h3> The only hurdle we encountered is that the HuC6280 does a bit of prefetching on certain opcodes. Therefore, this slightly modified the byte pattern we were looking for. #TODO remember which damn signal is #OE <a href="https://i1.wp.com/db-electronics.ca/wp-content/uploads/2016/02/pc-henshin-debug2.png" rel="lightbox[714] attachment wp-att-237"><img class="aligncenter size-large wp-image-237" src="https://i1.wp.com/db-electronics.ca/wp-content/uploads/2016/02/pc-henshin-debug2.png?resize=800%2C430" sizes="(max-width: 800px) 100vw, 800px" srcset="https://i1.wp.com/db-electronics.ca/wp-content/uploads/2016/02/pc-henshin-debug2.png?resize=1024%2C551 1024w, https://i1.wp.com/db-electronics.ca/wp-content/uploads/2016/02/pc-henshin-debug2.png?resize=300%2C162 300w, https://i1.wp.com/db-electronics.ca/wp-content/uploads/2016/02/pc-henshin-debug2.png?resize=768%2C413 768w, https://i1.wp.com/db-electronics.ca/wp-content/uploads/2016/02/pc-henshin-debug2.png?w=1382 1382w" alt="pc-henshin-debug2" width="800" height="430" data-attachment-id="237" data-permalink="http://db-electronics.ca/pc-henshin-debug2/" data-orig-file="https://i1.wp.com/db-electronics.ca/wp-content/uploads/2016/02/pc-henshin-debug2.png?fit=1382%2C744" data-orig-size="1382,744" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="pc-henshin-debug2" data-image-description="" data-medium-file="https://i1.wp.com/db-electronics.ca/wp-content/uploads/2016/02/pc-henshin-debug2.png?fit=300%2C162" data-large-file="https://i1.wp.com/db-electronics.ca/wp-content/uploads/2016/02/pc-henshin-debug2.png?fit=1024%2C551" /></a> Instead of hard-coding which bytes would be repeated we simply changed the VHDL state machine to allow most of the byte pattern to have repeated bytes without losing track of the pattern. It’s just better programming that way!
Excerpt


OldNewDate CreatedAuthorActions
May 24, 2017 @ 15:01:11 René
May 24, 2017 @ 15:01:09 [Autosave] René
May 24, 2017 @ 14:46:30 René

René

Electronics engineer and retrogaming fanatic!