@@ -1992,14 +1992,15 @@ gfx_Line:
1992
1992
call _ComputeOutcode
1993
1993
ld (iy - 2 ) , a
1994
1994
CohenSutherlandLoop:
1995
- ld b , (iy - 1 ) ; b = outcode0
1996
1995
ld a , (iy - 2 ) ; a = outcode1
1996
+ .skip_ld_A:
1997
+ ld b , (iy - 1 ) ; b = outcode0
1997
1998
tst a , b
1998
- jp nz , TrivialReject ; if(outcode0|outcode1)
1999
+ jr nz , TrivialReject ; if(outcode0|outcode1)
1999
2000
or a , a
2000
2001
jr nz , GetOutOutcode
2001
2002
or a , b
2002
- jp z , TrivialAccept
2003
+ jr z , TrivialAccept
2003
2004
GetOutOutcode: ; select correct outcode
2004
2005
push af ; a = outoutcode
2005
2006
rra
@@ -2042,6 +2043,14 @@ NotBottom:
2042
2043
ld hl , ti.lcdWidth - 1
2043
2044
smcWord _XMaxMinus1
2044
2045
jr ComputeNewY
2046
+
2047
+ TrivialReject:
2048
+ ld sp , iy
2049
+ ret
2050
+ TrivialAccept:
2051
+ ld sp , iy
2052
+ jr _Line_NoClip ; line routine handler
2053
+
2045
2054
NotRight:
2046
2055
rra
2047
2056
jr nc , FinishComputations ; if (outcodeOut & LEFT)
@@ -2085,17 +2094,7 @@ OutcodeOutOutcode1:
2085
2094
ld (iy + 12 ) , de
2086
2095
call _ComputeOutcode
2087
2096
ld (iy - 2 ) , a ; c = outcode1
2088
- jp CohenSutherlandLoop
2089
- TrivialReject:
2090
- inc sp
2091
- inc sp
2092
- inc sp
2093
- ret
2094
- TrivialAccept:
2095
- inc sp
2096
- inc sp
2097
- inc sp
2098
- ; jr _Line_NoClip ; line routine handler
2097
+ jp CohenSutherlandLoop.skip_ld_A
2099
2098
2100
2099
;-------------------------------------------------------------------------------
2101
2100
gfx_Line_NoClip:
@@ -2109,19 +2108,21 @@ gfx_Line_NoClip:
2109
2108
; None
2110
2109
ld iy , 0
2111
2110
add iy , sp
2111
+ _Line_NoClip: ; <-- carry is cleared
2112
2112
ld hl , (iy + 3 )
2113
2113
ld de , (iy + 9 )
2114
2114
ld b , (iy + 6 )
2115
2115
ld c , (iy + 12 ) ; line from hl,b to de,c
2116
- or a , a
2116
+ ; or a,a
2117
2117
sbc hl , de
2118
2118
add hl , de
2119
- jr c ,+ _ ; draw left to right
2119
+ jr c , _draw_left_to_right ; draw left to right
2120
2120
ex de , hl
2121
2121
ld a , b
2122
2122
ld b , c
2123
2123
ld c , a
2124
- _: push bc
2124
+ _draw_left_to_right:
2125
+ push bc
2125
2126
pop iy
2126
2127
push hl
2127
2128
ld hl , (CurrentBuffer)
@@ -2137,26 +2138,29 @@ _: push bc
2137
2138
sbc hl , bc ; xe - xs
2138
2139
push hl
2139
2140
pop bc ; bc = dx
2140
- ld a , iyh
2141
- or a , a
2142
- sbc hl , hl
2143
- ld l , a ; y1
2144
- ex de , hl
2145
- ld a , iyl
2146
- sbc hl , hl
2147
- ld l , a ; y0
2148
- sbc hl , de
2149
- jr nc , $ + 9
2150
- ex de , hl
2151
- sbc hl , hl
2152
- ccf
2153
- sbc hl , de
2154
- inc hl ; abs(dy)
2141
+
2142
+ xor a , a
2143
+ ld h , a
2144
+ ld d , a
2145
+ ld e , iyl ; y0
2146
+ ex.s de , hl
2147
+ ld e , iyh ; y1
2148
+
2149
+ sbc hl , de
2150
+
2151
+ jr nc , .positive_dy
2152
+ ex de , hl
2153
+ or a , a
2154
+ sbc hl , hl
2155
+ sbc hl , de ; abs(dy)
2156
+ .positive_dy:
2157
+
2155
2158
ld a , iyl
2156
2159
sub a , iyh
2157
2160
ld iy ,- 320
2158
- jr c , $ + 7
2161
+ jr c , .use_negative_IY
2159
2162
ld iy , 320
2163
+ .use_negative_IY:
2160
2164
or a , a
2161
2165
sbc hl , bc
2162
2166
add hl , bc ; hl = dy
@@ -2165,19 +2169,19 @@ dl_horizontal:
2165
2169
ld a , l
2166
2170
or a , h
2167
2171
ld a , $ 38
2168
- jr nz , $ + 4
2172
+ jr nz , .dl_nz
2169
2173
xor a , $ 20
2174
+ .dl_nz:
2170
2175
ld (_smc_dl_jr_0 + 0 ) , a ; write smc
2171
2176
ld (_smc_dl_width_1 + 1 ) , iy ; write smc
2172
2177
ex de , hl
2178
+ ; or a,a ; or a,h clears carry
2173
2179
sbc hl , hl
2174
- ccf
2175
2180
sbc hl , de
2176
- inc hl
2181
+ ld (_smc_dl_dx_1 + 1 ) , bc ; write smc
2182
+ ld (_smc_dl_dy_1 + 1 ) , hl ; write smc
2177
2183
ex de , hl ; de = -dy
2178
2184
pop hl ; restore buffer
2179
- ld (_smc_dl_dx_1 + 1 ) , bc ; write smc
2180
- ld (_smc_dl_dy_1 + 1 ) , de ; write smc
2181
2185
push bc
2182
2186
srl b
2183
2187
rr c
0 commit comments