@@ -1992,14 +1992,15 @@ gfx_Line:
19921992 call _ComputeOutcode
19931993 ld (iy - 2 ) , a
19941994CohenSutherlandLoop:
1995- ld b , (iy - 1 ) ; b = outcode0
19961995 ld a , (iy - 2 ) ; a = outcode1
1996+ .skip_ld_A:
1997+ ld b , (iy - 1 ) ; b = outcode0
19971998 tst a , b
1998- jp nz , TrivialReject ; if(outcode0|outcode1)
1999+ jr nz , TrivialReject ; if(outcode0|outcode1)
19992000 or a , a
20002001 jr nz , GetOutOutcode
20012002 or a , b
2002- jp z , TrivialAccept
2003+ jr z , TrivialAccept
20032004GetOutOutcode: ; select correct outcode
20042005 push af ; a = outoutcode
20052006 rra
@@ -2042,6 +2043,14 @@ NotBottom:
20422043 ld hl , ti.lcdWidth - 1
20432044smcWord _XMaxMinus1
20442045 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+
20452054NotRight:
20462055 rra
20472056 jr nc , FinishComputations ; if (outcodeOut & LEFT)
@@ -2085,17 +2094,7 @@ OutcodeOutOutcode1:
20852094 ld (iy + 12 ) , de
20862095 call _ComputeOutcode
20872096 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
20992098
21002099;-------------------------------------------------------------------------------
21012100gfx_Line_NoClip:
@@ -2109,19 +2108,21 @@ gfx_Line_NoClip:
21092108; None
21102109 ld iy , 0
21112110 add iy , sp
2111+ _Line_NoClip:
21122112 ld hl , (iy + 3 )
21132113 ld de , (iy + 9 )
21142114 ld b , (iy + 6 )
21152115 ld c , (iy + 12 ) ; line from hl,b to de,c
2116- or a , a
2116+ ; or a,a
21172117 sbc hl , de
21182118 add hl , de
2119- jr c ,+ _ ; draw left to right
2119+ jr c , _draw_left_to_right ; draw left to right
21202120 ex de , hl
21212121 ld a , b
21222122 ld b , c
21232123 ld c , a
2124- _: push bc
2124+ _draw_left_to_right:
2125+ push bc
21252126 pop iy
21262127 push hl
21272128 ld hl , (CurrentBuffer)
@@ -2146,17 +2147,18 @@ _: push bc
21462147 sbc hl , hl
21472148 ld l , a ; y0
21482149 sbc hl , de
2149- jr nc , $ + 9
2150+ jr nc , .positive_dy
21502151 ex de , hl
2152+ or a , a
21512153 sbc hl , hl
2152- ccf
2153- sbc hl , de
2154- inc hl ; abs(dy)
2154+ sbc hl , de ; abs(dy)
2155+ .positive_dy:
21552156 ld a , iyl
21562157 sub a , iyh
21572158 ld iy ,- 320
2158- jr c , $ + 7
2159+ jr c , .use_negative_IY
21592160 ld iy , 320
2161+ .use_negative_IY:
21602162 or a , a
21612163 sbc hl , bc
21622164 add hl , bc ; hl = dy
@@ -2165,15 +2167,15 @@ dl_horizontal:
21652167 ld a , l
21662168 or a , h
21672169 ld a , $ 38
2168- jr nz , $ + 4
2170+ jr nz , .dl_nz
21692171 xor a , $ 20
2172+ .dl_nz:
21702173 ld (_smc_dl_jr_0 + 0 ) , a ; write smc
21712174 ld (_smc_dl_width_1 + 1 ) , iy ; write smc
21722175 ex de , hl
2176+ ; or a,a ; or a,h clears carry
21732177 sbc hl , hl
2174- ccf
21752178 sbc hl , de
2176- inc hl
21772179 ex de , hl ; de = -dy
21782180 pop hl ; restore buffer
21792181 ld (_smc_dl_dx_1 + 1 ) , bc ; write smc
@@ -3998,8 +4000,7 @@ gfx_SetFontData:
39984000; Returns:
39994001; Pointer to previous font data
40004002 pop de
4001- pop hl
4002- push hl ; hl -> custom font data
4003+ ex ( sp ) , hl ; hl -> custom font data
40034004 push de
40044005 add hl , de
40054006 or a , a
@@ -4050,8 +4051,7 @@ gfx_SetFontSpacing:
40504051; Returns:
40514052; None
40524053 pop de
4053- pop hl
4054- push hl ; hl -> custom font width
4054+ ex ( sp ) , hl ; hl -> custom font width
40554055 push de
40564056 add hl , de
40574057 or a , a
@@ -4069,11 +4069,10 @@ gfx_SetMonospaceFont:
40694069; arg0 : Monospace spacing amount
40704070; Returns:
40714071; None
4072- pop hl
40734072 pop de
4073+ ex ( sp ) , hl
40744074 push de
4075- push hl
4076- ld a , e ; a = width
4075+ ld a , l ; a = width
40774076 ld (_TextFixedWidth) , a ; store the value of the monospace width
40784077 ret
40794078
@@ -4215,9 +4214,6 @@ _FillTriangle:
42154214 push de
42164215 call 0 ; horizline(a, y0, b-a+1);
42174216.line0 := $ - 3
4218- pop bc
4219- pop bc
4220- pop bc
42214217 ld sp , ix
42224218 pop ix
42234219 ret ; return;
@@ -5320,21 +5316,23 @@ _smc_dsrs_sinf_1: ; smc = sinf
53205316
53215317getSinCos:
53225318 ; returns a = sin/cos(a) * 128
5323- ld c , a
5324- bit 7 , a
5325- jr z , $ + 4
5326- sub a , 128
5327- bit 6 , a
5328- jr z , $ + 6
5329- ld e , a
5330- ld a , 128
5331- sub a , e
5332- ld de , 0
5333- ld e , a
5334- ld hl , _SineTable
5335- add hl , de
5336- ld a , (hl)
5337- bit 7 , c
5319+ ld de , $ 80
5320+ ld c , a
5321+ bit 7 , a
5322+ jr z , .bit7
5323+ sub a , e ; sub a, 128
5324+ .bit7:
5325+ bit 6 , a
5326+ jr z , .bit6
5327+ ; A = 128 - A
5328+ neg
5329+ add a , e ; add a, 128
5330+ .bit6:
5331+ ld e , a
5332+ ld hl , _SineTable
5333+ add hl , de
5334+ ld a , (hl)
5335+ bit 7 , c
53385336 ret z
53395337 neg
53405338 ret
0 commit comments