module ZXLib::Gfx
A module with Z80
Macros
for common ZX Spectrum graphics tasks¶ ↑
Example:
require 'zxlib/gfx' class Program include Z80 macro_import ZXLib::Gfx # invert pixel at 100, 100 ld l, 100 ld a, 100 xytoscr(a, l, ah:h, al:l, s:b, t:c) inc b ld a, 1 shift1 rrca djnz shift1 xor [hl] ld [hl], a ret end
The coordinate system.¶ ↑
All of the Gfx
routines, including Bobs
, Clip
, Draw
, and Sprite8
, are using the following screen coordinates system:
-
The coordinates (0,0) are indicating the top-left corner of the screen.
-
The vertical axis (y) is inversed - y increases towards the bottom of the screen. Hence e.g. 191 is the last visible pixel line and 23 is the last visible attributes cell row at the bottom.
-
The horizontal axis (x) is normal - x increases towards the right edge of the screen. Hence e.g. 255 is the last visible pixel column and 31 (or 63 in hi-res) is the last visible cell column on the far right.