Fix DisplayGet: add ensureStopped, response type, correct body parsing
- Add ensureStopped() before DisplayGet to ensure VICE is ready - Add ResponseType.DisplayGet (0x84) to types - Fix response parsing: FL(4)+DW(2)+DH(2)+XO(2)+YO(2)+IW(2)+IH(2)+BP(1)+BL(4)+BD - Width/height are 16-bit not 32-bit per VICE docs 🤖 Generated with [Claude Code](https://claude.ai/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
26b5b694c1
commit
8541408504
2 changed files with 19 additions and 13 deletions
|
|
@ -726,26 +726,31 @@ export class ViceClient {
|
||||||
innerHeight: number;
|
innerHeight: number;
|
||||||
pixels: Buffer;
|
pixels: Buffer;
|
||||||
}> {
|
}> {
|
||||||
|
// Ensure VICE is stopped before display capture
|
||||||
|
await this.ensureStopped();
|
||||||
|
|
||||||
// Body: useVicii(1) + format(1)
|
// Body: useVicii(1) + format(1)
|
||||||
// Format: 0 = indexed 8-bit
|
// Format: 0 = indexed 8-bit
|
||||||
const body = Buffer.alloc(2);
|
const body = Buffer.alloc(2);
|
||||||
body[0] = useVicii ? 1 : 0;
|
body[0] = useVicii ? 1 : 0;
|
||||||
body[1] = 0; // 8-bit indexed
|
body[1] = 0; // 8-bit indexed
|
||||||
|
|
||||||
const response = await this.sendCommand(Command.DisplayGet, body);
|
// Response type is 0x84 (same as command)
|
||||||
|
const response = await this.sendCommand(Command.DisplayGet, body, ResponseType.DisplayGet);
|
||||||
|
|
||||||
// Parse response
|
// Parse response per VICE docs:
|
||||||
// Response: length(4) + width(4) + height(4) + bpp(1) + offsetX(4) + offsetY(4) +
|
// FL(4) + DW(2) + DH(2) + XO(2) + YO(2) + IW(2) + IH(2) + BP(1) + BL(4) + BD(BL)
|
||||||
// innerWidth(4) + innerHeight(4) + pixels...
|
// FL = length of fields before display buffer (should be 17)
|
||||||
const dataLength = response.body.readUInt32LE(0);
|
// const fieldsLength = response.body.readUInt32LE(0); // Not used but documented
|
||||||
const width = response.body.readUInt32LE(4);
|
const width = response.body.readUInt16LE(4); // DW - debug width
|
||||||
const height = response.body.readUInt32LE(8);
|
const height = response.body.readUInt16LE(6); // DH - debug height
|
||||||
const bitsPerPixel = response.body[12];
|
const offsetX = response.body.readUInt16LE(8); // XO - x offset
|
||||||
const offsetX = response.body.readUInt32LE(13);
|
const offsetY = response.body.readUInt16LE(10); // YO - y offset
|
||||||
const offsetY = response.body.readUInt32LE(17);
|
const innerWidth = response.body.readUInt16LE(12); // IW - inner width
|
||||||
const innerWidth = response.body.readUInt32LE(21);
|
const innerHeight = response.body.readUInt16LE(14); // IH - inner height
|
||||||
const innerHeight = response.body.readUInt32LE(25);
|
const bitsPerPixel = response.body[16]; // BP - bits per pixel
|
||||||
const pixels = response.body.subarray(29, 29 + dataLength);
|
const bufferLength = response.body.readUInt32LE(17); // BL - buffer length
|
||||||
|
const pixels = response.body.subarray(21, 21 + bufferLength); // BD - display buffer
|
||||||
|
|
||||||
return {
|
return {
|
||||||
width,
|
width,
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,7 @@ export enum ResponseType {
|
||||||
Undump = 0x42,
|
Undump = 0x42,
|
||||||
ResourceGet = 0x51,
|
ResourceGet = 0x51,
|
||||||
ResourceSet = 0x52,
|
ResourceSet = 0x52,
|
||||||
|
DisplayGet = 0x84,
|
||||||
|
|
||||||
// Async event codes (sent by VICE unprompted)
|
// Async event codes (sent by VICE unprompted)
|
||||||
JAM = 0x61, // CPU jam event
|
JAM = 0x61, // CPU jam event
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue