pine_read16
Retrieve a 16-bit unsigned value from emulated PlayStation memory. Ensure address is 2-byte aligned for accurate reads.
Instructions
Read an unsigned 16-bit little-endian value from emulated memory. Address should be 2-byte aligned.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| address | Yes | Memory address (2-byte aligned) |
Implementation Reference
- src/tools.ts:46-54 (schema)Tool definition (schema) for pine_read16 - declares the tool name, description, and input schema requiring an integer address.
{ name: "pine_read16", description: "Read an unsigned 16-bit little-endian value from emulated memory. Address should be 2-byte aligned.", inputSchema: { type: "object", required: ["address"], properties: { address: { type: "integer", description: "Memory address (2-byte aligned)" } }, }, }, - src/tools.ts:207-207 (handler)Handler case in CallToolRequestSchema switch - reads the address argument, calls pine.read16(), and formats the result with hex representation.
case "pine_read16": return ok(`${addrHex(addr())}: ${fmtHex(await pine.read16(addr()))}`); - src/tools.ts:171-177 (registration)Registration function that sets up ListToolsRequestSchema (which exposes the TOOLS array including pine_read16) and CallToolRequestSchema (which handles the call).
export function registerTools(server: Server, pine: PineClient): void { server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: TOOLS })); server.setRequestHandler(CallToolRequestSchema, async (req) => { const { name, arguments: args = {} } = req.params; const p = args as Record<string, unknown>; const addr = () => p.address as number; - src/pine.ts:220-224 (helper)PineClient.read16() helper - sends a Read16 (opcode 0x01) request over the PINE protocol with the address, then decodes the response as a 16-bit unsigned little-endian integer.
async read16(addr: number): Promise<number> { const args = Buffer.alloc(4); args.writeUInt32LE(addr, 0); const r = await this.call(Op.Read16, args); return r.readUInt16LE(0); }