Skip to content

Instantly share code, notes, and snippets.

@prozacchiwawa
prozacchiwawa / readdress.py
Created May 5, 2024 07:36
Simple way of marking up a ppc disassembly with addresses and info
#!/usr/bin/env python
import sys
import argparse
import json
branch_instrs = [
'b',
'bl',
'beq',
@prozacchiwawa
prozacchiwawa / metris_challenge.txt
Last active January 21, 2024 02:58
A weird quine related challenge idea
Tetris has these pieces:
[][] [][] [][] [] [][][][] [] []
[][] [][] [][] [][] [] []
[] [][] [][]
If you associate a 4-byte sequence with each of these pieces and use the method
below to turn a tetris game with a specific piece sequence and move sequence
into a program using those sequences, it seems possible that that program could
itself be a tetris game that can write itself into memory or to some io device.
@prozacchiwawa
prozacchiwawa / rs6000_checksum.py
Created December 29, 2023 19:31
RS/6000 nvram checksum algorithm
def rol(r,n):
return (r << n) | (r >> (32 - n))
def crcgen(r3,r4):
r6 = rol(r3,8) & 0xff00
r0 = rol(r4,0) & 0xff
r3 = rol(r3,24) & 0xffffff
r4 = r3 ^ r0
r0 = rol(r4,8) & 0xffffff00
r0 = rol(r0,20) & 0xfffff
@prozacchiwawa
prozacchiwawa / palette.py
Last active March 16, 2023 00:33
A nice 64 color palette?
from PIL import Image
img = Image.new(mode="RGB", size=(8,8))
pixels = [ ]
# Black
pixels.append((0,0,0))
# Greys and white
for i in range(15):
v = int((i + 1) * (255 / 15))
@prozacchiwawa
prozacchiwawa / main.rs
Last active February 5, 2023 05:59
Haskell inspired type based destructuring in rust
use serde_json;
pub enum And<T,U> {
These(T,U)
}
pub enum Field<T> {
Named(&'static str,T)
}
#[cfg(any(test, feature = "fuzzer"))]
use rand::prelude::*;
use rand::Error;
use random_lfsr_256_galois::{LFSRGalois, LFSRGaloisBuilder};
// A pseudo RNG which uses a slice for all entropy. It iterates a given slice
// many times, scrambling the bits through an LFSR in subsequent passes so that
// the fuzzer maintains a relationship between the original input bits and the
// output with some predictability.
@prozacchiwawa
prozacchiwawa / div2.v
Last active September 26, 2022 08:24
very crap proof that n/2 < n for n > 0
Fixpoint nat_lt (a : nat) (b : nat) : bool :=
match b with
| 0 => false
| (S b1) =>
match a with
| 0 => true
| (S a1) => nat_lt a1 b1
end
end.
@prozacchiwawa
prozacchiwawa / xtwrap.py
Last active June 5, 2022 08:55
xtwrap - wrap cool-retro-term to suit gxemul's way of calling xterm
#!/usr/bin/env python3
import os
import sys
import tty
import time
import uuid
import signal
import socket
import argparse
/* no warnings in desmet c 2.4
C> C88 FORBIDDE.C
C> BIND FORBIDDE.O
*/
#include <stdio.h>
struct X {
int typ;
int x_str;
int next;
#include <stdio.h>
#include <graph.h>
#include <math.h>
#include <float.h>
#include <dos.h>
#include <malloc.h>
int *buf;
unsigned short off;
double direction;