Skip to content

Instantly share code, notes, and snippets.

View magical's full-sized avatar
🙀
🐛

Andrew Ekstedt magical

🙀
🐛
View GitHub Profile
package main
import (
"fmt"
"io"
"os"
)
func main() {
if len(os.Args) != 4 {
// Project euler #16
#include <stdio.h>
int digits[1000] = {1};
int len = 1;
void fold() {
int i, carry = 0;
for (i = 0; i < len; i++) {
; arguments
; ???
; ???
; target pokemon
; ball
; shakes (out param)
; crit (out param)
; output
; returns whether capture succeeded
; [r4] number of shakes
@magical
magical / xy-capture.txt
Last active August 29, 2015 14:11
Pokémon X capture routine analysis
; Pokemon X capture routine
; DllBattle.cro .text+0x2ee40
; tl;dr everything is pretty much the same
; but with more floating point.
; there are four shake checks again instead of three
; and the fourth root is now a 16/3 root.
; looks like we're going to use a truly staggering number of registers
2ee40: e92d4fff push {r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, lr}
>>> f = open("X/exefs/code.bin", 'rb')
>>> data = []
>>> for i in range(1, 65):
... _ = f.seek(0x4467d8 + i*22)
... data.append(f.read(22))
...
>>> text = [line.strip() for line in open("xy/rips/text/en/141")]
>>> for d in data: text[d[12]], struct.unpack("<H", d[18:20])[0]
...
('Hatching Power Lv. 1', 125)
@magical
magical / gist:b89789fe20d36885b646
Created April 14, 2015 06:23
Form differences
Pichu: pokeathlon
Unown: pokeathlon
Castform: pokeathlon, type, moves (level-up)
Deoxys: effort, pokeathlon, stats, moves (level-up, tutor)
Burmy: pokeathlon
Wormadam: effort, pokeathlon, stats, type, moves (level-up, machine, tutor)
Cherrim: pokeathlon
Shellos:
Gastrodon:
Rotom: exp, pokeathlon, stats, type, moves (form-change)
import re
import time
quotefix_re = re.compile(
r'''
^(
(?:
(?:
(?:[^\n\\"]|(?:\\{2})*\\"|\\[^\n"])*
(?:\\{2})*
# NOT A TUPLE
1 # NOT A TUPLE
1, 2 # a 2-tuple
1, 2, 3 # a 3-tuple
, # SYNTAX ERROR
1, # a 1-tuple
1, 2, # a 2-tuple
1, 2, 3, # a 3-tuple
@magical
magical / add.c
Created May 11, 2015 19:45
gcc and -Wconversion
// gcc 4.9.2
// gcc -Wconversion -c add.c
unsigned char x;
void foo(unsigned char y) {
x += y; // warning: conversion to ‘unsigned char’ from ‘int’ may alter its value
}

Keybase proof

I hereby claim:

  • I am magical on github.
  • I am magical (https://keybase.io/magical) on keybase.
  • I have a public key whose fingerprint is 63F7 C160 A01D F8D0 00CF 58E2 C0C0 B6A4 6234 3062

To claim this, I am signing this object: