Inital Commit. Mostly working

This commit is contained in:
Christian 2020-12-24 16:37:28 +01:00
commit 98bd366c24
12 changed files with 8694 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
desktop.ini
elm-stuff/*

24
elm.json Normal file
View File

@ -0,0 +1,24 @@
{
"type": "application",
"source-directories": [
"src"
],
"elm-version": "0.19.1",
"dependencies": {
"direct": {
"elm/browser": "1.0.2",
"elm/core": "1.0.5",
"elm/html": "1.0.0"
},
"indirect": {
"elm/json": "1.1.3",
"elm/time": "1.0.0",
"elm/url": "1.0.0",
"elm/virtual-dom": "1.0.2"
}
},
"test-dependencies": {
"direct": {},
"indirect": {}
}
}

90
out/css/colors-dark.css Normal file
View File

@ -0,0 +1,90 @@
:root {
--color-black: #05050F;
--color-white: #FFFFFF;
--color-white-light1: #FCF9ED;
--color-white-light2: #F9F3DC;
--color-black-light1: #131316;
--color-black-light2: #1C1C21;
--color-grey: #3B3B3F;
--color-grey-light1: #4F4F54;
--color-grey-light2: #5C5C61;
--color-arrow-main: #582E4E;
--color-ram-main: #294A35;
--color-ram-light1: #335C42;
--color-ram-light2: #3A694B;
--color-ram-dark1: #1D3526;
--color-cu-main: #11394A;
--color-cu-light1: #37A3D2;
--color-cu-light2: #7AC2E1;
--color-cu-dark1: #1E6685;
--color-alu-main: #214E52;
--color-alu-light1: #6DBEC5;
--color-alu-light2: #99D1D6;
--color-alu-dark1: #3A8B92;
--color-databus-main: #2F699E;
--color-databus-light1: #B0CDE8;
--color-databus-light2: #D0E1F1;
--color-addressbus-main: #3F3E33;
--color-addressbus-light1: #929077;
--color-addressbus-light2: #ADAC99;
--color-body: var(--color-black);
--color-body-text: var(--color-black);
--color-addressbus: var(--color-addressbus-main);
--color-addressbus-text: var(--color-white);
--color-databus: var(--color-databus-main);
--color-databus-text: var(--color-white);
--color-controls-button-text: var(--color-white);
--color-controls-button-border: var(--color-white);
--color-controls-button-text-hover: var(--color-white-light1);
--color-header: var(--color-grey);
--color-header-text: var(--color-white);
--color-ram: var(--color-ram-main);
--color-ram-text: var(--color-white);
--color-cu: var(--color-cu-main);
--color-cu-text: var(--color-white);
--color-alu: var(--color-alu-main);
--color-alu-text: var(--color-white);
--color-table-row: var(--color-black-light1);
--color-table-row-alt: var(--color-black-light2);
--color-table-text: var(--color-white);
--color-table-text-empty: var(--color-grey-light2);
--color-table-border: var(--color-black-light2);
--color-table-ram-head: var(--color-ram-dark1);
--color-table-ram-head-text: var(--color-white);
--color-table-ram-highlight: var(--color-ram-light2);
--color-table-ram-highlight-text: var(--color-black);
--color-table-cu-head: var(--color-cu-dark1);
--color-table-cu-head-text: var(--color-white);
--color-table-cu-highlight: var(--color-cu-light2);
--color-table-cu-highlight-text: var(--color-black);
--color-arrow: var(--color-arrow-main);
--color-arrow-text: var(--color-white);
--color-arrow-text-hover: var(--color-white-light2);
--color-arrow-border: var(--color-black-light1);
}
/* https://coolors.co/aa8f66-ed9b40-ffeedb-61c9a8-ba3b46-071013 */
/* https://coolors.co/faf3dd-000022-9c528b-62a87c-247ba0-429ea6-8fb8de-72705b */

90
out/css/colors-light.css Normal file
View File

@ -0,0 +1,90 @@
:root {
--color-black: #000022;
--color-white: #FFFFFF;
--color-white-light1: #FCF9ED;
--color-white-light2: #F9F3DC;
--color-black-light1: #00003D;
--color-black-light2: #000052;
--color-grey: #50506D;
--color-grey-light1: #68688D;
--color-grey-light2: #9595B1;
--color-arrow-main: #9C528B;
--color-ram-main: #62A87C;
--color-ram-light1: #89BE9C;
--color-ram-light2: #B0D4BD;
--color-ram-dark1: #48845E;
--color-cu-main: #247BA0;
--color-cu-light1: #37A3D2;
--color-cu-light2: #7AC2E1;
--color-cu-dark1: #1E6685;
--color-alu-main: #429EA6;
--color-alu-light1: #6DBEC5;
--color-alu-light2: #99D1D6;
--color-alu-dark1: #3A8B92;
--color-databus-main: #8FB8DE;
--color-databus-light1: #B0CDE8;
--color-databus-light2: #D0E1F1;
--color-addressbus-main: #72705B;
--color-addressbus-light1: #929077;
--color-addressbus-light2: #ADAC99;
--color-body: var(--color-white-light1);
--color-body-text: var(--color-black);
--color-addressbus: var(--color-addressbus-main);
--color-addressbus-text: var(--color-white);
--color-databus: var(--color-databus-main);
--color-databus-text: var(--color-white);
--color-controls-button-text: var(--color-black);
--color-controls-button-border: var(--color-black);
--color-controls-button-text-hover: var(--color-black-light1);
--color-header: var(--color-grey);
--color-header-text: var(--color-white);
--color-ram: var(--color-ram-main);
--color-ram-text: var(--color-white);
--color-cu: var(--color-cu-main);
--color-cu-text: var(--color-white);
--color-alu: var(--color-alu-main);
--color-alu-text: var(--color-white);
--color-table-row: var(--color-white-light1);
--color-table-row-alt: var(--color-white-light2);
--color-table-text: var(--color-black);
--color-table-text-empty: var(--color-grey-light2);
--color-table-border: var(--color-white-light2);
--color-table-ram-head: var(--color-ram-dark1);
--color-table-ram-head-text: var(--color-white);
--color-table-ram-highlight: var(--color-ram-light2);
--color-table-ram-highlight-text: var(--color-black);
--color-table-cu-head: var(--color-cu-dark1);
--color-table-cu-head-text: var(--color-white);
--color-table-cu-highlight: var(--color-cu-light2);
--color-table-cu-highlight-text: var(--color-black);
--color-arrow: var(--color-arrow-main);
--color-arrow-text: var(--color-white);
--color-arrow-text-hover: var(--color-white-light2);
--color-arrow-border: var(--color-black-light1);
}
/* https://coolors.co/aa8f66-ed9b40-ffeedb-61c9a8-ba3b46-071013 */
/* https://coolors.co/faf3dd-000022-9c528b-62a87c-247ba0-429ea6-8fb8de-72705b */

427
out/css/normalize.css vendored Normal file
View File

@ -0,0 +1,427 @@
/*! normalize.css v3.0.2 | MIT License | git.io/normalize */
/**
* 1. Set default font family to sans-serif.
* 2. Prevent iOS text size adjust after orientation change, without disabling
* user zoom.
*/
html {
font-family: sans-serif; /* 1 */
-ms-text-size-adjust: 100%; /* 2 */
-webkit-text-size-adjust: 100%; /* 2 */
}
/**
* Remove default margin.
*/
body {
margin: 0;
}
/* HTML5 display definitions
========================================================================== */
/**
* Correct `block` display not defined for any HTML5 element in IE 8/9.
* Correct `block` display not defined for `details` or `summary` in IE 10/11
* and Firefox.
* Correct `block` display not defined for `main` in IE 11.
*/
article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
main,
menu,
nav,
section,
summary {
display: block;
}
/**
* 1. Correct `inline-block` display not defined in IE 8/9.
* 2. Normalize vertical alignment of `progress` in Chrome, Firefox, and Opera.
*/
audio,
canvas,
progress,
video {
display: inline-block; /* 1 */
vertical-align: baseline; /* 2 */
}
/**
* Prevent modern browsers from displaying `audio` without controls.
* Remove excess height in iOS 5 devices.
*/
audio:not([controls]) {
display: none;
height: 0;
}
/**
* Address `[hidden]` styling not present in IE 8/9/10.
* Hide the `template` element in IE 8/9/11, Safari, and Firefox < 22.
*/
[hidden],
template {
display: none;
}
/* Links
========================================================================== */
/**
* Remove the gray background color from active links in IE 10.
*/
a {
background-color: transparent;
}
/**
* Improve readability when focused and also mouse hovered in all browsers.
*/
a:active,
a:hover {
outline: 0;
}
/* Text-level semantics
========================================================================== */
/**
* Address styling not present in IE 8/9/10/11, Safari, and Chrome.
*/
abbr[title] {
border-bottom: 1px dotted;
}
/**
* Address style set to `bolder` in Firefox 4+, Safari, and Chrome.
*/
b,
strong {
font-weight: bold;
}
/**
* Address styling not present in Safari and Chrome.
*/
dfn {
font-style: italic;
}
/**
* Address variable `h1` font-size and margin within `section` and `article`
* contexts in Firefox 4+, Safari, and Chrome.
*/
h1 {
font-size: 2em;
margin: 0.67em 0;
}
/**
* Address styling not present in IE 8/9.
*/
mark {
background: #ff0;
color: #000;
}
/**
* Address inconsistent and variable font size in all browsers.
*/
small {
font-size: 80%;
}
/**
* Prevent `sub` and `sup` affecting `line-height` in all browsers.
*/
sub,
sup {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline;
}
sup {
top: -0.5em;
}
sub {
bottom: -0.25em;
}
/* Embedded content
========================================================================== */
/**
* Remove border when inside `a` element in IE 8/9/10.
*/
img {
border: 0;
}
/**
* Correct overflow not hidden in IE 9/10/11.
*/
svg:not(:root) {
overflow: hidden;
}
/* Grouping content
========================================================================== */
/**
* Address margin not present in IE 8/9 and Safari.
*/
figure {
margin: 1em 40px;
}
/**
* Address differences between Firefox and other browsers.
*/
hr {
-moz-box-sizing: content-box;
box-sizing: content-box;
height: 0;
}
/**
* Contain overflow in all browsers.
*/
pre {
overflow: auto;
}
/**
* Address odd `em`-unit font size rendering in all browsers.
*/
code,
kbd,
pre,
samp {
font-family: monospace, monospace;
font-size: 1em;
}
/* Forms
========================================================================== */
/**
* Known limitation: by default, Chrome and Safari on OS X allow very limited
* styling of `select`, unless a `border` property is set.
*/
/**
* 1. Correct color not being inherited.
* Known issue: affects color of disabled elements.
* 2. Correct font properties not being inherited.
* 3. Address margins set differently in Firefox 4+, Safari, and Chrome.
*/
button,
input,
optgroup,
select,
textarea {
color: inherit; /* 1 */
font: inherit; /* 2 */
margin: 0; /* 3 */
}
/**
* Address `overflow` set to `hidden` in IE 8/9/10/11.
*/
button {
overflow: visible;
}
/**
* Address inconsistent `text-transform` inheritance for `button` and `select`.
* All other form control elements do not inherit `text-transform` values.
* Correct `button` style inheritance in Firefox, IE 8/9/10/11, and Opera.
* Correct `select` style inheritance in Firefox.
*/
button,
select {
text-transform: none;
}
/**
* 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio`
* and `video` controls.
* 2. Correct inability to style clickable `input` types in iOS.
* 3. Improve usability and consistency of cursor style between image-type
* `input` and others.
*/
button,
html input[type="button"], /* 1 */
input[type="reset"],
input[type="submit"] {
-webkit-appearance: button; /* 2 */
cursor: pointer; /* 3 */
}
/**
* Re-set default cursor for disabled elements.
*/
button[disabled],
html input[disabled] {
cursor: default;
}
/**
* Remove inner padding and border in Firefox 4+.
*/
button::-moz-focus-inner,
input::-moz-focus-inner {
border: 0;
padding: 0;
}
/**
* Address Firefox 4+ setting `line-height` on `input` using `!important` in
* the UA stylesheet.
*/
input {
line-height: normal;
}
/**
* It's recommended that you don't attempt to style these elements.
* Firefox's implementation doesn't respect box-sizing, padding, or width.
*
* 1. Address box sizing set to `content-box` in IE 8/9/10.
* 2. Remove excess padding in IE 8/9/10.
*/
input[type="checkbox"],
input[type="radio"] {
box-sizing: border-box; /* 1 */
padding: 0; /* 2 */
}
/**
* Fix the cursor style for Chrome's increment/decrement buttons. For certain
* `font-size` values of the `input`, it causes the cursor style of the
* decrement button to change from `default` to `text`.
*/
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
height: auto;
}
/**
* 1. Address `appearance` set to `searchfield` in Safari and Chrome.
* 2. Address `box-sizing` set to `border-box` in Safari and Chrome
* (include `-moz` to future-proof).
*/
input[type="search"] {
-webkit-appearance: textfield; /* 1 */
-moz-box-sizing: content-box;
-webkit-box-sizing: content-box; /* 2 */
box-sizing: content-box;
}
/**
* Remove inner padding and search cancel button in Safari and Chrome on OS X.
* Safari (but not Chrome) clips the cancel button when the search input has
* padding (and `textfield` appearance).
*/
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-decoration {
-webkit-appearance: none;
}
/**
* Define consistent border, margin, and padding.
*/
fieldset {
border: 1px solid #c0c0c0;
margin: 0 2px;
padding: 0.35em 0.625em 0.75em;
}
/**
* 1. Correct `color` not being inherited in IE 8/9/10/11.
* 2. Remove padding so people aren't caught out if they zero out fieldsets.
*/
legend {
border: 0; /* 1 */
padding: 0; /* 2 */
}
/**
* Remove default vertical scrollbar in IE 8/9/10/11.
*/
textarea {
overflow: auto;
}
/**
* Don't inherit the `font-weight` (applied by a rule above).
* NOTE: the default cannot safely be changed in Chrome and Safari on OS X.
*/
optgroup {
font-weight: bold;
}
/* Tables
========================================================================== */
/**
* Remove most spacing between table cells.
*/
table {
border-collapse: collapse;
border-spacing: 0;
}
td,
th {
padding: 0;
}

419
out/css/skeleton.css vendored Normal file
View File

@ -0,0 +1,419 @@
/*
* Skeleton V2.0.4
* Copyright 2014, Dave Gamache
* www.getskeleton.com
* Free to use under the MIT license.
* http://www.opensource.org/licenses/mit-license.php
* 12/29/2014
*/
/* Table of contents
- Grid
- Base Styles
- Typography
- Links
- Buttons
- Forms
- Lists
- Code
- Tables
- Spacing
- Utilities
- Clearing
- Media Queries
*/
/* Grid
*/
.container {
position: relative;
width: 100%;
max-width: 960px;
margin: 0 auto;
padding: 0 20px;
box-sizing: border-box; }
.column,
.columns {
width: 100%;
float: left;
box-sizing: border-box; }
/* For devices larger than 400px */
@media (min-width: 400px) {
.container {
width: 85%;
padding: 0; }
}
/* For devices larger than 550px */
@media (min-width: 550px) {
.container {
width: 80%; }
.column,
.columns {
margin-left: 4%; }
.column:first-child,
.columns:first-child {
margin-left: 0; }
.one.column,
.one.columns { width: 4.66666666667%; }
.two.columns { width: 13.3333333333%; }
.three.columns { width: 22%; }
.four.columns { width: 30.6666666667%; }
.five.columns { width: 39.3333333333%; }
.six.columns { width: 48%; }
.seven.columns { width: 56.6666666667%; }
.eight.columns { width: 65.3333333333%; }
.nine.columns { width: 74.0%; }
.ten.columns { width: 82.6666666667%; }
.eleven.columns { width: 91.3333333333%; }
.twelve.columns { width: 100%; margin-left: 0; }
.one-third.column { width: 30.6666666667%; }
.two-thirds.column { width: 65.3333333333%; }
.one-half.column { width: 48%; }
/* Offsets */
.offset-by-one.column,
.offset-by-one.columns { margin-left: 8.66666666667%; }
.offset-by-two.column,
.offset-by-two.columns { margin-left: 17.3333333333%; }
.offset-by-three.column,
.offset-by-three.columns { margin-left: 26%; }
.offset-by-four.column,
.offset-by-four.columns { margin-left: 34.6666666667%; }
.offset-by-five.column,
.offset-by-five.columns { margin-left: 43.3333333333%; }
.offset-by-six.column,
.offset-by-six.columns { margin-left: 52%; }
.offset-by-seven.column,
.offset-by-seven.columns { margin-left: 60.6666666667%; }
.offset-by-eight.column,
.offset-by-eight.columns { margin-left: 69.3333333333%; }
.offset-by-nine.column,
.offset-by-nine.columns { margin-left: 78.0%; }
.offset-by-ten.column,
.offset-by-ten.columns { margin-left: 86.6666666667%; }
.offset-by-eleven.column,
.offset-by-eleven.columns { margin-left: 95.3333333333%; }
.offset-by-one-third.column,
.offset-by-one-third.columns { margin-left: 34.6666666667%; }
.offset-by-two-thirds.column,
.offset-by-two-thirds.columns { margin-left: 69.3333333333%; }
.offset-by-one-half.column,
.offset-by-one-half.columns { margin-left: 52%; }
}
/* Base Styles
*/
/* NOTE
html is set to 62.5% so that all the REM measurements throughout Skeleton
are based on 10px sizing. So basically 1.5rem = 15px :) */
html {
font-size: 62.5%; }
body {
font-size: 1.5em; /* currently ems cause chrome bug misinterpreting rems on body element */
line-height: 1.6;
font-weight: 400;
color: #222;
font-family: Verdana, Geneva, Tahoma, sans-serif;
}
/* Typography
*/
h1, h2, h3, h4, h5, h6 {
margin-top: 0;
margin-bottom: 2rem;
font-weight: 300; }
h1 { font-size: 4.0rem; line-height: 1.2; letter-spacing: -.1rem;}
h2 { font-size: 3.6rem; line-height: 1.25; letter-spacing: -.1rem; }
h3 { font-size: 3.0rem; line-height: 1.3; letter-spacing: -.1rem; }
h4 { font-size: 2.4rem; line-height: 1.35; letter-spacing: -.08rem; }
h5 { font-size: 1.8rem; line-height: 1.5; letter-spacing: -.05rem; }
h6 { font-size: 1.5rem; line-height: 1.6; letter-spacing: 0; }
/* Larger than phablet */
@media (min-width: 550px) {
h1 { font-size: 5.0rem; }
h2 { font-size: 4.2rem; }
h3 { font-size: 3.6rem; }
h4 { font-size: 3.0rem; }
h5 { font-size: 2.4rem; }
h6 { font-size: 1.5rem; }
}
p {
margin-top: 0; }
/* Links
*/
a {
color: #1EAEDB; }
a:hover {
color: #0FA0CE; }
/* Buttons
*/
.button,
button,
input[type="submit"],
input[type="reset"],
input[type="button"] {
display: inline-block;
height: 38px;
padding: 0 30px;
color: #555;
text-align: center;
font-size: 11px;
font-weight: 600;
line-height: 38px;
letter-spacing: .1rem;
text-transform: uppercase;
text-decoration: none;
white-space: nowrap;
background-color: transparent;
border-radius: 4px;
border: 1px solid #bbb;
cursor: pointer;
box-sizing: border-box; }
.button:hover,
button:hover,
input[type="submit"]:hover,
input[type="reset"]:hover,
input[type="button"]:hover,
.button:focus,
button:focus,
input[type="submit"]:focus,
input[type="reset"]:focus,
input[type="button"]:focus {
color: #333;
border-color: #888;
outline: 0; }
.button.button-primary,
button.button-primary,
input[type="submit"].button-primary,
input[type="reset"].button-primary,
input[type="button"].button-primary {
color: #FFF;
background-color: #33C3F0;
border-color: #33C3F0; }
.button.button-primary:hover,
button.button-primary:hover,
input[type="submit"].button-primary:hover,
input[type="reset"].button-primary:hover,
input[type="button"].button-primary:hover,
.button.button-primary:focus,
button.button-primary:focus,
input[type="submit"].button-primary:focus,
input[type="reset"].button-primary:focus,
input[type="button"].button-primary:focus {
color: #FFF;
background-color: #1EAEDB;
border-color: #1EAEDB; }
/* Forms
*/
input[type="email"],
input[type="number"],
input[type="search"],
input[type="text"],
input[type="tel"],
input[type="url"],
input[type="password"],
textarea,
select {
height: 38px;
padding: 6px 10px; /* The 6px vertically centers text on FF, ignored by Webkit */
background-color: #fff;
border: 1px solid #D1D1D1;
border-radius: 4px;
box-shadow: none;
box-sizing: border-box; }
/* Removes awkward default styles on some inputs for iOS */
input[type="email"],
input[type="number"],
input[type="search"],
input[type="text"],
input[type="tel"],
input[type="url"],
input[type="password"],
textarea {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none; }
textarea {
min-height: 65px;
padding-top: 6px;
padding-bottom: 6px; }
input[type="email"]:focus,
input[type="number"]:focus,
input[type="search"]:focus,
input[type="text"]:focus,
input[type="tel"]:focus,
input[type="url"]:focus,
input[type="password"]:focus,
textarea:focus,
select:focus {
border: 1px solid #33C3F0;
outline: 0; }
label,
legend {
display: block;
margin-bottom: .5rem;
font-weight: 600; }
fieldset {
padding: 0;
border-width: 0; }
input[type="checkbox"],
input[type="radio"] {
display: inline; }
label > .label-body {
display: inline-block;
margin-left: .5rem;
font-weight: normal; }
/* Lists
*/
ul {
list-style: circle inside; }
ol {
list-style: decimal inside; }
ol, ul {
padding-left: 0;
margin-top: 0; }
ul ul,
ul ol,
ol ol,
ol ul {
margin: 1.5rem 0 1.5rem 3rem;
font-size: 90%; }
li {
margin-bottom: 1rem; }
/* Code
*/
code {
padding: .2rem .5rem;
margin: 0 .2rem;
font-size: 90%;
white-space: nowrap;
background: #F1F1F1;
border: 1px solid #E1E1E1;
border-radius: 4px; }
pre > code {
display: block;
padding: 1rem 1.5rem;
white-space: pre; }
/* Tables
*/
th,
td {
padding: 12px 15px;
text-align: left;
border-bottom: 1px solid #E1E1E1; }
th:first-child,
td:first-child {
padding-left: 0; }
th:last-child,
td:last-child {
padding-right: 0; }
/* Spacing
*/
button,
.button {
margin-bottom: 1rem; }
input,
textarea,
select,
fieldset {
margin-bottom: 1.5rem; }
pre,
blockquote,
dl,
figure,
table,
p,
ul,
ol,
form {
margin-bottom: 2.5rem; }
/* Utilities
*/
.u-full-width {
width: 100%;
box-sizing: border-box; }
.u-max-full-width {
max-width: 100%;
box-sizing: border-box; }
.u-pull-right {
float: right; }
.u-pull-left {
float: left; }
/* Misc
*/
hr {
margin-top: 3rem;
margin-bottom: 3.5rem;
border-width: 0;
border-top: 1px solid #E1E1E1; }
/* Clearing
*/
/* Self Clearing Goodness */
.container:after,
.row:after,
.u-cf {
content: "";
display: table;
clear: both; }
/* Media Queries
*/
/*
Note: The best way to structure the use of media queries is to create the queries
near the relevant code. For example, if you wanted to change the styles for buttons
on small devices, paste the mobile query code up in the buttons section and style it
there.
*/
/* Larger than mobile */
@media (min-width: 400px) {}
/* Larger than phablet (also point when grid becomes active) */
@media (min-width: 550px) {}
/* Larger than tablet */
@media (min-width: 750px) {}
/* Larger than desktop */
@media (min-width: 1000px) {}
/* Larger than Desktop HD */
@media (min-width: 1200px) {}

412
out/css/style.css Normal file
View File

@ -0,0 +1,412 @@
/* COLORS */
body {
background-color: var(--color-body);
color: var(--color-body-text);
}
.pc .addressbus {
background-color: var(--color-addressbus);
color: var(--color-addressbus-text);
}
.pc .databus {
background-color: var(--color-databus);
color: var(--color-databus-text);
}
.pc .ram {
background-color: var(--color-ram);
color: var(--color-ram-text);
}
.pc .cu {
background-color: var(--color-cu);
color: var(--color-cu-text);
}
.pc .alu {
background-color: var(--color-alu);
color: var(--color-alu-text);
}
.pc .section h1.header {
background-color: var(--color-header);
color: var(--color-header-text);
}
/* TABLE COLORS */
.pc .ram .scroller table thead.head th {
background-color: var(--color-table-ram-head);
color: var(--color-table-ram-head-text);
}
.pc .cu .scroller table thead.head th {
background-color: var(--color-table-cu-head);
color: var(--color-table-cu-head-text);
}
.pc .scroller table tr td {
background-color: var(--color-table-row);
color: var(--color-table-text);
border-bottom: 1px solid var(--color-table-border);
}
.pc .scroller table tr:nth-child(even) td{
background-color: var(--color-table-row-alt);
}
.pc .scroller table tr.empty td {
color: var(--color-table-text-empty);
}
.pc .ram .scroller table tr.current td {
background-color: var(--color-table-ram-highlight);
color: var(--color-table-ram-highlight-text);
}
.pc .cu .scroller table tr.current td {
background-color: var(--color-table-cu-highlight);
color: var(--color-table-cu-highlight-text);
}
/* CONTROLS COLORS */
.controls button, .controls .button {
/* background-color: whitesmoke; */
color: var(--color-controls-button-text);
border-color: var(--color-controls-button-border);
}
.controls button:hover, .controls .button:hover{
color: var(--color-controls-button-text-hover);
}
.pc .controls .checker::before {
border: 1px solid var(--color-controls-button-border);
}
.pc .controls .checker.checked::before {
color: var(--color-controls-button-text);
}
/* FORMATTING STUFF */
button {
margin: 0;
}
.pc {
height: 400px;
height: 99vh;
box-sizing: border-box;
padding: 1em;
display: grid;
grid-template-columns: auto auto auto;
gap: 9px;
}
.pc .grid-fullwidth{
grid-column: 1 / span 3;
}
.pc .section {
max-height: calc(80vh - 8em);
min-width: 20%;
box-sizing: border-box;
padding: 2.5em 1em 1em 1em;
display: flex;
flex-direction: column;
position: relative;
}
.pc .section h1.header {
font-size: 1.2em;
position: absolute;
top: 3px;
left: 4px;
padding: 3px;
}
.pc .row {
display: flex;
justify-content: space-evenly;
}
.pc .scroller {
overflow-x: auto;
overflow-y: scroll;
position: relative;
/* max-height: 60%; */
padding: 0;
box-sizing: border-box;
width: 100%;
margin: 1em 0 0 0;
}
.pc .scroller:last-child {
margin-bottom: -1em;
}
.pc .scroller table thead.head {
position: sticky;
top: 0;
left: 0;
height: 1em;
padding: 1em;
transition: 0.2s;
}
.pc .scroller table thead th {
position: -webkit-sticky;
position: sticky;
top: 0;
}
.pc .scroller table thead.head.shrunk {
height: .5em;
font-size: .8em;
}
.pc .scroller table thead.head th {
padding: 12px 4px 12px 15px;
transition: 0.2s;
}
.pc .scroller table thead.head.shrunk th {
padding-top: .2em;
padding-bottom: .2em;
}
.pc .scroller table .num {
text-align: right;
}
.pc .scroller table td:first-child,
.pc .scroller table td:last-child {
padding: 12px 15px;
}
.pc .scroller table tr.empty td {
padding: 3px 15px;
}
th.address {
width: 5rem;
padding-left: 8px;
text-align: right;
}
/* CONTROLS */
.pc .controls button{
text-transform: none !important;
font-weight: 600;
}
.pc .controls > :not(:last-child) {
margin-right: 0.75em;
}
.pc .controls .checker {
display: inline-block;
}
.pc .controls .checker label {
display: inline-block;
font-size: 0.8em;
white-space: initial;
white-space: break-spaces;
text-transform: none;
width: 6em;
width: min-content;
vertical-align: middle;
line-height: .9em;
cursor: pointer;
}
.pc .controls input[type=checkbox]{
display: none;
margin-left: -1em;
margin-right: 1em;
opacity: 0;
z-index: 0;
}
.pc .controls .checker::before{
content: "✔";
display: inline-block;
width: 2rem;
height: 2rem;
color: rgba(0,0,0,0);
border-radius: 4px;
vertical-align: middle;
margin: 0 .5em .25em -1em;
line-height: 1.8rem;
font-size: 1.4em;
box-sizing: border-box;
}
/* END CONTROLS */
/* RAM */
.pc .ram .scroller {
/* height: 100%; */
/* padding: 0.2em; */
box-sizing: border-box;
}
.pc .ram .scroller table {
width: 100%;
}
/* CONTROL UNIT */
.pc .cu p {
margin: 0 0 .2em 0;
}
.pc .cu .scroller table {
width: 100%;
}
/* BUSSES */
.pc .databus,
.pc .addressbus{
position: relative;
text-align: left;
margin: 0;
padding: .75em .5em;
}
.pc .databus .label,
.pc .addressbus .label {
/* position: absolute; */
/* left: .5em; */
margin-right: 1em;
}
.pc .addressbus {
margin-bottom: 1em;
}
.pc .databus {
margin-top: 2em;
}
/* ARROWS */
.arrow {
position: absolute;
bottom: 0;
left: 50%;
display: flex;
justify-content: center;
align-items: center;
width: 3rem;
height: 5rem;
/* transform: rotate(90deg) translate(1.5rem, 2.5rem) ; */
transform: translate(0, 3rem);
z-index: 100;
font-size: 0.5em;
color: var(--color-arrow-text);
background-color: var(--color-arrow);
}
.arrow.down {
left: 25%;
}
.arrow.up {
left: 75%;
transform: rotate(180deg) translate(0, -4.5rem);
}
.arrow.up > :nth-child(1){
/* transform: rotate(90deg) translate(0rem, 2rem); */
transform: rotate(180deg);
}
.arrow.top {
bottom: auto;
top: -6rem;
}
.arrow > :nth-child(1) {
font-size: 1.2em;
line-height: 1.1em;
font-weight: 600;
color: var(--color-arrow-text);
background-color: var(--color-arrow);
border-color: var(--color-arrow-text);
text-transform: none;
padding: 2px 10px;
margin: 0;
/* transform: rotate(-90deg) translate(0rem, -2rem); */
white-space: normal;
height: min-content;
}
.arrow > :nth-child(1) *{
color: var(--color-arrow-text);
display: block;
white-space: break-spaces;
}
.arrow > :nth-child(1):hover, .arrow > :nth-child(1) *:hover {
color: var(--color-arrow-text-hover);
}
.arrow > :nth-child(2) {
width: 0;
height: 0;
border-left: 2.5rem solid transparent;
border-right: 2.5rem solid transparent;
border-top: 2rem solid var(--color-arrow);
border-bottom: 0rem solid transparent;
position: absolute;
left: -1rem;
bottom: -2rem;
}
/* HELPERS */
.text-center {
text-align: center;
}
.text-left {
text-align: left;
}
.text-right {
text-align: right;
}
.level {
float: left;
margin-right: 1.5em;
}

6464
out/elm.js Normal file

File diff suppressed because it is too large Load Diff

9
out/icon/check.svg Normal file
View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 18.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Check" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 20 20" enable-background="new 0 0 20 20" xml:space="preserve">
<path d="M8.294,16.998c-0.435,0-0.847-0.203-1.111-0.553L3.61,11.724c-0.465-0.613-0.344-1.486,0.27-1.951
c0.615-0.467,1.488-0.344,1.953,0.27l2.351,3.104l5.911-9.492c0.407-0.652,1.267-0.852,1.921-0.445
c0.653,0.406,0.854,1.266,0.446,1.92L9.478,16.34c-0.242,0.391-0.661,0.635-1.12,0.656C8.336,16.998,8.316,16.998,8.294,16.998z"/>
</svg>

After

Width:  |  Height:  |  Size: 771 B

37
out/index.html Normal file
View File

@ -0,0 +1,37 @@
<!DOCTYPE html>
<html lang="de">
<head>
<!-- Basic Page Needs
-->
<meta charset="utf-8" />
<title>Zähler</title>
<meta name="description" content="" />
<meta name="author" content="" />
<!-- Mobile Specific Metas
-->
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- CSS
-->
<link rel="stylesheet" href="css/normalize.css" />
<link rel="stylesheet" href="css/skeleton.css" />
<link rel="stylesheet" href="css/colors-light.css">
<link rel="stylesheet" href="css/style.css" />
<!-- Favicon
-->
<!-- <link rel="icon" type="image/png" href="images/favicon.png" /> -->
</head>
<body>
<!-- Primary Page Layout
-->
<div id="elm"></div>
<!-- End Document
-->
<script src="elm.js"></script>
<script src="script.js"></script>
</body>
</html>

59
out/script.js Normal file
View File

@ -0,0 +1,59 @@
// Init Elm
var app = Elm.Main.init({
node: document.getElementById("elm"),
// flags: Date.now()
});
// Dom Objects
let pc = document.getElementsByClassName("pc")[0];
let pc_ram = pc.getElementsByClassName("ram")[0];
let pc_cu = pc.getElementsByClassName("cu")[0];
let pc_alu = pc.getElementsByClassName("alu")[0];
let pc_ram_scroller = pc_ram.getElementsByClassName("scroller")[0];
let pc_cu_scroller = pc_cu.getElementsByClassName("scroller")[0];
let control_autoscroll = document.getElementById("enableScrolling");
// Methods
function scrollToCurrent(){
if( control_autoscroll.checked == false ) return;
let current_ram = pc_ram.getElementsByClassName("current")[0];
if( typeof current_ram != "undefined"){
current_ram.scrollIntoView({behavior: "smooth", block: "center"});
}
let current_uCode = pc_cu.getElementsByClassName("current")[0];
if( typeof current_uCode != "undefined"){
current_uCode.scrollIntoView({behavior: "smooth", block: "center"});
}
}
function shrinkTableHead(scroll){
let scroller = scroll.target;
let pos = scroller.scrollTop;
let thead = scroller.getElementsByClassName("head")[0];
if( pos > 70 ){
thead.classList.add("shrunk");
}else if (pos < 40){
thead.classList.remove("shrunk");
}
}
// EVENT LISTENERS
pc_ram_scroller.addEventListener("scroll", shrinkTableHead);
pc_cu_scroller.addEventListener("scroll", shrinkTableHead);
// Recieve Elm updates via ports
app.ports.sendUUpdate.subscribe( (message) => {
// console.log("Update: ", message);
scrollToCurrent();
// Make sure that even when the calculation takes longer it will scroll correctly
setTimeout( scrollToCurrent, 100 );
} );

660
src/Main.elm Normal file
View File

@ -0,0 +1,660 @@
--module Main exposing (Model, Msg, update, view, init)
port module Main exposing (..)
import Browser
import Html exposing (Html, button, div, h1, p, text)
import Html.Attributes as HAttr exposing (class, classList, value)
import Html.Events exposing (onClick)
import Html.Lazy exposing (lazy)
import Tuple
import Array exposing (get)
-- Note that general Stuff is at the end of the document
-- PORTS
port sendUUpdate : String -> Cmd msg
port sendRamUpdate : String -> Cmd msg
port recieveLocalSession : (String -> msg) -> Sub msg
type alias PC =
{ ram : List Int
, dataBus : Int
, addressBus : Int
, instructionReg : Int
, programmCounter : Int
, uCounter : Int
, accumulator : Int
}
type alias Model =
{ pc : PC
, uCode : List (Maybe UAction)
, autoscroll : Bool
}
type UAction
= ActAccumulator2DataBus
| ActAccumulatorDecrement
| ActAccumulatorIncrement
| ActDataBus2Accumulator
| ActDataBus2InstructionReg
| ActDataBus2Ram
| ActInstructionReg2AddressBus
| ActInstructionReg2ProgrammCounter
| ActInstructionReg2UCounter
| ActProgrammCounterIncrement
| ActRam2DataBus
| ActResetUCounter
| ActProgrammCounter2AddressBus
uCodeDescriptions : List ( UAction, String )
uCodeDescriptions =
[ ( ActAccumulator2DataBus, "Acc -> DataBus" )
, ( ActAccumulatorDecrement, "Acc --" )
, ( ActAccumulatorIncrement, "Acc ++" )
, ( ActDataBus2Accumulator, "DataBus -> Acc" )
, ( ActDataBus2InstructionReg, "DataBus -> InstReg" )
, ( ActDataBus2Ram, "DataBus -> Ram" )
, ( ActInstructionReg2AddressBus, "InstReg -> AddrBus" )
, ( ActInstructionReg2ProgrammCounter, "InstReg -> ProgCount" )
, ( ActInstructionReg2UCounter, "InstReg -> µCounter" )
, ( ActProgrammCounterIncrement, "ProgCounter ++" )
, ( ActRam2DataBus, "Ram -> DataBus" )
, ( ActResetUCounter, "µCounter = 0" )
, ( ActProgrammCounter2AddressBus, "ProgCounter -> AddrBus" )
]
uCodeMaps : List ( UAction, PC -> PC )
uCodeMaps =
[ ( ActAccumulator2DataBus, actAccumulator2DataBus )
, ( ActAccumulatorDecrement, actAccumulatorDecrement )
, ( ActAccumulatorIncrement, actAccumulatorIncrement )
, ( ActDataBus2Accumulator, actDataBus2Accumulator )
, ( ActDataBus2InstructionReg, actDataBus2InstructionReg )
, ( ActDataBus2Ram, actDataBus2Ram )
, ( ActInstructionReg2AddressBus, actInstructionReg2AddressBus )
, ( ActInstructionReg2ProgrammCounter, actInstructionReg2ProgrammCounter )
, ( ActInstructionReg2UCounter, actInstructionReg2UCounter )
, ( ActProgrammCounterIncrement, actProgrammCounterIncrement )
, ( ActRam2DataBus, actRam2DataBus )
, ( ActResetUCounter, actResetUCounter )
, ( ActProgrammCounter2AddressBus, actProgrammCounter2AddressBus )
]
initialRam : List Int
initialRam =
[ 100005 -- 000 -- LoadA #005
, 300000 -- 001 -- IncA
, 200005 -- 002 -- StoreA #005
, 400000 -- 003 -- JMP #000
, 0 -- 004
, 5 -- 005
, 0 -- 006
, 0 -- 007
, 0 -- 008
, 0 -- 009
, 0 -- 010
]
initialPC : PC
initialPC =
PC
initialRam
0
0
0
0
0
0
initialUCodes : List (Maybe UAction)
initialUCodes =
[ Just ActProgrammCounter2AddressBus -- 000
, Just ActRam2DataBus -- 001
, Just ActDataBus2InstructionReg -- 002
, Just ActProgrammCounterIncrement -- 003
, Just ActInstructionReg2UCounter -- 004
, Nothing -- 005
, Nothing
, Nothing
, Nothing
, Nothing -- 009
-- 010 LOADA
, Just ActInstructionReg2AddressBus -- 010
, Just ActRam2DataBus -- 011
, Just ActDataBus2Accumulator -- 012
, Just ActResetUCounter -- 013
, Nothing -- 014
, Nothing
, Nothing
, Nothing
, Nothing
, Nothing -- 019
-- 020 STOA
, Just ActAccumulator2DataBus -- 020
, Just ActInstructionReg2AddressBus -- 021
, Just ActDataBus2Ram -- 022
, Just ActResetUCounter -- 023
, Nothing --024
, Nothing
, Nothing
, Nothing
, Nothing
, Nothing -- 029
-- 030 INCA
, Just ActAccumulatorIncrement -- 030
, Just ActResetUCounter -- 031
, Nothing -- 032
, Nothing
, Nothing
, Nothing
, Nothing
, Nothing
, Nothing
, Nothing -- 039
-- 040 JMP
, Just ActInstructionReg2ProgrammCounter -- 040
, Just ActResetUCounter -- 041
, Nothing -- 042
, Nothing
, Nothing
, Nothing
, Nothing
, Nothing
, Nothing
, Nothing -- 049
]
type Msg
= MsgUCycleStep
| MsgInstructionStep
| MsgReset
| MsgAutoscrollUpdate
| MsgManualStep UAction
| MsgLocalSessionRecieve String
update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
case msg of
MsgUCycleStep ->
( uStepPC model
, sendUUpdate "uCycle updated"
)
MsgInstructionStep ->
( model, Cmd.none )
MsgReset ->
( { model | pc = { initialPC | ram = model.pc.ram } }
, Cmd.none
)
MsgLocalSessionRecieve message_in ->
( model, Cmd.none )
MsgManualStep action ->
let
instruction = getAction action
in
( { model | pc = instruction model.pc}
, Cmd.none )
MsgAutoscrollUpdate ->
( { model | autoscroll = not model.autoscroll }
, Cmd.none
)
-- Practically a part of uStepPC but sepeated for manual mode
getAction : UAction -> (PC -> PC)
getAction uAction =
let
possible_instructions =
List.filter (\s -> Tuple.first s == uAction) uCodeMaps
in
case List.head possible_instructions of
Just ( name, instruction ) ->
instruction
_ ->
(\s -> s)
uStepPC : Model -> Model
uStepPC model =
let
uCounter =
model.pc.uCounter
may_instruction : Maybe (Maybe UAction)
may_instruction =
valueAt uCounter model.uCode
in
case may_instruction of
Just (Just action) ->
let
possible_instructions =
List.filter (\s -> Tuple.first s == action) uCodeMaps
in
case List.head possible_instructions of
Just ( name, instruction ) ->
let
old_pc =
model.pc
new_pc =
{ old_pc | uCounter = old_pc.uCounter + 1 }
in
{ model | pc = instruction new_pc }
_ ->
let
old_pc =
model.pc
new_pc =
{ old_pc | uCounter = 0 }
in
{ model | pc = new_pc }
_ ->
model
view : Model -> Html Msg
view model =
lazy viewPC model
viewPC : Model -> Html Msg
viewPC model =
div
[ class "pc" ]
[ div [ class "controls", class "grid-fullwidth" ]
[ button [ onClick MsgUCycleStep ] [ text "µZyklus" ]
, button [ onClick MsgInstructionStep ] [ text "Instruction" ]
, button [ onClick MsgReset ] [ text "Reset PC" ]
, div
[ classList
[ ("checker", True)
, ("button", True)
, ("checked", model.autoscroll) ]
, onClick MsgAutoscrollUpdate
]
[ Html.input
[ HAttr.type_ "checkbox"
, HAttr.id "enableScrolling"
, HAttr.checked model.autoscroll
, onClick MsgAutoscrollUpdate
]
[]
, Html.label
[ HAttr.for "enableScrolling" ]
[ text "Automatisch zum Eintrag Scrollen" ]
]
]
, div [ class "grid-fullwidth" ] [ lazy viewAddressBus model ]
, lazy viewRam model
, lazy viewCu model
, lazy viewAlu model
, div [ class "grid-fullwidth" ] [ lazy viewDataBus model ]
]
viewRam : Model -> Html Msg
viewRam model =
div [ class "section", class "ram" ]
[ h1 [ class "header" ] [ text "RAM" ]
, div [ class "arrow", class "down", class "top"] [ div [] [] , div [] [] ]
, div [ class "scroller" ]
[ Html.table [ class "" ]
[ Html.thead [ class "head" ]
[ Html.tr []
[ Html.th [ class "address" ] [ text "Addr" ]
, Html.th [] [ text "Value" ]
]
]
, lazy viewRamContent model
]
]
, div [ class "arrow", class "down"]
[ div [ class "button" ]
[ Html.a [ onClick (MsgManualStep ActRam2DataBus) ] [ text "Ram -> DataBus" ]]
, div [] []
]
, div [ class "arrow", class "up"]
[ div [ class "button" ]
[ Html.a [ onClick (MsgManualStep ActDataBus2Ram) ] [ text "DataBus -> Ram" ]]
, div [] []
]
]
viewRamContent : Model -> Html Msg
viewRamContent model =
let
indexedRam =
List.indexedMap Tuple.pair model.pc.ram
ram2table : ( Int, Int ) -> Html Msg
ram2table entry =
let
id =
Tuple.first entry
val =
Tuple.second entry
in
Html.tr
[ classList [ ( "current", id == model.pc.addressBus ) ] ]
[ Html.td [ class "num" ] [ text (String.fromInt id) ]
, Html.td [ class "num " ] [ text (String.fromInt val) ]
]
in
Html.tbody [] (List.map ram2table indexedRam)
viewCu : Model -> Html Msg
viewCu model =
div [ class "section", class "cu" ]
[ div [ class "arrow", class "up", class "top"]
[ div [ class "button" ]
[ Html.a [ onClick (MsgManualStep ActInstructionReg2AddressBus)] [ text "InstR -> AddrB" ]]
, div [] []
]
, h1 [ class "header" ] [ text "Control Unit" ]
, p []
[ text
("Programm Counter: "
++ String.fromInt model.pc.programmCounter
)
]
, p []
[ text
("Instruction Register: "
++ String.fromInt model.pc.instructionReg
)
]
, p []
[ text
("µCode Counter: "
++ String.fromInt model.pc.uCounter
)
]
, div [ class "scroller" ]
[ viewCuUCode model
]
, div [ class "arrow", class "up"]
[ div [ class "button" ]
[ Html.a [ onClick (MsgManualStep ActDataBus2InstructionReg) ] [ text "DB -> InstR" ]]
, div [] []
]
]
viewCuUCode : Model -> Html Msg
viewCuUCode model =
Html.table []
[ Html.thead [ class "head" ]
[ Html.tr []
[ Html.th [ class "address" ] [ text "Addr" ]
, Html.th [] [ text "Code" ]
]
]
, lazy viewCuUCodeContent model
]
viewCuUCodeContent : Model -> Html Msg
viewCuUCodeContent model =
let
indexedList =
List.indexedMap Tuple.pair model.uCode
list2table : ( Int, Maybe UAction ) -> Html Msg
list2table may_t =
let
id =
Tuple.first may_t
may_code =
Tuple.second may_t
in
case may_code of
Just code ->
let
possibleDescriptions : List ( UAction, String )
possibleDescriptions =
List.filter (\s -> Tuple.first s == code) uCodeDescriptions
codeDescription =
case List.head possibleDescriptions of
Just ( _, description ) ->
description
_ ->
"Idk what this is"
in
Html.tr
[ classList [ ( "current", id == model.pc.uCounter ) ] ]
[ Html.td [ class "num" ] [ text (String.fromInt id) ]
, Html.td [] [ text codeDescription ]
]
Nothing ->
Html.tr [ class "empty" ]
[ Html.td [ class "num" ] [ text (String.fromInt id) ]
, Html.td [] [ text "Empty" ]
]
in
Html.tbody [] (List.map list2table indexedList)
viewAlu : Model -> Html Msg
viewAlu model =
div [ class "section", class "alu" ]
[ h1 [ class "header" ] [ text "ALU" ]
, p [] [ text ("Accumulator: " ++ String.fromInt model.pc.accumulator) ]
, div [ class "arrow", class "up"]
[ div [ class "button" ]
[ Html.a [ onClick (MsgManualStep ActDataBus2Accumulator)] [ text "DB -> ALU" ]]
, div [] []
]
, div [ class "arrow", class "down"]
[ div [ class "button" ]
[ Html.a [ onClick (MsgManualStep ActAccumulator2DataBus)] [ text "ALU -> DB" ]]
, div [] []
]
]
viewDataBus : Model -> Html Msg
viewDataBus model =
div [ class "databus" ]
[ Html.span [ class "label" ] [ text "Databus" ]
, Html.span [] [ text (String.fromInt model.pc.dataBus) ]
]
viewAddressBus : Model -> Html Msg
viewAddressBus model =
div [ class "addressbus" ]
[ Html.span [ class "label" ] [ text "Addressbus" ]
, Html.span [] [ text (String.fromInt model.pc.addressBus) ]
]
-- END VIEWERS
-- ACTIONS
actRam2DataBus : PC -> PC
actRam2DataBus pc =
let
ab =
pc.addressBus
db =
valueAtInt ab pc.ram
in
{ pc | dataBus = db }
actDataBus2InstructionReg : PC -> PC
actDataBus2InstructionReg pc =
{ pc | instructionReg = pc.dataBus }
actResetUCounter : PC -> PC
actResetUCounter pc =
{ pc | uCounter = 0 }
actInstructionReg2UCounter : PC -> PC
actInstructionReg2UCounter pc =
-- Remove last 5 digits as they are address
-- Multiply by ten, because every instruction is 10 uCodes long
{ pc | uCounter = pc.instructionReg // 100000 * 10 }
actInstructionReg2AddressBus : PC -> PC
actInstructionReg2AddressBus pc =
-- Only bring last 5 digits to AB, because the rest is opcode
{ pc | addressBus = pc.instructionReg - pc.instructionReg // 100000 * 100000 }
actInstructionReg2ProgrammCounter : PC -> PC
actInstructionReg2ProgrammCounter pc =
-- Only bring last 5 digits to AB, because the rest is opcode
{ pc | programmCounter = pc.instructionReg - pc.instructionReg // 100000 * 100000 }
actProgrammCounterIncrement : PC -> PC
actProgrammCounterIncrement pc =
{ pc | programmCounter = pc.programmCounter + 1 }
actProgrammCounter2AddressBus : PC -> PC
actProgrammCounter2AddressBus pc =
{ pc | addressBus = pc.programmCounter }
actDataBus2Accumulator : PC -> PC
actDataBus2Accumulator pc =
{ pc | accumulator = pc.dataBus }
actAccumulator2DataBus : PC -> PC
actAccumulator2DataBus pc =
{ pc | dataBus = pc.accumulator }
actAccumulatorIncrement : PC -> PC
actAccumulatorIncrement pc =
{ pc | accumulator = pc.accumulator + 1 }
actAccumulatorDecrement : PC -> PC
actAccumulatorDecrement pc =
{ pc | accumulator = pc.accumulator - 1 }
actDataBus2Ram : PC -> PC
actDataBus2Ram pc =
let
newRam =
changeAt pc.addressBus pc.dataBus pc.ram
in
{ pc | ram = newRam }
-- END ACTIONS
-- HELPERS
valueAtInt : Int -> List Int -> Int
valueAtInt n l =
case valueAt n l of
Just a ->
a
Nothing ->
0
valueAt : Int -> List a -> Maybe a
valueAt n l =
List.head (List.drop n l)
changeAt : Int -> Int -> List Int -> List Int
changeAt pos newVal list =
let
before =
List.take pos list
after =
List.drop (pos + 1) list
len =
List.length list
in
if pos > len then
let
before2 =
List.append before (List.repeat (pos - len) 0)
in
List.append before2 (newVal :: after)
else
List.append before (newVal :: after)
-- END HELPERS
-- GENERAL
subscriptions : Model -> Sub Msg
subscriptions model =
recieveLocalSession MsgLocalSessionRecieve
init : () -> ( Model, Cmd Msg )
init flags =
( Model initialPC initialUCodes True, Cmd.none )
main : Program () Model Msg
main =
Browser.element
{ init = init
, view = view
, update = update
, subscriptions = subscriptions
}