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;
|
||||
pixels: Buffer;
|
||||
}> {
|
||||
// Ensure VICE is stopped before display capture
|
||||
await this.ensureStopped();
|
||||
|
||||
// Body: useVicii(1) + format(1)
|
||||
// Format: 0 = indexed 8-bit
|
||||
const body = Buffer.alloc(2);
|
||||
body[0] = useVicii ? 1 : 0;
|
||||
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
|
||||
// Response: length(4) + width(4) + height(4) + bpp(1) + offsetX(4) + offsetY(4) +
|
||||
// innerWidth(4) + innerHeight(4) + pixels...
|
||||
const dataLength = response.body.readUInt32LE(0);
|
||||
const width = response.body.readUInt32LE(4);
|
||||
const height = response.body.readUInt32LE(8);
|
||||
const bitsPerPixel = response.body[12];
|
||||
const offsetX = response.body.readUInt32LE(13);
|
||||
const offsetY = response.body.readUInt32LE(17);
|
||||
const innerWidth = response.body.readUInt32LE(21);
|
||||
const innerHeight = response.body.readUInt32LE(25);
|
||||
const pixels = response.body.subarray(29, 29 + dataLength);
|
||||
// Parse response per VICE docs:
|
||||
// FL(4) + DW(2) + DH(2) + XO(2) + YO(2) + IW(2) + IH(2) + BP(1) + BL(4) + BD(BL)
|
||||
// FL = length of fields before display buffer (should be 17)
|
||||
// const fieldsLength = response.body.readUInt32LE(0); // Not used but documented
|
||||
const width = response.body.readUInt16LE(4); // DW - debug width
|
||||
const height = response.body.readUInt16LE(6); // DH - debug height
|
||||
const offsetX = response.body.readUInt16LE(8); // XO - x offset
|
||||
const offsetY = response.body.readUInt16LE(10); // YO - y offset
|
||||
const innerWidth = response.body.readUInt16LE(12); // IW - inner width
|
||||
const innerHeight = response.body.readUInt16LE(14); // IH - inner height
|
||||
const bitsPerPixel = response.body[16]; // BP - bits per pixel
|
||||
const bufferLength = response.body.readUInt32LE(17); // BL - buffer length
|
||||
const pixels = response.body.subarray(21, 21 + bufferLength); // BD - display buffer
|
||||
|
||||
return {
|
||||
width,
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@ export enum ResponseType {
|
|||
Undump = 0x42,
|
||||
ResourceGet = 0x51,
|
||||
ResourceSet = 0x52,
|
||||
DisplayGet = 0x84,
|
||||
|
||||
// Async event codes (sent by VICE unprompted)
|
||||
JAM = 0x61, // CPU jam event
|
||||
|
|
|
|||
Loading…
Reference in a new issue