{%- assign machine_id = include.id -%} {%- assign machine_type = include.type -%} {%- assign machine_config = include.config -%} {%- assign machine_layout = include.layout -%} {%- capture machine_name -%}{{ include.name | default: "PCjs Machine" }}{%- endcapture -%} {%- assign machine_errors = "" -%} {%- assign machine_does_not_exist = true -%} {%- for candidate in page.machines -%} {%- if candidate.id == machine_id -%} {%- assign machine = candidate -%} {%- if candidate.type -%}{%- assign machine_type = candidate.type -%}{%- endif -%} {%- if candidate.config -%}{%- assign machine_config = candidate.config -%}{%- endif -%} {%- if candidate.layout -%}{%- assign machine_layout = candidate.layout | replace: "/_includes/", "" | replace: ".html", "" -%}{%- endif -%} {%- if candidate.debugger -%}{%- assign machine_debugger = candidate.debugger -%}{%- endif -%} {%- assign machine_does_not_exist = false -%} {%- break -%} {%- endif -%} {%- endfor -%} {%- if machine_config -%} {%- if machine_config contains ".xml" %}

[{{ machine_name }} "{{ machine_id }}"]

Waiting for machine "{{machine_id }}" to load....

{%- assign machine = nil -%} {%- assign machine_does_not_exist = false -%} {%- comment -%}Machines that use XML files have their layouts built at page load time, using XSL files, so we're done here.{%- endcomment -%} {%- elsif machine_layout -%} {%- include {{ machine_layout }}.html id=machine_id -%} {%- assign machine = nil -%} {%- assign machine_does_not_exist = false -%} {%- comment -%}Machines that explicitly include an HTML layout file do not need any additional layout work performed below.{%- endcomment -%} {%- elsif machine_config contains "/machines/" -%} {%- assign machine_data = site.data -%} {%- assign machine_paths = machine_config | replace: "/machines/", "" | replace: ".json", "" | split: "/" -%} {%- for machine_path in machine_paths -%}{%- assign machine_data = machine_data[machine_path] -%}{%- endfor -%} {%- assign machine = machine_data -%} {%- assign machine_data = machine.machine -%} {%- comment -%}Any JSON configuration file in the /machines folder should be accessible through site.data, driving layout generation below.{%- endcomment -%} {%- unless machine %} {%- capture machine_errors %}{{ machine_errors }}

Missing machine configuration file: {{ machine_config }}

{%- endcapture -%} {%- endunless -%} {%- else -%} {%- assign machine = nil -%} {%- comment -%}The assumption here is that the page has defined its own layout, styles, and config file, so there's nothing more we need do here.{%- endcomment -%} {%- endif -%} {%- elsif machine -%} {%- unless machine.components -%} {%- assign machine_group = site.data.machines[machine_type].folder | split: '/' -%} {%- unless machine_group[1] %} {%- assign machine = site.data[machine_type][machine_id] -%} {%- else %} {%- assign machine_group = machine_group[0] -%} {%- assign machine = site.data[machine_group][machine_type][machine_id] -%} {%- endunless %} {%- unless machine -%} {%- capture machine_errors %}{{ machine_errors }}

Missing machine configuration for {{ machine_id }}

{%- endcapture -%} {%- endunless -%} {%- endunless -%} {%- endif -%} {%- if machine -%} {%- unless machine_data -%} {%- assign machine_data = site.data.machines[machine_type] -%} {%- endunless -%} {%- if machine_name == "PCjs Machine" -%} {%- if machine.name -%} {%- assign machine_name = machine.name -%} {%- elsif machine_type -%} {%- capture machine_name -%}{{ machine_type | upcase | replace:"X86","x86" }} Machine{%- endcapture -%} {%- endif -%} {%- endif -%} {%- assign machine_style = "" -%} {%- if machine.style -%} {%- capture machine_style -%} {%- for style in machine.style -%}{{ style[0] }}:{{style[1]}};{%- endfor -%} {%- endcapture -%} {%- endif -%} {%- assign machine_parms = "" -%} {%- if machine.parms -%} {%- capture machine_parms %} data-value="{ {% for prop in machine.parms %}{{ prop[0] }}:'{{ prop[1] }}',{% endfor %}@ }"{%- endcapture -%} {%- endif %}
{%- if machine_name != page.title %}

{{ machine_name }}

{%- endif %}
{%- for machine_component in machine.components -%} {%- assign config = nil -%} {%- comment -%}A machine_component with no "config" AND no "id" is assumed to simply be a string, containing the path to a config file.{%- endcomment -%} {%- if machine_component.config -%}{%- assign config = machine_component.config -%}{%- elsif machine_component.id == nil -%}{%- assign config = machine_component -%}{%- endif -%} {%- if config -%} {%- assign config_data = site.data -%} {%- assign config_paths = config | replace: "/machines/", "" | replace: ".json", "" | split: "/" -%} {%- for config_path in config_paths -%}{%- assign config_data = config_data[config_path] -%}{%- endfor -%} {%- assign component = config_data -%} {%- unless component and machine_component.class == nil or component.class == machine_component.class %} {%- capture machine_errors %}{{ machine_errors }}

Missing or invalid component configuration file: {{ config }}

{%- endcapture -%} {%- continue -%} {%- endunless -%} {%- else -%} {%- assign component = machine_component -%} {%- endif -%} {%- assign component_id = machine_component.id | default: component.id %} {%- assign component_config = "" %} {%- assign component_make = component.make | default: machine.make %} {%- assign component_model = component.model | default: machine.model %} {%- if site.developer %} {%- endif %} {%- assign component_title = "" %} {%- assign component_class = "" %} {%- assign component_style = "" %} {%- assign component_controls = "" %} {%- assign component_elements = "" %} {%- capture default_config -%}id:'{{ machine_id }}.{{ component_id }}',name:'{{ component.name }}'{%- endcapture -%} {%- if component.class == "computer" -%} {%- if component.modules -%} {%- capture module_config -%},modules:[{% for module in component.modules %}{ type:'{{ module.type }}',refID:'{{ module.id }}',start:{{ module.start }},end:{{ module.end }} },{% endfor %}@]{%- endcapture -%} {%- capture component_config -%}{ {{ default_config }}{{ module_config | replace: ",@", "" }} }{%- endcapture -%} {%- else -%} {%- capture component_config -%}{ {{ default_config }},autoPower:{{ component.autoPower | default: "true" }},busWidth:{{ component.busWidth | default: "0" }} }{%- endcapture -%} {%- endif -%} {%- elsif component.class == "chipset" -%} {%- capture component_config -%}{ {{ default_config }},model:'{{ component.model }}',scaleTimers:{{ component.scaleTimers | default: "false" }},sw1:'{{ machine_component.sw1 | default: component.sw1 }}',sw2:'{{ machine_component.sw2 | default: component.sw2 }}',sound:{{ component.sound | default: "true" }},floppies:{ {{ component.floppies }} },monitor:'{{ component.monitor }}',dateRTC:'{{ component.dateRTC }}' }{%- endcapture -%} {%- elsif component.class == "cpu" -%} {%- capture component_config -%}{ {{ default_config }},model:'{{ component.model }}',stepping:'{{ component.stepping }}',fpu:{{ component.fpu | default: "0" }},multiplier:{{ component.multiplier | default: "1" }},autoStart:{{ component.autoStart | default: "undefined" }},addrReset:{{ component.addrReset | default: "0" }} }{%- endcapture -%} {%- elsif component.class == "debugger" -%} {%- capture component_config -%}{ {{ default_config }},base:{{ component.base | default: "16" }},commands:'{{ component.commands }}',messages:'{{ component.messages }}' }{%- endcapture -%} {%- elsif component.class == "fdc" -%} {%- if component.autoMount -%} {%- capture component_autoMount -%}{%- for drive in component.autoMount -%}{{ drive[0] }}:{%- if drive[1].name -%}{name:"{{ drive[1].name }}"}{%- else -%}{path:"{{ drive[1].path }}"}{%- endif -%},{%- endfor -%}@{%- endcapture -%} {%- endif -%} {%- capture component_config -%}{ {{ default_config }},autoMount:'{ {{ component_autoMount | replace: ",@", "" }} }',diskettes:'{{ component.diskettes }}',server:'{{ component.server }}' }{%- endcapture -%} {%- elsif component.class == "hdc" -%} {%- capture component_drives -%}{%- for drive in component.drives -%}{ name:"{{ drive.name }}",type:{{ drive.type | default: "3" }},path:"{{ drive.path }}" },{%- endfor -%}@{%- endcapture -%} {%- capture component_config -%}{ {{ default_config }},drives:'[{{ component_drives | replace: ",@", "" }}]',type:'{{ component.type | default: "XT" }}',server:'{{ component.server }}' }{%- endcapture -%} {%- elsif component.class == "keyboard" -%} {%- capture component_config -%}{ {{ default_config }},model:'{{ component.model }}' }{%- endcapture -%} {%- elsif component.class == "mouse" -%} {%- capture component_config -%}{ {{ default_config }},adapter:{{ component.adapter | default: "0" }},binding:'{{ component.binding }}',type:'{{ component.type }}',scaleMouse:{{ component.scaleMouse | default: "0.5" }},serial:'{{ component.serial }}'}{%- endcapture -%} {%- elsif component.class == "panel" -%} {%- capture component_config -%}{ {{ default_config }} }{%- endcapture -%} {%- elsif component.class == "parallel" -%} {%- capture component_config -%}{ {{ default_config }},adapter:{{ component.adapter | default: "0" }},binding:'{{ component.binding }}'}{%- endcapture -%} {%- elsif component.class == "ram" -%} {%- capture component_config -%}{ {{ default_config }},addr:{{ component.addr | default: "0" }},size:{{ component['size'] | default: "0" }},file:'{{ component.file }}',load:{{ component.load | default: "null" }},exec:{{ component.exec | default: "null" }},test:{{ machine_component.test | default: component.test | default: "true" }} }{%- endcapture -%} {%- elsif component.class == "rom" -%} {%- capture component_config -%}{ {{ default_config }},addr:{{ component.addr | default: "0" }},size:{{ component['size'] | default: "0" }},file:'{{ component.file }}',alias:{{ component.alias | default: "null" }},notify:'{{ component.notify }}' }{%- endcapture -%} {%- elsif component.class == "serial" -%} {%- capture component_config -%}{ {{ default_config }},adapter:{{ component.adapter | default: "0" }},binding:'{{ component.binding }}',baudReceive:{{ component.baudReceive | default: "0" }},baudTransmit:{{ component.baudTransmit | default: "0" }},tabSize:{{ component.tabSize | default: "0" }},charBOL:{{ component.charBOL | default: "0" }},upperCase:{{ component.upperCase | default: "false" }} }{%- endcapture -%} {%- elsif component.class == "video" -%} {%- capture component_class %} pcjs-screen{%- endcapture -%} {%- capture component_config -%}{ {{ default_config }},model:'{{ machine_component.model | default: component.model }}',memory:'{{ machine_component.memory | default: component.memory }}',screenWidth:{{ component.screenWidth | default: "640" }},screenHeight:{{ component.screenHeight | default: "400" }},screenColor:'{{ component.screenColor }}',fontROM:'{{ component.fontROM }}',fontColor:'{{ component.fontColor }}',charCols:{{ component.charCols | default: 80 }},charRows:{{ component.charRows | default: 25 }},touchScreen:'{{ component.touchScreen }}',scale:{{ component.scale | default: false }},switches:'{{ component.switches }}',autoLock:{{ component.autoLock | default: false }},aspectRatio:{{ component.aspectRatio | default: 0 }},smoothing:{{ component.smoothing | default: "null" }},flicker:{{ component.flicker | default: 1.0 }} }{%- endcapture -%} {%- capture component_elements %} {%- if component.overlay %} {%- endif %} {% endcapture -%} {%- endif -%} {%- if component_config -%} {%- assign component_style = "" -%} {%- if component.style -%} {%- capture component_style -%} {%- for style in component.style -%}{{ style[0] }}:{{style[1]}};{%- endfor -%} {%- endcapture -%} {%- endif -%} {%- if component.title -%} {%- capture component_title %}
{{ component.title }}
{%- endcapture -%} {%- endif -%} {%- assign machine_controls = machine_component.controls | default: component.controls -%} {%- if machine_controls and machine_controls != "none" -%} {%- capture component_controls -%} {%- assign control_group = "" -%} {%- for control in machine_controls -%} {%- assign control_class = "" -%} {%- assign control_style = "" -%} {%- assign control_make = control.make | default: component_make %} {%- assign control_model = control.model | default: component_model %} {%- if control.class -%} {%- capture control_class %} {{ control.class }}{%- endcapture -%} {%- endif -%} {%- if control.style -%} {%- capture control_style -%} {%- for style in control.style -%}{{ style[0] }}:{{style[1]}};{%- endfor -%} {%- endcapture -%} {%- endif %} {%- if control.type == "group" -%} {%- if control_group != "" -%}
{%- endif %}
{%- capture control_group -%}{{ control.group }}.{{ control.id }}{%- endcapture -%} {%- continue -%} {%- endif %}
{%- if control.title %}
{{ control.title }}
{%- endif %} {%- if control.type == "button" %} {%- elsif control.type == "description" -%} {%- unless control.id %}
{{ control.label }}
{%- else %}
{{ control.label }}
{%- endunless -%} {%- elsif control.type == "file" %}
{%- elsif control.type == "keyboard" %} {%- assign keyboard_layout = site.data[machine_type][control_make].keyboard[control_model] %} {%- if site.developer %} {%- endif %} {%- for key in keyboard_layout %} {%- assign key_style = "" -%}{%- if key[1].height -%}{%- capture key_style %} style="height:{{ key[1].height }};"{%- endcapture -%}{%- endif %}
{{ key[1].label }}
{%- endfor -%} {%- elsif control.type == "led" %}
{%- elsif control.type == "list" %} {%- elsif control.type == "register" %}
{{ control.label | default: control.id }}
{{ control.value | default: "0000" }}
{%- elsif control.type == "flag" %}
{{ control.label | default: control.id }}
{{ control.value | default: "0" }}
{%- elsif control.type == "switches" %}
{%- for switch in control.switches -%} {%- if switch.value == "0"} {%- assign switch_color = "color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);" -%} {%- else -%} {%- assign switch_color = "color: rgb(255, 255, 255); background-color: rgb(0, 0, 0);" -%} {% endif %}
{{ switch.label }}
{%- endfor %}
{%- elsif control.type == "text" %} {%- elsif control.type == "textarea" %} {%- else %} {%- endif %}
{%- endfor %} {%- if control_group != "" %}
{%- endif -%} {%- endcapture -%} {%- endif -%} {%- endif %}
{{ component_title }}{{ component_controls }}
{{ component_elements }}
{%- endfor -%}
{%- if machine_debugger %}
[Debugger]
{%- endif %}
{%- endif -%} {%- if machine_does_not_exist -%}

{{ machine_name }} does not exist: {{ include.id }}

{%- endif -%} {{ machine_errors }}