From 7e2c08814ac7c037363acf6e195bdd190e2da547 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Magalh=C3=A3es?= <joamag@gmail.com> Date: Sun, 20 Nov 2022 01:28:48 +0000 Subject: [PATCH] refactor: small set of fixes --- frontends/web/nodemon.json | 2 +- frontends/web/ts/gb.ts | 21 ++++++++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/frontends/web/nodemon.json b/frontends/web/nodemon.json index e656d91c..f091de34 100644 --- a/frontends/web/nodemon.json +++ b/frontends/web/nodemon.json @@ -1,5 +1,5 @@ { - "ext": "js,ts,jsx,tsx,mjs,json", + "ext": "js,ts,jsx,tsx,mjs,css,json", "ignore": ["dist", ".parcel-cache"], "ignoreRoot": [".git"] } diff --git a/frontends/web/ts/gb.ts b/frontends/web/ts/gb.ts index 5ddc731f..79ceadd8 100644 --- a/frontends/web/ts/gb.ts +++ b/frontends/web/ts/gb.ts @@ -4,7 +4,8 @@ import { Entry, Feature, PixelFormat, - RomInfo + RomInfo, + Size } from "emukit"; import { PALETTES, PALETTES_MAP } from "./palettes"; @@ -25,6 +26,10 @@ const LOGIC_HZ = 4194304; const VISUAL_HZ = 59.7275; const IDLE_HZ = 10; +const DISPLAY_WIDTH = 160; +const DISPLAY_HEIGHT = 144; +const DISPLAY_SCALE = 2; + /** * The rate at which the local storage RAM state flush * operation is going to be performed, this value is the @@ -285,7 +290,9 @@ export class GameboyEmulator extends EmulatorBase implements Emulator { // in case a remote ROM loading operation has been // requested then loads it from the remote origin if (loadRom) { - ({ name: romName, data: romData } = await this.fetchRom(romPath)); + ({ name: romName, data: romData } = await GameboyEmulator.fetchRom( + romPath + )); } else if (romName === null || romData === null) { [romName, romData] = [this.romName, this.romData]; } @@ -397,6 +404,14 @@ export class GameboyEmulator extends EmulatorBase implements Emulator { return PixelFormat.RGB; } + get dimensions(): Size { + return { + width: DISPLAY_WIDTH, + height: DISPLAY_HEIGHT, + scale: DISPLAY_SCALE + }; + } + /** * Returns the array buffer that contains the complete set of * pixel data that is going to be drawn. @@ -559,7 +574,7 @@ export class GameboyEmulator extends EmulatorBase implements Emulator { this.gameBoy?.set_palette_colors_ws(palette.colors); } - private async fetchRom( + private static async fetchRom( romPath: string ): Promise<{ name: string; data: Uint8Array }> { // extracts the name of the ROM from the provided -- GitLab