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