Fix register parsing (VICE binary protocol v2 format), getDisplay ensureStopped race, getPalette missing VC body
This commit is contained in:
parent
d06d2ef71d
commit
1bea1deba9
2 changed files with 19 additions and 17 deletions
30
src/index.ts
30
src/index.ts
|
|
@ -378,17 +378,19 @@ Related tools: setRegister, step, continue, status`,
|
||||||
};
|
};
|
||||||
|
|
||||||
for (let i = 0; i < count && offset < response.body.length; i++) {
|
for (let i = 0; i < count && offset < response.body.length; i++) {
|
||||||
|
const itemSize = response.body[offset];
|
||||||
|
offset += 1;
|
||||||
const id = response.body[offset];
|
const id = response.body[offset];
|
||||||
const size = response.body[offset + 1];
|
offset += 1;
|
||||||
offset += 2;
|
const valueSize = itemSize - 1;
|
||||||
|
|
||||||
let value = 0;
|
let value = 0;
|
||||||
if (size === 1) {
|
if (valueSize === 1) {
|
||||||
value = response.body[offset];
|
value = response.body[offset];
|
||||||
} else if (size === 2) {
|
} else if (valueSize === 2) {
|
||||||
value = response.body.readUInt16LE(offset);
|
value = response.body.readUInt16LE(offset);
|
||||||
}
|
}
|
||||||
offset += size;
|
offset += valueSize;
|
||||||
|
|
||||||
const name = regNames[id] || `R${id}`;
|
const name = regNames[id] || `R${id}`;
|
||||||
registers[name] = value;
|
registers[name] = value;
|
||||||
|
|
@ -500,14 +502,15 @@ Related tools: getRegisters, continue, setBreakpoint, status`,
|
||||||
let pc = 0;
|
let pc = 0;
|
||||||
|
|
||||||
for (let i = 0; i < count && offset < regResponse.body.length; i++) {
|
for (let i = 0; i < count && offset < regResponse.body.length; i++) {
|
||||||
|
const itemSize = regResponse.body[offset];
|
||||||
|
offset += 1;
|
||||||
const id = regResponse.body[offset];
|
const id = regResponse.body[offset];
|
||||||
const size = regResponse.body[offset + 1];
|
offset += 1;
|
||||||
offset += 2;
|
if (id === 3) {
|
||||||
if (id === 3 && size === 2) {
|
|
||||||
// PC
|
// PC
|
||||||
pc = regResponse.body.readUInt16LE(offset);
|
pc = regResponse.body.readUInt16LE(offset);
|
||||||
}
|
}
|
||||||
offset += size;
|
offset += itemSize - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return formatResponse({
|
return formatResponse({
|
||||||
|
|
@ -880,14 +883,15 @@ Related tools: readMemory, getRegisters, step`,
|
||||||
const count = regResponse.body.readUInt16LE(0);
|
const count = regResponse.body.readUInt16LE(0);
|
||||||
let offset = 2;
|
let offset = 2;
|
||||||
for (let i = 0; i < count && offset < regResponse.body.length; i++) {
|
for (let i = 0; i < count && offset < regResponse.body.length; i++) {
|
||||||
|
const itemSize = regResponse.body[offset];
|
||||||
|
offset += 1;
|
||||||
const id = regResponse.body[offset];
|
const id = regResponse.body[offset];
|
||||||
const size = regResponse.body[offset + 1];
|
offset += 1;
|
||||||
offset += 2;
|
if (id === 3) {
|
||||||
if (id === 3 && size === 2) {
|
|
||||||
startAddress = regResponse.body.readUInt16LE(offset);
|
startAddress = regResponse.body.readUInt16LE(offset);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
offset += size;
|
offset += itemSize - 1;
|
||||||
}
|
}
|
||||||
startAddress = startAddress ?? 0;
|
startAddress = startAddress ?? 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -730,9 +730,6 @@ 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);
|
||||||
|
|
@ -770,7 +767,8 @@ export class ViceClient {
|
||||||
|
|
||||||
// Get palette (color table)
|
// Get palette (color table)
|
||||||
async getPalette(): Promise<Array<{ r: number; g: number; b: number }>> {
|
async getPalette(): Promise<Array<{ r: number; g: number; b: number }>> {
|
||||||
const response = await this.sendCommand(Command.PaletteGet);
|
// VICE 3.6+ expects 1-byte body (useVIC flag), not empty
|
||||||
|
const response = await this.sendCommand(Command.PaletteGet, Buffer.from([1]));
|
||||||
|
|
||||||
// Parse response
|
// Parse response
|
||||||
// Response: count(2) + [r(1) + g(1) + b(1)]...
|
// Response: count(2) + [r(1) + g(1) + b(1)]...
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue