Skip to content

Instantly share code, notes, and snippets.

@Lincoln-LM
Lincoln-LM / main.py
Created March 10, 2024 13:58
GPU-powered ORAS TinyMT seed finding via soaring fidgets
from math import log2
from time import perf_counter_ns
import numpy as np
import pyopencl as cl
BASE_ADVANCE = 45
class TinyMT:
def __init__(self, seed):
self.state = [seed, 0x8F7011EE, 0xFC78FF1F, 0x3793FDFF]
@Lincoln-LM
Lincoln-LM / route_encount_spawners.json
Created February 28, 2024 16:41
SwSh simplified encount spawner data for areas a_0101-a_1201
{
"areas/a_0201.json": [
{
"pos": [
16737.070312,
2100.0,
8907.0
],
"max_spawns": 1
},
@Lincoln-LM
Lincoln-LM / gfpak.py
Created February 23, 2024 20:15
very basic GFPAK compression/decompression
from io import BytesIO
import struct
from dataclasses import dataclass
import lz4.block
import os
def fnv1a(s: str):
"""FNV1a hash"""
h = 0xCBF29CE484222645
@Lincoln-LM
Lincoln-LM / main.py
Created February 7, 2024 00:47
Pokemon Rumble (WiiWare) save file encryption/decryption
from hashlib import sha1
with open("savedata.bin", "rb") as savedata:
data = bytearray(savedata.read())
for chunk in range(0x33ff, -1, -1):
chunk_pos = chunk << 4
for i in range(16):
data[chunk_pos + i] = (
data[chunk_pos + i] - data[chunk_pos + ((chunk + i) & 0xF) - 16]
@Lincoln-LM
Lincoln-LM / randomized_spawns.txt
Last active February 5, 2024 07:36
Pokemon Rumble live randomized spawns gecko code
Name: Randomized Spawns
Author: Lincoln-LM
c2159ad0 00000008
809e0020 28041752
4182002c 38600000
3880022c 3d80801a
398cdef0 7d8803a6
4e800021 3c808036
3884df88 1c63001c
@Lincoln-LM
Lincoln-LM / flower.py
Last active January 12, 2024 00:41
Minecraft 1.16.1 (possibly other versions as well) flower forest flower type generation
GRADIENT = [
[1, 1],
[-1, 1],
[1, -1],
[-1, -1],
[1, 0],
[-1, 0],
[1, 0],
[-1, 0],
[0, 1],
@Lincoln-LM
Lincoln-LM / lattice_reduction.jl
Last active January 4, 2024 23:49
LCRNG seed searching/cracking from recorded "multiply and shift" rand(x) outputs via lattice reduction
# Heavily based on LattiCG
using JuMP, CDDLib, Nemo
const MULT::BigInt = 0x5D588B656C078965
const ADD::BigInt = 0x269EC3
const MOD::BigInt = BigInt(1) << 64
"Bound the RNG state based on a given rand(maximum) value"
function bounds(value, maximum = 1 << 32)
@Lincoln-LM
Lincoln-LM / output.txt
Created December 9, 2023 01:24
1-(4095/4096)^3 expansions
3 shiny roll chance:
fraction: 50319361/68719476736
decimal: 0.000732243075617589056491851806640625
repeats from digit None onward
alternate fraction: 1/1365.66672092676216615707818706203363750982449876499822801803862334420343692361276209369987826355744064397002179737536810135565910703834255764893357846893167025710044290904250552784245412019441184875141796812562862235074884993074534471930198000725804129348939864319819164635258384938552776932123601490090464384076737381462375883509331527481042535496426514637179116801582595613644616830487970624269254929529013693158782362121013420659296528030234724165118074531987796903859729061344797283892376932211042982044227469422753599752588273130097975608235565630493598676660460771749466373390552395925695479320574043060681951028750146489340355494577922005011152665472043653336535811732585395907551369740168202851383585733531075643031317508185368252192232727279664779526910129085303766079223462317019486793562422225512760386603478529864479002426123813456216186847046805701686076657
@Lincoln-LM
Lincoln-LM / hidden_encounters.md
Last active November 16, 2023 10:22
Cleaned up logic & addresses for generating hidden encounters in Pokemon Shield

Hidden Encounters

Pseudocode

All functions detailed here are cleaned up from the pseudocode produced by Ghidra of Pokemon Shield

Some function names are taken from leftover symbols but the rest are chosen based on utility

FUN_7100dc8590 is called every step