Initial commit

moved from private version control
This commit is contained in:
2025-10-19 21:12:41 +11:00
parent 5e84773bbe
commit e64f3e881e
187 changed files with 25372 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
import { mapMgetNode } from "./mget.js";
import { mapMsetNode } from "./mset.js";
import { mapDrawNode } from "./map.js";
import { mapTlineNode } from "./tline.js";
/**
* All map-related node modules backed by PICO-8 helpers.
*/
export const mapNodes = [mapMgetNode, mapMsetNode, mapDrawNode, mapTlineNode];
/**
* Checklist tracking coverage of documented map helpers.
* @type {Array<{ function: string, nodeId: string, implemented: boolean }>}
*/
export const mapFunctionChecklist = [
{ function: "MGET", nodeId: "map_mget", implemented: true },
{ function: "MSET", nodeId: "map_mset", implemented: true },
{ function: "MAP", nodeId: "map_map", implemented: true },
{ function: "TLINE", nodeId: "map_tline", implemented: true },
];

View File

@@ -0,0 +1,108 @@
import { createNodeModule } from "../../nodeTypes.js";
/**
* Draws map tiles using PICO-8's map helper.
*/
export const mapDrawNode = createNodeModule(
{
id: "map_map",
title: "Draw Map",
category: "Map",
description:
"Render a section of the map to the screen with optional layers.",
searchTags: ["map", "draw", "tiles", "layer"],
inputs: [
{ id: "exec_in", name: "Exec", direction: "input", kind: "exec" },
{
id: "tile_x",
name: "Tile X",
direction: "input",
kind: "number",
description: "Starting tile X coordinate",
},
{
id: "tile_y",
name: "Tile Y",
direction: "input",
kind: "number",
description: "Starting tile Y coordinate",
},
{
id: "screen_x",
name: "Screen X",
direction: "input",
kind: "number",
description: "Screen X position in pixels",
},
{
id: "screen_y",
name: "Screen Y",
direction: "input",
kind: "number",
description: "Screen Y position in pixels",
},
{
id: "tile_w",
name: "Tile Width",
direction: "input",
kind: "number",
description: "Number of tiles across",
},
{
id: "tile_h",
name: "Tile Height",
direction: "input",
kind: "number",
description: "Number of tiles down",
},
{
id: "layers",
name: "Layers",
direction: "input",
kind: "number",
description: "Sprite flag bitmask",
},
],
outputs: [
{ id: "exec_out", name: "Exec", direction: "output", kind: "exec" },
],
properties: [],
},
{
emitExec: ({ indent, indentLevel, resolveValueInput, emitNextExec }) => {
const OMIT = "__pg_omit__";
const tileX = resolveValueInput("tile_x", OMIT);
const tileY = resolveValueInput("tile_y", OMIT);
const screenX = resolveValueInput("screen_x", OMIT);
const screenY = resolveValueInput("screen_y", OMIT);
const tileW = resolveValueInput("tile_w", OMIT);
const tileH = resolveValueInput("tile_h", OMIT);
const layers = resolveValueInput("layers", OMIT);
const values = [
{ value: tileX, placeholder: "0" },
{ value: tileY, placeholder: "0" },
{ value: screenX, placeholder: "0" },
{ value: screenY, placeholder: "0" },
{ value: tileW, placeholder: "nil" },
{ value: tileH, placeholder: "nil" },
{ value: layers, placeholder: "nil" },
];
let lastIndex = values.length - 1;
while (lastIndex >= 0 && values[lastIndex].value === OMIT) {
lastIndex -= 1;
}
const args = [];
for (let index = 0; index <= lastIndex; index += 1) {
const entry = values[index];
args.push(entry.value === OMIT ? entry.placeholder : entry.value);
}
const call = args.length ? `map(${args.join(", ")})` : "map()";
const line = `${indent(indentLevel)}${call}`;
return [line, ...emitNextExec("exec_out")];
},
}
);

View File

@@ -0,0 +1,41 @@
import { createNodeModule } from "../../nodeTypes.js";
/**
* Reads a map tile value using PICO-8's mget helper.
*/
export const mapMgetNode = createNodeModule(
{
id: "map_mget",
title: "Get Map Tile",
category: "Map",
description: "Fetch the numeric map value at a tile coordinate.",
searchTags: ["mget", "map", "tile", "read"],
inputs: [
{
id: "x",
name: "Tile X",
direction: "input",
kind: "number",
defaultValue: 0,
},
{
id: "y",
name: "Tile Y",
direction: "input",
kind: "number",
defaultValue: 0,
},
],
outputs: [
{ id: "value", name: "Value", direction: "output", kind: "number" },
],
properties: [],
},
{
evaluateValue: ({ resolveValueInput }) => {
const x = resolveValueInput("x", "0");
const y = resolveValueInput("y", "0");
return `mget(${x}, ${y})`;
},
}
);

View File

@@ -0,0 +1,51 @@
import { createNodeModule } from "../../nodeTypes.js";
/**
* Writes a map tile value using PICO-8's mset helper.
*/
export const mapMsetNode = createNodeModule(
{
id: "map_mset",
title: "Set Map Tile",
category: "Map",
description: "Store a numeric value at a tile coordinate.",
searchTags: ["mset", "map", "tile", "write"],
inputs: [
{ id: "exec_in", name: "Exec", direction: "input", kind: "exec" },
{
id: "x",
name: "Tile X",
direction: "input",
kind: "number",
defaultValue: 0,
},
{
id: "y",
name: "Tile Y",
direction: "input",
kind: "number",
defaultValue: 0,
},
{
id: "value",
name: "Value",
direction: "input",
kind: "number",
defaultValue: 0,
},
],
outputs: [
{ id: "exec_out", name: "Exec", direction: "output", kind: "exec" },
],
properties: [],
},
{
emitExec: ({ indent, indentLevel, resolveValueInput, emitNextExec }) => {
const x = resolveValueInput("x", "0");
const y = resolveValueInput("y", "0");
const value = resolveValueInput("value", "0");
const line = `${indent(indentLevel)}mset(${x}, ${y}, ${value})`;
return [line, ...emitNextExec("exec_out")];
},
}
);

View File

@@ -0,0 +1,157 @@
import { createNodeModule } from "../../nodeTypes.js";
/**
* Draws textured lines or configures precision using PICO-8's tline helper.
*/
export const mapTlineNode = createNodeModule(
{
id: "map_tline",
title: "Draw Textured Line",
category: "Map",
description:
"Render a textured line from map data or adjust tline precision.",
searchTags: ["tline", "map", "texture", "line"],
inputs: [
{ id: "exec_in", name: "Exec", direction: "input", kind: "exec" },
{
id: "x0",
name: "X0",
direction: "input",
kind: "number",
description: "Line start X",
},
{
id: "y0",
name: "Y0",
direction: "input",
kind: "number",
description: "Line start Y",
},
{
id: "x1",
name: "X1",
direction: "input",
kind: "number",
description: "Line end X",
},
{
id: "y1",
name: "Y1",
direction: "input",
kind: "number",
description: "Line end Y",
},
{
id: "mx",
name: "Map X",
direction: "input",
kind: "number",
description: "Map sample X (tiles)",
},
{
id: "my",
name: "Map Y",
direction: "input",
kind: "number",
description: "Map sample Y (tiles)",
},
{
id: "mdx",
name: "MDX",
direction: "input",
kind: "number",
description: "Map X delta",
},
{
id: "mdy",
name: "MDY",
direction: "input",
kind: "number",
description: "Map Y delta",
},
{
id: "layers",
name: "Layers",
direction: "input",
kind: "number",
description: "Sprite flag bitmask",
},
{
id: "precision",
name: "Precision",
direction: "input",
kind: "number",
description: "Precision override when setting mode",
},
],
outputs: [
{ id: "exec_out", name: "Exec", direction: "output", kind: "exec" },
],
properties: [
{
key: "mode",
label: "Mode",
type: "enum",
defaultValue: "draw",
options: [
{ label: "Draw Line", value: "draw" },
{ label: "Set Precision", value: "precision" },
],
},
],
},
{
emitExec: ({
node,
indent,
indentLevel,
resolveValueInput,
emitNextExec,
}) => {
const mode = String(node.properties.mode ?? "draw");
if (mode === "precision") {
const precision = resolveValueInput("precision", "16");
const line = `${indent(indentLevel)}tline(${precision})`;
return [line, ...emitNextExec("exec_out")];
}
const OMIT = "__pg_omit__";
const x0 = resolveValueInput("x0", OMIT);
const y0 = resolveValueInput("y0", OMIT);
const x1 = resolveValueInput("x1", OMIT);
const y1 = resolveValueInput("y1", OMIT);
const mx = resolveValueInput("mx", OMIT);
const my = resolveValueInput("my", OMIT);
const mdx = resolveValueInput("mdx", OMIT);
const mdy = resolveValueInput("mdy", OMIT);
const layers = resolveValueInput("layers", OMIT);
const values = [
{ value: x0, placeholder: "0" },
{ value: y0, placeholder: "0" },
{ value: x1, placeholder: "0" },
{ value: y1, placeholder: "0" },
{ value: mx, placeholder: "0" },
{ value: my, placeholder: "0" },
{ value: mdx, placeholder: "0.125" },
{ value: mdy, placeholder: "0" },
{ value: layers, placeholder: "nil" },
];
let lastIndex = values.length - 1;
while (lastIndex >= 0 && values[lastIndex].value === OMIT) {
lastIndex -= 1;
}
const args = [];
for (let index = 0; index <= lastIndex; index += 1) {
const entry = values[index];
args.push(entry.value === OMIT ? entry.placeholder : entry.value);
}
const call = args.length ? `tline(${args.join(", ")})` : "tline()";
const line = `${indent(indentLevel)}${call}`;
return [line, ...emitNextExec("exec_out")];
},
}
);