Skip to content

Commit

Permalink
Make linting work again
Browse files Browse the repository at this point in the history
  • Loading branch information
eliben committed Jul 15, 2020
1 parent 9fffee2 commit 31b0e25
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .jshintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
node_modules
src/sim8080.js
js8080simBundle.js

1 change: 1 addition & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@

// environments
"node": true,
"browser": true,
"mocha": true
}
26 changes: 15 additions & 11 deletions ui.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
'use strict';

// This is for jshint that will worry it can't find js8080sim, which is injected
// in a <script> tag in the HTML.
/* globals js8080sim: false */

const STORAGE_ID = 'js8080sim';

// Set up listeners.
Expand All @@ -11,7 +15,7 @@ document.querySelector("#run").addEventListener("mousedown", runCode);
// Create and populate the CPU state table.
const cpuStateTable = document.querySelector('#cpuState');
const registers = ['a', 'b', 'c', 'd', 'e',
'h', 'l', 'pc', 'sp', 'halted']
'h', 'l', 'pc', 'sp', 'halted'];
const registerWidths = {
'a': 2,
'b': 2,
Expand Down Expand Up @@ -91,8 +95,8 @@ loadUiState();
function loadUiState() {
let state = JSON.parse(localStorage.getItem(STORAGE_ID));
if (state) {
codetext.value = state['codetext'];
maxsteps.value = state['maxsteps'];
codetext.value = state.codetext;
maxsteps.value = state.maxsteps;
} else {
maxsteps.value = "10000";
}
Expand Down Expand Up @@ -144,10 +148,10 @@ function runCode() {
valueElement.textContent = formatNum(state[regName], width);
} else if (regName === 'f') {
let regval = state[regName];
flagsStateValues['Sign'].textContent = formatNum((regval >> 7) & 0x01, 2);
flagsStateValues['Zero'].textContent = formatNum((regval >> 6) & 0x01, 2);
flagsStateValues['Parity'].textContent = formatNum((regval >> 2) & 0x01, 2);
flagsStateValues['Carry'].textContent = formatNum(regval & 0x01, 2);
flagsStateValues.Sign.textContent = formatNum((regval >> 7) & 0x01, 2);
flagsStateValues.Zero.textContent = formatNum((regval >> 6) & 0x01, 2);
flagsStateValues.Parity.textContent = formatNum((regval >> 2) & 0x01, 2);
flagsStateValues.Carry.textContent = formatNum(regval & 0x01, 2);
} else {
console.log('cannot find state value for', regName);
}
Expand Down Expand Up @@ -195,10 +199,10 @@ function codetextKey(event) {

let numSpaces = startLinePos - prevNewlinePos - 1;

codetext.value = codetext.value.substring(0, pos)
+ '\n'
+ ' '.repeat(numSpaces)
+ codetext.value.substring(pos, codetext.value.length);
codetext.value = codetext.value.substring(0, pos) +
'\n' +
' '.repeat(numSpaces) +
codetext.value.substring(pos, codetext.value.length);
codetext.selectionStart = pos + numSpaces + 1;
codetext.selectionEnd = pos + numSpaces + 1;
event.stopPropagation();
Expand Down

0 comments on commit 31b0e25

Please sign in to comment.