Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- BlackLine:
- call LineIntro ; (l,e) = (x1,y1)
- ret nc ; (c,a) = (x2,y2)
- cp h
- jr c,__BlackLineHoriz ; Line is rather horizontal than vertical
- __BlackLineVert:
- ld b,l ; Pixel counter
- inc b
- rra ; nc at this point so (A=E/2)
- __BlackLineVLoop:
- push af
- ld a,(ix+0)
- or c ; Writing pixel to current position
- ld (ix+0),a
- pop af
- add ix,de
- sub h ; Handling gradient
- jr nc,__BlackLineVNext
- add a,l
- rrc c ; Rotating mask
- jr nc,__BlackLineVNext ; Handling byte boundary
- inc ix
- __BlackLineVNext:
- djnz __BlackLineVLoop
- ret
- __BlackLineHoriz:
- ld b,h ; Pixel counter
- inc b
- ld a,h ; Setting up gradient counter
- srl a
- __BlackLineHLoop:
- push af ; Saving A
- ld a,(ix+0)
- or c ; Writing pixel to current position
- ld (ix+0),a
- pop af ; Recalling A
- rrc c ; Rotating mask
- jr nc,__BlackLineHSkip ; Handling byte boundary
- inc ix
- __BlackLineHSkip:
- sub l ; Handling gradient
- jr nc,__BlackLineHNext
- add a,h
- add ix,de
- __BlackLineHNext:
- djnz __BlackLineHLoop
- ret
- WhiteLine:
- call LineIntro ; (l,e) = (x1,y1)
- ret nc ; (c,a) = (x2,y2)
- push af
- ld a,c
- cpl
- ld c,a
- pop af
- cp h
- jr c,__WhiteLineHoriz ; Line is rather horizontal than vertical
- __WhiteLineVert:
- ld b,l ; Pixel counter
- inc b
- rra ; nc at this point so (A=E/2)
- __WhiteLineVLoop:
- push af
- ld a,(ix+0)
- and c ; Writing pixel to current position
- ld (ix+0),a
- pop af
- add ix,de
- sub h ; Handling gradient
- jr nc,__WhiteLineVNext
- add a,l
- rrc c ; Rotating mask
- jr c,__WhiteLineVNext ; Handling byte boundary
- inc ix
- __WhiteLineVNext:
- djnz __WhiteLineVLoop
- ret
- __WhiteLineHoriz:
- ld b,h ; Pixel counter
- inc b
- ld a,h ; Setting up gradient counter
- srl a
- __WhiteLineHLoop:
- push af ; Saving A
- ld a,(ix+0)
- and c ; Writing pixel to current position
- ld (ix+0),a
- pop af ; Recalling A
- rrc c ; Rotating mask
- jr c,__WhiteLineHSkip ; Handling byte boundary
- inc ix
- __WhiteLineHSkip:
- sub l ; Handling gradient
- jr nc,__WhiteLineHNext
- add a,h
- add ix,de
- __WhiteLineHNext:
- djnz __WhiteLineHLoop
- ret
- LineIntro:
- cp 64
- ret nc
- ld b,a
- ld a,e
- cp 64
- ret nc
- ld d,l
- ld l,b
- ld a,d
- cp 96
- ret nc
- ld a,c
- cp 96
- ret nc
- ld h,a
- sub d
- jr nc,__LineIntroSkipRev
- ex de,hl
- neg
- __LineIntroSkipRev:
- push af ; Saving DX (it will be popped into DE below)
- ld a,d ; IX+=D/8+E*12 (actually E*4+E*4+E*4)
- rra
- rra
- rra
- and %00011111
- ld c,a
- ld b,0
- add ix,bc
- ld a,e
- add a,a
- add a,a
- ld c,a
- add ix,bc
- add ix,bc
- add ix,bc
- ld a,d ; Calculating the starting pixel mask
- and %00000111
- inc a
- ld b,a
- ld a,%00000001
- __LineIntroMaskLoop:
- rrca
- djnz __LineIntroMaskLoop
- ld c,a
- ld a,l ; Calculating delta Y and negating the Y increment if necessary
- sub e ; This is the last instruction for which we need the original data
- ld de,12
- jr nc,__LineIntroSkipNeg
- ld de,-12
- neg
- __LineIntroSkipNeg:
- pop hl ; Recalling DX
- ld l,a ; D=DX, E=DY
- scf
- ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement