@@ -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:
@@ -4215,9 +4210,6 @@ _FillTriangle:
42154210 push de
42164211 call 0 ; horizline(a, y0, b-a+1);
42174212.line0 := $ - 3
4218- pop bc
4219- pop bc
4220- pop bc
42214213 ld sp , ix
42224214 pop ix
42234215 ret ; return;
@@ -4260,7 +4252,7 @@ _FillTriangle:
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
@@ -6387,6 +6378,7 @@ _Maximum:
63876378; Oututs:
63886379; HL=max number
63896380 or a , a
6381+ .no_carry:
63906382 sbc hl , de
63916383 add hl , de
63926384 jp p , .skip
@@ -6405,6 +6397,7 @@ _Minimum:
64056397; Oututs:
64066398; HL=min number
64076399 or a , a
6400+ .no_carry:
64086401 sbc hl , de
64096402 ex de , hl
64106403 jp p , .skip
@@ -6442,7 +6435,7 @@ smcWord _XMax
64426435smcWord _YMin
64436436.YMin := $ - 3
64446437 ld de , (iy + 6 )
6445- call _Maximum
6438+ call _Maximum.no_carry
64466439 ld (iy + 6 ) , hl
64476440 ld hl , ti.lcdHeight
64486441smcWord _YMax
0 commit comments