{"id":59,"date":"2013-02-11T10:53:33","date_gmt":"2013-02-11T18:53:33","guid":{"rendered":"http:\/\/adamantyr.com\/blog\/?p=59"},"modified":"2017-09-20T08:31:19","modified_gmt":"2017-09-20T16:31:19","slug":"bug-extermination","status":"publish","type":"post","link":"http:\/\/www.adamantyr.com\/index.php\/2013\/02\/11\/bug-extermination\/","title":{"rendered":"Bug Extermination"},"content":{"rendered":"<p>Okay, I spent several hours on code fixing, building, re-building, file editing, spreadsheet updates&#8230; all aimed at getting the game back on a (sort of) running basis. I also thought some new screenshots would be nice to splash around the blog.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-full wp-image-588\" src=\"http:\/\/test.adamantyr.com\/wp-content\/uploads\/2017\/09\/shot1.png\" alt=\"\" width=\"272\" height=\"208\" \/><\/p>\n<p>I updated the travel screen to remove numerical references to health, wounds, stamina and fatigue. I thought it was unnecessarily cluttering things up. I&#8217;m well aware that as the game designer, I know exactly how the statistics work. Because of that, I think &#8220;Why not just show all the values all the time? I need to see them for debugging after all&#8230;&#8221;<\/p>\n<p>It&#8217;s an easy trap to fall into to just display everything, because there&#8217;s no mystery to ME how it works. But part of a game is for the player to figure out how things work.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignright size-full wp-image-582\" src=\"http:\/\/test.adamantyr.com\/wp-content\/uploads\/2017\/09\/shot3.png\" alt=\"\" width=\"272\" height=\"208\" \/><\/p>\n<p>I wrote a Trek game once that included a torpedo course calculator. But I realized that it more or less ruined the gameplay because it would tell you exactly what angle to use, and any guess work was removed. What fun is that?<\/p>\n<p>No worries, though, I won&#8217;t forget to show the numbers on the statistics screens. I&#8217;ve updated those to show the new reduced statistics. The party overview is also a quick way to see exact values if needed.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-full wp-image-589\" src=\"http:\/\/test.adamantyr.com\/wp-content\/uploads\/2017\/09\/shot2.png\" alt=\"\" width=\"272\" height=\"208\" \/><\/p>\n<p>My real focus of the debugging was to get the combat engine back to a state where I could start debugging what was going wrong with the visual displays. (Which internally is called the FX code.)<\/p>\n<p>Fortunately, it turned out to be pretty easy to convert the engine to an &#8220;act immediately&#8221; state rather than save actions up. I also recovered several hundred bytes of memory that was being used for action processing, although I&#8217;ll have to back later to figure out how best to make use of that.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-583 alignright\" src=\"http:\/\/test.adamantyr.com\/wp-content\/uploads\/2017\/09\/shot4.png\" alt=\"\" width=\"272\" height=\"208\" \/><\/p>\n<p>I&#8217;ve found the easiest way for me to debug and fix issues is to keep a notepad and pencil by my side as I run through the code. Any bug I see is written down on the list. Once I have a substantial number, or the program crashes, I go to the source to find the causes for each bug. As I fix them, I cross them off the list. Then I recompile and re-run the code, and validate that each bug got fixed.<\/p>\n<p>Once I got movement working, the engine felt MUCH more playable and enjoyable. I really like the effect that actions have as well; you&#8217;re left with a real tactical challenge. Do you move into position but cost yourself some fatigue? Or do you wait a turn to let the opponents come to you, and enjoy a little defensive bonus?<\/p>\n<p>Guarding and movement was easy. Attacking, though, proved to be extremely buggy. I finally had to find a decent breakpoint in my code (Classic99 is awesome, but Visual Studio it is not&#8230;) and halt the action to step through. And that means going through ALL the code, including the incredibly long and painful disk routines to load data.<\/p>\n<p>I found several issues in the FX code, including an annoying one with Unit ID&#8217;s. Each &#8220;character&#8221; on screen, both players and monsters, have a unit ID in a byte form. This lets me determine on the battle map who is where. Unfortunately, the &#8216;0&#8217; value is used to indicate a movable space, but the various indexes are also zero-based. Which means every time I need to convert Unit ID to some other array, I have to subtract one from it first. And I forgot to do that in two places.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-full wp-image-584\" src=\"http:\/\/test.adamantyr.com\/wp-content\/uploads\/2017\/09\/shot5.png\" alt=\"\" width=\"272\" height=\"208\" \/><\/p>\n<p>This actually explains why behavior was so inconsistent before with hitting creatures; it wasn&#8217;t finding the creature in the expected location on the left, so the game continued, but if I attacked upwards it DID find a creature, and moved into the buggier code. Which you can see in this screenshot&#8230;.<\/p>\n<p>Any 99&#8217;er programmer in assembly should immediately recognize what this screen means: seriously bad mojo with your video manipulation. Usually this is caused by a counter value being way off. Your routines end up overwriting all of VDP memory, which makes sound, graphics, and sprites all go haywire.<\/p>\n<p>At least now I know where the bugs are occurring, I just have to step through the code and find the bad values that are causing the problem. It will probably be something VERY simple. After I get basic melee attacks working, I&#8217;m moving on to ranged attacks, then spells. I also have a lot of commented out or hard-coded values for setting up the battle map and unit placement; this all needs to be replaced with working code and tested too.<\/p>\n<p>Oh, and at this time, I&#8217;m hovering right below 20,095 bytes of space used in the 32k memory expansion. I converted my program to use the CPU RAM space in the cartridge (located at &gt;6000) for RAM space, so that I can spill over into the lower 8k with code. I&#8217;m pretty confident I have enough memory to complete the game.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Okay, I spent several hours on code fixing, building, re-building, file editing, spreadsheet updates&#8230; all aimed at getting the game back on a (sort of) running basis. I also thought some new screenshots would be nice to splash around the &hellip; <a href=\"http:\/\/www.adamantyr.com\/index.php\/2013\/02\/11\/bug-extermination\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[2,3,4,5,11],"tags":[],"class_list":["post-59","post","type-post","status-publish","format-standard","hentry","category-blog","category-coding","category-crpg","category-design","category-screenshots"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pgaeMJ-X","_links":{"self":[{"href":"http:\/\/www.adamantyr.com\/index.php\/wp-json\/wp\/v2\/posts\/59","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.adamantyr.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.adamantyr.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.adamantyr.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.adamantyr.com\/index.php\/wp-json\/wp\/v2\/comments?post=59"}],"version-history":[{"count":2,"href":"http:\/\/www.adamantyr.com\/index.php\/wp-json\/wp\/v2\/posts\/59\/revisions"}],"predecessor-version":[{"id":662,"href":"http:\/\/www.adamantyr.com\/index.php\/wp-json\/wp\/v2\/posts\/59\/revisions\/662"}],"wp:attachment":[{"href":"http:\/\/www.adamantyr.com\/index.php\/wp-json\/wp\/v2\/media?parent=59"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.adamantyr.com\/index.php\/wp-json\/wp\/v2\/categories?post=59"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.adamantyr.com\/index.php\/wp-json\/wp\/v2\/tags?post=59"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}