Re: A85: FLine


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

Re: A85: FLine




At 12:28 1998-05-18 EDT, you wrote:
>
>Would I be able to save any memory by modifying the source rather than by
>just adding a few lines of code?

Ah, well, you wouldn't have to write those instructions + another byte
saved actually. OK, here's the source (again) with clock cycles
in the inner loop. This is - again - the 86 source (I seem to have lost
the 85 source :-/) and it's slightly different. It uses BC = video mem
when calling.

FLine:
 push bc
 push de
 push hl
 push bc
 ld a,h
 cp d
 jr nc,DXpos
 ex de,hl
DXpos:
 ld b,d
 ld c,e
 pop de
 push hl
 call FindPixel
 add hl,de
 ex (sp),hl
 ld e,c
 ld c,a
 ld a,h
 sub b
 ld b,a
 ld a,l
 sub e
 ld de,16
 jr nc,DYpos
 neg
 ld de,-16
DYpos:
 push af
 sub b
 jr nc,DY_Greater
 add a,a
 neg
 ld (x_ai+1),a
 pop af
 add a,a
 ld (XDNeg+1),a
 sub b
 pop hl
 push af
 ld a,c
 or (hl)
 ld (hl),a
 pop af
 bit 7,a
 jr nz,XDNeg
XNewRow:
 add hl,de        ; 11
x_ai:
 sub 0            ; 7
 push af          ; 11
 rrc c            ; 8
 jr nc,XNoWrap1   ; 7 / 12  \
 inc hl           ; 6       / 12.5
XNoWrap1:
 ld a,c           ; 4
 or (hl)          ; 7
 ld (hl),a        ; 10
 pop af           ; 10
 dec b            ; 4
 jr z,LineDone    ; 7
 jr nc,XNewRow    ; 7 / 12  ==> 101
XDNeg:
 add a,0          ; 7
 push af          ; 11
 rrc c            ; 8
 jr nc,XNoWrap2   ; 7 / 12  \
 inc hl           ; 6       / 12.5
XNoWrap2:
 ld a,c           ; 4
 or (hl)          ; 7
 ld (hl),a        ; 10
 pop af           ; 10
 dec b            ; 4
 jr z,LineDone    ; 7
 jr c,XNewRow     ; 7 / 12  \
 jr XDNeg         ; 12      / 15.5    ==> 96   ==> 98.5
DY_Greater:
 neg
 add a,a
 ld (YNoWrap+1),a
 ld a,b
 add a,a
 ld (YDNeg+1),a
 pop hl
 sub h
 ld b,h
 pop hl
 push af
 ld a,c
 or (hl)
 ld (hl),a
 pop af
YRepeat:
 bit 7,a          ; 8
 jr nz,YDNeg      ; 7 / 12
 rrc c            ; 8
 jr nc,YNoWrap    ; 7 / 12  \
 inc hl           ; 6       / 12.5
YNoWrap:
 add a,0          ; 7
 jr YPlot         ; 12
YDNeg:
 add a,0          ; 7
YPlot:            ; ==> 40.75
 add hl,de        ; 11
 push af          ; 11
 ld a,c           ; 4
 or (hl)          ; 7
 ld (hl),a        ; 10
 pop af           ; 10
 djnz YRepeat     ; 13  ==> 106.75
LineDone:
 pop hl
 pop de
 pop bc
 ret

--
Real name: Jimmy Mårdell                "can't go mucking with a 'void *'"
IRC......: Yarin                                // Apple's MPW C compiler
Email....: mailto:yarin@acc.umu.se        
Homepage.: http://www.algonet.se/~mja/


References: