Skip to content

Instantly share code, notes, and snippets.

@mrorigo
mrorigo / cpu.c
Last active October 9, 2022 14:21
Cycle exact 6502 (2A03) emulator in <1k lines of C
/**
* Copyright (C) 2022 orIgo <[email protected]>
*
* Cycle exact 6502 (2A03) emulator.
*
* - To initialize the cpu, provide an initialized `cpu_bus_t *` with memory read/write primitives to `cpu_init()` .
* - For each tick/cycle, call `cpu_tick()` with the returned `cpu_t *`, checking the return value to detect HLT.
* - To cause an NMI request, call `cpu_nmi()`.
*/
#include "cpu.h"