mirror of
https://github.com/litruv/picoGraph.git
synced 2026-07-25 03:06:05 +10:00
Initial commit
moved from private version control
This commit is contained in:
45
scripts/nodes/library/memory/peek.js
Normal file
45
scripts/nodes/library/memory/peek.js
Normal file
@@ -0,0 +1,45 @@
|
||||
import { createNodeModule } from "../../nodeTypes.js";
|
||||
|
||||
/**
|
||||
* Reads bytes from base RAM using PICO-8's peek helper.
|
||||
*/
|
||||
export const memoryPeekNode = createNodeModule(
|
||||
{
|
||||
id: "memory_peek",
|
||||
title: "Peek Memory",
|
||||
category: "Memory",
|
||||
description: "Read a byte or sequence of bytes from base RAM.",
|
||||
searchTags: ["peek", "memory", "read"],
|
||||
inputs: [
|
||||
{
|
||||
id: "address",
|
||||
name: "Address",
|
||||
direction: "input",
|
||||
kind: "number",
|
||||
defaultValue: 0,
|
||||
},
|
||||
{
|
||||
id: "count",
|
||||
name: "Count",
|
||||
direction: "input",
|
||||
kind: "number",
|
||||
description: "Optional number of bytes to read",
|
||||
},
|
||||
],
|
||||
outputs: [
|
||||
{ id: "value", name: "Value", direction: "output", kind: "number" },
|
||||
],
|
||||
properties: [],
|
||||
},
|
||||
{
|
||||
evaluateValue: ({ resolveValueInput }) => {
|
||||
const OMIT = "__pg_omit__";
|
||||
const address = resolveValueInput("address", "0");
|
||||
const count = resolveValueInput("count", OMIT);
|
||||
if (count === OMIT) {
|
||||
return `peek(${address})`;
|
||||
}
|
||||
return `peek(${address}, ${count})`;
|
||||
},
|
||||
}
|
||||
);
|
||||
Reference in New Issue
Block a user