Re: A86: Line routines


[Prev][Next][Index][Thread]

Re: A86: Line routines




if the x position is a multiple of 8 then it's on a byte boundry.  each
pixel is 1 bit, so 8 pixels are in one byte.  the screen is 128/8 or 16
bytes wide.  pixels 0-7 are in the first byte, 8-15 in the second, and so
on.  if both ends of a horizontal line are a multiple of 8 then you're
only filling entrie bytes and since the processor deals primarily in
bytes filling an entire byte at once is easy.

actually, the left should be a multiple of 8 and the right one less than
a multiple of 8.

the 8-pixels-in-a-byte rule is also important for getting the memory
location of a particular pixel.  i would imagine that most people new to
asm would use findpixel everywhere, but it's much better if you can
precalculate these.  here's how it works, the screen starts at $fc00. 
start with that.  each row is 16 (or $0010) bytes, so add y*16.  now
every 8 pixels starts a new byte, so add x/8.  this gives you the byte
address, but it refers to 8 pixels, not just one.  getting down to
individual pixels is a little tricky because the processor normally deals
in entire bytes.

so to draw a horizontal line on row 4 from column 40 to 95, you'd do
this:
	ld a,$ff		;8 pixels on
	ld hl,$fc45		;starting location
	ld b,7-1		;width-1
hloop:	ld (hl),a
	inc hl
	djnz hloop
	ld (hl),a

-josh

>
>The lines will not move at all, and I have no idea what you mean by a 
>byte 
>boundary.  Can you comment this, so I know what I am looking at?  
>Thanks.
>
>.db "Patrick Gray",0
>

___________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com/getjuno.html
or call Juno at (800) 654-JUNO [654-5866]