yes, i have yet another routine that needs optimizing. This time it's drawing a vertical line to the screen (not the buffer). Here it is:
Code:
It is currently at 77 bytes, and I would really like to shave it down. If it is as efficient (speed and size, size first) it can get, please tell me so I know!
On another note, I'm having troubles coming up with a routine that does the same thing on the horizontal. Could someone direct me down the right path?
Code:
;============================================
;vertical
;============================================
;
;test routine for drawing a vertical line to the screen
;
;inputs:
; de: coord1 (top)
; b: length
;
;TODO: make smaller and faster
;
vertical:
di ;we need interrupts off for this
;get starting row
ld a,e
add a,$80
ld e,a
;get starting column
ld a,d
srl a ;divide by 8
srl a
srl a
add a,$20
ld h,a ;save column
ld a,d
and %00000111 ;offset for line shift
ld l,a
vdraw:
ld c,%10000000
ld a,l ;see how we are on drawing
or a
jr z,vSkip1
vLoop2: ;else, we need to shift it
srl c ;shift c
dec a
jr nz,vLoop2 ;keep shifting it it's not zero
vSkip1:
;get right row
ld a,e
call $000B
out ($10),a
;get right column
ld a,h
call $000B
out ($10),a
call $000B ;dummy read
in a,($11)
call $000B
in a,($11)
or c ;doesn't erase everything else
;now we have to re-put coordinates in right place
ld c,a
;get right row
ld a,e
call $000B
out ($10),a
;get right column
ld a,h
call $000B
out ($10),a
ld a,c ;needs to be in acc to draw to screen
call $000B
out ($11),a ;write it to screen
inc e ;go to next row
djnz vdraw ;repeat for how ever long we need to
ei ;enable interrupts because we turned them off
ret
It is currently at 77 bytes, and I would really like to shave it down. If it is as efficient (speed and size, size first) it can get, please tell me so I know!
On another note, I'm having troubles coming up with a routine that does the same thing on the horizontal. Could someone direct me down the right path?