Skip to content

Instantly share code, notes, and snippets.

View ISSOtm's full-sized avatar
🦀
Rewriting RGBDS... In Rust!

Eldred Habert ISSOtm

🦀
Rewriting RGBDS... In Rust!
View GitHub Profile
@ISSOtm
ISSOtm / gb-vwf.sym
Created September 13, 2020 19:17
gb-vwf sym file
; File generated by rgblink
00:0008 WaitVBlank
00:0010 MemsetSmall
00:0018 MemcpySmall
00:0074 MemcpySmall.noVBlank
00:0076 LCDMemcpy
00:0079 LCDMemcpy.loop
00:008c LCDMemsetSmall
00:008d LCDMemsetSmallFromB
00:0099 CharsetPtrs
@ISSOtm
ISSOtm / subnet.py
Created October 9, 2020 21:49
Python script to print info about an IPv4 subnet mask
#!/usr/bin/env python3
import itertools
import sys
if len(sys.argv) < 2:
print(f"Usage: {argv[0]} <subnet mask>\n\tSubnet mask must be in dotted decimal form.", file=sys.stderr)
exit(1)
@ISSOtm
ISSOtm / Makefile
Last active February 20, 2021 23:39
CRC self-test code for Game Boy
$(BINDIR)/game.gb: $(SRCDIR)/tools/crcify.py $(OBJS)
@$(MKDIR) -p $(@D)
$(RGBLINK) $(LDFLAGS) -o $@ $(OBJS)
$(RGBFIX) $(FIXFLAGS) $@
$(RGBASM) $(ASFLAGS) -D'BANK_BYTE=$$'$$(xxd -s 0x148 -l 1 -p $@) -o $(OBJDIR)/crc.o $(SRCDIR)/crc.asm
$(RGBLINK) $(LDFLAGS) -o $@ $(OBJS) \
&& $(RGBFIX) $(FIXFLAGS) $@ \
&& $(PY) $< $@ \
&& $(RGBFIX) $(FIXFLAGS) $@
@ISSOtm
ISSOtm / low_byte.asm
Last active February 24, 2021 21:04
Various routines for subpixel positions, primarily intended for 12.4 format. Code licensed under CC0 license.
; Get the low byte of the integer (pixel) part of a 12.4 precision coordinate
; @param hl A pointer to the coordinate
; @return a The pixel part
; @return Carry Clear
; @return Z Set depending on whether `a` is zero or not
GetPixelsLowByte::
ld a, [hli]
xor [hl]
and $0F
xor [hl]
@ISSOtm
ISSOtm / 2byte_charmaps.asm
Created March 7, 2021 20:00
Macro for shimming 2-byte charmaps
NEWCHARMAP "Low byte"
charmap "A", $12
NEWCHARMAP "High byte"
charmap "A", $34
; ...
@ISSOtm
ISSOtm / bestsci.i
Created March 10, 2021 21:11
INTERCAL program that prints "Arch is the best!" by transcoding ASCII on the fly. Uses C-INTERCAL I/O
PLEASE NOTE THAT THIS WAS MADE FOR C-INTERCAL
PLEASE DO .10 <- #18
PLEASE DO ,10 <- .10
PLEASE DO ,11 <- .10
DO NOT BE AFRAID, THESE ARE ASCII NUMBERS, NOT "TURING TAPE"
DO ,10SUB#1 <- #65
DO ,10SUB#2 <- #114
DO ,10SUB#3 <- #99
DO ,10SUB#4 <- #104
@ISSOtm
ISSOtm / make.log
Created March 14, 2021 15:17
Log of building gb-boilerplate from scratch
issotm@sheik-kitty ~/gb-boilerplate% make -dr [master|✔]
GNU Make 4.3
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Reading makefiles...
Reading makefile 'Makefile'...
Reading makefile 'project.mk' (search path) (no ~ expansion)...
@ISSOtm
ISSOtm / conventions.md
Last active April 11, 2021 17:06
My conventions when writing Game Boy ASM (naming / casing, best practices)

Casing

  • Labels use PascalCase. DrawNPCs, GetOffsetFromCamera.
  • Labels in RAM (VRAM, SRAM, WRAM, HRAM; you shouldn't be using Echo RAM or OAM) use the same convention but are prefixed with the initial of the RAM they're in, in lowercase. wCameraOffsetBuffer, hVBlankFlag, vTilesetTiles, sSaveFileChecksum. Rationale: to know in which memory type the label is; this is important because VRAM and SRAM have special access precautions and HRAM can (should (must)) be accessed using the ldh instruction.
  • Local labels use camelCase, regardless of memory type. (.waitVRAM, wPlayer.xCoord)
  • Macro names use snake_case. wait_vram, rst wait_vblank, end_struct.
  • Constants use CAPS_SNAKE. NB_NPCS, OVERWORLD_STAT_LOAD_MAP.
  • Constants posing as labels use the appropriate label convention.

Best practices

@ISSOtm
ISSOtm / seeds.rs
Last active April 15, 2021 16:01
Seed bruteforcer for ZZAZZ's fools2021
use std::collections::HashSet;
use std::convert::TryInto;
use std::ops::Deref;
use std::sync::{Arc, Mutex};
use std::thread;
const NB_THREADS: usize = 8;
fn main() {
let mut seeds = Arc::new(Mutex::new(HashSet::new()));
@ISSOtm
ISSOtm / seed_bruter.rs
Last active April 15, 2021 16:05
Invocation: `grep '^1' seeds.txt | ./seed_bruter`. Due to a BGB bug, you must copy it to the temp folder that this program creates...
use std::convert::{TryFrom, TryInto};
use std::env::{self, Args};
use std::fs::{self, File};
use std::io::{self, BufRead, BufReader, BufWriter, Read, Stdin, Write};
use std::path::PathBuf;
use std::process::{self, Command, Stdio};
use std::thread;
use std::time::Duration;
const NB_CHILDREN: usize = 8;