A83: Re: Clearing & xoring rectangles
[Prev][Next][Index][Thread]
A83: Re: Clearing & xoring rectangles
The easiest, smallest, and of course, slowest way is to use the _iLine rom
call. STYLE is the type of line you want to draw (0 = off, 1 = on, 2 =
XOR/reverse). I am assuming here that _iLine doesn't destroy any important
registers (meaning anything other than AF). If it does, add a few pushes
and pops:
ld bc,(10<<8)+10 ; p1 = 10,10
ld de,(30<<8)+30 ; p2 = 30,30
ld h,STYLE ; 0 = off, 1 = on, 2 = xor
Box: ; IN: p1 = b,c p2 = d,e h = style
ld l,d ; save p2x
ld d,b ; left side
call _iLine ; *draw line
ld d,l ; restore p2x
ld l,e ; save p2y
ld e,c ; top side
call _iLine ; *draw line
ld e,l ; restore p2y
ld l,b ; save p1x
ld b,d ; right side
call _iLine ; *draw line
ld b,l ; restore p1x
ld c,e ; bottom side
call _iLine ; *draw line
; if you call this as a routine, add a RET here
What this does is simple. It uses the rom's line drawing routine four times
to draw the four sides of the box. The L register is used to save the coord
that is changed for each line.
This will work fine if you only need to draw a few boxes at a time, like for
a title screen or something. But this is way too slow to be used in the
middle of a game as a general purpose box drawing routine. The reason for
this is the use of _iLine. First, it's a rom call. Rom calls are slow,
because the correct rom page must be loaded before the actual routine is
called. The second reason is that the routine can set, reset, or xor
pixels. Being a rom routine, it does not do self-modifying code to change
the actual pixel setting instruction (between OR, AND, XOR), and I would
doubt that they have a separate routine for each type of line. The next is
that _iLine is a general purpose line drawing routine, and it is not
specifically designed to just draw horizontal or vertical lines which a fast
box drawing routine needs. These types of lines can usually be drawn at
least an order of magnitude faster than a normal line, depending the
algorithm used for drawing it. Jimmy Mardell's has an excellent
implementation of Bresenham's algorith, and he worked the inner loop down to
between 98.5 and 106.75 t's. I would doubt that the rom routine is that
well coded, making it even more important to use a special horizontal and
vertical algorithm.
I wrote a fairly decent box drawing routine a while back. If someone wants
it, email me (not the list) and I'll port it to the 83. Sorry about the
rant, but I'm kind of a fanatic when it comes to fast graphics code. ;-)
TANSTATFC!
-----Original Message-----
From: Henry Davidowich <rdaneelolivaw@hotmail.com>
To: assembly-83@lists.ticalc.org <assembly-83@lists.ticalc.org>
Date: Saturday, October 24, 1998 11:38 PM
Subject: A83: Clearing & xoring rectangles
>
>OK, lets say I have the top left and bottom right coordinates of a
>rectangle. I want to reset every pixel in that rectangle; how? I want
>to xor every pixel in that rectangle; how? Thanks!
>
>______________________________________________________
>Get Your Private, Free Email at http://www.hotmail.com