From 008428800463b4fb15781b81b4f474bea67416fb Mon Sep 17 00:00:00 2001 From: Marc Trudel Date: Thu, 25 Mar 2021 17:17:45 +0900 Subject: [PATCH] chores: MD settings, no recompile module on init - Settings for Mega Drive were missing from the API - Compile the module on the first initialize only; recreating a new binary is costly, and likely will consume a lot more memory than needed. --- higan/target-web/api.d.ts | 14 +++++++++++++ higan/target-web/api.js | 42 +++++++++++++++++++++++++++------------ 2 files changed, 43 insertions(+), 13 deletions(-) diff --git a/higan/target-web/api.d.ts b/higan/target-web/api.d.ts index 8c46c79..283f7a4 100644 --- a/higan/target-web/api.d.ts +++ b/higan/target-web/api.d.ts @@ -86,6 +86,20 @@ export const Settings: SettingsEntries = { */ SyncOnce: 'cpu/synconce' } + }, + [Emulator.MegaDrive]: { + PPU: { + /** + * Skip frame. When enabled, skip the rendering of half the frames, which + * may provide slighgtly better performance. + */ + Skipframe: 'ppu/skipframe', + /** + * Skip DMA execution when the DMA is inactive or disabled. Off by default, as + * it can break a number of games. + */ + OptimizeSteps: 'vdp/optimizeSteps' + } } } diff --git a/higan/target-web/api.js b/higan/target-web/api.js index f269617..9d0012e 100644 --- a/higan/target-web/api.js +++ b/higan/target-web/api.js @@ -12,7 +12,7 @@ export const EmulatorEvent = { } export const Settings = { - ['Super Famicom']: { + [Emulator.SuperFamicom]: { CPU: { Lockstep: 'cpu/lockstep', Fastmath: 'cpu/fastmath', @@ -28,7 +28,7 @@ export const Settings = { Skipframe: 'ppu/skipframe' } }, - ['Famicom']: { + [Emulator.Famicom]: { PPU: { Skipframe: 'ppu/skipframe', Overscan: 'ppu/overscan' @@ -36,6 +36,12 @@ export const Settings = { CPU: { SyncOnce: 'cpu/synconce' } + }, + [Emulator.MegaDrive]: { + PPU: { + Skipframe: 'ppu/skipframe', + OptimizeSteps: 'vdp/optimizeSteps' + } } } @@ -132,6 +138,26 @@ byuu.initialize = async function (parent, ctxOptions) { throw new Error('The DOM ID attribute "canvas" is reserved by byuu for it\'s own canvas') } + function finalize() { + lib.initialize(document.title || 'byuu') + + // Set callbacks, patch into event emission + lib.onFrameStart(() => byuu.emit('frame.start')) + lib.onFrameEnd(() => byuu.emit('frame.end')) + lib.onResize((width, height) => { + byuu.displayRatio = width / height; + byuu.emit('resize', { width, height }); + }) + + initialized = true + } + + // If the module was initialized at least once, do not reload; + // immediately complete the initialization steps, and return; + if (initialized) { + return finalize(); + } + return new Promise((resolve) => { // Module isn't a real promise, and unless we set // things as follow the code seem to tight-loop @@ -146,17 +172,7 @@ byuu.initialize = async function (parent, ctxOptions) { canvas }).then((result) => { lib = result - lib.initialize(document.title || 'byuu') - - // Set callbacks, patch into event emission - lib.onFrameStart(() => byuu.emit('frame.start')) - lib.onFrameEnd(() => byuu.emit('frame.end')) - lib.onResize((width, height) => { - byuu.displayRatio = width / height; - byuu.emit('resize', { width, height }); - }) - - initialized = true + finalize() resolve() }) })