[A83] Re: variable horizontal line routine?
[Prev][Next][Index][Thread]
[A83] Re: variable horizontal line routine?
Just some general ideas for optimizing it a bit:
horizline:
;42 bytes
;c = x, l = y
ld h,0
add hl,hl ; * 2
add hl,hl ; * 4
ld d,h
ld e,l
add hl,hl ; * 8
add hl,de ; * 12
ld a,c
rra
rra
rra
and %00011111 ; x / 8
ld e,a
ld a,12
sub e ;get number of bytes left in row
push af ;save it
add hl,de ;add x component
ld de,graphbuf ;whatever that address is ;-)
add hl,de
ld a,c
cpl
and %00000111
inc a ;shift 1-8 times depending on x value
ld b,a
xor a
getbitmask:
sl1 a ;undocumented opcode ;-)
djnz getbitmask
pop bc ;number of bytes left in row
copybytes:
ld (hl),a
inc hl
ld a,$ff ;write $ff to all the other bytes
djnz copybytes
ret
In a message dated Fri, 1 Jun 2001 8:19:47 AM Eastern Daylight Time, Olle Hedman <oh@hem.passagen.se> writes:
<<
At 12:32 2001-06-01, you wrote:
>ok, this should work, and should be fast enough, if you want you could
I'm sorry, but that is a _really_ crappy horiz-line routine.
It is about as slow as you can make a horiz-lineroutine. It is even quite
possible that useing the rom linedrawingroutine is much faster.
what you should do is find the byte in screenram where the line should start,
with the formula x/8 + y*12 (12 is the width of the buffer in bytes)
then find wich pixel it starts on, and then fill this part of a byte, and
then do bytewrites directly to the mem.
something along these lines: (Sorry, havn't even touched an 83 in 2 years,
and almost not used any z80 so it could be a bit of here and there, but
approx this: (its heavily based on my pixelplotting routine I posted in
this list about 2* years ago or so)
input: a=x e=y
ld d,0 ; Do y*12
sla e
sla e
ld hl,0
add hl,de
add hl,de
add hl,de
ld d,0 ; Do x/8
ld e,a
srl e
srl e
srl e
add hl,de
ld b,e ; save bytexpos in b too.
ld de,graphbuf <-- or whatever. the adress of the graphbuf
anyway.
add hl,de ; Add address to graphbuf
ld de,0007h ; Get the remainder of x/8
and e
ld e,a
ld IX,pixtable ; Look up in table where line should start
add IX,de
ld a,(IX+0) ; and load this
ld (HL),a
ld a,12 <--- maybe this should be 11 or something.
sub b
ld b,a
loop:
inc HL
ld (HL),0ffh <--- you can do this can't you?
djnz loop
ret
pixtable
.db 11111111b
.db 01111111b
.db 00111111b
.db 00011111b
.db 00001111b
.db 00000111b
.db 00000011b
.db 00000001b
------
Ok. this should work, untested now though. if it doesn't work it should
with just a minor bugfixing. (I can help you bugfix if you want)
And this can at least claim to be fast. Maybe you can do it even faster,
but I don't think it is possible to do it much faster.
///Olle
>>
Follow-Ups: