@@ -2512,9 +2512,7 @@ gfx_GetClipRegion:
2512
2512
ld hl , 3
2513
2513
add hl , sp
2514
2514
ld iy , (hl)
2515
- dec iy
2516
- dec iy
2517
- dec iy
2515
+ lea iy , iy - 3
2518
2516
call _ClipRegion ; get the clipping region
2519
2517
sbc a , a ; return false if offscreen (0)
2520
2518
inc a
@@ -3237,20 +3235,7 @@ _Tilemap:
3237
3235
ld (ix - 3 ) , h
3238
3236
sbc hl , bc
3239
3237
ld (ix - 12 ) , hl
3240
- jp .yloop
3241
-
3242
- .xres := $ + 3
3243
- . loop :
3244
- ld (ix - 1 ) , 0
3245
- ld hl , 0
3246
- .xoffset := $ - 3
3247
- ld (ix - 7 ) , hl
3248
- ld l , (iy + t_width)
3249
- ld h , (ix - 4 )
3250
- mlt hl
3251
- ld (.ynext) , hl
3252
- xor a , a
3253
- jr .xloop
3238
+ jr .yloop
3254
3239
3255
3240
.xloopinner:
3256
3241
or a , a
@@ -3306,7 +3291,20 @@ _Tilemap:
3306
3291
.yloop:
3307
3292
ld a , (iy + t_draw_height)
3308
3293
cp a , (ix - 3 )
3309
- jp nz , . loop
3294
+ jr z , .finish_loop
3295
+ .xres := $ + 3
3296
+ ; .loop:
3297
+ ld (ix - 1 ) , 0
3298
+ ld hl , 0
3299
+ .xoffset := $ - 3
3300
+ ld (ix - 7 ) , hl
3301
+ ld l , (iy + t_width)
3302
+ ld h , (ix - 4 )
3303
+ mlt hl
3304
+ ld (.ynext) , hl
3305
+ xor a , a
3306
+ jr .xloop
3307
+ .finish_loop:
3310
3308
ld sp , ix
3311
3309
pop ix
3312
3310
ret
@@ -3898,10 +3896,11 @@ gfx_GetCharWidth:
3898
3896
; arg0 : Character
3899
3897
; Returns:
3900
3898
; Width of character in pixels
3901
- ld iy , 0
3902
- lea de , iy
3903
- add iy , sp
3904
- ld a , (iy + 3 ) ; a = character
3899
+ ld hl , 3
3900
+ add hl , sp
3901
+ ld a , (hl) ; a = character
3902
+ sbc hl , hl
3903
+ ex de , hl
3905
3904
_GetCharWidth:
3906
3905
sbc hl , hl
3907
3906
ld l , a
@@ -4014,8 +4013,7 @@ gfx_SetFontData:
4014
4013
; Returns:
4015
4014
; Pointer to previous font data
4016
4015
pop de
4017
- pop hl
4018
- push hl ; hl -> custom font data
4016
+ ex ( sp ) , hl ; hl -> custom font data
4019
4017
push de
4020
4018
add hl , de
4021
4019
or a , a
@@ -4066,8 +4064,7 @@ gfx_SetFontSpacing:
4066
4064
; Returns:
4067
4065
; None
4068
4066
pop de
4069
- pop hl
4070
- push hl ; hl -> custom font width
4067
+ ex ( sp ) , hl ; hl -> custom font width
4071
4068
push de
4072
4069
add hl , de
4073
4070
or a , a
@@ -4088,10 +4085,9 @@ gfx_SetMonospaceFont:
4088
4085
pop hl
4089
4086
pop de
4090
4087
push de
4091
- push hl
4092
4088
ld a , e ; a = width
4093
4089
ld (_TextFixedWidth) , a ; store the value of the monospace width
4094
- ret
4090
+ jp (hl)
4095
4091
4096
4092
;-------------------------------------------------------------------------------
4097
4093
gfx_FillTriangle_NoClip:
@@ -4231,9 +4227,6 @@ _FillTriangle:
4231
4227
push de
4232
4228
call 0 ; horizline(a, y0, b-a+1);
4233
4229
.line0 := $ - 3
4234
- pop bc
4235
- pop bc
4236
- pop bc
4237
4230
ld sp , ix
4238
4231
pop ix
4239
4232
ret ; return;
@@ -4276,7 +4269,7 @@ _FillTriangle:
4276
4269
.sublast:
4277
4270
ld bc , (ix + 9 )
4278
4271
ld (ix - 12 ) , bc ; for (y = y0; y <= last; y++)
4279
- jp .firstloopstart
4272
+ jr .firstloopstart
4280
4273
.firstloop:
4281
4274
ld hl , (ix - 15 )
4282
4275
ld bc , (ix - 33 )
@@ -4353,7 +4346,7 @@ _FillTriangle:
4353
4346
ld de , (ix - 21 )
4354
4347
call _MultiplyHLDE ; sb = dx02 * (y - y0);
4355
4348
ld (ix - 18 ) , hl
4356
- jp .secondloopstart ; for(; y <= y2; y++)
4349
+ jr .secondloopstart ; for(; y <= y2; y++)
4357
4350
.secondloop:
4358
4351
ld hl , (ix - 15 )
4359
4352
ld bc , (ix - 39 )
@@ -4856,8 +4849,7 @@ gfx_ScaleSprite:
4856
4849
pop de ; de->tgt_data
4857
4850
ld iy , 0
4858
4851
ld iyl , a
4859
- ld a , c ; du = bc:iyl
4860
- ld (du) , a ; ixl = target_height
4852
+ ld ixh , c ; (.du) = bc:iyl, ixl = target_height
4861
4853
4862
4854
; b = out_loop_times
4863
4855
; de = target buffer adress
@@ -4867,9 +4859,9 @@ ScaleWidth := $+2
4867
4859
ld iyh , 0
4868
4860
xor a , a
4869
4861
ld b , a
4870
- ld c , 0
4871
- du := $ - 1
4872
- . loop : ldi
4862
+ ld c , ixh ; (.du)
4863
+ . loop :
4864
+ ldi
4873
4865
add a , iyl
4874
4866
adc hl , bc ; xu += du
4875
4867
inc bc ; bc:iyl is du
@@ -6354,6 +6346,7 @@ _Maximum:
6354
6346
; Oututs:
6355
6347
; HL=max number
6356
6348
or a , a
6349
+ .no_carry:
6357
6350
sbc hl , de
6358
6351
add hl , de
6359
6352
jp p , .skip
@@ -6372,6 +6365,7 @@ _Minimum:
6372
6365
; Oututs:
6373
6366
; HL=min number
6374
6367
or a , a
6368
+ .no_carry:
6375
6369
sbc hl , de
6376
6370
ex de , hl
6377
6371
jp p , .skip
@@ -6409,7 +6403,7 @@ smcWord _XMax
6409
6403
smcWord _YMin
6410
6404
.YMin := $ - 3
6411
6405
ld de , (iy + 6 )
6412
- call _Maximum
6406
+ call _Maximum.no_carry
6413
6407
ld (iy + 6 ) , hl
6414
6408
ld hl , ti.lcdHeight
6415
6409
smcWord _YMax
0 commit comments