Skip to content

Instantly share code, notes, and snippets.

Avatar

merry MerryMage

View GitHub Profile
View tmask_wmask.cpp
#include <optional>
template <typename Fn>
#if defined(_MSC_VER)
__declspec(noinline, noreturn)
#elif defined(__GNUC__)
[[noreturn, gnu::noinline, gnu::cold]]
#endif
static void assert_noinline_call(const Fn& fn) {
fn();
View constructor.cpp
#include <cstdio>
class A {
public:
A() = default;
static void OverridableInit() {
std::printf("I am in A\n");
}
View biquad.hpp
case Type::LowShelf:
if(gain >= 0) {
n = 1 / (1 + k / q + k * k);
a0 = (1 + sqrt(v) / q * k + v * k * k) * n;
a1 = 2 * (v * k * k - 1) * n;
a2 = (1 - sqrt(v) / q * k + v * k * k) * n;
b1 = 2 * (k * k - 1) * n;
b2 = (1 - k / q + k * k) * n;
} else {
n = 1 / (1 + sqrt(v) / q * k + v * k * k);
View high_shelf2.py
import math
import numpy
import matplotlib.pyplot as plt
def IdealH(f):
T = 1. / 441000. # we use the tenfold sampling frequency
OmegaU = 1. / 15e-6
OmegaL = 15. / 50. * OmegaU
# Calculate filter coefficients
V0 = OmegaL / OmegaU
View high_shelf.py
import math
import numpy
import matplotlib.pyplot as plt
def IdealH(f):
T = 1. / 441000. # we use the tenfold sampling frequency
OmegaU = 1. / 15e-6
OmegaL = 15. / 50. * OmegaU
# Calculate filter coefficients
View signatures.cpp
void ADR(Imm<2> immlo, Imm<19> immhi, Reg Rd);
void ADRP(Imm<2> immlo, Imm<19> immhi, Reg Rd);
void ADD_addsub_imm(bool sf, Imm<2> shift, Imm<12> imm12, Reg Rn, Reg Rd);
void ADDS_addsub_imm(bool sf, Imm<2> shift, Imm<12> imm12, Reg Rn, Reg Rd);
void SUB_addsub_imm(bool sf, Imm<2> shift, Imm<12> imm12, Reg Rn, Reg Rd);
void SUBS_addsub_imm(bool sf, Imm<2> shift, Imm<12> imm12, Reg Rn, Reg Rd);
void AND_log_imm(bool sf, bool N, Imm<6> immr, Imm<6> imms, Reg Rn, Reg Rd);
void ORR_log_imm(bool sf, bool N, Imm<6> immr, Imm<6> imms, Reg Rn, Reg Rd);
void EOR_log_imm(bool sf, bool N, Imm<6> immr, Imm<6> imms, Reg Rn, Reg Rd);
void ANDS_log_imm(bool sf, bool N, Imm<6> immr, Imm<6> imms, Reg Rn, Reg Rd);
View arm64 inst
ld1 {v4.s}[1], [x7], #4
fadd v1.2s, v1.2s, v3.2s
sshll v2.4s, v2.4h, #0
sshll v3.4s, v3.4h, #0
fmul v3.2s, v4.2s, v3.s[0]
fcvtzs w12, s0, #0xf
fsqrt s0, s0
frinta s0, s0
fmax d1, d1, d2
fmin d8, d0, d2
@MerryMage
MerryMage / post.md
Last active Jan 8, 2021
Dumping the GBA BIOS
View post.md

Dumping the GBA BIOS

endrift has recently written an article on a new method she discovered for dumping the GBA's BIOS, different from the MidiKey2Freq method currently used. This article is about a third method I've discovered that is different from those two.

I've been having a very recent fascination with the Game Boy Advance. The hardware is simple relative to more complex modern handhelds and the CPU is of an architecture I'm already familiar with (ARM7TDMI), making it a rather fun toy to play with. The GBA is a console where cycle counting is important. In order to learn more about the hardware, I have been reading documentation that others have produced (like Martin Korth's GBATEK) and writing small programs to test edge-cases of the hardware that I didn't quite understand. One example of this was the BIOS ROM.

BIOS Protection

The

View main.c
#include <gba_console.h>
#include <gba_video.h>
#include <gba_interrupt.h>
#include <gba_systemcalls.h>
#include <gba_input.h>
#include <stdio.h>
#include <stdlib.h>
u32* WRAM = (u32*)0x02000000;
@MerryMage
MerryMage / coro.md
Created Jul 10, 2017
Personal Notes on the Coroutines TS
View coro.md