Skip to content

Instantly share code, notes, and snippets.

View JeremyLikness's full-sized avatar

Jeremy Likness JeremyLikness

View GitHub Profile
import {EventEmitter} from 'angular2/core';
import {IConsoleService} from './interfaces';
import {Constants} from '../globalConstants';
export class ConsoleService implements IConsoleService {
public lines: string[];
public logEvent: EventEmitter<string> = new EventEmitter<string>();
import {Component, Inject, ElementRef} from 'angular2/core';
import {IConsoleService} from '../services/interfaces';
import {ConsoleService} from '../services/consoleService';
@Component({
selector: 'console',
templateUrl: 'templates/console.html'
})
import {IDisplayService} from './interfaces';
import {Constants} from '../globalConstants';
export class DisplayService implements IDisplayService {
constructor() {
this.pixels = new Array<number>(Constants.Display.Size);
this.callback = (address: number, value: number) => {};
}
<div class="column">
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" [attr.width]="canvasWidth" [attr.height]="canvasHeight">
<rect x="0" y="0" [attr.width]="canvasWidth" [attr.height]="canvasHeight"
style="fill:white;"/>
<rect *ngFor="#pixel of pixelBuffer" [attr.x]="pixel.x" [attr.y]="pixel.y"
[attr.width]="pixel.width" [attr.height]="pixel.height" [style.fill]="pixel.fill"/>
</svg>
</div>
import {OpCodes} from './opsCodes';
import {IOperation, ICpu} from '../emulator/interfaces';
export class BaseOpCode implements IOperation {
constructor(
public opName: string,
public sizeBytes: number,
public addressingMode: number,
public opCode: number) {
import {Component, Inject} from 'angular2/core';
import {Hexadecimal} from '../pipes/hexadecimal';
import {EightBits} from '../pipes/eightbits';
import {ICpu} from '../emulator/interfaces';
import {Cpu} from '../emulator/cpu';
@Component({
selector: 'cpuStats',
<div class="column">
<table>
<tr><th>PC</th><th>SP</th><th>A</th><th>X</th><th>Y</th><td>NV-BDIZC</td><th>Runtime</th><th>IPS</th></tr>
<tr>
<td>{{cpu.rPC | hexadecimal}}</td>
<td>{{cpu.rSP | hexadecimal}}</td>
<td>{{cpu.rA | hexadecimal}}</td>
<td>{{cpu.rX | hexadecimal}}</td>
<td>{{cpu.rY | hexadecimal}}</td>
<td>{{cpu.rP | eightbits}}</td>
import {beforeEachProviders, it, describe, expect, inject} from '@angular/core/testing';
import {QuotesService} from './quotes.service';
describe('Quotes Service', () => {
beforeEachProviders(() => [QuotesService]);
it('should return a quote when getQuotes is called',
inject([QuotesService], (service: QuotesService) => {
var quote = service.getQuote();
import {Injectable} from '@angular/core';
@Injectable()
export class QuotesService {
public quotes: string[] =
[
"This is a Hollywood square.",
"Pick me! Ooh, ooh, pick me!",
"Are you thinking hard?",
"Tap. Tap. Tap.",
it('should set the row and column', inject([], () => {
return builder.createAsync(CellComponentTestController)
.then((fixture: ComponentFixture<any>) => {
fixture.detectChanges();
let query = fixture.debugElement.query(By.directive(CellComponent));
expect(query).toBeTruthy();
expect(query.componentInstance).toBeTruthy();
expect(query.componentInstance.col).toBe(1);
expect(query.componentInstance.row).toBe(2);
});