pcjs/_includes/machine-engines.html
2017-06-25 09:28:58 -07:00

190 lines
10 KiB
HTML

{% comment %}
As discussed in /modules/markout/lib/markout.js, our Node web server recognizes the following machine properties
in the Front Matter of our Markdown documents, for compatibility with the Jekyll web server:
'id' (eg: ibm5150)
'name' (eg: "IBM PC (Model 5150) with Monochrome Display")
'type' (eg: c1p, pcx86, pc8080, pdp10, pdp11)
'debugger' (default: false)
'config' (default: machine.xml)
'template' (default: machine.xsl)
'debug' (default: false; true enables asserts and is much slower)
'uncompiled' (default: false; true is useful for debugging but slower)
'parms' (stringified object that collects additional machine properties listed below)
Note that if you want BACKTRACK support enabled in a machine, both 'debugger' and 'uncompiled' must be true.
Also note that while multiple machines ARE supported on a single page, there are some limitations; for example,
loading two or more machines of the same 'type' but with different 'debug', 'uncompiled', or 'debugger' settings
may not work as desired.
The following optional machine properties will be added to the 'parms' property:
'autoMount' (eg: {"A":{"name":"OS/2 FOOTBALL (v7.68.17)","path":"/disks/pc/os2/misc/football/FOOTBALL-76817.json"}})
'autoPower' (eg: true)
'autoStart' (eg: true)
'autoType' (eg: $date\r$time\r)
'drives' (eg: '[{name:"68Mb Hard Disk",type:4,path:"http://archive.pcjs.org/disks/pc/fixed/68mb/win95.json"}]')
'resume' (eg: 1)
'state' (eg: state.json)
'commands' (debugger commands, if any)
'messages' (eg: fault)
'connection' (eg: serialPort->vt100a.serialPort)
Finally, all our JavaScript components expect multi-word property names to use camelCase, so we automatically convert
any lower-case forms to camelCase, both here and in markout.js and components.xsl, in case we've gotten sloppy in any
of our Markdown or XML documents. Examples: 'automount' becomes 'autoMount', 'autopower' becomes 'autoPower', etc.
{% endcomment %}
{% for machine in page.machines %}
{% capture machine_type %}{{ machine.type | remove:"-dbg" }}{% endcapture %}
{% if machine_type == "c1p" %}
{% assign machine_app = "c1pjs" %}
{% elsif machine_type == "pdp10" or machine_type == "pdp11" %}
{% assign machine_app = "pdpjs" %}
{% else %}
{% capture machine_app %}{{ machine_type }}{% endcapture %}
{% endif %}
{% unless machine.config %}
{% assign machine_config = "machine.xml" %}
{% else %}
{% assign machine_config = machine.config %}
{% endunless %}
{% if machine.debugger or machine_config contains "debugger" %}
{% capture machine_file %}{{ machine_type }}-dbg{% endcapture %}
{% assign machine_debugger = true %}
{% else %}
{% capture machine_file %}{{ machine.type }}{% endcapture %}
{% if machine.type != machine_type %}
{% assign machine_debugger = true %}
{% else %}
{% assign machine_debugger = false %}
{% endif %}
{% endif %}
{% capture machine_embed %}embed{{ machine_type | upcase | replace:"X86","x86" }}{% endcapture %}
{% if machine.automount != nil %}
{% if machine.automount == "" %}
{% assign machine_autoMount = "{}" %}
{% else %}
{% capture machine_autoMount %}{{ machine.automount|jsonify }}{% endcapture %}
{% endif %}
{% else %}
{% if machine.autoMount == "" %}
{% assign machine_autoMount = "{}" %}
{% else %}
{% capture machine_autoMount %}{{ machine.autoMount|jsonify }}{% endcapture %}
{% endif %}
{% endif %}
{% if machine.autopower != nil %}
{% capture machine_autoPower %},autoPower:{{ machine.autopower }}{% endcapture %}
{% elsif machine.autoPower != nil %}
{% capture machine_autoPower %},autoPower:{{ machine.autoPower }}{% endcapture %}
{% else %}
{% assign machine_autoPower = "" %}
{% endif %}
{% if machine.autostart != nil %}
{% capture machine_autoStart %},autoStart:{{ machine.autostart }}{% endcapture %}
{% elsif machine.autoStart != nil %}
{% capture machine_autoStart %},autoStart:{{ machine.autoStart }}{% endcapture %}
{% else %}
{% assign machine_autoStart = "" %}
{% endif %}
{% if machine.autotype != nil %}
{% capture machine_autoType %},autoType:"{{ machine.autotype | replace:"\r":"\\\\r" | replace:"\n":"\\\\n" | replace:"\t":"\\\\t" | replace:"\x":"\\\\x" }}"{% endcapture %}
{% elsif machine.autoType != nil %}
{% capture machine_autoType %},autoType:"{{ machine.autoType | replace:"\r":"\\\\r" | replace:"\n":"\\\\n" | replace:"\t":"\\\\t" | replace:"\x":"\\\\x" }}"{% endcapture %}
{% else %}
{% assign machine_autoType = "" %}
{% endif %}
{% if machine.drives != nil %}
{% if machine.drives == "" %}
{% assign machine_drives = ",drives:[]" %}
{% else %}
{% capture machine_drives %},drives:{{ machine.drives }}{% endcapture %}
{% endif %}
{% else %}
{% assign machine_drives = "" %}
{% endif %}
{% unless machine.template %}
{% assign machine_template = "" %}
{% else %}
{% assign machine_template = machine.template %}
{% endunless %}
{% capture machine_parms %}{{ site.left_brace }}autoMount:{{ machine_autoMount }}{{ machine_autoPower }}{{ machine_autoStart }}{{ machine_autoType }}{{ machine_drives }},resume:"{{ machine.resume }}",state:"{{ machine.state }}",commands:"{{ machine.commands }}",messages:"{{ machine.messages }}",connection:"{{ machine.connection }}"{{ site.right_brace }}{% endcapture %}
{% if site.pcjs.compiled == true and machine.uncompiled != true %}
{% capture machine_script %}
<script type="text/javascript" src="{{ site.baseurl }}/versions/{{ machine_app }}/{{ site.pcjs.version }}/{{ machine_file }}.js"></script>{% endcapture %}
{% unless machine_scripts contains machine_script %}
{{ machine_script }}
{% endunless %}
{% capture machine_scripts %}{{ machine_scripts }}{{ machine_script }}{% endcapture %}
{% if machine_template == "" %}
{% capture machine_template %}{{ site.baseurl }}/versions/{{ machine_app }}/{{ site.pcjs.version }}/components.xsl{% endcapture %}
{% endif %}
{% else %}
{% capture machine_file_uncompiled %}{{ machine_file | remove:"-dbg" | append:"-uncompiled" }}{% endcapture %}
{% capture machine_script %}
<script type="text/javascript" src="{{ site.baseurl }}/versions/{{ machine_app }}/{{ site.pcjs.version }}/{{ machine_file_uncompiled }}.js"></script>{% endcapture %}
{% unless machine_scripts contains machine_script %}
{{ machine_script }}
{% endunless %}
{% capture machine_scripts %}{{ machine_scripts }}{{ machine_script }}{% endcapture %}
{% if machine_template == "" %}
{% capture machine_template %}{{ site.baseurl }}/versions/{{ machine_app }}/{{ site.pcjs.version }}/components.xsl{% endcapture %}
{% endif %}
{% comment %}
The following approach worked well before we converted most of the code to ES6 classes. Unfortunately, ES6 classes
don't coexist well with the conditional Node require() statements inside the individual scripts. Since we were already
stripping all the Node-related code from the scripts to build monolithic scripts that we could feed into the Closure
Compiler, we have simply moved those monolithic scripts from the /tmp folder to the /versions folder, with "-uncompiled"
suffixes. And since they are now checked in alongside the compiled files, there's the added benefit that we can always
reference them from source maps.
So, the following template code is no longer of any use, but we'll leave it here for historical reference. Note that
our Node web server still serves up individual scripts, because it has the ability to strip all Node references from the
scripts before delivering them to the web browser. But that's not really feasible in the Jekyll environment.
{% if machine_type == "c1p" %}{% assign array_scripts = site.pcjs.c1p_scripts %}{% endif %}
{% if machine_type == "pcx86" %}{% assign array_scripts = site.pcjs.pcx86_scripts %}{% endif %}
{% if machine_type == "pc8080" %}{% assign array_scripts = site.pcjs.pc8080_scripts %}{% endif %}
{% if machine_type == "pdp10" %}{% assign array_scripts = site.pcjs.pdp10_scripts %}{% endif %}
{% if machine_type == "pdp11" %}{% assign array_scripts = site.pcjs.pdp11_scripts %}{% endif %}
{% for script in array_scripts %}
{% if script != "/modules/shared/lib/nodebug.js" or machine.debug != true and site.pcjs.debug != true %}
{% capture machine_script %}<script type="text/javascript" src="{{ site.baseurl }}{{ script }}"></script>{% endcapture %}
{% unless machine_scripts contains machine_script %}
{{ machine_script }}
{% if script contains "shared/lib/defines.js" %}
{% if site.pcjs.private %}
{{ machine_script | replace:"defines.js","private.js" }}
{% endif %}
{% endif %}
{% if script contains "js/lib/defines.js" %}
{% if machine_debugger != true %}
{{ machine_script | replace:"defines.js","nodebugger.js" }}
{% endif %}
{% endif %}
{% endunless %}
{% capture machine_scripts %}{{ machine_scripts }}{{ machine_script }}{% endcapture %}
{% endif %}
{% endfor %}
{% if machine_template == "" %}
{% if machine_app != "c1pjs" %}
{% capture machine_template %}{{ site.baseurl }}/modules/shared/templates/components.xsl{% endcapture %}
{% else %}
{% capture machine_template %}{{ site.baseurl }}/modules/{{ machine_app }}/templates/components.xsl{% endcapture %}
{% endif %}
{% endif %}
{% endcomment %}
{% endif %}
<script type="text/javascript">{{ machine_embed }}('{{ machine.id }}','{{ machine_config }}','{{ machine_template }}','{{ machine_parms }}');</script>
{% if machine.sticky == "top" %}
<script type="text/javascript" src="{{ site.baseurl }}/modules/shared/lib/sticky.js"></script>
<script type="text/javascript">addStickyMachine('{{ machine.id }}');</script>
{% endif %}
{% if page.build %}
<script type="text/javascript" src="{{ site.baseurl }}/modules/build/lib/build.js"></script>
<script type="text/javascript">buildPC("{{ page.build }}");</script>
{% endif %}
{% endfor %}