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:
;============================================
;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?
You should try to somehow use the auto-increment for this. Like read the 64 bytes and save to memory, then run through them, drawing the line and outputting. Horizontal should be simple, just write $ff to 12 screen bytes.

Edit: Also, you shouldn't rotate the mask each time through the loop, just do it before the loop starts. And try doing

Code:
set 7,e
instead of
Code:
ld a,e
add a,$80
ld e,a


Edit2: Now I see what you were saying about horizontal, you don't necessarily want to do it across the whole screen. Then scrap the "64" above and replace it with "b".
someone suggested that I make a copy of the buffer and draw to that, then I could revert to the old buffer to 'erase' the line. Would this be just as effective (size and speed wise)? I tried it and it's definitely faster, but i'm not sure if it's worth the 768 bytes extra just for the extra buffer.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement