Re: A85: FIND_PIXEL


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

Re: A85: FIND_PIXEL



Michael Pearce wrote:
> 
> Find_Pixel basically works like this.  It has 2 inputs.  register b,
> the x position and register c, the y position.  the origin is the
> bottom left hand corner (though most sprite routines use the origin as
> the top left).  It then returns a value in hl which is the *byte*
> offset in memory.  Every 8 pixels on the screen make up a byte.  For
> each row of the video memory, there are 128 pixels.  So this means
> that there are 16 bytes in a row of video memory.  So to move over 8
> pixels in the x direction (from the origin), add one byte to hl.  To
> move up one row (from the origin) add 16 to hl.  

Actually subtract 16 to go up one row, add 16 to go down a row. The memory 
goes from top to bottom which is why most sprite routines use an origin in 
the top left corner. And don't forget to use

	ld	de,$fc00
	add	hl,de
after calling FIND_PIXEL. 
To understand really how the video mem works, you need to visualize it:
byte--	+$01	  +$02	     +$03	...etc
bit--	76543210 | 76543210 | 76543210  ...
row
$fc00	XpixelsX   XXXXXXXX   XXXXXXXX	...
$fc10	XXXXXXXX   XXXXXXXX   XXXXXXXX  ...
$fc20	XXXXXXXX   XXXXXXXX   XXXXXXXX  ...

Now, Find_PIXEL also resets all but one of the bits in reg a,which is the BIT 
in the chart above. So here's some useful routines:
PixelOn:
	ROM_CALL_(FIND_PIXEL)
	ld	de,$fc00
	add	hl,de
	or	(hl)
	ld	(hl),a
PixelOff:
	ROM_CALL_(FIND_PIXEL)
	ld	de,$fc00
	add	hl,de
	cpl
	and	(hl)
	ld	(hl),a
PixelChange:
	ROM_CALL_(FIND_PIXEL)
	ld	de,$fc00
	add	hl,de
	xor	(hl)
	ld	(hl),a
PixelTest:
	ROM_CALL_(FIND_PIXEL)
	ld	de,$fc00
	add	hl,de
	and	(hl)
	;z flag set means pixel is off
For plotting non aligned sprites, use one of many routines available at 
ticalc.org. For aligned sprites, use a direct memory access routine, probably 
also available at ticalc.org. And don't forget to set ROM page 4 before 
calling FIND_PIXEL!

	ld	a,4
	out	(5),a

I hope that answers all of your questions.

> On Tue, 19 Aug 97 13:23:00 -0500, you wrote:
> 
> >I've already read the ZShell Function Library and would like to use
> >FIND_PIXEL.  The explanation provided was not very clear and I'd
> >appreciate if someone could explain it to me.
> >

-- 
Terry Peng
email-	tpeng@geocities.com
web-	http://www.geocities.com/SiliconValley/Bay/5104/index.html


Follow-Ups: References: