Skip to content

Instantly share code, notes, and snippets.

View CT075's full-sized avatar

Cameron Wong CT075

View GitHub Profile
import itertools as it
def read_little_endian_word(xs):
result = 0
for x in reversed(xs):
result <<= 8
result += x
return result
def read_pointer(xs):
PUSH
// DifficultySelect_Init
// - proc->unk_30 = 0
// + proc->unk_30 = 1
//
// Change the initial state of the difficulty select proc to Normal mode.
//
// TECHNICAL NOTES:
// The compiler actually optimized a 0-write to both unk_30 and unk_2c to use
(* Heterogeneous ("universal") maps.
*
* Keys are represented as the type ['a Key.t], where the ['a] is the type of
* the value stored at that key.
*)
structure Univ_map : sig
structure Key : sig
type 'a t
val create : unit -> 'a t
(* Submitter nickname: JCB *)
(* Submission begins HERE *)
(**
typedef struct stack_header stack_t;
struct stack_header {
list* top;
list* floor;
};
signature PRICES =
sig
datatype tix = OH | BC | SK
val price : tix -> int
end
signature CART =
sig
(* Implementation of Conway's GOL with red/blue cells as specified by
* /r/dailyprogrammer's Intermediate challenge #315
*)
structure Conway =
struct
(* this seed is fixed, because SML *sucks* and there's no way to get the
* system time that I could find.
*)
@CT075
CT075 / hitcrit.asm
Created December 16, 2016 16:47
hitcrit by hand
CRIT_ST:
push {r3-r4, lr}
mov r2, r0 @ r0 = 0203A3F0, attacker
mov r3, r0 @
add r2, #0x60 @ 0x60 = index of attacker hit
add r1, #0x62 @ 0x62 = index of defender avo
ldrh r2, [r2] @ load
ldrh r1, [r1] @
sub r1, r2, r1 @ calc final hit
mov r2, r0 @
@CT075
CT075 / hitcrit_c.asm
Created December 16, 2016 16:46
hitcrit via gcc
hitToCrit:
movs r3, #96
push {r4, lr}
ldrh r4, [r0, r3]
adds r3, r3, #2
ldrh r2, [r1, r3]
movs r3, #0
cmp r4, r2
bcc .L2
subs r3, r4, r2
@CT075
CT075 / makeROM
Last active May 23, 2016 17:20
sample syntax for romhacking makefile
// Order to do stuff
ROMHack: text gfx events asm bin
// Commands
events:
assemble prologue_events
text:
inserttext prologue_1
inserttext prologue_2
#!/usr/bin/python
for _ in range(5):
s,*gs=[bin(i)[2:].zfill(3)for i in tuple(map(int,input().split(', ')))]
print('\t'.join(map(' '.join, (gs,[''.join((('rwsrwsrwt'[i*3:i*3+3])if int(s[::-1][i])else'rwx')[j]if int(g[j])else'-'for j in range(3))for i,g in enumerate(gs)]))))