Skip to content

Instantly share code, notes, and snippets.

View PikalaxALT's full-sized avatar
🤧
ARM assembly is nothing to sneeze at.

PikalaxALT

🤧
ARM assembly is nothing to sneeze at.
View GitHub Profile
# Implements a beta binomial distribution using the scipy discrete random
# variable API.
# Requires scipy 0.14.0 or newer; recommend scipy 0.15.0 or newer
# Distribution functions unapologetically adapted from Wikipedia
# http://en.wikipedia.org/wiki/Beta-binomial_distribution
from numpy import exp, floor, ceil, sqrt, r_, maximum, where, sum, zeros, linspace
from numpy.lib.function_base import vectorize
from scipy.stats._distn_infrastructure import rv_discrete, rv_frozen
from scipy.stats import beta, binom
@PikalaxALT
PikalaxALT / z80disasm.py
Created March 9, 2017 03:48
Script for disassembling Gameboy Z80
#!/usr/bin/python3
import re, sys, argparse, random
TileMap = -1000 # 0xc3a0
AttrMap = -1000 # 0xccd9
SCREEN_WIDTH = 20
SCREEN_HEIGHT = 18
z80table = [
# $00
@PikalaxALT
PikalaxALT / pokecrystal_rng.txt
Created May 10, 2017 02:26
Brief description of how and when the RNG updates in the Pokemon Crystal overworld, with the goal of bringing RNG manipulation to gen 2 speedrunning.
The RNG update function is as follows:
* The value at 0xFF04 (rDIV) is read and added, with carry, to 0xFFE1 (hRandomAdd); the value is stored back to hRandomAdd.
* The value at rDIV is read again (it may have incremented) and subtracted, with carry, from 0xFFE2 (hRandomSub); the value is stored back to hRandomSub and returned in the accumulator.
Every time the VBlank interrupt toggles, the RNG is called. This happens once every frame.
When you turnframe or step onto a tile that can generate an encounter, the RNG is rolled a number of times for that encounter. This excludes the first 5 steps after loading the current map from a connection, warp, or battle; during this time, no wild encounters may be generated so as to prevent the player from being encounter-locked. Note that encounters are not rolled until the frame your step or turnframe finishes. The pattern is as such:
* Roll RNG and compare it with the modified encounter rate. If the rolled number is greater than the encounter rate, the ro
APCGX7rC47Q43Cpp4Y8E9sHsJWJPlVzbUyRCbxcRHCEkb4na8b3e6LPZ
F7RXzOZn-I846wC8K-ajSNH2B0PX1U9GWcxG5tsx102uC_0jPsLsVqUU
GdAUOqrmHXOPu5ciaQ6ARunk9EYVx2jNH6o9N2cxIUbEL06e5a75oW5J
mR2ruEhtEz6TTvUDJ46tEieWq1QD_909sVCleLz_4BK8C3RnTVoEifvk
B_r2L9YaQGI8EgtN3EUaNvC329BeGP0FxznOOB28fwz5Y9HBX_eEvy25
vdYw1EvfJLlWxCM4XHwzhXN9zyANs7-3dlHOjXTG0cr8KcJ5W2juJNw1
udF91MCBjyJjpi3_8FQ08YW2w38ndZ7CsIHjcjdVk8A1S1BUGEAslnxB
a8b3FcCM9t4wGQbcDTT2XschjREgz2rWha4bSnhMRTCaAr3h2vebTly6
GkyBAZhQHKl-xwQfFDT016lKrhCNtVygxYy6vXFMWVyBqJwldq7gvy7z
YJvwS1mASoOfW1AJpcMLWL317bLSq1kaJk-7JRgzrqyJSEclWNkBQ2P5
@PikalaxALT
PikalaxALT / test_sql.py
Created May 15, 2018 12:35
Test suite for [PikalaxBOT](/pikalaxalt/pikalaxbot)
import unittest
import sqlite3
from utils import sql
from collections import namedtuple
User = namedtuple('User', ['id', 'name'])
Context = namedtuple('Context', ['author'])
me = User(148462033770119168, 'PikalaxALT')
ctx = Context(me)
import asyncio
import discord
from discord.ext import commands
from collections import Counter
class FooCog:
THUMBS_UP = '\U0001ff4d'
THUMBS_DOWN = '\U0001ff4e'
#include <stdio.h>
#include <getopt.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
struct Section {
unsigned short end;
bool invalid;
char * name;
@PikalaxALT
PikalaxALT / gbz80disasm.py
Last active January 8, 2022 17:29
Rudimentary GBZ80 disassembler (MBC3 only for the time being)
import argparse
from functools import total_ordering
from z80table import z80table, extdtable
import re
def fread(file, n):
return int.from_bytes(file.read(n), 'little')
@PikalaxALT
PikalaxALT / save.s
Last active November 18, 2018 01:03
output by arm-none-eabi-gcc-8.1.0
.file ""
.text
.syntax divided
.section .rodata
.align 2
.thumb
.syntax unified
.align 1
.p2align 2,,3
.arch armv4t
@PikalaxALT
PikalaxALT / moves.tsv
Created December 18, 2018 14:28
All moves in gen 2 and whether they are considered damaging by bingo rules
Name Effect Power Type Accuracy PP Effect chance Is damaging?
POUND EFFECT_NORMAL_HIT 40 NORMAL 100 35 0 TRUE
KARATE_CHOP EFFECT_NORMAL_HIT 50 FIGHTING 100 25 0 TRUE
DOUBLESLAP EFFECT_MULTI_HIT 15 NORMAL 85 10 0 TRUE
COMET_PUNCH EFFECT_MULTI_HIT 18 NORMAL 85 15 0 TRUE
MEGA_PUNCH EFFECT_NORMAL_HIT 80 NORMAL 85 20 0 TRUE
PAY_DAY EFFECT_PAY_DAY 40 NORMAL 100 20 0 TRUE
FIRE_PUNCH EFFECT_BURN_HIT 75 FIRE 100 15 10 TRUE
ICE_PUNCH EFFECT_FREEZE_HIT 75 ICE 100 15 10 TRUE
THUNDERPUNCH EFFECT_PARALYZE_HIT 75 ELECTRIC 100 15 10 TRUE