{"id":17438,"date":"2023-09-18T22:33:49","date_gmt":"2023-09-19T02:33:49","guid":{"rendered":"https:\/\/scruss.com\/blog\/?p=17438"},"modified":"2023-09-18T22:33:49","modified_gmt":"2023-09-19T02:33:49","slug":"the-glorious-futility-of-generating-naplps-in-2023","status":"publish","type":"post","link":"https:\/\/scruss.com\/blog\/2023\/09\/18\/the-glorious-futility-of-generating-naplps-in-2023\/","title":{"rendered":"The glorious futility of generating NAPLPS in 2023"},"content":{"rendered":"\n<figure class=\"wp-block-video\"><video height=\"720\" style=\"aspect-ratio: 1152 \/ 720;\" width=\"1152\" controls src=\"https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2023\/09\/naplps-maple-c64.mp4\"><\/video><figcaption class=\"wp-element-caption\">Yeah! Actual real NAPLPS made by me!<\/figcaption><\/figure>\n\n\n\n<p><a href=\"https:\/\/en.wikipedia.org\/wiki\/NAPLPS\">NAPLPS<\/a> \u2014 an almost-forgotten videotex vector graphics format with a regrettable pronunciation (<em>\/nap-lips\/<\/em>, no really) \u2014 was really hard to create. Back in the early days when it was a worthwhile Canadian initiative called <strong>Telidon<\/strong> (see Inter\/Access&#8217;s exhibit <em><a href=\"https:\/\/interaccess.org\/exhibition\/remember-tomorrow-telidon-story\">Remember Tomorrow: A Telidon Story<\/a><\/em>) it required a custom video workstation costing $$$$$$. It got cheaper by the time the 1990s rolled round, but it was never easy and so interest waned.<\/p>\n\n\n\n<p>I don&#8217;t claim what I made is particularly interesting:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"640\" src=\"https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2023\/09\/naplps-maple-c64-1024x640.jpg\" alt=\"a lo-res red maple leaf in the bottom left corner of a black screen\" class=\"wp-image-17441\" srcset=\"https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2023\/09\/naplps-maple-c64-1024x640.jpg 1024w, https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2023\/09\/naplps-maple-c64-320x200.jpg 320w, https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2023\/09\/naplps-maple-c64-160x100.jpg 160w, https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2023\/09\/naplps-maple-c64-768x480.jpg 768w, https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2023\/09\/naplps-maple-c64.jpg 1152w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">suspiciously canadian<\/figcaption><\/figure>\n\n\n\n<p>but even decoding the tutorial and standards material was hard. NAPLPS made heavy use of bitfields interleaved and packed into 7 and 8-bit characters. It was kind of a clever idea (lower resolution data could be packed into fewer bytes) but the implementation is quite unpleasant.<\/p>\n\n\n\n<p>A few of the references\/tools\/resources I relied on:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The <a href=\"https:\/\/archive.org\/details\/naplps-CSA-T500-1983\">NAPLPS: videotex\/teletext presentation level protocol syntax<\/a> standard. Long. Quite dull and abstract, but it is <span style=\"text-decoration: underline;\">the<\/span> reference<\/li>\n\n\n\n<li>The 1983 BYTE Magazine article series <em><a href=\"https:\/\/archive.org\/details\/byte-1983-naplps\">NAPLPS: A New Standard for Text and Graphics<\/a><\/em>. Also long and needlessly wordy, with digressions into extensions that were never implemented. Contains a commented byte dump of an image that explains most concepts by example<\/li>\n\n\n\n<li><a href=\"https:\/\/archive.org\/details\/NAPLPS_ZIP\/\">Technical specifications for NAPLPS graphics<\/a> \u2014 aka NAPLPS.ASC. A large text file explaining how NAPLPS works. Fairly clear, but the ASCII art diagrams aren&#8217;t the most obvious<\/li>\n\n\n\n<li><a href=\"https:\/\/n1ckfg.github.io\/Telidon\/\">TelidonP5<\/a> \u2014 an online NAPLPS viewer. Not perfect, but helpful for proofing work<\/li>\n\n\n\n<li><a href=\"http:\/\/jammingsignal.com\/2018\/01\/10\/videotex-naplps-client-for-the-commodore-64-archived\/\">Videotex \u2013 NAPLPS Client for the Commodore 64 Archived<\/a> \u2014 a terminal for the C64 that supports (some) NAPLPS. Very limited in the size of file it can view<\/li>\n\n\n\n<li><a href=\"https:\/\/webapp.library.uvic.ca\/jdurno\/\">John Durno<\/a> has spent years recovering Telidon \/ NAPLPS works. He has published many useful resources on the subject<\/li>\n<\/ul>\n\n\n\n<p>Here&#8217;s the fragment of code I wrote to generate the NAPLPS:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\n#!\/usr\/bin\/env python3\n# -*- coding: utf-8 -*-\n# draw a disappointing maple leaf in NAPLPS - scruss, 2023-09\n\n# stylized maple leaf polygon, quite similar to\n# the coordinates used in the Canadian flag ...\nmaple = &#x5B;\n    &#x5B;62, 2],\n    &#x5B;62, 35],\n    &#x5B;94, 31],\n    &#x5B;91, 41],\n    &#x5B;122, 66],\n    &#x5B;113, 70],\n    &#x5B;119, 90],\n    &#x5B;100, 86],\n    &#x5B;97, 96],\n    &#x5B;77, 74],\n    &#x5B;85, 114],\n    &#x5B;73, 108],\n    &#x5B;62, 130],\n    &#x5B;51, 108],\n    &#x5B;39, 114],\n    &#x5B;47, 74],\n    &#x5B;27, 96],\n    &#x5B;24, 86],\n    &#x5B;5, 90],\n    &#x5B;11, 70],\n    &#x5B;2, 66],\n    &#x5B;33, 41],\n    &#x5B;30, 31],\n    &#x5B;62, 35],\n]\n\n\ndef colour(r, g, b):\n    # r, g and b are limited to the range 0-3\n    return chr(0o74) + chr(\n        64\n        + ((g &amp; 2) &lt;&lt; 4)\n        + ((r &amp; 2) &lt;&lt; 3)\n        + ((b &amp; 2) &lt;&lt; 2)\n        + ((g &amp; 1) &lt;&lt; 2)\n        + ((r &amp; 1) &lt;&lt; 1)\n        + (b &amp; 1)\n    )\n\n\ndef coord(x, y):\n    # if you stick with 256 x 192 integer coordinates this should be okay\n    xsign = 0\n    ysign = 0\n    if x &lt; 0:\n        xsign = 1\n        x = x * -1\n        x = ((x ^ 255) + 1) &amp; 255\n    if y &lt; 0:\n        ysign = 1\n        y = y * -1\n        y = ((y ^ 255) + 1) &amp; 255\n    return (\n        chr(\n            64\n            + (xsign &lt;&lt; 5)\n            + ((x &amp; 0xC0) &gt;&gt; 3)\n            + (ysign &lt;&lt; 2)\n            + ((y &amp; 0xC0) &gt;&gt; 6)\n        )\n        + chr(64 + ((x &amp; 0x38)) + ((y &amp; 0x38) &gt;&gt; 3))\n        + chr(64 + ((x &amp; 7) &lt;&lt; 3) + (y &amp; 7))\n    )\n\n\nf = open(&quot;maple.nap&quot;, &quot;w&quot;)\nf.write(chr(0x18) + chr(0x1B))  # preamble\n\nf.write(chr(0o16))  # SO: into graphics mode\n\nf.write(colour(0, 0, 0))  # black\nf.write(chr(0o40) + chr(0o120))  # clear screen to current colour\n\nf.write(colour(3, 0, 0))  # red\n\n# *** STALK ***\nf.write(\n    chr(0o44) + coord(maple&#x5B;0]&#x5B;0], maple&#x5B;0]&#x5B;1])\n)  # point set absolute\nf.write(\n    chr(0o51)\n    + coord(maple&#x5B;1]&#x5B;0] - maple&#x5B;0]&#x5B;0], maple&#x5B;1]&#x5B;1] - maple&#x5B;0]&#x5B;1])\n)  # line relative\n\n# *** LEAF ***\nf.write(\n    chr(0o67) + coord(maple&#x5B;1]&#x5B;0], maple&#x5B;1]&#x5B;1])\n)  # set polygon filled\n# append all the relative leaf vertices\nfor i in range(2, len(maple)):\n    f.write(\n        coord(\n            maple&#x5B;i]&#x5B;0] - maple&#x5B;i - 1]&#x5B;0], maple&#x5B;i]&#x5B;1] - maple&#x5B;i - 1]&#x5B;1]\n        )\n    )\n\nf.write(chr(0x0F) + chr(0x1A))  # postamble\nf.close()\n<\/pre><\/div>\n\n\n<p>There are a couple of perhaps useful routines in there:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><code>colour(r, g, b)<\/code> spits out the code for two bits per component RGB. Inputs are limited to the range 0\u20133 without error checking<\/li>\n\n\n\n<li><code>coord(x, y)<\/code> converts integer coordinates to a NAPLPS output stream. Best limited to a 256 \u00d7 192 size. Will also work with positive\/negative relative coordinates.<\/li>\n<\/ol>\n\n\n\n<p>Here&#8217;s the generated file:<\/p>\n\n\n\n<div class=\"wp-block-file\"><a id=\"wp-block-file--media-0b90ca5c-346c-49ea-943d-02ca446c4aa0\" href=\"https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2023\/09\/maple_nap.zip\">maple_nap.zip<\/a><a href=\"https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2023\/09\/maple_nap.zip\" class=\"wp-block-file__button wp-element-button\" download aria-describedby=\"wp-block-file--media-0b90ca5c-346c-49ea-943d-02ca446c4aa0\">Download<\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>NAPLPS \u2014 an almost-forgotten videotex vector graphics format with a regrettable pronunciation (\/nap-lips\/, no really) \u2014 was really hard to create. Back in the early days when it was a worthwhile Canadian initiative called Telidon (see Inter\/Access&#8217;s exhibit Remember Tomorrow: A Telidon Story) it required a custom video workstation costing $$$$$$. It got cheaper by [&hellip;]<\/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":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[7],"tags":[3328,3325,24,3327,2540,3326],"class_list":["post-17438","post","type-post","status-publish","format-standard","hentry","category-computers-suck","tag-bbs","tag-comms","tag-futile","tag-naplps","tag-python","tag-telidon"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pQNZZ-4xg","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/posts\/17438","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/comments?post=17438"}],"version-history":[{"count":1,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/posts\/17438\/revisions"}],"predecessor-version":[{"id":17443,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/posts\/17438\/revisions\/17443"}],"wp:attachment":[{"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/media?parent=17438"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/categories?post=17438"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/tags?post=17438"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}