diff --git a/src/baseplatform.ts b/src/baseplatform.ts new file mode 100644 index 00000000..4c275b4f --- /dev/null +++ b/src/baseplatform.ts @@ -0,0 +1,48 @@ + +export interface OpcodeMetadata { + minCycles: number; + // TODO +} + +export interface Platform { + start() : void; + reset() : void; + isRunning() : boolean; + getToolForFilename(s:string) : string; + getDefaultExtension() : string; + getPresets() : Preset[]; + pause() : void; + resume() : void; + loadROM(title:string, rom:Uint8Array); + + inspect?(ident:string) : void; + disassemble?(addr:number, readfn:(addr:number)=>number) : any; // TODO + readAddress?(addr:number) : number; + setFrameRate?(fps:number) : void; + getFrameRate?() : number; + cpuStateToLongString?(state) : string; + ramStateToLongString?(state) : string; + getRasterPosition() : {x:number, y:number}; + setupDebug?(debugfn : (state)=>void) : void; + clearDebug?() : void; + step?() : void; + runToVsync?() : void; + runToPC?(pc:number) : void; + runUntilReturn?() : void; + stepBack?() : void; + //TODO runEval?(evalfn : (cpustate) => boolean) : void; + runEval?(evalfn : Function) : void; + + getOpcodeMetadata?(opcode:number, offset:number) : OpcodeMetadata; //TODO + saveState?() : any; // TODO + getDebugCallback?() : any; // TODO + getSP?() : number; +} + +export interface Preset { + id : string; + name : string; + chapter? : number; + title? : string; +} + diff --git a/src/project.ts b/src/project.ts index 23f0e2ad..07d50f71 100644 --- a/src/project.ts +++ b/src/project.ts @@ -94,9 +94,9 @@ export class CodeProject { tools_preloaded = {}; callbackBuildResult : BuildResultCallback; callbackBuildStatus : BuildStatusCallback; - worker: any; + worker : Worker; platform_id : string; - platform: any; + platform: any; // TODO: use type store: any; callbackGetRemote : GetRemoteCallback; mainPath: string; diff --git a/src/ui.ts b/src/ui.ts index fd9a418f..ed6f6226 100644 --- a/src/ui.ts +++ b/src/ui.ts @@ -6,6 +6,7 @@ import $ = require("jquery"); import * as bootstrap from "bootstrap"; import { SourceFile, CodeProject } from "./project"; import { ProjectWindows } from "./windows"; +import { Platform, Preset } from "./baseplatform"; import * as Views from "./views"; // external libs (TODO) @@ -18,43 +19,6 @@ declare var PLATFORMS; // make sure VCS doesn't start if (window['Javatari']) window['Javatari'].AUTO_START = false; -interface Preset { - id : string; - name : string; - chapter? : number; - title? : string; -} - -interface Platform { - start() : void; - reset() : void; - isRunning() : boolean; - getToolForFilename(s:string) : string; - getDefaultExtension() : string; - getPresets() : Preset[]; - pause() : void; - resume() : void; - loadROM(title:string, rom:Uint8Array); - - inspect?(ident:string) : void; - disassemble?(addr:number, readfn:(addr:number)=>number) : any; // TODO - readAddress?(addr:number) : number; - setFrameRate?(fps:number) : void; - getFrameRate?() : number; - cpuStateToLongString?(state) : string; - ramStateToLongString?(state) : string; - getRasterPosition() : {x:number, y:number}; - setupDebug?(debugfn : (state)=>void) : void; - clearDebug?() : void; - step?() : void; - runToVsync?() : void; - runToPC?(pc:number) : void; - runUntilReturn?() : void; - stepBack?() : void; - //TODO runEval?(evalfn : (cpustate) => boolean) : void; - runEval?(evalfn : Function) : void; -} - var PRESETS : Preset[]; // presets array var platform_id : string; // platform ID string var platform : Platform; // platform object diff --git a/src/views.ts b/src/views.ts index 81f1f352..55cbb737 100644 --- a/src/views.ts +++ b/src/views.ts @@ -2,6 +2,7 @@ import $ = require("jquery"); import { SourceFile, WorkerError, CodeProject } from "./project"; +import { Platform } from "./baseplatform"; export interface ProjectView { createDiv(parent:HTMLElement, text:string) : HTMLElement; @@ -18,7 +19,7 @@ export interface ProjectView { // TODO: move to different namespace declare var CodeMirror; -declare var platform; +declare var platform : Platform; declare var platform_id : string; declare var compparams; declare var addr2symbol : {[addr:number]:string};