From 582cce78c86621a2d9dc50ff521b1e79e3903c7d Mon Sep 17 00:00:00 2001 From: Corwin Date: Mon, 8 Apr 2024 03:23:19 +0100 Subject: [PATCH 1/4] compress the combo rom --- justfile | 1 + 1 file changed, 1 insertion(+) diff --git a/justfile b/justfile index 2fa42ad5..d228a70c 100644 --- a/justfile +++ b/justfile @@ -110,6 +110,7 @@ build-site: build-combo-rom-site build-site-mgba-wrapper build-book cp book/book website/build/book -r cp website/app/build website/build/mgba -r cp examples/target/examples/combo.gba website/build/assets/combo.gba + gzip -9 -c website/build/assets/combo.gba > website/build/assets/combo.gba.gz _run-tool +tool: (cd tools && cargo build) From f0ee5a081c17acc54769321cb83583504eeaa5ca Mon Sep 17 00:00:00 2001 From: Corwin Date: Mon, 8 Apr 2024 03:23:47 +0100 Subject: [PATCH 2/4] make emulator wrapper be able to decompress gzip compressed roms --- website/app/src/mgba.tsx | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/website/app/src/mgba.tsx b/website/app/src/mgba.tsx index 7018ee6b..d857439e 100644 --- a/website/app/src/mgba.tsx +++ b/website/app/src/mgba.tsx @@ -41,6 +41,19 @@ export interface MgbaHandle { buttonRelease: (key: GbaKey) => void; } +const downloadGame = async (gameUrl: string): Promise => { + const game = await fetch(gameUrl); + + if (gameUrl.endsWith(".gz")) { + const decompressedStream = (await game.blob()) + .stream() + .pipeThrough(new DecompressionStream("gzip")); + return await new Response(decompressedStream).arrayBuffer(); + } else { + return await game.arrayBuffer(); + } +}; + export const Mgba = forwardRef( ({ gameUrl, volume, controls, paused }, ref) => { const canvas = useRef(null); @@ -52,9 +65,7 @@ export const Mgba = forwardRef( useEffect(() => { if (state !== MgbaState.Initialised) return; (async () => { - const game = await fetch(gameUrl); - const gameData = await game.arrayBuffer(); - + const gameData = await downloadGame(gameUrl); const gameSplit = gameUrl.split("/"); const gameBaseName = gameSplit[gameSplit.length - 1]; From f1ef67ad1e047eaf14ea608afe0bffa79b49365b Mon Sep 17 00:00:00 2001 From: Corwin Date: Mon, 8 Apr 2024 03:23:55 +0100 Subject: [PATCH 3/4] use the gzip compressed combo rom --- website/site/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/site/index.html b/website/site/index.html index e6b18c50..5338319e 100644 --- a/website/site/index.html +++ b/website/site/index.html @@ -155,7 +155,7 @@
From b830410e39d4d137a9d6a6e931dd5af614e34bca Mon Sep 17 00:00:00 2001 From: Corwin Date: Mon, 8 Apr 2024 03:24:06 +0100 Subject: [PATCH 4/4] remove log statement --- website/app/src/useFrameSkip.hook.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/website/app/src/useFrameSkip.hook.ts b/website/app/src/useFrameSkip.hook.ts index ff8c9d85..fa9e4633 100644 --- a/website/app/src/useFrameSkip.hook.ts +++ b/website/app/src/useFrameSkip.hook.ts @@ -14,7 +14,6 @@ export const useFrameSkip = (mgbaModule: MutableRefObject) => { const raf = (time: DOMHighResTimeStamp) => { if (previous) { const delta = time - previous; - console.log(delta); smoothedFrameTime = (smoothedFrameTime * 3 + delta) / 4;