{"id":164,"date":"2011-04-17T18:03:14","date_gmt":"2011-04-17T17:03:14","guid":{"rendered":"http:\/\/blog.blockos.org\/?p=164"},"modified":"2015-11-30T10:56:36","modified_gmt":"2015-11-30T09:56:36","slug":"alices-bubbles-part-1","status":"publish","type":"post","link":"https:\/\/blog.blockos.org\/?p=164","title":{"rendered":"Alice&#8217;s bubbles (Part 1)"},"content":{"rendered":"<p><img decoding=\"async\" class=\"aligncenter\" src=\"http:\/\/blog.blockos.org\/wp-content\/uploads\/2011\/04\/Marchen_Maze.png\" alt=\"Marchen Maze title screen\" \/><br \/>\nOr more humbly, the awesome M\u00e4rchen Maze translation postmortem. It&#8217;s more or less a compilation\/addendum for this pcedev forum <a href=\"http:\/\/pcedev.blockos.org\/viewtopic.php?f=5&amp;t=52\">[post]<\/a>.<\/p>\n<p>M\u00e4rchen Maze is a PCEngine HuCard game released by Namco the 11th of December 1990. It&#8217;s a conversion of the 1988 arcade game. It was also ported to the almighty Sharp X68000. As you may have guessed the X68000 version is a near perfect conversion of the original arcade game. It features some jolly 3D isometric view and colourfull introduction. Well, things are not that fancy on the PCEngine version. The 3D isometric view was changed to a top view (\u00e0 la Mercs or Commando). And the intro is now in sepia tones. What about the story and gameplay? Check the Video Game Den review <a href=\"http:\/\/www.videogameden.com\/hucard.htm?mma\">[here]<\/a>.<\/p>\n<p>Ok! Back to business.<br \/>\nThe PCEngine has some neat RPGs. Unfortunately only a few of them were translated into the idiom of the perfidious Albion (English). This was a perfect excuse for trying out that black art called romhacking. <a href=\"http:\/\/www.videogameden.com\/cdrom.htm?mom\">Monster Maker<\/a> was my first choice. I must admin that cdrom games are not a really good choice for your first romhacking experience. A HuCard game is far more simpler to hack. So I went for <a href=\"http:\/\/www.videogameden.com\/hucard.htm?mok\">Momotar\u014d Katsugeki<\/a>. It&#8217;s a cool platform game with tons of text. Unfortunately the text is displayed top to bottom and from left to right in bubbles. It was clearly out of my league. So I asked some people if they knew some easily translatable games. I can&#8217;t remember who suggested it. But M\u00e4rchen Maze was designated as it doesn&#8217;t have too much text and no apparent string compression.<\/p>\n<p>The first thing I had to do was to find where the text was stored in the ROM. After hours of pain, <a href=\"http:\/\/pages.interlog.com\/~daves\/\">David Shadoff<\/a> took pity. And like a mighty wizard, he managed to extract the whole script in no time. So I had the rom location of the strings. All I had to do was to put read breakpoint in <a href=\"http:\/\/mednafen.sourceforge.net\">Mednafen<\/a>. I was able to locate the text output routine (<strong>$87D6<\/strong>). The string &#8220;parsing&#8221; was spotted from <strong>$89E5<\/strong> to $<strong>8CD8 <\/strong>using step-by-step debugging starting from the the output routine. It made me realized that <strong>$5C<\/strong>,<strong>$5D<\/strong> held the pointer to the string to be displayed. The parsing routine was called from <strong>$E377<\/strong> using <strong>jmp ($202C)<\/strong> instead of <strong>jsr<\/strong>. The return address was pushed by hand onto the stack. Here&#8217;s an snippet of the parsing routine. <strong>$ff<\/strong> is a special value. More on this later.<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">l_89e2: LDY     $271b\r\n        LDA     [$5c], Y\r\n        CMP     #$ff\r\n        BNE     l_89ee<\/pre>\n<p>The most important information was that I now knew the zero page location holding the string pointer. Setting a write breakpoint to <strong>$5C:$5D<\/strong> led me to <strong>$8C4B<\/strong>. <\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">        LDA     [$52], Y\r\n        STA     &lt;$5c\r\n        INY     \r\n        LDA     [$52], Y\r\n        STA     &lt;$5d<\/pre>\n<p> I was lucky because what precedes told me where the string table was. <\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">        LDA     #$00\r\n        STA     &lt;$64\r\n        LDA     #$56\r\n        STA     &lt;$65\r\n        LDY     #$0c\r\n        LDA     [$64], Y\r\n        STA     &lt;$52\r\n        INY     \r\n        LDA     [$64], Y\r\n        STA     &lt;$53\r\n        LDA     $2716\r\n        ASL     A\r\n        TAY     \r\n        LDA     [$52], Y\r\n        STA     &lt;$5c\r\n        INY     \r\n        LDA     [$52], Y\r\n        STA     &lt;$5d<\/pre>\n<p> So <strong>$5c:$5d<\/strong> is set using the data pointed by <strong>$52:$53<\/strong> indexed by <strong>$2716<\/strong>. Let&#8217;s put <strong>$2716<\/strong> aside. This is clearly the string index. So <strong>$52:$53<\/strong> contains our string pointer. And the preceding lines tells us that the string table address is stored at <strong>$560C<\/strong>. A quick revealed that the string table was stored from <strong>$5614<\/strong> to <strong>$5849<\/strong>. If we translate the address, it&#8217;s at the file offsets <strong>$11814<\/strong> to <strong>$11A49<\/strong> (this is with the annoying 512 bytes offset). Now that I had the string pointer table, I could make it point to whenever I want (technically). So the translated texts may not have to fit into the original string locations. I checked that I got it right by swapping the pointer table entries. And as expected the intro started with the second text and so on.<br \/>\nA quick look at the tile vram showed me that the font already contains capital letters. So I decided to manually edit the ROM and managed to get this:<br \/>\n<img decoding=\"async\" class=\"aligncenter\" src=\"http:\/\/blog.blockos.org\/wp-content\/uploads\/2011\/04\/MarchenTest.png\" alt=\"Quick hack\" \/><\/p>\n<p>The next step was to modify the font in order to have lowercase letters.<br \/>\nTo continue&#8230;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Or more humbly, the awesome M\u00e4rchen Maze translation postmortem. It&#8217;s more or less a compilation\/addendum for this pcedev forum [post]. M\u00e4rchen Maze is a PCEngine HuCard game released by Namco the 11th of December 1990. It&#8217;s a conversion of the 1988 arcade game. It was also ported to the almighty\u2026 <a class=\"continue-reading-link\" href=\"https:\/\/blog.blockos.org\/?p=164\">Continue reading<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3,6],"tags":[27,30,19],"_links":{"self":[{"href":"https:\/\/blog.blockos.org\/index.php?rest_route=\/wp\/v2\/posts\/164"}],"collection":[{"href":"https:\/\/blog.blockos.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.blockos.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.blockos.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.blockos.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=164"}],"version-history":[{"count":70,"href":"https:\/\/blog.blockos.org\/index.php?rest_route=\/wp\/v2\/posts\/164\/revisions"}],"predecessor-version":[{"id":1022,"href":"https:\/\/blog.blockos.org\/index.php?rest_route=\/wp\/v2\/posts\/164\/revisions\/1022"}],"wp:attachment":[{"href":"https:\/\/blog.blockos.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=164"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.blockos.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=164"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.blockos.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=164"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}