Skip to content

Instantly share code, notes, and snippets.

@harukaappscreate
harukaappscreate / main.py
Created November 20, 2026 08:03
BTC MINER in stock Pyxel: real double-SHA-256 Bitcoin block-header miner (pure Python + hashlib, ~8 ms/frame) with a self-written dependency-free QR encoder (qr.py) and verifiable Test Mode. (MIT License)
# Copyright (c) 2026 haruka_apps
# License: MIT (https://opensource.org/licenses/MIT)
#
# BTC MINER - real Bitcoin SHA-256d grinding in stock Pyxel.
#
# Grinds a REAL Bitcoin block header (chain tip captured at build time from
# blockstream.info) at the REAL network difficulty, using only
# hashlib. Every number on screen is measured or computed from the template.
# If a hash <= target is ever found, the winning 80-byte header is shown as
# hex and as a QR code (self-written encoder, qr.py) for human carry-out.
@harukaappscreate
harukaappscreate / wasm4_vm.py
Last active November 19, 2026 21:54
Single-file Pure Python WASM-4 Fantasy Console VM (RegBBVM v4, no exec/eval, Pyxel/Pyodide). Drop any .wasm cart to play! / Pure Python製 高速WASM-4 VM | Demo: https://codeandmagic.samurai-apps.com/works/wasm-4-vm-drop-wasm-39918
# Copyright (c) 2026 haruka_apps
# License: MIT (https://opensource.org/licenses/MIT)
#
# WASM-4 VM (Drop .wasm) -- Single-file Pure Python WASM-4 Fantasy Console VM
#
# Live Demo (Code & Magic / Pyodide):
# https://codeandmagic.samurai-apps.com/works/wasm-4-vm-drop-wasm-39918
#
# Architecture (RegBBVM v4 + Built-in CC0 AOT Raycaster Demo):
# - Compiles dropped .wasm cartridges on the fly into a 3-address register IR
// @title slice.
// 3KB 1px Z-buffer & real-time CSG cross-section megademo for Playload.
const S = Math.sin, C = Math.cos, PI = Math.PI, A = Math.abs, M = Math.min, X = Math.max;
// Register 8 fast ASCII horizontal span glyphs (\x01..\x08, widths 1..8px)
const P = (w) => String.fromCharCode(w);
for (let w = 1; w <= 8; w++) pcg[P(w)].pat = [256 - (256 >> w), 0, 0, 0, 0, 0, 0, 0];
// ---------- AY-3-8910 Soundtrack: C minor (Cm - Ab - Fm - G7) at T120 (480f = 16 beats/scene) ----------
// @title crypt.
// 3KB real-time 3D dungeon action RPG (zero emojis) for Playload.
const S = Math.sin, C = Math.cos, A = Math.abs, M = Math.min, X = Math.max, H = Math.hypot;
// Register 8 fast ASCII horizontal span glyphs (\x01..\x08, widths 1..8px) via direct Uint8Array mutation
const P = (w) => String.fromCharCode(w);
for (let w = 1; w <= 8; w++) pcg[P(w)].pat[0] = 256 - (256 >> w);
// ---------- 1px Software Z-Buffer (Uint8Array 23,040) & 3D Oblique Prism Renderer ----------
// @title Cube Maze 3D
// Roll across all 6 faces of a 3D cube maze! ARW:Roll B:Retry
const M = Math, S = M.sin, C = M.cos, H = M.hypot, FC = String.fromCharCode;
const I3 = [0, 1, 2], I4 = [0, 1, 2, 3], Q4 = [[-1, -1], [1, -1], [1, 1], [-1, 1]];
// PCG: 1..8 = 1..8px solid horizontal spans; 11, 12 = 1x1 checkerboard dithers (skip 10 = '\n'!)
for (let i = 1; i < 13; i++)
if (i != 10) pcg[FC(i)].pat = [i < 9 ? 256 - (256 >> i) : i & 1 ? 85 : 170, 0, 0, 0, 0, 0, 0, 0];
// @title Vector Strike
// Arrows fly, A fire, B bomb. Shoot 8 fighters, then dive into the trench and hit the core!
const D = '#';
pcg[D].pat = '8000000000000000';
const F = 110, TL = 1800;
const N = (v) => { const l = Math.hypot(...v) || 1; return v.map((x) => x / l); };
const R = (s) => (Math.random() - 0.5) * s;
// Original fighter: nose, top fin, belly, wingtips, wing roots
const FV = [[0, 0, 9], [0, 3, -5], [0, -2, -5], [11, 0, -7], [-11, 0, -7], [4, 0, -4], [-4, 0, -4]];
// @title rubble.
// A 3KB megademo for Playload, after debris. No data, code only. Sound on! Any button pauses; it loops.
const S = Math.sin, C = Math.cos, PI = Math.PI, A = Math.abs, M = Math.min, X = Math.max;
const h = (i) => A(S(i * 12.9898) * 43758.5) % 1;
// Glyphs for drawing: dot, 2×2, 8×1 line, 4×4 cube (body, lit top, dark side), 8×8 cube (body, top, side)
['#80', '$c0c0', '%ff', '&f0f0f0f0', "'f0", '(10101010', ')ffffffffffffffff', '*ffff', '+0303030303030303']
.forEach((p) => (pcg[p[0]].pat = p.slice(1).padEnd(16, 0)));
// ---------- Music: A minor, Am F Dm E ----------
@harukaappscreate
harukaappscreate / main.py
Created October 20, 2026 08:29
zero. — A 0-asset megademo in Pyxel
"""zero. — データなしのメガデモ(Pyxel / Code & Magic)
画像も音声のファイルも使わない。このファイル 1 つだけで、起動したときに曲(約 2 分半)と形を NumPy で作り、
曲に合わせて 6 つの場面を描く。時計は音の再生位置なので、映像と曲はずれない。
01 signal いま鳴っている波形がオシロスコープの線になり、文字に集まる
02 tunnel 昔のデモの定番のトンネル(模様はその場で作る)
03 city 夜の街の上を飛ぶ(箱の三角形を NumPy のスキャンラインで描く。窓は画素ごとに計算)
04 swarm 1 万 2 千粒が 球 → 立方体 → 輪 → 文字 → 渦 と形を変える
05 metaballs 溶け合う金属の球(レイマーチング)
@harukaappscreate
harukaappscreate / COPYING-FREEDOOM.adoc
Created August 3, 2026 07:14
Freedoom E1M1 WAD wall viewer for PyxelBasic DRAW3D

Copyright © 2001-2024 Contributors to the Freedoom project. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  • Redistributions in binary form must reproduce the above copyright