Ticket #8248: actor-hit.diff
File actor-hit.diff, 5.7 KB (added by , 21 years ago) |
---|
-
scummvm/scumm/akos.cpp
diff -ur ScummVM-cvs20030614/scummvm/scumm/akos.cpp ScummVM-cvs20030614+hack/scummvm/scumm/akos.cpp
old new 353 353 354 354 do { 355 355 if (*scaleytab++ < _scaleY) { 356 masked = (y < _outheight) && v1.mask_ptr && ((mask[0] | mask[v1.imgbufoffs]) & maskbit); 356 if (_actorHitMode) { 357 if (color && (int16) y == _actorHitY && v1.x == _actorHitX) { 358 _actorHitResult = true; 359 return; 360 } 361 } else { 362 masked = (y < _outheight) && v1.mask_ptr && ((mask[0] | mask[v1.imgbufoffs]) & maskbit); 357 363 358 if (color && y < _outheight && !masked && !skip_column) { 359 pcolor = palette[color]; 360 if (_shadow_mode == 1) { 361 if (pcolor == 13) 362 pcolor = _shadow_table[*dst]; 363 } else if (_shadow_mode == 2) { 364 warning("codec1_spec2"); // TODO 365 } else if (_shadow_mode == 3) { 366 if (pcolor < 8) { 367 pcolor = (pcolor << 8) + *dst; 368 pcolor = _shadow_table[pcolor]; 364 if (color && y < _outheight && !masked && !skip_column) { 365 pcolor = palette[color]; 366 if (_shadow_mode == 1) { 367 if (pcolor == 13) 368 pcolor = _shadow_table[*dst]; 369 } else if (_shadow_mode == 2) { 370 warning("codec1_spec2"); // TODO 371 } else if (_shadow_mode == 3) { 372 if (pcolor < 8) { 373 pcolor = (pcolor << 8) + *dst; 374 pcolor = _shadow_table[pcolor]; 375 } 369 376 } 377 *dst = pcolor; 370 378 } 371 *dst = pcolor;372 379 } 373 380 dst += _outwidth; 374 381 mask += _numStrips; … … 644 651 v1.skip_width = _width; 645 652 v1.scaleXstep = _mirror ? 1 : -1; 646 653 647 _vm->updateDirtyRect(0, x_left, x_right, y_top, y_bottom, _dirty_id); 654 if (_actorHitMode) { 655 if (_actorHitX < x_left || _actorHitX >= x_right || _actorHitY < y_top || _actorHitY >= y_bottom) 656 return 0; 657 } else 658 _vm->updateDirtyRect(0, x_left, x_right, y_top, y_bottom, _dirty_id); 648 659 649 660 if (y_top >= (int)_outheight || y_bottom <= 0) 650 661 return 0; … … 717 728 byte AkosRenderer::codec5(int xmoveCur, int ymoveCur) { 718 729 int32 clip_left, clip_right, clip_top, clip_bottom, maxw, maxh; 719 730 731 if (_actorHitMode) { 732 warning("codec5: _actorHitMode not yet implemented"); 733 return 0; 734 } 735 720 736 if (!_mirror) { 721 737 clip_left = (_actorX - xmoveCur - _width) + 1; 722 738 } else { … … 923 939 int32 clip_left, clip_right, clip_top, clip_bottom, maxw, maxh; 924 940 int32 skip_x, skip_y, cur_x, cur_y; 925 941 const byte transparency = (_vm->_features & GF_HUMONGOUS) ? 0 : 255; 942 943 if (_actorHitMode) { 944 warning("codec16: _actorHitMode not yet implemented"); 945 return 0; 946 } 926 947 927 948 if (!_mirror) { 928 949 clip_left = (_actorX - xmoveCur - _width) + 1; -
scummvm/scumm/akos.h
diff -ur ScummVM-cvs20030614/scummvm/scumm/akos.h ScummVM-cvs20030614+hack/scummvm/scumm/akos.h
old new 65 65 aksq = 0; 66 66 akof = 0; 67 67 akcd = 0; 68 _actorHitMode = false; 68 69 } 69 70 71 bool _actorHitMode; 72 int16 _actorHitX, _actorHitY; 73 bool _actorHitResult; 74 70 75 void setPalette(byte *palette); 71 76 void setFacing(Actor *a); 72 77 void setCostume(int costume); -
scummvm/scumm/script_v8.cpp
diff -ur ScummVM-cvs20030614/scummvm/scumm/script_v8.cpp ScummVM-cvs20030614+hack/scummvm/scumm/script_v8.cpp
old new 22 22 #include "stdafx.h" 23 23 #include "scumm.h" 24 24 #include "actor.h" 25 #include "akos.h" 25 26 #include "charset.h" 26 27 #include "intern.h" 27 28 #include "sound.h" … … 1468 1469 } 1469 1470 case 0xD9: { // actorHit - used, for example, to detect ship collision 1470 1471 // during ship-to-ship combat. 1471 #if 01472 1472 Actor *a = derefActor(args[1], "actorHit"); 1473 int x = args[2]; 1474 int y = args[3]; 1475 1476 // TODO: this should perform a collision test, i.e. check if 1477 // point (x,y) lies on the given actor or not. 1478 // To achieve this, one needs to consider the current costume 1479 // etc. What the original code seems to do is to draw the 1480 // actor/costume (but maybe in a custom buffer?), and let the 1481 // draw code perform the hit test. 1482 // But I am not 100% clear on this. For example, it probably 1483 // shouldn't touch the gfx usage bits, and some other things... 1484 // So maybe we need dedicated code for this after all? 1485 1486 warning("actorHit(%d, %d, %d) NYI", args[1], x, y); 1487 1488 #endif 1489 1490 push(1); // FIXME - for now always return 1 1491 /* 1492 // Rough sketch, thanks to DanielFox and ludde 1493 struct SomeStruct { 1494 int RoomHeight, RoomWidth; 1495 byte *ScreenBuffer; 1496 } 1497 1498 dword_4FC150 = args[3]; // X 1499 dword_4FC154 = args[2]; // Y 1500 Actor &a = pActors[args[1]]; 1501 Point rel = GetScreenCoordsRelativeToRoom(), pt, scale; 1502 SomeStruct tmp; 1503 1504 pt.x = a.x + a.field_18 - rel.x; // 18/1C are some kind of 1505 pt.y = a.y + a.field_1C - rel.y; // X/Y offsets... 1506 scale.x = a.scale_x; 1507 scale.y = a.scale_y; 1508 1509 dword_4FC148 = 2; 1510 graphics_getBuffer1Info(&tmp); // Some kind of get_virtscreen? 1511 chore_drawActor(tmp, actor_nr, &pt, &scale); 1512 1513 if (dword_4FC148 != 1) // Guess this is changed by 1514 dword_4FC148 = 0; // chore_drawActor 1515 push(dword_4FC148); 1516 */ 1473 AkosRenderer *ar = (AkosRenderer *) _costumeRenderer; 1474 bool old_need_redraw = a->needRedraw; 1475 1476 ar->_actorHitX = args[2]; 1477 ar->_actorHitY = args[3] + _screenTop; 1478 ar->_actorHitMode = true; 1479 ar->_actorHitResult = false; 1480 1481 a->needRedraw = true; 1482 a->drawActorCostume(); 1483 a->needRedraw = old_need_redraw; 1484 1485 ar->_actorHitMode = false; 1486 push(ar->_actorHitResult); 1517 1487 break; 1518 1488 } 1519 1489 case 0xDA: // lipSyncWidth