annotate src/gba/Mode0.cpp @ 359:8c474d1d6956

script: got leomnades and TM13, shopping is complete.
author Robert McIntyre <rlm@mit.edu>
date Mon, 09 Apr 2012 08:27:45 -0500
parents f9f4f1b99eed
children
rev   line source
rlm@1 1 #include "GBAGfx.h"
rlm@1 2 #include "GBAGlobals.h"
rlm@1 3
rlm@1 4 void mode0RenderLine()
rlm@1 5 {
rlm@1 6 u16 *palette = (u16 *)paletteRAM;
rlm@1 7
rlm@1 8 if (DISPCNT & 0x80)
rlm@1 9 {
rlm@1 10 for (int x = 0; x < 240; x++)
rlm@1 11 {
rlm@1 12 lineMix[x] = 0x7fff;
rlm@1 13 }
rlm@1 14 return;
rlm@1 15 }
rlm@1 16
rlm@1 17 if (layerEnable & 0x0100)
rlm@1 18 {
rlm@1 19 gfxDrawTextScreen(BG0CNT, BG0HOFS, BG0VOFS, line0);
rlm@1 20 }
rlm@1 21
rlm@1 22 if (layerEnable & 0x0200)
rlm@1 23 {
rlm@1 24 gfxDrawTextScreen(BG1CNT, BG1HOFS, BG1VOFS, line1);
rlm@1 25 }
rlm@1 26
rlm@1 27 if (layerEnable & 0x0400)
rlm@1 28 {
rlm@1 29 gfxDrawTextScreen(BG2CNT, BG2HOFS, BG2VOFS, line2);
rlm@1 30 }
rlm@1 31
rlm@1 32 if (layerEnable & 0x0800)
rlm@1 33 {
rlm@1 34 gfxDrawTextScreen(BG3CNT, BG3HOFS, BG3VOFS, line3);
rlm@1 35 }
rlm@1 36
rlm@1 37 gfxDrawSprites(lineOBJ);
rlm@1 38
rlm@1 39 u32 backdrop = (READ16LE(&palette[0]) | 0x30000000);
rlm@1 40
rlm@1 41 for (int x = 0; x < 240; x++)
rlm@1 42 {
rlm@1 43 u32 color = backdrop;
rlm@1 44 u8 top = 0x20;
rlm@1 45
rlm@1 46 if (line0[x] < color)
rlm@1 47 {
rlm@1 48 color = line0[x];
rlm@1 49 top = 0x01;
rlm@1 50 }
rlm@1 51
rlm@1 52 if ((u8)(line1[x]>>24) < (u8)(color >> 24))
rlm@1 53 {
rlm@1 54 color = line1[x];
rlm@1 55 top = 0x02;
rlm@1 56 }
rlm@1 57
rlm@1 58 if ((u8)(line2[x]>>24) < (u8)(color >> 24))
rlm@1 59 {
rlm@1 60 color = line2[x];
rlm@1 61 top = 0x04;
rlm@1 62 }
rlm@1 63
rlm@1 64 if ((u8)(line3[x]>>24) < (u8)(color >> 24))
rlm@1 65 {
rlm@1 66 color = line3[x];
rlm@1 67 top = 0x08;
rlm@1 68 }
rlm@1 69
rlm@1 70 if ((u8)(lineOBJ[x]>>24) < (u8)(color >> 24))
rlm@1 71 {
rlm@1 72 color = lineOBJ[x];
rlm@1 73 top = 0x10;
rlm@1 74 }
rlm@1 75
rlm@1 76 if ((top & 0x10) && (color & 0x00010000))
rlm@1 77 {
rlm@1 78 // semi-transparent OBJ
rlm@1 79 u32 back = backdrop;
rlm@1 80 u8 top2 = 0x20;
rlm@1 81
rlm@1 82 if ((u8)(line0[x]>>24) < (u8)(back >> 24))
rlm@1 83 {
rlm@1 84 back = line0[x];
rlm@1 85 top2 = 0x01;
rlm@1 86 }
rlm@1 87
rlm@1 88 if ((u8)(line1[x]>>24) < (u8)(back >> 24))
rlm@1 89 {
rlm@1 90 back = line1[x];
rlm@1 91 top2 = 0x02;
rlm@1 92 }
rlm@1 93
rlm@1 94 if ((u8)(line2[x]>>24) < (u8)(back >> 24))
rlm@1 95 {
rlm@1 96 back = line2[x];
rlm@1 97 top2 = 0x04;
rlm@1 98 }
rlm@1 99
rlm@1 100 if ((u8)(line3[x]>>24) < (u8)(back >> 24))
rlm@1 101 {
rlm@1 102 back = line3[x];
rlm@1 103 top2 = 0x08;
rlm@1 104 }
rlm@1 105
rlm@1 106 if (top2 & (BLDMOD>>8))
rlm@1 107 color = gfxAlphaBlend(color, back,
rlm@1 108 coeff[COLEV & 0x1F],
rlm@1 109 coeff[(COLEV >> 8) & 0x1F]);
rlm@1 110 else
rlm@1 111 {
rlm@1 112 switch ((BLDMOD >> 6) & 3)
rlm@1 113 {
rlm@1 114 case 2:
rlm@1 115 if (BLDMOD & top)
rlm@1 116 color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
rlm@1 117 break;
rlm@1 118 case 3:
rlm@1 119 if (BLDMOD & top)
rlm@1 120 color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
rlm@1 121 break;
rlm@1 122 }
rlm@1 123 }
rlm@1 124 }
rlm@1 125
rlm@1 126 lineMix[x] = color;
rlm@1 127 }
rlm@1 128 }
rlm@1 129
rlm@1 130 void mode0RenderLineNoWindow()
rlm@1 131 {
rlm@1 132 u16 *palette = (u16 *)paletteRAM;
rlm@1 133
rlm@1 134 if (DISPCNT & 0x80)
rlm@1 135 {
rlm@1 136 for (int x = 0; x < 240; x++)
rlm@1 137 {
rlm@1 138 lineMix[x] = 0x7fff;
rlm@1 139 }
rlm@1 140 return;
rlm@1 141 }
rlm@1 142
rlm@1 143 if (layerEnable & 0x0100)
rlm@1 144 {
rlm@1 145 gfxDrawTextScreen(BG0CNT, BG0HOFS, BG0VOFS, line0);
rlm@1 146 }
rlm@1 147
rlm@1 148 if (layerEnable & 0x0200)
rlm@1 149 {
rlm@1 150 gfxDrawTextScreen(BG1CNT, BG1HOFS, BG1VOFS, line1);
rlm@1 151 }
rlm@1 152
rlm@1 153 if (layerEnable & 0x0400)
rlm@1 154 {
rlm@1 155 gfxDrawTextScreen(BG2CNT, BG2HOFS, BG2VOFS, line2);
rlm@1 156 }
rlm@1 157
rlm@1 158 if (layerEnable & 0x0800)
rlm@1 159 {
rlm@1 160 gfxDrawTextScreen(BG3CNT, BG3HOFS, BG3VOFS, line3);
rlm@1 161 }
rlm@1 162
rlm@1 163 gfxDrawSprites(lineOBJ);
rlm@1 164
rlm@1 165 u32 backdrop = (READ16LE(&palette[0]) | 0x30000000);
rlm@1 166
rlm@1 167 int effect = (BLDMOD >> 6) & 3;
rlm@1 168
rlm@1 169 for (int x = 0; x < 240; x++)
rlm@1 170 {
rlm@1 171 u32 color = backdrop;
rlm@1 172 u8 top = 0x20;
rlm@1 173
rlm@1 174 if (line0[x] < color)
rlm@1 175 {
rlm@1 176 color = line0[x];
rlm@1 177 top = 0x01;
rlm@1 178 }
rlm@1 179
rlm@1 180 if (line1[x] < (color & 0xFF000000))
rlm@1 181 {
rlm@1 182 color = line1[x];
rlm@1 183 top = 0x02;
rlm@1 184 }
rlm@1 185
rlm@1 186 if (line2[x] < (color & 0xFF000000))
rlm@1 187 {
rlm@1 188 color = line2[x];
rlm@1 189 top = 0x04;
rlm@1 190 }
rlm@1 191
rlm@1 192 if (line3[x] < (color & 0xFF000000))
rlm@1 193 {
rlm@1 194 color = line3[x];
rlm@1 195 top = 0x08;
rlm@1 196 }
rlm@1 197
rlm@1 198 if (lineOBJ[x] < (color & 0xFF000000))
rlm@1 199 {
rlm@1 200 color = lineOBJ[x];
rlm@1 201 top = 0x10;
rlm@1 202 }
rlm@1 203
rlm@1 204 if (!(color & 0x00010000))
rlm@1 205 {
rlm@1 206 switch (effect)
rlm@1 207 {
rlm@1 208 case 0:
rlm@1 209 break;
rlm@1 210 case 1:
rlm@1 211 {
rlm@1 212 if (top & BLDMOD)
rlm@1 213 {
rlm@1 214 u32 back = backdrop;
rlm@1 215 u8 top2 = 0x20;
rlm@1 216 if (line0[x] < back)
rlm@1 217 {
rlm@1 218 if (top != 0x01)
rlm@1 219 {
rlm@1 220 back = line0[x];
rlm@1 221 top2 = 0x01;
rlm@1 222 }
rlm@1 223 }
rlm@1 224
rlm@1 225 if (line1[x] < (back & 0xFF000000))
rlm@1 226 {
rlm@1 227 if (top != 0x02)
rlm@1 228 {
rlm@1 229 back = line1[x];
rlm@1 230 top2 = 0x02;
rlm@1 231 }
rlm@1 232 }
rlm@1 233
rlm@1 234 if (line2[x] < (back & 0xFF000000))
rlm@1 235 {
rlm@1 236 if (top != 0x04)
rlm@1 237 {
rlm@1 238 back = line2[x];
rlm@1 239 top2 = 0x04;
rlm@1 240 }
rlm@1 241 }
rlm@1 242
rlm@1 243 if (line3[x] < (back & 0xFF000000))
rlm@1 244 {
rlm@1 245 if (top != 0x08)
rlm@1 246 {
rlm@1 247 back = line3[x];
rlm@1 248 top2 = 0x08;
rlm@1 249 }
rlm@1 250 }
rlm@1 251
rlm@1 252 if (lineOBJ[x] < (back & 0xFF000000))
rlm@1 253 {
rlm@1 254 if (top != 0x10)
rlm@1 255 {
rlm@1 256 back = lineOBJ[x];
rlm@1 257 top2 = 0x10;
rlm@1 258 }
rlm@1 259 }
rlm@1 260
rlm@1 261 if (top2 & (BLDMOD>>8))
rlm@1 262 color = gfxAlphaBlend(color, back,
rlm@1 263 coeff[COLEV & 0x1F],
rlm@1 264 coeff[(COLEV >> 8) & 0x1F]);
rlm@1 265 }
rlm@1 266 break;
rlm@1 267 }
rlm@1 268 case 2:
rlm@1 269 if (BLDMOD & top)
rlm@1 270 color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
rlm@1 271 break;
rlm@1 272 case 3:
rlm@1 273 if (BLDMOD & top)
rlm@1 274 color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
rlm@1 275 break;
rlm@1 276 }
rlm@1 277 }
rlm@1 278 else
rlm@1 279 {
rlm@1 280 // semi-transparent OBJ
rlm@1 281 u32 back = backdrop;
rlm@1 282 u8 top2 = 0x20;
rlm@1 283
rlm@1 284 if (line0[x] < back)
rlm@1 285 {
rlm@1 286 back = line0[x];
rlm@1 287 top2 = 0x01;
rlm@1 288 }
rlm@1 289
rlm@1 290 if (line1[x] < (back & 0xFF000000))
rlm@1 291 {
rlm@1 292 back = line1[x];
rlm@1 293 top2 = 0x02;
rlm@1 294 }
rlm@1 295
rlm@1 296 if (line2[x] < (back & 0xFF000000))
rlm@1 297 {
rlm@1 298 back = line2[x];
rlm@1 299 top2 = 0x04;
rlm@1 300 }
rlm@1 301
rlm@1 302 if (line3[x] < (back & 0xFF000000))
rlm@1 303 {
rlm@1 304 back = line3[x];
rlm@1 305 top2 = 0x08;
rlm@1 306 }
rlm@1 307
rlm@1 308 if (top2 & (BLDMOD>>8))
rlm@1 309 color = gfxAlphaBlend(color, back,
rlm@1 310 coeff[COLEV & 0x1F],
rlm@1 311 coeff[(COLEV >> 8) & 0x1F]);
rlm@1 312 else
rlm@1 313 {
rlm@1 314 switch ((BLDMOD >> 6) & 3)
rlm@1 315 {
rlm@1 316 case 2:
rlm@1 317 if (BLDMOD & top)
rlm@1 318 color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
rlm@1 319 break;
rlm@1 320 case 3:
rlm@1 321 if (BLDMOD & top)
rlm@1 322 color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
rlm@1 323 break;
rlm@1 324 }
rlm@1 325 }
rlm@1 326 }
rlm@1 327
rlm@1 328 lineMix[x] = color;
rlm@1 329 }
rlm@1 330 }
rlm@1 331
rlm@1 332 void mode0RenderLineAll()
rlm@1 333 {
rlm@1 334 u16 *palette = (u16 *)paletteRAM;
rlm@1 335
rlm@1 336 if (DISPCNT & 0x80)
rlm@1 337 {
rlm@1 338 for (int x = 0; x < 240; x++)
rlm@1 339 {
rlm@1 340 lineMix[x] = 0x7fff;
rlm@1 341 }
rlm@1 342 return;
rlm@1 343 }
rlm@1 344
rlm@1 345 bool inWindow0 = false;
rlm@1 346 bool inWindow1 = false;
rlm@1 347
rlm@1 348 if (layerEnable & 0x2000)
rlm@1 349 {
rlm@1 350 u8 v0 = WIN0V >> 8;
rlm@1 351 u8 v1 = WIN0V & 255;
rlm@1 352 inWindow0 = ((v0 == v1) && (v0 >= 0xe8));
rlm@1 353 if (v1 >= v0)
rlm@1 354 inWindow0 |= (VCOUNT >= v0 && VCOUNT < v1);
rlm@1 355 else
rlm@1 356 inWindow0 |= (VCOUNT >= v0 || VCOUNT < v1);
rlm@1 357 }
rlm@1 358 if (layerEnable & 0x4000)
rlm@1 359 {
rlm@1 360 u8 v0 = WIN1V >> 8;
rlm@1 361 u8 v1 = WIN1V & 255;
rlm@1 362 inWindow1 = ((v0 == v1) && (v0 >= 0xe8));
rlm@1 363 if (v1 >= v0)
rlm@1 364 inWindow1 |= (VCOUNT >= v0 && VCOUNT < v1);
rlm@1 365 else
rlm@1 366 inWindow1 |= (VCOUNT >= v0 || VCOUNT < v1);
rlm@1 367 }
rlm@1 368
rlm@1 369 if ((layerEnable & 0x0100))
rlm@1 370 {
rlm@1 371 gfxDrawTextScreen(BG0CNT, BG0HOFS, BG0VOFS, line0);
rlm@1 372 }
rlm@1 373
rlm@1 374 if ((layerEnable & 0x0200))
rlm@1 375 {
rlm@1 376 gfxDrawTextScreen(BG1CNT, BG1HOFS, BG1VOFS, line1);
rlm@1 377 }
rlm@1 378
rlm@1 379 if ((layerEnable & 0x0400))
rlm@1 380 {
rlm@1 381 gfxDrawTextScreen(BG2CNT, BG2HOFS, BG2VOFS, line2);
rlm@1 382 }
rlm@1 383
rlm@1 384 if ((layerEnable & 0x0800))
rlm@1 385 {
rlm@1 386 gfxDrawTextScreen(BG3CNT, BG3HOFS, BG3VOFS, line3);
rlm@1 387 }
rlm@1 388
rlm@1 389 gfxDrawSprites(lineOBJ);
rlm@1 390 gfxDrawOBJWin(lineOBJWin);
rlm@1 391
rlm@1 392 u32 backdrop = (READ16LE(&palette[0]) | 0x30000000);
rlm@1 393
rlm@1 394 u8 inWin0Mask = WININ & 0xFF;
rlm@1 395 u8 inWin1Mask = WININ >> 8;
rlm@1 396 u8 outMask = WINOUT & 0xFF;
rlm@1 397
rlm@1 398 for (int x = 0; x < 240; x++)
rlm@1 399 {
rlm@1 400 u32 color = backdrop;
rlm@1 401 u8 top = 0x20;
rlm@1 402 u8 mask = outMask;
rlm@1 403
rlm@1 404 if (!(lineOBJWin[x] & 0x80000000))
rlm@1 405 {
rlm@1 406 mask = WINOUT >> 8;
rlm@1 407 }
rlm@1 408
rlm@1 409 if (inWindow1)
rlm@1 410 {
rlm@1 411 if (gfxInWin1[x])
rlm@1 412 mask = inWin1Mask;
rlm@1 413 }
rlm@1 414
rlm@1 415 if (inWindow0)
rlm@1 416 {
rlm@1 417 if (gfxInWin0[x])
rlm@1 418 {
rlm@1 419 mask = inWin0Mask;
rlm@1 420 }
rlm@1 421 }
rlm@1 422
rlm@1 423 if ((mask & 1) && (line0[x] < color))
rlm@1 424 {
rlm@1 425 color = line0[x];
rlm@1 426 top = 0x01;
rlm@1 427 }
rlm@1 428
rlm@1 429 if ((mask & 2) && ((u8)(line1[x]>>24) < (u8)(color >> 24)))
rlm@1 430 {
rlm@1 431 color = line1[x];
rlm@1 432 top = 0x02;
rlm@1 433 }
rlm@1 434
rlm@1 435 if ((mask & 4) && ((u8)(line2[x]>>24) < (u8)(color >> 24)))
rlm@1 436 {
rlm@1 437 color = line2[x];
rlm@1 438 top = 0x04;
rlm@1 439 }
rlm@1 440
rlm@1 441 if ((mask & 8) && ((u8)(line3[x]>>24) < (u8)(color >> 24)))
rlm@1 442 {
rlm@1 443 color = line3[x];
rlm@1 444 top = 0x08;
rlm@1 445 }
rlm@1 446
rlm@1 447 if ((mask & 16) && ((u8)(lineOBJ[x]>>24) < (u8)(color >> 24)))
rlm@1 448 {
rlm@1 449 color = lineOBJ[x];
rlm@1 450 top = 0x10;
rlm@1 451 }
rlm@1 452
rlm@1 453 // special FX on in the window
rlm@1 454 if (mask & 32)
rlm@1 455 {
rlm@1 456 if (!(color & 0x00010000))
rlm@1 457 {
rlm@1 458 switch ((BLDMOD >> 6) & 3)
rlm@1 459 {
rlm@1 460 case 0:
rlm@1 461 break;
rlm@1 462 case 1:
rlm@1 463 {
rlm@1 464 if (top & BLDMOD)
rlm@1 465 {
rlm@1 466 u32 back = backdrop;
rlm@1 467 u8 top2 = 0x20;
rlm@1 468 if ((mask & 1) && (u8)(line0[x]>>24) < (u8)(back >> 24))
rlm@1 469 {
rlm@1 470 if (top != 0x01)
rlm@1 471 {
rlm@1 472 back = line0[x];
rlm@1 473 top2 = 0x01;
rlm@1 474 }
rlm@1 475 }
rlm@1 476
rlm@1 477 if ((mask & 2) && (u8)(line1[x]>>24) < (u8)(back >> 24))
rlm@1 478 {
rlm@1 479 if (top != 0x02)
rlm@1 480 {
rlm@1 481 back = line1[x];
rlm@1 482 top2 = 0x02;
rlm@1 483 }
rlm@1 484 }
rlm@1 485
rlm@1 486 if ((mask & 4) && (u8)(line2[x]>>24) < (u8)(back >> 24))
rlm@1 487 {
rlm@1 488 if (top != 0x04)
rlm@1 489 {
rlm@1 490 back = line2[x];
rlm@1 491 top2 = 0x04;
rlm@1 492 }
rlm@1 493 }
rlm@1 494
rlm@1 495 if ((mask & 8) && (u8)(line3[x]>>24) < (u8)(back >> 24))
rlm@1 496 {
rlm@1 497 if (top != 0x08)
rlm@1 498 {
rlm@1 499 back = line3[x];
rlm@1 500 top2 = 0x08;
rlm@1 501 }
rlm@1 502 }
rlm@1 503
rlm@1 504 if ((mask & 16) && (u8)(lineOBJ[x]>>24) < (u8)(back >> 24))
rlm@1 505 {
rlm@1 506 if (top != 0x10)
rlm@1 507 {
rlm@1 508 back = lineOBJ[x];
rlm@1 509 top2 = 0x10;
rlm@1 510 }
rlm@1 511 }
rlm@1 512
rlm@1 513 if (top2 & (BLDMOD>>8))
rlm@1 514 color = gfxAlphaBlend(color, back,
rlm@1 515 coeff[COLEV & 0x1F],
rlm@1 516 coeff[(COLEV >> 8) & 0x1F]);
rlm@1 517 }
rlm@1 518 break;
rlm@1 519 }
rlm@1 520 case 2:
rlm@1 521 if (BLDMOD & top)
rlm@1 522 color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
rlm@1 523 break;
rlm@1 524 case 3:
rlm@1 525 if (BLDMOD & top)
rlm@1 526 color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
rlm@1 527 break;
rlm@1 528 }
rlm@1 529 }
rlm@1 530 else
rlm@1 531 {
rlm@1 532 // semi-transparent OBJ
rlm@1 533 u32 back = backdrop;
rlm@1 534 u8 top2 = 0x20;
rlm@1 535
rlm@1 536 if ((mask & 1) && ((u8)(line0[x]>>24) < (u8)(back >> 24)))
rlm@1 537 {
rlm@1 538 back = line0[x];
rlm@1 539 top2 = 0x01;
rlm@1 540 }
rlm@1 541
rlm@1 542 if ((mask & 2) && ((u8)(line1[x]>>24) < (u8)(back >> 24)))
rlm@1 543 {
rlm@1 544 back = line1[x];
rlm@1 545 top2 = 0x02;
rlm@1 546 }
rlm@1 547
rlm@1 548 if ((mask & 4) && ((u8)(line2[x]>>24) < (u8)(back >> 24)))
rlm@1 549 {
rlm@1 550 back = line2[x];
rlm@1 551 top2 = 0x04;
rlm@1 552 }
rlm@1 553
rlm@1 554 if ((mask & 8) && ((u8)(line3[x]>>24) < (u8)(back >> 24)))
rlm@1 555 {
rlm@1 556 back = line3[x];
rlm@1 557 top2 = 0x08;
rlm@1 558 }
rlm@1 559
rlm@1 560 if (top2 & (BLDMOD>>8))
rlm@1 561 color = gfxAlphaBlend(color, back,
rlm@1 562 coeff[COLEV & 0x1F],
rlm@1 563 coeff[(COLEV >> 8) & 0x1F]);
rlm@1 564 else
rlm@1 565 {
rlm@1 566 switch ((BLDMOD >> 6) & 3)
rlm@1 567 {
rlm@1 568 case 2:
rlm@1 569 if (BLDMOD & top)
rlm@1 570 color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
rlm@1 571 break;
rlm@1 572 case 3:
rlm@1 573 if (BLDMOD & top)
rlm@1 574 color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
rlm@1 575 break;
rlm@1 576 }
rlm@1 577 }
rlm@1 578 }
rlm@1 579 }
rlm@1 580 else if (color & 0x00010000)
rlm@1 581 {
rlm@1 582 // semi-transparent OBJ
rlm@1 583 u32 back = backdrop;
rlm@1 584 u8 top2 = 0x20;
rlm@1 585
rlm@1 586 if ((mask & 1) && ((u8)(line0[x]>>24) < (u8)(back >> 24)))
rlm@1 587 {
rlm@1 588 back = line0[x];
rlm@1 589 top2 = 0x01;
rlm@1 590 }
rlm@1 591
rlm@1 592 if ((mask & 2) && ((u8)(line1[x]>>24) < (u8)(back >> 24)))
rlm@1 593 {
rlm@1 594 back = line1[x];
rlm@1 595 top2 = 0x02;
rlm@1 596 }
rlm@1 597
rlm@1 598 if ((mask & 4) && ((u8)(line2[x]>>24) < (u8)(back >> 24)))
rlm@1 599 {
rlm@1 600 back = line2[x];
rlm@1 601 top2 = 0x04;
rlm@1 602 }
rlm@1 603
rlm@1 604 if ((mask & 8) && ((u8)(line3[x]>>24) < (u8)(back >> 24)))
rlm@1 605 {
rlm@1 606 back = line3[x];
rlm@1 607 top2 = 0x08;
rlm@1 608 }
rlm@1 609
rlm@1 610 if (top2 & (BLDMOD>>8))
rlm@1 611 color = gfxAlphaBlend(color, back,
rlm@1 612 coeff[COLEV & 0x1F],
rlm@1 613 coeff[(COLEV >> 8) & 0x1F]);
rlm@1 614 else
rlm@1 615 {
rlm@1 616 switch ((BLDMOD >> 6) & 3)
rlm@1 617 {
rlm@1 618 case 2:
rlm@1 619 if (BLDMOD & top)
rlm@1 620 color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
rlm@1 621 break;
rlm@1 622 case 3:
rlm@1 623 if (BLDMOD & top)
rlm@1 624 color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
rlm@1 625 break;
rlm@1 626 }
rlm@1 627 }
rlm@1 628 }
rlm@1 629
rlm@1 630 lineMix[x] = color;
rlm@1 631 }
rlm@1 632 }
rlm@1 633