Skip to content

Instantly share code, notes, and snippets.

View megakode's full-sized avatar

Peter Boné megakode

View GitHub Profile
@megakode
megakode / general_instructions.h
Created March 2, 2022 20:58
Gameboy DAA instruction
// DAA
// opcode: 0x27
// cycles: 4
// flags: Z H C
void CPU::daa(){
if (!getFlag(FlagBitmaskN)) { // after an addition, adjust if (half-)carry occurred or if result is out of bounds
if (getFlag(FlagBitmaskC) || regs.A > 0x99) { regs.A += 0x60; setFlag(FlagBitmaskC,true); }
if (getFlag(FlagBitmaskHalfCarry) || (regs.A & 0x0f) > 0x09) { regs.A += 0x6; }
@megakode
megakode / StickyHeadersCollectionViewFlowLayout.m
Last active September 20, 2022 10:06 — forked from randomsequence/StickyHeadersCollectionViewFlowLayout.m
A subclass of UICollectionViewFlowLayout which has UITableView style sticky headers.
// StickyHeadersCollectionViewFlowLayout
//
// A subclass of UICollectionViewFlowLayout which has UITableView style sticky headers.
//
// This code is based on Evadne Wu's code^1, with the following changes:
//
// * Fixes a crash for sections with zero items
// * Adds support for UIScrollView's contentInset
// * Adds support for UICollectionViewFlowLayout's sectionInset
//