Issues printing ASCII images with special characters

I’m currently running into an issue that I’m hoping someone can shed light on. I’m working on a game concept that uses ASCII art and diagrams (a loosely similar concept to the sonarscope in Seastalker). The problem is, Dialog’s rules for printing text make it difficult to print ASCII images that contain special characters and meaningful whitespace.

Dialog’s rules for special characters are: Some special characters (#, $, @, ~, *, |, , parentheses, brackets, and braces) need to be prefixed by a backslash (\)

Furthermore, Dialog will remove the required whitespace between characters to ensure an ASCII image or diagram is displayed correctly.

Here’s an example. Below is a piece of ASCII art that I attempted to include in a Dialog game.

                               o
                       _---|         _ _ _ _ _
                    o   ---|     o   ]-I-I-I-[
   _ _ _ _ _ _  _---|      | _---|    \ ` ' /
   ]-I-I-I-I-[   ---|      |  ---|    |.   |
    \ `   '_/       |     / \    |    | /^\|
     [*]  __|       ^    / ^ \   ^    | |*||
     |__   ,|      / \  /    `\ / \   | ===|
  ___| ___ ,|__   /    /=_=_=_=\   \  |,  _|
  I_I__I_I__I_I  (====(_________)___|_|____|____
  \-\--|-|--/-/  |     I  [ ]__I I_I__|____I_I_|
   |[]      '|   | []  |`__  . [  \-\--|-|--/-/
   |.   | |' |___|_____I___|___I___|---------|
  / \| []   .|_|-|_|-|-|_|-|_|-|_|-| []   [] |
 <===>  |   .|-=-=-=-=-=-=-=-=-=-=-|   |    / \
 ] []|`   [] ||.|.|.|.|.|.|.|.|.|.||-      <===>
 ] []| ` |   |/////////\\\\\\\\\\.||__.  | |[] [
 <===>     ' ||||| |   |   | ||||.||  []   <===>
  \T/  | |-- ||||| | O | O | ||||.|| . |'   \T/
   |      . _||||| |   |   | ||||.|| |     | |
../|' v . | .|||||/____|____\|||| /|. . | . ./
.|//\............/...........\........../../\\\

Here is the code that renders the ASCII image, with all special characters escaped with the proper backslash \.

(intro)
  (div @quote) { 
    Hurrying through the rainswept November night, you're glad to see the bright
    lights of the castle.
  
    (par)
                                     o
                             _---\\|         _ _ _ _ _
                          o   ---\\|     o   \]-I-I-I-\[
         _ _ _ _ _ _  _---\\|      \\| _---\\|    \\ ` ' /
         \]-I-I-I-I-\[   ---\\|      \\|  ---\\|    \\|.   \\|
          \\ `   '_/       \\|     / \\    \\|    \\| /^\\\\|
           \[\*\]  __\\|       ^    / ^ \\   ^    \\| \\|\*\\|\\|
           \\|__   ,\\|      / \\  /    `\\ / \\   \\| ===\\|
        ___\\| ___ ,\\|__   /    /=_=_=_=\\   \\  \\|,  _\\|
        I_I__I_I__I_I  \(====\(_________\)___\\|_\\|____\\|____
        \\-\\--\\|-\\|--/-/  \\|     I  \[ \]__I I_I__\\|____I_I_\\|
         \\|\[\]      '\\|   \\| \[\]  \\|`__  . \[  \\-\\--\\|-\\|--/-/
         \\|.   \\| \\|' \\|___\\|_____I___\\|___I___\\|---------\\|
        / \\\\| \[\]   .\\|_\\|-\\|_\\|-\\|-\\|_\\|-\\|_\\|-\\|_\\|-\\| \[\]   \[\] \\|
       <===>  \\|   .\\|-=-=-=-=-=-=-=-=-=-=-\\|   \\|    / \\
       \] \[\]\\|`   \[\] \\|\\|.\\|.\\|.\\|.\\|.\\|.\\|.\\|.\\|.\\|.\\|\\|-      <===>
       \] \[\]\\| ` \\|   \\|/////////\\\\\\\\\\\\\\\\\\\\.\\|\\|__.  \\| \\|\[\] \[
       <===>     ' \\|\\|\\|\\|\\| \\|   \\|   \\| \\|\\|\\|\\|.\\|\\|  \[\]   <===>
        \\T/  \\| \\|-- \\|\\|\\|\\|\\| \\| O \\| O \\| \\|\\|\\|\\|.\\|\\| . \\|'   \\T/
         \\|      . _\\|\\|\\|\\|\\| \\|   \\|   \\| \\|\\|\\|\\|.\\|\\| \\|     \\| \\|
      ../\\|' v . \\| .\\|\\|\\|\\|\\|/____\\|____\\\\|\\|\\|\\| /\\|. . \\| . ./
      .\\|//\\............/...........\\........../../\\\\\\
  }

Here is the final output using the Dialog file compiled to .z5 and run with Frotz, on MacOS.

Hurrying through the rainswept November night, you're glad to see the bright
lights of the castle.

o _---\| _ _ _ _ _ o---\| o]-I-I-I-[_ _ _ _ _ _ _---\| \| _---\| \ ` ' /]-I-I-I-I-
[---\| \|---\| \|. \| \ ` '_/ \| / \ \| \| /^\\| [*] __\| ^ / ^ \ ^ \| \|*\|\|
\|__,\| / \ / `\ / \ \| ===\| ___\| ___,\|__ / /=_=_=_=\ \ \|, _\| I_I__I_I__I_I
(====(_________)___\|_\|____\|____ \-\--\|-\|--/-/ \| I []__I I_I__\|____I_I_\|
\|[] '\| \| [] \|`__. [\-\--\|-\|--/-/ \|. \| \|'
\|___\|_____I___\|___I___\|---------\| / \\| [].\|_\|-\|_\|-\|-\|_\|-\|_\|-\|_\|-\|
[] [] \| <===> \|.\|-=-=-=-=-=-=-=-=-=-=-\| \| / \] []\|` []
\|\|.\|.\|.\|.\|.\|.\|.\|.\|.\|.\|\|-<===>] []\| ` \| \|/////////\\\\\\\\\\.\|\|__.
\| \|[] [<===> ' \|\|\|\|\| \| \| \| \|\|\|\|.\|\| [] <===> \T/ \| \|--\|\|\|\|\|
\| O \| O \| \|\|\|\|.\|\|. \|' \T/ \|. _\|\|\|\|\| \| \| \| \|\|\|\|.\|\| \| \|
\|../\|' v. \|.\|\|\|\|\|/____\|____\\|\|\|\| /\|..
\|../.\|//\............/...........\........../../\\\

As you can see, the final ASCII image is mangled due to the special text processing performed by Dialog. There is also some overhead with writing a custom script (which I wrote in Ruby) to escape all the necessary characters in a given piece of text.

It would be great if there were a way to print a block of text literally, without Dialog using it’s special text formatting approach (which works perfectly for formatting story text, but causes issues with special text like this). This would make it possible to print ASCII diagrams that retain their proper formatting. If there’s a workaround that currently exists, I would love to be enlightened.

4 Likes

One workaround would be to replace all the runs of spaces with (spaces N) in the Ruby script. But that’s just a quick fix.

3 Likes