From 2fd40ce383300d1cb8ac997bb867a4e23109d23c Mon Sep 17 00:00:00 2001 From: Steven Hugg Date: Fri, 22 Jun 2018 02:24:52 -0400 Subject: [PATCH] working on mame platforms --- src/emu.js | 14 ++++++---- src/platform/apple2.js | 9 +++--- src/platform/atari8.js | 60 ++++++++++++++++++++++++++++------------ src/platform/c64.js | 42 ++++++++++++++++++++++++++++ src/ui.js | 5 +++- src/worker/workermain.js | 23 +++++++++++---- 6 files changed, 119 insertions(+), 34 deletions(-) create mode 100644 src/platform/c64.js diff --git a/src/emu.js b/src/emu.js index 6932487e..40e3c2dd 100644 --- a/src/emu.js +++ b/src/emu.js @@ -973,14 +973,16 @@ var BaseMAMEPlatform = function() { $(video.canvas).attr('id','canvas'); // load asm.js module console.log("loading", opts.jsfile); + var modargs = [opts.driver, + '-debug', + '-debugger', 'none', + '-verbose', '-window', '-nokeepaspect', + '-resolution', canvas.width+'x'+canvas.height + ]; + if (romfn) modargs.push('-cart', romfn); window.JSMESS = {}; window.Module = { - arguments: [opts.driver, - '-debug', - '-debugger', 'none', - '-verbose', '-window', '-nokeepaspect', - '-resolution', canvas.width+'x'+canvas.height, - '-cart', romfn], + arguments: modargs, screenIsReadOnly: true, print: bufferConsoleOutput, canvas:video.canvas, diff --git a/src/platform/apple2.js b/src/platform/apple2.js index 0a889ba9..99bdce45 100644 --- a/src/platform/apple2.js +++ b/src/platform/apple2.js @@ -976,11 +976,11 @@ var Apple2MAMEPlatform = function(mainElement) { this.start = function() { self.startModule(mainElement, { jsfile:'mameapple2e.js', - //biosfile:['apple2/'], + biosfile:['apple2e.zip'], //cfgfile:'nes.cfg', driver:'apple2e', - width:256*2, - height:240*2, + width:280*2, + height:192*2, //romfn:'/emulator/cart.nes', //romsize:romSize, //romdata:new lzgmini().decode(lzgRom).slice(0, romSize), @@ -997,8 +997,7 @@ var Apple2MAMEPlatform = function(mainElement) { this.loadROM = function(title, data) { this.loadROMFile(data); - this.loadRegion(":nes_slot:cart:prg_rom", data.slice(0x10, 0x8010)); - this.loadRegion(":nes_slot:cart:chr_rom", data.slice(0x8010, 0xa010)); + // TODO } } diff --git a/src/platform/atari8.js b/src/platform/atari8.js index 5d1b19f6..1d3291a1 100644 --- a/src/platform/atari8.js +++ b/src/platform/atari8.js @@ -11,22 +11,6 @@ var Atari8MAMEPlatform = function(mainElement) { var self = this; this.__proto__ = new BaseMAMEPlatform(); -// - this.start = function() { - self.startModule(mainElement, { - jsfile:'mameatari400.js', - biosfile:'a5200/5200.rom', - //cfgfile:'atari5200.cfg', - driver:'a5200', - width:336*2, - height:225*2, - romfn:'/emulator/cart.rom', - romsize:0x4000, - preInit:function(_self) { - }, - }); - } - this.loadROM = function(title, data) { this.loadROMFile(data); this.loadRegion(":cartleft:cart:rom", data); @@ -38,6 +22,48 @@ var Atari8MAMEPlatform = function(mainElement) { this.getDefaultExtension = function() { return ".c"; }; } +var Atari800Platform = function(mainElement) { + var self = this; + this.__proto__ = new Atari8MAMEPlatform(mainElement); + + this.start = function() { + self.startModule(mainElement, { + jsfile:'mameatari400.js', + biosfile:'a400.zip', // TODO: load multiple files + //cfgfile:'atari5200.cfg', + driver:'a400', + width:336*2, + height:225*2, + romfn:'/emulator/cart.rom', + romsize:0x2000, + preInit:function(_self) { + }, + }); + } +} + +var Atari5200Platform = function(mainElement) { + var self = this; + this.__proto__ = new Atari8MAMEPlatform(mainElement); + + this.start = function() { + self.startModule(mainElement, { + jsfile:'mameatari400.js', + biosfile:'a5200/5200.rom', + //cfgfile:'atari5200.cfg', + driver:'a5200', + width:336*2, + height:225*2, + romfn:'/emulator/cart.rom', + romsize:0x2000, + preInit:function(_self) { + }, + }); + } +} + + /// -PLATFORMS['atari8-5200'] = Atari8MAMEPlatform; +PLATFORMS['atari8-800'] = Atari800Platform; +PLATFORMS['atari8-5200'] = Atari5200Platform; diff --git a/src/platform/c64.js b/src/platform/c64.js new file mode 100644 index 00000000..0091687a --- /dev/null +++ b/src/platform/c64.js @@ -0,0 +1,42 @@ +"use strict"; + +var C64_PRESETS = [ + {id:'hello.a', name:'Hello World (ASM)'}, + {id:'hellopm.a', name:'Hello Sprites (ASM)'}, +]; + +/// MAME support + +var C64MAMEPlatform = function(mainElement) { + var self = this; + this.__proto__ = new BaseMAMEPlatform(); + + this.loadROM = function(title, data) { + this.loadROMFile(data); + this.loadRegion(":basic", data); + } + + this.getPresets = function() { return C64_PRESETS; } + + this.getToolForFilename = getToolForFilename_6502; + this.getDefaultExtension = function() { return ".c"; }; + + this.start = function() { + self.startModule(mainElement, { + jsfile:'mamec64.js', + biosfile:'c64.zip', // TODO: load multiple files + //cfgfile:'atari5200.cfg', + driver:'c64', + width:336*2, + height:225*2, + romfn:'/emulator/cart.rom', + romsize:0x2000, + preInit:function(_self) { + }, + }); + } +} + +/// + +PLATFORMS['c64'] = C64MAMEPlatform; diff --git a/src/ui.js b/src/ui.js index 43c67b91..dc0bc54c 100644 --- a/src/ui.js +++ b/src/ui.js @@ -866,7 +866,10 @@ function resetAndDebug() { _resume(); platform.reset(); setupBreakpoint(); - platform.runEval(function(c) { return true; }); + if (platform.runEval) + platform.runEval(function(c) { return true; }); // break immediately + else + ; // TODO??? } else { platform.reset(); } diff --git a/src/worker/workermain.js b/src/worker/workermain.js index 192073de..547ca460 100644 --- a/src/worker/workermain.js +++ b/src/worker/workermain.js @@ -92,11 +92,23 @@ var PLATFORM_PARAMS = { cfgfile: 'apple2.cfg', libargs: ['apple2.lib'], }, + 'atari8-800': { + define: '__ATARI__', + cfgfile: 'atari-cart.cfg', + libargs: ['atari.lib'], + code_offset: 0xa000, // TODO + }, 'atari8-5200': { define: '__ATARI5200__', cfgfile: 'atari5200.cfg', libargs: ['atari5200.lib'], - //code_offset: 0x803, // TODO + code_offset: 0x4000, // TODO + }, + 'c64': { + define: '__C64__', + cfgfile: 'c64.cfg', + libargs: ['c64.lib'], + code_offset: 0x4000, // TODO }, 'verilog': { }, @@ -583,6 +595,7 @@ function assemblelinkCA65(code, platform) { objout = FS.readFile("main.o", {encoding:'binary'}); lstout = FS.readFile("main.lst", {encoding:'utf8'}); } catch (e) { + errors.push({line:1, msg:e+""}); return {errors:errors}; // TODO } if (errors.length) @@ -603,8 +616,8 @@ function assemblelinkCA65(code, platform) { starttime(); LD65.callMain(['--cfg-path', '/share/cfg', '--lib-path', '/share/lib', - '--lib-path', '/share/target/apple2/drv', - '-D', '__EXEHDR__=0', + '--lib-path', '/share/target/apple2/drv', // TODO + '-D', '__EXEHDR__=0', // TODO '-C', params.cfgfile, '-Ln', 'main.vice', //'--dbgfile', 'main.dbg', @@ -618,7 +631,8 @@ function assemblelinkCA65(code, platform) { var mapout = FS.readFile("main.map", {encoding:'utf8'}); var viceout = FS.readFile("main.vice", {encoding:'utf8'}); } catch (e) { - return {errors:errors}; + errors.push({line:1, msg:e+""}); + return {errors:errors}; // TODO } var listing = parseCA65Listing(lstout, mapout); //console.log(lstout); @@ -1156,7 +1170,6 @@ function compileCASPR(code, platform, options) { intermediate:{listing:miffile}, lines:[]}; } catch(e) { - console.log(e); errors.push({line:0,msg:e.message}); return {errors:errors}; // TODO }