diff --git a/js/base64.ts b/js/base64.ts index b40a82f..b0f0216 100644 --- a/js/base64.ts +++ b/js/base64.ts @@ -3,7 +3,9 @@ import { memory } from './types'; const B64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; /** Encode an array of bytes in base64. */ -export function base64_encode(data: memory) { +export function base64_encode(data: null | undefined): undefined; +export function base64_encode(data: memory): string; +export function base64_encode(data: memory | null | undefined): string | undefined { // Twacked by Will Scullin to handle arrays of 'bytes' // http://kevin.vanzonneveld.net @@ -28,7 +30,7 @@ export function base64_encode(data: memory) { const tmp_arr = []; if (!data) { - return data; + return undefined; } do { // pack three octets into four hexets diff --git a/js/cpu6502.ts b/js/cpu6502.ts index 9855c00..54ab765 100644 --- a/js/cpu6502.ts +++ b/js/cpu6502.ts @@ -140,6 +140,7 @@ type StrictInstruction = Instruction | Instruction | Instruction | + Instruction | Instruction type Instructions = Record @@ -147,7 +148,7 @@ type Instructions = Record type callback = (cpu: CPU6502) => void; export default class CPU6502 { - private readonly is65C02; + private readonly is65C02: boolean; /* Registers */ private pc = 0; // Program Counter @@ -190,7 +191,7 @@ export default class CPU6502 { * Set or clears `f` in the status register. `f` must be a byte with a * single bit set. */ - private setFlag(f: byte, on: boolean) { + private setFlag(f: flag, on: boolean) { this.sr = on ? (this.sr | f) : (this.sr & ~f); } @@ -844,7 +845,7 @@ export default class CPU6502 { } } - brc = (f: flag) => { + brc = (f: flag|0) => { const off = this.readBytePC(); // changes pc if ((f & this.sr) === 0) { this.readByte(this.pc);