From 30df465edfc9dce14c3a4413f7ea1b0f2f322ebd Mon Sep 17 00:00:00 2001 From: DavidVentura Date: Tue, 30 Jan 2024 15:19:34 +0100 Subject: [PATCH] implement SetVideoResolution --- impl.ts | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/impl.ts b/impl.ts index 056ccd3..4aaee08 100644 --- a/impl.ts +++ b/impl.ts @@ -1,9 +1,9 @@ import "./shim.ts"; -import { ControlCommands, Commands, ccDest } from "./datatypes.js"; -import { Session } from "./server.js"; +import { ccDest, Commands, ControlCommands } from "./datatypes.js"; import { XqBytesEnc } from "./func_replacements.js"; import { hexdump } from "./hexdump.js"; +import { Session } from "./server.js"; import { u16_swap } from "./utils.js"; const str2byte = (s: string): number[] => { @@ -82,6 +82,37 @@ export const SendStartVideo = (session: Session): DataView => { return makeDataReadWrite(session, ControlCommands.StartVideo, null); }; +export const SendVideoResolution = (session: Session, resol: 1 | 2 | 3 | 4): null => { + const pairs = { + 1: [ + // 320 x 240 + [0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0], + [0x7, 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, 0x0], + ], + 2: [ + // 640x480 + [0x7, 0x0, 0x0, 0x0, 0x50, 0x0, 0x0, 0x0], + [0x1, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0], + ], + 3: [ + // also 640x480 on the X5 + [0x1, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0], + [0x7, 0x0, 0x0, 0x0, 0x78, 0x0, 0x0, 0x0], + ], + 4: [ + // also 640x480 on the X5 + [0x1, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0], + [0x7, 0x0, 0x0, 0x0, 0xa0, 0x0, 0x0, 0x0], + ], + }; + + pairs[resol].forEach((payload: number[]) => { + const dv = new DataView(new Uint8Array(payload).buffer); + session.send(makeDataReadWrite(session, ControlCommands.VideoParamSet, dv)); + }); + return null; +}; + export const SendReboot = (session: Session): DataView => { //const dv = new DataView(new Uint8Array(8).fill(0).buffer); let dv = null;