@@ -907,7 +907,7 @@ gfx_Rectangle_NoClip:
907907 ; de = ti.lcdWidth
908908 sbc hl , de ; hl = &buf[y+height-1][x]
909909 pop bc ; bc = width
910- jp _HorizLine_NoClip_Draw ; draw bottom horizontal line
910+ jr _HorizLine_NoClip_Draw ; draw bottom horizontal line
911911
912912;-------------------------------------------------------------------------------
913913gfx_HorizLine:
@@ -2512,9 +2512,7 @@ gfx_GetClipRegion:
25122512 ld hl , 3
25132513 add hl , sp
25142514 ld iy , (hl)
2515- dec iy
2516- dec iy
2517- dec iy
2515+ lea iy , iy - 3
25182516 call _ClipRegion ; get the clipping region
25192517 sbc a , a ; return false if offscreen (0)
25202518 inc a
@@ -3221,20 +3219,7 @@ _Tilemap:
32213219 ld (ix - 3 ) , h
32223220 sbc hl , bc
32233221 ld (ix - 12 ) , hl
3224- jp .yloop
3225-
3226- .xres := $ + 3
3227- . loop :
3228- ld (ix - 1 ) , 0
3229- ld hl , 0
3230- .xoffset := $ - 3
3231- ld (ix - 7 ) , hl
3232- ld l , (iy + t_width)
3233- ld h , (ix - 4 )
3234- mlt hl
3235- ld (.ynext) , hl
3236- xor a , a
3237- jr .xloop
3222+ jr .yloop
32383223
32393224.xloopinner:
32403225 or a , a
@@ -3290,7 +3275,20 @@ _Tilemap:
32903275.yloop:
32913276 ld a , (iy + t_draw_height)
32923277 cp a , (ix - 3 )
3293- jp nz , . loop
3278+ jr z , .finish_loop
3279+ .xres := $ + 3
3280+ ; .loop:
3281+ ld (ix - 1 ) , 0
3282+ ld hl , 0
3283+ .xoffset := $ - 3
3284+ ld (ix - 7 ) , hl
3285+ ld l , (iy + t_width)
3286+ ld h , (ix - 4 )
3287+ mlt hl
3288+ ld (.ynext) , hl
3289+ xor a , a
3290+ jr .xloop
3291+ .finish_loop:
32943292 ld sp , ix
32953293 pop ix
32963294 ret
@@ -3857,8 +3855,7 @@ gfx_GetStringWidth:
38573855; Returns:
38583856; Width of string in pixels
38593857 pop de
3860- pop hl
3861- push hl ; hl -> string
3858+ ex ( sp ) , hl ; hl -> string
38623859 push de
38633860 ld de , 0
38643861. loop :
@@ -3882,10 +3879,11 @@ gfx_GetCharWidth:
38823879; arg0 : Character
38833880; Returns:
38843881; Width of character in pixels
3885- ld iy , 0
3886- lea de , iy
3887- add iy , sp
3888- ld a , (iy + 3 ) ; a = character
3882+ ld hl , 3
3883+ add hl , sp
3884+ ld a , (hl) ; a = character
3885+ sbc hl , hl
3886+ ex de , hl
38893887_GetCharWidth:
38903888 sbc hl , hl
38913889 ld l , a
@@ -3998,8 +3996,7 @@ gfx_SetFontData:
39983996; Returns:
39993997; Pointer to previous font data
40003998 pop de
4001- pop hl
4002- push hl ; hl -> custom font data
3999+ ex ( sp ) , hl ; hl -> custom font data
40034000 push de
40044001 add hl , de
40054002 or a , a
@@ -4050,8 +4047,7 @@ gfx_SetFontSpacing:
40504047; Returns:
40514048; None
40524049 pop de
4053- pop hl
4054- push hl ; hl -> custom font width
4050+ ex ( sp ) , hl ; hl -> custom font width
40554051 push de
40564052 add hl , de
40574053 or a , a
@@ -4072,10 +4068,9 @@ gfx_SetMonospaceFont:
40724068 pop hl
40734069 pop de
40744070 push de
4075- push hl
40764071 ld a , e ; a = width
40774072 ld (_TextFixedWidth) , a ; store the value of the monospace width
4078- ret
4073+ jp (hl)
40794074
40804075;-------------------------------------------------------------------------------
40814076gfx_FillTriangle_NoClip:
@@ -4147,7 +4142,7 @@ _FillTriangle:
41474142 ld hl , (ix + 9 )
41484143 or a , a
41494144 sbc hl , de
4150- jp nz , .notfl at
4145+ jr nz , .notfl at
41514146 ld bc , (ix + 6 ) ; x0
41524147 ld (ix - 6 ) , bc ; a = x0
41534148 ld (ix - 3 ) , bc ; b = x0;
@@ -4198,29 +4193,6 @@ _FillTriangle:
41984193 jp p , .cmp30
41994194 jp pe , .cmp31
42004195 jr .cmp32
4201- .cmp30:
4202- jp po , .cmp31
4203- .cmp32:
4204- ld bc , (ix + 18 )
4205- ld (ix - 6 ) , bc
4206- .cmp31:
4207- ld de , (ix - 3 )
4208- ld hl , (ix - 6 )
4209- or a , a
4210- sbc hl , de
4211- inc hl
4212- push hl
4213- ld bc , (ix + 9 )
4214- push bc
4215- push de
4216- call 0 ; horizline(a, y0, b-a+1);
4217- .line0 := $ - 3
4218- pop bc
4219- pop bc
4220- pop bc
4221- ld sp , ix
4222- pop ix
4223- ret ; return;
42244196.notfl at :
42254197 ld bc , (ix + 6 ) ; x0
42264198 ld hl , (ix + 12 )
@@ -4253,14 +4225,34 @@ _FillTriangle:
42534225 jr nz , .elselast ; if (y1 == y2) { last = y1; }
42544226 ld (ix - 24 ) , bc
42554227 jr .sublast
4228+ .cmp30:
4229+ jp po , .cmp31
4230+ .cmp32:
4231+ ld bc , (ix + 18 )
4232+ ld (ix - 6 ) , bc
4233+ .cmp31:
4234+ ld de , (ix - 3 )
4235+ ld hl , (ix - 6 )
4236+ or a , a
4237+ sbc hl , de
4238+ inc hl
4239+ push hl
4240+ ld bc , (ix + 9 )
4241+ push bc
4242+ push de
4243+ call 0 ; horizline(a, y0, b-a+1);
4244+ .line0 := $ - 3
4245+ ld sp , ix
4246+ pop ix
4247+ ret ; return;
42564248.elselast:
42574249 ld bc , (ix + 15 ) ; else { last = y1-1; }
42584250 dec bc
42594251 ld (ix - 24 ) , bc
42604252.sublast:
42614253 ld bc , (ix + 9 )
42624254 ld (ix - 12 ) , bc ; for (y = y0; y <= last; y++)
4263- jp .firstloopstart
4255+ jr .firstloopstart
42644256.firstloop:
42654257 ld hl , (ix - 15 )
42664258 ld bc , (ix - 33 )
@@ -4337,7 +4329,7 @@ _FillTriangle:
43374329 ld de , (ix - 21 )
43384330 call _MultiplyHLDE ; sb = dx02 * (y - y0);
43394331 ld (ix - 18 ) , hl
4340- jp .secondloopstart ; for(; y <= y2; y++)
4332+ jr .secondloopstart ; for(; y <= y2; y++)
43414333.secondloop:
43424334 ld hl , (ix - 15 )
43434335 ld bc , (ix - 39 )
@@ -4838,8 +4830,7 @@ gfx_ScaleSprite:
48384830 pop de ; de->tgt_data
48394831 ld iy , 0
48404832 ld iyl , a
4841- ld a , c ; du = bc:iyl
4842- ld (du) , a ; ixl = target_height
4833+ ld ixh , c ; (.du) = bc:iyl, ixl = target_height
48434834
48444835; b = out_loop_times
48454836; de = target buffer adress
@@ -4849,9 +4840,9 @@ ScaleWidth := $+2
48494840 ld iyh , 0
48504841 xor a , a
48514842 ld b , a
4852- ld c , 0
4853- du := $ - 1
4854- . loop : ldi
4843+ ld c , ixh ; (.du)
4844+ . loop :
4845+ ldi
48554846 add a , iyl
48564847 adc hl , bc ; xu += du
48574848 inc bc ; bc:iyl is du
@@ -6411,6 +6402,7 @@ _Maximum:
64116402; Oututs:
64126403; HL=max number
64136404 or a , a
6405+ .no_carry:
64146406 sbc hl , de
64156407 add hl , de
64166408 jp p , .skip
@@ -6429,6 +6421,7 @@ _Minimum:
64296421; Oututs:
64306422; HL=min number
64316423 or a , a
6424+ .no_carry:
64326425 sbc hl , de
64336426 ex de , hl
64346427 jp p , .skip
@@ -6466,7 +6459,7 @@ smcWord _XMax
64666459smcWord _YMin
64676460.YMin := $ - 3
64686461 ld de , (iy + 6 )
6469- call _Maximum
6462+ call _Maximum.no_carry
64706463 ld (iy + 6 ) , hl
64716464 ld hl , ti.lcdHeight
64726465smcWord _YMax
0 commit comments