{"id":154,"date":"2023-04-09T12:13:11","date_gmt":"2023-04-09T12:13:11","guid":{"rendered":"https:\/\/davidrobertparker.com\/?p=154"},"modified":"2023-04-10T09:47:12","modified_gmt":"2023-04-10T09:47:12","slug":"programming-super-star-trek-in-swiftui-a-progress-report","status":"publish","type":"post","link":"https:\/\/davidrobertparker.com\/index.php\/2023\/04\/09\/programming-super-star-trek-in-swiftui-a-progress-report\/","title":{"rendered":"Programming Super Star Trek in SwiftUI \u2014 A progress report . . ."},"content":{"rendered":"\n<p id=\"2366\">David Ahl\u2019s \u201cSuper Star Trek\u201d program, originally written in BASIC, was one of the first major programs that many converted to run on the range of personal computers in the 1980s and then in other languages. The history is amply summarised on&nbsp;<a href=\"https:\/\/en.wikipedia.org\/wiki\/Star_Trek_(1971_video_game)\" rel=\"noreferrer noopener\" target=\"_blank\">Wikipedia<\/a>.<\/p>\n\n\n\n<p id=\"11fc\">The challenge, alongside teaching myself to program apps to run on iOS in the Swift language, was to convert the original BASIC program, flaws and bugs included to run in iOS using the Swift language and, in particular, SwiftUI.<\/p>\n\n\n\n<p id=\"54dc\">One of the more recent conversions is Emanuele Bolognesi\u2019s&nbsp;<a rel=\"noreferrer noopener\" href=\"http:\/\/emabolo.com\/article\/i-rewrote-the-1978-text-only-super-star-trek-game\" target=\"_blank\">program<\/a>&nbsp;in the Perl language which is true, as far as it can be, to the original BASIC program. He subsequently reprogrammed it in the Lua language and improved some of the logic. Both implementations provide some insight into the problems in the original program in part due to the limitations of the BASIC language and the memory limitations of early personal computers where 16k bytes or less was often the main restriction. His analysis of the logic of the original BASIC program had been a great help in converting the BASIC into Swift.<\/p>\n\n\n\n<p id=\"903e\">There are a couple of \u201cbugs\u201d in the original BASIC listing in David Ahl\u2019s \u201cBASIC Computer Games\u201d book. There are two lines in the program where a \u201c0&#8243; looks like a \u201c2&#8243; due to the poor definition of the original printed listing. These errors have been carried through to many of the published versions of the original BASIC listing (including the often used listing on <a href=\"http:\/\/www.vintage-basic.net\/games.html\">Vintage BASIC website<\/a>) but they have been corrected in my conversion.<\/p>\n\n\n\n<p id=\"4877\">To take advantage of the iOS interface, I have based the design on another iOS implementation. This is Dennis Nederlof\u2019s \u201ciVoyages\u201d available from the Apple AppStore.<\/p>\n\n\n\n<p id=\"909b\">This is the main screen from my implementation in iOS and Swift on the iPad.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"709\" src=\"https:\/\/davidrobertparker.com\/wp-content\/uploads\/2023\/04\/CleanShot-2023-04-10-at-10.45.09@2x-1024x709.png\" alt=\"\" class=\"wp-image-159\" srcset=\"https:\/\/davidrobertparker.com\/wp-content\/uploads\/2023\/04\/CleanShot-2023-04-10-at-10.45.09@2x-1024x709.png 1024w, https:\/\/davidrobertparker.com\/wp-content\/uploads\/2023\/04\/CleanShot-2023-04-10-at-10.45.09@2x-300x208.png 300w, https:\/\/davidrobertparker.com\/wp-content\/uploads\/2023\/04\/CleanShot-2023-04-10-at-10.45.09@2x-768x532.png 768w, https:\/\/davidrobertparker.com\/wp-content\/uploads\/2023\/04\/CleanShot-2023-04-10-at-10.45.09@2x-1536x1064.png 1536w, https:\/\/davidrobertparker.com\/wp-content\/uploads\/2023\/04\/CleanShot-2023-04-10-at-10.45.09@2x-2048x1419.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p id=\"20a6\">The buttons on the top row provide, on the left, identification of the program version and help, and on the right, game restart and engage buttons.<\/p>\n\n\n\n<p id=\"1a18\">The middle part of the screen show the game\u2019s progress in a scrolling display meant to mimic the teletype output of the original program.<\/p>\n\n\n\n<p id=\"c679\">The bottom row of buttons provide the game\u2019s main controls. Left to right these are Navigation to route the Enterprise through the galaxy, a Short Range Scan of the quadrant in which the Enterprise is located, a Long Range Scan showing the contents of each immediately adjacent quadrant, two buttons controlling the ship\u2019s weapons (Phasers and Photon Torpedoes), Damage Control to manage the inevitable failure of the ship\u2019s components due to attack and travelling at warp speed, Shield Control to provide defence against attacking Klingons, a Computer to provide direction assistance and a map of the explored galaxy, and finally an option to Resign the current mission.<\/p>\n\n\n\n<p id=\"5097\">The implementation is not yet complete but the main screen display is working and good progress is being made with the ship\u2019s main functions.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>David Ahl\u2019s \u201cSuper Star Trek\u201d program, originally written in BASIC, was one of the first major programs that many converted to run on the&#8230;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[6],"tags":[],"class_list":["post-154","post","type-post","status-publish","format-standard","hentry","category-programming"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/davidrobertparker.com\/index.php\/wp-json\/wp\/v2\/posts\/154","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/davidrobertparker.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/davidrobertparker.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/davidrobertparker.com\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/davidrobertparker.com\/index.php\/wp-json\/wp\/v2\/comments?post=154"}],"version-history":[{"count":4,"href":"https:\/\/davidrobertparker.com\/index.php\/wp-json\/wp\/v2\/posts\/154\/revisions"}],"predecessor-version":[{"id":160,"href":"https:\/\/davidrobertparker.com\/index.php\/wp-json\/wp\/v2\/posts\/154\/revisions\/160"}],"wp:attachment":[{"href":"https:\/\/davidrobertparker.com\/index.php\/wp-json\/wp\/v2\/media?parent=154"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/davidrobertparker.com\/index.php\/wp-json\/wp\/v2\/categories?post=154"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/davidrobertparker.com\/index.php\/wp-json\/wp\/v2\/tags?post=154"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}