Re: A82: Drawing a box
[Prev][Next][Index][Thread]
Re: A82: Drawing a box
In a message dated 98-04-16 22:21:16 EDT, you write:
> Can someone help me write a simple routine that draws a "white" box on
> the screen? The box can't just be an outline 'cuz it'll be drawn on a
> black background. The inputs should be the upper left-hand corner and the
> bottom right-hand corner (which ever's easier). Feel free to use any
> registers you like. Thanks a bundle
let's say that the input is (d,e) - top left and (h,l) - bottom right. All
you do is make a routine that calculates the distance from d to h (a simple
subtraction will do) and loop from d that many times (store it in b, and you
can use djnz). then, for each loop, erase a line of pixels from e down to l,
effectively creating a loop nested within a loop. Use a routine like the one
below:
ErasePixel:
call FIND_PIXEL
ld de, GRAPH_MEM
add hl, de
cpl
and (hl)
ld (hl), a
ret
If you want the coordinates to start at the top left instead of the bottom
left, include this:
ld a, 63
sub c
ld c, a
Note: when you call it you must take your coords and put them into b and c.
This obviously works with the graph mem, so if you want to use the LCD you
will have to use a different routine to erase the pixel.
Please tell me if I did anything wrong!
~Adamman