Skip to content

Commit 32abda2

Browse files
ZERICO2005mateoconlechuga
authored andcommitted
optimized compare in circle routines
1 parent 27b4ca6 commit 32abda2

1 file changed

Lines changed: 19 additions & 31 deletions

File tree

src/graphx/graphx.asm

Lines changed: 19 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1645,32 +1645,28 @@ _Circle:
16451645
inc bc
16461646
ld (iy - 3), bc
16471647
ld bc, (iy - 9)
1648+
ld hl, $800000
16481649
or a, a
1649-
sbc hl, hl
16501650
sbc hl, bc
1651-
jp m, .cmp0
1652-
jp pe, .cmp1
1653-
jr .cmp2
1654-
.cmp0:
1655-
jp po, .cmp1
1656-
.cmp2:
16571651
ld hl, (iy - 3)
1652+
jp pe, .cmp1 ; BC > 0
1653+
; BC <= 0
1654+
.cmp2:
16581655
add hl, hl
16591656
inc hl
16601657
add hl, bc
1661-
jr .next
1658+
jr .loop
16621659
.cmp1:
16631660
ld bc, (iy - 6)
16641661
dec bc
16651662
ld (iy - 6), bc
1666-
ld hl, (iy - 3)
16671663
or a, a
16681664
sbc hl, bc
16691665
add hl, hl
16701666
inc hl
16711667
ld de, (iy - 9)
16721668
add hl, de
1673-
.next:
1669+
.loop:
16741670
ld (iy - 9), hl
16751671
ld bc, (iy - 3)
16761672
ld hl, (iy - 6)
@@ -1706,7 +1702,7 @@ gfx_Circle:
17061702
inc hl
17071703
sbc hl, bc ; HL = 1 - BC
17081704
call gfx_Wait
1709-
jr _Circle.next
1705+
jr _Circle.loop
17101706

17111707
;-------------------------------------------------------------------------------
17121708
_FillCircle:
@@ -1772,33 +1768,29 @@ _FillCircle:
17721768
ld bc, (ix - 3)
17731769
inc bc
17741770
ld (ix - 3), bc
1775-
ld bc, (ix - 9)
1771+
ld bc, (hl) ; ld bc, (ix - 9)
1772+
ld hl, $800000
17761773
or a, a
1777-
sbc hl, hl
17781774
sbc hl, bc
1779-
jp m, .cmp0
1780-
jp pe, .cmp2
1781-
jr .cmp1
1782-
.cmp0:
1783-
jp po, .cmp2
1784-
.cmp1:
17851775
ld hl, (ix - 3)
1776+
jp pe, .cmp2 ; BC > 0
1777+
; BC <= 0
1778+
.cmp1:
17861779
add hl, hl
17871780
inc hl
17881781
add hl, bc
1789-
jr .cmp3
1782+
jr .loop
17901783
.cmp2:
17911784
ld bc, (ix - 6)
17921785
dec bc
17931786
ld (ix - 6), bc
1794-
ld hl, (ix - 3)
17951787
ld de, (ix - 9)
17961788
or a, a
17971789
sbc hl, bc
17981790
add hl, hl
17991791
inc hl
18001792
add hl, de
1801-
.cmp3:
1793+
.loop:
18021794
ld (ix - 9), hl
18031795
ld bc, (ix - 3)
18041796
ld hl, (ix - 6)
@@ -1837,7 +1829,7 @@ gfx_FillCircle:
18371829
ld (ix - 3), hl
18381830
inc hl
18391831
sbc hl, bc ; HL = 1 - BC
1840-
jr _FillCircle.cmp3
1832+
jr _FillCircle.loop
18411833

18421834
;-------------------------------------------------------------------------------
18431835
_FillCircle_NoClip:
@@ -1898,16 +1890,13 @@ _FillCircle_NoClip:
18981890
inc bc
18991891
ld (ix - 3), bc
19001892
ld bc, (ix - 9)
1893+
ld hl, $800000
19011894
or a, a
1902-
sbc hl, hl
19031895
sbc hl, bc
1904-
jp m, .cmp0
1905-
jp pe, .cmp2
1906-
jr .cmp1
1907-
.cmp0:
1908-
jp po, .cmp2
1909-
.cmp1:
19101896
ld hl, (ix - 3)
1897+
jp pe, .cmp2 ; BC > 0
1898+
; BC <= 0
1899+
.cmp1:
19111900
add hl, hl
19121901
inc hl
19131902
add hl, bc
@@ -1916,7 +1905,6 @@ _FillCircle_NoClip:
19161905
ld bc, (ix - 6)
19171906
dec bc
19181907
ld (ix - 6), bc
1919-
ld hl, (ix - 3)
19201908
or a, a
19211909
sbc hl, bc
19221910
add hl, hl

0 commit comments

Comments
 (0)