Skip to content

Commit 589a897

Browse files
ZERICO2005mateoconlechuga
authored andcommitted
optimized graphx circle routines by changing jp to jr
1 parent 309e2c5 commit 589a897

File tree

1 file changed

+66
-63
lines changed

1 file changed

+66
-63
lines changed

src/graphx/graphx.asm

Lines changed: 66 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1584,32 +1584,9 @@ _ellipse_line_routine_2 := $-3
15841584
pop hl
15851585
pop hl
15861586
ret
1587-
15881587

15891588
;-------------------------------------------------------------------------------
1590-
gfx_Circle:
1591-
; Draws a clipped circle outline
1592-
; Arguments:
1593-
; arg0 : X coordinate
1594-
; arg1 : Y coordinate
1595-
; arg2 : Radius
1596-
; Returns:
1597-
; None
1598-
ld iy,0
1599-
add iy,sp
1600-
lea hl,iy-9
1601-
ld sp,hl
1602-
ld bc,(iy+9)
1603-
ld (iy-6),bc
1604-
sbc hl,hl
1605-
ld (iy-3),hl
1606-
adc hl,bc
1607-
jp z,.exit
1608-
ld hl,1
1609-
or a,a
1610-
sbc hl,bc
1611-
call gfx_Wait
1612-
jp .next
1589+
_Circle:
16131590
.sectors:
16141591
ld bc,(iy+3)
16151592
ld hl,(iy-6)
@@ -1718,31 +1695,32 @@ gfx_Circle:
17181695
.exit:
17191696
ld sp,iy
17201697
ret
1721-
1722-
;-------------------------------------------------------------------------------
1723-
gfx_FillCircle:
1724-
; Draws an clipped circle
1698+
gfx_Circle:
1699+
; Draws a clipped circle outline
17251700
; Arguments:
17261701
; arg0 : X coordinate
17271702
; arg1 : Y coordinate
17281703
; arg2 : Radius
17291704
; Returns:
17301705
; None
1731-
push ix
1732-
ld ix,0
1733-
add ix,sp
1734-
lea hl,ix-9
1735-
ld sp,hl
1736-
ld bc,(ix+12)
1737-
ld (ix-6),bc
1738-
sbc hl,hl
1739-
ld (ix-3),hl
1740-
adc hl,bc
1741-
jp z,_ResetStack
1742-
ld hl,1
1743-
or a,a
1744-
sbc hl,bc
1745-
jp .cmp3
1706+
ld iy, 0
1707+
add iy, sp
1708+
lea hl, iy - 9
1709+
ld sp, hl
1710+
ld bc, (iy + 9)
1711+
sbc hl, hl
1712+
adc hl, bc ; carry won't be set since HL is zero here
1713+
jr z, _Circle.exit
1714+
ld (iy - 6), bc
1715+
sbc hl, hl
1716+
ld (iy - 3), hl
1717+
inc hl
1718+
sbc hl, bc ; HL = 1 - BC
1719+
call gfx_Wait
1720+
jr _Circle.next
1721+
1722+
;-------------------------------------------------------------------------------
1723+
_FillCircle:
17461724
.fillsectors:
17471725
ld hl,(ix-3)
17481726
add hl,hl
@@ -1844,35 +1822,36 @@ gfx_FillCircle:
18441822
ret
18451823
.check:
18461824
jp po,.fillsectors
1825+
.ResetStack:
18471826
ld sp,ix
18481827
pop ix
18491828
ret
1850-
1851-
;-------------------------------------------------------------------------------
1852-
gfx_FillCircle_NoClip:
1853-
; Draws an unclipped circle
1829+
gfx_FillCircle:
1830+
; Draws an clipped circle
18541831
; Arguments:
18551832
; arg0 : X coordinate
18561833
; arg1 : Y coordinate
18571834
; arg2 : Radius
18581835
; Returns:
18591836
; None
18601837
push ix
1861-
ld ix,0
1862-
add ix,sp
1863-
lea hl,ix-9
1864-
ld sp,hl
1865-
ld bc,(ix+12)
1866-
ld (ix-6),bc
1867-
sbc hl,hl
1868-
ld (ix-3),hl
1869-
adc hl,bc
1870-
jp z,_ResetStack
1871-
ld hl,1
1872-
or a,a
1873-
sbc hl,bc
1874-
call gfx_Wait
1875-
jp .loop
1838+
ld ix, 0
1839+
add ix, sp
1840+
lea hl, ix - 9
1841+
ld sp, hl
1842+
ld bc, (ix + 12)
1843+
sbc hl, hl
1844+
adc hl, bc ; carry won't be set since HL is zero here
1845+
jr z, _FillCircle.ResetStack
1846+
ld (ix - 6), bc
1847+
sbc hl, hl
1848+
ld (ix - 3), hl
1849+
inc hl
1850+
sbc hl, bc ; HL = 1 - BC
1851+
jr _FillCircle.cmp3
1852+
1853+
;-------------------------------------------------------------------------------
1854+
_FillCircle_NoClip:
18761855
.fillsectors:
18771856
ld hl,(ix-3)
18781857
add hl,hl
@@ -1962,10 +1941,34 @@ gfx_FillCircle_NoClip:
19621941
or a,a
19631942
sbc hl,bc
19641943
jp nc,.fillsectors
1965-
_ResetStack:
1944+
.ResetStack:
19661945
ld sp,ix
19671946
pop ix
19681947
ret
1948+
gfx_FillCircle_NoClip:
1949+
; Draws an unclipped circle
1950+
; Arguments:
1951+
; arg0 : X coordinate
1952+
; arg1 : Y coordinate
1953+
; arg2 : Radius
1954+
; Returns:
1955+
; None
1956+
push ix
1957+
ld ix, 0
1958+
add ix, sp
1959+
lea hl, ix - 9
1960+
ld sp, hl
1961+
ld bc, (ix + 12)
1962+
sbc hl, hl
1963+
adc hl, bc ; carry won't be set since HL is zero here
1964+
jr z, _FillCircle_NoClip.ResetStack
1965+
ld (ix - 6), bc
1966+
sbc hl, hl
1967+
ld (ix - 3), hl
1968+
inc hl
1969+
sbc hl, bc ; HL = 1 - BC
1970+
call gfx_Wait
1971+
jr _FillCircle_NoClip.loop
19691972

19701973
;-------------------------------------------------------------------------------
19711974
gfx_Line:

0 commit comments

Comments
 (0)