@@ -117,6 +117,12 @@ DEFAULT_TEXT_BG_COLOR equ 255
117
117
DEFAULT_TEXT_TP_COLOR equ 255
118
118
;-------------------------------------------------------------------------------
119
119
120
+ ;-------------------------------------------------------------------------------
121
+ ; Useful Macros
122
+ #define mSignedCompareDE() or a , a \ sbc hl , de \ add hl , hl \ jp po , $ + 5 \.r \ ccf \
123
+ #define mSignedCompareBC() or a , a \ sbc hl , bc \ add hl , hl \ jp po , $ + 5 \.r \ ccf \
124
+ ;-------------------------------------------------------------------------------
125
+
120
126
;-------------------------------------------------------------------------------
121
127
_AllocSprite:
122
128
; Allocates space for a new sprite
@@ -663,12 +669,12 @@ _HorizLine:
663
669
add iy , sp
664
670
ld de , (_ymin) \.r
665
671
ld hl , (iy + 6 )
666
- call _SignedCompare_ASM \.r ; compare y coordinate <-> ymin
672
+ mSignedCompareDE() ; compare y coordinate <-> ymin
667
673
ret c
668
674
ld hl , (_ymax) \.r
669
675
dec hl ; inclusive
670
676
ld de , (iy + 6 )
671
- call _SignedCompare_ASM \.r ; compare y coordinate <-> ymax
677
+ mSignedCompareDE() ; compare y coordinate <-> ymax
672
678
ret c
673
679
ld hl , (iy + 9 )
674
680
ld de , (iy + 3 )
@@ -682,7 +688,7 @@ _HorizLine:
682
688
call _Min_ASM \.r
683
689
ld (iy + 9 ) , hl ; save minimum x value
684
690
ld de , (iy + 3 )
685
- call _SignedCompare_ASM \.r
691
+ mSignedCompareDE()
686
692
ret c
687
693
ld hl , (iy + 9 )
688
694
sbc hl , de
@@ -742,11 +748,11 @@ _VertLine:
742
748
ld hl , (_xmax) \.r
743
749
dec hl ; inclusive
744
750
ld de , (iy + 3 )
745
- call _SignedCompare_ASM \.r
751
+ mSignedCompareDE()
746
752
ret c ; return if x > xmax
747
- ld hl , (iy + 3 )
753
+ ex de , hl
748
754
ld de , (_xmin) \.r
749
- call _SignedCompare_ASM \.r
755
+ mSignedCompareDE()
750
756
ret c ; return if x < xmin
751
757
ld hl , (iy + 9 )
752
758
ld de , (iy + 6 )
@@ -760,7 +766,7 @@ _VertLine:
760
766
call _Min_ASM \.r ; get maximum y
761
767
ld (iy + 9 ) , hl
762
768
ld de , (iy + 6 )
763
- call _SignedCompare_ASM \.r
769
+ mSignedCompareDE()
764
770
ret c ; return if not within y bounds
765
771
ld hl , (iy + 9 )
766
772
sbc hl , de
@@ -2010,6 +2016,10 @@ _Sprite:
2010
2016
; arg4 : Height -- 8bits
2011
2017
; Returns:
2012
2018
; None
2019
+ scf
2020
+ sbc hl , hl
2021
+ ld (hl) , 2
2022
+
2013
2023
push ix ; save ix sp
2014
2024
call _ClipDraw_ASM \.r
2015
2025
pop ix ; restore ix sp
@@ -2214,13 +2224,13 @@ _ClipDraw_ASM:
2214
2224
ld (iy + 6 ) , hl ; save a ptr to the sprite data to change offsets
2215
2225
ld bc , (ix + 9 )
2216
2226
ld hl , (_ymin) \.r
2217
- call _SignedCompareBC_ASM \.r
2227
+ mSignedCompareBC()
2218
2228
jr c , NoTopClipNeeded_ASM
2219
2229
ld hl , (iy + 3 )
2220
2230
add hl , bc
2221
2231
ex de , hl
2222
2232
ld hl , (_ymin) \.r
2223
- call _SignedCompare_ASM \.r
2233
+ mSignedCompareDE()
2224
2234
ret nc ; bc = y location
2225
2235
ld hl , (_ymin) \.r ; ymin
2226
2236
or a , a
@@ -2239,13 +2249,13 @@ NoTopClipNeeded_ASM:
2239
2249
push bc
2240
2250
pop hl ; hl = y coordinate
2241
2251
ld de , (_ymax) \.r
2242
- call _SignedCompare_ASM \.r
2252
+ mSignedCompareDE()
2243
2253
ret nc ; return if offscreen on bottom
2244
2254
; bc = y coordinate
2245
2255
ld hl , (iy + 3 ) ; hl = tmpHeight
2246
2256
add hl , bc
2247
2257
ld de , (_ymax) \.r
2248
- call _SignedCompare_ASM \.r
2258
+ mSignedCompareDE()
2249
2259
jr c , NoBottomClipNeeded_ASM ; is partially clipped bottom?
2250
2260
ex de , hl ; hl = ymax
2251
2261
; bc = y coordinate
@@ -2254,14 +2264,14 @@ NoTopClipNeeded_ASM:
2254
2264
NoBottomClipNeeded_ASM:
2255
2265
ld hl , (ix + 6 ) ; hl = x coordinate
2256
2266
ld de , (_xmin) \.r
2257
- call _SignedCompare_ASM \.r
2267
+ mSignedCompareDE()
2258
2268
ld hl , (ix + 6 ) ; hl = x coordinate
2259
2269
jr nc , NoLeftClip_ASM ; is partially clipped left?
2260
2270
ld de , (iy + 0 ) ; de = tmpWidth
2261
2271
add hl , de
2262
2272
ld de , (_xmin) \.r
2263
2273
ex de , hl
2264
- call _SignedCompare_ASM \.r
2274
+ mSignedCompareDE()
2265
2275
ret nc ; return if offscreen
2266
2276
ld de , (ix + 6 ) ; de = x coordinate
2267
2277
ld hl , (_xmin) \.r
@@ -2279,15 +2289,15 @@ NoBottomClipNeeded_ASM:
2279
2289
ld (ix + 6 ) , hl ; save min x coordinate
2280
2290
NoLeftClip_ASM:
2281
2291
ld de , (_xmax) \.r ; de = xmax
2282
- call _SignedCompare_ASM \.r
2292
+ mSignedCompareDE()
2283
2293
ret nc ; return if offscreen
2284
2294
ld hl , (ix + 6 ) ; hl = x coordinate
2285
2295
ld de , (iy + 0 ) ; de = tmpWidth
2286
2296
add hl , de
2287
2297
ld de , (_xmax) \.r
2288
2298
ex de , hl
2289
- call _SignedCompare_ASM \.r ; is partially clipped right?
2290
- jr nc , NoRightClip_ASM
2299
+ mSignedCompareDE()
2300
+ jr nc , NoRightClip_ASM ; is partially clipped right?
2291
2301
ld hl , (_xmax) \.r ; clip on the right
2292
2302
ld de , (ix + 6 )
2293
2303
ccf
@@ -4231,7 +4241,7 @@ _: ld bc,(ix+6)
4231
4241
ld a , (ix + 9 )
4232
4242
ld (iy + 6 ) , a
4233
4243
ld (iy + 9 ) , 1
4234
- lea iy , iy + 10 ; push(x, x, y, 1);
4244
+ lea iy , iy + 10 ; push(x, x, y, 1)
4235
4245
InvalidPush_1:
4236
4246
add hl , de
4237
4247
dec hl
@@ -4248,7 +4258,7 @@ _: ld bc,(ix+6)
4248
4258
inc a
4249
4259
ld (iy + 6 ) , a
4250
4260
ld (iy + 9 ) ,- 1
4251
- lea iy , iy + 10 ; push(x, x, y+1, -1);
4261
+ lea iy , iy + 10 ; push(x, x, y+1, -1)
4252
4262
InvalidPush_2:
4253
4263
4254
4264
jp WhileStackNotEmptyBegin \.r ; while ( sp > stack )
@@ -4267,7 +4277,7 @@ WhileStackNotEmpty:
4267
4277
ld de , (iy + 6 )
4268
4278
add hl , de
4269
4279
ld (ix + 9 ) , l ; pop (xl, xr, y, dy);
4270
- ; for ( x = xl; x >= xmin && gfx_getpixel (x, y) == old_color; --x )
4280
+ ; for ( x = xl; x >= xmin && getpixel (x, y) == old_color; --x )
4271
4281
ld e , l
4272
4282
ld hl , (currDrawBuffer)
4273
4283
add hl , bc
@@ -4281,7 +4291,7 @@ WhileStackNotEmpty:
4281
4291
Loop_For_1:
4282
4292
NewColor_SMC_1 =$ + 1
4283
4293
ld a , 0
4284
- ld (de) , a ; setpixel(x, y);
4294
+ ld (de) , a ; setpixel(x, y)
4285
4295
dec de
4286
4296
dec bc
4287
4297
Loop_For_Begin_1:
@@ -4303,7 +4313,7 @@ Loop_For_Done:
4303
4313
jp nc , SkipChecks \.r
4304
4314
add hl , bc
4305
4315
inc hl
4306
- ld (ix - 19 ) , hl ; left = x+1;
4316
+ ld (ix - 19 ) , hl ; left = x+1
4307
4317
or a , a
4308
4318
sbc hl , bc ; if( left < xl )
4309
4319
jp p ,+ _ \.r
@@ -4348,7 +4358,7 @@ _: ld (iy+0),bc
4348
4358
NoPush_5:
4349
4359
InvalidPush_5:
4350
4360
ld bc , (ix - 16 )
4351
- inc bc ; x = xl+1;
4361
+ inc bc ; x = xl+1
4352
4362
4353
4363
DoWhileLoop:
4354
4364
ld e , (ix + 9 )
@@ -4464,10 +4474,10 @@ _: ld bc,(ix-43)
4464
4474
ld (iy + 9 ) , a ; a = -dy
4465
4475
ld a , (ix + 9 )
4466
4476
ld (iy + 6 ) , a
4467
- lea iy , iy + 10 ; push(xr+1, x-1, y, -dy);
4477
+ lea iy , iy + 10 ; push(xr+1, x-1, y, -dy)
4468
4478
SkipChecks:
4469
4479
InvalidPush_4:
4470
- ld bc , (ix + 6 ) ; for( ++x; x <= xr && getpixel(x, y) != old_color; ++x );
4480
+ ld bc , (ix + 6 ) ; for( ++x; x <= xr && getpixel(x, y) != old_color; ++x )
4471
4481
inc bc
4472
4482
ld e , (ix + 9 )
4473
4483
ld hl , (currDrawBuffer)
@@ -4487,7 +4497,7 @@ Loop_For_Begin_3:
4487
4497
sbc hl , bc
4488
4498
jr c , Loop_For_Done_3
4489
4499
add hl , bc
4490
- ld a , (de)
4500
+ ld a , (de) ; getpixel(x, y)
4491
4501
OldColor_SMC_3 =$ + 1
4492
4502
cp a , 0
4493
4503
jr nz , Loop_For_3
0 commit comments