Skip to content

Instantly share code, notes, and snippets.

@Angel996
Angel996 / space.z80
Last active April 27, 2020 15:09 — forked from davidblackuk/space.z80
How to convert a zx spectrum, x, y coordinate to a screen address via a lookup table. Forked from David Black's version, shorter, does not trash DE. The modification is based on the fact that character offset maximum value is 0x1F, which means we don't need to use 16-bit addition to add up the X coordinate.
; IN - B = pixel row (0..191)
; IN - C = character column (0..31)
; OUT - HL = screen address
; DE - unaffected
coords_to_address:
ld a, c
ld h, 0
ld l, b ; hl = row
add hl, hl ; hl = row number * 2