@@ -907,7 +907,7 @@ gfx_Rectangle_NoClip:
907
907
; de = ti.lcdWidth
908
908
sbc hl , de ; hl = &buf[y+height-1][x]
909
909
pop bc ; bc = width
910
- jp _HorizLine_NoClip_Draw ; draw bottom horizontal line
910
+ jr _HorizLine_NoClip_Draw ; draw bottom horizontal line
911
911
912
912
;-------------------------------------------------------------------------------
913
913
gfx_HorizLine:
@@ -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
@@ -3221,20 +3219,7 @@ _Tilemap:
3221
3219
ld (ix - 3 ) , h
3222
3220
sbc hl , bc
3223
3221
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
3238
3223
3239
3224
.xloopinner:
3240
3225
or a , a
@@ -3290,7 +3275,20 @@ _Tilemap:
3290
3275
.yloop:
3291
3276
ld a , (iy + t_draw_height)
3292
3277
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:
3294
3292
ld sp , ix
3295
3293
pop ix
3296
3294
ret
@@ -3857,8 +3855,7 @@ gfx_GetStringWidth:
3857
3855
; Returns:
3858
3856
; Width of string in pixels
3859
3857
pop de
3860
- pop hl
3861
- push hl ; hl -> string
3858
+ ex ( sp ) , hl ; hl -> string
3862
3859
push de
3863
3860
ld de , 0
3864
3861
. loop :
@@ -3882,10 +3879,11 @@ gfx_GetCharWidth:
3882
3879
; arg0 : Character
3883
3880
; Returns:
3884
3881
; 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
3889
3887
_GetCharWidth:
3890
3888
sbc hl , hl
3891
3889
ld l , a
@@ -3998,8 +3996,7 @@ gfx_SetFontData:
3998
3996
; Returns:
3999
3997
; Pointer to previous font data
4000
3998
pop de
4001
- pop hl
4002
- push hl ; hl -> custom font data
3999
+ ex ( sp ) , hl ; hl -> custom font data
4003
4000
push de
4004
4001
add hl , de
4005
4002
or a , a
@@ -4050,8 +4047,7 @@ gfx_SetFontSpacing:
4050
4047
; Returns:
4051
4048
; None
4052
4049
pop de
4053
- pop hl
4054
- push hl ; hl -> custom font width
4050
+ ex ( sp ) , hl ; hl -> custom font width
4055
4051
push de
4056
4052
add hl , de
4057
4053
or a , a
@@ -4072,10 +4068,9 @@ gfx_SetMonospaceFont:
4072
4068
pop hl
4073
4069
pop de
4074
4070
push de
4075
- push hl
4076
4071
ld a , e ; a = width
4077
4072
ld (_TextFixedWidth) , a ; store the value of the monospace width
4078
- ret
4073
+ jp (hl)
4079
4074
4080
4075
;-------------------------------------------------------------------------------
4081
4076
gfx_FillTriangle_NoClip:
@@ -4147,7 +4142,7 @@ _FillTriangle:
4147
4142
ld hl , (ix + 9 )
4148
4143
or a , a
4149
4144
sbc hl , de
4150
- jp nz , .notfl at
4145
+ jr nz , .notfl at
4151
4146
ld bc , (ix + 6 ) ; x0
4152
4147
ld (ix - 6 ) , bc ; a = x0
4153
4148
ld (ix - 3 ) , bc ; b = x0;
@@ -4198,29 +4193,6 @@ _FillTriangle:
4198
4193
jp p , .cmp30
4199
4194
jp pe , .cmp31
4200
4195
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;
4224
4196
.notfl at :
4225
4197
ld bc , (ix + 6 ) ; x0
4226
4198
ld hl , (ix + 12 )
@@ -4253,14 +4225,34 @@ _FillTriangle:
4253
4225
jr nz , .elselast ; if (y1 == y2) { last = y1; }
4254
4226
ld (ix - 24 ) , bc
4255
4227
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;
4256
4248
.elselast:
4257
4249
ld bc , (ix + 15 ) ; else { last = y1-1; }
4258
4250
dec bc
4259
4251
ld (ix - 24 ) , bc
4260
4252
.sublast:
4261
4253
ld bc , (ix + 9 )
4262
4254
ld (ix - 12 ) , bc ; for (y = y0; y <= last; y++)
4263
- jp .firstloopstart
4255
+ jr .firstloopstart
4264
4256
.firstloop:
4265
4257
ld hl , (ix - 15 )
4266
4258
ld bc , (ix - 33 )
@@ -4337,7 +4329,7 @@ _FillTriangle:
4337
4329
ld de , (ix - 21 )
4338
4330
call _MultiplyHLDE ; sb = dx02 * (y - y0);
4339
4331
ld (ix - 18 ) , hl
4340
- jp .secondloopstart ; for(; y <= y2; y++)
4332
+ jr .secondloopstart ; for(; y <= y2; y++)
4341
4333
.secondloop:
4342
4334
ld hl , (ix - 15 )
4343
4335
ld bc , (ix - 39 )
@@ -4838,8 +4830,7 @@ gfx_ScaleSprite:
4838
4830
pop de ; de->tgt_data
4839
4831
ld iy , 0
4840
4832
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
4843
4834
4844
4835
; b = out_loop_times
4845
4836
; de = target buffer adress
@@ -4849,9 +4840,9 @@ ScaleWidth := $+2
4849
4840
ld iyh , 0
4850
4841
xor a , a
4851
4842
ld b , a
4852
- ld c , 0
4853
- du := $ - 1
4854
- . loop : ldi
4843
+ ld c , ixh ; (.du)
4844
+ . loop :
4845
+ ldi
4855
4846
add a , iyl
4856
4847
adc hl , bc ; xu += du
4857
4848
inc bc ; bc:iyl is du
@@ -6398,6 +6389,7 @@ _Maximum:
6398
6389
; Oututs:
6399
6390
; HL=max number
6400
6391
or a , a
6392
+ .no_carry:
6401
6393
sbc hl , de
6402
6394
add hl , de
6403
6395
jp p , .skip
@@ -6416,6 +6408,7 @@ _Minimum:
6416
6408
; Oututs:
6417
6409
; HL=min number
6418
6410
or a , a
6411
+ .no_carry:
6419
6412
sbc hl , de
6420
6413
ex de , hl
6421
6414
jp p , .skip
@@ -6453,7 +6446,7 @@ smcWord _XMax
6453
6446
smcWord _YMin
6454
6447
.YMin := $ - 3
6455
6448
ld de , (iy + 6 )
6456
- call _Maximum
6449
+ call _Maximum.no_carry
6457
6450
ld (iy + 6 ) , hl
6458
6451
ld hl , ti.lcdHeight
6459
6452
smcWord _YMax
0 commit comments