memoscan
← all memos

Memo 0x7a09b788…2f834d on Ethereum

let value = 0; let shift = 0; let remaining = bits; while (remaining > 0) { const current = this.bytes[this.byteIndex] || 0; const available = 8 - this.bitIndex; const take = Math.min(available, remaining); const mask = (1 << take) - 1; value |= ((current >> this.bitIndex) & mask) << shift; this.bitIndex += take; if (this.bitIndex === 8) { this.bitIndex = 0; this.byteIndex += 1; } shift += take; remaining -= take; } return value; } } function grFrameLines(values, columns, rows) { const lines = []; for (let row = 0; row < rows; row += 1) { lines.push(values.slice(row * columns, row * columns + columns).join("")); } return lines.join("\n"); } function grDecodeToneFrames(encoded, columns, rows, frameCount) { const reader = new GrBitReader(grBase64Bytes(encoded)); const tones = ["0", "2", "4", "6", "9", "B", "D", "F"]; const frames = []; const cells = columns * rows; for (let frame = 0; frame < frameCount; frame += 1) { const values = new Array(cells); for (let cell = 0; cell < cells; cell += 1) values[cell] = tones[reader.read(3)] || "0"; frames.push(grFrameLines(values, columns, rows)); } return frames; } function grDecodeStyleFrames(encoded, columns, rows, frameCount, indexBits, valueBits, storageMode) { if (storageMode === "dense4bit") return grDecodeDense4BitStyleFrames(encoded, columns, rows, frameCount); return grDecodeSparseStyleFrames(encoded, columns, rows, frameCount, indexBits, valueBits); } function grDecodeDense4BitStyleFrames(encoded, columns, rows, frameCount) { const reader = new GrBitReader(grBase64Bytes(encoded)); const frames = []; const cells = columns * rows; for (let frame = 0; frame < frameCount; frame += 1) { const values = new Array(cells); for (let cell = 0; cell < cells; cell += 1) values[cell] = reader.read(4).toString(16).toUpperCase(); frames.push(grFrameLines(values, columns, rows)); } return frames; } function grDecodeSparseStyleFrames(encoded, columns, rows, frameCount, indexBits, valueBits) { const reader = new GrBitReader(grBase64Bytes(encoded)); const frames = []; const cells = columns * rows; for (let frame = 0; frame < frameCount; frame += 1) { const values = new Array(cells).fill("0"); const count = reader.read(16); for (let item = 0; item < count; item += 1) { const index = reader.read(indexBits); const style = reader.read(valueBits); if (index < cells) values[index] = String(style); } frames.push(grFrameLines(values, columns, rows)); } return frames; } const grConfig = grDecodeJson(GR_CONFIG_B64); const grRuntimeSeed = String(grConfig?.ritualEngineCompatibility?.seedField?.value || grConfig?.seed || ""); const grRuntime = GENESIS_RUNTIME_BY_SEED[grRuntimeSeed] || GENESIS_RUNTIME_BY_SEED[Object.keys(GENESIS_RUNTIME_BY_SEED)[0]]; Object.assign(SIGNAL_RITUAL_ENGINE, { glyphs: grRuntime.glyphs || grConfig.configuredGlyphs || "", ritualGlyphs: grRuntime.ritualGlyphs || (grConfig.configuredGlyphs || "").replace(/\s/g, ""), displayedFrames: grConfig.displayedFrames || grRuntime.displayedFrames, playbackMode: grConfig.playbackMode || grRuntime.playbackMode || "normal", timelineFrames: grConfig.timelineFrames || grRuntime.timelineFrames || grRuntime.displayedFrames, fps: grRuntime.fps || 12, keyframeSourceFrames: grRuntime.keyframeSourceFrames, storageSourceFrames: grRuntime.storageSourceFrames, interpolation: grRuntime.interpolation || "none", seed: grRuntime.seed, procedural: Boolean(grConfig.procedural ?? grRuntime.procedural), proceduralOverlay: Boolean(grConfig.proceduralOverlay ?? grRuntime.proceduralOverlay), proceduralMotion: grConfig.proceduralMotion || grRuntime.proceduralMotion || { enabled: false }, visualRenderer: grRuntime.visualRenderer, }); const keyframeSourceFrames = SIGNAL_RITUAL_ENGINE.storageSourceFrames || SIGNAL_RITUAL_ENGINE.keyframeSourceFrames; const columns = Math.max(1, Number(grConfig.grid?.columns) || grRuntime.columns || 1); const rows = Math.max(1, Number(grConfig.grid?.rows) || grRuntime.rows || 1); const cell = Math.max(1, Number(grRuntime.cell) || 16); const svgNs = "http://www.w3.org/2000/svg"; function grEnsureRuntimeSvgScaffold() { const art = document.getElementById("art"); if (!art) { return { art: null, artifactFrameLayer: null, glowCellsLayer: null, cellsLayer: null, scanlinesLayer: null, staticLayer: null, vignetteLayer: null, }; } const ensureLayer = (id, tagName = "g", beforeId = null) => { let node = document.getElementById(id); if (node) return node; node = document.createElementNS(svgNs, tagName); node.setAttribute("id", id); if (id === "scanlines" || id === "static" || id === "vignette") node.setAttribute("class", "fx"); if (beforeId) { const before = document.getElementById(beforeId); if (before && before.parentNode === art) art.insertBefore(node, before); else art.appendChild(node); } else { art.appendChild(node); } return node; }; const glowAmount = Math.max(0, Math.min(100, Number(SIGNAL_RITUAL_ENGINE.visualRenderer?.effects?.asciiGlow || 0))); if (glowAmount > 0 && !document.getElementById("glyphGlow")) { const glowStrength = glowAmount / 100; const wideRadius = Math.max(3, Math.min(22, cell * (0.38 + glowStrength * 0.72))).toFixed(2); const hotRadius = Math.max(1.5, Math.min(9, cell * (0.16 + glowStrength * 0.32))).toFixed(2); const wideAlpha = Math.max(0.12, Math.min(0.72, glowStrength * 0.62)).toFixed(3); const hotAlpha = Math.max(0.18, Math.min(0.9, glowStrength * 0.72)).toFixed(3); let defs = art.querySelector("defs"); if (!defs) { defs = document.createElementNS(svgNs, "defs"); art.insertBefore(defs, art.firstChild); } const filter = document.createElementNS(svgNs, "filter"); filter.setAttribute("id", "glyphGlow"); filter.setAttribute("x", "-30%"); filter.setAttribute("y", "-30%"); filter.setAttribute("width", "160%"); filter.setAttribute("height", "160%"); filter.setAttribute("color-interpolation-filters", "sRGB"); const wideBlur = document.createElementNS(svgNs, "feGaussianBlur"); wideBlur.setAttribute("in", "SourceGraphic"); wideBlur.setAttribute("stdDeviation", wideRadius); wideBlur.setAttribute("result", "wideBlur"); filter.appendChild(wideBlur); const wideTransfer = document.createElementNS(svgNs, "feComponentTransfer"); wideTransfer.setAttribute("in", "wideBlur"); wideTransfer.setAttribute("result", "wideGlow"); const wideFunc = document.createElementNS(svgNs, "feFuncA"); wideFunc.setAttribute("type", "linear"); wideFunc.setAttribute("slope", wideAlpha); wideTransfer.appendChild(wideFunc); filter.appendChild(wideTransfer); const hotBlur = document.createElementNS(svgNs, "feGaussianBlur"); hotBlur.setAttribute("in", "SourceGraphic"); hotBlur.setAttribute("stdDeviation", hotRadius); hotBlur.setAttribute("result", "hotBlur"); filter.appendChild(hotBlur); const hotTransfer = document.createElementNS(svgNs, "feComponentTransfer"); hotTransfer.setAttribute("in", "hotBlur"); hotTransfer.setAttribute("result", "hotGlow"); const hotFunc = document.createElementNS(svgNs, "feFuncA"); hotFunc.setAttribute("type", "linear"); hotFunc.setAttribute("slope", hotAlpha); hotTransfer.appendChild(hotFunc); filter.appendChild(hotTransfer); const merge = document.createElementNS(svgNs, "feMerge"); for (const input of ["wideGlow", "hotGlow", "SourceGraphic"]) { const node = document.createElementNS(svgNs, "feMergeNode"); node.setAttribute("in", input); merge.appendChild(node); } filter.appendChild(merge); defs.appendChild(filter); } const scanlinesLayer = ensureLayer("scanlines", "g", "static"); const staticLayer = ensureLayer("static", "g", "glowCells"); const glowCellsLayer = ensureLayer("glowCells", "g", "cells"); if (glowAmount > 0) glowCellsLayer.setAttribute("filter", "url(#glyphGlow)"); const cellsLayer = ensureLayer("cells", "g", "artifactFrame"); const artifactFrameLayer = ensureLayer("artifactFrame", "g", "vignette"); const vignetteLayer = ensureLayer("vignette", "rect"); if (!vignetteLayer.getAttribute("width")) vignetteLayer.setAttribute("width", "100%"); if (!vignetteLayer.getAttribute("height")) vignetteLayer.setAttribute("height", "100%"); if (!vignetteLayer.getAttribute("fill")) vignetteLayer.setAttribute("fill", "#000"); if (!vignetteLayer.getAttribute("opacity")) vignetteLayer.setAttribute("opacity", "0"); return { art, artifactFrameLayer, glowCellsLayer, cellsLayer, scanlinesLayer, staticLayer, vignetteLayer, }; } const grRuntimeSvg = grEnsureRuntimeSvgScaffold(); const art = grRuntimeSvg.art; const artifactFrameLayer = grRuntimeSvg.artifactFrameLayer; const glowCellsLayer = grRuntimeSvg.glowCellsLayer; const cellsLayer = grRuntimeSvg.cellsLayer; const scanlinesLayer = grRuntimeSvg.scanlinesLayer; const staticLayer = grRuntimeSvg.staticLayer; const vignetteLayer = grRuntimeSvg.vignetteLayer; const artifactFrame = grRuntime.artifactFrame || null; const artifactFramePad = artifactFrame?.padding || { left: 0, right: 0, top: 0, bottom: 0 }; const artifactFrameColumns = artifactFrame ? columns + (artifactFramePad.left || 0) + (artifactFramePad.right || 0) : columns; const artifactFrameRows = artifactFrame ? rows + (artifactFramePad.top || 0) + (artifactFramePad.bottom || 0) : rows; const artworkOffsetX = (artifactFramePad.left || 0) * cell; const artworkOffsetY = (artifactFramePad.top || 0) * cell; const outerMargin = 3; const cells = []; const rowOffsets = new Array(rows).fill(0); const scanlineRects = []; const staticRects = []; const toneLineCache = []; const styleLineCache = []; const toneFillCache = Object.create(null); const toneValueMap = { "0": 0, "2": 2 / 15, "4": 4 / 15, "6": 6 / 15, "9": 9 / 15, "B": 11 / 15, "D": 13 / 15, "F": 1 }; const SMOOTH_MARKETPLACE_MODE = true; const storedToneFrames = grDecodeToneFrames(GR_TONE_B64, columns, rows, keyframeSourceFrames.length); const storedStyleFrames = grDecodeStyleFrames(GR_STYLE_B64, columns, rows, keyframeSourceFrames.length, grConfig.styleIndexBits || 13, grConfig.styleValueBits || 3, grConfig.styleStorageMode || "sparseAnchors"); const RENDER_GLOW_ENABLED = Number(SIGNAL_RITUAL_ENGINE.visualRenderer?.effects?.asciiGlow || 0) > 0; const CACHE_FRAME_GROUPS = !(SIGNAL_RITUAL_ENGINE.proceduralMotion && SIGNAL_RITUAL_ENGINE.proceduralMotion.enabled); const PROCEDURAL_MOTION_CLOCK_FPS = 60; const PROCEDURAL_RENDER_FPS = 60; const PROCEDURAL_REPAINT_FPS = 60; const frameGroups = []; const warmingFrames = new Set(); let activeFrameGroup = null; let lastProceduralPaintFrame = -Infinity; setupSvgViewport(); let tick = -1; if (!CACHE_FRAME_GROUPS) { createCellNodes(cellsLayer, cells); } function setupSvgViewport() { if (!art) return; const width = artifactFrameColumns * cell; const height = artifactFrameRows * cell; const aspect = artifactFrameColumns / Math.max(1, artifactFrameRows); art.setAttribute("viewBox", (-outerMargin) + " " + (-outerMargin) + " " + (width + outerMargin * 2) + " " + (height + outerMargin * 2)); art.setAttribute("preserveAspectRatio", "xMidYMid meet"); art.style.width = "auto"; art.style.height = "min(100vh, calc(100vw / " + aspect + "), " + height + "px)"; const transform = artworkOffsetX || artworkOffsetY ? "translate(" + artworkOffsetX + " " + artworkOffsetY + ")" : ""; if (transform) { glowCellsLayer.setAttribute("transform", transform); cellsLayer.setAttribute("transform", transform); scanlinesLayer.setAttribute("transform", transform); staticLayer.setAttribute("transform", transform); vignetteLayer.setAttribute("transform", trans