Skip to content

Instantly share code, notes, and snippets.

@tako2
tako2 / dumplist.py
Created April 1, 2021 07:47
Dump binary file with check sums like pages published on retro pc magazines.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
from optparse import OptionParser
#==============================================================================
def dump_block(addr, data):
print('Add +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F :Sum')
idx = 0
@tako2
tako2 / img2pdf.py
Created June 14, 2021 15:33
画像ファイルを PDF に出力
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from PIL import Image
from reportlab.pdfgen import canvas
from reportlab.lib.pagesizes import A4
from reportlab.lib import pdfencrypt
from reportlab.lib.units import mm
from reportlab.lib.units import cm
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from optparse import OptionParser
import sys
import os
#==============================================================================
def put_chunk(f, chunk):
checksum = ((~sum(chunk)) + 1) & 0xff
@tako2
tako2 / bin2mi.py
Created February 1, 2025 07:40
Translate binary file to .mi file (for GOWIN FPGA Designer)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
from optparse import OptionParser
#==============================================================================
def dump_bin(out_fp, top_addr, data, size):
for addr in range(0, size, 16):
out_fp.write('{:04X}:'.format(top_addr + addr))
import bpy
import os
import json
from mathutils import Vector, Matrix
# 選択したオブジェクトを取得
objects = bpy.context.selected_objects
if not objects or not any(obj.type == 'MESH' for obj in objects):
print("少なくとも1つのメッシュオブジェクトを選択してください")
exit()
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import pyxel
import math
import json
import sys
COLORS = [0x000000, 0x0000FF, 0xFF0000, 0xFF00FF,
0x00FF00, 0x00FFFF, 0xFFFF00, 0xFFFFFF,
@tako2
tako2 / ops_impl.py
Created June 9, 2026 22:55
Z-machin の python 実装 xyppy に日本語翻訳を追加 (ops_impl.py の置き換え)
# ops_impl.py (as in this file implements the opcodes)
#
# the goal here is to have no z-machine version control flow in here,
# i.e. no 'if *.z5 then X else Y'. All that should be in ops_impl_compat.py
import random
from xyppy.debug import DBG, warn, err
from xyppy.zmath import to_signed_word