diff --git a/docs/SupportedEmulators.md b/docs/SupportedEmulators.md index a463ba176..e4193a4a8 100644 --- a/docs/SupportedEmulators.md +++ b/docs/SupportedEmulators.md @@ -13,6 +13,7 @@ These are using Javascript and/or using external websites to facilitate emulatio with Z88DK (target `+sms`) - [Viciious](https://github.com/compiler-explorer/viciious) (https://static.ce-cdn.net/viciious/viciious.html) - for `.prg` files built with LLVM MOS C64 or CC65 (`--target c64`) +- [WasmBoy](https://github.com/compiler-explorer/wasmboy) (https://static.ce-cdn.net/wasmboy/index.html) - for `.gb` ROM files built with z88dk (target `+gb`) ## Examples diff --git a/lib/compilers/z88dk.ts b/lib/compilers/z88dk.ts index c144c9c60..aebb7e33c 100644 --- a/lib/compilers/z88dk.ts +++ b/lib/compilers/z88dk.ts @@ -129,6 +129,10 @@ export class z88dkCompiler extends BaseCompiler { return `${this.outputFilebase}.sms`; } + getGbfilename() { + return `${this.outputFilebase}.gb`; + } + override async objdump( outputFilename: string, result: any, @@ -189,6 +193,11 @@ export class z88dkCompiler extends BaseCompiler { if (await utils.fileExists(smsFilepath)) { await addArtifactToResult(result, smsFilepath, ArtifactType.smsrom); } + + const gbFilepath = path.join(result.dirPath, this.getGbfilename()); + if (await utils.fileExists(gbFilepath)) { + await addArtifactToResult(result, gbFilepath, ArtifactType.gbrom); + } } return result; diff --git a/static/panes/compiler.ts b/static/panes/compiler.ts index 7e3b4e3b3..cc32480af 100644 --- a/static/panes/compiler.ts +++ b/static/panes/compiler.ts @@ -1782,6 +1782,8 @@ export class Compiler extends MonacoPanehere to emulate with a debugger, ' + + 'or here to emulate just to play.', + { + group: 'emulation', + collapseSimilar: true, + dismissTime: 10000, + onBeforeShow: elem => { + elem.find('#emulink').on('click', () => { + const tmstr = Date.now(); + const url = + 'https://static.ce-cdn.net/wasmboy/index.html?' + + tmstr + + '#rom-name=' + + encodeURIComponent(prg.title) + + '&rom-data=' + + encodeURIComponent(prg.content); + window.open(url, '_blank'); + }); + + elem.find('#emulink-play').on('click', () => { + BootstrapUtils.showModal(dialog); + + const gbemuframe = dialog.find('#gbemuframe')[0]; + assert(gbemuframe instanceof HTMLIFrameElement); + if ('contentWindow' in gbemuframe) { + const emuwindow = unwrap(gbemuframe.contentWindow); + const tmstr = Date.now(); + const url = + 'https://static.ce-cdn.net/wasmboy/iframe/index.html?' + + tmstr + + '#rom-name=' + + encodeURIComponent(prg.title) + + '&rom-data=' + + encodeURIComponent(prg.content); + emuwindow.location = url; + } + }); + }, + }, + ); + } + onEditorChange(editor: number, source: string, langId: string, compilerId?: number): void { if (this.sourceTreeId) { const tree = this.hub.getTreeById(this.sourceTreeId); diff --git a/types/tool.interfaces.ts b/types/tool.interfaces.ts index daeb4bb5c..24f0ba33f 100644 --- a/types/tool.interfaces.ts +++ b/types/tool.interfaces.ts @@ -59,6 +59,7 @@ export enum ArtifactType { timetrace = 'timetracejson', c64prg = 'c64prg', heaptracktxt = 'heaptracktxt', + gbrom = 'gbrom', } export type Artifact = { diff --git a/views/popups/_all.pug b/views/popups/_all.pug index efd10636f..486bc6287 100644 --- a/views/popups/_all.pug +++ b/views/popups/_all.pug @@ -36,3 +36,5 @@ include jsspeccyemu include miracleemu include jsnesemu + +include gbemu diff --git a/views/popups/gbemu.pug b/views/popups/gbemu.pug new file mode 100644 index 000000000..c42710163 --- /dev/null +++ b/views/popups/gbemu.pug @@ -0,0 +1,5 @@ +#gbemu.modal.fade.gl_keep(tabindex="-1" role="dialog") + .modal-dialog.modal-xl + .modal-content + .modal-body + iframe#gbemuframe(src="about:blank" width="670" height="560") \ No newline at end of file