{"id":92,"date":"2018-05-15T10:39:27","date_gmt":"2018-05-15T10:39:27","guid":{"rendered":"https:\/\/blogs.scummvm.org\/drenn1\/?p=92"},"modified":"2026-03-02T19:03:43","modified_gmt":"2026-03-02T19:03:43","slug":"gsoc-week-0-implementing-the-basics-in-star-trek","status":"publish","type":"post","link":"https:\/\/blogs.scummvm.org\/drenn1\/2018\/05\/15\/gsoc-week-0-implementing-the-basics-in-star-trek\/","title":{"rendered":"GSoC Week 0: Implementing the basics in Star Trek"},"content":{"rendered":"<p>Google Summer of Code officially started yesterday; but, since I got started a bit early, I already have a week\u2019s worth of things to talk about. If I want to support both Star Trek: 25th Anniversary and Star Trek: Judgment Rites, I need to get moving!<\/p>\n<h2 id=\"audio-and-the-options-menu\">Audio and the Options Menu<\/h2>\n<p>Since the engine could already display textboxes, the options menu seemed like a juicy next target. In fact, I barely needed to do anything to make it display; the buttons were loaded in exactly the same way as other textboxes.<\/p>\n<div>\n<figure class=\"image\"><img decoding=\"async\" src=\"..\/images\/gsoc-week-0-options.png\" alt=\"\" \/><img decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/blogs.scummvm.org\/drenn1\/wp-content\/uploads\/sites\/62\/2022\/05\/gsoc-week-0-options.png\" \/><figcaption><\/figcaption><\/figure>\n<\/div>\n<p>This provided a nice segue into audio code; it showed me which variables corresponded to \u201cmusic enabled\u201d and \u201csfx enabled\u201d. MIDI music already worked thanks to the efforts of clone2727 from years back. I added support for midi sound effects, which turned out to just be separate tracks on the same midi file as the music.<\/p>\n<p>But there\u2019s more than just MIDI &#8211; the game features voice acting from the original Star Trek cast. Their lines, plus some other audio, are stored in .voc files on the CD. To work with ScummVM, they need to be copied from the CD to the hard drive with the rest of the game\u2019s data.<\/p>\n<p>I figured it would be easy. ScummVM has a built-in VOC decoder. What could possibly go wrong?<\/p>\n<p>Well, I was greeted by\u00a0<a href=\"https:\/\/blogs.scummvm.org\/drenn1\/wp-content\/uploads\/sites\/62\/2022\/05\/redalert-bad.wav\">this<\/a>.\u00a0<strong>SWEET JESUS THAT IS LOUD<\/strong>. (I always use headphones, by the way.) However, it\u2019s definitely the red alert sound.<\/p>\n<p>OK, so after a quick look at the decoder function\u2019s flags, I passed\u00a0<code class=\"language-plaintext highlighter-rouge\">Audio::FLAG_UNSIGNED<\/code>\u00a0to the decoder.\u00a0<a href=\"https:\/\/blogs.scummvm.org\/drenn1\/wp-content\/uploads\/sites\/62\/2022\/05\/redalert-good.wav\">That\u2019s much better<\/a>.<\/p>\n<h2 id=\"beam-me-down-scotty\">Beam me down, Scotty<\/h2>\n<p>With audio working, animations were next on my list. As it turned out, the transporter room was perfect for testing this; the entire sequence is just 5 objects being animated.<\/p>\n<div>\n<figure class=\"image\"><img decoding=\"async\" src=\"..\/images\/gsoc-week-0-beamdown-1.gif\" alt=\"\" \/><img decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/blogs.scummvm.org\/drenn1\/wp-content\/uploads\/sites\/62\/2022\/05\/gsoc-week-0-beamdown-1.gif\" \/><figcaption><\/figcaption><\/figure>\n<\/div>\n<p>Did you notice that every crewman is McCoy? That\u2019s because the other 3 officers have their animations based on McCoy\u2019s. They just apply an xor over the face and recolor the uniforms.<\/p>\n<p>After fixing that (and discovering that the timer runs at 18.206 Hz, the rate of the DOS clock), the animations looked perfect, aside from layering.<\/p>\n<div>\n<figure class=\"image\"><img decoding=\"async\" src=\"..\/images\/gsoc-week-0-beamdown-2.gif\" alt=\"\" \/><img decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/blogs.scummvm.org\/drenn1\/wp-content\/uploads\/sites\/62\/2022\/05\/gsoc-week-0-beamdown-2.gif\" \/><figcaption><\/figcaption><\/figure>\n<\/div>\n<h2 id=\"scaling\">Scaling<\/h2>\n<p>Sprite scaling would be needed before tackling away missions. Star Trek optimized this heavily; they wrote a function which constructed another function in RAM! This resulting function was just an unrolled loop which copies a row of unscaled pixels to a row of scaled pixels. This is DOS, so there\u2019s no interpolation here.<\/p>\n<p>I obviously don\u2019t need to do anything as fancy as dynamically constructing a function in ScummVM. There\u2019s no way I could do that portably, anyway. Fortunately, my computer is probably a hundred times faster than what Star Trek was developed on, so I\u2019m not too worried.<\/p>\n<div>\n<figure class=\"image\"><figcaption><img decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/blogs.scummvm.org\/drenn1\/wp-content\/uploads\/sites\/62\/2022\/05\/gsoc-week-0-scaling.gif\" \/>Weirdest transporter accident I&#8217;ve ever seen&#8230;<\/figcaption><\/figure>\n<\/div>\n<h2 id=\"away-missions\">Away Missions<\/h2>\n<p>With animations done, it was time for me to do movement and pathfinding.<\/p>\n<div>\n<figure class=\"image\"><img decoding=\"async\" src=\"..\/images\/gsoc-week-0-movement.gif\" alt=\"\" \/><img decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/blogs.scummvm.org\/drenn1\/wp-content\/uploads\/sites\/62\/2022\/05\/gsoc-week-0-movement.gif\" \/><figcaption><\/figcaption><\/figure>\n<\/div>\n<p>Pathfinding is a simple system where each room has a set of waypoints. Given a source and a destination, the game locates the waypoints closest to each. Kirk then moves to the source waypoint, moves along a set path to the destination waypoint, and then moves from there to the exact destination you clicked on. This sometimes causes Kirk to walk back-and-forth when he\u2019s starting a walk, since he might need to move backwards to reach a waypoint. I\u2019m not sure if other adventure games do this, but it does make movement in this game feel somewhat finicky.<\/p>\n<p>Anyway, just today I figured out how warps work &#8211; some of them, anyway. Each room has a set of polygons where warps occur if Kirk walks into them. However, apparently the doors in the first room of the first mission are more complicated. It seems that, since a sound effect goes with them, they need to call some room-specific code to handle that.<\/p>\n<div>\n<figure class=\"image\"><img decoding=\"async\" src=\"..\/images\/gsoc-week-0-warps.gif\" alt=\"\" \/><img decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/blogs.scummvm.org\/drenn1\/wp-content\/uploads\/sites\/62\/2022\/05\/gsoc-week-0-warps.gif\" \/><figcaption><\/figcaption><\/figure>\n<\/div>\n<p>The game is suddenly starting to feel alive. Not only can I control Kirk, but the crewmen follow behind him when moving between screens, or do their idle animation when waiting around. It\u2019s a small thing, but it\u2019s rather refreshing after looking at static screens for so long.<\/p>\n<h2 id=\"other-stuff\">Other stuff<\/h2>\n<p>I found an interesting error message:<\/p>\n<p>\u201d<code class=\"language-plaintext highlighter-rouge\">Jay didn't think about pmcheck.<\/code>\u201d<\/p>\n<p>Jay is probably Jayesh Patel, who is credited as one of the programmers. I don\u2019t really know what that error message means, but at least I\u2019ll know who to blame if I ever see it. \ud83d\ude42<\/p>\n<p>Anyway, next on my list of things is to work on the action menu and inventory menu. And, very soon, I\u2019ll need to start looking into how room-specific logic works. Again, this is all done with x86 code and not a scripting language, so it will need to be tackled on a room-by-room basis.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Google Summer of Code officially started yesterday; but, since I got started a bit early, I already have a week\u2019s worth of things to talk about. If I want to support both Star Trek: 25th Anniversary and Star Trek: Judgment Rites, I need to get moving! Audio and the Options Menu Since the engine could [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-92","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blogs.scummvm.org\/drenn1\/wp-json\/wp\/v2\/posts\/92","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.scummvm.org\/drenn1\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.scummvm.org\/drenn1\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.scummvm.org\/drenn1\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.scummvm.org\/drenn1\/wp-json\/wp\/v2\/comments?post=92"}],"version-history":[{"count":3,"href":"https:\/\/blogs.scummvm.org\/drenn1\/wp-json\/wp\/v2\/posts\/92\/revisions"}],"predecessor-version":[{"id":126,"href":"https:\/\/blogs.scummvm.org\/drenn1\/wp-json\/wp\/v2\/posts\/92\/revisions\/126"}],"wp:attachment":[{"href":"https:\/\/blogs.scummvm.org\/drenn1\/wp-json\/wp\/v2\/media?parent=92"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/drenn1\/wp-json\/wp\/v2\/categories?post=92"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/drenn1\/wp-json\/wp\/v2\/tags?post=92"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}