make react component

This commit is contained in:
dylan
2024-03-31 12:13:27 -07:00
parent 55fca0a5c2
commit d606a8002f
8 changed files with 117 additions and 66 deletions

View File

@ -1,8 +1,8 @@
import { assertNever } from "@firebox/tsutil";
import { pngToRom } from "./pngToRom";
import { renderCart as rawRenderCart } from "./rawRenderCart";
import { RenderCart, renderCart as rawRenderCart } from "./rawRenderCart";
type PicoCart = {
export type PicoCart = {
name: string;
src: string;
} | {
@ -20,7 +20,9 @@ type PlayerButtons = {
menu: boolean;
}
type PicoPlayerHandle = {
export type PicoPlayerHandle = {
raw: ReturnType<RenderCart>;
rawModule: unknown;
// external things
readonly canvas: HTMLCanvasElement;
@ -35,16 +37,16 @@ type PicoPlayerHandle = {
setGamepadCount: (count: number) => void;
readonly gpio: number[]; // read + write (should be 256-tuple)
// state (all communicated out)
// state
readonly state: {
readonly frameNumber: number;
readonly isPaused: boolean;
readonly hasFocus: boolean;
readonly requestPointerLock: boolean;
readonly requirePageNavigateConfirmation: boolean;
readonly showDpad: boolean;
readonly shutdownRequested: boolean;
readonly soundVolume: number;
frameNumber: number;
isPaused: boolean;
hasFocus: boolean;
requestPointerLock: boolean;
requirePageNavigateConfirmation: boolean;
showDpad: boolean;
shutdownRequested: boolean;
soundVolume: number;
};
// misc?
@ -109,6 +111,8 @@ export const makePicoConsole = async (props: {
];
handle.pico8_gamepads = {count: 0};
return {
raw: handle,
rawModule: Module,
canvas,
state: {
frameNumber: handle.pico8_state.frame_number!,