{"id":22,"date":"2012-08-08T03:31:43","date_gmt":"2012-08-08T09:31:43","guid":{"rendered":"http:\/\/elysianshadows.com\/2012\/08\/estk-dreamcast-integration\/"},"modified":"2012-08-08T03:31:43","modified_gmt":"2012-08-08T09:31:43","slug":"estk-dreamcast-integration","status":"publish","type":"post","link":"http:\/\/elysianshadows.com\/updates\/estk-dreamcast-integration\/","title":{"rendered":"ESTk Dreamcast Integration"},"content":{"rendered":"\n<p><span style=\"text-decoration: underline; font-size: 14pt;\"><strong>FRONT-END: Artists, musicians, level developers, and right-brained people<\/strong><\/span><br \/><strong><span style=\"color: #ff00ff;\">1) Invoking the Dreamcast<\/p>\n<p><\/span><\/strong><em><span style=\"color: #ff0000;\">NOTE: Before you can begin invoking the Dreamcast from ESTk, you must burn dc-lool ip and load it into your Dreamcast. This doesn&#8217;t require a modded or special Dreamcast. It just requires you burning the image correctly. DC-Load IP allows you to send executable files from your PC to your DC. Currently the Toolkit only supports the IP version (as opposed to the serial version), so your Dreamcast will require a broadband adapter.<\/span><\/em><\/p>\n<p>You can invoke the engine from the Toolbar, by selecting the desired icon from the drop-down menu and pushing the play button<br \/><img loading=\"lazy\" decoding=\"async\" class=\" size-full wp-image-15\" src=\"http:\/\/elysianshadows.com\/updates\/wp-content\/uploads\/2012\/08\/invokeDCIcon.png\" alt=\"invokeDCIcon.png\" width=\"324\" height=\"276\" width=\"324\" height=\"276\" srcset=\"http:\/\/elysianshadows.com\/updates\/wp-content\/uploads\/2012\/08\/invokeDCIcon.png 324w, http:\/\/elysianshadows.com\/updates\/wp-content\/uploads\/2012\/08\/invokeDCIcon-300x255.png 300w\" sizes=\"auto, (max-width: 324px) 100vw, 324px\" \/><br \/>OR you can invoke the engine from the Engine file menu by selecting a platform.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\" size-full wp-image-16\" src=\"http:\/\/elysianshadows.com\/updates\/wp-content\/uploads\/2012\/08\/invokeDCDropDown.png\" alt=\"invokeDCDropDown.png\" width=\"386\" height=\"240\" width=\"386\" height=\"240\" srcset=\"http:\/\/elysianshadows.com\/updates\/wp-content\/uploads\/2012\/08\/invokeDCDropDown.png 386w, http:\/\/elysianshadows.com\/updates\/wp-content\/uploads\/2012\/08\/invokeDCDropDown-300x186.png 300w\" sizes=\"auto, (max-width: 386px) 100vw, 386px\" \/><br \/><strong><span style=\"color: #ff00ff;\">2) Error without Settings<\/span><\/strong><\/p>\n<p>Since this is our first time running the ESTk, we will receive an error message in the Toolkit&#8217;s debug log when we try to invoke the Dreamcast bitching about our configuration.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\" size-full wp-image-17\" src=\"http:\/\/elysianshadows.com\/updates\/wp-content\/uploads\/2012\/08\/invokeDCSettingsError.png\" alt=\"invokeDCSettingsError.png\" width=\"828\" height=\"690\" width=\"828\" height=\"690\" srcset=\"http:\/\/elysianshadows.com\/updates\/wp-content\/uploads\/2012\/08\/invokeDCSettingsError.png 828w, http:\/\/elysianshadows.com\/updates\/wp-content\/uploads\/2012\/08\/invokeDCSettingsError-300x250.png 300w\" sizes=\"auto, (max-width: 828px) 100vw, 828px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><strong><span style=\"color: #ff00ff;\">3) Enter Dreamcast-Specific Settings<\/span><\/strong><\/p>\n<p>The &#8220;Engine Settings&#8221; dialog will launch, requesting Dreamcast-specific settings.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\" size-full wp-image-18\" src=\"http:\/\/elysianshadows.com\/updates\/wp-content\/uploads\/2012\/08\/invokeDCSettings.png\" alt=\"invokeDCSettings.png\" width=\"563\" height=\"382\" width=\"563\" height=\"382\" srcset=\"http:\/\/elysianshadows.com\/updates\/wp-content\/uploads\/2012\/08\/invokeDCSettings.png 563w, http:\/\/elysianshadows.com\/updates\/wp-content\/uploads\/2012\/08\/invokeDCSettings-300x203.png 300w\" sizes=\"auto, (max-width: 563px) 100vw, 563px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><strong>MAC Address<\/strong> &#8211; Hardware address of your Dreamcast&#8217;s ethernet adapter. DC-Load will display this onscreen once your DC boots. (note: 00:00:00:00:00 format on Linux\/OSX and 00-00-00-00-00 format on Windows)<br \/><strong>IP Address<\/strong> &#8211; The desired IP address you wish to assign to your Dreamcast<br \/><strong>SUDO Password<\/strong> &#8211; Only required for OSX and Linux. This is required to add an entry to your arp table for the Dreamcast. It is not saved with the rest of the settings for security reasons, so you will have to reenter every time ESTk is launched. (note: Windows does not require a password for the ARP, because the manifest embedded within the win32 executable requires you to run ESTk as an administrator).<\/p>\n<p><em><span style=\"color: #ff0000;\">COMMENT: Special thanks to Marcel for this dialog box&#8230; I only know how to code these fuckers by hand (never really learned to use designer), and we have decided as a team to migrate away from hand-coded widgets so that non developers can also contribute to widget design through QT designer&#8230; Marcel dropped everything on his entity framework, whipped the dialog together, rigged up all of the signals and slots, AND EVEN MADE THE BASTARD SAVE YOUR SETTINGS!<\/span><\/em><\/p>\n<p><strong><span style=\"color: #ff00ff;\">4) Reinvoke<\/span><\/strong><br \/>Now attempt to reinvoke the Dreamcast. If your settings are correct, ESTk should enter an entry into your arp table for the DC and begin the transfer. You can see both dc-tool&#8217;s debug output and the engine&#8217;s debug output in the engine dialog within ESTk.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\" size-full wp-image-19\" src=\"http:\/\/elysianshadows.com\/updates\/wp-content\/uploads\/2012\/08\/invokeDCOSX.png\" alt=\"invokeDCOSX.png\" width=\"1280\" height=\"800\" width=\"1280\" height=\"800\" srcset=\"http:\/\/elysianshadows.com\/updates\/wp-content\/uploads\/2012\/08\/invokeDCOSX.png 1280w, http:\/\/elysianshadows.com\/updates\/wp-content\/uploads\/2012\/08\/invokeDCOSX-300x187.png 300w, http:\/\/elysianshadows.com\/updates\/wp-content\/uploads\/2012\/08\/invokeDCOSX-1024x640.png 1024w\" sizes=\"auto, (max-width: 1280px) 100vw, 1280px\" \/><\/p>\n<p><strong><span style=\"color: #ff00ff;\">5) Enjoy Your Level on the Dreamcast!<\/span><\/strong><br \/>Now you are able to play through your levels on your Dreamcast as you create them just as you would on a PC!<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\" size-full wp-image-20\" src=\"http:\/\/elysianshadows.com\/updates\/wp-content\/uploads\/2012\/08\/dcscreen1.png\" alt=\"dcscreen1.png\" width=\"640\" height=\"480\" width=\"640\" height=\"480\" srcset=\"http:\/\/elysianshadows.com\/updates\/wp-content\/uploads\/2012\/08\/dcscreen1.png 640w, http:\/\/elysianshadows.com\/updates\/wp-content\/uploads\/2012\/08\/dcscreen1-300x225.png 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\" size-full wp-image-21\" src=\"http:\/\/elysianshadows.com\/updates\/wp-content\/uploads\/2012\/08\/dcscreen2.png\" alt=\"dcscreen2.png\" width=\"640\" height=\"480\" width=\"640\" height=\"480\" srcset=\"http:\/\/elysianshadows.com\/updates\/wp-content\/uploads\/2012\/08\/dcscreen2.png 640w, http:\/\/elysianshadows.com\/updates\/wp-content\/uploads\/2012\/08\/dcscreen2-300x225.png 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/p>\n<p><span style=\"text-decoration: underline; font-size: 14pt;\"><strong>BACK-END: Programmers, developers, big-dick-players, and left-brained people<\/strong><\/span><br \/><strong><span style=\"color: #ff00ff;\">0) File-based Command-line Arguments<\/span><\/strong><br \/>The first design problem that we ran into with invoking the Dreamcast was a lack of support for command-line arguments. ESTk has used a traditional command-line mechanism for specifying a current level or area to load within the engine on Windows, Linux and OSX. The command-line call looks something like:<br \/>[code]esgamma.exe -l C:\/levels\/forest -a C:\/levels\/forest\/areas\/forest1 -x 200 -y 200[\/code] <br \/>This tells ESGamma the level and area to load as well as the starting coordinates for the player.<\/p>\n<p>Unfortunately, dc-tool and dc-load do not pass command-line arguments to the Dreamcast when loading an executable. To circumvent this bullshit, ESGamma now &nbsp;searches for command-line arguments in a text file within the working directory called &#8220;gamma_args.txt&#8221; when no command-line arguments are present. This allows for the traditional, convenient method to be used with Windows, Linux, and OSX, and it allows for ESTk to generate an argument file (with the exact same format) for passing data to the Dreamcast.<\/p>\n<p><strong><span style=\"color: #ff00ff;\">1) Arping and Invoking DC-Tool<\/span><\/strong><br \/>The actual behind-the scenes action taken by ESTk when you push the &#8220;play&#8221; button for the Dreamcast is pretty straightforward.<\/p>\n<p>1) Save the current level and area<br \/>2) Generate gamma_arg.txt as virtual command-line arguments to the ESGammaDC<br \/>3) add arp entry for your Dreamcast<br \/>4) invoke dc-tool and send the Dreamcast build of ESGamma to your DC&#8217;s IP address. <br \/>The command to execute ESGamma on the Dreamcast is:<br \/>[code]dc-tool -x ESGamma.elf -t 192.168.1.1 -c ProjectDirectory[\/code]<br \/>where the &#8216;x&#8217; flag specifies the Dreamcast binary file for the engine, &#8216;t&#8217; specifies the IP address of your Dreamcast, and &#8216;c&#8217; specifies the PC working directory where the Dreamcast should load all of its files from.<\/p>\n<p><strong><span style=\"color: #ff00ff;\">2) Win32 dc-tool Modifications<\/span><\/strong><br \/>Sounds simple enough, doesn&#8217;t it? Unfortunately it&#8217;s rarely ever that simple with multiplatform development. It turns out that the win32 build of dc-tool does not support the -c option (v1.0.3 had the flag, and it didn&#8217;t work, then v1.0.4 took the flag out instead of fixing it). This means that ESTk has no way of telling ESGammaDC where to load the assets from. Without this, the only way to load from a custom PC directory on win32 is to hard-code the PC directory into the Dreamcast build of the engine, which is unacceptable from the Toolkit&#8217;s perspective.<\/p>\n<p>After desperately searching for alternatives, I realized that I had no choice other than to implement the -c flag myself. I downloaded the dc-tool v1.0.4 source and dove in.<\/p>\n<p>I decided to build dc-tool with the QT Creator and the MinGW in its SDK. It wasn&#8217;t too hard, but it definitely took some code changes to get the bastard compiling. Some structures from time.h were not defined, and the there is no nanosecond resolution sleep function (dc-tool really only needed ms). Also, whatever preprocessor directives were being used to check for memset() and memcpy() were wrong.<\/p>\n<p>Once, I finally got the bad boy compilng, I was ready to move onto -c flag. The Linux\/OSX implementation was a single function call to chroot(). This functionality does not exist on Windows, so I was tasked with finding a workaround.<\/p>\n<p>I realized that every Dreamcast access (regardless of the Dreamcast&#8217;s current directory) is an absolute path from root. For example, the Dreamcast requesting a tilesheet, might look like:<br \/>[code]\/level\/Forest\/tile\/tilesheet.png[\/code]<\/p>\n<p>Using this, I was able to store the string passed to dc-tool with the -c flag and concatenate it with every file request. For example, invoking dc-tool with -c C:\/ESDev would result in the above example becoming:<br \/>[code]C:\/ESDev\/level\/Forest\/tile\/tilesheet.png[\/code]<\/p>\n<p>Now we can force every file operation to be relative to our chroot path on Windows.<\/p>\n<p>While I was at it, I also decided to add another flag &#8216;-m&#8217; to the win32 build. The &#8216;-m&#8217; flag takes a windows-formatted mac address parameter and automatically does the arp within dc-tool using the Winsock library. Now we (ESTk) can assign our Dreamcast an IP address and send it an executable with a single command.<\/p>\n<p>Aaaand no article would be complete without some code&#8230; So here&#8217;s all of the logic within our Invoke Engine Dialog window to invoke the bastard on the Dreamcast from every platform:<\/p>\n<pre>case ENGINE_DC: {     \/\/Check if we have all of the required Dreamcast settings     if(_dcIpAddr.isNull() || _dcMacAddr.isNull()) return false; #ifdef Q_OS_WIN     _engine-&gt;start(QString(ENGINE_DIALOG_DCTOOL_PATH)+QString(\" -t \")+_dcIpAddr+QString(\" -m \")+_dcMacAddr+QString(\" -x \")+QString(ENGINE_DIALOG_DC_PATH)+QString(\" -c \")+getCurrentProject()-&gt;getLocation()); #elif defined(Q_OS_LINUX) || defined(Q_OS_MAC)     if(_sudoPswd.isNull()) return false; \/\/required for OSX\/Linux     static QProcess *echo = NULL;     static QProcess *arp = NULL;     delete arp;     delete echo;     arp = new QProcess(this);     echo = new QProcess(this);     echo-&gt;setStandardOutputProcess(arp);     echo-&gt;start(QString(\"echo \")+_sudoPswd);     arp-&gt;start(QString(\"sudo -S arp -s \")+_dcIpAddr+QString(\" \")+_dcMacAddr);     arp-&gt;waitForFinished();     delete echo;     echo = new QProcess(this);     echo-&gt;setStandardOutputProcess(_engine);     echo-&gt;start(QString(\"echo \")+_sudoPswd);     _engine-&gt;start(QString(\"sudo -S \") + QString(ENGINE_DIALOG_DCTOOL_PATH)+QString(\" -t \")+_dcIpAddr+QString(\" -x \")+QString(ENGINE_DIALOG_DC_PATH)+QString(\" -c \")+getCurrentProject()-&gt;getLocation()); #endif     break; } <\/pre>\n<p><span style=\"color: #ff0000;\">&nbsp;FALCO EDIT:<br \/><\/span>Another little tidbit that I forgot to mention was about arping on Windows. Arp is an OS-level networking command that requires administrative privileges. We were able to handle this on OSX and Linux by simply having the user enter their sudo password (WHICH IS NOT SAVED). Unfortunately there is no command-line mechanism on Windows for entering your administrative password&#8230; We had to do things the Windows way&#8230;<\/p>\n<p>We have embedded a manifest within the Toolkit now that requests administrative permissions from Windows. This isn&#8217;t really anything special, but it is in the realm of QT (a platform agnostic IDE). We found some good resources for how to add this as a platform-specific post-linker step for Windows only. We added the following to our QT project:<br \/>[code]win32 {<\/p>\n<p>&nbsp; &nbsp; WINSDK_DIR = C:\/Program Files (x86)\/Microsoft SDKs\/Windows\/v7.0A<br \/>&nbsp; &nbsp; WIN_PWD = $$replace(PWD, \/, \\)<br \/>&nbsp; &nbsp; OUT_PWD_WIN = $$replace(OUT_PWD, \/, \\)<br \/>&nbsp; &nbsp; QMAKE_POST_LINK = &#8220;$$WINSDK_DIR\/bin\/x64\/mt.exe -manifest $$quote($$WIN_PWD\\$$basename(TARGET).manifest) outputresource:$$quote($$OUT_PWD_WIN\\${DESTDIR_TARGET};1)&#8221;<br \/>}[\/code]<br \/>This simply invokes the Windows sytem utility mt.exe which then embeds a manifest file within a prebuild executable. Our manifest file is very simple:<\/p>\n<p>[code]<\/p>\n<p>&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;utf-8&#8243;?&gt;<br \/>&lt;assembly xmlns=&#8221;urn:schemas-microsoft-com:asm.v1&#8243; manifestVersion=&#8221;1.0&#8243;&gt;<br \/> &lt;trustInfo xmlns=&#8221;urn:schemas-microsoft-com:asm.v3&#8243;&gt;<br \/> &lt;security&gt;<br \/> &lt;requestedPrivileges&gt;<br \/> &lt;requestedExecutionLevel level=&#8221;requireAdministrator&#8221; \/&gt;<br \/> &lt;\/requestedPrivileges&gt;<br \/> &lt;\/security&gt;<br \/> &lt;\/trustInfo&gt;<br \/>&lt;\/assembly&gt;<\/p>\n<p>[\/code]Now running ESTk will pop a Windows dialog box asking for authorization to run the application as an administrator&#8230; This will allow ESTk to perform the ARP operation. Luckily this extra build step still remains hidden from the build process thanks to the flexibility of QT&#8217;s qmake&#8230;<\/p>\n<p>The <strong><span style=\"color: #ff00ff;\">Policy of Pristinity<\/span><\/strong> has been upheld!<\/p>\n<p class=\"readmore\"><a href=\"http:\/\/forums.elysianshadows.com\/viewtopic.php?f=48&#038;t=7853\">DISCUSSION TOPIC<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Gentlemen,<\/p>\n<p>I took a minivacation from work to dev, read, achieve, and get my shit together. Marcel and I wound up having a 72-hour development marathon where we raped house and destroyed some serious code. This post has been a long time coming, and I am very happy to write this as the very first live article release for the site&#8230; The fans will be seeing this at the same time as the rest of the Elysian Shadows development team!<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\" size-full wp-image-13\" src=\"http:\/\/elysianshadows.com\/updates\/wp-content\/uploads\/2012\/08\/406089_423927204317597_1497245634_n.jpeg\" alt=\"406089_423927204317597_1497245634_n.jpeg\" width=\"720\" height=\"540\" width=\"720\" height=\"540\" srcset=\"http:\/\/elysianshadows.com\/updates\/wp-content\/uploads\/2012\/08\/406089_423927204317597_1497245634_n.jpeg 720w, http:\/\/elysianshadows.com\/updates\/wp-content\/uploads\/2012\/08\/406089_423927204317597_1497245634_n-300x225.jpeg 300w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><br \/><img loading=\"lazy\" decoding=\"async\" class=\" size-full wp-image-14\" src=\"http:\/\/elysianshadows.com\/updates\/wp-content\/uploads\/2012\/08\/319480_423927217650929_1382146571_n.jpeg\" alt=\"319480_423927217650929_1382146571_n.jpeg\" width=\"720\" height=\"540\" width=\"720\" height=\"540\" srcset=\"http:\/\/elysianshadows.com\/updates\/wp-content\/uploads\/2012\/08\/319480_423927217650929_1382146571_n.jpeg 720w, http:\/\/elysianshadows.com\/updates\/wp-content\/uploads\/2012\/08\/319480_423927217650929_1382146571_n-300x225.jpeg 300w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><\/p>\n<p>Marcel was perfecting the new Entity arhitecture for the Toolkit (which is paving way for the future of component implementation, especially the Animation System next). Meanwhile, I vowed to finish integrating the Dreamcast tools with our own Toolkit, to finally realize our dream of seamlessly developing on embedded platforms through the Toolkit. Since the very birth of libGyro, the goal has been to abstract all special code, considerations, and low-level implementation logic away from the high-level developers and level designers. I wanted our artists to be able to play through their levels as they create them just as easily on the Dreamcast as they can on their own PCs. I am proud to say that (for the Dreamcast), this goal has [i]finally[\/i] been realized. <span style=\"color: #ff00ff;\">It&#8217;s now a single click of the play button&#8230;<\/span><\/p>\n","protected":false},"author":1,"featured_media":13,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[21,14,16,17,13,18,24,20,22,15,19,23],"class_list":["post-22","post","type-post","status-publish","format-standard","hentry","category-underlying-technology","tag-2d-engine","tag-adventures-in-game-development","tag-dc-tool","tag-dreamcast-homebrew","tag-elysian-shadows","tag-estk","tag-invoke-engine","tag-level-editor","tag-opengl","tag-qt","tag-toolkit","tag-ubuntu"],"_links":{"self":[{"href":"http:\/\/elysianshadows.com\/updates\/wp-json\/wp\/v2\/posts\/22","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/elysianshadows.com\/updates\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/elysianshadows.com\/updates\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/elysianshadows.com\/updates\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/elysianshadows.com\/updates\/wp-json\/wp\/v2\/comments?post=22"}],"version-history":[{"count":0,"href":"http:\/\/elysianshadows.com\/updates\/wp-json\/wp\/v2\/posts\/22\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/elysianshadows.com\/updates\/wp-json\/wp\/v2\/media\/13"}],"wp:attachment":[{"href":"http:\/\/elysianshadows.com\/updates\/wp-json\/wp\/v2\/media?parent=22"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/elysianshadows.com\/updates\/wp-json\/wp\/v2\/categories?post=22"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/elysianshadows.com\/updates\/wp-json\/wp\/v2\/tags?post=22"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}