Skip to content

Instantly share code, notes, and snippets.

@davidblackuk
davidblackuk / space.z80
Created March 18, 2018 14:39
How to convert a zx spectrum, x, y coordinate to a screen address via a lookup table. See http://www.overtakenbyevents.com/lets-talk-about-the-zx-specrum-screen-layout-part-three/
; IN - B = pixel row (0..191)
; IN - C = character column (0..31)
; OUT - HL = screen address
; OUT - DE = trash
coords_to_address:
ld h, 0
ld l, b ; hl = row
add hl, hl ; hl = row number * 2
ld de, screen_map ; de = screen map
add hl, de ; de = screen_map + (row * 2)