"implements Platform" for classes; fixed DASM unresolved w/ mult files

This commit is contained in:
Steven Hugg 2018-08-25 22:00:45 -04:00
parent 0ade973ad7
commit 27cae568fc
11 changed files with 40 additions and 27 deletions

View File

@ -148,8 +148,6 @@ if (window.location.host.endsWith('8bitworkshop.com')) {
<button id="dbg_memory" type="submit" title="Show Memory" style="display:none"><span class="glyphicon glyphicon-sunglasses" aria-hidden="true"></span></button>
<button id="dbg_profile" type="submit" title="Show Profile" style="display:none"><span class="glyphicon glyphicon-stats" aria-hidden="true"></span></button>
<button id="dbg_bitmap" type="submit" title="Edit Bitmap"><span class="glyphicon glyphicon-camera" aria-hidden="true"></span></button>
</span>
<span class="btn_group view_group" id="replay_bar" style="display:none">
<button id="dbg_record" type="submit" title="Start/Stop Replay Recording"><span class="glyphicon glyphicon-record" aria-hidden="true"></span></button>
</span>
<span class="dropdown" style="float:right">

View File

@ -40,12 +40,18 @@ export interface Platform {
pause() : void;
resume() : void;
loadROM(title:string, rom:any); // TODO: Uint8Array
loadState?(state : EmuState) : void;
saveState?() : EmuState;
loadControlsState?(state : EmuControlsState) : void;
saveControlsState?() : EmuControlsState;
inspect?(ident:string) : void;
disassemble?(addr:number, readfn:(addr:number)=>number) : DisasmLine;
readAddress?(addr:number) : number;
setFrameRate?(fps:number) : void;
getFrameRate?() : number;
setupDebug?(debugfn : (state)=>void) : void;
clearDebug?() : void;
step?() : void;
@ -54,22 +60,18 @@ export interface Platform {
runUntilReturn?() : void;
stepBack?() : void;
runEval?(evalfunc/* : DebugEvalCondition*/) : void;
getDebugCallback?() : any; // TODO
getOpcodeMetadata?(opcode:number, offset:number) : OpcodeMetadata; //TODO
loadState?(state : EmuState) : void;
saveState?() : EmuState;
getDebugCallback?() : any; // TODO
getSP?() : number;
getOriginPC?() : number;
newCodeAnalyzer() : CodeAnalyzer;
newCodeAnalyzer?() : CodeAnalyzer;
getDebugCategories() : string[];
getDebugInfo(category:string, state:EmuState) : string;
getDebugCategories?() : string[];
getDebugInfo?(category:string, state:EmuState) : string;
setRecorder?(recorder : EmuRecorder) : void;
advance?(novideo? : boolean) : void;
loadControlsState?(state : EmuControlsState) : void;
saveControlsState?() : EmuControlsState;
}
export interface Preset {
@ -584,7 +586,6 @@ export abstract class Base6809Platform extends BaseZ80Platform {
declare var FS, ENV, Module; // mame emscripten
// TODO: make class
export abstract class BaseMAMEPlatform {
loaded = false;
@ -801,12 +802,13 @@ export abstract class BaseMAMEPlatform {
return state;
}
/*
saveState() {
this.luareset();
this.luacall('mamedbg.printstate()');
return this.preserveState();
}
*/
initlua() {
if (!this.initluavars) {
this.luacall(this.luadebugscript);

View File

@ -1,6 +1,6 @@
"use strict";
import { Platform, Base6502Platform, BaseMAMEPlatform, getOpcodeMetadata_6502 } from "../baseplatform";
import { Platform, Base6502Platform, BaseMAMEPlatform, getOpcodeMetadata_6502, getToolForFilename_6502 } from "../baseplatform";
import { PLATFORMS, RAM, newAddressDecoder, padBytes, noise, setKeyboardFromMap, AnimationTimer, RasterVideo, Keys, makeKeycodeMap, dumpRAM } from "../emu";
import { hex, lzgmini } from "../util";
import { SampleAudio } from "../audio";
@ -52,7 +52,7 @@ const _Apple2Platform = function(mainElement) {
var bank2rdoffset=0, bank2wroffset=0;
var grparams : AppleGRParams;
class Apple2Platform extends Base6502Platform {
class Apple2Platform extends Base6502Platform implements Platform {
getPresets() {
return APPLE2_PRESETS;
@ -1025,7 +1025,7 @@ const APPLEIIGO_LZG = [
/// MAME support
class Apple2MAMEPlatform extends BaseMAMEPlatform {
class Apple2MAMEPlatform extends BaseMAMEPlatform implements Platform {
start () {
this.startModule(this.mainElement, {
@ -1045,6 +1045,7 @@ class Apple2MAMEPlatform extends BaseMAMEPlatform {
getOpcodeMetadata = getOpcodeMetadata_6502;
getDefaultExtension () { return ".c"; };
getToolForFilename = getToolForFilename_6502;
getPresets () { return APPLE2_PRESETS; }

View File

@ -33,7 +33,7 @@ var ColecoVision_PRESETS = [
/// MAME support
class ColecoVisionMAMEPlatform extends BaseMAMEPlatform {
class ColecoVisionMAMEPlatform extends BaseMAMEPlatform implements Platform {
start() {
this.startModule(this.mainElement, {

View File

@ -200,7 +200,7 @@ const _GalaxianPlatform = function(mainElement, options) {
0x510000, 0xae0000 // blue
];
class GalaxianPlatform extends BaseZ80Platform {
class GalaxianPlatform extends BaseZ80Platform implements Platform {
getPresets() {
return GALAXIAN_PRESETS;

View File

@ -39,7 +39,7 @@ const _Midway8080BWPlatform = function(mainElement) {
[Keys.VK_2, 1, 0x2],
]);
class Midway8080BWPlatform extends BaseZ80Platform {
class Midway8080BWPlatform extends BaseZ80Platform implements Platform {
getPresets() {
return MW8080BW_PRESETS;

View File

@ -71,7 +71,7 @@ const _JSNESPlatform = function(mainElement) {
var frameindex = 0;
var nsamples = 0;
class JSNESPlatform extends Base6502Platform {
class JSNESPlatform extends Base6502Platform implements Platform {
debugPCDelta = 1;
getPresets() { return JSNES_PRESETS; }
@ -299,7 +299,7 @@ const _JSNESPlatform = function(mainElement) {
/// MAME support
class NESMAMEPlatform extends BaseMAMEPlatform {
class NESMAMEPlatform extends BaseMAMEPlatform implements Platform {
// = function(mainElement, lzgRom, romSize) {
lzgRom;
romSize;
@ -319,6 +319,14 @@ class NESMAMEPlatform extends BaseMAMEPlatform {
});
}
loadROM(title, data) {
this.loadROMFile(data);
this.loadRegion(":nes_slot:cart:prg_rom", data.slice(0x10, 0x8010));
if (data.length > 0x8010)
this.loadRegion(":nes_slot:cart:chr_rom", data.slice(0x8010, 0xa010));
}
getPresets() { return JSNES_PRESETS; }
getOpcodeMetadata = getOpcodeMetadata_6502;
getToolForFilename = getToolForFilename_6502;
getDefaultExtension() { return ".c"; };

View File

@ -240,7 +240,7 @@ function nonegstr(n) {
///////////////
class VCSMAMEPlatform extends BaseMAMEPlatform {
class VCSMAMEPlatform extends BaseMAMEPlatform implements Platform {
// MCFG_SCREEN_RAW_PARAMS( MASTER_CLOCK_NTSC, 228, 26, 26 + 160 + 16, 262, 24 , 24 + 192 + 31 )

View File

@ -97,7 +97,7 @@ const _VicDualPlatform = function(mainElement) {
[Keys.VK_5, 3, 0x8],
]);
class VicDualPlatform extends BaseZ80Platform {
class VicDualPlatform extends BaseZ80Platform implements Platform {
getPresets() {
return VICDUAL_PRESETS;

View File

@ -74,9 +74,9 @@ function inspectVariable(ed, name) { // TODO: ed?
function getCurrentPresetTitle() : string {
if (!current_preset_entry)
return "ROM";
return main_file_id || "ROM";
else
return current_preset_entry.title || current_preset_entry.name || "ROM";
return current_preset_entry.title || current_preset_entry.name || main_file_id || "ROM";
}
function setLastPreset(id:string) {
@ -325,7 +325,7 @@ function _shareEmbedLink(e) {
new ClipboardJS(".btn");
});
loadScript('lib/liblzg.js', () => {
// TODO: Module is bad var name
// TODO: Module is bad var name (conflicts with MAME)
var lzgrom = compressLZG( window['Module'], current_output );
window['Module'] = null; // so we load it again next time
var lzgb64 = btoa(byteArrayToString(lzgrom));

View File

@ -544,12 +544,13 @@ function parseDASMListing(code, unresolved, mainFilename) {
});
}
}
// TODO: check filename too
// TODO: better symbol test (word boundaries)
// TODO: ignore IFCONST and IFNCONST usage
for (var key in unresolved) {
var pos = restline ? restline.indexOf(key) : line.indexOf(key);
if (pos >= 0) {
errors.push({
path:filename,
line:linenum,
msg:"Unresolved symbol '" + key + "'"
});
@ -577,7 +578,10 @@ function assembleDASM(step) {
function match_fn(s) {
var matches = re_usl.exec(s);
if (matches) {
unresolved[matches[1]] = 0;
var key = matches[1];
if (key != 'NO_ILLEGAL_OPCODES') { // TODO
unresolved[matches[1]] = 0;
}
} else if (s.startsWith("Warning:")) {
errors.push({line:1, msg:s.substr(9)});
}