Skip to content

Instantly share code, notes, and snippets.

View leiradel's full-sized avatar

Andre Leiradella leiradel

View GitHub Profile
@leiradel
leiradel / ula.c
Last active June 30, 2024 20:25
ULA commands for frame generation and CPU control
#pragma once
/*#
# ula.h
A ZX Spectrum ULA emulator in a C header.
Do this:
~~~C
#define CHIPS_IMPL
~~~
@leiradel
leiradel / ula_screen.md
Created July 12, 2024 14:51
ULA screen line timing
T-State Area Latch Write
0 left border mask 1 (border) latch 0 bits 7 and 6
1 left border attr 1 (border) latch 0 bits 5 and 4
2 left border latch 0 bits 3 and 2
3 left border latch 0 bits 1 and 0
4 left border latch 1 bits 7 and 6
5 left border latch 1 bits 5 and 4
6 left border mask 0 (border) latch 1 bits 3 and 2
7 left border attr 0 (border) latch 1 bits 1 and 0
@leiradel
leiradel / listbasic.c
Created March 5, 2026 18:10
A small function that creates a listing of a ZX Spectrum BASIC program
// Original code by Mike Daley
// License: MIT
std::string listbasic(const Memory& mem, uint64_t offset) {
uint64_t size = mem.size();
std::string listing;
while (offset + 4 <= size) {
uint16_t const lineNumber = mem.peekU16BE(offset);
uint16_t const lineLength = mem.peekU16LE(offset + 2);