# demo - guided tour of FRST Computer
#
# DESCRIPTIVE tour: each slide narrates a capability and shows the command
# to type.  It deliberately does NOT launch interactive tools (p, ed, games,
# gopher, boards, bbs) itself.
#
# WHY: a sourced rc script does not reliably resume after a full-screen tool
# that reads /dev/cons (p, ed, vt, the games...) hands control back -- the
# tour wedges the instant such a tool returns.  Verified on native_sim: `p`
# works fine at the prompt, but `p` launched from this sourced script hangs
# the rest of the tour.  Until the zrc parser/exec overhaul lands, stay in the
# known-good subset: echo / read _ / clear / ls.  Everything else is shown as
# a command for the visitor to run.  NOTE: `epaper on` is also NOT used inline
# -- enabling e-ink then rendering many full-screen slides wedges the tour
# around stop 5 (cumulative e-paper refreshes; see project_epaper_thread_coupling).
# (See project_zrc_parser_bugs for the full list of zrc script footguns:
#  no nested { }, no `;`/`!`/apostrophes inside single-quoted echoes, keep
#  each { } block well under DOT_LINE_MAX, no inline interactive launches.)
#
# Usage:
#   demo            run the tour

# --- preflight ---------------------------------------------------------

offline=0
if (~ $1 skip) { offline=1 }

# "Attuned?" = is the crystal mounted at /n/dc (what attune creates).  Do NOT
# test /net/tcp/clone: native_sim and WASM register a LOCAL /net at boot, so
# clone always exists even with no crystal.  Flat single-level ifs only.
if (test ! -e /n/dc) { offline=1 }

# --- intro -------------------------------------------------------------

clear
echo ''
echo '   ----------------------------------------------'
echo '   FRST Computer'
echo '   ----------------------------------------------'
echo ''
echo '   Your time machine awaits.'
echo ''
echo '   FRST is a personal computer designed to take'
echo '   you back - to the parts of the internet that'
echo '   never went bad.  Gopher menus, telnet BBSes'
echo '   still accepting calls in 2026, the rhythm of'
echo '   typing at a text screen and getting words back.'
echo ''
echo '   The software you are running is the same'
echo '   software that runs on the Model 4 deck:'
echo '   a 7.5" e-ink computer in a 3D-printed case.'
echo ''
echo '   This tour narrates the deck; the commands it'
echo '   names are yours to type when it ends.'
echo ''
echo '   Press Enter to begin.'
read _

# --- stop 1: feel the deck (epaper is known-good from a script) ---------

clear
echo ''
echo '   Stop 1 of 6: feel the deck.'
echo ''
echo '   E-paper takes ~400 ms to refresh.  No fades,'
echo '   no scrolling - it thinks before it speaks,'
echo '   and reads gorgeously in sunlight.'
echo ''
echo '   `epaper on` makes the browser refresh at the'
echo '   same pace as the real display - try it to feel'
echo '   the latency.  `epaper off` drops back to instant.'
echo ''
echo '   Press Enter.'
read _

# --- stop 2: everything is a file (ls is known-good) -------------------

clear
echo ''
echo '   Stop 2 of 6: everything is a file.'
echo ''
echo '   In Plan 9, devices, services, and network'
echo '   sockets all show up in the filesystem.'
echo '   No special APIs - just `ls`, `cat`, pipes.'
echo ''
ls /dev
echo ''
echo '   Press Enter.'
read _

# --- stop 3: read ------------------------------------------------------

clear
echo ''
echo '   Stop 3 of 6: read.'
echo ''
echo '   `p` is the e-ink-tuned pager - page-at-a-time,'
echo '   clean typography, slow when it must be.  Space'
echo '   or Enter advances, q quits.'
echo ''
echo '   Try it after the tour:'
echo ''
echo '       p /n/local/text/whytext.oct'
echo ''
echo '   Press Enter.'
read _

# --- stop 4: write -----------------------------------------------------

clear
echo ''
echo '   Stop 4 of 6: write.'
echo ''
echo '   FRST ships ed, vi, sam, and a screen editor.'
echo '   ed is small, line-oriented, the foundation of'
echo '   all the others: i to insert, a lone . to end'
echo '   insert, w to save, q to quit.'
echo ''
echo '   Try it:'
echo ''
echo '       ed /n/local/demo.txt'
echo ''
echo '   Press Enter.'
read _

# --- stop 5: play ------------------------------------------------------

clear
echo ''
echo '   Stop 5 of 6: a deck is never just a terminal.'
echo ''
echo '   All playable right now, no network required:'
echo ''
echo '       fractal      draw the Mandelbrot set'
echo '       tetris       the classic'
echo '       snake        eat, grow, mind your tail'
echo '       chess        against the deck'
echo '       woz          Apple 1 emulator, Integer BASIC'
echo '       zork         the adventure that started it'
echo ''
echo '   Press Enter.'
read _

# --- stop 6: the small internet ---------------------------------------

clear
echo ''
echo '   Stop 6 of 6: the small internet.'
echo ''
echo '   Gopher is what the web could have been:'
echo '   text-first, no ads, no popups, no JavaScript.'
echo '   Telnet BBSes are still online in 2026 - ANSI'
echo '   art, message boards, door games.  And `bbs` is'
echo '   FRSTs own board, served over 9P from the crystal.'
echo ''
echo '       gopher gopher.floodgap.com'
echo '       boards                 a curated dialing book'
echo '       telnet telehack.com    dial one yourself'
echo '       bbs                    the FRST commons'
echo ''
echo '   Press Enter.'
read _

# --- close: tailor the on-ramp to whether a crystal is attuned ---------

if (~ $offline 1) {
    clear
    echo ''
    echo '   ----------------------------------------------'
    echo '   That is the tour.'
    echo '   ----------------------------------------------'
    echo ''
    echo '   You are not attuned yet, so gopher / boards /'
    echo '   bbs need a data crystal first:'
    echo ''
    echo '       attune                 tune in to the BBS'
    echo ''
    echo '   The reading, writing, and games above all work'
    echo '   right now, offline.'
    echo ''
    echo '   Want a Model 4 of your own?  frstcomputer.com'
    echo ''
    exit 0
}

clear
echo ''
echo '   ----------------------------------------------'
echo '   That is the tour.'
echo '   ----------------------------------------------'
echo ''
echo '   You are attuned - every command above works now.'
echo '   Start anywhere:'
echo ''
echo '       gopher gopher.floodgap.com'
echo '       bbs'
echo '       p /n/local/text/whytext.oct'
echo ''
echo '   `help` lists everything else.'
echo ''
echo '   Want a Model 4 of your own?  frstcomputer.com'
echo ''
