pine_write8
Writes a single byte (u8 value 0-255) to a specified memory address in emulated RAM. Writes to ROM or read-only regions are ignored.
Instructions
Write a byte (u8) to emulated RAM. Writes to ROM/read-only regions are silently ignored by the emulator.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| address | Yes | Memory address | |
| value | Yes |
Implementation Reference
- src/tools.ts:74-85 (registration)Tool schema registration for pine_write8 in the TOOLS array. Defines name, description ('Write a byte (u8) to emulated RAM'), and inputSchema with required 'address' (integer) and 'value' (integer 0-255) parameters.
{ name: "pine_write8", description: "Write a byte (u8) to emulated RAM. Writes to ROM/read-only regions are silently ignored by the emulator.", inputSchema: { type: "object", required: ["address", "value"], properties: { address: { type: "integer", description: "Memory address" }, value: { type: "integer", minimum: 0, maximum: 255 }, }, }, }, - src/tools.ts:211-214 (handler)Tool handler for pine_write8 in the switch statement. Calls pine.write8(addr(), p.value as number) and returns a success message with the hex-formatted written value and target address.
case "pine_write8": { await pine.write8(addr(), p.value as number); return ok(`Wrote ${fmtHex(p.value as number)} → ${addrHex(addr())}`); } - src/pine.ts:236-241 (helper)The write8 method on PineClient. Constructs a 5-byte buffer (4-byte LE address + 1-byte value) and sends it via the PINE protocol using opcode Op.Write8 (0x04).
async write8(addr: number, val: number): Promise<void> { const args = Buffer.alloc(5); args.writeUInt32LE(addr, 0); args.writeUInt8(val, 4); await this.call(Op.Write8, args); } - src/pine.ts:25-43 (helper)Opcode constant definition. Op.Write8 is defined as 0x04, used by the write8 helper to identify the write operation to the PINE server.
export const Op = { Read8: 0x00, Read16: 0x01, Read32: 0x02, Read64: 0x03, Write8: 0x04, Write16: 0x05, Write32: 0x06, Write64: 0x07, Version: 0x08, SaveState: 0x09, LoadState: 0x0A, Title: 0x0B, ID: 0x0C, UUID: 0x0D, GameVersion: 0x0E, Status: 0x0F, } as const; export type Opcode = typeof Op[keyof typeof Op];