@@ -4124,7 +4124,7 @@ _: rla
4124
4124
4125
4125
;-------------------------------------------------------------------------------
4126
4126
_FloodFill:
4127
- ; Preforms an implementation of a flood fill so no one hopefully crashes the stack
4127
+ ; Implements a flood fill so no one hopefully crashes the stack
4128
4128
; Maximum stack depth is 3224 bytes
4129
4129
; Arguments:
4130
4130
; arg0 : X Coordinate
@@ -4140,9 +4140,13 @@ _FloodFill:
4140
4140
call _PixelPtrNoChks_ASM \.r ; ov = p(x, y);
4141
4141
ld a , (hl)
4142
4142
4143
- ld (ff_color0_smc) , a \.r
4144
- ld (ff_color1_smc) , a \.r
4145
- ld (ff_color2_smc) , a \.r
4143
+ ld (ff_oldcolor0_smc) , a \.r
4144
+ ld (ff_oldcolor1_smc) , a \.r
4145
+ ld (ff_oldcolor2_smc) , a \.r
4146
+
4147
+ ld a , (ix + 12 )
4148
+ ld (ff_newcolor0_smc) , a \.r
4149
+ ld (ff_newcolor1_smc) , a \.r
4146
4150
4147
4151
ld hl , (_xmax) \.r ; smc to gain speedz in inner loops
4148
4152
ld (ff_xmax_smc) , hl \.r
@@ -4169,10 +4173,6 @@ _FloodFill:
4169
4173
ld (iy + 7 ) , 255 ; sp->dy = -1;
4170
4174
lea iy , iy + 8 ; sp++;
4171
4175
4172
- ld a , (ix + 12 )
4173
- ld (ff_newcolor0_smc) , a \.r
4174
- ld (ff_newcolor1_smc) , a \.r
4175
-
4176
4176
ff_doloop: ; do {
4177
4177
lea iy , iy - 8 ; sp--;
4178
4178
ld a , (iy + 7 )
@@ -4191,6 +4191,10 @@ ff_doloop: ; do {
4191
4191
mlt de
4192
4192
add hl , de
4193
4193
add hl , de
4194
+ ff_xmin_smc =$ + 1
4195
+ ld de , 0
4196
+ ff_oldcolor0_smc =$ + 1
4197
+ ld a , 0
4194
4198
4195
4199
jr + _
4196
4200
ff_forloop0: ; for (x=x1; !(x & 0x8000) && x>=xmin && p(x, y) == ov; x--) { s(x, y); }
@@ -4200,15 +4204,11 @@ ff_newcolor0_smc =$+1
4200
4204
dec bc
4201
4205
_: bit 7 , b
4202
4206
jr nz ,+ _
4203
- ff_xmin_smc =$ + 1
4204
- ld de , 0
4205
4207
or a , a
4206
4208
sbc hl , de
4207
- add hl , de
4208
4209
jr c ,+ _
4209
- ld a , (hl)
4210
- ff_color0_smc =$ + 1
4211
- cp a , 0
4210
+ add hl , de
4211
+ cp a , (hl)
4212
4212
jr z , ff_forloop0
4213
4213
4214
4214
_: ld (ix + 6 ) , bc
@@ -4218,8 +4218,8 @@ _: ld (ix+6),bc
4218
4218
jr nz ,+ _
4219
4219
or a , a
4220
4220
sbc hl , bc
4221
- add hl , bc
4222
4221
jp nc , ff_skip \.r ; if (!(x & 0x8000) && (unsigned)x>=x1) goto skip;
4222
+ add hl , bc
4223
4223
_: inc hl
4224
4224
ld (ix - 11 ) , hl ; l = x+1;
4225
4225
or a , a
@@ -4256,8 +4256,6 @@ ff_badpush0:
4256
4256
ld bc , (ix - 8 )
4257
4257
inc bc ; x = x1+1;
4258
4258
4259
- ld (ix + 6 ) , bc
4260
-
4261
4259
ld hl , (currDrawBuffer)
4262
4260
add hl , bc
4263
4261
ld e , (ix + 9 )
@@ -4267,21 +4265,23 @@ ff_badpush0:
4267
4265
add hl , de
4268
4266
ex de , hl ; de -> draw location
4269
4267
; do {
4270
- jr ff_innerdoloop ; for (; (unsigned)x<=xmax && gfx_getpixel(x, y) == ov; x++) { gfx_setpixel(x, y); }
4268
+ ff_forloop1start:
4269
+ ff_xmax_smc =$ + 1
4270
+ ld hl , 0
4271
+
4272
+ jr + _ ; for (; (unsigned)x<=xmax && gfx_getpixel(x, y) == ov; x++) { gfx_setpixel(x, y); }
4271
4273
ff_forloop1:
4272
4274
ff_newcolor1_smc =$ + 1
4273
4275
ld a , 0
4274
4276
ld (de) , a
4275
4277
inc de
4276
4278
inc bc
4277
- ff_xmax_smc =$ + 1
4278
- ff_innerdoloop:
4279
- ld hl , 0
4280
- or a , a
4279
+ _: or a , a
4281
4280
sbc hl , bc
4282
4281
jr c ,+ _
4282
+ add hl , bc
4283
4283
ld a , (de)
4284
- ff_color1_smc =$+ 1
4284
+ ff_oldcolor1_smc =$+ 1
4285
4285
cp a , 0
4286
4286
jr z , ff_forloop1
4287
4287
@@ -4301,21 +4301,20 @@ _: ld (ix+6),bc
4301
4301
ld a , (_ymax) \.r
4302
4302
cp a , e
4303
4303
jr c , ff_badpush1 ; compare y values
4304
+ dec bc
4305
+ ld (iy + 3 ) , bc
4304
4306
ld a , (ix + 9 )
4305
4307
ld (iy + 6 ) , a
4306
4308
ld bc , (ix - 11 )
4307
4309
ld (iy + 0 ) , bc
4308
- ld bc , (ix + 6 )
4309
- dec bc
4310
- ld (iy + 3 ) , bc
4311
4310
ld a , (ix - 4 )
4312
4311
ld (iy + 7 ) , a
4313
4312
lea iy , iy + 8
4314
4313
ff_badpush1:
4315
4314
ld hl , (ix - 15 ) ; if (x>x2+1) { push(y, x2+1, x-1, -dy); }
4315
+ ld bc , (ix + 6 )
4316
4316
inc hl
4317
4317
or a , a
4318
- ld bc , (ix + 6 )
4319
4318
sbc hl , bc
4320
4319
jr nc , ff_skip
4321
4320
lea de , ix - 24
@@ -4334,17 +4333,16 @@ ff_badpush1:
4334
4333
ld a , (_ymax) \.r
4335
4334
cp a , e
4336
4335
jr c , ff_badpush2 ; compare y values
4337
- ld a , (ix + 9 )
4338
- ld (iy + 6 ) , a
4336
+ dec bc
4337
+ ld (iy + 3 ) , bc
4339
4338
ld bc , (ix - 15 )
4340
4339
inc bc
4341
4340
ld (iy + 0 ) , bc
4342
- ld bc , (ix + 6 )
4343
- dec bc
4344
- ld (iy + 3 ) , bc
4345
4341
ld a , (ix - 4 )
4346
4342
neg
4347
4343
ld (iy + 7 ) , a
4344
+ ld a , (ix + 9 )
4345
+ ld (iy + 6 ) , a
4348
4346
lea iy , iy + 8
4349
4347
ff_skip:
4350
4348
ff_badpush2: ; skip: for (x++; (unsigned)x<=x2 && gfx_getpixel(x, y) != ov; x++);
@@ -4359,26 +4357,26 @@ ff_badpush2: ; skip: for (x++; (unsigned)x<=x2 &&
4359
4357
add hl , de
4360
4358
add hl , de
4361
4359
ex de , hl ; de -> draw location
4360
+ ld hl , (ix - 15 )
4362
4361
4363
4362
jr + _
4364
4363
ff_forloop2:
4365
4364
inc bc
4366
4365
inc de
4367
- _: ld hl , (ix - 15 )
4368
- or a , a
4366
+ _: or a , a
4369
4367
sbc hl , bc
4368
+ add hl , bc
4370
4369
jr c ,+ _
4371
4370
ld a , (de)
4372
- ff_color2_smc =$+ 1
4371
+ ff_oldcolor2_smc =$+ 1
4373
4372
cp a , 0
4374
4373
jr nz , ff_forloop2
4375
4374
4376
4375
_: ld (ix + 6 ) , bc
4377
4376
ld (ix - 11 ) , bc ; l = x;
4378
- ld hl , (ix - 15 )
4379
4377
or a , a
4380
4378
sbc hl , bc
4381
- jp nc , ff_innerdoloop \.r ; } while ((unsigned)x<=x2);
4379
+ jp nc , ff_forloop1start \.r ; } while ((unsigned)x<=x2);
4382
4380
4383
4381
ff_stacktop_smc =$ + 1
4384
4382
ld hl , 0
0 commit comments