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) 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]; 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; 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 @@