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
#include <stdio.h>
#include <getopt.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
struct Section {
unsigned short end;
bool invalid;
char * name;
import asyncio
import discord
from discord.ext import commands
from collections import Counter
class FooCog:
THUMBS_UP = '\U0001ff4d'
THUMBS_DOWN = '\U0001ff4e'
@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)
APCGX7rC47Q43Cpp4Y8E9sHsJWJPlVzbUyRCbxcRHCEkb4na8b3e6LPZ
F7RXzOZn-I846wC8K-ajSNH2B0PX1U9GWcxG5tsx102uC_0jPsLsVqUU
GdAUOqrmHXOPu5ciaQ6ARunk9EYVx2jNH6o9N2cxIUbEL06e5a75oW5J
mR2ruEhtEz6TTvUDJ46tEieWq1QD_909sVCleLz_4BK8C3RnTVoEifvk
B_r2L9YaQGI8EgtN3EUaNvC329BeGP0FxznOOB28fwz5Y9HBX_eEvy25
vdYw1EvfJLlWxCM4XHwzhXN9zyANs7-3dlHOjXTG0cr8KcJ5W2juJNw1
udF91MCBjyJjpi3_8FQ08YW2w38ndZ7CsIHjcjdVk8A1S1BUGEAslnxB
a8b3FcCM9t4wGQbcDTT2XschjREgz2rWha4bSnhMRTCaAr3h2vebTly6
GkyBAZhQHKl-xwQfFDT016lKrhCNtVygxYy6vXFMWVyBqJwldq7gvy7z
YJvwS1mASoOfW1AJpcMLWL317bLSq1kaJk-7JRgzrqyJSEclWNkBQ2P5
@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
@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
# 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