Re: LZ: a line source program
[Prev][Next][Index][Thread]
Re: LZ: a line source program
>Here is the source to a new line routine. If you are drawing lines
>vertically or horizontally, this routine is smaller and faster than
>Stephanie's line.asm, and it even includes 2 types of diagonal lines. I've
>been having trouble with Stephanie's line.asm, so I made this. Note: if
>line.asm works for you, and if you want lines that this program doesn't
>support, use Stephanie's source. I'm releasing the source code, so anyone
>can edit it to fit their own uses. Basically it works like this: the
>beginning point is stored in hl, and the ending point is stored in de, with
>the c register determining what type of line to draw. If c is 0, then it
>draws a vertical line from hl (x,y format) to de (actually, d is not even
>used in the vertical line routine, it draws a line from (h,l) to (h,e)). If
>c is 1, it draws a horizontal line from (h,l) to (d,l)- e is not used here.
>If c is 2 or 3, it draws the respective diagonal line from (h,l) to (d,e).
I've got an idea how to make faster horizontal and vertical lines. I have not
tested the source! But it's a pain to assemble programs on the amiga, through
a emulator. I NEED the source for TASM!
Vertline works like this: It does a FIND_PIXEL. HL contains the address of the
byte that contains the first pixel. A is the value to be ored with that
address. Then I do a loop that is executed hight nr of times. It adds 16 to hl
(ie it moves one line down). Then it ores A into that address.
Horizline works like this: It does a FIND_PIXEL for the left dot. Lets say a
contains this: a=00100000 then we save a into d. And dec a. a=00011111. Then
we add a,d. a=00111111. This is what we or out.
Then we do a FIND_PIXEL for the right pixel. lets say a= 00001000. We dec a.
A= 00000111. Then we xor with $ff. a=11111000. This is what we put out.
The only thing left now is to put $ff into all bytes in between, and make them
black.
One warning: Horizline will not work if the two pixels is in the same byte.
This will never happen if they are 8 pixels or more from each other.
Two warnings: These routines has not been tested at all! Please test them, and
remove the bugs, and then you can give me the source again.
Send any questions or comments to me.
Well here it is:
Vertline:
;Draws a line from b,c to b,c+e (e is the hight)
ROM_CALL(FIND_PIXEL)
ld b,0
ld c,e ;bc contains hight
ld de, $fc00
add hl, de
ld de,16 ;This should be added to hl every loop
Vertloop
ld b,a ;save the accumulator
or (hl)
ld (hl),a
ld a,b
ld b,0
djnz Vertloop
ret
;42 cycles per pixel!
Horizline Draws a line from b,c to d,e make sure c=e and b<d
ROM_CALL(FIND_PIXEL)
ld b,d
ld c,e
ld d,a
dec a
or d
ld de, $fc00
add hl, de
or (hl)
ld (hl),a
inc hl
ld d,h
ld e,l
ROM_CALL(FIND_PIXEL)
dec a
xor $ff
ld b,d
ld c,e
ld de, $fc00
add hl, de
or (hl)
ld (hl),a
ld a,l
sub c
jr z,horend
dec hl
ld b,0
ld c,a
ld a,$ff
horloop
ld (HL),a
dec hl
djnz horloop
horend
ret
/Oscar Lindberg
References: