[Scummvm-git-logs] scummvm master -> f48a0ac1c1ac8214dfb2b88134787ebb8dbf4c17
sev-
noreply at scummvm.org
Fri Apr 26 21:22:04 UTC 2024
This automated email contains information about 71 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
823aca6784 SCUMM: HE: Preliminar clean up for WIZ rewrite
b3f60f4414 SCUMM: HE: Preliminar clean up for WIZ rewrite pt.2
e7f979ee9f SCUMM: HE: Preliminar clean up for WIZ rewrite pt.3
baa1e06d29 SCUMM: HE: Preliminar clean up for WIZ rewrite pt.4
f17fe7413c SCUMM: HE: Begin WIZ and graphics rewrite
4761c31476 SCUMM: HE: Fix pixelDepth value for 16-bit color games
a64d977fdb SCUMM: HE: Add some basic WIZ primitives
be804a82eb SCUMM: HE: Fix primitives after testing them
289148dcef SCUMM: HE: Continue implementing WIZ stuff
0a3b6c49b2 SCUMM: HE: Implement FloodFill operation
d64a379d21 SCUMM: HE: Begin porting Wiz and other graphics code
4f98334ef4 SCUMM: HE: Add auxiliary compression routines and more stuff
0b0dc876a0 SCUMM: HE: Add remaining compression routines
50a3ad80ab SCUMM: HE: Fix Wiz warping
0da69cc866 SCUMM: HE: Actually fix Wiz warping
b4c4f58c40 SCUMM: HE: Fix TRLE FLIP comp
b19c4b772d SCUMM: HE: Overhaul more of the GFX system
4bcfff35bd SCUMM: HE: Bump save version
483ac31ced SCUMM: HE: Relabel Polygon functions
50d18e054d SCUMM: HE: Implement proper sprite collision
7040db13af SCUMM: HE: Clean-up pass
c4cac1f148 SCUMM: HE: Fix some transparency issues
0ae4143e6f SCUMM: HE: Fix more 8-bit vs 16-bit discrepancies
9dd2ea4e43 SCUMM: HE: Re-implement WIZ text and Aux images
2da4608506 SCUMM: HE: Re-implement BMAP routines
86b9af993a SCUMM: HE: Re-implement AKOS TRLE drawing
9d1ebb0cba SCUMM: HE: Fix TRLE AKOS cels not being erased
a6ebc81784 SCUMM: HE: Fix several sprite rendering issues
0f91f728af SCUMM: HE: More HE95 changes
7f004920a4 SCUMM: HE: Fix Aux Images rendering
5ac8ea75a0 SCUMM: HE: Fix sub HE95 games not starting
ce193359e1 SCUMM: HE: Fix more 8-bit vs 16-bit issues
8d416fbbc7 SCUMM: HE: Fix remap call
bb509c68f0 SCUMM: HE: More fixes
7d46b01e40 SCUMM: HE: More 8-bit vs 16-bit fixes
8b69b3eccd SCUMM: HE: Compression function names cleanup
6bb2a93a0e SCUMM: HE: Fix WARPWIZ issue
9f460f6cf5 SCUMM: HE: More cleanup and changes
1f493dec1a SCUMM: HE: Add new HE variant (99.5) as game feature flag
055d0f1ff1 SCUMM: HE: Fix TRLE compression rect
d4d2ce6fb4 SCUMM: HE: Fix crash in Backyard Football
92fd7a6a5c SCUMM: HE: Fix some games crashing at startup
a3e147ca3d SCUMM: HE: Mark actual HE99.5 games in detection table
1b7836e6fa SCUMM: HE: Fix palette remapping issues
f5714eaefd SCUMM: HE: Fix cursor wrong colors
65e391dcef SCUMM: HE: Remove useless casts
a136275a92 SCUMM: HE: Fix some Spy Fox 1 (HE90) issues
d632a18996 SCUMM: HE: Fix some mem leaks
35939dd19d SCUMM: HE: Fix warnings
e70935815d SCUMM: HE: Fix AUX animations
c65097c055 SCUMM: HE: Hopefully fix palette remapping for good
e4b9e601d4 SCUMM: HE: Fix sprite ordering for HE95
25855773e7 SCUMM: HE: Fix pixel color retrieval
9cd1e63b53 SCUMM: HE: Fix Backyard games sprite ordering issues
30760ad716 SCUMM: HE: Swap some tags with MKTAG macros
12f511928a SCUMM: HE: Cleanup
6c5949d8de SCUMM: HE: Fix glitched bottom left score table on BASEBALL97
ee2bf64267 SCUMM: HE: Fix typo in palette remapping function
8f4b909f38 SCUMM: HE: Comments and styling clean-up
1ddcbf1d6f SCUMM: HE: Begin implementing Moonbase Commander graphics hooks
1d1b7172fd SCUMM: HE: Fix null pointer access
6b5c870397 SCUMM: HE: Implement more Moonbase graphics
ea66c16d3c SCUMM: HE: Clean up and finish hooking up external U32 prototypes
bdc1608f87 SCUMM: HE: Clean-up and removal of development functions
3cddf27f99 SCUMM: HE: Reimplement Moonbase gfx T14 routine
184cd608f8 SCUMM: HE: Reimplement Moonbase distortion routines
ec61ee97d8 SCUMM: HE: Fix build when ENABLE_HE is not defined
6192dfe5c0 SCUMM: HE: Fix build and warnings
6f5878aed5 SCUMM: HE: Hopefully fix MSVC win32 errors
e338e0912a SCUMM: HE: Fix formatting
f48a0ac1c1 SCUMM: HE: Fix another win32 build error
Commit: 823aca6784fb0949bce0895d4c4c8f51d67b2c8d
https://github.com/scummvm/scummvm/commit/823aca6784fb0949bce0895d4c4c8f51d67b2c8d
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Preliminar clean up for WIZ rewrite
Changed paths:
engines/scumm/he/intern_he.h
engines/scumm/he/script_v100he.cpp
engines/scumm/he/script_v90he.cpp
engines/scumm/he/sprite_he.h
diff --git a/engines/scumm/he/intern_he.h b/engines/scumm/he/intern_he.h
index 255b58a8ac3..40f17715a0d 100644
--- a/engines/scumm/he/intern_he.h
+++ b/engines/scumm/he/intern_he.h
@@ -576,6 +576,7 @@ protected:
SO_DRAW_XPOS = 38,
SO_DRAW_YPOS = 39,
SO_PROPERTY = 42,
+ SO_PRIORITY = 43,
SO_MOVE = 44,
SO_FIND = 45,
SO_GENERAL_CLIP_STATE = 46,
@@ -588,9 +589,17 @@ protected:
SO_ANGLE = 53,
SO_SET_FLAGS = 54,
SO_INIT = 57,
+ SO_AT_IMAGE = 62,
+ SO_IMAGE = 63,
+ SO_AT = 65,
+ SO_ERASE = 68,
+ SO_TO = 70,
SO_STEP_DIST = 77,
SO_ANIMATION = 82,
SO_PALETTE = 86,
+ SO_SCALE = 92,
+ SO_ANIMATION_SPEED = 97,
+ SO_SHADOW = 98,
SO_UPDATE = 124,
SO_CLASS = 125,
SO_SORT = 129,
@@ -609,7 +618,11 @@ protected:
SO_FONT_RENDER = 143,
SO_CLOSE = 165,
SO_RENDER_ELLIPSE = 189,
+ SO_REC = 195,
SO_FONT_END = 196,
+ SO_ACTOR_VARIABLE = 198,
+ SO_BAK = 199,
+ SO_BAKREC = 200
};
struct VideoParameters {
@@ -701,8 +714,8 @@ protected:
void o90_atan2();
void o90_getSegmentAngle();
void o90_getActorData();
- void o90_startScriptUnk();
- void o90_jumpToScriptUnk();
+ void o90_priorityStartScript();
+ void o90_priorityChainScript();
void o90_videoOps();
void o90_getVideoData();
void o90_wizImageOps();
@@ -727,7 +740,7 @@ protected:
void o90_getObjectData();
void o90_getPaletteData();
void o90_paletteOps();
- void o90_fontUnk();
+ void o90_fontEnum();
void o90_getActorAnimProgress();
void o90_kernelGetFunctions();
void o90_kernelSetFunctions();
diff --git a/engines/scumm/he/script_v100he.cpp b/engines/scumm/he/script_v100he.cpp
index 6246e60254e..ee2b53a1964 100644
--- a/engines/scumm/he/script_v100he.cpp
+++ b/engines/scumm/he/script_v100he.cpp
@@ -256,7 +256,7 @@ void ScummEngine_v100he::setupOpcodes() {
OPCODE(0xb0, o72_findObjectWithClassOf);
OPCODE(0xb1, o71_polygonHit);
OPCODE(0xb2, o90_getLinesIntersectionPoint);
- OPCODE(0xb3, o90_fontUnk);
+ OPCODE(0xb3, o90_fontEnum);
/* B4 */
OPCODE(0xb4, o72_getNumFreeArrays);
OPCODE(0xb5, o72_getArrayDimSize);
diff --git a/engines/scumm/he/script_v90he.cpp b/engines/scumm/he/script_v90he.cpp
index 12fa39b0fd5..0cc95ee5600 100644
--- a/engines/scumm/he/script_v90he.cpp
+++ b/engines/scumm/he/script_v90he.cpp
@@ -61,9 +61,9 @@ void ScummEngine_v90he::setupOpcodes() {
OPCODE(0x28, o90_setSpriteGroupInfo);
OPCODE(0x29, o90_getWizData);
OPCODE(0x2a, o90_getActorData);
- OPCODE(0x2b, o90_startScriptUnk);
+ OPCODE(0x2b, o90_priorityStartScript);
/* 2C */
- OPCODE(0x2c, o90_jumpToScriptUnk);
+ OPCODE(0x2c, o90_priorityChainScript);
OPCODE(0x2d, o90_videoOps);
OPCODE(0x2e, o90_getVideoData);
OPCODE(0x2f, o90_floodFill);
@@ -86,7 +86,7 @@ void ScummEngine_v90he::setupOpcodes() {
OPCODE(0x94, o90_getPaletteData);
OPCODE(0x9e, o90_paletteOps);
- OPCODE(0xa5, o90_fontUnk);
+ OPCODE(0xa5, o90_fontEnum);
OPCODE(0xab, o90_getActorAnimProgress);
OPCODE(0xc8, o90_kernelGetFunctions);
OPCODE(0xc9, o90_kernelSetFunctions);
@@ -111,39 +111,39 @@ void ScummEngine_v90he::o90_wizImageOps() {
int subOp = fetchScriptByte();
switch (subOp) {
- case 32: // HE99+
+ case SO_WIDTH: // 32, HE99+
_wizParams.processFlags |= kWPFUseDefImgWidth;
_wizParams.resDefImgW = pop();
break;
- case 33: // HE99+
+ case SO_HEIGHT: // 33, HE99+
_wizParams.processFlags |= kWPFUseDefImgHeight;
_wizParams.resDefImgH = pop();
break;
- case 46:
+ case SO_GENERAL_CLIP_STATE: // 46
// Dummy case
pop();
break;
- case 47:
+ case SO_GENERAL_CLIP_RECT: // 47
_wizParams.box.bottom = pop();
_wizParams.box.right = pop();
_wizParams.box.top = pop();
_wizParams.box.left = pop();
break;
- case 48:
+ case SO_DRAW: // 48
_wizParams.processMode = 1;
break;
- case 49:
+ case SO_LOAD: // 49
_wizParams.processFlags |= kWPFUseFile;
_wizParams.processMode = 3;
copyScriptString(_wizParams.filename, sizeof(_wizParams.filename));
break;
- case 50:
+ case SO_SAVE: // 50
_wizParams.processFlags |= kWPFUseFile;
_wizParams.processMode = 4;
copyScriptString(_wizParams.filename, sizeof(_wizParams.filename));
_wizParams.fileWriteMode = pop();
break;
- case 51:
+ case SO_CAPTURE: // 51
_wizParams.processFlags |= kWPFClipBox | 0x100;
_wizParams.processMode = 2;
_wizParams.box.bottom = pop();
@@ -153,19 +153,19 @@ void ScummEngine_v90he::o90_wizImageOps() {
_wizParams.compType = pop();
adjustRect(_wizParams.box);
break;
- case 52:
+ case SO_STATE: // 52
_wizParams.processFlags |= kWPFNewState;
_wizParams.img.state = pop();
break;
- case 53:
+ case SO_ANGLE: // 53
_wizParams.processFlags |= kWPFRotate;
_wizParams.angle = pop();
break;
- case 54:
+ case SO_SET_FLAGS: // 54
_wizParams.processFlags |= kWPFNewFlags;
_wizParams.img.flags |= pop();
break;
- case 56:
+ case SO_NOW: // 56
_wizParams.img.flags = pop();
_wizParams.img.state = pop();
_wizParams.img.y1 = pop();
@@ -173,7 +173,7 @@ void ScummEngine_v90he::o90_wizImageOps() {
_wizParams.img.resNum = pop();
_wiz->displayWizImage(&_wizParams.img);
break;
- case 57:
+ case SO_INIT: // 57
_wizParams.img.resNum = pop();
_wizParams.processMode = 0;
_wizParams.processFlags = 0;
@@ -184,18 +184,19 @@ void ScummEngine_v90he::o90_wizImageOps() {
_wizParams.spriteId = 0;
_wizParams.spriteGroup = 0;
break;
- case 62: // HE99+
+ case SO_AT_IMAGE: // 62, HE99+
_wizParams.processFlags |= kWPFMaskImg;
_wizParams.sourceImage = pop();
break;
- case 65:
- case 154:
+ case SO_AT: // 65
+ case SO_CURSOR_HOTSPOT: // 154
_wizParams.processFlags |= kWPFSetPos;
_wizParams.img.y1 = pop();
_wizParams.img.x1 = pop();
break;
- case 66:
- case 249: // HE98+
+ case SO_COLOR: // 66
+ // TODO: I haven't found SO_COLOR in any executable, recheck later...
+ case SO_COLOR_LIST: // 249, HE98+
b = pop();
a = pop();
_wizParams.processFlags |= kWPFRemapPalette;
@@ -208,7 +209,7 @@ void ScummEngine_v90he::o90_wizImageOps() {
_wizParams.remapColor[a] = b;
_wizParams.remapNum++;
break;
- case 67:
+ case SO_CLIPPED: // 67
_wizParams.processFlags |= kWPFClipBox;
_wizParams.box.bottom = pop();
_wizParams.box.right = pop();
@@ -216,26 +217,26 @@ void ScummEngine_v90he::o90_wizImageOps() {
_wizParams.box.left = pop();
adjustRect(_wizParams.box);
break;
- case 86: // HE99+
+ case SO_PALETTE: // 86, HE99+
_wizParams.processFlags |= kWPFPaletteNum;
_wizParams.img.palette = pop();
break;
- case 92:
+ case SO_SCALE: // 92
_wizParams.processFlags |= kWPFScaled;
_wizParams.scale = pop();
break;
- case 98:
+ case SO_SHADOW: // 98
_wizParams.processFlags |= kWPFShadow;
_wizParams.img.shadow = pop();
break;
- case 131: // HE99+
+ case SO_POLY_POLYGON: // 131, HE99+
_wizParams.processFlags |= 0x1000 | 0x100 | 0x2;
_wizParams.processMode = 7;
_wizParams.polygonId2 = pop();
_wizParams.polygonId1 = pop();
_wizParams.compType = pop();
break;
- case 133: // HE99+
+ case SO_RENDER_RECTANGLE: // 133, HE99+
_wizParams.processFlags |= kWPFFillColor | kWPFClipBox2;
_wizParams.processMode = 9;
_wizParams.fillColor = pop();
@@ -245,7 +246,7 @@ void ScummEngine_v90he::o90_wizImageOps() {
_wizParams.box2.left = pop();
adjustRect(_wizParams.box2);
break;
- case 134: // HE99+
+ case SO_RENDER_LINE: // 134, HE99+
_wizParams.processFlags |= kWPFFillColor | kWPFClipBox2;
_wizParams.processMode = 10;
_wizParams.fillColor = pop();
@@ -255,7 +256,7 @@ void ScummEngine_v90he::o90_wizImageOps() {
_wizParams.box2.left = pop();
adjustRect(_wizParams.box2);
break;
- case 135: // HE99+
+ case SO_RENDER_PIXEL: // 135, HE99+
_wizParams.processFlags |= kWPFFillColor | kWPFClipBox2;
_wizParams.processMode = 11;
_wizParams.fillColor = pop();
@@ -263,7 +264,7 @@ void ScummEngine_v90he::o90_wizImageOps() {
_wizParams.box2.left = _wizParams.box2.right = pop();
adjustRect(_wizParams.box2);
break;
- case 136: // HE99+
+ case SO_RENDER_FLOOD_FILL: // 136, HE99+
_wizParams.processFlags |= kWPFFillColor | kWPFClipBox2;
_wizParams.processMode = 12;
_wizParams.fillColor = pop();
@@ -271,19 +272,19 @@ void ScummEngine_v90he::o90_wizImageOps() {
_wizParams.box2.left = _wizParams.box2.right = pop();
adjustRect(_wizParams.box2);
break;
- case 137: // HE99+
+ case SO_RENDER_INTO_IMAGE: // 137, HE99+
_wizParams.processFlags |= kWPFDstResNum;
_wizParams.dstResNum = pop();
break;
- case 139: // HE99+
+ case SO_NEW_GENERAL_PROPERTY: // 139, HE99+
_wizParams.processFlags |= kWPFParams;
_wizParams.params1 = pop();
_wizParams.params2 = pop();
break;
- case 141: // HE99+
+ case SO_FONT_START: // 141, HE99+
_wizParams.processMode = 13;
break;
- case 142: // HE99+
+ case SO_FONT_CREATE: // 142, HE99+
_wizParams.processMode = 15;
_wizParams.fontProperties.bgColor = pop();
_wizParams.fontProperties.fgColor = pop();
@@ -291,13 +292,13 @@ void ScummEngine_v90he::o90_wizImageOps() {
_wizParams.fontProperties.style = pop();
copyScriptString(_wizParams.fontProperties.fontName, sizeof(_wizParams.fontProperties.fontName));
break;
- case 143: // HE99+
+ case SO_FONT_RENDER: // 143, HE99+
_wizParams.processMode = 16;
_wizParams.fontProperties.yPos = pop();
_wizParams.fontProperties.xPos = pop();
copyScriptString(_wizParams.fontProperties.string, sizeof(_wizParams.fontProperties.string));
break;
- case 189: // HE99+
+ case SO_RENDER_ELLIPSE: // 189, HE99+
_wizParams.processMode = 17;
_wizParams.ellipseProperties.color = pop();
_wizParams.ellipseProperties.lod = pop();
@@ -308,18 +309,18 @@ void ScummEngine_v90he::o90_wizImageOps() {
_wizParams.ellipseProperties.py = pop();
_wizParams.ellipseProperties.px = pop();
break;
- case 196: // HE99+
+ case SO_FONT_END: // 196, HE99+
_wizParams.processMode = 14;
break;
- case 217: // HE99+
+ case SO_NEW: // 217, HE99+
_wizParams.processMode = 8;
break;
- case 246:
+ case SO_SET_POLYGON: // 246
_wizParams.processFlags |= kWPFNewFlags | kWPFSetPos | 2;
_wizParams.img.flags |= kWIFIsPolygon;
_wizParams.polygonId1 = _wizParams.img.y1 = _wizParams.img.x1 = pop();
break;
- case 255:
+ case SO_END: // 255
if (_wizParams.img.resNum)
_wiz->processWizImage(&_wizParams);
break;
@@ -351,16 +352,25 @@ void ScummEngine_v90he::o90_max() {
}
void ScummEngine_v90he::o90_sin() {
+ // TODO: the math calculation albeit more precise
+ // is not accurate enough with respect to what the
+ // engine expects. Implement the correct one...
double a = pop() * M_PI / 180.;
push((int)(sin(a) * 100000));
}
void ScummEngine_v90he::o90_cos() {
+ // TODO: the math calculation albeit more precise
+ // is not accurate enough with respect to what the
+ // engine expects. Implement the correct one...
double a = pop() * M_PI / 180.;
push((int)(cos(a) * 100000));
}
void ScummEngine_v90he::o90_sqrt() {
+ // TODO: the math calculation albeit more precise
+ // is not accurate enough with respect to what the
+ // engine expects. Implement the correct one...
int i = pop();
if (i < 2) {
push(i);
@@ -397,8 +407,8 @@ void ScummEngine_v90he::o90_getDistanceBetweenPoints() {
byte subOp = fetchScriptByte();
switch (subOp) {
- case 23: // HE100
- case 28:
+ case ScummEngine_v100he::SO_COORD_2D: // 23
+ case SO_COORD_2D: // 28
y2 = pop();
x2 = pop();
y1 = pop();
@@ -412,8 +422,8 @@ void ScummEngine_v90he::o90_getDistanceBetweenPoints() {
push((int)sqrt((double)(d + 1)));
}
break;
- case 24: // HE100
- case 29:
+ case ScummEngine_v100he::SO_COORD_3D: // 24
+ case SO_COORD_3D: // 29
z2 = pop();
y2 = pop();
x2 = pop();
@@ -437,13 +447,13 @@ void ScummEngine_v90he::o90_getDistanceBetweenPoints() {
void ScummEngine_v90he::o90_getSpriteInfo() {
int args[16];
- int spriteId, flags, groupId, type;
+ int spriteId, flags, groupId, type, count;
int32 x, y;
byte subOp = fetchScriptByte();
switch (subOp) {
- case 30:
+ case SO_XPOS: // 30
spriteId = pop();
if (spriteId) {
_sprite->getSpritePosition(spriteId, x, y);
@@ -452,7 +462,7 @@ void ScummEngine_v90he::o90_getSpriteInfo() {
push(0);
}
break;
- case 31:
+ case SO_YPOS: // 31
spriteId = pop();
if (spriteId) {
_sprite->getSpritePosition(spriteId, x, y);
@@ -461,7 +471,7 @@ void ScummEngine_v90he::o90_getSpriteInfo() {
push(0);
}
break;
- case 32:
+ case SO_WIDTH: // 32
spriteId = pop();
if (spriteId) {
_sprite->getSpriteImageDim(spriteId, x, y);
@@ -470,7 +480,7 @@ void ScummEngine_v90he::o90_getSpriteInfo() {
push(0);
}
break;
- case 33:
+ case SO_HEIGHT: // 33
spriteId = pop();
if (spriteId) {
_sprite->getSpriteImageDim(spriteId, x, y);
@@ -479,7 +489,7 @@ void ScummEngine_v90he::o90_getSpriteInfo() {
push(0);
}
break;
- case 34:
+ case SO_STEP_DIST_X: // 34
spriteId = pop();
if (spriteId) {
_sprite->getSpriteDist(spriteId, x, y);
@@ -488,7 +498,7 @@ void ScummEngine_v90he::o90_getSpriteInfo() {
push(0);
}
break;
- case 35:
+ case SO_STEP_DIST_Y: // 35
spriteId = pop();
if (spriteId) {
_sprite->getSpriteDist(spriteId, x, y);
@@ -497,52 +507,52 @@ void ScummEngine_v90he::o90_getSpriteInfo() {
push(0);
}
break;
- case 36:
+ case SO_COUNT: // 36
spriteId = pop();
if (spriteId)
push(_sprite->getSpriteImageStateCount(spriteId));
else
push(0);
break;
- case 37:
+ case SO_GROUP: // 37
spriteId = pop();
if (spriteId)
push(_sprite->getSpriteGroup(spriteId));
else
push(0);
break;
- case 38:
+ case SO_DRAW_XPOS: // 38
spriteId = pop();
if (spriteId)
push(_sprite->getSpriteDisplayX(spriteId));
else
push(0);
break;
- case 39:
+ case SO_DRAW_YPOS: // 39
spriteId = pop();
if (spriteId)
push(_sprite->getSpriteDisplayY(spriteId));
else
push(0);
break;
- case 42:
+ case SO_PROPERTY: // 42
flags = pop();
spriteId = pop();
if (spriteId) {
switch (flags) {
- case 0:
+ case SPRPROP_HFLIP: // 0
push(_sprite->getSpriteFlagXFlipped(spriteId));
break;
- case 1:
+ case SPRPROP_VFLIP: // 1
push(_sprite->getSpriteFlagYFlipped(spriteId));
break;
- case 2:
+ case SPRPROP_ACTIVE: // 2
push(_sprite->getSpriteFlagActive(spriteId));
break;
- case 3:
+ case SPRPROP_BACKGROUND_RENDER: // 3
push(_sprite->getSpriteFlagDoubleBuffered(spriteId));
break;
- case 4:
+ case SPRPROP_USE_IMAGE_REMAP_TABLE: // 4
push(_sprite->getSpriteFlagRemapPalette(spriteId));
break;
default:
@@ -552,14 +562,14 @@ void ScummEngine_v90he::o90_getSpriteInfo() {
push(0);
}
break;
- case 43:
+ case SO_PRIORITY: // 43
spriteId = pop();
if (spriteId)
push(_sprite->getSpritePriority(spriteId));
else
push(0);
break;
- case 45:
+ case SO_FIND: // 45
if (_game.heversion == 99) {
flags = getStackList(args, ARRAYSIZE(args));
type = pop();
@@ -580,86 +590,88 @@ void ScummEngine_v90he::o90_getSpriteInfo() {
push(_sprite->findSpriteWithClassOf(x, y, groupId, 0, 0, 0));
}
break;
- case 52:
+ case SO_STATE: // 52
spriteId = pop();
if (spriteId)
push(_sprite->getSpriteImageState(spriteId));
else
push(0);
break;
- case 62:
+ case SO_AT_IMAGE: // 62
spriteId = pop();
if (spriteId)
push(_sprite->getSpriteSourceImage(spriteId));
else
push(0);
break;
- case 63:
+ case SO_IMAGE: // 63
spriteId = pop();
if (spriteId)
push(_sprite->getSpriteImage(spriteId));
else
push(0);
break;
- case 68:
+ case SO_ERASE: // 68
spriteId = pop();
if (spriteId)
push(_sprite->getSpriteFlagEraseType(spriteId));
else
push(1);
break;
- case 82:
+ case SO_ANIMATION: // 82
spriteId = pop();
if (spriteId)
push(_sprite->getSpriteFlagAutoAnim(spriteId));
else
push(0);
break;
- case 86:
+ case SO_PALETTE: // 86
spriteId = pop();
if (spriteId)
push(_sprite->getSpritePalette(spriteId));
else
push(0);
break;
- case 92:
+ case SO_SCALE: // 92
spriteId = pop();
if (spriteId)
push(_sprite->getSpriteScale(spriteId));
else
push(0);
break;
- case 97:
+ case SO_ANIMATION_SPEED: // 97
spriteId = pop();
if (spriteId)
push(_sprite->getSpriteAnimSpeed(spriteId));
else
push(1);
break;
- case 98:
+ case SO_SHADOW: // 98
spriteId = pop();
if (spriteId)
push(_sprite->getSpriteShadow(spriteId));
else
push(0);
break;
- case 124:
+ case SO_UPDATE: // 124
spriteId = pop();
if (spriteId)
push(_sprite->getSpriteFlagUpdateType(spriteId));
else
push(0);
break;
- case 125:
- flags = getStackList(args, ARRAYSIZE(args));
+ case SO_CLASS: // 125
+ count = getStackList(args, ARRAYSIZE(args));
spriteId = pop();
+
+ // TODO: Implement HE98-99-100 differences here
if (spriteId) {
- push(_sprite->getSpriteClass(spriteId, flags, args));
+ push(_sprite->getSpriteClass(spriteId, count, args));
} else {
push(0);
}
break;
- case 139:
+ case SO_NEW_GENERAL_PROPERTY: // 139
flags = pop();
spriteId = pop();
if (spriteId)
@@ -667,14 +679,14 @@ void ScummEngine_v90he::o90_getSpriteInfo() {
else
push(0);
break;
- case 140:
+ case SO_MASK: // 140
spriteId = pop();
if (spriteId)
push(_sprite->getSpriteMaskImage(spriteId));
else
push(0);
break;
- case 198:
+ case SO_ACTOR_VARIABLE: // 198
pop();
spriteId = pop();
if (spriteId)
@@ -696,7 +708,7 @@ void ScummEngine_v90he::o90_setSpriteInfo() {
byte subOp = fetchScriptByte();
switch (subOp) {
- case 34:
+ case SO_STEP_DIST_X: // 34
args[0] = pop();
if (_curSpriteId > _curMaxSpriteId)
break;
@@ -709,7 +721,7 @@ void ScummEngine_v90he::o90_setSpriteInfo() {
_sprite->setSpriteDist(spriteId, args[0], tmp[1]);
}
break;
- case 35:
+ case SO_STEP_DIST_Y: // 35
args[0] = pop();
if (_curSpriteId > _curMaxSpriteId)
break;
@@ -722,7 +734,7 @@ void ScummEngine_v90he::o90_setSpriteInfo() {
_sprite->setSpriteDist(spriteId, tmp[0], args[0]);
}
break;
- case 37:
+ case SO_GROUP: // 37
args[0] = pop();
if (_curSpriteId > _curMaxSpriteId)
break;
@@ -733,7 +745,7 @@ void ScummEngine_v90he::o90_setSpriteInfo() {
for (; spriteId <= _curMaxSpriteId; spriteId++)
_sprite->setSpriteGroup(spriteId, args[0]);
break;
- case 42:
+ case SO_PROPERTY: // 42
args[1] = pop();
args[0] = pop();
if (_curSpriteId > _curMaxSpriteId)
@@ -744,26 +756,26 @@ void ScummEngine_v90he::o90_setSpriteInfo() {
for (; spriteId <= _curMaxSpriteId; spriteId++)
switch (args[1]) {
- case 0:
+ case SPRPROP_HFLIP: // 0
_sprite->setSpriteFlagXFlipped(spriteId, args[0]);
break;
- case 1:
+ case SPRPROP_VFLIP: // 1
_sprite->setSpriteFlagYFlipped(spriteId, args[0]);
break;
- case 2:
+ case SPRPROP_ACTIVE: // 2
_sprite->setSpriteFlagActive(spriteId, args[0]);
break;
- case 3:
+ case SPRPROP_BACKGROUND_RENDER: // 3
_sprite->setSpriteFlagDoubleBuffered(spriteId, args[0]);
break;
- case 4:
+ case SPRPROP_USE_IMAGE_REMAP_TABLE: // 4
_sprite->setSpriteFlagRemapPalette(spriteId, args[0]);
break;
default:
break;
}
break;
- case 43:
+ case SO_PRIORITY: // 43
args[0] = pop();
if (_curSpriteId > _curMaxSpriteId)
break;
@@ -774,7 +786,7 @@ void ScummEngine_v90he::o90_setSpriteInfo() {
for (; spriteId <= _curMaxSpriteId; spriteId++)
_sprite->setSpritePriority(spriteId, args[0]);
break;
- case 44:
+ case SO_MOVE: // 44
args[1] = pop();
args[0] = pop();
if (_curSpriteId > _curMaxSpriteId)
@@ -786,7 +798,7 @@ void ScummEngine_v90he::o90_setSpriteInfo() {
for (; spriteId <= _curMaxSpriteId; spriteId++)
_sprite->moveSprite(spriteId, args[0], args[1]);
break;
- case 52:
+ case SO_STATE: // 52
args[0] = pop();
if (_curSpriteId > _curMaxSpriteId)
break;
@@ -797,7 +809,7 @@ void ScummEngine_v90he::o90_setSpriteInfo() {
for (; spriteId <= _curMaxSpriteId; spriteId++)
_sprite->setSpriteImageState(spriteId, args[0]);
break;
- case 53:
+ case SO_ANGLE: // 53
args[0] = pop();
if (_curSpriteId > _curMaxSpriteId)
break;
@@ -808,7 +820,7 @@ void ScummEngine_v90he::o90_setSpriteInfo() {
for (; spriteId <= _curMaxSpriteId; spriteId++)
_sprite->setSpriteAngle(spriteId, args[0]);
break;
- case 57:
+ case SO_INIT: // 57
if (_game.features & GF_HE_985 || _game.heversion >= 99) {
_curMaxSpriteId = pop();
_curSpriteId = pop();
@@ -820,7 +832,7 @@ void ScummEngine_v90he::o90_setSpriteInfo() {
_curMaxSpriteId = _curSpriteId; // to make all functions happy
}
break;
- case 62: // HE99+
+ case SO_AT_IMAGE: // 62, HE99+
args[0] = pop();
if (_curSpriteId > _curMaxSpriteId)
break;
@@ -831,7 +843,7 @@ void ScummEngine_v90he::o90_setSpriteInfo() {
for (; spriteId <= _curMaxSpriteId; spriteId++)
_sprite->setSpriteSourceImage(spriteId, args[0]);
break;
- case 63:
+ case SO_IMAGE: // 63
args[0] = pop();
if (_curSpriteId > _curMaxSpriteId)
break;
@@ -842,7 +854,7 @@ void ScummEngine_v90he::o90_setSpriteInfo() {
for (; spriteId <= _curMaxSpriteId; spriteId++)
_sprite->setSpriteImage(spriteId, args[0]);
break;
- case 65:
+ case SO_AT: // 65
args[1] = pop();
args[0] = pop();
if (_curSpriteId > _curMaxSpriteId)
@@ -854,7 +866,7 @@ void ScummEngine_v90he::o90_setSpriteInfo() {
for (; spriteId <= _curMaxSpriteId; spriteId++)
_sprite->setSpritePosition(spriteId, args[0], args[1]);
break;
- case 68:
+ case SO_ERASE: // 68
args[0] = pop();
if (_curSpriteId > _curMaxSpriteId)
break;
@@ -865,7 +877,7 @@ void ScummEngine_v90he::o90_setSpriteInfo() {
for (; spriteId <= _curMaxSpriteId; spriteId++)
_sprite->setSpriteFlagEraseType(spriteId, args[0]);
break;
- case 77:
+ case SO_STEP_DIST: // 77
args[1] = pop();
args[0] = pop();
if (_curSpriteId > _curMaxSpriteId)
@@ -877,7 +889,7 @@ void ScummEngine_v90he::o90_setSpriteInfo() {
for (; spriteId <= _curMaxSpriteId; spriteId++)
_sprite->setSpriteDist(spriteId, args[0], args[1]);
break;
- case 82:
+ case SO_ANIMATION: // 82
args[0] = pop();
if (_curSpriteId > _curMaxSpriteId)
break;
@@ -888,7 +900,7 @@ void ScummEngine_v90he::o90_setSpriteInfo() {
for (; spriteId <= _curMaxSpriteId; spriteId++)
_sprite->setSpriteFlagAutoAnim(spriteId, args[0]);
break;
- case 86: // HE 98+
+ case SO_PALETTE: // 86, HE98+
args[0] = pop();
if (_curSpriteId > _curMaxSpriteId)
break;
@@ -899,7 +911,7 @@ void ScummEngine_v90he::o90_setSpriteInfo() {
for (; spriteId <= _curMaxSpriteId; spriteId++)
_sprite->setSpritePalette(spriteId, args[0]);
break;
- case 92: // HE 99+
+ case SO_SCALE: // 92, HE99+
args[0] = pop();
if (_curSpriteId > _curMaxSpriteId)
break;
@@ -910,7 +922,7 @@ void ScummEngine_v90he::o90_setSpriteInfo() {
for (; spriteId <= _curMaxSpriteId; spriteId++)
_sprite->setSpriteScale(spriteId, args[0]);
break;
- case 97: // HE 98+
+ case SO_ANIMATION_SPEED: // 97, HE98+
args[0] = pop();
if (_curSpriteId > _curMaxSpriteId)
break;
@@ -921,7 +933,7 @@ void ScummEngine_v90he::o90_setSpriteInfo() {
for (; spriteId <= _curMaxSpriteId; spriteId++)
_sprite->setSpriteAnimSpeed(spriteId, args[0]);
break;
- case 98:
+ case SO_SHADOW: // 98
args[0] = pop();
if (_curSpriteId > _curMaxSpriteId)
break;
@@ -932,7 +944,7 @@ void ScummEngine_v90he::o90_setSpriteInfo() {
for (; spriteId <= _curMaxSpriteId; spriteId++)
_sprite->setSpriteShadow(spriteId, args[0]);
break;
- case 124:
+ case SO_UPDATE: // 124
args[0] = pop();
if (_curSpriteId > _curMaxSpriteId)
break;
@@ -943,7 +955,7 @@ void ScummEngine_v90he::o90_setSpriteInfo() {
for (; spriteId <= _curMaxSpriteId; spriteId++)
_sprite->setSpriteFlagUpdateType(spriteId, args[0]);
break;
- case 125:
+ case SO_CLASS: // 125
n = getStackList(args, ARRAYSIZE(args));
if (_curSpriteId != 0 && _curMaxSpriteId != 0 && n != 0) {
int *p = &args[n - 1];
@@ -966,7 +978,7 @@ void ScummEngine_v90he::o90_setSpriteInfo() {
} while (--n);
}
break;
- case 139: // HE 99+
+ case SO_NEW_GENERAL_PROPERTY: // 139, HE99+
args[1] = pop();
args[0] = pop();
if (_curSpriteId > _curMaxSpriteId)
@@ -978,7 +990,7 @@ void ScummEngine_v90he::o90_setSpriteInfo() {
for (; spriteId <= _curMaxSpriteId; spriteId++)
_sprite->setSpriteGeneralProperty(spriteId, args[0], args[1]);
break;
- case 140: // HE 99+
+ case SO_MASK: // 140, HE99+
args[0] = pop();
if (_curSpriteId > _curMaxSpriteId)
break;
@@ -989,10 +1001,10 @@ void ScummEngine_v90he::o90_setSpriteInfo() {
for (; spriteId <= _curMaxSpriteId; spriteId++)
_sprite->setSpriteMaskImage(spriteId, args[0]);
break;
- case 158:
+ case SO_RESTART: // 158
_sprite->resetTables(true);
break;
- case 198:
+ case SO_ACTOR_VARIABLE: // 198
args[1] = pop();
args[0] = pop();
if (_curSpriteId > _curMaxSpriteId)
@@ -1004,7 +1016,7 @@ void ScummEngine_v90he::o90_setSpriteInfo() {
for (; spriteId <= _curMaxSpriteId; spriteId++)
_sprite->setSpriteUserValue(spriteId, args[0], args[1]);
break;
- case 217:
+ case SO_NEW: // 217
if (_curSpriteId > _curMaxSpriteId)
break;
spriteId = _curSpriteId;
@@ -1026,14 +1038,14 @@ void ScummEngine_v90he::o90_getSpriteGroupInfo() {
byte subOp = fetchScriptByte();
switch (subOp) {
- case 8: // HE 99+
+ case SO_ARRAY: // 8, HE99+
spriteGroupId = pop();
if (spriteGroupId)
push(getGroupSpriteArray(spriteGroupId));
else
push(0);
break;
- case 30:
+ case SO_XPOS: // 30
spriteGroupId = pop();
if (spriteGroupId) {
_sprite->getGroupPosition(spriteGroupId, tx, ty);
@@ -1042,7 +1054,7 @@ void ScummEngine_v90he::o90_getSpriteGroupInfo() {
push(0);
}
break;
- case 31:
+ case SO_YPOS: // 31
spriteGroupId = pop();
if (spriteGroupId) {
_sprite->getGroupPosition(spriteGroupId, tx, ty);
@@ -1051,21 +1063,21 @@ void ScummEngine_v90he::o90_getSpriteGroupInfo() {
push(0);
}
break;
- case 42: // HE 99+
+ case SO_PROPERTY: // 42, HE99+
type = pop();
spriteGroupId = pop();
if (spriteGroupId) {
switch (type) {
- case 0:
+ case SPRGRPPROP_XMUL: // 0
push(_sprite->getGroupXMul(spriteGroupId));
break;
- case 1:
+ case SPRGRPPROP_XDIV: // 1
push(_sprite->getGroupXDiv(spriteGroupId));
break;
- case 2:
+ case SPRGRPPROP_YMUL: // 2
push(_sprite->getGroupYMul(spriteGroupId));
break;
- case 3:
+ case SPRGRPPROP_YDIV: // 3
push(_sprite->getGroupYDiv(spriteGroupId));
break;
default:
@@ -1075,24 +1087,26 @@ void ScummEngine_v90he::o90_getSpriteGroupInfo() {
push(0);
}
break;
- case 43:
+ case SO_PRIORITY: // 43
spriteGroupId = pop();
if (spriteGroupId)
push(_sprite->getGroupPriority(spriteGroupId));
else
push(0);
break;
- case 63: // HE 99+
+ case SO_IMAGE: // 63, HE99+
spriteGroupId = pop();
if (spriteGroupId)
push(_sprite->getGroupDstResNum(spriteGroupId));
else
push(0);
break;
- case 139: // HE 99+
- // dummy case
- pop();
- pop();
+ case SO_NEW_GENERAL_PROPERTY: // 139, HE99+
+ pop(); // propertyCode
+ pop(); // groupNum
+
+ // The original just checked if groupNum was within
+ // bounds and just pushed 0 to the stack
push(0);
break;
default:
@@ -1106,10 +1120,10 @@ void ScummEngine_v90he::o90_setSpriteGroupInfo() {
byte subOp = fetchScriptByte();
switch (subOp) {
- case 37:
- type = pop() - 1;
+ case SO_GROUP: // 37
+ type = pop();
switch (type) {
- case 0:
+ case SPRGRPOP_MOVE: // 1
value2 = pop();
value1 = pop();
if (!_curSpriteGroupId)
@@ -1117,48 +1131,48 @@ void ScummEngine_v90he::o90_setSpriteGroupInfo() {
_sprite->moveGroupMembers(_curSpriteGroupId, value1, value2);
break;
- case 1:
+ case SPRGRPOP_ORDER: // 2
value1 = pop();
if (!_curSpriteGroupId)
break;
_sprite->setGroupMembersPriority(_curSpriteGroupId, value1);
break;
- case 2:
+ case SPRGRPOP_NEW_GROUP: // 3
value1 = pop();
if (!_curSpriteGroupId)
break;
_sprite->setGroupMembersGroup(_curSpriteGroupId, value1);
break;
- case 3:
+ case SPRGRPOP_UPDATE_TYPE: // 4
value1 = pop();
if (!_curSpriteGroupId)
break;
_sprite->setGroupMembersUpdateType(_curSpriteGroupId, value1);
break;
- case 4:
+ case SPRGRPOP_NEW: // 5
if (!_curSpriteGroupId)
break;
_sprite->setGroupMembersResetSprite(_curSpriteGroupId);
break;
- case 5:
+ case SPRGRPOP_ANIMATION_SPEED: // 6
value1 = pop();
if (!_curSpriteGroupId)
break;
_sprite->setGroupMembersAnimationSpeed(_curSpriteGroupId, value1);
break;
- case 6:
+ case SPRGRPOP_ANIMATION_TYPE: // 7
value1 = pop();
if (!_curSpriteGroupId)
break;
_sprite->setGroupMembersAutoAnimFlag(_curSpriteGroupId, value1);
break;
- case 7:
+ case SPRGRPOP_SHADOW: // 8
value1 = pop();
if (!_curSpriteGroupId)
break;
@@ -1169,37 +1183,37 @@ void ScummEngine_v90he::o90_setSpriteGroupInfo() {
error("o90_setSpriteGroupInfo subOp 0: Unknown case %d", subOp);
}
break;
- case 42:
+ case SO_PROPERTY: // 42
type = pop();
value1 = pop();
if (!_curSpriteGroupId)
break;
switch (type) {
- case 0:
+ case SPRGRPPROP_XMUL: // 0
_sprite->setGroupXMul(_curSpriteGroupId, value1);
break;
- case 1:
+ case SPRGRPPROP_XDIV: // 1
_sprite->setGroupXDiv(_curSpriteGroupId, value1);
break;
- case 2:
+ case SPRGRPPROP_YMUL: // 2
_sprite->setGroupYMul(_curSpriteGroupId, value1);
break;
- case 3:
+ case SPRGRPPROP_YDIV: // 3
_sprite->setGroupYDiv(_curSpriteGroupId, value1);
break;
default:
error("o90_setSpriteGroupInfo subOp 5: Unknown case %d", subOp);
}
break;
- case 43:
+ case SO_PRIORITY: // 43
value1 = pop();
if (!_curSpriteGroupId)
break;
_sprite->setGroupPriority(_curSpriteGroupId, value1);
break;
- case 44:
+ case SO_MOVE: // 44
value2 = pop();
value1 = pop();
if (!_curSpriteGroupId)
@@ -1207,17 +1221,17 @@ void ScummEngine_v90he::o90_setSpriteGroupInfo() {
_sprite->moveGroup(_curSpriteGroupId, value1, value2);
break;
- case 57:
+ case SO_INIT: // 57
_curSpriteGroupId = pop();
break;
- case 63:
+ case SO_IMAGE: // 63
value1 = pop();
if (!_curSpriteGroupId)
break;
_sprite->setGroupImage(_curSpriteGroupId, value1);
break;
- case 65:
+ case SO_AT: // 65
value2 = pop();
value1 = pop();
if (!_curSpriteGroupId)
@@ -1225,7 +1239,7 @@ void ScummEngine_v90he::o90_setSpriteGroupInfo() {
_sprite->setGroupPosition(_curSpriteGroupId, value1, value2);
break;
- case 67:
+ case SO_CLIPPED: // 67
value4 = pop();
value3 = pop();
value2 = pop();
@@ -1235,13 +1249,13 @@ void ScummEngine_v90he::o90_setSpriteGroupInfo() {
_sprite->setGroupBounds(_curSpriteGroupId, value1, value2, value3, value4);
break;
- case 93:
+ case SO_NEVER_ZCLIP: // 93
if (!_curSpriteGroupId)
break;
_sprite->resetGroupBounds(_curSpriteGroupId);
break;
- case 217:
+ case SO_NEW: // 217
if (!_curSpriteGroupId)
break;
@@ -1255,55 +1269,56 @@ void ScummEngine_v90he::o90_setSpriteGroupInfo() {
void ScummEngine_v90he::o90_getWizData() {
byte filename[4096];
int resId, state, type;
+ int fontImageNum, fontProperty;
int32 w, h;
int32 x, y;
byte subOp = fetchScriptByte();
switch (subOp) {
- case 30:
+ case SO_XPOS: // 30
state = pop();
resId = pop();
_wiz->getWizImageSpot(resId, state, x, y);
push(x);
break;
- case 31:
+ case SO_YPOS: // 31
state = pop();
resId = pop();
_wiz->getWizImageSpot(resId, state, x, y);
push(y);
break;
- case 32:
+ case SO_WIDTH: // 32
state = pop();
resId = pop();
_wiz->getWizImageDim(resId, state, w, h);
push(w);
break;
- case 33:
+ case SO_HEIGHT: // 33
state = pop();
resId = pop();
_wiz->getWizImageDim(resId, state, w, h);
push(h);
break;
- case 36:
+ case SO_COUNT: // 36
resId = pop();
push(_wiz->getWizImageStates(resId));
break;
- case 45:
+ case SO_FIND: // 45
y = pop();
x = pop();
state = pop();
resId = pop();
push(_wiz->isWizPixelNonTransparent(resId, state, x, y, 0));
break;
- case 66:
+ case SO_COLOR: // 66
y = pop();
x = pop();
state = pop();
resId = pop();
push(_wiz->getWizPixelColor(resId, state, x, y));
break;
- case 130:
+ case SO_HISTOGRAM: // 130
h = pop();
w = pop();
y = pop();
@@ -1317,17 +1332,37 @@ void ScummEngine_v90he::o90_getWizData() {
}
push(computeWizHistogram(resId, state, x, y, w, h));
break;
- case 139:
+ case SO_NEW_GENERAL_PROPERTY: // 139
+ // TODO: Recheck, this looks different at least in HE99...
type = pop();
state = pop();
resId = pop();
push(_wiz->getWizImageData(resId, state, type));
break;
- case 141:
- pop();
+ case SO_FONT_START: // 141
+ // TODO: Implement...
+
+ fontProperty = pop();
copyScriptString(filename, sizeof(filename));
- pop();
- push(0);
+ fontImageNum = pop();
+
+ if (fontImageNum) {
+ switch (fontProperty) {
+ case 2: // PFONT_EXTENT_X
+ //push(PFONT_GetStringWidth(iImage, szResultString));
+ break;
+
+ case 3: // PFONT_EXTENT_Y
+ //push(PFONT_GetStringHeight(iImage, szResultString));
+ break;
+ default:
+ // No default case in the original...
+ break;
+ }
+ } else {
+ push(0);
+ }
+
debug(0, "o90_getWizData() case 111 unhandled");
break;
default:
@@ -1369,7 +1404,7 @@ void ScummEngine_v90he::o90_getActorData() {
}
}
-void ScummEngine_v90he::o90_startScriptUnk() {
+void ScummEngine_v90he::o90_priorityStartScript() {
int args[25];
int script, cycle;
byte flags;
@@ -1378,10 +1413,10 @@ void ScummEngine_v90he::o90_startScriptUnk() {
cycle = pop();
script = pop();
flags = fetchScriptByte();
- runScript(script, (flags == 199 || flags == 200), (flags == 195 || flags == 200), args, cycle);
+ runScript(script, (flags == SO_BAK || flags == SO_BAKREC), (flags == SO_REC || flags == SO_BAKREC), args, cycle);
}
-void ScummEngine_v90he::o90_jumpToScriptUnk() {
+void ScummEngine_v90he::o90_priorityChainScript() {
int args[25];
int script, cycle;
byte flags;
@@ -1391,7 +1426,7 @@ void ScummEngine_v90he::o90_jumpToScriptUnk() {
script = pop();
flags = fetchScriptByte();
stopObjectCode();
- runScript(script, (flags == 199 || flags == 200), (flags == 195 || flags == 200), args, cycle);
+ runScript(script, (flags == SO_BAK || flags == SO_BAKREC), (flags == SO_REC || flags == SO_BAKREC), args, cycle);
}
void ScummEngine_v90he::o90_videoOps() {
@@ -1400,40 +1435,40 @@ void ScummEngine_v90he::o90_videoOps() {
int subOp = status - 49;
switch (subOp) {
- case 0:
+ case SO_LOAD: // 49
copyScriptString(_videoParams.filename, sizeof(_videoParams.filename));
_videoParams.status = status;
break;
- case 5:
+ case SO_SET_FLAGS: // 54
_videoParams.flags |= pop();
break;
- case 8:
+ case SO_INIT: // 57
memset(_videoParams.filename, 0, sizeof(_videoParams.filename));
_videoParams.status = 0;
_videoParams.flags = 0;
_videoParams.number = pop();
_videoParams.wizResNum = 0;
break;
- case 14:
+ case SO_IMAGE: // 63
_videoParams.wizResNum = pop();
if (_videoParams.wizResNum)
_videoParams.flags |= 2;
break;
- case 116:
+ case SO_CLOSE: // 165
_videoParams.status = status;
break;
- case 206:
- if (_videoParams.status == 49) {
+ case SO_END: // 255
+ if (_videoParams.status == SO_LOAD) {
// Start video
if (_videoParams.flags == 0)
_videoParams.flags = 4;
if (_videoParams.flags & 2) {
- VAR(119) = _moviePlay->load(convertFilePath(_videoParams.filename), _videoParams.flags, _videoParams.wizResNum);
+ VAR(VAR_OPERATION_FAILURE) = _moviePlay->load(convertFilePath(_videoParams.filename), _videoParams.flags, _videoParams.wizResNum);
} else {
- VAR(119) = _moviePlay->load(convertFilePath(_videoParams.filename), _videoParams.flags);
+ VAR(VAR_OPERATION_FAILURE) = _moviePlay->load(convertFilePath(_videoParams.filename), _videoParams.flags);
}
- } else if (_videoParams.status == 165) {
+ } else if (_videoParams.status == SO_CLOSE) {
// Stop video
_moviePlay->close();
}
@@ -1448,27 +1483,27 @@ void ScummEngine_v90he::o90_getVideoData() {
byte subOp = fetchScriptByte();
switch (subOp) {
- case 32: // Get width
+ case SO_WIDTH: // 32
pop();
push(_moviePlay->getWidth());
break;
- case 33: // Get height
+ case SO_HEIGHT: // 33
pop();
push(_moviePlay->getHeight());
break;
- case 36: // Get frame count
+ case SO_COUNT: // 36
pop();
push(_moviePlay->getFrameCount());
break;
- case 52: // Get current frame
+ case SO_STATE: // 52
pop();
push(_moviePlay->getCurFrame());
break;
- case 63: // Get image number
+ case SO_IMAGE: // 63
pop();
push(_moviePlay->getImageNum());
break;
- case 139: // Get statistics
+ case SO_NEW_GENERAL_PROPERTY: // 139
debug(0, "o90_getVideoData: subOp 107 stub (%d, %d)", pop(), pop());
push(0);
break;
@@ -1481,10 +1516,11 @@ void ScummEngine_v90he::o90_floodFill() {
byte subOp = fetchScriptByte();
switch (subOp) {
- case 54:
+ case SO_SET_FLAGS: // 54
+ // TODO floodInfo.flags |= pop();
pop();
break;
- case 57:
+ case SO_INIT: // 57
_floodFillParams.reset();
_floodFillParams.box.left = 0;
_floodFillParams.box.top = 0;
@@ -1492,21 +1528,21 @@ void ScummEngine_v90he::o90_floodFill() {
_floodFillParams.box.bottom = 479;
adjustRect(_floodFillParams.box);
break;
- case 65:
+ case SO_AT: // 65
_floodFillParams.y = pop();
_floodFillParams.x = pop();
break;
- case 66:
- _floodFillParams.flags = pop();
+ case SO_COLOR: // 66
+ _floodFillParams.flags = pop(); // TODO: Should be .color!
break;
- case 67:
+ case SO_CLIPPED: // 67
_floodFillParams.box.bottom = pop();
_floodFillParams.box.right = pop();
_floodFillParams.box.top = pop();
_floodFillParams.box.left = pop();
adjustRect(_floodFillParams.box);
break;
- case 255:
+ case SO_END: // 255
floodFill(&_floodFillParams, this);
break;
default:
@@ -1581,14 +1617,14 @@ void ScummEngine_v90he::o90_getPolygonOverlap() {
int subOp = pop();
switch (subOp) {
- case 1:
+ case OVERLAP_POINT_TO_RECT: // 1
{
Common::Rect r(args1[0], args1[1], args1[2] + 1, args1[3] + 1);
Common::Point p(args2[0], args2[1]);
push(r.contains(p) ? 1 : 0);
}
break;
- case 2:
+ case OVERLAP_POINT_TO_CIRCLE: // 2
{
int dx = args2[0] - args1[0];
int dy = args2[1] - args1[1];
@@ -1603,14 +1639,14 @@ void ScummEngine_v90he::o90_getPolygonOverlap() {
}
}
break;
- case 3:
+ case OVERLAP_RECT_TO_RECT: // 3
{
Common::Rect r1(args1[0], args1[1], args1[2] + 1, args1[3] + 1);
Common::Rect r2(args2[0], args2[1], args2[2] + 1, args2[3] + 1);
push(r2.intersects(r1) ? 1 : 0);
}
break;
- case 4:
+ case OVERLAP_CIRCLE_TO_CIRCLE: // 4
{
int dx = args2[0] - args1[0];
int dy = args2[1] - args1[1];
@@ -1621,7 +1657,7 @@ void ScummEngine_v90he::o90_getPolygonOverlap() {
push((dist < args1[2] && dist < args2[2]) ? 1 : 0);
}
break;
- case 5:
+ case OVERLAP_POINT_N_SIDED_POLYGON: // 5
{
assert((n1 & 1) == 0);
n1 /= 2;
@@ -1641,7 +1677,7 @@ void ScummEngine_v90he::o90_getPolygonOverlap() {
}
break;
// HE 98+
- case 6:
+ case OVERLAP_SPRITE_TO_SPRITE: // 6
{
Common::Rect r1, r2;
_sprite->getSpriteBounds(args2[0], false, r2);
@@ -1666,7 +1702,7 @@ void ScummEngine_v90he::o90_getPolygonOverlap() {
push(r2.intersects(r1) ? 1 : 0);
}
break;
- case 7:
+ case OVERLAP_SPRITE_TO_RECT: // 7
{
Common::Rect r2;
_sprite->getSpriteBounds(args2[0], false, r2);
@@ -1685,8 +1721,9 @@ void ScummEngine_v90he::o90_getPolygonOverlap() {
push(r2.intersects(r1) ? 1 : 0);
}
break;
- case 8:
- case 10: // TODO: Draw sprites to buffer and compare.
+ case OVERLAP_DRAW_POS_SPRITE_TO_SPRITE: // 8
+ case OVERLAP_SPRITE_TO_SPRITE_PIXEL_PERFECT: // 10
+ // TODO: Draw sprites to buffer and compare.
{
Common::Rect r1, r2;
_sprite->getSpriteBounds(args2[0], true, r2);
@@ -1711,7 +1748,7 @@ void ScummEngine_v90he::o90_getPolygonOverlap() {
push(r2.intersects(r1) ? 1 : 0);
}
break;
- case 9:
+ case OVERLAP_DRAW_POS_SPRITE_TO_RECT: // 9
{
Common::Rect r2;
_sprite->getSpriteBounds(args2[0], true, r2);
@@ -1751,22 +1788,22 @@ void ScummEngine_v90he::o90_dim2dim2Array() {
byte subOp = fetchScriptByte();
switch (subOp) {
- case 2: // SO_BIT_ARRAY
+ case SO_BIT: // 2
data = kBitArray;
break;
- case 3: // SO_NIBBLE_ARRAY
+ case SO_NIBBLE: // 3
data = kNibbleArray;
break;
- case 4: // SO_BYTE_ARRAY
+ case SO_BYTE: // 4
data = kByteArray;
break;
- case 5: // SO_INT_ARRAY
+ case SO_INT: // 5
data = kIntArray;
break;
- case 6:
+ case SO_DWORD: // 6
data = kDwordArray;
break;
- case 7: // SO_STRING_ARRAY
+ case SO_STRING: // 7
data = kStringArray;
break;
default:
@@ -1798,13 +1835,13 @@ void ScummEngine_v90he::o90_redim2dimArray() {
byte subOp = fetchScriptByte();
switch (subOp) {
- case 4:
+ case SO_BYTE: // 4
redimArray(fetchScriptWord(), a, b, c, d, kByteArray);
break;
- case 5:
+ case SO_INT: // 5
redimArray(fetchScriptWord(), a, b, c, d, kIntArray);
break;
- case 6:
+ case SO_DWORD: // 6
redimArray(fetchScriptWord(), a, b, c, d, kDwordArray);
break;
default:
@@ -2108,7 +2145,7 @@ void ScummEngine_v90he::o90_getObjectData() {
_heObjectNum = getObjectIndex(_heObject);
break;
case SO_NEW_GENERAL_PROPERTY:
- // Dummy case
+ // Dummy case, as in the original
pop();
push(0);
break;
@@ -2181,17 +2218,17 @@ void ScummEngine_v90he::o90_paletteOps() {
byte subOp = fetchScriptByte();
switch (subOp) {
- case SO_INIT:
+ case SO_INIT: // 57
_hePaletteNum = pop();
break;
- case SO_IMAGE:
+ case SO_IMAGE: // 63
b = pop();
a = pop();
if (_hePaletteNum != 0) {
setHEPaletteFromImage(_hePaletteNum, a, b);
}
break;
- case SO_COLOR:
+ case SO_COLOR: // 66
e = pop();
d = pop();
c = pop();
@@ -2203,7 +2240,7 @@ void ScummEngine_v90he::o90_paletteOps() {
}
}
break;
- case 70:
+ case SO_TO: // 70
c = pop();
b = pop();
a = pop();
@@ -2213,31 +2250,31 @@ void ScummEngine_v90he::o90_paletteOps() {
}
}
break;
- case 76: //HE99+
+ case SO_COSTUME: // 76, HE99+
a = pop();
if (_hePaletteNum != 0) {
setHEPaletteFromCostume(_hePaletteNum, a);
}
break;
- case 86:
+ case SO_PALETTE: // 86
a = pop();
if (_hePaletteNum != 0) {
copyHEPalette(_hePaletteNum, a);
}
break;
- case 175:
+ case SO_ROOM_PALETTE: // 175
b = pop();
a = pop();
if (_hePaletteNum != 0) {
setHEPaletteFromRoom(_hePaletteNum, a, b);
}
break;
- case 217:
+ case SO_NEW: // 217
if (_hePaletteNum != 0) {
restoreHEPalette(_hePaletteNum);
}
break;
- case 255:
+ case SO_END: // 255
_hePaletteNum = 0;
break;
default:
@@ -2245,37 +2282,39 @@ void ScummEngine_v90he::o90_paletteOps() {
}
}
-void ScummEngine_v90he::o90_fontUnk() {
- // Font related
+void ScummEngine_v90he::o90_fontEnum() {
byte string[80];
int a;
byte subOp = fetchScriptByte();
switch (subOp) {
+ case ScummEngine_v100he::SO_INIT: // HE100
+ case SO_INIT:
+ push(1);
+ break;
case ScummEngine_v100he::SO_PROPERTY: // HE100
case SO_PROPERTY:
- a = pop();
- if (a == 2) {
- copyScriptString(string, sizeof(string));
- push(-1);
- } else if (a == 1) {
+ switch (pop()) {
+ case 1: // FONT_ENUM_GET
pop();
writeVar(0, 0);
defineArray(0, kStringArray, 0, 0, 0, 0);
writeArray(0, 0, 0, 0);
push(readVar(0));
+ break;
+ case 2: // FONT_ENUM_FIND
+ copyScriptString(string, sizeof(string));
+ push(-1);
+ break;
}
- break;
- case ScummEngine_v100he::SO_INIT: // HE100
- case SO_INIT:
- push(1);
+
break;
default:
- error("o90_fontUnk: Unknown case %d", subOp);
+ error("o90_fontEnum: Unknown case %d", subOp);
}
- debug(1, "o90_fontUnk stub (%d)", subOp);
+ debug(1, "o90_fontEnum stub (%d)", subOp);
}
void ScummEngine_v90he::o90_getActorAnimProgress() {
@@ -2327,7 +2366,7 @@ void ScummEngine_v90he::o90_kernelSetFunctions() {
switch (args[0]) {
case 20:
a = (ActorHE *)derefActor(args[1], "o90_kernelSetFunctions: 20");
- queueAuxBlock(a);
+ queueAuxBlock(a); // TODO: Shouldn't this be HEQueueEraseAuxActor?
break;
case 21:
_skipDrawObject = 1;
diff --git a/engines/scumm/he/sprite_he.h b/engines/scumm/he/sprite_he.h
index ab1adc82ed2..5a335fdc79e 100644
--- a/engines/scumm/he/sprite_he.h
+++ b/engines/scumm/he/sprite_he.h
@@ -46,6 +46,45 @@ enum SpriteGroupFlags {
kSGFClipBox = (1 << 0)
};
+enum SpritePropertySubOps {
+ SPRPROP_HFLIP = 0,
+ SPRPROP_VFLIP = 1,
+ SPRPROP_ACTIVE = 2,
+ SPRPROP_BACKGROUND_RENDER = 3,
+ SPRPROP_USE_IMAGE_REMAP_TABLE = 4,
+};
+
+enum SpriteGroupPropertySubOps {
+ SPRGRPPROP_XMUL = 0,
+ SPRGRPPROP_XDIV = 1,
+ SPRGRPPROP_YMUL = 2,
+ SPRGRPPROP_YDIV = 3,
+};
+
+enum SpriteGroupSubOps {
+ SPRGRPOP_MOVE = 1,
+ SPRGRPOP_ORDER = 2,
+ SPRGRPOP_NEW_GROUP = 3,
+ SPRGRPOP_UPDATE_TYPE = 4,
+ SPRGRPOP_NEW = 5,
+ SPRGRPOP_ANIMATION_SPEED = 6,
+ SPRGRPOP_ANIMATION_TYPE = 7,
+ SPRGRPOP_SHADOW = 8,
+};
+
+enum PolygonOverlapSubOps {
+ OVERLAP_POINT_TO_RECT = 1,
+ OVERLAP_POINT_TO_CIRCLE = 2,
+ OVERLAP_RECT_TO_RECT = 3,
+ OVERLAP_CIRCLE_TO_CIRCLE = 4,
+ OVERLAP_POINT_N_SIDED_POLYGON = 5,
+ OVERLAP_SPRITE_TO_SPRITE = 6,
+ OVERLAP_SPRITE_TO_RECT = 7,
+ OVERLAP_DRAW_POS_SPRITE_TO_SPRITE = 8,
+ OVERLAP_DRAW_POS_SPRITE_TO_RECT = 9,
+ OVERLAP_SPRITE_TO_SPRITE_PIXEL_PERFECT = 10,
+};
+
struct SpriteInfo {
int32 id;
int32 zorder;
Commit: b3f60f44142b7457b90ad0c9ff5c54e0d1cb6622
https://github.com/scummvm/scummvm/commit/b3f60f44142b7457b90ad0c9ff5c54e0d1cb6622
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Preliminar clean up for WIZ rewrite pt.2
Changed paths:
engines/scumm/he/animation_he.cpp
engines/scumm/he/animation_he.h
engines/scumm/he/floodfill_he.cpp
engines/scumm/he/floodfill_he.h
engines/scumm/he/script_v100he.cpp
engines/scumm/he/script_v90he.cpp
diff --git a/engines/scumm/he/animation_he.cpp b/engines/scumm/he/animation_he.cpp
index 99108baf066..8ae3e016601 100644
--- a/engines/scumm/he/animation_he.cpp
+++ b/engines/scumm/he/animation_he.cpp
@@ -77,7 +77,7 @@ int MoviePlayer::load(const Common::Path &filename, int flags, int image) {
debug(1, "Playing video %s", filename.toString().c_str());
- if (flags & 2)
+ if (flags & vfImageSurface)
_vm->_wiz->createWizEmptyImage(image, 0, 0, _video->getWidth(), _video->getHeight());
_flags = flags;
@@ -155,13 +155,13 @@ void MoviePlayer::handleNextFrame() {
VirtScreen *pvs = &_vm->_virtscr[kMainVirtScreen];
- if (_flags & 2) {
+ if (_flags & vfImageSurface) {
uint8 *dstPtr = _vm->getResourceAddress(rtImage, _wizResNum);
assert(dstPtr);
uint8 *dst = _vm->findWrappedBlock(MKTAG('W','I','Z','D'), dstPtr, 0, 0);
assert(dst);
copyFrameToBuffer(dst, kDstResource, 0, 0, _vm->_screenWidth * _vm->_bytesPerPixel);
- } else if (_flags & 1) {
+ } else if (_flags & vfBackground) {
copyFrameToBuffer(pvs->getBackPixels(0, 0), kDstScreen, 0, 0, pvs->pitch);
Common::Rect imageRect(_video->getWidth(), _video->getHeight());
diff --git a/engines/scumm/he/animation_he.h b/engines/scumm/he/animation_he.h
index 36229744321..af520333e68 100644
--- a/engines/scumm/he/animation_he.h
+++ b/engines/scumm/he/animation_he.h
@@ -39,7 +39,17 @@ namespace Scumm {
class ScummEngine_v90he;
class MoviePlayer {
+
public:
+ enum VideoFlags {
+ vfBackground = 0x00000001,
+ vfImageSurface = 0x00000002,
+ vfForeground = 0x00000004,
+ vfLooping = 0x00000008,
+ vfAllowFrameSkip = 0x00000010,
+ vfDefault = (vfForeground),
+ };
+
MoviePlayer(ScummEngine_v90he *vm, Audio::Mixer *mixer);
~MoviePlayer();
diff --git a/engines/scumm/he/floodfill_he.cpp b/engines/scumm/he/floodfill_he.cpp
index adf6eabe030..ceb93ad1b59 100644
--- a/engines/scumm/he/floodfill_he.cpp
+++ b/engines/scumm/he/floodfill_he.cpp
@@ -174,14 +174,18 @@ skip:
}
void floodFill(FloodFillParameters *ffp, ScummEngine_v90he *vm) {
+ // To test this operation: use room 33 of BluesBirthday yellow disc
uint8 *dst;
VirtScreen *vs = &vm->_virtscr[kMainVirtScreen];
- if (ffp->flags & 0x8000) {
+
+ int32 colorBackMask = vm->_game.heversion > 99 ? 0x01000000 : 0x8000;
+
+ if (ffp->color & colorBackMask) {
dst = vs->getBackPixels(0, vs->topline);
} else {
dst = vs->getPixels(0, vs->topline);
}
- uint8 color = ffp->flags & 0xFF;
+ uint8 color = ffp->color & 0xFF;
Common::Rect r;
r.left = r.top = 12345;
@@ -204,7 +208,7 @@ void floodFill(FloodFillParameters *ffp, ScummEngine_v90he *vm) {
ffs->color1 = *(dst + ffp->y * vs->w + ffp->x);
}
- debug(5, "floodFill() x=%d y=%d color1=%d ffp->flags=0x%X", ffp->x, ffp->y, ffs->color1, ffp->flags);
+ debug(5, "floodFill() x=%d y=%d color1=%d ffp->color=0x%X", ffp->x, ffp->y, ffs->color1, ffp->color);
if (ffs->color1 != color) {
floodFillProcess(ffp->x, ffp->y, ffs, floodFillPixelCheck);
r = ffs->dstBox;
@@ -214,10 +218,10 @@ void floodFill(FloodFillParameters *ffp, ScummEngine_v90he *vm) {
delete[] ffs->fillLineTable;
delete ffs;
- vm->VAR(119) = 1;
+ vm->VAR(vm->VAR_OPERATION_FAILURE) = 1;
if (r.left <= r.right && r.top <= r.bottom) {
- if (ffp->flags & 0x8000) {
+ if (ffp->color & colorBackMask) {
vm->restoreBackgroundHE(r);
} else {
++r.bottom;
diff --git a/engines/scumm/he/floodfill_he.h b/engines/scumm/he/floodfill_he.h
index 60e04b5d71f..ee29a3dc476 100644
--- a/engines/scumm/he/floodfill_he.h
+++ b/engines/scumm/he/floodfill_he.h
@@ -30,12 +30,14 @@ struct FloodFillParameters {
Common::Rect box;
int32 x;
int32 y;
+ int32 color;
int32 flags;
void reset() {
box.top = box.left = box.bottom = box.right = 0;
x = 0;
y = 0;
+ color = 0;
flags = 0;
}
};
diff --git a/engines/scumm/he/script_v100he.cpp b/engines/scumm/he/script_v100he.cpp
index ee2b53a1964..3dfe28a6f0b 100644
--- a/engines/scumm/he/script_v100he.cpp
+++ b/engines/scumm/he/script_v100he.cpp
@@ -2292,7 +2292,7 @@ void ScummEngine_v100he::o100_videoOps() {
case SO_IMAGE:
_videoParams.wizResNum = pop();
if (_videoParams.wizResNum)
- _videoParams.flags |= 2;
+ _videoParams.flags |= MoviePlayer::vfImageSurface;
break;
case SO_LOAD:
copyScriptString(_videoParams.filename, sizeof(_videoParams.filename));
@@ -2305,12 +2305,12 @@ void ScummEngine_v100he::o100_videoOps() {
if (_videoParams.status == SO_LOAD) {
// Start video
if (_videoParams.flags == 0)
- _videoParams.flags = 4;
+ _videoParams.flags = MoviePlayer::vfDefault;
- if (_videoParams.flags & 2) {
- VAR(119) = _moviePlay->load(convertFilePath(_videoParams.filename), _videoParams.flags, _videoParams.wizResNum);
+ if (_videoParams.flags & MoviePlayer::vfImageSurface) {
+ VAR(VAR_OPERATION_FAILURE) = _moviePlay->load(convertFilePath(_videoParams.filename), _videoParams.flags, _videoParams.wizResNum);
} else {
- VAR(119) = _moviePlay->load(convertFilePath(_videoParams.filename), _videoParams.flags);
+ VAR(VAR_OPERATION_FAILURE) = _moviePlay->load(convertFilePath(_videoParams.filename), _videoParams.flags);
}
} else if (_videoParams.status == SO_CLOSE) {
// Stop video
diff --git a/engines/scumm/he/script_v90he.cpp b/engines/scumm/he/script_v90he.cpp
index 0cc95ee5600..837a4e92c0a 100644
--- a/engines/scumm/he/script_v90he.cpp
+++ b/engines/scumm/he/script_v90he.cpp
@@ -1350,10 +1350,12 @@ void ScummEngine_v90he::o90_getWizData() {
switch (fontProperty) {
case 2: // PFONT_EXTENT_X
//push(PFONT_GetStringWidth(iImage, szResultString));
+ push(0);
break;
case 3: // PFONT_EXTENT_Y
//push(PFONT_GetStringHeight(iImage, szResultString));
+ push(0);
break;
default:
// No default case in the original...
@@ -1432,7 +1434,7 @@ void ScummEngine_v90he::o90_priorityChainScript() {
void ScummEngine_v90he::o90_videoOps() {
// Uses Smacker video
int status = fetchScriptByte();
- int subOp = status - 49;
+ int subOp = status;
switch (subOp) {
case SO_LOAD: // 49
@@ -1452,7 +1454,7 @@ void ScummEngine_v90he::o90_videoOps() {
case SO_IMAGE: // 63
_videoParams.wizResNum = pop();
if (_videoParams.wizResNum)
- _videoParams.flags |= 2;
+ _videoParams.flags |= MoviePlayer::vfImageSurface;
break;
case SO_CLOSE: // 165
_videoParams.status = status;
@@ -1461,9 +1463,9 @@ void ScummEngine_v90he::o90_videoOps() {
if (_videoParams.status == SO_LOAD) {
// Start video
if (_videoParams.flags == 0)
- _videoParams.flags = 4;
+ _videoParams.flags = MoviePlayer::vfDefault;
- if (_videoParams.flags & 2) {
+ if (_videoParams.flags & MoviePlayer::vfImageSurface) {
VAR(VAR_OPERATION_FAILURE) = _moviePlay->load(convertFilePath(_videoParams.filename), _videoParams.flags, _videoParams.wizResNum);
} else {
VAR(VAR_OPERATION_FAILURE) = _moviePlay->load(convertFilePath(_videoParams.filename), _videoParams.flags);
@@ -1517,7 +1519,7 @@ void ScummEngine_v90he::o90_floodFill() {
switch (subOp) {
case SO_SET_FLAGS: // 54
- // TODO floodInfo.flags |= pop();
+ _floodFillParams.flags |= pop();
pop();
break;
case SO_INIT: // 57
@@ -1526,14 +1528,13 @@ void ScummEngine_v90he::o90_floodFill() {
_floodFillParams.box.top = 0;
_floodFillParams.box.right = 639;
_floodFillParams.box.bottom = 479;
- adjustRect(_floodFillParams.box);
break;
case SO_AT: // 65
_floodFillParams.y = pop();
_floodFillParams.x = pop();
break;
case SO_COLOR: // 66
- _floodFillParams.flags = pop(); // TODO: Should be .color!
+ _floodFillParams.color = pop();
break;
case SO_CLIPPED: // 67
_floodFillParams.box.bottom = pop();
Commit: e7f979ee9fec0edfc68872311bc644081ee737d3
https://github.com/scummvm/scummvm/commit/e7f979ee9fec0edfc68872311bc644081ee737d3
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Preliminar clean up for WIZ rewrite pt.3
Changed paths:
engines/scumm/he/intern_he.h
engines/scumm/he/script_v100he.cpp
diff --git a/engines/scumm/he/intern_he.h b/engines/scumm/he/intern_he.h
index 40f17715a0d..4c4dedbae55 100644
--- a/engines/scumm/he/intern_he.h
+++ b/engines/scumm/he/intern_he.h
@@ -968,6 +968,14 @@ protected:
SO_ROOM_SAVEGAME_BY_NAME = 137,
SO_ROOM_SCREEN = 138,
SO_ROOM_SCROLL = 139,
+ SO_ROOM_SHAKE_OFF = 140,
+ SO_ROOM_SHAKE_ON = 141,
+ SO_ROOM_TRANSFORM = 142,
+
+ // SCRIPT
+ SO_BAK = 128,
+ SO_BAKREC = 129,
+ SO_REC = 130,
// SYSTEM
SO_FLUSH_OBJECT_DRAW_QUEUE = 128,
@@ -1031,8 +1039,8 @@ protected:
void o100_createSound();
void o100_dim2dim2Array();
void o100_paletteOps();
- void o100_jumpToScriptUnk();
- void o100_startScriptUnk();
+ void o100_priorityChainScript();
+ void o100_priorityStartScript();
void o100_redimArray();
void o100_roomOps();
void o100_setSystemMessage();
diff --git a/engines/scumm/he/script_v100he.cpp b/engines/scumm/he/script_v100he.cpp
index 3dfe28a6f0b..39888a97fe1 100644
--- a/engines/scumm/he/script_v100he.cpp
+++ b/engines/scumm/he/script_v100he.cpp
@@ -149,8 +149,8 @@ void ScummEngine_v100he::setupOpcodes() {
OPCODE(0x57, o6_printSystem);
/* 58 */
OPCODE(0x58, o6_printText);
- OPCODE(0x59, o100_jumpToScriptUnk);
- OPCODE(0x5a, o100_startScriptUnk);
+ OPCODE(0x59, o100_priorityChainScript);
+ OPCODE(0x5a, o100_priorityStartScript);
OPCODE(0x5b, o6_pseudoRoom);
/* 5C */
OPCODE(0x5c, o6_pushByte);
@@ -740,7 +740,7 @@ void ScummEngine_v100he::o100_jumpToScript() {
script = pop();
flags = fetchScriptByte();
stopObjectCode();
- runScript(script, (flags == 128 || flags == 129), (flags == 130 || flags == 129), args);
+ runScript(script, (flags == SO_BAK || flags == SO_BAKREC), (flags == SO_REC || flags == SO_BAKREC), args);
}
void ScummEngine_v100he::o100_createSound() {
@@ -965,9 +965,9 @@ void ScummEngine_v100he::o100_setSpriteGroupInfo() {
_sprite->setGroupBounds(_curSpriteGroupId, value1, value2, value3, value4);
break;
case SO_GROUP: // 38
- type = pop() - 1;
+ type = pop();
switch (type) {
- case 0: // SPRGRPOP_MOVE
+ case SPRGRPOP_MOVE: // 1
value2 = pop();
value1 = pop();
if (!_curSpriteGroupId)
@@ -975,48 +975,48 @@ void ScummEngine_v100he::o100_setSpriteGroupInfo() {
_sprite->moveGroupMembers(_curSpriteGroupId, value1, value2);
break;
- case 1: // SPRGRPOP_ORDER
+ case SPRGRPOP_ORDER: // 2
value1 = pop();
if (!_curSpriteGroupId)
break;
_sprite->setGroupMembersPriority(_curSpriteGroupId, value1);
break;
- case 2: // SPRGRPOP_NEW_GROUP
+ case SPRGRPOP_NEW_GROUP: // 3
value1 = pop();
if (!_curSpriteGroupId)
break;
_sprite->setGroupMembersGroup(_curSpriteGroupId, value1);
break;
- case 3: // SPRGRPOP_UPDATE_TYPE
+ case SPRGRPOP_UPDATE_TYPE: // 4
value1 = pop();
if (!_curSpriteGroupId)
break;
_sprite->setGroupMembersUpdateType(_curSpriteGroupId, value1);
break;
- case 4: // SPRGRPOP_NEW
+ case SPRGRPOP_NEW: // 5
if (!_curSpriteGroupId)
break;
_sprite->setGroupMembersResetSprite(_curSpriteGroupId);
break;
- case 5: // SPRGRPOP_ANIMATION_SPEED
+ case SPRGRPOP_ANIMATION_SPEED: // 6
value1 = pop();
if (!_curSpriteGroupId)
break;
_sprite->setGroupMembersAnimationSpeed(_curSpriteGroupId, value1);
break;
- case 6: // SPRGRPOP_ANIMATION_TYPE
+ case SPRGRPOP_ANIMATION_TYPE: // 7
value1 = pop();
if (!_curSpriteGroupId)
break;
_sprite->setGroupMembersAutoAnimFlag(_curSpriteGroupId, value1);
break;
- case 7: // SPRGRPOP_SHADOW
+ case SPRGRPOP_SHADOW: // 8
value1 = pop();
if (!_curSpriteGroupId)
break;
@@ -1070,16 +1070,16 @@ void ScummEngine_v100he::o100_setSpriteGroupInfo() {
break;
switch (type) {
- case 0: // SPRGRPPROP_XMUL
+ case SPRGRPPROP_XMUL: // 0
_sprite->setGroupXMul(_curSpriteGroupId, value1);
break;
- case 1: // SPRGRPPROP_XDIV
+ case SPRGRPPROP_XDIV: // 1
_sprite->setGroupXDiv(_curSpriteGroupId, value1);
break;
- case 2: // SPRGRPPROP_YMUL
+ case SPRGRPPROP_YMUL: // 2
_sprite->setGroupYMul(_curSpriteGroupId, value1);
break;
- case 3: // SPRGRPPROP_YDIV
+ case SPRGRPPROP_YDIV: // 3
_sprite->setGroupYDiv(_curSpriteGroupId, value1);
break;
default:
@@ -1557,7 +1557,7 @@ void ScummEngine_v100he::o100_paletteOps() {
}
}
-void ScummEngine_v100he::o100_jumpToScriptUnk() {
+void ScummEngine_v100he::o100_priorityChainScript() {
int args[25];
int script, cycle;
byte flags;
@@ -1567,10 +1567,10 @@ void ScummEngine_v100he::o100_jumpToScriptUnk() {
script = pop();
flags = fetchScriptByte();
stopObjectCode();
- runScript(script, (flags == 128 || flags == 129), (flags == 130 || flags == 129), args, cycle);
+ runScript(script, (flags == SO_BAK || flags == SO_BAKREC), (flags == SO_REC || flags == SO_BAKREC), args, cycle);
}
-void ScummEngine_v100he::o100_startScriptUnk() {
+void ScummEngine_v100he::o100_priorityStartScript() {
int args[25];
int script, cycle;
byte flags;
@@ -1579,7 +1579,7 @@ void ScummEngine_v100he::o100_startScriptUnk() {
cycle = pop();
script = pop();
flags = fetchScriptByte();
- runScript(script, (flags == 128 || flags == 129), (flags == 130 || flags == 129), args, cycle);
+ runScript(script, (flags == SO_BAK || flags == SO_BAKREC), (flags == SO_REC || flags == SO_BAKREC), args, cycle);
}
void ScummEngine_v100he::o100_redimArray() {
@@ -2016,19 +2016,19 @@ void ScummEngine_v100he::o100_setSpriteInfo() {
for (; spriteId <= _curMaxSpriteId; spriteId++)
switch (args[1]) {
- case 0:
+ case SPRPROP_HFLIP: // 0
_sprite->setSpriteFlagXFlipped(spriteId, args[0]);
break;
- case 1:
+ case SPRPROP_VFLIP: // 1
_sprite->setSpriteFlagYFlipped(spriteId, args[0]);
break;
- case 2:
+ case SPRPROP_ACTIVE: // 2
_sprite->setSpriteFlagActive(spriteId, args[0]);
break;
- case 3:
+ case SPRPROP_BACKGROUND_RENDER: // 3
_sprite->setSpriteFlagDoubleBuffered(spriteId, args[0]);
break;
- case 4:
+ case SPRPROP_USE_IMAGE_REMAP_TABLE: // 4
_sprite->setSpriteFlagRemapPalette(spriteId, args[0]);
break;
default:
@@ -2167,7 +2167,7 @@ void ScummEngine_v100he::o100_startScript() {
getStackList(args, ARRAYSIZE(args));
script = pop();
flags = fetchScriptByte();
- runScript(script, (flags == 128 || flags == 129), (flags == 130 || flags == 129), args);
+ runScript(script, (flags == SO_BAK || flags == SO_BAKREC), (flags == SO_REC || flags == SO_BAKREC), args);
}
void ScummEngine_v100he::o100_systemOps() {
@@ -2545,16 +2545,16 @@ void ScummEngine_v100he::o100_getSpriteGroupInfo() {
spriteGroupId = pop();
if (spriteGroupId) {
switch (type) {
- case 0: // SPRGRPPROP_XMUL
+ case SPRGRPPROP_XMUL: // 0
push(_sprite->getGroupXMul(spriteGroupId));
break;
- case 1: // SPRGRPPROP_XDIV
+ case SPRGRPPROP_XDIV: // 1
push(_sprite->getGroupXDiv(spriteGroupId));
break;
- case 2: // SPRGRPPROP_YMUL
+ case SPRGRPPROP_YMUL: // 2
push(_sprite->getGroupYMul(spriteGroupId));
break;
- case 3: // SPRGRPPROP_YDIV
+ case SPRGRPPROP_YDIV: // 3
push(_sprite->getGroupYDiv(spriteGroupId));
break;
default:
@@ -2895,19 +2895,19 @@ void ScummEngine_v100he::o100_getSpriteInfo() {
spriteId = pop();
if (spriteId) {
switch (flags) {
- case 0:
+ case SPRPROP_HFLIP: // 0
push(_sprite->getSpriteFlagXFlipped(spriteId));
break;
- case 1:
+ case SPRPROP_VFLIP: // 1
push(_sprite->getSpriteFlagYFlipped(spriteId));
break;
- case 2:
+ case SPRPROP_ACTIVE: // 2
push(_sprite->getSpriteFlagActive(spriteId));
break;
- case 3:
+ case SPRPROP_BACKGROUND_RENDER: // 3
push(_sprite->getSpriteFlagDoubleBuffered(spriteId));
break;
- case 4:
+ case SPRPROP_USE_IMAGE_REMAP_TABLE: // 4
push(_sprite->getSpriteFlagRemapPalette(spriteId));
break;
default:
Commit: baa1e06d294f0c37a877c9e0f276827f42b29d04
https://github.com/scummvm/scummvm/commit/baa1e06d294f0c37a877c9e0f276827f42b29d04
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Preliminar clean up for WIZ rewrite pt.4
Changed paths:
engines/scumm/he/floodfill_he.cpp
engines/scumm/he/script_v100he.cpp
engines/scumm/he/script_v72he.cpp
engines/scumm/he/script_v90he.cpp
engines/scumm/he/sprite_he.cpp
engines/scumm/he/wiz_he.cpp
engines/scumm/he/wiz_he.h
diff --git a/engines/scumm/he/floodfill_he.cpp b/engines/scumm/he/floodfill_he.cpp
index ceb93ad1b59..c8e560d50a2 100644
--- a/engines/scumm/he/floodfill_he.cpp
+++ b/engines/scumm/he/floodfill_he.cpp
@@ -231,13 +231,13 @@ void floodFill(FloodFillParameters *ffp, ScummEngine_v90he *vm) {
}
void Wiz::fillWizFlood(const WizParameters *params) {
- if (params->processFlags & kWPFClipBox2) {
- int px = params->box2.left;
- int py = params->box2.top;
+ if (params->actionFlags & kWAFRenderCoords) {
+ int px = params->renderCoords.left;
+ int py = params->renderCoords.top;
uint8 *dataPtr = _vm->getResourceAddress(rtImage, params->img.resNum);
if (dataPtr) {
int state = 0;
- if (params->processFlags & kWPFNewState) {
+ if (params->actionFlags & kWAFState) {
state = params->img.state;
}
uint8 *wizh = _vm->findWrappedBlock(MKTAG('W','I','Z','H'), dataPtr, state, 0);
@@ -247,14 +247,14 @@ void Wiz::fillWizFlood(const WizParameters *params) {
int h = READ_LE_UINT32(wizh + 0x8);
assert(c == 0);
Common::Rect imageRect(w, h);
- if (params->processFlags & kWPFClipBox) {
+ if (params->actionFlags & kWAFRect) {
if (!imageRect.intersects(params->box)) {
return;
}
imageRect.clip(params->box);
}
uint8 color = _vm->VAR(93);
- if (params->processFlags & kWPFFillColor) {
+ if (params->actionFlags & kWAFColor) {
color = params->fillColor;
}
if (imageRect.contains(px, py)) {
diff --git a/engines/scumm/he/script_v100he.cpp b/engines/scumm/he/script_v100he.cpp
index 39888a97fe1..36318728191 100644
--- a/engines/scumm/he/script_v100he.cpp
+++ b/engines/scumm/he/script_v100he.cpp
@@ -37,7 +37,7 @@
namespace Scumm {
-#define OPCODE(i, x) _opcodes[i]._OPCODE(ScummEngine_v100he, x)
+#define OPCODE(i, x2) _opcodes[i]._OPCODE(ScummEngine_v100he, x2)
void ScummEngine_v100he::setupOpcodes() {
/* 00 */
@@ -831,12 +831,12 @@ void ScummEngine_v100he::o100_dimArray() {
}
void ScummEngine_v100he::o100_drawLine() {
- int id, unk1, unk2, x, x1, y1;
+ int color, y2, step, x2, x1, y1;
- unk2 = pop();
- id = pop();
- unk1 = pop();
- x = pop();
+ step = pop();
+ color = pop();
+ y2 = pop();
+ x2 = pop();
y1 = pop();
x1 = pop();
@@ -844,13 +844,13 @@ void ScummEngine_v100he::o100_drawLine() {
switch (subOp) {
case SO_ACTOR:
- drawLine(x1, y1, x, unk1, unk2, 2, id);
+ drawLine(x1, y1, x2, y2, step, 2, color);
break;
case SO_COLOR:
- drawLine(x1, y1, x, unk1, unk2, 1, id);
+ drawLine(x1, y1, x2, y2, step, 1, color);
break;
case SO_IMAGE:
- drawLine(x1, y1, x, unk1, unk2, 3, id);
+ drawLine(x1, y1, x2, y2, step, 3, color);
break;
default:
error("o100_drawLine: default case %d", subOp);
@@ -1203,41 +1203,41 @@ void ScummEngine_v100he::o100_wizImageOps() {
switch (subOp) {
case SO_INIT: // 0
_wizParams.img.resNum = pop();
- _wizParams.processMode = 0;
- _wizParams.processFlags = 0;
+ _wizParams.actionMode = kWAUnknown;
+ _wizParams.actionFlags = 0;
_wizParams.remapNum = 0;
_wizParams.img.flags = 0;
- _wizParams.params1 = 0;
- _wizParams.params2 = 0;
+ _wizParams.propertyValue = 0;
+ _wizParams.propertyNumber = 0;
_wizParams.spriteId = 0;
_wizParams.spriteGroup = 0;
break;
case SO_ANGLE: // 2
- _wizParams.processFlags |= kWPFRotate;
+ _wizParams.actionFlags |= kWAFRotate;
_wizParams.angle = pop();
break;
case SO_AT: // 6
case SO_CURSOR_HOTSPOT: // 132
- _wizParams.processFlags |= kWPFSetPos;
+ _wizParams.actionFlags |= kWAFSpot;
_wizParams.img.y1 = pop();
_wizParams.img.x1 = pop();
break;
case SO_AT_IMAGE: // 7
- _wizParams.processFlags |= kWPFMaskImg;
+ _wizParams.actionFlags |= kWAFSourceImg;
_wizParams.sourceImage = pop();
break;
case SO_CAPTURE: // 11
- _wizParams.processFlags |= kWPFClipBox | 0x100;
- _wizParams.processMode = 2;
+ _wizParams.actionFlags |= kWAFRect | kWAFCompressionType;
+ _wizParams.actionMode = kWACapture;
_wizParams.box.bottom = pop();
_wizParams.box.right = pop();
_wizParams.box.top = pop();
_wizParams.box.left = pop();
- _wizParams.compType = pop();
+ _wizParams.compressionType = pop();
adjustRect(_wizParams.box);
break;
case SO_CLIPPED: // 18
- _wizParams.processFlags |= kWPFClipBox;
+ _wizParams.actionFlags |= kWAFRect;
_wizParams.box.bottom = pop();
_wizParams.box.right = pop();
_wizParams.box.top = pop();
@@ -1247,19 +1247,19 @@ void ScummEngine_v100he::o100_wizImageOps() {
case SO_COLOR_LIST: // 21
b = pop();
a = pop();
- _wizParams.processFlags |= kWPFRemapPalette;
- _wizParams.processMode = 6;
+ _wizParams.actionFlags |= kWAFRemapList;
+ _wizParams.actionMode = kWAModify;
if (_wizParams.remapNum == 0) {
- memset(_wizParams.remapIndex, 0, sizeof(_wizParams.remapIndex));
+ memset(_wizParams.remapList, 0, sizeof(_wizParams.remapList));
} else {
- assert(_wizParams.remapNum < ARRAYSIZE(_wizParams.remapIndex));
- _wizParams.remapIndex[_wizParams.remapNum] = a;
- _wizParams.remapColor[a] = b;
+ assert(_wizParams.remapNum < ARRAYSIZE(_wizParams.remapList));
+ _wizParams.remapList[_wizParams.remapNum] = a;
+ _wizParams.remapTable[a] = b;
++_wizParams.remapNum;
}
break;
case SO_DRAW: // 29
- _wizParams.processMode = 1;
+ _wizParams.actionMode = kWADraw;
break;
case SO_GENERAL_CLIP_RECT: // 36
_wizParams.box.bottom = pop();
@@ -1272,21 +1272,21 @@ void ScummEngine_v100he::o100_wizImageOps() {
pop();
break;
case SO_HEIGHT: // 39
- _wizParams.processFlags |= kWPFUseDefImgHeight;
+ _wizParams.actionFlags |= kWAFHeight;
_wizParams.resDefImgH = pop();
break;
case SO_LOAD: // 47
- _wizParams.processFlags |= kWPFUseFile;
- _wizParams.processMode = 3;
+ _wizParams.actionFlags |= kWAFFilename;
+ _wizParams.actionMode = kWALoad;
copyScriptString(_wizParams.filename, sizeof(_wizParams.filename));
break;
case SO_NEW: // 53
- _wizParams.processMode = 8;
+ _wizParams.actionMode = kWANew;
break;
case SO_NEW_GENERAL_PROPERTY: // 54
- _wizParams.processFlags |= kWPFParams;
- _wizParams.params1 = pop();
- _wizParams.params2 = pop();
+ _wizParams.actionFlags |= kWAFProperty;
+ _wizParams.propertyValue = pop();
+ _wizParams.propertyNumber = pop();
break;
case SO_NOW: // 55
_wizParams.img.flags = pop();
@@ -1299,45 +1299,45 @@ void ScummEngine_v100he::o100_wizImageOps() {
_wiz->displayWizImage(&_wizParams.img);
break;
case SO_PALETTE: // 57
- _wizParams.processFlags |= kWPFPaletteNum;
+ _wizParams.actionFlags |= kWAFPalette;
_wizParams.img.palette = pop();
break;
case SO_POLY_TO_POLY: // 58
- _wizParams.processFlags |= 0x1000 | 0x100 | 0x2;
- _wizParams.processMode = 7;
- _wizParams.polygonId2 = pop();
- _wizParams.polygonId1 = pop();
- _wizParams.compType = pop();
+ _wizParams.actionFlags |= kWAFPolygon2 | kWAFCompressionType | kWAFPolygon;
+ _wizParams.actionMode = kWAPolyCapture;
+ _wizParams.polygon2 = pop();
+ _wizParams.polygon = pop();
+ _wizParams.compressionType = pop();
break;
case SO_SAVE: // 64
- _wizParams.processFlags |= kWPFUseFile;
- _wizParams.processMode = 4;
+ _wizParams.actionFlags |= kWAFFilename;
+ _wizParams.actionMode = kWASave;
copyScriptString(_wizParams.filename, sizeof(_wizParams.filename));
- _wizParams.fileWriteMode = pop();
+ _wizParams.fileType = pop();
break;
case SO_SCALE: // 65
- _wizParams.processFlags |= kWPFScaled;
+ _wizParams.actionFlags |= kWAFScaled;
_wizParams.scale = pop();
break;
case SO_SET_FLAGS: // 67
- _wizParams.processFlags |= kWPFNewFlags;
+ _wizParams.actionFlags |= kWAFFlags;
_wizParams.img.flags |= pop();
break;
case SO_SET_POLYGON: // 68
- _wizParams.processFlags |= kWPFNewFlags | kWPFSetPos | 2;
+ _wizParams.actionFlags |= kWAFFlags | kWAFSpot | kWAFPolygon;
_wizParams.img.flags |= kWIFIsPolygon;
- _wizParams.polygonId1 = _wizParams.img.y1 = _wizParams.img.x1 = pop();
+ _wizParams.polygon = _wizParams.img.y1 = _wizParams.img.x1 = pop();
break;
case SO_SHADOW: // 70
- _wizParams.processFlags |= kWPFShadow;
+ _wizParams.actionFlags |= kWAFShadow;
_wizParams.img.shadow = pop();
break;
case SO_STATE: // 73
- _wizParams.processFlags |= kWPFNewState;
+ _wizParams.actionFlags |= kWAFState;
_wizParams.img.state = pop();
break;
case SO_WIDTH: // 84
- _wizParams.processFlags |= kWPFUseDefImgWidth;
+ _wizParams.actionFlags |= kWAFWidth;
_wizParams.resDefImgW = pop();
break;
case SO_END: // 92
@@ -1345,7 +1345,7 @@ void ScummEngine_v100he::o100_wizImageOps() {
_wiz->processWizImage(&_wizParams);
break;
case SO_FONT_CREATE: // 128
- _wizParams.processMode = 15;
+ _wizParams.actionMode = kWAFontCreate;
_wizParams.fontProperties.bgColor = pop();
_wizParams.fontProperties.fgColor = pop();
_wizParams.fontProperties.size = pop();
@@ -1353,19 +1353,19 @@ void ScummEngine_v100he::o100_wizImageOps() {
copyScriptString(_wizParams.fontProperties.fontName, sizeof(_wizParams.fontProperties.fontName));
break;
case SO_FONT_END: // 129
- _wizParams.processMode = 14;
+ _wizParams.actionMode = kWAFontEnd;
break;
case SO_FONT_RENDER: // 130
- _wizParams.processMode = 16;
+ _wizParams.actionMode = kWAFontRender;
_wizParams.fontProperties.yPos = pop();
_wizParams.fontProperties.xPos = pop();
copyScriptString(_wizParams.fontProperties.string, sizeof(_wizParams.fontProperties.string));
break;
case SO_FONT_START: // 131
- _wizParams.processMode = 13;
+ _wizParams.actionMode = kWAFontStart;
break;
case SO_RENDER_ELLIPSE: // 133
- _wizParams.processMode = 17;
+ _wizParams.actionMode = kWARenderEllipse;
_wizParams.ellipseProperties.color = pop();
_wizParams.ellipseProperties.lod = pop();
_wizParams.ellipseProperties.ky = pop();
@@ -1376,44 +1376,44 @@ void ScummEngine_v100he::o100_wizImageOps() {
_wizParams.ellipseProperties.px = pop();
break;
case SO_RENDER_FLOOD_FILL: // 134
- _wizParams.processFlags |= kWPFFillColor | kWPFClipBox2;
- _wizParams.processMode = 12;
+ _wizParams.actionFlags |= kWAFColor | kWAFRenderCoords;
+ _wizParams.actionMode = kWARenderFloodFill;
_wizParams.fillColor = pop();
- _wizParams.box2.top = _wizParams.box2.bottom = pop();
- _wizParams.box2.left = _wizParams.box2.right = pop();
- adjustRect(_wizParams.box2);
+ _wizParams.renderCoords.top = _wizParams.renderCoords.bottom = pop();
+ _wizParams.renderCoords.left = _wizParams.renderCoords.right = pop();
+ adjustRect(_wizParams.renderCoords);
break;
case SO_RENDER_INTO_IMAGE: // 135
- _wizParams.processFlags |= kWPFDstResNum;
+ _wizParams.actionFlags |= kWAFDestImage;
_wizParams.dstResNum = pop();
break;
case SO_RENDER_LINE: // 136
- _wizParams.processFlags |= kWPFFillColor | kWPFClipBox2;
- _wizParams.processMode = 10;
+ _wizParams.actionFlags |= kWAFColor | kWAFRenderCoords;
+ _wizParams.actionMode = 10;
_wizParams.fillColor = pop();
- _wizParams.box2.bottom = pop();
- _wizParams.box2.right = pop();
- _wizParams.box2.top = pop();
- _wizParams.box2.left = pop();
- adjustRect(_wizParams.box2);
+ _wizParams.renderCoords.bottom = pop();
+ _wizParams.renderCoords.right = pop();
+ _wizParams.renderCoords.top = pop();
+ _wizParams.renderCoords.left = pop();
+ adjustRect(_wizParams.renderCoords);
break;
case SO_RENDER_PIXEL: // 137
- _wizParams.processFlags |= kWPFFillColor | kWPFClipBox2;
- _wizParams.processMode = 11;
+ _wizParams.actionFlags |= kWAFColor | kWAFRenderCoords;
+ _wizParams.actionMode = kWARenderPixel;
_wizParams.fillColor = pop();
- _wizParams.box2.top = _wizParams.box2.bottom = pop();
- _wizParams.box2.left = _wizParams.box2.right = pop();
- adjustRect(_wizParams.box2);
+ _wizParams.renderCoords.top = _wizParams.renderCoords.bottom = pop();
+ _wizParams.renderCoords.left = _wizParams.renderCoords.right = pop();
+ adjustRect(_wizParams.renderCoords);
break;
case SO_RENDER_RECTANGLE: // 138
- _wizParams.processFlags |= kWPFFillColor | kWPFClipBox2;
- _wizParams.processMode = 9;
+ _wizParams.actionFlags |= kWAFColor | kWAFRenderCoords;
+ _wizParams.actionMode = kWARenderRectangle;
_wizParams.fillColor = pop();
- _wizParams.box2.bottom = pop();
- _wizParams.box2.right = pop();
- _wizParams.box2.top = pop();
- _wizParams.box2.left = pop();
- adjustRect(_wizParams.box2);
+ _wizParams.renderCoords.bottom = pop();
+ _wizParams.renderCoords.right = pop();
+ _wizParams.renderCoords.top = pop();
+ _wizParams.renderCoords.left = pop();
+ adjustRect(_wizParams.renderCoords);
break;
default:
error("o100_wizImageOps: Unknown case %d", subOp);
diff --git a/engines/scumm/he/script_v72he.cpp b/engines/scumm/he/script_v72he.cpp
index f9af89c3860..843aa02aa0b 100644
--- a/engines/scumm/he/script_v72he.cpp
+++ b/engines/scumm/he/script_v72he.cpp
@@ -640,7 +640,7 @@ void ScummEngine_v72he::o72_printWizImage() {
wi.resNum = pop();
wi.x1 = wi.y1 = 0;
wi.state = 0;
- wi.flags = kWIFPrint;
+ wi.flags = kWRFPrint;
_wiz->displayWizImage(&wi);
}
diff --git a/engines/scumm/he/script_v90he.cpp b/engines/scumm/he/script_v90he.cpp
index 837a4e92c0a..b38418ff597 100644
--- a/engines/scumm/he/script_v90he.cpp
+++ b/engines/scumm/he/script_v90he.cpp
@@ -112,11 +112,11 @@ void ScummEngine_v90he::o90_wizImageOps() {
switch (subOp) {
case SO_WIDTH: // 32, HE99+
- _wizParams.processFlags |= kWPFUseDefImgWidth;
+ _wizParams.actionFlags |= kWAFWidth;
_wizParams.resDefImgW = pop();
break;
case SO_HEIGHT: // 33, HE99+
- _wizParams.processFlags |= kWPFUseDefImgHeight;
+ _wizParams.actionFlags |= kWAFHeight;
_wizParams.resDefImgH = pop();
break;
case SO_GENERAL_CLIP_STATE: // 46
@@ -130,39 +130,39 @@ void ScummEngine_v90he::o90_wizImageOps() {
_wizParams.box.left = pop();
break;
case SO_DRAW: // 48
- _wizParams.processMode = 1;
+ _wizParams.actionMode = kWADraw;
break;
case SO_LOAD: // 49
- _wizParams.processFlags |= kWPFUseFile;
- _wizParams.processMode = 3;
+ _wizParams.actionFlags |= kWAFFilename;
+ _wizParams.actionMode = kWALoad;
copyScriptString(_wizParams.filename, sizeof(_wizParams.filename));
break;
case SO_SAVE: // 50
- _wizParams.processFlags |= kWPFUseFile;
- _wizParams.processMode = 4;
+ _wizParams.actionFlags |= kWAFFilename;
+ _wizParams.actionMode = kWASave;
copyScriptString(_wizParams.filename, sizeof(_wizParams.filename));
- _wizParams.fileWriteMode = pop();
+ _wizParams.fileType = pop();
break;
case SO_CAPTURE: // 51
- _wizParams.processFlags |= kWPFClipBox | 0x100;
- _wizParams.processMode = 2;
+ _wizParams.actionFlags |= kWAFRect | kWAFCompressionType;
+ _wizParams.actionMode = kWACapture;
_wizParams.box.bottom = pop();
_wizParams.box.right = pop();
_wizParams.box.top = pop();
_wizParams.box.left = pop();
- _wizParams.compType = pop();
+ _wizParams.compressionType = pop();
adjustRect(_wizParams.box);
break;
case SO_STATE: // 52
- _wizParams.processFlags |= kWPFNewState;
+ _wizParams.actionFlags |= kWAFState;
_wizParams.img.state = pop();
break;
case SO_ANGLE: // 53
- _wizParams.processFlags |= kWPFRotate;
+ _wizParams.actionFlags |= kWAFRotate;
_wizParams.angle = pop();
break;
case SO_SET_FLAGS: // 54
- _wizParams.processFlags |= kWPFNewFlags;
+ _wizParams.actionFlags |= kWAFFlags;
_wizParams.img.flags |= pop();
break;
case SO_NOW: // 56
@@ -175,22 +175,22 @@ void ScummEngine_v90he::o90_wizImageOps() {
break;
case SO_INIT: // 57
_wizParams.img.resNum = pop();
- _wizParams.processMode = 0;
- _wizParams.processFlags = 0;
+ _wizParams.actionMode = kWAUnknown;
+ _wizParams.actionFlags = 0;
_wizParams.remapNum = 0;
_wizParams.img.flags = 0;
- _wizParams.params1 = 0;
- _wizParams.params2 = 0;
+ _wizParams.propertyValue = 0;
+ _wizParams.propertyNumber = 0;
_wizParams.spriteId = 0;
_wizParams.spriteGroup = 0;
break;
case SO_AT_IMAGE: // 62, HE99+
- _wizParams.processFlags |= kWPFMaskImg;
+ _wizParams.actionFlags |= kWAFSourceImg;
_wizParams.sourceImage = pop();
break;
case SO_AT: // 65
case SO_CURSOR_HOTSPOT: // 154
- _wizParams.processFlags |= kWPFSetPos;
+ _wizParams.actionFlags |= kWAFSpot;
_wizParams.img.y1 = pop();
_wizParams.img.x1 = pop();
break;
@@ -199,18 +199,18 @@ void ScummEngine_v90he::o90_wizImageOps() {
case SO_COLOR_LIST: // 249, HE98+
b = pop();
a = pop();
- _wizParams.processFlags |= kWPFRemapPalette;
- _wizParams.processMode = 6;
+ _wizParams.actionFlags |= kWAFRemapList;
+ _wizParams.actionMode = kWAModify;
if (_wizParams.remapNum == 0) {
- memset(_wizParams.remapIndex, 0, sizeof(_wizParams.remapIndex));
+ memset(_wizParams.remapList, 0, sizeof(_wizParams.remapList));
}
- assert(_wizParams.remapNum < ARRAYSIZE(_wizParams.remapIndex));
- _wizParams.remapIndex[_wizParams.remapNum] = a;
- _wizParams.remapColor[a] = b;
+ assert(_wizParams.remapNum < ARRAYSIZE(_wizParams.remapList));
+ _wizParams.remapList[_wizParams.remapNum] = a;
+ _wizParams.remapTable[a] = b;
_wizParams.remapNum++;
break;
case SO_CLIPPED: // 67
- _wizParams.processFlags |= kWPFClipBox;
+ _wizParams.actionFlags |= kWAFRect;
_wizParams.box.bottom = pop();
_wizParams.box.right = pop();
_wizParams.box.top = pop();
@@ -218,74 +218,74 @@ void ScummEngine_v90he::o90_wizImageOps() {
adjustRect(_wizParams.box);
break;
case SO_PALETTE: // 86, HE99+
- _wizParams.processFlags |= kWPFPaletteNum;
+ _wizParams.actionFlags |= kWAFPalette;
_wizParams.img.palette = pop();
break;
case SO_SCALE: // 92
- _wizParams.processFlags |= kWPFScaled;
+ _wizParams.actionFlags |= kWAFScaled;
_wizParams.scale = pop();
break;
case SO_SHADOW: // 98
- _wizParams.processFlags |= kWPFShadow;
+ _wizParams.actionFlags |= kWAFShadow;
_wizParams.img.shadow = pop();
break;
case SO_POLY_POLYGON: // 131, HE99+
- _wizParams.processFlags |= 0x1000 | 0x100 | 0x2;
- _wizParams.processMode = 7;
- _wizParams.polygonId2 = pop();
- _wizParams.polygonId1 = pop();
- _wizParams.compType = pop();
+ _wizParams.actionFlags |= kWAFPolygon2 | kWAFCompressionType | kWAFPolygon;
+ _wizParams.actionMode = kWAPolyCapture;
+ _wizParams.polygon2 = pop();
+ _wizParams.polygon = pop();
+ _wizParams.compressionType = pop();
break;
case SO_RENDER_RECTANGLE: // 133, HE99+
- _wizParams.processFlags |= kWPFFillColor | kWPFClipBox2;
- _wizParams.processMode = 9;
+ _wizParams.actionFlags |= kWAFColor | kWAFRenderCoords;
+ _wizParams.actionMode = kWARenderRectangle;
_wizParams.fillColor = pop();
- _wizParams.box2.bottom = pop();
- _wizParams.box2.right = pop();
- _wizParams.box2.top = pop();
- _wizParams.box2.left = pop();
- adjustRect(_wizParams.box2);
+ _wizParams.renderCoords.bottom = pop();
+ _wizParams.renderCoords.right = pop();
+ _wizParams.renderCoords.top = pop();
+ _wizParams.renderCoords.left = pop();
+ adjustRect(_wizParams.renderCoords);
break;
case SO_RENDER_LINE: // 134, HE99+
- _wizParams.processFlags |= kWPFFillColor | kWPFClipBox2;
- _wizParams.processMode = 10;
+ _wizParams.actionFlags |= kWAFColor | kWAFRenderCoords;
+ _wizParams.actionMode = kWARenderLine;
_wizParams.fillColor = pop();
- _wizParams.box2.bottom = pop();
- _wizParams.box2.right = pop();
- _wizParams.box2.top = pop();
- _wizParams.box2.left = pop();
- adjustRect(_wizParams.box2);
+ _wizParams.renderCoords.bottom = pop();
+ _wizParams.renderCoords.right = pop();
+ _wizParams.renderCoords.top = pop();
+ _wizParams.renderCoords.left = pop();
+ adjustRect(_wizParams.renderCoords);
break;
case SO_RENDER_PIXEL: // 135, HE99+
- _wizParams.processFlags |= kWPFFillColor | kWPFClipBox2;
- _wizParams.processMode = 11;
+ _wizParams.actionFlags |= kWAFColor | kWAFRenderCoords;
+ _wizParams.actionMode = kWARenderPixel;
_wizParams.fillColor = pop();
- _wizParams.box2.top = _wizParams.box2.bottom = pop();
- _wizParams.box2.left = _wizParams.box2.right = pop();
- adjustRect(_wizParams.box2);
+ _wizParams.renderCoords.top = _wizParams.renderCoords.bottom = pop();
+ _wizParams.renderCoords.left = _wizParams.renderCoords.right = pop();
+ adjustRect(_wizParams.renderCoords);
break;
case SO_RENDER_FLOOD_FILL: // 136, HE99+
- _wizParams.processFlags |= kWPFFillColor | kWPFClipBox2;
- _wizParams.processMode = 12;
+ _wizParams.actionFlags |= kWAFColor | kWAFRenderCoords;
+ _wizParams.actionMode = kWARenderFloodFill;
_wizParams.fillColor = pop();
- _wizParams.box2.top = _wizParams.box2.bottom = pop();
- _wizParams.box2.left = _wizParams.box2.right = pop();
- adjustRect(_wizParams.box2);
+ _wizParams.renderCoords.top = _wizParams.renderCoords.bottom = pop();
+ _wizParams.renderCoords.left = _wizParams.renderCoords.right = pop();
+ adjustRect(_wizParams.renderCoords);
break;
case SO_RENDER_INTO_IMAGE: // 137, HE99+
- _wizParams.processFlags |= kWPFDstResNum;
+ _wizParams.actionFlags |= kWAFDestImage;
_wizParams.dstResNum = pop();
break;
case SO_NEW_GENERAL_PROPERTY: // 139, HE99+
- _wizParams.processFlags |= kWPFParams;
- _wizParams.params1 = pop();
- _wizParams.params2 = pop();
+ _wizParams.actionFlags |= kWAFProperty;
+ _wizParams.propertyValue = pop();
+ _wizParams.propertyNumber = pop();
break;
case SO_FONT_START: // 141, HE99+
- _wizParams.processMode = 13;
+ _wizParams.actionMode = kWAFontStart;
break;
case SO_FONT_CREATE: // 142, HE99+
- _wizParams.processMode = 15;
+ _wizParams.actionMode = kWAFontCreate;
_wizParams.fontProperties.bgColor = pop();
_wizParams.fontProperties.fgColor = pop();
_wizParams.fontProperties.size = pop();
@@ -293,13 +293,13 @@ void ScummEngine_v90he::o90_wizImageOps() {
copyScriptString(_wizParams.fontProperties.fontName, sizeof(_wizParams.fontProperties.fontName));
break;
case SO_FONT_RENDER: // 143, HE99+
- _wizParams.processMode = 16;
+ _wizParams.actionMode = kWAFontRender;
_wizParams.fontProperties.yPos = pop();
_wizParams.fontProperties.xPos = pop();
copyScriptString(_wizParams.fontProperties.string, sizeof(_wizParams.fontProperties.string));
break;
case SO_RENDER_ELLIPSE: // 189, HE99+
- _wizParams.processMode = 17;
+ _wizParams.actionMode = kWARenderEllipse;
_wizParams.ellipseProperties.color = pop();
_wizParams.ellipseProperties.lod = pop();
_wizParams.ellipseProperties.ky = pop();
@@ -310,15 +310,15 @@ void ScummEngine_v90he::o90_wizImageOps() {
_wizParams.ellipseProperties.px = pop();
break;
case SO_FONT_END: // 196, HE99+
- _wizParams.processMode = 14;
+ _wizParams.actionMode = kWAFontEnd;
break;
case SO_NEW: // 217, HE99+
- _wizParams.processMode = 8;
+ _wizParams.actionMode = kWANew;
break;
case SO_SET_POLYGON: // 246
- _wizParams.processFlags |= kWPFNewFlags | kWPFSetPos | 2;
+ _wizParams.actionFlags |= kWAFFlags | kWAFSpot | kWAFPolygon;
_wizParams.img.flags |= kWIFIsPolygon;
- _wizParams.polygonId1 = _wizParams.img.y1 = _wizParams.img.x1 = pop();
+ _wizParams.polygon = _wizParams.img.y1 = _wizParams.img.x1 = pop();
break;
case SO_END: // 255
if (_wizParams.img.resNum)
@@ -2285,7 +2285,6 @@ void ScummEngine_v90he::o90_paletteOps() {
void ScummEngine_v90he::o90_fontEnum() {
byte string[80];
- int a;
byte subOp = fetchScriptByte();
diff --git a/engines/scumm/he/sprite_he.cpp b/engines/scumm/he/sprite_he.cpp
index bbdf580ae86..6eb80a94ede 100644
--- a/engines/scumm/he/sprite_he.cpp
+++ b/engines/scumm/he/sprite_he.cpp
@@ -1300,7 +1300,7 @@ void Sprite::processImages(bool arg) {
wiz.conditionBits = spi->conditionBits;
spi->curImageState = wiz.img.state = imageState;
spi->curImage = wiz.img.resNum = image;
- wiz.processFlags = kWPFNewState | kWPFSetPos;
+ wiz.actionFlags = kWAFState | kWAFSpot;
spi->curAngle = spi->angle;
spi->curScale = spi->scale;
spi->pos.x = wiz.img.x1;
@@ -1327,41 +1327,41 @@ void Sprite::processImages(bool arg) {
bboxPtr->bottom = -1234;
}
- wiz.img.flags = kWIFMarkBufferDirty;
+ wiz.img.flags = kWRFForeground;
wiz.img.zorder = 0;
if (spr_flags & kSFXFlipped)
wiz.img.flags |= kWIFFlipX;
if (spr_flags & kSFYFlipped)
wiz.img.flags |= kWIFFlipY;
if (spr_flags & kSFDoubleBuffered) {
- wiz.img.flags &= ~kWIFMarkBufferDirty;
- wiz.img.flags |= kWIFBlitToFrontVideoBuffer;
+ wiz.img.flags &= ~kWRFForeground;
+ wiz.img.flags |= kWRFBackground;
}
if (spi->shadow) {
wiz.img.flags |= 0x200;
- wiz.processFlags |= kWPFShadow;
+ wiz.actionFlags |= kWAFShadow;
wiz.img.shadow = spi->shadow;
}
if (spr_flags & kSFRemapPalette)
- wiz.img.flags |= kWIFRemapPalette;
+ wiz.img.flags |= kWRFRemap;
if (spi->zbufferImage) {
- wiz.processFlags |= 0x200000;
+ wiz.actionFlags |= 0x200000;
wiz.img.zbuffer = spi->zbufferImage;
wiz.img.zorder = spi->priority;
}
if (spi->sourceImage) {
- wiz.processFlags |= kWPFMaskImg;
+ wiz.actionFlags |= kWAFSourceImg;
wiz.sourceImage = spi->sourceImage;
}
- wiz.processFlags |= kWPFNewFlags;
+ wiz.actionFlags |= kWAFFlags;
wiz.img.flags |= spi->imgFlags;
if (spr_flags & kSFRotated) {
- wiz.processFlags |= kWPFRotate;
+ wiz.actionFlags |= kWAFRotate;
wiz.angle = spi->angle;
}
if (spr_flags & kSFScaled) {
- wiz.processFlags |= kWPFScaled;
+ wiz.actionFlags |= kWAFScaled;
wiz.scale = spi->scale;
}
spi->curImgFlags = wiz.img.flags;
@@ -1370,7 +1370,7 @@ void Sprite::processImages(bool arg) {
Common::Rect &spgBbox = _spriteGroups[spi->group].bbox;
if (spgBbox.isValidRect() && spi->bbox.intersects(spgBbox)) {
spi->bbox.clip(spgBbox);
- wiz.processFlags |= kWPFClipBox;
+ wiz.actionFlags |= kWAFRect;
wiz.box = spi->bbox;
} else {
bboxPtr->left = 1234;
@@ -1381,11 +1381,11 @@ void Sprite::processImages(bool arg) {
}
}
if (spi->palette) {
- wiz.processFlags |= kWPFPaletteNum;
+ wiz.actionFlags |= kWAFPalette;
wiz.img.palette = spi->palette;
}
if (spi->image && spi->group && _spriteGroups[spi->group].image) {
- wiz.processFlags |= kWPFDstResNum;
+ wiz.actionFlags |= kWAFDestImage;
wiz.dstResNum = _spriteGroups[spi->group].image;
}
_vm->_wiz->displayWizComplexImage(&wiz);
diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp
index 8857be3fa08..f6a1eb3ac93 100644
--- a/engines/scumm/he/wiz_he.cpp
+++ b/engines/scumm/he/wiz_he.cpp
@@ -1473,14 +1473,14 @@ uint8 *Wiz::drawWizImage(int resNum, int state, int maskNum, int maskState, int
assert(mask);
}
- if (flags & kWIFHasPalette) {
+ if (flags & kWRFUsePalette) {
uint8 *pal = _vm->findWrappedBlock(MKTAG('R','G','B','S'), dataPtr, state, 0);
assert(pal);
_vm->setPaletteFromPtr(pal, 256);
}
uint8 *rmap = NULL;
- if (flags & kWIFRemapPalette) {
+ if (flags & kWRFRemap) {
rmap = _vm->findWrappedBlock(MKTAG('R','M','A','P'), dataPtr, state, 0);
assert(rmap);
if (_vm->_game.heversion <= 80 || READ_BE_UINT32(rmap) != 0x01234567) {
@@ -1490,12 +1490,12 @@ uint8 *Wiz::drawWizImage(int resNum, int state, int maskNum, int maskState, int
}
}
- if (flags & kWIFPrint) {
+ if (flags & kWRFPrint) {
error("WizImage printing is unimplemented");
}
int32 dstPitch, dstType, cw, ch;
- if (flags & kWIFBlitToMemBuffer) {
+ if (flags & kWRFAlloc) {
dst = (uint8 *)malloc(width * height * _vm->_bytesPerPixel);
int transColor = (_vm->VAR_WIZ_TCOLOR != 0xFF) ? (_vm->VAR(_vm->VAR_WIZ_TCOLOR)) : 5;
@@ -1529,7 +1529,7 @@ uint8 *Wiz::drawWizImage(int resNum, int state, int maskNum, int maskState, int
dstType = kDstResource;
} else {
VirtScreen *pvs = &_vm->_virtscr[kMainVirtScreen];
- if (flags & kWIFMarkBufferDirty) {
+ if (flags & kWRFForeground) {
dst = pvs->getPixels(0, pvs->topline);
} else {
dst = pvs->getBackPixels(0, pvs->topline);
@@ -1547,7 +1547,7 @@ uint8 *Wiz::drawWizImage(int resNum, int state, int maskNum, int maskState, int
if (rScreen.intersects(clip)) {
rScreen.clip(clip);
} else {
- if (flags & kWIFBlitToMemBuffer)
+ if (flags & kWRFAlloc)
free(dst);
return 0;
@@ -1556,14 +1556,14 @@ uint8 *Wiz::drawWizImage(int resNum, int state, int maskNum, int maskState, int
if (rScreen.intersects(_rectOverride)) {
rScreen.clip(_rectOverride);
} else {
- if (flags & kWIFBlitToMemBuffer)
+ if (flags & kWRFAlloc)
free(dst);
return 0;
}
}
- if (flags & kWIFRemapPalette && _vm->_bytesPerPixel == 1) {
+ if (flags & kWRFRemap && _vm->_bytesPerPixel == 1) {
palPtr = rmap + 4;
}
@@ -1585,11 +1585,11 @@ uint8 *Wiz::drawWizImage(int resNum, int state, int maskNum, int maskState, int
state, &rScreen, flags, palPtr, transColor, _vm->_bytesPerPixel, xmapPtr, conditionBits);
}
- if (!(flags & kWIFBlitToMemBuffer) && dstResNum == 0) {
+ if (!(flags & kWRFAlloc) && dstResNum == 0) {
Common::Rect rImage(x1, y1, x1 + width, y1 + height);
if (rImage.intersects(rScreen)) {
rImage.clip(rScreen);
- if (!(flags & kWIFBlitToFrontVideoBuffer) && (flags & (kWIFBlitToFrontVideoBuffer | kWIFMarkBufferDirty))) {
+ if (!(flags & kWRFBackground) && (flags & (kWRFBackground | kWRFForeground))) {
++rImage.bottom;
_vm->markRectAsDirty(kMainVirtScreen, rImage);
} else {
@@ -1948,7 +1948,7 @@ void Wiz::captureWizPolygon(int resNum, int maskNum, int maskState, int id1, int
assert(maskNum);
const Common::Rect *r = NULL;
- const uint8 *src = drawWizImage(maskNum, maskState, 0, 0, 0, 0, 0, 0, 0, r, kWIFBlitToMemBuffer, 0, 0, 0);
+ const uint8 *src = drawWizImage(maskNum, maskState, 0, 0, 0, 0, 0, 0, 0, r, kWRFAlloc, 0, 0, 0);
getWizImageDim(maskNum, maskState, srcw, srch);
dstw = wp->bound.width();
@@ -2009,8 +2009,8 @@ void Wiz::drawWizPolygonTransform(int resNum, int state, Common::Point *wp, int
bool freeBuffer = true;
if (_vm->_game.heversion >= 99) {
- if (getWizImageData(resNum, state, 0) != 0 || (flags & (kWIFRemapPalette | kWIFFlipX | kWIFFlipY)) || palette != 0) {
- flags |= kWIFBlitToMemBuffer;
+ if (getWizImageData(resNum, state, 0) != 0 || (flags & (kWRFRemap | kWIFFlipX | kWIFFlipY)) || palette != 0) {
+ flags |= kWRFAlloc;
if (flags & 0x800000) {
debug(7, "drawWizPolygonTransform() unhandled flag 0x800000");
@@ -2027,7 +2027,7 @@ void Wiz::drawWizPolygonTransform(int resNum, int state, Common::Point *wp, int
}
} else {
if (getWizImageData(resNum, state, 0) != 0) {
- srcWizBuf = drawWizImage(resNum, state, 0, 0, 0, 0, 0, shadow, 0, r, kWIFBlitToMemBuffer, 0, _vm->getHEPaletteSlot(palette), 0);
+ srcWizBuf = drawWizImage(resNum, state, 0, 0, 0, 0, 0, shadow, 0, r, kWRFAlloc, 0, _vm->getHEPaletteSlot(palette), 0);
} else {
uint8 *dataPtr = _vm->getResourceAddress(rtImage, resNum);
assert(dataPtr);
@@ -2052,7 +2052,7 @@ void Wiz::drawWizPolygonTransform(int resNum, int state, Common::Point *wp, int
dstpitch = dstw * _vm->_bytesPerPixel;
dstType = kDstResource;
} else {
- if (flags & kWIFMarkBufferDirty) {
+ if (flags & kWRFForeground) {
dst = pvs->getPixels(0, 0);
} else {
dst = pvs->getBackPixels(0, 0);
@@ -2067,7 +2067,7 @@ void Wiz::drawWizPolygonTransform(int resNum, int state, Common::Point *wp, int
getWizImageDim(resNum, state, wizW, wizH);
drawWizPolygonImage(dst, srcWizBuf, 0, dstpitch, dstType, dstw, dsth, wizW, wizH, bound, wp, _vm->_bytesPerPixel);
- if (flags & kWIFMarkBufferDirty) {
+ if (flags & kWRFForeground) {
_vm->markRectAsDirty(kMainVirtScreen, bound);
} else {
_vm->restoreBackgroundHE(bound);
@@ -2224,7 +2224,7 @@ void Wiz::loadWizCursor(int resId, int palette) {
const Common::Rect *r = NULL;
_cursorImage = true;
- uint8 *cursor = drawWizImage(resId, 0, 0, 0, 0, 0, 0, 0, 0, r, kWIFBlitToMemBuffer, 0, _vm->getHEPaletteSlot(palette), 0);
+ uint8 *cursor = drawWizImage(resId, 0, 0, 0, 0, 0, 0, 0, 0, r, kWRFAlloc, 0, _vm->getHEPaletteSlot(palette), 0);
_cursorImage = false;
int32 cw, ch;
@@ -2240,60 +2240,60 @@ void Wiz::loadWizCursor(int resId, int palette) {
void Wiz::displayWizComplexImage(const WizParameters *params) {
int sourceImage = 0;
- if (params->processFlags & kWPFMaskImg) {
+ if (params->actionFlags & kWAFSourceImg) {
sourceImage = params->sourceImage;
- debug(7, "displayWizComplexImage() flag kWPFMaskImg");
+ debug(7, "displayWizComplexImage() flag kWAFSourceImg");
}
int palette = 0;
- if (params->processFlags & kWPFPaletteNum) {
+ if (params->actionFlags & kWAFPalette) {
palette = params->img.palette;
}
int scale = 256;
- if (params->processFlags & kWPFScaled) {
+ if (params->actionFlags & kWAFScaled) {
scale = params->scale;
}
int rotationAngle = 0;
- if (params->processFlags & kWPFRotate) {
+ if (params->actionFlags & kWAFRotate) {
rotationAngle = params->angle;
}
int state = 0;
- if (params->processFlags & kWPFNewState) {
+ if (params->actionFlags & kWAFState) {
state = params->img.state;
}
int flags = 0;
- if (params->processFlags & kWPFNewFlags) {
+ if (params->actionFlags & kWAFFlags) {
flags = params->img.flags;
}
int po_x = 0;
int po_y = 0;
- if (params->processFlags & kWPFSetPos) {
+ if (params->actionFlags & kWAFSpot) {
po_x = params->img.x1;
po_y = params->img.y1;
}
int shadow = 0;
- if (params->processFlags & kWPFShadow) {
+ if (params->actionFlags & kWAFShadow) {
shadow = params->img.shadow;
}
int zbuffer = 0;
- if (params->processFlags & kWPFZBuffer) {
+ if (params->actionFlags & kWAFZBufferImage) {
zbuffer = params->img.zbuffer;
- debug(7, "displayWizComplexImage() unhandled flag kWPFZBuffer");
+ debug(7, "displayWizComplexImage() unhandled flag kWAFZBufferImage");
}
const Common::Rect *r = NULL;
- if (params->processFlags & kWPFClipBox) {
+ if (params->actionFlags & kWAFRect) {
r = ¶ms->box;
}
int dstResNum = 0;
- if (params->processFlags & kWPFDstResNum) {
+ if (params->actionFlags & kWAFDestImage) {
dstResNum = params->dstResNum;
}
- if (_vm->_game.heversion >= 99 && params->processFlags & kWPFRemapPalette) {
+ if (_vm->_game.heversion >= 99 && params->actionFlags & kWAFRemapList) {
remapWizImagePal(params);
- flags |= kWIFRemapPalette;
+ flags |= kWRFRemap;
}
if (_vm->_fullRedraw && dstResNum == 0) {
- if (sourceImage != 0 || (params->processFlags & (kWPFScaled | kWPFRotate)))
+ if (sourceImage != 0 || (params->actionFlags & (kWAFScaled | kWAFRotate)))
error("Can't do this command in the enter script");
assert(_imagesNum < ARRAYSIZE(_images));
@@ -2311,7 +2311,7 @@ void Wiz::displayWizComplexImage(const WizParameters *params) {
} else {
if (sourceImage != 0) {
drawWizImage(params->sourceImage, 0, params->img.resNum, state, po_x, po_y, params->img.zorder, shadow, zbuffer, r, flags, dstResNum, _vm->getHEPaletteSlot(palette), 0);
- } else if (params->processFlags & (kWPFScaled | kWPFRotate)) {
+ } else if (params->actionFlags & (kWAFScaled | kWAFRotate)) {
drawWizComplexPolygon(params->img.resNum, state, po_x, po_y, shadow, rotationAngle, scale, r, flags, dstResNum, palette);
} else {
if (flags & kWIFIsPolygon) {
@@ -2347,9 +2347,9 @@ void Wiz::createWizEmptyImage(int resNum, int img_x, int img_y, int img_w, int i
}
uint8 *res_data = _vm->_res->createResource(rtImage, resNum, res_size);
if (!res_data) {
- _vm->VAR(119) = -1;
+ _vm->VAR(_vm->VAR_OPERATION_FAILURE) = -1;
} else {
- _vm->VAR(119) = 0;
+ _vm->VAR(_vm->VAR_OPERATION_FAILURE) = 0;
WRITE_BE_UINT32(res_data, 'AWIZ'); res_data += 4;
WRITE_BE_UINT32(res_data, res_size); res_data += 4;
WRITE_BE_UINT32(res_data, 'WIZH'); res_data += 4;
@@ -2384,7 +2384,7 @@ void Wiz::createWizEmptyImage(int resNum, int img_x, int img_y, int img_w, int i
void Wiz::fillWizRect(const WizParameters *params) {
int state = 0;
- if (params->processFlags & kWPFNewState) {
+ if (params->actionFlags & kWAFState) {
state = params->img.state;
}
uint8 *dataPtr = _vm->getResourceAddress(rtImage, params->img.resNum);
@@ -2397,19 +2397,19 @@ void Wiz::fillWizRect(const WizParameters *params) {
assert(c == 0 || c == 2);
uint8 bitDepth = (c == 2) ? 2 : 1;
Common::Rect areaRect, imageRect(w, h);
- if (params->processFlags & kWPFClipBox) {
+ if (params->actionFlags & kWAFRect) {
if (!imageRect.intersects(params->box)) {
return;
}
imageRect.clip(params->box);
}
- if (params->processFlags & kWPFClipBox2) {
- areaRect = params->box2;
+ if (params->actionFlags & kWAFRenderCoords) {
+ areaRect = params->renderCoords;
} else {
areaRect = imageRect;
}
uint16 color = _vm->VAR(93);
- if (params->processFlags & kWPFFillColor) {
+ if (params->actionFlags & kWAFColor) {
color = params->fillColor;
}
if (areaRect.intersects(imageRect)) {
@@ -2453,9 +2453,9 @@ static void drawProc(int x, int y, int c, void *data) {
}
void Wiz::fillWizLine(const WizParameters *params) {
- if (params->processFlags & kWPFClipBox2) {
+ if (params->actionFlags & kWAFRenderCoords) {
int state = 0;
- if (params->processFlags & kWPFNewState) {
+ if (params->actionFlags & kWAFState) {
state = params->img.state;
}
uint8 *dataPtr = _vm->getResourceAddress(rtImage, params->img.resNum);
@@ -2468,22 +2468,22 @@ void Wiz::fillWizLine(const WizParameters *params) {
assert(c == 0 || c == 2);
uint8 bitDepth = (c == 2) ? 2 : 1;
Common::Rect imageRect(w, h);
- if (params->processFlags & kWPFClipBox) {
+ if (params->actionFlags & kWAFRect) {
if (!imageRect.intersects(params->box)) {
return;
}
imageRect.clip(params->box);
}
uint16 color = _vm->VAR(93);
- if (params->processFlags & kWPFFillColor) {
+ if (params->actionFlags & kWAFColor) {
color = params->fillColor;
}
uint8 *wizd = _vm->findWrappedBlock(MKTAG('W','I','Z','D'), dataPtr, state, 0);
assert(wizd);
- int x1 = params->box2.left;
- int y1 = params->box2.top;
- int x2 = params->box2.right;
- int y2 = params->box2.bottom;
+ int x1 = params->renderCoords.left;
+ int y1 = params->renderCoords.top;
+ int x2 = params->renderCoords.right;
+ int y2 = params->renderCoords.bottom;
drawProcP lineP;
@@ -2492,8 +2492,8 @@ void Wiz::fillWizLine(const WizParameters *params) {
lineP.pitch = w * bitDepth;
lineP.depth = bitDepth;
- if (params->processFlags & kWPFParams) {
- Graphics::drawThickLine(x1, y1, x2, y2, params->params1, params->params2, color, drawProc, &lineP);
+ if (params->actionFlags & kWAFProperty) {
+ Graphics::drawThickLine(x1, y1, x2, y2, params->propertyValue, params->propertyNumber, color, drawProc, &lineP);
} else {
Graphics::drawLine(x1, y1, x2, y2, color, drawProc, &lineP);
}
@@ -2503,13 +2503,13 @@ void Wiz::fillWizLine(const WizParameters *params) {
}
void Wiz::fillWizPixel(const WizParameters *params) {
- if (params->processFlags & kWPFClipBox2) {
- int px = params->box2.left;
- int py = params->box2.top;
+ if (params->actionFlags & kWAFRenderCoords) {
+ int px = params->renderCoords.left;
+ int py = params->renderCoords.top;
uint8 *dataPtr = _vm->getResourceAddress(rtImage, params->img.resNum);
if (dataPtr) {
int state = 0;
- if (params->processFlags & kWPFNewState) {
+ if (params->actionFlags & kWAFState) {
state = params->img.state;
}
uint8 *wizh = _vm->findWrappedBlock(MKTAG('W','I','Z','H'), dataPtr, state, 0);
@@ -2519,14 +2519,14 @@ void Wiz::fillWizPixel(const WizParameters *params) {
int h = READ_LE_UINT32(wizh + 0x8);
assert(c == 0);
Common::Rect imageRect(w, h);
- if (params->processFlags & kWPFClipBox) {
+ if (params->actionFlags & kWAFRect) {
if (!imageRect.intersects(params->box)) {
return;
}
imageRect.clip(params->box);
}
uint16 color = _vm->VAR(93);
- if (params->processFlags & kWPFFillColor) {
+ if (params->actionFlags & kWAFColor) {
color = params->fillColor;
}
if (imageRect.contains(px, py)) {
@@ -2540,9 +2540,9 @@ void Wiz::fillWizPixel(const WizParameters *params) {
}
void Wiz::remapWizImagePal(const WizParameters *params) {
- int st = (params->processFlags & kWPFNewState) ? params->img.state : 0;
+ int st = (params->actionFlags & kWAFState) ? params->img.state : 0;
int num = params->remapNum;
- const uint8 *index = params->remapIndex;
+ const uint8 *index = params->remapList;
uint8 *iwiz = _vm->getResourceAddress(rtImage, params->img.resNum);
assert(iwiz);
uint8 *rmap = _vm->findWrappedBlock(MKTAG('R','M','A','P'), iwiz, st, 0);
@@ -2550,25 +2550,25 @@ void Wiz::remapWizImagePal(const WizParameters *params) {
WRITE_BE_UINT32(rmap, 0x01234567);
while (num--) {
uint8 idx = *index++;
- rmap[4 + idx] = params->remapColor[idx];
+ rmap[4 + idx] = params->remapTable[idx];
}
_vm->_res->setModified(rtImage, params->img.resNum);
}
void Wiz::processWizImage(const WizParameters *params) {
- debug(7, "processWizImage: processMode %d", params->processMode);
- switch (params->processMode) {
- case 0:
+ debug(7, "processWizImage: actionMode %d", params->actionMode);
+ switch (params->actionMode) {
+ case kWAUnknown:
// Used in racedemo
break;
- case 1:
+ case kWADraw:
displayWizComplexImage(params);
break;
- case 2:
- captureWizImage(params->img.resNum, params->box, (params->img.flags & kWIFBlitToFrontVideoBuffer) != 0, params->compType);
+ case kWACapture:
+ captureWizImage(params->img.resNum, params->box, (params->img.flags & kWRFBackground) != 0, params->compressionType);
break;
- case 3:
- if (params->processFlags & kWPFUseFile) {
+ case kWALoad:
+ if (params->actionFlags & kWAFFilename) {
Common::SeekableReadStream *f = _vm->openFileForReading(params->filename);
if (f) {
@@ -2581,29 +2581,29 @@ void Wiz::processWizImage(const WizParameters *params) {
_vm->_res->nukeResource(rtImage, params->img.resNum);
error("i/o error when reading '%s'", params->filename);
_vm->VAR(_vm->VAR_GAME_LOADED) = -2;
- _vm->VAR(119) = -2;
+ _vm->VAR(_vm->VAR_OPERATION_FAILURE) = -2;
} else {
_vm->_res->setModified(rtImage, params->img.resNum);
_vm->VAR(_vm->VAR_GAME_LOADED) = 0;
- _vm->VAR(119) = 0;
+ _vm->VAR(_vm->VAR_OPERATION_FAILURE) = 0;
}
} else {
_vm->VAR(_vm->VAR_GAME_LOADED) = -1;
- _vm->VAR(119) = -1;
+ _vm->VAR(_vm->VAR_OPERATION_FAILURE) = -1;
}
delete f;
} else {
_vm->VAR(_vm->VAR_GAME_LOADED) = -3;
- _vm->VAR(119) = -3;
+ _vm->VAR(_vm->VAR_OPERATION_FAILURE) = -3;
debug(0, "Unable to open for read '%s'", params->filename);
}
}
break;
- case 4:
- if (params->processFlags & kWPFUseFile) {
- switch (params->fileWriteMode) {
+ case kWASave:
+ if (params->actionFlags & kWAFFilename) {
+ switch (params->fileType) {
case 2:
- _vm->VAR(119) = -1;
+ _vm->VAR(_vm->VAR_OPERATION_FAILURE) = -1;
break;
case 1:
// TODO Write image to file
@@ -2613,15 +2613,15 @@ void Wiz::processWizImage(const WizParameters *params) {
if (!f) {
debug(0, "Unable to open for write '%s'", params->filename);
- _vm->VAR(119) = -3;
+ _vm->VAR(_vm->VAR_OPERATION_FAILURE) = -3;
} else {
byte *p = _vm->getResourceAddress(rtImage, params->img.resNum);
uint32 size = READ_BE_UINT32(p + 4);
if (f->write(p, size) != size) {
error("i/o error when writing '%s'", params->filename);
- _vm->VAR(119) = -2;
+ _vm->VAR(_vm->VAR_OPERATION_FAILURE) = -2;
} else {
- _vm->VAR(119) = 0;
+ _vm->VAR(_vm->VAR_OPERATION_FAILURE) = 0;
}
f->finalize();
delete f;
@@ -2629,73 +2629,76 @@ void Wiz::processWizImage(const WizParameters *params) {
break;
}
default:
- error("processWizImage: processMode 4 unhandled fileWriteMode %d", params->fileWriteMode);
+ error("processWizImage: actionMode kWASave unhandled fileType %d", params->fileType);
}
}
break;
- case 6:
+ case kWAGlobalState:
+ // Do nothing...
+ break;
+ case kWAModify:
remapWizImagePal(params);
break;
// HE 99+
- case 7:
- captureWizPolygon(params->img.resNum, params->sourceImage, (params->processFlags & kWPFNewState) ? params->img.state : 0, params->polygonId1, params->polygonId2, params->compType);
+ case kWAPolyCapture:
+ captureWizPolygon(params->img.resNum, params->sourceImage, (params->actionFlags & kWAFState) ? params->img.state : 0, params->polygon, params->polygon2, params->compressionType);
break;
- case 8: {
+ case kWANew: {
int img_w = 640;
- if (params->processFlags & kWPFUseDefImgWidth) {
+ if (params->actionFlags & kWAFWidth) {
img_w = params->resDefImgW;
}
int img_h = 480;
- if (params->processFlags & kWPFUseDefImgHeight) {
+ if (params->actionFlags & kWAFHeight) {
img_h = params->resDefImgH;
}
int img_x = 0;
int img_y = 0;
- if (params->processFlags & 1) {
+ if (params->actionFlags & 1) {
img_x = params->img.x1;
img_y = params->img.y1;
}
- if (params->processFlags & kWPFParams) {
- debug(7, "Compression %d Color Depth %d", params->params1, params->params2);
+ if (params->actionFlags & kWAFProperty) {
+ debug(7, "Compression %d Color Depth %d", params->propertyValue, params->propertyNumber);
}
createWizEmptyImage(params->img.resNum, img_x, img_y, img_w, img_h);
}
break;
- case 9:
+ case kWARenderRectangle:
fillWizRect(params);
break;
- case 10:
+ case kWARenderLine:
fillWizLine(params);
break;
- case 11:
+ case kWARenderPixel:
fillWizPixel(params);
break;
- case 12:
+ case kWARenderFloodFill:
fillWizFlood(params);
break;
- case 13:
+ case kWAFontStart:
// Used for text in FreddisFunShop/PuttsFunShop/SamsFunShop
// TODO: Start Font
break;
- case 14:
+ case kWAFontEnd:
// Used for text in FreddisFunShop/PuttsFunShop/SamsFunShop
// TODO: End Font
break;
- case 15:
+ case kWAFontCreate:
// Used for text in FreddisFunShop/PuttsFunShop/SamsFunShop
// TODO: Create Font
break;
- case 16:
+ case kWAFontRender:
// TODO: Render Font String
error("Render Font String");
break;
- case 17:
+ case kWARenderEllipse:
// Used in to draw circles in FreddisFunShop/PuttsFunShop/SamsFunShop
// TODO: Ellipse
_vm->_res->setModified(rtImage, params->img.resNum);
break;
default:
- error("Unhandled processWizImage mode %d", params->processMode);
+ error("Unhandled processWizImage mode %d", params->actionMode);
}
}
diff --git a/engines/scumm/he/wiz_he.h b/engines/scumm/he/wiz_he.h
index 6fc2fcab0f6..e39dcab90ab 100644
--- a/engines/scumm/he/wiz_he.h
+++ b/engines/scumm/he/wiz_he.h
@@ -79,38 +79,31 @@ struct EllipseProperties {
};
struct WizParameters {
- int field_0;
+ int dwSize;
byte filename[260];
Common::Rect box;
- int processFlags;
- int processMode;
- int field_11C;
- int field_120;
- int field_124;
- int field_128;
- int field_12C;
- int field_130;
- int field_134;
- int field_138;
- int compType;
- int fileWriteMode;
+ int actionFlags;
+ int actionMode;
+ int params[8];
+ int compressionType;
+ int fileType;
int angle;
int scale;
- int polygonId1;
- int polygonId2;
+ int polygon;
+ int polygon2;
int resDefImgW;
int resDefImgH;
int sourceImage;
- int params1;
- int params2;
- uint8 remapColor[256];
- uint8 remapIndex[256];
+ int propertyValue;
+ int propertyNumber;
+ uint8 remapTable[256];
+ uint8 remapList[256];
int remapNum;
int dstResNum;
uint16 fillColor;
FontProperties fontProperties;
EllipseProperties ellipseProperties;
- Common::Rect box2;
+ Common::Rect renderCoords;
int blendFlags;
int spriteId;
int spriteGroup;
@@ -118,38 +111,31 @@ struct WizParameters {
WizImage img;
void reset() {
- field_0 = 0;
+ dwSize = 0;
memset(filename, 0, sizeof(filename));
box.top = box.left = box.bottom = box.right = 0;
- processFlags = 0;
- processMode = 0;
- field_11C = 0;
- field_120 = 0;
- field_124 = 0;
- field_128 = 0;
- field_12C = 0;
- field_130 = 0;
- field_134 = 0;
- field_138 = 0;
- compType = 0;
- fileWriteMode = 0;
+ actionFlags = 0;
+ actionMode = 0;
+ memset(params, 0, sizeof(params));
+ compressionType = 0;
+ fileType = 0;
angle = 0;
scale = 0;
- polygonId1 = 0;
- polygonId2 = 0;
+ polygon = 0;
+ polygon2 = 0;
resDefImgW = 0;
resDefImgH = 0;
sourceImage = 0;
- params1 = 0;
- params2 = 0;
- memset(remapColor, 0, sizeof(remapColor));
- memset(remapIndex, 0, sizeof(remapIndex));
+ propertyValue = 0;
+ propertyNumber = 0;
+ memset(remapTable, 0, sizeof(remapTable));
+ memset(remapList, 0, sizeof(remapList));
remapNum = 0;
dstResNum = 0;
fillColor = 0;
memset(&fontProperties, 0, sizeof(FontProperties));
memset(&ellipseProperties, 0, sizeof(EllipseProperties));
- box2.left = box2.top = box2.bottom = box2.right = 0;
+ renderCoords.left = renderCoords.top = renderCoords.bottom = renderCoords.right = 0;
blendFlags = 0;
spriteId = 0;
spriteGroup = 0;
@@ -158,40 +144,66 @@ struct WizParameters {
}
};
-enum WizImageFlags {
- kWIFHasPalette = 0x1,
- kWIFRemapPalette = 0x2,
- kWIFPrint = 0x4,
- kWIFBlitToFrontVideoBuffer = 0x8,
- kWIFMarkBufferDirty = 0x10,
- kWIFBlitToMemBuffer = 0x20,
- kWIFIsPolygon = 0x40,
- kWIFZPlaneOn = 0x80,
- kWIFZPlaneOff = 0x100,
- kWIFUseShadow = 0x200,
- kWIFFlipX = 0x400,
- kWIFFlipY = 0x800
+enum WizRenderingFlags {
+ kWRFUsePalette = 0x00000001,
+ kWRFRemap = 0x00000002,
+ kWRFPrint = 0x00000004,
+ kWRFBackground = 0x00000008,
+ kWRFForeground = 0x00000010,
+ kWRFAlloc = 0x00000020,
+ kWIFIsPolygon = 0x00000040,
+ kWIFZPlaneOn = 0x00000080,
+ kWIFZPlaneOff = 0x00000100,
+ kWIFUseShadow = 0x00000200,
+ kWIFFlipX = 0x00000400,
+ kWIFFlipY = 0x00000800,
+ hWRFRotate90 = 0x00001000
};
-enum WizProcessFlags {
- kWPFSetPos = 0x1,
- kWPFShadow = 0x4,
- kWPFScaled = 0x8,
- kWPFRotate = 0x10,
- kWPFNewFlags = 0x20,
- kWPFRemapPalette = 0x40,
- kWPFClipBox = 0x200,
- kWPFNewState = 0x400,
- kWPFUseFile = 0x800,
- kWPFUseDefImgWidth = 0x2000,
- kWPFUseDefImgHeight = 0x4000,
- kWPFPaletteNum = 0x8000,
- kWPFDstResNum = 0x10000,
- kWPFFillColor = 0x20000,
- kWPFClipBox2 = 0x40000,
- kWPFMaskImg = 0x80000,
- kWPFParams = 0x100000,
- kWPFZBuffer = 0x200000
+enum WizActions {
+ kWAUnknown = 0,
+ kWADraw = 1,
+ kWACapture = 2,
+ kWALoad = 3,
+ kWASave = 4,
+ kWAGlobalState = 5,
+ kWAModify = 6,
+ kWAPolyCapture = 7,
+ kWANew = 8,
+ kWARenderRectangle = 9,
+ kWARenderLine = 10,
+ kWARenderPixel = 11,
+ kWARenderFloodFill = 12,
+ kWAFontStart = 13,
+ kWAFontEnd = 14,
+ kWAFontCreate = 15,
+ kWAFontRender = 16,
+ kWARenderEllipse = 17,
+};
+
+enum WizActionFlags {
+ kWAFSpot = 0x00000001,
+ kWAFPolygon = 0x00000002,
+ kWAFShadow = 0x00000004,
+ kWAFScaled = 0x00000008,
+ kWAFRotate = 0x00000010,
+ kWAFFlags = 0x00000020,
+ kWAFRemapList = 0x00000040,
+ kWAFFileType = 0x00000080,
+ kWAFCompressionType = 0x00000100,
+ kWAFRect = 0x00000200,
+ kWAFState = 0x00000400,
+ kWAFFilename = 0x00000800,
+ kWAFPolygon2 = 0x00001000,
+ kWAFWidth = 0x00002000,
+ kWAFHeight = 0x00004000,
+ kWAFPalette = 0x00008000,
+ kWAFDestImage = 0x00010000,
+ kWAFColor = 0x00020000,
+ kWAFRenderCoords = 0x00040000,
+ kWAFSourceImg = 0x00080000,
+ kWAFProperty = 0x00100000,
+ kWAFZBufferImage = 0x00200000
};
enum WizCompositeFlags {
Commit: f17fe7413cd48dc6f9f3ad2935690850a619ee1f
https://github.com/scummvm/scummvm/commit/f17fe7413cd48dc6f9f3ad2935690850a619ee1f
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Begin WIZ and graphics rewrite
Changed paths:
engines/scumm/actor.cpp
engines/scumm/he/animation_he.cpp
engines/scumm/he/floodfill_he.cpp
engines/scumm/he/intern_he.h
engines/scumm/he/script_v100he.cpp
engines/scumm/he/script_v72he.cpp
engines/scumm/he/script_v80he.cpp
engines/scumm/he/script_v90he.cpp
engines/scumm/he/sprite_he.cpp
engines/scumm/he/sprite_he.h
engines/scumm/he/wiz_he.cpp
engines/scumm/he/wiz_he.h
engines/scumm/scumm.cpp
diff --git a/engines/scumm/actor.cpp b/engines/scumm/actor.cpp
index b842de62e4a..eae457b908b 100644
--- a/engines/scumm/actor.cpp
+++ b/engines/scumm/actor.cpp
@@ -1621,7 +1621,7 @@ void Actor_v7::turnToDirection(int newdir) {
newdir = remapDirection((newdir + 360) % 360, false);
_moving &= ~MF_TURN;
- if (isInCurrentRoom() && !_ignoreBoxes) {
+ if (isInCurrentRoom() && !_ignoreBoxes) {
byte flags = _vm->getBoxFlags(_walkbox);
if ((flags & kBoxXFlip) || isInClass(kObjectClassXFlip))
newdir = 360 - newdir;
@@ -2353,31 +2353,31 @@ void ScummEngine_v6::processActors() {
#ifdef ENABLE_HE
void ScummEngine_v71he::processActors() {
- preProcessAuxQueue();
+ heFlushAuxEraseQueue();
if (!_skipProcessActors)
ScummEngine_v6::processActors();
_fullRedraw = false;
- postProcessAuxQueue();
+ heFlushAuxQueues();
}
void ScummEngine_v90he::processActors() {
- preProcessAuxQueue();
+ heFlushAuxEraseQueue();
- _sprite->setRedrawFlags(false);
- _sprite->processImages(true);
+ _sprite->checkForForcedRedraws(false);
+ _sprite->renderSprites(true);
if (!_skipProcessActors)
ScummEngine_v6::processActors();
_fullRedraw = false;
- postProcessAuxQueue();
+ heFlushAuxQueues();
- _sprite->setRedrawFlags(true);
- _sprite->processImages(false);
+ _sprite->checkForForcedRedraws(true);
+ _sprite->renderSprites(false);
}
#endif
@@ -3510,7 +3510,7 @@ bool ActorHE::isTalkConditionSet(int slot) const {
}
#ifdef ENABLE_HE
-void ScummEngine_v71he::preProcessAuxQueue() {
+void ScummEngine_v71he::heFlushAuxEraseQueue() {
if (!_skipProcessActors) {
for (int i = 0; i < _auxBlocksNum; ++i) {
AuxBlock *ab = &_auxBlocks[i];
@@ -3522,7 +3522,7 @@ void ScummEngine_v71he::preProcessAuxQueue() {
_auxBlocksNum = 0;
}
-void ScummEngine_v71he::postProcessAuxQueue() {
+void ScummEngine_v71he::heFlushAuxQueues() {
if (!_skipProcessActors) {
for (int i = 0; i < _auxEntriesNum; ++i) {
AuxEntry *ae = &_auxEntries[i];
diff --git a/engines/scumm/he/animation_he.cpp b/engines/scumm/he/animation_he.cpp
index 8ae3e016601..8b93921827d 100644
--- a/engines/scumm/he/animation_he.cpp
+++ b/engines/scumm/he/animation_he.cpp
@@ -77,8 +77,9 @@ int MoviePlayer::load(const Common::Path &filename, int flags, int image) {
debug(1, "Playing video %s", filename.toString().c_str());
+ int bitsPerPixel = (_vm->_game.features & GF_16BIT_COLOR) ? 16 : 8;
if (flags & vfImageSurface)
- _vm->_wiz->createWizEmptyImage(image, 0, 0, _video->getWidth(), _video->getHeight());
+ _vm->_wiz->dwCreateRawWiz(image, _video->getWidth(), _video->getHeight(), kCWFDefault, bitsPerPixel, 0, 0);
_flags = flags;
_wizResNum = image;
diff --git a/engines/scumm/he/floodfill_he.cpp b/engines/scumm/he/floodfill_he.cpp
index c8e560d50a2..a37b5501c65 100644
--- a/engines/scumm/he/floodfill_he.cpp
+++ b/engines/scumm/he/floodfill_he.cpp
@@ -230,15 +230,15 @@ void floodFill(FloodFillParameters *ffp, ScummEngine_v90he *vm) {
}
}
-void Wiz::fillWizFlood(const WizParameters *params) {
+void Wiz::processWizImageRenderFloodFillCmd(const WizImageCommand *params) {
if (params->actionFlags & kWAFRenderCoords) {
int px = params->renderCoords.left;
int py = params->renderCoords.top;
- uint8 *dataPtr = _vm->getResourceAddress(rtImage, params->img.resNum);
+ uint8 *dataPtr = _vm->getResourceAddress(rtImage, params->image);
if (dataPtr) {
int state = 0;
if (params->actionFlags & kWAFState) {
- state = params->img.state;
+ state = params->state;
}
uint8 *wizh = _vm->findWrappedBlock(MKTAG('W','I','Z','H'), dataPtr, state, 0);
assert(wizh);
@@ -255,7 +255,7 @@ void Wiz::fillWizFlood(const WizParameters *params) {
}
uint8 color = _vm->VAR(93);
if (params->actionFlags & kWAFColor) {
- color = params->fillColor;
+ color = params->colorValue;
}
if (imageRect.contains(px, py)) {
uint8 *wizd = _vm->findWrappedBlock(MKTAG('W','I','Z','D'), dataPtr, state, 0);
@@ -289,7 +289,7 @@ void Wiz::fillWizFlood(const WizParameters *params) {
}
}
}
- _vm->_res->setModified(rtImage, params->img.resNum);
+ _vm->_res->setModified(rtImage, params->image);
}
} // End of namespace Scumm
diff --git a/engines/scumm/he/intern_he.h b/engines/scumm/he/intern_he.h
index 4c4dedbae55..dfb4a5f4705 100644
--- a/engines/scumm/he/intern_he.h
+++ b/engines/scumm/he/intern_he.h
@@ -298,8 +298,8 @@ protected:
void redrawBGAreas() override;
void processActors() override;
- void preProcessAuxQueue();
- void postProcessAuxQueue();
+ void heFlushAuxEraseQueue();
+ void heFlushAuxQueues();
void clearDrawQueues() override;
@@ -383,7 +383,7 @@ protected:
int _stringLength = 1;
byte _stringBuffer[4096];
- WizParameters _wizParams;
+ WizImageCommand _wizImageCommand;
public:
ScummEngine_v72he(OSystem *syst, const DetectorResult &dr);
diff --git a/engines/scumm/he/script_v100he.cpp b/engines/scumm/he/script_v100he.cpp
index 36318728191..b894055ee1d 100644
--- a/engines/scumm/he/script_v100he.cpp
+++ b/engines/scumm/he/script_v100he.cpp
@@ -938,7 +938,7 @@ void ScummEngine_v100he::o100_floodFill() {
void ScummEngine_v100he::o100_setSpriteGroupInfo() {
byte string[260];
- int type, value1, value2, value3, value4;
+ int type, value1, value2, value3, value4, propertyCode;
byte subOp = fetchScriptByte();
@@ -949,79 +949,69 @@ void ScummEngine_v100he::o100_setSpriteGroupInfo() {
case SO_AT: // 6
value2 = pop();
value1 = pop();
- if (!_curSpriteGroupId)
- break;
+ if (_curSpriteGroupId)
+ _sprite->setGroupPosition(_curSpriteGroupId, value1, value2);
- _sprite->setGroupPosition(_curSpriteGroupId, value1, value2);
break;
case SO_CLIPPED: // 18
value4 = pop();
value3 = pop();
value2 = pop();
value1 = pop();
- if (!_curSpriteGroupId)
- break;
+ if (_curSpriteGroupId)
+ _sprite->setGroupBounds(_curSpriteGroupId, value1, value2, value3, value4);
- _sprite->setGroupBounds(_curSpriteGroupId, value1, value2, value3, value4);
break;
case SO_GROUP: // 38
type = pop();
switch (type) {
case SPRGRPOP_MOVE: // 1
- value2 = pop();
- value1 = pop();
- if (!_curSpriteGroupId)
- break;
+ value2 = pop(); // dy
+ value1 = pop(); // dx
+ if (_curSpriteGroupId)
+ _sprite->moveGroupMembers(_curSpriteGroupId, value1, value2);
- _sprite->moveGroupMembers(_curSpriteGroupId, value1, value2);
break;
case SPRGRPOP_ORDER: // 2
- value1 = pop();
- if (!_curSpriteGroupId)
- break;
+ value1 = pop(); // order
+ if (_curSpriteGroupId)
+ _sprite->setGroupMembersPriority(_curSpriteGroupId, value1);
- _sprite->setGroupMembersPriority(_curSpriteGroupId, value1);
break;
case SPRGRPOP_NEW_GROUP: // 3
- value1 = pop();
- if (!_curSpriteGroupId)
- break;
+ value1 = pop(); // newGroup
+ if (_curSpriteGroupId)
+ _sprite->setGroupMembersGroup(_curSpriteGroupId, value1);
- _sprite->setGroupMembersGroup(_curSpriteGroupId, value1);
break;
case SPRGRPOP_UPDATE_TYPE: // 4
- value1 = pop();
- if (!_curSpriteGroupId)
- break;
+ value1 = pop(); // updateType
+ if (_curSpriteGroupId)
+ _sprite->setGroupMembersUpdateType(_curSpriteGroupId, value1);
- _sprite->setGroupMembersUpdateType(_curSpriteGroupId, value1);
break;
case SPRGRPOP_NEW: // 5
- if (!_curSpriteGroupId)
- break;
+ if (_curSpriteGroupId)
+ _sprite->setGroupMembersResetSprite(_curSpriteGroupId);
- _sprite->setGroupMembersResetSprite(_curSpriteGroupId);
break;
case SPRGRPOP_ANIMATION_SPEED: // 6
- value1 = pop();
- if (!_curSpriteGroupId)
- break;
+ value1 = pop(); // animationSpeed
+ if (_curSpriteGroupId)
+ _sprite->setGroupMembersAnimationSpeed(_curSpriteGroupId, value1);
- _sprite->setGroupMembersAnimationSpeed(_curSpriteGroupId, value1);
break;
case SPRGRPOP_ANIMATION_TYPE: // 7
- value1 = pop();
- if (!_curSpriteGroupId)
- break;
+ value1 = pop(); // animationType
+ if (_curSpriteGroupId)
+ _sprite->setGroupMembersAutoAnimFlag(_curSpriteGroupId, value1);
- _sprite->setGroupMembersAutoAnimFlag(_curSpriteGroupId, value1);
break;
case SPRGRPOP_SHADOW: // 8
- value1 = pop();
- if (!_curSpriteGroupId)
- break;
+ value1 = pop(); // shadowNum
+ if (_curSpriteGroupId)
+ _sprite->setGroupMembersShadow(_curSpriteGroupId, value1);
- _sprite->setGroupMembersShadow(_curSpriteGroupId, value1);
break;
default:
error("o100_setSpriteGroupInfo subOp 38: Unknown case %d", subOp);
@@ -1029,27 +1019,24 @@ void ScummEngine_v100he::o100_setSpriteGroupInfo() {
break;
case SO_IMAGE: // 40
value1 = pop();
- if (!_curSpriteGroupId)
- break;
+ if (_curSpriteGroupId)
+ _sprite->setGroupImage(_curSpriteGroupId, value1);
- _sprite->setGroupImage(_curSpriteGroupId, value1);
break;
case SO_MOVE: // 49
value2 = pop();
value1 = pop();
- if (!_curSpriteGroupId)
- break;
+ if (_curSpriteGroupId)
+ _sprite->moveGroup(_curSpriteGroupId, value1, value2);
- _sprite->moveGroup(_curSpriteGroupId, value1, value2);
break;
case SO_NAME: // 52
copyScriptString(string, sizeof(string));
break;
case SO_NEW: // 53
- if (!_curSpriteGroupId)
- break;
+ if (_curSpriteGroupId)
+ _sprite->resetGroup(_curSpriteGroupId);
- _sprite->resetGroup(_curSpriteGroupId);
break;
case SO_NEW_GENERAL_PROPERTY: // 54
// dummy case
@@ -1058,39 +1045,37 @@ void ScummEngine_v100he::o100_setSpriteGroupInfo() {
break;
case SO_PRIORITY: // 59
value1 = pop();
- if (!_curSpriteGroupId)
- break;
+ if (_curSpriteGroupId)
+ _sprite->setGroupPriority(_curSpriteGroupId, value1);
- _sprite->setGroupPriority(_curSpriteGroupId, value1);
break;
case SO_PROPERTY: // 60
- type = pop();
+ propertyCode = pop();
value1 = pop();
- if (!_curSpriteGroupId)
- break;
-
- switch (type) {
- case SPRGRPPROP_XMUL: // 0
- _sprite->setGroupXMul(_curSpriteGroupId, value1);
- break;
- case SPRGRPPROP_XDIV: // 1
- _sprite->setGroupXDiv(_curSpriteGroupId, value1);
- break;
- case SPRGRPPROP_YMUL: // 2
- _sprite->setGroupYMul(_curSpriteGroupId, value1);
- break;
- case SPRGRPPROP_YDIV: // 3
- _sprite->setGroupYDiv(_curSpriteGroupId, value1);
- break;
- default:
- error("o100_setSpriteGroupInfo subOp 60: Unknown case %d", subOp);
+ if (_curSpriteGroupId) {
+ switch (propertyCode) {
+ case SPRGRPPROP_XMUL: // 0
+ _sprite->setGroupXMul(_curSpriteGroupId, value1);
+ break;
+ case SPRGRPPROP_XDIV: // 1
+ _sprite->setGroupXDiv(_curSpriteGroupId, value1);
+ break;
+ case SPRGRPPROP_YMUL: // 2
+ _sprite->setGroupYMul(_curSpriteGroupId, value1);
+ break;
+ case SPRGRPPROP_YDIV: // 3
+ _sprite->setGroupYDiv(_curSpriteGroupId, value1);
+ break;
+ default:
+ error("o100_setSpriteGroupInfo subOp 60: Unknown case %d", subOp);
+ }
}
+
break;
case SO_NEVER_ZCLIP: // 89
- if (!_curSpriteGroupId)
- break;
+ if (_curSpriteGroupId)
+ _sprite->resetGroupBounds(_curSpriteGroupId);
- _sprite->resetGroupBounds(_curSpriteGroupId);
break;
default:
error("o100_setSpriteGroupInfo: Unknown case %d", subOp);
@@ -1202,218 +1187,227 @@ void ScummEngine_v100he::o100_wizImageOps() {
switch (subOp) {
case SO_INIT: // 0
- _wizParams.img.resNum = pop();
- _wizParams.actionMode = kWAUnknown;
- _wizParams.actionFlags = 0;
- _wizParams.remapNum = 0;
- _wizParams.img.flags = 0;
- _wizParams.propertyValue = 0;
- _wizParams.propertyNumber = 0;
- _wizParams.spriteId = 0;
- _wizParams.spriteGroup = 0;
+ _wizImageCommand.image = pop();
+ _wizImageCommand.actionMode = kWAUnknown;
+ _wizImageCommand.actionFlags = 0;
+ _wizImageCommand.remapCount = 0;
+ _wizImageCommand.flags = 0;
+ _wizImageCommand.propertyValue = 0;
+ _wizImageCommand.propertyNumber = 0;
+ _wizImageCommand.extendedRenderInfo.sprite = 0;
+ _wizImageCommand.extendedRenderInfo.group = 0;
break;
case SO_ANGLE: // 2
- _wizParams.actionFlags |= kWAFRotate;
- _wizParams.angle = pop();
+ _wizImageCommand.actionFlags |= kWAFAngle;
+ _wizImageCommand.angle = pop();
break;
case SO_AT: // 6
case SO_CURSOR_HOTSPOT: // 132
- _wizParams.actionFlags |= kWAFSpot;
- _wizParams.img.y1 = pop();
- _wizParams.img.x1 = pop();
+ _wizImageCommand.actionFlags |= kWAFSpot;
+ _wizImageCommand.yPos = pop();
+ _wizImageCommand.xPos = pop();
break;
case SO_AT_IMAGE: // 7
- _wizParams.actionFlags |= kWAFSourceImg;
- _wizParams.sourceImage = pop();
+ _wizImageCommand.actionFlags |= kWAFSourceImg;
+ _wizImageCommand.sourceImage = pop();
break;
case SO_CAPTURE: // 11
- _wizParams.actionFlags |= kWAFRect | kWAFCompressionType;
- _wizParams.actionMode = kWACapture;
- _wizParams.box.bottom = pop();
- _wizParams.box.right = pop();
- _wizParams.box.top = pop();
- _wizParams.box.left = pop();
- _wizParams.compressionType = pop();
- adjustRect(_wizParams.box);
+ _wizImageCommand.actionFlags |= kWAFRect | kWAFCompressionType;
+ _wizImageCommand.actionMode = kWACapture;
+ _wizImageCommand.box.bottom = pop();
+ _wizImageCommand.box.right = pop();
+ _wizImageCommand.box.top = pop();
+ _wizImageCommand.box.left = pop();
+ _wizImageCommand.compressionType = pop();
+ adjustRect(_wizImageCommand.box);
break;
case SO_CLIPPED: // 18
- _wizParams.actionFlags |= kWAFRect;
- _wizParams.box.bottom = pop();
- _wizParams.box.right = pop();
- _wizParams.box.top = pop();
- _wizParams.box.left = pop();
- adjustRect(_wizParams.box);
+ _wizImageCommand.actionFlags |= kWAFRect;
+ _wizImageCommand.box.bottom = pop();
+ _wizImageCommand.box.right = pop();
+ _wizImageCommand.box.top = pop();
+ _wizImageCommand.box.left = pop();
+ adjustRect(_wizImageCommand.box);
break;
case SO_COLOR_LIST: // 21
b = pop();
a = pop();
- _wizParams.actionFlags |= kWAFRemapList;
- _wizParams.actionMode = kWAModify;
- if (_wizParams.remapNum == 0) {
- memset(_wizParams.remapList, 0, sizeof(_wizParams.remapList));
+ _wizImageCommand.actionFlags |= kWAFRemapList;
+ _wizImageCommand.actionMode = kWAModify;
+ if (_wizImageCommand.remapCount == 0) {
+ memset(_wizImageCommand.remapList, 0, sizeof(_wizImageCommand.remapList));
} else {
- assert(_wizParams.remapNum < ARRAYSIZE(_wizParams.remapList));
- _wizParams.remapList[_wizParams.remapNum] = a;
- _wizParams.remapTable[a] = b;
- ++_wizParams.remapNum;
+ assert(_wizImageCommand.remapCount < ARRAYSIZE(_wizImageCommand.remapList));
+ _wizImageCommand.remapList[_wizImageCommand.remapCount] = a;
+ _wizImageCommand.remapTable[a] = b;
+ ++_wizImageCommand.remapCount;
}
break;
case SO_DRAW: // 29
- _wizParams.actionMode = kWADraw;
+ _wizImageCommand.actionMode = kWADraw;
break;
case SO_GENERAL_CLIP_RECT: // 36
- _wizParams.box.bottom = pop();
- _wizParams.box.right = pop();
- _wizParams.box.top = pop();
- _wizParams.box.left = pop();
+ _wizImageCommand.box.bottom = pop();
+ _wizImageCommand.box.right = pop();
+ _wizImageCommand.box.top = pop();
+ _wizImageCommand.box.left = pop();
break;
case SO_GENERAL_CLIP_STATE: // 37
// Dummy case
pop();
break;
case SO_HEIGHT: // 39
- _wizParams.actionFlags |= kWAFHeight;
- _wizParams.resDefImgH = pop();
+ _wizImageCommand.actionFlags |= kWAFHeight;
+ _wizImageCommand.height = pop();
break;
case SO_LOAD: // 47
- _wizParams.actionFlags |= kWAFFilename;
- _wizParams.actionMode = kWALoad;
- copyScriptString(_wizParams.filename, sizeof(_wizParams.filename));
+ _wizImageCommand.actionFlags |= kWAFFilename;
+ _wizImageCommand.actionMode = kWALoad;
+ copyScriptString(_wizImageCommand.filename, sizeof(_wizImageCommand.filename));
break;
case SO_NEW: // 53
- _wizParams.actionMode = kWANew;
+ _wizImageCommand.actionMode = kWANew;
break;
case SO_NEW_GENERAL_PROPERTY: // 54
- _wizParams.actionFlags |= kWAFProperty;
- _wizParams.propertyValue = pop();
- _wizParams.propertyNumber = pop();
+ _wizImageCommand.actionFlags |= kWAFProperty;
+ _wizImageCommand.propertyValue = pop();
+ _wizImageCommand.propertyNumber = pop();
break;
case SO_NOW: // 55
- _wizParams.img.flags = pop();
- _wizParams.img.state = pop();
- _wizParams.img.y1 = pop();
- _wizParams.img.x1 = pop();
- _wizParams.spriteId = 0;
- _wizParams.spriteGroup = 0;
- _wizParams.img.resNum = pop();
- _wiz->displayWizImage(&_wizParams.img);
+ _wizImageCommand.flags = pop();
+ _wizImageCommand.state = pop();
+ _wizImageCommand.yPos = pop();
+ _wizImageCommand.xPos = pop();
+ _wizImageCommand.image = pop();
+
+ _wizImageCommand.extendedRenderInfo.sprite = 0;
+ _wizImageCommand.extendedRenderInfo.group = 0;
+
+ _wiz->simpleDrawAWiz(
+ _wizImageCommand.image,
+ _wizImageCommand.state,
+ _wizImageCommand.xPos,
+ _wizImageCommand.yPos,
+ _wizImageCommand.flags
+ );
+
break;
case SO_PALETTE: // 57
- _wizParams.actionFlags |= kWAFPalette;
- _wizParams.img.palette = pop();
+ _wizImageCommand.actionFlags |= kWAFPalette;
+ _wizImageCommand.palette = pop();
break;
case SO_POLY_TO_POLY: // 58
- _wizParams.actionFlags |= kWAFPolygon2 | kWAFCompressionType | kWAFPolygon;
- _wizParams.actionMode = kWAPolyCapture;
- _wizParams.polygon2 = pop();
- _wizParams.polygon = pop();
- _wizParams.compressionType = pop();
+ _wizImageCommand.actionFlags |= kWAFPolygon2 | kWAFCompressionType | kWAFPolygon;
+ _wizImageCommand.actionMode = kWAPolyCapture;
+ _wizImageCommand.polygon2 = pop();
+ _wizImageCommand.polygon = pop();
+ _wizImageCommand.compressionType = pop();
break;
case SO_SAVE: // 64
- _wizParams.actionFlags |= kWAFFilename;
- _wizParams.actionMode = kWASave;
- copyScriptString(_wizParams.filename, sizeof(_wizParams.filename));
- _wizParams.fileType = pop();
+ _wizImageCommand.actionFlags |= kWAFFilename;
+ _wizImageCommand.actionMode = kWASave;
+ copyScriptString(_wizImageCommand.filename, sizeof(_wizImageCommand.filename));
+ _wizImageCommand.fileType = pop();
break;
case SO_SCALE: // 65
- _wizParams.actionFlags |= kWAFScaled;
- _wizParams.scale = pop();
+ _wizImageCommand.actionFlags |= kWAFScale;
+ _wizImageCommand.scale = pop();
break;
case SO_SET_FLAGS: // 67
- _wizParams.actionFlags |= kWAFFlags;
- _wizParams.img.flags |= pop();
+ _wizImageCommand.actionFlags |= kWAFFlags;
+ _wizImageCommand.flags |= pop();
break;
case SO_SET_POLYGON: // 68
- _wizParams.actionFlags |= kWAFFlags | kWAFSpot | kWAFPolygon;
- _wizParams.img.flags |= kWIFIsPolygon;
- _wizParams.polygon = _wizParams.img.y1 = _wizParams.img.x1 = pop();
+ _wizImageCommand.actionFlags |= kWAFFlags | kWAFSpot | kWAFPolygon;
+ _wizImageCommand.flags |= kWRFIsPolygon;
+ _wizImageCommand.polygon = _wizImageCommand.yPos = _wizImageCommand.xPos = pop();
break;
case SO_SHADOW: // 70
- _wizParams.actionFlags |= kWAFShadow;
- _wizParams.img.shadow = pop();
+ _wizImageCommand.actionFlags |= kWAFShadow;
+ _wizImageCommand.shadow = pop();
break;
case SO_STATE: // 73
- _wizParams.actionFlags |= kWAFState;
- _wizParams.img.state = pop();
+ _wizImageCommand.actionFlags |= kWAFState;
+ _wizImageCommand.state = pop();
break;
case SO_WIDTH: // 84
- _wizParams.actionFlags |= kWAFWidth;
- _wizParams.resDefImgW = pop();
+ _wizImageCommand.actionFlags |= kWAFWidth;
+ _wizImageCommand.width = pop();
break;
case SO_END: // 92
- if (_wizParams.img.resNum)
- _wiz->processWizImage(&_wizParams);
+ if (_wizImageCommand.image)
+ _wiz->processWizImageCmd(&_wizImageCommand);
break;
case SO_FONT_CREATE: // 128
- _wizParams.actionMode = kWAFontCreate;
- _wizParams.fontProperties.bgColor = pop();
- _wizParams.fontProperties.fgColor = pop();
- _wizParams.fontProperties.size = pop();
- _wizParams.fontProperties.style = pop();
- copyScriptString(_wizParams.fontProperties.fontName, sizeof(_wizParams.fontProperties.fontName));
+ _wizImageCommand.actionMode = kWAFontCreate;
+ _wizImageCommand.fontProperties.bgColor = pop();
+ _wizImageCommand.fontProperties.fgColor = pop();
+ _wizImageCommand.fontProperties.size = pop();
+ _wizImageCommand.fontProperties.style = pop();
+ copyScriptString(_wizImageCommand.fontProperties.fontName, sizeof(_wizImageCommand.fontProperties.fontName));
break;
case SO_FONT_END: // 129
- _wizParams.actionMode = kWAFontEnd;
+ _wizImageCommand.actionMode = kWAFontEnd;
break;
case SO_FONT_RENDER: // 130
- _wizParams.actionMode = kWAFontRender;
- _wizParams.fontProperties.yPos = pop();
- _wizParams.fontProperties.xPos = pop();
- copyScriptString(_wizParams.fontProperties.string, sizeof(_wizParams.fontProperties.string));
+ _wizImageCommand.actionMode = kWAFontRender;
+ _wizImageCommand.fontProperties.yPos = pop();
+ _wizImageCommand.fontProperties.xPos = pop();
+ copyScriptString(_wizImageCommand.fontProperties.string, sizeof(_wizImageCommand.fontProperties.string));
break;
case SO_FONT_START: // 131
- _wizParams.actionMode = kWAFontStart;
+ _wizImageCommand.actionMode = kWAFontStart;
break;
case SO_RENDER_ELLIPSE: // 133
- _wizParams.actionMode = kWARenderEllipse;
- _wizParams.ellipseProperties.color = pop();
- _wizParams.ellipseProperties.lod = pop();
- _wizParams.ellipseProperties.ky = pop();
- _wizParams.ellipseProperties.kx = pop();
- _wizParams.ellipseProperties.qy = pop();
- _wizParams.ellipseProperties.qx = pop();
- _wizParams.ellipseProperties.py = pop();
- _wizParams.ellipseProperties.px = pop();
+ _wizImageCommand.actionMode = kWARenderEllipse;
+ _wizImageCommand.ellipseProperties.color = pop();
+ _wizImageCommand.ellipseProperties.lod = pop();
+ _wizImageCommand.ellipseProperties.ky = pop();
+ _wizImageCommand.ellipseProperties.kx = pop();
+ _wizImageCommand.ellipseProperties.qy = pop();
+ _wizImageCommand.ellipseProperties.qx = pop();
+ _wizImageCommand.ellipseProperties.py = pop();
+ _wizImageCommand.ellipseProperties.px = pop();
break;
case SO_RENDER_FLOOD_FILL: // 134
- _wizParams.actionFlags |= kWAFColor | kWAFRenderCoords;
- _wizParams.actionMode = kWARenderFloodFill;
- _wizParams.fillColor = pop();
- _wizParams.renderCoords.top = _wizParams.renderCoords.bottom = pop();
- _wizParams.renderCoords.left = _wizParams.renderCoords.right = pop();
- adjustRect(_wizParams.renderCoords);
+ _wizImageCommand.actionFlags |= kWAFColor | kWAFRenderCoords;
+ _wizImageCommand.actionMode = kWARenderFloodFill;
+ _wizImageCommand.colorValue = pop();
+ _wizImageCommand.renderCoords.top = _wizImageCommand.renderCoords.bottom = pop();
+ _wizImageCommand.renderCoords.left = _wizImageCommand.renderCoords.right = pop();
+ adjustRect(_wizImageCommand.renderCoords);
break;
case SO_RENDER_INTO_IMAGE: // 135
- _wizParams.actionFlags |= kWAFDestImage;
- _wizParams.dstResNum = pop();
+ _wizImageCommand.actionFlags |= kWAFDestImage;
+ _wizImageCommand.destImageNumber = pop();
break;
case SO_RENDER_LINE: // 136
- _wizParams.actionFlags |= kWAFColor | kWAFRenderCoords;
- _wizParams.actionMode = 10;
- _wizParams.fillColor = pop();
- _wizParams.renderCoords.bottom = pop();
- _wizParams.renderCoords.right = pop();
- _wizParams.renderCoords.top = pop();
- _wizParams.renderCoords.left = pop();
- adjustRect(_wizParams.renderCoords);
+ _wizImageCommand.actionFlags |= kWAFColor | kWAFRenderCoords;
+ _wizImageCommand.actionMode = kWARenderLine;
+ _wizImageCommand.colorValue = pop();
+ _wizImageCommand.renderCoords.bottom = pop();
+ _wizImageCommand.renderCoords.right = pop();
+ _wizImageCommand.renderCoords.top = pop();
+ _wizImageCommand.renderCoords.left = pop();
+ adjustRect(_wizImageCommand.renderCoords);
break;
case SO_RENDER_PIXEL: // 137
- _wizParams.actionFlags |= kWAFColor | kWAFRenderCoords;
- _wizParams.actionMode = kWARenderPixel;
- _wizParams.fillColor = pop();
- _wizParams.renderCoords.top = _wizParams.renderCoords.bottom = pop();
- _wizParams.renderCoords.left = _wizParams.renderCoords.right = pop();
- adjustRect(_wizParams.renderCoords);
+ _wizImageCommand.actionFlags |= kWAFColor | kWAFRenderCoords;
+ _wizImageCommand.actionMode = kWARenderPixel;
+ _wizImageCommand.colorValue = pop();
+ _wizImageCommand.renderCoords.top = _wizImageCommand.renderCoords.bottom = pop();
+ _wizImageCommand.renderCoords.left = _wizImageCommand.renderCoords.right = pop();
+ adjustRect(_wizImageCommand.renderCoords);
break;
case SO_RENDER_RECTANGLE: // 138
- _wizParams.actionFlags |= kWAFColor | kWAFRenderCoords;
- _wizParams.actionMode = kWARenderRectangle;
- _wizParams.fillColor = pop();
- _wizParams.renderCoords.bottom = pop();
- _wizParams.renderCoords.right = pop();
- _wizParams.renderCoords.top = pop();
- _wizParams.renderCoords.left = pop();
- adjustRect(_wizParams.renderCoords);
+ _wizImageCommand.actionFlags |= kWAFColor | kWAFRenderCoords;
+ _wizImageCommand.actionMode = kWARenderRectangle;
+ _wizImageCommand.colorValue = pop();
+ _wizImageCommand.renderCoords.bottom = pop();
+ _wizImageCommand.renderCoords.right = pop();
+ _wizImageCommand.renderCoords.top = pop();
+ _wizImageCommand.renderCoords.left = pop();
+ adjustRect(_wizImageCommand.renderCoords);
break;
default:
error("o100_wizImageOps: Unknown case %d", subOp);
diff --git a/engines/scumm/he/script_v72he.cpp b/engines/scumm/he/script_v72he.cpp
index 843aa02aa0b..690a14a8124 100644
--- a/engines/scumm/he/script_v72he.cpp
+++ b/engines/scumm/he/script_v72he.cpp
@@ -533,7 +533,9 @@ void ScummEngine_v72he::o72_captureWizImage() {
grab.right = pop() + 1;
grab.top = pop();
grab.left = pop();
- _wiz->captureWizImage(pop(), grab, false, true);
+ int image = pop();
+
+ _wiz->takeAWiz(image, grab, false, true);
}
void ScummEngine_v72he::o72_getTimer() {
@@ -636,12 +638,13 @@ void ScummEngine_v72he::o72_drawObject() {
}
void ScummEngine_v72he::o72_printWizImage() {
- WizImage wi;
- wi.resNum = pop();
- wi.x1 = wi.y1 = 0;
+ WizBufferElement wi;
+ wi.image = pop();
+ wi.x = wi.y = 0;
wi.state = 0;
wi.flags = kWRFPrint;
- _wiz->displayWizImage(&wi);
+
+ _wiz->simpleDrawAWiz(wi.image, wi.state, wi.x, wi.y, wi.flags);
}
void ScummEngine_v72he::o72_getArrayDimSize() {
@@ -1478,13 +1481,13 @@ void ScummEngine_v72he::o72_kernelGetFunctions() {
}
void ScummEngine_v72he::o72_drawWizImage() {
- WizImage wi;
+ WizBufferElement wi;
wi.flags = pop();
- wi.y1 = pop();
- wi.x1 = pop();
- wi.resNum = pop();
+ wi.y = pop();
+ wi.x = pop();
+ wi.image = pop();
wi.state = 0;
- _wiz->displayWizImage(&wi);
+ _wiz->simpleDrawAWiz(wi.image, wi.state, wi.x, wi.y, wi.flags);
}
void ScummEngine_v72he::debugInput(byte* string) {
diff --git a/engines/scumm/he/script_v80he.cpp b/engines/scumm/he/script_v80he.cpp
index b1b376e8a36..a6cf23e13ae 100644
--- a/engines/scumm/he/script_v80he.cpp
+++ b/engines/scumm/he/script_v80he.cpp
@@ -327,12 +327,12 @@ void ScummEngine_v80he::o80_setState() {
}
void ScummEngine_v80he::o80_drawWizPolygon() {
- WizImage wi;
- wi.x1 = wi.y1 = pop();
- wi.resNum = pop();
+ WizBufferElement wi;
+ wi.x = wi.y = pop();
+ wi.image = pop();
wi.state = 0;
- wi.flags = kWIFIsPolygon;
- _wiz->displayWizImage(&wi);
+ wi.flags = kWRFIsPolygon;
+ _wiz->simpleDrawAWiz(wi.image, wi.state, wi.x, wi.y, wi.flags);
}
/**
@@ -371,13 +371,13 @@ void ScummEngine_v80he::drawLine(int x1, int y1, int x, int y, int step, int typ
ActorHE *a = (ActorHE *)derefActor(id, "drawLine");
a->drawActorToBackBuf(x, y);
} else if (type == 3) {
- WizImage wi;
+ WizBufferElement wi;
wi.flags = 0;
- wi.y1 = y;
- wi.x1 = x;
- wi.resNum = id;
+ wi.y = y;
+ wi.x = x;
+ wi.image = id;
wi.state = 0;
- _wiz->displayWizImage(&wi);
+ _wiz->simpleDrawAWiz(wi.image, wi.state, wi.x, wi.y, wi.flags);
} else {
drawPixel(x, y, id);
}
@@ -422,13 +422,13 @@ void ScummEngine_v80he::drawLine(int x1, int y1, int x, int y, int step, int typ
ActorHE *a = (ActorHE *)derefActor(id, "drawLine");
a->drawActorToBackBuf(x, y);
} else if (type == 3) {
- WizImage wi;
+ WizBufferElement wi;
wi.flags = 0;
- wi.y1 = y;
- wi.x1 = x;
- wi.resNum = id;
+ wi.y = y;
+ wi.x = x;
+ wi.image = id;
wi.state = 0;
- _wiz->displayWizImage(&wi);
+ _wiz->simpleDrawAWiz(wi.image, wi.state, wi.x, wi.y, wi.flags);
} else {
drawPixel(x, y, id);
}
diff --git a/engines/scumm/he/script_v90he.cpp b/engines/scumm/he/script_v90he.cpp
index b38418ff597..008ed46e9c6 100644
--- a/engines/scumm/he/script_v90he.cpp
+++ b/engines/scumm/he/script_v90he.cpp
@@ -112,217 +112,225 @@ void ScummEngine_v90he::o90_wizImageOps() {
switch (subOp) {
case SO_WIDTH: // 32, HE99+
- _wizParams.actionFlags |= kWAFWidth;
- _wizParams.resDefImgW = pop();
+ _wizImageCommand.actionFlags |= kWAFWidth;
+ _wizImageCommand.width = pop();
break;
case SO_HEIGHT: // 33, HE99+
- _wizParams.actionFlags |= kWAFHeight;
- _wizParams.resDefImgH = pop();
+ _wizImageCommand.actionFlags |= kWAFHeight;
+ _wizImageCommand.height = pop();
break;
case SO_GENERAL_CLIP_STATE: // 46
// Dummy case
pop();
break;
case SO_GENERAL_CLIP_RECT: // 47
- _wizParams.box.bottom = pop();
- _wizParams.box.right = pop();
- _wizParams.box.top = pop();
- _wizParams.box.left = pop();
+ _wizImageCommand.box.bottom = pop();
+ _wizImageCommand.box.right = pop();
+ _wizImageCommand.box.top = pop();
+ _wizImageCommand.box.left = pop();
break;
case SO_DRAW: // 48
- _wizParams.actionMode = kWADraw;
+ _wizImageCommand.actionMode = kWADraw;
break;
case SO_LOAD: // 49
- _wizParams.actionFlags |= kWAFFilename;
- _wizParams.actionMode = kWALoad;
- copyScriptString(_wizParams.filename, sizeof(_wizParams.filename));
+ _wizImageCommand.actionFlags |= kWAFFilename;
+ _wizImageCommand.actionMode = kWALoad;
+ copyScriptString(_wizImageCommand.filename, sizeof(_wizImageCommand.filename));
break;
case SO_SAVE: // 50
- _wizParams.actionFlags |= kWAFFilename;
- _wizParams.actionMode = kWASave;
- copyScriptString(_wizParams.filename, sizeof(_wizParams.filename));
- _wizParams.fileType = pop();
+ _wizImageCommand.actionFlags |= kWAFFilename;
+ _wizImageCommand.actionMode = kWASave;
+ copyScriptString(_wizImageCommand.filename, sizeof(_wizImageCommand.filename));
+ _wizImageCommand.fileType = pop();
break;
case SO_CAPTURE: // 51
- _wizParams.actionFlags |= kWAFRect | kWAFCompressionType;
- _wizParams.actionMode = kWACapture;
- _wizParams.box.bottom = pop();
- _wizParams.box.right = pop();
- _wizParams.box.top = pop();
- _wizParams.box.left = pop();
- _wizParams.compressionType = pop();
- adjustRect(_wizParams.box);
+ _wizImageCommand.actionFlags |= kWAFRect | kWAFCompressionType;
+ _wizImageCommand.actionMode = kWACapture;
+ _wizImageCommand.box.bottom = pop();
+ _wizImageCommand.box.right = pop();
+ _wizImageCommand.box.top = pop();
+ _wizImageCommand.box.left = pop();
+ _wizImageCommand.compressionType = pop();
+ adjustRect(_wizImageCommand.box);
break;
case SO_STATE: // 52
- _wizParams.actionFlags |= kWAFState;
- _wizParams.img.state = pop();
+ _wizImageCommand.actionFlags |= kWAFState;
+ _wizImageCommand.state = pop();
break;
case SO_ANGLE: // 53
- _wizParams.actionFlags |= kWAFRotate;
- _wizParams.angle = pop();
+ _wizImageCommand.actionFlags |= kWAFAngle;
+ _wizImageCommand.angle = pop();
break;
case SO_SET_FLAGS: // 54
- _wizParams.actionFlags |= kWAFFlags;
- _wizParams.img.flags |= pop();
+ _wizImageCommand.actionFlags |= kWAFFlags;
+ _wizImageCommand.flags |= pop();
break;
case SO_NOW: // 56
- _wizParams.img.flags = pop();
- _wizParams.img.state = pop();
- _wizParams.img.y1 = pop();
- _wizParams.img.x1 = pop();
- _wizParams.img.resNum = pop();
- _wiz->displayWizImage(&_wizParams.img);
+ _wizImageCommand.flags = pop();
+ _wizImageCommand.state = pop();
+ _wizImageCommand.yPos = pop();
+ _wizImageCommand.xPos = pop();
+ _wizImageCommand.image = pop();
+
+ _wiz->simpleDrawAWiz(
+ _wizImageCommand.image,
+ _wizImageCommand.state,
+ _wizImageCommand.xPos,
+ _wizImageCommand.yPos,
+ _wizImageCommand.flags
+ );
+
break;
case SO_INIT: // 57
- _wizParams.img.resNum = pop();
- _wizParams.actionMode = kWAUnknown;
- _wizParams.actionFlags = 0;
- _wizParams.remapNum = 0;
- _wizParams.img.flags = 0;
- _wizParams.propertyValue = 0;
- _wizParams.propertyNumber = 0;
- _wizParams.spriteId = 0;
- _wizParams.spriteGroup = 0;
+ _wizImageCommand.image = pop();
+ _wizImageCommand.actionMode = kWAUnknown;
+ _wizImageCommand.actionFlags = 0;
+ _wizImageCommand.remapCount = 0;
+ _wizImageCommand.flags = 0;
+ _wizImageCommand.propertyValue = 0;
+ _wizImageCommand.propertyNumber = 0;
+ _wizImageCommand.extendedRenderInfo.sprite = 0;
+ _wizImageCommand.extendedRenderInfo.group = 0;
break;
case SO_AT_IMAGE: // 62, HE99+
- _wizParams.actionFlags |= kWAFSourceImg;
- _wizParams.sourceImage = pop();
+ _wizImageCommand.actionFlags |= kWAFSourceImg;
+ _wizImageCommand.sourceImage = pop();
break;
case SO_AT: // 65
case SO_CURSOR_HOTSPOT: // 154
- _wizParams.actionFlags |= kWAFSpot;
- _wizParams.img.y1 = pop();
- _wizParams.img.x1 = pop();
+ _wizImageCommand.actionFlags |= kWAFSpot;
+ _wizImageCommand.yPos = pop();
+ _wizImageCommand.xPos = pop();
break;
case SO_COLOR: // 66
// TODO: I haven't found SO_COLOR in any executable, recheck later...
case SO_COLOR_LIST: // 249, HE98+
b = pop();
a = pop();
- _wizParams.actionFlags |= kWAFRemapList;
- _wizParams.actionMode = kWAModify;
- if (_wizParams.remapNum == 0) {
- memset(_wizParams.remapList, 0, sizeof(_wizParams.remapList));
+ _wizImageCommand.actionFlags |= kWAFRemapList;
+ _wizImageCommand.actionMode = kWAModify;
+ if (_wizImageCommand.remapCount == 0) {
+ memset(_wizImageCommand.remapList, 0, sizeof(_wizImageCommand.remapList));
}
- assert(_wizParams.remapNum < ARRAYSIZE(_wizParams.remapList));
- _wizParams.remapList[_wizParams.remapNum] = a;
- _wizParams.remapTable[a] = b;
- _wizParams.remapNum++;
+ assert(_wizImageCommand.remapCount < ARRAYSIZE(_wizImageCommand.remapList));
+ _wizImageCommand.remapList[_wizImageCommand.remapCount] = a;
+ _wizImageCommand.remapTable[a] = b;
+ _wizImageCommand.remapCount++;
break;
case SO_CLIPPED: // 67
- _wizParams.actionFlags |= kWAFRect;
- _wizParams.box.bottom = pop();
- _wizParams.box.right = pop();
- _wizParams.box.top = pop();
- _wizParams.box.left = pop();
- adjustRect(_wizParams.box);
+ _wizImageCommand.actionFlags |= kWAFRect;
+ _wizImageCommand.box.bottom = pop();
+ _wizImageCommand.box.right = pop();
+ _wizImageCommand.box.top = pop();
+ _wizImageCommand.box.left = pop();
+ adjustRect(_wizImageCommand.box);
break;
case SO_PALETTE: // 86, HE99+
- _wizParams.actionFlags |= kWAFPalette;
- _wizParams.img.palette = pop();
+ _wizImageCommand.actionFlags |= kWAFPalette;
+ _wizImageCommand.palette = pop();
break;
case SO_SCALE: // 92
- _wizParams.actionFlags |= kWAFScaled;
- _wizParams.scale = pop();
+ _wizImageCommand.actionFlags |= kWAFScale;
+ _wizImageCommand.scale = pop();
break;
case SO_SHADOW: // 98
- _wizParams.actionFlags |= kWAFShadow;
- _wizParams.img.shadow = pop();
+ _wizImageCommand.actionFlags |= kWAFShadow;
+ _wizImageCommand.shadow = pop();
break;
case SO_POLY_POLYGON: // 131, HE99+
- _wizParams.actionFlags |= kWAFPolygon2 | kWAFCompressionType | kWAFPolygon;
- _wizParams.actionMode = kWAPolyCapture;
- _wizParams.polygon2 = pop();
- _wizParams.polygon = pop();
- _wizParams.compressionType = pop();
+ _wizImageCommand.actionFlags |= kWAFPolygon2 | kWAFCompressionType | kWAFPolygon;
+ _wizImageCommand.actionMode = kWAPolyCapture;
+ _wizImageCommand.polygon2 = pop();
+ _wizImageCommand.polygon = pop();
+ _wizImageCommand.compressionType = pop();
break;
case SO_RENDER_RECTANGLE: // 133, HE99+
- _wizParams.actionFlags |= kWAFColor | kWAFRenderCoords;
- _wizParams.actionMode = kWARenderRectangle;
- _wizParams.fillColor = pop();
- _wizParams.renderCoords.bottom = pop();
- _wizParams.renderCoords.right = pop();
- _wizParams.renderCoords.top = pop();
- _wizParams.renderCoords.left = pop();
- adjustRect(_wizParams.renderCoords);
+ _wizImageCommand.actionFlags |= kWAFColor | kWAFRenderCoords;
+ _wizImageCommand.actionMode = kWARenderRectangle;
+ _wizImageCommand.colorValue = pop();
+ _wizImageCommand.renderCoords.bottom = pop();
+ _wizImageCommand.renderCoords.right = pop();
+ _wizImageCommand.renderCoords.top = pop();
+ _wizImageCommand.renderCoords.left = pop();
+ adjustRect(_wizImageCommand.renderCoords);
break;
case SO_RENDER_LINE: // 134, HE99+
- _wizParams.actionFlags |= kWAFColor | kWAFRenderCoords;
- _wizParams.actionMode = kWARenderLine;
- _wizParams.fillColor = pop();
- _wizParams.renderCoords.bottom = pop();
- _wizParams.renderCoords.right = pop();
- _wizParams.renderCoords.top = pop();
- _wizParams.renderCoords.left = pop();
- adjustRect(_wizParams.renderCoords);
+ _wizImageCommand.actionFlags |= kWAFColor | kWAFRenderCoords;
+ _wizImageCommand.actionMode = kWARenderLine;
+ _wizImageCommand.colorValue = pop();
+ _wizImageCommand.renderCoords.bottom = pop();
+ _wizImageCommand.renderCoords.right = pop();
+ _wizImageCommand.renderCoords.top = pop();
+ _wizImageCommand.renderCoords.left = pop();
+ adjustRect(_wizImageCommand.renderCoords);
break;
case SO_RENDER_PIXEL: // 135, HE99+
- _wizParams.actionFlags |= kWAFColor | kWAFRenderCoords;
- _wizParams.actionMode = kWARenderPixel;
- _wizParams.fillColor = pop();
- _wizParams.renderCoords.top = _wizParams.renderCoords.bottom = pop();
- _wizParams.renderCoords.left = _wizParams.renderCoords.right = pop();
- adjustRect(_wizParams.renderCoords);
+ _wizImageCommand.actionFlags |= kWAFColor | kWAFRenderCoords;
+ _wizImageCommand.actionMode = kWARenderPixel;
+ _wizImageCommand.colorValue = pop();
+ _wizImageCommand.renderCoords.top = _wizImageCommand.renderCoords.bottom = pop();
+ _wizImageCommand.renderCoords.left = _wizImageCommand.renderCoords.right = pop();
+ adjustRect(_wizImageCommand.renderCoords);
break;
case SO_RENDER_FLOOD_FILL: // 136, HE99+
- _wizParams.actionFlags |= kWAFColor | kWAFRenderCoords;
- _wizParams.actionMode = kWARenderFloodFill;
- _wizParams.fillColor = pop();
- _wizParams.renderCoords.top = _wizParams.renderCoords.bottom = pop();
- _wizParams.renderCoords.left = _wizParams.renderCoords.right = pop();
- adjustRect(_wizParams.renderCoords);
+ _wizImageCommand.actionFlags |= kWAFColor | kWAFRenderCoords;
+ _wizImageCommand.actionMode = kWARenderFloodFill;
+ _wizImageCommand.colorValue = pop();
+ _wizImageCommand.renderCoords.top = _wizImageCommand.renderCoords.bottom = pop();
+ _wizImageCommand.renderCoords.left = _wizImageCommand.renderCoords.right = pop();
+ adjustRect(_wizImageCommand.renderCoords);
break;
case SO_RENDER_INTO_IMAGE: // 137, HE99+
- _wizParams.actionFlags |= kWAFDestImage;
- _wizParams.dstResNum = pop();
+ _wizImageCommand.actionFlags |= kWAFDestImage;
+ _wizImageCommand.destImageNumber = pop();
break;
case SO_NEW_GENERAL_PROPERTY: // 139, HE99+
- _wizParams.actionFlags |= kWAFProperty;
- _wizParams.propertyValue = pop();
- _wizParams.propertyNumber = pop();
+ _wizImageCommand.actionFlags |= kWAFProperty;
+ _wizImageCommand.propertyValue = pop();
+ _wizImageCommand.propertyNumber = pop();
break;
case SO_FONT_START: // 141, HE99+
- _wizParams.actionMode = kWAFontStart;
+ _wizImageCommand.actionMode = kWAFontStart;
break;
case SO_FONT_CREATE: // 142, HE99+
- _wizParams.actionMode = kWAFontCreate;
- _wizParams.fontProperties.bgColor = pop();
- _wizParams.fontProperties.fgColor = pop();
- _wizParams.fontProperties.size = pop();
- _wizParams.fontProperties.style = pop();
- copyScriptString(_wizParams.fontProperties.fontName, sizeof(_wizParams.fontProperties.fontName));
+ _wizImageCommand.actionMode = kWAFontCreate;
+ _wizImageCommand.fontProperties.bgColor = pop();
+ _wizImageCommand.fontProperties.fgColor = pop();
+ _wizImageCommand.fontProperties.size = pop();
+ _wizImageCommand.fontProperties.style = pop();
+ copyScriptString(_wizImageCommand.fontProperties.fontName, sizeof(_wizImageCommand.fontProperties.fontName));
break;
case SO_FONT_RENDER: // 143, HE99+
- _wizParams.actionMode = kWAFontRender;
- _wizParams.fontProperties.yPos = pop();
- _wizParams.fontProperties.xPos = pop();
- copyScriptString(_wizParams.fontProperties.string, sizeof(_wizParams.fontProperties.string));
+ _wizImageCommand.actionMode = kWAFontRender;
+ _wizImageCommand.fontProperties.yPos = pop();
+ _wizImageCommand.fontProperties.xPos = pop();
+ copyScriptString(_wizImageCommand.fontProperties.string, sizeof(_wizImageCommand.fontProperties.string));
break;
case SO_RENDER_ELLIPSE: // 189, HE99+
- _wizParams.actionMode = kWARenderEllipse;
- _wizParams.ellipseProperties.color = pop();
- _wizParams.ellipseProperties.lod = pop();
- _wizParams.ellipseProperties.ky = pop();
- _wizParams.ellipseProperties.kx = pop();
- _wizParams.ellipseProperties.qy = pop();
- _wizParams.ellipseProperties.qx = pop();
- _wizParams.ellipseProperties.py = pop();
- _wizParams.ellipseProperties.px = pop();
+ _wizImageCommand.actionMode = kWARenderEllipse;
+ _wizImageCommand.ellipseProperties.color = pop();
+ _wizImageCommand.ellipseProperties.lod = pop();
+ _wizImageCommand.ellipseProperties.ky = pop();
+ _wizImageCommand.ellipseProperties.kx = pop();
+ _wizImageCommand.ellipseProperties.qy = pop();
+ _wizImageCommand.ellipseProperties.qx = pop();
+ _wizImageCommand.ellipseProperties.py = pop();
+ _wizImageCommand.ellipseProperties.px = pop();
break;
case SO_FONT_END: // 196, HE99+
- _wizParams.actionMode = kWAFontEnd;
+ _wizImageCommand.actionMode = kWAFontEnd;
break;
case SO_NEW: // 217, HE99+
- _wizParams.actionMode = kWANew;
+ _wizImageCommand.actionMode = kWANew;
break;
case SO_SET_POLYGON: // 246
- _wizParams.actionFlags |= kWAFFlags | kWAFSpot | kWAFPolygon;
- _wizParams.img.flags |= kWIFIsPolygon;
- _wizParams.polygon = _wizParams.img.y1 = _wizParams.img.x1 = pop();
+ _wizImageCommand.actionFlags |= kWAFFlags | kWAFSpot | kWAFPolygon;
+ _wizImageCommand.flags |= kWRFIsPolygon;
+ _wizImageCommand.polygon = _wizImageCommand.yPos = _wizImageCommand.xPos = pop();
break;
case SO_END: // 255
- if (_wizParams.img.resNum)
- _wiz->processWizImage(&_wizParams);
+ if (_wizImageCommand.image)
+ _wiz->processWizImageCmd(&_wizImageCommand);
break;
default:
error("o90_wizImageOps: unhandled case %d", subOp);
diff --git a/engines/scumm/he/sprite_he.cpp b/engines/scumm/he/sprite_he.cpp
index 6eb80a94ede..e642c6002fb 100644
--- a/engines/scumm/he/sprite_he.cpp
+++ b/engines/scumm/he/sprite_he.cpp
@@ -62,29 +62,29 @@ void Sprite::getSpriteBounds(int spriteId, bool checkGroup, Common::Rect &bound)
SpriteInfo *spi = &_spriteTable[spriteId];
- _vm->_wiz->getWizImageSpot(spi->image, spi->imageState, spr_wiz_x, spr_wiz_y);
+ _vm->_wiz->getWizImageSpot(spi->image, spi->state, spr_wiz_x, spr_wiz_y);
if (checkGroup && spi->group) {
SpriteGroup *spg = &_spriteGroups[spi->group];
if (spg->scaling) {
- x1 = spi->tx * spg->scale_x_ratio_mul / spg->scale_x_ratio_div - spr_wiz_x + spg->tx;
- y1 = spi->ty * spg->scale_y_ratio_mul / spg->scale_y_ratio_div - spr_wiz_y + spg->ty;
+ x1 = spi->posX * spg->scale_x_ratio_mul / spg->scale_x_ratio_div - spr_wiz_x + spg->tx;
+ y1 = spi->posY * spg->scale_y_ratio_mul / spg->scale_y_ratio_div - spr_wiz_y + spg->ty;
} else {
- x1 = spi->tx - spr_wiz_x + spg->tx;
- y1 = spi->ty - spr_wiz_y + spg->ty;
+ x1 = spi->posX - spr_wiz_x + spg->tx;
+ y1 = spi->posY - spr_wiz_y + spg->ty;
}
} else {
- x1 = spi->tx - spr_wiz_x;
- y1 = spi->ty - spr_wiz_y;
+ x1 = spi->posX - spr_wiz_x;
+ y1 = spi->posY - spr_wiz_y;
}
if (spi->image) {
angle = spi->angle;
scale = spi->scale;
- _vm->_wiz->getWizImageDim(spi->image, spi->imageState, w, h);
- if (spi->flags & (kSFScaled | kSFRotated)) {
+ _vm->_wiz->getWizImageDim(spi->image, spi->state, w, h);
+ if (spi->flags & (kSFScaleSpecified | kSFAngleSpecified)) {
Common::Point pts[4];
- _vm->_wiz->polygonTransform(spi->image, spi->imageState, x1, y1, angle, scale, pts);
+ _vm->_wiz->polygonTransform(spi->image, spi->state, x1, y1, angle, scale, pts);
_vm->_wiz->polygonCalcBoundBox(pts, 4, bound);
} else {
bound.left = x1;
@@ -111,7 +111,7 @@ int Sprite::findSpriteWithClassOf(int x_pos, int y_pos, int spriteGroupId, int t
for (int i = (_numSpritesToProcess - 1); i >= 0; i--) {
SpriteInfo *spi = _activeSpritesTable[i];
- if (!spi->curImage)
+ if (!spi->lastImage)
continue;
if (spriteGroupId && spi->group != spriteGroupId)
@@ -134,65 +134,65 @@ int Sprite::findSpriteWithClassOf(int x_pos, int y_pos, int spriteGroupId, int t
continue;
if (type) {
- if (spi->bbox.left > spi->bbox.right)
+ if (spi->lastRect.left > spi->lastRect.right)
continue;
- if (spi->bbox.top > spi->bbox.bottom)
+ if (spi->lastRect.top > spi->lastRect.bottom)
continue;
- if (spi->bbox.left > x_pos)
+ if (spi->lastRect.left > x_pos)
continue;
- if (spi->bbox.top > y_pos)
+ if (spi->lastRect.top > y_pos)
continue;
- if (spi->bbox.right < x_pos)
+ if (spi->lastRect.right < x_pos)
continue;
- if (spi->bbox.bottom < y_pos)
+ if (spi->lastRect.bottom < y_pos)
continue;
return spi->id;
} else {
int image, imageState, angle, scale;
int32 w, h;
- image = spi->curImage;
+ image = spi->lastImage;
if (spi->maskImage) {
int32 x1, x2, y1, y2;
image = spi->maskImage;
- imageState = spi->curImageState % _vm->_wiz->getWizImageStates(spi->maskImage);
+ imageState = spi->lastState % _vm->_wiz->getWizImageStates(spi->maskImage);
- pos[0].x = x_pos - spi->pos.x;
- pos[0].y = y_pos - spi->pos.y;
+ pos[0].x = x_pos - spi->lastSpot.x;
+ pos[0].y = y_pos - spi->lastSpot.y;
- _vm->_wiz->getWizImageSpot(spi->curImage, imageState, x1, y1);
+ _vm->_wiz->getWizImageSpot(spi->lastImage, imageState, x1, y1);
_vm->_wiz->getWizImageSpot(spi->maskImage, imageState, x2, y2);
pos[0].x += (x2 - x1);
pos[0].y += (y2 - y1);
} else {
- if (spi->bbox.left > spi->bbox.right)
+ if (spi->lastRect.left > spi->lastRect.right)
continue;
- if (spi->bbox.top > spi->bbox.bottom)
+ if (spi->lastRect.top > spi->lastRect.bottom)
continue;
- if (spi->bbox.left > x_pos)
+ if (spi->lastRect.left > x_pos)
continue;
- if (spi->bbox.top > y_pos)
+ if (spi->lastRect.top > y_pos)
continue;
- if (spi->bbox.right < x_pos)
+ if (spi->lastRect.right < x_pos)
continue;
- if (spi->bbox.bottom < y_pos)
+ if (spi->lastRect.bottom < y_pos)
continue;
- pos[0].x = x_pos - spi->pos.x;
- pos[0].y = y_pos - spi->pos.y;
- imageState = spi->curImageState;
+ pos[0].x = x_pos - spi->lastSpot.x;
+ pos[0].y = y_pos - spi->lastSpot.y;
+ imageState = spi->lastState;
}
- angle = spi->curAngle;
- scale = spi->curScale;
- if ((spi->flags & kSFScaled) || (spi->flags & kSFRotated)) {
- if (spi->flags & kSFScaled && scale) {
+ angle = spi->lastAngle;
+ scale = spi->lastScale;
+ if ((spi->flags & kSFScaleSpecified) || (spi->flags & kSFAngleSpecified)) {
+ if (spi->flags & kSFScaleSpecified && scale) {
pos[0].x = pos[0].x * 256 / scale;
pos[0].y = pos[0].y * 256 / scale;
}
- if (spi->flags & kSFRotated && angle) {
+ if (spi->flags & kSFAngleSpecified && angle) {
angle = (360 - angle) % 360;
_vm->_wiz->polygonRotatePoints(pos, 1, angle);
}
@@ -202,7 +202,7 @@ int Sprite::findSpriteWithClassOf(int x_pos, int y_pos, int spriteGroupId, int t
pos[0].y += h / 2;
}
- if (_vm->_wiz->isWizPixelNonTransparent(image, imageState, pos[0].x, pos[0].y, spi->curImgFlags))
+ if (_vm->_wiz->isWizPixelNonTransparent(image, imageState, pos[0].x, pos[0].y, spi->lastRenderFlags))
return spi->id;
}
}
@@ -236,19 +236,19 @@ int Sprite::getSpriteClass(int spriteId, int num, int *args) {
int Sprite::getSpriteFlagDoubleBuffered(int spriteId) {
assertRange(1, spriteId, _varNumSprites, "sprite");
- return ((_spriteTable[spriteId].flags & kSFDoubleBuffered) != 0) ? 1 : 0;
+ return ((_spriteTable[spriteId].flags & kSFBackgroundRender) != 0) ? 1 : 0;
}
int Sprite::getSpriteFlagYFlipped(int spriteId) {
assertRange(1, spriteId, _varNumSprites, "sprite");
- return ((_spriteTable[spriteId].flags & kSFYFlipped) != 0) ? 1 : 0;
+ return ((_spriteTable[spriteId].flags & kSFVFlip) != 0) ? 1 : 0;
}
int Sprite::getSpriteFlagXFlipped(int spriteId) {
assertRange(1, spriteId, _varNumSprites, "sprite");
- return ((_spriteTable[spriteId].flags & kSFXFlipped) != 0) ? 1 : 0;
+ return ((_spriteTable[spriteId].flags & kSFHFlip) != 0) ? 1 : 0;
}
int Sprite::getSpriteFlagActive(int spriteId) {
@@ -260,7 +260,7 @@ int Sprite::getSpriteFlagActive(int spriteId) {
int Sprite::getSpriteFlagRemapPalette(int spriteId) {
assertRange(1, spriteId, _varNumSprites, "sprite");
- return ((_spriteTable[spriteId].flags & kSFRemapPalette) != 0) ? 1 : 0;
+ return ((_spriteTable[spriteId].flags & kSFUseImageRemap) != 0) ? 1 : 0;
}
int Sprite::getSpriteFlagAutoAnim(int spriteId) {
@@ -273,19 +273,19 @@ int Sprite::getSpriteFlagAutoAnim(int spriteId) {
if (_vm->_game.id == GID_PJGAMES)
return 0;
- return ((_spriteTable[spriteId].flags & kSFAutoAnim) != 0) ? 1 : 0;
+ return ((_spriteTable[spriteId].flags & kSFAutoAnimate) != 0) ? 1 : 0;
}
int Sprite::getSpriteFlagUpdateType(int spriteId) {
assertRange(1, spriteId, _varNumSprites, "sprite");
- return ((_spriteTable[spriteId].flags & kSFMarkDirty) != 0) ? 1 : 0;
+ return ((_spriteTable[spriteId].flags & kSFSmartRender) != 0) ? 1 : 0;
}
int Sprite::getSpriteFlagEraseType(int spriteId) {
assertRange(1, spriteId, _varNumSprites, "sprite");
- return ((_spriteTable[spriteId].flags & kSFImageless) != 0) ? 1 : 0;
+ return ((_spriteTable[spriteId].flags & kSFIgnoreErase) != 0) ? 1 : 0;
}
int Sprite::getSpriteImage(int spriteId) {
@@ -297,7 +297,7 @@ int Sprite::getSpriteImage(int spriteId) {
int Sprite::getSpriteImageState(int spriteId) {
assertRange(1, spriteId, _varNumSprites, "sprite");
- return _spriteTable[spriteId].imageState;
+ return _spriteTable[spriteId].state;
}
int Sprite::getSpriteGroup(int spriteId) {
@@ -322,18 +322,18 @@ int Sprite::getSpriteDisplayX(int spriteId) {
assertRange(1, spriteId, _varNumSprites, "sprite");
if (_spriteTable[spriteId].group)
- return _spriteTable[spriteId].tx + _spriteGroups[_spriteTable[spriteId].group].tx;
+ return _spriteTable[spriteId].posX + _spriteGroups[_spriteTable[spriteId].group].tx;
else
- return _spriteTable[spriteId].tx;
+ return _spriteTable[spriteId].posX;
}
int Sprite::getSpriteDisplayY(int spriteId) {
assertRange(1, spriteId, _varNumSprites, "sprite");
if (_spriteTable[spriteId].group)
- return _spriteTable[spriteId].ty + _spriteGroups[_spriteTable[spriteId].group].ty;
+ return _spriteTable[spriteId].posY + _spriteGroups[_spriteTable[spriteId].group].ty;
else
- return _spriteTable[spriteId].ty;
+ return _spriteTable[spriteId].posY;
}
int Sprite::getSpriteUserValue(int spriteId) {
@@ -351,7 +351,7 @@ int Sprite::getSpriteShadow(int spriteId) {
int Sprite::getSpriteImageStateCount(int spriteId) {
assertRange(1, spriteId, _varNumSprites, "sprite");
- return _spriteTable[spriteId].imageStateCount;
+ return _spriteTable[spriteId].maxStates;
}
int Sprite::getSpriteScale(int spriteId) {
@@ -386,11 +386,11 @@ int Sprite::getSpriteGeneralProperty(int spriteId, int type) {
switch (type) {
case 0x7B:
- return _spriteTable[spriteId].imgFlags;
+ return _spriteTable[spriteId].specialRenderFlags;
case 0x7D:
return _spriteTable[spriteId].conditionBits;
case 0x7E:
- return _spriteTable[spriteId].animProgress;
+ return _spriteTable[spriteId].animState;
default:
error("getSpriteGeneralProperty: Invalid type %d", type);
}
@@ -400,7 +400,7 @@ void Sprite::getSpriteImageDim(int spriteId, int32 &w, int32 &h) {
assertRange(1, spriteId, _varNumSprites, "sprite");
if (_spriteTable[spriteId].image) {
- _vm->_wiz->getWizImageDim(_spriteTable[spriteId].image, _spriteTable[spriteId].imageState, w, h);
+ _vm->_wiz->getWizImageDim(_spriteTable[spriteId].image, _spriteTable[spriteId].state, w, h);
} else {
w = 0;
h = 0;
@@ -410,15 +410,15 @@ void Sprite::getSpriteImageDim(int spriteId, int32 &w, int32 &h) {
void Sprite::getSpritePosition(int spriteId, int32 &tx, int32 &ty) {
assertRange(1, spriteId, _varNumSprites, "sprite");
- tx = _spriteTable[spriteId].tx;
- ty = _spriteTable[spriteId].ty;
+ tx = _spriteTable[spriteId].posX;
+ ty = _spriteTable[spriteId].posY;
}
void Sprite::getSpriteDist(int spriteId, int32 &dx, int32 &dy) {
assertRange(1, spriteId, _varNumSprites, "sprite");
- dx = _spriteTable[spriteId].dx;
- dy = _spriteTable[spriteId].dy;
+ dx = _spriteTable[spriteId].deltaPosX;
+ dy = _spriteTable[spriteId].deltaPosY;
}
//
@@ -503,7 +503,7 @@ void Sprite::setSpritePalette(int spriteId, int value) {
if (_spriteTable[spriteId].palette != value) {
_spriteTable[spriteId].palette = value;
- _spriteTable[spriteId].flags |= kSFChanged | kSFNeedRedraw;
+ _spriteTable[spriteId].flags |= kSFErase | kSFRender;
}
}
@@ -512,7 +512,7 @@ void Sprite::setSpriteSourceImage(int spriteId, int value) {
if (_spriteTable[spriteId].sourceImage != value) {
_spriteTable[spriteId].sourceImage = value;
- _spriteTable[spriteId].flags |= kSFChanged | kSFNeedRedraw;
+ _spriteTable[spriteId].flags |= kSFErase | kSFRender;
}
}
@@ -526,13 +526,13 @@ void Sprite::setSpriteImageState(int spriteId, int state) {
assertRange(1, spriteId, _varNumSprites, "sprite");
if (_spriteTable[spriteId].image) {
- int imageStateCount = _spriteTable[spriteId].imageStateCount - 1;
+ int imageStateCount = _spriteTable[spriteId].maxStates - 1;
state = MAX(0, state);
state = MIN(state, imageStateCount);
- if (_spriteTable[spriteId].imageState != state) {
- _spriteTable[spriteId].imageState = state;
- _spriteTable[spriteId].flags |= kSFChanged | kSFNeedRedraw;
+ if (_spriteTable[spriteId].state != state) {
+ _spriteTable[spriteId].state = state;
+ _spriteTable[spriteId].flags |= kSFErase | kSFRender;
}
}
}
@@ -540,10 +540,10 @@ void Sprite::setSpriteImageState(int spriteId, int state) {
void Sprite::setSpritePosition(int spriteId, int tx, int ty) {
assertRange(1, spriteId, _varNumSprites, "sprite");
- if (_spriteTable[spriteId].tx != tx || _spriteTable[spriteId].ty != ty) {
- _spriteTable[spriteId].tx = tx;
- _spriteTable[spriteId].ty = ty;
- _spriteTable[spriteId].flags |= kSFChanged | kSFNeedRedraw;
+ if (_spriteTable[spriteId].posX != tx || _spriteTable[spriteId].posY != ty) {
+ _spriteTable[spriteId].posX = tx;
+ _spriteTable[spriteId].posY = ty;
+ _spriteTable[spriteId].flags |= kSFErase | kSFRender;
}
}
@@ -552,14 +552,14 @@ void Sprite::setSpriteGroup(int spriteId, int value) {
assertRange(0, value, _varNumSpriteGroups, "sprite group");
_spriteTable[spriteId].group = value;
- _spriteTable[spriteId].flags |= kSFChanged | kSFNeedRedraw;
+ _spriteTable[spriteId].flags |= kSFErase | kSFRender;
}
void Sprite::setSpriteDist(int spriteId, int value1, int value2) {
assertRange(1, spriteId, _varNumSprites, "sprite");
- _spriteTable[spriteId].dx = value1;
- _spriteTable[spriteId].dy = value2;
+ _spriteTable[spriteId].deltaPosX = value1;
+ _spriteTable[spriteId].deltaPosY = value2;
}
void Sprite::setSpriteShadow(int spriteId, int value) {
@@ -567,7 +567,7 @@ void Sprite::setSpriteShadow(int spriteId, int value) {
_spriteTable[spriteId].shadow = value;
if (_spriteTable[spriteId].image)
- _spriteTable[spriteId].flags |= kSFChanged | kSFNeedRedraw;
+ _spriteTable[spriteId].flags |= kSFErase | kSFRender;
}
void Sprite::setSpriteUserValue(int spriteId, int value1, int value2) {
@@ -585,36 +585,36 @@ void Sprite::setSpritePriority(int spriteId, int value) {
void Sprite::moveSprite(int spriteId, int value1, int value2) {
assertRange(1, spriteId, _varNumSprites, "sprite");
- _spriteTable[spriteId].tx += value1;
- _spriteTable[spriteId].ty += value2;
+ _spriteTable[spriteId].posX += value1;
+ _spriteTable[spriteId].posY += value2;
if (value1 || value2)
- _spriteTable[spriteId].flags |= kSFChanged | kSFNeedRedraw;
+ _spriteTable[spriteId].flags |= kSFErase | kSFRender;
}
void Sprite::setSpriteScale(int spriteId, int value) {
assertRange(1, spriteId, _varNumSprites, "sprite");
- _spriteTable[spriteId].flags |= kSFScaled;
+ _spriteTable[spriteId].flags |= kSFScaleSpecified;
if (_spriteTable[spriteId].scale != value) {
_spriteTable[spriteId].scale = value;
if (_spriteTable[spriteId].image)
- _spriteTable[spriteId].flags |= kSFChanged | kSFNeedRedraw;
+ _spriteTable[spriteId].flags |= kSFErase | kSFRender;
}
}
void Sprite::setSpriteAngle(int spriteId, int value) {
assertRange(1, spriteId, _varNumSprites, "sprite");
- _spriteTable[spriteId].flags |= kSFRotated;
+ _spriteTable[spriteId].flags |= kSFAngleSpecified;
if (_spriteTable[spriteId].angle != value) {
_spriteTable[spriteId].angle = value;
if (_spriteTable[spriteId].image)
- _spriteTable[spriteId].flags |= kSFChanged | kSFNeedRedraw;
+ _spriteTable[spriteId].flags |= kSFErase | kSFRender;
}
}
@@ -623,12 +623,12 @@ void Sprite::setSpriteFlagDoubleBuffered(int spriteId, int value) {
int oldFlags = _spriteTable[spriteId].flags;
if (value)
- _spriteTable[spriteId].flags |= kSFDoubleBuffered;
+ _spriteTable[spriteId].flags |= kSFBackgroundRender;
else
- _spriteTable[spriteId].flags &= ~kSFDoubleBuffered;
+ _spriteTable[spriteId].flags &= ~kSFBackgroundRender;
if (_spriteTable[spriteId].image && _spriteTable[spriteId].flags != oldFlags)
- _spriteTable[spriteId].flags |= kSFChanged | kSFNeedRedraw;
+ _spriteTable[spriteId].flags |= kSFErase | kSFRender;
}
void Sprite::setSpriteFlagYFlipped(int spriteId, int value) {
@@ -636,12 +636,12 @@ void Sprite::setSpriteFlagYFlipped(int spriteId, int value) {
int oldFlags = _spriteTable[spriteId].flags;
if (value)
- _spriteTable[spriteId].flags |= kSFYFlipped;
+ _spriteTable[spriteId].flags |= kSFVFlip;
else
- _spriteTable[spriteId].flags &= ~kSFYFlipped;
+ _spriteTable[spriteId].flags &= ~kSFVFlip;
if (_spriteTable[spriteId].image && _spriteTable[spriteId].flags != oldFlags)
- _spriteTable[spriteId].flags |= kSFChanged | kSFNeedRedraw;
+ _spriteTable[spriteId].flags |= kSFErase | kSFRender;
}
void Sprite::setSpriteFlagXFlipped(int spriteId, int value) {
@@ -649,12 +649,12 @@ void Sprite::setSpriteFlagXFlipped(int spriteId, int value) {
int oldFlags = _spriteTable[spriteId].flags;
if (value)
- _spriteTable[spriteId].flags |= kSFXFlipped;
+ _spriteTable[spriteId].flags |= kSFHFlip;
else
- _spriteTable[spriteId].flags &= ~kSFXFlipped;
+ _spriteTable[spriteId].flags &= ~kSFHFlip;
if (_spriteTable[spriteId].image && _spriteTable[spriteId].flags != oldFlags)
- _spriteTable[spriteId].flags |= kSFChanged | kSFNeedRedraw;
+ _spriteTable[spriteId].flags |= kSFErase | kSFRender;
}
void Sprite::setSpriteFlagActive(int spriteId, int value) {
@@ -671,21 +671,21 @@ void Sprite::setSpriteFlagRemapPalette(int spriteId, int value) {
int oldFlags = _spriteTable[spriteId].flags;
if (value)
- _spriteTable[spriteId].flags |= kSFRemapPalette;
+ _spriteTable[spriteId].flags |= kSFUseImageRemap;
else
- _spriteTable[spriteId].flags &= ~kSFRemapPalette;
+ _spriteTable[spriteId].flags &= ~kSFUseImageRemap;
if (_spriteTable[spriteId].image && _spriteTable[spriteId].flags != oldFlags)
- _spriteTable[spriteId].flags |= kSFChanged | kSFNeedRedraw;
+ _spriteTable[spriteId].flags |= kSFErase | kSFRender;
}
void Sprite::setSpriteFlagAutoAnim(int spriteId, int value) {
assertRange(1, spriteId, _varNumSprites, "sprite");
if (value)
- _spriteTable[spriteId].flags |= kSFAutoAnim;
+ _spriteTable[spriteId].flags |= kSFAutoAnimate;
else
- _spriteTable[spriteId].flags &= ~kSFAutoAnim;
+ _spriteTable[spriteId].flags &= ~kSFAutoAnimate;
}
void Sprite::setSpriteFlagUpdateType(int spriteId, int value) {
@@ -693,14 +693,14 @@ void Sprite::setSpriteFlagUpdateType(int spriteId, int value) {
switch (value) {
case 2:
- _spriteTable[spriteId].flags &= ~(kSFMarkDirty);
- _spriteTable[spriteId].flags |= kSFBlitDirectly;
+ _spriteTable[spriteId].flags &= ~(kSFSmartRender);
+ _spriteTable[spriteId].flags |= kSFDontCombineErase;
break;
case 1:
- _spriteTable[spriteId].flags |= kSFMarkDirty | kSFBlitDirectly;
+ _spriteTable[spriteId].flags |= kSFSmartRender | kSFDontCombineErase;
break;
case 0:
- _spriteTable[spriteId].flags &= ~(kSFMarkDirty | kSFBlitDirectly);
+ _spriteTable[spriteId].flags &= ~(kSFSmartRender | kSFDontCombineErase);
break;
default:
error("setSpriteFlagUpdateType: Invalid value %d", value);
@@ -712,16 +712,16 @@ void Sprite::setSpriteFlagEraseType(int spriteId, int value) {
// Note that condition is inverted
if (!value)
- _spriteTable[spriteId].flags |= kSFImageless;
+ _spriteTable[spriteId].flags |= kSFIgnoreErase;
else
- _spriteTable[spriteId].flags &= ~kSFImageless;
+ _spriteTable[spriteId].flags &= ~kSFIgnoreErase;
}
void Sprite::setSpriteAnimSpeed(int spriteId, int value) {
assertRange(1, spriteId, _varNumSprites, "sprite");
_spriteTable[spriteId].animSpeed = value;
- _spriteTable[spriteId].animProgress = value;
+ _spriteTable[spriteId].animState = value;
}
void Sprite::setSpriteSetClass(int spriteId, int classId, int toggle) {
@@ -754,18 +754,18 @@ void Sprite::setSpriteGeneralProperty(int spriteId, int type, int value) {
switch (type) {
case 0x7B:
- _spriteTable[spriteId].imgFlags = value;
- _spriteTable[spriteId].flags |= kSFChanged | kSFNeedRedraw;
+ _spriteTable[spriteId].specialRenderFlags = value;
+ _spriteTable[spriteId].flags |= kSFErase | kSFRender;
break;
case 0x7D:
_spriteTable[spriteId].conditionBits = value;
- _spriteTable[spriteId].flags |= kSFChanged | kSFNeedRedraw;
+ _spriteTable[spriteId].flags |= kSFErase | kSFRender;
break;
case 0x7E:
delay = MAX(0, value);
delay = MIN(delay, _spriteTable[spriteId].animSpeed);
- _spriteTable[spriteId].animProgress = delay;
+ _spriteTable[spriteId].animState = delay;
break;
default:
error("setSpriteGeneralProperty: Invalid value %d", type);
@@ -781,29 +781,29 @@ void Sprite::resetSprite(int spriteId) {
setSpriteImage(spriteId, 0);
_spriteTable[spriteId].shadow = 0;
- _spriteTable[spriteId].tx = 0;
- _spriteTable[spriteId].ty = 0;
+ _spriteTable[spriteId].posX = 0;
+ _spriteTable[spriteId].posY = 0;
- _spriteTable[spriteId].flags &= ~(kSFYFlipped | kSFXFlipped);
- _spriteTable[spriteId].flags |= kSFChanged | kSFNeedRedraw;
- _spriteTable[spriteId].dx = 0;
- _spriteTable[spriteId].dy = 0;
+ _spriteTable[spriteId].flags &= ~(kSFVFlip | kSFHFlip);
+ _spriteTable[spriteId].flags |= kSFErase | kSFRender;
+ _spriteTable[spriteId].deltaPosX = 0;
+ _spriteTable[spriteId].deltaPosY = 0;
_spriteTable[spriteId].userValue = 0;
_spriteTable[spriteId].group = 0;
_spriteTable[spriteId].animSpeed = 0;
- _spriteTable[spriteId].animProgress = 0;
+ _spriteTable[spriteId].animState = 0;
_spriteTable[spriteId].classFlags = 0;
_spriteTable[spriteId].palette = 0;
_spriteTable[spriteId].sourceImage = 0;
_spriteTable[spriteId].maskImage = 0;
_spriteTable[spriteId].priority = 0;
_spriteTable[spriteId].zbufferImage = 0;
- _spriteTable[spriteId].imgFlags = 0;
+ _spriteTable[spriteId].specialRenderFlags = 0;
_spriteTable[spriteId].conditionBits = 0;
if (_vm->_game.heversion >= 100) {
- _spriteTable[spriteId].flags &= ~kSFMarkDirty;
- _spriteTable[spriteId].flags |= kSFAutoAnim | kSFBlitDirectly;
+ _spriteTable[spriteId].flags &= ~kSFSmartRender;
+ _spriteTable[spriteId].flags |= kSFAutoAnimate | kSFDontCombineErase;
}
}
@@ -813,34 +813,34 @@ void Sprite::setSpriteImage(int spriteId, int imageNum) {
assertRange(1, spriteId, _varNumSprites, "sprite");
origResId = _spriteTable[spriteId].image;
- origResWizStates = _spriteTable[spriteId].imageStateCount;
+ origResWizStates = _spriteTable[spriteId].maxStates;
_spriteTable[spriteId].image = imageNum;
_spriteTable[spriteId].animIndex = 0;
- _spriteTable[spriteId].imageState = 0;
+ _spriteTable[spriteId].state = 0;
if (_spriteTable[spriteId].image) {
- _spriteTable[spriteId].imageStateCount = _vm->_wiz->getWizImageStates(_spriteTable[spriteId].image);
+ _spriteTable[spriteId].maxStates = _vm->_wiz->getWizImageStates(_spriteTable[spriteId].image);
if (_vm->VAR(139))
_spriteTable[spriteId].flags |= kSFActive;
else
- _spriteTable[spriteId].flags |= kSFActive | kSFAutoAnim | kSFMarkDirty | kSFBlitDirectly;
+ _spriteTable[spriteId].flags |= kSFActive | kSFAutoAnimate | kSFSmartRender | kSFDontCombineErase;
- if (_spriteTable[spriteId].image != origResId || _spriteTable[spriteId].imageStateCount != origResWizStates)
- _spriteTable[spriteId].flags |= kSFChanged | kSFNeedRedraw;
+ if (_spriteTable[spriteId].image != origResId || _spriteTable[spriteId].maxStates != origResWizStates)
+ _spriteTable[spriteId].flags |= kSFErase | kSFRender;
} else {
if (_vm->VAR(139))
_spriteTable[spriteId].flags &= ~kSFActive;
else if (_vm->_game.heversion >= 100 && origResId == 0)
_spriteTable[spriteId].flags = 0;
- else if (_spriteTable[spriteId].flags & kSFImageless)
+ else if (_spriteTable[spriteId].flags & kSFIgnoreErase)
_spriteTable[spriteId].flags = 0;
else
- _spriteTable[spriteId].flags = kSFChanged | kSFBlitDirectly;
- _spriteTable[spriteId].curImage = 0;
- _spriteTable[spriteId].curImageState = 0;
- _spriteTable[spriteId].imageStateCount = 0;
+ _spriteTable[spriteId].flags = kSFErase | kSFDontCombineErase;
+ _spriteTable[spriteId].lastImage = 0;
+ _spriteTable[spriteId].lastState = 0;
+ _spriteTable[spriteId].maxStates = 0;
}
}
@@ -851,7 +851,7 @@ void Sprite::redrawSpriteGroup(int spriteGroupId) {
for (int i = 0; i < _numSpritesToProcess; ++i) {
SpriteInfo *spi = _activeSpritesTable[i];
if (spi->group == spriteGroupId) {
- spi->flags |= kSFChanged | kSFNeedRedraw;
+ spi->flags |= kSFErase | kSFRender;
}
}
}
@@ -861,11 +861,11 @@ void Sprite::moveGroupMembers(int spriteGroupId, int value1, int value2) {
for (int i = 1; i < _varNumSprites; i++) {
if (_spriteTable[i].group == spriteGroupId) {
- _spriteTable[i].tx += value1;
- _spriteTable[i].ty += value2;
+ _spriteTable[i].posX += value1;
+ _spriteTable[i].posY += value2;
if (value1 || value2)
- _spriteTable[i].flags |= kSFChanged | kSFNeedRedraw;
+ _spriteTable[i].flags |= kSFErase | kSFRender;
}
}
}
@@ -885,7 +885,7 @@ void Sprite::setGroupMembersGroup(int spriteGroupId, int value) {
for (int i = 1; i < _varNumSprites; i++) {
if (_spriteTable[i].group == spriteGroupId) {
_spriteTable[i].group = value;
- _spriteTable[i].flags |= kSFChanged | kSFNeedRedraw;
+ _spriteTable[i].flags |= kSFErase | kSFRender;
}
}
}
@@ -914,7 +914,7 @@ void Sprite::setGroupMembersAnimationSpeed(int spriteGroupId, int value) {
for (int i = 1; i < _varNumSprites; i++) {
if (_spriteTable[i].group == spriteGroupId) {
_spriteTable[i].animSpeed = value;
- _spriteTable[i].animProgress = value;
+ _spriteTable[i].animState = value;
}
}
}
@@ -925,9 +925,9 @@ void Sprite::setGroupMembersAutoAnimFlag(int spriteGroupId, int value) {
for (int i = 1; i < _varNumSprites; i++) {
if (_spriteTable[i].group == spriteGroupId) {
if (value)
- _spriteTable[i].flags |= kSFAutoAnim;
+ _spriteTable[i].flags |= kSFAutoAnimate;
else
- _spriteTable[i].flags &= ~kSFAutoAnim;
+ _spriteTable[i].flags &= ~kSFAutoAnimate;
}
}
}
@@ -939,7 +939,7 @@ void Sprite::setGroupMembersShadow(int spriteGroupId, int value) {
if (_spriteTable[i].group == spriteGroupId) {
_spriteTable[i].shadow = value;
if (_spriteTable[i].image)
- _spriteTable[i].flags |= kSFChanged | kSFNeedRedraw;
+ _spriteTable[i].flags |= kSFErase | kSFRender;
}
}
}
@@ -947,7 +947,7 @@ void Sprite::setGroupMembersShadow(int spriteGroupId, int value) {
void Sprite::setGroupBounds(int spriteGroupId, int x1, int y1, int x2, int y2) {
assertRange(1, spriteGroupId, _varNumSpriteGroups, "sprite group");
- _spriteGroups[spriteGroupId].flags |= kSGFClipBox;
+ _spriteGroups[spriteGroupId].flags |= kSGFUseClipRect;
_spriteGroups[spriteGroupId].bbox.left = x1;
_spriteGroups[spriteGroupId].bbox.top = y1;
_spriteGroups[spriteGroupId].bbox.right = x2;
@@ -1052,7 +1052,7 @@ void Sprite::setGroupYDiv(int spriteGroupId, int value) {
void Sprite::resetGroupBounds(int spriteGroupId) {
assertRange(1, spriteGroupId, _varNumSpriteGroups, "sprite group");
- _spriteGroups[spriteGroupId].flags &= ~(kSGFClipBox);
+ _spriteGroups[spriteGroupId].flags &= ~(kSGFUseClipRect);
redrawSpriteGroup(spriteGroupId);
}
@@ -1073,7 +1073,7 @@ void Sprite::resetGroup(int spriteGroupId) {
spg->priority = 0;
spg->tx = spg->ty = 0;
- spg->flags &= ~kSGFClipBox;
+ spg->flags &= ~kSGFUseClipRect;
redrawSpriteGroup(spriteGroupId);
spg->image = 0;
@@ -1110,35 +1110,35 @@ void Sprite::resetBackground() {
for (int i = 0; i < _numSpritesToProcess; ++i) {
SpriteInfo *spi = _activeSpritesTable[i];
- if (!(spi->flags & kSFImageless) && (spi->flags & kSFChanged)) {
- spi->flags &= ~kSFChanged;
- if (spi->bbox.left <= spi->bbox.right && spi->bbox.top <= spi->bbox.bottom) {
- if (spi->flags & kSFBlitDirectly) {
- _vm->restoreBackgroundHE(spi->bbox, USAGE_BIT_RESTORED);
+ if (!(spi->flags & kSFIgnoreErase) && (spi->flags & kSFErase)) {
+ spi->flags &= ~kSFErase;
+ if (spi->lastRect.left <= spi->lastRect.right && spi->lastRect.top <= spi->lastRect.bottom) {
+ if (spi->flags & kSFDontCombineErase) {
+ _vm->restoreBackgroundHE(spi->lastRect, USAGE_BIT_RESTORED);
} else if (firstLoop) {
- xmin = spi->bbox.left;
- ymin = spi->bbox.top;
- xmax = spi->bbox.right;
- ymax = spi->bbox.bottom;
+ xmin = spi->lastRect.left;
+ ymin = spi->lastRect.top;
+ xmax = spi->lastRect.right;
+ ymax = spi->lastRect.bottom;
firstLoop = false;
refreshScreen = true;
} else {
- if (xmin > spi->bbox.left) {
- xmin = spi->bbox.left;
+ if (xmin > spi->lastRect.left) {
+ xmin = spi->lastRect.left;
}
- if (ymin > spi->bbox.top) {
- ymin = spi->bbox.top;
+ if (ymin > spi->lastRect.top) {
+ ymin = spi->lastRect.top;
}
- if (xmax < spi->bbox.right) {
- xmax = spi->bbox.right;
+ if (xmax < spi->lastRect.right) {
+ xmax = spi->lastRect.right;
}
- if (ymax < spi->bbox.bottom) {
- ymax = spi->bbox.bottom;
+ if (ymax < spi->lastRect.bottom) {
+ ymax = spi->lastRect.bottom;
}
refreshScreen = true;
}
- if (!(spi->flags & kSFNeedRedraw) && spi->image)
- spi->flags |= kSFNeedRedraw;
+ if (!(spi->flags & kSFRender) && spi->image)
+ spi->flags |= kSFRender;
}
}
}
@@ -1147,21 +1147,21 @@ void Sprite::resetBackground() {
}
}
-void Sprite::setRedrawFlags(bool checkZOrder) {
+void Sprite::checkForForcedRedraws(bool checkZOrder) {
VirtScreen *vs = &_vm->_virtscr[kMainVirtScreen];
for (int i = 0; i < _numSpritesToProcess; ++i) {
SpriteInfo *spi = _activeSpritesTable[i];
- if (!(spi->flags & kSFNeedRedraw)) {
- if ((!checkZOrder || spi->priority >= 0) && (spi->flags & kSFMarkDirty)) {
- int32 lp = spi->bbox.left / 8;
+ if (!(spi->flags & kSFRender)) {
+ if ((!checkZOrder || spi->priority >= 0) && (spi->flags & kSFSmartRender)) {
+ int32 lp = spi->lastRect.left / 8;
lp = MAX((int32)0, lp);
lp = MIN(lp, _vm->_gdi->_numStrips);
- int32 rp = (spi->bbox.right + 7) / 8;
+ int32 rp = (spi->lastRect.right + 7) / 8;
rp = MAX((int32)0, rp);
rp = MIN(rp, _vm->_gdi->_numStrips);
for (; lp < rp; lp++) {
- if (vs->tdirty[lp] < vs->h && spi->bbox.bottom >= vs->tdirty[lp] && spi->bbox.top <= vs->bdirty[lp]) {
- spi->flags |= kSFNeedRedraw;
+ if (vs->tdirty[lp] < vs->h && spi->lastRect.bottom >= vs->tdirty[lp] && spi->lastRect.top <= vs->bdirty[lp]) {
+ spi->flags |= kSFRender;
break;
}
}
@@ -1173,31 +1173,31 @@ void Sprite::setRedrawFlags(bool checkZOrder) {
void Sprite::updateImages() {
for (int i = 0; i < _numSpritesToProcess; ++i) {
SpriteInfo *spi = _activeSpritesTable[i];
- if (spi->dx || spi->dy) {
- int tx = spi->tx;
- int ty = spi->ty;
- spi->tx += spi->dx;
- spi->ty += spi->dy;
- if (tx != spi->tx || ty != spi->ty) {
- spi->flags |= kSFChanged | kSFNeedRedraw;
+ if (spi->deltaPosX || spi->deltaPosY) {
+ int tx = spi->posX;
+ int ty = spi->posY;
+ spi->posX += spi->deltaPosX;
+ spi->posY += spi->deltaPosY;
+ if (tx != spi->posX || ty != spi->posY) {
+ spi->flags |= kSFErase | kSFRender;
}
}
- if (spi->flags & kSFAutoAnim) {
+ if (spi->flags & kSFAutoAnimate) {
if (spi->animSpeed) {
- --spi->animProgress;
- if (spi->animProgress)
+ --spi->animState;
+ if (spi->animState)
continue;
- spi->animProgress = spi->animSpeed;
+ spi->animState = spi->animSpeed;
}
- int imageState = spi->imageState;
- ++spi->imageState;
- if (spi->imageState >= spi->imageStateCount) {
- spi->imageState = 0;
+ int imageState = spi->state;
+ ++spi->state;
+ if (spi->state >= spi->maxStates) {
+ spi->state = 0;
if (imageState == 0)
continue;
}
- spi->flags |= kSFChanged | kSFNeedRedraw;
+ spi->flags |= kSFErase | kSFRender;
}
}
}
@@ -1206,10 +1206,10 @@ static int compareSprTable(const void *a, const void *b) {
const SpriteInfo *spr1 = *(const SpriteInfo *const*)a;
const SpriteInfo *spr2 = *(const SpriteInfo *const*)b;
- if (spr1->zorder > spr2->zorder)
+ if (spr1->combinedPriority > spr2->combinedPriority)
return 1;
- if (spr1->zorder < spr2->zorder)
+ if (spr1->combinedPriority < spr2->combinedPriority)
return -1;
return 0;
@@ -1227,10 +1227,10 @@ void Sprite::sortActiveSprites() {
SpriteInfo *spi = &_spriteTable[i];
if (spi->flags & kSFActive) {
- if (!(spi->flags & kSFMarkDirty)) {
- spi->flags |= kSFNeedRedraw;
- if (!(spi->flags & kSFImageless))
- spi->flags |= kSFChanged;
+ if (!(spi->flags & kSFSmartRender)) {
+ spi->flags |= kSFRender;
+ if (!(spi->flags & kSFIgnoreErase))
+ spi->flags |= kSFErase;
}
if (spi->group)
groupZorder = _spriteGroups[spi->group].priority;
@@ -1238,7 +1238,7 @@ void Sprite::sortActiveSprites() {
groupZorder = 0;
spi->id = i;
- spi->zorder = spi->priority + groupZorder;
+ spi->combinedPriority = spi->priority + groupZorder;
_activeSpritesTable[_numSpritesToProcess++] = spi;
}
@@ -1250,75 +1250,75 @@ void Sprite::sortActiveSprites() {
qsort(_activeSpritesTable, _numSpritesToProcess, sizeof(SpriteInfo *), compareSprTable);
}
-void Sprite::processImages(bool arg) {
+void Sprite::renderSprites(bool arg) {
int spr_flags;
int32 spr_wiz_x, spr_wiz_y;
int image, imageState;
Common::Rect *bboxPtr;
int angle, scale;
int32 w, h;
- WizParameters wiz;
+ WizImageCommand wiz;
for (int i = 0; i < _numSpritesToProcess; i++) {
SpriteInfo *spi = _activeSpritesTable[i];
- if (!(spi->flags & kSFNeedRedraw))
+ if (!(spi->flags & kSFRender))
continue;
spr_flags = spi->flags;
if (arg) {
- if (spi->zorder >= 0)
+ if (spi->combinedPriority >= 0)
return;
} else {
- if (spi->zorder < 0)
+ if (spi->combinedPriority < 0)
continue;
}
- spi->flags &= ~kSFNeedRedraw;
+ spi->flags &= ~kSFRender;
image = spi->image;
- imageState = spi->imageState;
- _vm->_wiz->getWizImageSpot(spi->image, spi->imageState, spr_wiz_x, spr_wiz_y);
+ imageState = spi->state;
+ _vm->_wiz->getWizImageSpot(spi->image, spi->state, spr_wiz_x, spr_wiz_y);
if (spi->group) {
SpriteGroup *spg = &_spriteGroups[spi->group];
if (spg->scaling) {
- wiz.img.x1 = spi->tx * spg->scale_x_ratio_mul / spg->scale_x_ratio_div - spr_wiz_x + spg->tx;
- wiz.img.y1 = spi->ty * spg->scale_y_ratio_mul / spg->scale_y_ratio_div - spr_wiz_y + spg->ty;
+ wiz.xPos = spi->posX * spg->scale_x_ratio_mul / spg->scale_x_ratio_div - spr_wiz_x + spg->tx;
+ wiz.yPos = spi->posY * spg->scale_y_ratio_mul / spg->scale_y_ratio_div - spr_wiz_y + spg->ty;
} else {
- wiz.img.x1 = spi->tx - spr_wiz_x + spg->tx;
- wiz.img.y1 = spi->ty - spr_wiz_y + spg->ty;
+ wiz.xPos = spi->posX - spr_wiz_x + spg->tx;
+ wiz.yPos = spi->posY - spr_wiz_y + spg->ty;
}
} else {
- wiz.img.x1 = spi->tx - spr_wiz_x;
- wiz.img.y1 = spi->ty - spr_wiz_y;
+ wiz.xPos = spi->posX - spr_wiz_x;
+ wiz.yPos = spi->posY - spr_wiz_y;
}
- wiz.spriteId = spi->id;
- wiz.spriteGroup = spi->group;
- wiz.conditionBits = spi->conditionBits;
- spi->curImageState = wiz.img.state = imageState;
- spi->curImage = wiz.img.resNum = image;
+ wiz.extendedRenderInfo.sprite = spi->id;
+ wiz.extendedRenderInfo.group = spi->group;
+ wiz.extendedRenderInfo.conditionBits = spi->conditionBits;
+ spi->lastState = wiz.state = imageState;
+ spi->lastImage = wiz.image = image;
wiz.actionFlags = kWAFState | kWAFSpot;
- spi->curAngle = spi->angle;
- spi->curScale = spi->scale;
- spi->pos.x = wiz.img.x1;
- spi->pos.y = wiz.img.y1;
- bboxPtr = &spi->bbox;
+ spi->lastAngle = spi->angle;
+ spi->lastScale = spi->scale;
+ spi->lastSpot.x = wiz.xPos;
+ spi->lastSpot.y = wiz.yPos;
+ bboxPtr = &spi->lastRect;
if (image) {
angle = spi->angle;
scale = spi->scale;
_vm->_wiz->getWizImageDim(image, imageState, w, h);
- if (spi->flags & (kSFScaled | kSFRotated)) {
+ if (spi->flags & (kSFScaleSpecified | kSFAngleSpecified)) {
Common::Point pts[4];
- _vm->_wiz->polygonTransform(image, imageState, wiz.img.x1, wiz.img.y1, angle, scale, pts);
- _vm->_wiz->polygonCalcBoundBox(pts, 4, spi->bbox);
+ _vm->_wiz->polygonTransform(image, imageState, wiz.xPos, wiz.yPos, angle, scale, pts);
+ _vm->_wiz->polygonCalcBoundBox(pts, 4, spi->lastRect);
} else {
- bboxPtr->left = wiz.img.x1;
- bboxPtr->top = wiz.img.y1;
- bboxPtr->right = wiz.img.x1 + w;
- bboxPtr->bottom = wiz.img.y1 + h;
+ bboxPtr->left = wiz.xPos;
+ bboxPtr->top = wiz.yPos;
+ bboxPtr->right = wiz.xPos + w;
+ bboxPtr->bottom = wiz.yPos + h;
}
} else {
bboxPtr->left = 1234;
@@ -1327,51 +1327,51 @@ void Sprite::processImages(bool arg) {
bboxPtr->bottom = -1234;
}
- wiz.img.flags = kWRFForeground;
- wiz.img.zorder = 0;
- if (spr_flags & kSFXFlipped)
- wiz.img.flags |= kWIFFlipX;
- if (spr_flags & kSFYFlipped)
- wiz.img.flags |= kWIFFlipY;
- if (spr_flags & kSFDoubleBuffered) {
- wiz.img.flags &= ~kWRFForeground;
- wiz.img.flags |= kWRFBackground;
+ wiz.flags = kWRFForeground;
+ wiz.zPos = 0;
+ if (spr_flags & kSFHFlip)
+ wiz.flags |= kWRFFlipX;
+ if (spr_flags & kSFVFlip)
+ wiz.flags |= kWRFFlipY;
+ if (spr_flags & kSFBackgroundRender) {
+ wiz.flags &= ~kWRFForeground;
+ wiz.flags |= kWRFBackground;
}
if (spi->shadow) {
- wiz.img.flags |= 0x200;
+ wiz.flags |= kWRFUseShadow;
wiz.actionFlags |= kWAFShadow;
- wiz.img.shadow = spi->shadow;
+ wiz.shadow = spi->shadow;
}
- if (spr_flags & kSFRemapPalette)
- wiz.img.flags |= kWRFRemap;
+ if (spr_flags & kSFUseImageRemap)
+ wiz.flags |= kWRFRemap;
if (spi->zbufferImage) {
- wiz.actionFlags |= 0x200000;
- wiz.img.zbuffer = spi->zbufferImage;
- wiz.img.zorder = spi->priority;
+ wiz.actionFlags |= kWAFZBufferImage;
+ wiz.zbufferImage = spi->zbufferImage;
+ wiz.zPos = spi->priority;
}
if (spi->sourceImage) {
wiz.actionFlags |= kWAFSourceImg;
wiz.sourceImage = spi->sourceImage;
}
wiz.actionFlags |= kWAFFlags;
- wiz.img.flags |= spi->imgFlags;
+ wiz.flags |= spi->specialRenderFlags;
- if (spr_flags & kSFRotated) {
- wiz.actionFlags |= kWAFRotate;
+ if (spr_flags & kSFAngleSpecified) {
+ wiz.actionFlags |= kWAFAngle;
wiz.angle = spi->angle;
}
- if (spr_flags & kSFScaled) {
- wiz.actionFlags |= kWAFScaled;
+ if (spr_flags & kSFScaleSpecified) {
+ wiz.actionFlags |= kWAFScale;
wiz.scale = spi->scale;
}
- spi->curImgFlags = wiz.img.flags;
+ spi->lastRenderFlags = wiz.flags;
- if (spi->group && (_spriteGroups[spi->group].flags & kSGFClipBox)) {
+ if (spi->group && (_spriteGroups[spi->group].flags & kSGFUseClipRect)) {
Common::Rect &spgBbox = _spriteGroups[spi->group].bbox;
- if (spgBbox.isValidRect() && spi->bbox.intersects(spgBbox)) {
- spi->bbox.clip(spgBbox);
+ if (spgBbox.isValidRect() && spi->lastRect.intersects(spgBbox)) {
+ spi->lastRect.clip(spgBbox);
wiz.actionFlags |= kWAFRect;
- wiz.box = spi->bbox;
+ wiz.box = spi->lastRect;
} else {
bboxPtr->left = 1234;
bboxPtr->top = 1234;
@@ -1382,54 +1382,54 @@ void Sprite::processImages(bool arg) {
}
if (spi->palette) {
wiz.actionFlags |= kWAFPalette;
- wiz.img.palette = spi->palette;
+ wiz.palette = spi->palette;
}
if (spi->image && spi->group && _spriteGroups[spi->group].image) {
wiz.actionFlags |= kWAFDestImage;
- wiz.dstResNum = _spriteGroups[spi->group].image;
+ wiz.destImageNumber = _spriteGroups[spi->group].image;
}
- _vm->_wiz->displayWizComplexImage(&wiz);
+ _vm->_wiz->processWizImageDrawCmd(&wiz);
}
}
static void syncWithSerializer(Common::Serializer &s, SpriteInfo &si) {
s.syncAsSint32LE(si.id, VER(48));
- s.syncAsSint32LE(si.zorder, VER(48));
+ s.syncAsSint32LE(si.combinedPriority, VER(48));
s.syncAsSint32LE(si.flags, VER(48));
s.syncAsSint32LE(si.image, VER(48));
- s.syncAsSint32LE(si.imageState, VER(48));
+ s.syncAsSint32LE(si.state, VER(48));
s.syncAsSint32LE(si.group, VER(48));
s.syncAsSint32LE(si.palette, VER(48));
s.syncAsSint32LE(si.priority, VER(48));
- s.syncAsSint32LE(si.bbox.left, VER(48));
- s.syncAsSint32LE(si.bbox.top, VER(48));
- s.syncAsSint32LE(si.bbox.right, VER(48));
- s.syncAsSint32LE(si.bbox.bottom, VER(48));
- s.syncAsSint32LE(si.dx, VER(48));
- s.syncAsSint32LE(si.dy, VER(48));
- s.syncAsSint32LE(si.pos.x, VER(48));
- s.syncAsSint32LE(si.pos.y, VER(48));
- s.syncAsSint32LE(si.tx, VER(48));
- s.syncAsSint32LE(si.ty, VER(48));
+ s.syncAsSint32LE(si.lastRect.left, VER(48));
+ s.syncAsSint32LE(si.lastRect.top, VER(48));
+ s.syncAsSint32LE(si.lastRect.right, VER(48));
+ s.syncAsSint32LE(si.lastRect.bottom, VER(48));
+ s.syncAsSint32LE(si.deltaPosX, VER(48));
+ s.syncAsSint32LE(si.deltaPosY, VER(48));
+ s.syncAsSint32LE(si.lastSpot.x, VER(48));
+ s.syncAsSint32LE(si.lastSpot.y, VER(48));
+ s.syncAsSint32LE(si.posX, VER(48));
+ s.syncAsSint32LE(si.posY, VER(48));
s.syncAsSint32LE(si.userValue, VER(48));
- s.syncAsSint32LE(si.curImageState, VER(48));
- s.syncAsSint32LE(si.curImage, VER(48));
- s.syncAsSint32LE(si.imglistNum, VER(48));
+ s.syncAsSint32LE(si.lastState, VER(48));
+ s.syncAsSint32LE(si.lastImage, VER(48));
+ s.syncAsSint32LE(si.imageList, VER(48));
s.syncAsSint32LE(si.shadow, VER(48));
- s.syncAsSint32LE(si.imageStateCount, VER(48));
+ s.syncAsSint32LE(si.maxStates, VER(48));
s.syncAsSint32LE(si.angle, VER(48));
s.syncAsSint32LE(si.scale, VER(48));
- s.syncAsSint32LE(si.animProgress, VER(48));
- s.syncAsSint32LE(si.curAngle, VER(48));
- s.syncAsSint32LE(si.curScale, VER(48));
- s.syncAsSint32LE(si.curImgFlags, VER(48));
+ s.syncAsSint32LE(si.animState, VER(48));
+ s.syncAsSint32LE(si.lastAngle, VER(48));
+ s.syncAsSint32LE(si.lastScale, VER(48));
+ s.syncAsSint32LE(si.lastRenderFlags, VER(48));
s.syncAsSint32LE(si.animIndex, VER(48));
s.syncAsSint32LE(si.animSpeed, VER(48));
s.syncAsSint32LE(si.sourceImage, VER(48));
s.syncAsSint32LE(si.maskImage, VER(48));
s.syncAsSint32LE(si.zbufferImage, VER(48));
s.syncAsSint32LE(si.classFlags, VER(48));
- s.syncAsSint32LE(si.imgFlags, VER(48));
+ s.syncAsSint32LE(si.specialRenderFlags, VER(48));
s.syncAsSint32LE(si.conditionBits, VER(48));
}
diff --git a/engines/scumm/he/sprite_he.h b/engines/scumm/he/sprite_he.h
index 5a335fdc79e..552227af55c 100644
--- a/engines/scumm/he/sprite_he.h
+++ b/engines/scumm/he/sprite_he.h
@@ -27,23 +27,25 @@
namespace Scumm {
enum SpriteFlags {
- kSFChanged = 0x1,
- kSFNeedRedraw = 0x2,
- kSFScaled = 0x10,
- kSFRotated = 0x20,
- kSFDoubleBuffered = 0x1000,
- kSFYFlipped = 0x2000,
- kSFXFlipped = 0x4000,
- kSFActive = 0x8000,
- kSFRemapPalette = 0x80000,
- kSFAutoAnim = 0x200000,
- kSFMarkDirty = 0x400000,
- kSFBlitDirectly = 0x2000000,
- kSFImageless = 0x40000000
+ kSFErase = 0x00000001,
+ kSFRender = 0x00000002,
+ kSFScaleSpecified = 0x00000010,
+ kSFAngleSpecified = 0x00000020,
+ kSFBackgroundRender = 0x00001000,
+ kSFVFlip = 0x00002000,
+ kSFHFlip = 0x00004000,
+ kSFActive = 0x00008000,
+ kSFUseImageRemap = 0x00080000,
+ kSFAutoAnimate = 0x00200000,
+ kSFSmartRender = 0x00400000,
+ kSFDontAnimImageList = 0x01000000,
+ kSFDontCombineErase = 0x02000000,
+ kSFIgnoreRender = 0x20000000,
+ kSFIgnoreErase = 0x40000000
};
enum SpriteGroupFlags {
- kSGFClipBox = (1 << 0)
+ kSGFUseClipRect = (1 << 0)
};
enum SpritePropertySubOps {
@@ -87,74 +89,74 @@ enum PolygonOverlapSubOps {
struct SpriteInfo {
int32 id;
- int32 zorder;
+ int32 combinedPriority;
int32 flags;
int32 image;
- int32 imageState;
+ int32 state;
int32 group;
int32 palette;
int32 priority;
- Common::Rect bbox;
- int32 dx;
- int32 dy;
- Common::Point pos;
- int32 tx;
- int32 ty;
+ Common::Rect lastRect;
+ int32 deltaPosX;
+ int32 deltaPosY;
+ Common::Point lastSpot;
+ int32 posX;
+ int32 posY;
int32 userValue;
- int32 curImageState;
- int32 curImage;
- int32 imglistNum;
+ int32 lastState;
+ int32 lastImage;
+ int32 imageList;
int32 shadow;
- int32 imageStateCount;
+ int32 maxStates;
int32 angle;
int32 scale;
- int32 animProgress;
- int32 curAngle;
- int32 curScale;
- int32 curImgFlags;
+ int32 animState;
+ int32 lastAngle;
+ int32 lastScale;
+ int32 lastRenderFlags;
int32 animIndex;
int32 animSpeed;
int32 sourceImage;
int32 maskImage;
int32 zbufferImage;
int32 classFlags;
- int32 imgFlags;
+ int32 specialRenderFlags;
int32 conditionBits;
void reset() {
id = 0;
- zorder = 0;
+ combinedPriority = 0;
flags = 0;
image = 0;
- imageState = 0;
+ state = 0;
group = 0;
palette = 0;
priority = 0;
- bbox.top = bbox.left = bbox.bottom = bbox.right = 0;
- dx = 0;
- dy = 0;
- pos.x = pos.y = 0;
- tx = 0;
- ty = 0;
+ lastRect.top = lastRect.left = lastRect.bottom = lastRect.right = 0;
+ deltaPosX = 0;
+ deltaPosY = 0;
+ lastSpot.x = lastSpot.y = 0;
+ posX = 0;
+ posY = 0;
userValue = 0;
- curImageState = 0;
- curImage = 0;
- imglistNum = 0;
+ lastState = 0;
+ lastImage = 0;
+ imageList = 0;
shadow = 0;
- imageStateCount = 0;
+ maxStates = 0;
angle = 0;
scale = 0;
- animProgress = 0;
- curAngle = 0;
- curScale = 0;
- curImgFlags = 0;
+ animState = 0;
+ lastAngle = 0;
+ lastScale = 0;
+ lastRenderFlags = 0;
animIndex = 0;
animSpeed = 0;
sourceImage = 0;
maskImage = 0;
zbufferImage = 0;
classFlags = 0;
- imgFlags = 0;
+ specialRenderFlags = 0;
conditionBits = 0;
}
};
@@ -205,9 +207,9 @@ public:
void saveLoadWithSerializer(Common::Serializer &s) override;
void resetBackground();
- void setRedrawFlags(bool checkZOrder);
+ void checkForForcedRedraws(bool checkZOrder);
void sortActiveSprites();
- void processImages(bool arg);
+ void renderSprites(bool arg);
void updateImages();
int findSpriteWithClassOf(int x, int y, int spriteGroupId, int d, int num, int *args);
diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp
index f6a1eb3ac93..e5e25f86d26 100644
--- a/engines/scumm/he/wiz_he.cpp
+++ b/engines/scumm/he/wiz_he.cpp
@@ -35,15 +35,15 @@
namespace Scumm {
Wiz::Wiz(ScummEngine_v71he *vm) : _vm(vm) {
- _imagesNum = 0;
- memset(&_images, 0, sizeof(_images));
+ _wizBufferIndex = 0;
+ memset(&_wizBuffer, 0, sizeof(_wizBuffer));
memset(&_polygons, 0, sizeof(_polygons));
_cursorImage = false;
_rectOverrideEnabled = false;
}
void Wiz::clearWizBuffer() {
- _imagesNum = 0;
+ _wizBufferIndex = 0;
}
void Wiz::polygonClear() {
@@ -79,7 +79,7 @@ void Wiz::polygonLoad(const uint8 *polData) {
}
void Wiz::polygonStore(int id, bool flag, int vert1x, int vert1y, int vert2x, int vert2y, int vert3x, int vert3y, int vert4x, int vert4y) {
- WizPolygon *wp = NULL;
+ WizPolygon *wp = nullptr;
for (int i = 0; i < ARRAYSIZE(_polygons); ++i) {
if (_polygons[i].id == 0) {
wp = &_polygons[i];
@@ -374,11 +374,11 @@ void Wiz::copy16BitWizImage(uint8 *dst, const uint8 *src, int dstPitch, int dstT
Common::Rect r1, r2;
if (calcClipRects(dstw, dsth, srcx, srcy, srcw, srch, rect, r1, r2)) {
dst += r2.top * dstPitch + r2.left * 2;
- if (flags & kWIFFlipY) {
+ if (flags & kWRFFlipY) {
const int dy = (srcy < 0) ? srcy : (srch - r1.height());
r1.translate(0, dy);
}
- if (flags & kWIFFlipX) {
+ if (flags & kWRFFlipX) {
const int dx = (srcx < 0) ? srcx : (srcw - r1.width());
r1.translate(dx, 0);
}
@@ -395,20 +395,20 @@ void Wiz::copyWizImage(uint8 *dst, const uint8 *src, int dstPitch, int dstType,
Common::Rect r1, r2;
if (calcClipRects(dstw, dsth, srcx, srcy, srcw, srch, rect, r1, r2)) {
dst += r2.top * dstPitch + r2.left * bitDepth;
- if (flags & kWIFFlipY) {
+ if (flags & kWRFFlipY) {
const int dy = (srcy < 0) ? srcy : (srch - r1.height());
r1.translate(0, dy);
}
- if (flags & kWIFFlipX) {
+ if (flags & kWRFFlipX) {
const int dx = (srcx < 0) ? srcx : (srcw - r1.width());
r1.translate(dx, 0);
}
if (xmapPtr) {
decompressWizImage<kWizXMap>(dst, dstPitch, dstType, src, r1, flags, palPtr, xmapPtr, bitDepth);
} else if (palPtr) {
- decompressWizImage<kWizRMap>(dst, dstPitch, dstType, src, r1, flags, palPtr, NULL, bitDepth);
+ decompressWizImage<kWizRMap>(dst, dstPitch, dstType, src, r1, flags, palPtr, nullptr, bitDepth);
} else {
- decompressWizImage<kWizCopy>(dst, dstPitch, dstType, src, r1, flags, NULL, NULL, bitDepth);
+ decompressWizImage<kWizCopy>(dst, dstPitch, dstType, src, r1, flags, nullptr, nullptr, bitDepth);
}
}
}
@@ -456,11 +456,11 @@ void Wiz::copyMaskWizImage(uint8 *dst, const uint8 *src, const uint8 *mask, int
return;
}
dst += dstRect.top * dstPitch + dstRect.left * 2;
- if (flags & kWIFFlipY) {
+ if (flags & kWRFFlipY) {
const int dy = (srcy < 0) ? srcy : (srch - srcRect.height());
srcRect.translate(0, dy);
}
- if (flags & kWIFFlipX) {
+ if (flags & kWRFFlipX) {
const int dx = (srcx < 0) ? srcx : (srcw - srcRect.width());
srcRect.translate(dx, 0);
}
@@ -483,7 +483,7 @@ void Wiz::copyMaskWizImage(uint8 *dst, const uint8 *src, const uint8 *mask, int
return;
dstInc = 2;
- if (flags & kWIFFlipX) {
+ if (flags & kWRFFlipX) {
dstPtr += (w - 1) * 2;
dstInc = -2;
}
@@ -631,13 +631,13 @@ void Wiz::copyWizImageWithMask(uint8 *dst, const uint8 *src, int dstPitch, int d
void Wiz::copyRaw16BitWizImage(uint8 *dst, const uint8 *src, int dstPitch, int dstType, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, int transColor) {
Common::Rect r1, r2;
if (calcClipRects(dstw, dsth, srcx, srcy, srcw, srch, rect, r1, r2)) {
- if (flags & kWIFFlipX) {
+ if (flags & kWRFFlipX) {
int l = r1.left;
int r = r1.right;
r1.left = srcw - r;
r1.right = srcw - l;
}
- if (flags & kWIFFlipY) {
+ if (flags & kWRFFlipY) {
int t = r1.top;
int b = r1.bottom;
r1.top = srch - b;
@@ -664,13 +664,13 @@ void Wiz::copyRaw16BitWizImage(uint8 *dst, const uint8 *src, int dstPitch, int d
void Wiz::copyRawWizImage(uint8 *dst, const uint8 *src, int dstPitch, int dstType, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, const uint8 *palPtr, int transColor, uint8 bitDepth) {
Common::Rect r1, r2;
if (calcClipRects(dstw, dsth, srcx, srcy, srcw, srch, rect, r1, r2)) {
- if (flags & kWIFFlipX) {
+ if (flags & kWRFFlipX) {
int l = r1.left;
int r = r1.right;
r1.left = srcw - r;
r1.right = srcw - l;
}
- if (flags & kWIFFlipY) {
+ if (flags & kWRFFlipY) {
int t = r1.top;
int b = r1.bottom;
r1.top = srch - b;
@@ -683,7 +683,7 @@ void Wiz::copyRawWizImage(uint8 *dst, const uint8 *src, int dstPitch, int dstTyp
if (palPtr) {
decompressRawWizImage<kWizRMap>(dst, dstPitch, dstType, src, srcw, w, h, transColor, palPtr, bitDepth);
} else {
- decompressRawWizImage<kWizCopy>(dst, dstPitch, dstType, src, srcw, w, h, transColor, NULL, bitDepth);
+ decompressRawWizImage<kWizCopy>(dst, dstPitch, dstType, src, srcw, w, h, transColor, nullptr, bitDepth);
}
}
}
@@ -727,12 +727,12 @@ void Wiz::decompress16BitWizImage(uint8 *dst, int dstPitch, int dstType, const u
if (h <= 0 || w <= 0)
return;
- if (flags & kWIFFlipY) {
+ if (flags & kWRFFlipY) {
dstPtr += (h - 1) * dstPitch;
dstPitch = -dstPitch;
}
dstInc = 2;
- if (flags & kWIFFlipX) {
+ if (flags & kWRFFlipX) {
dstPtr += (w - 1) * 2;
dstInc = -2;
}
@@ -861,12 +861,12 @@ void Wiz::decompressWizImage(uint8 *dst, int dstPitch, int dstType, const uint8
if (h <= 0 || w <= 0)
return;
- if (flags & kWIFFlipY) {
+ if (flags & kWRFFlipY) {
dstPtr += (h - 1) * dstPitch;
dstPitch = -dstPitch;
}
dstInc = bitDepth;
- if (flags & kWIFFlipX) {
+ if (flags & kWRFFlipX) {
dstPtr += (w - 1) * bitDepth;
dstInc = -bitDepth;
}
@@ -1313,8 +1313,12 @@ static int wizPackType0(uint8 *dst, const uint8 *src, int srcPitch, const Common
return size;
}
-void Wiz::captureWizImage(int resNum, const Common::Rect& r, bool backBuffer, int compType) {
- uint8 *src = NULL;
+void Wiz::processWizImageCaptureCmd(const WizImageCommand *params) {
+ takeAWiz(params->image, params->box, (params->flags & kWRFBackground) != 0, params->compressionType);
+}
+
+void Wiz::takeAWiz(int resNum, const Common::Rect &r, bool backBuffer, int compType) {
+ uint8 *src = nullptr;
VirtScreen *pvs = &_vm->_virtscr[kMainVirtScreen];
if (backBuffer) {
src = pvs->getBackPixels(0, 0);
@@ -1413,34 +1417,40 @@ void Wiz::captureImage(uint8 *src, int srcPitch, int srcw, int srch, int resNum,
_vm->_res->setModified(rtImage, resNum);
}
-void Wiz::displayWizImage(WizImage *pwi) {
- if (_vm->_fullRedraw) {
- assert(_imagesNum < ARRAYSIZE(_images));
- WizImage *wi = &_images[_imagesNum];
- wi->resNum = pwi->resNum;
- wi->x1 = pwi->x1;
- wi->y1 = pwi->y1;
- wi->zorder = 0;
- wi->state = pwi->state;
- wi->flags = pwi->flags;
- wi->shadow = 0;
- wi->zbuffer = 0;
- wi->palette = 0;
- ++_imagesNum;
- } else if (pwi->flags & kWIFIsPolygon) {
- drawWizPolygon(pwi->resNum, pwi->state, pwi->x1, pwi->flags, 0, 0, 0);
+void Wiz::simpleDrawAWiz(int image, int state, int x, int y, int flags) {
+ if (!_vm->_fullRedraw) {
+ if (flags & kWRFIsPolygon) {
+ drawWizPolygon(image, state, x, flags, 0, 0, 0);
+ } else {
+ const Common::Rect *r = nullptr;
+ drawWizImage(image, state, 0, 0, x, y, 0, 0, 0, r, flags, 0, _vm->getHEPaletteSlot(0), 0);
+ }
} else {
- const Common::Rect *r = NULL;
- drawWizImage(pwi->resNum, pwi->state, 0, 0, pwi->x1, pwi->y1, 0, 0, 0, r, pwi->flags, 0, _vm->getHEPaletteSlot(0), 0);
+ bufferAWiz(image, state, x, y, 0, flags, 0, 0, 0);
}
}
+void Wiz::bufferAWiz(int image, int state, int x, int y, int z, int flags, int optionalShadowImage, int optionalZBufferImage, int whichPalette) {
+ assert(_wizBufferIndex < ARRAYSIZE(_wizBuffer));
+ WizBufferElement *wi = &_wizBuffer[_wizBufferIndex];
+ wi->image = image;
+ wi->x = x;
+ wi->y = y;
+ wi->z = z;
+ wi->state = state;
+ wi->flags = flags;
+ wi->shadow = optionalShadowImage;
+ wi->zbuffer = optionalZBufferImage;
+ wi->palette = whichPalette;
+ ++_wizBufferIndex;
+}
+
uint8 *Wiz::drawWizImage(int resNum, int state, int maskNum, int maskState, int x1, int y1, int zorder, int shadow, int zbuffer, const Common::Rect *clipBox, int flags, int dstResNum, const uint8 *palPtr, uint32 conditionBits) {
debug(7, "drawWizImage(resNum %d, state %d maskNum %d maskState %d x1 %d y1 %d flags 0x%X zorder %d shadow %d zbuffer %d dstResNum %d conditionBits: 0x%x)", resNum, state, maskNum, maskState, x1, y1, flags, zorder, shadow, zbuffer, dstResNum, conditionBits);
uint8 *dataPtr;
- uint8 *dst = NULL;
+ uint8 *dst = nullptr;
- const uint8 *xmapPtr = NULL;
+ const uint8 *xmapPtr = nullptr;
if (shadow) {
dataPtr = _vm->getResourceAddress(rtImage, shadow);
assert(dataPtr);
@@ -1479,7 +1489,7 @@ uint8 *Wiz::drawWizImage(int resNum, int state, int maskNum, int maskState, int
_vm->setPaletteFromPtr(pal, 256);
}
- uint8 *rmap = NULL;
+ uint8 *rmap = nullptr;
if (flags & kWRFRemap) {
rmap = _vm->findWrappedBlock(MKTAG('R','M','A','P'), dataPtr, state, 0);
assert(rmap);
@@ -1570,7 +1580,7 @@ uint8 *Wiz::drawWizImage(int resNum, int state, int maskNum, int maskState, int
int transColor = -1;
if (_vm->VAR_WIZ_TCOLOR != 0xFF) {
uint8 *trns = _vm->findWrappedBlock(MKTAG('T','R','N','S'), dataPtr, state, 0);
- transColor = (trns == NULL) ? _vm->VAR(_vm->VAR_WIZ_TCOLOR) : -1;
+ transColor = (trns == nullptr) ? _vm->VAR(_vm->VAR_WIZ_TCOLOR) : -1;
}
if (_vm->_game.id == GID_MOONBASE &&
@@ -1615,15 +1625,15 @@ void Wiz::drawWizImageEx(uint8 *dst, uint8 *dataPtr, uint8 *maskPtr, int dstPitc
assert(wizd);
switch (comp) {
- case 0:
+ case kWCTNone:
copyRawWizImage(dst, wizd, dstPitch, dstType, dstw, dsth, srcx, srcy, srcw, srch, rect, flags, palPtr, transColor, bitDepth);
break;
- case 1:
- if (flags & kWIFZPlaneOn) {
+ case kWCTTRLE:
+ if (flags & kWRFZPlaneOn) {
dst = _vm->getMaskBuffer(0, 0, 1);
dstPitch /= _vm->_bytesPerPixel;
copyWizImageWithMask(dst, wizd, dstPitch, dstw, dsth, srcx, srcy, srcw, srch, rect, 0, 2);
- } else if (flags & kWIFZPlaneOff) {
+ } else if (flags & kWRFZPlaneOff) {
dst = _vm->getMaskBuffer(0, 0, 1);
dstPitch /= _vm->_bytesPerPixel;
copyWizImageWithMask(dst, wizd, dstPitch, dstw, dsth, srcx, srcy, srcw, srch, rect, 0, 1);
@@ -1632,20 +1642,20 @@ void Wiz::drawWizImageEx(uint8 *dst, uint8 *dataPtr, uint8 *maskPtr, int dstPitc
}
break;
#ifdef USE_RGB_COLOR
- case 2:
+ case kWCTNone16Bpp:
if (maskPtr) {
copyMaskWizImage(dst, wizd, maskPtr, dstPitch, dstType, dstw, dsth, srcx, srcy, srcw, srch, rect, flags, palPtr);
} else {
copyRaw16BitWizImage(dst, wizd, dstPitch, dstType, dstw, dsth, srcx, srcy, srcw, srch, rect, flags, transColor);
}
break;
- case 4:
+ case kWCTComposite:
copyCompositeWizImage(dst, dataPtr, wizd, maskPtr, dstPitch, dstType, dstw, dsth, srcx, srcy, srcw, srch, state, rect, flags, palPtr, transColor, bitDepth, xmapPtr, conditionBits);
break;
- case 5:
+ case kWCTTRLE16Bpp:
copy16BitWizImage(dst, wizd, dstPitch, dstType, dstw, dsth, srcx, srcy, srcw, srch, rect, flags, xmapPtr);
break;
- case 9:
+ case kWCTDataBlockDependent:
copy555WizImage(dst, wizd, dstPitch, dstType, dstw, dsth, srcx, srcy, rect, conditionBits);
break;
#endif
@@ -1750,17 +1760,17 @@ void Wiz::copyCompositeWizImage(uint8 *dst, uint8 *wizPtr, uint8 *compositeInfoB
}
uint srcw1 = 0, srch1 = 0;
- if (drawFlags & (kWIFFlipX | kWIFFlipY)) {
+ if (drawFlags & (kWRFFlipX | kWRFFlipY)) {
uint8 *wizh = _vm->findWrappedBlock(MKTAG('W','I','Z','H'), wizPtr, subState, 0);
assert(wizh);
srcw1 = READ_LE_UINT32(wizh + 0x4);
srch1 = READ_LE_UINT32(wizh + 0x8);
}
- if (drawFlags & kWIFFlipX)
+ if (drawFlags & kWRFFlipX)
xPos = (srcw - (xPos + srcw1));
- if (drawFlags & kWIFFlipY)
+ if (drawFlags & kWRFFlipY)
yPos = (srch - (yPos + srch1));
if (layerCmdDataBits & kWCFSubConditionBits) {
@@ -1908,13 +1918,20 @@ struct PolygonDrawData {
}
};
-void Wiz::captureWizPolygon(int resNum, int maskNum, int maskState, int id1, int id2, int compType) {
- debug(7, "captureWizPolygon: resNum %d, maskNum %d maskState %d, id1 %d id2 %d compType %d", resNum, maskNum, maskState, id1, id2, compType);
+void Wiz::processWizImagePolyCaptureCmd(const WizImageCommand *params) {
+ int resNum = params->image;
+ int maskNum = params->sourceImage;
+ bool maskState = (params->actionFlags & kWAFState) ? params->state : 0;
+ int id1 = params->polygon;
+ int id2 = params->polygon2;
+ int compType = params->compressionType;
+
+ debug(7, "processWizImagePolyCaptureCmd: resNum %d, maskNum %d maskState %d, id1 %d id2 %d compType %d", resNum, maskNum, maskState, id1, id2, compType);
int i, j;
WizPolygon *wp;
- wp = NULL;
+ wp = nullptr;
for (i = 0; i < ARRAYSIZE(_polygons); ++i) {
if (_polygons[i].id == id1) {
wp = &_polygons[i];
@@ -1928,7 +1945,7 @@ void Wiz::captureWizPolygon(int resNum, int maskNum, int maskState, int id1, int
error("Invalid point count %d for Polygon1 %d", wp->numVerts, id1);
}
- wp = NULL;
+ wp = nullptr;
for (i = 0; i < ARRAYSIZE(_polygons); ++i) {
if (_polygons[i].id == id2) {
wp = &_polygons[i];
@@ -1947,7 +1964,7 @@ void Wiz::captureWizPolygon(int resNum, int maskNum, int maskState, int id1, int
uint8 *imageBuffer;
assert(maskNum);
- const Common::Rect *r = NULL;
+ const Common::Rect *r = nullptr;
const uint8 *src = drawWizImage(maskNum, maskState, 0, 0, 0, 0, 0, 0, 0, r, kWRFAlloc, 0, 0, 0);
getWizImageDim(maskNum, maskState, srcw, srch);
@@ -1970,7 +1987,7 @@ void Wiz::captureWizPolygon(int resNum, int maskNum, int maskState, int id1, int
}
Common::Rect bound;
- drawWizPolygonImage(imageBuffer, src, NULL, dstpitch, kDstMemory, dstw, dsth, srcw, srch, bound, wp->vert, _vm->_bytesPerPixel);
+ drawWizPolygonImage(imageBuffer, src, nullptr, dstpitch, kDstMemory, dstw, dsth, srcw, srch, bound, wp->vert, _vm->_bytesPerPixel);
captureImage(imageBuffer, dstpitch, dstw, dsth, resNum, wp->bound, compType);
free(imageBuffer);
@@ -1985,7 +2002,7 @@ void Wiz::drawWizComplexPolygon(int resNum, int state, int po_x, int po_y, int s
void Wiz::drawWizPolygon(int resNum, int state, int id, int flags, int shadow, int dstResNum, int palette) {
int i;
- WizPolygon *wp = NULL;
+ WizPolygon *wp = nullptr;
for (i = 0; i < ARRAYSIZE(_polygons); ++i) {
if (_polygons[i].id == id) {
wp = &_polygons[i];
@@ -2004,16 +2021,16 @@ void Wiz::drawWizPolygon(int resNum, int state, int id, int flags, int shadow, i
void Wiz::drawWizPolygonTransform(int resNum, int state, Common::Point *wp, int flags, int shadow, int dstResNum, int palette) {
debug(7, "drawWizPolygonTransform(resNum %d, flags 0x%X, shadow %d dstResNum %d palette %d)", resNum, flags, shadow, dstResNum, palette);
- const Common::Rect *r = NULL;
- uint8 *srcWizBuf = NULL;
+ const Common::Rect *r = nullptr;
+ uint8 *srcWizBuf = nullptr;
bool freeBuffer = true;
if (_vm->_game.heversion >= 99) {
- if (getWizImageData(resNum, state, 0) != 0 || (flags & (kWRFRemap | kWIFFlipX | kWIFFlipY)) || palette != 0) {
+ if (getWizImageData(resNum, state, 0) != 0 || (flags & (kWRFRemap | kWRFFlipX | kWRFFlipY)) || palette != 0) {
flags |= kWRFAlloc;
- if (flags & 0x800000) {
- debug(7, "drawWizPolygonTransform() unhandled flag 0x800000");
+ if (flags & kWRFAreaSampleDuringWarp) {
+ debug(7, "drawWizPolygonTransform() unhandled flag kWRFAreaSampleDuringWarp");
}
srcWizBuf = drawWizImage(resNum, state, 0, 0, 0, 0, 0, shadow, 0, r, flags, 0, _vm->getHEPaletteSlot(palette), 0);
@@ -2196,16 +2213,16 @@ void Wiz::drawWizPolygonImage(uint8 *dst, const uint8 *src, const uint8 *mask, i
}
void Wiz::flushWizBuffer() {
- for (int i = 0; i < _imagesNum; ++i) {
- WizImage *pwi = &_images[i];
- if (pwi->flags & kWIFIsPolygon) {
- drawWizPolygon(pwi->resNum, pwi->state, pwi->x1, pwi->flags, pwi->shadow, 0, pwi->palette);
+ for (int i = 0; i < _wizBufferIndex; ++i) {
+ WizBufferElement *pwi = &_wizBuffer[i];
+ if (pwi->flags & kWRFIsPolygon) {
+ drawWizPolygon(pwi->image, pwi->state, pwi->x, pwi->flags, pwi->shadow, 0, pwi->palette);
} else {
- const Common::Rect *r = NULL;
- drawWizImage(pwi->resNum, pwi->state, 0, 0, pwi->x1, pwi->y1, pwi->zorder, pwi->shadow, pwi->zbuffer, r, pwi->flags, 0, _vm->getHEPaletteSlot(pwi->palette), 0);
+ const Common::Rect *r = nullptr;
+ drawWizImage(pwi->image, pwi->state, 0, 0, pwi->x, pwi->y, pwi->z, pwi->shadow, pwi->zbuffer, r, pwi->flags, 0, _vm->getHEPaletteSlot(pwi->palette), 0);
}
}
- _imagesNum = 0;
+ _wizBufferIndex = 0;
}
void Wiz::loadWizCursor(int resId, int palette) {
@@ -2222,7 +2239,7 @@ void Wiz::loadWizCursor(int resId, int palette) {
y = 32;
}
- const Common::Rect *r = NULL;
+ const Common::Rect *r = nullptr;
_cursorImage = true;
uint8 *cursor = drawWizImage(resId, 0, 0, 0, 0, 0, 0, 0, 0, r, kWRFAlloc, 0, _vm->getHEPaletteSlot(palette), 0);
_cursorImage = false;
@@ -2238,106 +2255,160 @@ void Wiz::loadWizCursor(int resId, int palette) {
free(cursor);
}
-void Wiz::displayWizComplexImage(const WizParameters *params) {
- int sourceImage = 0;
+#define ADD_REQUIRED_IMAGE(whatImageIsRequired) { \
+ if (ARRAYSIZE(requiredImages) <= (requiredImageCount + 1)) { \
+ error("Wiz::processWizImageDrawCmd(): Too many required images for image operation (limit %d).", ARRAYSIZE(requiredImages)); \
+ } \
+ requiredImages[requiredImageCount] = whatImageIsRequired; \
+ ++requiredImageCount; \
+}
+
+void Wiz::processWizImageDrawCmd(const WizImageCommand *params) {
+ int requiredImages[5];
+ int requiredImageCount = 0;
+ int sourceImage, palette, scale, rotationAngle, state, flags, po_x, po_y, shadow;
+ int zbuffer = 0;
+ int dstResNum = 0;
+ const Common::Rect *r;
+
+ ADD_REQUIRED_IMAGE(params->image);
+
if (params->actionFlags & kWAFSourceImg) {
sourceImage = params->sourceImage;
- debug(7, "displayWizComplexImage() flag kWAFSourceImg");
+ ADD_REQUIRED_IMAGE(sourceImage);
+ } else {
+ sourceImage = 0;
}
- int palette = 0;
+
if (params->actionFlags & kWAFPalette) {
- palette = params->img.palette;
+ palette = params->palette;
+ } else {
+ palette = 0;
}
- int scale = 256;
- if (params->actionFlags & kWAFScaled) {
+
+ if (params->actionFlags & kWAFScale) {
scale = params->scale;
+ } else {
+ scale = 256;
}
- int rotationAngle = 0;
- if (params->actionFlags & kWAFRotate) {
+
+ if (params->actionFlags & kWAFAngle) {
rotationAngle = params->angle;
+ } else {
+ rotationAngle = 0;
}
- int state = 0;
+
if (params->actionFlags & kWAFState) {
- state = params->img.state;
+ state = params->state;
+ } else {
+ state = 0;
}
- int flags = 0;
+
if (params->actionFlags & kWAFFlags) {
- flags = params->img.flags;
+ flags = params->flags;
+ } else {
+ flags = 0;
}
- int po_x = 0;
- int po_y = 0;
+
if (params->actionFlags & kWAFSpot) {
- po_x = params->img.x1;
- po_y = params->img.y1;
+ po_x = params->xPos;
+ po_y = params->yPos;
+ } else {
+ po_x = 0;
+ po_y = 0;
}
- int shadow = 0;
+
if (params->actionFlags & kWAFShadow) {
- shadow = params->img.shadow;
+ shadow = params->shadow;
+ ADD_REQUIRED_IMAGE(shadow);
+ } else {
+ shadow = 0;
}
- int zbuffer = 0;
+
if (params->actionFlags & kWAFZBufferImage) {
- zbuffer = params->img.zbuffer;
- debug(7, "displayWizComplexImage() unhandled flag kWAFZBufferImage");
+ zbuffer = params->zbufferImage;
+ ADD_REQUIRED_IMAGE(zbuffer);
}
- const Common::Rect *r = NULL;
+
if (params->actionFlags & kWAFRect) {
r = ¶ms->box;
+ } else {
+ r = nullptr;
}
- int dstResNum = 0;
+
if (params->actionFlags & kWAFDestImage) {
- dstResNum = params->dstResNum;
+ dstResNum = params->destImageNumber;
+ ADD_REQUIRED_IMAGE(dstResNum);
}
+
+ if (requiredImageCount > 0) {
+ // TODO
+ }
+
+ // TODO:
+ //if (params->actionFlags & kWAFDestImage) {
+ // // Get the rendering surface for this image
+ // if (!DW_SetSimpleBitmapStructFromImage(params->destImageNumber, 0, &fakeBitmap)) {
+ // error("Image %d is invalid for rendering into", params->destImageNumber);
+ // }
+ //
+ // destBitmap = &fakeBitmap;
+ //} else {
+ // destBitmap = nullptr;
+ //}
+
if (_vm->_game.heversion >= 99 && params->actionFlags & kWAFRemapList) {
- remapWizImagePal(params);
+ processWizImageModifyCmd(params);
flags |= kWRFRemap;
}
- if (_vm->_fullRedraw && dstResNum == 0) {
- if (sourceImage != 0 || (params->actionFlags & (kWAFScaled | kWAFRotate)))
- error("Can't do this command in the enter script");
+ // Dispatch the command...
- assert(_imagesNum < ARRAYSIZE(_images));
- WizImage *pwi = &_images[_imagesNum];
- pwi->resNum = params->img.resNum;
- pwi->x1 = po_x;
- pwi->y1 = po_y;
- pwi->zorder = params->img.zorder;
- pwi->state = state;
- pwi->flags = flags;
- pwi->shadow = shadow;
- pwi->zbuffer = zbuffer;
- pwi->palette = palette;
- ++_imagesNum;
- } else {
+ if (!_vm->_fullRedraw || dstResNum != 0) {
if (sourceImage != 0) {
- drawWizImage(params->sourceImage, 0, params->img.resNum, state, po_x, po_y, params->img.zorder, shadow, zbuffer, r, flags, dstResNum, _vm->getHEPaletteSlot(palette), 0);
- } else if (params->actionFlags & (kWAFScaled | kWAFRotate)) {
- drawWizComplexPolygon(params->img.resNum, state, po_x, po_y, shadow, rotationAngle, scale, r, flags, dstResNum, palette);
+ drawWizImage(params->sourceImage, 0, params->image, state, po_x, po_y, params->zPos, shadow, zbuffer, r, flags, dstResNum, _vm->getHEPaletteSlot(palette), 0);
} else {
- if (flags & kWIFIsPolygon) {
- drawWizPolygon(params->img.resNum, state, po_x, flags, shadow, dstResNum, palette);
+ if (params->actionFlags & (kWAFScale | kWAFAngle)) {
+ drawWizComplexPolygon(params->image, state, po_x, po_y, shadow, rotationAngle, scale, r, flags, dstResNum, palette);
} else {
- drawWizImage(params->img.resNum, state, 0, 0, po_x, po_y, params->img.zorder, shadow, zbuffer, r, flags, dstResNum, _vm->getHEPaletteSlot(palette), params->conditionBits);
+ if (flags & kWRFIsPolygon) {
+ drawWizPolygon(params->image, state, po_x, flags, shadow, dstResNum, palette);
+ } else {
+ drawWizImage(params->image, state, 0, 0, po_x, po_y, params->zPos, shadow, zbuffer, r, flags, dstResNum, _vm->getHEPaletteSlot(palette), params->extendedRenderInfo.conditionBits);
+ }
}
}
+ } else {
+ if (sourceImage != 0 || (params->actionFlags & (kWAFScale | kWAFAngle)))
+ error("Can't do this command in the enter script");
+
+ bufferAWiz(params->image, state, po_x, po_y, params->zPos, flags, shadow, zbuffer, palette);
}
}
-void Wiz::createWizEmptyImage(int resNum, int img_x, int img_y, int img_w, int img_h) {
- const uint16 flags = 0xB;
- const uint8 compType = (_vm->_game.features & GF_16BIT_COLOR) ? 2 : 0;
- const uint8 bitDepth = (_vm->_game.features & GF_16BIT_COLOR) ? 2 : 1;
- int res_size = 0x1C;
- if (flags & 1) {
- res_size += 0x308;
+#undef ADD_REQUIRED_IMAGE
+
+void Wiz::dwCreateRawWiz(int imageNum, int w, int h, int flags, int bitsPerPixel, int optionalSpotX, int optionalSpotY) {
+ int compressionType, wizdSize;
+ int globSize = 8; // AWIZ header size
+
+ globSize += WIZBLOCK_WIZH_SIZE;
+
+ if (flags & kCWFPalette) {
+ globSize += WIZBLOCK_RGBS_SIZE;
}
- if (flags & 2) {
- res_size += 0x10;
+
+ if (flags & kCWFSpot) {
+ globSize += WIZBLOCK_SPOT_SIZE;
}
- if (flags & 8) {
- res_size += 0x10C;
+
+ if (flags & kCWFRemapTable) {
+ globSize += WIZBLOCK_RMAP_SIZE;
}
- res_size += 8 + img_w * img_h * bitDepth;
+
+ globSize += 8; // WIZD header size
+ wizdSize = w * h * (bitsPerPixel / 8);
+ globSize += wizdSize;
const uint8 *palPtr;
if (_vm->_game.heversion >= 99) {
@@ -2345,49 +2416,76 @@ void Wiz::createWizEmptyImage(int resNum, int img_x, int img_y, int img_w, int i
} else {
palPtr = _vm->_currentPalette;
}
- uint8 *res_data = _vm->_res->createResource(rtImage, resNum, res_size);
- if (!res_data) {
+
+ uint8 *writePtr = _vm->_res->createResource(rtImage, imageNum, globSize);
+
+ if (!writePtr) {
_vm->VAR(_vm->VAR_OPERATION_FAILURE) = -1;
+ return;
} else {
_vm->VAR(_vm->VAR_OPERATION_FAILURE) = 0;
- WRITE_BE_UINT32(res_data, 'AWIZ'); res_data += 4;
- WRITE_BE_UINT32(res_data, res_size); res_data += 4;
- WRITE_BE_UINT32(res_data, 'WIZH'); res_data += 4;
- WRITE_BE_UINT32(res_data, 0x14); res_data += 4;
- WRITE_LE_UINT32(res_data, compType); res_data += 4;
- WRITE_LE_UINT32(res_data, img_w); res_data += 4;
- WRITE_LE_UINT32(res_data, img_h); res_data += 4;
- if (flags & 1) {
- WRITE_BE_UINT32(res_data, 'RGBS'); res_data += 4;
- WRITE_BE_UINT32(res_data, 0x308); res_data += 4;
- memcpy(res_data, palPtr, 0x300); res_data += 0x300;
- }
- if (flags & 2) {
- WRITE_BE_UINT32(res_data, 'SPOT'); res_data += 4;
- WRITE_BE_UINT32(res_data, 0x10); res_data += 4;
- WRITE_BE_UINT32(res_data, img_x); res_data += 4;
- WRITE_BE_UINT32(res_data, img_y); res_data += 4;
- }
- if (flags & 8) {
- WRITE_BE_UINT32(res_data, 'RMAP'); res_data += 4;
- WRITE_BE_UINT32(res_data, 0x10C); res_data += 4;
- WRITE_BE_UINT32(res_data, 0); res_data += 4;
- for (int i = 0; i < 256; ++i) {
- *res_data++ = i;
- }
+ }
+
+ switch (bitsPerPixel) {
+ case 8:
+ compressionType = kWCTNone;
+ break;
+ case 16:
+ compressionType = kWCTNone16Bpp;
+ break;
+ case 32:
+ compressionType = kWCTNone32Bpp;
+ break;
+ default:
+ error("Unsupported image bits size %d", bitsPerPixel);
+ break;
+ }
+
+ WRITE_BE_UINT32(writePtr, 'AWIZ'); writePtr += 4;
+ WRITE_BE_UINT32(writePtr, globSize); writePtr += 4;
+ WRITE_BE_UINT32(writePtr, 'WIZH'); writePtr += 4;
+ WRITE_BE_UINT32(writePtr, WIZBLOCK_WIZH_SIZE); writePtr += 4;
+ WRITE_LE_UINT32(writePtr, compressionType); writePtr += 4;
+ WRITE_LE_UINT32(writePtr, w); writePtr += 4;
+ WRITE_LE_UINT32(writePtr, h); writePtr += 4;
+
+ if (flags & kCWFPalette) {
+ WRITE_BE_UINT32(writePtr, 'RGBS'); writePtr += 4;
+ WRITE_BE_UINT32(writePtr, WIZBLOCK_RGBS_SIZE); writePtr += 4;
+ memcpy(writePtr, palPtr, WIZBLOCK_RGBS_DATA_SIZE);
+
+ writePtr += WIZBLOCK_RGBS_DATA_SIZE;
+ }
+
+ if (flags & kCWFSpot) {
+ WRITE_BE_UINT32(writePtr, 'SPOT'); writePtr += 4;
+ WRITE_BE_UINT32(writePtr, WIZBLOCK_SPOT_SIZE); writePtr += 4;
+ WRITE_BE_UINT32(writePtr + 0, optionalSpotX);
+ WRITE_BE_UINT32(writePtr + 4, optionalSpotY);
+
+ writePtr += WIZBLOCK_SPOT_DATA_SIZE;
+ }
+
+ if (flags & kCWFRemapTable) {
+ WRITE_BE_UINT32(writePtr, 'RMAP'); writePtr += 4;
+ WRITE_BE_UINT32(writePtr, WIZBLOCK_RMAP_SIZE); writePtr += 4;
+ WRITE_BE_UINT32(writePtr, 0); writePtr += 4;
+
+ for (int i = 0; i < 256; ++i) {
+ *writePtr++ = i;
}
- WRITE_BE_UINT32(res_data, 'WIZD'); res_data += 4;
- WRITE_BE_UINT32(res_data, 8 + img_w * img_h * bitDepth); res_data += 4;
}
- _vm->_res->setModified(rtImage, resNum);
+
+ WRITE_BE_UINT32(writePtr, 'WIZD'); writePtr += 4;
+ WRITE_BE_UINT32(writePtr, 8 + wizdSize); writePtr += 4;
}
-void Wiz::fillWizRect(const WizParameters *params) {
+void Wiz::processWizImageRenderRectCmd(const WizImageCommand *params) {
int state = 0;
if (params->actionFlags & kWAFState) {
- state = params->img.state;
+ state = params->state;
}
- uint8 *dataPtr = _vm->getResourceAddress(rtImage, params->img.resNum);
+ uint8 *dataPtr = _vm->getResourceAddress(rtImage, params->image);
if (dataPtr) {
uint8 *wizh = _vm->findWrappedBlock(MKTAG('W','I','Z','H'), dataPtr, state, 0);
assert(wizh);
@@ -2410,7 +2508,7 @@ void Wiz::fillWizRect(const WizParameters *params) {
}
uint16 color = _vm->VAR(93);
if (params->actionFlags & kWAFColor) {
- color = params->fillColor;
+ color = params->colorValue;
}
if (areaRect.intersects(imageRect)) {
areaRect.clip(imageRect);
@@ -2430,7 +2528,7 @@ void Wiz::fillWizRect(const WizParameters *params) {
}
}
}
- _vm->_res->setModified(rtImage, params->img.resNum);
+ _vm->_res->setModified(rtImage, params->image);
}
struct drawProcP {
@@ -2452,13 +2550,13 @@ static void drawProc(int x, int y, int c, void *data) {
}
}
-void Wiz::fillWizLine(const WizParameters *params) {
+void Wiz::processWizImageRenderLineCmd(const WizImageCommand *params) {
if (params->actionFlags & kWAFRenderCoords) {
int state = 0;
if (params->actionFlags & kWAFState) {
- state = params->img.state;
+ state = params->state;
}
- uint8 *dataPtr = _vm->getResourceAddress(rtImage, params->img.resNum);
+ uint8 *dataPtr = _vm->getResourceAddress(rtImage, params->image);
if (dataPtr) {
uint8 *wizh = _vm->findWrappedBlock(MKTAG('W','I','Z','H'), dataPtr, state, 0);
assert(wizh);
@@ -2476,7 +2574,7 @@ void Wiz::fillWizLine(const WizParameters *params) {
}
uint16 color = _vm->VAR(93);
if (params->actionFlags & kWAFColor) {
- color = params->fillColor;
+ color = params->colorValue;
}
uint8 *wizd = _vm->findWrappedBlock(MKTAG('W','I','Z','D'), dataPtr, state, 0);
assert(wizd);
@@ -2499,18 +2597,18 @@ void Wiz::fillWizLine(const WizParameters *params) {
}
}
}
- _vm->_res->setModified(rtImage, params->img.resNum);
+ _vm->_res->setModified(rtImage, params->image);
}
-void Wiz::fillWizPixel(const WizParameters *params) {
+void Wiz::processWizImageRenderPixelCmd(const WizImageCommand *params) {
if (params->actionFlags & kWAFRenderCoords) {
int px = params->renderCoords.left;
int py = params->renderCoords.top;
- uint8 *dataPtr = _vm->getResourceAddress(rtImage, params->img.resNum);
+ uint8 *dataPtr = _vm->getResourceAddress(rtImage, params->image);
if (dataPtr) {
int state = 0;
if (params->actionFlags & kWAFState) {
- state = params->img.state;
+ state = params->state;
}
uint8 *wizh = _vm->findWrappedBlock(MKTAG('W','I','Z','H'), dataPtr, state, 0);
assert(wizh);
@@ -2527,7 +2625,7 @@ void Wiz::fillWizPixel(const WizParameters *params) {
}
uint16 color = _vm->VAR(93);
if (params->actionFlags & kWAFColor) {
- color = params->fillColor;
+ color = params->colorValue;
}
if (imageRect.contains(px, py)) {
uint8 *wizd = _vm->findWrappedBlock(MKTAG('W','I','Z','D'), dataPtr, state, 0);
@@ -2536,14 +2634,14 @@ void Wiz::fillWizPixel(const WizParameters *params) {
}
}
}
- _vm->_res->setModified(rtImage, params->img.resNum);
+ _vm->_res->setModified(rtImage, params->image);
}
-void Wiz::remapWizImagePal(const WizParameters *params) {
- int st = (params->actionFlags & kWAFState) ? params->img.state : 0;
- int num = params->remapNum;
+void Wiz::processWizImageModifyCmd(const WizImageCommand *params) {
+ int st = (params->actionFlags & kWAFState) ? params->state : 0;
+ int num = params->remapCount;
const uint8 *index = params->remapList;
- uint8 *iwiz = _vm->getResourceAddress(rtImage, params->img.resNum);
+ uint8 *iwiz = _vm->getResourceAddress(rtImage, params->image);
assert(iwiz);
uint8 *rmap = _vm->findWrappedBlock(MKTAG('R','M','A','P'), iwiz, st, 0);
assert(rmap);
@@ -2552,153 +2650,217 @@ void Wiz::remapWizImagePal(const WizParameters *params) {
uint8 idx = *index++;
rmap[4 + idx] = params->remapTable[idx];
}
- _vm->_res->setModified(rtImage, params->img.resNum);
+ _vm->_res->setModified(rtImage, params->image);
}
-void Wiz::processWizImage(const WizParameters *params) {
- debug(7, "processWizImage: actionMode %d", params->actionMode);
- switch (params->actionMode) {
- case kWAUnknown:
- // Used in racedemo
- break;
- case kWADraw:
- displayWizComplexImage(params);
- break;
- case kWACapture:
- captureWizImage(params->img.resNum, params->box, (params->img.flags & kWRFBackground) != 0, params->compressionType);
- break;
- case kWALoad:
- if (params->actionFlags & kWAFFilename) {
- Common::SeekableReadStream *f = _vm->openFileForReading(params->filename);
-
- if (f) {
- uint32 id = f->readUint32BE();
- if (id == MKTAG('A','W','I','Z') || id == MKTAG('M','U','L','T')) {
- uint32 size = f->readUint32BE();
- f->seek(0, SEEK_SET);
- byte *p = _vm->_res->createResource(rtImage, params->img.resNum, size);
- if (f->read(p, size) != size) {
- _vm->_res->nukeResource(rtImage, params->img.resNum);
- error("i/o error when reading '%s'", params->filename);
- _vm->VAR(_vm->VAR_GAME_LOADED) = -2;
- _vm->VAR(_vm->VAR_OPERATION_FAILURE) = -2;
- } else {
- _vm->_res->setModified(rtImage, params->img.resNum);
- _vm->VAR(_vm->VAR_GAME_LOADED) = 0;
- _vm->VAR(_vm->VAR_OPERATION_FAILURE) = 0;
- }
+void Wiz::processWizImageRenderEllipseCmd(const WizImageCommand *params) {
+ // Used in to draw circles in FreddisFunShop/PuttsFunShop/SamsFunShop
+ // TODO: Ellipse
+ _vm->_res->setModified(rtImage, params->image);
+}
+
+void Wiz::processWizImageFontStartCmd(const WizImageCommand *params) {
+ // Used for text in FreddisFunShop/PuttsFunShop/SamsFunShop
+ // TODO: Start Font
+}
+
+void Wiz::processWizImageFontEndCmd(const WizImageCommand *params) {
+ // Used for text in FreddisFunShop/PuttsFunShop/SamsFunShop
+ // TODO: End Font
+}
+
+void Wiz::processWizImageFontCreateCmd(const WizImageCommand *params) {
+ // Used for text in FreddisFunShop/PuttsFunShop/SamsFunShop
+ // TODO: Create Font
+}
+
+void Wiz::processWizImageFontRenderCmd(const WizImageCommand *params) {
+ // TODO: Render Font String
+ error("Wiz::processWizImageFontRenderCmd(): Render Font String");
+}
+
+void Wiz::processNewWizImageCmd(const WizImageCommand *params) {
+ int width, height;
+ int propertyNumber = 0, propertyValue = 0;
+ int hotspotX, hotspotY;
+
+ if (params->actionFlags & kWAFWidth) {
+ width = params->width;
+ } else {
+ width = 640;
+ }
+
+ if (params->actionFlags & kWAFHeight) {
+ height = params->height;
+ } else {
+ height = 480;
+ }
+
+ if (params->actionFlags & kWAFSpot) {
+ hotspotX = params->xPos;
+ hotspotY = params->yPos;
+ } else {
+ hotspotX = 0;
+ hotspotY = 0;
+ }
+
+ // Determine pixel depth...
+ if (params->actionFlags & kWAFProperty) {
+ propertyNumber = params->propertyNumber;
+ propertyValue = params->propertyValue;
+ }
+
+ int pixelDepth = 8;
+ if (propertyNumber == 1) {
+ pixelDepth = propertyValue;
+
+ if ((pixelDepth != 16) && (pixelDepth != 8)) {
+ error("Wiz::processNewWizImageCmd(): Currently the only pixel depths supported for a new image are 16 and 8. You picked %d.\n", pixelDepth);
+ }
+ }
+
+ dwCreateRawWiz(params->image, width, height, kCWFDefault, pixelDepth, hotspotX, hotspotY);
+
+ _vm->_res->setModified(rtImage, params->image);
+}
+
+void Wiz::processWizImageLoadCmd(const WizImageCommand *params) {
+ if (params->actionFlags & kWAFFilename) {
+ Common::SeekableReadStream *f = _vm->openFileForReading(params->filename);
+
+ if (f) {
+ uint32 id = f->readUint32BE();
+
+ if (id == MKTAG('A', 'W', 'I', 'Z') || id == MKTAG('M', 'U', 'L', 'T')) {
+ uint32 size = f->readUint32BE();
+ f->seek(0, SEEK_SET);
+
+ byte *p = _vm->_res->createResource(rtImage, params->image, size);
+
+ if (f->read(p, size) != size) {
+ _vm->_res->nukeResource(rtImage, params->image);
+ error("i/o error when reading '%s'", params->filename);
+ _vm->VAR(_vm->VAR_GAME_LOADED) = DW_LOAD_READ_FAILURE;
+ _vm->VAR(_vm->VAR_OPERATION_FAILURE) = DW_LOAD_READ_FAILURE;
} else {
- _vm->VAR(_vm->VAR_GAME_LOADED) = -1;
- _vm->VAR(_vm->VAR_OPERATION_FAILURE) = -1;
+ _vm->_res->setModified(rtImage, params->image);
+ _vm->VAR(_vm->VAR_GAME_LOADED) = DW_LOAD_SUCCESS;
+ _vm->VAR(_vm->VAR_OPERATION_FAILURE) = DW_LOAD_SUCCESS;
}
- delete f;
+
} else {
- _vm->VAR(_vm->VAR_GAME_LOADED) = -3;
- _vm->VAR(_vm->VAR_OPERATION_FAILURE) = -3;
- debug(0, "Unable to open for read '%s'", params->filename);
+ _vm->VAR(_vm->VAR_GAME_LOADED) = DW_LOAD_NOT_TYPE;
+ _vm->VAR(_vm->VAR_OPERATION_FAILURE) = DW_LOAD_NOT_TYPE;
}
+
+ delete f;
+ } else {
+ _vm->VAR(_vm->VAR_GAME_LOADED) = DW_LOAD_OPEN_FAILURE;
+ _vm->VAR(_vm->VAR_OPERATION_FAILURE) = DW_LOAD_OPEN_FAILURE;
+ debug(0, "Unable to open for read '%s'", params->filename);
}
- break;
- case kWASave:
- if (params->actionFlags & kWAFFilename) {
- switch (params->fileType) {
- case 2:
- _vm->VAR(_vm->VAR_OPERATION_FAILURE) = -1;
- break;
- case 1:
- // TODO Write image to file
- break;
- case 0: {
- Common::WriteStream *f = _vm->openSaveFileForWriting(params->filename);
+ }
+}
+
+void Wiz::processWizImageSaveCmd(const WizImageCommand *params) {
+ if (params->actionFlags & kWAFFilename) {
+ switch (params->fileType) {
+ case DW_SAVE_RAW_FORMAT:
+ // Ignore on purpose...
+ _vm->VAR(_vm->VAR_OPERATION_FAILURE) = DW_SAVE_NOT_TYPE;
+ break;
+ case DW_SAVE_PCX_FORMAT:
+ // TODO Write image to file
+ break;
+ case DW_SAVE_WIZ_FORMAT: {
+ Common::WriteStream *f = _vm->openSaveFileForWriting(params->filename);
+
+ if (!f) {
+ debug(0, "Unable to open for write '%s'", params->filename);
+ _vm->VAR(_vm->VAR_OPERATION_FAILURE) = DW_SAVE_CREATE_FAILURE;
+ } else {
+ byte *p = _vm->getResourceAddress(rtImage, params->image);
+ uint32 size = READ_BE_UINT32(p + 4);
- if (!f) {
- debug(0, "Unable to open for write '%s'", params->filename);
- _vm->VAR(_vm->VAR_OPERATION_FAILURE) = -3;
+ if (f->write(p, size) != size) {
+ error("i/o error when writing '%s'", params->filename);
+ _vm->VAR(_vm->VAR_OPERATION_FAILURE) = DW_SAVE_WRITE_FAILURE;
} else {
- byte *p = _vm->getResourceAddress(rtImage, params->img.resNum);
- uint32 size = READ_BE_UINT32(p + 4);
- if (f->write(p, size) != size) {
- error("i/o error when writing '%s'", params->filename);
- _vm->VAR(_vm->VAR_OPERATION_FAILURE) = -2;
- } else {
- _vm->VAR(_vm->VAR_OPERATION_FAILURE) = 0;
- }
- f->finalize();
- delete f;
+ _vm->VAR(_vm->VAR_OPERATION_FAILURE) = DW_SAVE_SUCCESS;
}
- break;
- }
- default:
- error("processWizImage: actionMode kWASave unhandled fileType %d", params->fileType);
+
+ f->finalize();
+ delete f;
}
+
+ break;
}
+ default:
+ error("processWizImageCmd: actionMode kWASave unhandled fileType %d", params->fileType);
+ }
+ }
+}
+
+void Wiz::processWizImageCmd(const WizImageCommand *params) {
+ debug(7, "processWizImageCmd: actionMode %d", params->actionMode);
+ switch (params->actionMode) {
+ case kWAUnknown:
+ // Do nothing...
+ break;
+ case kWADraw:
+ processWizImageDrawCmd(params);
+ break;
+ case kWACapture:
+ processWizImageCaptureCmd(params);
+ break;
+ case kWALoad:
+ processWizImageLoadCmd(params);
+ break;
+ case kWASave:
+ processWizImageSaveCmd(params);
break;
case kWAGlobalState:
// Do nothing...
break;
case kWAModify:
- remapWizImagePal(params);
+ processWizImageModifyCmd(params);
break;
// HE 99+
case kWAPolyCapture:
- captureWizPolygon(params->img.resNum, params->sourceImage, (params->actionFlags & kWAFState) ? params->img.state : 0, params->polygon, params->polygon2, params->compressionType);
+ processWizImagePolyCaptureCmd(params);
break;
- case kWANew: {
- int img_w = 640;
- if (params->actionFlags & kWAFWidth) {
- img_w = params->resDefImgW;
- }
- int img_h = 480;
- if (params->actionFlags & kWAFHeight) {
- img_h = params->resDefImgH;
- }
- int img_x = 0;
- int img_y = 0;
- if (params->actionFlags & 1) {
- img_x = params->img.x1;
- img_y = params->img.y1;
- }
- if (params->actionFlags & kWAFProperty) {
- debug(7, "Compression %d Color Depth %d", params->propertyValue, params->propertyNumber);
- }
- createWizEmptyImage(params->img.resNum, img_x, img_y, img_w, img_h);
- }
+ case kWANew:
+ processNewWizImageCmd(params);
break;
case kWARenderRectangle:
- fillWizRect(params);
+ processWizImageRenderRectCmd(params);
break;
case kWARenderLine:
- fillWizLine(params);
+ processWizImageRenderLineCmd(params);
break;
case kWARenderPixel:
- fillWizPixel(params);
+ processWizImageRenderPixelCmd(params);
break;
case kWARenderFloodFill:
- fillWizFlood(params);
+ processWizImageRenderFloodFillCmd(params);
break;
case kWAFontStart:
- // Used for text in FreddisFunShop/PuttsFunShop/SamsFunShop
- // TODO: Start Font
+ processWizImageFontStartCmd(params);
break;
case kWAFontEnd:
- // Used for text in FreddisFunShop/PuttsFunShop/SamsFunShop
- // TODO: End Font
+ processWizImageFontEndCmd(params);
break;
case kWAFontCreate:
- // Used for text in FreddisFunShop/PuttsFunShop/SamsFunShop
- // TODO: Create Font
+ processWizImageFontCreateCmd(params);
break;
case kWAFontRender:
- // TODO: Render Font String
- error("Render Font String");
+ processWizImageFontRenderCmd(params);
break;
case kWARenderEllipse:
- // Used in to draw circles in FreddisFunShop/PuttsFunShop/SamsFunShop
- // TODO: Ellipse
- _vm->_res->setModified(rtImage, params->img.resNum);
+ processWizImageRenderEllipseCmd(params);
break;
default:
- error("Unhandled processWizImage mode %d", params->actionMode);
+ error("Unhandled processWizImageCmd mode %d", params->actionMode);
}
}
@@ -2744,13 +2906,13 @@ int Wiz::getWizImageData(int resNum, int state, int type) {
assert(wizh);
return READ_LE_UINT32(wizh + 0x0);
case 1:
- return (_vm->findWrappedBlock(MKTAG('R','G','B','S'), dataPtr, state, 0) != NULL) ? 1 : 0;
+ return (_vm->findWrappedBlock(MKTAG('R','G','B','S'), dataPtr, state, 0) != nullptr) ? 1 : 0;
case 2:
- return (_vm->findWrappedBlock(MKTAG('R','M','A','P'), dataPtr, state, 0) != NULL) ? 1 : 0;
+ return (_vm->findWrappedBlock(MKTAG('R','M','A','P'), dataPtr, state, 0) != nullptr) ? 1 : 0;
case 3:
- return (_vm->findWrappedBlock(MKTAG('T','R','N','S'), dataPtr, state, 0) != NULL) ? 1 : 0;
+ return (_vm->findWrappedBlock(MKTAG('T','R','N','S'), dataPtr, state, 0) != nullptr) ? 1 : 0;
case 4:
- return (_vm->findWrappedBlock(MKTAG('X','M','A','P'), dataPtr, state, 0) != NULL) ? 1 : 0;
+ return (_vm->findWrappedBlock(MKTAG('X','M','A','P'), dataPtr, state, 0) != nullptr) ? 1 : 0;
default:
error("getWizImageData: Unknown type %d", type);
}
@@ -2768,11 +2930,11 @@ int Wiz::getWizImageStates(const uint8 *dataPtr) {
const byte *offs, *wrap;
wrap = _vm->findResource(MKTAG('W','R','A','P'), dataPtr);
- if (wrap == NULL)
+ if (wrap == nullptr)
return 1;
offs = _vm->findResourceData(MKTAG('O','F','F','S'), wrap);
- if (offs == NULL)
+ if (offs == nullptr)
return 1;
return _vm->getResourceDataSize(offs) / 4;
@@ -2806,10 +2968,10 @@ int Wiz::isWizPixelNonTransparent(uint8 *data, int state, int x, int y, int flag
uint8 *wizd = _vm->findWrappedBlock(MKTAG('W','I','Z','D'), data, state, 0);
assert(wizd);
if (x >= 0 && x < w && y >= 0 && y < h) {
- if (flags & kWIFFlipX) {
+ if (flags & kWRFFlipX) {
x = w - x - 1;
}
- if (flags & kWIFFlipY) {
+ if (flags & kWRFFlipY) {
y = h - y - 1;
}
switch (c) {
diff --git a/engines/scumm/he/wiz_he.h b/engines/scumm/he/wiz_he.h
index e39dcab90ab..0f0078b3e94 100644
--- a/engines/scumm/he/wiz_he.h
+++ b/engines/scumm/he/wiz_he.h
@@ -26,6 +26,30 @@
namespace Scumm {
+#define WIZBLOCK_WIZH_DATA_SIZE (4 * 3)
+#define WIZBLOCK_RGBS_DATA_SIZE (768)
+#define WIZBLOCK_SPOT_DATA_SIZE (4 * 2)
+#define WIZBLOCK_RMAP_DATA_SIZE (256 + 4)
+
+#define WIZBLOCK_WIZH_SIZE (8 + (WIZBLOCK_WIZH_DATA_SIZE))
+#define WIZBLOCK_RGBS_SIZE (8 + (WIZBLOCK_RGBS_DATA_SIZE))
+#define WIZBLOCK_SPOT_SIZE (8 + (WIZBLOCK_SPOT_DATA_SIZE))
+#define WIZBLOCK_RMAP_SIZE (8 + (WIZBLOCK_RMAP_DATA_SIZE))
+
+#define DW_LOAD_SUCCESS 0
+#define DW_LOAD_NOT_TYPE -1
+#define DW_LOAD_READ_FAILURE -2
+#define DW_LOAD_OPEN_FAILURE -3
+
+#define DW_SAVE_SUCCESS 0
+#define DW_SAVE_NOT_TYPE -1
+#define DW_SAVE_WRITE_FAILURE -2
+#define DW_SAVE_CREATE_FAILURE -3
+
+#define DW_SAVE_WIZ_FORMAT 0
+#define DW_SAVE_PCX_FORMAT 1
+#define DW_SAVE_RAW_FORMAT 2
+
struct WizPolygon {
Common::Point vert[5];
Common::Rect bound;
@@ -44,11 +68,11 @@ struct WizPolygon {
}
};
-struct WizImage {
- int resNum;
- int x1;
- int y1;
- int zorder;
+struct WizBufferElement {
+ int image;
+ int x;
+ int y;
+ int z;
int state;
int flags;
int shadow;
@@ -56,7 +80,7 @@ struct WizImage {
int palette;
};
-struct FontProperties {
+struct WizFontProperties {
byte string[4096];
byte fontName[4096];
int fgColor;
@@ -67,7 +91,7 @@ struct FontProperties {
int yPos;
};
-struct EllipseProperties {
+struct WizEllipseProperties {
int px;
int py;
int qx;
@@ -78,37 +102,49 @@ struct EllipseProperties {
int color;
};
-struct WizParameters {
+struct WizExtendedRenderInfo {
+ int32 blendFlags;
+ int32 sprite;
+ int32 group;
+ int32 conditionBits;
+};
+
+struct WizImageCommand {
int dwSize;
byte filename[260];
Common::Rect box;
int actionFlags;
int actionMode;
int params[8];
+ int flags;
+ int xPos;
+ int yPos;
+ int zPos;
int compressionType;
int fileType;
int angle;
+ int state;
int scale;
+ int shadow;
int polygon;
int polygon2;
- int resDefImgW;
- int resDefImgH;
+ int image;
+ int width;
+ int height;
+ int palette;
int sourceImage;
int propertyValue;
int propertyNumber;
uint8 remapTable[256];
uint8 remapList[256];
- int remapNum;
- int dstResNum;
- uint16 fillColor;
- FontProperties fontProperties;
- EllipseProperties ellipseProperties;
+ int remapCount;
+ int destImageNumber;
+ int zbufferImage;
+ uint16 colorValue;
+ WizFontProperties fontProperties;
+ WizEllipseProperties ellipseProperties;
Common::Rect renderCoords;
- int blendFlags;
- int spriteId;
- int spriteGroup;
- int conditionBits;
- WizImage img;
+ WizExtendedRenderInfo extendedRenderInfo;
void reset() {
dwSize = 0;
@@ -117,76 +153,98 @@ struct WizParameters {
actionFlags = 0;
actionMode = 0;
memset(params, 0, sizeof(params));
+ image = 0;
+ xPos = 0;
+ yPos = 0;
+ zPos = 0;
+ state = 0;
+ flags = 0;
+ shadow = 0;
+ zbufferImage = 0;
+ palette = 0;
compressionType = 0;
fileType = 0;
angle = 0;
scale = 0;
polygon = 0;
polygon2 = 0;
- resDefImgW = 0;
- resDefImgH = 0;
+ width = 0;
+ height = 0;
sourceImage = 0;
propertyValue = 0;
propertyNumber = 0;
memset(remapTable, 0, sizeof(remapTable));
memset(remapList, 0, sizeof(remapList));
- remapNum = 0;
- dstResNum = 0;
- fillColor = 0;
- memset(&fontProperties, 0, sizeof(FontProperties));
- memset(&ellipseProperties, 0, sizeof(EllipseProperties));
+ remapCount = 0;
+ destImageNumber = 0;
+ colorValue = 0;
+ memset(&fontProperties, 0, sizeof(WizFontProperties));
+ memset(&ellipseProperties, 0, sizeof(WizEllipseProperties));
renderCoords.left = renderCoords.top = renderCoords.bottom = renderCoords.right = 0;
- blendFlags = 0;
- spriteId = 0;
- spriteGroup = 0;
- conditionBits = 0;
- memset(&img, 0, sizeof(WizImage));
+ memset(&extendedRenderInfo, 0, sizeof(WizExtendedRenderInfo));
+
}
};
enum WizRenderingFlags {
+ // Standard rendering flags
kWRFUsePalette = 0x00000001,
kWRFRemap = 0x00000002,
kWRFPrint = 0x00000004,
kWRFBackground = 0x00000008,
kWRFForeground = 0x00000010,
kWRFAlloc = 0x00000020,
- kWIFIsPolygon = 0x00000040,
- kWIFZPlaneOn = 0x00000080,
- kWIFZPlaneOff = 0x00000100,
- kWIFUseShadow = 0x00000200,
- kWIFFlipX = 0x00000400,
- kWIFFlipY = 0x00000800,
- hWRFRotate90 = 0x00001000
+ kWRFIsPolygon = 0x00000040,
+ kWRFZPlaneOn = 0x00000080,
+ kWRFZPlaneOff = 0x00000100,
+ kWRFUseShadow = 0x00000200,
+ kWRFFlipX = 0x00000400,
+ kWRFFlipY = 0x00000800,
+ kWRFRotate90 = 0x00001000,
+
+ // Special rendering flags
+ kWRFSpecialRenderBitMask = 0xfff00000,
+ kWRFAdditiveBlend = 0x00100000,
+ kWRFSubtractiveBlend = 0x00200000,
+ kWRF5050Blend = 0x00400000,
+ kWRFAreaSampleDuringWarp = 0x00800000,
+ kWRFUseSourceImageAsAlphaChannel = 0x01000000,
+ kWRFBooleanAlpha = 0x02000000,
+ kWRFInverseAlpha = 0x04000000,
+ kWRFUseImageAsAlphaChannel = 0x08000000,
+ kWRFUseBlendPrimitives = 0x10000000,
+ kWRFFutureExpansionBit1 = 0x20000000,
+ kWRFFutureExpansionBit2 = 0x40000000,
+ kWRFFutureExpansionBit3 = 0x80000000,
};
enum WizActions {
- kWAUnknown = 0,
- kWADraw = 1,
- kWACapture = 2,
- kWALoad = 3,
- kWASave = 4,
- kWAGlobalState = 5,
- kWAModify = 6,
- kWAPolyCapture = 7,
- kWANew = 8,
+ kWAUnknown = 0,
+ kWADraw = 1,
+ kWACapture = 2,
+ kWALoad = 3,
+ kWASave = 4,
+ kWAGlobalState = 5,
+ kWAModify = 6,
+ kWAPolyCapture = 7,
+ kWANew = 8,
kWARenderRectangle = 9,
- kWARenderLine = 10,
- kWARenderPixel = 11,
+ kWARenderLine = 10,
+ kWARenderPixel = 11,
kWARenderFloodFill = 12,
- kWAFontStart = 13,
- kWAFontEnd = 14,
- kWAFontCreate = 15,
- kWAFontRender = 16,
- kWARenderEllipse = 17,
+ kWAFontStart = 13,
+ kWAFontEnd = 14,
+ kWAFontCreate = 15,
+ kWAFontRender = 16,
+ kWARenderEllipse = 17,
};
enum WizActionFlags {
kWAFSpot = 0x00000001,
kWAFPolygon = 0x00000002,
kWAFShadow = 0x00000004,
- kWAFScaled = 0x00000008,
- kWAFRotate = 0x00000010,
+ kWAFScale = 0x00000008,
+ kWAFAngle = 0x00000010,
kWAFFlags = 0x00000020,
kWAFRemapList = 0x00000040,
kWAFFileType = 0x00000080,
@@ -207,12 +265,36 @@ enum WizActionFlags {
};
enum WizCompositeFlags {
- kWCFConditionBits = 0x01,
- kWCFSubState = 0x02,
- kWCFXDelta = 0x04,
- kWCFYDelta = 0x08,
- kWCFDrawFlags = 0x10,
- kWCFSubConditionBits = 0x20
+ kWCFConditionBits = 0x00000001,
+ kWCFSubState = 0x00000002,
+ kWCFXDelta = 0x00000004,
+ kWCFYDelta = 0x00000008,
+ kWCFDrawFlags = 0x00000010,
+ kWCFSubConditionBits = 0x00000020
+};
+
+enum WizCompressionTypes {
+ kWCTNone = 0x00000000,
+ kWCTTRLE = 0x00000001,
+ kWCTNone16Bpp = 0x00000002,
+ kWCTNone32Bpp = 0x00000003,
+ kWCTComposite = 0x00000004,
+ kWCTTRLE16Bpp = 0x00000005,
+ kWCTTRLE32Bpp = 0x00000006,
+ kWCTMRLEWithLineSizePrefix = 0x00000007,
+ kWCTMRLEWithoutLineSizePrefix = 0x00000008,
+ kWCTDataBlockDependent = 0x00000009,
+ kWCTNone16BppBigEndian = 0x0000000A,
+ kWCTNone32BppBigEndian = 0x0000000B,
+ kWCTTRLE16BppBigEndian = 0x0000000C,
+ kWCTTRLE32BppBigEndian = 0x0000000D
+};
+
+enum CreateWizFlags {
+ kCWFPalette = 0x00000001,
+ kCWFSpot = 0x00000002,
+ kCWFRemapTable = 0x00000008,
+ kCWFDefault = ((kCWFPalette) | (kCWFSpot) | (kCWFRemapTable))
};
enum WizSpcConditionTypes : uint {
@@ -251,8 +333,8 @@ public:
NUM_IMAGES = 255
};
- WizImage _images[NUM_IMAGES];
- uint16 _imagesNum;
+ WizBufferElement _wizBuffer[NUM_IMAGES];
+ uint16 _wizBufferIndex;
WizPolygon _polygons[NUM_POLYGONS];
Wiz(ScummEngine_v71he *vm);
@@ -273,12 +355,24 @@ public:
void polygonRotatePoints(Common::Point *pts, int num, int alpha);
void polygonTransform(int resNum, int state, int po_x, int po_y, int angle, int zoom, Common::Point *vert);
- void createWizEmptyImage(int resNum, int x1, int y1, int width, int height);
- void fillWizRect(const WizParameters *params);
- void fillWizLine(const WizParameters *params);
- void fillWizPixel(const WizParameters *params);
- void fillWizFlood(const WizParameters *params);
- void remapWizImagePal(const WizParameters *params);
+ void dwCreateRawWiz(int imageNum, int w, int h, int flags, int bitsPerPixel, int optionalSpotX, int optionalSpotY);
+ void processWizImageCmd(const WizImageCommand *params);
+ void processWizImageCaptureCmd(const WizImageCommand *params);
+ void processWizImagePolyCaptureCmd(const WizImageCommand *params);
+ void processWizImageDrawCmd(const WizImageCommand *params);
+ void processWizImageRenderRectCmd(const WizImageCommand *params);
+ void processWizImageRenderLineCmd(const WizImageCommand *params);
+ void processWizImageRenderPixelCmd(const WizImageCommand *params);
+ void processWizImageRenderFloodFillCmd(const WizImageCommand *params);
+ void processWizImageModifyCmd(const WizImageCommand *params);
+ void processWizImageRenderEllipseCmd(const WizImageCommand *params);
+ void processWizImageFontStartCmd(const WizImageCommand *params);
+ void processWizImageFontEndCmd(const WizImageCommand *params);
+ void processWizImageFontCreateCmd(const WizImageCommand *params);
+ void processWizImageFontRenderCmd(const WizImageCommand *params);
+ void processNewWizImageCmd(const WizImageCommand *params);
+ void processWizImageLoadCmd(const WizImageCommand *params);
+ void processWizImageSaveCmd(const WizImageCommand *params);
void getWizImageDim(int resNum, int state, int32 &w, int32 &h);
void getWizImageDim(uint8 *dataPtr, int state, int32 &w, int32 &h);
@@ -296,12 +390,11 @@ public:
void getWizImageSpot(uint8 *data, int state, int32 &x, int32 &y);
void loadWizCursor(int resId, int palette);
- void captureWizImage(int resNum, const Common::Rect& r, bool frontBuffer, int compType);
void captureImage(uint8 *src, int srcPitch, int srcw, int srch, int resNum, const Common::Rect& r, int compType);
- void captureWizPolygon(int resNum, int maskNum, int maskState, int id1, int id2, int compType);
- void displayWizComplexImage(const WizParameters *params);
- void displayWizImage(WizImage *pwi);
- void processWizImage(const WizParameters *params);
+ void takeAWiz(int resNum, const Common::Rect &r, bool backBuffer, int compType);
+
+ void simpleDrawAWiz(int image, int state, int x, int y, int flags);
+ void bufferAWiz(int image, int state, int x, int y, int z, int flags, int optionalShadowImage, int optionalZBufferImage, int whichPalette);
uint8 *drawWizImage(int resNum, int state, int maskNum, int maskState, int x1, int y1, int zorder, int shadow, int zbuffer, const Common::Rect *clipBox, int flags, int dstResNum, const uint8 *palPtr, uint32 conditionBits);
void drawWizImageEx(uint8 *dst, uint8 *src, uint8 *mask, int dstPitch, int dstType, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, int state, const Common::Rect *rect, int flags, const uint8 *palPtr, int transColor, uint8 bitDepth, const uint8 *xmapPtr, uint32 conditionBits);
diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
index 5cfb5b72310..06ff4a94d8c 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -1982,7 +1982,7 @@ void ScummEngine_v90he::resetScumm() {
_hePaletteNum = 0;
_sprite->resetTables(0);
- _wizParams.reset();
+ _wizImageCommand.reset();
if (_game.heversion >= 98)
_logicHE = LogicHE::makeLogicHE(this);
Commit: 4761c3147621b8fabac4266495ead8197a6212a2
https://github.com/scummvm/scummvm/commit/4761c3147621b8fabac4266495ead8197a6212a2
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Fix pixelDepth value for 16-bit color games
Changed paths:
engines/scumm/he/wiz_he.cpp
diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp
index e5e25f86d26..f5f090347ab 100644
--- a/engines/scumm/he/wiz_he.cpp
+++ b/engines/scumm/he/wiz_he.cpp
@@ -2710,7 +2710,7 @@ void Wiz::processNewWizImageCmd(const WizImageCommand *params) {
propertyValue = params->propertyValue;
}
- int pixelDepth = 8;
+ int pixelDepth = (_vm->_game.features & GF_16BIT_COLOR) ? 16 : 8;
if (propertyNumber == 1) {
pixelDepth = propertyValue;
Commit: a64d977fdb8914c7fdf9e3bf200b952087cf5ff0
https://github.com/scummvm/scummvm/commit/a64d977fdb8914c7fdf9e3bf200b952087cf5ff0
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Add some basic WIZ primitives
Changed paths:
A engines/scumm/he/wiz_primitives_he.cpp
engines/scumm/he/intern_he.h
engines/scumm/he/wiz_he.cpp
engines/scumm/he/wiz_he.h
engines/scumm/module.mk
engines/scumm/scumm.cpp
engines/scumm/scumm.h
engines/scumm/vars.cpp
diff --git a/engines/scumm/he/intern_he.h b/engines/scumm/he/intern_he.h
index dfb4a5f4705..12a65f57a59 100644
--- a/engines/scumm/he/intern_he.h
+++ b/engines/scumm/he/intern_he.h
@@ -320,7 +320,7 @@ protected:
void o71_polygonOps();
void o71_polygonHit();
- byte VAR_WIZ_TCOLOR;
+ byte VAR_WIZ_TRANSPARENT_COLOR;
public:
/* Actor AuxQueue stuff (HE) */
AuxBlock _auxBlocks[16];
diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp
index f5f090347ab..aff90c4f3fa 100644
--- a/engines/scumm/he/wiz_he.cpp
+++ b/engines/scumm/he/wiz_he.cpp
@@ -1342,7 +1342,7 @@ void Wiz::captureImage(uint8 *src, int srcPitch, int srcw, int srch, int resNum,
int w = rCapt.width();
int h = rCapt.height();
- int transColor = (_vm->VAR_WIZ_TCOLOR != 0xFF) ? _vm->VAR(_vm->VAR_WIZ_TCOLOR) : 5;
+ int transColor = (_vm->VAR_WIZ_TRANSPARENT_COLOR != 0xFF) ? _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR) : 5;
if (_vm->_game.features & GF_16BIT_COLOR)
compType = 2;
@@ -1507,7 +1507,7 @@ uint8 *Wiz::drawWizImage(int resNum, int state, int maskNum, int maskState, int
int32 dstPitch, dstType, cw, ch;
if (flags & kWRFAlloc) {
dst = (uint8 *)malloc(width * height * _vm->_bytesPerPixel);
- int transColor = (_vm->VAR_WIZ_TCOLOR != 0xFF) ? (_vm->VAR(_vm->VAR_WIZ_TCOLOR)) : 5;
+ int transColor = (_vm->VAR_WIZ_TRANSPARENT_COLOR != 0xFF) ? (_vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR)) : 5;
if (_vm->_bytesPerPixel == 2) {
uint8 *tmpPtr = dst;
@@ -1578,9 +1578,9 @@ uint8 *Wiz::drawWizImage(int resNum, int state, int maskNum, int maskState, int
}
int transColor = -1;
- if (_vm->VAR_WIZ_TCOLOR != 0xFF) {
+ if (_vm->VAR_WIZ_TRANSPARENT_COLOR != 0xFF) {
uint8 *trns = _vm->findWrappedBlock(MKTAG('T','R','N','S'), dataPtr, state, 0);
- transColor = (trns == nullptr) ? _vm->VAR(_vm->VAR_WIZ_TCOLOR) : -1;
+ transColor = (trns == nullptr) ? _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR) : -1;
}
if (_vm->_game.id == GID_MOONBASE &&
@@ -1974,7 +1974,7 @@ void Wiz::processWizImagePolyCaptureCmd(const WizImageCommand *params) {
imageBuffer = (uint8 *)malloc(dstw * dsth * _vm->_bytesPerPixel);
assert(imageBuffer);
- const uint16 transColor = (_vm->VAR_WIZ_TCOLOR != 0xFF) ? _vm->VAR(_vm->VAR_WIZ_TCOLOR) : 5;
+ const uint16 transColor = (_vm->VAR_WIZ_TRANSPARENT_COLOR != 0xFF) ? _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR) : 5;
if (_vm->_bytesPerPixel == 2) {
uint8 *tmpPtr = imageBuffer;
for (i = 0; i < dsth; i++) {
@@ -2095,7 +2095,7 @@ void Wiz::drawWizPolygonTransform(int resNum, int state, Common::Point *wp, int
}
void Wiz::drawWizPolygonImage(uint8 *dst, const uint8 *src, const uint8 *mask, int dstpitch, int dstType, int dstw, int dsth, int wizW, int wizH, Common::Rect &bound, Common::Point *wp, uint8 bitDepth) {
- int i, transColor = (_vm->VAR_WIZ_TCOLOR != 0xFF) ? _vm->VAR(_vm->VAR_WIZ_TCOLOR) : 5;
+ int i, transColor = (_vm->VAR_WIZ_TRANSPARENT_COLOR != 0xFF) ? _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR) : 5;
Common::Point bbox[4];
bbox[0].x = 0;
@@ -2348,7 +2348,7 @@ void Wiz::processWizImageDrawCmd(const WizImageCommand *params) {
// TODO:
//if (params->actionFlags & kWAFDestImage) {
// // Get the rendering surface for this image
- // if (!DW_SetSimpleBitmapStructFromImage(params->destImageNumber, 0, &fakeBitmap)) {
+ // if (!dwSetSimpleBitmapStructFromImage(params->destImageNumber, 0, &fakeBitmap)) {
// error("Image %d is invalid for rendering into", params->destImageNumber);
// }
//
@@ -2480,161 +2480,228 @@ void Wiz::dwCreateRawWiz(int imageNum, int w, int h, int flags, int bitsPerPixel
WRITE_BE_UINT32(writePtr, 8 + wizdSize); writePtr += 4;
}
+bool Wiz::dwSetSimpleBitmapStructFromImage(int imageNum, int imageState, WizSimpleBitmap *destBM) {
+ int compType, imageWidth, imageHeight;
+ byte *wizHeader;
+ byte *dataPtr;
+
+ // Get the image header
+ wizHeader = (byte *)getWizStateHeaderPrim(imageNum, imageState);
+
+ if (!wizHeader) {
+ return false;
+ }
+
+ // Double check the image header compression type
+ compType = READ_LE_UINT32(wizHeader);
+
+ if (!isUncompressedFormatTypeID(compType)) {
+ return false;
+ }
+
+ imageWidth = READ_LE_UINT32(wizHeader + 4);
+ imageHeight = READ_LE_UINT32(wizHeader + 8);
+
+ // Do some fun stuff
+ dataPtr = (byte *)getWizStateDataPrim(imageNum, imageState);
+
+ if (!dataPtr) {
+ return false;
+ }
+
+ // Hook up the image info to the simple bitmap info
+ destBM->bufferPtr = (int32 *)(dataPtr);
+ destBM->bitmapWidth = imageWidth;
+ destBM->bitmapHeight = imageHeight;
+
+ return true;
+}
+
void Wiz::processWizImageRenderRectCmd(const WizImageCommand *params) {
- int state = 0;
+ Common::Rect renderRect, clipRect, workClipRect;
+ int whichState, w, h, whichImage;
+ WizSimpleBitmap renderBitmap;
+ int32 whatColor;
+
+ // What state is going to rendered into?
if (params->actionFlags & kWAFState) {
- state = params->state;
+ whichState = params->state;
+ } else {
+ whichState = 0;
}
- uint8 *dataPtr = _vm->getResourceAddress(rtImage, params->image);
- if (dataPtr) {
- uint8 *wizh = _vm->findWrappedBlock(MKTAG('W','I','Z','H'), dataPtr, state, 0);
- assert(wizh);
- int c = READ_LE_UINT32(wizh + 0x0);
- int w = READ_LE_UINT32(wizh + 0x4);
- int h = READ_LE_UINT32(wizh + 0x8);
- assert(c == 0 || c == 2);
- uint8 bitDepth = (c == 2) ? 2 : 1;
- Common::Rect areaRect, imageRect(w, h);
- if (params->actionFlags & kWAFRect) {
- if (!imageRect.intersects(params->box)) {
- return;
- }
- imageRect.clip(params->box);
- }
- if (params->actionFlags & kWAFRenderCoords) {
- areaRect = params->renderCoords;
- } else {
- areaRect = imageRect;
- }
- uint16 color = _vm->VAR(93);
- if (params->actionFlags & kWAFColor) {
- color = params->colorValue;
- }
- if (areaRect.intersects(imageRect)) {
- areaRect.clip(imageRect);
- uint8 *wizd = _vm->findWrappedBlock(MKTAG('W','I','Z','D'), dataPtr, state, 0);
- assert(wizd);
- int dx = areaRect.width();
- int dy = areaRect.height();
- wizd += (areaRect.top * w + areaRect.left) * bitDepth;
- while (dy--) {
- if (bitDepth == 2) {
- for (int i = 0; i < dx; i++)
- WRITE_LE_UINT16(wizd + i * 2, color);
- } else {
- memset(wizd, color, dx);
- }
- wizd += w * bitDepth;
- }
+
+ whichImage = params->image;
+
+ // Make the clipping rect for this image / state
+ getWizImageDim(whichImage, whichState, w, h);
+ makeSizedRectAt(&clipRect, 0, 0, w, h);
+
+ if (params->actionFlags & kWAFRect) {
+ workClipRect.left = params->box.left;
+ workClipRect.top = params->box.top;
+ workClipRect.right = params->box.right;
+ workClipRect.bottom = params->box.bottom;
+
+ // Bail out if there isn't overlap between the clipping rects
+ if (!findRectOverlap(&clipRect, &workClipRect)) {
+ return;
}
}
- _vm->_res->setModified(rtImage, params->image);
-}
-struct drawProcP {
- Common::Rect *imageRect;
- uint8 *wizd;
- int pitch;
- int depth;
-};
+ // Get the rendering coords or assume the entire
+ if (params->actionFlags & kWAFRenderCoords) {
+ renderRect = params->renderCoords;
+ } else {
+ renderRect = clipRect;
+ }
+
+ // What is the rendering color
+ if (params->actionFlags & kWAFColor) {
+ whatColor = params->colorValue;
-static void drawProc(int x, int y, int c, void *data) {
- drawProcP *param = (drawProcP *)data;
+ } else {
+ whatColor = _vm->VAR(_vm->VAR_COLOR_BLACK);
+ }
+
+ // Get the simple bitmap
+ if (!dwSetSimpleBitmapStructFromImage(whichImage, whichState, &renderBitmap)) {
+ error("Wiz::processWizImageRenderRectCmd(): Image %d state %d invalid for rendering", whichImage, whichState);
+ }
- if (param->imageRect->contains(x, y)) {
- uint32 offs = y * param->pitch + x * param->depth;
- if (param->depth == 2)
- WRITE_LE_UINT16(param->wizd + offs, c);
- else
- *(param->wizd + offs) = c;
+ // If we're here we must be able to render into the image (clipped)...
+ if (findRectOverlap(&renderRect, &clipRect)) {
+ pgDrawSolidRect(&renderBitmap, &renderRect, whatColor);
+ _vm->_res->setModified(rtImage, params->image);
}
}
void Wiz::processWizImageRenderLineCmd(const WizImageCommand *params) {
- if (params->actionFlags & kWAFRenderCoords) {
- int state = 0;
- if (params->actionFlags & kWAFState) {
- state = params->state;
- }
- uint8 *dataPtr = _vm->getResourceAddress(rtImage, params->image);
- if (dataPtr) {
- uint8 *wizh = _vm->findWrappedBlock(MKTAG('W','I','Z','H'), dataPtr, state, 0);
- assert(wizh);
- int c = READ_LE_UINT32(wizh + 0x0);
- int w = READ_LE_UINT32(wizh + 0x4);
- int h = READ_LE_UINT32(wizh + 0x8);
- assert(c == 0 || c == 2);
- uint8 bitDepth = (c == 2) ? 2 : 1;
- Common::Rect imageRect(w, h);
- if (params->actionFlags & kWAFRect) {
- if (!imageRect.intersects(params->box)) {
- return;
- }
- imageRect.clip(params->box);
- }
- uint16 color = _vm->VAR(93);
- if (params->actionFlags & kWAFColor) {
- color = params->colorValue;
- }
- uint8 *wizd = _vm->findWrappedBlock(MKTAG('W','I','Z','D'), dataPtr, state, 0);
- assert(wizd);
- int x1 = params->renderCoords.left;
- int y1 = params->renderCoords.top;
- int x2 = params->renderCoords.right;
- int y2 = params->renderCoords.bottom;
-
- drawProcP lineP;
-
- lineP.imageRect = &imageRect;
- lineP.wizd = wizd;
- lineP.pitch = w * bitDepth;
- lineP.depth = bitDepth;
-
- if (params->actionFlags & kWAFProperty) {
- Graphics::drawThickLine(x1, y1, x2, y2, params->propertyValue, params->propertyNumber, color, drawProc, &lineP);
- } else {
- Graphics::drawLine(x1, y1, x2, y2, color, drawProc, &lineP);
- }
+ Common::Rect clipRect, workClipRect;
+ int whichState, w, h, whichImage;
+ WizSimpleBitmap renderBitmap;
+ int32 whatColor;
+ int iPropertyNumber = 0, iPropertyValue = 0;
+
+ if (!(params->actionFlags & kWAFRenderCoords)) {
+ return;
+ }
+
+ if (params->actionFlags & kWAFState) {
+ whichState = params->state;
+ } else {
+ whichState = 0;
+ }
+
+ if (params->actionFlags & kWAFProperty) {
+ iPropertyNumber = params->propertyNumber;
+ iPropertyValue = params->propertyValue;
+ }
+
+ whichImage = params->image;
+
+ getWizImageDim(whichImage, whichState, w, h);
+ makeSizedRectAt(&clipRect, 0, 0, w, h);
+
+ if (params->actionFlags & kWAFRect) {
+ workClipRect.left = params->box.left;
+ workClipRect.top = params->box.top;
+ workClipRect.right = params->box.right;
+ workClipRect.bottom = params->box.bottom;
+
+ // Bail out if there isn't overlap between the clipping rects
+ if (!findRectOverlap(&clipRect, &workClipRect)) {
+ return;
}
}
+
+ // What is the rendering color
+ if (params->actionFlags & kWAFColor) {
+ whatColor = params->colorValue;
+ } else {
+ whatColor = _vm->VAR(_vm->VAR_COLOR_BLACK);
+ }
+
+ // Get the simple bitmap
+ if (!dwSetSimpleBitmapStructFromImage(whichImage, whichState, &renderBitmap)) {
+ error("Wiz::processWizImageRenderLineCmd(): Image %d state %d invalid for rendering", whichImage, whichState);
+ }
+
+ // If we're here we must be able to render into the image (clipped)...
+ switch (iPropertyNumber) {
+ case 0:
+ pgClippedLineDraw(
+ &renderBitmap,
+ params->renderCoords.left, params->renderCoords.top,
+ params->renderCoords.right, params->renderCoords.bottom,
+ &clipRect, whatColor);
+
+ break;
+ case 1:
+ pgClippedThickLineDraw(
+ &renderBitmap,
+ params->renderCoords.left, params->renderCoords.top,
+ params->renderCoords.right, params->renderCoords.bottom,
+ &clipRect,
+ iPropertyValue,
+ whatColor);
+
+ break;
+ }
+
_vm->_res->setModified(rtImage, params->image);
}
void Wiz::processWizImageRenderPixelCmd(const WizImageCommand *params) {
+ Common::Rect clipRect, workClipRect;
+ int whichState, w, h, whichImage;
+ WizSimpleBitmap renderBitmap;
+ int32 whatColor;
+ Common::Point pt;
+
if (params->actionFlags & kWAFRenderCoords) {
- int px = params->renderCoords.left;
- int py = params->renderCoords.top;
- uint8 *dataPtr = _vm->getResourceAddress(rtImage, params->image);
- if (dataPtr) {
- int state = 0;
- if (params->actionFlags & kWAFState) {
- state = params->state;
- }
- uint8 *wizh = _vm->findWrappedBlock(MKTAG('W','I','Z','H'), dataPtr, state, 0);
- assert(wizh);
- int c = READ_LE_UINT32(wizh + 0x0);
- int w = READ_LE_UINT32(wizh + 0x4);
- int h = READ_LE_UINT32(wizh + 0x8);
- assert(c == 0);
- Common::Rect imageRect(w, h);
- if (params->actionFlags & kWAFRect) {
- if (!imageRect.intersects(params->box)) {
- return;
- }
- imageRect.clip(params->box);
- }
- uint16 color = _vm->VAR(93);
- if (params->actionFlags & kWAFColor) {
- color = params->colorValue;
- }
- if (imageRect.contains(px, py)) {
- uint8 *wizd = _vm->findWrappedBlock(MKTAG('W','I','Z','D'), dataPtr, state, 0);
- assert(wizd);
- *(wizd + py * w + px) = color;
- }
+ pt.x = params->renderCoords.left;
+ pt.y = params->renderCoords.top;
+ } else {
+ return;
+ }
+
+ if (params->actionFlags & kWAFState) {
+ whichState = params->state;
+ } else {
+ whichState = 0;
+ }
+
+ whichImage = params->image;
+
+ getWizImageDim(whichImage, whichState, w, h);
+ makeSizedRectAt(&clipRect, 0, 0, w, h);
+
+ if (params->actionFlags & kWAFRect) {
+ workClipRect.left = params->box.left;
+ workClipRect.top = params->box.top;
+ workClipRect.right = params->box.right;
+ workClipRect.bottom = params->box.bottom;
+
+ // Bail out if there isn't overlap between the clipping rects
+ if (!findRectOverlap(&clipRect, &workClipRect)) {
+ return;
}
}
- _vm->_res->setModified(rtImage, params->image);
+
+ if (params->actionFlags & kWAFColor) {
+ whatColor = params->colorValue;
+ } else {
+ whatColor = _vm->VAR(_vm->VAR_COLOR_BLACK);
+ }
+
+ if (!dwSetSimpleBitmapStructFromImage(whichImage, whichState, &renderBitmap)) {
+ error("Wiz::processWizImageRenderPixelCmd(): Image %d state %d invalid for rendering.", whichImage, whichState);
+ }
+
+ if (isPointInRect(&clipRect,&pt)) {
+ pgWritePixel(&renderBitmap, pt.x, pt.y, whatColor);
+ _vm->_res->setModified(rtImage, params->image);
+ }
}
void Wiz::processWizImageModifyCmd(const WizImageCommand *params) {
@@ -2654,8 +2721,43 @@ void Wiz::processWizImageModifyCmd(const WizImageCommand *params) {
}
void Wiz::processWizImageRenderEllipseCmd(const WizImageCommand *params) {
- // Used in to draw circles in FreddisFunShop/PuttsFunShop/SamsFunShop
- // TODO: Ellipse
+ int iWhichState = 0, iPropertyNumber = 0, iPropertyValue = 0;
+ int iWidth = 0, iHeight = 0;
+
+ if (params->actionFlags & kWAFProperty) {
+ iPropertyNumber = params->propertyNumber;
+ iPropertyValue = params->propertyValue;
+ }
+
+ // What state is going to rendered into?
+ if (params->actionFlags & kWAFState) {
+ iWhichState = params->state;
+ }
+
+ int iWhichImage = params->image;
+
+ // Make the clipping rect for this image / state
+ getWizImageDim(iWhichImage, iWhichState, iWidth, iHeight);
+
+ Common::Rect clipRect;
+ makeSizedRectAt(&clipRect, 0, 0, iWidth, iHeight);
+
+ // Get the simple bitmap
+ WizSimpleBitmap renderBitmap;
+
+ if (!dwSetSimpleBitmapStructFromImage(iWhichImage, iWhichState, &renderBitmap)) {
+ error("Wiz::processWizImageRenderEllipseCmd(): Image %d state %d invalid for rendering.", iWhichImage, iWhichState);
+ }
+
+ pgDrawClippedEllipse(&renderBitmap,
+ params->ellipseProperties.px, params->ellipseProperties.py,
+ params->ellipseProperties.qx, params->ellipseProperties.qy,
+ params->ellipseProperties.kx, params->ellipseProperties.ky,
+ params->ellipseProperties.lod,
+ &clipRect,
+ iPropertyValue,
+ params->ellipseProperties.color);
+
_vm->_res->setModified(rtImage, params->image);
}
@@ -2864,6 +2966,12 @@ void Wiz::processWizImageCmd(const WizImageCommand *params) {
}
}
+bool Wiz::isUncompressedFormatTypeID(int id) {
+ return ((kWCTNone == id) || (kWCTNone16Bpp == id) ||
+ (kWCTNone32Bpp == id) || (kWCTNone16BppBigEndian == id) ||
+ (kWCTNone32BppBigEndian == id));
+}
+
void Wiz::getWizImageDim(int resNum, int state, int32 &w, int32 &h) {
uint8 *dataPtr = _vm->getResourceAddress(rtImage, resNum);
assert(dataPtr);
@@ -2943,6 +3051,18 @@ int Wiz::getWizImageStates(const uint8 *dataPtr) {
}
}
+void *Wiz::getWizStateHeaderPrim(int resNum, int state) {
+ uint8 *data = _vm->getResourceAddress(rtImage, resNum);
+ assert(data);
+ return _vm->findWrappedBlock(MKTAG('W', 'I', 'Z', 'H'), data, state, false);
+}
+
+void *Wiz::getWizStateDataPrim(int resNum, int state) {
+ uint8 *data = _vm->getResourceAddress(rtImage, resNum);
+ assert(data);
+ return _vm->findWrappedBlock(MKTAG('W', 'I', 'Z', 'D'), data, state, false);
+}
+
int Wiz::isWizPixelNonTransparent(int resNum, int state, int x, int y, int flags) {
uint8 *data = _vm->getResourceAddress(rtImage, resNum);
assert(data);
@@ -2977,7 +3097,7 @@ int Wiz::isWizPixelNonTransparent(uint8 *data, int state, int x, int y, int flag
switch (c) {
case 0:
if (_vm->_game.heversion >= 99) {
- ret = getRawWizPixelColor(wizd, x, y, w, h, 1, _vm->VAR(_vm->VAR_WIZ_TCOLOR)) != _vm->VAR(_vm->VAR_WIZ_TCOLOR) ? 1 : 0;
+ ret = getRawWizPixelColor(wizd, x, y, w, h, 1, _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR)) != _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR) ? 1 : 0;
} else {
ret = 0;
}
@@ -2987,7 +3107,7 @@ int Wiz::isWizPixelNonTransparent(uint8 *data, int state, int x, int y, int flag
break;
#ifdef USE_RGB_COLOR
case 2:
- ret = getRawWizPixelColor(wizd, x, y, w, h, 2, _vm->VAR(_vm->VAR_WIZ_TCOLOR)) != _vm->VAR(_vm->VAR_WIZ_TCOLOR) ? 1 : 0;
+ ret = getRawWizPixelColor(wizd, x, y, w, h, 2, _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR)) != _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR) ? 1 : 0;
break;
case 4: {
uint16 color = 0xffff;
@@ -3028,23 +3148,23 @@ uint16 Wiz::getWizPixelColor(int resNum, int state, int x, int y) {
switch (c) {
case 0:
if (_vm->_game.heversion >= 99) {
- color = getRawWizPixelColor(wizd, x, y, w, h, 1, _vm->VAR(_vm->VAR_WIZ_TCOLOR));
+ color = getRawWizPixelColor(wizd, x, y, w, h, 1, _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR));
} else {
- color = _vm->VAR(_vm->VAR_WIZ_TCOLOR);
+ color = _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR);
}
break;
case 1:
- color = getWizPixelColor(wizd, x, y, w, h, 1, _vm->VAR(_vm->VAR_WIZ_TCOLOR));
+ color = getWizPixelColor(wizd, x, y, w, h, 1, _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR));
break;
#ifdef USE_RGB_COLOR
case 2:
- color = getRawWizPixelColor(wizd, x, y, w, h, 2, _vm->VAR(_vm->VAR_WIZ_TCOLOR));
+ color = getRawWizPixelColor(wizd, x, y, w, h, 2, _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR));
break;
case 4:
copyCompositeWizImage((byte *)&color, data, wizd, 0, 2, kDstMemory, 1, 1, -x, -y, w, h, state, 0, 0, 0, 0, 2, 0, 0);
break;
case 5:
- color = getWizPixelColor(wizd, x, y, w, h, 2, _vm->VAR(_vm->VAR_WIZ_TCOLOR));
+ color = getWizPixelColor(wizd, x, y, w, h, 2, _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR));
break;
#endif
default:
diff --git a/engines/scumm/he/wiz_he.h b/engines/scumm/he/wiz_he.h
index 0f0078b3e94..476b4716cac 100644
--- a/engines/scumm/he/wiz_he.h
+++ b/engines/scumm/he/wiz_he.h
@@ -186,6 +186,13 @@ struct WizImageCommand {
}
};
+struct WizSimpleBitmap {
+ int32 *bufferPtr;
+ int bitmapWidth;
+ int bitmapHeight;
+};
+
+
enum WizRenderingFlags {
// Standard rendering flags
kWRFUsePalette = 0x00000001,
@@ -311,6 +318,12 @@ enum WizMoonSystemBits {
kWMSBRopParamRShift = 8
};
+enum WizEclipseConstants {
+ kWECFixedSize = 16,
+ kWECPiOver2 = 102944, // Fixed point PI/2
+ kWECHalf = 32768 // Fixed point 1/2
+};
+
enum {
kWizXMap = 0,
kWizRMap,
@@ -356,6 +369,8 @@ public:
void polygonTransform(int resNum, int state, int po_x, int po_y, int angle, int zoom, Common::Point *vert);
void dwCreateRawWiz(int imageNum, int w, int h, int flags, int bitsPerPixel, int optionalSpotX, int optionalSpotY);
+ bool dwSetSimpleBitmapStructFromImage(int imageNum, int imageState, WizSimpleBitmap *destBM);
+
void processWizImageCmd(const WizImageCommand *params);
void processWizImageCaptureCmd(const WizImageCommand *params);
void processWizImagePolyCaptureCmd(const WizImageCommand *params);
@@ -378,11 +393,15 @@ public:
void getWizImageDim(uint8 *dataPtr, int state, int32 &w, int32 &h);
int getWizImageStates(int resnum);
int getWizImageStates(const uint8 *ptr);
+ void *getWizStateHeaderPrim(int resNum, int state);
+ void *getWizStateDataPrim(int resNum, int state);
+
int isWizPixelNonTransparent(int resnum, int state, int x, int y, int flags);
int isWizPixelNonTransparent(uint8 *data, int state, int x, int y, int flags);
int isPixelNonTransparent(const uint8 *data, int x, int y, int w, int h, uint8 bitdepth);
uint16 getWizPixelColor(int resnum, int state, int x, int y);
int getWizImageData(int resNum, int state, int type);
+ bool isUncompressedFormatTypeID(int id);
void flushWizBuffer();
@@ -438,6 +457,28 @@ public:
private:
ScummEngine_v71he *_vm;
+
+ /* Wiz Drawing Primitives
+ *
+ * These primitives are slightly different and less precise
+ * than the ones available in our Graphics subsystem.
+ * But they are more accurate in the context of SCUMM HE graphics.
+ * So leave them be and resist the urge to replace them with our own
+ * primitives, please :-P
+ */
+
+ int pgReadPixel(const WizSimpleBitmap *srcBM, int x, int y, int defaultValue);
+ void pgWritePixel(WizSimpleBitmap *srcBM, int x, int y, int32 value);
+ void pgClippedWritePixel(WizSimpleBitmap *srcBM, int x, int y, const Common::Rect *clipRectPtr, int32 value);
+ void pgClippedLineDraw(WizSimpleBitmap *destBM, int asx, int asy, int aex, int aey, const Common::Rect *clipRectPtr, int32 value);
+ void pgClippedThickLineDraw(WizSimpleBitmap *destBM, int asx, int asy, int aex, int aey, const Common::Rect *clipRectPtr, int iLineThickness, int32 value);
+ void pgDrawClippedEllipse(WizSimpleBitmap *pDestBitmap, int iPX, int iPY, int iQX, int iQY, int iKX, int iKY, int iLOD, const Common::Rect *pClipRectPtr, int iThickness, int32 aColor);
+ void pgDrawSolidRect(WizSimpleBitmap *destBM, const Common::Rect *rectPtr, int32 color);
+
+ bool findRectOverlap(Common::Rect *destRectPtr, const Common::Rect *sourceRectPtr);
+ bool isPointInRect(Common::Rect *r, Common::Point *pt);
+ void makeSizedRectAt(Common::Rect *rectPtr, int x, int y, int width, int height);
+ void makeSizedRect(Common::Rect *rectPtr, int width, int height);
};
} // End of namespace Scumm
diff --git a/engines/scumm/he/wiz_primitives_he.cpp b/engines/scumm/he/wiz_primitives_he.cpp
new file mode 100644
index 00000000000..9232a91f8f9
--- /dev/null
+++ b/engines/scumm/he/wiz_primitives_he.cpp
@@ -0,0 +1,458 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifdef ENABLE_HE
+
+#include "common/archive.h"
+#include "common/system.h"
+#include "common/math.h"
+#include "graphics/cursorman.h"
+#include "graphics/primitives.h"
+#include "scumm/he/intern_he.h"
+#include "scumm/resource.h"
+#include "scumm/scumm.h"
+#include "scumm/util.h"
+#include "scumm/he/wiz_he.h"
+#include "scumm/he/moonbase/moonbase.h"
+
+namespace Scumm {
+
+int Wiz::pgReadPixel(const WizSimpleBitmap *srcBM, int x, int y, int defaultValue) {
+ // RECHECK RAWPIXEL
+ if ((x < 0) || (y < 0) || (x >= srcBM->bitmapWidth) || (y >= srcBM->bitmapHeight)) {
+ return defaultValue;
+ } else {
+ return *(srcBM->bufferPtr + y * srcBM->bitmapWidth + x);
+ }
+}
+
+void Wiz::pgWritePixel(WizSimpleBitmap *srcBM, int x, int y, int32 value) {
+ // RECHECK RAWPIXEL
+ if ((x >= 0) && (y >= 0) && (x < srcBM->bitmapWidth) && (y < srcBM->bitmapHeight)) {
+ *(srcBM->bufferPtr + y * srcBM->bitmapWidth + x) = value;
+ }
+}
+
+void Wiz::pgClippedWritePixel(WizSimpleBitmap *srcBM, int x, int y, const Common::Rect *clipRectPtr, int32 value) {
+ // RECHECK RAWPIXEL
+ if ((x >= clipRectPtr->left) && (y >= clipRectPtr->top) && (x <= clipRectPtr->right) && (y <= clipRectPtr->bottom)) {
+ *(srcBM->bufferPtr + y * srcBM->bitmapWidth + x) = value;
+ }
+}
+
+#define GET_SIGN(x) ((x) > 0 ? 1 : ((x) == 0 ? 0 : (-1)))
+
+void Wiz::pgClippedLineDraw(WizSimpleBitmap *destBM, int asx, int asy, int aex, int aey, const Common::Rect *clipRectPtr, int32 value) {
+ // RECHECK RAWPIXEL
+ int x1, y1, x2, y2, d, dx, dy, sx, sy, incrA, incrB;
+
+ x1 = asx;
+ y1 = asy;
+ x2 = aex;
+ y2 = aey;
+ sx = GET_SIGN(x2 - x1);
+ sy = GET_SIGN(y2 - y1);
+ dx = abs(x2 - x1);
+ dy = abs(y2 - y1);
+
+ pgClippedWritePixel(destBM, x1, y1, clipRectPtr, value);
+
+ if (dx >= dy) {
+ d = (dy * 2) - dx;
+ incrA = dy * 2;
+ incrB = (dy - dx) * 2;
+
+ while (x1 != x2) {
+ if (d <= 0) {
+ d += incrA;
+ } else {
+ d += incrB;
+ y1 += sy;
+ }
+
+ x1 += sx;
+ pgClippedWritePixel(destBM, x1, y1, clipRectPtr, value);
+ }
+ } else {
+ d = (dx * 2) - dy;
+ incrA = dx * 2;
+ incrB = (dx - dy) * 2;
+
+ while (y1 != y2) {
+ if (d <= 0) {
+ d += incrA;
+ } else {
+ d += incrB;
+ x1 += sx;
+ }
+
+ y1 += sy;
+ pgClippedWritePixel(destBM, x1, y1, clipRectPtr, value);
+ }
+ }
+}
+
+#undef GET_SIGN
+
+struct WizScanLine {
+ int iXMin;
+ int iXMax;
+};
+
+int scanEdge(WizScanLine *aScanLines, int iScanLineStart, bool bLeftSide, int iX1, int iY1, int iX2, int iY2) {
+ int iCurScanLine = iScanLineStart;
+ int iDX, iDY;
+ double fInverseSlope;
+
+ // Get deltas
+ iDX = iX2 - iX1;
+ iDY = iY2 - iY1;
+
+ // Protect against horizontal lines
+ if (iDY <= 0) {
+ return 0;
+ }
+
+ // Calculate inverse slope
+ fInverseSlope = (double)iDX / (double)iDY;
+
+ for (int iY = iY1; iY < iY2; ++iY) {
+ if (bLeftSide) {
+ aScanLines[iCurScanLine].iXMin = iX1 + (int)(ceil((iY - iY1) * fInverseSlope));
+ } else {
+ aScanLines[iCurScanLine].iXMax = iX1 + (int)(ceil((iY - iY1) * fInverseSlope));
+ }
+
+ ++iCurScanLine;
+ }
+
+ return iCurScanLine;
+}
+
+void Wiz::pgClippedThickLineDraw(WizSimpleBitmap *destBM, int asx, int asy, int aex, int aey, const Common::Rect *clipRectPtr, int iLineThickness, int32 value) {
+ // RECHECK RAWPIXEL
+ int iDX = aex - asx;
+ int iDY = aey - asy;
+ double fDistance = sqrt((iDX * iDX) + (iDY * iDY));
+
+ // if distance is 0, don't draw
+ if (fDistance == 0) {
+ return;
+ }
+
+ // The ratio of half the line thickness to the length of the line...
+ double fScale = (double)(iLineThickness) / (2 * fDistance);
+
+ // The x and y increments from an endpoint needed to create a rectangle...
+ float fDDX = -fScale * (float)iDY;
+ float fDDY = fScale * (float)iDX;
+
+ if (fDDX > 0) { // round off
+ fDDX += 0.5;
+ } else {
+ fDDX -= 0.5;
+ }
+
+ if (fDDY > 0) {
+ fDDY += 0.5;
+ } else {
+ fDDY -= 0.5;
+ }
+
+ int iCompDX = (int)fDDX;
+ int iCompDY = (int)fDDY;
+
+ int aSortOrder[4] = { 0, 0, 0, 0 };
+
+ // determine point order of polygons based on line orientation
+ // topmost (and topleft in case of x or y = 0)
+ if ((iDX >= 0) && (iDY < 0)) {
+ aSortOrder[0] = 1;
+ aSortOrder[1] = 2;
+ aSortOrder[2] = 0;
+ aSortOrder[3] = 3;
+ }
+
+ if ((iDX > 0) && (iDY >= 0)) {
+ aSortOrder[0] = 0;
+ aSortOrder[1] = 1;
+ aSortOrder[2] = 3;
+ aSortOrder[3] = 2;
+ }
+
+ if ((iDX <= 0) && (iDY > 0)) {
+ aSortOrder[0] = 3;
+ aSortOrder[1] = 0;
+ aSortOrder[2] = 2;
+ aSortOrder[3] = 1;
+ }
+
+ if ((iDX < 0) && (iDY <= 0)) {
+ aSortOrder[0] = 2;
+ aSortOrder[1] = 3;
+ aSortOrder[2] = 1;
+ aSortOrder[3] = 0;
+ }
+
+ // Now we can compute the corner points...
+
+ int *xPoints = new int[4];
+ int *yPoints = new int[4];
+ int aLeftNeighborTable[4] = {1, 2, 3, 0};
+ int aRightNeighborTable[4] = {3, 2, 1, 0};
+
+ xPoints[aSortOrder[0]] = asx - iCompDX;
+ yPoints[aSortOrder[0]] = asy - iCompDY;
+
+ xPoints[aSortOrder[1]] = asx + iCompDX;
+ yPoints[aSortOrder[1]] = asy + iCompDY;
+
+ xPoints[aSortOrder[2]] = aex - iCompDX;
+ yPoints[aSortOrder[2]] = aey - iCompDY;
+
+ xPoints[aSortOrder[3]] = aex + iCompDX;
+ yPoints[aSortOrder[3]] = aey + iCompDY;
+
+ // determine how tall (how many scan lines) the polygon is
+ int iNumScanLines = yPoints[2] - yPoints[0];
+
+ // create scan line list
+ WizScanLine *aScanLines = new WizScanLine[iNumScanLines];
+
+ // scan left side
+ int iNextScanLine = scanEdge(aScanLines, 0, true, xPoints[0], yPoints[0], xPoints[1], yPoints[1]);
+ scanEdge(aScanLines, iNextScanLine, true, xPoints[1], yPoints[1], xPoints[2], yPoints[2]);
+
+ // scan right side
+ iNextScanLine = scanEdge(aScanLines, 0, false, xPoints[0], yPoints[0], xPoints[3], yPoints[3]);
+ scanEdge(aScanLines, iNextScanLine, false, xPoints[3], yPoints[3], xPoints[2], yPoints[2]);
+
+ // draw polygon
+ int iCurX, iCurY;
+ for (int iWhichScanLine = 0; iWhichScanLine < iNumScanLines; ++iWhichScanLine) {
+ iCurY = iWhichScanLine + yPoints[0];
+ for (iCurX = aScanLines[iWhichScanLine].iXMin; iCurX < aScanLines[iWhichScanLine].iXMax; ++iCurX) {
+ pgClippedWritePixel(destBM, iCurX, iCurY, clipRectPtr, value);
+ }
+ }
+}
+
+int convertToFixed(int iNumber) {
+ return (iNumber << kWECFixedSize);
+}
+
+int convertFromFixed(int iFixedNumber) {
+ return (iFixedNumber >> kWECFixedSize);
+}
+
+void Wiz::pgDrawClippedEllipse(WizSimpleBitmap *pDestBitmap, int iPX, int iPY, int iQX, int iQY, int iKX, int iKY, int iLOD, const Common::Rect *pClipRectPtr, int iThickness, int32 aColor) {
+ // RECHECK RAWPIXEL
+ // since this is fixed point, limit the LOD to 14 bits precision
+ if (iLOD > kWECFixedSize - 2) {
+ iLOD = kWECFixedSize - 2;
+ }
+
+ // determine the rest of the rectangle verts using the midpoint formula
+ int iKX1 = (2 * iQX) - iKX;
+ int iKY1 = (2 * iQY) - iKY;
+ int iKX3 = (2 * iPX) - iKX;
+ int iKY3 = (2 * iPY) - iKY;
+ int iKX2 = iKX1 - (iKX - iKX3);
+ int iKY2 = iKY1 + (iKY3 - iKY);
+
+ int iOpPX = (iKX1 + iKX2) / 2;
+ int iOpPY = (iKY1 + iKY2) / 2;
+ int iOpQX = (iKX3 + iKX2) / 2;
+ int iOpQY = (iKY3 + iKY2) / 2;
+
+ bool bFirstPass = true;
+ int x1 = 0, y1 = 0, x2 = 0, y2 = 0, iFirstX = 0, iFirstY = 0;
+
+ // Loop through each quadrant
+ for (int iSide = 0; iSide < 4; ++iSide) {
+ int xP = 0, yP = 0, xQ = 0, yQ = 0, xK = 0, yK = 0;
+
+ // Determine quadrant and convert input to fixed point
+ switch (iSide) {
+ case 0:
+ xP = convertToFixed(iPX);
+ yP = convertToFixed(iPY);
+ xQ = convertToFixed(iQX);
+ yQ = convertToFixed(iQY);
+ xK = convertToFixed(iKX);
+ yK = convertToFixed(iKY);
+ break;
+ case 1:
+ xP = convertToFixed(iQX);
+ yP = convertToFixed(iQY);
+ xQ = convertToFixed(iOpPX);
+ yQ = convertToFixed(iOpPY);
+ xK = convertToFixed(iKX1);
+ yK = convertToFixed(iKY1);
+ break;
+ case 2:
+ xP = convertToFixed(iOpPX);
+ yP = convertToFixed(iOpPY);
+ xQ = convertToFixed(iOpQX);
+ yQ = convertToFixed(iOpQY);
+ xK = convertToFixed(iKX2);
+ yK = convertToFixed(iKY2);
+ break;
+ case 3:
+ xP = convertToFixed(iOpQX);
+ yP = convertToFixed(iOpQY);
+ xQ = convertToFixed(iPX);
+ yQ = convertToFixed(iPY);
+ xK = convertToFixed(iKX3);
+ yK = convertToFixed(iKY3);
+ break;
+ }
+
+ int vx, ux, vy, uy, w, xJ, yJ;
+
+ vx = xK - xQ; // Displacements from center
+ ux = xK - xP;
+ vy = yK - yQ;
+ uy = yK - yP;
+ xJ = xP - vx + kWECHalf; // Center of ellipse J
+ yJ = yP - vy + kWECHalf;
+
+ ux -= (w = ux >> (2 * iLOD + 3)); // Cancel 2nd-order error
+ ux -= (w >>= (2 * iLOD + 4)); // Cancel 4th-order error
+ ux -= w >> (2 * iLOD + 3); // Cancel 6th-order error
+ ux += vx >> (iLOD + 1); // Cancel 1st-order error
+ uy -= (w = uy >> (2 * iLOD + 3)); // Cancel 2nd-order error
+ uy -= (w >>= (2 * iLOD + 4)); // Cancel 4th-order error
+ uy -= w >> (2 * iLOD + 3); // Cancel 6th-order error
+ uy += vy >> (iLOD + 1); // Cancel 1st-order error
+
+ for (int i = (kWECPiOver2 << iLOD) >> 16; i >= 0; --i) {
+ x2 = (xJ + vx) >> 16;
+ y2 = (yJ + vy) >> 16;
+
+ if (bFirstPass) {
+ x1 = x2;
+ y1 = y2;
+ iFirstX = x1;
+ iFirstY = y1;
+ bFirstPass = false;
+ } else {
+ if (iThickness > 0) {
+ pgClippedThickLineDraw(pDestBitmap, x1, y1, x2, y2, pClipRectPtr, 5, aColor);
+ } else {
+ // specific to print pack, should be moved to a thick pixel
+ pgClippedWritePixel(pDestBitmap, x2, y2, pClipRectPtr, aColor);
+ pgClippedWritePixel(pDestBitmap, x2 + 1, y2, pClipRectPtr, aColor);
+ pgClippedWritePixel(pDestBitmap, x2 - 1, y2, pClipRectPtr, aColor);
+ pgClippedWritePixel(pDestBitmap, x2, y2 + 1, pClipRectPtr, aColor);
+ pgClippedWritePixel(pDestBitmap, x2, y2 - 1, pClipRectPtr, aColor);
+ pgClippedWritePixel(pDestBitmap, x2 + 1, y2 + 1, pClipRectPtr, aColor);
+ pgClippedWritePixel(pDestBitmap, x2 + 1, y2 - 1, pClipRectPtr, aColor);
+ pgClippedWritePixel(pDestBitmap, x2 - 1, y2 + 1, pClipRectPtr, aColor);
+ pgClippedWritePixel(pDestBitmap, x2 - 1, y2 - 1, pClipRectPtr, aColor);
+ }
+ x1 = x2;
+ y1 = y2;
+ }
+
+ ux -= vx >> iLOD;
+ vx += ux >> iLOD;
+ uy -= vy >> iLOD;
+ vy += uy >> iLOD;
+ }
+ }
+
+ if (iThickness > 0) {
+ pgClippedThickLineDraw(pDestBitmap, x2, y2, iFirstX, iFirstY, pClipRectPtr, 5, aColor);
+ } else {
+ pgClippedLineDraw(pDestBitmap, x2, y2, iFirstX, iFirstY, pClipRectPtr, aColor);
+ }
+}
+
+void Wiz::pgDrawSolidRect(WizSimpleBitmap *destBM, const Common::Rect *rectPtr, int32 color) {
+ int32 *d; // RECHECK RAWPIXEL
+ int cw, dw, ch;
+ int x1 = rectPtr->left, y1 = rectPtr->top, x2 = rectPtr->right, y2 = rectPtr->bottom;
+
+ // Common calcs...
+ dw = destBM->bitmapWidth;
+ cw = x2 - x1 + 1;
+ ch = y2 - y1 + 1;
+ d = destBM->bufferPtr + y1 * dw + x1;
+
+ if (cw > 1) {
+ while (--ch >= 0) {
+ memset(d, color, cw); // RECHECK RAWPIXEL
+ d += dw;
+ }
+ } else {
+ while (--ch >= 0) {
+ *d = color;
+ d += dw;
+ }
+ }
+}
+
+bool Wiz::findRectOverlap(Common::Rect *destRectPtr, const Common::Rect *sourceRectPtr) {
+ // Make sure only points inside the viewPort are being set...
+ if ((destRectPtr->left > sourceRectPtr->right) || (destRectPtr->top > sourceRectPtr->bottom) ||
+ (destRectPtr->right < sourceRectPtr->left) || (destRectPtr->bottom < sourceRectPtr->top)) {
+ return false;
+ }
+
+ // Perform the actual clipping
+ if (destRectPtr->left < sourceRectPtr->left) {
+ destRectPtr->left = sourceRectPtr->left;
+ }
+
+ if (destRectPtr->top < sourceRectPtr->top) {
+ destRectPtr->top = sourceRectPtr->top;
+ }
+
+ if (destRectPtr->right > sourceRectPtr->right) {
+ destRectPtr->right = sourceRectPtr->right;
+ }
+
+ if (destRectPtr->bottom > sourceRectPtr->bottom) {
+ destRectPtr->bottom = sourceRectPtr->bottom;
+ }
+
+ return true;
+}
+
+bool Wiz::isPointInRect(Common::Rect* r, Common::Point* pt) {
+ return (pt->x >= r->left) && (pt->x <= r->right) && (pt->y >= r->top) && (pt->y <= r->bottom);
+}
+
+void Wiz::makeSizedRectAt(Common::Rect *rectPtr, int x, int y, int width, int height) {
+ rectPtr->left = x;
+ rectPtr->top = y;
+ rectPtr->right = x + width - 1;
+ rectPtr->bottom = y + height - 1;
+}
+
+void Wiz::makeSizedRect(Common::Rect *rectPtr, int width, int height) {
+ makeSizedRectAt(rectPtr, 0, 0, width, height);
+}
+
+} // End of namespace Scumm
+
+#endif // ENABLE_HE
diff --git a/engines/scumm/module.mk b/engines/scumm/module.mk
index 27c38dd11b6..7ab9105ce6f 100644
--- a/engines/scumm/module.mk
+++ b/engines/scumm/module.mk
@@ -153,6 +153,7 @@ MODULE_OBJS += \
he/script_v100he.o \
he/sprite_he.o \
he/wiz_he.o \
+ he/wiz_primitives_he.o \
he/localizer.o \
he/logic/baseball2001.o \
he/logic/basketball.o \
diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
index 06ff4a94d8c..a62fb7c0968 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -714,7 +714,7 @@ ScummEngine_v71he::ScummEngine_v71he(OSystem *syst, const DetectorResult &dr)
_skipProcessActors = 0;
- VAR_WIZ_TCOLOR = 0xFF;
+ VAR_WIZ_TRANSPARENT_COLOR = 0xFF;
}
ScummEngine_v71he::~ScummEngine_v71he() {
diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h
index 10ad5fdbc52..957807a4bbd 100644
--- a/engines/scumm/scumm.h
+++ b/engines/scumm/scumm.h
@@ -1845,6 +1845,8 @@ public:
byte VAR_ERROR_FLAG = 0xFF; // HE70-90
byte VAR_OPERATION_FAILURE = 0xFF; // HE99+
+ byte VAR_COLOR_BLACK = 0xFF;
+
// Exists both in V7 and in V72HE:
byte VAR_NUM_GLOBAL_OBJS = 0xFF;
diff --git a/engines/scumm/vars.cpp b/engines/scumm/vars.cpp
index ac6269c70fe..6c6214cfcb7 100644
--- a/engines/scumm/vars.cpp
+++ b/engines/scumm/vars.cpp
@@ -321,6 +321,7 @@ void ScummEngine_v80he::setupScummVars() {
VAR_SOUND_CALLBACK_SCRIPT = 87;
VAR_NUM_SOUND_CHANNELS = 88;
VAR_COLOR_DEPTH = 89;
+ VAR_COLOR_BLACK = 93;
VAR_REDRAW_ALL_ACTORS = 95;
}
@@ -337,7 +338,7 @@ void ScummEngine_v90he::setupScummVars() {
VAR_NUM_SPRITES = 106;
VAR_U32_VERSION = 107;
VAR_U32_ARRAY_UNK = 116;
- VAR_WIZ_TCOLOR = 117;
+ VAR_WIZ_TRANSPARENT_COLOR = 117;
VAR_OPERATION_FAILURE = 119;
VAR_START_DYN_SOUND_CHANNELS = 120;
}
@@ -728,7 +729,7 @@ void ScummEngine_v90he::resetScummVars() {
if (_game.heversion >= 95) {
VAR(VAR_NUM_SPRITE_GROUPS) = MAX(64, _numSprites / 4) - 1;
VAR(VAR_NUM_SPRITES) = _numSprites - 1;
- VAR(VAR_WIZ_TCOLOR) = 5;
+ VAR(VAR_WIZ_TRANSPARENT_COLOR) = 5;
VAR(VAR_START_DYN_SOUND_CHANNELS) = 9;
}
if (_game.heversion >= 98) {
Commit: be804a82ebb467ccfd9ef86ff3b009120f5316f4
https://github.com/scummvm/scummvm/commit/be804a82ebb467ccfd9ef86ff3b009120f5316f4
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Fix primitives after testing them
Changed paths:
engines/scumm/he/wiz_he.cpp
engines/scumm/he/wiz_he.h
engines/scumm/he/wiz_primitives_he.cpp
diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp
index aff90c4f3fa..7327e537e30 100644
--- a/engines/scumm/he/wiz_he.cpp
+++ b/engines/scumm/he/wiz_he.cpp
@@ -40,6 +40,7 @@ Wiz::Wiz(ScummEngine_v71he *vm) : _vm(vm) {
memset(&_polygons, 0, sizeof(_polygons));
_cursorImage = false;
_rectOverrideEnabled = false;
+ _uses16BitColor = (_vm->_game.features & GF_16BIT_COLOR);
}
void Wiz::clearWizBuffer() {
@@ -2484,6 +2485,7 @@ bool Wiz::dwSetSimpleBitmapStructFromImage(int imageNum, int imageState, WizSimp
int compType, imageWidth, imageHeight;
byte *wizHeader;
byte *dataPtr;
+ int blockHeaderSize = 8;
// Get the image header
wizHeader = (byte *)getWizStateHeaderPrim(imageNum, imageState);
@@ -2493,14 +2495,14 @@ bool Wiz::dwSetSimpleBitmapStructFromImage(int imageNum, int imageState, WizSimp
}
// Double check the image header compression type
- compType = READ_LE_UINT32(wizHeader);
+ compType = READ_LE_UINT32(wizHeader + blockHeaderSize);
if (!isUncompressedFormatTypeID(compType)) {
return false;
}
- imageWidth = READ_LE_UINT32(wizHeader + 4);
- imageHeight = READ_LE_UINT32(wizHeader + 8);
+ imageWidth = READ_LE_UINT32(wizHeader + blockHeaderSize + 4);
+ imageHeight = READ_LE_UINT32(wizHeader + blockHeaderSize + 8);
// Do some fun stuff
dataPtr = (byte *)getWizStateDataPrim(imageNum, imageState);
@@ -2510,7 +2512,7 @@ bool Wiz::dwSetSimpleBitmapStructFromImage(int imageNum, int imageState, WizSimp
}
// Hook up the image info to the simple bitmap info
- destBM->bufferPtr = (int32 *)(dataPtr);
+ destBM->bufferPtr = (RAWPIXEL *)(dataPtr + blockHeaderSize);
destBM->bitmapWidth = imageWidth;
destBM->bitmapHeight = imageHeight;
@@ -2521,7 +2523,7 @@ void Wiz::processWizImageRenderRectCmd(const WizImageCommand *params) {
Common::Rect renderRect, clipRect, workClipRect;
int whichState, w, h, whichImage;
WizSimpleBitmap renderBitmap;
- int32 whatColor;
+ RAWPIXEL whatColor;
// What state is going to rendered into?
if (params->actionFlags & kWAFState) {
@@ -2558,7 +2560,6 @@ void Wiz::processWizImageRenderRectCmd(const WizImageCommand *params) {
// What is the rendering color
if (params->actionFlags & kWAFColor) {
whatColor = params->colorValue;
-
} else {
whatColor = _vm->VAR(_vm->VAR_COLOR_BLACK);
}
@@ -2579,7 +2580,7 @@ void Wiz::processWizImageRenderLineCmd(const WizImageCommand *params) {
Common::Rect clipRect, workClipRect;
int whichState, w, h, whichImage;
WizSimpleBitmap renderBitmap;
- int32 whatColor;
+ RAWPIXEL whatColor;
int iPropertyNumber = 0, iPropertyValue = 0;
if (!(params->actionFlags & kWAFRenderCoords)) {
@@ -2655,7 +2656,7 @@ void Wiz::processWizImageRenderPixelCmd(const WizImageCommand *params) {
Common::Rect clipRect, workClipRect;
int whichState, w, h, whichImage;
WizSimpleBitmap renderBitmap;
- int32 whatColor;
+ RAWPIXEL whatColor;
Common::Point pt;
if (params->actionFlags & kWAFRenderCoords) {
@@ -3054,13 +3055,13 @@ int Wiz::getWizImageStates(const uint8 *dataPtr) {
void *Wiz::getWizStateHeaderPrim(int resNum, int state) {
uint8 *data = _vm->getResourceAddress(rtImage, resNum);
assert(data);
- return _vm->findWrappedBlock(MKTAG('W', 'I', 'Z', 'H'), data, state, false);
+ return _vm->findWrappedBlock(MKTAG('W', 'I', 'Z', 'H'), data, state, false) - 8;
}
void *Wiz::getWizStateDataPrim(int resNum, int state) {
uint8 *data = _vm->getResourceAddress(rtImage, resNum);
assert(data);
- return _vm->findWrappedBlock(MKTAG('W', 'I', 'Z', 'D'), data, state, false);
+ return _vm->findWrappedBlock(MKTAG('W', 'I', 'Z', 'D'), data, state, false) - 8;
}
int Wiz::isWizPixelNonTransparent(int resNum, int state, int x, int y, int flags) {
@@ -3079,7 +3080,7 @@ int Wiz::isWizPixelNonTransparent(uint8 *data, int state, int x, int y, int flag
int h = READ_LE_UINT32(wizh + 0x8);
if (_vm->_game.id == GID_MOONBASE) {
- uint16 color = 0xffff;
+ RAWPIXEL color = 0xffff;
drawWizImageEx((byte *)&color, data, 0, 2, kDstMemory, 1, 1, -x, -y, w, h, state, 0, 0, 0, 0, 2, 0, 0);
return color != 0xffff;
diff --git a/engines/scumm/he/wiz_he.h b/engines/scumm/he/wiz_he.h
index 476b4716cac..0e36d8ffda4 100644
--- a/engines/scumm/he/wiz_he.h
+++ b/engines/scumm/he/wiz_he.h
@@ -50,6 +50,8 @@ namespace Scumm {
#define DW_SAVE_PCX_FORMAT 1
#define DW_SAVE_RAW_FORMAT 2
+typedef uint16 RAWPIXEL;
+
struct WizPolygon {
Common::Point vert[5];
Common::Rect bound;
@@ -99,7 +101,7 @@ struct WizEllipseProperties {
int kx;
int ky;
int lod;
- int color;
+ RAWPIXEL color;
};
struct WizExtendedRenderInfo {
@@ -140,7 +142,7 @@ struct WizImageCommand {
int remapCount;
int destImageNumber;
int zbufferImage;
- uint16 colorValue;
+ RAWPIXEL colorValue;
WizFontProperties fontProperties;
WizEllipseProperties ellipseProperties;
Common::Rect renderCoords;
@@ -187,7 +189,7 @@ struct WizImageCommand {
};
struct WizSimpleBitmap {
- int32 *bufferPtr;
+ RAWPIXEL *bufferPtr;
int bitmapWidth;
int bitmapHeight;
};
@@ -356,6 +358,7 @@ public:
Common::Rect _rectOverride;
bool _cursorImage;
bool _rectOverrideEnabled;
+ bool _uses16BitColor = false;
void polygonClear();
void polygonLoad(const uint8 *polData);
@@ -448,10 +451,10 @@ public:
template<int type> static void write16BitColor(uint8 *dst, const uint8 *src, int dstType, const uint8 *xmapPtr);
#endif
template<int type> static void write8BitColor(uint8 *dst, const uint8 *src, int dstType, const uint8 *palPtr, const uint8 *xmapPtr, uint8 bitDepth);
- static void writeColor(uint8 *dstPtr, int dstType, uint16 color);
+ static void writeColor(uint8 *dstPtr, int dstType, RAWPIXEL color);
- uint16 getWizPixelColor(const uint8 *data, int x, int y, int w, int h, uint8 bitDepth, uint16 color);
- uint16 getRawWizPixelColor(const uint8 *data, int x, int y, int w, int h, uint8 bitDepth, uint16 color);
+ uint16 getWizPixelColor(const uint8 *data, int x, int y, int w, int h, uint8 bitDepth, RAWPIXEL color);
+ uint16 getRawWizPixelColor(const uint8 *data, int x, int y, int w, int h, uint8 bitDepth, RAWPIXEL color);
void computeWizHistogram(uint32 *histogram, const uint8 *data, const Common::Rect& rCapt);
void computeRawWizHistogram(uint32 *histogram, const uint8 *data, int srcPitch, const Common::Rect& rCapt);
@@ -468,12 +471,12 @@ private:
*/
int pgReadPixel(const WizSimpleBitmap *srcBM, int x, int y, int defaultValue);
- void pgWritePixel(WizSimpleBitmap *srcBM, int x, int y, int32 value);
- void pgClippedWritePixel(WizSimpleBitmap *srcBM, int x, int y, const Common::Rect *clipRectPtr, int32 value);
- void pgClippedLineDraw(WizSimpleBitmap *destBM, int asx, int asy, int aex, int aey, const Common::Rect *clipRectPtr, int32 value);
- void pgClippedThickLineDraw(WizSimpleBitmap *destBM, int asx, int asy, int aex, int aey, const Common::Rect *clipRectPtr, int iLineThickness, int32 value);
- void pgDrawClippedEllipse(WizSimpleBitmap *pDestBitmap, int iPX, int iPY, int iQX, int iQY, int iKX, int iKY, int iLOD, const Common::Rect *pClipRectPtr, int iThickness, int32 aColor);
- void pgDrawSolidRect(WizSimpleBitmap *destBM, const Common::Rect *rectPtr, int32 color);
+ void pgWritePixel(WizSimpleBitmap *srcBM, int x, int y, RAWPIXEL value);
+ void pgClippedWritePixel(WizSimpleBitmap *srcBM, int x, int y, const Common::Rect *clipRectPtr, RAWPIXEL value);
+ void pgClippedLineDraw(WizSimpleBitmap *destBM, int asx, int asy, int aex, int aey, const Common::Rect *clipRectPtr, RAWPIXEL value);
+ void pgClippedThickLineDraw(WizSimpleBitmap *destBM, int asx, int asy, int aex, int aey, const Common::Rect *clipRectPtr, int iLineThickness, RAWPIXEL value);
+ void pgDrawClippedEllipse(WizSimpleBitmap *pDestBitmap, int iPX, int iPY, int iQX, int iQY, int iKX, int iKY, int iLOD, const Common::Rect *pClipRectPtr, int iThickness, RAWPIXEL aColor);
+ void pgDrawSolidRect(WizSimpleBitmap *destBM, const Common::Rect *rectPtr, RAWPIXEL color);
bool findRectOverlap(Common::Rect *destRectPtr, const Common::Rect *sourceRectPtr);
bool isPointInRect(Common::Rect *r, Common::Point *pt);
diff --git a/engines/scumm/he/wiz_primitives_he.cpp b/engines/scumm/he/wiz_primitives_he.cpp
index 9232a91f8f9..37cdccd0a0c 100644
--- a/engines/scumm/he/wiz_primitives_he.cpp
+++ b/engines/scumm/he/wiz_primitives_he.cpp
@@ -36,32 +36,40 @@
namespace Scumm {
int Wiz::pgReadPixel(const WizSimpleBitmap *srcBM, int x, int y, int defaultValue) {
- // RECHECK RAWPIXEL
if ((x < 0) || (y < 0) || (x >= srcBM->bitmapWidth) || (y >= srcBM->bitmapHeight)) {
return defaultValue;
} else {
- return *(srcBM->bufferPtr + y * srcBM->bitmapWidth + x);
+ if (_uses16BitColor) {
+ return *(srcBM->bufferPtr + y * srcBM->bitmapWidth + x);
+ } else {
+ return *(((uint8 *)srcBM->bufferPtr) + y * srcBM->bitmapWidth + x);
+ }
}
}
-void Wiz::pgWritePixel(WizSimpleBitmap *srcBM, int x, int y, int32 value) {
- // RECHECK RAWPIXEL
+void Wiz::pgWritePixel(WizSimpleBitmap *srcBM, int x, int y, RAWPIXEL value) {
if ((x >= 0) && (y >= 0) && (x < srcBM->bitmapWidth) && (y < srcBM->bitmapHeight)) {
- *(srcBM->bufferPtr + y * srcBM->bitmapWidth + x) = value;
+ if (_uses16BitColor) {
+ *(srcBM->bufferPtr + y * srcBM->bitmapWidth + x) = value;
+ } else {
+ *(((uint8 *)srcBM->bufferPtr) + y * srcBM->bitmapWidth + x) = value;
+ }
}
}
-void Wiz::pgClippedWritePixel(WizSimpleBitmap *srcBM, int x, int y, const Common::Rect *clipRectPtr, int32 value) {
- // RECHECK RAWPIXEL
+void Wiz::pgClippedWritePixel(WizSimpleBitmap *srcBM, int x, int y, const Common::Rect *clipRectPtr, RAWPIXEL value) {
if ((x >= clipRectPtr->left) && (y >= clipRectPtr->top) && (x <= clipRectPtr->right) && (y <= clipRectPtr->bottom)) {
- *(srcBM->bufferPtr + y * srcBM->bitmapWidth + x) = value;
+ if (_uses16BitColor) {
+ *(srcBM->bufferPtr + y * srcBM->bitmapWidth + x) = value;
+ } else {
+ *(((uint8 *)srcBM->bufferPtr) + y * srcBM->bitmapWidth + x) = value;
+ }
}
}
#define GET_SIGN(x) ((x) > 0 ? 1 : ((x) == 0 ? 0 : (-1)))
-void Wiz::pgClippedLineDraw(WizSimpleBitmap *destBM, int asx, int asy, int aex, int aey, const Common::Rect *clipRectPtr, int32 value) {
- // RECHECK RAWPIXEL
+void Wiz::pgClippedLineDraw(WizSimpleBitmap *destBM, int asx, int asy, int aex, int aey, const Common::Rect *clipRectPtr, RAWPIXEL value) {
int x1, y1, x2, y2, d, dx, dy, sx, sy, incrA, incrB;
x1 = asx;
@@ -147,8 +155,7 @@ int scanEdge(WizScanLine *aScanLines, int iScanLineStart, bool bLeftSide, int iX
return iCurScanLine;
}
-void Wiz::pgClippedThickLineDraw(WizSimpleBitmap *destBM, int asx, int asy, int aex, int aey, const Common::Rect *clipRectPtr, int iLineThickness, int32 value) {
- // RECHECK RAWPIXEL
+void Wiz::pgClippedThickLineDraw(WizSimpleBitmap *destBM, int asx, int asy, int aex, int aey, const Common::Rect *clipRectPtr, int iLineThickness, RAWPIXEL value) {
int iDX = aex - asx;
int iDY = aey - asy;
double fDistance = sqrt((iDX * iDX) + (iDY * iDY));
@@ -263,8 +270,7 @@ int convertFromFixed(int iFixedNumber) {
return (iFixedNumber >> kWECFixedSize);
}
-void Wiz::pgDrawClippedEllipse(WizSimpleBitmap *pDestBitmap, int iPX, int iPY, int iQX, int iQY, int iKX, int iKY, int iLOD, const Common::Rect *pClipRectPtr, int iThickness, int32 aColor) {
- // RECHECK RAWPIXEL
+void Wiz::pgDrawClippedEllipse(WizSimpleBitmap *pDestBitmap, int iPX, int iPY, int iQX, int iQY, int iKX, int iKY, int iLOD, const Common::Rect *pClipRectPtr, int iThickness, RAWPIXEL aColor) {
// since this is fixed point, limit the LOD to 14 bits precision
if (iLOD > kWECFixedSize - 2) {
iLOD = kWECFixedSize - 2;
@@ -387,8 +393,9 @@ void Wiz::pgDrawClippedEllipse(WizSimpleBitmap *pDestBitmap, int iPX, int iPY, i
}
}
-void Wiz::pgDrawSolidRect(WizSimpleBitmap *destBM, const Common::Rect *rectPtr, int32 color) {
- int32 *d; // RECHECK RAWPIXEL
+void Wiz::pgDrawSolidRect(WizSimpleBitmap *destBM, const Common::Rect *rectPtr, RAWPIXEL color) {
+ RAWPIXEL *d;
+ uint8 *d8bit;
int cw, dw, ch;
int x1 = rectPtr->left, y1 = rectPtr->top, x2 = rectPtr->right, y2 = rectPtr->bottom;
@@ -398,15 +405,28 @@ void Wiz::pgDrawSolidRect(WizSimpleBitmap *destBM, const Common::Rect *rectPtr,
ch = y2 - y1 + 1;
d = destBM->bufferPtr + y1 * dw + x1;
+ d8bit = ((uint8 *)destBM->bufferPtr) + y1 * dw + x1;
+
if (cw > 1) {
while (--ch >= 0) {
- memset(d, color, cw); // RECHECK RAWPIXEL
- d += dw;
+ if (_uses16BitColor) {
+ for (int i = 0; i < dw; i++)
+ WRITE_LE_UINT16(&d[i], color);
+ d += dw;
+ } else {
+ memset(d8bit, color, cw);
+ d8bit += dw;
+ }
}
} else {
while (--ch >= 0) {
- *d = color;
- d += dw;
+ if (_uses16BitColor) {
+ *d = color;
+ d += dw;
+ } else {
+ *d8bit = color;
+ d8bit += dw;
+ }
}
}
}
Commit: 289148dcef4424a3ebd13082c70e396f857a6605
https://github.com/scummvm/scummvm/commit/289148dcef4424a3ebd13082c70e396f857a6605
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Continue implementing WIZ stuff
Changed paths:
engines/scumm/he/wiz_he.cpp
engines/scumm/he/wiz_he.h
engines/scumm/he/wiz_primitives_he.cpp
diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp
index 7327e537e30..0645d17e041 100644
--- a/engines/scumm/he/wiz_he.cpp
+++ b/engines/scumm/he/wiz_he.cpp
@@ -1315,7 +1315,12 @@ static int wizPackType0(uint8 *dst, const uint8 *src, int srcPitch, const Common
}
void Wiz::processWizImageCaptureCmd(const WizImageCommand *params) {
- takeAWiz(params->image, params->box, (params->flags & kWRFBackground) != 0, params->compressionType);
+ bool compressIt = (params->compressionType == kWCTTRLE);
+ bool background = (params->flags & kWRFBackground) != 0;
+
+ takeAWiz(params->image, params->box, background, params->compressionType);
+
+ _vm->_res->setModified(rtImage, params->image);
}
void Wiz::takeAWiz(int resNum, const Common::Rect &r, bool backBuffer, int compType) {
@@ -1415,7 +1420,6 @@ void Wiz::captureImage(uint8 *src, int srcPitch, int srcw, int srch, int resNum,
break;
}
}
- _vm->_res->setModified(rtImage, resNum);
}
void Wiz::simpleDrawAWiz(int image, int state, int x, int y, int flags) {
@@ -1494,7 +1498,7 @@ uint8 *Wiz::drawWizImage(int resNum, int state, int maskNum, int maskState, int
if (flags & kWRFRemap) {
rmap = _vm->findWrappedBlock(MKTAG('R','M','A','P'), dataPtr, state, 0);
assert(rmap);
- if (_vm->_game.heversion <= 80 || READ_BE_UINT32(rmap) != 0x01234567) {
+ if (_vm->_game.heversion <= 80 || READ_BE_UINT32(rmap) != WIZ_MAGIC_REMAP_NUMBER) {
uint8 *rgbs = _vm->findWrappedBlock(MKTAG('R','G','B','S'), dataPtr, state, 0);
assert(rgbs);
_vm->remapHEPalette(rgbs, rmap + 4);
@@ -2391,8 +2395,9 @@ void Wiz::processWizImageDrawCmd(const WizImageCommand *params) {
void Wiz::dwCreateRawWiz(int imageNum, int w, int h, int flags, int bitsPerPixel, int optionalSpotX, int optionalSpotY) {
int compressionType, wizdSize;
- int globSize = 8; // AWIZ header size
+ int blockHeaderSize = 8;
+ int globSize = blockHeaderSize; // AWIZ header size
globSize += WIZBLOCK_WIZH_SIZE;
if (flags & kCWFPalette) {
@@ -2407,17 +2412,10 @@ void Wiz::dwCreateRawWiz(int imageNum, int w, int h, int flags, int bitsPerPixel
globSize += WIZBLOCK_RMAP_SIZE;
}
- globSize += 8; // WIZD header size
- wizdSize = w * h * (bitsPerPixel / 8);
+ globSize += blockHeaderSize; // WIZD header size
+ wizdSize = (w * h * (bitsPerPixel / 8));
globSize += wizdSize;
- const uint8 *palPtr;
- if (_vm->_game.heversion >= 99) {
- palPtr = _vm->_hePalettes + _vm->_hePaletteSlot;
- } else {
- palPtr = _vm->_currentPalette;
- }
-
uint8 *writePtr = _vm->_res->createResource(rtImage, imageNum, globSize);
if (!writePtr) {
@@ -2451,6 +2449,13 @@ void Wiz::dwCreateRawWiz(int imageNum, int w, int h, int flags, int bitsPerPixel
WRITE_LE_UINT32(writePtr, h); writePtr += 4;
if (flags & kCWFPalette) {
+ const uint8 *palPtr;
+ if (_vm->_game.heversion >= 99) {
+ palPtr = _vm->_hePalettes + _vm->_hePaletteSlot;
+ } else {
+ palPtr = _vm->_currentPalette;
+ }
+
WRITE_BE_UINT32(writePtr, 'RGBS'); writePtr += 4;
WRITE_BE_UINT32(writePtr, WIZBLOCK_RGBS_SIZE); writePtr += 4;
memcpy(writePtr, palPtr, WIZBLOCK_RGBS_DATA_SIZE);
@@ -2512,18 +2517,44 @@ bool Wiz::dwSetSimpleBitmapStructFromImage(int imageNum, int imageState, WizSimp
}
// Hook up the image info to the simple bitmap info
- destBM->bufferPtr = (RAWPIXEL *)(dataPtr + blockHeaderSize);
+ destBM->bufferPtr = (WizRawPixel *)(dataPtr + blockHeaderSize);
destBM->bitmapWidth = imageWidth;
destBM->bitmapHeight = imageHeight;
return true;
}
+int Wiz::dwTryToLoadWiz(Common::SeekableReadStream *inFile, const WizImageCommand *params) {
+ uint32 blockSize;
+ uint32 blockId;
+ byte *ptr;
+
+ inFile->seek(0, SEEK_SET);
+ blockId = inFile->readUint32BE();
+
+ if ((blockId != MKTAG('A', 'W', 'I', 'Z')) && (blockId != MKTAG('M', 'U', 'L', 'T'))) {
+ return DW_LOAD_NOT_TYPE;
+ }
+
+ blockSize = inFile->readUint32BE();
+ inFile->seek(-8, SEEK_CUR);
+
+ ptr = _vm->_res->createResource(rtImage, params->image, blockSize);
+
+ if (inFile->read(ptr, blockSize) != blockSize) {
+ _vm->_res->nukeResource(rtImage, params->image);
+ return DW_LOAD_READ_FAILURE;
+ }
+
+ _vm->_res->setModified(rtImage, params->image);
+ return DW_LOAD_SUCCESS;
+}
+
void Wiz::processWizImageRenderRectCmd(const WizImageCommand *params) {
Common::Rect renderRect, clipRect, workClipRect;
int whichState, w, h, whichImage;
WizSimpleBitmap renderBitmap;
- RAWPIXEL whatColor;
+ WizRawPixel whatColor;
// What state is going to rendered into?
if (params->actionFlags & kWAFState) {
@@ -2580,7 +2611,7 @@ void Wiz::processWizImageRenderLineCmd(const WizImageCommand *params) {
Common::Rect clipRect, workClipRect;
int whichState, w, h, whichImage;
WizSimpleBitmap renderBitmap;
- RAWPIXEL whatColor;
+ WizRawPixel whatColor;
int iPropertyNumber = 0, iPropertyValue = 0;
if (!(params->actionFlags & kWAFRenderCoords)) {
@@ -2656,7 +2687,7 @@ void Wiz::processWizImageRenderPixelCmd(const WizImageCommand *params) {
Common::Rect clipRect, workClipRect;
int whichState, w, h, whichImage;
WizSimpleBitmap renderBitmap;
- RAWPIXEL whatColor;
+ WizRawPixel whatColor;
Common::Point pt;
if (params->actionFlags & kWAFRenderCoords) {
@@ -2705,20 +2736,38 @@ void Wiz::processWizImageRenderPixelCmd(const WizImageCommand *params) {
}
}
+void Wiz::remapImage(int image, int state, int tableCount, const uint8 *remapList, const uint8 *remapTable) {
+ int tableIndex;
+ uint8 *resAddr, *basePtr, *tablePtr;
+
+ resAddr = _vm->getResourceAddress(rtImage, image);
+ assert(resAddr);
+ basePtr = _vm->findWrappedBlock(MKTAG('R', 'M', 'A', 'P'), resAddr, state, 0);
+ assert(basePtr);
+
+ tablePtr = basePtr + 4;
+
+ _vm->_res->setModified(rtImage, image);
+ WRITE_BE_UINT32(basePtr, WIZ_MAGIC_REMAP_NUMBER);
+
+ for (int i = 0; i < tableCount; i++) {
+ tableIndex = *remapList++;
+ tablePtr[tableIndex] = remapTable[tableIndex];
+ }
+}
+
void Wiz::processWizImageModifyCmd(const WizImageCommand *params) {
- int st = (params->actionFlags & kWAFState) ? params->state : 0;
- int num = params->remapCount;
- const uint8 *index = params->remapList;
- uint8 *iwiz = _vm->getResourceAddress(rtImage, params->image);
- assert(iwiz);
- uint8 *rmap = _vm->findWrappedBlock(MKTAG('R','M','A','P'), iwiz, st, 0);
- assert(rmap);
- WRITE_BE_UINT32(rmap, 0x01234567);
- while (num--) {
- uint8 idx = *index++;
- rmap[4 + idx] = params->remapTable[idx];
+ int state;
+
+ if (params->actionFlags & kWAFState) {
+ state = params->state;
+ } else {
+ state = 0;
+ }
+
+ if (params->actionFlags & kWAFRemapList) {
+ remapImage(params->image, state, params->remapCount, params->remapList, params->remapTable);
}
- _vm->_res->setModified(rtImage, params->image);
}
void Wiz::processWizImageRenderEllipseCmd(const WizImageCommand *params) {
@@ -2828,40 +2877,31 @@ void Wiz::processNewWizImageCmd(const WizImageCommand *params) {
}
void Wiz::processWizImageLoadCmd(const WizImageCommand *params) {
- if (params->actionFlags & kWAFFilename) {
- Common::SeekableReadStream *f = _vm->openFileForReading(params->filename);
+ Common::SeekableReadStream *inFile;
+ int result;
- if (f) {
- uint32 id = f->readUint32BE();
-
- if (id == MKTAG('A', 'W', 'I', 'Z') || id == MKTAG('M', 'U', 'L', 'T')) {
- uint32 size = f->readUint32BE();
- f->seek(0, SEEK_SET);
+ if (params->actionFlags & kWAFFilename) {
+ inFile = _vm->openFileForReading(params->filename);
- byte *p = _vm->_res->createResource(rtImage, params->image, size);
+ if (!inFile) {
+ _vm->VAR(_vm->VAR_GAME_LOADED) = DW_LOAD_OPEN_FAILURE;
+ _vm->VAR(_vm->VAR_OPERATION_FAILURE) = DW_LOAD_OPEN_FAILURE;
- if (f->read(p, size) != size) {
- _vm->_res->nukeResource(rtImage, params->image);
- error("i/o error when reading '%s'", params->filename);
- _vm->VAR(_vm->VAR_GAME_LOADED) = DW_LOAD_READ_FAILURE;
- _vm->VAR(_vm->VAR_OPERATION_FAILURE) = DW_LOAD_READ_FAILURE;
- } else {
- _vm->_res->setModified(rtImage, params->image);
- _vm->VAR(_vm->VAR_GAME_LOADED) = DW_LOAD_SUCCESS;
- _vm->VAR(_vm->VAR_OPERATION_FAILURE) = DW_LOAD_SUCCESS;
- }
+ debug(0, "Wiz::processWizImageLoadCmd(): Unable to open for read '%s'", params->filename);
+ return;
+ }
- } else {
- _vm->VAR(_vm->VAR_GAME_LOADED) = DW_LOAD_NOT_TYPE;
- _vm->VAR(_vm->VAR_OPERATION_FAILURE) = DW_LOAD_NOT_TYPE;
- }
+ result = dwTryToLoadWiz(inFile, params);
+ _vm->VAR(_vm->VAR_GAME_LOADED) = result;
+ _vm->VAR(_vm->VAR_OPERATION_FAILURE) = result;
- delete f;
- } else {
- _vm->VAR(_vm->VAR_GAME_LOADED) = DW_LOAD_OPEN_FAILURE;
- _vm->VAR(_vm->VAR_OPERATION_FAILURE) = DW_LOAD_OPEN_FAILURE;
- debug(0, "Unable to open for read '%s'", params->filename);
+ if (result == DW_LOAD_SUCCESS) {
+ debug(7, "Wiz::processWizImageLoadCmd(): Correctly loaded file '%s'", params->filename);
+ } else if (result == DW_LOAD_READ_FAILURE) {
+ debug(0, "Wiz::processWizImageLoadCmd(): Got DW_LOAD_READ_FAILURE for file '%s'", params->filename);
}
+
+ delete inFile;
}
}
@@ -3080,7 +3120,7 @@ int Wiz::isWizPixelNonTransparent(uint8 *data, int state, int x, int y, int flag
int h = READ_LE_UINT32(wizh + 0x8);
if (_vm->_game.id == GID_MOONBASE) {
- RAWPIXEL color = 0xffff;
+ WizRawPixel color = 0xffff;
drawWizImageEx((byte *)&color, data, 0, 2, kDstMemory, 1, 1, -x, -y, w, h, state, 0, 0, 0, 0, 2, 0, 0);
return color != 0xffff;
diff --git a/engines/scumm/he/wiz_he.h b/engines/scumm/he/wiz_he.h
index 0e36d8ffda4..57f0d13fe5e 100644
--- a/engines/scumm/he/wiz_he.h
+++ b/engines/scumm/he/wiz_he.h
@@ -50,7 +50,9 @@ namespace Scumm {
#define DW_SAVE_PCX_FORMAT 1
#define DW_SAVE_RAW_FORMAT 2
-typedef uint16 RAWPIXEL;
+#define WIZ_MAGIC_REMAP_NUMBER 0x76543210
+
+typedef uint16 WizRawPixel;
struct WizPolygon {
Common::Point vert[5];
@@ -101,7 +103,7 @@ struct WizEllipseProperties {
int kx;
int ky;
int lod;
- RAWPIXEL color;
+ WizRawPixel color;
};
struct WizExtendedRenderInfo {
@@ -142,7 +144,7 @@ struct WizImageCommand {
int remapCount;
int destImageNumber;
int zbufferImage;
- RAWPIXEL colorValue;
+ WizRawPixel colorValue;
WizFontProperties fontProperties;
WizEllipseProperties ellipseProperties;
Common::Rect renderCoords;
@@ -189,7 +191,7 @@ struct WizImageCommand {
};
struct WizSimpleBitmap {
- RAWPIXEL *bufferPtr;
+ WizRawPixel *bufferPtr;
int bitmapWidth;
int bitmapHeight;
};
@@ -373,6 +375,7 @@ public:
void dwCreateRawWiz(int imageNum, int w, int h, int flags, int bitsPerPixel, int optionalSpotX, int optionalSpotY);
bool dwSetSimpleBitmapStructFromImage(int imageNum, int imageState, WizSimpleBitmap *destBM);
+ int dwTryToLoadWiz(Common::SeekableReadStream *inFile, const WizImageCommand *params);
void processWizImageCmd(const WizImageCommand *params);
void processWizImageCaptureCmd(const WizImageCommand *params);
@@ -451,14 +454,15 @@ public:
template<int type> static void write16BitColor(uint8 *dst, const uint8 *src, int dstType, const uint8 *xmapPtr);
#endif
template<int type> static void write8BitColor(uint8 *dst, const uint8 *src, int dstType, const uint8 *palPtr, const uint8 *xmapPtr, uint8 bitDepth);
- static void writeColor(uint8 *dstPtr, int dstType, RAWPIXEL color);
+ static void writeColor(uint8 *dstPtr, int dstType, WizRawPixel color);
- uint16 getWizPixelColor(const uint8 *data, int x, int y, int w, int h, uint8 bitDepth, RAWPIXEL color);
- uint16 getRawWizPixelColor(const uint8 *data, int x, int y, int w, int h, uint8 bitDepth, RAWPIXEL color);
- void computeWizHistogram(uint32 *histogram, const uint8 *data, const Common::Rect& rCapt);
- void computeRawWizHistogram(uint32 *histogram, const uint8 *data, int srcPitch, const Common::Rect& rCapt);
+ uint16 getWizPixelColor(const uint8 *data, int x, int y, int w, int h, uint8 bitDepth, WizRawPixel color);
+ uint16 getRawWizPixelColor(const uint8 *data, int x, int y, int w, int h, uint8 bitDepth, WizRawPixel color);
+ void computeWizHistogram(uint32 *histogram, const uint8 *data, const Common::Rect &rCapt);
+ void computeRawWizHistogram(uint32 *histogram, const uint8 *data, int srcPitch, const Common::Rect &rCapt);
+ void remapImage(int image, int state, int tableCount, const uint8 *remapList, const uint8 *remapTable);
-private:
+ private:
ScummEngine_v71he *_vm;
/* Wiz Drawing Primitives
@@ -471,12 +475,12 @@ private:
*/
int pgReadPixel(const WizSimpleBitmap *srcBM, int x, int y, int defaultValue);
- void pgWritePixel(WizSimpleBitmap *srcBM, int x, int y, RAWPIXEL value);
- void pgClippedWritePixel(WizSimpleBitmap *srcBM, int x, int y, const Common::Rect *clipRectPtr, RAWPIXEL value);
- void pgClippedLineDraw(WizSimpleBitmap *destBM, int asx, int asy, int aex, int aey, const Common::Rect *clipRectPtr, RAWPIXEL value);
- void pgClippedThickLineDraw(WizSimpleBitmap *destBM, int asx, int asy, int aex, int aey, const Common::Rect *clipRectPtr, int iLineThickness, RAWPIXEL value);
- void pgDrawClippedEllipse(WizSimpleBitmap *pDestBitmap, int iPX, int iPY, int iQX, int iQY, int iKX, int iKY, int iLOD, const Common::Rect *pClipRectPtr, int iThickness, RAWPIXEL aColor);
- void pgDrawSolidRect(WizSimpleBitmap *destBM, const Common::Rect *rectPtr, RAWPIXEL color);
+ void pgWritePixel(WizSimpleBitmap *srcBM, int x, int y, WizRawPixel value);
+ void pgClippedWritePixel(WizSimpleBitmap *srcBM, int x, int y, const Common::Rect *clipRectPtr, WizRawPixel value);
+ void pgClippedLineDraw(WizSimpleBitmap *destBM, int asx, int asy, int aex, int aey, const Common::Rect *clipRectPtr, WizRawPixel value);
+ void pgClippedThickLineDraw(WizSimpleBitmap *destBM, int asx, int asy, int aex, int aey, const Common::Rect *clipRectPtr, int iLineThickness, WizRawPixel value);
+ void pgDrawClippedEllipse(WizSimpleBitmap *pDestBitmap, int iPX, int iPY, int iQX, int iQY, int iKX, int iKY, int iLOD, const Common::Rect *pClipRectPtr, int iThickness, WizRawPixel aColor);
+ void pgDrawSolidRect(WizSimpleBitmap *destBM, const Common::Rect *rectPtr, WizRawPixel color);
bool findRectOverlap(Common::Rect *destRectPtr, const Common::Rect *sourceRectPtr);
bool isPointInRect(Common::Rect *r, Common::Point *pt);
diff --git a/engines/scumm/he/wiz_primitives_he.cpp b/engines/scumm/he/wiz_primitives_he.cpp
index 37cdccd0a0c..ec96fbf3bce 100644
--- a/engines/scumm/he/wiz_primitives_he.cpp
+++ b/engines/scumm/he/wiz_primitives_he.cpp
@@ -47,7 +47,7 @@ int Wiz::pgReadPixel(const WizSimpleBitmap *srcBM, int x, int y, int defaultValu
}
}
-void Wiz::pgWritePixel(WizSimpleBitmap *srcBM, int x, int y, RAWPIXEL value) {
+void Wiz::pgWritePixel(WizSimpleBitmap *srcBM, int x, int y, WizRawPixel value) {
if ((x >= 0) && (y >= 0) && (x < srcBM->bitmapWidth) && (y < srcBM->bitmapHeight)) {
if (_uses16BitColor) {
*(srcBM->bufferPtr + y * srcBM->bitmapWidth + x) = value;
@@ -57,7 +57,7 @@ void Wiz::pgWritePixel(WizSimpleBitmap *srcBM, int x, int y, RAWPIXEL value) {
}
}
-void Wiz::pgClippedWritePixel(WizSimpleBitmap *srcBM, int x, int y, const Common::Rect *clipRectPtr, RAWPIXEL value) {
+void Wiz::pgClippedWritePixel(WizSimpleBitmap *srcBM, int x, int y, const Common::Rect *clipRectPtr, WizRawPixel value) {
if ((x >= clipRectPtr->left) && (y >= clipRectPtr->top) && (x <= clipRectPtr->right) && (y <= clipRectPtr->bottom)) {
if (_uses16BitColor) {
*(srcBM->bufferPtr + y * srcBM->bitmapWidth + x) = value;
@@ -69,7 +69,7 @@ void Wiz::pgClippedWritePixel(WizSimpleBitmap *srcBM, int x, int y, const Common
#define GET_SIGN(x) ((x) > 0 ? 1 : ((x) == 0 ? 0 : (-1)))
-void Wiz::pgClippedLineDraw(WizSimpleBitmap *destBM, int asx, int asy, int aex, int aey, const Common::Rect *clipRectPtr, RAWPIXEL value) {
+void Wiz::pgClippedLineDraw(WizSimpleBitmap *destBM, int asx, int asy, int aex, int aey, const Common::Rect *clipRectPtr, WizRawPixel value) {
int x1, y1, x2, y2, d, dx, dy, sx, sy, incrA, incrB;
x1 = asx;
@@ -155,7 +155,7 @@ int scanEdge(WizScanLine *aScanLines, int iScanLineStart, bool bLeftSide, int iX
return iCurScanLine;
}
-void Wiz::pgClippedThickLineDraw(WizSimpleBitmap *destBM, int asx, int asy, int aex, int aey, const Common::Rect *clipRectPtr, int iLineThickness, RAWPIXEL value) {
+void Wiz::pgClippedThickLineDraw(WizSimpleBitmap *destBM, int asx, int asy, int aex, int aey, const Common::Rect *clipRectPtr, int iLineThickness, WizRawPixel value) {
int iDX = aex - asx;
int iDY = aey - asy;
double fDistance = sqrt((iDX * iDX) + (iDY * iDY));
@@ -270,7 +270,7 @@ int convertFromFixed(int iFixedNumber) {
return (iFixedNumber >> kWECFixedSize);
}
-void Wiz::pgDrawClippedEllipse(WizSimpleBitmap *pDestBitmap, int iPX, int iPY, int iQX, int iQY, int iKX, int iKY, int iLOD, const Common::Rect *pClipRectPtr, int iThickness, RAWPIXEL aColor) {
+void Wiz::pgDrawClippedEllipse(WizSimpleBitmap *pDestBitmap, int iPX, int iPY, int iQX, int iQY, int iKX, int iKY, int iLOD, const Common::Rect *pClipRectPtr, int iThickness, WizRawPixel aColor) {
// since this is fixed point, limit the LOD to 14 bits precision
if (iLOD > kWECFixedSize - 2) {
iLOD = kWECFixedSize - 2;
@@ -393,8 +393,8 @@ void Wiz::pgDrawClippedEllipse(WizSimpleBitmap *pDestBitmap, int iPX, int iPY, i
}
}
-void Wiz::pgDrawSolidRect(WizSimpleBitmap *destBM, const Common::Rect *rectPtr, RAWPIXEL color) {
- RAWPIXEL *d;
+void Wiz::pgDrawSolidRect(WizSimpleBitmap *destBM, const Common::Rect *rectPtr, WizRawPixel color) {
+ WizRawPixel *d;
uint8 *d8bit;
int cw, dw, ch;
int x1 = rectPtr->left, y1 = rectPtr->top, x2 = rectPtr->right, y2 = rectPtr->bottom;
Commit: 0a3b6c49b2de62ebe64ad1c497754f4d678c46cd
https://github.com/scummvm/scummvm/commit/0a3b6c49b2de62ebe64ad1c497754f4d678c46cd
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Implement FloodFill operation
Changed paths:
A engines/scumm/he/gfx_primitives_he.cpp
R engines/scumm/he/floodfill_he.cpp
R engines/scumm/he/floodfill_he.h
R engines/scumm/he/wiz_primitives_he.cpp
engines/scumm/actor.cpp
engines/scumm/charset.cpp
engines/scumm/gfx.cpp
engines/scumm/he/animation_he.cpp
engines/scumm/he/intern_he.h
engines/scumm/he/script_v100he.cpp
engines/scumm/he/script_v72he.cpp
engines/scumm/he/script_v90he.cpp
engines/scumm/he/sprite_he.cpp
engines/scumm/he/wiz_he.cpp
engines/scumm/he/wiz_he.h
engines/scumm/module.mk
engines/scumm/saveload.cpp
diff --git a/engines/scumm/actor.cpp b/engines/scumm/actor.cpp
index eae457b908b..10fa15667ab 100644
--- a/engines/scumm/actor.cpp
+++ b/engines/scumm/actor.cpp
@@ -3515,7 +3515,7 @@ void ScummEngine_v71he::heFlushAuxEraseQueue() {
for (int i = 0; i < _auxBlocksNum; ++i) {
AuxBlock *ab = &_auxBlocks[i];
if (ab->r.top <= ab->r.bottom) {
- restoreBackgroundHE(ab->r);
+ backgroundToForegroundBlit(ab->r);
}
}
}
diff --git a/engines/scumm/charset.cpp b/engines/scumm/charset.cpp
index 56825c064b2..6274ab2c14b 100644
--- a/engines/scumm/charset.cpp
+++ b/engines/scumm/charset.cpp
@@ -1226,7 +1226,7 @@ void CharsetRendererClassic::printCharIntern(bool is2byte, const byte *charPtr,
if (_blitAlso && vs->hasTwoBuffers) {
Common::Rect dst(_left, _top, _left + origWidth, _top + origHeight);
- ((ScummEngine_v71he *)_vm)->restoreBackgroundHE(dst);
+ ((ScummEngine_v71he *)_vm)->backgroundToForegroundBlit(dst);
}
#endif
} else {
diff --git a/engines/scumm/gfx.cpp b/engines/scumm/gfx.cpp
index 5dd7286a25c..a2f61a4ad0d 100644
--- a/engines/scumm/gfx.cpp
+++ b/engines/scumm/gfx.cpp
@@ -2502,7 +2502,7 @@ void Gdi::drawBMAPBg(const byte *ptr, VirtScreen *vs) {
debug(0, "Gdi::drawBMAPBg: default case %d", code);
}
- ((ScummEngine_v71he *)_vm)->restoreBackgroundHE(Common::Rect(vs->w, vs->h));
+ ((ScummEngine_v71he *)_vm)->backgroundToForegroundBlit(Common::Rect(vs->w, vs->h));
int numzbuf = getZPlanes(ptr, zplane_list, true);
if (numzbuf <= 1)
@@ -2569,11 +2569,11 @@ void Gdi::drawBMAPObject(const byte *ptr, VirtScreen *vs, int obj, int x, int y,
rect1.top -= rect2.top;
rect1.bottom -= rect2.top;
- ((ScummEngine_v71he *)_vm)->restoreBackgroundHE(rect1);
+ ((ScummEngine_v71he *)_vm)->backgroundToForegroundBlit(rect1);
}
}
-void ScummEngine_v70he::restoreBackgroundHE(Common::Rect rect, int dirtybit) {
+void ScummEngine_v70he::backgroundToForegroundBlit(Common::Rect rect, int dirtybit) {
byte *src, *dst;
VirtScreen *vs = &_virtscr[kMainVirtScreen];
@@ -2587,16 +2587,16 @@ void ScummEngine_v70he::restoreBackgroundHE(Common::Rect rect, int dirtybit) {
rect.left = MIN((int)rect.left, (int)vs->w - 1);
rect.right = MAX(0, (int)rect.right);
- rect.right = MIN((int)rect.right, (int)vs->w);
+ rect.right = MIN((int)rect.right, (int)vs->w - 1);
rect.top = MAX(0, (int)rect.top);
rect.top = MIN((int)rect.top, (int)vs->h - 1);
rect.bottom = MAX(0, (int)rect.bottom);
- rect.bottom = MIN((int)rect.bottom, (int)vs->h);
+ rect.bottom = MIN((int)rect.bottom, (int)vs->h - 1);
- const int rw = rect.width();
- const int rh = rect.height();
+ const int rw = rect.width() + 1;
+ const int rh = rect.height() + 1;
if (rw == 0 || rh == 0)
return;
@@ -2607,6 +2607,8 @@ void ScummEngine_v70he::restoreBackgroundHE(Common::Rect rect, int dirtybit) {
assert(rw <= _screenWidth && rw > 0);
assert(rh <= _screenHeight && rh > 0);
blit(dst, _virtscr[kMainVirtScreen].pitch, src, _virtscr[kMainVirtScreen].pitch, rw, rh, vs->format.bytesPerPixel);
+
+ rect.bottom++;
markRectAsDirty(kMainVirtScreen, rect, dirtybit);
}
#endif
diff --git a/engines/scumm/he/animation_he.cpp b/engines/scumm/he/animation_he.cpp
index 8b93921827d..6317a91ab88 100644
--- a/engines/scumm/he/animation_he.cpp
+++ b/engines/scumm/he/animation_he.cpp
@@ -166,7 +166,7 @@ void MoviePlayer::handleNextFrame() {
copyFrameToBuffer(pvs->getBackPixels(0, 0), kDstScreen, 0, 0, pvs->pitch);
Common::Rect imageRect(_video->getWidth(), _video->getHeight());
- _vm->restoreBackgroundHE(imageRect);
+ _vm->backgroundToForegroundBlit(imageRect);
} else {
copyFrameToBuffer(pvs->getPixels(0, 0), kDstScreen, 0, 0, pvs->pitch);
diff --git a/engines/scumm/he/floodfill_he.cpp b/engines/scumm/he/floodfill_he.cpp
deleted file mode 100644
index a37b5501c65..00000000000
--- a/engines/scumm/he/floodfill_he.cpp
+++ /dev/null
@@ -1,297 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifdef ENABLE_HE
-
-#include "scumm/he/floodfill_he.h"
-#include "scumm/he/intern_he.h"
-#include "scumm/resource.h"
-#include "scumm/scumm.h"
-
-namespace Scumm {
-
-static bool floodFillPixelCheck(int x, int y, const FloodFillState *ffs) {
- int diffColor = ffs->color1 - ffs->color2;
- if (x >= 0 && x < ffs->dst_w && y >= 0 && y < ffs->dst_h) {
- uint8 color = *(ffs->dst + y * ffs->dst_w + x);
- diffColor = color - ffs->color1;
- }
- return diffColor == 0;
-}
-
-static void floodFillProcessRect(FloodFillState *ffs, const Common::Rect *r) {
- Common::Rect *dr = &ffs->dstBox;
- if (dr->right >= dr->left && dr->top <= dr->bottom) {
- int rw = r->right - r->left + 1;
- int rh = r->bottom - r->top + 1;
- assert(r->top + rh <= ffs->dst_h);
- assert(r->left + rw <= ffs->dst_w);
- uint8 *dst = ffs->dst + r->top * ffs->dst_w + r->left;
- if (rw <= 1) {
- --rh;
- while (rh >= 0) {
- *dst = ffs->color2;
- dst += ffs->dst_w;
- --rh;
- }
- } else {
- --rh;
- while (rh >= 0) {
- memset(dst, ffs->color2, rw);
- dst += ffs->dst_w;
- --rh;
- }
- }
- dr->extend(*r);
- } else {
- *dr = *r;
- }
-}
-
-static void floodFillAddLine(FloodFillLine **ffl, int y, int x1, int x2, int dy) {
- (*ffl)->y = y;
- (*ffl)->x1 = x1;
- (*ffl)->x2 = x2;
- (*ffl)->inc = dy;
- (*ffl)++;
-}
-
-static void floodFillProcess(int x, int y, FloodFillState *ffs, FloodFillPixelCheckCallback pixelCheckCallback) {
- ffs->dstBox.left = ffs->dstBox.top = 12345;
- ffs->dstBox.right = ffs->dstBox.bottom = -12345;
-
- FloodFillLine **fillLineCur = &ffs->fillLineTableCur;
- FloodFillLine **fillLineEnd = &ffs->fillLineTableEnd;
-
- assert(*fillLineCur < *fillLineEnd);
- if (ffs->srcBox.top <= y + 1 && ffs->srcBox.bottom >= y + 1) {
- (*fillLineCur)->y = y;
- (*fillLineCur)->x1 = x;
- (*fillLineCur)->x2 = x;
- (*fillLineCur)->inc = 1;
- (*fillLineCur)++;
- }
-
- assert(*fillLineCur < *fillLineEnd);
- if (ffs->srcBox.top <= y && ffs->srcBox.bottom >= y) {
- (*fillLineCur)->y = y + 1;
- (*fillLineCur)->x1 = x;
- (*fillLineCur)->x2 = x;
- (*fillLineCur)->inc = -1;
- (*fillLineCur)++;
- }
-
- assert(ffs->fillLineTable <= *fillLineCur);
- FloodFillLine **fillLineStart = fillLineCur;
-
- while (ffs->fillLineTable < *fillLineStart) {
- Common::Rect r;
- int x_start;
- FloodFillLine *fflCur = --(*fillLineCur);
- int dy = fflCur->inc;
- int x_end = fflCur->x2;
- int x1 = fflCur->x1;
- int x2 = fflCur->x1 + 1;
- r.bottom = r.top = y = fflCur->y + fflCur->inc;
- r.left = x2;
- r.right = x1;
- x = x1;
- while (ffs->srcBox.left <= x) {
- if (!(*pixelCheckCallback)(x, y, ffs)) {
- break;
- }
- r.left = x;
- --x;
- }
- if (r.right >= r.left && r.top <= r.bottom) {
- floodFillProcessRect(ffs, &r);
- }
- if (x >= x1) goto skip;
- x_start = x + 1;
- if (x1 > x_start) {
- assert(*fillLineEnd > *fillLineCur);
- if (ffs->srcBox.top <= y - dy && ffs->srcBox.bottom >= y - dy) {
- --x1;
- floodFillAddLine(fillLineCur, y, x_start, x1, -dy);
- }
- }
- x = x2;
- while (x_start <= x_end) {
- r.left = x;
- r.top = y;
- r.right = x - 1;
- r.bottom = y;
- while (ffs->srcBox.right >= x) {
- if (!(*pixelCheckCallback)(x, y, ffs)) {
- break;
- }
- r.right = x;
- ++x;
- }
- if (r.right >= r.left && r.top <= r.bottom) {
- floodFillProcessRect(ffs, &r);
- }
- assert(ffs->fillLineTableCur < ffs->fillLineTableEnd);
- if (ffs->srcBox.top <= y + dy && ffs->srcBox.bottom >= y + dy) {
- floodFillAddLine(&ffs->fillLineTableCur, y, x_start, x - 1, dy);
- }
- x_start = x_end + 1;
- if (x > x_start) {
- assert(ffs->fillLineTableCur < ffs->fillLineTableEnd);
- if (ffs->srcBox.top <= y - dy && ffs->srcBox.bottom >= y - dy) {
- floodFillAddLine(&ffs->fillLineTableCur, y, x_start, x - 1, -dy);
- }
- }
-skip:
- ++x;
- while (x <= x_end) {
- if ((*pixelCheckCallback)(x, y, ffs)) {
- break;
- }
- ++x;
- }
- x_start = x;
- }
- }
-}
-
-void floodFill(FloodFillParameters *ffp, ScummEngine_v90he *vm) {
- // To test this operation: use room 33 of BluesBirthday yellow disc
- uint8 *dst;
- VirtScreen *vs = &vm->_virtscr[kMainVirtScreen];
-
- int32 colorBackMask = vm->_game.heversion > 99 ? 0x01000000 : 0x8000;
-
- if (ffp->color & colorBackMask) {
- dst = vs->getBackPixels(0, vs->topline);
- } else {
- dst = vs->getPixels(0, vs->topline);
- }
- uint8 color = ffp->color & 0xFF;
-
- Common::Rect r;
- r.left = r.top = 12345;
- r.right = r.bottom = -12345;
-
- FloodFillState *ffs = new FloodFillState;
- ffs->fillLineTableCount = vs->h * 2;
- ffs->fillLineTable = new FloodFillLine[ffs->fillLineTableCount];
- ffs->color2 = color;
- ffs->dst = dst;
- ffs->dst_w = vs->w;
- ffs->dst_h = vs->h;
- ffs->srcBox = ffp->box;
- ffs->fillLineTableCur = &ffs->fillLineTable[0];
- ffs->fillLineTableEnd = &ffs->fillLineTable[ffs->fillLineTableCount];
-
- if (ffp->x < 0 || ffp->y < 0 || ffp->x >= vs->w || ffp->y >= vs->h) {
- ffs->color1 = color;
- } else {
- ffs->color1 = *(dst + ffp->y * vs->w + ffp->x);
- }
-
- debug(5, "floodFill() x=%d y=%d color1=%d ffp->color=0x%X", ffp->x, ffp->y, ffs->color1, ffp->color);
- if (ffs->color1 != color) {
- floodFillProcess(ffp->x, ffp->y, ffs, floodFillPixelCheck);
- r = ffs->dstBox;
- }
- r.debugPrint(5, "floodFill() dirty_rect");
-
- delete[] ffs->fillLineTable;
- delete ffs;
-
- vm->VAR(vm->VAR_OPERATION_FAILURE) = 1;
-
- if (r.left <= r.right && r.top <= r.bottom) {
- if (ffp->color & colorBackMask) {
- vm->restoreBackgroundHE(r);
- } else {
- ++r.bottom;
- vm->markRectAsDirty(kMainVirtScreen, r);
- }
- }
-}
-
-void Wiz::processWizImageRenderFloodFillCmd(const WizImageCommand *params) {
- if (params->actionFlags & kWAFRenderCoords) {
- int px = params->renderCoords.left;
- int py = params->renderCoords.top;
- uint8 *dataPtr = _vm->getResourceAddress(rtImage, params->image);
- if (dataPtr) {
- int state = 0;
- if (params->actionFlags & kWAFState) {
- state = params->state;
- }
- uint8 *wizh = _vm->findWrappedBlock(MKTAG('W','I','Z','H'), dataPtr, state, 0);
- assert(wizh);
- int c = READ_LE_UINT32(wizh + 0x0);
- int w = READ_LE_UINT32(wizh + 0x4);
- int h = READ_LE_UINT32(wizh + 0x8);
- assert(c == 0);
- Common::Rect imageRect(w, h);
- if (params->actionFlags & kWAFRect) {
- if (!imageRect.intersects(params->box)) {
- return;
- }
- imageRect.clip(params->box);
- }
- uint8 color = _vm->VAR(93);
- if (params->actionFlags & kWAFColor) {
- color = params->colorValue;
- }
- if (imageRect.contains(px, py)) {
- uint8 *wizd = _vm->findWrappedBlock(MKTAG('W','I','Z','D'), dataPtr, state, 0);
- assert(wizd);
-
- FloodFillState *ffs = new FloodFillState;
- ffs->fillLineTableCount = h * 2;
- ffs->fillLineTable = new FloodFillLine[ffs->fillLineTableCount];
- ffs->color2 = color;
- ffs->dst = wizd;
- ffs->dst_w = w;
- ffs->dst_h = h;
- ffs->srcBox = imageRect;
- ffs->fillLineTableCur = &ffs->fillLineTable[0];
- ffs->fillLineTableEnd = &ffs->fillLineTable[ffs->fillLineTableCount];
-
- if (px < 0 || py < 0 || px >= w || py >= h) {
- ffs->color1 = color;
- } else {
- ffs->color1 = *(wizd + py * w + px);
- }
-
- debug(0, "floodFill() x=%d y=%d color1=%d", px, py, ffs->color1);
-
- if (ffs->color1 != color) {
- floodFillProcess(px, py, ffs, floodFillPixelCheck);
- }
-
- delete[] ffs->fillLineTable;
- delete ffs;
- }
- }
- }
- _vm->_res->setModified(rtImage, params->image);
-}
-
-} // End of namespace Scumm
-
-#endif // ENABLE_HE
diff --git a/engines/scumm/he/floodfill_he.h b/engines/scumm/he/floodfill_he.h
deleted file mode 100644
index ee29a3dc476..00000000000
--- a/engines/scumm/he/floodfill_he.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#if !defined(SCUMM_HE_FLOODFILL_HE_H) && defined(ENABLE_HE)
-#define SCUMM_HE_FLOODFILL_HE_H
-
-#include "common/rect.h"
-
-namespace Scumm {
-
-struct FloodFillParameters {
- Common::Rect box;
- int32 x;
- int32 y;
- int32 color;
- int32 flags;
-
- void reset() {
- box.top = box.left = box.bottom = box.right = 0;
- x = 0;
- y = 0;
- color = 0;
- flags = 0;
- }
-};
-
-struct FloodFillLine {
- int y;
- int x1;
- int x2;
- int inc;
-};
-
-struct FloodFillState {
- FloodFillLine *fillLineTable;
- FloodFillLine *fillLineTableEnd;
- FloodFillLine *fillLineTableCur;
- Common::Rect dstBox;
- Common::Rect srcBox;
- uint8 *dst;
- int dst_w;
- int dst_h;
- int color1;
- int color2;
- int fillLineTableCount;
-};
-
-class ScummEngine_v90he;
-
-typedef bool (*FloodFillPixelCheckCallback)(int x, int y, const FloodFillState *ffs);
-
-void floodFill(FloodFillParameters *ffp, ScummEngine_v90he *vm);
-
-} // End of namespace Scumm
-
-#endif
diff --git a/engines/scumm/he/wiz_primitives_he.cpp b/engines/scumm/he/gfx_primitives_he.cpp
similarity index 64%
rename from engines/scumm/he/wiz_primitives_he.cpp
rename to engines/scumm/he/gfx_primitives_he.cpp
index ec96fbf3bce..a7e1254b41c 100644
--- a/engines/scumm/he/wiz_primitives_he.cpp
+++ b/engines/scumm/he/gfx_primitives_he.cpp
@@ -431,6 +431,48 @@ void Wiz::pgDrawSolidRect(WizSimpleBitmap *destBM, const Common::Rect *rectPtr,
}
}
+void Wiz::pgFloodFillCmd(int x, int y, int color, const Common::Rect *optionalClipRect) {
+ Common::Rect updateRect;
+ WizSimpleBitmap fakeBitmap;
+ int colorToWrite;
+
+ // Setup the bitmap...
+ int32 colorBackMask = _vm->_game.heversion > 99 ? 0x01000000 : 0x8000;
+ pgSimpleBitmapFromDrawBuffer(&fakeBitmap, (color & colorBackMask) != 0);
+
+ // Strip the color info down...
+ colorToWrite = getRawPixel(color);
+
+ // Call the primitive
+ updateRect.left = updateRect.top = 12345;
+ updateRect.right = updateRect.bottom = -12345;
+
+ _vm->VAR(_vm->VAR_OPERATION_FAILURE) = floodSimpleFill(
+ &fakeBitmap, x, y, colorToWrite, optionalClipRect, &updateRect);
+
+ if (isRectValid(updateRect)) {
+ if (color & colorBackMask) {
+ _vm->backgroundToForegroundBlit(updateRect);
+ } else {
+ updateRect.bottom++;
+ _vm->markRectAsDirty(kMainVirtScreen, updateRect);
+ }
+ }
+}
+
+void Wiz::pgSimpleBitmapFromDrawBuffer(WizSimpleBitmap *bitmapPtr, bool background) {
+ VirtScreen *vs = &_vm->_virtscr[kMainVirtScreen];
+
+ bitmapPtr->bitmapWidth = vs->w;
+ bitmapPtr->bitmapHeight = vs->h;
+
+ if (background) {
+ bitmapPtr->bufferPtr = (WizRawPixel *)vs->getBackPixels(0, vs->topline);
+ } else {
+ bitmapPtr->bufferPtr = (WizRawPixel *)vs->getPixels(0, vs->topline);
+ }
+}
+
bool Wiz::findRectOverlap(Common::Rect *destRectPtr, const Common::Rect *sourceRectPtr) {
// Make sure only points inside the viewPort are being set...
if ((destRectPtr->left > sourceRectPtr->right) || (destRectPtr->top > sourceRectPtr->bottom) ||
@@ -458,10 +500,14 @@ bool Wiz::findRectOverlap(Common::Rect *destRectPtr, const Common::Rect *sourceR
return true;
}
-bool Wiz::isPointInRect(Common::Rect* r, Common::Point* pt) {
+bool Wiz::isPointInRect(Common::Rect *r, Common::Point *pt) {
return (pt->x >= r->left) && (pt->x <= r->right) && (pt->y >= r->top) && (pt->y <= r->bottom);
}
+bool Wiz::isRectValid(Common::Rect r) {
+ return r.left <= r.right && r.top <= r.bottom;
+}
+
void Wiz::makeSizedRectAt(Common::Rect *rectPtr, int x, int y, int width, int height) {
rectPtr->left = x;
rectPtr->top = y;
@@ -473,6 +519,204 @@ void Wiz::makeSizedRect(Common::Rect *rectPtr, int width, int height) {
makeSizedRectAt(rectPtr, 0, 0, width, height);
}
+void Wiz::combineRects(Common::Rect *destRect, Common::Rect *ra, Common::Rect *rb) {
+ destRect->left = MIN<int16>(ra->left, rb->left);
+ destRect->top = MIN<int16>(ra->top, rb->top);
+ destRect->right = MAX<int16>(ra->right, rb->right);
+ destRect->bottom = MAX<int16>(ra->bottom, rb->bottom);
+}
+
+void Wiz::floodInitFloodState(WizFloodState *statePtr, WizSimpleBitmap *bitmapPtr, int colorToWrite, const Common::Rect *optionalClippingRect) {
+ statePtr->colorToWrite = colorToWrite;
+ statePtr->bitmapPtr = bitmapPtr;
+
+ if (!optionalClippingRect) {
+ if (bitmapPtr) {
+ makeSizedRect(&statePtr->clipping, bitmapPtr->bitmapWidth, bitmapPtr->bitmapHeight);
+ } else {
+ makeSizedRect(&statePtr->clipping, 1, 1);
+ }
+ } else {
+ statePtr->clipping = *optionalClippingRect;
+ }
+
+ statePtr->sp = statePtr->stack;
+ statePtr->top = statePtr->stack + statePtr->numStackElements;
+}
+
+WizFloodState *Wiz::floodCreateFloodState(int numStackElements) {
+ WizFloodState *statePtr;
+
+ statePtr = (WizFloodState *)malloc(sizeof(WizFloodState));
+
+ if (!statePtr) {
+ return nullptr;
+ }
+
+ statePtr->numStackElements = numStackElements;
+ statePtr->stack = (WizFloodSegment *)malloc(numStackElements * sizeof(WizFloodSegment));
+
+ if (!statePtr->stack) {
+ floodDestroyFloodState(statePtr);
+ return nullptr;
+ }
+
+ floodInitFloodState(statePtr, nullptr, 0, nullptr);
+ return statePtr;
+}
+
+void Wiz::floodDestroyFloodState(WizFloodState *statePtr) {
+ if (statePtr->stack) {
+ free(statePtr->stack);
+ statePtr->stack = nullptr;
+ }
+
+ free(statePtr);
+ statePtr = nullptr;
+}
+
+static bool floodSimpleFloodCheckPixel(Wiz *w, int x, int y, WizFloodState *state) {
+ return (w->pgReadPixel(state->bitmapPtr, x, y, state->colorToWrite) == state->writeOverColor);
+}
+
+bool Wiz::floodBoundryColorFloodCheckPixel(int x, int y, WizFloodState *state) {
+ int pixel = pgReadPixel(state->bitmapPtr, x, y, state->colorToWrite);
+ return (pixel != state->boundryColor) && (pixel != state->colorToWrite);
+}
+
+#define FLOOD_PUSH(Y, XL, XR, DY, SS) \
+ if ((SS)->sp < (SS)->top && Y + (DY) >= (SS)->clipping.top && Y + (DY) <= (SS)->clipping.bottom) { \
+ (SS)->sp->y = Y; \
+ (SS)->sp->xl = XL; \
+ (SS)->sp->xr = XR; \
+ (SS)->sp->dy = DY; \
+ (SS)->sp++; \
+ }
+
+#define FLOOD_POP(Y, XL, XR, DY, SS) { \
+ (SS)->sp--; \
+ Y = (SS)->sp->y + (DY = (SS)->sp->dy); \
+ XL = (SS)->sp->xl; \
+ XR = (SS)->sp->xr; \
+ }
+
+
+void Wiz::floodFloodFillPrim(int x, int y, WizFloodState *statePtr, bool (*checkPixelFnPtr)(Wiz *w, int x, int y, WizFloodState *state)) {
+ Common::Rect fillRect;
+
+ int l, x1, x2, dy;
+
+ // Make the initial update invalid...
+ statePtr->updateRect.left = statePtr->updateRect.top = 12345;
+ statePtr->updateRect.right = statePtr->updateRect.bottom = -12345;
+
+ FLOOD_PUSH(y, x, x, 1, statePtr);
+ FLOOD_PUSH(y + 1, x, x, -1, statePtr);
+
+ while (statePtr->sp > statePtr->stack) {
+ FLOOD_POP(y, x1, x2, dy, statePtr);
+
+ // Fill the left span from this point!
+ fillRect.left = x1 + 1;
+ fillRect.top = y;
+ fillRect.right = x1;
+ fillRect.bottom = y;
+
+ for (x = x1; (x >= statePtr->clipping.left) && (*checkPixelFnPtr)(this, x, y, statePtr); x--) {
+ fillRect.left = x;
+ }
+
+ if (isRectValid(fillRect)) {
+ floodPerformOpOnRect(statePtr, &fillRect);
+ }
+
+ // This goto, while ugly, allows me to avoid rewriting
+ // a second version of the do-while loop below... Have mercy :-)
+ if (x >= x1)
+ goto skip;
+
+ l = x + 1;
+
+ if (l < x1) {
+ FLOOD_PUSH(y, l, x1 - 1, -dy, statePtr);
+ }
+
+ x = x1 + 1;
+
+ do {
+ // Fill the right span from this point!
+ fillRect.left = x;
+ fillRect.top = y;
+ fillRect.right = x - 1;
+ fillRect.bottom = y;
+
+ for (; (x <= statePtr->clipping.right) && (*checkPixelFnPtr)(this, x, y, statePtr); x++) {
+ fillRect.right = x;
+ }
+
+ if (isRectValid(fillRect)) {
+ floodPerformOpOnRect(statePtr, &fillRect);
+ }
+
+ FLOOD_PUSH(y, l, x - 1, dy, statePtr);
+
+ if (x > (x2 + 1)) {
+ FLOOD_PUSH(y, x2 + 1, x - 1, -dy, statePtr);
+ }
+
+ skip:
+ for (x++; (x <= x2) && (!(*checkPixelFnPtr)(this, x, y, statePtr)); x++)
+ ;
+
+ l = x;
+
+ } while (x <= x2);
+ }
+}
+
+#undef FLOOD_POP
+#undef FLOOD_PUSH
+
+void Wiz::floodPerformOpOnRect(WizFloodState *statePtr, Common::Rect *rectPtr) {
+ pgDrawSolidRect(statePtr->bitmapPtr, rectPtr, (WizRawPixel)statePtr->colorToWrite);
+
+ if (isRectValid(statePtr->updateRect)) {
+ combineRects(&statePtr->updateRect, &statePtr->updateRect, rectPtr);
+ } else {
+ statePtr->updateRect = *rectPtr;
+ }
+}
+
+bool Wiz::floodSimpleFill(WizSimpleBitmap *bitmapPtr, int x, int y, int colorToWrite, const Common::Rect *optionalClipRect, Common::Rect *updateRectPtr) {
+ WizFloodState *statePtr;
+
+ statePtr = floodCreateFloodState(bitmapPtr->bitmapHeight * 2);
+
+ if (!statePtr) {
+ return false;
+ }
+
+ floodInitFloodState(statePtr, bitmapPtr, colorToWrite, optionalClipRect);
+
+ statePtr->writeOverColor = pgReadPixel(bitmapPtr, x, y, colorToWrite);
+
+ if (colorToWrite != statePtr->writeOverColor) {
+ floodFloodFillPrim(x, y, statePtr, floodSimpleFloodCheckPixel);
+ *updateRectPtr = statePtr->updateRect;
+ }
+
+ floodDestroyFloodState(statePtr);
+ return true;
+}
+
+int Wiz::getRawPixel(int color) {
+ if (_uses16BitColor) {
+ return color & 0xFFFF;
+ } else {
+ return color & 0xFF;
+ }
+}
+
} // End of namespace Scumm
#endif // ENABLE_HE
diff --git a/engines/scumm/he/intern_he.h b/engines/scumm/he/intern_he.h
index 12a65f57a59..e2a7249d122 100644
--- a/engines/scumm/he/intern_he.h
+++ b/engines/scumm/he/intern_he.h
@@ -24,7 +24,6 @@
#include "scumm/scumm_v6.h"
#ifdef ENABLE_HE
-#include "scumm/he/floodfill_he.h"
#include "scumm/he/wiz_he.h"
#endif
#include "scumm/actor_he.h" // For AuxBlock & AuxEntry
@@ -210,7 +209,7 @@ public:
Common::Path generateFilename(const int room) const override;
- void restoreBackgroundHE(Common::Rect rect, int dirtybit = 0);
+ void backgroundToForegroundBlit(Common::Rect rect, int dirtybit = 0);
protected:
void allocateArrays() override;
@@ -384,6 +383,7 @@ protected:
byte _stringBuffer[4096];
WizImageCommand _wizImageCommand;
+ FloodFillCommand _floodFillCommand;
public:
ScummEngine_v72he(OSystem *syst, const DetectorResult &dr);
@@ -561,7 +561,6 @@ class ScummEngine_v90he : public ScummEngine_v80he {
friend class Sprite;
protected:
- FloodFillParameters _floodFillParams;
enum SubOpType {
SO_COORD_2D = 28,
SO_COORD_3D = 29,
diff --git a/engines/scumm/he/script_v100he.cpp b/engines/scumm/he/script_v100he.cpp
index b894055ee1d..d607528a7ce 100644
--- a/engines/scumm/he/script_v100he.cpp
+++ b/engines/scumm/he/script_v100he.cpp
@@ -904,32 +904,30 @@ void ScummEngine_v100he::o100_floodFill() {
switch (subOp) {
case SO_INIT:
- _floodFillParams.reset();
- _floodFillParams.box.left = 0;
- _floodFillParams.box.top = 0;
- _floodFillParams.box.right = 639;
- _floodFillParams.box.bottom = 479;
- adjustRect(_floodFillParams.box);
+ _floodFillCommand.reset();
+ _floodFillCommand.box.left = 0;
+ _floodFillCommand.box.top = 0;
+ _floodFillCommand.box.right = 639;
+ _floodFillCommand.box.bottom = 479;
break;
case SO_AT:
- _floodFillParams.y = pop();
- _floodFillParams.x = pop();
+ _floodFillCommand.y = pop();
+ _floodFillCommand.x = pop();
break;
case SO_CLIPPED:
- _floodFillParams.box.bottom = pop();
- _floodFillParams.box.right = pop();
- _floodFillParams.box.top = pop();
- _floodFillParams.box.left = pop();
- adjustRect(_floodFillParams.box);
+ _floodFillCommand.box.bottom = pop();
+ _floodFillCommand.box.right = pop();
+ _floodFillCommand.box.top = pop();
+ _floodFillCommand.box.left = pop();
break;
case SO_COLOR:
- _floodFillParams.flags = pop();
+ _floodFillCommand.color = pop();
break;
case SO_SET_FLAGS:
- pop();
+ _floodFillCommand.flags |= pop();
break;
case SO_END:
- floodFill(&_floodFillParams, this);
+ _wiz->pgFloodFillCmd(_floodFillCommand.x, _floodFillCommand.y, _floodFillCommand.color, &_floodFillCommand.box);
break;
default:
error("o100_floodFill: Unknown case %d", subOp);
@@ -2197,7 +2195,7 @@ void ScummEngine_v100he::o100_systemOps() {
debug(0, "Start executable (%s)", string);
break;
case SO_UPDATE_SCREEN:
- restoreBackgroundHE(Common::Rect(_screenWidth, _screenHeight));
+ backgroundToForegroundBlit(Common::Rect(_screenWidth, _screenHeight));
updatePalette();
break;
default:
diff --git a/engines/scumm/he/script_v72he.cpp b/engines/scumm/he/script_v72he.cpp
index 690a14a8124..fa454912795 100644
--- a/engines/scumm/he/script_v72he.cpp
+++ b/engines/scumm/he/script_v72he.cpp
@@ -1332,7 +1332,7 @@ void ScummEngine_v72he::o72_systemOps() {
clearDrawObjectQueue();
break;
case SO_UPDATE_SCREEN: // HE80+
- restoreBackgroundHE(Common::Rect(_screenWidth, _screenHeight));
+ backgroundToForegroundBlit(Common::Rect(_screenWidth, _screenHeight));
updatePalette();
break;
case SO_RESTART:
diff --git a/engines/scumm/he/script_v90he.cpp b/engines/scumm/he/script_v90he.cpp
index 008ed46e9c6..deca931a323 100644
--- a/engines/scumm/he/script_v90he.cpp
+++ b/engines/scumm/he/script_v90he.cpp
@@ -1527,32 +1527,30 @@ void ScummEngine_v90he::o90_floodFill() {
switch (subOp) {
case SO_SET_FLAGS: // 54
- _floodFillParams.flags |= pop();
- pop();
+ _floodFillCommand.flags |= pop();
break;
case SO_INIT: // 57
- _floodFillParams.reset();
- _floodFillParams.box.left = 0;
- _floodFillParams.box.top = 0;
- _floodFillParams.box.right = 639;
- _floodFillParams.box.bottom = 479;
+ _floodFillCommand.reset();
+ _floodFillCommand.box.left = 0;
+ _floodFillCommand.box.top = 0;
+ _floodFillCommand.box.right = 639;
+ _floodFillCommand.box.bottom = 479;
break;
case SO_AT: // 65
- _floodFillParams.y = pop();
- _floodFillParams.x = pop();
+ _floodFillCommand.y = pop();
+ _floodFillCommand.x = pop();
break;
case SO_COLOR: // 66
- _floodFillParams.color = pop();
+ _floodFillCommand.color = pop();
break;
case SO_CLIPPED: // 67
- _floodFillParams.box.bottom = pop();
- _floodFillParams.box.right = pop();
- _floodFillParams.box.top = pop();
- _floodFillParams.box.left = pop();
- adjustRect(_floodFillParams.box);
+ _floodFillCommand.box.bottom = pop();
+ _floodFillCommand.box.right = pop();
+ _floodFillCommand.box.top = pop();
+ _floodFillCommand.box.left = pop();
break;
case SO_END: // 255
- floodFill(&_floodFillParams, this);
+ _wiz->pgFloodFillCmd(_floodFillCommand.x, _floodFillCommand.y, _floodFillCommand.color, &_floodFillCommand.box);
break;
default:
error("o90_floodFill: Unknown case %d", subOp);
diff --git a/engines/scumm/he/sprite_he.cpp b/engines/scumm/he/sprite_he.cpp
index e642c6002fb..2d270f6fa53 100644
--- a/engines/scumm/he/sprite_he.cpp
+++ b/engines/scumm/he/sprite_he.cpp
@@ -1096,7 +1096,7 @@ void Sprite::resetTables(bool refreshScreen) {
resetGroup(curGrp);
if (refreshScreen) {
- _vm->restoreBackgroundHE(Common::Rect(_vm->_screenWidth, _vm->_screenHeight));
+ _vm->backgroundToForegroundBlit(Common::Rect(_vm->_screenWidth, _vm->_screenHeight));
}
_numSpritesToProcess = 0;
}
@@ -1114,7 +1114,7 @@ void Sprite::resetBackground() {
spi->flags &= ~kSFErase;
if (spi->lastRect.left <= spi->lastRect.right && spi->lastRect.top <= spi->lastRect.bottom) {
if (spi->flags & kSFDontCombineErase) {
- _vm->restoreBackgroundHE(spi->lastRect, USAGE_BIT_RESTORED);
+ _vm->backgroundToForegroundBlit(spi->lastRect, USAGE_BIT_RESTORED);
} else if (firstLoop) {
xmin = spi->lastRect.left;
ymin = spi->lastRect.top;
@@ -1143,7 +1143,7 @@ void Sprite::resetBackground() {
}
}
if (refreshScreen) {
- _vm->restoreBackgroundHE(Common::Rect(xmin, ymin, xmax, ymax), USAGE_BIT_RESTORED);
+ _vm->backgroundToForegroundBlit(Common::Rect(xmin, ymin, xmax, ymax), USAGE_BIT_RESTORED);
}
}
diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp
index 0645d17e041..c4513d12006 100644
--- a/engines/scumm/he/wiz_he.cpp
+++ b/engines/scumm/he/wiz_he.cpp
@@ -1608,7 +1608,7 @@ uint8 *Wiz::drawWizImage(int resNum, int state, int maskNum, int maskState, int
++rImage.bottom;
_vm->markRectAsDirty(kMainVirtScreen, rImage);
} else {
- _vm->restoreBackgroundHE(rImage);
+ _vm->backgroundToForegroundBlit(rImage);
}
}
}
@@ -2090,9 +2090,10 @@ void Wiz::drawWizPolygonTransform(int resNum, int state, Common::Point *wp, int
drawWizPolygonImage(dst, srcWizBuf, 0, dstpitch, dstType, dstw, dsth, wizW, wizH, bound, wp, _vm->_bytesPerPixel);
if (flags & kWRFForeground) {
+ ++bound.bottom;
_vm->markRectAsDirty(kMainVirtScreen, bound);
} else {
- _vm->restoreBackgroundHE(bound);
+ _vm->backgroundToForegroundBlit(bound);
}
if (freeBuffer)
@@ -2831,6 +2832,68 @@ void Wiz::processWizImageFontRenderCmd(const WizImageCommand *params) {
error("Wiz::processWizImageFontRenderCmd(): Render Font String");
}
+void Wiz::processWizImageRenderFloodFillCmd(const WizImageCommand *params) {
+ Common::Rect renderRect, clipRect, workClipRect;
+ int whichState, w, h, whichImage;
+ WizSimpleBitmap renderBitmap;
+ WizRawPixel whatColor;
+ Common::Point pt;
+
+ // Get the rendering coords or bail if none...
+ if (params->actionFlags & kWAFRenderCoords) {
+ pt.x = params->renderCoords.left;
+ pt.y = params->renderCoords.top;
+ } else {
+ return;
+ }
+
+ // What state is going to rendered into?
+ if (params->actionFlags & kWAFState) {
+ whichState = params->state;
+ } else {
+ whichState = 0;
+ }
+
+ whichImage = params->image;
+
+ // Make the clipping rect for this image / state
+ getWizImageDim(whichImage, whichState, w, h);
+ makeSizedRectAt(&clipRect, 0, 0, w, h);
+
+ if (params->actionFlags & kWAFRect) {
+ workClipRect.left = params->box.left;
+ workClipRect.top = params->box.top;
+ workClipRect.right = params->box.right;
+ workClipRect.bottom = params->box.bottom;
+
+ // Bail out if there isn't overlap between the clipping rects
+ if (!findRectOverlap(&clipRect, &workClipRect)) {
+ return;
+ }
+ }
+
+ // What is the rendering color
+ if (params->actionFlags & kWAFColor) {
+ whatColor = params->colorValue;
+ } else {
+ whatColor = _vm->VAR(_vm->VAR_COLOR_BLACK);
+ }
+
+ // Get the simple bitmap
+ if (!dwSetSimpleBitmapStructFromImage(whichImage, whichState, &renderBitmap)) {
+ error("Image %d state %d invalid for rendering.", whichImage, whichState);
+ }
+
+ // If we're here we must be able to render into the image (clipped)...
+ if (isPointInRect(&clipRect, &pt)) {
+ floodSimpleFill(&renderBitmap, pt.x, pt.y, whatColor, &clipRect, &renderRect);
+
+ if (_vm->_game.heversion > 99) {
+ _vm->_res->setModified(rtImage, params->image);
+ }
+ }
+}
+
void Wiz::processNewWizImageCmd(const WizImageCommand *params) {
int width, height;
int propertyNumber = 0, propertyValue = 0;
diff --git a/engines/scumm/he/wiz_he.h b/engines/scumm/he/wiz_he.h
index 57f0d13fe5e..110448457d6 100644
--- a/engines/scumm/he/wiz_he.h
+++ b/engines/scumm/he/wiz_he.h
@@ -190,12 +190,45 @@ struct WizImageCommand {
}
};
+struct FloodFillCommand {
+ Common::Rect box;
+ int32 x;
+ int32 y;
+ int32 flags;
+ int32 color;
+
+ void reset() {
+ box.top = box.left = box.bottom = box.right = 0;
+ x = 0;
+ y = 0;
+ flags = 0;
+ color = 0;
+ }
+};
+
struct WizSimpleBitmap {
WizRawPixel *bufferPtr;
int bitmapWidth;
int bitmapHeight;
};
+struct WizFloodSegment {
+ int y, xl, xr, dy;
+};
+
+struct WizFloodState {
+ WizFloodSegment *stack;
+ WizFloodSegment *top;
+ WizFloodSegment *sp;
+ Common::Rect updateRect;
+ Common::Rect clipping;
+ WizSimpleBitmap *bitmapPtr;
+ int writeOverColor;
+ int colorToWrite;
+ int boundryColor;
+ int numStackElements;
+};
+
enum WizRenderingFlags {
// Standard rendering flags
@@ -465,7 +498,7 @@ public:
private:
ScummEngine_v71he *_vm;
- /* Wiz Drawing Primitives
+ /* Drawing Primitives
*
* These primitives are slightly different and less precise
* than the ones available in our Graphics subsystem.
@@ -474,6 +507,8 @@ public:
* primitives, please :-P
*/
+ // Primitives
+public:
int pgReadPixel(const WizSimpleBitmap *srcBM, int x, int y, int defaultValue);
void pgWritePixel(WizSimpleBitmap *srcBM, int x, int y, WizRawPixel value);
void pgClippedWritePixel(WizSimpleBitmap *srcBM, int x, int y, const Common::Rect *clipRectPtr, WizRawPixel value);
@@ -481,11 +516,30 @@ public:
void pgClippedThickLineDraw(WizSimpleBitmap *destBM, int asx, int asy, int aex, int aey, const Common::Rect *clipRectPtr, int iLineThickness, WizRawPixel value);
void pgDrawClippedEllipse(WizSimpleBitmap *pDestBitmap, int iPX, int iPY, int iQX, int iQY, int iKX, int iKY, int iLOD, const Common::Rect *pClipRectPtr, int iThickness, WizRawPixel aColor);
void pgDrawSolidRect(WizSimpleBitmap *destBM, const Common::Rect *rectPtr, WizRawPixel color);
+ void pgFloodFillCmd(int x, int y, int color, const Common::Rect *optionalClipRect);
+ void pgSimpleBitmapFromDrawBuffer(WizSimpleBitmap *bitmapPtr, bool background);
+ // Rectangles
bool findRectOverlap(Common::Rect *destRectPtr, const Common::Rect *sourceRectPtr);
bool isPointInRect(Common::Rect *r, Common::Point *pt);
+ bool isRectValid(Common::Rect r);
void makeSizedRectAt(Common::Rect *rectPtr, int x, int y, int width, int height);
void makeSizedRect(Common::Rect *rectPtr, int width, int height);
+ void combineRects(Common::Rect *destRect, Common::Rect *ra, Common::Rect *rb);
+
+ // Flood fill
+ void floodInitFloodState(WizFloodState *statePtr, WizSimpleBitmap *bitmapPtr, int colorToWrite, const Common::Rect *optionalClippingRect);
+ WizFloodState *floodCreateFloodState(int numStackElements);
+ void floodDestroyFloodState(WizFloodState *state);
+ //bool floodSimpleFloodCheckPixel(int x, int y, WizFloodState *state);
+ bool floodBoundryColorFloodCheckPixel(int x, int y, WizFloodState *state);
+ void floodFloodFillPrim(int x, int y, WizFloodState *statePtr, bool (*checkPixelFnPtr)(Wiz *w, int x, int y, WizFloodState *state));
+ void floodPerformOpOnRect(WizFloodState *statePtr, Common::Rect *rectPtr);
+ bool floodSimpleFill(WizSimpleBitmap *bitmapPtr, int x, int y, int colorToWrite, const Common::Rect *optionalClipRect, Common::Rect *updateRectPtr);
+
+ // Utils
+ int getRawPixel(int color);
+
};
} // End of namespace Scumm
diff --git a/engines/scumm/module.mk b/engines/scumm/module.mk
index 7ab9105ce6f..ea3352c48b0 100644
--- a/engines/scumm/module.mk
+++ b/engines/scumm/module.mk
@@ -143,7 +143,7 @@ ifdef ENABLE_HE
MODULE_OBJS += \
he/animation_he.o \
he/cup_player_he.o \
- he/floodfill_he.o \
+ he/gfx_primitives_he.o \
he/logic_he.o \
he/palette_he.o \
he/script_v71he.o \
@@ -153,7 +153,6 @@ MODULE_OBJS += \
he/script_v100he.o \
he/sprite_he.o \
he/wiz_he.o \
- he/wiz_primitives_he.o \
he/localizer.o \
he/logic/baseball2001.o \
he/logic/basketball.o \
diff --git a/engines/scumm/saveload.cpp b/engines/scumm/saveload.cpp
index ed12c89f5b3..e08b9c68daf 100644
--- a/engines/scumm/saveload.cpp
+++ b/engines/scumm/saveload.cpp
@@ -2260,15 +2260,16 @@ void ScummEngine_v71he::saveLoadWithSerializer(Common::Serializer &s) {
s.syncArray(_wiz->_polygons, ARRAYSIZE(_wiz->_polygons), syncWithSerializer);
}
-void syncWithSerializer(Common::Serializer &s, FloodFillParameters &ffp) {
- s.syncAsSint32LE(ffp.box.left, VER(51));
- s.syncAsSint32LE(ffp.box.top, VER(51));
- s.syncAsSint32LE(ffp.box.right, VER(51));
- s.syncAsSint32LE(ffp.box.bottom, VER(51));
- s.syncAsSint32LE(ffp.x, VER(51));
- s.syncAsSint32LE(ffp.y, VER(51));
- s.syncAsSint32LE(ffp.flags, VER(51));
- s.skip(4, VER(51), VER(62)); // unk1C
+void syncWithSerializer(Common::Serializer &s, FloodFillCommand &ffc) {
+ s.syncAsSint32LE(ffc.box.left, VER(51));
+ s.syncAsSint32LE(ffc.box.top, VER(51));
+ s.syncAsSint32LE(ffc.box.right, VER(51));
+ s.syncAsSint32LE(ffc.box.bottom, VER(51));
+ s.syncAsSint32LE(ffc.x, VER(51));
+ s.syncAsSint32LE(ffc.y, VER(51));
+ s.syncAsSint32LE(ffc.flags, VER(51));
+ s.skip(4, VER(51), VER(62)); // color
+ s.syncAsSint32LE(ffc.color, VER(114));
}
void ScummEngine_v90he::saveLoadWithSerializer(Common::Serializer &s) {
@@ -2276,7 +2277,7 @@ void ScummEngine_v90he::saveLoadWithSerializer(Common::Serializer &s) {
_sprite->saveLoadWithSerializer(s);
- syncWithSerializer(s, _floodFillParams);
+ syncWithSerializer(s, _floodFillCommand);
s.syncAsSint32LE(_curMaxSpriteId, VER(51));
s.syncAsSint32LE(_curSpriteId, VER(51));
Commit: d64a379d217107b95cd5ebeb5a7f66d55d5f409a
https://github.com/scummvm/scummvm/commit/d64a379d217107b95cd5ebeb5a7f66d55d5f409a
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Begin porting Wiz and other graphics code
Changed paths:
A engines/scumm/he/gfx_comp/aux_comp.cpp
A engines/scumm/he/gfx_comp/mrle_comp.cpp
A engines/scumm/he/gfx_comp/trle_comp.cpp
A engines/scumm/he/polygon_he.cpp
A engines/scumm/he/wizwarp_he.cpp
engines/scumm/gfx.cpp
engines/scumm/he/gfx_primitives_he.cpp
engines/scumm/he/script_v100he.cpp
engines/scumm/he/script_v71he.cpp
engines/scumm/he/script_v72he.cpp
engines/scumm/he/script_v80he.cpp
engines/scumm/he/script_v90he.cpp
engines/scumm/he/sprite_he.cpp
engines/scumm/he/wiz_he.cpp
engines/scumm/he/wiz_he.h
engines/scumm/module.mk
engines/scumm/object.cpp
engines/scumm/palette.cpp
engines/scumm/saveload.cpp
engines/scumm/scumm.h
diff --git a/engines/scumm/gfx.cpp b/engines/scumm/gfx.cpp
index a2f61a4ad0d..e8856c11a6a 100644
--- a/engines/scumm/gfx.cpp
+++ b/engines/scumm/gfx.cpp
@@ -1148,7 +1148,7 @@ void ScummEngine_v71he::redrawBGAreas() {
void ScummEngine_v72he::redrawBGAreas() {
ScummEngine_v71he::redrawBGAreas();
- _wiz->flushWizBuffer();
+ _wiz->flushAWizBuffer();
}
#endif
diff --git a/engines/scumm/he/gfx_comp/aux_comp.cpp b/engines/scumm/he/gfx_comp/aux_comp.cpp
new file mode 100644
index 00000000000..6d6c1eaa9e8
--- /dev/null
+++ b/engines/scumm/he/gfx_comp/aux_comp.cpp
@@ -0,0 +1,34 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifdef ENABLE_HE
+
+#include "common/math.h"
+#include "common/system.h"
+#include "scumm/he/intern_he.h"
+#include "scumm/he/wiz_he.h"
+
+namespace Scumm {
+
+
+} // End of namespace Scumm
+
+#endif // ENABLE_HE
diff --git a/engines/scumm/he/gfx_comp/mrle_comp.cpp b/engines/scumm/he/gfx_comp/mrle_comp.cpp
new file mode 100644
index 00000000000..2749e91acd0
--- /dev/null
+++ b/engines/scumm/he/gfx_comp/mrle_comp.cpp
@@ -0,0 +1,395 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifdef ENABLE_HE
+
+#include "common/math.h"
+#include "common/system.h"
+#include "scumm/he/intern_he.h"
+#include "scumm/he/wiz_he.h"
+
+namespace Scumm {
+
+static void MRLEFLIP_HorzFlipAlignWithRect(Common::Rect *rectToAlign, const Common::Rect *baseRect) {
+ int dx = (baseRect->right - rectToAlign->right) - (rectToAlign->left - baseRect->left);
+ rectToAlign->left += dx;
+ rectToAlign->right += dx;
+}
+
+static void MRLEFLIP_VertFlipAlignWithRect(Common::Rect *rectToAlign, const Common::Rect *baseRect) {
+ int dy = (baseRect->bottom - rectToAlign->bottom) - (rectToAlign->top - baseRect->top);
+ rectToAlign->top += dy;
+ rectToAlign->bottom += dy;
+}
+
+#define HANDLE_SKIP_PIXELS_MACRO() { \
+ /* Decompress bytes to do simple clipping... */ \
+ while (skipAmount > 0) { \
+ if ((runCount = *dataStream++) & 1) { \
+ \
+ /* Handle the transparent color... */ \
+ runCount >>= 1; \
+ if (runCount > skipAmount) { \
+ runCount -= skipAmount; \
+ goto DoTransparentRun; \
+ } else { \
+ skipAmount -= runCount; \
+ } \
+ \
+ } else { /* xxxxxxx0 */ \
+ /* Handle a run of color... */ \
+ runCount >>= 1; \
+ if (runCount > skipAmount) { \
+ runCount -= skipAmount; \
+ goto WriteRunData; \
+ } else { \
+ skipAmount -= runCount; \
+ } \
+ } \
+ } \
+ }
+
+#define HANDLE_RUN_DECOMPRESS_MACRO(_TransparentCode_, _RunCode_) { \
+ while (decompAmount > 0) { \
+ runCount = *dataStream++; \
+ \
+ if (runCount & 1) { /* xxxxxxx1 */ \
+ runCount >>= 1; \
+ DoTransparentRun: \
+ decompAmount -= runCount; \
+ _TransparentCode_ \
+ \
+ } else { /* xxxxxxx0 */ \
+ \
+ runCount >>= 1; \
+ WriteRunData: \
+ decompAmount -= runCount; \
+ if (decompAmount < 0) { \
+ runCount += decompAmount; \
+ } \
+ _RunCode_ \
+ } \
+ } \
+ }
+
+static void MRLEFLIP_AltSource_F_XBppToXBpp(Wiz *wiz,
+ WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream,
+ int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
+ const WizRawPixel *srcPtr;
+ int runCount;
+
+ srcPtr = (const WizRawPixel *)altSourcePtr;
+
+ // Decompress bytes to do simple clipping...
+ HANDLE_SKIP_PIXELS_MACRO();
+
+ // Really decompress to the dest buffer...
+ HANDLE_RUN_DECOMPRESS_MACRO(
+ {
+ destPtr += runCount;
+ srcPtr += runCount;
+ },
+ {
+ memcpy(destPtr, srcPtr, (runCount * sizeof(WizRawPixel)));
+ destPtr += runCount;
+ srcPtr += runCount;
+ }
+ );
+}
+
+static void MRLEFLIP_AltSource_B_XBppToXBpp(Wiz *wiz,
+ WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream,
+ int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
+ const WizRawPixel *srcPtr;
+ int runCount;
+
+ srcPtr = (const WizRawPixel *)altSourcePtr;
+
+ // Decompress bytes to do simple clipping...
+ HANDLE_SKIP_PIXELS_MACRO();
+
+ // Really decompress to the dest buffer...
+ HANDLE_RUN_DECOMPRESS_MACRO(
+ {
+ destPtr -= runCount;
+ srcPtr -= runCount;
+ },
+ {
+ destPtr -= runCount;
+ srcPtr -= runCount;
+ memcpy(destPtr + 1, srcPtr + 1, (runCount * sizeof(WizRawPixel)));
+ }
+ );
+}
+
+static void MRLEFLIP_AltSource_F_8BppToXBpp(Wiz *wiz,
+ WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream,
+ int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
+ const byte *srcPtr;
+ int runCount;
+
+ srcPtr = (const byte *)altSourcePtr;
+
+ // Decompress bytes to do simple clipping...
+ HANDLE_SKIP_PIXELS_MACRO();
+
+ // Really decompress to the dest buffer...
+ HANDLE_RUN_DECOMPRESS_MACRO(
+ {
+ destPtr += runCount;
+ srcPtr += runCount;
+ },
+ {
+ wiz->memcpy8BppConversion(destPtr, srcPtr, runCount, conversionTable);
+ destPtr += runCount;
+ srcPtr += runCount;
+ });
+}
+
+static void MRLEFLIP_AltSource_B_8BppToXBpp(Wiz *wiz,
+ WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream,
+ int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
+ const WizRawPixel *srcPtr;
+ int runCount;
+
+ srcPtr = (const WizRawPixel *)altSourcePtr;
+
+ // Decompress bytes to do simple clipping...
+ HANDLE_SKIP_PIXELS_MACRO();
+
+ // Really decompress to the dest buffer...
+ HANDLE_RUN_DECOMPRESS_MACRO(
+ {
+ destPtr -= runCount;
+ srcPtr -= runCount;
+ },
+ {
+ destPtr -= runCount;
+ srcPtr -= runCount;
+ wiz->memcpy8BppConversion(destPtr + 1, srcPtr + 1, runCount, conversionTable);
+ });
+}
+
+static void MRLEFLIP_AltSource_DecompImageHull(Wiz *wiz,
+ WizRawPixel *bufferPtr, int bufferWidth, const Common::Rect *destRect,
+ const byte *altSourceBuffer, int altBytesPerLine,
+ int altBytesPerPixel, const Common::Rect *altRect,
+ const byte *compData, const Common::Rect *sourceRect,
+ const WizRawPixel *conversionTable,
+ void (*functionPtr)(Wiz *wiz,
+ WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream,
+ int skipAmount, int decompAmount, const WizRawPixel *conversionTable)) {
+ int decompWidth, decompHeight, counter, sX1, lineSize;
+
+ // Yet more general setup...
+ sX1 = sourceRect->left;
+
+ decompWidth = sourceRect->right - sourceRect->left + 1;
+ decompHeight = sourceRect->bottom - sourceRect->top + 1;
+
+ // Quickly skip down to the lines to be compressed & dest position...
+ bufferPtr += bufferWidth * destRect->top + destRect->left;
+
+ for (counter = sourceRect->top; counter > 0; counter--) {
+ compData += READ_LE_UINT16((byte *)compData) + 2;
+ }
+
+ // Calc the ALT buffer location
+ altSourceBuffer += (altBytesPerLine * altRect->top) + (altRect->left * altBytesPerPixel);
+
+ // Flip the dest offset if vertical flipping...
+ if (destRect->top > destRect->bottom) {
+ bufferWidth = -bufferWidth;
+ altBytesPerLine = -altBytesPerLine;
+ }
+
+ // Decompress all the lines that are visible!!!!
+ while (decompHeight-- > 0) {
+ lineSize = READ_LE_UINT16((byte *)compData);
+
+ if (lineSize != 0) {
+ (*functionPtr)(wiz,
+ bufferPtr, altSourceBuffer, compData + 2, sX1,
+ decompWidth, conversionTable);
+
+ compData += lineSize + 2;
+ bufferPtr += bufferWidth;
+ altSourceBuffer += altBytesPerLine;
+
+ } else {
+ // Handle a completely transparent line!
+ compData += 2;
+ bufferPtr += bufferWidth;
+ altSourceBuffer += altBytesPerLine;
+ }
+ }
+}
+
+void Wiz::MRLEFLIP_AltSource_DecompressPrim(
+ WizRawPixel *destBufferPtr, int destBufferWidth, int destBufferHeight,
+ const void *altBufferPtr, int altBitsPerPixel,
+ const WizCompressedImage *imagePtr, int destX, int destY,
+ const Common::Rect *sourceCoords, const Common::Rect *clipRectPtr,
+ int32 flags, const WizRawPixel *conversionTable,
+ void (*forewordFunctionPtr)(Wiz *wiz,
+ WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream,
+ int skipAmount, int decompAmount, const WizRawPixel *conversionTable),
+ void (*backwardFunctionPtr)(Wiz *wiz,
+ WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream,
+ int skipAmount, int decompAmount, const WizRawPixel *conversionTable)) {
+
+ Common::Rect sourceRect, destRect, clipRect, workRect, inSourceRect;
+ int width, height;
+
+ void (*functionPtr)(Wiz * wiz,
+ WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream,
+ int skipAmount, int decompAmount, const WizRawPixel *conversionTable);
+
+ if (!sourceCoords) {
+ width = imagePtr->width;
+ height = imagePtr->height;
+
+ sourceRect.left = 0;
+ sourceRect.top = 0;
+ sourceRect.right = width - 1;
+ sourceRect.bottom = height - 1;
+ } else {
+ width = sourceCoords->right - sourceCoords->left + 1;
+ height = sourceCoords->bottom - sourceCoords->top + 1;
+ sourceRect = *sourceCoords;
+ }
+
+ inSourceRect = sourceRect;
+
+ destRect.left = destX;
+ destRect.top = destY;
+ destRect.right = destX + width - 1;
+ destRect.bottom = destY + height - 1;
+
+ // Custom clip rect...
+ if (!clipRectPtr) {
+ clipRect = *clipRectPtr;
+
+ workRect.left = 0;
+ workRect.top = 0;
+ workRect.right = destBufferWidth - 1;
+ workRect.bottom = destBufferHeight - 1;
+
+ if (!findRectOverlap(&clipRect, &workRect)) {
+ return;
+ }
+ } else {
+ clipRect.left = 0;
+ clipRect.top = 0;
+ clipRect.right = destBufferWidth - 1;
+ clipRect.bottom = destBufferHeight - 1;
+ }
+
+ // Clip the source & dest coords to the clipping rectangle...
+ clipRectCoords(&sourceRect, &destRect, &clipRect);
+
+ if (destRect.right < destRect.left) {
+ return;
+ }
+
+ if (destRect.bottom < destRect.top) {
+ return;
+ }
+
+ if (sourceRect.right < sourceRect.left) {
+ return;
+ }
+
+ if (sourceRect.bottom < sourceRect.top) {
+ return;
+ }
+
+ // Handle the flip coords source adjustment...
+ if (flags & kWRFHFlip) {
+ functionPtr = backwardFunctionPtr;
+ MRLEFLIP_HorzFlipAlignWithRect(&sourceRect, &inSourceRect);
+ SWAP<int16>(destRect.left, destRect.right);
+ } else {
+ functionPtr = forewordFunctionPtr;
+ }
+
+ if (flags & kWRFVFlip) {
+ MRLEFLIP_VertFlipAlignWithRect(&sourceRect, &inSourceRect);
+ SWAP<int16>(destRect.top, destRect.bottom);
+ }
+
+ // Call the primitive image renderer...
+ MRLEFLIP_AltSource_DecompImageHull(this,
+ destBufferPtr, destBufferWidth, &destRect,
+ (const byte *)altBufferPtr, ((destBufferWidth * altBitsPerPixel) / 8),
+ (altBitsPerPixel / 8), &destRect, imagePtr->data, &sourceRect,
+ conversionTable, functionPtr);
+}
+
+void Wiz::MRLEFLIP_AltSource_DecompressImage(
+ WizRawPixel *destBufferPtr, const byte *compData, int destBufferWidth, int destBufferHeight,
+ const void *altBufferPtr, int altWidth, int altHeight, int altBitsPerPixel,
+ int x, int y, int width, int height, Common::Rect *clipRectPtr,
+ int32 wizFlags, const WizRawPixel *conversionTable) {
+
+ Common::Rect srcRect, clipRect;
+ WizCompressedImage fakeImage;
+
+ // General setup
+ fakeImage.data = (byte *)compData;
+ fakeImage.width = width;
+ fakeImage.height = height;
+
+ makeSizedRect(&srcRect, width, height);
+ makeSizedRect(&clipRect, destBufferWidth, destBufferHeight);
+
+ if (clipRectPtr) {
+ if (!findRectOverlap(&clipRect, clipRectPtr)) {
+ return;
+ }
+ }
+
+ // Check the assumptions about the alt src buffer matching the dest buffer
+ if ((altWidth != destBufferWidth) || (altHeight != destBufferHeight)) {
+ return;
+ }
+
+ // Dispatch to the next level of code. (8bpp or conversion)
+ if (altBitsPerPixel == 16) {
+ MRLEFLIP_AltSource_DecompressPrim(
+ destBufferPtr, destBufferWidth, destBufferHeight,
+ altBufferPtr, altBitsPerPixel, &fakeImage, x, y,
+ &srcRect, &clipRect, wizFlags, conversionTable,
+ MRLEFLIP_AltSource_F_XBppToXBpp,
+ MRLEFLIP_AltSource_B_XBppToXBpp);
+ } else if (altBitsPerPixel == 8) {
+ MRLEFLIP_AltSource_DecompressPrim(
+ destBufferPtr, destBufferWidth, destBufferHeight,
+ altBufferPtr, altBitsPerPixel, &fakeImage, x, y,
+ &srcRect, &clipRect, wizFlags, conversionTable,
+ MRLEFLIP_AltSource_F_8BppToXBpp,
+ MRLEFLIP_AltSource_B_8BppToXBpp);
+ }
+}
+
+} // End of namespace Scumm
+
+#endif // ENABLE_HE
diff --git a/engines/scumm/he/gfx_comp/trle_comp.cpp b/engines/scumm/he/gfx_comp/trle_comp.cpp
new file mode 100644
index 00000000000..6d6c1eaa9e8
--- /dev/null
+++ b/engines/scumm/he/gfx_comp/trle_comp.cpp
@@ -0,0 +1,34 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifdef ENABLE_HE
+
+#include "common/math.h"
+#include "common/system.h"
+#include "scumm/he/intern_he.h"
+#include "scumm/he/wiz_he.h"
+
+namespace Scumm {
+
+
+} // End of namespace Scumm
+
+#endif // ENABLE_HE
diff --git a/engines/scumm/he/gfx_primitives_he.cpp b/engines/scumm/he/gfx_primitives_he.cpp
index a7e1254b41c..e5fe63846bf 100644
--- a/engines/scumm/he/gfx_primitives_he.cpp
+++ b/engines/scumm/he/gfx_primitives_he.cpp
@@ -21,17 +21,10 @@
#ifdef ENABLE_HE
-#include "common/archive.h"
#include "common/system.h"
#include "common/math.h"
-#include "graphics/cursorman.h"
-#include "graphics/primitives.h"
#include "scumm/he/intern_he.h"
-#include "scumm/resource.h"
-#include "scumm/scumm.h"
-#include "scumm/util.h"
#include "scumm/he/wiz_he.h"
-#include "scumm/he/moonbase/moonbase.h"
namespace Scumm {
@@ -473,6 +466,903 @@ void Wiz::pgSimpleBitmapFromDrawBuffer(WizSimpleBitmap *bitmapPtr, bool backgrou
}
}
+void Wiz::pgDrawRawDataFormatImage(WizRawPixel *bufferPtr, const WizRawPixel *rawData, int bufferWidth, int bufferHeight, int x, int y, int width, int height, Common::Rect *clipRectPtr, int32 wizFlags, const void *extraTable, int transparentColor) {
+ Common::Rect srcRect, dstRect, clipRect;
+ WizSimpleBitmap srcBitmap, dstBitmap;
+ int off, t;
+
+ // Build the dest bitmap clipping rect and clip the "CLIP"
+ // rect passed in to it.
+ clipRect.left = 0;
+ clipRect.top = 0;
+ clipRect.right = bufferWidth - 1;
+ clipRect.bottom = bufferHeight - 1;
+
+ if (clipRectPtr) {
+ if (!findRectOverlap(&clipRect, clipRectPtr)) {
+ return;
+ }
+ }
+
+ // Build the src and dest rects based on the passed in coords
+ srcRect.left = 0;
+ srcRect.top = 0;
+ srcRect.right = (width - 1);
+ srcRect.bottom = (height - 1);
+
+ dstRect.left = x;
+ dstRect.top = y;
+ dstRect.right = (x + width - 1);
+ dstRect.bottom = (y + height - 1);
+
+ // Clip the src & dst coords to the clipping rect
+ clipRectCoords(&srcRect, &dstRect, &clipRect);
+
+ if (dstRect.right < dstRect.left) {
+ return;
+ }
+
+ if (dstRect.bottom < dstRect.top) {
+ return;
+ }
+
+ if (srcRect.right < srcRect.left) {
+ return;
+ }
+
+ if (srcRect.bottom < srcRect.top) {
+ return;
+ }
+
+ if (_vm->_game.heversion > 90) {
+ if (wizFlags & kWRFHFlip) {
+ off = ((width - (srcRect.right + 1)) - srcRect.left);
+ t = srcRect.left + off;
+ srcRect.left = srcRect.right + off;
+ srcRect.right = t;
+ }
+
+ if (wizFlags & kWRFVFlip) {
+ off = ((height - (srcRect.bottom + 1)) - srcRect.top);
+ t = srcRect.top + off;
+ srcRect.top = srcRect.bottom + off;
+ srcRect.bottom = t;
+ }
+ }
+
+ // Setup the fake simple bitmaps...
+ dstBitmap.bufferPtr = bufferPtr;
+ dstBitmap.bitmapWidth = bufferWidth;
+ dstBitmap.bitmapHeight = bufferHeight;
+
+ srcBitmap.bufferPtr = (WizRawPixel *)rawData;
+ srcBitmap.bitmapWidth = width;
+ srcBitmap.bitmapHeight = height;
+
+ // Dispatch the drawing to the specific drawing function...
+ if (_vm->_game.heversion <= 90) {
+ pgSimpleBlit(&dstBitmap, &dstRect, &srcBitmap, &srcRect);
+ } else {
+ if (extraTable) {
+ if (wizFlags & kWRFRemap) {
+ if (transparentColor == -1) {
+ pgSimpleBlitRemapColors(&dstBitmap, &dstRect, &srcBitmap, &srcRect, (byte *)extraTable);
+ } else {
+ pgSimpleBlitTransparentRemapColors(&dstBitmap, &dstRect, &srcBitmap, &srcRect, (WizRawPixel)transparentColor, (byte *)extraTable);
+ }
+ } else {
+ if (transparentColor == -1) {
+ pgSimpleBlitMixColors(&dstBitmap, &dstRect, &srcBitmap, &srcRect, (byte *)extraTable);
+ } else {
+ pgSimpleBlitTransparentMixColors(&dstBitmap, &dstRect, &srcBitmap, &srcRect, (WizRawPixel)transparentColor, (byte *)extraTable);
+ }
+ }
+ } else {
+ // Dispatch the drawing to the specific drawing function...
+ if (transparentColor == -1) {
+ pgSimpleBlit(&dstBitmap, &dstRect, &srcBitmap, &srcRect);
+ } else {
+ pgTransparentSimpleBlit(&dstBitmap, &dstRect, &srcBitmap, &srcRect, (WizRawPixel)transparentColor);
+ }
+ }
+ }
+}
+
+void Wiz::pgSimpleBlit(WizSimpleBitmap *destBM, Common::Rect *destRect, WizSimpleBitmap *sourceBM, Common::Rect *sourceRect) {
+ int cw, dw, sw, ch, cSize;
+ WizRawPixel *s, *d;
+
+ // Common calcs...
+ dw = destBM->bitmapWidth;
+ sw = sourceBM->bitmapWidth;
+ cw = abs(sourceRect->right - sourceRect->left) + 1;
+ ch = abs(sourceRect->bottom - sourceRect->top) + 1;
+ d = destBM->bufferPtr + destRect->top * dw + destRect->left;
+ s = sourceBM->bufferPtr + sourceRect->top * sw + sourceRect->left;
+
+ // Going up or down?
+ if (sourceRect->top > sourceRect->bottom) {
+ sw = -sw;
+ }
+
+ // Left or right?
+ if (sourceRect->left <= sourceRect->right) {
+ cSize = (cw * sizeof(WizRawPixel));
+
+ while (--ch >= 0) {
+ memcpy(d, s, cSize); // TODO
+
+ d += dw;
+ s += sw;
+ }
+ } else {
+ dw -= cw;
+ sw += cw;
+
+ while (--ch >= 0) {
+ for (int i = cw; --i >= 0;) {
+ *d++ = *s--;
+ }
+
+ d += dw;
+ s += sw;
+ }
+ }
+}
+
+void Wiz::pgSimpleBlitRemapColors(WizSimpleBitmap *destBM, Common::Rect *destRect, WizSimpleBitmap *sourceBM, Common::Rect *sourceRect, const byte *remapColorTable) {
+ int cw, dw, sw, ch;
+ WizRawPixel *s, *d;
+
+ // Common calcs...
+ dw = destBM->bitmapWidth;
+ sw = sourceBM->bitmapWidth;
+ cw = abs(sourceRect->right - sourceRect->left) + 1;
+ ch = abs(sourceRect->bottom - sourceRect->top) + 1;
+ d = destBM->bufferPtr + destRect->top * dw + destRect->left;
+ s = sourceBM->bufferPtr + sourceRect->top * sw + sourceRect->left;
+
+ // Going up or down?
+ if (sourceRect->top > sourceRect->bottom) {
+ sw = -sw;
+ }
+
+ // Left or right?
+ if (sourceRect->left <= sourceRect->right) {
+ while (--ch >= 0) {
+ pgForewordRemapPixelCopy(d, s, cw, remapColorTable);
+
+ d += dw;
+ s += sw;
+ }
+ } else {
+ d += (cw - 1);
+ s -= (cw - 1);
+
+ while (--ch >= 0) {
+ pgBackwardsRemapPixelCopy(d, s, cw, remapColorTable);
+
+ d += dw;
+ s += sw;
+ }
+ }
+}
+
+void Wiz::pgSimpleBlitTransparentRemapColors(WizSimpleBitmap *destBM, Common::Rect *destRect, WizSimpleBitmap *sourceBM, Common::Rect *sourceRect, WizRawPixel transparentColor, const byte *remapColorTable) {
+ int cw, dw, sw, ch;
+ WizRawPixel *s, *d;
+
+ // Common calcs...
+ dw = destBM->bitmapWidth;
+ sw = sourceBM->bitmapWidth;
+ cw = abs(sourceRect->right - sourceRect->left) + 1;
+ ch = abs(sourceRect->bottom - sourceRect->top) + 1;
+ d = destBM->bufferPtr + destRect->top * dw + destRect->left;
+ s = sourceBM->bufferPtr + sourceRect->top * sw + sourceRect->left;
+
+ // Going up or down?
+ if (sourceRect->top > sourceRect->bottom) {
+ sw = -sw;
+ }
+
+ // Left or right?
+ if (sourceRect->left <= sourceRect->right) {
+ while (--ch >= 0) {
+ pgTransparentForewordRemapPixelCopy(d, s, cw, transparentColor, remapColorTable);
+
+ d += dw;
+ s += sw;
+ }
+ } else {
+ d += (cw - 1);
+ s -= (cw - 1);
+
+ while (--ch >= 0) {
+ pgTransparentBackwardsRemapPixelCopy(d, s, cw, transparentColor, remapColorTable);
+
+ d += dw;
+ s += sw;
+ }
+ }
+}
+
+void Wiz::pgSimpleBlitMixColors(WizSimpleBitmap *destBM, Common::Rect *destRect, WizSimpleBitmap *sourceBM, Common::Rect *sourceRect, const byte *mixColorTable) {
+ int cw, dw, sw, ch;
+ WizRawPixel *s, *d;
+
+ // Common calcs...
+ dw = destBM->bitmapWidth;
+ sw = sourceBM->bitmapWidth;
+ cw = abs(sourceRect->right - sourceRect->left) + 1;
+ ch = abs(sourceRect->bottom - sourceRect->top) + 1;
+ d = destBM->bufferPtr + destRect->top * dw + destRect->left;
+ s = sourceBM->bufferPtr + sourceRect->top * sw + sourceRect->left;
+
+ // Going up or down?
+ if (sourceRect->top > sourceRect->bottom) {
+ sw = -sw;
+ }
+
+ // Left or right?
+ if (sourceRect->left <= sourceRect->right) {
+ while (--ch >= 0) {
+ pgForewordMixColorsPixelCopy(d, s, cw, mixColorTable);
+
+ d += dw;
+ s += sw;
+ }
+ } else {
+ d += (cw - 1);
+ s -= (cw - 1);
+
+ while (--ch >= 0) {
+ pgBackwardsMixColorsPixelCopy(d, s, cw, mixColorTable);
+
+ d += dw;
+ s += sw;
+ }
+ }
+}
+
+void Wiz::pgSimpleBlitTransparentMixColors(WizSimpleBitmap *destBM, Common::Rect *destRect, WizSimpleBitmap *sourceBM, Common::Rect *sourceRect, WizRawPixel transparentColor, const byte *mixColorTable) {
+ int cw, dw, sw, ch;
+ WizRawPixel *s, *d;
+
+ // Common calcs...
+ dw = destBM->bitmapWidth;
+ sw = sourceBM->bitmapWidth;
+ cw = abs(sourceRect->right - sourceRect->left) + 1;
+ ch = abs(sourceRect->bottom - sourceRect->top) + 1;
+ d = destBM->bufferPtr + destRect->top * dw + destRect->left;
+ s = sourceBM->bufferPtr + sourceRect->top * sw + sourceRect->left;
+
+ // Going up or down?
+ if (sourceRect->top > sourceRect->bottom) {
+ sw = -sw;
+ }
+
+ // Left or right?
+ if (sourceRect->left <= sourceRect->right) {
+ while (--ch >= 0) {
+ pgTransparentForewordMixColorsPixelCopy(d, s, cw, transparentColor, mixColorTable);
+
+ d += dw;
+ s += sw;
+ }
+ } else {
+ d += (cw - 1);
+ s -= (cw - 1);
+
+ while (--ch >= 0) {
+ pgTransparentBackwardsMixColorsPixelCopy(d, s, cw, transparentColor, mixColorTable);
+
+ d += dw;
+ s += sw;
+ }
+ }
+}
+
+void Wiz::pgTransparentSimpleBlit(WizSimpleBitmap *destBM, Common::Rect *destRect, WizSimpleBitmap *sourceBM, Common::Rect *sourceRect, WizRawPixel transparentColor) {
+ int value, cw, dw, sw, ch, soff, doff, tColor;
+ WizRawPixel *s, *d;
+
+ // Common calcs...
+ dw = destBM->bitmapWidth;
+ sw = sourceBM->bitmapWidth;
+ cw = abs(sourceRect->right - sourceRect->left) + 1;
+ ch = abs(sourceRect->bottom - sourceRect->top) + 1;
+ d = destBM->bufferPtr + destRect->top * dw + destRect->left;
+ s = sourceBM->bufferPtr + sourceRect->top * sw + sourceRect->left;
+
+ tColor = (int)transparentColor;
+
+ // Going up or down?
+ if (sourceRect->top > sourceRect->bottom) {
+ sw = -sw;
+ }
+
+ // Left or right?
+ if (sourceRect->left <= sourceRect->right) {
+ soff = sw - cw;
+ doff = dw - cw;
+
+ while (--ch >= 0) {
+ for (int x = cw; --x >= 0;) {
+ value = *s++;
+
+ if (value != tColor) {
+ *d++ = value;
+ } else {
+ d++;
+ }
+ }
+
+ s += soff;
+ d += doff;
+ }
+
+ } else {
+ soff = sw + cw;
+ doff = dw - cw;
+
+ while (--ch >= 0) {
+ for (int x = cw; --x >= 0;) {
+ value = *s--;
+
+ if (value != tColor) {
+ *d++ = value;
+ } else {
+ d++;
+ }
+ }
+
+ s += soff;
+ d += doff;
+ }
+ }
+}
+
+void Wiz::pgDraw8BppFormatImage(WizRawPixel *bufferPtr, const byte *rawData, int bufferWidth, int bufferHeight, int x, int y, int width, int height, Common::Rect *clipRectPtr, int32 wizFlags, const void *extraTable, int transparentColor, const WizRawPixel *conversionTable) {
+ Common::Rect srcRect, dstRect, clipRect;
+ WizSimpleBitmap srcBitmap, dstBitmap;
+
+ // Build the dest bitmap clipping rect and clip the "CLIP"
+ // rect passed in to it.
+ clipRect.left = 0;
+ clipRect.top = 0;
+ clipRect.right = bufferWidth - 1;
+ clipRect.bottom = bufferHeight - 1;
+
+ if (clipRectPtr) {
+ if (!findRectOverlap(&clipRect, clipRectPtr)) {
+ return;
+ }
+ }
+
+ // Build the src and dest rects based on the passed in coords
+ srcRect.left = 0;
+ srcRect.top = 0;
+ srcRect.right = (width - 1);
+ srcRect.bottom = (height - 1);
+
+ dstRect.left = x;
+ dstRect.top = y;
+ dstRect.right = (x + width - 1);
+ dstRect.bottom = (y + height - 1);
+
+ // Clip the src & dst coords to the clipping rect
+ clipRectCoords(&srcRect, &dstRect, &clipRect);
+
+ if (dstRect.right < dstRect.left) {
+ return;
+ }
+
+ if (dstRect.bottom < dstRect.top) {
+ return;
+ }
+
+ if (srcRect.right < srcRect.left) {
+ return;
+ }
+
+ if (srcRect.bottom < srcRect.top) {
+ return;
+ }
+
+ if (wizFlags & kWRFHFlip) {
+ int off, t;
+ off = ((width - (srcRect.right + 1)) - srcRect.left);
+ t = srcRect.left + off;
+ srcRect.left = srcRect.right + off;
+ srcRect.right = t;
+ }
+
+ if (wizFlags & kWRFVFlip) {
+ int off, t;
+ off = ((height - (srcRect.bottom + 1)) - srcRect.top);
+ t = srcRect.top + off;
+ srcRect.top = srcRect.bottom + off;
+ srcRect.bottom = t;
+ }
+
+ // Setup the fake simple bitmaps...
+ dstBitmap.bufferPtr = bufferPtr;
+ dstBitmap.bitmapWidth = bufferWidth;
+ dstBitmap.bitmapHeight = bufferHeight;
+
+ srcBitmap.bufferPtr = (WizRawPixel *)rawData;
+ srcBitmap.bitmapWidth = width;
+ srcBitmap.bitmapHeight = height;
+
+ // Dispatch the drawing to the specific drawing function...
+ if (transparentColor == -1) {
+ pgDraw8BppSimpleBlit(&dstBitmap, &dstRect, &srcBitmap, &srcRect, conversionTable);
+ } else {
+ pgDraw8BppTransparentSimpleBlit(&dstBitmap, &dstRect, &srcBitmap, &srcRect, transparentColor, conversionTable);
+ }
+}
+
+void Wiz::pgDraw8BppSimpleBlit(WizSimpleBitmap *destBM, Common::Rect *destRect, WizSimpleBitmap *sourceBM, Common::Rect *sourceRect, const WizRawPixel *conversionTable) {
+ int x, cw, dw, sw, ch;
+ const byte *s;
+ WizRawPixel *d;
+
+ // Common calcs...
+ dw = destBM->bitmapWidth;
+ sw = sourceBM->bitmapWidth;
+ cw = abs(sourceRect->right - sourceRect->left) + 1;
+ ch = abs(sourceRect->bottom - sourceRect->top) + 1;
+ d = destBM->bufferPtr + destRect->top * dw + destRect->left;
+ s = ((const byte *)sourceBM->bufferPtr) + sourceRect->top * sw + sourceRect->left;
+
+ // Going up or down?
+ if (sourceRect->top > sourceRect->bottom) {
+ sw = -sw;
+ }
+
+ // Left or right?
+ if (sourceRect->left <= sourceRect->right) {
+ while (--ch >= 0) {
+ memcpy8BppConversion(d, s, cw, conversionTable);
+
+ d += dw;
+ s += sw;
+ }
+ } else {
+ dw -= cw;
+ sw += cw;
+
+ while (--ch >= 0) {
+ for (x = cw; --x >= 0;) {
+ *d++ = convert8BppToRawPixel(*s--, conversionTable);
+ }
+
+ d += dw;
+ s += sw;
+ }
+ }
+}
+
+void Wiz::pgDraw8BppTransparentSimpleBlit(WizSimpleBitmap *destBM, Common::Rect *destRect, WizSimpleBitmap *sourceBM, Common::Rect *sourceRect, int transparentColor, const WizRawPixel *conversionTable) {
+ int cw, dw, sw, ch, soff, doff, value;
+ const byte *s;
+ WizRawPixel *d;
+
+ // Common calcs...
+ dw = destBM->bitmapWidth;
+ sw = sourceBM->bitmapWidth;
+ cw = abs(sourceRect->right - sourceRect->left) + 1;
+ ch = abs(sourceRect->bottom - sourceRect->top) + 1;
+ d = destBM->bufferPtr + destRect->top * dw + destRect->left;
+ s = ((const byte *)sourceBM->bufferPtr) + sourceRect->top * sw + sourceRect->left;
+
+ // Going up or down?
+ if (sourceRect->top > sourceRect->bottom) {
+ sw = -sw;
+ }
+
+ // Left or right?
+ if (sourceRect->left <= sourceRect->right) {
+ soff = sw - cw;
+ doff = dw - cw;
+
+ while (--ch >= 0) {
+ for (int x = cw; --x >= 0;) {
+ value = *s++;
+
+ if (value != transparentColor) {
+ *d++ = convert8BppToRawPixel(value, conversionTable);
+ } else {
+ d++;
+ }
+ }
+
+ s += soff;
+ d += doff;
+ }
+ } else {
+ soff = sw + cw;
+ doff = dw - cw;
+
+ while (--ch >= 0) {
+ for (int x = cw; --x >= 0;) {
+ value = *s--;
+ if (value != transparentColor) {
+ *d++ = convert8BppToRawPixel(value, conversionTable);
+ } else {
+ d++;
+ }
+ }
+
+ s += soff;
+ d += doff;
+ }
+ }
+}
+
+void Wiz::pgDrawImageWith16BitZBuffer(WizSimpleBitmap *psbDst, const WizSimpleBitmap *psbZBuffer, const byte *imgData, int x, int y, int z, int width, int height, Common::Rect *prcClip) {
+ // validate parameters
+ assert(psbDst && psbZBuffer && imgData && prcClip);
+
+ // z-buffer and destination buffer must have the same dimensions
+ assert(psbDst->bitmapWidth == psbZBuffer->bitmapWidth);
+ assert(psbDst->bitmapHeight == psbZBuffer->bitmapHeight);
+
+ // make sure that clip rect is clipped to destination buffer
+ Common::Rect dstRect;
+
+ makeSizedRect(&dstRect, psbDst->bitmapWidth, psbDst->bitmapHeight);
+
+ if (!findRectOverlap(prcClip, &dstRect)) {
+ // rectangles don't intersect - no drawing necessary
+ return;
+ }
+
+ // make sure that clip rect is clipped to source image
+ Common::Rect srcRect;
+
+ srcRect.left = x;
+ srcRect.top = y;
+ srcRect.right = x + (width - 1);
+ srcRect.bottom = y + (height - 1);
+
+ if (!findRectOverlap(prcClip, &srcRect)) {
+ // rectangles don't intersect - no drawing necessary
+ return;
+ }
+
+ // perform the drawing
+ int dstWidth = psbDst->bitmapWidth; // same for destination and Z buffer
+
+ WizRawPixel *pSrc = (WizRawPixel *)imgData + (prcClip->top - y) * width + (prcClip->left - x);
+ WizRawPixel *pDst = (WizRawPixel *)psbDst->bufferPtr + prcClip->top * dstWidth + prcClip->left;
+ WizRawPixel *pZB = (WizRawPixel *)psbZBuffer->bufferPtr + prcClip->top * dstWidth + prcClip->left;
+
+ const int drawWidth = (prcClip->right - prcClip->left + 1);
+ const int drawHeight = (prcClip->bottom - prcClip->top + 1);
+
+ for (int row = 0; row < drawHeight; ++row) {
+ for (int col = 0; col < drawWidth; ++col, ++pZB, ++pDst, ++pSrc) {
+ // left hand rule - don't draw unless we're closer than the z-buffer value
+ if (*pZB > z) {
+ *pDst = *pSrc;
+ }
+ }
+
+ // move to the next line
+ pSrc += width - drawWidth;
+ pDst += dstWidth - drawWidth;
+ pZB += dstWidth - drawWidth;
+ }
+}
+
+void Wiz::pgForewordRemapPixelCopy(WizRawPixel *dstPtr, const WizRawPixel *srcPtr, int size, const byte *lookupTable) {
+ if (!_uses16BitColor) {
+ while (size-- > 0) {
+ *dstPtr++ = *(lookupTable + *srcPtr++);
+ }
+ } else {
+ while (size-- > 0) {
+ *dstPtr++ = *srcPtr++;
+ }
+ }
+}
+
+void Wiz::pgTransparentForewordRemapPixelCopy(WizRawPixel *dstPtr, const WizRawPixel *srcPtr, int size, WizRawPixel transparentColor, const byte *lookupTable) {
+ if (!_uses16BitColor) {
+ while (size-- > 0) {
+ WizRawPixel srcColor = *srcPtr++;
+
+ if (transparentColor != srcColor) {
+ WizRawPixel remappedColor = *(lookupTable + srcColor);
+
+ if (transparentColor != remappedColor) {
+ *dstPtr++ = remappedColor;
+ } else {
+ ++dstPtr;
+ }
+ } else {
+ ++dstPtr;
+ }
+ }
+ } else {
+ while (size-- > 0) {
+ WizRawPixel srcColor = *srcPtr++;
+
+ if (transparentColor != srcColor) {
+ *dstPtr++ = srcColor;
+ } else {
+ ++dstPtr;
+ }
+ }
+ }
+}
+
+void Wiz::pgTransparentBackwardsRemapPixelCopy(WizRawPixel *dstPtr, const WizRawPixel *srcPtr, int size, WizRawPixel transparentColor, const byte *lookupTable) {
+ if (!_uses16BitColor) {
+ while (size-- > 0) {
+ WizRawPixel srcColor = *srcPtr++;
+
+ if (transparentColor != srcColor) {
+ WizRawPixel remappedColor = *(lookupTable + srcColor);
+
+ if (transparentColor != remappedColor) {
+ *dstPtr-- = remappedColor;
+ } else {
+ --dstPtr;
+ }
+ } else {
+ --dstPtr;
+ }
+ }
+ } else {
+ while (size-- > 0) {
+ WizRawPixel srcColor = *srcPtr++;
+
+ if (transparentColor != srcColor) {
+ *dstPtr-- = srcColor;
+ } else {
+ --dstPtr;
+ }
+ }
+ }
+}
+
+void Wiz::pgBackwardsRemapPixelCopy(WizRawPixel *dstPtr, const WizRawPixel *srcPtr, int size, const byte *lookupTable) {
+ if (!_uses16BitColor) {
+ while (size-- > 0) {
+ *dstPtr-- = *(lookupTable + *srcPtr++);
+ }
+ } else {
+ while (size-- > 0) {
+ *dstPtr-- = *srcPtr++;
+ }
+ }
+}
+
+void Wiz::pgForewordMixColorsPixelCopy(WizRawPixel *dstPtr, const WizRawPixel *srcPtr, int size, const byte *lookupTable) {
+ if (!_uses16BitColor) {
+ while (size-- > 0) {
+ *dstPtr++ = *(lookupTable + ((*srcPtr++) * 256) + *dstPtr);
+ }
+ } else {
+ while (size-- > 0) {
+ if (_vm->_game.heversion > 99) {
+ WizRawPixel srcColor = *srcPtr++;
+ WizRawPixel dstColor = *dstPtr;
+
+ *dstPtr++ = WIZRAWPIXEL_50_50_MIX(
+ WIZRAWPIXEL_50_50_PREMIX_COLOR(srcColor),
+ WIZRAWPIXEL_50_50_PREMIX_COLOR(dstColor));
+ } else {
+ *dstPtr++ = (*srcPtr++);
+ }
+ }
+ }
+}
+
+void Wiz::pgBackwardsMixColorsPixelCopy(WizRawPixel *dstPtr, const WizRawPixel *srcPtr, int size, const byte *lookupTable) {
+ if (!_uses16BitColor) {
+ while (size-- > 0) {
+ *dstPtr-- = *(lookupTable + ((*srcPtr++) * 256) + *dstPtr);
+ }
+ } else {
+ while (size-- > 0) {
+ if (_vm->_game.heversion > 99) {
+ WizRawPixel srcColor = *srcPtr++;
+ WizRawPixel dstColor = *dstPtr;
+
+ *dstPtr-- = WIZRAWPIXEL_50_50_MIX(
+ WIZRAWPIXEL_50_50_PREMIX_COLOR(srcColor),
+ WIZRAWPIXEL_50_50_PREMIX_COLOR(dstColor));
+ } else {
+ *dstPtr-- = (*srcPtr++);
+ }
+ }
+ }
+}
+
+void Wiz::pgTransparentForewordMixColorsPixelCopy(WizRawPixel *dstPtr, const WizRawPixel *srcPtr, int size, WizRawPixel transparentColor, const byte *lookupTable) {
+ if (!_uses16BitColor) {
+ while (size-- > 0) {
+ WizRawPixel srcColor = *srcPtr++;
+
+ if (transparentColor != srcColor) {
+ WizRawPixel resultColor = *(lookupTable + (srcColor * 256) + *dstPtr);
+
+ if (transparentColor != resultColor) {
+ *dstPtr++ = resultColor;
+ } else {
+ ++dstPtr;
+ }
+ } else {
+ ++dstPtr;
+ }
+ }
+ } else {
+ while (size-- > 0) {
+ WizRawPixel srcColor = *srcPtr++;
+
+ if (transparentColor != srcColor) {
+ WizRawPixel dstColor = *dstPtr;
+
+ *dstPtr++ = WIZRAWPIXEL_50_50_MIX(
+ WIZRAWPIXEL_50_50_PREMIX_COLOR(srcColor),
+ WIZRAWPIXEL_50_50_PREMIX_COLOR(dstColor));
+ } else {
+ ++dstPtr;
+ }
+ }
+ }
+}
+
+void Wiz::pgTransparentBackwardsMixColorsPixelCopy(WizRawPixel *dstPtr, const WizRawPixel *srcPtr, int size, WizRawPixel transparentColor, const byte *lookupTable) {
+ if (!_uses16BitColor) {
+ while (size-- > 0) {
+ WizRawPixel srcColor = *srcPtr++;
+
+ if (transparentColor != srcColor) {
+ WizRawPixel resultColor = *(lookupTable + (srcColor * 256) + *dstPtr);
+
+ if (transparentColor != resultColor) {
+ *dstPtr-- = resultColor;
+ } else {
+ --dstPtr;
+ }
+ } else {
+ --dstPtr;
+ }
+ }
+ } else {
+ while (size-- > 0) {
+ WizRawPixel srcColor = *srcPtr++;
+
+ if (transparentColor != srcColor) {
+ WizRawPixel dstColor = *dstPtr;
+
+ *dstPtr-- = WIZRAWPIXEL_50_50_MIX(
+ WIZRAWPIXEL_50_50_PREMIX_COLOR(srcColor),
+ WIZRAWPIXEL_50_50_PREMIX_COLOR(dstColor));
+ } else {
+ --dstPtr;
+ }
+ }
+ }
+}
+
+static void pgBlitForwardSrcArbitraryDstPixelTransfer(Wiz *wiz, WizRawPixel *dstPtr, int dstStep, const WizRawPixel *srcPtr, int count, const void *userParam, const void *userParam2) {
+ for (int i = 0; i < count; i++) {
+ *dstPtr = *srcPtr++;
+ dstPtr += dstStep;
+ }
+}
+
+static void pgBlitForwardSrcArbitraryDstTransparentPixelTransfer(Wiz *wiz, WizRawPixel *dstPtr, int dstStep, const WizRawPixel *srcPtr, int count, const void *userParam, const void *userParam2) {
+ WizRawPixel transparentColor, color;
+ transparentColor = *((const WizRawPixel *)userParam);
+
+ for (int i = 0; i < count; i++) {
+ color = *srcPtr++;
+
+ if (transparentColor != color) {
+ *dstPtr = color;
+ }
+
+ dstPtr += dstStep;
+ }
+}
+
+void Wiz::pgBlit90DegreeRotate(WizSimpleBitmap *dstBitmap, int x, int y, const WizSimpleBitmap *srcBitmap, const Common::Rect *optionalSrcRect, const Common::Rect *optionalClipRect, bool hFlip, bool vFlip) {
+ pgBlit90DegreeRotateCore(
+ dstBitmap, x, y, srcBitmap, optionalSrcRect, optionalClipRect,
+ hFlip, vFlip, nullptr, nullptr, pgBlitForwardSrcArbitraryDstPixelTransfer);
+}
+
+void Wiz::pgBlit90DegreeRotateTransparent(WizSimpleBitmap *dstBitmap, int x, int y, const WizSimpleBitmap *srcBitmap, const Common::Rect *optionalSrcRect, const Common::Rect *optionalClipRect, bool hFlip, bool vFlip, WizRawPixel transparentColor) {
+ pgBlit90DegreeRotateCore(
+ dstBitmap, x, y, srcBitmap, optionalSrcRect, optionalClipRect,
+ hFlip, vFlip, &transparentColor, nullptr, pgBlitForwardSrcArbitraryDstTransparentPixelTransfer);
+}
+
+void Wiz::pgBlit90DegreeRotateCore(WizSimpleBitmap *dstBitmap, int x, int y, const WizSimpleBitmap *srcBitmap, const Common::Rect *optionalSrcRect,
+ const Common::Rect *optionalClipRect, bool hFlip, bool vFlip, const void *userParam, const void *userParam2,
+ void(*srcTransferFP)(Wiz *wiz, WizRawPixel *dstPtr, int dstStep, const WizRawPixel *srcPtr, int count, const void *userParam, const void *userParam2)) {
+
+ Common::Rect dstRect, srcRect, clipRect, clippedDstRect, clippedSrcRect;
+ int dstOffset, dstStep, wx, w, h, srcOffset, dstX, dstY;
+ const WizRawPixel *srcPtr;
+ WizRawPixel *dstWorkPtr;
+ WizRawPixel *dstPtr;
+
+ // Do as much pre-clipping as possible
+ makeSizedRect(&clipRect, dstBitmap->bitmapWidth, dstBitmap->bitmapHeight);
+
+ if (optionalClipRect) {
+ if (!findRectOverlap(&clipRect, optionalClipRect)) {
+ return;
+ }
+ }
+
+ // Clip the source rect against the actual src bitmap limits
+ makeSizedRect(&srcRect, srcBitmap->bitmapWidth, srcBitmap->bitmapHeight);
+
+ if (optionalSrcRect) {
+ if (!findRectOverlap(&srcRect, optionalSrcRect)) {
+ return;
+ }
+ }
+
+ // Make the "dest" rect then clip it against the clip rect
+ makeSizedRectAt(&dstRect, x, y, getRectHeight(&srcRect), getRectWidth(&srcRect));
+
+ clippedDstRect = dstRect;
+
+ if (!findRectOverlap(&clippedDstRect, &clipRect)) {
+ return;
+ }
+
+ // Make the clipped src rect adjusted for the 90 degree rotation.
+ clippedSrcRect.left = srcRect.left + (clippedDstRect.top - dstRect.top);
+ clippedSrcRect.top = srcRect.top + (dstRect.right - clippedDstRect.right);
+ clippedSrcRect.right = srcRect.right - (dstRect.bottom - clippedDstRect.bottom);
+ clippedSrcRect.bottom = srcRect.bottom - (clippedDstRect.left - dstRect.left);
+
+ // Perform any flipping of the coords and setup the step variables
+ if (hFlip) {
+ horzFlipAlignWithRect(&clippedSrcRect, &srcRect);
+ dstY = clippedDstRect.bottom;
+ dstStep = -dstBitmap->bitmapWidth;
+ } else {
+ dstY = clippedDstRect.top;
+ dstStep = dstBitmap->bitmapWidth;
+ }
+
+ if (vFlip) {
+ vertFlipAlignWithRect(&clippedSrcRect, &srcRect);
+ dstX = clippedDstRect.left;
+ dstOffset = 1;
+ } else {
+ dstX = clippedDstRect.right;
+ dstOffset = -1;
+ }
+
+ // Finally get down to business and do the blit!
+ dstPtr = dstBitmap->bufferPtr + dstX + (dstY * dstBitmap->bitmapWidth);
+ srcPtr = srcBitmap->bufferPtr + clippedSrcRect.left + (clippedSrcRect.top * srcBitmap->bitmapWidth);
+
+ w = getRectWidth(&clippedSrcRect);
+ h = getRectHeight(&clippedSrcRect);
+
+ // Transfer the src line to the dest line using the passed transfer prim.
+ srcOffset = srcBitmap->bitmapWidth;
+
+ while (--h >= 0) {
+ (*srcTransferFP)(this, dstPtr, dstStep, srcPtr, w, userParam, userParam2);
+ dstPtr += dstOffset;
+ srcPtr += srcOffset;
+ }
+}
+
bool Wiz::findRectOverlap(Common::Rect *destRectPtr, const Common::Rect *sourceRectPtr) {
// Make sure only points inside the viewPort are being set...
if ((destRectPtr->left > sourceRectPtr->right) || (destRectPtr->top > sourceRectPtr->bottom) ||
@@ -526,6 +1416,32 @@ void Wiz::combineRects(Common::Rect *destRect, Common::Rect *ra, Common::Rect *r
destRect->bottom = MAX<int16>(ra->bottom, rb->bottom);
}
+void Wiz::clipRectCoords(Common::Rect *sourceRectPtr, Common::Rect *destRectPtr, Common::Rect *clipRectPtr) {
+ int16 value = destRectPtr->left - clipRectPtr->left;
+ if (value < 0) {
+ sourceRectPtr->left -= value;
+ destRectPtr->left -= value;
+ }
+
+ value = destRectPtr->right - clipRectPtr->right;
+ if (value > 0) {
+ sourceRectPtr->right -= value;
+ destRectPtr->right -= value;
+ }
+
+ value = destRectPtr->top - clipRectPtr->top;
+ if (value < 0) {
+ sourceRectPtr->top -= value;
+ destRectPtr->top -= value;
+ }
+
+ value = destRectPtr->bottom - clipRectPtr->bottom;
+ if (value > 0) {
+ sourceRectPtr->bottom -= value;
+ destRectPtr->bottom -= value;
+ }
+}
+
void Wiz::floodInitFloodState(WizFloodState *statePtr, WizSimpleBitmap *bitmapPtr, int colorToWrite, const Common::Rect *optionalClippingRect) {
statePtr->colorToWrite = colorToWrite;
statePtr->bitmapPtr = bitmapPtr;
@@ -709,14 +1625,85 @@ bool Wiz::floodSimpleFill(WizSimpleBitmap *bitmapPtr, int x, int y, int colorToW
return true;
}
+int Wiz::getRectWidth(Common::Rect *rectPtr) {
+ return abs(rectPtr->width()) + 1;
+}
+
+int Wiz::getRectHeight(Common::Rect *rectPtr) {
+ return abs(rectPtr->height()) + 1;
+}
+
+void Wiz::moveRect(Common::Rect *rectPtr, int dx, int dy) {
+ rectPtr->left += dx;
+ rectPtr->right += dx;
+ rectPtr->top += dy;
+ rectPtr->bottom += dy;
+}
+
+void Wiz::horzFlipAlignWithRect(Common::Rect *rectToAlign, const Common::Rect *baseRect) {
+ int dx = (baseRect->right - rectToAlign->right) - (rectToAlign->left - baseRect->left);
+ moveRect(rectToAlign, dx, 0);
+}
+
+void Wiz::vertFlipAlignWithRect(Common::Rect *rectToAlign, const Common::Rect *baseRect) {
+ int dy = (baseRect->bottom - rectToAlign->bottom) - (rectToAlign->top - baseRect->top);
+ moveRect(rectToAlign, 0, dy);
+}
+
int Wiz::getRawPixel(int color) {
+ return color & WIZRAWPIXEL_MASK;
+}
+
+void Wiz::memset8BppConversion(void *dstPtr, int value, size_t count, const WizRawPixel *conversionTable) {
if (_uses16BitColor) {
- return color & 0xFFFF;
+ rawPixelMemset(dstPtr, (int)convert8BppToRawPixel((WizRawPixel)value, conversionTable), count);
} else {
- return color & 0xFF;
+ memset(dstPtr, value, count);
}
}
+void Wiz::memcpy8BppConversion(void *dstPtr, const void *srcPtr, size_t count, const WizRawPixel *conversionTable) {
+ if (_uses16BitColor) {
+ WizRawPixel *dstWritePtr = (WizRawPixel *)(dstPtr);
+ const byte *srcReadPtr = (const byte *)(srcPtr);
+ int counter = count;
+ while (0 <= --counter) {
+ *dstWritePtr++ = convert8BppToRawPixel((WizRawPixel)(*srcReadPtr++), conversionTable);
+ }
+ } else {
+ memcpy(dstPtr, srcPtr, count);
+ }
+}
+
+void Wiz::rawPixelMemset(void *dstPtr, int value, size_t count) {
+ if (_uses16BitColor) {
+ uint16 *dst16Bit = (uint16 *)dstPtr;
+ for (int i = 0; i < count; i++)
+ WRITE_LE_UINT16(&dst16Bit[i], value);
+ } else {
+ uint8 *dst8Bit = (uint8 *)dstPtr;
+ memset(dst8Bit, value, count);
+ }
+}
+
+WizRawPixel Wiz::convert8BppToRawPixel(WizRawPixel value, const WizRawPixel *conversionTable) {
+ if (_uses16BitColor) {
+ return *(conversionTable + value);
+ } else {
+ return value;
+ }
+}
+
+void Wiz::rawPixelExtractComponents(WizRawPixel aPixel, int &r, int &g, int &b) {
+ r = (aPixel & WIZRAWPIXEL_R_MASK) >> WIZRAWPIXEL_R_SHIFT;
+ g = (aPixel & WIZRAWPIXEL_G_MASK) >> WIZRAWPIXEL_G_SHIFT;
+ b = (aPixel & WIZRAWPIXEL_B_MASK) >> WIZRAWPIXEL_B_SHIFT;
+}
+
+void Wiz::rawPixelPackComponents(WizRawPixel &aPixel, int r, int g, int b) {
+ aPixel = (r << WIZRAWPIXEL_R_SHIFT) | (g << WIZRAWPIXEL_G_SHIFT) | (b << WIZRAWPIXEL_B_SHIFT);
+}
+
} // End of namespace Scumm
#endif // ENABLE_HE
diff --git a/engines/scumm/he/polygon_he.cpp b/engines/scumm/he/polygon_he.cpp
new file mode 100644
index 00000000000..aa01a768397
--- /dev/null
+++ b/engines/scumm/he/polygon_he.cpp
@@ -0,0 +1,249 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifdef ENABLE_HE
+
+#include "common/math.h"
+#include "common/system.h"
+#include "scumm/he/intern_he.h"
+#include "scumm/he/wiz_he.h"
+
+namespace Scumm {
+
+void Wiz::polygonClear() {
+ for (int i = 0; i < ARRAYSIZE(_polygons); i++) {
+ if (_polygons[i].flag == 1)
+ _polygons[i].reset();
+ }
+}
+
+void Wiz::polygonLoad(const uint8 *polData) {
+ int slots = READ_LE_UINT32(polData);
+ polData += 4;
+
+ bool flag = 1;
+ int id, points, vert1x, vert1y, vert2x, vert2y, vert3x, vert3y, vert4x, vert4y;
+ while (slots--) {
+ id = READ_LE_UINT32(polData);
+ points = READ_LE_UINT32(polData + 4);
+ if (points != 4)
+ error("Illegal polygon with %d points", points);
+ vert1x = READ_LE_UINT32(polData + 8);
+ vert1y = READ_LE_UINT32(polData + 12);
+ vert2x = READ_LE_UINT32(polData + 16);
+ vert2y = READ_LE_UINT32(polData + 20);
+ vert3x = READ_LE_UINT32(polData + 24);
+ vert3y = READ_LE_UINT32(polData + 28);
+ vert4x = READ_LE_UINT32(polData + 32);
+ vert4y = READ_LE_UINT32(polData + 36);
+
+ polData += 40;
+ polygonStore(id, flag, vert1x, vert1y, vert2x, vert2y, vert3x, vert3y, vert4x, vert4y);
+ }
+}
+
+void Wiz::polygonStore(int id, bool localFlag, int vert1x, int vert1y, int vert2x, int vert2y, int vert3x, int vert3y, int vert4x, int vert4y) {
+ for (int i = 0; i < ARRAYSIZE(_polygons); ++i) {
+ if (_polygons[i].id == 0) {
+ _polygons[i].points[0].x = vert1x;
+ _polygons[i].points[0].y = vert1y;
+ _polygons[i].points[1].x = vert2x;
+ _polygons[i].points[1].y = vert2y;
+ _polygons[i].points[2].x = vert3x;
+ _polygons[i].points[2].y = vert3y;
+ _polygons[i].points[3].x = vert4x;
+ _polygons[i].points[3].y = vert4y;
+ _polygons[i].points[4].x = vert1x;
+ _polygons[i].points[4].y = vert1y;
+ _polygons[i].id = id;
+ _polygons[i].numPoints = 5;
+ _polygons[i].flag = localFlag;
+
+ polyBuildBoundingRect(_polygons[i].points, _polygons[i].numPoints, _polygons[i].boundingRect);
+
+ return;
+ }
+ }
+
+ error("Wiz::polygonStore: out of polygon slot, max = %d", ARRAYSIZE(_polygons));
+}
+
+void Wiz::polyRotatePoints(Common::Point *pts, int num, int angle) {
+ double alpha = angle * M_PI / 180.;
+ double cos_alpha = cos(alpha);
+ double sin_alpha = sin(alpha);
+
+ for (int i = 0; i < num; ++i) {
+ int16 x = pts[i].x;
+ int16 y = pts[i].y;
+ pts[i].x = (int16)(((double)x * cos_alpha) - ((double)y * sin_alpha));
+ pts[i].y = (int16)(((double)y * cos_alpha) + ((double)x * sin_alpha));
+ }
+}
+
+void Wiz::polygonTransform(int resNum, int state, int po_x, int po_y, int angle, int scale, Common::Point *pts) {
+ int32 w, h;
+
+ getWizImageDim(resNum, state, w, h);
+
+ // set the transformation origin to the center of the image
+ if (_vm->_game.heversion >= 99) {
+ pts[0].x = pts[3].x = -(w / 2);
+ pts[1].x = pts[2].x = w / 2 - 1;
+ pts[0].y = pts[1].y = -(h / 2);
+ pts[2].y = pts[3].y = h / 2 - 1;
+ } else {
+ pts[1].x = pts[2].x = w / 2 - 1;
+ pts[0].x = pts[0].y = pts[1].y = pts[3].x = -(w / 2);
+ pts[2].y = pts[3].y = h / 2 - 1;
+ }
+
+ // scale
+ if (scale != 0 && scale != 256) {
+ for (int i = 0; i < 4; ++i) {
+ pts[i].x = pts[i].x * scale / 256;
+ pts[i].y = pts[i].y * scale / 256;
+ }
+ }
+
+ // rotate
+ if (angle != 0)
+ polyRotatePoints(pts, 4, angle);
+
+ // translate
+ for (int i = 0; i < 4; ++i) {
+ pts[i].x += po_x;
+ pts[i].y += po_y;
+ }
+}
+
+void Wiz::polyMovePolygonPoints(Common::Point *listOfPoints, int numverts, int deltaX, int deltaY) {
+ for (int i = 0; i < numverts; i++) {
+ listOfPoints->x += deltaX;
+ listOfPoints->y += deltaY;
+ listOfPoints++;
+ }
+}
+
+void Wiz::polyBuildBoundingRect(Common::Point *points, int numVerts, Common::Rect &rect) {
+ rect.left = 10000;
+ rect.top = 10000;
+ rect.right = -10000;
+ rect.bottom = -10000;
+
+ // compute bounding box
+ for (int j = 0; j < numVerts; j++) {
+ if (points[j].x < rect.left) rect.left = points[j].x;
+ if (points[j].y < rect.top) rect.top = points[j].y;
+ if (points[j].x > rect.right) rect.right = points[j].x;
+ if (points[j].y > rect.bottom) rect.bottom = points[j].y;
+ }
+}
+
+void Wiz::polygonErase(int fromId, int toId) {
+ for (int i = 0; i < ARRAYSIZE(_polygons); i++) {
+ if (_polygons[i].id >= fromId && _polygons[i].id <= toId)
+ _polygons[i].reset();
+ }
+}
+
+int Wiz::polygonTestForObjectHit(int id, int x, int y) {
+ for (int i = 0; i < ARRAYSIZE(_polygons); i++) {
+ if ((id == 0 || _polygons[i].id == id) && _polygons[i].boundingRect.contains(x, y)) {
+ if (polyIsPointInsidePoly(_polygons[i], x, y)) {
+ return _polygons[i].id;
+ }
+ }
+ }
+
+ return 0;
+}
+
+bool Wiz::polygonDefined(int id) {
+ for (int i = 0; i < ARRAYSIZE(_polygons); i++)
+ if (_polygons[i].id == id)
+ return true;
+ return false;
+}
+
+bool Wiz::polyIsPointInsidePoly(const WizPolygon &pol, int x, int y) {
+ int pi = pol.numPoints - 1;
+ bool diry = (y < pol.points[pi].y);
+ bool curdir;
+ bool r = false;
+
+ for (int i = 0; i < pol.numPoints; i++) {
+ curdir = (y < pol.points[i].y);
+
+ if (curdir != diry) {
+ if (((pol.points[pi].y - pol.points[i].y) * (pol.points[i].x - x) <
+ (pol.points[pi].x - pol.points[i].x) * (pol.points[i].y - y)) == diry)
+ r = !r;
+ }
+
+ pi = i;
+ diry = curdir;
+ }
+
+ if (_vm->_game.heversion >= 80) {
+ int a, b;
+ pi = pol.numPoints - 1;
+ if (r == 0) {
+ for (int i = 0; i < pol.numPoints; i++) {
+ if (pol.points[i].y == y && pol.points[i].y == pol.points[pi].y) {
+
+ a = pol.points[i].x;
+ b = pol.points[pi].x;
+
+ if (pol.points[i].x >= pol.points[pi].x)
+ a = pol.points[pi].x;
+
+ if (pol.points[i].x > pol.points[pi].x)
+ b = pol.points[i].x;
+
+ if (x >= a && x <= b)
+ return 1;
+
+ } else if (pol.points[i].x == x && pol.points[i].x == pol.points[pi].x) {
+
+ a = pol.points[i].y;
+ b = pol.points[i].y;
+
+ if (pol.points[i].y >= pol.points[pi].y)
+ a = pol.points[pi].y;
+
+ if (pol.points[i].y <= pol.points[pi].y)
+ b = pol.points[pi].y;
+
+ if (y >= a && y <= b)
+ return 1;
+ }
+ pi = i;
+ }
+ }
+ }
+
+ return r;
+}
+
+} // End of namespace Scumm
+
+#endif // ENABLE_HE
diff --git a/engines/scumm/he/script_v100he.cpp b/engines/scumm/he/script_v100he.cpp
index d607528a7ce..d96c7ca65b7 100644
--- a/engines/scumm/he/script_v100he.cpp
+++ b/engines/scumm/he/script_v100he.cpp
@@ -1317,7 +1317,7 @@ void ScummEngine_v100he::o100_wizImageOps() {
break;
case SO_SET_POLYGON: // 68
_wizImageCommand.actionFlags |= kWAFFlags | kWAFSpot | kWAFPolygon;
- _wizImageCommand.flags |= kWRFIsPolygon;
+ _wizImageCommand.flags |= kWRFPolygon;
_wizImageCommand.polygon = _wizImageCommand.yPos = _wizImageCommand.xPos = pop();
break;
case SO_SHADOW: // 70
diff --git a/engines/scumm/he/script_v71he.cpp b/engines/scumm/he/script_v71he.cpp
index a92d24eb0f1..2c57a61b0bf 100644
--- a/engines/scumm/he/script_v71he.cpp
+++ b/engines/scumm/he/script_v71he.cpp
@@ -224,15 +224,15 @@ void ScummEngine_v71he::o71_kernelSetFunctions() {
a->_clipOverride.bottom = args[2];
break;
case 42:
- _wiz->_rectOverrideEnabled = true;
- _wiz->_rectOverride.left = args[1];
- _wiz->_rectOverride.top = args[2];
- _wiz->_rectOverride.right = args[3];
- _wiz->_rectOverride.bottom = args[4];
- adjustRect(_wiz->_rectOverride);
+ _wiz->_lUseWizClipRect = true;
+ _wiz->_lWizClipRect.left = args[1];
+ _wiz->_lWizClipRect.top = args[2];
+ _wiz->_lWizClipRect.right = args[3];
+ _wiz->_lWizClipRect.bottom = args[4];
+ adjustRect(_wiz->_lWizClipRect);
break;
case 43:
- _wiz->_rectOverrideEnabled = false;
+ _wiz->_lUseWizClipRect = false;
break;
default:
error("o71_kernelSetFunctions: default case %d (param count %d)", args[0], num);
@@ -444,7 +444,7 @@ void ScummEngine_v71he::o71_polygonOps() {
void ScummEngine_v71he::o71_polygonHit() {
int y = pop();
int x = pop();
- push(_wiz->polygonHit(0, x, y));
+ push(_wiz->polygonTestForObjectHit(0, x, y));
}
} // End of namespace Scumm
diff --git a/engines/scumm/he/script_v72he.cpp b/engines/scumm/he/script_v72he.cpp
index fa454912795..f83208cb8b8 100644
--- a/engines/scumm/he/script_v72he.cpp
+++ b/engines/scumm/he/script_v72he.cpp
@@ -418,7 +418,7 @@ int ScummEngine_v72he::findObject(int x, int y, int num, int *args) {
// Check polygon bounds
if (_wiz->polygonDefined(_objs[i].obj_nr)) {
- if (_wiz->polygonHit(_objs[i].obj_nr, x, y))
+ if (_wiz->polygonTestForObjectHit(_objs[i].obj_nr, x, y))
result = _objs[i].obj_nr;
else if (VAR_POLYGONS_ONLY != 0xFF && VAR(VAR_POLYGONS_ONLY))
continue;
diff --git a/engines/scumm/he/script_v80he.cpp b/engines/scumm/he/script_v80he.cpp
index a6cf23e13ae..d57deb20e75 100644
--- a/engines/scumm/he/script_v80he.cpp
+++ b/engines/scumm/he/script_v80he.cpp
@@ -331,7 +331,7 @@ void ScummEngine_v80he::o80_drawWizPolygon() {
wi.x = wi.y = pop();
wi.image = pop();
wi.state = 0;
- wi.flags = kWRFIsPolygon;
+ wi.flags = kWRFPolygon;
_wiz->simpleDrawAWiz(wi.image, wi.state, wi.x, wi.y, wi.flags);
}
diff --git a/engines/scumm/he/script_v90he.cpp b/engines/scumm/he/script_v90he.cpp
index deca931a323..2202eb52455 100644
--- a/engines/scumm/he/script_v90he.cpp
+++ b/engines/scumm/he/script_v90he.cpp
@@ -325,7 +325,7 @@ void ScummEngine_v90he::o90_wizImageOps() {
break;
case SO_SET_POLYGON: // 246
_wizImageCommand.actionFlags |= kWAFFlags | kWAFSpot | kWAFPolygon;
- _wizImageCommand.flags |= kWRFIsPolygon;
+ _wizImageCommand.flags |= kWRFPolygon;
_wizImageCommand.polygon = _wizImageCommand.yPos = _wizImageCommand.xPos = pop();
break;
case SO_END: // 255
@@ -1673,13 +1673,13 @@ void ScummEngine_v90he::o90_getPolygonOverlap() {
} else {
WizPolygon wp;
wp.reset();
- wp.numVerts = n1;
- assert(n1 < ARRAYSIZE(wp.vert));
+ wp.numPoints = n1;
+ assert(n1 < ARRAYSIZE(wp.points));
for (int i = 0; i < n1; ++i) {
- wp.vert[i].x = args1[i * 2 + 0];
- wp.vert[i].y = args1[i * 2 + 1];
+ wp.points[i].x = args1[i * 2 + 0];
+ wp.points[i].y = args1[i * 2 + 1];
}
- push(_wiz->polygonContains(wp, args2[0], args2[1]) ? 1 : 0);
+ push(_wiz->polyIsPointInsidePoly(wp, args2[0], args2[1]) ? 1 : 0);
}
}
break;
@@ -2396,15 +2396,15 @@ void ScummEngine_v90he::o90_kernelSetFunctions() {
// Used in readdemo
break;
case 42:
- _wiz->_rectOverrideEnabled = true;
- _wiz->_rectOverride.left = args[1];
- _wiz->_rectOverride.top = args[2];
- _wiz->_rectOverride.right = args[3];
- _wiz->_rectOverride.bottom = args[4];
- adjustRect(_wiz->_rectOverride);
+ _wiz->_lUseWizClipRect = true;
+ _wiz->_lWizClipRect.left = args[1];
+ _wiz->_lWizClipRect.top = args[2];
+ _wiz->_lWizClipRect.right = args[3];
+ _wiz->_lWizClipRect.bottom = args[4];
+ adjustRect(_wiz->_lWizClipRect);
break;
case 43:
- _wiz->_rectOverrideEnabled = false;
+ _wiz->_lUseWizClipRect = false;
break;
case 714:
setResourceOffHeap(args[1], args[2], args[3]);
diff --git a/engines/scumm/he/sprite_he.cpp b/engines/scumm/he/sprite_he.cpp
index 2d270f6fa53..53de0160168 100644
--- a/engines/scumm/he/sprite_he.cpp
+++ b/engines/scumm/he/sprite_he.cpp
@@ -85,7 +85,7 @@ void Sprite::getSpriteBounds(int spriteId, bool checkGroup, Common::Rect &bound)
if (spi->flags & (kSFScaleSpecified | kSFAngleSpecified)) {
Common::Point pts[4];
_vm->_wiz->polygonTransform(spi->image, spi->state, x1, y1, angle, scale, pts);
- _vm->_wiz->polygonCalcBoundBox(pts, 4, bound);
+ _vm->_wiz->polyBuildBoundingRect(pts, 4, bound);
} else {
bound.left = x1;
bound.top = y1;
@@ -194,7 +194,7 @@ int Sprite::findSpriteWithClassOf(int x_pos, int y_pos, int spriteGroupId, int t
}
if (spi->flags & kSFAngleSpecified && angle) {
angle = (360 - angle) % 360;
- _vm->_wiz->polygonRotatePoints(pos, 1, angle);
+ _vm->_wiz->polyRotatePoints(pos, 1, angle);
}
_vm->_wiz->getWizImageDim(image, imageState, w, h);
@@ -1313,7 +1313,7 @@ void Sprite::renderSprites(bool arg) {
if (spi->flags & (kSFScaleSpecified | kSFAngleSpecified)) {
Common::Point pts[4];
_vm->_wiz->polygonTransform(image, imageState, wiz.xPos, wiz.yPos, angle, scale, pts);
- _vm->_wiz->polygonCalcBoundBox(pts, 4, spi->lastRect);
+ _vm->_wiz->polyBuildBoundingRect(pts, 4, spi->lastRect);
} else {
bboxPtr->left = wiz.xPos;
bboxPtr->top = wiz.yPos;
@@ -1330,9 +1330,9 @@ void Sprite::renderSprites(bool arg) {
wiz.flags = kWRFForeground;
wiz.zPos = 0;
if (spr_flags & kSFHFlip)
- wiz.flags |= kWRFFlipX;
+ wiz.flags |= kWRFHFlip;
if (spr_flags & kSFVFlip)
- wiz.flags |= kWRFFlipY;
+ wiz.flags |= kWRFVFlip;
if (spr_flags & kSFBackgroundRender) {
wiz.flags &= ~kWRFForeground;
wiz.flags |= kWRFBackground;
diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp
index c4513d12006..92e694b3a3e 100644
--- a/engines/scumm/he/wiz_he.cpp
+++ b/engines/scumm/he/wiz_he.cpp
@@ -39,7 +39,7 @@ Wiz::Wiz(ScummEngine_v71he *vm) : _vm(vm) {
memset(&_wizBuffer, 0, sizeof(_wizBuffer));
memset(&_polygons, 0, sizeof(_polygons));
_cursorImage = false;
- _rectOverrideEnabled = false;
+ _lUseWizClipRect = false;
_uses16BitColor = (_vm->_game.features & GF_16BIT_COLOR);
}
@@ -47,213 +47,6 @@ void Wiz::clearWizBuffer() {
_wizBufferIndex = 0;
}
-void Wiz::polygonClear() {
- for (int i = 0; i < ARRAYSIZE(_polygons); i++) {
- if (_polygons[i].flag == 1)
- _polygons[i].reset();
- }
-}
-
-void Wiz::polygonLoad(const uint8 *polData) {
- int slots = READ_LE_UINT32(polData);
- polData += 4;
-
- bool flag = 1;
- int id, points, vert1x, vert1y, vert2x, vert2y, vert3x, vert3y, vert4x, vert4y;
- while (slots--) {
- id = READ_LE_UINT32(polData);
- points = READ_LE_UINT32(polData + 4);
- if (points != 4)
- error("Illegal polygon with %d points", points);
- vert1x = READ_LE_UINT32(polData + 8);
- vert1y = READ_LE_UINT32(polData + 12);
- vert2x = READ_LE_UINT32(polData + 16);
- vert2y = READ_LE_UINT32(polData + 20);
- vert3x = READ_LE_UINT32(polData + 24);
- vert3y = READ_LE_UINT32(polData + 28);
- vert4x = READ_LE_UINT32(polData + 32);
- vert4y = READ_LE_UINT32(polData + 36);
-
- polData += 40;
- polygonStore(id, flag, vert1x, vert1y, vert2x, vert2y, vert3x, vert3y, vert4x, vert4y);
- }
-}
-
-void Wiz::polygonStore(int id, bool flag, int vert1x, int vert1y, int vert2x, int vert2y, int vert3x, int vert3y, int vert4x, int vert4y) {
- WizPolygon *wp = nullptr;
- for (int i = 0; i < ARRAYSIZE(_polygons); ++i) {
- if (_polygons[i].id == 0) {
- wp = &_polygons[i];
- break;
- }
- }
- if (!wp) {
- error("Wiz::polygonStore: out of polygon slot, max = %d", ARRAYSIZE(_polygons));
- }
-
- wp->vert[0].x = vert1x;
- wp->vert[0].y = vert1y;
- wp->vert[1].x = vert2x;
- wp->vert[1].y = vert2y;
- wp->vert[2].x = vert3x;
- wp->vert[2].y = vert3y;
- wp->vert[3].x = vert4x;
- wp->vert[3].y = vert4y;
- wp->vert[4].x = vert1x;
- wp->vert[4].y = vert1y;
- wp->id = id;
- wp->numVerts = 5;
- wp->flag = flag;
-
- polygonCalcBoundBox(wp->vert, wp->numVerts, wp->bound);
-}
-
-void Wiz::polygonRotatePoints(Common::Point *pts, int num, int angle) {
- double alpha = angle * M_PI / 180.;
- double cos_alpha = cos(alpha);
- double sin_alpha = sin(alpha);
-
- for (int i = 0; i < num; ++i) {
- int16 x = pts[i].x;
- int16 y = pts[i].y;
- pts[i].x = (int16)(x * cos_alpha - y * sin_alpha);
- pts[i].y = (int16)(y * cos_alpha + x * sin_alpha);
- }
-}
-
-void Wiz::polygonTransform(int resNum, int state, int po_x, int po_y, int angle, int scale, Common::Point *pts) {
- int32 w, h;
-
- getWizImageDim(resNum, state, w, h);
-
- // set the transformation origin to the center of the image
- if (_vm->_game.heversion >= 99) {
- pts[0].x = pts[3].x = -(w / 2);
- pts[1].x = pts[2].x = w / 2 - 1;
- pts[0].y = pts[1].y = -(h / 2);
- pts[2].y = pts[3].y = h / 2 - 1;
- } else {
- pts[1].x = pts[2].x = w / 2 - 1;
- pts[0].x = pts[0].y = pts[1].y = pts[3].x = -(w / 2);
- pts[2].y = pts[3].y = h / 2 - 1;
- }
-
- // scale
- if (scale != 0 && scale != 256) {
- for (int i = 0; i < 4; ++i) {
- pts[i].x = pts[i].x * scale / 256;
- pts[i].y = pts[i].y * scale / 256;
- }
- }
-
- // rotate
- if (angle != 0)
- polygonRotatePoints(pts, 4, angle);
-
- // translate
- for (int i = 0; i < 4; ++i) {
- pts[i].x += po_x;
- pts[i].y += po_y;
- }
-}
-
-void Wiz::polygonCalcBoundBox(Common::Point *vert, int numVerts, Common::Rect &bound) {
- bound.left = 10000;
- bound.top = 10000;
- bound.right = -10000;
- bound.bottom = -10000;
-
- // compute bounding box
- for (int j = 0; j < numVerts; j++) {
- Common::Rect r(vert[j].x, vert[j].y, vert[j].x + 1, vert[j].y + 1);
- bound.extend(r);
- }
-}
-
-void Wiz::polygonErase(int fromId, int toId) {
- for (int i = 0; i < ARRAYSIZE(_polygons); i++) {
- if (_polygons[i].id >= fromId && _polygons[i].id <= toId)
- _polygons[i].reset();
- }
-}
-
-int Wiz::polygonHit(int id, int x, int y) {
- for (int i = 0; i < ARRAYSIZE(_polygons); i++) {
- if ((id == 0 || _polygons[i].id == id) && _polygons[i].bound.contains(x, y)) {
- if (polygonContains(_polygons[i], x, y)) {
- return _polygons[i].id;
- }
- }
- }
- return 0;
-}
-
-bool Wiz::polygonDefined(int id) {
- for (int i = 0; i < ARRAYSIZE(_polygons); i++)
- if (_polygons[i].id == id)
- return true;
- return false;
-}
-
-bool Wiz::polygonContains(const WizPolygon &pol, int x, int y) {
- int pi = pol.numVerts - 1;
- bool diry = (y < pol.vert[pi].y);
- bool curdir;
- bool r = false;
-
- for (int i = 0; i < pol.numVerts; i++) {
- curdir = (y < pol.vert[i].y);
-
- if (curdir != diry) {
- if (((pol.vert[pi].y - pol.vert[i].y) * (pol.vert[i].x - x) <
- (pol.vert[pi].x - pol.vert[i].x) * (pol.vert[i].y - y)) == diry)
- r = !r;
- }
-
- pi = i;
- diry = curdir;
- }
-
- // HE80+
- int a, b;
- pi = pol.numVerts - 1;
- if (r == 0) {
- for (int i = 0; i < pol.numVerts; i++) {
- if (pol.vert[i].y == y && pol.vert[i].y == pol.vert[pi].y) {
-
- a = pol.vert[i].x;
- b = pol.vert[pi].x;
-
- if (pol.vert[i].x >= pol.vert[pi].x)
- a = pol.vert[pi].x;
-
- if (pol.vert[i].x > pol.vert[pi].x)
- b = pol.vert[i].x;
-
- if (x >= a && x <= b)
- return 1;
-
- } else if (pol.vert[i].x == x && pol.vert[i].x == pol.vert[pi].x) {
-
- a = pol.vert[i].y;
- b = pol.vert[i].y;
-
- if (pol.vert[i].y >= pol.vert[pi].y)
- a = pol.vert[pi].y;
-
- if (pol.vert[i].y <= pol.vert[pi].y)
- b = pol.vert[pi].y;
-
- if (y >= a && y <= b)
- return 1;
- }
- pi = i;
- }
- }
-
- return r;
-}
-
void Wiz::copyAuxImage(uint8 *dst1, uint8 *dst2, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, uint8 bitDepth) {
assert(bitDepth == 1);
@@ -375,11 +168,11 @@ void Wiz::copy16BitWizImage(uint8 *dst, const uint8 *src, int dstPitch, int dstT
Common::Rect r1, r2;
if (calcClipRects(dstw, dsth, srcx, srcy, srcw, srch, rect, r1, r2)) {
dst += r2.top * dstPitch + r2.left * 2;
- if (flags & kWRFFlipY) {
+ if (flags & kWRFVFlip) {
const int dy = (srcy < 0) ? srcy : (srch - r1.height());
r1.translate(0, dy);
}
- if (flags & kWRFFlipX) {
+ if (flags & kWRFHFlip) {
const int dx = (srcx < 0) ? srcx : (srcw - r1.width());
r1.translate(dx, 0);
}
@@ -396,11 +189,11 @@ void Wiz::copyWizImage(uint8 *dst, const uint8 *src, int dstPitch, int dstType,
Common::Rect r1, r2;
if (calcClipRects(dstw, dsth, srcx, srcy, srcw, srch, rect, r1, r2)) {
dst += r2.top * dstPitch + r2.left * bitDepth;
- if (flags & kWRFFlipY) {
+ if (flags & kWRFVFlip) {
const int dy = (srcy < 0) ? srcy : (srch - r1.height());
r1.translate(0, dy);
}
- if (flags & kWRFFlipX) {
+ if (flags & kWRFHFlip) {
const int dx = (srcx < 0) ? srcx : (srcw - r1.width());
r1.translate(dx, 0);
}
@@ -457,11 +250,11 @@ void Wiz::copyMaskWizImage(uint8 *dst, const uint8 *src, const uint8 *mask, int
return;
}
dst += dstRect.top * dstPitch + dstRect.left * 2;
- if (flags & kWRFFlipY) {
+ if (flags & kWRFVFlip) {
const int dy = (srcy < 0) ? srcy : (srch - srcRect.height());
srcRect.translate(0, dy);
}
- if (flags & kWRFFlipX) {
+ if (flags & kWRFHFlip) {
const int dx = (srcx < 0) ? srcx : (srcw - srcRect.width());
srcRect.translate(dx, 0);
}
@@ -484,7 +277,7 @@ void Wiz::copyMaskWizImage(uint8 *dst, const uint8 *src, const uint8 *mask, int
return;
dstInc = 2;
- if (flags & kWRFFlipX) {
+ if (flags & kWRFHFlip) {
dstPtr += (w - 1) * 2;
dstInc = -2;
}
@@ -632,13 +425,13 @@ void Wiz::copyWizImageWithMask(uint8 *dst, const uint8 *src, int dstPitch, int d
void Wiz::copyRaw16BitWizImage(uint8 *dst, const uint8 *src, int dstPitch, int dstType, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, int transColor) {
Common::Rect r1, r2;
if (calcClipRects(dstw, dsth, srcx, srcy, srcw, srch, rect, r1, r2)) {
- if (flags & kWRFFlipX) {
+ if (flags & kWRFHFlip) {
int l = r1.left;
int r = r1.right;
r1.left = srcw - r;
r1.right = srcw - l;
}
- if (flags & kWRFFlipY) {
+ if (flags & kWRFVFlip) {
int t = r1.top;
int b = r1.bottom;
r1.top = srch - b;
@@ -665,13 +458,13 @@ void Wiz::copyRaw16BitWizImage(uint8 *dst, const uint8 *src, int dstPitch, int d
void Wiz::copyRawWizImage(uint8 *dst, const uint8 *src, int dstPitch, int dstType, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, const uint8 *palPtr, int transColor, uint8 bitDepth) {
Common::Rect r1, r2;
if (calcClipRects(dstw, dsth, srcx, srcy, srcw, srch, rect, r1, r2)) {
- if (flags & kWRFFlipX) {
+ if (flags & kWRFHFlip) {
int l = r1.left;
int r = r1.right;
r1.left = srcw - r;
r1.right = srcw - l;
}
- if (flags & kWRFFlipY) {
+ if (flags & kWRFVFlip) {
int t = r1.top;
int b = r1.bottom;
r1.top = srch - b;
@@ -728,12 +521,12 @@ void Wiz::decompress16BitWizImage(uint8 *dst, int dstPitch, int dstType, const u
if (h <= 0 || w <= 0)
return;
- if (flags & kWRFFlipY) {
+ if (flags & kWRFVFlip) {
dstPtr += (h - 1) * dstPitch;
dstPitch = -dstPitch;
}
dstInc = 2;
- if (flags & kWRFFlipX) {
+ if (flags & kWRFHFlip) {
dstPtr += (w - 1) * 2;
dstInc = -2;
}
@@ -862,12 +655,12 @@ void Wiz::decompressWizImage(uint8 *dst, int dstPitch, int dstType, const uint8
if (h <= 0 || w <= 0)
return;
- if (flags & kWRFFlipY) {
+ if (flags & kWRFVFlip) {
dstPtr += (h - 1) * dstPitch;
dstPitch = -dstPitch;
}
dstInc = bitDepth;
- if (flags & kWRFFlipX) {
+ if (flags & kWRFHFlip) {
dstPtr += (w - 1) * bitDepth;
dstInc = -bitDepth;
}
@@ -1424,12 +1217,7 @@ void Wiz::captureImage(uint8 *src, int srcPitch, int srcw, int srch, int resNum,
void Wiz::simpleDrawAWiz(int image, int state, int x, int y, int flags) {
if (!_vm->_fullRedraw) {
- if (flags & kWRFIsPolygon) {
- drawWizPolygon(image, state, x, flags, 0, 0, 0);
- } else {
- const Common::Rect *r = nullptr;
- drawWizImage(image, state, 0, 0, x, y, 0, 0, 0, r, flags, 0, _vm->getHEPaletteSlot(0), 0);
- }
+ drawAWiz(image, state, x, y, 0, flags, 0, 0, nullptr, 0, nullptr);
} else {
bufferAWiz(image, state, x, y, 0, flags, 0, 0, 0);
}
@@ -1450,6 +1238,321 @@ void Wiz::bufferAWiz(int image, int state, int x, int y, int z, int flags, int o
++_wizBufferIndex;
}
+byte *Wiz::drawAWiz(int image, int state, int x, int y, int z, int flags, int optionalShadowImage, int optionalZBufferImage, Common::Rect *optionalClipRect, int whichPalette, WizSimpleBitmap *optionalBitmapOverride) {
+ return drawAWizEx(image, state, x, y, z, flags,
+ optionalShadowImage, optionalZBufferImage, optionalClipRect,
+ whichPalette, optionalBitmapOverride, nullptr);
+}
+
+byte *Wiz::drawAWizEx(int image, int state, int x, int y, int z, int flags, int optionalShadowImage, int optionalZBufferImage, Common::Rect *optionalClipRect, int whichPalette, WizSimpleBitmap *optionalBitmapOverride, const WizImageCommand *optionalICmdPtr) {
+ const WizRawPixel *colorConversionTable;
+ Common::Rect *clipRectPtr;
+
+ if (whichPalette) {
+ colorConversionTable = (WizRawPixel *)_vm->getHEPaletteSlot(whichPalette);
+ } else {
+ colorConversionTable = nullptr;
+ }
+
+ // Get the "shadow"...
+ if (!optionalShadowImage) {
+ if (_lWizActiveShadow && (flags & kWRFUseShadow)) {
+ optionalShadowImage = _lWizActiveShadow;
+ }
+ }
+
+ if (!(flags & kWRFPolygon)) {
+ // Get the clipping rect if any...
+ if (!optionalClipRect) {
+ if (_lUseWizClipRect && !(flags & (kWRFPrint | kWRFAlloc))) {
+ clipRectPtr = &_lWizClipRect;
+ } else {
+ clipRectPtr = nullptr;
+ }
+ } else {
+ clipRectPtr = optionalClipRect;
+ }
+
+ // Call the primitive renderer.
+ return (byte *)drawAWizPrimEx(image, state, x, y, z,
+ optionalShadowImage, optionalZBufferImage, clipRectPtr,
+ flags, optionalBitmapOverride, colorConversionTable, optionalICmdPtr);
+ } else {
+ WARPWIZ_DrawWiz(
+ image, state, x, flags, _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR),
+ optionalBitmapOverride, colorConversionTable, optionalShadowImage);
+
+ return nullptr;
+ }
+}
+
+void *Wiz::drawAWizPrim(int globNum, int state, int x, int y, int z, int shadowImage, int zbufferImage, const Common::Rect *optionalClipRect, int flags, WizSimpleBitmap *optionalBitmapOverride, const WizRawPixel *optionalColorConversionTable) {
+ return drawAWizPrimEx(globNum, state, x, y, z,
+ shadowImage, zbufferImage, optionalClipRect, flags,
+ optionalBitmapOverride, optionalColorConversionTable, 0);
+}
+
+void *Wiz::drawAWizPrimEx(int globNum, int state, int x, int y, int z, int shadowImage, int zbufferImage, const Common::Rect *optionalClipRect, int flags, WizSimpleBitmap *optionalBitmapOverride, const WizRawPixel *optionalColorConversionTable, const WizImageCommand *optionalICmdPtr) {
+ int dest_w, dest_h, src_w, src_h, src_c, remapID;
+ byte *src_d, *src_p, *pp, *remap_p, *shadow_p;
+ Common::Rect dest_r, clip_r;
+ bool markUpdates;
+ WizRawPixel *dest_p;
+
+ markUpdates = true;
+
+ // Set the optional remap table up to the default if one isn't specified
+ if (!optionalColorConversionTable) {
+ optionalColorConversionTable = (WizRawPixel *)_vm->getHEPaletteSlot(1);
+ }
+
+ // If using a shadow make sure both globs are in ram!!!!
+ if (shadowImage) {
+ shadow_p = (byte *)getColorMixBlockPtrForWiz(shadowImage);
+
+ if (shadow_p) {
+ shadow_p += 8;
+ }
+ } else {
+ shadow_p = nullptr;
+ }
+
+ // If using a z-buffer make sure both globs are in ram!!!!
+ if (zbufferImage) {
+ // uncompressed 16-bit z-buffers only for now
+ byte *pzbHeader = (byte *)getWizStateHeaderPrim(zbufferImage, 0);
+
+ assert(pzbHeader);
+
+ int zbComp = READ_LE_UINT32(pzbHeader + _vm->_resourceHeaderSize);
+
+ if (zbComp != kWCTNone16Bpp) {
+ error("Wiz::drawAWizPrimEx(): 16-bit uncompressed z-buffers are the only currently supported format");
+ }
+ }
+
+ // Get the header for this "state"
+ pp = (byte *)getWizStateHeaderPrim(globNum, state);
+ if (!pp)
+ error("Wiz::drawAWizPrimEx(): %d state %d missing header", globNum, state);
+
+ src_c = READ_LE_UINT32(pp + _vm->_resourceHeaderSize + 0);
+ src_w = READ_LE_UINT32(pp + _vm->_resourceHeaderSize + 4);
+ src_h = READ_LE_UINT32(pp + _vm->_resourceHeaderSize + 8);
+
+ if ((!isUncompressedFormatTypeID(src_c)) && (kWCTTRLE != src_c)) {
+ error("Wiz::drawAWizPrimEx(): %d has invalid compression type %d", globNum, src_c);
+ }
+
+ // Get the data block for this "state"
+ src_d = (byte *)getWizStateDataPrim( globNum, state);
+ if (!src_d)
+ error("Wiz::drawAWizPrimEx(): %d state %d missing data block", globNum, state);
+
+ // Copy the palette from this "state"?
+ if (flags & kWRFUsePalette) {
+ src_p = (byte *)getWizStatePaletteDataPrim(globNum, state);
+ if (!src_p)
+ error("Wiz::drawAWizPrimEx(): %d state %d missing palette block", globNum, state);
+
+ _vm->setPaletteFromPtr(src_p + _vm->_resourceHeaderSize, 256);
+ }
+
+ // Remap this wiz "state"?
+ if (flags & kWRFRemap) {
+ remap_p = (byte *)getWizStateRemapDataPrim(globNum, state);
+ if (!remap_p)
+ error("Wiz::drawAWizPrimEx(): %d state %d is missing a remap palette block", globNum, state);
+
+ remapID = READ_LE_UINT32(remap_p + _vm->_resourceHeaderSize);
+
+ if (remapID != WIZ_MAGIC_REMAP_NUMBER) {
+ if (remapID != _vm->_paletteChangedCounter) {
+ WRITE_LE_UINT32(remap_p + _vm->_resourceHeaderSize, _vm->_paletteChangedCounter);
+
+ src_p = (byte *)getWizStatePaletteDataPrim(globNum, state);
+ if (!src_p)
+ error("Wiz::drawAWizPrimEx(): %d state %d missing palette block", globNum, state);
+
+ _vm->remapHEPalette(src_p, remap_p + 4);
+ }
+ }
+ }
+
+ // Get the dest pointer...
+ if (flags & (kWRFPrint | kWRFAlloc)) {
+ dest_w = src_w;
+ dest_h = src_h;
+ dest_p = (WizRawPixel *)malloc(dest_w * dest_h * sizeof(WizRawPixel));
+
+ if (!dest_p) {
+ warning("Wiz::drawAWizPrimEx(): Not enough memory for image operation (print / other)");
+ return nullptr;
+ } else if (flags & kWRFAlloc) {
+ memset8BppConversion(
+ dest_p,
+ _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR),
+ dest_w * dest_h,
+ optionalColorConversionTable);
+ }
+
+ } else {
+ if (optionalBitmapOverride) {
+ dest_w = optionalBitmapOverride->bitmapWidth;
+ dest_h = optionalBitmapOverride->bitmapHeight;
+ dest_p = optionalBitmapOverride->bufferPtr;
+
+ markUpdates = false;
+ } else {
+ VirtScreen *pvs = &_vm->_virtscr[kMainVirtScreen];
+ dest_w = pvs->w;
+ dest_h = pvs->h;
+
+ if (flags & kWRFForeground) {
+ dest_p = (WizRawPixel *)pvs->getPixels(0, pvs->topline);
+ } else {
+ dest_p = (WizRawPixel *)pvs->getBackPixels(0, pvs->topline);
+ }
+ }
+ }
+
+ // Make the clipping rect equal to the limits of the draw buffer
+ clip_r.left = 0;
+ clip_r.top = 0;
+ clip_r.right = dest_w - 1;
+ clip_r.bottom = dest_h - 1;
+
+ if (optionalClipRect && (!(flags & (kWRFPrint | kWRFAlloc)))) {
+ if (!findRectOverlap(&clip_r, optionalClipRect)) {
+ return nullptr;
+ }
+ }
+
+ // Get down to business and decompress the image...
+ if (zbufferImage) {
+ WizSimpleBitmap sbZBuffer;
+ sbZBuffer.bitmapHeight = 0;
+ sbZBuffer.bitmapWidth = 0;
+ sbZBuffer.bufferPtr = nullptr;
+
+ dwSetSimpleBitmapStructFromImage(zbufferImage, 0, &sbZBuffer);
+
+ // Validate destination for z-buffer
+ if ((dest_w != sbZBuffer.bitmapWidth) ||
+ (dest_h != sbZBuffer.bitmapHeight)) {
+ error("Wiz::drawAWizPrimEx(): destination size must match z-buffer size d:%dx%d z:%dx%d",
+ dest_w, dest_h, sbZBuffer.bitmapWidth, sbZBuffer.bitmapHeight);
+ }
+
+ WizSimpleBitmap sbDst;
+
+ sbDst.bufferPtr = dest_p;
+ sbDst.bitmapWidth = dest_w;
+ sbDst.bitmapHeight = dest_h;
+
+ if (src_c != kWCTTRLE) {
+ pgDrawImageWith16BitZBuffer(&sbDst, &sbZBuffer, src_d + _vm->_resourceHeaderSize, x, y, z, src_w, src_h, &clip_r);
+ }
+ } else if (src_c == kWCTTRLE) {
+ if (flags & kWRFZPlaneOn) {
+ if (_vm->_gdi->_numZBuffer <= 1) {
+ error("Wiz::drawAWizPrimEx(): No zplane %d (limit 0 to %d)", 1, (_vm->_gdi->_numZBuffer - 1));
+ }
+ //_vm->getMaskBuffer(0, 0, 1); TODO
+ //AUX_DrawZplaneFromTRLEImage(TextZplane + WindowXmin + TZPoffset[1], src_d + _vm->_resourceHeaderSize, dest_w, dest_h, x, y, src_w, src_h, &clip_r, WIZ_ZPLANE_OP_IGNORE, WIZ_ZPLANE_OP_SET);
+ } else if (flags & kWRFZPlaneOff) {
+ if (_vm->_gdi->_numZBuffer <= 1) {
+ error("Wiz::drawAWizPrimEx(): No zplane %d (limit 0 to %d)", 1, (_vm->_gdi->_numZBuffer - 1));
+ }
+ //_vm->getMaskBuffer(0, 0, 1); TODO
+ //AUX_DrawZplaneFromTRLEImage(TextZplane + WindowXmin + TZPoffset[1], src_d + _vm->_resourceHeaderSize, dest_w, dest_h, x, y, src_w, src_h, &clip_r, WIZ_ZPLANE_OP_IGNORE, WIZ_ZPLANE_OP_CLEAR);
+ } else {
+ void *dataPtr = nullptr;
+
+ if (shadow_p)
+ dataPtr = shadow_p;
+
+ if (flags & kWRFRemap)
+ dataPtr = remap_p + _vm->_resourceHeaderSize + 4;
+ // TODO
+ //TRLEFLIP_DecompressImage(
+ // dest_p, src_d + _vm->_resourceHeaderSize, dest_w, dest_h,
+ // x, y, src_w, src_h, &clip_r, flags, dataPtr,
+ // optionalColorConversionTable,
+ // optionalICmdPtr);
+ }
+
+ } else {
+ int transColorOverride;
+ void *dataPtr = nullptr;
+
+ if (shadow_p)
+ dataPtr = shadow_p;
+
+ if (flags & kWRFRemap)
+ dataPtr = remap_p + _vm->_resourceHeaderSize + 4;
+
+ if (doesRawWizStateHaveTransparency(globNum, state)) {
+ transColorOverride = _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR);
+ } else {
+ transColorOverride = -1;
+ }
+
+ if (kWCTNone16Bpp != src_c && kWCTNone16BppBigEndian != src_c) {
+ if (kWCTNone == src_c) {
+ pgDraw8BppFormatImage(
+ dest_p, (byte *)(src_d + _vm->_resourceHeaderSize), dest_w, dest_h,
+ x, y, src_w, src_h, &clip_r, flags, dataPtr, transColorOverride,
+ optionalColorConversionTable);
+ } else {
+ error("Wiz::drawAWizPrimEx(): Raw data type mismatch for mode %d vs %d", src_c, kWCTNone16Bpp);
+ }
+
+ } else {
+
+ // Use the native transfer function
+ if (optionalColorConversionTable &&
+ ((WizRawPixel *)_vm->getHEPaletteSlot(1) != optionalColorConversionTable)) {
+ flags |= kWRFRemap;
+ dataPtr = (void *)optionalColorConversionTable;
+ }
+
+ pgDrawRawDataFormatImage(
+ dest_p, (WizRawPixel *)(src_d + _vm->_resourceHeaderSize), dest_w, dest_h,
+ x, y, src_w, src_h, &clip_r, flags, dataPtr, transColorOverride);
+ }
+ }
+
+ // Is this a print operation?
+ if (flags & kWRFPrint) {
+ warning("Wiz::drawAWizPrimEx(): Printing not yet supported");
+
+ if ((flags & kWRFAlloc) == 0) {
+ free(dest_p);
+ dest_p = nullptr;
+ }
+ } else {
+ if (!(flags & kWRFAlloc) && markUpdates) {
+ dest_r.left = x;
+ dest_r.top = y;
+ dest_r.right = x + src_w - 1;
+ dest_r.bottom = y + src_h - 1;
+
+ if (findRectOverlap(&dest_r, &clip_r)) {
+ // If neither forground or background, copy to both
+ if ((flags & kWRFBackground) || ((flags & (kWRFBackground | kWRFForeground)) == 0)) {
+ _vm->backgroundToForegroundBlit(dest_r);
+ } else {
+ ++dest_r.bottom;
+ _vm->markRectAsDirty(kMainVirtScreen, dest_r);
+ }
+ }
+ }
+ }
+
+ return dest_p;
+}
+
uint8 *Wiz::drawWizImage(int resNum, int state, int maskNum, int maskState, int x1, int y1, int zorder, int shadow, int zbuffer, const Common::Rect *clipBox, int flags, int dstResNum, const uint8 *palPtr, uint32 conditionBits) {
debug(7, "drawWizImage(resNum %d, state %d maskNum %d maskState %d x1 %d y1 %d flags 0x%X zorder %d shadow %d zbuffer %d dstResNum %d conditionBits: 0x%x)", resNum, state, maskNum, maskState, x1, y1, flags, zorder, shadow, zbuffer, dstResNum, conditionBits);
uint8 *dataPtr;
@@ -1567,9 +1670,9 @@ uint8 *Wiz::drawWizImage(int resNum, int state, int maskNum, int maskState, int
return 0;
}
- } else if (_rectOverrideEnabled) {
- if (rScreen.intersects(_rectOverride)) {
- rScreen.clip(_rectOverride);
+ } else if (_lUseWizClipRect) {
+ if (rScreen.intersects(_lWizClipRect)) {
+ rScreen.clip(_lWizClipRect);
} else {
if (flags & kWRFAlloc)
free(dst);
@@ -1765,17 +1868,17 @@ void Wiz::copyCompositeWizImage(uint8 *dst, uint8 *wizPtr, uint8 *compositeInfoB
}
uint srcw1 = 0, srch1 = 0;
- if (drawFlags & (kWRFFlipX | kWRFFlipY)) {
+ if (drawFlags & (kWRFHFlip | kWRFVFlip)) {
uint8 *wizh = _vm->findWrappedBlock(MKTAG('W','I','Z','H'), wizPtr, subState, 0);
assert(wizh);
srcw1 = READ_LE_UINT32(wizh + 0x4);
srch1 = READ_LE_UINT32(wizh + 0x8);
}
- if (drawFlags & kWRFFlipX)
+ if (drawFlags & kWRFHFlip)
xPos = (srcw - (xPos + srcw1));
- if (drawFlags & kWRFFlipY)
+ if (drawFlags & kWRFVFlip)
yPos = (srch - (yPos + srch1));
if (layerCmdDataBits & kWCFSubConditionBits) {
@@ -1946,8 +2049,8 @@ void Wiz::processWizImagePolyCaptureCmd(const WizImageCommand *params) {
if (!wp) {
error("Polygon1 %d is not defined", id1);
}
- if (wp->numVerts != 5) {
- error("Invalid point count %d for Polygon1 %d", wp->numVerts, id1);
+ if (wp->numPoints != 5) {
+ error("Invalid point count %d for Polygon1 %d", wp->numPoints, id1);
}
wp = nullptr;
@@ -1960,8 +2063,8 @@ void Wiz::processWizImagePolyCaptureCmd(const WizImageCommand *params) {
if (!wp) {
error("Polygon2 %d is not defined", id2);
}
- if (wp->numVerts != 5) {
- error("Invalid point count %d for Polygon2 %d", wp->numVerts, id2);
+ if (wp->numPoints != 5) {
+ error("Invalid point count %d for Polygon2 %d", wp->numPoints, id2);
}
int32 dstw, dsth, dstpitch;
@@ -1973,8 +2076,8 @@ void Wiz::processWizImagePolyCaptureCmd(const WizImageCommand *params) {
const uint8 *src = drawWizImage(maskNum, maskState, 0, 0, 0, 0, 0, 0, 0, r, kWRFAlloc, 0, 0, 0);
getWizImageDim(maskNum, maskState, srcw, srch);
- dstw = wp->bound.width();
- dsth = wp->bound.height();
+ dstw = wp->boundingRect.width();
+ dsth = wp->boundingRect.height();
dstpitch = dstw * _vm->_bytesPerPixel;
imageBuffer = (uint8 *)malloc(dstw * dsth * _vm->_bytesPerPixel);
assert(imageBuffer);
@@ -1992,9 +2095,9 @@ void Wiz::processWizImagePolyCaptureCmd(const WizImageCommand *params) {
}
Common::Rect bound;
- drawWizPolygonImage(imageBuffer, src, nullptr, dstpitch, kDstMemory, dstw, dsth, srcw, srch, bound, wp->vert, _vm->_bytesPerPixel);
+ drawWizPolygonImage(imageBuffer, src, nullptr, dstpitch, kDstMemory, dstw, dsth, srcw, srch, bound, wp->points, _vm->_bytesPerPixel);
- captureImage(imageBuffer, dstpitch, dstw, dsth, resNum, wp->bound, compType);
+ captureImage(imageBuffer, dstpitch, dstw, dsth, resNum, wp->boundingRect, compType);
free(imageBuffer);
}
@@ -2017,11 +2120,11 @@ void Wiz::drawWizPolygon(int resNum, int state, int id, int flags, int shadow, i
if (!wp) {
error("Polygon %d is not defined", id);
}
- if (wp->numVerts != 5) {
- error("Invalid point count %d for Polygon %d", wp->numVerts, id);
+ if (wp->numPoints != 5) {
+ error("Invalid point count %d for Polygon %d", wp->numPoints, id);
}
- drawWizPolygonTransform(resNum, state, wp->vert, flags, shadow, dstResNum, palette);
+ drawWizPolygonTransform(resNum, state, wp->points, flags, shadow, dstResNum, palette);
}
void Wiz::drawWizPolygonTransform(int resNum, int state, Common::Point *wp, int flags, int shadow, int dstResNum, int palette) {
@@ -2031,7 +2134,7 @@ void Wiz::drawWizPolygonTransform(int resNum, int state, Common::Point *wp, int
bool freeBuffer = true;
if (_vm->_game.heversion >= 99) {
- if (getWizImageData(resNum, state, 0) != 0 || (flags & (kWRFRemap | kWRFFlipX | kWRFFlipY)) || palette != 0) {
+ if (getWizImageData(resNum, state, 0) != 0 || (flags & (kWRFRemap | kWRFHFlip | kWRFVFlip)) || palette != 0) {
flags |= kWRFAlloc;
if (flags & kWRFAreaSampleDuringWarp) {
@@ -2218,10 +2321,10 @@ void Wiz::drawWizPolygonImage(uint8 *dst, const uint8 *src, const uint8 *mask, i
bound.bottom = ymax_p + 1;
}
-void Wiz::flushWizBuffer() {
+void Wiz::flushAWizBuffer() {
for (int i = 0; i < _wizBufferIndex; ++i) {
WizBufferElement *pwi = &_wizBuffer[i];
- if (pwi->flags & kWRFIsPolygon) {
+ if (pwi->flags & kWRFPolygon) {
drawWizPolygon(pwi->image, pwi->state, pwi->x, pwi->flags, pwi->shadow, 0, pwi->palette);
} else {
const Common::Rect *r = nullptr;
@@ -2270,12 +2373,18 @@ void Wiz::loadWizCursor(int resId, int palette) {
}
void Wiz::processWizImageDrawCmd(const WizImageCommand *params) {
- int requiredImages[5];
+ int shadowImage, state, angle, scale, paletteNumber, sourceImage;
+ int zbufferImage = 0;
+ const WizRawPixel *colorConversionTablePtr;
+ Common::Rect *optionalRect;
+ WizSimpleBitmap *destBitmap;
+ WizSimpleBitmap fakeBitmap;
+ Common::Rect clipRect;
+ int32 flags;
+ Common::Point pt;
+
+ int requiredImages[5] = {0, 0, 0, 0, 0};
int requiredImageCount = 0;
- int sourceImage, palette, scale, rotationAngle, state, flags, po_x, po_y, shadow;
- int zbuffer = 0;
- int dstResNum = 0;
- const Common::Rect *r;
ADD_REQUIRED_IMAGE(params->image);
@@ -2287,9 +2396,9 @@ void Wiz::processWizImageDrawCmd(const WizImageCommand *params) {
}
if (params->actionFlags & kWAFPalette) {
- palette = params->palette;
+ paletteNumber = params->palette;
} else {
- palette = 0;
+ paletteNumber = 0;
}
if (params->actionFlags & kWAFScale) {
@@ -2299,9 +2408,9 @@ void Wiz::processWizImageDrawCmd(const WizImageCommand *params) {
}
if (params->actionFlags & kWAFAngle) {
- rotationAngle = params->angle;
+ angle = params->angle;
} else {
- rotationAngle = 0;
+ angle = 0;
}
if (params->actionFlags & kWAFState) {
@@ -2317,78 +2426,120 @@ void Wiz::processWizImageDrawCmd(const WizImageCommand *params) {
}
if (params->actionFlags & kWAFSpot) {
- po_x = params->xPos;
- po_y = params->yPos;
+ pt.x = params->xPos;
+ pt.y = params->yPos;
} else {
- po_x = 0;
- po_y = 0;
+ pt.x = 0;
+ pt.y = 0;
}
if (params->actionFlags & kWAFShadow) {
- shadow = params->shadow;
- ADD_REQUIRED_IMAGE(shadow);
+ shadowImage = params->shadow;
+ ADD_REQUIRED_IMAGE(shadowImage);
} else {
- shadow = 0;
+ shadowImage = 0;
}
if (params->actionFlags & kWAFZBufferImage) {
- zbuffer = params->zbufferImage;
- ADD_REQUIRED_IMAGE(zbuffer);
+ zbufferImage = params->zbufferImage;
+ ADD_REQUIRED_IMAGE(zbufferImage);
}
if (params->actionFlags & kWAFRect) {
- r = ¶ms->box;
+ clipRect.left = params->box.left;
+ clipRect.top = params->box.top;
+ clipRect.right = params->box.right;
+ clipRect.bottom = params->box.bottom;
+ optionalRect = &clipRect;
} else {
- r = nullptr;
+ optionalRect = nullptr;
}
if (params->actionFlags & kWAFDestImage) {
- dstResNum = params->destImageNumber;
- ADD_REQUIRED_IMAGE(dstResNum);
+ ADD_REQUIRED_IMAGE(params->destImageNumber);
}
if (requiredImageCount > 0) {
- // TODO
+ // Mark the all the image globs as stuck
+ for (int i = 0; i < requiredImageCount; i++) {
+ _vm->_res->lock(rtImage, requiredImages[i]);
+ }
+
+ // Make sure that the globs are in RAM by requesting their address
+ // Do this twice to hopefully ensure that there will be no heap movement
+ for (int i = 0; i < requiredImageCount; i++) {
+ _vm->ensureResourceLoaded(rtImage, requiredImages[i]);
+ }
+
+ // Mark the all the image globs as NOT stuck
+ for (int i = 0; i < requiredImageCount; i++) {
+ _vm->_res->unlock(rtImage, requiredImages[i]);
+ }
+
+ // Validate that all of the images are on the heap!
+ for (int i = 0; i < requiredImageCount; i++) {
+ if (!_vm->getResourceAddress(rtImage, requiredImages[i])) {
+ error("Wiz::processWizImageDrawCmd(): Image %d missing for image operation", requiredImages[i]);
+ }
+ }
+
+ // See if the images are in their native format and twiddle if need be.
+ for (int i = 0; i < requiredImageCount; i++) {
+ ensureNativeFormatImageForState(requiredImages[i], state);
+ }
}
- // TODO:
- //if (params->actionFlags & kWAFDestImage) {
- // // Get the rendering surface for this image
- // if (!dwSetSimpleBitmapStructFromImage(params->destImageNumber, 0, &fakeBitmap)) {
- // error("Image %d is invalid for rendering into", params->destImageNumber);
- // }
- //
- // destBitmap = &fakeBitmap;
- //} else {
- // destBitmap = nullptr;
- //}
+ if (params->actionFlags & kWAFDestImage) {
+ // Get the rendering surface for this image
+ if (!dwSetSimpleBitmapStructFromImage(params->destImageNumber, 0, &fakeBitmap)) {
+ error("Wiz::processWizImageDrawCmd(): Image %d is invalid for rendering into", params->destImageNumber);
+ }
- if (_vm->_game.heversion >= 99 && params->actionFlags & kWAFRemapList) {
+ destBitmap = &fakeBitmap;
+ } else {
+ destBitmap = nullptr;
+ }
+
+ if (_vm->_game.heversion >= 99 && (params->actionFlags & kWAFRemapList)) {
processWizImageModifyCmd(params);
flags |= kWRFRemap;
}
// Dispatch the command...
-
- if (!_vm->_fullRedraw || dstResNum != 0) {
+ if (!_vm->_fullRedraw || destBitmap != 0) {
if (sourceImage != 0) {
- drawWizImage(params->sourceImage, 0, params->image, state, po_x, po_y, params->zPos, shadow, zbuffer, r, flags, dstResNum, _vm->getHEPaletteSlot(palette), 0);
+ dwAltSourceDrawWiz(
+ params->image, state, pt.x, pt.y,
+ sourceImage, 0, flags, paletteNumber,
+ optionalRect, destBitmap);
} else {
- if (params->actionFlags & (kWAFScale | kWAFAngle)) {
- drawWizComplexPolygon(params->image, state, po_x, po_y, shadow, rotationAngle, scale, r, flags, dstResNum, palette);
+ if (!(params->actionFlags & (kWAFScale | kWAFAngle))) {
+ drawAWizEx(
+ params->image, state,
+ pt.x, pt.y, params->zPos,
+ flags,
+ shadowImage, zbufferImage,
+ optionalRect,
+ paletteNumber,
+ destBitmap,
+ params);
} else {
- if (flags & kWRFIsPolygon) {
- drawWizPolygon(params->image, state, po_x, flags, shadow, dstResNum, palette);
+ if (paletteNumber) {
+ colorConversionTablePtr = (WizRawPixel *)_vm->getHEPaletteSlot(paletteNumber);
} else {
- drawWizImage(params->image, state, 0, 0, po_x, po_y, params->zPos, shadow, zbuffer, r, flags, dstResNum, _vm->getHEPaletteSlot(palette), params->extendedRenderInfo.conditionBits);
+ colorConversionTablePtr = nullptr;
}
+
+ dwHandleComplexImageDraw(
+ params->image, state, pt.x, pt.y, shadowImage, angle, scale,
+ optionalRect, flags, destBitmap, colorConversionTablePtr);
}
}
} else {
if (sourceImage != 0 || (params->actionFlags & (kWAFScale | kWAFAngle)))
error("Can't do this command in the enter script");
- bufferAWiz(params->image, state, po_x, po_y, params->zPos, flags, shadow, zbuffer, palette);
+ bufferAWiz(params->image, state, pt.x, pt.y, params->zPos, flags, shadowImage, zbufferImage, paletteNumber);
}
}
@@ -2397,8 +2548,7 @@ void Wiz::processWizImageDrawCmd(const WizImageCommand *params) {
void Wiz::dwCreateRawWiz(int imageNum, int w, int h, int flags, int bitsPerPixel, int optionalSpotX, int optionalSpotY) {
int compressionType, wizdSize;
- int blockHeaderSize = 8;
- int globSize = blockHeaderSize; // AWIZ header size
+ int globSize = _vm->_resourceHeaderSize; // AWIZ header size
globSize += WIZBLOCK_WIZH_SIZE;
if (flags & kCWFPalette) {
@@ -2413,7 +2563,7 @@ void Wiz::dwCreateRawWiz(int imageNum, int w, int h, int flags, int bitsPerPixel
globSize += WIZBLOCK_RMAP_SIZE;
}
- globSize += blockHeaderSize; // WIZD header size
+ globSize += _vm->_resourceHeaderSize; // WIZD header size
wizdSize = (w * h * (bitsPerPixel / 8));
globSize += wizdSize;
@@ -2491,7 +2641,6 @@ bool Wiz::dwSetSimpleBitmapStructFromImage(int imageNum, int imageState, WizSimp
int compType, imageWidth, imageHeight;
byte *wizHeader;
byte *dataPtr;
- int blockHeaderSize = 8;
// Get the image header
wizHeader = (byte *)getWizStateHeaderPrim(imageNum, imageState);
@@ -2501,14 +2650,14 @@ bool Wiz::dwSetSimpleBitmapStructFromImage(int imageNum, int imageState, WizSimp
}
// Double check the image header compression type
- compType = READ_LE_UINT32(wizHeader + blockHeaderSize);
+ compType = READ_LE_UINT32(wizHeader + _vm->_resourceHeaderSize);
if (!isUncompressedFormatTypeID(compType)) {
return false;
}
- imageWidth = READ_LE_UINT32(wizHeader + blockHeaderSize + 4);
- imageHeight = READ_LE_UINT32(wizHeader + blockHeaderSize + 8);
+ imageWidth = READ_LE_UINT32(wizHeader + _vm->_resourceHeaderSize + 4);
+ imageHeight = READ_LE_UINT32(wizHeader + _vm->_resourceHeaderSize + 8);
// Do some fun stuff
dataPtr = (byte *)getWizStateDataPrim(imageNum, imageState);
@@ -2518,7 +2667,7 @@ bool Wiz::dwSetSimpleBitmapStructFromImage(int imageNum, int imageState, WizSimp
}
// Hook up the image info to the simple bitmap info
- destBM->bufferPtr = (WizRawPixel *)(dataPtr + blockHeaderSize);
+ destBM->bufferPtr = (WizRawPixel *)(dataPtr + _vm->_resourceHeaderSize);
destBM->bitmapWidth = imageWidth;
destBM->bitmapHeight = imageHeight;
@@ -2551,6 +2700,426 @@ int Wiz::dwTryToLoadWiz(Common::SeekableReadStream *inFile, const WizImageComman
return DW_LOAD_SUCCESS;
}
+void Wiz::dwAltSourceDrawWiz(int maskImage, int maskState, int x, int y, int sourceImage, int sourceState, int32 flags, int paletteNumber, const Common::Rect *optionalClipRect, const WizSimpleBitmap *destBitmapPtr) {
+ int srcBitsPerPixel, sourceCompressionType, maskCompressionType;
+ int srcBitmapWidth, srcBitmapHeight, maskWidth, maskHeight;
+ Common::Rect clipRect, destRect;
+ WizSimpleBitmap drawBufferBitmap;
+ WizRawPixel *conversionTable;
+ byte *sourceBufferPtr;
+ byte *maskDataPtr;
+ bool markUpdates;
+
+ // Get the conversion table if any
+ if (paletteNumber) {
+ conversionTable = (WizRawPixel *)_vm->getHEPaletteSlot(paletteNumber);
+ } else {
+ if (_uses16BitColor) {
+ conversionTable = (WizRawPixel *)_vm->getHEPaletteSlot(1); // Generic conversion table
+ } else {
+ conversionTable = nullptr;
+ }
+ }
+
+ // Get the dest bitmap ptr
+ if (!destBitmapPtr) {
+ markUpdates = true;
+
+ if (flags & kWRFForeground) {
+ pgSimpleBitmapFromDrawBuffer(&drawBufferBitmap, false);
+ } else {
+ pgSimpleBitmapFromDrawBuffer(&drawBufferBitmap, true);
+ }
+
+ destBitmapPtr = &drawBufferBitmap;
+ } else {
+ markUpdates = false;
+ }
+
+ // Check for overlap with the optional clip rectangle, if any
+ clipRect.left = 0;
+ clipRect.top = 0;
+ clipRect.right = destBitmapPtr->bitmapWidth - 1;
+ clipRect.bottom = destBitmapPtr->bitmapHeight - 1;
+
+ if (optionalClipRect) {
+ if (!findRectOverlap(&clipRect, optionalClipRect)) {
+ return; // We're done there is no update region.
+ }
+ }
+
+ // Get the source (alt) bitmap ptr & general info
+ sourceCompressionType = getWizCompressionType(sourceImage, sourceState);
+
+ if (!dwIsUncompressedFormatTypeID(sourceCompressionType)) {
+ error("Wiz::dwAltSourceDrawWiz(): Source image %d must be uncompressed.", sourceImage);
+ }
+
+ switch (sourceCompressionType) {
+
+ default:
+ case kWCTNone:
+ srcBitsPerPixel = 8; // Default
+ break;
+
+ case kWCTNone16Bpp:
+ case kWCTNone16BppBigEndian:
+ srcBitsPerPixel = 16;
+ break;
+
+ case kWCTNone32Bpp:
+ case kWCTNone32BppBigEndian:
+ srcBitsPerPixel = 32;
+ break;
+ }
+
+ // Get the source wiz data pointer.
+ sourceBufferPtr = (byte *)getWizStateDataPrim(sourceImage, sourceState);
+
+ if (!sourceBufferPtr) {
+ error("Wiz::dwAltSourceDrawWiz(): Image %d missing data block", sourceImage);
+ }
+
+ sourceBufferPtr += 8;
+ getWizImageDim(sourceImage, sourceState, srcBitmapWidth, srcBitmapHeight);
+
+ if ((destBitmapPtr->bitmapWidth != srcBitmapWidth) ||
+ (destBitmapPtr->bitmapHeight != srcBitmapHeight)) {
+
+ error(
+ "Wiz::dwAltSourceDrawWiz(): Source image %d and dest image size mismatch (%d,%d) need (%d,%d)",
+ sourceImage, srcBitmapWidth, srcBitmapHeight,
+ destBitmapPtr->bitmapWidth, destBitmapPtr->bitmapHeight);
+ }
+
+ // Finally get the compressed data pointer
+ maskCompressionType = getWizCompressionType(maskImage, maskState);
+
+ if (!dwIsMaskCompatibleCompressionType(maskCompressionType)) {
+ error("Wiz::dwAltSourceDrawWiz(): Mask image %d must be a maskable compression type.", maskImage);
+ }
+
+ maskDataPtr = (byte *)getWizStateDataPrim(maskImage, maskState);
+
+ if (!maskDataPtr) {
+ error("Wiz::dwAltSourceDrawWiz(): Image %d missing data block", maskImage);
+ }
+
+ maskDataPtr += 8;
+ getWizImageDim(maskImage, maskState, maskWidth, maskHeight);
+
+ // Make sure that we have an overlap before we call the decompressor
+ destRect.left = x;
+ destRect.top = y;
+ destRect.right = x + maskWidth - 1;
+ destRect.bottom = y + maskHeight - 1;
+
+ if (!findRectOverlap(&destRect, &clipRect)) {
+ // We're done, there is no update region...
+ return;
+ }
+
+ // Finally call the primitive...
+ if (maskCompressionType == kWCTTRLE) { // TODO
+ //TRLEFLIP_AltSource_DecompressImage(
+ // destBitmapPtr->bufferPtr, maskDataPtr,
+ // destBitmapPtr->bitmapWidth, destBitmapPtr->bitmapHeight,
+ // sourceBufferPtr, srcBitmapWidth, srcBitmapHeight, srcBitsPerPixel,
+ // x, y, maskWidth, maskHeight, &clipRect, flags, conversionTable,
+ // nullptr);
+
+ } else if (maskCompressionType == kWCTMRLEWithLineSizePrefix) {
+ MRLEFLIP_AltSource_DecompressImage(
+ destBitmapPtr->bufferPtr, maskDataPtr,
+ destBitmapPtr->bitmapWidth, destBitmapPtr->bitmapHeight,
+ sourceBufferPtr, srcBitmapWidth, srcBitmapHeight, srcBitsPerPixel,
+ x, y, maskWidth, maskHeight, &clipRect, flags, conversionTable);
+ }
+
+ // What type of update is necessary?
+ if (!(flags & kWRFAlloc) && markUpdates) {
+ // If neither foreground or background, copy to both...
+ if ((flags & (kWRFBackground | kWRFForeground)) == 0) {
+ _vm->backgroundToForegroundBlit(destRect);
+ } else {
+ ++destRect.bottom;
+ _vm->markRectAsDirty(kMainVirtScreen, destRect);
+ }
+ }
+}
+
+#define SWAP_POINTS(a, b) { \
+ int t; \
+ t = *b; \
+ *b = *a; \
+ *b = t; \
+}
+
+
+void Wiz::dwHandleComplexImageDraw(int image, int state, int x, int y, int shadow, int angle, int scale, const Common::Rect *clipRect, int32 flags, WizSimpleBitmap *optionalBitmapOverride, const WizRawPixel *optionalColorConversionTable) {
+ int w, h, correctedAngle;
+ Common::Point listOfPoints[4];
+ byte *shadowPtr;
+
+ // Set the optional remap table up to the default if one isn't specified
+ if (!optionalColorConversionTable) {
+ if (!_uses16BitColor) {
+ optionalColorConversionTable = (WizRawPixel *)_vm->getHEPaletteSlot(1);
+ }
+ }
+
+ // Setup the initial quad (0,0) relative...
+ getWizImageDim(image, state, w, h);
+
+ listOfPoints[0].x = -w / 2;
+ listOfPoints[0].y = -h / 2;
+
+ listOfPoints[1].x = listOfPoints[0].x + w - 1;
+ listOfPoints[1].y = listOfPoints[0].y;
+
+ listOfPoints[2].x = listOfPoints[1].x;
+ listOfPoints[2].y = listOfPoints[0].y + h - 1;
+
+ listOfPoints[3].x = listOfPoints[0].x;
+ listOfPoints[3].y = listOfPoints[2].y;
+
+ // Hflip
+ if (flags & kWRFHFlip) {
+ SWAP_POINTS(&listOfPoints[0].x, &listOfPoints[1].x);
+ SWAP_POINTS(&listOfPoints[2].x, &listOfPoints[3].x);
+ }
+
+ // VFlip
+ if (flags & kWRFVFlip) {
+ SWAP_POINTS(&listOfPoints[0].y, &listOfPoints[1].y);
+ SWAP_POINTS(&listOfPoints[2].y, &listOfPoints[3].y);
+ }
+
+ // Scale the points?
+ if (scale != 256) {
+ for (int i = 0; i < 4; i++) {
+ listOfPoints[i].x = (scale * listOfPoints[i].x) / 256;
+ listOfPoints[i].y = (scale * listOfPoints[i].y) / 256;
+ }
+ }
+
+ // Rotate the points
+ if (angle) {
+ polyRotatePoints(listOfPoints, 4, angle);
+ }
+
+ // Offset the points
+ polyMovePolygonPoints(listOfPoints, 4, x, y);
+
+ // Special case rotate 0,90,180,270 degree special cases
+ if (scale == 256) {
+ Common::Rect boundingRect;
+
+ correctedAngle = abs(angle % 360);
+
+ if (angle < 0) {
+ correctedAngle = (360 - correctedAngle);
+ }
+
+ // Get the upper left point so that our blit matches in position
+ // the normal warp drawing function.
+ polyBuildBoundingRect(listOfPoints, 4, boundingRect);
+ x = boundingRect.left;
+ y = boundingRect.top;
+
+ // Special case renderers don't use shadows...
+ if (!shadow) {
+ switch (correctedAngle) {
+ case 0:
+ handleRotate0SpecialCase(
+ image, state, x, y, shadow, correctedAngle, scale, clipRect, flags,
+ optionalBitmapOverride, optionalColorConversionTable);
+ return;
+ break;
+
+ case 90:
+ handleRotate90SpecialCase(
+ image, state, x, y, shadow, correctedAngle, scale, clipRect, flags,
+ optionalBitmapOverride, optionalColorConversionTable);
+ return;
+ break;
+
+ case 180:
+ handleRotate180SpecialCase(
+ image, state, x, y, shadow, correctedAngle, scale, clipRect, flags,
+ optionalBitmapOverride, optionalColorConversionTable);
+ return;
+ break;
+
+ case 270:
+ handleRotate270SpecialCase(
+ image, state, x, y, shadow, correctedAngle, scale, clipRect, flags,
+ optionalBitmapOverride, optionalColorConversionTable);
+ return;
+ break;
+ }
+ }
+ }
+
+ // If there is a shadow get it's address
+ if (shadow) {
+ shadowPtr = (byte *)getColorMixBlockPtrForWiz(shadow);
+ shadowPtr += _vm->_resourceHeaderSize;
+ } else {
+ shadowPtr = nullptr;
+ }
+
+ // Finally call the renderer
+ WARPWIZ_DrawWizTo4Points(
+ image, state, listOfPoints, flags,
+ _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR),
+ clipRect, optionalBitmapOverride, optionalColorConversionTable,
+ shadowPtr);
+}
+
+#undef SWAP_POINTS
+
+bool Wiz::dwIsMaskCompatibleCompressionType(int compressionType) {
+ return (kWCTTRLE == compressionType) || (kWCTMRLEWithLineSizePrefix == compressionType);
+}
+
+bool Wiz::dwIsUncompressedFormatTypeID(int id) {
+ return ((kWCTNone == id) ||
+ (kWCTNone16Bpp == id) || (kWCTNone32Bpp == id) ||
+ (kWCTNone16BppBigEndian == id) || (kWCTNone32BppBigEndian == id));
+}
+
+void Wiz::handleRotate0SpecialCase(int image, int state, int x, int y, int shadow, int angle, int scale, const Common::Rect *clipRect, int32 flags, WizSimpleBitmap *optionalBitmapOverride, const WizRawPixel *optionalColorConversionTable) {
+ drawAWizPrim(image, state, x, y, 0, shadow, 0, clipRect, flags, optionalBitmapOverride, optionalColorConversionTable);
+}
+
+void Wiz::handleRotate90SpecialCase(int image, int state, int x, int y, int shadow, int angle, int scale, const Common::Rect *clipRect, int32 flags, WizSimpleBitmap *optionalBitmapOverride, const WizRawPixel *optionalColorConversionTable) {
+ WizSimpleBitmap srcBitmap, dstBitmap;
+ void *uncompressedWizStateData;
+ Common::Rect updateRect;
+ int compressionType;
+
+ // Make the update rect and check it against the clip rect if one
+ int w, h;
+ getWizImageDim(image, state, w, h);
+ makeSizedRectAt(&updateRect, x, y, h, w); // We are swapping height and width on purpose!
+
+ if (clipRect) {
+ if (!findRectOverlap(&updateRect, clipRect)) {
+ return;
+ }
+ }
+
+ // Check to see if this is yet another special case :-)
+ compressionType = getWizCompressionType(image, state);
+
+ if (compressionType == kWCTTRLE) {
+ int dest_w, dest_h, src_w, src_h;
+ const byte *compressedDataPtr;
+ WizRawPixel *dest_p;
+
+ // Get the size of the compressed image
+ src_w = w;
+ src_h = h;
+
+ // Get the compressed data ptr!
+ compressedDataPtr = (byte *)getWizStateDataPrim(image, state);
+ compressedDataPtr += _vm->_resourceHeaderSize;
+
+ // Get the write data...
+ if (optionalBitmapOverride) {
+ dest_p = optionalBitmapOverride->bufferPtr;
+ dest_w = optionalBitmapOverride->bitmapWidth;
+ dest_h = optionalBitmapOverride->bitmapHeight;
+ } else {
+ VirtScreen *pvs = &_vm->_virtscr[kMainVirtScreen];
+
+ dest_w = pvs->w;
+ dest_h = pvs->h;
+
+ if (flags & kWRFForeground) {
+ dest_p = (WizRawPixel *)pvs->getPixels(0, 0);
+ } else {
+ dest_p = (WizRawPixel *)pvs->getBackPixels(0, 0);
+ }
+ }
+
+ // TODO
+ //TRLEFLIP_Rotate90_DecompressImage(
+ // dest_p, compressedDataPtr, dest_w, dest_h, x, y, src_w, src_h,
+ // clipRect, flags, nullptr, optionalColorConversionTable,
+ // nullptr);
+
+ // Update the screen? (If not writing to another bitmap...)
+ if (!optionalBitmapOverride) {
+ if (!(flags & kWRFForeground)) {
+ _vm->backgroundToForegroundBlit(updateRect);
+ } else {
+ ++updateRect.bottom;
+ _vm->markRectAsDirty(kMainVirtScreen, updateRect);
+ }
+ }
+
+ return;
+ }
+
+ // Get the image from the basic drawing function...
+ srcBitmap.bufferPtr = (WizRawPixel *)drawAWizPrim(
+ image, state, 0, 0, 0, 0, 0, 0, kWRFAlloc,
+ 0, optionalColorConversionTable);
+
+ srcBitmap.bitmapWidth = w;
+ srcBitmap.bitmapHeight = h;
+
+ // Get the bitmap to render into...
+ if (optionalBitmapOverride) {
+ dstBitmap = *optionalBitmapOverride;
+ } else {
+ pgSimpleBitmapFromDrawBuffer(&dstBitmap, (kWRFForeground != (kWRFForeground & flags)));
+ }
+
+ // Call the 90 blit function...
+ if (_vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR) == -1) {
+ pgBlit90DegreeRotate(
+ &dstBitmap, x, y, &srcBitmap, nullptr, clipRect,
+ (flags & kWRFHFlip), (flags & kWRFVFlip));
+ } else {
+ pgBlit90DegreeRotateTransparent(
+ &dstBitmap, x, y, &srcBitmap, nullptr, clipRect,
+ (flags & kWRFHFlip), (flags & kWRFVFlip),
+ (WizRawPixel)_vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR));
+ }
+
+ // Free up working bitmap from
+ free(srcBitmap.bufferPtr);
+ srcBitmap.bufferPtr = nullptr;
+
+ // Update the screen? (If not writing to another bitmap...)
+ if (!optionalBitmapOverride) {
+ if (!(flags & kWRFForeground)) {
+ _vm->backgroundToForegroundBlit(updateRect);
+ } else {
+ ++updateRect.bottom;
+ _vm->markRectAsDirty(kMainVirtScreen, updateRect);
+ }
+ }
+}
+
+void Wiz::handleRotate180SpecialCase(int image, int state, int x, int y, int shadow, int angle, int scale, const Common::Rect *clipRect, int32 flags, WizSimpleBitmap *optionalBitmapOverride, const WizRawPixel *optionalColorConversionTable) {
+ flags ^= (kWRFVFlip | kWRFHFlip);
+
+ drawAWizPrim(image, state, x, y, 0, shadow, 0, clipRect, flags, optionalBitmapOverride, optionalColorConversionTable);
+}
+
+void Wiz::handleRotate270SpecialCase(int image, int state, int x, int y, int shadow, int angle, int scale, const Common::Rect *clipRect, int32 flags, WizSimpleBitmap *optionalBitmapOverride, const WizRawPixel *optionalColorConversionTable) {
+ flags ^= (kWRFVFlip | kWRFHFlip);
+
+ handleRotate90SpecialCase(
+ image, state, x, y, shadow, angle, scale,
+ clipRect, flags, optionalBitmapOverride,
+ optionalColorConversionTable);
+}
+
void Wiz::processWizImageRenderRectCmd(const WizImageCommand *params) {
Common::Rect renderRect, clipRect, workClipRect;
int whichState, w, h, whichImage;
@@ -2757,6 +3326,10 @@ void Wiz::remapImage(int image, int state, int tableCount, const uint8 *remapLis
}
}
+void Wiz::ensureNativeFormatImageForState(int image, int state) {
+ // TODO
+}
+
void Wiz::processWizImageModifyCmd(const WizImageCommand *params) {
int state;
@@ -3107,6 +3680,7 @@ void Wiz::getWizImageSpot(uint8 *dataPtr, int state, int32 &x, int32 &y) {
}
int Wiz::getWizImageData(int resNum, int state, int type) {
+ // TODO: Fix
uint8 *dataPtr, *wizh;
dataPtr = _vm->getResourceAddress(rtImage, resNum);
@@ -3155,16 +3729,48 @@ int Wiz::getWizImageStates(const uint8 *dataPtr) {
}
}
-void *Wiz::getWizStateHeaderPrim(int resNum, int state) {
- uint8 *data = _vm->getResourceAddress(rtImage, resNum);
+byte *Wiz::getWizStateHeaderPrim(int resNum, int state) {
+ byte *data = _vm->getResourceAddress(rtImage, resNum);
assert(data);
- return _vm->findWrappedBlock(MKTAG('W', 'I', 'Z', 'H'), data, state, false) - 8;
+ return _vm->findWrappedBlock(MKTAG('W', 'I', 'Z', 'H'), data, state, false) - _vm->_resourceHeaderSize;
}
-void *Wiz::getWizStateDataPrim(int resNum, int state) {
- uint8 *data = _vm->getResourceAddress(rtImage, resNum);
+byte *Wiz::getWizStateDataPrim(int resNum, int state) {
+ byte *data = _vm->getResourceAddress(rtImage, resNum);
+ assert(data);
+ return _vm->findWrappedBlock(MKTAG('W', 'I', 'Z', 'D'), data, state, false) - _vm->_resourceHeaderSize;
+}
+
+byte *Wiz::getWizStatePaletteDataPrim(int globNum, int state) {
+ byte *data = _vm->getResourceAddress(rtImage, globNum);
+ assert(data);
+ return _vm->findWrappedBlock(MKTAG('R', 'G', 'B', 'S'), data, state, false) - _vm->_resourceHeaderSize;
+}
+
+byte *Wiz::getWizStateRemapDataPrim(int globNum, int state) {
+ byte *data = _vm->getResourceAddress(rtImage, globNum);
+ assert(data);
+ return _vm->findWrappedBlock(MKTAG('R', 'M', 'A', 'P'), data, state, false) - _vm->_resourceHeaderSize;
+}
+
+const byte *Wiz::getColorMixBlockPtrForWiz(int image) {
+ byte *data = _vm->getResourceAddress(rtImage, image);
+ assert(data);
+ return _vm->findResourceData(MKTAG('X', 'M', 'A', 'P'), data);
+}
+
+int Wiz::getWizCompressionType(int image, int state) {
+ byte *data = (byte *)getWizStateHeaderPrim(image, state);
+ assert(data);
+
+ return READ_LE_UINT32(data + _vm->_resourceHeaderSize);
+}
+
+bool Wiz::doesRawWizStateHaveTransparency(int globNum, int state) {
+ byte *data = _vm->getResourceAddress(rtImage, globNum);
assert(data);
- return _vm->findWrappedBlock(MKTAG('W', 'I', 'Z', 'D'), data, state, false) - 8;
+
+ return _vm->findWrappedBlock(MKTAG('T', 'R', 'N', 'S'), data, state, false) != nullptr;
}
int Wiz::isWizPixelNonTransparent(int resNum, int state, int x, int y, int flags) {
@@ -3192,10 +3798,10 @@ int Wiz::isWizPixelNonTransparent(uint8 *data, int state, int x, int y, int flag
uint8 *wizd = _vm->findWrappedBlock(MKTAG('W','I','Z','D'), data, state, 0);
assert(wizd);
if (x >= 0 && x < w && y >= 0 && y < h) {
- if (flags & kWRFFlipX) {
+ if (flags & kWRFHFlip) {
x = w - x - 1;
}
- if (flags & kWRFFlipY) {
+ if (flags & kWRFVFlip) {
y = h - y - 1;
}
switch (c) {
diff --git a/engines/scumm/he/wiz_he.h b/engines/scumm/he/wiz_he.h
index 110448457d6..18629c48be3 100644
--- a/engines/scumm/he/wiz_he.h
+++ b/engines/scumm/he/wiz_he.h
@@ -52,22 +52,41 @@ namespace Scumm {
#define WIZ_MAGIC_REMAP_NUMBER 0x76543210
+#define WIZRAWPIXEL_R_MASK (_uses16BitColor ? 0x7C00 : 0xFF)
+#define WIZRAWPIXEL_G_MASK (_uses16BitColor ? 0x03E0 : 0xFF)
+#define WIZRAWPIXEL_B_MASK (_uses16BitColor ? 0x001F : 0xFF)
+
+#define WIZRAWPIXEL_R_SHIFT (_uses16BitColor ? 10 : 0)
+#define WIZRAWPIXEL_G_SHIFT (_uses16BitColor ? 5 : 0)
+#define WIZRAWPIXEL_B_SHIFT (_uses16BitColor ? 0 : 0)
+
+#define WIZRAWPIXEL_MASK (_uses16BitColor ? 0xFFFF : 0xFF)
+
+#define WIZRAWPIXEL_LO_R_BIT (1 << WIZRAWPIXEL_R_SHIFT)
+#define WIZRAWPIXEL_LO_G_BIT (1 << WIZRAWPIXEL_G_SHIFT)
+#define WIZRAWPIXEL_LO_B_BIT (1 << WIZRAWPIXEL_B_SHIFT)
+#define WIZRAWPIXEL_LO_BITS ((WIZRAWPIXEL_LO_R_BIT) | (WIZRAWPIXEL_LO_G_BIT) | (WIZRAWPIXEL_LO_B_BIT))
+#define WIZRAWPIXEL_HI_BITS ~WIZRAWPIXEL_LO_BITS
+
+#define WIZRAWPIXEL_50_50_PREMIX_COLOR(__rawColor__) (((__rawColor__) & WIZRAWPIXEL_HI_BITS) >> 1)
+#define WIZRAWPIXEL_50_50_MIX(__colorA__, __colorB__) ((__colorA__) + (__colorB__))
+
typedef uint16 WizRawPixel;
struct WizPolygon {
- Common::Point vert[5];
- Common::Rect bound;
+ Common::Point points[5];
+ Common::Rect boundingRect;
int id;
- int numVerts;
+ int numPoints;
bool flag;
void reset() {
- for (int i = 0; i < ARRAYSIZE(vert); i++) {
- vert[i].x = vert[i].y = 0;
+ for (int i = 0; i < ARRAYSIZE(points); i++) {
+ points[i].x = points[i].y = 0;
}
- bound.top = bound.left = bound.bottom = bound.right = 0;
+ boundingRect.top = boundingRect.left = boundingRect.bottom = boundingRect.right = 0;
id = 0;
- numVerts = 0;
+ numPoints = 0;
flag = 0;
}
};
@@ -229,6 +248,36 @@ struct WizFloodState {
int numStackElements;
};
+struct WizCompressedImage {
+ byte *data;
+ int width;
+ int height;
+};
+
+struct WarpWizOneSpan {
+ int dstLeft;
+ int dstRight;
+ Common::Point srcLeft;
+ Common::Point srcRight;
+};
+
+struct WarpWizOneDrawSpan {
+ int dstOffset;
+ int xSrcStep;
+ int ySrcStep;
+ int xSrcOffset;
+ int ySrcOffset;
+ int dstWidth;
+};
+
+struct WarpWizOneSpanTable {
+ Common::Point dstMinPt, dstMaxPt;
+ Common::Point srcMinPt, srcMaxPt;
+ WarpWizOneDrawSpan *drawSpans;
+ WarpWizOneSpan *spans;
+ int drawSpanCount;
+ int spanCount;
+};
enum WizRenderingFlags {
// Standard rendering flags
@@ -238,12 +287,12 @@ enum WizRenderingFlags {
kWRFBackground = 0x00000008,
kWRFForeground = 0x00000010,
kWRFAlloc = 0x00000020,
- kWRFIsPolygon = 0x00000040,
+ kWRFPolygon = 0x00000040,
kWRFZPlaneOn = 0x00000080,
kWRFZPlaneOff = 0x00000100,
kWRFUseShadow = 0x00000200,
- kWRFFlipX = 0x00000400,
- kWRFFlipY = 0x00000800,
+ kWRFHFlip = 0x00000400,
+ kWRFVFlip = 0x00000800,
kWRFRotate90 = 0x00001000,
// Special rendering flags
@@ -355,7 +404,7 @@ enum WizMoonSystemBits {
kWMSBRopParamRShift = 8
};
-enum WizEclipseConstants {
+enum WizEllipseConstants {
kWECFixedSize = 16,
kWECPiOver2 = 102944, // Fixed point PI/2
kWECHalf = 32768 // Fixed point 1/2
@@ -390,25 +439,31 @@ public:
Wiz(ScummEngine_v71he *vm);
void clearWizBuffer();
- Common::Rect _rectOverride;
+ Common::Rect _lWizClipRect;
bool _cursorImage;
- bool _rectOverrideEnabled;
+ bool _lUseWizClipRect = false;
bool _uses16BitColor = false;
+ int _lWizActiveShadow = 0;
void polygonClear();
void polygonLoad(const uint8 *polData);
void polygonStore(int id, bool flag, int vert1x, int vert1y, int vert2x, int vert2y, int vert3x, int vert3y, int vert4x, int vert4y);
- void polygonCalcBoundBox(Common::Point *vert, int numVerts, Common::Rect & bound);
+ void polyBuildBoundingRect(Common::Point *vert, int numVerts, Common::Rect & bound);
void polygonErase(int fromId, int toId);
- int polygonHit(int id, int x, int y);
+ int polygonTestForObjectHit(int id, int x, int y);
bool polygonDefined(int id);
- bool polygonContains(const WizPolygon &pol, int x, int y);
- void polygonRotatePoints(Common::Point *pts, int num, int alpha);
+ bool polyIsPointInsidePoly(const WizPolygon &pol, int x, int y);
+ void polyRotatePoints(Common::Point *pts, int num, int alpha);
void polygonTransform(int resNum, int state, int po_x, int po_y, int angle, int zoom, Common::Point *vert);
+ void polyMovePolygonPoints(Common::Point *listOfPoints, int numverts, int deltaX, int deltaY);
void dwCreateRawWiz(int imageNum, int w, int h, int flags, int bitsPerPixel, int optionalSpotX, int optionalSpotY);
bool dwSetSimpleBitmapStructFromImage(int imageNum, int imageState, WizSimpleBitmap *destBM);
int dwTryToLoadWiz(Common::SeekableReadStream *inFile, const WizImageCommand *params);
+ void dwAltSourceDrawWiz(int maskImage, int maskState, int x, int y, int sourceImage, int sourceState, int32 flags, int paletteNumber, const Common::Rect *optionalClipRect, const WizSimpleBitmap *destBitmapPtr);
+ void dwHandleComplexImageDraw(int image, int state, int x, int y, int shadow, int angle, int scale, const Common::Rect *clipRect, int32 flags, WizSimpleBitmap *optionalBitmapOverride, const WizRawPixel *optionalColorConversionTable);
+ bool dwIsMaskCompatibleCompressionType(int compressionType);
+ bool dwIsUncompressedFormatTypeID(int id);
void processWizImageCmd(const WizImageCommand *params);
void processWizImageCaptureCmd(const WizImageCommand *params);
@@ -432,8 +487,13 @@ public:
void getWizImageDim(uint8 *dataPtr, int state, int32 &w, int32 &h);
int getWizImageStates(int resnum);
int getWizImageStates(const uint8 *ptr);
- void *getWizStateHeaderPrim(int resNum, int state);
- void *getWizStateDataPrim(int resNum, int state);
+ byte *getWizStateHeaderPrim(int resNum, int state);
+ byte *getWizStateDataPrim(int resNum, int state);
+ byte *getWizStatePaletteDataPrim(int resNum, int state);
+ byte *getWizStateRemapDataPrim(int resNum, int state);
+ int getWizCompressionType(int resNum, int state);
+ bool doesRawWizStateHaveTransparency(int globNum, int state);
+ const byte *getColorMixBlockPtrForWiz(int image);
int isWizPixelNonTransparent(int resnum, int state, int x, int y, int flags);
int isWizPixelNonTransparent(uint8 *data, int state, int x, int y, int flags);
@@ -442,7 +502,12 @@ public:
int getWizImageData(int resNum, int state, int type);
bool isUncompressedFormatTypeID(int id);
- void flushWizBuffer();
+ void handleRotate0SpecialCase(int image, int state, int x, int y, int shadow, int angle, int scale, const Common::Rect *clipRect, int32 flags, WizSimpleBitmap *optionalBitmapOverride, const WizRawPixel *optionalColorConversionTable);
+ void handleRotate90SpecialCase(int image, int state, int x, int y, int shadow, int angle, int scale, const Common::Rect *clipRect, int32 flags, WizSimpleBitmap *optionalBitmapOverride, const WizRawPixel *optionalColorConversionTable);
+ void handleRotate180SpecialCase(int image, int state, int x, int y, int shadow, int angle, int scale, const Common::Rect *clipRect, int32 flags, WizSimpleBitmap *optionalBitmapOverride, const WizRawPixel *optionalColorConversionTable);
+ void handleRotate270SpecialCase(int image, int state, int x, int y, int shadow, int angle, int scale, const Common::Rect *clipRect, int32 flags, WizSimpleBitmap *optionalBitmapOverride, const WizRawPixel *optionalColorConversionTable);
+
+ void flushAWizBuffer();
void getWizImageSpot(int resId, int state, int32 &x, int32 &y);
void getWizImageSpot(uint8 *data, int state, int32 &x, int32 &y);
@@ -453,6 +518,12 @@ public:
void simpleDrawAWiz(int image, int state, int x, int y, int flags);
void bufferAWiz(int image, int state, int x, int y, int z, int flags, int optionalShadowImage, int optionalZBufferImage, int whichPalette);
+ byte *drawAWiz(int image, int state, int x, int y, int z, int flags, int optionalShadowImage, int optionalZBufferImage,
+ Common::Rect *optionalClipRect, int whichPalette, WizSimpleBitmap *optionalBitmapOverride);
+ byte *drawAWizEx(int image, int state, int x, int y, int z, int flags, int optionalShadowImage, int optionalZBufferImage, Common::Rect *optionalClipRect,
+ int whichPalette, WizSimpleBitmap *optionalBitmapOverride, const WizImageCommand *optionalICmdPtr);
+ void *drawAWizPrim(int globNum, int state, int x, int y, int z, int shadowImage, int zbufferImage, const Common::Rect *optionalClipRect, int flags, WizSimpleBitmap *optionalBitmapOverride, const WizRawPixel *optionalColorConversionTable);
+ void *drawAWizPrimEx(int globNum, int state, int x, int y, int z, int shadowImage, int zbufferImage, const Common::Rect *optionalClipRect, int flags, WizSimpleBitmap *optionalBitmapOverride, const WizRawPixel *optionalColorConversionTable, const WizImageCommand *optionalICmdPtr);
uint8 *drawWizImage(int resNum, int state, int maskNum, int maskState, int x1, int y1, int zorder, int shadow, int zbuffer, const Common::Rect *clipBox, int flags, int dstResNum, const uint8 *palPtr, uint32 conditionBits);
void drawWizImageEx(uint8 *dst, uint8 *src, uint8 *mask, int dstPitch, int dstType, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, int state, const Common::Rect *rect, int flags, const uint8 *palPtr, int transColor, uint8 bitDepth, const uint8 *xmapPtr, uint32 conditionBits);
@@ -495,6 +566,8 @@ public:
void computeRawWizHistogram(uint32 *histogram, const uint8 *data, int srcPitch, const Common::Rect &rCapt);
void remapImage(int image, int state, int tableCount, const uint8 *remapList, const uint8 *remapTable);
+ void ensureNativeFormatImageForState(int image, int state);
+
private:
ScummEngine_v71he *_vm;
@@ -517,8 +590,32 @@ public:
void pgDrawClippedEllipse(WizSimpleBitmap *pDestBitmap, int iPX, int iPY, int iQX, int iQY, int iKX, int iKY, int iLOD, const Common::Rect *pClipRectPtr, int iThickness, WizRawPixel aColor);
void pgDrawSolidRect(WizSimpleBitmap *destBM, const Common::Rect *rectPtr, WizRawPixel color);
void pgFloodFillCmd(int x, int y, int color, const Common::Rect *optionalClipRect);
- void pgSimpleBitmapFromDrawBuffer(WizSimpleBitmap *bitmapPtr, bool background);
+ void pgSimpleBitmapFromDrawBuffer(WizSimpleBitmap *bitmapPtr, bool background);
+ void pgDrawRawDataFormatImage(WizRawPixel *bufferPtr, const WizRawPixel *rawData, int bufferWidth, int bufferHeight, int x, int y, int width, int height, Common::Rect *clipRectPtr, int32 wizFlags, const void *extraTable, int transparentColor);
+ void pgSimpleBlit(WizSimpleBitmap *destBM, Common::Rect *destRect, WizSimpleBitmap *sourceBM, Common::Rect *sourceRect);
+ void pgSimpleBlitRemapColors(WizSimpleBitmap *destBM, Common::Rect *destRect, WizSimpleBitmap *sourceBM, Common::Rect *sourceRect, const byte *remapColorTable);
+ void pgSimpleBlitTransparentRemapColors(WizSimpleBitmap *destBM, Common::Rect *destRect, WizSimpleBitmap *sourceBM, Common::Rect *sourceRect, WizRawPixel transparentColor, const byte *remapColorTable);
+ void pgSimpleBlitMixColors(WizSimpleBitmap *destBM, Common::Rect *destRect, WizSimpleBitmap *sourceBM, Common::Rect *sourceRect, const byte *mixColorTable);
+ void pgSimpleBlitTransparentMixColors(WizSimpleBitmap *destBM, Common::Rect *destRect, WizSimpleBitmap *sourceBM, Common::Rect *sourceRect, WizRawPixel transparentColor, const byte *mixColorTable);
+ void pgTransparentSimpleBlit(WizSimpleBitmap *destBM, Common::Rect *destRect, WizSimpleBitmap *sourceBM, Common::Rect *sourceRect, WizRawPixel transparentColor);
+
+ void pgDraw8BppFormatImage(WizRawPixel *bufferPtr, const byte *rawData, int bufferWidth, int bufferHeight, int x, int y, int width, int height, Common::Rect *clipRectPtr, int32 wizFlags, const void *extraTable, int transparentColor, const WizRawPixel *conversionTable);
+ void pgDraw8BppSimpleBlit(WizSimpleBitmap *destBM, Common::Rect *destRect, WizSimpleBitmap *sourceBM, Common::Rect *sourceRect, const WizRawPixel *conversionTable);
+ void pgDraw8BppTransparentSimpleBlit(WizSimpleBitmap *destBM, Common::Rect *destRect, WizSimpleBitmap *sourceBM, Common::Rect *sourceRect, int transparentColor, const WizRawPixel *conversionTable);
+ void pgDrawImageWith16BitZBuffer(WizSimpleBitmap *psbDst, const WizSimpleBitmap *psbZBuffer, const byte *imgData, int x, int y, int z, int width, int height, Common::Rect *prcClip);
+ void pgForewordRemapPixelCopy(WizRawPixel *dstPtr, const WizRawPixel *srcPtr, int size, const byte *lookupTable);
+ void pgBackwardsRemapPixelCopy(WizRawPixel *dstPtr, const WizRawPixel *srcPtr, int size, const byte *lookupTable);
+ void pgTransparentForewordRemapPixelCopy(WizRawPixel *dstPtr, const WizRawPixel *srcPtr, int size, WizRawPixel transparentColor, const byte *lookupTable);
+ void pgTransparentBackwardsRemapPixelCopy(WizRawPixel *dstPtr, const WizRawPixel *srcPtr, int size, WizRawPixel transparentColor, const byte *lookupTable);
+ void pgForewordMixColorsPixelCopy(WizRawPixel *dstPtr, const WizRawPixel *srcPtr, int size, const byte *lookupTable);
+ void pgBackwardsMixColorsPixelCopy(WizRawPixel *dstPtr, const WizRawPixel *srcPtr, int size, const byte *lookupTable);
+ void pgTransparentForewordMixColorsPixelCopy(WizRawPixel *dstPtr, const WizRawPixel *srcPtr, int size, WizRawPixel transparentColor, const byte *lookupTable);
+ void pgTransparentBackwardsMixColorsPixelCopy(WizRawPixel *dstPtr, const WizRawPixel *srcPtr, int size, WizRawPixel transparentColor, const byte *lookupTable);
+ void pgBlit90DegreeRotate(WizSimpleBitmap *dstBitmap, int x, int y, const WizSimpleBitmap *srcBitmap, const Common::Rect *optionalSrcRect, const Common::Rect *optionalClipRect, bool hFlip, bool vFlip);
+ void pgBlit90DegreeRotateTransparent(WizSimpleBitmap *dstBitmap, int x, int y, const WizSimpleBitmap *srcBitmap, const Common::Rect *optionalSrcRect, const Common::Rect *optionalClipRect, bool hFlip, bool vFlip, WizRawPixel transparentColor);
+ void pgBlit90DegreeRotateCore(WizSimpleBitmap *dstBitmap, int x, int y, const WizSimpleBitmap *srcBitmap, const Common::Rect *optionalSrcRect, const Common::Rect *optionalClipRect, bool hFlip, bool vFlip, const void *userParam, const void *userParam2,
+ void (*srcTransferFP)(Wiz *wiz, WizRawPixel *dstPtr, int dstStep, const WizRawPixel *srcPtr, int count, const void *userParam, const void *userParam2));
// Rectangles
bool findRectOverlap(Common::Rect *destRectPtr, const Common::Rect *sourceRectPtr);
bool isPointInRect(Common::Rect *r, Common::Point *pt);
@@ -526,12 +623,17 @@ public:
void makeSizedRectAt(Common::Rect *rectPtr, int x, int y, int width, int height);
void makeSizedRect(Common::Rect *rectPtr, int width, int height);
void combineRects(Common::Rect *destRect, Common::Rect *ra, Common::Rect *rb);
+ void clipRectCoords(Common::Rect *sourceRectPtr, Common::Rect *destRectPtr, Common::Rect *clipRectPtr);
+ int getRectWidth(Common::Rect *rectPtr);
+ int getRectHeight(Common::Rect *rectPtr);
+ void moveRect(Common::Rect *rectPtr, int dx, int dy);
+ void horzFlipAlignWithRect(Common::Rect *rectToAlign, const Common::Rect *baseRect);
+ void vertFlipAlignWithRect(Common::Rect *rectToAlign, const Common::Rect *baseRect);
// Flood fill
void floodInitFloodState(WizFloodState *statePtr, WizSimpleBitmap *bitmapPtr, int colorToWrite, const Common::Rect *optionalClippingRect);
WizFloodState *floodCreateFloodState(int numStackElements);
void floodDestroyFloodState(WizFloodState *state);
- //bool floodSimpleFloodCheckPixel(int x, int y, WizFloodState *state);
bool floodBoundryColorFloodCheckPixel(int x, int y, WizFloodState *state);
void floodFloodFillPrim(int x, int y, WizFloodState *statePtr, bool (*checkPixelFnPtr)(Wiz *w, int x, int y, WizFloodState *state));
void floodPerformOpOnRect(WizFloodState *statePtr, Common::Rect *rectPtr);
@@ -539,7 +641,60 @@ public:
// Utils
int getRawPixel(int color);
+ void memset8BppConversion(void *dstPtr, int value, size_t count, const WizRawPixel *conversionTable);
+ void memcpy8BppConversion(void *dstPtr, const void *srcPtr, size_t count, const WizRawPixel *conversionTable);
+ void rawPixelMemset(void *dstPtr, int value, size_t count);
+ WizRawPixel convert8BppToRawPixel(WizRawPixel value, const WizRawPixel *conversionTable);
+ void rawPixelExtractComponents(WizRawPixel aPixel, int &r, int &g, int &b);
+ void rawPixelPackComponents(WizRawPixel &aPixel, int r, int g, int b);
+
+
+ /*
+ * Compression Primitives
+ */
+
+ // MRLE
+ void MRLEFLIP_AltSource_DecompressImage(
+ WizRawPixel *destBufferPtr, const byte *compData, int destBufferWidth, int destBufferHeight,
+ const void *altBufferPtr, int altWidth, int altHeight, int altBitsPerPixel,
+ int x, int y, int width, int height, Common::Rect *clipRectPtr,
+ int32 wizFlags, const WizRawPixel *conversionTable);
+ void MRLEFLIP_AltSource_DecompressPrim(
+ WizRawPixel *destBufferPtr, int destBufferWidth, int destBufferHeight,
+ const void *altBufferPtr, int altBitsPerPixel,
+ const WizCompressedImage *imagePtr, int destX, int destY,
+ const Common::Rect *sourceCoords, const Common::Rect *clipRectPtr,
+ int32 flags, const WizRawPixel *conversionTable,
+ void (*forewordFunctionPtr)(Wiz *wiz,
+ WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream,
+ int skipAmount, int decompAmount, const WizRawPixel *conversionTable),
+ void (*backwardFunctionPtr)(Wiz *wiz,
+ WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream,
+ int skipAmount, int decompAmount, const WizRawPixel *conversionTable));
+
+
+ /*
+ * Image Warping on Polygons Primitives
+ */
+ bool WARPWIZ_DrawWiz(int image, int state, int polygon, int32 flags, int transparentColor, WizSimpleBitmap *optionalDestBitmap, const WizRawPixel *optionalColorConversionTable, int shadowImage);
+ bool WARPWIZ_DrawWizTo4Points(int image, int state, const Common::Point *dstPoints, int32 flags, int transparentColor, const Common::Rect *optionalClipRect, WizSimpleBitmap *optionalDestBitmap, const WizRawPixel *optionalColorConversionTable, byte *colorMixTable);
+ WarpWizOneSpanTable *WARPWIZ_CreateSpanTable(int spanCount);
+ void WARPWIZ_DestroySpanTable(WarpWizOneSpanTable *spanTable);
+ WarpWizOneSpanTable *WARPWIZ_BuildSpanTable(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const Common::Point *dstPts, const Common::Point *srcPts, int npoints, const Common::Rect *clipRectPtr);
+ void WARPWIZ_ProcessDrawSpansA(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizOneDrawSpan *drawSpans, int count);
+ void WARPWIZ_ProcessDrawSpansTransparent(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizOneDrawSpan *drawSpans, int count, WizRawPixel transparentColor);
+ void WARPWIZ_ProcessDrawSpansTransparentFiltered(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizOneDrawSpan *drawSpans, int count, WizRawPixel transparentColor, byte *pXmapColorTable, bool bIsHintColor, WizRawPixel hintColor);
+ void WARPWIZ_ProcessDrawSpansMixColors( WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizOneDrawSpan *drawSpans, int count, WizRawPixel transparentColor, byte *tablePtr);
+ void WARPWIZ_FillSpanWithLine(WarpWizOneSpanTable *st, const Common::Point *dstA, const Common::Point *dstB, const Common::Point *srcA, const Common::Point *srcB);
+ void WARPWIZ_ProcessDrawSpans_Sampled(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizOneDrawSpan *drawSpans, int count);
+ void WARPWIZ_ProcessDrawSpansTransparent_Sampled(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap,const WarpWizOneDrawSpan *drawSpans, int count, WizRawPixel transparentColor);
+ bool WARPWIZ_NPt2NPtWarp_CORE(WizSimpleBitmap *dstBitmap, const Common::Point *dstpoints, const WizSimpleBitmap *srcBitmap, const Common::Point *srcpoints, int npoints, int transparentColor, const Common::Rect *optionalClipRect, int32 wizFlags);
+ bool WARPWIZ_NPt2NPtNonClippedWarp(WizSimpleBitmap *dstBitmap, const Common::Point *dstpoints, const WizSimpleBitmap *srcBitmap, const Common::Point *srcpoints, int npoints, int transparentColor);
+ bool WARPWIZ_NPt2NPtClippedWarp(WizSimpleBitmap *dstBitmap, const Common::Point *dstpoints, const WizSimpleBitmap *srcBitmap, const Common::Point *srcpoints, int npoints, int transparentColor, const Common::Rect *optionalClipRect);
+ bool WARPWIZ_NPt2NPtClippedWarpMixColors(WizSimpleBitmap *dstBitmap, const Common::Point *dstpoints, const WizSimpleBitmap *srcBitmap, const Common::Point *srcpoints, int npoints, int transparentColor, const Common::Rect *optionalClipRect, byte *colorMixTable);
+ bool WARPWIZ_NPt2NPtNonClippedWarpFiltered(WizSimpleBitmap *dstBitmap, const Common::Point *dstpoints, const WizSimpleBitmap *srcBitmap, const Common::Point *srcpoints, int npoints, int transparentColor, byte *pXmapColorTable, bool bIsHintColor, WizRawPixel hintColor);
+ void WARPWIZ_FindMinMaxpoints(Common::Point *minPtr, Common::Point *maxPtr, const Common::Point *points, int npoints);
};
} // End of namespace Scumm
diff --git a/engines/scumm/he/wizwarp_he.cpp b/engines/scumm/he/wizwarp_he.cpp
new file mode 100644
index 00000000000..8317c3fad58
--- /dev/null
+++ b/engines/scumm/he/wizwarp_he.cpp
@@ -0,0 +1,1129 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifdef ENABLE_HE
+
+#include "common/math.h"
+#include "common/system.h"
+#include "scumm/he/intern_he.h"
+#include "scumm/he/wiz_he.h"
+
+namespace Scumm {
+
+#define WARP_FRAC_SIZE (_vm->_game.heversion > 98 ? 20 : 16)
+#define WARP_FRAC_VALUE (1 << (WARP_FRAC_SIZE))
+#define WARP_TEXTURE_LIMIT (1 << (31 - (WARP_FRAC_SIZE)))
+#define WARP_TO_FRAC(_x_) ((_x_) << (WARP_FRAC_SIZE))
+#define WARP_FROM_FRAC(_x_) ((_x_) >> (WARP_FRAC_SIZE))
+
+bool Wiz::WARPWIZ_DrawWiz(int image, int state, int polygon, int32 flags, int transparentColor, WizSimpleBitmap *optionalDestBitmap, const WizRawPixel *optionalColorConversionTable, int shadowImage) {
+ byte *xmapColorTable;
+ int polyIndex;
+
+ // Error check the params.
+ for (polyIndex = 0; polyIndex < ARRAYSIZE(_polygons); polyIndex++) {
+ if (_polygons[polyIndex].id == polygon) {
+ break;
+ }
+ }
+
+ if (ARRAYSIZE(_polygons) <= polyIndex) {
+ error("Polygon %d not defined", polygon);
+ }
+
+ if (_polygons[polyIndex].numPoints != 5) {
+ error("Invalid point count");
+ }
+
+ // How to lock this bad boy down?
+ if (shadowImage) {
+ xmapColorTable = (byte *)getColorMixBlockPtrForWiz(shadowImage);
+ if (xmapColorTable) {
+ xmapColorTable += _vm->_resourceHeaderSize;
+ }
+
+ } else {
+ xmapColorTable = nullptr;
+ }
+
+ // Call the actual warping primitive
+ return WARPWIZ_DrawWizTo4Points(
+ image, state, _polygons[polyIndex].points, flags, transparentColor,
+ nullptr, optionalDestBitmap, optionalColorConversionTable, xmapColorTable);
+}
+
+bool Wiz::WARPWIZ_DrawWizTo4Points(int image, int state, const Common::Point *dstPoints, int32 flags, int transparentColor, const Common::Rect *optionalClipRect, WizSimpleBitmap *optionalDestBitmap, const WizRawPixel *optionalColorConversionTable, byte *colorMixTable) {
+ WizSimpleBitmap dstBitmap, srcBitmap;
+ bool rValue, freeBitmapBits;
+ Common::Rect updateRect;
+ int x, y;
+ Common::Point srcPoints[4];
+ byte *ptr;
+
+ // Set the optional remap table up to the default if one isn't specified
+ if (!optionalColorConversionTable && _uses16BitColor) {
+ optionalColorConversionTable = (WizRawPixel *)_vm->getHEPaletteSlot(1);
+ }
+
+ // Decompress the wiz into a SIMPLEBITMAP... (Always if using a remap table)
+ if ((getWizCompressionType(image, state) != kWCTNone) ||
+ (optionalColorConversionTable != nullptr) || (flags & (kWRFHFlip | kWRFVFlip | kWRFRemap))) {
+
+ srcBitmap.bufferPtr = (WizRawPixel *)drawAWizPrim(image, state, 0, 0, 0, 0, 0, 0, kWRFAlloc | flags, 0, optionalColorConversionTable);
+
+ if (!srcBitmap.bufferPtr) {
+ return false;
+ }
+
+ freeBitmapBits = true;
+ } else {
+ // Get a pointer to the bits!
+ ptr = (byte *)getWizStateDataPrim(image, state);
+ if (!ptr)
+ error("Image %d missing data", image);
+
+ // Map the srcBitmap bits to the wiz data...
+ srcBitmap.bufferPtr = (WizRawPixel *)(ptr + 8);
+ freeBitmapBits = false;
+ }
+
+ // Fill in the dest bitmap structure.
+ if (optionalDestBitmap) {
+ dstBitmap = *optionalDestBitmap;
+ } else {
+ VirtScreen *pvs = &_vm->_virtscr[kMainVirtScreen];
+ dstBitmap.bitmapWidth = pvs->w;
+ dstBitmap.bitmapHeight = pvs->h;
+
+ if (flags & kWRFForeground) {
+ dstBitmap.bufferPtr = (WizRawPixel *)pvs->getPixels(0, pvs->topline);
+ } else {
+ dstBitmap.bufferPtr = (WizRawPixel *)pvs->getBackPixels(0, pvs->topline);
+ }
+
+ if (!dstBitmap.bufferPtr) {
+ error("Missing drawing buffer?");
+ }
+
+ dstBitmap.bufferPtr += pvs->xstart;
+ }
+
+ // Find the bounding rect and double check the coords.
+ updateRect.left = 12345;
+ updateRect.top = 12345;
+ updateRect.right = -12345;
+ updateRect.bottom = -12345;
+
+ for (int i = 0; i < 4; i++) {
+ x = dstPoints[i].x;
+ y = dstPoints[i].y;
+ updateRect.left = MIN<int16>(updateRect.left, x);
+ updateRect.top = MIN<int16>(updateRect.top, y);
+ updateRect.right = MIN<int16>(updateRect.right, x);
+ updateRect.bottom = MIN<int16>(updateRect.bottom, y);
+ }
+
+ updateRect.left = MAX<int16>(0, MIN<int16>((dstBitmap.bitmapWidth - 1), updateRect.left));
+ updateRect.top = MAX<int16>(0, MIN<int16>((dstBitmap.bitmapHeight - 1), updateRect.top));
+ updateRect.right = MAX<int16>(0, MIN<int16>((dstBitmap.bitmapWidth - 1), updateRect.right));
+ updateRect.bottom = MAX<int16>(0, MIN<int16>((dstBitmap.bitmapHeight - 1), updateRect.bottom));
+
+ getWizImageDim(image, state, srcBitmap.bitmapWidth, srcBitmap.bitmapHeight);
+
+ srcPoints[0].x = 0;
+ srcPoints[0].y = 0;
+ srcPoints[1].x = srcBitmap.bitmapWidth - 1;
+ srcPoints[1].y = 0;
+ srcPoints[2].x = srcBitmap.bitmapWidth - 1;
+ srcPoints[2].y = srcBitmap.bitmapHeight - 1;
+ srcPoints[3].x = 0;
+ srcPoints[3].y = srcBitmap.bitmapHeight - 1;
+
+ // Call the warping primitive!
+ if (colorMixTable) {
+ rValue = WARPWIZ_NPt2NPtClippedWarpMixColors(
+ &dstBitmap, dstPoints, &srcBitmap, srcPoints, 4, transparentColor,
+ optionalClipRect, colorMixTable);
+ } else {
+ if (_vm->_game.heversion > 99) {
+ rValue = WARPWIZ_NPt2NPtWarp_CORE(
+ &dstBitmap, dstPoints, &srcBitmap, srcPoints,
+ 4, transparentColor, optionalClipRect, flags);
+ } else {
+ if (optionalClipRect) {
+ rValue = WARPWIZ_NPt2NPtClippedWarp(
+ &dstBitmap, dstPoints, &srcBitmap, srcPoints, 4, transparentColor,
+ optionalClipRect);
+ } else {
+ rValue = WARPWIZ_NPt2NPtNonClippedWarp(
+ &dstBitmap, dstPoints, &srcBitmap, srcPoints, 4, transparentColor);
+ }
+ }
+ }
+
+ // Update the screen? (If not writing to another bitmap...)
+ if (rValue && !optionalDestBitmap) {
+ if (!(flags & kWRFForeground)) {
+ _vm->backgroundToForegroundBlit(updateRect);
+ } else {
+ ++updateRect.bottom;
+ _vm->markRectAsDirty(kMainVirtScreen, updateRect);
+ }
+ }
+
+ // Cleanup!
+ if (freeBitmapBits) {
+ free(srcBitmap.bufferPtr);
+ }
+
+ return rValue;
+}
+
+WarpWizOneSpanTable *Wiz::WARPWIZ_CreateSpanTable(int spanCount) {
+ WarpWizOneSpanTable *spanTable;
+ WarpWizOneSpan *spanPtr;
+ int counter;
+
+ spanTable = (WarpWizOneSpanTable *)malloc(sizeof(WarpWizOneSpanTable));
+ if (!spanTable) {
+ return nullptr;
+ }
+
+ spanTable->spanCount = spanCount;
+ spanTable->spans = (WarpWizOneSpan *)malloc(spanCount * sizeof(WarpWizOneSpan));
+ if (!spanTable->spans) {
+ WARPWIZ_DestroySpanTable(spanTable);
+ return nullptr;
+ }
+
+ spanPtr = spanTable->spans;
+ for (counter = 0; counter < spanCount; counter++) {
+ spanPtr->dstLeft = INT_MAX;
+ spanPtr->dstRight = INT_MIN;
+ spanPtr++;
+ }
+
+ spanTable->drawSpans = (WarpWizOneDrawSpan *)malloc(spanCount * sizeof(WarpWizOneDrawSpan));
+ if (!spanTable->drawSpans) {
+ WARPWIZ_DestroySpanTable(spanTable);
+ return nullptr;
+ }
+
+ return spanTable;
+}
+
+void Wiz::WARPWIZ_DestroySpanTable(WarpWizOneSpanTable *spanTable) {
+ if (spanTable->drawSpans) {
+ free(spanTable->drawSpans);
+ spanTable->drawSpans = nullptr;
+ }
+
+ if (spanTable->spans) {
+ free(spanTable->spans);
+ spanTable->spans = nullptr;
+ }
+
+ free(spanTable);
+ spanTable = nullptr;
+}
+
+WarpWizOneSpanTable *Wiz::WARPWIZ_BuildSpanTable(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const Common::Point *dstPts, const Common::Point *srcPts, int npoints, const Common::Rect *clipRectPtr) {
+ int offset, dw, sw, nonClippedWidth, maxOffset, cl, cr, cy, dl, cw;
+ Common::Point srcPt, dstPt, dstMinPt, dstMaxPt, srcMinPt, srcMaxPt, clippedPt;
+ WarpWizOneDrawSpan *drawSpan;
+ Common::Rect clippingRect;
+ WarpWizOneSpanTable *st;
+ WarpWizOneSpan *span;
+ bool ignoreAll;
+
+ // Setup the clipping rect
+ clippingRect.left = 0;
+ clippingRect.top = 0;
+ clippingRect.right = dstBitmap->bitmapWidth - 1;
+ clippingRect.bottom = dstBitmap->bitmapHeight - 1;
+ ignoreAll = false;
+
+ if (clipRectPtr) {
+ if (!findRectOverlap(&clippingRect, clipRectPtr)) {
+ ignoreAll = true;
+ }
+ }
+
+ // Find the span table fun parts...
+ WARPWIZ_FindMinMaxpoints(&dstMinPt, &dstMaxPt, dstPts, npoints);
+ WARPWIZ_FindMinMaxpoints(&srcMinPt, &srcMaxPt, srcPts, npoints);
+
+ st = WARPWIZ_CreateSpanTable((dstMaxPt.y - dstMinPt.y) + 1);
+ if (!st) {
+ return nullptr;
+ }
+
+ st->dstMinPt = dstMinPt;
+ st->dstMaxPt = dstMaxPt;
+ st->srcMinPt = srcMinPt;
+ st->srcMaxPt = srcMaxPt;
+
+ dstPt = *dstPts;
+ srcPt = *srcPts;
+
+ // Scan convert the polygon...
+ for (int i = 1; i < npoints; i++) {
+ WARPWIZ_FillSpanWithLine(st, dstPts, dstPts + 1, srcPts, srcPts + 1);
+ dstPts++;
+ srcPts++;
+ }
+
+ WARPWIZ_FillSpanWithLine(st, dstPts, &dstPt, srcPts, &srcPt);
+
+ // Build the draw span table!
+ drawSpan = st->drawSpans;
+ dw = dstBitmap->bitmapWidth;
+ sw = srcBitmap->bitmapWidth;
+ span = st->spans;
+ offset = ((int)st->dstMinPt.y) * dw;
+ maxOffset = (dw * (dstBitmap->bitmapHeight - 1));
+ st->drawSpanCount = 0;
+ cy = st->dstMinPt.y;
+
+ if (ignoreAll) {
+ return st;
+ }
+
+ for (int i = st->spanCount; --i >= 0; ++cy, ++span, offset += dw) {
+ // Clip vertical or all ?
+ if ((cy < clippingRect.top) || (cy > clippingRect.bottom)) {
+ continue;
+ }
+
+ // Clip horizontal
+ cl = MAX<int>(clippingRect.left, span->dstLeft);
+ cr = MAX<int>(clippingRect.right, span->dstRight);
+
+ if ((cw = (cr - cl + 1)) <= 0) {
+ continue;
+ }
+
+ // Calc the step values
+ nonClippedWidth = (span->dstRight) - (span->dstLeft) + 1;
+ drawSpan->xSrcStep = WARP_TO_FRAC((span->srcRight.x - span->srcLeft.x)) / nonClippedWidth;
+ drawSpan->ySrcStep = WARP_TO_FRAC((span->srcRight.y - span->srcLeft.y)) / nonClippedWidth;
+
+ // Calc the clipped values...
+ drawSpan->dstOffset = offset + cl;
+ drawSpan->dstWidth = cw;
+ drawSpan->xSrcOffset = WARP_TO_FRAC(span->srcLeft.x);
+ drawSpan->ySrcOffset = WARP_TO_FRAC(span->srcLeft.y);
+
+ if ((dl = (cl - span->dstLeft)) != 0) {
+ drawSpan->xSrcOffset += (dl * drawSpan->xSrcStep);
+ drawSpan->ySrcOffset += (dl * drawSpan->ySrcStep);
+ }
+
+ st->drawSpanCount++;
+ drawSpan++;
+ }
+
+ return st;
+}
+
+void Wiz::WARPWIZ_FindMinMaxpoints(Common::Point *minPtr, Common::Point *maxPtr, const Common::Point *points, int npoints) {
+ Common::Point minPt, maxPt, pt;
+
+ // Find the limits...
+ maxPt.x = INT16_MIN;
+ maxPt.y = INT16_MIN;
+ minPt.x = INT16_MAX;
+ minPt.y = INT16_MAX;
+
+ for (int i = 0; i < npoints; i++) {
+ pt = *points++;
+
+ if (pt.x < minPt.x) {
+ minPt.x = pt.x;
+ }
+
+ if (pt.y < minPt.y) {
+ minPt.y = pt.y;
+ }
+
+ if (pt.x > maxPt.x) {
+ maxPt.x = pt.x;
+ }
+
+ if (pt.y > maxPt.y) {
+ maxPt.y = pt.y;
+ }
+ }
+
+ *minPtr = minPt;
+ *maxPtr = maxPt;
+}
+
+void Wiz::WARPWIZ_ProcessDrawSpansA(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizOneDrawSpan *drawSpans, int count) {
+ int xStep, yStep, sw, xOffset, yOffset;
+ const WizRawPixel *srcPtr;
+ WizRawPixel *dstPtr;
+
+ sw = srcBitmap->bitmapWidth;
+ srcPtr = srcBitmap->bufferPtr;
+
+ for (int yCounter = count; --yCounter >= 0;) {
+ dstPtr = dstBitmap->bufferPtr + drawSpans->dstOffset;
+ xOffset = drawSpans->xSrcOffset;
+ yOffset = drawSpans->ySrcOffset;
+ xStep = drawSpans->xSrcStep;
+ yStep = drawSpans->ySrcStep;
+
+ for (int xCounter = drawSpans->dstWidth; --xCounter >= 0;) {
+ *dstPtr++ = *(srcPtr + (sw * WARP_FROM_FRAC(yOffset)) + WARP_FROM_FRAC(xOffset));
+
+ xOffset += xStep;
+ yOffset += yStep;
+ }
+
+ drawSpans++;
+ }
+}
+
+void Wiz::WARPWIZ_ProcessDrawSpansTransparent(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizOneDrawSpan *drawSpans, int count, WizRawPixel transparentColor) {
+ int xStep, yStep, sw, xOffset, yOffset;
+ const WizRawPixel *srcPtr;
+ WizRawPixel srcColor;
+ WizRawPixel *dstPtr;
+
+ sw = srcBitmap->bitmapWidth;
+ srcPtr = srcBitmap->bufferPtr;
+
+ for (int yCounter = count; --yCounter >= 0;) {
+ dstPtr = dstBitmap->bufferPtr + drawSpans->dstOffset;
+ xOffset = drawSpans->xSrcOffset;
+ yOffset = drawSpans->ySrcOffset;
+ xStep = drawSpans->xSrcStep;
+ yStep = drawSpans->ySrcStep;
+
+ for (int xCounter = drawSpans->dstWidth; --xCounter >= 0;) {
+ srcColor = *(srcPtr + (sw * WARP_FROM_FRAC(yOffset)) + WARP_FROM_FRAC(xOffset));
+ if (srcColor != transparentColor) {
+ *dstPtr++ = srcColor;
+ } else {
+ dstPtr++;
+ }
+
+ xOffset += xStep;
+ yOffset += yStep;
+ }
+
+ drawSpans++;
+ }
+}
+
+void Wiz::WARPWIZ_ProcessDrawSpansTransparentFiltered(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizOneDrawSpan *drawSpans, int count, WizRawPixel transparentColor, byte *pXmapColorTable, bool bIsHintColor, WizRawPixel hintColor) {
+ int srcWidth = srcBitmap->bitmapWidth;
+ const WizRawPixel *srcPtr = srcBitmap->bufferPtr;
+ bool bSkipFilter = false;
+
+ int xStep, yStep, xOffset, yOffset;
+ WizRawPixel srcColor, srcColorN, srcColorS, srcColorE, srcColorW;
+ int iCurrentX, iCurrentY, iXScan, iYScan;
+ WizRawPixel *dstPtr;
+
+ // set up a rect for clipping if needed
+ Common::Rect aSrcRect; // the source rectangle for clipping
+ Common::Rect aScanRect; // the dest rectangle for clipping
+ aSrcRect.left = 0;
+ aSrcRect.top = 0;
+ aSrcRect.right = srcWidth;
+ aSrcRect.bottom = srcBitmap->bitmapHeight;
+ iYScan = aSrcRect.bottom / count;
+
+ for (int yCounter = count; --yCounter >= 0;) {
+ dstPtr = dstBitmap->bufferPtr + drawSpans->dstOffset;
+ xOffset = drawSpans->xSrcOffset;
+ yOffset = drawSpans->ySrcOffset;
+ xStep = drawSpans->xSrcStep;
+ yStep = drawSpans->ySrcStep;
+ iXScan = WARP_FROM_FRAC(xStep); // the width of the seach should be the x step size
+
+ for (int xCounter = drawSpans->dstWidth; --xCounter >= 0;) {
+ iCurrentX = WARP_FROM_FRAC(xOffset);
+ iCurrentY = WARP_FROM_FRAC(yOffset);
+
+ // get the current color and the surrounding colors
+ srcColor = *(srcPtr + (srcWidth * iCurrentY) + iCurrentX);
+
+ bSkipFilter = false;
+ if (bIsHintColor) {
+ // check if we need to clip our scan rectangle
+ aScanRect.left = iCurrentX - iXScan;
+ aScanRect.top = iCurrentY - iYScan;
+ aScanRect.right = iCurrentX + iXScan;
+ aScanRect.bottom = iCurrentY + iYScan;
+ findRectOverlap(&aScanRect, &aSrcRect);
+
+ // scan through rect looking for hint color
+ for (int yScan = aScanRect.top; yScan < aScanRect.bottom; ++yScan) {
+ for (int xScan = aScanRect.left; xScan < aScanRect.right; ++xScan) {
+ if ((*(srcPtr + (yScan * srcWidth) + xScan)) == hintColor) {
+ srcColor = hintColor;
+ bSkipFilter = true;
+ break;
+ }
+ }
+
+ if (bSkipFilter) {
+ break;
+ }
+ }
+ }
+
+ if ((srcColor != transparentColor) && !bSkipFilter) {
+ // check if top
+ if (iCurrentY != 0) {
+ srcColorN = *(srcPtr + (srcWidth * (iCurrentY - 1)) + iCurrentX);
+ } else {
+ srcColorN = transparentColor;
+ }
+
+ // check if bottom
+ if (iCurrentY != aSrcRect.bottom) {
+ srcColorS = *(srcPtr + (srcWidth * (iCurrentY + 1)) + iCurrentX);
+ } else {
+ srcColorS = transparentColor;
+ }
+
+ // check for left edge
+ if (iCurrentX != 0) {
+ srcColorW = *(srcPtr + (srcWidth * iCurrentY) + (iCurrentX - 1));
+ } else {
+ srcColorW = transparentColor;
+ }
+
+ // check for right edge
+ if (iCurrentX != aSrcRect.right) {
+ srcColorE = *(srcPtr + (srcWidth * iCurrentY) + (iCurrentX + 1));
+ } else {
+ srcColorE = transparentColor;
+ }
+
+ // make transparent color black
+ if (srcColorN == transparentColor) {
+ srcColorN = srcColor;
+ }
+
+ if (srcColorS == transparentColor) {
+ srcColorS = srcColor;
+ }
+
+ if (srcColorW == transparentColor) {
+ srcColorW = srcColor;
+ }
+
+ if (srcColorE == transparentColor) {
+ srcColorE = srcColor;
+ }
+
+ if (!_uses16BitColor) {
+ // in 8 bit mode go around the pixel adding in colors from the xmap color table
+ // ignores transparent pixels
+ // trying 1/8 of the surrounding colors
+ srcColor = *(pXmapColorTable + (srcColorN * 256) + srcColor);
+ srcColor = *(pXmapColorTable + (srcColorS * 256) + srcColor);
+ srcColor = *(pXmapColorTable + (srcColorE * 256) + srcColor);
+ srcColor = *(pXmapColorTable + (srcColorW * 256) + srcColor);
+
+ } else {
+ int rs = 0, gs = 0, bs = 0;
+ float rd = 0, gd = 0, bd = 0;
+
+ // get 1/4 of each surrounding pixel and add into source pixel
+ rawPixelExtractComponents(srcColorN, rs, gs, bs);
+ rd += rs;
+ gd += gs;
+ bd += bs;
+
+ rawPixelExtractComponents(srcColorS, rs, gs, bs);
+ rd += rs;
+ gd += gs;
+ bd += bs;
+
+ rawPixelExtractComponents(srcColorW, rs, gs, bs);
+ rd += rs;
+ gd += gs;
+ bd += bs;
+
+ rawPixelExtractComponents(srcColorE, rs, gs, bs);
+ rd += rs;
+ gd += gs;
+ bd += bs;
+
+ // average pixels
+ rd /= 4.0f;
+ gd /= 4.0f;
+ bd /= 4.0f;
+
+ // get source pixel colors
+ rawPixelExtractComponents(srcColor, rs, gs, bs);
+ rd += rs;
+ gd += gs;
+ bd += bs;
+
+ // now average the two
+ rd /= 2.0f;
+ gd /= 2.0f;
+ bd /= 2.0f;
+
+ // pack the pixel back up
+ rawPixelPackComponents(srcColor, (int)rd, (int)gd, (int)bd);
+ }
+ }
+
+ if (srcColor != transparentColor) {
+ *dstPtr++ = srcColor;
+ } else {
+ dstPtr++;
+ }
+
+ xOffset += xStep;
+ yOffset += yStep;
+ }
+
+ drawSpans++;
+ }
+}
+
+void Wiz::WARPWIZ_ProcessDrawSpansMixColors(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizOneDrawSpan *drawSpans, int count, WizRawPixel transparentColor, byte *tablePtr) {
+ int xStep, yStep, sw, xOffset, yOffset;
+ WizRawPixel srcColor;
+ const WizRawPixel *srcPtr;
+ WizRawPixel *dstPtr;
+
+ sw = srcBitmap->bitmapWidth;
+ srcPtr = srcBitmap->bufferPtr;
+
+ for (int yCounter = count; --yCounter >= 0;) {
+
+ dstPtr = dstBitmap->bufferPtr + drawSpans->dstOffset;
+ xOffset = drawSpans->xSrcOffset;
+ yOffset = drawSpans->ySrcOffset;
+ xStep = drawSpans->xSrcStep;
+ yStep = drawSpans->ySrcStep;
+
+ for (int xCounter = drawSpans->dstWidth; --xCounter >= 0;) {
+ if (!_uses16BitColor) {
+ srcColor = (*(srcPtr + (sw * WARP_FROM_FRAC(yOffset)) + WARP_FROM_FRAC(xOffset)));
+ if (srcColor != transparentColor) {
+ *dstPtr++ = *(tablePtr + (srcColor * 256) + (*dstPtr));
+ } else {
+ dstPtr++;
+ }
+ } else {
+ srcColor = *(srcPtr + (sw * WARP_FROM_FRAC(yOffset)) + WARP_FROM_FRAC(xOffset));
+
+ *dstPtr++ = WIZRAWPIXEL_50_50_MIX(WIZRAWPIXEL_50_50_PREMIX_COLOR(srcColor), WIZRAWPIXEL_50_50_PREMIX_COLOR(*dstPtr));
+ }
+
+ xOffset += xStep;
+ yOffset += yStep;
+ }
+
+ drawSpans++;
+ }
+}
+
+void Wiz::WARPWIZ_FillSpanWithLine(WarpWizOneSpanTable *st, const Common::Point *dstA, const Common::Point *dstB, const Common::Point *srcA, const Common::Point *srcB) {
+ Common::Point dstStep, srcStep, dstPt, srcPt, dpt, spt;
+ int h, lx1, ly1, lx2, ly2;
+ WarpWizOneSpan *spanPtr;
+
+ dstPt.x = WARP_TO_FRAC(dstA->x);
+ srcPt.x = WARP_TO_FRAC(srcA->x);
+ srcPt.y = WARP_TO_FRAC(srcA->y);
+ h = abs(dstB->y - dstA->y) + 1;
+ dstStep.x = WARP_TO_FRAC((dstB->x - dstA->x)) / h;
+ srcStep.x = WARP_TO_FRAC((srcB->x - srcA->x)) / h;
+ srcStep.y = WARP_TO_FRAC((srcB->y - srcA->y)) / h;
+ spanPtr = &st->spans[(dstA->y - st->dstMinPt.y)];
+
+ if (srcA->x <= srcB->x) {
+ lx1 = srcA->x;
+ lx2 = srcB->x;
+ } else {
+ lx1 = srcB->x;
+ lx2 = srcA->x;
+ }
+
+ if (srcA->y <= srcB->y) {
+ ly1 = srcA->y;
+ ly2 = srcB->y;
+ } else {
+ ly1 = srcB->y;
+ ly2 = srcA->y;
+ }
+
+ for (int i = h; --i >= 0;) {
+ dpt.x = WARP_FROM_FRAC(dstPt.x + (WARP_FRAC_VALUE / 2));
+ spt.x = MAX<int>(lx1, MIN<int>(lx2, WARP_FROM_FRAC(srcPt.x + (WARP_FRAC_VALUE / 2))));
+ spt.y = MAX<int>(ly1, MIN<int>(ly2, WARP_FROM_FRAC(srcPt.y + (WARP_FRAC_VALUE / 2))));
+
+ if (dpt.x < spanPtr->dstLeft) {
+ spanPtr->dstLeft = dpt.x;
+ spanPtr->srcLeft = spt;
+ }
+
+ if (dpt.x > spanPtr->dstRight) {
+ spanPtr->dstRight = dpt.x;
+ spanPtr->srcRight = spt;
+ }
+
+ dstPt.x += dstStep.x;
+ srcPt.x += srcStep.x;
+ srcPt.y += srcStep.y;
+
+ if (dstA->y < dstB->y) {
+ spanPtr++;
+ } else {
+ spanPtr--;
+ }
+ }
+}
+
+void Wiz::WARPWIZ_ProcessDrawSpans_Sampled(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizOneDrawSpan *drawSpans, int count) {
+ // Setup read pointer and clipping limits for the sampling rect
+ const WizRawPixel *srcPtr = srcBitmap->bufferPtr;
+
+ int sw = srcBitmap->bitmapWidth;
+ int src_x_limit = (srcBitmap->bitmapWidth - 1);
+ int src_y_limit = (srcBitmap->bitmapHeight - 1);
+
+ // Process all of the spans in this span collection.
+ for (int yCounter = count; --yCounter >= 0;) {
+ WizRawPixel *dstPtr = dstBitmap->bufferPtr + drawSpans->dstOffset;
+
+ int xOffset = drawSpans->xSrcOffset;
+ int yOffset = drawSpans->ySrcOffset;
+ int xStep = drawSpans->xSrcStep;
+ int yStep = drawSpans->ySrcStep;
+
+ // Figure out the sample rect for this "slope"
+ int sample_cx = (WARP_FROM_FRAC(xStep));
+ int sample_cy = (WARP_FROM_FRAC(yStep));
+
+ if (sample_cx < 0) {
+ sample_cx = -sample_cx;
+ }
+
+ if (sample_cy < 0) {
+ sample_cy = -sample_cy;
+ }
+
+ // Make the sampling area square using the largest delta
+ if (sample_cx > sample_cy) {
+ sample_cy = sample_cx;
+ } else {
+ sample_cx = sample_cy;
+ }
+
+ int sample_x_offset = sample_cx;
+ int sample_y_offset = sample_cy;
+
+ // Process all pixels covered by this "span"
+ for (int xCounter = drawSpans->dstWidth; --xCounter >= 0;) {
+ if (!_uses16BitColor) {
+ *dstPtr++ = (*(srcPtr + (sw * WARP_FROM_FRAC(yOffset)) + WARP_FROM_FRAC(xOffset)));
+ } else {
+ // Do a really lame sampling of the potential source pixels
+ int sx = WARP_FROM_FRAC(xOffset);
+ int sy = WARP_FROM_FRAC(yOffset);
+
+ int sx1 = sx;
+ int sy1 = sy;
+
+ int sx2 = sx + sample_x_offset;
+ int sy2 = sy + sample_y_offset;
+
+ // Clip the source sample coords to the bitmap limits
+ sx1 = MAX<int>(0, MIN<int>(src_x_limit, sx1));
+ sy1 = MAX<int>(0, MIN<int>(src_y_limit, sy1));
+ sx2 = MAX<int>(0, MIN<int>(src_x_limit, sx2));
+ sy2 = MAX<int>(0, MIN<int>(src_y_limit, sy2));
+
+ // Now that the clipping is done figure out the sampling area
+ int sxc = ((sx2 - sx1) + 1);
+ int syc = ((sy2 - sy1) + 1);
+ int total = (sxc * syc);
+
+ // Sample pixels from the source potential sampling area
+ if (total > 1) {
+ int total_R, total_G, total_B;
+ const WizRawPixel *samplePtr = (srcPtr + ((sw * sy1) + sx1));
+
+ rawPixelExtractComponents(*samplePtr, total_R, total_G, total_B);
+
+ int sampleStep = sw - sxc;
+ ++total;
+
+ for (int i = 0; i < syc; sy++) {
+ for (int j = 0; j < sxc; j++) {
+ int r, g, b;
+
+ WizRawPixel src_color = *samplePtr++;
+ rawPixelExtractComponents(src_color, r, g, b);
+
+ total_R += r;
+ total_G += g;
+ total_B += b;
+ }
+
+ samplePtr += sampleStep;
+ }
+
+ rawPixelPackComponents(*dstPtr, total_R / total, total_G / total, total_B / total);
+
+ } else {
+ *dstPtr = (*(srcPtr + (sw * sy1) + sx1));
+ }
+ }
+
+ xOffset += xStep;
+ yOffset += yStep;
+ }
+
+ drawSpans++;
+ }
+}
+
+void Wiz::WARPWIZ_ProcessDrawSpansTransparent_Sampled(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizOneDrawSpan *drawSpans, int count, WizRawPixel transparentColor) {
+ // Setup read pointer and clipping limits for the sampling rect
+ const WizRawPixel *srcPtr = srcBitmap->bufferPtr;
+
+ int sw = srcBitmap->bitmapWidth;
+ int src_x_limit = (srcBitmap->bitmapWidth - 1);
+ int src_y_limit = (srcBitmap->bitmapHeight - 1);
+
+ // Process all of the spans in this span collection.
+ for (int yCounter = count; --yCounter >= 0;) {
+
+ WizRawPixel *dstPtr = dstBitmap->bufferPtr + drawSpans->dstOffset;
+
+ int xOffset = drawSpans->xSrcOffset;
+ int yOffset = drawSpans->ySrcOffset;
+ int xStep = drawSpans->xSrcStep;
+ int yStep = drawSpans->ySrcStep;
+
+ // Figure out the sample rect for this "slope"
+ int sample_cx = (WARP_FROM_FRAC(xStep));
+ int sample_cy = (WARP_FROM_FRAC(yStep));
+
+ if (sample_cx < 0) {
+ sample_cx = -sample_cx;
+ }
+
+ if (sample_cy < 0) {
+ sample_cy = -sample_cy;
+ }
+
+ // Make the sampling area square using the largest delta
+ if (sample_cx > sample_cy) {
+ sample_cy = sample_cx;
+ } else {
+ sample_cx = sample_cy;
+ }
+
+ int sample_x_offset = sample_cx;
+ int sample_y_offset = sample_cy;
+
+ // Process all pixels covered by this "span"
+ for (int xCounter = drawSpans->dstWidth; --xCounter >= 0;) {
+ if (!_uses16BitColor) {
+ WizRawPixel src_color = (*(srcPtr + (sw * WARP_FROM_FRAC(yOffset)) + WARP_FROM_FRAC(xOffset)));
+
+ if (src_color != transparentColor) {
+ *dstPtr++ = src_color;
+ } else {
+ dstPtr++;
+ }
+
+ } else {
+ // Do a really lame sampling of the potential source pixels
+ int sx = WARP_FROM_FRAC(xOffset);
+ int sy = WARP_FROM_FRAC(yOffset);
+
+ int sx1 = sx;
+ int sy1 = sy;
+
+ int sx2 = sx + sample_x_offset;
+ int sy2 = sy + sample_y_offset;
+
+ // Clip the source sample coords to the bitmap limits, this could
+ // be moved outside the loop if efficiency was important!
+ sx1 = MAX<int>(0, MIN<int>(src_x_limit, sx1));
+ sy1 = MAX<int>(0, MIN<int>(src_y_limit, sy1));
+ sx2 = MAX<int>(0, MIN<int>(src_x_limit, sx2));
+ sy2 = MAX<int>(0, MIN<int>(src_y_limit, sy2));
+
+ // Now that the clipping is done figure out the sampling area
+ int sxc = ((sx2 - sx1) + 1);
+ int syc = ((sy2 - sy1) + 1);
+ int total = (sxc * syc);
+
+ // Sample pixels from the source potential sampling area
+ // For non-linear transformations this could be fairly incorrect!
+ if (total > 1) {
+ int total_R, total_G, total_B;
+
+ const WizRawPixel *samplePtr = (srcPtr + ((sw * sy1) + sx1));
+
+ WizRawPixel first_color = (*(srcPtr + (sw * sy1) + sx1));
+
+ if (first_color != transparentColor) {
+ rawPixelExtractComponents(*samplePtr, total_R, total_G, total_B);
+ ++total;
+ } else {
+ total_R = 0;
+ total_G = 0;
+ total_B = 0;
+ }
+
+ int sampleStep = sw - sxc;
+
+ for (int i = 0; i < syc; i++) {
+ for (int j = 0; j < sxc; j++) {
+ WizRawPixel src_color = *samplePtr++;
+
+ if (src_color != transparentColor) {
+ int r, g, b;
+
+ rawPixelExtractComponents(src_color, r, g, b);
+
+ total_R += r;
+ total_G += g;
+ total_B += b;
+
+ } else {
+ --total;
+ }
+ }
+
+ samplePtr += sampleStep;
+ }
+
+ if (total) {
+ WizRawPixel src_color;
+
+ rawPixelPackComponents(src_color, total_R / total, total_G / total, total_B / total);
+
+ if (transparentColor != src_color) {
+ *dstPtr = src_color;
+ } else {
+ *dstPtr = 4;
+ }
+ }
+
+ } else {
+ WizRawPixel src_color = (*(srcPtr + (sw * sy1) + sx1));
+
+ if (src_color != transparentColor) {
+ *dstPtr = src_color;
+ }
+ }
+
+ dstPtr++;
+ }
+
+ xOffset += xStep;
+ yOffset += yStep;
+ }
+
+ drawSpans++;
+ }
+}
+
+bool Wiz::WARPWIZ_NPt2NPtWarp_CORE(WizSimpleBitmap *dstBitmap, const Common::Point *dstpoints, const WizSimpleBitmap *srcBitmap, const Common::Point *srcpoints, int npoints, int transparentColor, const Common::Rect *optionalClipRect, int32 wizFlags) {
+ WarpWizOneSpanTable *st;
+
+ if ((srcBitmap->bitmapWidth >= WARP_TEXTURE_LIMIT) || (srcBitmap->bitmapHeight >= WARP_TEXTURE_LIMIT)) {
+ error("Source bitmap (%d,%d) too big limit (%d,%d)",
+ srcBitmap->bitmapWidth, srcBitmap->bitmapHeight,
+ WARP_TEXTURE_LIMIT, WARP_TEXTURE_LIMIT);
+ }
+
+ st = WARPWIZ_BuildSpanTable(dstBitmap, srcBitmap, dstpoints, srcpoints, npoints, optionalClipRect);
+
+ if (st) {
+ if (st->drawSpanCount) {
+ if (transparentColor != -1) {
+ if (wizFlags & kWRFAreaSampleDuringWarp) {
+ WARPWIZ_ProcessDrawSpansTransparent_Sampled(
+ dstBitmap, srcBitmap, st->drawSpans, st->drawSpanCount,
+ (WizRawPixel)transparentColor);
+ } else {
+ WARPWIZ_ProcessDrawSpansTransparent(
+ dstBitmap, srcBitmap, st->drawSpans, st->drawSpanCount,
+ (WizRawPixel)transparentColor);
+ }
+ } else {
+ if (wizFlags & kWRFAreaSampleDuringWarp) {
+ WARPWIZ_ProcessDrawSpans_Sampled(
+ dstBitmap, srcBitmap, st->drawSpans, st->drawSpanCount);
+ } else {
+ WARPWIZ_ProcessDrawSpansA(
+ dstBitmap, srcBitmap, st->drawSpans, st->drawSpanCount);
+ }
+ }
+ }
+
+ WARPWIZ_DestroySpanTable(st);
+ return true;
+ }
+
+ warning("Unable to warp bitmap");
+ return false;
+}
+
+bool Wiz::WARPWIZ_NPt2NPtNonClippedWarp(WizSimpleBitmap *dstBitmap, const Common::Point *dstpoints, const WizSimpleBitmap *srcBitmap, const Common::Point *srcpoints, int npoints, int transparentColor) {
+ if (_vm->_game.heversion > 99) {
+ return WARPWIZ_NPt2NPtWarp_CORE(
+ dstBitmap, dstpoints, srcBitmap, srcpoints,
+ npoints, transparentColor, nullptr, 0);
+ } else {
+ WarpWizOneSpanTable *st;
+
+ if ((srcBitmap->bitmapWidth >= WARP_TEXTURE_LIMIT) || (srcBitmap->bitmapHeight >= WARP_TEXTURE_LIMIT)) {
+ error("Source bitmap (%d,%d) too big limit (%d,%d)",
+ srcBitmap->bitmapWidth, srcBitmap->bitmapHeight,
+ WARP_TEXTURE_LIMIT, WARP_TEXTURE_LIMIT);
+ }
+
+ st = WARPWIZ_BuildSpanTable(dstBitmap, srcBitmap, dstpoints, srcpoints, npoints, nullptr);
+
+ if (st) {
+ if (st->drawSpanCount) {
+ if (transparentColor != -1) {
+ WARPWIZ_ProcessDrawSpansTransparent(
+ dstBitmap, srcBitmap, st->drawSpans, st->drawSpanCount,
+ (WizRawPixel)transparentColor);
+ } else {
+ WARPWIZ_ProcessDrawSpansA(dstBitmap, srcBitmap, st->drawSpans, st->drawSpanCount);
+ }
+ }
+
+ WARPWIZ_DestroySpanTable(st);
+ return true;
+
+ } else {
+ warning("Unable to warp bitmap");
+ return false;
+ }
+ }
+}
+
+bool Wiz::WARPWIZ_NPt2NPtClippedWarp(WizSimpleBitmap *dstBitmap, const Common::Point *dstpoints, const WizSimpleBitmap *srcBitmap, const Common::Point *srcpoints, int npoints, int transparentColor, const Common::Rect *optionalClipRect) {
+ if (_vm->_game.heversion > 99) {
+ return WARPWIZ_NPt2NPtWarp_CORE(
+ dstBitmap, dstpoints, srcBitmap, srcpoints,
+ npoints, transparentColor, nullptr, 0);
+ } else {
+ WarpWizOneSpanTable *st;
+
+ if ((srcBitmap->bitmapWidth >= WARP_TEXTURE_LIMIT) || (srcBitmap->bitmapHeight >= WARP_TEXTURE_LIMIT)) {
+ error("Source bitmap (%d,%d) too big limit (%d,%d)",
+ srcBitmap->bitmapWidth, srcBitmap->bitmapHeight,
+ WARP_TEXTURE_LIMIT, WARP_TEXTURE_LIMIT);
+ }
+
+ st = WARPWIZ_BuildSpanTable(dstBitmap, srcBitmap, dstpoints, srcpoints, npoints, optionalClipRect);
+
+ if (st) {
+ if (st->drawSpanCount) {
+ if (transparentColor != -1) {
+ WARPWIZ_ProcessDrawSpansTransparent(
+ dstBitmap, srcBitmap, st->drawSpans, st->drawSpanCount,
+ (WizRawPixel)transparentColor);
+ } else {
+ WARPWIZ_ProcessDrawSpansA(dstBitmap, srcBitmap, st->drawSpans, st->drawSpanCount);
+ }
+ }
+
+ WARPWIZ_DestroySpanTable(st);
+ return true;
+ } else {
+ warning("Unable to warp bitmap");
+ return false;
+ }
+ }
+}
+
+bool Wiz::WARPWIZ_NPt2NPtClippedWarpMixColors(WizSimpleBitmap *dstBitmap, const Common::Point *dstpoints, const WizSimpleBitmap *srcBitmap, const Common::Point *srcpoints, int npoints, int transparentColor, const Common::Rect *optionalClipRect, byte *colorMixTable) {
+ WarpWizOneSpanTable *st;
+
+ if ((srcBitmap->bitmapWidth >= WARP_TEXTURE_LIMIT) || (srcBitmap->bitmapHeight >= WARP_TEXTURE_LIMIT)) {
+ error("Source bitmap (%d,%d) too big limit (%d,%d)",
+ srcBitmap->bitmapWidth, srcBitmap->bitmapHeight,
+ WARP_TEXTURE_LIMIT, WARP_TEXTURE_LIMIT);
+ }
+
+ st = WARPWIZ_BuildSpanTable(
+ dstBitmap, srcBitmap, dstpoints, srcpoints, npoints, optionalClipRect);
+
+ if (st) {
+ if (st->drawSpanCount) {
+ WARPWIZ_ProcessDrawSpansMixColors(
+ dstBitmap, srcBitmap, st->drawSpans, st->drawSpanCount,
+ transparentColor, colorMixTable);
+ }
+
+ WARPWIZ_DestroySpanTable(st);
+ return true;
+ } else {
+ warning("Unable to warp bitmap");
+ return false;
+ }
+}
+
+bool Wiz::WARPWIZ_NPt2NPtNonClippedWarpFiltered(WizSimpleBitmap *dstBitmap, const Common::Point *dstpoints, const WizSimpleBitmap *srcBitmap, const Common::Point *srcpoints, int npoints, int transparentColor, byte *pXmapColorTable, bool bIsHintColor, WizRawPixel hintColor) {
+ WarpWizOneSpanTable *st;
+
+ if ((srcBitmap->bitmapWidth >= WARP_TEXTURE_LIMIT) || (srcBitmap->bitmapHeight >= WARP_TEXTURE_LIMIT)) {
+ error("Source bitmap (%d,%d) too big limit (%d,%d)",
+ srcBitmap->bitmapWidth, srcBitmap->bitmapHeight,
+ WARP_TEXTURE_LIMIT, WARP_TEXTURE_LIMIT);
+ }
+
+ st = WARPWIZ_BuildSpanTable(dstBitmap, srcBitmap, dstpoints, srcpoints, npoints, 0);
+
+ if (st) {
+ if (st->drawSpanCount) {
+ WARPWIZ_ProcessDrawSpansTransparentFiltered(dstBitmap, srcBitmap, st->drawSpans,
+ st->drawSpanCount,(WizRawPixel)transparentColor, pXmapColorTable, bIsHintColor, hintColor);
+ }
+
+ WARPWIZ_DestroySpanTable(st);
+ return true;
+
+ } else {
+ warning("Unable to warp bitmap");
+ return false;
+ }
+}
+
+} // End of namespace Scumm
+
+#endif // ENABLE_HE
diff --git a/engines/scumm/module.mk b/engines/scumm/module.mk
index ea3352c48b0..7f17e752b7e 100644
--- a/engines/scumm/module.mk
+++ b/engines/scumm/module.mk
@@ -143,9 +143,13 @@ ifdef ENABLE_HE
MODULE_OBJS += \
he/animation_he.o \
he/cup_player_he.o \
+ he/gfx_comp/aux_comp.o \
+ he/gfx_comp/mrle_comp.o \
+ he/gfx_comp/trle_comp.o \
he/gfx_primitives_he.o \
he/logic_he.o \
he/palette_he.o \
+ he/polygon_he.o \
he/script_v71he.o \
he/script_v72he.o \
he/script_v80he.o \
@@ -153,6 +157,7 @@ MODULE_OBJS += \
he/script_v100he.o \
he/sprite_he.o \
he/wiz_he.o \
+ he/wizwarp_he.o \
he/localizer.o \
he/logic/baseball2001.o \
he/logic/basketball.o \
diff --git a/engines/scumm/object.cpp b/engines/scumm/object.cpp
index 18bb27a3feb..1d5a53e43ee 100644
--- a/engines/scumm/object.cpp
+++ b/engines/scumm/object.cpp
@@ -569,7 +569,7 @@ int ScummEngine::findObject(int x, int y) {
if (b == 0) {
#ifdef ENABLE_HE
if (_game.heversion >= 71) {
- if (((ScummEngine_v71he *)this)->_wiz->polygonHit(_objs[i].obj_nr, x, y))
+ if (((ScummEngine_v71he *)this)->_wiz->polygonTestForObjectHit(_objs[i].obj_nr, x, y))
return _objs[i].obj_nr;
}
#endif
diff --git a/engines/scumm/palette.cpp b/engines/scumm/palette.cpp
index 0f7e1bd028c..d18c325f4ed 100644
--- a/engines/scumm/palette.cpp
+++ b/engines/scumm/palette.cpp
@@ -585,6 +585,8 @@ void ScummEngine::setDirtyColors(int min, int max) {
_palDirtyMin = min;
if (_palDirtyMax < max)
_palDirtyMax = max;
+
+ _paletteChangedCounter++; // HE99+
}
void ScummEngine::initCycl(const byte *ptr) {
diff --git a/engines/scumm/saveload.cpp b/engines/scumm/saveload.cpp
index e08b9c68daf..e21b4b9c044 100644
--- a/engines/scumm/saveload.cpp
+++ b/engines/scumm/saveload.cpp
@@ -2235,22 +2235,22 @@ void ScummEngine_v70he::saveLoadWithSerializer(Common::Serializer &s) {
#ifdef ENABLE_HE
static void syncWithSerializer(Common::Serializer &s, WizPolygon &wp) {
- s.syncAsSint16LE(wp.vert[0].x, VER(40));
- s.syncAsSint16LE(wp.vert[0].y, VER(40));
- s.syncAsSint16LE(wp.vert[1].x, VER(40));
- s.syncAsSint16LE(wp.vert[1].y, VER(40));
- s.syncAsSint16LE(wp.vert[2].x, VER(40));
- s.syncAsSint16LE(wp.vert[2].y, VER(40));
- s.syncAsSint16LE(wp.vert[3].x, VER(40));
- s.syncAsSint16LE(wp.vert[3].y, VER(40));
- s.syncAsSint16LE(wp.vert[4].x, VER(40));
- s.syncAsSint16LE(wp.vert[4].y, VER(40));
- s.syncAsSint16LE(wp.bound.left, VER(40));
- s.syncAsSint16LE(wp.bound.top, VER(40));
- s.syncAsSint16LE(wp.bound.right, VER(40));
- s.syncAsSint16LE(wp.bound.bottom, VER(40));
+ s.syncAsSint16LE(wp.points[0].x, VER(40));
+ s.syncAsSint16LE(wp.points[0].y, VER(40));
+ s.syncAsSint16LE(wp.points[1].x, VER(40));
+ s.syncAsSint16LE(wp.points[1].y, VER(40));
+ s.syncAsSint16LE(wp.points[2].x, VER(40));
+ s.syncAsSint16LE(wp.points[2].y, VER(40));
+ s.syncAsSint16LE(wp.points[3].x, VER(40));
+ s.syncAsSint16LE(wp.points[3].y, VER(40));
+ s.syncAsSint16LE(wp.points[4].x, VER(40));
+ s.syncAsSint16LE(wp.points[4].y, VER(40));
+ s.syncAsSint16LE(wp.boundingRect.left, VER(40));
+ s.syncAsSint16LE(wp.boundingRect.top, VER(40));
+ s.syncAsSint16LE(wp.boundingRect.right, VER(40));
+ s.syncAsSint16LE(wp.boundingRect.bottom, VER(40));
s.syncAsSint16LE(wp.id, VER(40));
- s.syncAsSint16LE(wp.numVerts, VER(40));
+ s.syncAsSint16LE(wp.numPoints, VER(40));
s.syncAsByte(wp.flag, VER(40));
}
diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h
index 957807a4bbd..714c4651769 100644
--- a/engines/scumm/scumm.h
+++ b/engines/scumm/scumm.h
@@ -1507,6 +1507,7 @@ protected:
int _shadowPaletteSize = 0;
byte _currentPalette[3 * 256];
byte _darkenPalette[3 * 256];
+ int _paletteChangedCounter = 1;
int _palDirtyMin = 0, _palDirtyMax = 0;
Commit: 4f98334ef4b06ffb9a4e42773c7781fbc1f25fdd
https://github.com/scummvm/scummvm/commit/4f98334ef4b06ffb9a4e42773c7781fbc1f25fdd
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Add auxiliary compression routines and more stuff
Changed paths:
engines/scumm/he/gfx_comp/aux_comp.cpp
engines/scumm/he/gfx_primitives_he.cpp
engines/scumm/he/polygon_he.cpp
engines/scumm/he/script_v100he.cpp
engines/scumm/he/script_v72he.cpp
engines/scumm/he/script_v90he.cpp
engines/scumm/he/sprite_he.cpp
engines/scumm/he/wiz_he.cpp
engines/scumm/he/wiz_he.h
diff --git a/engines/scumm/he/gfx_comp/aux_comp.cpp b/engines/scumm/he/gfx_comp/aux_comp.cpp
index 6d6c1eaa9e8..e2c69157e73 100644
--- a/engines/scumm/he/gfx_comp/aux_comp.cpp
+++ b/engines/scumm/he/gfx_comp/aux_comp.cpp
@@ -28,6 +28,1419 @@
namespace Scumm {
+#define WRLE_QUICK_CACHE (0)
+#define WRLE_CAN_STOP_EARLY (0)
+#define TRACK_COMPRESSION_STATS (0)
+
+#define WRLE_BIT_SIZE(zp) (1 << (8-(zp)))
+
+#define WRLE_TINY_RUN_BITS 0x01
+#define WRLE_TINY_RUN_BIT_COUNT 1
+#define WRLE_TINY_RUN_COUNT_BITS 2
+#define WRLE_TINY_RUN_MIN_COUNT 3
+#define WRLE_TINY_RUN_BITS_OVERHEAD ((WRLE_TINY_RUN_BIT_COUNT)+(WRLE_TINY_RUN_COUNT_BITS))
+#define WRLE_TINY_RUN_MAX_COUNT ((WRLE_TINY_RUN_MIN_COUNT) + ((1 << (WRLE_TINY_RUN_COUNT_BITS)) - 1))
+
+#define WRLE_TRUN_BITS 0x00
+#define WRLE_TRUN_BIT_COUNT 2
+#define WRLE_SMALL_TRUN_SIZE (WRLE_BIT_SIZE(WRLE_TRUN_BIT_COUNT)-1)
+#define WRLE_LARGE_TRUN_SIZE 65536
+
+#define WRLE_SINGLE_COLOR_BITS 0x02
+#define WRLE_SINGLE_COLOR_BIT_COUNT 3
+
+#define WRLE_LESS_RUN_BITS 0x06
+#define WRLE_LESS_RUN_BIT_COUNT 3
+#define WRLE_LESS_SMALL_RUN_SIZE (WRLE_BIT_SIZE(WRLE_LESS_RUN_BIT_COUNT)-1)
+#define WRLE_LESS_LARGE_RUN_SIZE 256
+
+#define AUX_IGNORE_ZPLANE_BITS(_dst, _mask, _count) \
+ { \
+ int _counter; \
+ for (_counter = 0; _counter < _count; _counter++) { \
+ if (0 == (_mask >>= 1)) { \
+ _mask = 0x80; \
+ _dst++; \
+ } \
+ } \
+ }
+
+#define AUX_SET_ZPLANE_BITS(_dst, _mask, _count) \
+ { \
+ int _counter; \
+ for (_counter = 0; _counter < _count; _counter++) { \
+ *(_dst) |= _mask; \
+ if (0 == (_mask >>= 1)) { \
+ _mask = 0x80; \
+ _dst++; \
+ } \
+ } \
+ }
+
+#define AUX_CLEAR_ZPLANE_BITS(_dst, _mask, _count) \
+ { \
+ int _counter; \
+ for (_counter = 0; _counter < _count; _counter++) { \
+ *(_dst) &= ~_mask; \
+ if (0 == (_mask >>= 1)) { \
+ _mask = 0x80; \
+ _dst++; \
+ } \
+ } \
+ }
+
+
+void Wiz::auxWRLEUncompressPixelStream(WizRawPixel *destStream, const byte *singleColorTable, const byte *streamData, int streamSize, const WizRawPixel *conversionTable) {
+ int value, runCount;
+
+ while (streamSize > 0) {
+ value = *streamData++;
+
+ if (value & 0x01) { // xxxxxxx1
+ // Tiny run handler
+ runCount = WRLE_TINY_RUN_MIN_COUNT + ((value >> 1) & 0x03);
+ streamSize -= runCount;
+
+ memset8BppConversion(
+ destStream, *(singleColorTable + (value >> 3)),
+ runCount, conversionTable);
+
+ destStream += runCount;
+
+ } else if (!(value & 0x02)) { // xxxxxx00
+ // Transparent run
+ runCount = value >> 2;
+ if (0 == runCount) {
+ runCount = 1 + (*streamData + 256 * *(streamData + 1));
+ streamData += 2;
+ }
+
+ streamSize -= runCount;
+ destStream += runCount;
+
+ } else if (value & 0x04) { // xxxxx110 ?
+ // Run of some color
+ value >>= 3;
+ if (0 == value) {
+ runCount = 1 + *streamData++;
+ } else {
+ runCount = value;
+ }
+
+ streamSize -= runCount;
+
+ memset8BppConversion(
+ destStream, *((byte *)streamData),
+ runCount, conversionTable);
+
+ streamData += sizeof(byte);
+ destStream += runCount;
+
+ } else { // xxxxx010
+ // Single color!
+ *destStream++ = convert8BppToRawPixel(*(singleColorTable + (value >> 3)), conversionTable);
+ streamSize--;
+ }
+ }
+}
+
+void Wiz::auxWRLEUncompressAndCopyFromStreamOffset(WizRawPixel *destStream, const byte *singleColorTable, const byte *streamData, int streamSize, byte copyFromColor, int streamOffset, const WizRawPixel *conversionTable) {
+ int value, runCount;
+ byte color;
+
+ while (streamSize > 0) {
+ value = *streamData++;
+
+ if (value & 0x01) { // xxxxxxx1
+ // Tiny run handler
+ runCount = WRLE_TINY_RUN_MIN_COUNT + ((value >> 1) & 0x03);
+ streamSize -= runCount;
+
+ color = *(singleColorTable + (value >> 3));
+
+ if (copyFromColor != color) {
+ memset8BppConversion(
+ destStream, color, runCount, conversionTable);
+ } else {
+ memcpy(
+ destStream, destStream + streamOffset,
+ (runCount * sizeof(WizRawPixel)));
+ }
+
+ destStream += runCount;
+
+ } else if (!(value & 0x02)) { // xxxxxx00
+ // Transparent run
+ runCount = value >> 2;
+ if (runCount == 0) {
+ runCount = 1 + (*streamData + 256 * *(streamData + 1));
+ streamData += 2;
+ }
+
+ streamSize -= runCount;
+ destStream += runCount;
+
+ } else if (value & 0x04) { // xxxxx110 ?
+ // Run of some color
+ value >>= 3;
+ if (value == 0) {
+ runCount = 1 + *streamData++;
+ } else {
+ runCount = value;
+ }
+
+ streamSize -= runCount;
+
+ color = *((byte *)streamData);
+
+ if (color != copyFromColor) {
+ memset8BppConversion(
+ destStream, color,
+ runCount, conversionTable);
+ } else {
+ memcpy(
+ destStream, destStream + streamOffset,
+ (runCount * sizeof(WizRawPixel)));
+ }
+
+ streamData += sizeof(byte);
+ destStream += runCount;
+
+ } else { // xxxxx010
+ // Single color!
+ color = *(singleColorTable + (value >> 3));
+
+ if (color != copyFromColor) {
+ *destStream++ = convert8BppToRawPixel(color, conversionTable);
+ } else {
+ *destStream++ = *(destStream + streamOffset);
+ }
+
+ streamSize--;
+ }
+ }
+}
+
+void Wiz::auxDecompSRLEStream(WizRawPixel *destStream, const WizRawPixel *backgroundStream, const byte *singleColorTable, const byte *streamData, int streamSize, const WizRawPixel *conversionTable) {
+ int value, runCount;
+
+ while (streamSize > 0) {
+ value = *streamData++;
+
+ if (value & 0x01) { // xxxxxxx1
+ // Transparent run
+ runCount = value >> 1;
+ if (runCount == 0) {
+ runCount = 1 + (*streamData + 256 * *(streamData + 1));
+ streamData += 2;
+ }
+
+ streamSize -= runCount;
+ backgroundStream += runCount;
+ destStream += runCount;
+
+ } else if (!(value & 0x02)) { // xxxxxx00
+ // Background run
+ runCount = 1 + (value >> 2);
+ streamSize -= runCount;
+ memcpy(destStream, backgroundStream, runCount * sizeof(WizRawPixel));
+ backgroundStream += runCount;
+ destStream += runCount;
+
+ } else if (value & 0x04) { // xxxxx110
+ // Run of some color
+ value >>= 3;
+ if (value == 0) {
+ runCount = 1 + *streamData++;
+ } else {
+ runCount = value;
+ }
+
+ streamSize -= runCount;
+
+ memset8BppConversion(
+ destStream, *streamData++, runCount,
+ conversionTable);
+
+ backgroundStream += runCount;
+ destStream += runCount;
+
+ } else { // xxxxx010
+ // Single color!
+
+ *destStream++ = convert8BppToRawPixel(*(singleColorTable + (value >> 3)), conversionTable);
+ backgroundStream++;
+ streamSize--;
+ }
+ }
+}
+
+void Wiz::auxDecompDRLEImage(WizRawPixel *foregroundBufferPtr, WizRawPixel *backgroundBufferPtr, byte *compData, int bufferWidth, int bufferHeight, int x, int y, int width, int height, Common::Rect *clipRectPtr, const WizRawPixel *conversionTable) {
+ Common::Rect sourceRect, destRect, clipRect, workRect;
+
+ sourceRect.left = 0;
+ sourceRect.top = 0;
+ sourceRect.right = width - 1;
+ sourceRect.bottom = height - 1;
+
+ destRect.left = x;
+ destRect.top = y;
+ destRect.right = x + width - 1;
+ destRect.bottom = y + height - 1;
+
+ // Custom clip rect...
+ if (!clipRectPtr) {
+ clipRect = *clipRectPtr;
+ workRect.left = 0;
+ workRect.top = 0;
+ workRect.right = bufferWidth - 1;
+ workRect.bottom = bufferHeight - 1;
+
+ if (!findRectOverlap(&clipRect, &workRect)) {
+ return;
+ }
+ } else {
+ clipRect.left = 0;
+ clipRect.top = 0;
+ clipRect.right = bufferWidth - 1;
+ clipRect.bottom = bufferHeight - 1;
+ }
+
+ // Clip the source & dest coords to the clipping rectangle...
+ clipRectCoords(&sourceRect, &destRect, &clipRect);
+
+ if (destRect.right < destRect.left) {
+ return;
+ }
+
+ if (destRect.bottom < destRect.top) {
+ return;
+ }
+
+ if (sourceRect.right < sourceRect.left) {
+ return;
+ }
+
+ if (sourceRect.bottom < sourceRect.top) {
+ return;
+ }
+
+ auxDecompDRLEPrim(
+ foregroundBufferPtr, backgroundBufferPtr, bufferWidth,
+ &destRect, compData, &sourceRect, conversionTable);
+}
+
+void Wiz::auxDecompDRLEPrim(WizRawPixel *foregroundBufferPtr, WizRawPixel *backgroundBufferPtr, int bufferWidth, Common::Rect *destRect, byte *compData, Common::Rect *sourceRect, const WizRawPixel *conversionTable) {
+ int decompWidth, decompHeight, counter, sX1, dX1, dX2, lineSize;
+
+ // General setup...
+ sX1 = sourceRect->left;
+ dX1 = destRect->left;
+ dX2 = destRect->right;
+ decompWidth = sourceRect->right - sourceRect->left + 1;
+ decompHeight = sourceRect->bottom - sourceRect->top + 1;
+
+ // Quickly skip down to the lines to be compressed & dest position...
+ foregroundBufferPtr += bufferWidth * destRect->top + dX1;
+ backgroundBufferPtr += bufferWidth * destRect->top + dX1;
+
+ for (counter = sourceRect->top; counter > 0; counter--) {
+ compData += READ_LE_UINT16(compData) + 2;
+ }
+
+ // Decompress all the lines that are visible!!!!
+ while (decompHeight-- > 0) {
+ lineSize = READ_LE_UINT16(compData);
+
+ if (lineSize != 0) {
+ auxDecompDRLEStream(
+ foregroundBufferPtr, compData + 2, backgroundBufferPtr,
+ sX1, decompWidth, conversionTable);
+
+ compData += lineSize + 2;
+ foregroundBufferPtr += bufferWidth;
+ backgroundBufferPtr += bufferWidth;
+
+ } else {
+ // Handle a completely transparent line!
+ compData += 2;
+ foregroundBufferPtr += bufferWidth;
+ backgroundBufferPtr += bufferWidth;
+ }
+ }
+}
+
+void Wiz::auxDecompTRLEImage(WizRawPixel *bufferPtr, byte *compData, int bufferWidth, int bufferHeight, int x, int y, int width, int height, Common::Rect *clipRectPtr, const WizRawPixel *conversionTable) {
+ Common::Rect sourceRect, destRect, clipRect, workRect;
+
+ sourceRect.left = 0;
+ sourceRect.top = 0;
+ sourceRect.right = width - 1;
+ sourceRect.bottom = height - 1;
+
+ destRect.left = x;
+ destRect.top = y;
+ destRect.right = x + width - 1;
+ destRect.bottom = y + height - 1;
+
+ // Custom clip rect...
+ if (!clipRectPtr) {
+ clipRect = *clipRectPtr;
+ workRect.left = 0;
+ workRect.top = 0;
+ workRect.right = bufferWidth - 1;
+ workRect.bottom = bufferHeight - 1;
+ if (!findRectOverlap(&clipRect, &workRect)) {
+ return;
+ }
+ } else {
+ clipRect.left = 0;
+ clipRect.top = 0;
+ clipRect.right = bufferWidth - 1;
+ clipRect.bottom = bufferHeight - 1;
+ }
+
+ // Clip the source & dest coords to the clipping rectangle...
+ clipRectCoords(&sourceRect, &destRect, &clipRect);
+
+ if (destRect.right < destRect.left) {
+ return;
+ }
+
+ if (destRect.bottom < destRect.top) {
+ return;
+ }
+
+ if (sourceRect.right < sourceRect.left) {
+ return;
+ }
+
+ if (sourceRect.bottom < sourceRect.top) {
+ return;
+ }
+
+ // Call the primitive image renderer...
+ auxDecompTRLEPrim(
+ bufferPtr, bufferWidth, &destRect, compData,
+ &sourceRect, conversionTable);
+}
+
+void Wiz::auxDecompTRLEPrim(WizRawPixel *bufferPtr, int bufferWidth, Common::Rect *destRect, byte *compData, Common::Rect *sourceRect, const WizRawPixel *conversionTable) {
+ int decompWidth, decompHeight, counter, sX1, dX1, dX2, lineSize;
+
+ // General setup...
+ sX1 = sourceRect->left;
+ dX1 = destRect->left;
+ dX2 = destRect->right;
+ decompWidth = sourceRect->right - sourceRect->left + 1;
+ decompHeight = sourceRect->bottom - sourceRect->top + 1;
+
+ // Quickly skip down to the lines to be compressed & dest position...
+ bufferPtr += bufferWidth * destRect->top + dX1;
+ for (counter = sourceRect->top; counter > 0; counter--) {
+ compData += READ_LE_UINT16(compData) + 2;
+ }
+
+ // Decompress all the lines that are visible!!!!
+ while (decompHeight-- > 0) {
+ lineSize = READ_LE_UINT16(compData);
+
+ if (lineSize != 0) {
+ auxDecompTRLEStream(
+ bufferPtr, compData + 2, sX1, decompWidth, conversionTable);
+
+ compData += lineSize + 2;
+ bufferPtr += bufferWidth;
+ } else {
+ // Handle a completely transparent line!
+ compData += 2;
+ bufferPtr += bufferWidth;
+ }
+ }
+}
+
+
+void Wiz::auxDrawZplaneFromTRLEImage(byte *zplanePtr, byte *compData, int zplanePixelWidth, int zplanePixelHeight, int x, int y, int width, int height, Common::Rect *clipRectPtr, int transOp, int solidOp) {
+ Common::Rect sourceRect, destRect, clipRect, workRect;
+
+ sourceRect.left = 0;
+ sourceRect.top = 0;
+ sourceRect.right = width - 1;
+ sourceRect.bottom = height - 1;
+
+ destRect.left = x;
+ destRect.top = y;
+ destRect.right = x + width - 1;
+ destRect.bottom = y + height - 1;
+
+ // Custom clip rect...
+ if (!clipRectPtr) {
+ clipRect = *clipRectPtr;
+
+ workRect.left = 0;
+ workRect.top = 0;
+ workRect.right = zplanePixelWidth - 1;
+ workRect.bottom = zplanePixelHeight - 1;
+
+ if (!findRectOverlap(&clipRect, &workRect)) {
+ return;
+ }
+ } else {
+ clipRect.left = 0;
+ clipRect.top = 0;
+ clipRect.right = zplanePixelWidth - 1;
+ clipRect.bottom = zplanePixelHeight - 1;
+ }
+
+ // Clip the source & dest coords to the clipping rectangle...
+ clipRectCoords(&sourceRect, &destRect, &clipRect);
+
+ if (destRect.right < destRect.left) {
+ return;
+ }
+
+ if (destRect.bottom < destRect.top) {
+ return;
+ }
+
+ if (sourceRect.right < sourceRect.left) {
+ return;
+ }
+
+ if (sourceRect.bottom < sourceRect.top) {
+ return;
+ }
+
+ // Call the primitive image renderer...
+ auxDrawZplaneFromTRLEPrim(
+ zplanePtr, zplanePixelWidth, &destRect, compData, &sourceRect, transOp, solidOp);
+}
+
+void Wiz::auxDrawZplaneFromTRLEPrim(byte *zplanePtr, int zplanePixelWidth, Common::Rect *destRect, byte *compData, Common::Rect *sourceRect, int transOp, int solidOp) {
+ int decompWidth, decompHeight, counter, sX1, dX1, dX2, lineSize, mask, zplaneWidth;
+
+ // General setup...
+ sX1 = sourceRect->left;
+ dX1 = destRect->left;
+ dX2 = destRect->right;
+ decompWidth = sourceRect->right - sourceRect->left + 1;
+ decompHeight = sourceRect->bottom - sourceRect->top + 1;
+
+ // Quickly skip down to the lines to be compressed & dest position...
+ zplaneWidth = zplanePixelWidth / 8;
+ zplanePtr += zplaneWidth * destRect->top + (dX1 / 8);
+ mask = 1 << (7 - (dX1 % 8));
+
+ for (counter = sourceRect->top; counter > 0; counter--) {
+ compData += READ_LE_UINT16(compData) + 2;
+ }
+
+ // Decompress all the lines that are visible!!!!
+ while (decompHeight-- > 0) {
+ lineSize = READ_LE_UINT16(compData);
+
+ if (lineSize != 0) {
+ auxZplaneFromTRLEStream(
+ zplanePtr, compData + 2, sX1, decompWidth, mask, transOp, solidOp);
+
+ compData += lineSize + 2;
+ zplanePtr += zplaneWidth;
+
+ } else {
+ // Handle a completely transparent line!
+ compData += 2;
+ zplanePtr += zplaneWidth;
+ }
+ }
+}
+
+void Wiz::auxDecompRemappedTRLEImage(WizRawPixel *bufferPtr, byte *compData, int bufferWidth, int bufferHeight, int x, int y, int width, int height, Common::Rect *clipRectPtr, byte *remapTable, const WizRawPixel *conversionTable) {
+ Common::Rect sourceRect, destRect, clipRect, workRect;
+
+ sourceRect.left = 0;
+ sourceRect.top = 0;
+ sourceRect.right = width - 1;
+ sourceRect.bottom = height - 1;
+
+ destRect.left = x;
+ destRect.top = y;
+ destRect.right = x + width - 1;
+ destRect.bottom = y + height - 1;
+
+ // Custom clip rect...
+ if (!clipRectPtr) {
+ clipRect = *clipRectPtr;
+
+ workRect.left = 0;
+ workRect.top = 0;
+ workRect.right = bufferWidth - 1;
+ workRect.bottom = bufferHeight - 1;
+
+ if (!findRectOverlap(&clipRect, &workRect)) {
+ return;
+ }
+ } else {
+ clipRect.left = 0;
+ clipRect.top = 0;
+ clipRect.right = bufferWidth - 1;
+ clipRect.bottom = bufferHeight - 1;
+ }
+
+ // Clip the source & dest coords to the clipping rectangle...
+ clipRectCoords(&sourceRect, &destRect, &clipRect);
+
+ if (destRect.right < destRect.left) {
+ return;
+ }
+
+ if (destRect.bottom < destRect.top) {
+ return;
+ }
+
+ if (sourceRect.right < sourceRect.left) {
+ return;
+ }
+
+ if (sourceRect.bottom < sourceRect.top) {
+ return;
+ }
+
+ // Call the primitive image renderer...
+ auxDecompRemappedTRLEPrim(
+ bufferPtr, bufferWidth, &destRect, compData, &sourceRect, remapTable,
+ conversionTable);
+}
+
+void Wiz::auxDecompRemappedTRLEPrim(WizRawPixel *bufferPtr, int bufferWidth, Common::Rect *destRect, byte *compData, Common::Rect *sourceRect, byte *remapTable, const WizRawPixel *conversionTable) {
+ int decompWidth, decompHeight, counter, sX1, dX1, dX2, lineSize;
+
+ // General setup...
+ sX1 = sourceRect->left;
+ dX1 = destRect->left;
+ dX2 = destRect->right;
+ decompWidth = sourceRect->right - sourceRect->left + 1;
+ decompHeight = sourceRect->bottom - sourceRect->top + 1;
+
+ // Quickly skip down to the lines to be compressed & dest position...
+ bufferPtr += bufferWidth * destRect->top + dX1;
+ for (counter = sourceRect->top; counter > 0; counter--) {
+ compData += READ_LE_UINT16(compData) + 2;
+ }
+
+ // Decompress all the lines that are visible!!!!
+ while (decompHeight-- > 0) {
+ lineSize = READ_LE_UINT16(compData);
+
+ if (lineSize != 0) {
+ auxDecompRemappedTRLEStream(
+ bufferPtr, compData + 2, sX1, decompWidth,
+ remapTable, conversionTable);
+
+ compData += lineSize + 2;
+ bufferPtr += bufferWidth;
+ } else {
+ // Handle a completely transparent line!
+ compData += 2;
+ bufferPtr += bufferWidth;
+ }
+ }
+}
+
+bool Wiz::auxHitTestTRLEXPos(byte *dataStream, int skipAmount) {
+ int runCount;
+
+ // Decompress bytes to do simple clipping...
+ while (skipAmount > 0) {
+
+ if ((runCount = *dataStream++) & 1) {
+
+ // Handle the transparent color...
+ runCount >>= 1;
+ if (runCount > skipAmount) {
+ return false;
+ } else {
+ skipAmount -= runCount;
+ }
+
+ } else if (runCount & 2) {
+
+ // Handle a run of color...
+ runCount = (runCount >> 2) + 1;
+ if (runCount > skipAmount) {
+ return true;
+ } else {
+ skipAmount -= runCount;
+ dataStream++;
+ }
+
+ } else {
+ // Handle a literal run of pixels...
+ runCount = (runCount >> 2) + 1;
+ if (runCount > skipAmount) {
+ return true;
+ } else {
+ skipAmount -= runCount;
+ dataStream += runCount;
+ }
+ }
+ }
+
+ // Transparent or not?
+ runCount = *dataStream++;
+
+ if (runCount & 1) {
+ return false;
+ } else {
+ return true;
+ }
+}
+
+bool Wiz::auxHitTestTRLEImageRelPos(byte *compData, int x, int y, int width, int height) {
+ int counter;
+
+ // Quickly reject points outside the image boundry.
+ if ((x < 0) || (width <= x) || (y < 0) || (height <= y)) {
+ return false;
+ }
+
+ // Quickly skip down to the lines to be compressed & dest position...
+ for (counter = 0; counter < y; counter++) {
+ compData += READ_LE_UINT16(compData) + 2;
+ }
+
+ if (READ_LE_UINT16(compData) != 0) {
+ return auxHitTestTRLEXPos(compData + 2, x);
+ } else {
+ return false;
+ }
+}
+
+bool Wiz::auxPixelHitTestTRLEXPos(byte *dataStream, int skipAmount, int transparentValue) {
+ int runCount;
+
+ // Decompress bytes to do simple clipping...
+ while (skipAmount > 0) {
+ if ((runCount = *dataStream++) & 1) {
+ // Handle the transparent color...
+ runCount >>= 1;
+
+ if (runCount > skipAmount) {
+ return transparentValue;
+ } else {
+ skipAmount -= runCount;
+ }
+
+ } else if (runCount & 2) {
+ // Handle a run of color...
+ runCount = (runCount >> 2) + 1;
+
+ if (runCount > skipAmount) {
+ return *dataStream;
+ } else {
+ skipAmount -= runCount;
+ dataStream++;
+ }
+ } else {
+ // Handle a literal run of pixels...
+ runCount = (runCount >> 2) + 1;
+
+ if (runCount > skipAmount) {
+ runCount -= skipAmount;
+ dataStream += skipAmount;
+ return *dataStream;
+ } else {
+ skipAmount -= runCount;
+ dataStream += runCount;
+ }
+ }
+ }
+
+ // Really decompress to the dest buffer...
+ runCount = *dataStream++;
+
+ if (runCount & 1) {
+ return transparentValue;
+ }
+
+ return *dataStream;
+}
+
+int Wiz::auxPixelHitTestTRLEImageRelPos(byte *compData, int x, int y, int width, int height, int transparentValue) {
+ int counter;
+
+ // Quickly reject points outside the image boundry.
+ if ((x < 0) || (width <= x) || (y < 0) || (height <= y)) {
+ return transparentValue;
+ }
+
+ // Quickly skip down to the lines to be compressed & dest position...
+ for (counter = 0; counter < y; counter++) {
+ compData += READ_LE_UINT16(compData) + 2;
+ }
+
+ if (READ_LE_UINT16(compData) != 0) {
+ return auxPixelHitTestTRLEXPos(compData + 2, x, transparentValue);
+ } else {
+ return transparentValue;
+ }
+}
+
+void Wiz::auxDecompMixColorsTRLEImage(WizRawPixel *bufferPtr, byte *compData, int bufferWidth, int bufferHeight, int x, int y, int width, int height, Common::Rect *clipRectPtr, byte *coloMixTable, const WizRawPixel *conversionTable) {
+ Common::Rect sourceRect, destRect, clipRect, workRect;
+
+ sourceRect.left = 0;
+ sourceRect.top = 0;
+ sourceRect.right = width - 1;
+ sourceRect.bottom = height - 1;
+
+ destRect.left = x;
+ destRect.top = y;
+ destRect.right = x + width - 1;
+ destRect.bottom = y + height - 1;
+
+ // Custom clip rect...
+ if (!clipRectPtr) {
+ clipRect = *clipRectPtr;
+
+ workRect.left = 0;
+ workRect.top = 0;
+ workRect.right = bufferWidth - 1;
+ workRect.bottom = bufferHeight - 1;
+
+ if (!findRectOverlap(&clipRect, &workRect)) {
+ return;
+ }
+ } else {
+ clipRect.left = 0;
+ clipRect.top = 0;
+ clipRect.right = bufferWidth - 1;
+ clipRect.bottom = bufferHeight - 1;
+ }
+
+ // Clip the source & dest coords to the clipping rectangle...
+ clipRectCoords(&sourceRect, &destRect, &clipRect);
+
+ if (destRect.right < destRect.left) {
+ return;
+ }
+
+ if (destRect.bottom < destRect.top) {
+ return;
+ }
+
+ if (sourceRect.right < sourceRect.left) {
+ return;
+ }
+
+ if (sourceRect.bottom < sourceRect.top) {
+ return;
+ }
+
+ // Call the primitive image renderer...
+ auxDecompMixColorsTRLEPrim(
+ bufferPtr, bufferWidth, &destRect, compData, &sourceRect, coloMixTable,
+ conversionTable);
+}
+
+void Wiz::auxDecompMixColorsTRLEPrim(WizRawPixel *bufferPtr, int bufferWidth, Common::Rect *destRect, byte *compData, Common::Rect *sourceRect, byte *coloMixTable, const WizRawPixel *conversionTable) {
+ int decompWidth, decompHeight, counter, sX1, dX1, dX2, lineSize;
+
+ // General setup...
+ sX1 = sourceRect->left;
+ dX1 = destRect->left;
+ dX2 = destRect->right;
+ decompWidth = sourceRect->right - sourceRect->left + 1;
+ decompHeight = sourceRect->bottom - sourceRect->top + 1;
+
+ // Quickly skip down to the lines to be compressed & dest position...
+ bufferPtr += bufferWidth * destRect->top + dX1;
+ for (counter = sourceRect->top; counter > 0; counter--) {
+ compData += READ_LE_UINT16(compData) + 2;
+ }
+
+ // Decompress all the lines that are visible!!!!
+ while (decompHeight-- > 0) {
+ lineSize = READ_LE_UINT16(compData);
+
+ if (lineSize != 0) {
+ auxColorMixDecompressLine(
+ bufferPtr, compData + 2, sX1, decompWidth, coloMixTable,
+ conversionTable);
+
+ compData += lineSize + 2;
+ bufferPtr += bufferWidth;
+
+ } else {
+ // Handle a completely transparent line!
+ compData += 2;
+ bufferPtr += bufferWidth;
+ }
+ }
+}
+
+void Wiz::auxDecompDRLEStream(WizRawPixel *destPtr, byte *dataStream, WizRawPixel *backgroundPtr, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
+ int runCount;
+
+ // Decompress bytes to do simple clipping...
+ while (skipAmount > 0) {
+ if ((runCount = *dataStream++) & 1) {
+ // Handle the transparent color...
+ runCount >>= 1;
+ if (runCount > skipAmount) {
+ runCount -= skipAmount;
+ goto DoTransparentRun;
+ } else {
+ skipAmount -= runCount;
+ }
+
+ } else if (runCount & 2) {
+ // Handle a run of color...
+ runCount = (runCount >> 2) + 1;
+ if (runCount > skipAmount) {
+ runCount -= skipAmount;
+ goto WriteRunData;
+ } else {
+ skipAmount -= runCount;
+ dataStream++;
+ }
+
+ } else {
+ // Handle a background run of pixels...
+ runCount = (runCount >> 2) + 1;
+ if (runCount > skipAmount) {
+ runCount -= skipAmount;
+ dataStream += skipAmount;
+ goto WriteBackgroundData;
+ } else {
+ skipAmount -= runCount;
+ dataStream += runCount;
+ }
+ }
+ }
+
+ // Really decompress to the dest buffer...
+ while (decompAmount > 0) {
+ runCount = *dataStream++;
+
+ if (runCount & 1) {
+ /* xxxxxxx1 */
+ runCount >>= 1;
+
+ DoTransparentRun:
+ destPtr += runCount;
+ backgroundPtr += runCount;
+ decompAmount -= runCount;
+
+ } else if (runCount & 2) {
+ /* xxxxxx10 */
+ runCount = (runCount >> 2) + 1;
+
+ WriteRunData:
+ decompAmount -= runCount;
+ if (decompAmount >= 0) {
+ memset8BppConversion(destPtr, *dataStream++, runCount, conversionTable);
+ destPtr += runCount;
+ backgroundPtr += runCount;
+ } else {
+ runCount += decompAmount;
+ memset8BppConversion(destPtr, *dataStream++, runCount, conversionTable);
+ }
+ } else {
+ /* xxxxxx00 */
+ runCount = (runCount >> 2) + 1;
+ WriteBackgroundData:
+ decompAmount -= runCount;
+ if (decompAmount >= 0) {
+ memcpy(destPtr, backgroundPtr, runCount * sizeof(WizRawPixel));
+
+ destPtr += runCount;
+ backgroundPtr += runCount;
+ } else {
+ runCount += decompAmount;
+ memcpy(destPtr, backgroundPtr, runCount * sizeof(WizRawPixel));
+
+ }
+ }
+ }
+}
+
+void Wiz::auxDecompTRLEStream(WizRawPixel *destPtr, byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
+ int runCount;
+
+ // Decompress bytes to do simple clipping...
+ while (skipAmount > 0) {
+ if ((runCount = *dataStream++) & 1) {
+ // Handle the transparent color...
+ runCount >>= 1;
+ if (runCount > skipAmount) {
+ runCount -= skipAmount;
+ goto DoTransparentRun;
+ } else {
+ skipAmount -= runCount;
+ }
+
+ } else if (runCount & 2) {
+ // Handle a run of color...
+ runCount = (runCount >> 2) + 1;
+ if (runCount > skipAmount) {
+ runCount -= skipAmount;
+ goto WriteRunData;
+ } else {
+ skipAmount -= runCount;
+ dataStream++;
+ }
+
+ } else {
+ // Handle a literal run of pixels...
+ runCount = (runCount >> 2) + 1;
+ if (runCount > skipAmount) {
+ runCount -= skipAmount;
+ dataStream += skipAmount;
+ goto WriteLiteralData;
+ } else {
+ skipAmount -= runCount;
+ dataStream += runCount;
+ }
+ }
+ }
+
+ // Really decompress to the dest buffer...
+ while (decompAmount > 0) {
+ runCount = *dataStream++;
+
+ if (runCount & 1) {
+ /* xxxxxxx1 */
+ runCount >>= 1;
+
+ DoTransparentRun:
+ destPtr += runCount;
+ decompAmount -= runCount;
+
+ } else if (runCount & 2) {
+ /* xxxxxx10 */
+ runCount = (runCount >> 2) + 1;
+
+ WriteRunData:
+ decompAmount -= runCount;
+ if (decompAmount >= 0) {
+ memset8BppConversion(destPtr, *dataStream++, runCount, conversionTable);
+ destPtr += runCount;
+ } else {
+ runCount += decompAmount;
+ memset8BppConversion(destPtr, *dataStream, runCount, conversionTable);
+ }
+
+ } else {
+ /* xxxxxx00 */
+ runCount = (runCount >> 2) + 1;
+
+ WriteLiteralData:
+ decompAmount -= runCount;
+ if (decompAmount >= 0) {
+ memcpy8BppConversion(destPtr, dataStream, runCount, conversionTable);
+ dataStream += runCount;
+ destPtr += runCount;
+ } else {
+ runCount += decompAmount;
+ memcpy8BppConversion(destPtr, dataStream, runCount, conversionTable);
+ }
+ }
+ }
+}
+
+void Wiz::auxDecompRemappedTRLEStream(WizRawPixel *destPtr, byte *dataStream, int skipAmount, int decompAmount, byte *remapTable, const WizRawPixel *conversionTable) {
+ int runCount;
+
+ // Decompress bytes to do simple clipping...
+ while (skipAmount > 0) {
+ if ((runCount = *dataStream++) & 1) {
+ // Handle the transparent color...
+ runCount >>= 1;
+ if (runCount > skipAmount) {
+ runCount -= skipAmount;
+ goto DoTransparentRun;
+ } else {
+ skipAmount -= runCount;
+ }
+
+ } else if (runCount & 2) {
+ // Handle a run of color...
+ runCount = (runCount >> 2) + 1;
+ if (runCount > skipAmount) {
+ runCount -= skipAmount;
+ goto WriteRunData;
+ } else {
+ skipAmount -= runCount;
+ dataStream++;
+ }
+
+ } else {
+ // Handle a literal run of pixels...
+ runCount = (runCount >> 2) + 1;
+ if (runCount > skipAmount) {
+ runCount -= skipAmount;
+ dataStream += skipAmount;
+ goto WriteLiteralData;
+ } else {
+ skipAmount -= runCount;
+ dataStream += runCount;
+ }
+ }
+ }
+
+ // Really decompress to the dest buffer...
+ while (decompAmount > 0) {
+ runCount = *dataStream++;
+
+ if (runCount & 1) {
+ /* xxxxxxx1 */
+ runCount >>= 1;
+ DoTransparentRun:
+
+ destPtr += runCount;
+ decompAmount -= runCount;
+
+ } else if (runCount & 2) {
+ /* xxxxxx10 */
+ runCount = (runCount >> 2) + 1;
+ WriteRunData:
+ decompAmount -= runCount;
+ if (decompAmount >= 0) {
+ memset8BppConversion(destPtr, *(remapTable + *dataStream++), runCount, conversionTable);
+ destPtr += runCount;
+ } else {
+ runCount += decompAmount;
+ memset8BppConversion(destPtr, *(remapTable + *dataStream), runCount, conversionTable);
+ }
+
+ } else {
+
+ /* xxxxxx00 */
+ runCount = (runCount >> 2) + 1;
+ WriteLiteralData:
+ decompAmount -= runCount;
+ if (decompAmount >= 0) {
+ auxRemappedMemcpy(destPtr, dataStream, runCount, remapTable, conversionTable);
+ dataStream += runCount;
+ destPtr += runCount;
+ } else {
+ runCount += decompAmount;
+ auxRemappedMemcpy(destPtr, dataStream, runCount, remapTable, conversionTable);
+ }
+ }
+ }
+}
+
+
+void Wiz::auxZplaneFromTRLEStream(byte *destPtr, byte *dataStream, int skipAmount, int decompAmount, int mask, int transOp, int solidOp) {
+ int runCount;
+
+ // Decompress bytes to do simple clipping...
+ while (skipAmount > 0) {
+ if ((runCount = *dataStream++) & 1) {
+ // Handle the transparent color...
+ runCount >>= 1;
+ if (runCount > skipAmount) {
+ runCount -= skipAmount;
+ goto DoTransparentRun;
+ } else {
+ skipAmount -= runCount;
+ }
+
+ } else if (runCount & 2) {
+ // Handle a run of color...
+ runCount = (runCount >> 2) + 1;
+ if (runCount > skipAmount) {
+ runCount -= skipAmount;
+ goto WriteRunData;
+ } else {
+ skipAmount -= runCount;
+ dataStream++;
+ }
+
+ } else {
+ // Handle a literal run of pixels...
+ runCount = (runCount >> 2) + 1;
+ if (runCount > skipAmount) {
+ runCount -= skipAmount;
+ dataStream += skipAmount;
+ goto WriteLiteralData;
+ } else {
+ skipAmount -= runCount;
+ dataStream += runCount;
+ }
+ }
+ }
+
+ // Really decompress to the dest buffer...
+ while (decompAmount > 0) {
+ runCount = *dataStream++;
+
+ if (runCount & 1) {
+ /* xxxxxxx1 */
+ runCount >>= 1;
+ DoTransparentRun:
+ if (transOp == kWZOIgnore) {
+ AUX_IGNORE_ZPLANE_BITS(destPtr, mask, runCount);
+ } else if (transOp == kWZOClear) {
+ AUX_CLEAR_ZPLANE_BITS(destPtr, mask, runCount);
+ } else {
+ AUX_SET_ZPLANE_BITS(destPtr, mask, runCount);
+ }
+
+ decompAmount -= runCount;
+
+ } else if (runCount & 2) {
+ /* xxxxxx10 */
+ runCount = (runCount >> 2) + 1;
+ WriteRunData:
+ decompAmount -= runCount;
+ if (decompAmount >= 0) {
+ if (solidOp == kWZOSet) {
+ AUX_SET_ZPLANE_BITS(destPtr, mask, runCount);
+ } else if (solidOp == kWZOClear) {
+ AUX_CLEAR_ZPLANE_BITS(destPtr, mask, runCount);
+ } else {
+ AUX_IGNORE_ZPLANE_BITS(destPtr, mask, runCount);
+ }
+ dataStream++;
+ } else {
+ runCount += decompAmount;
+ if (solidOp == kWZOSet) {
+ AUX_SET_ZPLANE_BITS(destPtr, mask, runCount);
+ } else if (solidOp == kWZOClear) {
+ AUX_CLEAR_ZPLANE_BITS(destPtr, mask, runCount);
+ } else {
+ AUX_IGNORE_ZPLANE_BITS(destPtr, mask, runCount);
+ }
+ }
+
+ } else {
+ /* xxxxxx00 */
+ runCount = (runCount >> 2) + 1;
+
+ WriteLiteralData:
+ decompAmount -= runCount;
+ if (decompAmount >= 0) {
+ if (solidOp == kWZOSet) {
+ AUX_SET_ZPLANE_BITS(destPtr, mask, runCount);
+ } else if (solidOp == kWZOClear) {
+ AUX_CLEAR_ZPLANE_BITS(destPtr, mask, runCount);
+ } else {
+ AUX_IGNORE_ZPLANE_BITS(destPtr, mask, runCount);
+ }
+ dataStream += runCount;
+ } else {
+ runCount += decompAmount;
+ if (solidOp == kWZOSet) {
+ AUX_SET_ZPLANE_BITS(destPtr, mask, runCount);
+ } else if (solidOp == kWZOClear) {
+ AUX_CLEAR_ZPLANE_BITS(destPtr, mask, runCount);
+ } else {
+ AUX_IGNORE_ZPLANE_BITS(destPtr, mask, runCount);
+ }
+ }
+ }
+ }
+}
+
+void Wiz::auxColorMixDecompressLine(WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const byte *colorMixTable, const WizRawPixel *conversionTable) {
+ if (_uses16BitColor)
+ return;
+
+ const byte *remapTable;
+ int runCount;
+
+ // Decompress bytes to do simple clipping...
+ while (skipAmount > 0) {
+ if ((runCount = *dataStream++) & 1) {
+ // Handle the transparent color...
+ runCount >>= 1;
+ if (runCount > skipAmount) {
+ runCount -= skipAmount;
+ goto DoTransparentRun;
+ } else {
+ skipAmount -= runCount;
+ }
+ } else if (runCount & 2) {
+ // Handle a run of color...
+ runCount = (runCount >> 2) + 1;
+ if (runCount > skipAmount) {
+ runCount -= skipAmount;
+ goto WriteRunData;
+ } else {
+ skipAmount -= runCount;
+ dataStream++;
+ }
+
+ } else {
+ // Handle a literal run of pixels...
+ runCount = (runCount >> 2) + 1;
+ if (runCount > skipAmount) {
+ runCount -= skipAmount;
+ dataStream += skipAmount;
+ goto WriteLiteralData;
+ } else {
+ skipAmount -= runCount;
+ dataStream += runCount;
+ }
+ }
+ }
+
+ // Really decompress to the dest buffer...
+ while (decompAmount > 0) {
+ runCount = *dataStream++;
+
+ if (runCount & 1) {
+ /* xxxxxxx1 */
+ runCount >>= 1;
+ DoTransparentRun:
+ destPtr += runCount;
+ decompAmount -= runCount;
+
+ } else if (runCount & 2) {
+ /* xxxxxx10 */
+ runCount = (runCount >> 2) + 1;
+ WriteRunData:
+ decompAmount -= runCount;
+ if (decompAmount < 0) {
+ runCount += decompAmount;
+ }
+ remapTable = colorMixTable + ((*((const byte *)dataStream)) << 8);
+ dataStream++;
+ while (--runCount >= 0) {
+ *destPtr++ = *(remapTable + *destPtr);
+ }
+
+ } else {
+ /* xxxxxx00 */
+ runCount = (runCount >> 2) + 1;
+ WriteLiteralData:
+ decompAmount -= runCount;
+ if (decompAmount < 0) {
+ runCount += decompAmount;
+ }
+ while (--runCount >= 0) {
+ *destPtr++ = *(colorMixTable + ((*((const byte *)dataStream)) << 8) + *destPtr);
+ dataStream++;
+ }
+ }
+ }
+}
+
+void Wiz::auxHistogramTRLELine(int *tablePtr, const byte *dataStream, int skipAmount, int decompAmount) {
+ int runCount;
+
+ // Decompress bytes to do simple clipping...
+ while (skipAmount > 0) {
+ if ((runCount = *dataStream++) & 1) {
+ // Handle the transparent color...
+ runCount >>= 1;
+ if (runCount > skipAmount) {
+ runCount -= skipAmount;
+ goto DoTransparentRun;
+ } else {
+ skipAmount -= runCount;
+ }
+
+ } else if (runCount & 2) {
+ // Handle a run of color...
+ runCount = (runCount >> 2) + 1;
+ if (runCount > skipAmount) {
+ runCount -= skipAmount;
+ goto WriteRunData;
+ } else {
+ skipAmount -= runCount;
+ dataStream += sizeof(byte);
+ }
+
+ } else {
+ // Handle a literal run of pixels...
+ runCount = (runCount >> 2) + 1;
+ if (runCount > skipAmount) {
+ runCount -= skipAmount;
+ dataStream += (skipAmount * sizeof(byte));
+ goto WriteLiteralData;
+ } else {
+ skipAmount -= runCount;
+ dataStream += (runCount * sizeof(byte));
+ }
+ }
+ }
+
+ // Really histogram the non-skipped data...
+ while (decompAmount > 0) {
+ runCount = *dataStream++;
+
+ if (runCount & 1) {
+ /* xxxxxxx1 */
+ runCount >>= 1;
+
+ DoTransparentRun:
+ decompAmount -= runCount;
+
+ } else if (runCount & 2) {
+ /* xxxxxx10 */
+ runCount = (runCount >> 2) + 1;
+
+ WriteRunData:
+ decompAmount -= runCount;
+ if (decompAmount < 0) {
+ runCount += decompAmount;
+ }
+
+ *(tablePtr + *((const byte *)dataStream)) += runCount;
+ dataStream += sizeof(byte);
+ } else {
+ /* xxxxxx00 */
+ runCount = (runCount >> 2) + 1;
+
+ WriteLiteralData:
+ decompAmount -= runCount;
+ if (decompAmount < 0) {
+ runCount += decompAmount;
+ }
+
+ while (--runCount >= 0) {
+ (*(tablePtr + *((const byte *)dataStream)))++;
+ dataStream += sizeof(byte);
+ }
+ }
+ }
+}
+
+void Wiz::auxHistogramTRLEPrim(int *histogramTablePtr, byte *compData, Common::Rect *sourceRect) {
+ int decompWidth, decompHeight, counter, sX1, lineSize;
+
+ // Yet more general setup...
+ sX1 = sourceRect->left;
+ decompWidth = sourceRect->right - sourceRect->left + 1;
+ decompHeight = sourceRect->bottom - sourceRect->top + 1;
+
+ // Quickly skip down to the lines to be compressed & dest position...
+ for (counter = sourceRect->top; counter > 0; counter--) {
+ compData += READ_LE_UINT16(compData) + 2;
+ }
+
+ // Decompress all the lines that are visible!!!!
+ while (decompHeight-- > 0) {
+ lineSize = READ_LE_UINT16(compData);
+
+ if (lineSize != 0) {
+ auxHistogramTRLELine(histogramTablePtr, compData + 2, sX1, decompWidth);
+ compData += lineSize + 2;
+ } else {
+ // Handle a completely transparent line!
+ compData += 2;
+ }
+ }
+}
+
+void Wiz::auxRemappedMemcpy(WizRawPixel *dstPtr, byte *srcPtr, int count, byte *remapTable, const WizRawPixel *conversionTable) {
+ do {
+ *dstPtr++ = convert8BppToRawPixel(*(remapTable + *srcPtr++), conversionTable);
+ } while (--count > 0);
+}
} // End of namespace Scumm
diff --git a/engines/scumm/he/gfx_primitives_he.cpp b/engines/scumm/he/gfx_primitives_he.cpp
index e5fe63846bf..01b51f8a031 100644
--- a/engines/scumm/he/gfx_primitives_he.cpp
+++ b/engines/scumm/he/gfx_primitives_he.cpp
@@ -1289,9 +1289,8 @@ void Wiz::pgBlit90DegreeRotateCore(WizSimpleBitmap *dstBitmap, int x, int y, con
void(*srcTransferFP)(Wiz *wiz, WizRawPixel *dstPtr, int dstStep, const WizRawPixel *srcPtr, int count, const void *userParam, const void *userParam2)) {
Common::Rect dstRect, srcRect, clipRect, clippedDstRect, clippedSrcRect;
- int dstOffset, dstStep, wx, w, h, srcOffset, dstX, dstY;
+ int dstOffset, dstStep, w, h, srcOffset, dstX, dstY;
const WizRawPixel *srcPtr;
- WizRawPixel *dstWorkPtr;
WizRawPixel *dstPtr;
// Do as much pre-clipping as possible
diff --git a/engines/scumm/he/polygon_he.cpp b/engines/scumm/he/polygon_he.cpp
index aa01a768397..4599f9b6900 100644
--- a/engines/scumm/he/polygon_he.cpp
+++ b/engines/scumm/he/polygon_he.cpp
@@ -143,6 +143,35 @@ void Wiz::polyMovePolygonPoints(Common::Point *listOfPoints, int numverts, int d
}
}
+bool Wiz::polyIsRectangle(const Common::Point *points, int numverts) {
+ // assume it's not
+ bool bRetVal = false;
+
+ // if there aren't four points, it's not a rectangle, duh!
+ if (numverts == 4) {
+ // check if point 0 is on same x and y axis as neighbors
+ if (points[0].x == points[1].x) {
+ // point 3 must be on y axis to form a right angle
+ if (points[0].y == points[3].y) {
+ // check opposite point to make sure that its neighbors form a right angle
+ if ((points[2].x == points[3].x) && (points[2].y == points[1].y)) {
+ bRetVal = true;
+ }
+ }
+ } else if (points[0].x == points[3].x) { // the second of two possible orientations
+ // point 1 must be on y axis to form right angle
+ if (points[0].y == points[1].y) {
+ // check opposite point to make sure that its neighbors form a right angle
+ if ((points[2].x == points[1].x) && (points[2].y == points[3].y)) {
+ bRetVal = true;
+ }
+ }
+ }
+ }
+
+ return bRetVal;
+}
+
void Wiz::polyBuildBoundingRect(Common::Point *points, int numVerts, Common::Rect &rect) {
rect.left = 10000;
rect.top = 10000;
diff --git a/engines/scumm/he/script_v100he.cpp b/engines/scumm/he/script_v100he.cpp
index d96c7ca65b7..9eb009a53e8 100644
--- a/engines/scumm/he/script_v100he.cpp
+++ b/engines/scumm/he/script_v100he.cpp
@@ -1206,7 +1206,7 @@ void ScummEngine_v100he::o100_wizImageOps() {
_wizImageCommand.xPos = pop();
break;
case SO_AT_IMAGE: // 7
- _wizImageCommand.actionFlags |= kWAFSourceImg;
+ _wizImageCommand.actionFlags |= kWAFSourceImage;
_wizImageCommand.sourceImage = pop();
break;
case SO_CAPTURE: // 11
diff --git a/engines/scumm/he/script_v72he.cpp b/engines/scumm/he/script_v72he.cpp
index f83208cb8b8..9ee356230a9 100644
--- a/engines/scumm/he/script_v72he.cpp
+++ b/engines/scumm/he/script_v72he.cpp
@@ -528,14 +528,17 @@ void ScummEngine_v72he::o72_getObjectImageY() {
}
void ScummEngine_v72he::o72_captureWizImage() {
- Common::Rect grab;
- grab.bottom = pop() + 1;
- grab.right = pop() + 1;
- grab.top = pop();
- grab.left = pop();
+ int y2 = pop();
+ int x2 = pop();
+ int y1 = pop();
+ int x1 = pop();
int image = pop();
- _wiz->takeAWiz(image, grab, false, true);
+ _wiz->takeAWiz(image, x1, y1, x2, y2, false, true);
+
+ if (_game.heversion > 99) {
+ _res->setModified(rtImage, image);
+ }
}
void ScummEngine_v72he::o72_getTimer() {
diff --git a/engines/scumm/he/script_v90he.cpp b/engines/scumm/he/script_v90he.cpp
index 2202eb52455..73f4037a0bb 100644
--- a/engines/scumm/he/script_v90he.cpp
+++ b/engines/scumm/he/script_v90he.cpp
@@ -193,7 +193,7 @@ void ScummEngine_v90he::o90_wizImageOps() {
_wizImageCommand.extendedRenderInfo.group = 0;
break;
case SO_AT_IMAGE: // 62, HE99+
- _wizImageCommand.actionFlags |= kWAFSourceImg;
+ _wizImageCommand.actionFlags |= kWAFSourceImage;
_wizImageCommand.sourceImage = pop();
break;
case SO_AT: // 65
diff --git a/engines/scumm/he/sprite_he.cpp b/engines/scumm/he/sprite_he.cpp
index 53de0160168..25b5e6fac88 100644
--- a/engines/scumm/he/sprite_he.cpp
+++ b/engines/scumm/he/sprite_he.cpp
@@ -1350,7 +1350,7 @@ void Sprite::renderSprites(bool arg) {
wiz.zPos = spi->priority;
}
if (spi->sourceImage) {
- wiz.actionFlags |= kWAFSourceImg;
+ wiz.actionFlags |= kWAFSourceImage;
wiz.sourceImage = spi->sourceImage;
}
wiz.actionFlags |= kWAFFlags;
diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp
index 92e694b3a3e..20b3d3d9de9 100644
--- a/engines/scumm/he/wiz_he.cpp
+++ b/engines/scumm/he/wiz_he.cpp
@@ -1111,108 +1111,52 @@ void Wiz::processWizImageCaptureCmd(const WizImageCommand *params) {
bool compressIt = (params->compressionType == kWCTTRLE);
bool background = (params->flags & kWRFBackground) != 0;
- takeAWiz(params->image, params->box, background, params->compressionType);
+ takeAWiz(params->image, params->box.left, params->box.top, params->box.right, params->box.bottom, background, compressIt);
_vm->_res->setModified(rtImage, params->image);
}
-void Wiz::takeAWiz(int resNum, const Common::Rect &r, bool backBuffer, int compType) {
- uint8 *src = nullptr;
+void Wiz::takeAWiz(int globnum, int x1, int y1, int x2, int y2, bool back, bool compress) {
+ int bufferWidth, bufferHeight;
+ Common::Rect rect, clipRect;
+ WizRawPixel *srcPtr;
+
VirtScreen *pvs = &_vm->_virtscr[kMainVirtScreen];
- if (backBuffer) {
- src = pvs->getBackPixels(0, 0);
+ bufferWidth = pvs->w;
+ bufferHeight = pvs->h;
+
+ if (back) {
+ srcPtr = (WizRawPixel *)pvs->getPixels(0, 0);
} else {
- src = pvs->getPixels(0, 0);
+ srcPtr = (WizRawPixel *)pvs->getBackPixels(0, 0);
}
- captureImage(src, pvs->pitch, pvs->w, pvs->h, resNum, r, compType);
-}
-
-void Wiz::captureImage(uint8 *src, int srcPitch, int srcw, int srch, int resNum, const Common::Rect& r, int compType) {
- debug(7, "captureImage(%d, %d, [%d,%d,%d,%d])", resNum, compType, r.left, r.top, r.right, r.bottom);
- Common::Rect rCapt(srcw, srch);
- if (rCapt.intersects(r)) {
- rCapt.clip(r);
- const uint8 *palPtr;
- if (_vm->_game.heversion >= 99) {
- palPtr = _vm->_hePalettes + _vm->_hePaletteSlot;
- } else {
- palPtr = _vm->_currentPalette;
- }
-
- int w = rCapt.width();
- int h = rCapt.height();
- int transColor = (_vm->VAR_WIZ_TRANSPARENT_COLOR != 0xFF) ? _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR) : 5;
- if (_vm->_game.features & GF_16BIT_COLOR)
- compType = 2;
+ rect.left = x1;
+ rect.top = y1;
+ rect.right = x2;
+ rect.bottom = y2;
- // compute compressed size
- int dataSize = 0;
- int headerSize = palPtr ? 1080 : 36;
- switch (compType) {
- case 0:
- dataSize = wizPackType0(0, src, srcPitch, rCapt);
- break;
- case 1:
- dataSize = wizPackType1(0, src, srcPitch, rCapt, transColor);
- break;
-#ifdef USE_RGB_COLOR
- case 2:
- dataSize = wizPackType2(0, src, srcPitch, rCapt);
- break;
-#endif
- default:
- error("unhandled compression type %d", compType);
- break;
- }
+ clipRect.left = 0;
+ clipRect.top = 0;
+ clipRect.right = bufferWidth - 1;
+ clipRect.bottom = bufferHeight - 1;
- // alignment
- dataSize = (dataSize + 1) & ~1;
- int wizSize = headerSize + dataSize;
- // write header
- uint8 *wizImg = _vm->_res->createResource(rtImage, resNum, dataSize + headerSize);
- WRITE_BE_UINT32(wizImg + 0x00, 'AWIZ');
- WRITE_BE_UINT32(wizImg + 0x04, wizSize);
- WRITE_BE_UINT32(wizImg + 0x08, 'WIZH');
- WRITE_BE_UINT32(wizImg + 0x0C, 0x14);
- WRITE_LE_UINT32(wizImg + 0x10, compType);
- WRITE_LE_UINT32(wizImg + 0x14, w);
- WRITE_LE_UINT32(wizImg + 0x18, h);
- int curSize = 0x1C;
- if (palPtr) {
- WRITE_BE_UINT32(wizImg + 0x1C, 'RGBS');
- WRITE_BE_UINT32(wizImg + 0x20, 0x308);
- memcpy(wizImg + 0x24, palPtr, 0x300);
- WRITE_BE_UINT32(wizImg + 0x324, 'RMAP');
- WRITE_BE_UINT32(wizImg + 0x328, 0x10C);
- WRITE_BE_UINT32(wizImg + 0x32C, 0);
- curSize = 0x330;
- for (int i = 0; i < 256; ++i) {
- wizImg[curSize] = i;
- ++curSize;
- }
- }
- WRITE_BE_UINT32(wizImg + curSize + 0x0, 'WIZD');
- WRITE_BE_UINT32(wizImg + curSize + 0x4, dataSize + 8);
- curSize += 8;
+ if (!findRectOverlap(&rect, &clipRect)) {
+ error("Capture rect invalid (%-4d,%4d,%-4d,%4d)", x1, y1, x2, y2);
+ }
- // write compressed data
- switch (compType) {
- case 0:
- wizPackType0(wizImg + headerSize, src, srcPitch, rCapt);
- break;
- case 1:
- wizPackType1(wizImg + headerSize, src, srcPitch, rCapt, transColor);
- break;
-#ifdef USE_RGB_COLOR
- case 2:
- wizPackType2(wizImg + headerSize, src, srcPitch, rCapt);
- break;
-#endif
- default:
- break;
- }
+ uint8 *palPtr = nullptr;
+ if (_vm->_game.heversion >= 99) {
+ palPtr = _vm->_hePalettes + _vm->_hePaletteSlot;
+ } else {
+ palPtr = _vm->_currentPalette;
}
+
+ buildAWiz(
+ srcPtr, bufferWidth, bufferHeight,
+ palPtr, &rect,
+ (compress) ? kWCTTRLE : kWCTNone,
+ globnum, _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR));
}
void Wiz::simpleDrawAWiz(int image, int state, int x, int y, int flags) {
@@ -1300,6 +1244,7 @@ void *Wiz::drawAWizPrimEx(int globNum, int state, int x, int y, int z, int shado
WizRawPixel *dest_p;
markUpdates = true;
+ remap_p = nullptr;
// Set the optional remap table up to the default if one isn't specified
if (!optionalColorConversionTable) {
@@ -1458,14 +1403,14 @@ void *Wiz::drawAWizPrimEx(int globNum, int state, int x, int y, int z, int shado
if (_vm->_gdi->_numZBuffer <= 1) {
error("Wiz::drawAWizPrimEx(): No zplane %d (limit 0 to %d)", 1, (_vm->_gdi->_numZBuffer - 1));
}
- //_vm->getMaskBuffer(0, 0, 1); TODO
- //AUX_DrawZplaneFromTRLEImage(TextZplane + WindowXmin + TZPoffset[1], src_d + _vm->_resourceHeaderSize, dest_w, dest_h, x, y, src_w, src_h, &clip_r, WIZ_ZPLANE_OP_IGNORE, WIZ_ZPLANE_OP_SET);
+
+ auxDrawZplaneFromTRLEImage(_vm->getMaskBuffer(0, 0, 1), src_d + _vm->_resourceHeaderSize, dest_w, dest_h, x, y, src_w, src_h, &clip_r, kWZOIgnore, kWZOSet);
} else if (flags & kWRFZPlaneOff) {
if (_vm->_gdi->_numZBuffer <= 1) {
error("Wiz::drawAWizPrimEx(): No zplane %d (limit 0 to %d)", 1, (_vm->_gdi->_numZBuffer - 1));
}
- //_vm->getMaskBuffer(0, 0, 1); TODO
- //AUX_DrawZplaneFromTRLEImage(TextZplane + WindowXmin + TZPoffset[1], src_d + _vm->_resourceHeaderSize, dest_w, dest_h, x, y, src_w, src_h, &clip_r, WIZ_ZPLANE_OP_IGNORE, WIZ_ZPLANE_OP_CLEAR);
+
+ auxDrawZplaneFromTRLEImage(_vm->getMaskBuffer(0, 0, 1), src_d + _vm->_resourceHeaderSize, dest_w, dest_h, x, y, src_w, src_h, &clip_r, kWZOIgnore, kWZOClear);
} else {
void *dataPtr = nullptr;
@@ -1553,6 +1498,137 @@ void *Wiz::drawAWizPrimEx(int globNum, int state, int x, int y, int z, int shado
return dest_p;
}
+void Wiz::buildAWiz(const WizRawPixel *bufPtr, int bufWidth, int bufHeight, const byte *palettePtr, const Common::Rect *rectPtr, int compressionType, int globNum, int transparentColor) {
+ int dataSize, globSize, dataOffset, counter, height, width;
+ Common::Rect compRect;
+ byte *ptr;
+
+ // Make sure that the coords passed in make sense.
+ compRect.left = 0;
+ compRect.top = 0;
+ compRect.right = bufWidth - 1;
+ compRect.bottom = bufHeight - 1;
+
+ dataSize = 0;
+
+ if (!rectPtr) {
+ if (!findRectOverlap(&compRect, rectPtr)) {
+ error("Build wiz incorrect size (%d,%d,%d,%d)", rectPtr->left, rectPtr->top, rectPtr->right, rectPtr->bottom);
+ }
+ }
+
+ // Force the compression type if in hi-color mode.
+ if (_uses16BitColor) {
+ compressionType = kWCTNone16Bpp;
+ }
+
+ // Estimate the size of the wiz.
+ globSize = (_vm->_resourceHeaderSize * 3) + 12; // AWIZ, WIZH + data (12), WIZD
+
+ if (!palettePtr) {
+ globSize += (_vm->_resourceHeaderSize * 2) + 768 + 256 + 4; // RGBS + 768, RMAP + 256 + 4
+ }
+
+ if (compressionType == kWCTTRLE) {
+ // TODO
+ //dataSize = TRLE_CompressImageArea(
+ // nullptr, bufPtr, bufWidth, compRect.left, compRect.top, compRect.right, compRect.bottom,
+ // (WizRawPixel)transparentColor);
+ } else if (isUncompressedFormatTypeID(compressionType)) {
+ dataSize = ((getRectWidth(&compRect) * getRectHeight(&compRect)) * sizeof(WizRawPixel));
+ } else {
+ error("Unknown compression type %d", compressionType);
+ }
+
+ // Make sure that the "glob" is even sized...
+ if (dataSize & 1) {
+ dataSize++;
+ }
+
+ // Finalize the glob size!
+ globSize += dataSize;
+
+ // Actually build the wiz!
+ ptr = (byte *)_vm->_res->createResource(rtImage, globNum, globSize);
+
+ dataOffset = 0;
+
+ // AWIZ block
+ WRITE_BE_UINT32(ptr + 0, MKTAG('A', 'W', 'I', 'Z'));
+ WRITE_BE_UINT32(ptr + 4, globSize); dataOffset += _vm->_resourceHeaderSize;
+
+ // WIZH
+ WRITE_BE_UINT32(ptr + dataOffset + 0, MKTAG('W', 'I', 'Z', 'H'));
+ WRITE_BE_UINT32(ptr + dataOffset + 4, (12 + _vm->_resourceHeaderSize)); dataOffset += _vm->_resourceHeaderSize;
+ WRITE_LE_UINT32(ptr + dataOffset, compressionType); dataOffset += 4; // COMPRESSION-TYPE
+ WRITE_LE_UINT32(ptr + dataOffset, getRectWidth(&compRect)); dataOffset += 4; // WIDTH
+ WRITE_LE_UINT32(ptr + dataOffset, getRectHeight(&compRect)); dataOffset += 4; // HEIGHT
+
+ if (!palettePtr) {
+ // RGBS
+ WRITE_BE_UINT32(ptr + dataOffset + 0, MKTAG('R', 'G', 'B', 'S'));
+ WRITE_BE_UINT32(ptr + dataOffset + 4, (768 + _vm->_resourceHeaderSize)); dataOffset += _vm->_resourceHeaderSize;
+ memcpy(ptr + dataOffset, palettePtr, 768); dataOffset += 768;
+
+ // RMAP
+ WRITE_BE_UINT32(ptr + dataOffset + 0, MKTAG('R', 'M', 'A', 'P'));
+ WRITE_BE_UINT32(ptr + dataOffset + 4, (256 + 4 + _vm->_resourceHeaderSize)); dataOffset += _vm->_resourceHeaderSize;
+ WRITE_LE_UINT32(ptr + dataOffset, 0); dataOffset += 4; // Remapped flag
+
+ for (counter = 0; counter < 256; counter++) {
+ *(ptr + dataOffset) = counter;
+ dataOffset++;
+ }
+ }
+
+ // WIZD
+ WRITE_BE_UINT32(ptr + dataOffset + 0, MKTAG('W', 'I', 'Z', 'D'));
+ WRITE_BE_UINT32(ptr + dataOffset + 4, (dataSize + _vm->_resourceHeaderSize)); dataOffset += _vm->_resourceHeaderSize;
+
+ if (compressionType == kWCTTRLE) {
+ if (!_uses16BitColor) {
+ // TODO
+ // TRLE_CompressImageArea(
+ // ptr + dataOffset, bufPtr, bufWidth,
+ // compRect.left, compRect.top, compRect.top, compRect.bottom,
+ // (byte)transparentColor);
+ } else {
+ error("Incorrect type %d for current pixel mode 16 bit", compressionType);
+ }
+ } else {
+ WizSimpleBitmap srcBitmap, dstBitmap;
+ Common::Rect dstRect;
+
+ // Src setup
+ srcBitmap.bufferPtr = (WizRawPixel *)bufPtr;
+ srcBitmap.bitmapWidth = bufWidth;
+ srcBitmap.bitmapHeight = bufHeight;
+
+ // Dst setup
+ width = getRectWidth(&compRect);
+ height = getRectHeight(&compRect);
+
+ dstBitmap.bufferPtr = (WizRawPixel *)(ptr + dataOffset);
+ dstBitmap.bitmapWidth = width;
+ dstBitmap.bitmapHeight = height;
+
+ dstRect.left = 0;
+ dstRect.top = 0;
+ dstRect.right = width - 1;
+ dstRect.bottom = height - 1;
+
+ // Call the blit primitive. There should be a rendering
+ // pipeline. That would allow things to happen much smoother.
+ pgSimpleBlit(&dstBitmap, &dstRect, &srcBitmap, &compRect);
+ }
+
+ // Error check.
+ dataOffset += dataSize;
+ if (globSize != dataOffset) {
+ error("WIZ size mismatch!");
+ }
+}
+
uint8 *Wiz::drawWizImage(int resNum, int state, int maskNum, int maskState, int x1, int y1, int zorder, int shadow, int zbuffer, const Common::Rect *clipBox, int flags, int dstResNum, const uint8 *palPtr, uint32 conditionBits) {
debug(7, "drawWizImage(resNum %d, state %d maskNum %d maskState %d x1 %d y1 %d flags 0x%X zorder %d shadow %d zbuffer %d dstResNum %d conditionBits: 0x%x)", resNum, state, maskNum, maskState, x1, y1, flags, zorder, shadow, zbuffer, dstResNum, conditionBits);
uint8 *dataPtr;
@@ -2027,78 +2103,380 @@ struct PolygonDrawData {
};
void Wiz::processWizImagePolyCaptureCmd(const WizImageCommand *params) {
- int resNum = params->image;
- int maskNum = params->sourceImage;
- bool maskState = (params->actionFlags & kWAFState) ? params->state : 0;
- int id1 = params->polygon;
- int id2 = params->polygon2;
- int compType = params->compressionType;
+ //int resNum = params->image;
+ //int maskNum = params->sourceImage;
+ //bool maskState = (params->actionFlags & kWAFState) ? params->state : 0;
+ //int id1 = params->polygon;
+ //int id2 = params->polygon2;
+ //int compType = params->compressionType;
+ //
+ //debug(7, "processWizImagePolyCaptureCmd: resNum %d, maskNum %d maskState %d, id1 %d id2 %d compType %d", resNum, maskNum, maskState, id1, id2, compType);
+ //
+ //int i, j;
+ //WizPolygon *wp;
+ //
+ //wp = nullptr;
+ //for (i = 0; i < ARRAYSIZE(_polygons); ++i) {
+ // if (_polygons[i].id == id1) {
+ // wp = &_polygons[i];
+ // break;
+ // }
+ //}
+ //if (!wp) {
+ // error("Polygon1 %d is not defined", id1);
+ //}
+ //if (wp->numPoints != 5) {
+ // error("Invalid point count %d for Polygon1 %d", wp->numPoints, id1);
+ //}
+ //
+ //wp = nullptr;
+ //for (i = 0; i < ARRAYSIZE(_polygons); ++i) {
+ // if (_polygons[i].id == id2) {
+ // wp = &_polygons[i];
+ // break;
+ // }
+ //}
+ //if (!wp) {
+ // error("Polygon2 %d is not defined", id2);
+ //}
+ //if (wp->numPoints != 5) {
+ // error("Invalid point count %d for Polygon2 %d", wp->numPoints, id2);
+ //}
+ //
+ //int32 dstw, dsth, dstpitch;
+ //int32 srcw, srch;
+ //uint8 *imageBuffer;
+ //
+ //assert(maskNum);
+ //const Common::Rect *r = nullptr;
+ //const uint8 *src = drawWizImage(maskNum, maskState, 0, 0, 0, 0, 0, 0, 0, r, kWRFAlloc, 0, 0, 0);
+ //getWizImageDim(maskNum, maskState, srcw, srch);
+ //
+ //dstw = wp->boundingRect.width();
+ //dsth = wp->boundingRect.height();
+ //dstpitch = dstw * _vm->_bytesPerPixel;
+ //imageBuffer = (uint8 *)malloc(dstw * dsth * _vm->_bytesPerPixel);
+ //assert(imageBuffer);
+ //
+ //const uint16 transColor = (_vm->VAR_WIZ_TRANSPARENT_COLOR != 0xFF) ? _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR) : 5;
+ //if (_vm->_bytesPerPixel == 2) {
+ // uint8 *tmpPtr = imageBuffer;
+ // for (i = 0; i < dsth; i++) {
+ // for (j = 0; j < dstw; j++)
+ // WRITE_LE_UINT16(tmpPtr + j * 2, transColor);
+ // tmpPtr += dstpitch;
+ // }
+ //} else {
+ // memset(imageBuffer, transColor, dstw * dsth);
+ //}
+ //
+ //Common::Rect bound;
+ //drawWizPolygonImage(imageBuffer, src, nullptr, dstpitch, kDstMemory, dstw, dsth, srcw, srch, bound, wp->points, _vm->_bytesPerPixel);
+ //
+ //captureImage(imageBuffer, dstpitch, dstw, dsth, resNum, wp->boundingRect, compType);
+ //free(imageBuffer);
+
+ int polygon1, polygon2, compressionType, srcImage = 0, shadow = 0, state = 0;
+ bool bIsHintColor = false;
+ int iHintColor = 0;
+
+ // Get all the options...
+ if (params->actionFlags & kWAFPolygon) {
+ polygon1 = params->polygon;
+ } else {
+ error("Image capture poly: no polygon 1 specified.");
+ }
+
+ if (params->actionFlags & kWAFPolygon2) {
+ polygon2 = params->polygon2;
+ } else {
+ polygon2 = polygon1;
+ }
- debug(7, "processWizImagePolyCaptureCmd: resNum %d, maskNum %d maskState %d, id1 %d id2 %d compType %d", resNum, maskNum, maskState, id1, id2, compType);
+ if (params->actionFlags & kWAFCompressionType) {
+ compressionType = params->compressionType;
+ } else {
+ compressionType = kWCTNone;
+ }
- int i, j;
- WizPolygon *wp;
+ if (params->actionFlags & kWAFShadow) {
+ shadow = params->shadow;
+ }
- wp = nullptr;
- for (i = 0; i < ARRAYSIZE(_polygons); ++i) {
- if (_polygons[i].id == id1) {
- wp = &_polygons[i];
- break;
- }
+ if (params->actionFlags & kWAFDestImage) {
+ error("Image capture poly: destination 'image' not supported, use 'source image'");
}
- if (!wp) {
- error("Polygon1 %d is not defined", id1);
+
+ if (params->actionFlags & kWAFSourceImage) {
+ srcImage = params->sourceImage;
}
- if (wp->numPoints != 5) {
- error("Invalid point count %d for Polygon1 %d", wp->numPoints, id1);
+
+ if (params->actionFlags & kWAFState) {
+ state = params->state;
}
- wp = nullptr;
- for (i = 0; i < ARRAYSIZE(_polygons); ++i) {
- if (_polygons[i].id == id2) {
- wp = &_polygons[i];
+ if (params->actionFlags & kWAFProperty) {
+ if (params->propertyNumber == 1) { // Color hint property
+ if (!shadow) {
+ debug(7, "ProcessWizImagePolyCaptureCmd: color hint does nothing for an unfiltered scale.");
+ }
+
+ bIsHintColor = true;
+ iHintColor = params->propertyValue;
+ }
+ }
+
+ // validate the parameters
+ bool bPoly1Found = false;
+ bool bPoly2Found = false;
+
+ for (int polyIndex = 0; polyIndex < ARRAYSIZE(_polygons); ++polyIndex) {
+ if (polygon1 == _polygons[polyIndex].id) {
+ bPoly1Found = true;
+ polygon1 = polyIndex;
+ if (_polygons[polyIndex].numPoints != 5)
+ error("Invalid point count");
+ }
+
+ if (polygon2 == _polygons[polyIndex].id) {
+ bPoly2Found = true;
+ polygon2 = polyIndex;
+ if (_polygons[polyIndex].numPoints != 5)
+ error("Invalid point count");
+ }
+
+ if (bPoly1Found && bPoly2Found) {
break;
}
}
- if (!wp) {
- error("Polygon2 %d is not defined", id2);
+
+ if (!bPoly1Found) {
+ error("Image capture poly: Polygon %d not defined", polygon1);
}
- if (wp->numPoints != 5) {
- error("Invalid point count %d for Polygon2 %d", wp->numPoints, id2);
+
+ if (!bPoly2Found) {
+ error("Image capture poly: Polygon %d not defined", polygon2);
+ }
+
+ if (_polygons[polygon1].numPoints != _polygons[polygon2].numPoints) {
+ error("Image capture poly: Polygons MUST have same number of points.");
}
- int32 dstw, dsth, dstpitch;
- int32 srcw, srch;
- uint8 *imageBuffer;
+ // create the buffers to hold the source and dest image bits
+ // since a lot of drawing commands will be called, and we can't gurantee
+ // that the source image will stick around, we make a buffer big enough
+ // to contain it and then copy the bits in.
- assert(maskNum);
- const Common::Rect *r = nullptr;
- const uint8 *src = drawWizImage(maskNum, maskState, 0, 0, 0, 0, 0, 0, 0, r, kWRFAlloc, 0, 0, 0);
- getWizImageDim(maskNum, maskState, srcw, srch);
-
- dstw = wp->boundingRect.width();
- dsth = wp->boundingRect.height();
- dstpitch = dstw * _vm->_bytesPerPixel;
- imageBuffer = (uint8 *)malloc(dstw * dsth * _vm->_bytesPerPixel);
- assert(imageBuffer);
-
- const uint16 transColor = (_vm->VAR_WIZ_TRANSPARENT_COLOR != 0xFF) ? _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR) : 5;
- if (_vm->_bytesPerPixel == 2) {
- uint8 *tmpPtr = imageBuffer;
- for (i = 0; i < dsth; i++) {
- for (j = 0; j < dstw; j++)
- WRITE_LE_UINT16(tmpPtr + j * 2, transColor);
- tmpPtr += dstpitch;
+ WizSimpleBitmap srcBitmap, destBitmap;
+ srcBitmap.bufferPtr = nullptr;
+ destBitmap.bufferPtr = nullptr;
+
+ // we need to get the poly points
+
+ // build a bounding rect for the polys and set the appropriate sizes in the bitmaps
+ Common::Rect destPolyRect;
+ Common::Rect srcPolyRect;
+
+ polyBuildBoundingRect(_polygons[polygon2].points, _polygons[polygon2].numPoints, destPolyRect);
+ destBitmap.bitmapWidth = getRectWidth(&destPolyRect);
+ destBitmap.bitmapHeight = getRectHeight(&destPolyRect);
+ destBitmap.bufferPtr = (WizRawPixel *)malloc(destBitmap.bitmapWidth * destBitmap.bitmapHeight * sizeof(WizRawPixel));
+
+ if (destBitmap.bufferPtr == 0) {
+ error("Image capture poly: Could not allocate destination buffer");
+ }
+
+ // fill with transparent color
+ rawPixelMemset(destBitmap.bufferPtr,
+ _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR),
+ destBitmap.bitmapWidth * destBitmap.bitmapHeight);
+
+ // get the bound rect for the poly
+ polyBuildBoundingRect(_polygons[polygon1].points, _polygons[polygon1].numPoints, srcPolyRect);
+
+ // we need to get the points so that they can be offset to the correct position in
+ // the source buffer in the case of a screen capture (since the whole screen may not
+ // be captured, and the polygon may be offset into it, so we only create a buffer of the size needed
+ int iPointCt;
+ Common::Point srcPoints[5];
+ for (iPointCt = 0; iPointCt < 5; ++iPointCt) {
+ srcPoints[iPointCt].x = _polygons[polygon1].points[iPointCt].x;
+ srcPoints[iPointCt].y = _polygons[polygon1].points[iPointCt].y;
+ }
+
+ // check for one to one rectangle, which will set up for an image copy later
+ bool bOneToOneRect = false;
+ // see if they are both rectangles, passing in 4 because it turns out you can only create a 4 vertex polygon in scumm
+ // according to set4Polygon
+ if (polyIsRectangle(_polygons[polygon1].points, 4) && polyIsRectangle(_polygons[polygon2].points, 4)) {
+ // check if the points are all the same
+ for (iPointCt = 0; iPointCt < 4; ++iPointCt) {
+ if ((_polygons[polygon1].points[iPointCt].x != _polygons[polygon2].points[iPointCt].x) ||
+ (_polygons[polygon1].points[iPointCt].y != _polygons[polygon2].points[iPointCt].y)) {
+ break;
+ }
+ }
+
+ if (iPointCt == 4) {
+ bOneToOneRect = true;
}
+ }
+
+ // if there is a source image, get its bits, otherwise capture from the screen
+ if (srcImage) {
+ // get the wiz size
+ Common::Rect clipRect;
+ int w, h;
+ getWizImageDim(srcImage, state, w, h);
+
+ clipRect.left = 0;
+ clipRect.top = 0;
+ clipRect.right = w;
+ clipRect.bottom = h;
+
+ // make sure capture area isn't outside or bigger than the source image
+ Common::Rect testRect;
+ combineRects(&testRect, &srcPolyRect, &clipRect);
+
+ if ((getRectWidth(&testRect) * getRectHeight(&testRect)) >
+ (getRectWidth(&clipRect) * getRectHeight(&clipRect))) {
+ error("Image capture poly: Specified polygon captures points outside bounds of source image");
+ }
+
+ // clip poly to image and verify it's within the image
+ if (!findRectOverlap(&srcPolyRect, &clipRect)) {
+ error("Image capture poly: Specified polygon doesn't intersect source image.");
+ }
+
+ srcBitmap.bitmapWidth = getRectWidth(&srcPolyRect);
+ srcBitmap.bitmapHeight = getRectHeight(&srcPolyRect);
+
+ if ((srcBitmap.bitmapWidth == 0) || (srcBitmap.bitmapHeight == 0)) {
+ error("Image capture poly: Poly or source image invalid");
+ }
+
+ // create the bitmap
+ srcBitmap.bufferPtr = (WizRawPixel *)malloc(srcBitmap.bitmapWidth * srcBitmap.bitmapHeight * sizeof(WizRawPixel));
+ if (srcBitmap.bufferPtr == 0) {
+ error("Image capture poly: Could not allocate source buffer");
+ }
+
+ // clear to transparent
+ rawPixelMemset(srcBitmap.bufferPtr,
+ _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR),
+ srcBitmap.bitmapWidth * srcBitmap.bitmapHeight);
+
+ drawAWiz(srcImage, state, 0, 0, 0, 0, 0, 0, &srcPolyRect, 0, &srcBitmap);
+ } else { // we must be capturing from screen
+
+ // get the window size
+ VirtScreen *pvs = &_vm->_virtscr[kMainVirtScreen];
+ int iWindowWidth = pvs->w;
+ int iWindowHeight = pvs->h;
+
+ // intersect the bound rect and the window rect
+ Common::Rect clipRect;
+ clipRect.left = 0;
+ clipRect.top = 0;
+ clipRect.right = iWindowWidth - 1;
+ clipRect.bottom = iWindowHeight - 1;
+
+ if (!findRectOverlap(&srcPolyRect, &clipRect)) {
+ error("Image capture poly: Specified polygon doesn't intersect screen.");
+ }
+
+ srcBitmap.bitmapWidth = getRectWidth(&srcPolyRect);
+ srcBitmap.bitmapHeight = getRectHeight(&srcPolyRect);
+
+ if ((srcBitmap.bitmapWidth == 0) || (srcBitmap.bitmapHeight == 0)) {
+ error("Image capture poly: Specified screen rectangle invalid.");
+ }
+
+ // create the bitmap
+ srcBitmap.bufferPtr = (WizRawPixel *)malloc(srcBitmap.bitmapWidth * srcBitmap.bitmapHeight * sizeof(WizRawPixel));
+ if (!srcBitmap.bufferPtr) {
+ error("Image capture poly: Could not allocate source buffer");
+ }
+
+ // clear to transparent
+ rawPixelMemset(srcBitmap.bufferPtr,
+ _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR),
+ srcBitmap.bitmapWidth * srcBitmap.bitmapHeight);
+
+ // fill it with screen data
+ WizRawPixel *screenPtr = (WizRawPixel *)pvs->getPixels(srcPolyRect.left, srcPolyRect.top);
+ WizRawPixel *destPtr;
+
+ destPtr = srcBitmap.bufferPtr;
+
+ int iScreenRowLen = 640 * sizeof(WizRawPixel);
+ int iDestRowLen = srcBitmap.bitmapWidth * sizeof(WizRawPixel);
+
+ for (int iRow = 0; iRow < srcBitmap.bitmapHeight; ++iRow) {
+ memcpy(destPtr, screenPtr, iDestRowLen);
+ screenPtr += iScreenRowLen;
+ destPtr += iDestRowLen;
+ }
+
+ // translate the polygon so it is in the correct place in the buffer
+ int iDX = 0, iDY = 0;
+ iDX = 0 - srcPolyRect.left;
+ iDY = 0 - srcPolyRect.top;
+ polyMovePolygonPoints(srcPoints, _polygons[polygon1].numPoints, iDX, iDY);
+ }
+
+ // if there is an xmap, do filtered warp
+ if (shadow) {
+ // get the color map, bypass the header information
+ byte *pXmapColorTable = (byte *)getColorMixBlockPtrForWiz(shadow);
+
+ if (!pXmapColorTable) {
+ error("Image capture poly: Shadow specified but not present in image.");
+ }
+
+ pXmapColorTable += _vm->_resourceHeaderSize;
+
+ WARPWIZ_NPt2NPtNonClippedWarpFiltered(
+ &destBitmap, _polygons[polygon2].points, &srcBitmap, srcPoints,
+ _polygons[polygon1].numPoints, _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR),
+ pXmapColorTable, bIsHintColor, (WizRawPixel)iHintColor);
+
+ } else if (bOneToOneRect) { // if a one to one copy is performed, just copy this bits
+ memcpy(destBitmap.bufferPtr, srcBitmap.bufferPtr, destBitmap.bitmapHeight * destBitmap.bitmapWidth);
+ } else { // otherwise do "old" warp
+ WARPWIZ_NPt2NPtNonClippedWarp(
+ &destBitmap, _polygons[polygon2].points, &srcBitmap, srcPoints,
+ _polygons[polygon1].numPoints, _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR));
+ }
+
+ // now build a wiz with the destination bitmap and throw the bitmaps away
+ if (srcBitmap.bufferPtr) {
+ free(srcBitmap.bufferPtr);
+ srcBitmap.bufferPtr = nullptr;
+ }
+
+ uint8 *palPtr = nullptr;
+ if (_vm->_game.heversion >= 99) {
+ palPtr = _vm->_hePalettes + _vm->_hePaletteSlot;
} else {
- memset(imageBuffer, transColor, dstw * dsth);
+ palPtr = _vm->_currentPalette;
}
- Common::Rect bound;
- drawWizPolygonImage(imageBuffer, src, nullptr, dstpitch, kDstMemory, dstw, dsth, srcw, srch, bound, wp->points, _vm->_bytesPerPixel);
+ buildAWiz(destBitmap.bufferPtr,
+ destBitmap.bitmapWidth,
+ destBitmap.bitmapHeight,
+ palPtr,
+ &destPolyRect,
+ compressionType,
+ params->image,
+ _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR));
+
+ if (destBitmap.bufferPtr) {
+ free(destBitmap.bufferPtr);
+ destBitmap.bufferPtr = nullptr;
+ }
- captureImage(imageBuffer, dstpitch, dstw, dsth, resNum, wp->boundingRect, compType);
- free(imageBuffer);
+ _vm->_res->setModified(rtImage, params->image);
}
void Wiz::drawWizComplexPolygon(int resNum, int state, int po_x, int po_y, int shadow, int angle, int scale, const Common::Rect *r, int flags, int dstResNum, int palette) {
@@ -2388,7 +2766,7 @@ void Wiz::processWizImageDrawCmd(const WizImageCommand *params) {
ADD_REQUIRED_IMAGE(params->image);
- if (params->actionFlags & kWAFSourceImg) {
+ if (params->actionFlags & kWAFSourceImage) {
sourceImage = params->sourceImage;
ADD_REQUIRED_IMAGE(sourceImage);
} else {
@@ -2935,28 +3313,24 @@ void Wiz::dwHandleComplexImageDraw(int image, int state, int x, int y, int shado
image, state, x, y, shadow, correctedAngle, scale, clipRect, flags,
optionalBitmapOverride, optionalColorConversionTable);
return;
- break;
case 90:
handleRotate90SpecialCase(
image, state, x, y, shadow, correctedAngle, scale, clipRect, flags,
optionalBitmapOverride, optionalColorConversionTable);
return;
- break;
case 180:
handleRotate180SpecialCase(
image, state, x, y, shadow, correctedAngle, scale, clipRect, flags,
optionalBitmapOverride, optionalColorConversionTable);
return;
- break;
case 270:
handleRotate270SpecialCase(
image, state, x, y, shadow, correctedAngle, scale, clipRect, flags,
optionalBitmapOverride, optionalColorConversionTable);
return;
- break;
}
}
}
@@ -2995,7 +3369,6 @@ void Wiz::handleRotate0SpecialCase(int image, int state, int x, int y, int shado
void Wiz::handleRotate90SpecialCase(int image, int state, int x, int y, int shadow, int angle, int scale, const Common::Rect *clipRect, int32 flags, WizSimpleBitmap *optionalBitmapOverride, const WizRawPixel *optionalColorConversionTable) {
WizSimpleBitmap srcBitmap, dstBitmap;
- void *uncompressedWizStateData;
Common::Rect updateRect;
int compressionType;
diff --git a/engines/scumm/he/wiz_he.h b/engines/scumm/he/wiz_he.h
index 18629c48be3..c3371e0f1f2 100644
--- a/engines/scumm/he/wiz_he.h
+++ b/engines/scumm/he/wiz_he.h
@@ -352,7 +352,7 @@ enum WizActionFlags {
kWAFDestImage = 0x00010000,
kWAFColor = 0x00020000,
kWAFRenderCoords = 0x00040000,
- kWAFSourceImg = 0x00080000,
+ kWAFSourceImage = 0x00080000,
kWAFProperty = 0x00100000,
kWAFZBufferImage = 0x00200000
};
@@ -410,6 +410,12 @@ enum WizEllipseConstants {
kWECHalf = 32768 // Fixed point 1/2
};
+enum WizZPlaneOps {
+ kWZOIgnore = 0,
+ kWZOClear = 1,
+ kWZOSet = 2
+};
+
enum {
kWizXMap = 0,
kWizRMap,
@@ -456,6 +462,7 @@ public:
void polyRotatePoints(Common::Point *pts, int num, int alpha);
void polygonTransform(int resNum, int state, int po_x, int po_y, int angle, int zoom, Common::Point *vert);
void polyMovePolygonPoints(Common::Point *listOfPoints, int numverts, int deltaX, int deltaY);
+ bool polyIsRectangle(const Common::Point *points, int numverts);
void dwCreateRawWiz(int imageNum, int w, int h, int flags, int bitsPerPixel, int optionalSpotX, int optionalSpotY);
bool dwSetSimpleBitmapStructFromImage(int imageNum, int imageState, WizSimpleBitmap *destBM);
@@ -513,8 +520,7 @@ public:
void getWizImageSpot(uint8 *data, int state, int32 &x, int32 &y);
void loadWizCursor(int resId, int palette);
- void captureImage(uint8 *src, int srcPitch, int srcw, int srch, int resNum, const Common::Rect& r, int compType);
- void takeAWiz(int resNum, const Common::Rect &r, bool backBuffer, int compType);
+ void takeAWiz(int globnum, int x1, int y1, int x2, int y2, bool back, bool compress);
void simpleDrawAWiz(int image, int state, int x, int y, int flags);
void bufferAWiz(int image, int state, int x, int y, int z, int flags, int optionalShadowImage, int optionalZBufferImage, int whichPalette);
@@ -524,6 +530,7 @@ public:
int whichPalette, WizSimpleBitmap *optionalBitmapOverride, const WizImageCommand *optionalICmdPtr);
void *drawAWizPrim(int globNum, int state, int x, int y, int z, int shadowImage, int zbufferImage, const Common::Rect *optionalClipRect, int flags, WizSimpleBitmap *optionalBitmapOverride, const WizRawPixel *optionalColorConversionTable);
void *drawAWizPrimEx(int globNum, int state, int x, int y, int z, int shadowImage, int zbufferImage, const Common::Rect *optionalClipRect, int flags, WizSimpleBitmap *optionalBitmapOverride, const WizRawPixel *optionalColorConversionTable, const WizImageCommand *optionalICmdPtr);
+ void buildAWiz(const WizRawPixel *bufPtr, int bufWidth, int bufHeight, const byte *palettePtr, const Common::Rect *rectPtr, int compressionType, int globNum, int transparentColor);
uint8 *drawWizImage(int resNum, int state, int maskNum, int maskState, int x1, int y1, int zorder, int shadow, int zbuffer, const Common::Rect *clipBox, int flags, int dstResNum, const uint8 *palPtr, uint32 conditionBits);
void drawWizImageEx(uint8 *dst, uint8 *src, uint8 *mask, int dstPitch, int dstType, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, int state, const Common::Rect *rect, int flags, const uint8 *palPtr, int transColor, uint8 bitDepth, const uint8 *xmapPtr, uint32 conditionBits);
@@ -672,6 +679,49 @@ public:
WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream,
int skipAmount, int decompAmount, const WizRawPixel *conversionTable));
+ // Auxiliary compression routines
+ void auxWRLEUncompressPixelStream(WizRawPixel *destStream, const byte *singleColorTable, const byte *streamData, int streamSize, const WizRawPixel *conversionTable);
+ void auxWRLEUncompressAndCopyFromStreamOffset(WizRawPixel *destStream, const byte *singleColorTable, const byte *streamData, int streamSize, byte copyFromColor, int streamOffset, const WizRawPixel *conversionTable);
+
+ void auxDecompSRLEStream(WizRawPixel *destStream, const WizRawPixel *backgroundStream, const byte *singleColorTable, const byte *streamData, int streamSize, const WizRawPixel *conversionTable);
+
+ void auxDecompDRLEStream(WizRawPixel *destPtr, byte *dataStream, WizRawPixel *backgroundPtr, int skipAmount, int decompAmount, const WizRawPixel *conversionTable);
+ void auxDecompDRLEImage(WizRawPixel *foregroundBufferPtr, WizRawPixel *backgroundBufferPtr, byte *compData, int bufferWidth, int bufferHeight, int x, int y, int width, int height, Common::Rect *clipRectPtr, const WizRawPixel *conversionTable);
+ void auxDecompDRLEPrim(WizRawPixel *foregroundBufferPtr, WizRawPixel *backgroundBufferPtr, int bufferWidth, Common::Rect *destRect, byte *compData, Common::Rect *sourceRect, const WizRawPixel *conversionTable);
+
+ void auxDecompTRLEStream(WizRawPixel *destPtr, byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable);
+ void auxDecompTRLEImage(WizRawPixel *bufferPtr, byte *compData, int bufferWidth, int bufferHeight, int x, int y, int width, int height, Common::Rect *clipRectPtr, const WizRawPixel *conversionTable);
+ void auxDecompTRLEPrim(WizRawPixel *bufferPtr, int bufferWidth, Common::Rect *destRect, byte *compData, Common::Rect *sourceRect, const WizRawPixel *conversionTable);
+ void auxDrawZplaneFromTRLEImage(byte *zplanePtr, byte *compData, int zplanePixelWidth, int zplanePixelHeight, int x, int y, int width, int height, Common::Rect *clipRectPtr, int transOp, int solidOp);
+ void auxDrawZplaneFromTRLEPrim(byte *zplanePtr, int zplanePixelWidth, Common::Rect *destRect, byte *compData, Common::Rect *sourceRect, int transOp, int solidOp);
+
+ void auxDecompRemappedTRLEStream(WizRawPixel *destPtr, byte *dataStream, int skipAmount, int decompAmount, byte *remapTable, const WizRawPixel *conversionTable);
+ void auxDecompRemappedTRLEImage(WizRawPixel *bufferPtr, byte *compData, int bufferWidth, int bufferHeight, int x, int y, int width, int height, Common::Rect *clipRectPtr, byte *remapTable, const WizRawPixel *conversionTable);
+ void auxDecompRemappedTRLEPrim(WizRawPixel *bufferPtr, int bufferWidth, Common::Rect *destRect, byte *compData, Common::Rect *sourceRect, byte *remapTable, const WizRawPixel *conversionTable);
+
+ bool auxHitTestTRLEXPos(byte *dataStream, int skipAmount);
+ bool auxHitTestTRLEImageRelPos(byte *compData, int x, int y, int width, int height);
+ bool auxPixelHitTestTRLEXPos(byte *dataStream, int skipAmount, int transparentValue);
+ int auxPixelHitTestTRLEImageRelPos(byte *compData, int x, int y, int width, int height, int transparentValue);
+
+ void auxDecompMixColorsTRLEImage(WizRawPixel *bufferPtr, byte *compData, int bufferWidth, int bufferHeight, int x, int y, int width, int height, Common::Rect *clipRectPtr, byte *coloMixTable, const WizRawPixel *conversionTable);
+ void auxDecompMixColorsTRLEPrim(WizRawPixel *bufferPtr, int bufferWidth, Common::Rect *destRect, byte *compData, Common::Rect *sourceRect, byte *coloMixTable, const WizRawPixel *conversionTable);
+ void auxColorMixDecompressLine(
+ WizRawPixel *destPtr, const byte *dataStream, int skipAmount,
+ int decompAmount, const byte *colorMixTable,
+ const WizRawPixel *conversionTable);
+
+ void auxRemappedMemcpy(
+ WizRawPixel *dstPtr, byte *srcPtr, int count, byte *remapTable,
+ const WizRawPixel *conversionTable);
+
+ void auxZplaneFromTRLEStream(
+ byte *destPtr, byte *dataStream, int skipAmount, int decompAmount,
+ int mask, int transOp, int solidOp);
+
+ void auxHistogramTRLELine(int *tablePtr, const byte *dataStream, int skipAmount, int decompAmount);
+ void auxHistogramTRLEPrim(int *histogramTablePtr, byte *compData, Common::Rect *sourceRect);
+
/*
* Image Warping on Polygons Primitives
Commit: 0b0dc876a030fd9fb55da7f3cda3191514a17487
https://github.com/scummvm/scummvm/commit/0b0dc876a030fd9fb55da7f3cda3191514a17487
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Add remaining compression routines
Changed paths:
engines/scumm/he/gfx_comp/aux_comp.cpp
engines/scumm/he/gfx_comp/mrle_comp.cpp
engines/scumm/he/gfx_comp/trle_comp.cpp
engines/scumm/he/gfx_primitives_he.cpp
engines/scumm/he/intern_he.h
engines/scumm/he/script_v100he.cpp
engines/scumm/he/sprite_he.cpp
engines/scumm/he/wiz_he.cpp
engines/scumm/he/wiz_he.h
engines/scumm/he/wizwarp_he.cpp
diff --git a/engines/scumm/he/gfx_comp/aux_comp.cpp b/engines/scumm/he/gfx_comp/aux_comp.cpp
index e2c69157e73..f3e4ad1c68f 100644
--- a/engines/scumm/he/gfx_comp/aux_comp.cpp
+++ b/engines/scumm/he/gfx_comp/aux_comp.cpp
@@ -28,22 +28,18 @@
namespace Scumm {
-#define WRLE_QUICK_CACHE (0)
-#define WRLE_CAN_STOP_EARLY (0)
-#define TRACK_COMPRESSION_STATS (0)
-
-#define WRLE_BIT_SIZE(zp) (1 << (8-(zp)))
+#define WRLE_BIT_SIZE(zp) (1 << (8 - (zp)))
#define WRLE_TINY_RUN_BITS 0x01
#define WRLE_TINY_RUN_BIT_COUNT 1
#define WRLE_TINY_RUN_COUNT_BITS 2
#define WRLE_TINY_RUN_MIN_COUNT 3
-#define WRLE_TINY_RUN_BITS_OVERHEAD ((WRLE_TINY_RUN_BIT_COUNT)+(WRLE_TINY_RUN_COUNT_BITS))
+#define WRLE_TINY_RUN_BITS_OVERHEAD ((WRLE_TINY_RUN_BIT_COUNT) + (WRLE_TINY_RUN_COUNT_BITS))
#define WRLE_TINY_RUN_MAX_COUNT ((WRLE_TINY_RUN_MIN_COUNT) + ((1 << (WRLE_TINY_RUN_COUNT_BITS)) - 1))
#define WRLE_TRUN_BITS 0x00
#define WRLE_TRUN_BIT_COUNT 2
-#define WRLE_SMALL_TRUN_SIZE (WRLE_BIT_SIZE(WRLE_TRUN_BIT_COUNT)-1)
+#define WRLE_SMALL_TRUN_SIZE (WRLE_BIT_SIZE(WRLE_TRUN_BIT_COUNT) - 1)
#define WRLE_LARGE_TRUN_SIZE 65536
#define WRLE_SINGLE_COLOR_BITS 0x02
@@ -51,42 +47,36 @@ namespace Scumm {
#define WRLE_LESS_RUN_BITS 0x06
#define WRLE_LESS_RUN_BIT_COUNT 3
-#define WRLE_LESS_SMALL_RUN_SIZE (WRLE_BIT_SIZE(WRLE_LESS_RUN_BIT_COUNT)-1)
+#define WRLE_LESS_SMALL_RUN_SIZE (WRLE_BIT_SIZE(WRLE_LESS_RUN_BIT_COUNT) - 1)
#define WRLE_LESS_LARGE_RUN_SIZE 256
-#define AUX_IGNORE_ZPLANE_BITS(_dst, _mask, _count) \
- { \
- int _counter; \
- for (_counter = 0; _counter < _count; _counter++) { \
- if (0 == (_mask >>= 1)) { \
- _mask = 0x80; \
- _dst++; \
- } \
- } \
- }
-
-#define AUX_SET_ZPLANE_BITS(_dst, _mask, _count) \
- { \
- int _counter; \
- for (_counter = 0; _counter < _count; _counter++) { \
- *(_dst) |= _mask; \
- if (0 == (_mask >>= 1)) { \
- _mask = 0x80; \
- _dst++; \
- } \
- } \
- }
-
-#define AUX_CLEAR_ZPLANE_BITS(_dst, _mask, _count) \
- { \
- int _counter; \
- for (_counter = 0; _counter < _count; _counter++) { \
- *(_dst) &= ~_mask; \
- if (0 == (_mask >>= 1)) { \
- _mask = 0x80; \
- _dst++; \
- } \
- } \
+#define AUX_IGNORE_ZPLANE_BITS(_dst, _mask, _count) { \
+ for (int _counter = 0; _counter < _count; _counter++) { \
+ if (0 == (_mask >>= 1)) { \
+ _mask = 0x80; \
+ _dst++; \
+ } \
+ } \
+ }
+
+#define AUX_SET_ZPLANE_BITS(_dst, _mask, _count) { \
+ for (int _counter = 0; _counter < _count; _counter++) { \
+ *(_dst) |= _mask; \
+ if (0 == (_mask >>= 1)) { \
+ _mask = 0x80; \
+ _dst++; \
+ } \
+ } \
+ }
+
+#define AUX_CLEAR_ZPLANE_BITS(_dst, _mask, _count) { \
+ for (int _counter = 0; _counter < _count; _counter++) { \
+ *(_dst) &= ~_mask; \
+ if (0 == (_mask >>= 1)) { \
+ _mask = 0x80; \
+ _dst++; \
+ } \
+ } \
}
diff --git a/engines/scumm/he/gfx_comp/mrle_comp.cpp b/engines/scumm/he/gfx_comp/mrle_comp.cpp
index 2749e91acd0..f6b54ea3034 100644
--- a/engines/scumm/he/gfx_comp/mrle_comp.cpp
+++ b/engines/scumm/he/gfx_comp/mrle_comp.cpp
@@ -350,6 +350,9 @@ void Wiz::MRLEFLIP_AltSource_DecompressImage(
int x, int y, int width, int height, Common::Rect *clipRectPtr,
int32 wizFlags, const WizRawPixel *conversionTable) {
+ if (!_uses16BitColor)
+ error("Wiz::MRLEFLIP_AltSource_DecompressImage(): It's used, fix it...");
+
Common::Rect srcRect, clipRect;
WizCompressedImage fakeImage;
diff --git a/engines/scumm/he/gfx_comp/trle_comp.cpp b/engines/scumm/he/gfx_comp/trle_comp.cpp
index 6d6c1eaa9e8..42c7135b859 100644
--- a/engines/scumm/he/gfx_comp/trle_comp.cpp
+++ b/engines/scumm/he/gfx_comp/trle_comp.cpp
@@ -28,6 +28,2534 @@
namespace Scumm {
+#define TRLEFLIP_MEMSET(_dPt, _Pv, _rC) \
+ wiz->rawPixelMemset((_dPt), wiz->convert8BppToRawPixel(_Pv, conversionTable), (_rC))
+
+#define HANDLE_SKIP_PIXELS_MACRO() { \
+ /* Decompress bytes to do simple clipping... */ \
+ while (skipAmount > 0) { \
+ if ((runCount = *dataStream++) & 1) { \
+ /* Handle the transparent color... */ \
+ runCount >>= 1; \
+ if (runCount > skipAmount) { \
+ runCount -= skipAmount; \
+ goto DoTransparentRun; \
+ } else { \
+ skipAmount -= runCount; \
+ } \
+ } else if (runCount & 2) { \
+ /* Handle a run of color... */ \
+ runCount = (runCount >> 2) + 1; \
+ if (runCount > skipAmount) { \
+ runCount -= skipAmount; \
+ goto WriteRunData; \
+ } else { \
+ skipAmount -= runCount; \
+ dataStream += sizeof(byte); \
+ } \
+ } else { \
+ /* Handle a literal run of pixels... */ \
+ runCount = (runCount >> 2) + 1; \
+ if (runCount > skipAmount) { \
+ runCount -= skipAmount; \
+ dataStream += (skipAmount * sizeof(byte)); \
+ goto WriteLiteralData; \
+ } else { \
+ skipAmount -= runCount; \
+ dataStream += (runCount * sizeof(byte)); \
+ } \
+ } \
+ } \
+ }
+
+#define HANDLE_RUN_DECOMPRESS_MACRO(_TransparentCode_, _RunCode_, _LiteralCode_) { \
+ while (decompAmount > 0) { \
+ runCount = *dataStream++; \
+ \
+ if (runCount & 1) { /* xxxxxxx1 */ \
+ runCount >>= 1; \
+ DoTransparentRun: \
+ decompAmount -= runCount; \
+ _TransparentCode_ \
+ } else if (runCount & 2) { /* xxxxxx10 */ \
+ runCount = (runCount >> 2) + 1; \
+ WriteRunData: \
+ decompAmount -= runCount; \
+ if (decompAmount < 0) { \
+ runCount += decompAmount; \
+ } \
+ _RunCode_ \
+ dataStream++; \
+ } else { /* xxxxxx00 */ \
+ runCount = (runCount >> 2) + 1; \
+ WriteLiteralData: \
+ decompAmount -= runCount; \
+ if (decompAmount < 0) { \
+ runCount += decompAmount; \
+ } \
+ _LiteralCode_ \
+ dataStream += runCount; \
+ } \
+ } \
+ }
+
+#define TRLEFLIP_X_Foreward_MACRO(MEMSET_PARAM, MEMCPY_PARAM) { \
+ int runCount; \
+ HANDLE_SKIP_PIXELS_MACRO(); \
+ HANDLE_RUN_DECOMPRESS_MACRO( \
+ { destPtr += runCount; }, \
+ { \
+ (MEMSET_PARAM)( \
+ destPtr, wiz->convert8BppToRawPixel(*dataStream, conversionTable), runCount); \
+ destPtr += runCount; \
+ }, \
+ { \
+ (MEMCPY_PARAM)(destPtr, dataStream, runCount, conversionTable); \
+ destPtr += runCount; \
+ }); \
+ }
+
+#define TRLEFLIP_X_Backward_MACRO(MEMSET_PARAM, MEMCPY_PARAM) { \
+ int runCount; \
+ HANDLE_SKIP_PIXELS_MACRO(); \
+ HANDLE_RUN_DECOMPRESS_MACRO( \
+ { destPtr -= runCount; }, \
+ { \
+ destPtr -= runCount; \
+ (MEMSET_PARAM)( \
+ destPtr + 1, wiz->convert8BppToRawPixel(*dataStream, conversionTable), runCount); \
+ }, \
+ { \
+ (MEMCPY_PARAM)(destPtr, dataStream, runCount, conversionTable); \
+ destPtr -= runCount; \
+ }); \
+ }
+
+#define TRLEFLIP_X_ArbitraryDstStep_MACRO(COLOROPERATION) { \
+ int runCount; \
+ HANDLE_SKIP_PIXELS_MACRO(); \
+ HANDLE_RUN_DECOMPRESS_MACRO( \
+ { destPtr += (destStepValue * runCount); }, \
+ { \
+ WizRawPixel adjustedRunColor = wiz->convert8BppToRawPixel(*dataStream, conversionTable); \
+ for (int counter = 0; counter < runCount; counter++) { \
+ WizRawPixel workColor = *destPtr; \
+ *destPtr = (WizRawPixel)COLOROPERATION(workColor, adjustedRunColor); \
+ destPtr += destStepValue; \
+ } \
+ }, \
+ { \
+ const byte *src = (const byte *)dataStream; \
+ for (int counter = 0; counter < runCount; counter++) { \
+ WizRawPixel adjustedRunColor = wiz->convert8BppToRawPixel(*src++, conversionTable); \
+ WizRawPixel workColor = *destPtr; \
+ *destPtr = (WizRawPixel)COLOROPERATION(workColor, adjustedRunColor); \
+ destPtr += destStepValue; \
+ } \
+ }); \
+ }
+
+#define TRLEFLIP_ALTX_Foreward_MACRO(X_MEMSET_PARAM, X_MEMCPY_PARAM) { \
+ const WizRawPixel *srcPtr = (const WizRawPixel *)altSourcePtr; \
+ int runCount; \
+ HANDLE_SKIP_PIXELS_MACRO(); \
+ HANDLE_RUN_DECOMPRESS_MACRO( \
+ { destPtr += runCount; srcPtr += runCount; }, \
+ { \
+ X_MEMSET_PARAM(wiz, \
+ destPtr, srcPtr, wiz->convert8BppToRawPixel(*dataStream, conversionTable), runCount); \
+ destPtr += runCount; \
+ srcPtr += runCount; \
+ }, \
+ { \
+ X_MEMCPY_PARAM(wiz, destPtr, srcPtr, dataStream, runCount, conversionTable); \
+ destPtr += runCount; \
+ srcPtr += runCount; \
+ }); \
+ }
+
+#define TRLEFLIP_ALTX_Backward_MACRO(X_MEMSET_PARAM, X_MEMCPY_PARAM) { \
+ const WizRawPixel *srcPtr = (const WizRawPixel *)altSourcePtr; \
+ int runCount; \
+ HANDLE_SKIP_PIXELS_MACRO(); \
+ HANDLE_RUN_DECOMPRESS_MACRO( \
+ {destPtr -= runCount; srcPtr -= runCount; }, \
+ { \
+ destPtr -= runCount; \
+ srcPtr -= runCount; \
+ X_MEMSET_PARAM(wiz, \
+ destPtr + 1, srcPtr + 1, wiz->convert8BppToRawPixel(*dataStream, conversionTable), runCount); \
+ }, \
+ { \
+ X_MEMCPY_PARAM(wiz, destPtr, srcPtr, dataStream, runCount, conversionTable); \
+ destPtr -= runCount; \
+ srcPtr -= runCount; \
+ }); \
+ }
+
+#define TRLE_DUMP 0
+#define TRLE_RUN 1
+#define TRLE_MINRUN 3
+#define TRLE_MAXRUN 128
+#define TRLE_MAXDAT 128
+
+#define trle_putbyte(c) { \
+ if (dest) { \
+ *dest++ = (c); \
+ } \
+ ++_trlePutsize; \
+ }
+#define trle_outdump(nn) dest = trle_putdump(dest, nn)
+#define trle_outrun(nn, cc) dest = trle_putrun(dest, nn, cc, tcolor)
+
+
+void Wiz::TRLEFLIP_CheckAlphaSetup() {
+ if (s_InitializelphaTable && _uses16BitColor) {
+ s_InitializelphaTable = false;
+
+ // int alpha to float table
+ for (int i = 1; i < 255; i++) {
+ s_AlphaTable[i] = (float)i / 255.0f;
+ }
+
+ // Force 0 & 255 values just incase the float accuracy is bad.
+ s_AlphaTable[0] = 0.0f;
+ s_AlphaTable[255] = 1.0f;
+
+ // Quantized pre-computed alpha results.
+ int alpha_index = 0;
+
+ for (int alpha = 0; alpha < 256; alpha += WIZ_QUANTIZED_ALPHA_DIV, alpha_index++) {
+ float fa = (float)(alpha + WIZ_QUANTIZED_ALPHA_DIV - 1) / 255.0f;
+ float ia = 1.0f - fa;
+
+ for (int colorA = 0; colorA < WIZ_COLOR16_COMPONENT_COUNT; colorA++) {
+ float ca = (float)colorA * fa;
+
+ for (int colorB = 0; colorB < WIZ_COLOR16_COMPONENT_COUNT; colorB++) {
+ int value = (int)(ca + ((float)colorB * ia));
+ s_Precomputed16bppTable[alpha_index][colorA][colorB] = value;
+ }
+ }
+ }
+ }
+}
+
+WizRawPixel Wiz::TRLEFLIP_AlphaMixPrim(WizRawPixel b, WizRawPixel a, int alpha) {
+ int quantized = (alpha / WIZ_QUANTIZED_ALPHA_DIV);
+
+ return (
+ ((s_Precomputed16bppTable[quantized]
+ [((a & WIZRAWPIXEL_R_MASK) >> WIZRAWPIXEL_R_SHIFT)]
+ [((b & WIZRAWPIXEL_R_MASK) >> WIZRAWPIXEL_R_SHIFT)])
+ << WIZRAWPIXEL_R_SHIFT) |
+ ((s_Precomputed16bppTable[quantized]
+ [((a & WIZRAWPIXEL_G_MASK) >> WIZRAWPIXEL_G_SHIFT)]
+ [((b & WIZRAWPIXEL_G_MASK) >> WIZRAWPIXEL_G_SHIFT)])
+ << WIZRAWPIXEL_G_SHIFT) |
+ ((s_Precomputed16bppTable[quantized]
+ [((a & WIZRAWPIXEL_B_MASK) >> WIZRAWPIXEL_B_SHIFT)]
+ [((b & WIZRAWPIXEL_B_MASK) >> WIZRAWPIXEL_B_SHIFT)])
+ << WIZRAWPIXEL_B_SHIFT));
+}
+
+void TRLEFLIP_HorzFlipAlignWithRect(Common::Rect *rectToAlign, const Common::Rect *baseRect) {
+ int dx = (baseRect->right - rectToAlign->right) - (rectToAlign->left - baseRect->left);
+ rectToAlign->left += dx;
+ rectToAlign->right += dx;
+}
+
+void TRLEFLIP_VertFlipAlignWithRect(Common::Rect *rectToAlign, const Common::Rect *baseRect) {
+ int dy = (baseRect->bottom - rectToAlign->bottom) - (rectToAlign->top - baseRect->top);
+ rectToAlign->top += dy;
+ rectToAlign->bottom += dy;
+}
+
+void Wiz::TRLEFLIP_DecompImageHull(
+ WizRawPixel *bufferPtr, int bufferWidth, const Common::Rect *destRect,
+ const byte *compData, const Common::Rect *sourceRect, const void *extraPtr,
+ const WizRawPixel *conversionTable,
+ void (*functionPtr)(Wiz *wiz,
+ WizRawPixel *destPtr, const byte *dataStream, int skipAmount,
+ int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable)) {
+ int decompWidth, decompHeight, counter, sX1, lineSize;
+
+ // General setup...
+ sX1 = sourceRect->left;
+ decompWidth = sourceRect->right - sourceRect->left + 1;
+ decompHeight = sourceRect->bottom - sourceRect->top + 1;
+
+ // Quickly skip down to the lines to be compressed & dest position...
+ WizRawPixel8 *buf8 = (WizRawPixel8 *)bufferPtr;
+ WizRawPixel16 *buf16 = (WizRawPixel16 *)bufferPtr;
+
+ if (_uses16BitColor) {
+ buf16 += bufferWidth * destRect->top + destRect->left;
+ bufferPtr = (WizRawPixel *)buf16;
+ } else {
+ buf8 += bufferWidth * destRect->top + destRect->left;
+ bufferPtr = (WizRawPixel *)buf8;
+ }
+
+ for (counter = sourceRect->top; counter > 0; counter--) {
+ compData += READ_LE_UINT16((byte *)compData) + 2;
+ }
+
+ // Flip the dest offset if vertical flipping...
+ if (destRect->top > destRect->bottom) {
+ bufferWidth = -bufferWidth;
+ }
+
+ // Decompress all the lines that are visible!!!!
+ while (decompHeight-- > 0) {
+ lineSize = READ_LE_UINT16((byte *)compData);
+
+ if (lineSize != 0) {
+ (*functionPtr)(this, bufferPtr, compData + 2, sX1, decompWidth, extraPtr, conversionTable);
+ compData += lineSize + 2;
+
+ if (_uses16BitColor) {
+ buf16 = (WizRawPixel16 *)bufferPtr;
+ buf16 += bufferWidth;
+ bufferPtr = (WizRawPixel *)buf16;
+ } else {
+ buf8 = (WizRawPixel8 *)bufferPtr;
+ buf8 += bufferWidth;
+ bufferPtr = (WizRawPixel *)buf8;
+ }
+ } else {
+ // Handle a completely transparent line!
+ compData += 2;
+
+ if (_uses16BitColor) {
+ buf16 = (WizRawPixel16 *)bufferPtr;
+ buf16 += bufferWidth;
+ bufferPtr = (WizRawPixel *)buf16;
+ } else {
+ buf8 = (WizRawPixel8 *)bufferPtr;
+ buf8 += bufferWidth;
+ bufferPtr = (WizRawPixel *)buf8;
+ }
+ }
+ }
+}
+
+void Wiz::TRLEFLIP_DecompressPrim(
+ WizSimpleBitmap *bitmapPtr, const COMPRESSEDIMAGE *imagePtr, int destX, int destY,
+ const Common::Rect *sourceCoords, const Common::Rect *clipRectPtr, const void *extraPtr,
+ int32 flags, const WizRawPixel *conversionTable,
+ void (*forewordFunctionPtr)(Wiz *wiz,
+ WizRawPixel *destPtr, const byte *dataStream, int skipAmount,
+ int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable),
+ void (*backwardFunctionPtr)(Wiz *wiz,
+ WizRawPixel *destPtr, const byte *dataStream, int skipAmount,
+ int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable)) {
+
+ Common::Rect sourceRect, destRect, clipRect, workRect, inSourceRect;
+ int width, height, bufferWidth, bufferHeight;
+
+ void (*functionPtr)(Wiz *wiz,
+ WizRawPixel * destPtr, const byte *dataStream, int skipAmount,
+ int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable);
+
+ bufferWidth = bitmapPtr->bitmapWidth;
+ bufferHeight = bitmapPtr->bitmapHeight;
+
+ if (!sourceCoords) {
+ width = imagePtr->width;
+ height = imagePtr->height;
+
+ sourceRect.left = 0;
+ sourceRect.top = 0;
+ sourceRect.right = width - 1;
+ sourceRect.bottom = height - 1;
+ } else {
+ width = sourceCoords->right - sourceCoords->left + 1;
+ height = sourceCoords->bottom - sourceCoords->top + 1;
+ sourceRect = *sourceCoords;
+ }
+
+ inSourceRect = sourceRect;
+
+ destRect.left = destX;
+ destRect.top = destY;
+ destRect.right = destX + width - 1;
+ destRect.bottom = destY + height - 1;
+
+ // Custom clip rect...
+ if (clipRectPtr) {
+ clipRect = *clipRectPtr;
+
+ workRect.left = 0;
+ workRect.top = 0;
+ workRect.right = bufferWidth - 1;
+ workRect.bottom = bufferHeight - 1;
+
+ if (!findRectOverlap(&clipRect, &workRect)) {
+ return;
+ }
+ } else {
+ clipRect.left = 0;
+ clipRect.top = 0;
+ clipRect.right = bufferWidth - 1;
+ clipRect.bottom = bufferHeight - 1;
+ }
+
+ // Clip the source & dest coords to the clipping rectangle...
+ clipRectCoords(&sourceRect, &destRect, &clipRect);
+
+ if (destRect.right < destRect.left) {
+ return;
+ }
+
+ if (destRect.bottom < destRect.top) {
+ return;
+ }
+
+ if (sourceRect.right < sourceRect.left) {
+ return;
+ }
+
+ if (sourceRect.bottom < sourceRect.top) {
+ return;
+ }
+
+ // Handle the flip coords source adjustment...
+ if (flags & kWRFHFlip) {
+ functionPtr = backwardFunctionPtr;
+ TRLEFLIP_HorzFlipAlignWithRect(&sourceRect, &inSourceRect);
+ swapRectX(&destRect);
+ } else {
+ functionPtr = forewordFunctionPtr;
+ }
+
+ if (flags & kWRFVFlip) {
+ TRLEFLIP_VertFlipAlignWithRect(&sourceRect, &inSourceRect);
+ swapRectY(&destRect);
+ }
+
+ // Call the primitive image renderer...
+ TRLEFLIP_DecompImageHull(
+ bitmapPtr->bufferPtr, bufferWidth, &destRect, imagePtr->data,
+ &sourceRect, extraPtr, conversionTable, functionPtr);
+}
+
+void Wiz::TRLEFLIP_50_50_Mix_PixelMemset(WizRawPixel *dstPtr, WizRawPixel mixColor, int size) {
+ WizRawPixel adjustedColor = WIZRAWPIXEL_50_50_PREMIX_COLOR(mixColor);
+
+ while (size-- > 0) {
+ *dstPtr++ = WIZRAWPIXEL_50_50_MIX(
+ adjustedColor, WIZRAWPIXEL_50_50_PREMIX_COLOR(*dstPtr));
+ }
+}
+
+void Wiz::TRLEFLIP_50_50_Mix_ForwardPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable) {
+ while (size-- > 0) {
+ WizRawPixel srcColor = convert8BppToRawPixel(*srcPtr++, conversionTable);
+ *dstPtr++ = WIZRAWPIXEL_50_50_MIX(
+ WIZRAWPIXEL_50_50_PREMIX_COLOR(srcColor),
+ WIZRAWPIXEL_50_50_PREMIX_COLOR(*dstPtr));
+ }
+}
+
+void Wiz::TRLEFLIP_50_50_Mix_BackwardsPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable) {
+ while (size-- > 0) {
+ WizRawPixel srcColor = convert8BppToRawPixel(*srcPtr++, conversionTable);
+ *dstPtr-- = WIZRAWPIXEL_50_50_MIX(
+ WIZRAWPIXEL_50_50_PREMIX_COLOR(srcColor),
+ WIZRAWPIXEL_50_50_PREMIX_COLOR(*dstPtr));
+ }
+}
+
+void Wiz::TRLEFLIP_ADDITIVE_PixelMemset(WizRawPixel *dstPtr, WizRawPixel mixColor, int size) {
+ while (size-- > 0) {
+ WizRawPixel workColor = *dstPtr;
+
+ *dstPtr++ = (WizRawPixel)WIZRAWPIXEL_ADDITIVE_MIX(workColor, mixColor);
+ }
+}
+
+void Wiz::TRLEFLIP_ADDITIVE_ForwardPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable) {
+ while (size-- > 0) {
+ WizRawPixel srcColor = convert8BppToRawPixel(*srcPtr++, conversionTable);
+ WizRawPixel workColor = *dstPtr;
+
+ *dstPtr++ = (WizRawPixel)WIZRAWPIXEL_ADDITIVE_MIX(workColor, srcColor);
+ }
+}
+
+void Wiz::TRLEFLIP_ADDITIVE_BackwardsPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable) {
+ while (size-- > 0) {
+ WizRawPixel srcColor = convert8BppToRawPixel(*srcPtr++, conversionTable);
+ WizRawPixel workColor = *dstPtr;
+
+ *dstPtr-- = (WizRawPixel)WIZRAWPIXEL_ADDITIVE_MIX(workColor, srcColor);
+ }
+}
+void Wiz::TRLEFLIP_SUBTRACTIVE_PixelMemset(WizRawPixel *dstPtr, WizRawPixel mixColor, int size) {
+ while (size-- > 0) {
+ WizRawPixel workColor = *dstPtr;
+
+ *dstPtr++ = (WizRawPixel)WIZRAWPIXEL_SUBTRACTIVE_MIX(workColor, mixColor);
+ }
+}
+
+void Wiz::TRLEFLIP_SUBTRACTIVE_ForwardPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable) {
+ while (size-- > 0) {
+ WizRawPixel srcColor = convert8BppToRawPixel(*srcPtr++, conversionTable);
+ WizRawPixel workColor = *dstPtr;
+
+ *dstPtr++ = (WizRawPixel)WIZRAWPIXEL_SUBTRACTIVE_MIX(workColor, srcColor);
+ }
+}
+
+void Wiz::TRLEFLIP_SUBTRACTIVE_BackwardsPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable) {
+ while (size-- > 0) {
+ WizRawPixel srcColor = convert8BppToRawPixel(*srcPtr++, conversionTable);
+ WizRawPixel workColor = *dstPtr;
+
+ *dstPtr-- = (WizRawPixel)WIZRAWPIXEL_SUBTRACTIVE_MIX(workColor, srcColor);
+ }
+}
+
+void Wiz::TRLEFLIP_RemapDestPixels(WizRawPixel *dstPtr, int size, const byte *lookupTable) {
+ if (!_uses16BitColor) {
+ while (size-- > 0) {
+ *dstPtr++ = *(lookupTable + *dstPtr);
+ }
+ }
+}
+
+void Wiz::TRLEFLIP_ForwardPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable) {
+ WizRawPixel8 *buf8 = (WizRawPixel8 *)dstPtr;
+ WizRawPixel16 *buf16 = (WizRawPixel16 *)dstPtr;
+
+ while (size-- > 0) {
+ if (_uses16BitColor) {
+ *buf16++ = (WizRawPixel16)convert8BppToRawPixel(*srcPtr++, conversionTable);
+ } else {
+ *buf8++ = (WizRawPixel8)convert8BppToRawPixel(*srcPtr++, conversionTable);
+ }
+
+ //*dstPtr++ = convert8BppToRawPixel(*srcPtr++, conversionTable);
+ }
+
+ if (_uses16BitColor) {
+ dstPtr = (WizRawPixel *)buf16;
+ } else {
+ dstPtr = (WizRawPixel *)buf8;
+ }
+}
+
+void Wiz::TRLEFLIP_BackwardsPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable) {
+ WizRawPixel8 *buf8 = (WizRawPixel8 *)dstPtr;
+ WizRawPixel16 *buf16 = (WizRawPixel16 *)dstPtr;
+
+ while (size-- > 0) {
+ if (_uses16BitColor) {
+ *buf16-- = (WizRawPixel16)convert8BppToRawPixel(*srcPtr++, conversionTable);
+ } else {
+ *buf8-- = (WizRawPixel8)convert8BppToRawPixel(*srcPtr++, conversionTable);
+ }
+
+ //*dstPtr-- = convert8BppToRawPixel(*srcPtr++, conversionTable);
+ }
+
+ if (_uses16BitColor) {
+ dstPtr = (WizRawPixel *)buf16;
+ } else {
+ dstPtr = (WizRawPixel *)buf8;
+ }
+}
+
+void Wiz::TRLEFLIP_ForewordLookupPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const byte *lookupTable, const WizRawPixel *conversionTable) {
+ WizRawPixel8 *buf8 = (WizRawPixel8 *)dstPtr;
+ WizRawPixel16 *buf16 = (WizRawPixel16 *)dstPtr;
+
+ while (size-- > 0) {
+ if (_uses16BitColor) {
+ *buf16++ = (WizRawPixel16)convert8BppToRawPixel(*(lookupTable + *srcPtr++), conversionTable);
+ } else {
+ *buf8++ = (WizRawPixel8)convert8BppToRawPixel(*(lookupTable + *srcPtr++), conversionTable);
+ }
+
+ //*dstPtr++ = convert8BppToRawPixel(*(lookupTable + *srcPtr++), conversionTable);
+ }
+
+ if (_uses16BitColor) {
+ dstPtr = (WizRawPixel *)buf16;
+ } else {
+ dstPtr = (WizRawPixel *)buf8;
+ }
+}
+
+void Wiz::TRLEFLIP_BackwardsLookupPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const byte *lookupTable, const WizRawPixel *conversionTable) {
+ WizRawPixel8 *buf8 = (WizRawPixel8 *)dstPtr;
+ WizRawPixel16 *buf16 = (WizRawPixel16 *)dstPtr;
+
+ while (size-- > 0) {
+ if (_uses16BitColor) {
+ *buf16-- = (WizRawPixel16)convert8BppToRawPixel(*(lookupTable + *srcPtr++), conversionTable);
+ } else {
+ *buf8-- = (WizRawPixel8)convert8BppToRawPixel(*(lookupTable + *srcPtr++), conversionTable);
+ }
+
+ //*dstPtr-- = convert8BppToRawPixel(*(lookupTable + *srcPtr++), conversionTable);
+ }
+
+ if (_uses16BitColor) {
+ dstPtr = (WizRawPixel *)buf16;
+ } else {
+ dstPtr = (WizRawPixel *)buf8;
+ }
+}
+
+void Wiz::TRLEFLIP_ForewordMixColorsPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const byte *lookupTable) {
+ WizRawPixel8 *buf8 = (WizRawPixel8 *)dstPtr;
+ WizRawPixel16 *buf16 = (WizRawPixel16 *)dstPtr;
+
+ while (size-- > 0) {
+ if (!_uses16BitColor) {
+ *buf8++ = *(lookupTable + ((*srcPtr++) * 256) + *buf8);
+ //*dstPtr++ = *(lookupTable + ((*srcPtr++) * 256) + *dstPtr);
+ } else {
+ *buf16++ = *srcPtr++;
+ //*dstPtr++ = *srcPtr++;
+ }
+ }
+
+ if (_uses16BitColor) {
+ dstPtr = (WizRawPixel *)buf16;
+ } else {
+ dstPtr = (WizRawPixel *)buf8;
+ }
+}
+
+void Wiz::TRLEFLIP_BackwardsMixColorsPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const byte *lookupTable) {
+ WizRawPixel8 *buf8 = (WizRawPixel8 *)dstPtr;
+ WizRawPixel16 *buf16 = (WizRawPixel16 *)dstPtr;
+
+ while (size-- > 0) {
+ if (!_uses16BitColor) {
+ *buf8-- = *(lookupTable + ((*srcPtr++) * 256) + *buf8);
+ //*dstPtr-- = *(lookupTable + ((*srcPtr++) * 256) + *dstPtr);
+ } else {
+ *buf16-- = *srcPtr++;
+ //*dstPtr-- = *srcPtr++;
+ }
+ }
+
+ if (_uses16BitColor) {
+ dstPtr = (WizRawPixel *)buf16;
+ } else {
+ dstPtr = (WizRawPixel *)buf8;
+ }
+}
+
+static void TRLEFLIP_ADDATIVE_DecompressLineForeword(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable) {
+ TRLEFLIP_X_Foreward_MACRO(
+ wiz->TRLEFLIP_ADDITIVE_PixelMemset,
+ wiz->TRLEFLIP_ADDITIVE_ForwardPixelCopy);
+}
+
+static void TRLEFLIP_ADDATIVE_DecompressLineBackward(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable) {
+ TRLEFLIP_X_Backward_MACRO(
+ wiz->TRLEFLIP_ADDITIVE_PixelMemset,
+ wiz->TRLEFLIP_ADDITIVE_BackwardsPixelCopy);
+}
+
+static void TRLEFLIP_SUBTRACTIVE_DecompressLineForeword(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable) {
+ TRLEFLIP_X_Foreward_MACRO(
+ wiz->TRLEFLIP_SUBTRACTIVE_PixelMemset,
+ wiz->TRLEFLIP_SUBTRACTIVE_ForwardPixelCopy);
+}
+
+static void TRLEFLIP_SUBTRACTIVE_DecompressLineBackward(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable) {
+ TRLEFLIP_X_Backward_MACRO(
+ wiz->TRLEFLIP_SUBTRACTIVE_PixelMemset,
+ wiz->TRLEFLIP_SUBTRACTIVE_BackwardsPixelCopy);
+}
+
+static void TRLEFLIP_DecompressLineForeword(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable) {
+ int runCount;
+ WizRawPixel8 *dest8 = (WizRawPixel8 *)destPtr;
+ WizRawPixel16 *dest16 = (WizRawPixel16 *)destPtr;
+
+ // Decompress bytes to do simple clipping...
+ HANDLE_SKIP_PIXELS_MACRO();
+
+ // Really decompress to the dest buffer...
+ HANDLE_RUN_DECOMPRESS_MACRO(
+ {
+ if (wiz->_uses16BitColor) {
+ dest16 += runCount;
+ destPtr = (WizRawPixel *)dest16;
+ } else {
+ dest8 += runCount;
+ destPtr = (WizRawPixel *)dest8;
+ }
+ },
+ {
+ TRLEFLIP_MEMSET(destPtr, *((byte *)dataStream), runCount);
+ if (wiz->_uses16BitColor) {
+ dest16 += runCount;
+ destPtr = (WizRawPixel *)dest16;
+ } else {
+ dest8 += runCount;
+ destPtr = (WizRawPixel *)dest8;
+ }
+ },
+ {
+ wiz->TRLEFLIP_ForwardPixelCopy(destPtr, dataStream, runCount, conversionTable);
+ if (wiz->_uses16BitColor) {
+ dest16 += runCount;
+ destPtr = (WizRawPixel *)dest16;
+ } else {
+ dest8 += runCount;
+ destPtr = (WizRawPixel *)dest8;
+ }
+ });
+}
+
+static void TRLEFLIP_DecompressLineBackward(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable) {
+ int runCount;
+ WizRawPixel8 *dest8 = (WizRawPixel8 *)destPtr;
+ WizRawPixel16 *dest16 = (WizRawPixel16 *)destPtr;
+
+ // Decompress bytes to do simple clipping...
+ HANDLE_SKIP_PIXELS_MACRO();
+
+ // Really decompress to the dest buffer...
+ HANDLE_RUN_DECOMPRESS_MACRO(
+ {
+ if (wiz->_uses16BitColor) {
+ dest16 -= runCount;
+ destPtr = (WizRawPixel *)dest16;
+ } else {
+ dest8 -= runCount;
+ destPtr = (WizRawPixel *)dest8;
+ }
+ },
+ {
+ if (wiz->_uses16BitColor) {
+ dest16 -= runCount;
+ destPtr = (WizRawPixel *)dest16;
+ } else {
+ dest8 -= runCount;
+ destPtr = (WizRawPixel *)dest8;
+ }
+ TRLEFLIP_MEMSET(destPtr + 1, *((byte *)dataStream), runCount);
+ },
+ {
+ wiz->TRLEFLIP_BackwardsPixelCopy(destPtr, dataStream, runCount, conversionTable);
+ if (wiz->_uses16BitColor) {
+ dest16 -= runCount;
+ destPtr = (WizRawPixel *)dest16;
+ } else {
+ dest8 -= runCount;
+ destPtr = (WizRawPixel *)dest8;
+ }
+ });
+}
+
+static void TRLEFLIP_LookupDecompressLineForeword(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable) {
+ const byte *lookupTable;
+ int runCount;
+ WizRawPixel8 *dest8 = (WizRawPixel8 *)destPtr;
+ WizRawPixel16 *dest16 = (WizRawPixel16 *)destPtr;
+
+ lookupTable = (byte *)extraPtr;
+
+ // Decompress bytes to do simple clipping...
+ HANDLE_SKIP_PIXELS_MACRO();
+
+ // Really decompress to the dest buffer...
+ HANDLE_RUN_DECOMPRESS_MACRO(
+ {
+ if (wiz->_uses16BitColor) {
+ dest16 += runCount;
+ destPtr = (WizRawPixel *)dest16;
+ } else {
+ dest8 += runCount;
+ destPtr = (WizRawPixel *)dest8;
+ }
+ },
+ {
+ TRLEFLIP_MEMSET(destPtr, *(lookupTable + *dataStream), runCount);
+ if (wiz->_uses16BitColor) {
+ dest16 += runCount;
+ destPtr = (WizRawPixel *)dest16;
+ } else {
+ dest8 += runCount;
+ destPtr = (WizRawPixel *)dest8;
+ }
+ },
+ {
+ wiz->TRLEFLIP_ForewordLookupPixelCopy(destPtr, dataStream, runCount, lookupTable, conversionTable);
+ if (wiz->_uses16BitColor) {
+ dest16 += runCount;
+ destPtr = (WizRawPixel *)dest16;
+ } else {
+ dest8 += runCount;
+ destPtr = (WizRawPixel *)dest8;
+ }
+ });
+}
+
+static void TRLEFLIP_LookupDecompressLineBackward(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable) {
+ const byte *lookupTable;
+ int runCount;
+ WizRawPixel8 *dest8 = (WizRawPixel8 *)destPtr;
+ WizRawPixel16 *dest16 = (WizRawPixel16 *)destPtr;
+
+ lookupTable = (byte *)extraPtr;
+
+ // Decompress bytes to do simple clipping...
+ HANDLE_SKIP_PIXELS_MACRO();
+
+ // Really decompress to the dest buffer...
+ HANDLE_RUN_DECOMPRESS_MACRO(
+ {
+ if (wiz->_uses16BitColor) {
+ dest16 -= runCount;
+ destPtr = (WizRawPixel *)dest16;
+ } else {
+ dest8 -= runCount;
+ destPtr = (WizRawPixel *)dest8;
+ }
+ },
+ {
+ if (wiz->_uses16BitColor) {
+ dest16 -= runCount;
+ destPtr = (WizRawPixel *)dest16;
+ } else {
+ dest8 -= runCount;
+ destPtr = (WizRawPixel *)dest8;
+ }
+ TRLEFLIP_MEMSET(destPtr + 1, *(lookupTable + *dataStream), runCount);
+ },
+ {
+ wiz->TRLEFLIP_BackwardsLookupPixelCopy(destPtr, dataStream, runCount, lookupTable, conversionTable);
+ if (wiz->_uses16BitColor) {
+ dest16 -= runCount;
+ destPtr = (WizRawPixel *)dest16;
+ } else {
+ dest8 -= runCount;
+ destPtr = (WizRawPixel *)dest8;
+ }
+ });
+}
+
+static void TRLEFLIP_MixDecompressLineForeword(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable) {
+ const byte *lookupTable;
+ int runCount;
+ WizRawPixel8 *dest8 = (WizRawPixel8 *)destPtr;
+ WizRawPixel16 *dest16 = (WizRawPixel16 *)destPtr;
+
+ lookupTable = (byte *)extraPtr;
+
+ // Decompress bytes to do simple clipping...
+ HANDLE_SKIP_PIXELS_MACRO();
+
+ // Really decompress to the dest buffer...
+ HANDLE_RUN_DECOMPRESS_MACRO(
+ {
+ if (wiz->_uses16BitColor) {
+ dest16 += runCount;
+ destPtr = (WizRawPixel *)dest16;
+ } else {
+ dest8 += runCount;
+ destPtr = (WizRawPixel *)dest8;
+ }
+ },
+ {
+ if (!wiz->_uses16BitColor) {
+ wiz->TRLEFLIP_RemapDestPixels(destPtr, runCount, lookupTable + (*dataStream * 256));
+ dest8 += runCount;
+ destPtr = (WizRawPixel *)dest8;
+ } else {
+ wiz->TRLEFLIP_50_50_Mix_PixelMemset(
+ destPtr, wiz->convert8BppToRawPixel(*dataStream, conversionTable), runCount);
+
+ dest16 += runCount;
+ destPtr = (WizRawPixel *)dest16;
+ }
+ },
+ {
+ if (!wiz->_uses16BitColor) {
+ wiz->TRLEFLIP_ForewordMixColorsPixelCopy(destPtr, dataStream, runCount, lookupTable);
+ dest8 += runCount;
+ destPtr = (WizRawPixel *)dest8;
+ } else {
+ wiz->TRLEFLIP_50_50_Mix_ForwardPixelCopy(destPtr, dataStream, runCount, conversionTable);
+ dest16 += runCount;
+ destPtr = (WizRawPixel *)dest16;
+ }
+ });
+}
+
+static void TRLEFLIP_MixDecompressLineBackward(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable) {
+ const byte *lookupTable;
+ int runCount;
+ WizRawPixel8 *dest8 = (WizRawPixel8 *)destPtr;
+ WizRawPixel16 *dest16 = (WizRawPixel16 *)destPtr;
+
+ lookupTable = (byte *)extraPtr;
+
+ // Decompress bytes to do simple clipping...
+ HANDLE_SKIP_PIXELS_MACRO();
+
+ // Really decompress to the dest buffer...
+ HANDLE_RUN_DECOMPRESS_MACRO(
+ {
+ if (wiz->_uses16BitColor) {
+ dest16 -= runCount;
+ destPtr = (WizRawPixel *)dest16;
+ } else {
+ dest8 -= runCount;
+ destPtr = (WizRawPixel *)dest8;
+ }
+ },
+ {
+ if (!wiz->_uses16BitColor) {
+ dest8 -= runCount;
+ destPtr = (WizRawPixel *)dest8;
+ wiz->TRLEFLIP_RemapDestPixels(destPtr + 1, runCount, lookupTable + (*dataStream * 256));
+ } else {
+ dest16 -= runCount;
+ destPtr = (WizRawPixel *)dest16;
+ wiz->TRLEFLIP_50_50_Mix_PixelMemset(
+ destPtr, wiz->convert8BppToRawPixel(*dataStream, conversionTable), runCount);
+ }
+ },
+ {
+ if (!wiz->_uses16BitColor) {
+ wiz->TRLEFLIP_BackwardsMixColorsPixelCopy(destPtr, dataStream, runCount, lookupTable);
+ dest8 -= runCount;
+ destPtr = (WizRawPixel *)dest8;
+ } else {
+ wiz->TRLEFLIP_50_50_Mix_BackwardsPixelCopy(destPtr, dataStream, runCount, conversionTable);
+ dest16 -= runCount;
+ destPtr = (WizRawPixel *)dest16;
+ }
+ });
+}
+
+static void TRLEFLIP_ArbitraryDstStepDecompressLine(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *userParam, int destStepValue, const WizRawPixel *conversionTable) {
+ int runCount;
+ WizRawPixel8 *dest8 = (WizRawPixel8 *)destPtr;
+ WizRawPixel16 *dest16 = (WizRawPixel16 *)destPtr;
+
+ // Decompress bytes to do simple clipping...
+ HANDLE_SKIP_PIXELS_MACRO();
+
+ // Really decompress to the dest buffer...
+ HANDLE_RUN_DECOMPRESS_MACRO(
+ {
+ if (!wiz->_uses16BitColor) {
+ while (--runCount >= 0) {
+ dest8 += destStepValue;
+ }
+
+ destPtr = (WizRawPixel *)dest8;
+ } else {
+ while (--runCount >= 0) {
+ dest16 += destStepValue;
+ }
+
+ destPtr = (WizRawPixel *)dest16;
+ }
+ },
+ {
+ if (!wiz->_uses16BitColor) {
+ WizRawPixel8 val8 = (WizRawPixel8)wiz->convert8BppToRawPixel(*dataStream, conversionTable);
+
+ for (int counter = 0; counter < runCount; counter++) {
+ *dest8 = val8;
+ dest8 += destStepValue;
+ }
+
+ destPtr = (WizRawPixel *)dest8;
+ } else {
+ WizRawPixel16 val16 = (WizRawPixel16)wiz->convert8BppToRawPixel(*dataStream, conversionTable);
+
+ for (int counter = 0; counter < runCount; counter++) {
+ *dest16 = val16;
+ dest16 += destStepValue;
+ }
+
+ destPtr = (WizRawPixel *)dest16;
+ }
+ },
+ {
+ const byte *src = (const byte *)dataStream;
+
+ if (!wiz->_uses16BitColor) {
+ for (int counter = 0; counter < runCount; counter++) {
+ *dest8 = (WizRawPixel8)wiz->convert8BppToRawPixel(*src++, conversionTable);
+ dest8 += destStepValue;
+ }
+
+ destPtr = (WizRawPixel *)dest8;
+ } else {
+ for (int counter = 0; counter < runCount; counter++) {
+ *dest16 = (WizRawPixel16)wiz->convert8BppToRawPixel(*src++, conversionTable);
+ dest16 += destStepValue;
+ }
+
+ destPtr = (WizRawPixel *)dest16;
+ }
+ }
+ );
+}
+
+static void TRLEFLIP_LookupArbitraryDstStepDecompressLine(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *userParam, int destStepValue, const WizRawPixel *conversionTable) {
+ const byte *lookupTable;
+ int runCount;
+ WizRawPixel8 *dest8 = (WizRawPixel8 *)destPtr;
+ WizRawPixel16 *dest16 = (WizRawPixel16 *)destPtr;
+
+ lookupTable = (const byte *)userParam;
+
+ // Decompress bytes to do simple clipping...
+ HANDLE_SKIP_PIXELS_MACRO();
+
+ // Really decompress to the dest buffer...
+ HANDLE_RUN_DECOMPRESS_MACRO(
+ {
+ if (!wiz->_uses16BitColor) {
+ while (--runCount >= 0) {
+ dest8 += destStepValue;
+ }
+
+ destPtr = (WizRawPixel *)dest8;
+ } else {
+ while (--runCount >= 0) {
+ dest16 += destStepValue;
+ }
+
+ destPtr = (WizRawPixel *)dest16;
+ }
+ },
+ {
+ if (!wiz->_uses16BitColor) {
+ WizRawPixel8 val8 = (WizRawPixel8)wiz->convert8BppToRawPixel(*(lookupTable + *dataStream), conversionTable);
+
+ for (int counter = 0; counter < runCount; counter++) {
+ *dest8 = val8;
+ dest8 += destStepValue;
+ }
+
+ destPtr = (WizRawPixel *)dest8;
+ } else {
+ WizRawPixel16 val16 = (WizRawPixel16)wiz->convert8BppToRawPixel(*(lookupTable + *dataStream), conversionTable);
+
+ for (int counter = 0; counter < runCount; counter++) {
+ *dest16 = val16;
+ dest16 += destStepValue;
+ }
+
+ destPtr = (WizRawPixel *)dest16;
+ }
+ },
+ {
+ const byte *src = (const byte *)dataStream;
+ if (!wiz->_uses16BitColor) {
+ for (int counter = 0; counter < runCount; counter++) {
+ *dest8 = (WizRawPixel8)wiz->convert8BppToRawPixel(*(lookupTable + *src++), conversionTable);
+ dest8 += destStepValue;
+ }
+
+ destPtr = (WizRawPixel *)dest8;
+ } else {
+ for (int counter = 0; counter < runCount; counter++) {
+ *dest16 = (WizRawPixel16)wiz->convert8BppToRawPixel(*(lookupTable + *src++), conversionTable);
+ dest16 += destStepValue;
+ }
+
+ destPtr = (WizRawPixel *)dest16;
+ }
+ }
+ );
+}
+
+static void TRLEFLIP_MixArbitraryDstStepDecompressLine(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *userParam, int destStepValue, const WizRawPixel *conversionTable) {
+ bool _uses16BitColor = wiz->_uses16BitColor;
+ const byte *mixColorTable;
+ const byte *lookupTable;
+ int runCount;
+ WizRawPixel8 *dest8 = (WizRawPixel8 *)destPtr;
+ WizRawPixel16 *dest16 = (WizRawPixel16 *)destPtr;
+
+ mixColorTable = (const byte *)userParam;
+
+ // Decompress bytes to do simple clipping...
+ HANDLE_SKIP_PIXELS_MACRO();
+
+ // Really decompress to the dest buffer...
+ HANDLE_RUN_DECOMPRESS_MACRO(
+ {
+ if (!wiz->_uses16BitColor) {
+ while (--runCount >= 0) {
+ dest8 += destStepValue;
+ }
+
+ destPtr = (WizRawPixel *)dest8;
+ } else {
+ while (--runCount >= 0) {
+ dest16 += destStepValue;
+ }
+
+ destPtr = (WizRawPixel *)dest16;
+ }
+ },
+ {
+ if (!_uses16BitColor) {
+ WizRawPixel8 value = (WizRawPixel8)wiz->convert8BppToRawPixel(*dataStream, conversionTable);
+ lookupTable = mixColorTable + (value * 256);
+
+ for (int counter = 0; counter < runCount; counter++) {
+ *dest8 = (WizRawPixel8)(*(lookupTable + *destPtr));
+ dest8 += destStepValue;
+ }
+
+ destPtr = (WizRawPixel *)dest8;
+ } else {
+ WizRawPixel16 adjustedRunColor = (WizRawPixel16)WIZRAWPIXEL_50_50_PREMIX_COLOR(
+ wiz->convert8BppToRawPixel(*dataStream, conversionTable));
+
+ for (int counter = 0; counter < runCount; counter++) {
+ *dest16 = (WizRawPixel16)(WIZRAWPIXEL_50_50_MIX(
+ adjustedRunColor, WIZRAWPIXEL_50_50_PREMIX_COLOR(*dest16)));
+ dest16 += destStepValue;
+ }
+
+ destPtr = (WizRawPixel *)dest16;
+ }
+ },
+ {
+ if (!_uses16BitColor) {
+ const WizRawPixel8 *src = (const WizRawPixel8 *)dataStream;
+
+ for (int counter = 0; counter < runCount; counter++) {
+ *dest8 = (WizRawPixel8)wiz->convert8BppToRawPixel(
+ (*(mixColorTable + ((*src++) * 256) + *dest8)), conversionTable);
+ dest8 += destStepValue;
+ }
+
+ destPtr = (WizRawPixel *)dest8;
+ } else {
+ const byte *src;
+
+ src = (const byte *)dataStream;
+
+ for (int counter = 0; counter < runCount; counter++) {
+ WizRawPixel16 adjustedColor = (WizRawPixel16)(WIZRAWPIXEL_50_50_PREMIX_COLOR(
+ wiz->convert8BppToRawPixel(*src++, conversionTable)));
+ *dest16 = (WizRawPixel16)(WIZRAWPIXEL_50_50_MIX(
+ adjustedColor, WIZRAWPIXEL_50_50_PREMIX_COLOR(*dest16)));
+
+ dest16 += destStepValue;
+ }
+
+ destPtr = (WizRawPixel *)dest16;
+ }
+ }
+ );
+}
+
+static void TRLEFLIP_ADDITIVE_ArbitraryDstStepDecompressLine(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *userParam, int destStepValue, const WizRawPixel *conversionTable) {
+ bool _uses16BitColor = wiz->_uses16BitColor;
+ TRLEFLIP_X_ArbitraryDstStep_MACRO(WIZRAWPIXEL_ADDITIVE_MIX);
+}
+
+static void TRLEFLIP_SUBTRACTIVE_ArbitraryDstStepDecompressLine(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *userParam, int destStepValue, const WizRawPixel *conversionTable) {
+ bool _uses16BitColor = wiz->_uses16BitColor;
+ TRLEFLIP_X_ArbitraryDstStep_MACRO(WIZRAWPIXEL_SUBTRACTIVE_MIX);
+}
+
+void Wiz::TRLEFLIP_90_DegreeRotateCore(WizSimpleBitmap *dstBitmap, int x, int y, const COMPRESSEDIMAGE *imagePtr, const Common::Rect *optionalSrcRect,
+ const Common::Rect *optionalClipRect, bool hFlip, bool vFlip, const void *userParam, const WizRawPixel *conversionTable,
+ void(*functionPtr)(Wiz *wiz,
+ WizRawPixel *destPtr, const byte *dataStream, int skipAmount,
+ int decompAmount, const void *userParam, int destStepValue,
+ const WizRawPixel *conversionTable)) {
+
+ Common::Rect dstRect, srcRect, clipRect, clippedDstRect, clippedSrcRect;
+ int dstOffset, dstStep, w, h, srcOffset, dstX, dstY, skipAmount, c;
+ WizRawPixel *dstPtr;
+ byte *compData;
+
+ // Do as much pre-clipping as possible
+ makeSizedRect(&clipRect, dstBitmap->bitmapWidth, dstBitmap->bitmapHeight);
+
+ if (optionalClipRect) {
+ if (!findRectOverlap(&clipRect, optionalClipRect)) {
+ return;
+ }
+ }
+
+ // Clip the source rect against the actual src bitmap limits
+ makeSizedRect(&srcRect, imagePtr->width, imagePtr->height);
+
+ if (optionalSrcRect) {
+ if (!findRectOverlap(&srcRect, optionalSrcRect)) {
+ return;
+ }
+ }
+
+ // Make the "dest" rect then clip it against the clip rect
+ makeSizedRectAt(
+ &dstRect, x, y, getRectHeight(&srcRect), getRectWidth(&srcRect));
+
+ clippedDstRect = dstRect;
+
+ if (!findRectOverlap(&clippedDstRect, &clipRect)) {
+ return;
+ }
+
+ // Make the clipped src rect adjusted for the 90 degree rotation.
+ clippedSrcRect.left = srcRect.left + (clippedDstRect.top - dstRect.top);
+ clippedSrcRect.top = srcRect.top + (dstRect.right - clippedDstRect.right);
+ clippedSrcRect.right = srcRect.right - (dstRect.bottom - clippedDstRect.bottom);
+ clippedSrcRect.bottom = srcRect.bottom - (clippedDstRect.left - dstRect.left);
+
+ // Perform any flipping of the coords and setup the step variables
+ if (hFlip) {
+ horzFlipAlignWithRect(&clippedSrcRect, &srcRect);
+ dstY = clippedDstRect.bottom;
+ dstStep = -dstBitmap->bitmapWidth;
+ } else {
+ dstY = clippedDstRect.top;
+ dstStep = dstBitmap->bitmapWidth;
+ }
+
+ if (vFlip) {
+ vertFlipAlignWithRect(&clippedSrcRect, &srcRect);
+ dstX = clippedDstRect.left;
+ dstOffset = 1;
+ } else {
+ dstX = clippedDstRect.right;
+ dstOffset = -1;
+ }
+
+ // Finally get down to business and do the blit!
+ WizRawPixel8 *dst8 = ((WizRawPixel8 *)dstBitmap->bufferPtr) + dstX + (dstY * dstBitmap->bitmapWidth);
+ WizRawPixel16 *dst16 = ((WizRawPixel16 *)dstBitmap->bufferPtr) + dstX + (dstY * dstBitmap->bitmapWidth);
+
+ if (!_uses16BitColor) {
+ dstPtr = (WizRawPixel *)dst8;
+ } else {
+ dstPtr = (WizRawPixel *)dst16;
+ }
+
+ w = getRectWidth(&clippedSrcRect);
+ h = getRectHeight(&clippedSrcRect);
+
+ // General setup / skip n lines
+ skipAmount = clippedSrcRect.left;
+ compData = imagePtr->data;
+
+ for (c = clippedSrcRect.top; --c >= 0;) {
+ compData += READ_LE_UINT16(compData) + 2;
+ }
+
+ // Transfer the src line to the dest line using the passed transfer prim.
+ while (--h >= 0) {
+ srcOffset = READ_LE_UINT16(compData);
+
+ if (srcOffset) {
+ (*functionPtr)(this, dstPtr, compData + 2, skipAmount, w, userParam, dstStep, conversionTable);
+ compData += (srcOffset + 2);
+ } else {
+ compData += 2;
+ }
+
+ dstPtr += dstOffset;
+ }
+}
+
+void Wiz::TRLEFLIP_DecompressImage(
+ WizRawPixel *bufferPtr, const byte *compData, int bufferWidth, int bufferHeight,
+ int x, int y, int width, int height, Common::Rect *clipRectPtr,
+ int32 wizFlags, const void *extraTable, const WizRawPixel *conversionTable,
+ const WizImageCommand *optionalICmdPtr) {
+ COMPRESSEDIMAGE fakeImage;
+ WizSimpleBitmap fakeBitmap;
+
+ if (_uses16BitColor)
+ TRLEFLIP_CheckAlphaSetup();
+
+ // General setup for the primitives
+ fakeBitmap.bufferPtr = bufferPtr;
+ fakeBitmap.bitmapWidth = bufferWidth;
+ fakeBitmap.bitmapHeight = bufferHeight;
+
+ fakeImage.data = (byte *)compData;
+ fakeImage.width = width;
+ fakeImage.height = height;
+
+ if (!_uses16BitColor) {
+ // Check to see if there is a remap to be performed on the TRLE data...
+ if (conversionTable && (conversionTable != (WizRawPixel *)_vm->getHEPaletteSlot(1))) {
+ extraTable = (const void *)conversionTable;
+ wizFlags &= ~kWRFUseShadow;
+ wizFlags |= kWRFRemap;
+ }
+ } else {
+ if (wizFlags & kWRFRemap) {
+ extraTable = nullptr;
+ wizFlags &= ~(kWRFUseShadow | kWRFRemap);
+ }
+ }
+
+ if (_uses16BitColor) {
+ // Check for new "special" rendering modes
+ if (wizFlags & kWRFSpecialRenderBitMask) {
+ if (wizFlags & kWRFAdditiveBlend) {
+ TRLEFLIP_DecompressPrim(
+ &fakeBitmap, &fakeImage, x, y, nullptr, clipRectPtr, extraTable, wizFlags, conversionTable,
+ TRLEFLIP_ADDATIVE_DecompressLineForeword,
+ TRLEFLIP_ADDATIVE_DecompressLineBackward);
+
+ return;
+ } else if (wizFlags & kWRFSubtractiveBlend) {
+ TRLEFLIP_DecompressPrim(
+ &fakeBitmap, &fakeImage, x, y, nullptr, clipRectPtr, extraTable, wizFlags, conversionTable,
+ TRLEFLIP_SUBTRACTIVE_DecompressLineForeword,
+ TRLEFLIP_SUBTRACTIVE_DecompressLineBackward);
+
+ return;
+ } else if (wizFlags & kWRF5050Blend) {
+ TRLEFLIP_DecompressPrim(
+ &fakeBitmap, &fakeImage, x, y, nullptr, clipRectPtr, extraTable, wizFlags, conversionTable,
+ TRLEFLIP_MixDecompressLineForeword,
+ TRLEFLIP_MixDecompressLineBackward);
+
+ return;
+ }
+ }
+ }
+
+ // Find which draw primitives need to be called...
+ if (!extraTable) {
+ TRLEFLIP_DecompressPrim(
+ &fakeBitmap, &fakeImage, x, y, nullptr, clipRectPtr, extraTable, wizFlags, conversionTable,
+ TRLEFLIP_DecompressLineForeword, TRLEFLIP_DecompressLineBackward);
+ } else if (wizFlags & kWRFRemap) {
+ TRLEFLIP_DecompressPrim(
+ &fakeBitmap, &fakeImage, x, y, nullptr, clipRectPtr, extraTable, wizFlags, conversionTable,
+ TRLEFLIP_LookupDecompressLineForeword, TRLEFLIP_LookupDecompressLineBackward);
+ } else /* if (wizFlags & kWRFUseShadow) */ {
+ TRLEFLIP_DecompressPrim(
+ &fakeBitmap, &fakeImage, x, y, nullptr, clipRectPtr, extraTable, wizFlags, conversionTable,
+ TRLEFLIP_MixDecompressLineForeword,
+ TRLEFLIP_MixDecompressLineBackward);
+ }
+}
+
+void Wiz::TRLEFLIP_Rotate90_DecompressImage(
+ WizRawPixel *bufferPtr, const byte *compData, int bufferWidth, int bufferHeight,
+ int x, int y, int width, int height, const Common::Rect *clipRectPtr,
+ int32 wizFlags, const void *extraTable, const WizRawPixel *conversionTable,
+ WizImageCommand *optionalICmdPtr) {
+ COMPRESSEDIMAGE fakeImage;
+ WizSimpleBitmap fakeBitmap;
+
+ if (_uses16BitColor)
+ TRLEFLIP_CheckAlphaSetup();
+
+ // General setup for the primitives
+ fakeBitmap.bufferPtr = bufferPtr;
+ fakeBitmap.bitmapWidth = bufferWidth;
+ fakeBitmap.bitmapHeight = bufferHeight;
+
+ fakeImage.data = (byte *)compData;
+ fakeImage.width = width;
+ fakeImage.height = height;
+
+ if (!_uses16BitColor) {
+ // Check to see if there is a remap to be performed on the TRLE data...
+ if (conversionTable && (conversionTable != (WizRawPixel *)_vm->getHEPaletteSlot(1))) {
+ extraTable = (const void *)conversionTable;
+ wizFlags &= ~kWRFUseShadow;
+ wizFlags |= kWRFRemap;
+ }
+ } else {
+ if (kWRFRemap & wizFlags) {
+ extraTable = nullptr;
+ wizFlags &= ~(kWRFUseShadow | kWRFRemap);
+ }
+ }
+
+ if (_uses16BitColor) {
+ // Check for new "special" rendering modes
+ if (wizFlags & kWRFSpecialRenderBitMask) {
+ if (wizFlags & kWRFAdditiveBlend) {
+ TRLEFLIP_90_DegreeRotateCore(
+ &fakeBitmap, x, y, &fakeImage, nullptr, clipRectPtr,
+ (wizFlags & kWRFHFlip), (wizFlags & kWRFVFlip),
+ extraTable, conversionTable,
+ TRLEFLIP_ADDITIVE_ArbitraryDstStepDecompressLine);
+
+ return;
+ } else if (wizFlags & kWRFSubtractiveBlend) {
+ TRLEFLIP_90_DegreeRotateCore(
+ &fakeBitmap, x, y, &fakeImage, nullptr, clipRectPtr,
+ (wizFlags & kWRFHFlip), (wizFlags & kWRFVFlip),
+ extraTable, conversionTable,
+ TRLEFLIP_SUBTRACTIVE_ArbitraryDstStepDecompressLine);
+
+ return;
+ } else if (wizFlags & kWRF5050Blend) {
+ TRLEFLIP_90_DegreeRotateCore(
+ &fakeBitmap, x, y, &fakeImage, nullptr, clipRectPtr,
+ (wizFlags & kWRFHFlip), (wizFlags & kWRFVFlip),
+ extraTable, conversionTable,
+ TRLEFLIP_MixArbitraryDstStepDecompressLine);
+
+ return;
+ }
+ }
+ }
+
+ // Find which draw primitives need to be called...
+ if (!extraTable) {
+ TRLEFLIP_90_DegreeRotateCore(
+ &fakeBitmap, x, y, &fakeImage, nullptr, clipRectPtr,
+ (wizFlags & kWRFHFlip), (wizFlags & kWRFVFlip),
+ extraTable, conversionTable,
+ TRLEFLIP_ArbitraryDstStepDecompressLine);
+
+ } else if (wizFlags & kWRFRemap) {
+ TRLEFLIP_90_DegreeRotateCore(
+ &fakeBitmap, x, y, &fakeImage, nullptr, clipRectPtr,
+ (wizFlags & kWRFHFlip), (wizFlags & kWRFVFlip),
+ extraTable, conversionTable,
+ TRLEFLIP_LookupArbitraryDstStepDecompressLine);
+ } else /* if (wizFlags & kWRFUseShadow) */ {
+ TRLEFLIP_90_DegreeRotateCore(
+ &fakeBitmap, x, y, &fakeImage, nullptr, clipRectPtr,
+ (wizFlags & kWRFHFlip), (wizFlags & kWRFVFlip),
+ extraTable, conversionTable,
+ TRLEFLIP_MixArbitraryDstStepDecompressLine);
+ }
+}
+
+static void TRLEFLIP_X2X_BOOL_ALPHA_Memset(Wiz *wiz, WizRawPixel *dstPtr, const WizRawPixel *srcPtr, const WizRawPixel value, int size) {
+ // 16-bit only
+ while (size-- > 0) {
+ if (*srcPtr++) {
+ *dstPtr++ = value;
+ } else {
+ ++dstPtr;
+ }
+ }
+}
+
+static void TRLEFLIP_X2X_BOOL_INVALPHA_Memset(Wiz *wiz, WizRawPixel *dstPtr, const WizRawPixel *srcPtr, const WizRawPixel value, int size) {
+ // 16-bit only
+ while (size-- > 0) {
+ if (*srcPtr++) {
+ ++dstPtr;
+ } else {
+ *dstPtr++ = value;
+ }
+ }
+}
+
+static void TRLEFLIP_X2X_BOOL_ALPHA_F_Memcpy(Wiz *wiz, WizRawPixel *dstPtr, const WizRawPixel *srcPtr, const byte *dataPtr,
+ // 16-bit only
+ int size, const WizRawPixel *conversionTable) {
+ while (size-- > 0) {
+ if ((*srcPtr)) {
+ *dstPtr = wiz->convert8BppToRawPixel(*dataPtr, conversionTable);
+ }
+
+ ++dstPtr;
+ ++srcPtr;
+ ++dataPtr;
+ }
+}
+
+static void TRLEFLIP_X2X_BOOL_ALPHA_B_Memcpy(Wiz *wiz, WizRawPixel *dstPtr, const WizRawPixel *srcPtr, const byte *dataPtr, int size, const WizRawPixel *conversionTable) {
+ // 16-bit only
+ while (size-- > 0) {
+ if ((*srcPtr)) {
+ *dstPtr = wiz->convert8BppToRawPixel(*dataPtr, conversionTable);
+ }
+
+ --dstPtr;
+ --srcPtr;
+ ++dataPtr;
+ }
+}
+
+static void TRLEFLIP_X2X_BOOL_INVALPHA_F_Memcpy(Wiz *wiz, WizRawPixel *dstPtr, const WizRawPixel *srcPtr, const byte *dataPtr, int size, const WizRawPixel *conversionTable) {
+ // 16-bit only
+ while (size-- > 0) {
+ if (!(*srcPtr)) {
+ *dstPtr = wiz->convert8BppToRawPixel(*dataPtr, conversionTable);
+ }
+
+ ++dstPtr;
+ ++srcPtr;
+ ++dataPtr;
+ }
+}
+
+static void TRLEFLIP_X2X_BOOL_INVALPHA_B_Memcpy(Wiz *wiz, WizRawPixel *dstPtr, const WizRawPixel *srcPtr, const byte *dataPtr, int size, const WizRawPixel *conversionTable) {
+ // 16-bit only
+ while (size-- > 0) {
+ if (!(*srcPtr)) {
+ *dstPtr = wiz->convert8BppToRawPixel(*dataPtr, conversionTable);
+ }
+
+ --dstPtr;
+ --srcPtr;
+ ++dataPtr;
+ }
+}
+
+static void TRLEFLIP_AltSource_F_BOOL_ALPHA_X2X(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
+ // 16-bit only
+ TRLEFLIP_ALTX_Foreward_MACRO(
+ TRLEFLIP_X2X_BOOL_ALPHA_Memset,
+ TRLEFLIP_X2X_BOOL_ALPHA_F_Memcpy);
+}
+
+static void TRLEFLIP_AltSource_B_BOOL_ALPHA_X2X(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
+ // 16-bit only
+ TRLEFLIP_ALTX_Backward_MACRO(
+ TRLEFLIP_X2X_BOOL_ALPHA_Memset,
+ TRLEFLIP_X2X_BOOL_ALPHA_B_Memcpy);
+}
+
+static void TRLEFLIP_AltSource_F_BOOL_INVALPHA_X2X(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
+ // 16-bit only
+ TRLEFLIP_ALTX_Foreward_MACRO(
+ TRLEFLIP_X2X_BOOL_INVALPHA_Memset,
+ TRLEFLIP_X2X_BOOL_INVALPHA_F_Memcpy);
+}
+
+static void TRLEFLIP_AltSource_B_BOOL_INVALPHA_X2X(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
+ // 16-bit only
+ TRLEFLIP_ALTX_Backward_MACRO(
+ TRLEFLIP_X2X_BOOL_INVALPHA_Memset,
+ TRLEFLIP_X2X_BOOL_INVALPHA_B_Memcpy);
+}
+
+static void TRLEFLIP_X2X_ALPHA_Memset(Wiz *wiz, WizRawPixel *dstPtr, const WizRawPixel *srcPtr, const WizRawPixel value, int size) {
+ // 16-bit only
+ while (size-- > 0) {
+ int alpha = ((*srcPtr++) & 255);
+
+ if (alpha) {
+ *dstPtr = wiz->TRLEFLIP_AlphaMixPrim(value, *dstPtr, (255 - alpha));
+ }
+
+ ++dstPtr;
+ }
+}
+
+static void TRLEFLIP_X2X_INVALPHA_Memset(Wiz *wiz, WizRawPixel *dstPtr, const WizRawPixel *srcPtr, const WizRawPixel value, int size) {
+ // 16-bit only
+ while (size-- > 0) {
+ int alpha = (255 - ((*srcPtr++) & 255));
+
+ if (alpha) {
+ *dstPtr = wiz->TRLEFLIP_AlphaMixPrim(value, *dstPtr, (255 - alpha));
+ }
+
+ ++dstPtr;
+ }
+}
+
+static void TRLEFLIP_X2X_ALPHA_F_Memcpy(Wiz *wiz, WizRawPixel *dstPtr, const WizRawPixel *srcPtr, const byte *dataPtr, int size, const WizRawPixel *conversionTable) {
+ // 16-bit only
+ while (size-- > 0) {
+ int alpha = ((*srcPtr++) & 255);
+
+ if (alpha) {
+ *dstPtr = wiz->TRLEFLIP_AlphaMixPrim(*dstPtr, wiz->convert8BppToRawPixel(*dataPtr, conversionTable), alpha);
+ }
+
+ ++dstPtr;
+ ++dataPtr;
+ }
+}
+
+static void TRLEFLIP_X2X_ALPHA_B_Memcpy(Wiz *wiz, WizRawPixel *dstPtr, const WizRawPixel *srcPtr, const byte *dataPtr, int size, const WizRawPixel *conversionTable) {
+ // 16-bit only
+ while (size-- > 0) {
+ int alpha = ((*srcPtr--) & 255);
+
+ if (alpha) {
+ *dstPtr = wiz->TRLEFLIP_AlphaMixPrim(*dstPtr, wiz->convert8BppToRawPixel(*dataPtr, conversionTable), alpha);
+ }
+
+ --dstPtr;
+ ++dataPtr;
+ }
+}
+
+static void TRLEFLIP_X2X_INVALPHA_F_Memcpy(Wiz *wiz, WizRawPixel *dstPtr, const WizRawPixel *srcPtr, const byte *dataPtr, int size, const WizRawPixel *conversionTable) {
+ // 16-bit only
+ while (size-- > 0) {
+ int alpha = (255 - ((*srcPtr++) & 255));
+
+ if (alpha) {
+ *dstPtr = wiz->TRLEFLIP_AlphaMixPrim(*dstPtr, wiz->convert8BppToRawPixel(*dataPtr, conversionTable), alpha);
+ }
+
+ ++dstPtr;
+ ++dataPtr;
+ }
+}
+
+static void TRLEFLIP_X2X_INVALPHA_B_Memcpy(Wiz *wiz, WizRawPixel *dstPtr, const WizRawPixel *srcPtr, const byte *dataPtr, int size, const WizRawPixel *conversionTable) {
+ // 16-bit only
+ while (size-- > 0) {
+ int alpha = (255 - ((*srcPtr--) & 255));
+
+ if (alpha) {
+ *dstPtr = wiz->TRLEFLIP_AlphaMixPrim(
+ *dstPtr, wiz->convert8BppToRawPixel(*dataPtr, conversionTable), alpha);
+ }
+
+ --dstPtr;
+ ++dataPtr;
+ }
+}
+
+static void TRLEFLIP_AltSource_F_ALPHA_X2X(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
+ // 16-bit only
+ TRLEFLIP_ALTX_Foreward_MACRO(
+ TRLEFLIP_X2X_ALPHA_Memset,
+ TRLEFLIP_X2X_ALPHA_F_Memcpy);
+}
+
+static void TRLEFLIP_AltSource_B_ALPHA_X2X(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
+ // 16-bit only
+ TRLEFLIP_ALTX_Backward_MACRO(
+ TRLEFLIP_X2X_ALPHA_Memset,
+ TRLEFLIP_X2X_ALPHA_B_Memcpy);
+}
+
+static void TRLEFLIP_AltSource_F_INVALPHA_X2X(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
+ // 16-bit only
+ TRLEFLIP_ALTX_Foreward_MACRO(
+ TRLEFLIP_X2X_INVALPHA_Memset,
+ TRLEFLIP_X2X_INVALPHA_F_Memcpy);
+}
+
+static void TRLEFLIP_AltSource_B_INVALPHA_X2X(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
+ // 16-bit only
+ TRLEFLIP_ALTX_Backward_MACRO(
+ TRLEFLIP_X2X_INVALPHA_Memset,
+ TRLEFLIP_X2X_INVALPHA_B_Memcpy);
+}
+
+static void TRLEFLIP_ATRLE_ALPHA_Memset(Wiz *wiz, WizRawPixel *dstPtr, const WizRawPixel *srcPtr, const WizRawPixel value, int size) {
+ // 16-bit only
+ int alpha = (value & 255);
+
+ if (alpha) {
+ while (size-- > 0) {
+ *dstPtr = wiz->TRLEFLIP_AlphaMixPrim(*dstPtr, *srcPtr, alpha);
+
+ ++dstPtr;
+ ++srcPtr;
+ }
+ }
+}
+
+static void TRLEFLIP_ATRLE_INVALPHA_Memset(Wiz *wiz, WizRawPixel *dstPtr, const WizRawPixel *srcPtr, const WizRawPixel value, int size) {
+ // 16-bit only
+ int alpha = (255 - (value & 255));
+
+ if (alpha) {
+ while (size-- > 0) {
+ *dstPtr = wiz->TRLEFLIP_AlphaMixPrim(*dstPtr, *srcPtr, alpha);
+
+ ++dstPtr;
+ ++srcPtr;
+ }
+ }
+}
+
+static void TRLEFLIP_ATRLE_ALPHA_F_Memcpy(Wiz *wiz, WizRawPixel *dstPtr, const WizRawPixel *srcPtr, const byte *dataPtr, int size, const WizRawPixel *conversionTable) {
+ // 16-bit only
+ while (size-- > 0) {
+ int alpha = ((wiz->convert8BppToRawPixel(*dataPtr++, conversionTable)) & 255);
+
+ if (alpha) {
+ *dstPtr = wiz->TRLEFLIP_AlphaMixPrim(
+ *dstPtr, *srcPtr, alpha);
+ }
+
+ ++dstPtr;
+ ++srcPtr;
+ }
+}
+
+static void TRLEFLIP_ATRLE_ALPHA_B_Memcpy(Wiz *wiz, WizRawPixel *dstPtr, const WizRawPixel *srcPtr, const byte *dataPtr, int size, const WizRawPixel *conversionTable) {
+ // 16-bit only
+ while (size-- > 0) {
+ int alpha = ((wiz->convert8BppToRawPixel(*dataPtr++, conversionTable)) & 255);
+
+ if (alpha) {
+ *dstPtr = wiz->TRLEFLIP_AlphaMixPrim(
+ *dstPtr, *srcPtr, alpha);
+ }
+
+ --dstPtr;
+ --srcPtr;
+ }
+}
+
+static void TRLEFLIP_ATRLE_INVALPHA_F_Memcpy(Wiz *wiz, WizRawPixel *dstPtr, const WizRawPixel *srcPtr, const byte *dataPtr, int size, const WizRawPixel *conversionTable) {
+ // 16-bit only
+ while (size-- > 0) {
+ int alpha = (255 - ((wiz->convert8BppToRawPixel(*dataPtr++, conversionTable)) & 255));
+
+ if (alpha) {
+ *dstPtr = wiz->TRLEFLIP_AlphaMixPrim(
+ *dstPtr, *srcPtr, alpha);
+ }
+
+ ++dstPtr;
+ ++srcPtr;
+ }
+}
+
+static void TRLEFLIP_ATRLE_INVALPHA_B_Memcpy(Wiz *wiz, WizRawPixel *dstPtr, const WizRawPixel *srcPtr, const byte *dataPtr, int size, const WizRawPixel *conversionTable) {
+ // 16-bit only
+ while (size-- > 0) {
+ int alpha = (255 - ((wiz->convert8BppToRawPixel(*dataPtr++, conversionTable)) & 255));
+
+ if (alpha) {
+ *dstPtr = wiz->TRLEFLIP_AlphaMixPrim(
+ *dstPtr, *srcPtr, alpha);
+ }
+
+ --dstPtr;
+ --srcPtr;
+ }
+}
+
+static void TRLEFLIP_AltSource_F_ALPHA_ATRLE(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
+ // 16-bit only
+ TRLEFLIP_ALTX_Foreward_MACRO(
+ TRLEFLIP_ATRLE_ALPHA_Memset,
+ TRLEFLIP_ATRLE_ALPHA_F_Memcpy);
+}
+
+static void TRLEFLIP_AltSource_B_ALPHA_ATRLE(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
+ // 16-bit only
+ TRLEFLIP_ALTX_Backward_MACRO(
+ TRLEFLIP_ATRLE_ALPHA_Memset,
+ TRLEFLIP_ATRLE_ALPHA_B_Memcpy);
+}
+
+static void TRLEFLIP_AltSource_F_INVALPHA_ATRLE(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
+ // 16-bit only
+ TRLEFLIP_ALTX_Foreward_MACRO(
+ TRLEFLIP_ATRLE_INVALPHA_Memset,
+ TRLEFLIP_ATRLE_INVALPHA_F_Memcpy);
+}
+
+static void TRLEFLIP_AltSource_B_INVALPHA_ATRLE(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
+ // 16-bit only
+ TRLEFLIP_ALTX_Backward_MACRO(
+ TRLEFLIP_ATRLE_INVALPHA_Memset,
+ TRLEFLIP_ATRLE_INVALPHA_B_Memcpy);
+}
+
+static void TRLEFLIP_AltSource_F_XBppToXBpp(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
+ const WizRawPixel *srcPtr;
+ int runCount;
+
+ srcPtr = (const WizRawPixel *)altSourcePtr;
+
+ // Decompress bytes to do simple clipping...
+ HANDLE_SKIP_PIXELS_MACRO();
+
+ // Really decompress to the dest buffer...
+ HANDLE_RUN_DECOMPRESS_MACRO(
+ {
+ destPtr += runCount;
+ srcPtr += runCount;
+ },
+ {
+ memcpy(destPtr, srcPtr, (runCount * sizeof(WizRawPixel)));
+ destPtr += runCount;
+ srcPtr += runCount;
+ },
+ {
+ memcpy(destPtr, srcPtr, (runCount * sizeof(WizRawPixel)));
+ destPtr += runCount;
+ srcPtr += runCount;
+ });
+}
+
+static void TRLEFLIP_AltSource_B_XBppToXBpp(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
+ const WizRawPixel *srcPtr;
+ int runCount;
+
+ srcPtr = (const WizRawPixel *)altSourcePtr;
+
+ // Decompress bytes to do simple clipping...
+ HANDLE_SKIP_PIXELS_MACRO();
+
+ // Really decompress to the dest buffer...
+ HANDLE_RUN_DECOMPRESS_MACRO(
+ {
+ destPtr -= runCount;
+ srcPtr -= runCount;
+ },
+ {
+ destPtr -= runCount;
+ srcPtr -= runCount;
+ memcpy(destPtr + 1, srcPtr + 1, (runCount * sizeof(WizRawPixel)));
+ },
+ {
+ destPtr -= runCount;
+ srcPtr -= runCount;
+ memcpy(destPtr + 1, srcPtr + 1, (runCount * sizeof(WizRawPixel)));
+ });
+}
+
+static void TRLEFLIP_AltSource_F_8BppToXBpp(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
+ const byte *srcPtr;
+ int runCount;
+
+ srcPtr = (const byte *)altSourcePtr;
+
+ // Decompress bytes to do simple clipping...
+ HANDLE_SKIP_PIXELS_MACRO();
+
+ // Really decompress to the dest buffer...
+ HANDLE_RUN_DECOMPRESS_MACRO(
+ {
+ destPtr += runCount;
+ srcPtr += runCount;
+ },
+ {
+ wiz->memcpy8BppConversion(destPtr, srcPtr, runCount, conversionTable);
+ destPtr += runCount;
+ srcPtr += runCount;
+ },
+ {
+ wiz->memcpy8BppConversion(destPtr, srcPtr, runCount, conversionTable);
+ destPtr += runCount;
+ srcPtr += runCount;
+ });
+}
+
+static void TRLEFLIP_AltSource_B_8BppToXBpp(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
+ const WizRawPixel *srcPtr;
+ int runCount;
+
+ srcPtr = (const WizRawPixel *)altSourcePtr;
+
+ // Decompress bytes to do simple clipping...
+ HANDLE_SKIP_PIXELS_MACRO();
+
+ // Really decompress to the dest buffer...
+ HANDLE_RUN_DECOMPRESS_MACRO(
+ {
+ destPtr -= runCount;
+ srcPtr -= runCount;
+ },
+ {
+ destPtr -= runCount;
+ srcPtr -= runCount;
+ wiz->memcpy8BppConversion(destPtr + 1, srcPtr + 1, runCount, conversionTable);
+ },
+ {
+ destPtr -= runCount;
+ srcPtr -= runCount;
+ wiz->memcpy8BppConversion(destPtr + 1, srcPtr + 1, runCount, conversionTable);
+ });
+}
+
+static void TRLEFLIP_AltSource_INV_F_XBppToXBpp(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
+ const WizRawPixel *srcPtr;
+ int runCount;
+
+ srcPtr = (const WizRawPixel *)altSourcePtr;
+
+ // Decompress bytes to do simple clipping...
+ HANDLE_SKIP_PIXELS_MACRO();
+
+ // Really decompress to the dest buffer...
+ HANDLE_RUN_DECOMPRESS_MACRO(
+ {
+ memcpy(destPtr, srcPtr, (runCount * sizeof(WizRawPixel)));
+ destPtr += runCount;
+ srcPtr += runCount;
+ },
+ {
+ destPtr += runCount;
+ srcPtr += runCount;
+ },
+ {
+ destPtr += runCount;
+ srcPtr += runCount;
+ });
+}
+
+static void TRLEFLIP_AltSource_INV_B_XBppToXBpp(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
+ const WizRawPixel *srcPtr;
+ int runCount;
+
+ srcPtr = (const WizRawPixel *)altSourcePtr;
+
+ // Decompress bytes to do simple clipping...
+ HANDLE_SKIP_PIXELS_MACRO();
+
+ // Really decompress to the dest buffer...
+ HANDLE_RUN_DECOMPRESS_MACRO(
+ {
+ destPtr -= runCount;
+ srcPtr -= runCount;
+ memcpy(destPtr + 1, srcPtr + 1, (runCount * sizeof(WizRawPixel)));
+ },
+ {
+ destPtr -= runCount;
+ srcPtr -= runCount;
+ },
+ {
+ destPtr -= runCount;
+ srcPtr -= runCount;
+ });
+}
+
+void Wiz::TRLEFLIP_AltSource_DecompImageHull(
+ WizRawPixel *bufferPtr, int bufferWidth, const Common::Rect *destRect,
+ const byte *altSourceBuffer, int altBytesPerLine,
+ int altBytesPerPixel, const Common::Rect *altRect,
+ const byte *compData, const Common::Rect *sourceRect,
+ const WizRawPixel *conversionTable,
+ void (*functionPtr)(Wiz *,
+ WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream,
+ int skipAmount, int decompAmount, const WizRawPixel *conversionTable)) {
+ int decompWidth, decompHeight, counter, sX1, lineSize;
+
+ // General setup...
+ sX1 = sourceRect->left;
+
+ decompWidth = sourceRect->right - sourceRect->left + 1;
+ decompHeight = sourceRect->bottom - sourceRect->top + 1;
+
+ // Quickly skip down to the lines to be compressed & dest position...
+ WizRawPixel8 *buf8 = (WizRawPixel8 *)bufferPtr;
+ WizRawPixel16 *buf16 = (WizRawPixel16 *)bufferPtr;
+
+ if (_uses16BitColor) {
+ buf16 += bufferWidth * destRect->top + destRect->left;
+ bufferPtr = (WizRawPixel *)buf16;
+ } else {
+ buf8 += bufferWidth * destRect->top + destRect->left;
+ bufferPtr = (WizRawPixel *)buf8;
+ }
+
+ for (counter = sourceRect->top; counter > 0; counter--) {
+ compData += READ_LE_UINT16((byte *)compData) + 2;
+ }
+
+ // Calc the ALT buffer location
+ altSourceBuffer += (altBytesPerLine * altRect->top) + (altRect->left * altBytesPerPixel);
+
+ // Flip the dest offset if vertical flipping...
+ if (destRect->top > destRect->bottom) {
+ bufferWidth = -bufferWidth;
+ altBytesPerLine = -altBytesPerLine;
+ }
+
+ // Decompress all the lines that are visible!!!!
+ while (decompHeight-- > 0) {
+ lineSize = READ_LE_UINT16((byte *)compData);
+
+ if (lineSize != 0) {
+ (*functionPtr)(this,
+ bufferPtr, altSourceBuffer, compData + 2, sX1,
+ decompWidth, conversionTable);
+
+ compData += lineSize + 2;
+
+ if (_uses16BitColor) {
+ buf16 = (WizRawPixel16 *)bufferPtr;
+ buf16 += bufferWidth;
+ bufferPtr = (WizRawPixel *)buf16;
+ } else {
+ buf8 = (WizRawPixel8 *)bufferPtr;
+ buf8 += bufferWidth;
+ bufferPtr = (WizRawPixel *)buf8;
+ }
+
+ altSourceBuffer += altBytesPerLine;
+ } else {
+ // Handle a completely transparent line!
+ compData += 2;
+
+ if (_uses16BitColor) {
+ buf16 = (WizRawPixel16 *)bufferPtr;
+ buf16 += bufferWidth;
+ bufferPtr = (WizRawPixel *)buf16;
+ } else {
+ buf8 = (WizRawPixel8 *)bufferPtr;
+ buf8 += bufferWidth;
+ bufferPtr = (WizRawPixel *)buf8;
+ }
+
+ altSourceBuffer += altBytesPerLine;
+ }
+ }
+}
+
+void Wiz::TRLEFLIP_AltSource_DecompressPrim(
+ WizRawPixel *destBufferPtr, int destBufferWidth, int destBufferHeight,
+ const void *altBufferPtr, int altBitsPerPixel,
+ const COMPRESSEDIMAGE *imagePtr, int destX, int destY,
+ const Common::Rect *sourceCoords, const Common::Rect *clipRectPtr,
+ int32 flags, const WizRawPixel *conversionTable,
+ void (*forewordFunctionPtr)(Wiz *wiz,
+ WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream,
+ int skipAmount, int decompAmount, const WizRawPixel *conversionTable),
+ void (*backwardFunctionPtr)(Wiz *wiz,
+ WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream,
+ int skipAmount, int decompAmount, const WizRawPixel *conversionTable)) {
+ Common::Rect sourceRect, destRect, clipRect, workRect, inSourceRect;
+ int width, height;
+
+ void (*functionPtr)(Wiz *wiz,
+ WizRawPixel * destPtr, const void *altSourcePtr, const byte *dataStream,
+ int skipAmount, int decompAmount, const WizRawPixel *conversionTable);
+
+ if (!sourceCoords) {
+ width = imagePtr->width;
+ height = imagePtr->height;
+
+ sourceRect.left = 0;
+ sourceRect.top = 0;
+ sourceRect.right = width - 1;
+ sourceRect.bottom = height - 1;
+ } else {
+ width = sourceCoords->right - sourceCoords->left + 1;
+ height = sourceCoords->bottom - sourceCoords->top + 1;
+ sourceRect = *sourceCoords;
+ }
+
+ inSourceRect = sourceRect;
+
+ destRect.left = destX;
+ destRect.top = destY;
+ destRect.right = destX + width - 1;
+ destRect.bottom = destY + height - 1;
+
+ // Custom clip rect...
+ if (clipRectPtr) {
+ clipRect = *clipRectPtr;
+
+ workRect.left = 0;
+ workRect.top = 0;
+ workRect.right = destBufferWidth - 1;
+ workRect.bottom = destBufferHeight - 1;
+
+ if (!findRectOverlap(&clipRect, &workRect)) {
+ return;
+ }
+ } else {
+ clipRect.left = 0;
+ clipRect.top = 0;
+ clipRect.right = destBufferWidth - 1;
+ clipRect.bottom = destBufferHeight - 1;
+ }
+
+ // Clip the source & dest coords to the clipping rectangle...
+ clipRectCoords(&sourceRect, &destRect, &clipRect);
+
+ if (destRect.right < destRect.left) {
+ return;
+ }
+
+ if (destRect.bottom < destRect.top) {
+ return;
+ }
+
+ if (sourceRect.right < sourceRect.left) {
+ return;
+ }
+
+ if (sourceRect.bottom < sourceRect.top) {
+ return;
+ }
+
+ // Handle the flip coords source adjustment...
+ if (flags & kWRFHFlip) {
+ functionPtr = backwardFunctionPtr;
+ TRLEFLIP_HorzFlipAlignWithRect(&sourceRect, &inSourceRect);
+ swapRectX(&destRect);
+ } else {
+ functionPtr = forewordFunctionPtr;
+ }
+
+ if (flags & kWRFVFlip) {
+ TRLEFLIP_VertFlipAlignWithRect(&sourceRect, &inSourceRect);
+ swapRectY(&destRect);
+ }
+
+ // Call the primitive image renderer...
+ TRLEFLIP_AltSource_DecompImageHull(
+ destBufferPtr, destBufferWidth, &destRect,
+ (const byte *)altBufferPtr, ((destBufferWidth * altBitsPerPixel) / 8),
+ (altBitsPerPixel / 8), &destRect, imagePtr->data, &sourceRect,
+ conversionTable, functionPtr);
+}
+
+bool Wiz::TRLEFLIP_AltSource_SpecialCaseDispatch(
+ WizRawPixel *destBufferPtr, const byte *compData, int destBufferWidth, int destBufferHeight,
+ const void *altBufferPtr, int altWidth, int altHeight, int altBitsPerPixel,
+ int x, int y, int width, int height, Common::Rect *clipRectPtr,
+ int32 wizFlags, const WizRawPixel *conversionTable,
+ WizImageCommand *optionalICmdPtr) {
+
+ if (!_uses16BitColor || altBitsPerPixel != 16) {
+ return false;
+ }
+
+ // General setup
+ Common::Rect srcRect, clipRect;
+ COMPRESSEDIMAGE fakeImage;
+
+ fakeImage.data = (byte *)compData;
+ fakeImage.width = width;
+ fakeImage.height = height;
+
+ makeSizedRect(&srcRect, width, height);
+ makeSizedRect(&clipRect, destBufferWidth, destBufferHeight);
+
+ if (clipRectPtr) {
+ if (!findRectOverlap(&clipRect, clipRectPtr)) {
+ return true;
+ }
+ }
+
+ // Try to find a special case renderer!
+ if (wizFlags & kWRFUseImageAsAlphaChannel) {
+ if (wizFlags & kWRFBooleanAlpha) {
+ if (wizFlags & kWRFInverseAlpha) {
+ // Inverse alpha
+ TRLEFLIP_AltSource_DecompressPrim(
+ destBufferPtr, destBufferWidth, destBufferHeight,
+ altBufferPtr, altBitsPerPixel, &fakeImage, x, y,
+ &srcRect, &clipRect, wizFlags, conversionTable,
+ TRLEFLIP_AltSource_INV_F_XBppToXBpp,
+ TRLEFLIP_AltSource_INV_B_XBppToXBpp);
+
+ return true;
+ } else {
+ // Normal alpha
+ TRLEFLIP_AltSource_DecompressPrim(
+ destBufferPtr, destBufferWidth, destBufferHeight,
+ altBufferPtr, altBitsPerPixel, &fakeImage, x, y,
+ &srcRect, &clipRect, wizFlags, conversionTable,
+ TRLEFLIP_AltSource_F_XBppToXBpp,
+ TRLEFLIP_AltSource_B_XBppToXBpp);
+
+ return true;
+ }
+ } else {
+ if (wizFlags & kWRFInverseAlpha) {
+ // Inverse alpha
+ TRLEFLIP_AltSource_DecompressPrim(
+ destBufferPtr, destBufferWidth, destBufferHeight,
+ altBufferPtr, altBitsPerPixel, &fakeImage, x, y,
+ &srcRect, &clipRect, wizFlags, conversionTable,
+ TRLEFLIP_AltSource_F_INVALPHA_ATRLE,
+ TRLEFLIP_AltSource_B_INVALPHA_ATRLE);
+
+ return true;
+ } else {
+ // Normal alpha
+ TRLEFLIP_AltSource_DecompressPrim(
+ destBufferPtr, destBufferWidth, destBufferHeight,
+ altBufferPtr, altBitsPerPixel, &fakeImage, x, y,
+ &srcRect, &clipRect, wizFlags, conversionTable,
+ TRLEFLIP_AltSource_F_ALPHA_ATRLE,
+ TRLEFLIP_AltSource_B_ALPHA_ATRLE);
+
+ return true;
+ }
+ }
+ } else if (wizFlags & kWRFUseSourceImageAsAlphaChannel) {
+ if (wizFlags & kWRFBooleanAlpha) {
+ if (wizFlags & kWRFInverseAlpha) {
+ // Inverse alpha
+ TRLEFLIP_AltSource_DecompressPrim(
+ destBufferPtr, destBufferWidth, destBufferHeight,
+ altBufferPtr, altBitsPerPixel, &fakeImage, x, y,
+ &srcRect, &clipRect, wizFlags, conversionTable,
+ TRLEFLIP_AltSource_F_BOOL_INVALPHA_X2X,
+ TRLEFLIP_AltSource_B_BOOL_INVALPHA_X2X);
+
+ return true;
+ } else {
+ // Normal alpha
+ TRLEFLIP_AltSource_DecompressPrim(
+ destBufferPtr, destBufferWidth, destBufferHeight,
+ altBufferPtr, altBitsPerPixel, &fakeImage, x, y,
+ &srcRect, &clipRect, wizFlags, conversionTable,
+ TRLEFLIP_AltSource_F_BOOL_ALPHA_X2X,
+ TRLEFLIP_AltSource_B_BOOL_ALPHA_X2X);
+
+ return true;
+ }
+ } else {
+ if (wizFlags & kWRFInverseAlpha) {
+ // Inverse alpha
+ TRLEFLIP_AltSource_DecompressPrim(
+ destBufferPtr, destBufferWidth, destBufferHeight,
+ altBufferPtr, altBitsPerPixel, &fakeImage, x, y,
+ &srcRect, &clipRect, wizFlags, conversionTable,
+ TRLEFLIP_AltSource_F_INVALPHA_X2X,
+ TRLEFLIP_AltSource_B_INVALPHA_X2X);
+
+ return true;
+ } else {
+ // Normal alpha
+ TRLEFLIP_AltSource_DecompressPrim(
+ destBufferPtr, destBufferWidth, destBufferHeight,
+ altBufferPtr, altBitsPerPixel, &fakeImage, x, y,
+ &srcRect, &clipRect, wizFlags, conversionTable,
+ TRLEFLIP_AltSource_F_ALPHA_X2X,
+ TRLEFLIP_AltSource_B_ALPHA_X2X);
+
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
+void Wiz::TRLEFLIP_AltSource_DecompressImage(
+ WizRawPixel *destBufferPtr, const byte *compData, int destBufferWidth, int destBufferHeight,
+ const void *altBufferPtr, int altWidth, int altHeight, int altBitsPerPixel,
+ int x, int y, int width, int height, Common::Rect *clipRectPtr,
+ int32 wizFlags, const WizRawPixel *conversionTable,
+ WizImageCommand *optionalICmdPtr) {
+ Common::Rect srcRect, clipRect;
+ COMPRESSEDIMAGE fakeImage;
+ int curBpp = _uses16BitColor ? 16 : 8;
+
+ if (_uses16BitColor)
+ TRLEFLIP_CheckAlphaSetup();
+
+ // General setup
+ fakeImage.data = (byte *)compData;
+ fakeImage.width = width;
+ fakeImage.height = height;
+
+ makeSizedRect(&srcRect, width, height);
+ makeSizedRect(&clipRect, destBufferWidth, destBufferHeight);
+
+ if (clipRectPtr) {
+ if (!findRectOverlap(&clipRect, clipRectPtr)) {
+ return;
+ }
+ }
+
+ // Check the assumptions about the alt src buffer matching the dest buffer
+ if ((altWidth != destBufferWidth) || (altHeight != destBufferHeight)) {
+ return;
+ }
+
+ if (_uses16BitColor) {
+ // Check for new "special" rendering modes
+ if (wizFlags & kWRFSpecialRenderBitMask) {
+ if (!TRLEFLIP_AltSource_SpecialCaseDispatch(
+ destBufferPtr, compData, destBufferWidth, destBufferHeight,
+ altBufferPtr, altWidth, altHeight, altBitsPerPixel,
+ x, y, width, height, clipRectPtr, wizFlags, conversionTable,
+ optionalICmdPtr)) {
+ } else {
+ return;
+ }
+ }
+ }
+
+ // Dispatch to the next level of code. (8bpp or conversion)
+ if (altBitsPerPixel == curBpp) {
+ if (!_uses16BitColor)
+ error("Wiz::TRLEFLIP_AltSource_DecompressImage(): Yeah, it's used, fix it! 1");
+ TRLEFLIP_AltSource_DecompressPrim(
+ destBufferPtr, destBufferWidth, destBufferHeight,
+ altBufferPtr, altBitsPerPixel, &fakeImage, x, y,
+ &srcRect, &clipRect, wizFlags, conversionTable,
+ TRLEFLIP_AltSource_F_XBppToXBpp,
+ TRLEFLIP_AltSource_B_XBppToXBpp);
+ } else if (altBitsPerPixel == 8) {
+ if (!_uses16BitColor)
+ error("Wiz::TRLEFLIP_AltSource_DecompressImage(): Yeah, it's used, fix it! 2");
+ TRLEFLIP_AltSource_DecompressPrim(
+ destBufferPtr, destBufferWidth, destBufferHeight,
+ altBufferPtr, altBitsPerPixel, &fakeImage, x, y,
+ &srcRect, &clipRect, wizFlags, conversionTable,
+ TRLEFLIP_AltSource_F_8BppToXBpp,
+ TRLEFLIP_AltSource_B_8BppToXBpp);
+ }
+}
+
+int Wiz::TRLE_CompressImageArea(
+ byte *destBuffer, const WizRawPixel *sourceBuffer, int sourceBufferWidth,
+ int x1, int y1, int x2, int y2, WizRawPixel transparentColor) {
+ int width, height, totalSize, lineSize;
+ byte *sizeWordPtr = nullptr;
+
+ width = x2 - x1 + 1;
+ height = y2 - y1 + 1;
+
+ WizRawPixel8 *buf8 = (WizRawPixel8 *)sourceBuffer;
+ WizRawPixel16 *buf16 = (WizRawPixel16 *)sourceBuffer;
+
+ if (_uses16BitColor) {
+ buf16 += sourceBufferWidth * y1 + x1;
+ sourceBuffer = (WizRawPixel *)buf16;
+ } else {
+ buf8 += sourceBufferWidth * y1 + x1;
+ sourceBuffer = (WizRawPixel *)buf8;
+ }
+
+ totalSize = 0;
+
+ while (height-- > 0) {
+ if (destBuffer) {
+ sizeWordPtr = destBuffer;
+ destBuffer += 2;
+ }
+
+ totalSize += 2;
+ lineSize = trle_rle_compression(
+ destBuffer, sourceBuffer, width, transparentColor);
+
+ // Refresh pointers, you never know...
+ buf8 = (WizRawPixel8 *)sourceBuffer;
+ buf16 = (WizRawPixel16 *)sourceBuffer;
+
+ if (_uses16BitColor) {
+ buf16 += sourceBufferWidth;
+ sourceBuffer = (WizRawPixel *)buf16;
+ } else {
+ buf8 += sourceBufferWidth;
+ sourceBuffer = (WizRawPixel *)buf8;
+ }
+
+ totalSize += lineSize;
+ if (destBuffer) {
+ WRITE_LE_UINT16(sizeWordPtr, (uint16)lineSize);
+ destBuffer += lineSize;
+ }
+ }
+
+ return totalSize;
+}
+
+byte *Wiz::trle_putdump(byte *dest, int nn) {
+ int i, count, index;
+ byte value;
+
+ index = 0;
+
+ do {
+
+ count = nn;
+ if (count > 64) {
+ count = 64;
+ }
+ nn -= count;
+
+ value = count - 1;
+ value <<= 2;
+ trle_putbyte(value);
+
+ for (i = 0; i < count; i++) {
+ trle_putbyte(_trleBuf[index++]);
+ }
+
+ } while (nn > 0);
+
+ return dest;
+}
+
+byte *Wiz::trle_putrun(byte *dest, int nn, int cc, int tColor) {
+ byte value;
+ int count;
+
+ if (cc == tColor) {
+
+ do {
+
+ count = nn;
+ if (count > 127) {
+ count = 127;
+ }
+ nn -= count;
+
+ value = count;
+ value <<= 1;
+ value |= 1;
+ trle_putbyte(value);
+
+ } while (nn > 0);
+
+ } else {
+
+ do {
+
+ count = nn;
+ if (count > 64) {
+ count = 64;
+ }
+ nn -= count;
+
+ value = count - 1;
+ value <<= 2;
+ value |= 2;
+ trle_putbyte(value);
+ trle_putbyte(cc);
+
+ } while (nn > 0);
+ }
+
+ return dest;
+}
+
+int Wiz::trle_rle_compression(byte *pdest, const WizRawPixel *psource, int rowsize, WizRawPixel tcolor) {
+ byte *dest;
+ WizRawPixel c;
+ WizRawPixel lastc = 0;
+ int mode = TRLE_DUMP;
+ int nbuf = 0;
+ int rstart = 0;
+ int counter;
+
+ const WizRawPixel *source = psource;
+ const WizRawPixel8 *source8 = (WizRawPixel8 *)psource;
+ const WizRawPixel16 *source16 = (WizRawPixel16 *)psource;
+
+ // Check for completely transparent
+ for (counter = 0; counter < rowsize; counter++) {
+ if (_uses16BitColor) {
+ if (*(source16 + counter) != tcolor) {
+ break;
+ }
+ } else {
+ if (*(source8 + counter) != tcolor) {
+ break;
+ }
+ }
+ }
+
+ if (counter >= rowsize) {
+ return 0;
+ }
+
+ dest = pdest;
+ _trlePutsize = 0;
+
+ if (_uses16BitColor) {
+ _trleBuf[0] = lastc = c = (*source16++);
+ _trleBuf[0] = (byte)c;
+ source = (WizRawPixel *)source16;
+ } else {
+ _trleBuf[0] = lastc = c = (*source8++);
+ _trleBuf[0] = (byte)c;
+ source = (WizRawPixel *)source8;
+ }
+
+ nbuf = 1;
+ rowsize--;
+ mode = ((c == tcolor) ? TRLE_RUN : TRLE_DUMP);
+
+ for (; rowsize; --rowsize) {
+ if (_uses16BitColor) {
+ c = (*source16++);
+ _trleBuf[nbuf++] = (byte)c;
+ source = (WizRawPixel *)source16;
+ } else {
+ c = (*source8++);
+ _trleBuf[nbuf++] = (byte)c;
+ source = (WizRawPixel *)source8;
+ }
+
+ switch (mode) {
+ case TRLE_DUMP:
+ // Don't allow transparent colors in a literal run!
+ if (c == tcolor) {
+ trle_outdump(nbuf - 1);
+ _trleBuf[0] = c;
+ nbuf = 1;
+ rstart = 0;
+ mode = TRLE_RUN;
+ break;
+ }
+
+ // check to see if too literal run too big if so dump it
+ if (nbuf > TRLE_MAXDAT) {
+ trle_outdump(nbuf - 1);
+ _trleBuf[0] = c;
+ nbuf = 1;
+ rstart = 0;
+ break;
+ }
+
+ // Check to see if you can start a run of data...
+ if (c == lastc) {
+ if (nbuf - rstart >= TRLE_MINRUN) {
+ if (rstart > 0) {
+ trle_outdump(rstart);
+ }
+ mode = TRLE_RUN;
+ } else {
+ if (rstart == 0) {
+ mode = TRLE_RUN;
+ }
+ }
+ } else {
+ rstart = nbuf - 1;
+ break;
+ }
+
+ case TRLE_RUN:
+ // Check run to see if still going...
+ if ((c != lastc) || (nbuf - rstart > TRLE_MAXRUN)) {
+ trle_outrun(nbuf - 1 - rstart, lastc);
+ _trleBuf[0] = c;
+ nbuf = 1;
+ rstart = 0;
+ // Don't allow transparent colors in a literal run!
+ mode = ((c == tcolor) ? TRLE_RUN : TRLE_DUMP);
+ }
+ break;
+ }
+
+ lastc = c;
+ }
+
+ switch (mode) {
+ case TRLE_DUMP:
+ trle_outdump(nbuf);
+ break;
+ case TRLE_RUN:
+ trle_outrun(nbuf - rstart, lastc);
+ break;
+ }
+
+ return _trlePutsize;
+}
} // End of namespace Scumm
diff --git a/engines/scumm/he/gfx_primitives_he.cpp b/engines/scumm/he/gfx_primitives_he.cpp
index 01b51f8a031..bd08fd4ff21 100644
--- a/engines/scumm/he/gfx_primitives_he.cpp
+++ b/engines/scumm/he/gfx_primitives_he.cpp
@@ -33,9 +33,9 @@ int Wiz::pgReadPixel(const WizSimpleBitmap *srcBM, int x, int y, int defaultValu
return defaultValue;
} else {
if (_uses16BitColor) {
- return *(srcBM->bufferPtr + y * srcBM->bitmapWidth + x);
+ return *(((WizRawPixel16 *)srcBM->bufferPtr) + y * srcBM->bitmapWidth + x);
} else {
- return *(((uint8 *)srcBM->bufferPtr) + y * srcBM->bitmapWidth + x);
+ return *(((WizRawPixel8 *)srcBM->bufferPtr) + y * srcBM->bitmapWidth + x);
}
}
}
@@ -43,9 +43,9 @@ int Wiz::pgReadPixel(const WizSimpleBitmap *srcBM, int x, int y, int defaultValu
void Wiz::pgWritePixel(WizSimpleBitmap *srcBM, int x, int y, WizRawPixel value) {
if ((x >= 0) && (y >= 0) && (x < srcBM->bitmapWidth) && (y < srcBM->bitmapHeight)) {
if (_uses16BitColor) {
- *(srcBM->bufferPtr + y * srcBM->bitmapWidth + x) = value;
+ *(((WizRawPixel16 *)srcBM->bufferPtr) + y * srcBM->bitmapWidth + x) = value;
} else {
- *(((uint8 *)srcBM->bufferPtr) + y * srcBM->bitmapWidth + x) = value;
+ *(((WizRawPixel8 *)srcBM->bufferPtr) + y * srcBM->bitmapWidth + x) = value;
}
}
}
@@ -53,9 +53,9 @@ void Wiz::pgWritePixel(WizSimpleBitmap *srcBM, int x, int y, WizRawPixel value)
void Wiz::pgClippedWritePixel(WizSimpleBitmap *srcBM, int x, int y, const Common::Rect *clipRectPtr, WizRawPixel value) {
if ((x >= clipRectPtr->left) && (y >= clipRectPtr->top) && (x <= clipRectPtr->right) && (y <= clipRectPtr->bottom)) {
if (_uses16BitColor) {
- *(srcBM->bufferPtr + y * srcBM->bitmapWidth + x) = value;
+ *(((WizRawPixel16 *)srcBM->bufferPtr) + y * srcBM->bitmapWidth + x) = value;
} else {
- *(((uint8 *)srcBM->bufferPtr) + y * srcBM->bitmapWidth + x) = value;
+ *(((WizRawPixel8 *)srcBM->bufferPtr) + y * srcBM->bitmapWidth + x) = value;
}
}
}
@@ -387,8 +387,8 @@ void Wiz::pgDrawClippedEllipse(WizSimpleBitmap *pDestBitmap, int iPX, int iPY, i
}
void Wiz::pgDrawSolidRect(WizSimpleBitmap *destBM, const Common::Rect *rectPtr, WizRawPixel color) {
- WizRawPixel *d;
- uint8 *d8bit;
+ WizRawPixel16 *d16bit;
+ WizRawPixel8 *d8bit;
int cw, dw, ch;
int x1 = rectPtr->left, y1 = rectPtr->top, x2 = rectPtr->right, y2 = rectPtr->bottom;
@@ -396,16 +396,16 @@ void Wiz::pgDrawSolidRect(WizSimpleBitmap *destBM, const Common::Rect *rectPtr,
dw = destBM->bitmapWidth;
cw = x2 - x1 + 1;
ch = y2 - y1 + 1;
- d = destBM->bufferPtr + y1 * dw + x1;
- d8bit = ((uint8 *)destBM->bufferPtr) + y1 * dw + x1;
+ d16bit = ((WizRawPixel16 *)destBM->bufferPtr) + y1 * dw + x1;
+ d8bit = ((WizRawPixel8 *)destBM->bufferPtr) + y1 * dw + x1;
if (cw > 1) {
while (--ch >= 0) {
if (_uses16BitColor) {
- for (int i = 0; i < dw; i++)
- WRITE_LE_UINT16(&d[i], color);
- d += dw;
+ for (int i = 0; i < cw; i++)
+ WRITE_LE_UINT16(&d16bit[i], color);
+ d16bit += dw;
} else {
memset(d8bit, color, cw);
d8bit += dw;
@@ -414,8 +414,8 @@ void Wiz::pgDrawSolidRect(WizSimpleBitmap *destBM, const Common::Rect *rectPtr,
} else {
while (--ch >= 0) {
if (_uses16BitColor) {
- *d = color;
- d += dw;
+ *d16bit = color;
+ d16bit += dw;
} else {
*d8bit = color;
d8bit += dw;
@@ -453,6 +453,37 @@ void Wiz::pgFloodFillCmd(int x, int y, int color, const Common::Rect *optionalCl
}
}
+void Wiz::pgHistogramBitmapSubRect(int *tablePtr, const WizSimpleBitmap *bitmapPtr, const Common::Rect *sourceRect) {
+ if (!_uses16BitColor) {
+ Common::Rect rect, clipRect;
+ WizRawPixel8 *srcPtr;
+ int off, h, w, x;
+
+ rect = *sourceRect;
+
+ clipRect.left = 0;
+ clipRect.top = 0;
+ clipRect.right = (bitmapPtr->bitmapWidth - 1);
+ clipRect.bottom = (bitmapPtr->bitmapHeight - 1);
+
+ if (findRectOverlap(&rect, &clipRect)) {
+ srcPtr = ((WizRawPixel8 *)bitmapPtr->bufferPtr) + bitmapPtr->bitmapWidth * rect.top + rect.left;
+
+ w = getRectWidth(&rect);
+ h = getRectHeight(&rect);
+ off = bitmapPtr->bitmapWidth - w;
+
+ while (--h >= 0) {
+ for (x = w; --x >= 0;) {
+ *(tablePtr + *srcPtr++) += 1;
+ }
+
+ srcPtr += off;
+ }
+ }
+ }
+}
+
void Wiz::pgSimpleBitmapFromDrawBuffer(WizSimpleBitmap *bitmapPtr, bool background) {
VirtScreen *vs = &_vm->_virtscr[kMainVirtScreen];
@@ -1286,7 +1317,7 @@ void Wiz::pgBlit90DegreeRotateTransparent(WizSimpleBitmap *dstBitmap, int x, int
void Wiz::pgBlit90DegreeRotateCore(WizSimpleBitmap *dstBitmap, int x, int y, const WizSimpleBitmap *srcBitmap, const Common::Rect *optionalSrcRect,
const Common::Rect *optionalClipRect, bool hFlip, bool vFlip, const void *userParam, const void *userParam2,
- void(*srcTransferFP)(Wiz *wiz, WizRawPixel *dstPtr, int dstStep, const WizRawPixel *srcPtr, int count, const void *userParam, const void *userParam2)) {
+ void (*srcTransferFP)(Wiz *wiz, WizRawPixel *dstPtr, int dstStep, const WizRawPixel *srcPtr, int count, const void *userParam, const void *userParam2)) {
Common::Rect dstRect, srcRect, clipRect, clippedDstRect, clippedSrcRect;
int dstOffset, dstStep, w, h, srcOffset, dstX, dstY;
@@ -1649,13 +1680,25 @@ void Wiz::vertFlipAlignWithRect(Common::Rect *rectToAlign, const Common::Rect *b
moveRect(rectToAlign, 0, dy);
}
+void Wiz::swapRectX(Common::Rect *rectPtr) {
+ int16 t = rectPtr->right;
+ rectPtr->right = rectPtr->left;
+ rectPtr->left = t;
+}
+
+void Wiz::swapRectY(Common::Rect *rectPtr) {
+ int16 t = rectPtr->bottom;
+ rectPtr->bottom = rectPtr->top;
+ rectPtr->top = t;
+}
+
int Wiz::getRawPixel(int color) {
return color & WIZRAWPIXEL_MASK;
}
void Wiz::memset8BppConversion(void *dstPtr, int value, size_t count, const WizRawPixel *conversionTable) {
if (_uses16BitColor) {
- rawPixelMemset(dstPtr, (int)convert8BppToRawPixel((WizRawPixel)value, conversionTable), count);
+ rawPixelMemset(dstPtr, (int)convert8BppToRawPixel((WizRawPixel16)value, conversionTable), count);
} else {
memset(dstPtr, value, count);
}
@@ -1663,11 +1706,11 @@ void Wiz::memset8BppConversion(void *dstPtr, int value, size_t count, const WizR
void Wiz::memcpy8BppConversion(void *dstPtr, const void *srcPtr, size_t count, const WizRawPixel *conversionTable) {
if (_uses16BitColor) {
- WizRawPixel *dstWritePtr = (WizRawPixel *)(dstPtr);
+ WizRawPixel16 *dstWritePtr = (WizRawPixel16 *)(dstPtr);
const byte *srcReadPtr = (const byte *)(srcPtr);
int counter = count;
while (0 <= --counter) {
- *dstWritePtr++ = convert8BppToRawPixel((WizRawPixel)(*srcReadPtr++), conversionTable);
+ *dstWritePtr++ = convert8BppToRawPixel((WizRawPixel16)(*srcReadPtr++), conversionTable);
}
} else {
memcpy(dstPtr, srcPtr, count);
@@ -1676,18 +1719,18 @@ void Wiz::memcpy8BppConversion(void *dstPtr, const void *srcPtr, size_t count, c
void Wiz::rawPixelMemset(void *dstPtr, int value, size_t count) {
if (_uses16BitColor) {
- uint16 *dst16Bit = (uint16 *)dstPtr;
+ WizRawPixel16 *dst16Bit = (WizRawPixel16 *)dstPtr;
for (int i = 0; i < count; i++)
WRITE_LE_UINT16(&dst16Bit[i], value);
} else {
- uint8 *dst8Bit = (uint8 *)dstPtr;
+ WizRawPixel8 *dst8Bit = (WizRawPixel8 *)dstPtr;
memset(dst8Bit, value, count);
}
}
WizRawPixel Wiz::convert8BppToRawPixel(WizRawPixel value, const WizRawPixel *conversionTable) {
if (_uses16BitColor) {
- return *(conversionTable + value);
+ return *(((WizRawPixel16 *)conversionTable) + value);
} else {
return value;
}
diff --git a/engines/scumm/he/intern_he.h b/engines/scumm/he/intern_he.h
index e2a7249d122..dd0e270883c 100644
--- a/engines/scumm/he/intern_he.h
+++ b/engines/scumm/he/intern_he.h
@@ -334,6 +334,8 @@ public:
};
class ScummEngine_v72he : public ScummEngine_v71he {
+ friend class Wiz;
+
protected:
enum SubOpType {
SO_NONE = 1,
diff --git a/engines/scumm/he/script_v100he.cpp b/engines/scumm/he/script_v100he.cpp
index 9eb009a53e8..968b5b4dddc 100644
--- a/engines/scumm/he/script_v100he.cpp
+++ b/engines/scumm/he/script_v100he.cpp
@@ -2204,7 +2204,7 @@ void ScummEngine_v100he::o100_systemOps() {
}
void ScummEngine_v100he::o100_cursorCommand() {
- int a, b, i;
+ int a, b;
int args[16];
byte subOp = fetchScriptByte();
@@ -2215,7 +2215,7 @@ void ScummEngine_v100he::o100_cursorCommand() {
break;
case SO_CHARSET_COLOR:
getStackList(args, ARRAYSIZE(args));
- for (i = 0; i < 16; i++)
+ for (int i = 0; i < 16; i++)
_charsetColorMap[i] = _charsetData[_string[1]._default.charset][i] = (unsigned char)args[i];
break;
case SO_CURSOR_IMAGE:
@@ -2582,6 +2582,7 @@ void ScummEngine_v100he::o100_getSpriteGroupInfo() {
void ScummEngine_v100he::o100_getWizData() {
byte filename[4096];
int resId, state, type;
+ Common::Rect clipRect;
int32 w, h;
int32 x, y;
@@ -2593,18 +2594,17 @@ void ScummEngine_v100he::o100_getWizData() {
x = pop();
state = pop();
resId = pop();
- push(_wiz->getWizPixelColor(resId, state, x, y));
+ push(_wiz->pixelHitTestWiz(resId, state, x, y, 0));
break;
case SO_COUNT:
- resId = pop();
- push(_wiz->getWizImageStates(resId));
+ push(_wiz->getWizImageStates(pop()));
break;
case SO_FIND:
y = pop();
x = pop();
state = pop();
resId = pop();
- push(_wiz->isWizPixelNonTransparent(resId, state, x, y, 0));
+ push(_wiz->hitTestWiz(resId, state, x, y, 0));
break;
case SO_HEIGHT:
state = pop();
@@ -2615,8 +2615,11 @@ void ScummEngine_v100he::o100_getWizData() {
case SO_NEW_GENERAL_PROPERTY:
type = pop();
state = pop();
- resId = pop();
- push(_wiz->getWizImageData(resId, state, type));
+ if (resId = pop()) {
+ push(_wiz->dwGetImageGeneralProperty(resId, state, type));
+ } else {
+ push(0);
+ }
break;
case SO_WIDTH:
state = pop();
@@ -2644,18 +2647,19 @@ void ScummEngine_v100he::o100_getWizData() {
debug(0, "o100_getWizData() case 111 unhandled");
break;
case SO_HISTOGRAM:
- h = pop();
- w = pop();
- y = pop();
- x = pop();
+ clipRect.bottom = pop();
+ clipRect.right = pop();
+ clipRect.top = pop();
+ clipRect.left = pop();
state = pop();
resId = pop();
- if (x == -1 && y == -1 && w == -1 && h == -1) {
+ if (clipRect.left == -1 && clipRect.top == -1 &&
+ clipRect.right == -1 && clipRect.bottom == -1) {
_wiz->getWizImageDim(resId, state, w, h);
- x = 0;
- y = 0;
+ _wiz->makeSizedRect(&clipRect, w, h);
}
- push(computeWizHistogram(resId, state, x, y, w, h));
+
+ push(_wiz->createHistogramArrayForImage(resId, state, &clipRect));
break;
default:
error("o100_getWizData: Unknown case %d", subOp);
diff --git a/engines/scumm/he/sprite_he.cpp b/engines/scumm/he/sprite_he.cpp
index 25b5e6fac88..0ec0cc74b91 100644
--- a/engines/scumm/he/sprite_he.cpp
+++ b/engines/scumm/he/sprite_he.cpp
@@ -1258,6 +1258,7 @@ void Sprite::renderSprites(bool arg) {
int angle, scale;
int32 w, h;
WizImageCommand wiz;
+ wiz.reset();
for (int i = 0; i < _numSpritesToProcess; i++) {
SpriteInfo *spi = _activeSpritesTable[i];
diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp
index 20b3d3d9de9..a66e5f95ffe 100644
--- a/engines/scumm/he/wiz_he.cpp
+++ b/engines/scumm/he/wiz_he.cpp
@@ -1091,22 +1091,6 @@ static int wizPackType1(uint8 *dst, const uint8 *src, int srcPitch, const Common
return dataSize;
}
-static int wizPackType0(uint8 *dst, const uint8 *src, int srcPitch, const Common::Rect& rCapt) {
- debug(9, "wizPackType0([%d,%d,%d,%d])", rCapt.left, rCapt.top, rCapt.right, rCapt.bottom);
- int w = rCapt.width();
- int h = rCapt.height();
- int size = w * h;
- if (dst) {
- src += rCapt.top * srcPitch + rCapt.left;
- while (h--) {
- memcpy(dst, src, w);
- dst += w;
- src += srcPitch;
- }
- }
- return size;
-}
-
void Wiz::processWizImageCaptureCmd(const WizImageCommand *params) {
bool compressIt = (params->compressionType == kWCTTRLE);
bool background = (params->flags & kWRFBackground) != 0;
@@ -1255,9 +1239,10 @@ void *Wiz::drawAWizPrimEx(int globNum, int state, int x, int y, int z, int shado
if (shadowImage) {
shadow_p = (byte *)getColorMixBlockPtrForWiz(shadowImage);
- if (shadow_p) {
- shadow_p += 8;
- }
+ // TODO: I don't think this is needed here?
+ //if (shadow_p) {
+ // shadow_p += 8;
+ //}
} else {
shadow_p = nullptr;
}
@@ -1277,7 +1262,7 @@ void *Wiz::drawAWizPrimEx(int globNum, int state, int x, int y, int z, int shado
}
// Get the header for this "state"
- pp = (byte *)getWizStateHeaderPrim(globNum, state);
+ pp = getWizStateHeaderPrim(globNum, state);
if (!pp)
error("Wiz::drawAWizPrimEx(): %d state %d missing header", globNum, state);
@@ -1285,12 +1270,12 @@ void *Wiz::drawAWizPrimEx(int globNum, int state, int x, int y, int z, int shado
src_w = READ_LE_UINT32(pp + _vm->_resourceHeaderSize + 4);
src_h = READ_LE_UINT32(pp + _vm->_resourceHeaderSize + 8);
- if ((!isUncompressedFormatTypeID(src_c)) && (kWCTTRLE != src_c)) {
+ if ((!isUncompressedFormatTypeID(src_c)) && (src_c != kWCTTRLE)) {
error("Wiz::drawAWizPrimEx(): %d has invalid compression type %d", globNum, src_c);
}
// Get the data block for this "state"
- src_d = (byte *)getWizStateDataPrim( globNum, state);
+ src_d = (byte *)getWizStateDataPrim(globNum, state);
if (!src_d)
error("Wiz::drawAWizPrimEx(): %d state %d missing data block", globNum, state);
@@ -1328,7 +1313,11 @@ void *Wiz::drawAWizPrimEx(int globNum, int state, int x, int y, int z, int shado
if (flags & (kWRFPrint | kWRFAlloc)) {
dest_w = src_w;
dest_h = src_h;
- dest_p = (WizRawPixel *)malloc(dest_w * dest_h * sizeof(WizRawPixel));
+ if (_uses16BitColor) {
+ dest_p = (WizRawPixel *)malloc(dest_w * dest_h * sizeof(WizRawPixel16));
+ } else {
+ dest_p = (WizRawPixel *)malloc(dest_w * dest_h * sizeof(WizRawPixel8));
+ }
if (!dest_p) {
warning("Wiz::drawAWizPrimEx(): Not enough memory for image operation (print / other)");
@@ -1419,12 +1408,12 @@ void *Wiz::drawAWizPrimEx(int globNum, int state, int x, int y, int z, int shado
if (flags & kWRFRemap)
dataPtr = remap_p + _vm->_resourceHeaderSize + 4;
- // TODO
- //TRLEFLIP_DecompressImage(
- // dest_p, src_d + _vm->_resourceHeaderSize, dest_w, dest_h,
- // x, y, src_w, src_h, &clip_r, flags, dataPtr,
- // optionalColorConversionTable,
- // optionalICmdPtr);
+
+ TRLEFLIP_DecompressImage(
+ dest_p, src_d + _vm->_resourceHeaderSize, dest_w, dest_h,
+ x, y, src_w, src_h, &clip_r, flags, dataPtr,
+ optionalColorConversionTable,
+ optionalICmdPtr);
}
} else {
@@ -1443,8 +1432,8 @@ void *Wiz::drawAWizPrimEx(int globNum, int state, int x, int y, int z, int shado
transColorOverride = -1;
}
- if (kWCTNone16Bpp != src_c && kWCTNone16BppBigEndian != src_c) {
- if (kWCTNone == src_c) {
+ if (src_c != kWCTNone16Bpp && src_c != kWCTNone16BppBigEndian) {
+ if (src_c == kWCTNone) {
pgDraw8BppFormatImage(
dest_p, (byte *)(src_d + _vm->_resourceHeaderSize), dest_w, dest_h,
x, y, src_w, src_h, &clip_r, flags, dataPtr, transColorOverride,
@@ -1454,7 +1443,6 @@ void *Wiz::drawAWizPrimEx(int globNum, int state, int x, int y, int z, int shado
}
} else {
-
// Use the native transfer function
if (optionalColorConversionTable &&
((WizRawPixel *)_vm->getHEPaletteSlot(1) != optionalColorConversionTable)) {
@@ -1484,7 +1472,7 @@ void *Wiz::drawAWizPrimEx(int globNum, int state, int x, int y, int z, int shado
dest_r.bottom = y + src_h - 1;
if (findRectOverlap(&dest_r, &clip_r)) {
- // If neither forground or background, copy to both
+ // If neither foreground or background, copy to both
if ((flags & kWRFBackground) || ((flags & (kWRFBackground | kWRFForeground)) == 0)) {
_vm->backgroundToForegroundBlit(dest_r);
} else {
@@ -1511,7 +1499,7 @@ void Wiz::buildAWiz(const WizRawPixel *bufPtr, int bufWidth, int bufHeight, cons
dataSize = 0;
- if (!rectPtr) {
+ if (rectPtr) {
if (!findRectOverlap(&compRect, rectPtr)) {
error("Build wiz incorrect size (%d,%d,%d,%d)", rectPtr->left, rectPtr->top, rectPtr->right, rectPtr->bottom);
}
@@ -1530,10 +1518,9 @@ void Wiz::buildAWiz(const WizRawPixel *bufPtr, int bufWidth, int bufHeight, cons
}
if (compressionType == kWCTTRLE) {
- // TODO
- //dataSize = TRLE_CompressImageArea(
- // nullptr, bufPtr, bufWidth, compRect.left, compRect.top, compRect.right, compRect.bottom,
- // (WizRawPixel)transparentColor);
+ dataSize = TRLE_CompressImageArea(
+ nullptr, bufPtr, bufWidth, compRect.left, compRect.top, compRect.right, compRect.bottom,
+ (WizRawPixel)transparentColor);
} else if (isUncompressedFormatTypeID(compressionType)) {
dataSize = ((getRectWidth(&compRect) * getRectHeight(&compRect)) * sizeof(WizRawPixel));
} else {
@@ -1587,11 +1574,10 @@ void Wiz::buildAWiz(const WizRawPixel *bufPtr, int bufWidth, int bufHeight, cons
if (compressionType == kWCTTRLE) {
if (!_uses16BitColor) {
- // TODO
- // TRLE_CompressImageArea(
- // ptr + dataOffset, bufPtr, bufWidth,
- // compRect.left, compRect.top, compRect.top, compRect.bottom,
- // (byte)transparentColor);
+ TRLE_CompressImageArea(
+ ptr + dataOffset, bufPtr, bufWidth,
+ compRect.left, compRect.top, compRect.top, compRect.bottom,
+ (byte)transparentColor);
} else {
error("Incorrect type %d for current pixel mode 16 bit", compressionType);
}
@@ -1629,6 +1615,153 @@ void Wiz::buildAWiz(const WizRawPixel *bufPtr, int bufWidth, int bufHeight, cons
}
}
+int Wiz::pixelHitTestWiz(int image, int state, int x, int y, int32 flags) {
+ return pixelHitTestWizPrim(image, state, x, y, flags);
+}
+
+int Wiz::pixelHitTestWizPrim(int globNum, int state, int x, int y, int32 flags) {
+
+#ifdef SCUMM_XTL_BRIDGE // 5/9/2000 BPT
+ int outValue = 0;
+
+ if (PU_OverrideImagePixelHitTest(&outValue, globType, globNum, state, x, y, flags)) {
+ return outValue;
+ }
+#endif
+
+ int src_c, src_w, src_h;
+ byte *src_d;
+ byte *pp;
+
+ // Get the header (width, height + compression)
+ pp = getWizStateHeaderPrim(globNum, state);
+
+ src_c = READ_LE_UINT32(pp + _vm->_resourceHeaderSize + 0);
+ src_w = READ_LE_UINT32(pp + _vm->_resourceHeaderSize + 4);
+ src_h = READ_LE_UINT32(pp + _vm->_resourceHeaderSize + 8);
+
+ // If the compression type is TRLE...
+ if (src_c == kWCTTRLE) {
+ src_d = getWizStateDataPrim(globNum, state);
+
+ // Where should the color lookup happen?
+ int pixel = auxPixelHitTestTRLEImageRelPos(
+ src_d + _vm->_resourceHeaderSize, x, y, src_w, src_h,
+ _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR));
+
+ int compType = getWizCompressionType(globNum, state);
+
+ if (LITTLE_ENDIAN_WIZ(compType)) {
+ return pixel;
+ } else {
+ if (WIZ_16BPP(compType)) {
+ return SWAP_BYTES_16(pixel);
+ } else {
+ return pixel;
+ }
+ }
+
+ } else if (isUncompressedFormatTypeID(src_c)) {
+ WizSimpleBitmap srcBitmap;
+
+ src_d = getWizStateDataPrim(globNum, state);
+
+ srcBitmap.bufferPtr = (WizRawPixel *)(src_d + _vm->_resourceHeaderSize);
+ srcBitmap.bitmapWidth = src_w;
+ srcBitmap.bitmapHeight = src_h;
+
+ int pixel = pgReadPixel(&srcBitmap, x, y, _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR));
+ int compType = getWizCompressionType(globNum, state);
+
+ if (LITTLE_ENDIAN_WIZ(compType)) {
+ return pixel;
+ } else {
+ if (WIZ_16BPP(compType)) {
+ return SWAP_BYTES_16(pixel);
+ } else {
+ return pixel;
+ }
+ }
+ } else {
+ return _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR);
+ }
+}
+
+int Wiz::hitTestWiz(int image, int state, int x, int y, int32 flags) {
+ return hitTestWizPrim(image, state, x, y, flags);
+}
+
+int Wiz::hitTestWizPrim(int globNum, int state, int x, int y, int32 flags) {
+
+#ifdef SCUMM_XTL_BRIDGE // 5/9/2000 BPT
+ int outValue = 0;
+
+ if (PU_OverrideImageHitTest(&outValue, globType, globNum, state, x, y, flags)) {
+ return outValue;
+ }
+#endif
+
+ int src_c, src_w, src_h;
+ byte *src_d;
+ byte *pp;
+
+ // Get the header (width, height + compression)
+ pp = getWizStateHeaderPrim(globNum, state);
+
+ src_c = READ_LE_UINT32(pp + _vm->_resourceHeaderSize + 0);
+ src_w = READ_LE_UINT32(pp + _vm->_resourceHeaderSize + 4);
+ src_h = READ_LE_UINT32(pp + _vm->_resourceHeaderSize + 8);
+
+ if (_vm->_game.heversion > 98) {
+ // Flip the test coords if needed and do simple point rejection
+ // (should be faster than calling the various functions)
+
+ if (flags & kWRFHFlip) {
+ x = ((src_w - 1) - x);
+
+ if (x < 0) {
+ return 0;
+ }
+
+ } else if ((x >= src_w) || (x < 0)) {
+ return 0;
+ }
+
+ if (flags & kWRFVFlip) {
+ y = ((src_h - 1) - y);
+
+ if (y < 0) {
+ return 0;
+ }
+
+ } else if ((y >= src_h) || (y < 0)) {
+ return 0;
+ }
+ }
+
+ // If the compression type is TRLE...
+ if (src_c == kWCTTRLE) {
+ src_d = getWizStateDataPrim(globNum, state);
+
+ return auxHitTestTRLEImageRelPos(src_d + _vm->_resourceHeaderSize, x, y, src_w, src_h) ? 1 : 0;
+ } else if (_vm->_game.heversion > 98 && isUncompressedFormatTypeID(src_c)) {
+ WizSimpleBitmap srcBitmap;
+
+ src_d = getWizStateDataPrim(globNum, state);
+
+ srcBitmap.bufferPtr = (WizRawPixel *)(src_d + _vm->_resourceHeaderSize);
+ srcBitmap.bitmapWidth = src_w;
+ srcBitmap.bitmapHeight = src_h;
+
+ return (_vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR) !=
+ pgReadPixel(&srcBitmap, x, y, _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR)))
+ ? 1
+ : 0;
+ } else {
+ return 0;
+ }
+}
+
uint8 *Wiz::drawWizImage(int resNum, int state, int maskNum, int maskState, int x1, int y1, int zorder, int shadow, int zbuffer, const Common::Rect *clipBox, int flags, int dstResNum, const uint8 *palPtr, uint32 conditionBits) {
debug(7, "drawWizImage(resNum %d, state %d maskNum %d maskState %d x1 %d y1 %d flags 0x%X zorder %d shadow %d zbuffer %d dstResNum %d conditionBits: 0x%x)", resNum, state, maskNum, maskState, x1, y1, flags, zorder, shadow, zbuffer, dstResNum, conditionBits);
uint8 *dataPtr;
@@ -2103,79 +2236,6 @@ struct PolygonDrawData {
};
void Wiz::processWizImagePolyCaptureCmd(const WizImageCommand *params) {
- //int resNum = params->image;
- //int maskNum = params->sourceImage;
- //bool maskState = (params->actionFlags & kWAFState) ? params->state : 0;
- //int id1 = params->polygon;
- //int id2 = params->polygon2;
- //int compType = params->compressionType;
- //
- //debug(7, "processWizImagePolyCaptureCmd: resNum %d, maskNum %d maskState %d, id1 %d id2 %d compType %d", resNum, maskNum, maskState, id1, id2, compType);
- //
- //int i, j;
- //WizPolygon *wp;
- //
- //wp = nullptr;
- //for (i = 0; i < ARRAYSIZE(_polygons); ++i) {
- // if (_polygons[i].id == id1) {
- // wp = &_polygons[i];
- // break;
- // }
- //}
- //if (!wp) {
- // error("Polygon1 %d is not defined", id1);
- //}
- //if (wp->numPoints != 5) {
- // error("Invalid point count %d for Polygon1 %d", wp->numPoints, id1);
- //}
- //
- //wp = nullptr;
- //for (i = 0; i < ARRAYSIZE(_polygons); ++i) {
- // if (_polygons[i].id == id2) {
- // wp = &_polygons[i];
- // break;
- // }
- //}
- //if (!wp) {
- // error("Polygon2 %d is not defined", id2);
- //}
- //if (wp->numPoints != 5) {
- // error("Invalid point count %d for Polygon2 %d", wp->numPoints, id2);
- //}
- //
- //int32 dstw, dsth, dstpitch;
- //int32 srcw, srch;
- //uint8 *imageBuffer;
- //
- //assert(maskNum);
- //const Common::Rect *r = nullptr;
- //const uint8 *src = drawWizImage(maskNum, maskState, 0, 0, 0, 0, 0, 0, 0, r, kWRFAlloc, 0, 0, 0);
- //getWizImageDim(maskNum, maskState, srcw, srch);
- //
- //dstw = wp->boundingRect.width();
- //dsth = wp->boundingRect.height();
- //dstpitch = dstw * _vm->_bytesPerPixel;
- //imageBuffer = (uint8 *)malloc(dstw * dsth * _vm->_bytesPerPixel);
- //assert(imageBuffer);
- //
- //const uint16 transColor = (_vm->VAR_WIZ_TRANSPARENT_COLOR != 0xFF) ? _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR) : 5;
- //if (_vm->_bytesPerPixel == 2) {
- // uint8 *tmpPtr = imageBuffer;
- // for (i = 0; i < dsth; i++) {
- // for (j = 0; j < dstw; j++)
- // WRITE_LE_UINT16(tmpPtr + j * 2, transColor);
- // tmpPtr += dstpitch;
- // }
- //} else {
- // memset(imageBuffer, transColor, dstw * dsth);
- //}
- //
- //Common::Rect bound;
- //drawWizPolygonImage(imageBuffer, src, nullptr, dstpitch, kDstMemory, dstw, dsth, srcw, srch, bound, wp->points, _vm->_bytesPerPixel);
- //
- //captureImage(imageBuffer, dstpitch, dstw, dsth, resNum, wp->boundingRect, compType);
- //free(imageBuffer);
-
int polygon1, polygon2, compressionType, srcImage = 0, shadow = 0, state = 0;
bool bIsHintColor = false;
int iHintColor = 0;
@@ -2728,7 +2788,9 @@ void Wiz::loadWizCursor(int resId, int palette) {
const Common::Rect *r = nullptr;
_cursorImage = true;
- uint8 *cursor = drawWizImage(resId, 0, 0, 0, 0, 0, 0, 0, 0, r, kWRFAlloc, 0, _vm->getHEPaletteSlot(palette), 0);
+ // TODO
+ //uint8 *cursor = drawWizImage(resId, 0, 0, 0, 0, 0, 0, 0, 0, r, kWRFAlloc, 0, _vm->getHEPaletteSlot(palette), 0);
+ uint8 *cursor = (uint8 *)drawAWizPrim(resId, 0, 0, 0, 0, 0, 0, 0, kWRFAlloc, 0, (WizRawPixel *)_vm->getHEPaletteSlot(palette));
_cursorImage = false;
int32 cw, ch;
@@ -2961,9 +3023,6 @@ void Wiz::dwCreateRawWiz(int imageNum, int w, int h, int flags, int bitsPerPixel
case 16:
compressionType = kWCTNone16Bpp;
break;
- case 32:
- compressionType = kWCTNone32Bpp;
- break;
default:
error("Unsupported image bits size %d", bitsPerPixel);
break;
@@ -3144,11 +3203,6 @@ void Wiz::dwAltSourceDrawWiz(int maskImage, int maskState, int x, int y, int sou
case kWCTNone16BppBigEndian:
srcBitsPerPixel = 16;
break;
-
- case kWCTNone32Bpp:
- case kWCTNone32BppBigEndian:
- srcBitsPerPixel = 32;
- break;
}
// Get the source wiz data pointer.
@@ -3198,13 +3252,13 @@ void Wiz::dwAltSourceDrawWiz(int maskImage, int maskState, int x, int y, int sou
}
// Finally call the primitive...
- if (maskCompressionType == kWCTTRLE) { // TODO
- //TRLEFLIP_AltSource_DecompressImage(
- // destBitmapPtr->bufferPtr, maskDataPtr,
- // destBitmapPtr->bitmapWidth, destBitmapPtr->bitmapHeight,
- // sourceBufferPtr, srcBitmapWidth, srcBitmapHeight, srcBitsPerPixel,
- // x, y, maskWidth, maskHeight, &clipRect, flags, conversionTable,
- // nullptr);
+ if (maskCompressionType == kWCTTRLE) {
+ TRLEFLIP_AltSource_DecompressImage(
+ destBitmapPtr->bufferPtr, maskDataPtr,
+ destBitmapPtr->bitmapWidth, destBitmapPtr->bitmapHeight,
+ sourceBufferPtr, srcBitmapWidth, srcBitmapHeight, srcBitsPerPixel,
+ x, y, maskWidth, maskHeight, &clipRect, flags, conversionTable,
+ nullptr);
} else if (maskCompressionType == kWCTMRLEWithLineSizePrefix) {
MRLEFLIP_AltSource_DecompressImage(
@@ -3359,8 +3413,38 @@ bool Wiz::dwIsMaskCompatibleCompressionType(int compressionType) {
bool Wiz::dwIsUncompressedFormatTypeID(int id) {
return ((kWCTNone == id) ||
- (kWCTNone16Bpp == id) || (kWCTNone32Bpp == id) ||
- (kWCTNone16BppBigEndian == id) || (kWCTNone32BppBigEndian == id));
+ (kWCTNone16Bpp == id) ||
+ (kWCTNone16BppBigEndian == id));
+}
+
+int Wiz::dwGetImageGeneralProperty(int image, int state, int property) {
+ switch (property) {
+ case kWIPCompressionType:
+ return getWizCompressionType(image, state);
+ break;
+
+ case kWIPPaletteBlockPresent:
+ return doesStateContainBlock(image, state, MKTAG('R', 'G', 'B', 'S'));
+ break;
+
+ case kWIPRemapBlockPresent:
+ return doesStateContainBlock(image, state, MKTAG('R', 'M', 'A', 'P'));
+ break;
+
+ case kWIPOpaqueBlockPresent:
+ return doesRawWizStateHaveTransparency(image, state);
+ break;
+
+ case kWIPXMAPBlockPresent:
+ return doesStateContainBlock(image, state, MKTAG('X', 'M', 'A', 'P'));
+ break;
+
+ default:
+ debug("Wiz::dwGetImageGeneralProperty(): image %d state %d property %d (unknown property id).", image, state, property);
+ break;
+ }
+
+ return 0;
}
void Wiz::handleRotate0SpecialCase(int image, int state, int x, int y, int shadow, int angle, int scale, const Common::Rect *clipRect, int32 flags, WizSimpleBitmap *optionalBitmapOverride, const WizRawPixel *optionalColorConversionTable) {
@@ -3417,11 +3501,10 @@ void Wiz::handleRotate90SpecialCase(int image, int state, int x, int y, int shad
}
}
- // TODO
- //TRLEFLIP_Rotate90_DecompressImage(
- // dest_p, compressedDataPtr, dest_w, dest_h, x, y, src_w, src_h,
- // clipRect, flags, nullptr, optionalColorConversionTable,
- // nullptr);
+ TRLEFLIP_Rotate90_DecompressImage(
+ dest_p, compressedDataPtr, dest_w, dest_h, x, y, src_w, src_h,
+ clipRect, flags, nullptr, optionalColorConversionTable,
+ nullptr);
// Update the screen? (If not writing to another bitmap...)
if (!optionalBitmapOverride) {
@@ -3699,8 +3782,115 @@ void Wiz::remapImage(int image, int state, int tableCount, const uint8 *remapLis
}
}
+int Wiz::createHistogramArrayForImage(int image, int state, const Common::Rect *optionalClipRect) {
+ int src_c, src_w, src_h, globNum;
+ Common::Rect realClippedRect;
+ int histogramTable[256];
+ byte *src_d;
+ byte *pp;
+
+ // This only makes sense in 8 bit color!!!!
+ globNum = image;
+
+ _vm->writeVar(0, 0);
+ ((ScummEngine_v72he *)_vm)->defineArray(0, _vm->kDwordArray, 0, 0, 0, 255);
+
+ if (_vm->readVar(0) != 0) {
+ // Get the header (width, height + compression)
+ pp = getWizStateHeaderPrim(globNum, state);
+
+ src_c = READ_LE_UINT32(pp + _vm->_resourceHeaderSize + 0);
+ src_w = READ_LE_UINT32(pp + _vm->_resourceHeaderSize + 4);
+ src_h = READ_LE_UINT32(pp + _vm->_resourceHeaderSize + 8);
+
+ // Clip the passed in coords to the real dimensions of the image
+ makeSizedRect(&realClippedRect, src_w, src_h);
+
+ if (optionalClipRect) {
+ if (!findRectOverlap(&realClippedRect, optionalClipRect)) {
+ return _vm->readVar(0);
+ }
+ }
+
+ // Get the data pointer
+ src_d = getWizStateDataPrim(globNum, state);
+
+ // Start with a clean array...
+ memset(histogramTable, 0, sizeof(histogramTable));
+
+ // Handle the different compression types...
+ if (src_c == kWCTTRLE) {
+ // Get the histogram...
+ auxHistogramTRLEPrim(histogramTable, src_d + _vm->_resourceHeaderSize, &realClippedRect);
+ } else if (src_c == kWCTNone) {
+ WizSimpleBitmap srcBitmap;
+
+ srcBitmap.bufferPtr = (WizRawPixel *)(src_d + _vm->_resourceHeaderSize);
+ srcBitmap.bitmapWidth = src_w;
+ srcBitmap.bitmapHeight = src_h;
+
+ pgHistogramBitmapSubRect(histogramTable, &srcBitmap, &realClippedRect);
+ } else {
+ warning("Wiz::createHistogramArrayForImage(): Unable to return histogram for type %d", src_c);
+ }
+
+ // Fill in the scumm array with the values...
+ if (_vm->readVar(0) != 0) {
+ for (int i = 0; i < 256; i++) {
+ ((ScummEngine_v72he *)_vm)->writeArray(0, 0, i, histogramTable[i]);
+ }
+ }
+ }
+
+ return _vm->readVar(0); // Too much fun!!!!
+}
+
void Wiz::ensureNativeFormatImageForState(int image, int state) {
- // TODO
+ // If AWIZ block is an XMAP, we don't want to do anything with it
+ if (dwGetImageGeneralProperty(image, state, kWIPXMAPBlockPresent)) {
+ return;
+ }
+
+ int compType = getWizCompressionType(image, state);
+ bool wiz16bpp = WIZ_16BPP(compType);
+ bool native = NATIVE_WIZ_TYPE(compType);
+
+ if (wiz16bpp && !native) {
+ uint16 *ptr = (uint16 *)getWizStateDataPrim(image, state);
+
+ int w, h;
+ getWizImageDim(image, state, w, h);
+ int32 pixelCount = w * h; // Number of pixels to twiddle
+
+ if (pixelCount <= 0) {
+ error("Width or height 0 for image %d state %d", image, state);
+ }
+
+ uint16 *thisPixel = ptr + 2; // Skip the "WIZD" header
+
+ for (int i = 0; i < pixelCount; i++) {
+ thisPixel[i] = SWAP_BYTES_16(thisPixel[i]);
+ }
+
+ int newCompType = compType;
+ switch (compType) {
+ case kWCTNone16Bpp:
+ newCompType += kWCTNone16BppBigEndian - kWCTNone16Bpp;
+ break;
+ case kWCTTRLE16Bpp:
+ newCompType += kWCTTRLE16BppBigEndian - kWCTTRLE16Bpp;
+ break;
+ case kWCTNone16BppBigEndian:
+ newCompType -= kWCTNone16BppBigEndian - kWCTNone16Bpp;
+ break;
+ case kWCTTRLE16BppBigEndian:
+ newCompType -= kWCTTRLE16BppBigEndian - kWCTTRLE16Bpp;
+ break;
+ }
+
+ // Reset the compression type
+ setWizCompressionType(image, state, newCompType);
+ }
}
void Wiz::processWizImageModifyCmd(const WizImageCommand *params) {
@@ -3954,7 +4144,12 @@ void Wiz::processWizImageSaveCmd(const WizImageCommand *params) {
}
void Wiz::processWizImageCmd(const WizImageCommand *params) {
- debug(7, "processWizImageCmd: actionMode %d", params->actionMode);
+ // TODO
+ //if (PU_ProcessWizImageCmd(params)) {
+ // return;
+ //}
+ debug(5, "processWizImageCmd: actionMode %d for image %d", params->actionMode, params->image);
+
switch (params->actionMode) {
case kWAUnknown:
// Do nothing...
@@ -4017,9 +4212,7 @@ void Wiz::processWizImageCmd(const WizImageCommand *params) {
}
bool Wiz::isUncompressedFormatTypeID(int id) {
- return ((kWCTNone == id) || (kWCTNone16Bpp == id) ||
- (kWCTNone32Bpp == id) || (kWCTNone16BppBigEndian == id) ||
- (kWCTNone32BppBigEndian == id));
+ return ((kWCTNone == id) || (kWCTNone16Bpp == id) || (kWCTNone16BppBigEndian == id));
}
void Wiz::getWizImageDim(int resNum, int state, int32 &w, int32 &h) {
@@ -4132,6 +4325,13 @@ const byte *Wiz::getColorMixBlockPtrForWiz(int image) {
return _vm->findResourceData(MKTAG('X', 'M', 'A', 'P'), data);
}
+void Wiz::setWizCompressionType(int image, int state, int newType) {
+ byte *data = getWizStateHeaderPrim(image, state);
+ assert(data);
+
+ WRITE_LE_UINT32(data + _vm->_resourceHeaderSize, newType);
+}
+
int Wiz::getWizCompressionType(int image, int state) {
byte *data = (byte *)getWizStateHeaderPrim(image, state);
assert(data);
@@ -4146,6 +4346,13 @@ bool Wiz::doesRawWizStateHaveTransparency(int globNum, int state) {
return _vm->findWrappedBlock(MKTAG('T', 'R', 'N', 'S'), data, state, false) != nullptr;
}
+bool Wiz::doesStateContainBlock(int globNum, int state, uint32 blockID) {
+ byte *data = _vm->getResourceAddress(rtImage, globNum);
+ assert(data);
+
+ return _vm->findWrappedBlock(blockID, data, state, false) != nullptr;
+}
+
int Wiz::isWizPixelNonTransparent(int resNum, int state, int x, int y, int flags) {
uint8 *data = _vm->getResourceAddress(rtImage, resNum);
assert(data);
diff --git a/engines/scumm/he/wiz_he.h b/engines/scumm/he/wiz_he.h
index c3371e0f1f2..ac09640f7bb 100644
--- a/engines/scumm/he/wiz_he.h
+++ b/engines/scumm/he/wiz_he.h
@@ -50,6 +50,29 @@ namespace Scumm {
#define DW_SAVE_PCX_FORMAT 1
#define DW_SAVE_RAW_FORMAT 2
+#if defined SCUMM_LITTLE_ENDIAN
+#define NATIVE_WIZ_COMP_NONE_16BPP kWCTNone16Bpp
+#define NATIVE_WIZ_COMP_TRLE_16BPP kWCTTRLE16Bpp
+
+#elif defined SCUMM_BIG_ENDIAN
+#define NATIVE_WIZ_COMP_NONE_16BPP kWCTNone16BppBigEndian
+#define NATIVE_WIZ_COMP_TRLE_16BPP kWCTTRLE16BppBigEndian
+#endif
+
+#define LITTLE_ENDIAN_WIZ(wizComp) \
+ (wizComp) == kWCTNone16Bpp || \
+ (wizComp) == kWCTTRLE16Bpp
+
+#define NATIVE_WIZ_TYPE(wizComp) \
+ (wizComp) == NATIVE_WIZ_COMP_NONE_16BPP || \
+ (wizComp) == NATIVE_WIZ_COMP_TRLE_16BPP \
+
+#define WIZ_16BPP(wizComp) \
+ (wizComp) == kWCTNone16Bpp || \
+ (wizComp) == kWCTTRLE16Bpp || \
+ (wizComp) == kWCTNone16BppBigEndian || \
+ (wizComp) == kWCTTRLE16BppBigEndian
+
#define WIZ_MAGIC_REMAP_NUMBER 0x76543210
#define WIZRAWPIXEL_R_MASK (_uses16BitColor ? 0x7C00 : 0xFF)
@@ -68,10 +91,26 @@ namespace Scumm {
#define WIZRAWPIXEL_LO_BITS ((WIZRAWPIXEL_LO_R_BIT) | (WIZRAWPIXEL_LO_G_BIT) | (WIZRAWPIXEL_LO_B_BIT))
#define WIZRAWPIXEL_HI_BITS ~WIZRAWPIXEL_LO_BITS
+#define WIZ_COLOR16_COMPONENT_COUNT (1 << 5)
+#define WIZ_QUANTIZED_ALPHA_COUNT 16
+#define WIZ_QUANTIZED_ALPHA_DIV ((256) / (WIZ_QUANTIZED_ALPHA_COUNT))
+
#define WIZRAWPIXEL_50_50_PREMIX_COLOR(__rawColor__) (((__rawColor__) & WIZRAWPIXEL_HI_BITS) >> 1)
#define WIZRAWPIXEL_50_50_MIX(__colorA__, __colorB__) ((__colorA__) + (__colorB__))
+#define WIZRAWPIXEL_ADDITIVE_MIX(__colorA__, __colorB__) \
+ (MIN<int>(WIZRAWPIXEL_R_MASK, (((__colorA__) & WIZRAWPIXEL_R_MASK) + ((__colorB__) & WIZRAWPIXEL_R_MASK))) | \
+ MIN<int>(WIZRAWPIXEL_G_MASK, (((__colorA__) & WIZRAWPIXEL_G_MASK) + ((__colorB__) & WIZRAWPIXEL_G_MASK))) | \
+ MIN<int>(WIZRAWPIXEL_B_MASK, (((__colorA__) & WIZRAWPIXEL_B_MASK) + ((__colorB__) & WIZRAWPIXEL_B_MASK))))
+
+#define WIZRAWPIXEL_SUBTRACTIVE_MIX(__colorA__, __colorB__) \
+ (MAX<int>(WIZRAWPIXEL_LO_R_BIT, (((__colorA__) & WIZRAWPIXEL_R_MASK) - ((__colorB__) & WIZRAWPIXEL_R_MASK))) | \
+ MAX<int>(WIZRAWPIXEL_LO_G_BIT, (((__colorA__) & WIZRAWPIXEL_G_MASK) - ((__colorB__) & WIZRAWPIXEL_G_MASK))) | \
+ MAX<int>(WIZRAWPIXEL_LO_B_BIT, (((__colorA__) & WIZRAWPIXEL_B_MASK) - ((__colorB__) & WIZRAWPIXEL_B_MASK))))
+
typedef uint16 WizRawPixel;
+typedef uint8 WizRawPixel8;
+typedef uint16 WizRawPixel16;
struct WizPolygon {
Common::Point points[5];
@@ -279,6 +318,12 @@ struct WarpWizOneSpanTable {
int spanCount;
};
+struct COMPRESSEDIMAGE {
+ byte *data;
+ int width;
+ int height;
+};
+
enum WizRenderingFlags {
// Standard rendering flags
kWRFUsePalette = 0x00000001,
@@ -370,17 +415,17 @@ enum WizCompressionTypes {
kWCTNone = 0x00000000,
kWCTTRLE = 0x00000001,
kWCTNone16Bpp = 0x00000002,
- kWCTNone32Bpp = 0x00000003,
+ // kWCTNone32Bpp = 0x00000003,
kWCTComposite = 0x00000004,
kWCTTRLE16Bpp = 0x00000005,
- kWCTTRLE32Bpp = 0x00000006,
+ // kWCTTRLE32Bpp = 0x00000006,
kWCTMRLEWithLineSizePrefix = 0x00000007,
kWCTMRLEWithoutLineSizePrefix = 0x00000008,
kWCTDataBlockDependent = 0x00000009,
kWCTNone16BppBigEndian = 0x0000000A,
- kWCTNone32BppBigEndian = 0x0000000B,
+ // kWCTNone32BppBigEndian = 0x0000000B,
kWCTTRLE16BppBigEndian = 0x0000000C,
- kWCTTRLE32BppBigEndian = 0x0000000D
+ // kWCTTRLE32BppBigEndian = 0x0000000D
};
enum CreateWizFlags {
@@ -390,6 +435,14 @@ enum CreateWizFlags {
kCWFDefault = ((kCWFPalette) | (kCWFSpot) | (kCWFRemapTable))
};
+enum WizImgProps {
+ kWIPCompressionType = 0x10000000,
+ kWIPPaletteBlockPresent = 0x10000001,
+ kWIPRemapBlockPresent = 0x10000002,
+ kWIPOpaqueBlockPresent = 0x10000003,
+ kWIPXMAPBlockPresent = 0x10000004
+};
+
enum WizSpcConditionTypes : uint {
kWSPCCTBits = 0xc0000000,
kWSPCCTOr = 0x00000000,
@@ -471,6 +524,7 @@ public:
void dwHandleComplexImageDraw(int image, int state, int x, int y, int shadow, int angle, int scale, const Common::Rect *clipRect, int32 flags, WizSimpleBitmap *optionalBitmapOverride, const WizRawPixel *optionalColorConversionTable);
bool dwIsMaskCompatibleCompressionType(int compressionType);
bool dwIsUncompressedFormatTypeID(int id);
+ int dwGetImageGeneralProperty(int image, int state, int property);
void processWizImageCmd(const WizImageCommand *params);
void processWizImageCaptureCmd(const WizImageCommand *params);
@@ -500,7 +554,10 @@ public:
byte *getWizStateRemapDataPrim(int resNum, int state);
int getWizCompressionType(int resNum, int state);
bool doesRawWizStateHaveTransparency(int globNum, int state);
+ bool doesStateContainBlock(int globNum, int state, uint32 blockID);
const byte *getColorMixBlockPtrForWiz(int image);
+ void setWizCompressionType(int image, int state, int newType);
+
int isWizPixelNonTransparent(int resnum, int state, int x, int y, int flags);
int isWizPixelNonTransparent(uint8 *data, int state, int x, int y, int flags);
@@ -531,6 +588,10 @@ public:
void *drawAWizPrim(int globNum, int state, int x, int y, int z, int shadowImage, int zbufferImage, const Common::Rect *optionalClipRect, int flags, WizSimpleBitmap *optionalBitmapOverride, const WizRawPixel *optionalColorConversionTable);
void *drawAWizPrimEx(int globNum, int state, int x, int y, int z, int shadowImage, int zbufferImage, const Common::Rect *optionalClipRect, int flags, WizSimpleBitmap *optionalBitmapOverride, const WizRawPixel *optionalColorConversionTable, const WizImageCommand *optionalICmdPtr);
void buildAWiz(const WizRawPixel *bufPtr, int bufWidth, int bufHeight, const byte *palettePtr, const Common::Rect *rectPtr, int compressionType, int globNum, int transparentColor);
+ int pixelHitTestWiz(int image, int state, int x, int y, int32 flags);
+ int pixelHitTestWizPrim(int globNum, int state, int x, int y, int32 flags);
+ int hitTestWiz(int image, int state, int x, int y, int32 flags);
+ int hitTestWizPrim(int globNum, int state, int x, int y, int32 flags);
uint8 *drawWizImage(int resNum, int state, int maskNum, int maskState, int x1, int y1, int zorder, int shadow, int zbuffer, const Common::Rect *clipBox, int flags, int dstResNum, const uint8 *palPtr, uint32 conditionBits);
void drawWizImageEx(uint8 *dst, uint8 *src, uint8 *mask, int dstPitch, int dstType, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, int state, const Common::Rect *rect, int flags, const uint8 *palPtr, int transColor, uint8 bitDepth, const uint8 *xmapPtr, uint32 conditionBits);
@@ -573,11 +634,15 @@ public:
void computeRawWizHistogram(uint32 *histogram, const uint8 *data, int srcPitch, const Common::Rect &rCapt);
void remapImage(int image, int state, int tableCount, const uint8 *remapList, const uint8 *remapTable);
+ int createHistogramArrayForImage(int image, int state, const Common::Rect *optionalClipRect);
+
void ensureNativeFormatImageForState(int image, int state);
- private:
+private:
ScummEngine_v71he *_vm;
+
+public:
/* Drawing Primitives
*
* These primitives are slightly different and less precise
@@ -588,7 +653,6 @@ public:
*/
// Primitives
-public:
int pgReadPixel(const WizSimpleBitmap *srcBM, int x, int y, int defaultValue);
void pgWritePixel(WizSimpleBitmap *srcBM, int x, int y, WizRawPixel value);
void pgClippedWritePixel(WizSimpleBitmap *srcBM, int x, int y, const Common::Rect *clipRectPtr, WizRawPixel value);
@@ -598,6 +662,7 @@ public:
void pgDrawSolidRect(WizSimpleBitmap *destBM, const Common::Rect *rectPtr, WizRawPixel color);
void pgFloodFillCmd(int x, int y, int color, const Common::Rect *optionalClipRect);
+ void pgHistogramBitmapSubRect(int *tablePtr, const WizSimpleBitmap *bitmapPtr, const Common::Rect *sourceRect);
void pgSimpleBitmapFromDrawBuffer(WizSimpleBitmap *bitmapPtr, bool background);
void pgDrawRawDataFormatImage(WizRawPixel *bufferPtr, const WizRawPixel *rawData, int bufferWidth, int bufferHeight, int x, int y, int width, int height, Common::Rect *clipRectPtr, int32 wizFlags, const void *extraTable, int transparentColor);
void pgSimpleBlit(WizSimpleBitmap *destBM, Common::Rect *destRect, WizSimpleBitmap *sourceBM, Common::Rect *sourceRect);
@@ -623,6 +688,7 @@ public:
void pgBlit90DegreeRotateTransparent(WizSimpleBitmap *dstBitmap, int x, int y, const WizSimpleBitmap *srcBitmap, const Common::Rect *optionalSrcRect, const Common::Rect *optionalClipRect, bool hFlip, bool vFlip, WizRawPixel transparentColor);
void pgBlit90DegreeRotateCore(WizSimpleBitmap *dstBitmap, int x, int y, const WizSimpleBitmap *srcBitmap, const Common::Rect *optionalSrcRect, const Common::Rect *optionalClipRect, bool hFlip, bool vFlip, const void *userParam, const void *userParam2,
void (*srcTransferFP)(Wiz *wiz, WizRawPixel *dstPtr, int dstStep, const WizRawPixel *srcPtr, int count, const void *userParam, const void *userParam2));
+
// Rectangles
bool findRectOverlap(Common::Rect *destRectPtr, const Common::Rect *sourceRectPtr);
bool isPointInRect(Common::Rect *r, Common::Point *pt);
@@ -636,6 +702,8 @@ public:
void moveRect(Common::Rect *rectPtr, int dx, int dy);
void horzFlipAlignWithRect(Common::Rect *rectToAlign, const Common::Rect *baseRect);
void vertFlipAlignWithRect(Common::Rect *rectToAlign, const Common::Rect *baseRect);
+ void swapRectX(Common::Rect *rectPtr);
+ void swapRectY(Common::Rect *rectPtr);
// Flood fill
void floodInitFloodState(WizFloodState *statePtr, WizSimpleBitmap *bitmapPtr, int colorToWrite, const Common::Rect *optionalClippingRect);
@@ -655,7 +723,6 @@ public:
void rawPixelExtractComponents(WizRawPixel aPixel, int &r, int &g, int &b);
void rawPixelPackComponents(WizRawPixel &aPixel, int r, int g, int b);
-
/*
* Compression Primitives
*/
@@ -722,6 +789,115 @@ public:
void auxHistogramTRLELine(int *tablePtr, const byte *dataStream, int skipAmount, int decompAmount);
void auxHistogramTRLEPrim(int *histogramTablePtr, byte *compData, Common::Rect *sourceRect);
+ // TRLE
+ int _trlePutsize = 0;
+ byte _trleBuf[(128 * 2) * sizeof(WizRawPixel)];
+
+ byte *trle_putdump(byte *dest, int nn);
+ byte *trle_putrun(byte *dest, int nn, int cc, int tcolor);
+ int trle_rle_compression(byte *pdest, const WizRawPixel *psource, int rowsize, WizRawPixel tcolor);
+ int TRLE_CompressImageArea(byte *destBuffer, const WizRawPixel *sourceBuffer, int sourceBufferWidth, int x1, int y1, int x2, int y2, WizRawPixel transparentColor);
+
+ // TRLE FLIP
+ bool s_InitializelphaTable = true;
+ float s_AlphaTable[256];
+ int s_Precomputed16bppTable[WIZ_QUANTIZED_ALPHA_COUNT][WIZ_COLOR16_COMPONENT_COUNT][WIZ_COLOR16_COMPONENT_COUNT];
+
+ void TRLEFLIP_DecompressImage(
+ WizRawPixel *bufferPtr, const byte *compData, int bufferWidth, int bufferHeight,
+ int x, int y, int width, int height, Common::Rect *clipRectPtr,
+ int32 wizFlags, const void *extraTable, const WizRawPixel *conversionTable,
+ const WizImageCommand *optionalICmdPtr);
+
+ void TRLEFLIP_DecompressPrim(
+ WizSimpleBitmap *bitmapPtr, const COMPRESSEDIMAGE *imagePtr, int destX, int destY,
+ const Common::Rect *sourceCoords, const Common::Rect *clipRectPtr, const void *extraPtr,
+ int32 flags, const WizRawPixel *conversionTable,
+ void (*forewordFunctionPtr)(Wiz *wiz,
+ WizRawPixel *destPtr, const byte *dataStream, int skipAmount,
+ int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable),
+ void (*backwardFunctionPtr)(Wiz *wiz,
+ WizRawPixel *destPtr, const byte *dataStream, int skipAmount,
+ int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable));
+
+ void TRLEFLIP_DecompImageHull(
+ WizRawPixel *bufferPtr, int bufferWidth, const Common::Rect *destRect,
+ const byte *compData, const Common::Rect *sourceRect, const void *extraPtr,
+ const WizRawPixel *conversionTable,
+ void (*functionPtr)(Wiz *wiz,
+ WizRawPixel *destPtr, const byte *dataStream, int skipAmount,
+ int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable));
+
+ void TRLEFLIP_AltSource_DecompressImage(
+ WizRawPixel *destBufferPtr, const byte *compData, int destBufferWidth, int destBufferHeight,
+ const void *altBufferPtr, int altWidth, int altHeight, int altBitsPerPixel,
+ int x, int y, int width, int height, Common::Rect *clipRectPtr,
+ int32 wizFlags, const WizRawPixel *conversionTable,
+ WizImageCommand *optionalICmdPtr);
+
+ void TRLEFLIP_AltSource_DecompressPrim(
+ WizRawPixel *destBufferPtr, int destBufferWidth, int destBufferHeight,
+ const void *altBufferPtr, int altBitsPerPixel,
+ const COMPRESSEDIMAGE *imagePtr, int destX, int destY,
+ const Common::Rect *sourceCoords, const Common::Rect *clipRectPtr,
+ int32 flags, const WizRawPixel *conversionTable,
+ void (*forewordFunctionPtr)(Wiz *wiz,
+ WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream,
+ int skipAmount, int decompAmount, const WizRawPixel *conversionTable),
+ void (*backwardFunctionPtr)(Wiz *wiz,
+ WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream,
+ int skipAmount, int decompAmount, const WizRawPixel *conversionTable));
+
+ void TRLEFLIP_AltSource_DecompImageHull(
+ WizRawPixel *bufferPtr, int bufferWidth, const Common::Rect *destRect,
+ const byte *altSourceBuffer, int altBytesPerLine,
+ int altBytesPerPixel, const Common::Rect *altRect,
+ const byte *compData, const Common::Rect *sourceRect,
+ const WizRawPixel *conversionTable,
+ void (*functionPtr)(Wiz *,
+ WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream,
+ int skipAmount, int decompAmount, const WizRawPixel *conversionTable));
+
+ bool TRLEFLIP_AltSource_SpecialCaseDispatch(
+ WizRawPixel *destBufferPtr, const byte *compData, int destBufferWidth, int destBufferHeight,
+ const void *altBufferPtr, int altWidth, int altHeight, int altBitsPerPixel,
+ int x, int y, int width, int height, Common::Rect *clipRectPtr,
+ int32 wizFlags, const WizRawPixel *conversionTable,
+ WizImageCommand *optionalICmdPtr);
+
+ void TRLEFLIP_Rotate90_DecompressImage(
+ WizRawPixel *bufferPtr, const byte *compData, int bufferWidth, int bufferHeight,
+ int x, int y, int width, int height, const Common::Rect *clipRectPtr,
+ int32 wizFlags, const void *extraTable, const WizRawPixel *conversionTable,
+ WizImageCommand *optionalICmdPtr);
+
+ void TRLEFLIP_90_DegreeRotateCore(
+ WizSimpleBitmap *dstBitmap, int x, int y, const COMPRESSEDIMAGE *imagePtr, const Common::Rect *optionalSrcRect,
+ const Common::Rect *optionalClipRect, bool hFlip, bool vFlip, const void *userParam, const WizRawPixel *conversionTable,
+ void (*functionPtr)(Wiz *wiz,
+ WizRawPixel *destPtr, const byte *dataStream, int skipAmount,
+ int decompAmount, const void *userParam, int destStepValue,
+ const WizRawPixel *conversionTable));
+
+ void TRLEFLIP_CheckAlphaSetup();
+ WizRawPixel TRLEFLIP_AlphaMixPrim(WizRawPixel b, WizRawPixel a, int alpha);
+ void TRLEFLIP_50_50_Mix_PixelMemset(WizRawPixel *dstPtr, WizRawPixel mixColor, int size);
+ void TRLEFLIP_50_50_Mix_ForwardPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable);
+ void TRLEFLIP_50_50_Mix_BackwardsPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable);
+ void TRLEFLIP_ADDITIVE_PixelMemset(WizRawPixel *dstPtr, WizRawPixel mixColor, int size);
+ void TRLEFLIP_ADDITIVE_ForwardPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable);
+ void TRLEFLIP_ADDITIVE_BackwardsPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable);
+ void TRLEFLIP_SUBTRACTIVE_PixelMemset(WizRawPixel *dstPtr, WizRawPixel mixColor, int size);
+ void TRLEFLIP_SUBTRACTIVE_ForwardPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable);
+ void TRLEFLIP_SUBTRACTIVE_BackwardsPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable);
+ void TRLEFLIP_RemapDestPixels(WizRawPixel *dstPtr, int size, const byte *lookupTable);
+ void TRLEFLIP_ForwardPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable);
+ void TRLEFLIP_BackwardsPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable);
+ void TRLEFLIP_ForewordLookupPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const byte *lookupTable, const WizRawPixel *conversionTable);
+ void TRLEFLIP_BackwardsLookupPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const byte *lookupTable, const WizRawPixel *conversionTable);
+ void TRLEFLIP_ForewordMixColorsPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const byte *lookupTable);
+ void TRLEFLIP_BackwardsMixColorsPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const byte *lookupTable);
+
/*
* Image Warping on Polygons Primitives
diff --git a/engines/scumm/he/wizwarp_he.cpp b/engines/scumm/he/wizwarp_he.cpp
index 8317c3fad58..f6abd4ce25d 100644
--- a/engines/scumm/he/wizwarp_he.cpp
+++ b/engines/scumm/he/wizwarp_he.cpp
@@ -83,7 +83,7 @@ bool Wiz::WARPWIZ_DrawWizTo4Points(int image, int state, const Common::Point *ds
optionalColorConversionTable = (WizRawPixel *)_vm->getHEPaletteSlot(1);
}
- // Decompress the wiz into a SIMPLEBITMAP... (Always if using a remap table)
+ // Decompress the wiz into a WizSimpleBitmap... (Always if using a remap table)
if ((getWizCompressionType(image, state) != kWCTNone) ||
(optionalColorConversionTable != nullptr) || (flags & (kWRFHFlip | kWRFVFlip | kWRFRemap))) {
@@ -348,10 +348,10 @@ void Wiz::WARPWIZ_FindMinMaxpoints(Common::Point *minPtr, Common::Point *maxPtr,
Common::Point minPt, maxPt, pt;
// Find the limits...
- maxPt.x = INT16_MIN;
- maxPt.y = INT16_MIN;
- minPt.x = INT16_MAX;
- minPt.y = INT16_MAX;
+ maxPt.x = -0x8000;
+ maxPt.y = -0x8000;
+ minPt.x = 0x7FFF;
+ minPt.y = 0x7FFF;
for (int i = 0; i < npoints; i++) {
pt = *points++;
Commit: 50a3ad80abadac2aa6468ac1d003f8b4a8bd8dfc
https://github.com/scummvm/scummvm/commit/50a3ad80abadac2aa6468ac1d003f8b4a8bd8dfc
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Fix Wiz warping
Changed paths:
engines/scumm/he/gfx_primitives_he.cpp
engines/scumm/he/wiz_he.cpp
engines/scumm/he/wiz_he.h
engines/scumm/he/wizwarp_he.cpp
diff --git a/engines/scumm/he/gfx_primitives_he.cpp b/engines/scumm/he/gfx_primitives_he.cpp
index bd08fd4ff21..a7933b5881f 100644
--- a/engines/scumm/he/gfx_primitives_he.cpp
+++ b/engines/scumm/he/gfx_primitives_he.cpp
@@ -1698,9 +1698,9 @@ int Wiz::getRawPixel(int color) {
void Wiz::memset8BppConversion(void *dstPtr, int value, size_t count, const WizRawPixel *conversionTable) {
if (_uses16BitColor) {
- rawPixelMemset(dstPtr, (int)convert8BppToRawPixel((WizRawPixel16)value, conversionTable), count);
+ rawPixelMemset((WizRawPixel16 *)dstPtr, (int)convert8BppToRawPixel((WizRawPixel16)value, conversionTable), count);
} else {
- memset(dstPtr, value, count);
+ memset((WizRawPixel8 *)dstPtr, value, count);
}
}
@@ -1713,7 +1713,7 @@ void Wiz::memcpy8BppConversion(void *dstPtr, const void *srcPtr, size_t count, c
*dstWritePtr++ = convert8BppToRawPixel((WizRawPixel16)(*srcReadPtr++), conversionTable);
}
} else {
- memcpy(dstPtr, srcPtr, count);
+ memcpy((WizRawPixel8 *)dstPtr, (const byte *)srcPtr, count);
}
}
diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp
index a66e5f95ffe..11622125c5c 100644
--- a/engines/scumm/he/wiz_he.cpp
+++ b/engines/scumm/he/wiz_he.cpp
@@ -1239,10 +1239,9 @@ void *Wiz::drawAWizPrimEx(int globNum, int state, int x, int y, int z, int shado
if (shadowImage) {
shadow_p = (byte *)getColorMixBlockPtrForWiz(shadowImage);
- // TODO: I don't think this is needed here?
- //if (shadow_p) {
- // shadow_p += 8;
- //}
+ if (shadow_p) {
+ shadow_p += _vm->_resourceHeaderSize;
+ }
} else {
shadow_p = nullptr;
}
@@ -2496,16 +2495,40 @@ void Wiz::processWizImagePolyCaptureCmd(const WizImageCommand *params) {
pXmapColorTable += _vm->_resourceHeaderSize;
+ WarpWizPoint polypoints[5];
+ for (int i = 0; i < 5; i++) {
+ WarpWizPoint tmp(_polygons[polygon2].points[i]);
+ polypoints[i] = tmp;
+ }
+
+ WarpWizPoint srcWarpPoints[5];
+ for (int i = 0; i < 5; i++) {
+ WarpWizPoint tmp(srcPoints[i]);
+ srcWarpPoints[i] = tmp;
+ }
+
WARPWIZ_NPt2NPtNonClippedWarpFiltered(
- &destBitmap, _polygons[polygon2].points, &srcBitmap, srcPoints,
+ &destBitmap, polypoints, &srcBitmap, srcWarpPoints,
_polygons[polygon1].numPoints, _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR),
pXmapColorTable, bIsHintColor, (WizRawPixel)iHintColor);
} else if (bOneToOneRect) { // if a one to one copy is performed, just copy this bits
memcpy(destBitmap.bufferPtr, srcBitmap.bufferPtr, destBitmap.bitmapHeight * destBitmap.bitmapWidth);
} else { // otherwise do "old" warp
+ WarpWizPoint polypoints[5];
+ for (int i = 0; i < 5; i++) {
+ WarpWizPoint tmp(_polygons[polygon2].points[i]);
+ polypoints[i] = tmp;
+ }
+
+ WarpWizPoint srcWarpPoints[5];
+ for (int i = 0; i < 5; i++) {
+ WarpWizPoint tmp(srcPoints[i]);
+ srcWarpPoints[i] = tmp;
+ }
+
WARPWIZ_NPt2NPtNonClippedWarp(
- &destBitmap, _polygons[polygon2].points, &srcBitmap, srcPoints,
+ &destBitmap, polypoints, &srcBitmap, srcWarpPoints,
_polygons[polygon1].numPoints, _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR));
}
@@ -3397,9 +3420,15 @@ void Wiz::dwHandleComplexImageDraw(int image, int state, int x, int y, int shado
shadowPtr = nullptr;
}
+ WarpWizPoint listOfWarpPoints[4];
+ for (int i = 0; i < 4; i++) {
+ WarpWizPoint tmp(listOfPoints[i]);
+ listOfWarpPoints[i] = tmp;
+ }
+
// Finally call the renderer
WARPWIZ_DrawWizTo4Points(
- image, state, listOfPoints, flags,
+ image, state, listOfWarpPoints, flags,
_vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR),
clipRect, optionalBitmapOverride, optionalColorConversionTable,
shadowPtr);
@@ -4322,7 +4351,7 @@ byte *Wiz::getWizStateRemapDataPrim(int globNum, int state) {
const byte *Wiz::getColorMixBlockPtrForWiz(int image) {
byte *data = _vm->getResourceAddress(rtImage, image);
assert(data);
- return _vm->findResourceData(MKTAG('X', 'M', 'A', 'P'), data);
+ return _vm->findResourceData(MKTAG('X', 'M', 'A', 'P'), data) - _vm->_resourceHeaderSize;
}
void Wiz::setWizCompressionType(int image, int state, int newType) {
diff --git a/engines/scumm/he/wiz_he.h b/engines/scumm/he/wiz_he.h
index ac09640f7bb..f91d5309669 100644
--- a/engines/scumm/he/wiz_he.h
+++ b/engines/scumm/he/wiz_he.h
@@ -293,11 +293,27 @@ struct WizCompressedImage {
int height;
};
+// Our Common::Point has int16 coordinates.
+// This is not enough for polygon warping...
+struct WarpWizPoint {
+ int32 x;
+ int32 y;
+
+ WarpWizPoint(Common::Point pt) {
+ x = pt.x;
+ y = pt.y;
+ }
+
+ WarpWizPoint() {
+ x = y = 0;
+ }
+};
+
struct WarpWizOneSpan {
int dstLeft;
int dstRight;
- Common::Point srcLeft;
- Common::Point srcRight;
+ WarpWizPoint srcLeft;
+ WarpWizPoint srcRight;
};
struct WarpWizOneDrawSpan {
@@ -310,8 +326,8 @@ struct WarpWizOneDrawSpan {
};
struct WarpWizOneSpanTable {
- Common::Point dstMinPt, dstMaxPt;
- Common::Point srcMinPt, srcMaxPt;
+ WarpWizPoint dstMinPt, dstMaxPt;
+ WarpWizPoint srcMinPt, srcMaxPt;
WarpWizOneDrawSpan *drawSpans;
WarpWizOneSpan *spans;
int drawSpanCount;
@@ -904,23 +920,23 @@ public:
*/
bool WARPWIZ_DrawWiz(int image, int state, int polygon, int32 flags, int transparentColor, WizSimpleBitmap *optionalDestBitmap, const WizRawPixel *optionalColorConversionTable, int shadowImage);
- bool WARPWIZ_DrawWizTo4Points(int image, int state, const Common::Point *dstPoints, int32 flags, int transparentColor, const Common::Rect *optionalClipRect, WizSimpleBitmap *optionalDestBitmap, const WizRawPixel *optionalColorConversionTable, byte *colorMixTable);
+ bool WARPWIZ_DrawWizTo4Points(int image, int state, const WarpWizPoint *dstPoints, int32 flags, int transparentColor, const Common::Rect *optionalClipRect, WizSimpleBitmap *optionalDestBitmap, const WizRawPixel *optionalColorConversionTable, byte *colorMixTable);
WarpWizOneSpanTable *WARPWIZ_CreateSpanTable(int spanCount);
void WARPWIZ_DestroySpanTable(WarpWizOneSpanTable *spanTable);
- WarpWizOneSpanTable *WARPWIZ_BuildSpanTable(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const Common::Point *dstPts, const Common::Point *srcPts, int npoints, const Common::Rect *clipRectPtr);
+ WarpWizOneSpanTable *WARPWIZ_BuildSpanTable(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizPoint *dstPts, const WarpWizPoint *srcPts, int npoints, const Common::Rect *clipRectPtr);
void WARPWIZ_ProcessDrawSpansA(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizOneDrawSpan *drawSpans, int count);
void WARPWIZ_ProcessDrawSpansTransparent(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizOneDrawSpan *drawSpans, int count, WizRawPixel transparentColor);
void WARPWIZ_ProcessDrawSpansTransparentFiltered(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizOneDrawSpan *drawSpans, int count, WizRawPixel transparentColor, byte *pXmapColorTable, bool bIsHintColor, WizRawPixel hintColor);
- void WARPWIZ_ProcessDrawSpansMixColors( WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizOneDrawSpan *drawSpans, int count, WizRawPixel transparentColor, byte *tablePtr);
- void WARPWIZ_FillSpanWithLine(WarpWizOneSpanTable *st, const Common::Point *dstA, const Common::Point *dstB, const Common::Point *srcA, const Common::Point *srcB);
+ void WARPWIZ_ProcessDrawSpansMixColors(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizOneDrawSpan *drawSpans, int count, WizRawPixel transparentColor, byte *tablePtr);
+ void WARPWIZ_FillSpanWithLine(WarpWizOneSpanTable *st, const WarpWizPoint *dstA, const WarpWizPoint *dstB, const WarpWizPoint *srcA, const WarpWizPoint *srcB);
void WARPWIZ_ProcessDrawSpans_Sampled(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizOneDrawSpan *drawSpans, int count);
void WARPWIZ_ProcessDrawSpansTransparent_Sampled(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap,const WarpWizOneDrawSpan *drawSpans, int count, WizRawPixel transparentColor);
- bool WARPWIZ_NPt2NPtWarp_CORE(WizSimpleBitmap *dstBitmap, const Common::Point *dstpoints, const WizSimpleBitmap *srcBitmap, const Common::Point *srcpoints, int npoints, int transparentColor, const Common::Rect *optionalClipRect, int32 wizFlags);
- bool WARPWIZ_NPt2NPtNonClippedWarp(WizSimpleBitmap *dstBitmap, const Common::Point *dstpoints, const WizSimpleBitmap *srcBitmap, const Common::Point *srcpoints, int npoints, int transparentColor);
- bool WARPWIZ_NPt2NPtClippedWarp(WizSimpleBitmap *dstBitmap, const Common::Point *dstpoints, const WizSimpleBitmap *srcBitmap, const Common::Point *srcpoints, int npoints, int transparentColor, const Common::Rect *optionalClipRect);
- bool WARPWIZ_NPt2NPtClippedWarpMixColors(WizSimpleBitmap *dstBitmap, const Common::Point *dstpoints, const WizSimpleBitmap *srcBitmap, const Common::Point *srcpoints, int npoints, int transparentColor, const Common::Rect *optionalClipRect, byte *colorMixTable);
- bool WARPWIZ_NPt2NPtNonClippedWarpFiltered(WizSimpleBitmap *dstBitmap, const Common::Point *dstpoints, const WizSimpleBitmap *srcBitmap, const Common::Point *srcpoints, int npoints, int transparentColor, byte *pXmapColorTable, bool bIsHintColor, WizRawPixel hintColor);
- void WARPWIZ_FindMinMaxpoints(Common::Point *minPtr, Common::Point *maxPtr, const Common::Point *points, int npoints);
+ bool WARPWIZ_NPt2NPtWarp_CORE(WizSimpleBitmap *dstBitmap, const WarpWizPoint *dstpoints, const WizSimpleBitmap *srcBitmap, const WarpWizPoint *srcpoints, int npoints, int transparentColor, const Common::Rect *optionalClipRect, int32 wizFlags);
+ bool WARPWIZ_NPt2NPtNonClippedWarp(WizSimpleBitmap *dstBitmap, const WarpWizPoint *dstpoints, const WizSimpleBitmap *srcBitmap, const WarpWizPoint *srcpoints, int npoints, int transparentColor);
+ bool WARPWIZ_NPt2NPtClippedWarp(WizSimpleBitmap *dstBitmap, const WarpWizPoint *dstpoints, const WizSimpleBitmap *srcBitmap, const WarpWizPoint *srcpoints, int npoints, int transparentColor, const Common::Rect *optionalClipRect);
+ bool WARPWIZ_NPt2NPtClippedWarpMixColors(WizSimpleBitmap *dstBitmap, const WarpWizPoint *dstpoints, const WizSimpleBitmap *srcBitmap, const WarpWizPoint *srcpoints, int npoints, int transparentColor, const Common::Rect *optionalClipRect, byte *colorMixTable);
+ bool WARPWIZ_NPt2NPtNonClippedWarpFiltered(WizSimpleBitmap *dstBitmap, const WarpWizPoint *dstpoints, const WizSimpleBitmap *srcBitmap, const WarpWizPoint *srcpoints, int npoints, int transparentColor, byte *pXmapColorTable, bool bIsHintColor, WizRawPixel hintColor);
+ void WARPWIZ_FindMinMaxpoints(WarpWizPoint *minPtr, WarpWizPoint *maxPtr, const WarpWizPoint *points, int npoints);
};
} // End of namespace Scumm
diff --git a/engines/scumm/he/wizwarp_he.cpp b/engines/scumm/he/wizwarp_he.cpp
index f6abd4ce25d..ced2a1f3d27 100644
--- a/engines/scumm/he/wizwarp_he.cpp
+++ b/engines/scumm/he/wizwarp_he.cpp
@@ -65,17 +65,23 @@ bool Wiz::WARPWIZ_DrawWiz(int image, int state, int polygon, int32 flags, int tr
}
// Call the actual warping primitive
+ WarpWizPoint polypoints[5];
+ for (int i = 0; i < 5; i++) {
+ WarpWizPoint tmp(_polygons[polyIndex].points[i]);
+ polypoints[i] = tmp;
+ }
+
return WARPWIZ_DrawWizTo4Points(
- image, state, _polygons[polyIndex].points, flags, transparentColor,
+ image, state, polypoints, flags, transparentColor,
nullptr, optionalDestBitmap, optionalColorConversionTable, xmapColorTable);
}
-bool Wiz::WARPWIZ_DrawWizTo4Points(int image, int state, const Common::Point *dstPoints, int32 flags, int transparentColor, const Common::Rect *optionalClipRect, WizSimpleBitmap *optionalDestBitmap, const WizRawPixel *optionalColorConversionTable, byte *colorMixTable) {
+bool Wiz::WARPWIZ_DrawWizTo4Points(int image, int state, const WarpWizPoint *dstPoints, int32 flags, int transparentColor, const Common::Rect *optionalClipRect, WizSimpleBitmap *optionalDestBitmap, const WizRawPixel *optionalColorConversionTable, byte *colorMixTable) {
WizSimpleBitmap dstBitmap, srcBitmap;
bool rValue, freeBitmapBits;
Common::Rect updateRect;
int x, y;
- Common::Point srcPoints[4];
+ WarpWizPoint srcPoints[4];
byte *ptr;
// Set the optional remap table up to the default if one isn't specified
@@ -101,7 +107,7 @@ bool Wiz::WARPWIZ_DrawWizTo4Points(int image, int state, const Common::Point *ds
error("Image %d missing data", image);
// Map the srcBitmap bits to the wiz data...
- srcBitmap.bufferPtr = (WizRawPixel *)(ptr + 8);
+ srcBitmap.bufferPtr = (WizRawPixel *)(ptr + _vm->_resourceHeaderSize);
freeBitmapBits = false;
}
@@ -123,7 +129,15 @@ bool Wiz::WARPWIZ_DrawWizTo4Points(int image, int state, const Common::Point *ds
error("Missing drawing buffer?");
}
- dstBitmap.bufferPtr += pvs->xstart;
+ if (_uses16BitColor) {
+ WizRawPixel16 *buf16 = (WizRawPixel16 *)dstBitmap.bufferPtr;
+ buf16 += pvs->xstart;
+ dstBitmap.bufferPtr = (WizRawPixel *)buf16;
+ } else {
+ WizRawPixel8 *buf8 = (WizRawPixel8 *)dstBitmap.bufferPtr;
+ buf8 += pvs->xstart;
+ dstBitmap.bufferPtr = (WizRawPixel *)buf8;
+ }
}
// Find the bounding rect and double check the coords.
@@ -192,6 +206,7 @@ bool Wiz::WARPWIZ_DrawWizTo4Points(int image, int state, const Common::Point *ds
// Cleanup!
if (freeBitmapBits) {
free(srcBitmap.bufferPtr);
+ srcBitmap.bufferPtr = nullptr;
}
return rValue;
@@ -245,9 +260,9 @@ void Wiz::WARPWIZ_DestroySpanTable(WarpWizOneSpanTable *spanTable) {
spanTable = nullptr;
}
-WarpWizOneSpanTable *Wiz::WARPWIZ_BuildSpanTable(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const Common::Point *dstPts, const Common::Point *srcPts, int npoints, const Common::Rect *clipRectPtr) {
+WarpWizOneSpanTable *Wiz::WARPWIZ_BuildSpanTable(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizPoint *dstPts, const WarpWizPoint *srcPts, int npoints, const Common::Rect *clipRectPtr) {
int offset, dw, sw, nonClippedWidth, maxOffset, cl, cr, cy, dl, cw;
- Common::Point srcPt, dstPt, dstMinPt, dstMaxPt, srcMinPt, srcMaxPt, clippedPt;
+ WarpWizPoint srcPt, dstPt, dstMinPt, dstMaxPt, srcMinPt, srcMaxPt, clippedPt;
WarpWizOneDrawSpan *drawSpan;
Common::Rect clippingRect;
WarpWizOneSpanTable *st;
@@ -298,7 +313,7 @@ WarpWizOneSpanTable *Wiz::WARPWIZ_BuildSpanTable(WizSimpleBitmap *dstBitmap, con
dw = dstBitmap->bitmapWidth;
sw = srcBitmap->bitmapWidth;
span = st->spans;
- offset = ((int)st->dstMinPt.y) * dw;
+ offset = st->dstMinPt.y * dw;
maxOffset = (dw * (dstBitmap->bitmapHeight - 1));
st->drawSpanCount = 0;
cy = st->dstMinPt.y;
@@ -344,8 +359,8 @@ WarpWizOneSpanTable *Wiz::WARPWIZ_BuildSpanTable(WizSimpleBitmap *dstBitmap, con
return st;
}
-void Wiz::WARPWIZ_FindMinMaxpoints(Common::Point *minPtr, Common::Point *maxPtr, const Common::Point *points, int npoints) {
- Common::Point minPt, maxPt, pt;
+void Wiz::WARPWIZ_FindMinMaxpoints(WarpWizPoint *minPtr, WarpWizPoint *maxPtr, const WarpWizPoint *points, int npoints) {
+ WarpWizPoint minPt, maxPt, pt;
// Find the limits...
maxPt.x = -0x8000;
@@ -379,21 +394,38 @@ void Wiz::WARPWIZ_FindMinMaxpoints(Common::Point *minPtr, Common::Point *maxPtr,
void Wiz::WARPWIZ_ProcessDrawSpansA(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizOneDrawSpan *drawSpans, int count) {
int xStep, yStep, sw, xOffset, yOffset;
- const WizRawPixel *srcPtr;
- WizRawPixel *dstPtr;
+
+ const WizRawPixel8 *src8;
+ const WizRawPixel16 *src16;
+
+ WizRawPixel8 *dst8 = (WizRawPixel8 *)dstBitmap->bufferPtr;
+ WizRawPixel16 *dst16 = (WizRawPixel16 *)dstBitmap->bufferPtr;
sw = srcBitmap->bitmapWidth;
- srcPtr = srcBitmap->bufferPtr;
+
+ src8 = (WizRawPixel8 *)srcBitmap->bufferPtr;
+ src16 = (WizRawPixel16 *)srcBitmap->bufferPtr;
for (int yCounter = count; --yCounter >= 0;) {
- dstPtr = dstBitmap->bufferPtr + drawSpans->dstOffset;
+ if (!_uses16BitColor) {
+ dst8 = (WizRawPixel8 *)dstBitmap->bufferPtr;
+ dst8 += drawSpans->dstOffset;
+ } else {
+ dst16 = (WizRawPixel16 *)dstBitmap->bufferPtr;
+ dst16 += drawSpans->dstOffset;
+ }
+
xOffset = drawSpans->xSrcOffset;
yOffset = drawSpans->ySrcOffset;
xStep = drawSpans->xSrcStep;
yStep = drawSpans->ySrcStep;
for (int xCounter = drawSpans->dstWidth; --xCounter >= 0;) {
- *dstPtr++ = *(srcPtr + (sw * WARP_FROM_FRAC(yOffset)) + WARP_FROM_FRAC(xOffset));
+ if (!_uses16BitColor) {
+ *dst8++ = *(src8 + (sw * WARP_FROM_FRAC(yOffset)) + WARP_FROM_FRAC(xOffset));
+ } else {
+ *dst16++ = *(src16 + (sw * WARP_FROM_FRAC(yOffset)) + WARP_FROM_FRAC(xOffset));
+ }
xOffset += xStep;
yOffset += yStep;
@@ -405,26 +437,46 @@ void Wiz::WARPWIZ_ProcessDrawSpansA(WizSimpleBitmap *dstBitmap, const WizSimpleB
void Wiz::WARPWIZ_ProcessDrawSpansTransparent(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizOneDrawSpan *drawSpans, int count, WizRawPixel transparentColor) {
int xStep, yStep, sw, xOffset, yOffset;
- const WizRawPixel *srcPtr;
+
+ const WizRawPixel8 *src8 = (WizRawPixel8 *)srcBitmap->bufferPtr;
+ const WizRawPixel16 *src16 = (WizRawPixel16 *)srcBitmap->bufferPtr;
+
+ WizRawPixel8 *dst8 = (WizRawPixel8 *)dstBitmap->bufferPtr;
+ WizRawPixel16 *dst16 = (WizRawPixel16 *)dstBitmap->bufferPtr;
+
WizRawPixel srcColor;
- WizRawPixel *dstPtr;
sw = srcBitmap->bitmapWidth;
- srcPtr = srcBitmap->bufferPtr;
for (int yCounter = count; --yCounter >= 0;) {
- dstPtr = dstBitmap->bufferPtr + drawSpans->dstOffset;
+ if (!_uses16BitColor) {
+ dst8 = (WizRawPixel8 *)dstBitmap->bufferPtr;
+ dst8 += drawSpans->dstOffset;
+ } else {
+ dst16 = (WizRawPixel16 *)dstBitmap->bufferPtr;
+ dst16 += drawSpans->dstOffset;
+ }
+
xOffset = drawSpans->xSrcOffset;
yOffset = drawSpans->ySrcOffset;
xStep = drawSpans->xSrcStep;
yStep = drawSpans->ySrcStep;
for (int xCounter = drawSpans->dstWidth; --xCounter >= 0;) {
- srcColor = *(srcPtr + (sw * WARP_FROM_FRAC(yOffset)) + WARP_FROM_FRAC(xOffset));
- if (srcColor != transparentColor) {
- *dstPtr++ = srcColor;
+ if (!_uses16BitColor) {
+ srcColor = *(src8 + (sw * WARP_FROM_FRAC(yOffset)) + WARP_FROM_FRAC(xOffset));
+ if (srcColor != transparentColor) {
+ *dst8++ = (WizRawPixel8)srcColor;
+ } else {
+ dst8++;
+ }
} else {
- dstPtr++;
+ srcColor = *(src16 + (sw * WARP_FROM_FRAC(yOffset)) + WARP_FROM_FRAC(xOffset));
+ if (srcColor != transparentColor) {
+ *dst16++ = (WizRawPixel16)srcColor;
+ } else {
+ dst16++;
+ }
}
xOffset += xStep;
@@ -437,13 +489,18 @@ void Wiz::WARPWIZ_ProcessDrawSpansTransparent(WizSimpleBitmap *dstBitmap, const
void Wiz::WARPWIZ_ProcessDrawSpansTransparentFiltered(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizOneDrawSpan *drawSpans, int count, WizRawPixel transparentColor, byte *pXmapColorTable, bool bIsHintColor, WizRawPixel hintColor) {
int srcWidth = srcBitmap->bitmapWidth;
- const WizRawPixel *srcPtr = srcBitmap->bufferPtr;
+
+ const WizRawPixel8 *src8 = (WizRawPixel8 *)srcBitmap->bufferPtr;
+ const WizRawPixel16 *src16 = (WizRawPixel16 *)srcBitmap->bufferPtr;
+
bool bSkipFilter = false;
int xStep, yStep, xOffset, yOffset;
WizRawPixel srcColor, srcColorN, srcColorS, srcColorE, srcColorW;
int iCurrentX, iCurrentY, iXScan, iYScan;
- WizRawPixel *dstPtr;
+
+ WizRawPixel8 *dst8 = (WizRawPixel8 *)dstBitmap->bufferPtr;
+ WizRawPixel16 *dst16 = (WizRawPixel16 *)dstBitmap->bufferPtr;
// set up a rect for clipping if needed
Common::Rect aSrcRect; // the source rectangle for clipping
@@ -455,19 +512,30 @@ void Wiz::WARPWIZ_ProcessDrawSpansTransparentFiltered(WizSimpleBitmap *dstBitmap
iYScan = aSrcRect.bottom / count;
for (int yCounter = count; --yCounter >= 0;) {
- dstPtr = dstBitmap->bufferPtr + drawSpans->dstOffset;
+ if (!_uses16BitColor) {
+ dst8 = (WizRawPixel8 *)dstBitmap->bufferPtr;
+ dst8 += drawSpans->dstOffset;
+ } else {
+ dst16 = (WizRawPixel16 *)dstBitmap->bufferPtr;
+ dst16 += drawSpans->dstOffset;
+ }
+
xOffset = drawSpans->xSrcOffset;
yOffset = drawSpans->ySrcOffset;
xStep = drawSpans->xSrcStep;
yStep = drawSpans->ySrcStep;
- iXScan = WARP_FROM_FRAC(xStep); // the width of the seach should be the x step size
+ iXScan = WARP_FROM_FRAC(xStep); // the width of the search should be the x step size
for (int xCounter = drawSpans->dstWidth; --xCounter >= 0;) {
iCurrentX = WARP_FROM_FRAC(xOffset);
iCurrentY = WARP_FROM_FRAC(yOffset);
// get the current color and the surrounding colors
- srcColor = *(srcPtr + (srcWidth * iCurrentY) + iCurrentX);
+ if (!_uses16BitColor) {
+ srcColor = *(src8 + (srcWidth * iCurrentY) + iCurrentX);
+ } else {
+ srcColor = *(src16 + (srcWidth * iCurrentY) + iCurrentX);
+ }
bSkipFilter = false;
if (bIsHintColor) {
@@ -481,10 +549,18 @@ void Wiz::WARPWIZ_ProcessDrawSpansTransparentFiltered(WizSimpleBitmap *dstBitmap
// scan through rect looking for hint color
for (int yScan = aScanRect.top; yScan < aScanRect.bottom; ++yScan) {
for (int xScan = aScanRect.left; xScan < aScanRect.right; ++xScan) {
- if ((*(srcPtr + (yScan * srcWidth) + xScan)) == hintColor) {
- srcColor = hintColor;
- bSkipFilter = true;
- break;
+ if (!_uses16BitColor) {
+ if ((*(src8 + (yScan * srcWidth) + xScan)) == hintColor) {
+ srcColor = hintColor;
+ bSkipFilter = true;
+ break;
+ }
+ } else {
+ if ((*(src16 + (yScan * srcWidth) + xScan)) == hintColor) {
+ srcColor = hintColor;
+ bSkipFilter = true;
+ break;
+ }
}
}
@@ -497,28 +573,44 @@ void Wiz::WARPWIZ_ProcessDrawSpansTransparentFiltered(WizSimpleBitmap *dstBitmap
if ((srcColor != transparentColor) && !bSkipFilter) {
// check if top
if (iCurrentY != 0) {
- srcColorN = *(srcPtr + (srcWidth * (iCurrentY - 1)) + iCurrentX);
+ if (!_uses16BitColor) {
+ srcColorN = *(src8 + (srcWidth * (iCurrentY - 1)) + iCurrentX);
+ } else {
+ srcColorN = *(src16 + (srcWidth * (iCurrentY - 1)) + iCurrentX);
+ }
} else {
srcColorN = transparentColor;
}
// check if bottom
if (iCurrentY != aSrcRect.bottom) {
- srcColorS = *(srcPtr + (srcWidth * (iCurrentY + 1)) + iCurrentX);
+ if (!_uses16BitColor) {
+ srcColorS = *(src8 + (srcWidth * (iCurrentY + 1)) + iCurrentX);
+ } else {
+ srcColorS = *(src16 + (srcWidth * (iCurrentY + 1)) + iCurrentX);
+ }
} else {
srcColorS = transparentColor;
}
// check for left edge
if (iCurrentX != 0) {
- srcColorW = *(srcPtr + (srcWidth * iCurrentY) + (iCurrentX - 1));
+ if (!_uses16BitColor) {
+ srcColorW = *(src8 + (srcWidth * iCurrentY) + (iCurrentX - 1));
+ } else {
+ srcColorW = *(src16 + (srcWidth * iCurrentY) + (iCurrentX - 1));
+ }
} else {
srcColorW = transparentColor;
}
// check for right edge
if (iCurrentX != aSrcRect.right) {
- srcColorE = *(srcPtr + (srcWidth * iCurrentY) + (iCurrentX + 1));
+ if (!_uses16BitColor) {
+ srcColorE = *(src8 + (srcWidth * iCurrentY) + (iCurrentX + 1));
+ } else {
+ srcColorE = *(src16 + (srcWidth * iCurrentY) + (iCurrentX + 1));
+ }
} else {
srcColorE = transparentColor;
}
@@ -596,9 +688,17 @@ void Wiz::WARPWIZ_ProcessDrawSpansTransparentFiltered(WizSimpleBitmap *dstBitmap
}
if (srcColor != transparentColor) {
- *dstPtr++ = srcColor;
+ if (!_uses16BitColor) {
+ *dst8++ = srcColor;
+ } else {
+ *dst16++ = srcColor;
+ }
} else {
- dstPtr++;
+ if (!_uses16BitColor) {
+ dst8++;
+ } else {
+ dst16++;
+ }
}
xOffset += xStep;
@@ -612,15 +712,24 @@ void Wiz::WARPWIZ_ProcessDrawSpansTransparentFiltered(WizSimpleBitmap *dstBitmap
void Wiz::WARPWIZ_ProcessDrawSpansMixColors(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizOneDrawSpan *drawSpans, int count, WizRawPixel transparentColor, byte *tablePtr) {
int xStep, yStep, sw, xOffset, yOffset;
WizRawPixel srcColor;
- const WizRawPixel *srcPtr;
- WizRawPixel *dstPtr;
+
+ const WizRawPixel8 *src8 = (WizRawPixel8 *)srcBitmap->bufferPtr;
+ const WizRawPixel16 *src16 = (WizRawPixel16 *)srcBitmap->bufferPtr;
+
+ WizRawPixel8 *dst8 = (WizRawPixel8 *)dstBitmap->bufferPtr;
+ WizRawPixel16 *dst16 = (WizRawPixel16 *)dstBitmap->bufferPtr;
sw = srcBitmap->bitmapWidth;
- srcPtr = srcBitmap->bufferPtr;
for (int yCounter = count; --yCounter >= 0;) {
+ if (!_uses16BitColor) {
+ dst8 = (WizRawPixel8 *)dstBitmap->bufferPtr;
+ dst8 += drawSpans->dstOffset;
+ } else {
+ dst16 = (WizRawPixel16 *)dstBitmap->bufferPtr;
+ dst16 += drawSpans->dstOffset;
+ }
- dstPtr = dstBitmap->bufferPtr + drawSpans->dstOffset;
xOffset = drawSpans->xSrcOffset;
yOffset = drawSpans->ySrcOffset;
xStep = drawSpans->xSrcStep;
@@ -628,16 +737,16 @@ void Wiz::WARPWIZ_ProcessDrawSpansMixColors(WizSimpleBitmap *dstBitmap, const Wi
for (int xCounter = drawSpans->dstWidth; --xCounter >= 0;) {
if (!_uses16BitColor) {
- srcColor = (*(srcPtr + (sw * WARP_FROM_FRAC(yOffset)) + WARP_FROM_FRAC(xOffset)));
+ srcColor = (*(src8 + (sw * WARP_FROM_FRAC(yOffset)) + WARP_FROM_FRAC(xOffset)));
if (srcColor != transparentColor) {
- *dstPtr++ = *(tablePtr + (srcColor * 256) + (*dstPtr));
+ *dst8++ = *(tablePtr + (srcColor * 256) + (*dst8));
} else {
- dstPtr++;
+ dst8++;
}
} else {
- srcColor = *(srcPtr + (sw * WARP_FROM_FRAC(yOffset)) + WARP_FROM_FRAC(xOffset));
+ srcColor = *(src16 + (sw * WARP_FROM_FRAC(yOffset)) + WARP_FROM_FRAC(xOffset));
- *dstPtr++ = WIZRAWPIXEL_50_50_MIX(WIZRAWPIXEL_50_50_PREMIX_COLOR(srcColor), WIZRAWPIXEL_50_50_PREMIX_COLOR(*dstPtr));
+ *dst16++ = WIZRAWPIXEL_50_50_MIX(WIZRAWPIXEL_50_50_PREMIX_COLOR(srcColor), WIZRAWPIXEL_50_50_PREMIX_COLOR(*dst16));
}
xOffset += xStep;
@@ -648,8 +757,8 @@ void Wiz::WARPWIZ_ProcessDrawSpansMixColors(WizSimpleBitmap *dstBitmap, const Wi
}
}
-void Wiz::WARPWIZ_FillSpanWithLine(WarpWizOneSpanTable *st, const Common::Point *dstA, const Common::Point *dstB, const Common::Point *srcA, const Common::Point *srcB) {
- Common::Point dstStep, srcStep, dstPt, srcPt, dpt, spt;
+void Wiz::WARPWIZ_FillSpanWithLine(WarpWizOneSpanTable *st, const WarpWizPoint *dstA, const WarpWizPoint *dstB, const WarpWizPoint *srcA, const WarpWizPoint *srcB) {
+ WarpWizPoint dstStep, srcStep, dstPt, srcPt, dpt, spt;
int h, lx1, ly1, lx2, ly2;
WarpWizOneSpan *spanPtr;
@@ -707,7 +816,10 @@ void Wiz::WARPWIZ_FillSpanWithLine(WarpWizOneSpanTable *st, const Common::Point
void Wiz::WARPWIZ_ProcessDrawSpans_Sampled(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizOneDrawSpan *drawSpans, int count) {
// Setup read pointer and clipping limits for the sampling rect
- const WizRawPixel *srcPtr = srcBitmap->bufferPtr;
+ const WizRawPixel8 *src8 = (WizRawPixel8 *)srcBitmap->bufferPtr;
+ const WizRawPixel16 *src16 = (WizRawPixel16 *)srcBitmap->bufferPtr;
+ WizRawPixel8 *dst8 = (WizRawPixel8 *)dstBitmap->bufferPtr;
+ WizRawPixel16 *dst16 = (WizRawPixel16 *)dstBitmap->bufferPtr;
int sw = srcBitmap->bitmapWidth;
int src_x_limit = (srcBitmap->bitmapWidth - 1);
@@ -715,7 +827,13 @@ void Wiz::WARPWIZ_ProcessDrawSpans_Sampled(WizSimpleBitmap *dstBitmap, const Wiz
// Process all of the spans in this span collection.
for (int yCounter = count; --yCounter >= 0;) {
- WizRawPixel *dstPtr = dstBitmap->bufferPtr + drawSpans->dstOffset;
+ if (!_uses16BitColor) {
+ dst8 = (WizRawPixel8 *)dstBitmap->bufferPtr;
+ dst8 += drawSpans->dstOffset;
+ } else {
+ dst16 = (WizRawPixel16 *)dstBitmap->bufferPtr;
+ dst16 += drawSpans->dstOffset;
+ }
int xOffset = drawSpans->xSrcOffset;
int yOffset = drawSpans->ySrcOffset;
@@ -747,7 +865,7 @@ void Wiz::WARPWIZ_ProcessDrawSpans_Sampled(WizSimpleBitmap *dstBitmap, const Wiz
// Process all pixels covered by this "span"
for (int xCounter = drawSpans->dstWidth; --xCounter >= 0;) {
if (!_uses16BitColor) {
- *dstPtr++ = (*(srcPtr + (sw * WARP_FROM_FRAC(yOffset)) + WARP_FROM_FRAC(xOffset)));
+ *dst8++ = (*(src8 + (sw * WARP_FROM_FRAC(yOffset)) + WARP_FROM_FRAC(xOffset)));
} else {
// Do a really lame sampling of the potential source pixels
int sx = WARP_FROM_FRAC(xOffset);
@@ -773,7 +891,7 @@ void Wiz::WARPWIZ_ProcessDrawSpans_Sampled(WizSimpleBitmap *dstBitmap, const Wiz
// Sample pixels from the source potential sampling area
if (total > 1) {
int total_R, total_G, total_B;
- const WizRawPixel *samplePtr = (srcPtr + ((sw * sy1) + sx1));
+ const WizRawPixel *samplePtr = (const WizRawPixel *)(src16 + ((sw * sy1) + sx1));
rawPixelExtractComponents(*samplePtr, total_R, total_G, total_B);
@@ -795,10 +913,9 @@ void Wiz::WARPWIZ_ProcessDrawSpans_Sampled(WizSimpleBitmap *dstBitmap, const Wiz
samplePtr += sampleStep;
}
- rawPixelPackComponents(*dstPtr, total_R / total, total_G / total, total_B / total);
-
+ rawPixelPackComponents(*dst16, total_R / total, total_G / total, total_B / total);
} else {
- *dstPtr = (*(srcPtr + (sw * sy1) + sx1));
+ *dst16 = (*(src16 + (sw * sy1) + sx1));
}
}
@@ -812,7 +929,10 @@ void Wiz::WARPWIZ_ProcessDrawSpans_Sampled(WizSimpleBitmap *dstBitmap, const Wiz
void Wiz::WARPWIZ_ProcessDrawSpansTransparent_Sampled(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizOneDrawSpan *drawSpans, int count, WizRawPixel transparentColor) {
// Setup read pointer and clipping limits for the sampling rect
- const WizRawPixel *srcPtr = srcBitmap->bufferPtr;
+ const WizRawPixel8 *src8 = (WizRawPixel8 *)srcBitmap->bufferPtr;
+ const WizRawPixel16 *src16 = (WizRawPixel16 *)srcBitmap->bufferPtr;
+ WizRawPixel8 *dst8 = (WizRawPixel8 *)dstBitmap->bufferPtr;
+ WizRawPixel16 *dst16 = (WizRawPixel16 *)dstBitmap->bufferPtr;
int sw = srcBitmap->bitmapWidth;
int src_x_limit = (srcBitmap->bitmapWidth - 1);
@@ -820,8 +940,13 @@ void Wiz::WARPWIZ_ProcessDrawSpansTransparent_Sampled(WizSimpleBitmap *dstBitmap
// Process all of the spans in this span collection.
for (int yCounter = count; --yCounter >= 0;) {
-
- WizRawPixel *dstPtr = dstBitmap->bufferPtr + drawSpans->dstOffset;
+ if (!_uses16BitColor) {
+ dst8 = (WizRawPixel8 *)dstBitmap->bufferPtr;
+ dst8 += drawSpans->dstOffset;
+ } else {
+ dst16 = (WizRawPixel16 *)dstBitmap->bufferPtr;
+ dst16 += drawSpans->dstOffset;
+ }
int xOffset = drawSpans->xSrcOffset;
int yOffset = drawSpans->ySrcOffset;
@@ -853,12 +978,12 @@ void Wiz::WARPWIZ_ProcessDrawSpansTransparent_Sampled(WizSimpleBitmap *dstBitmap
// Process all pixels covered by this "span"
for (int xCounter = drawSpans->dstWidth; --xCounter >= 0;) {
if (!_uses16BitColor) {
- WizRawPixel src_color = (*(srcPtr + (sw * WARP_FROM_FRAC(yOffset)) + WARP_FROM_FRAC(xOffset)));
+ WizRawPixel src_color = (*(src8 + (sw * WARP_FROM_FRAC(yOffset)) + WARP_FROM_FRAC(xOffset)));
if (src_color != transparentColor) {
- *dstPtr++ = src_color;
+ *dst8++ = src_color;
} else {
- dstPtr++;
+ dst8++;
}
} else {
@@ -889,9 +1014,9 @@ void Wiz::WARPWIZ_ProcessDrawSpansTransparent_Sampled(WizSimpleBitmap *dstBitmap
if (total > 1) {
int total_R, total_G, total_B;
- const WizRawPixel *samplePtr = (srcPtr + ((sw * sy1) + sx1));
+ const WizRawPixel *samplePtr = (const WizRawPixel *)(src16 + ((sw * sy1) + sx1));
- WizRawPixel first_color = (*(srcPtr + (sw * sy1) + sx1));
+ WizRawPixel first_color = (*(src16 + (sw * sy1) + sx1));
if (first_color != transparentColor) {
rawPixelExtractComponents(*samplePtr, total_R, total_G, total_B);
@@ -931,21 +1056,21 @@ void Wiz::WARPWIZ_ProcessDrawSpansTransparent_Sampled(WizSimpleBitmap *dstBitmap
rawPixelPackComponents(src_color, total_R / total, total_G / total, total_B / total);
if (transparentColor != src_color) {
- *dstPtr = src_color;
+ *dst16 = src_color;
} else {
- *dstPtr = 4;
+ *dst16 = 4;
}
}
} else {
- WizRawPixel src_color = (*(srcPtr + (sw * sy1) + sx1));
+ WizRawPixel src_color = (*(src16 + (sw * sy1) + sx1));
if (src_color != transparentColor) {
- *dstPtr = src_color;
+ *dst16 = src_color;
}
}
- dstPtr++;
+ dst16++;
}
xOffset += xStep;
@@ -956,7 +1081,7 @@ void Wiz::WARPWIZ_ProcessDrawSpansTransparent_Sampled(WizSimpleBitmap *dstBitmap
}
}
-bool Wiz::WARPWIZ_NPt2NPtWarp_CORE(WizSimpleBitmap *dstBitmap, const Common::Point *dstpoints, const WizSimpleBitmap *srcBitmap, const Common::Point *srcpoints, int npoints, int transparentColor, const Common::Rect *optionalClipRect, int32 wizFlags) {
+bool Wiz::WARPWIZ_NPt2NPtWarp_CORE(WizSimpleBitmap *dstBitmap, const WarpWizPoint *dstpoints, const WizSimpleBitmap *srcBitmap, const WarpWizPoint *srcpoints, int npoints, int transparentColor, const Common::Rect *optionalClipRect, int32 wizFlags) {
WarpWizOneSpanTable *st;
if ((srcBitmap->bitmapWidth >= WARP_TEXTURE_LIMIT) || (srcBitmap->bitmapHeight >= WARP_TEXTURE_LIMIT)) {
@@ -998,7 +1123,7 @@ bool Wiz::WARPWIZ_NPt2NPtWarp_CORE(WizSimpleBitmap *dstBitmap, const Common::Poi
return false;
}
-bool Wiz::WARPWIZ_NPt2NPtNonClippedWarp(WizSimpleBitmap *dstBitmap, const Common::Point *dstpoints, const WizSimpleBitmap *srcBitmap, const Common::Point *srcpoints, int npoints, int transparentColor) {
+bool Wiz::WARPWIZ_NPt2NPtNonClippedWarp(WizSimpleBitmap *dstBitmap, const WarpWizPoint *dstpoints, const WizSimpleBitmap *srcBitmap, const WarpWizPoint *srcpoints, int npoints, int transparentColor) {
if (_vm->_game.heversion > 99) {
return WARPWIZ_NPt2NPtWarp_CORE(
dstBitmap, dstpoints, srcBitmap, srcpoints,
@@ -1035,7 +1160,7 @@ bool Wiz::WARPWIZ_NPt2NPtNonClippedWarp(WizSimpleBitmap *dstBitmap, const Common
}
}
-bool Wiz::WARPWIZ_NPt2NPtClippedWarp(WizSimpleBitmap *dstBitmap, const Common::Point *dstpoints, const WizSimpleBitmap *srcBitmap, const Common::Point *srcpoints, int npoints, int transparentColor, const Common::Rect *optionalClipRect) {
+bool Wiz::WARPWIZ_NPt2NPtClippedWarp(WizSimpleBitmap *dstBitmap, const WarpWizPoint *dstpoints, const WizSimpleBitmap *srcBitmap, const WarpWizPoint *srcpoints, int npoints, int transparentColor, const Common::Rect *optionalClipRect) {
if (_vm->_game.heversion > 99) {
return WARPWIZ_NPt2NPtWarp_CORE(
dstBitmap, dstpoints, srcBitmap, srcpoints,
@@ -1071,7 +1196,7 @@ bool Wiz::WARPWIZ_NPt2NPtClippedWarp(WizSimpleBitmap *dstBitmap, const Common::P
}
}
-bool Wiz::WARPWIZ_NPt2NPtClippedWarpMixColors(WizSimpleBitmap *dstBitmap, const Common::Point *dstpoints, const WizSimpleBitmap *srcBitmap, const Common::Point *srcpoints, int npoints, int transparentColor, const Common::Rect *optionalClipRect, byte *colorMixTable) {
+bool Wiz::WARPWIZ_NPt2NPtClippedWarpMixColors(WizSimpleBitmap *dstBitmap, const WarpWizPoint *dstpoints, const WizSimpleBitmap *srcBitmap, const WarpWizPoint *srcpoints, int npoints, int transparentColor, const Common::Rect *optionalClipRect, byte *colorMixTable) {
WarpWizOneSpanTable *st;
if ((srcBitmap->bitmapWidth >= WARP_TEXTURE_LIMIT) || (srcBitmap->bitmapHeight >= WARP_TEXTURE_LIMIT)) {
@@ -1098,7 +1223,7 @@ bool Wiz::WARPWIZ_NPt2NPtClippedWarpMixColors(WizSimpleBitmap *dstBitmap, const
}
}
-bool Wiz::WARPWIZ_NPt2NPtNonClippedWarpFiltered(WizSimpleBitmap *dstBitmap, const Common::Point *dstpoints, const WizSimpleBitmap *srcBitmap, const Common::Point *srcpoints, int npoints, int transparentColor, byte *pXmapColorTable, bool bIsHintColor, WizRawPixel hintColor) {
+bool Wiz::WARPWIZ_NPt2NPtNonClippedWarpFiltered(WizSimpleBitmap *dstBitmap, const WarpWizPoint *dstpoints, const WizSimpleBitmap *srcBitmap, const WarpWizPoint *srcpoints, int npoints, int transparentColor, byte *pXmapColorTable, bool bIsHintColor, WizRawPixel hintColor) {
WarpWizOneSpanTable *st;
if ((srcBitmap->bitmapWidth >= WARP_TEXTURE_LIMIT) || (srcBitmap->bitmapHeight >= WARP_TEXTURE_LIMIT)) {
Commit: 0da69cc86685a133259067ef64e788226695aa36
https://github.com/scummvm/scummvm/commit/0da69cc86685a133259067ef64e788226695aa36
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Actually fix Wiz warping
Changed paths:
engines/scumm/he/wizwarp_he.cpp
diff --git a/engines/scumm/he/wizwarp_he.cpp b/engines/scumm/he/wizwarp_he.cpp
index ced2a1f3d27..e4a939a119e 100644
--- a/engines/scumm/he/wizwarp_he.cpp
+++ b/engines/scumm/he/wizwarp_he.cpp
@@ -177,7 +177,7 @@ bool Wiz::WARPWIZ_DrawWizTo4Points(int image, int state, const WarpWizPoint *dst
&dstBitmap, dstPoints, &srcBitmap, srcPoints, 4, transparentColor,
optionalClipRect, colorMixTable);
} else {
- if (_vm->_game.heversion > 99) {
+ if (_vm->_game.heversion >= 99) { // TODO: Recheck!! Code valid for executables from 3/14/2000 onwards
rValue = WARPWIZ_NPt2NPtWarp_CORE(
&dstBitmap, dstPoints, &srcBitmap, srcPoints,
4, transparentColor, optionalClipRect, flags);
@@ -231,8 +231,8 @@ WarpWizOneSpanTable *Wiz::WARPWIZ_CreateSpanTable(int spanCount) {
spanPtr = spanTable->spans;
for (counter = 0; counter < spanCount; counter++) {
- spanPtr->dstLeft = INT_MAX;
- spanPtr->dstRight = INT_MIN;
+ spanPtr->dstLeft = 0x7FFFFFFF;
+ spanPtr->dstRight = (-0x7FFFFFFF - 1);
spanPtr++;
}
@@ -330,7 +330,7 @@ WarpWizOneSpanTable *Wiz::WARPWIZ_BuildSpanTable(WizSimpleBitmap *dstBitmap, con
// Clip horizontal
cl = MAX<int>(clippingRect.left, span->dstLeft);
- cr = MAX<int>(clippingRect.right, span->dstRight);
+ cr = MIN<int>(clippingRect.right, span->dstRight);
if ((cw = (cr - cl + 1)) <= 0) {
continue;
@@ -363,10 +363,10 @@ void Wiz::WARPWIZ_FindMinMaxpoints(WarpWizPoint *minPtr, WarpWizPoint *maxPtr, c
WarpWizPoint minPt, maxPt, pt;
// Find the limits...
- maxPt.x = -0x8000;
- maxPt.y = -0x8000;
- minPt.x = 0x7FFF;
- minPt.y = 0x7FFF;
+ maxPt.x = (-0x7FFFFFFF - 1);
+ maxPt.y = (-0x7FFFFFFF - 1);
+ minPt.x = 0x7FFFFFFF;
+ minPt.y = 0x7FFFFFFF;
for (int i = 0; i < npoints; i++) {
pt = *points++;
Commit: b4c4f58c4056d6d0937869a48e2a627ca6a8d4f5
https://github.com/scummvm/scummvm/commit/b4c4f58c4056d6d0937869a48e2a627ca6a8d4f5
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Fix TRLE FLIP comp
Changed paths:
engines/scumm/he/gfx_comp/trle_comp.cpp
diff --git a/engines/scumm/he/gfx_comp/trle_comp.cpp b/engines/scumm/he/gfx_comp/trle_comp.cpp
index 42c7135b859..5984057e7cc 100644
--- a/engines/scumm/he/gfx_comp/trle_comp.cpp
+++ b/engines/scumm/he/gfx_comp/trle_comp.cpp
@@ -1382,13 +1382,13 @@ void Wiz::TRLEFLIP_Rotate90_DecompressImage(
wizFlags |= kWRFRemap;
}
} else {
- if (kWRFRemap & wizFlags) {
+ if (_vm->_game.heversion < 100 || wizFlags & kWRFRemap) {
extraTable = nullptr;
wizFlags &= ~(kWRFUseShadow | kWRFRemap);
}
}
- if (_uses16BitColor) {
+ if (_vm->_game.heversion > 99 && _uses16BitColor) {
// Check for new "special" rendering modes
if (wizFlags & kWRFSpecialRenderBitMask) {
if (wizFlags & kWRFAdditiveBlend) {
Commit: b19c4b772d660833579101e6cec1380cbcaf6cea
https://github.com/scummvm/scummvm/commit/b19c4b772d660833579101e6cec1380cbcaf6cea
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Overhaul more of the GFX system
* Overhaul sprites system
* Fix compression routines for 8-bit graphics
* More fixes and clean-up
Changed paths:
engines/scumm/actor.cpp
engines/scumm/akos.cpp
engines/scumm/charset.cpp
engines/scumm/gfx.cpp
engines/scumm/he/gfx_comp/aux_comp.cpp
engines/scumm/he/gfx_comp/mrle_comp.cpp
engines/scumm/he/gfx_comp/trle_comp.cpp
engines/scumm/he/intern_he.h
engines/scumm/he/moonbase/moonbase_fow.cpp
engines/scumm/he/polygon_he.cpp
engines/scumm/he/script_v100he.cpp
engines/scumm/he/script_v71he.cpp
engines/scumm/he/script_v72he.cpp
engines/scumm/he/script_v90he.cpp
engines/scumm/he/sprite_he.cpp
engines/scumm/he/sprite_he.h
engines/scumm/he/wiz_he.cpp
engines/scumm/he/wiz_he.h
engines/scumm/saveload.cpp
engines/scumm/scumm.cpp
engines/scumm/vars.cpp
diff --git a/engines/scumm/actor.cpp b/engines/scumm/actor.cpp
index 10fa15667ab..bb7887b7fcc 100644
--- a/engines/scumm/actor.cpp
+++ b/engines/scumm/actor.cpp
@@ -3561,7 +3561,7 @@ void ScummEngine_v71he::heFlushAuxQueues() {
uint8 *dst2 = pvs->getBackPixels(0, pvs->topline);
switch (comp) {
case 1:
- Wiz::copyAuxImage(dst1, dst2, axfd + 10, pvs->pitch, pvs->h, x, y, w, h, _bytesPerPixel);
+ // TODO: Wiz::copyAuxImage(dst1, dst2, axfd + 10, pvs->pitch, pvs->h, x, y, w, h, _bytesPerPixel);
break;
default:
error("unimplemented compression type %d", comp);
@@ -3586,7 +3586,6 @@ void ScummEngine_v71he::heFlushAuxQueues() {
a->_auxBlock.r.top = (int16)READ_LE_UINT16(axer + 2) + dy;
a->_auxBlock.r.right = (int16)READ_LE_UINT16(axer + 4) + dx;
a->_auxBlock.r.bottom = (int16)READ_LE_UINT16(axer + 6) + dy;
- adjustRect(a->_auxBlock.r);
}
}
}
diff --git a/engines/scumm/akos.cpp b/engines/scumm/akos.cpp
index 7f96be622d3..be4829bcc07 100644
--- a/engines/scumm/akos.cpp
+++ b/engines/scumm/akos.cpp
@@ -1155,6 +1155,7 @@ byte AkosRenderer::paintCelMajMin(int xMoveCur, int yMoveCur) {
byte AkosRenderer::paintCelTRLE(int xMoveCur, int yMoveCur) {
#ifdef ENABLE_HE
+ /*
Common::Rect src, dst;
if (!_mirror) {
@@ -1227,6 +1228,9 @@ byte AkosRenderer::paintCelTRLE(int xMoveCur, int yMoveCur) {
Wiz::decompressWizImage<kWizCopy>(dstPtr, _out.pitch, kDstScreen, _srcPtr, src, 0, NULL, NULL, _vm->_bytesPerPixel);
}
}
+ */
+
+
#endif
return 0;
}
diff --git a/engines/scumm/charset.cpp b/engines/scumm/charset.cpp
index 6274ab2c14b..73ca577e556 100644
--- a/engines/scumm/charset.cpp
+++ b/engines/scumm/charset.cpp
@@ -1219,9 +1219,9 @@ void CharsetRendererClassic::printCharIntern(bool is2byte, const byte *charPtr,
byte imagePalette[256];
memset(imagePalette, 0, sizeof(imagePalette));
memcpy(imagePalette, _vm->_charsetColorMap, 4);
- Wiz::copyWizImage(dstPtr, charPtr, vs->pitch, kDstScreen, vs->w, vs->h, _left, _top, origWidth, origHeight, &rScreen, 0, imagePalette, NULL, _vm->_bytesPerPixel);
+ // TODO: Wiz::copyWizImage(dstPtr, charPtr, vs->pitch, kDstScreen, vs->w, vs->h, _left, _top, origWidth, origHeight, &rScreen, 0, imagePalette, NULL, _vm->_bytesPerPixel);
} else {
- Wiz::copyWizImage(dstPtr, charPtr, vs->pitch, kDstScreen, vs->w, vs->h, _left, _top, origWidth, origHeight, &rScreen, 0, NULL, NULL, _vm->_bytesPerPixel);
+ // TODO: Wiz::copyWizImage(dstPtr, charPtr, vs->pitch, kDstScreen, vs->w, vs->h, _left, _top, origWidth, origHeight, &rScreen, 0, NULL, NULL, _vm->_bytesPerPixel);
}
if (_blitAlso && vs->hasTwoBuffers) {
diff --git a/engines/scumm/gfx.cpp b/engines/scumm/gfx.cpp
index e8856c11a6a..672772ee35e 100644
--- a/engines/scumm/gfx.cpp
+++ b/engines/scumm/gfx.cpp
@@ -2553,23 +2553,27 @@ void Gdi::drawBMAPObject(const byte *ptr, VirtScreen *vs, int obj, int x, int y,
byte code = *bmap_ptr++;
int scrX = _vm->_screenStartStrip * 8 * _vm->_bytesPerPixel;
- if (code == 8 || code == 9) {
+ if (code == BMCOMP_RLE8BIT || code == BMCOMP_TRLE8BIT) {
Common::Rect rScreen(0, 0, vs->w, vs->h);
- byte *dst = (byte *)_vm->_virtscr[kMainVirtScreen].backBuf + scrX;
- Wiz::copyWizImage(dst, bmap_ptr, vs->pitch, kDstScreen, vs->w, vs->h, x - scrX, y, w, h, &rScreen, 0, 0, 0, _vm->_bytesPerPixel);
+ WizRawPixel *dst = (WizRawPixel *)(_vm->_virtscr[kMainVirtScreen].backBuf + scrX);
+ // TODO: Wiz::copyWizImage(dst, bmap_ptr, vs->pitch, kDstScreen, vs->w, vs->h, x - scrX, y, w, h, &rScreen, 0, 0, 0, _vm->_bytesPerPixel);
+ ((ScummEngine_v71he *)_vm)->_wiz->auxDecompTRLEImage(
+ dst, bmap_ptr, vs->w, vs->h,
+ x, y, w, h, &rScreen,
+ nullptr);
}
- Common::Rect rect1(x, y, x + w, y + h);
- Common::Rect rect2(scrX, 0, vs->w + scrX, vs->h);
+ Common::Rect renderArea, clipArea;
- if (rect1.intersects(rect2)) {
- rect1.clip(rect2);
- rect1.left -= rect2.left;
- rect1.right -= rect2.left;
- rect1.top -= rect2.top;
- rect1.bottom -= rect2.top;
+ ((ScummEngine_v71he *)_vm)->_wiz->makeSizedRectAt(&renderArea, x, y, w, h);
+ ((ScummEngine_v71he *)_vm)->_wiz->makeSizedRect(&clipArea, vs->w, vs->h);
- ((ScummEngine_v71he *)_vm)->backgroundToForegroundBlit(rect1);
+ ((ScummEngine_v71he *)_vm)->_wiz->findRectOverlap(&renderArea, &clipArea);
+
+ // Unless the image was entirely clipped, copy newly decompressed
+ // pixels from the background buffer into the foreground buffer...
+ if (((ScummEngine_v71he *)_vm)->_wiz->isRectValid(renderArea)) {
+ ((ScummEngine_v71he *)_vm)->backgroundToForegroundBlit(renderArea);
}
}
diff --git a/engines/scumm/he/gfx_comp/aux_comp.cpp b/engines/scumm/he/gfx_comp/aux_comp.cpp
index f3e4ad1c68f..55e819590ce 100644
--- a/engines/scumm/he/gfx_comp/aux_comp.cpp
+++ b/engines/scumm/he/gfx_comp/aux_comp.cpp
@@ -51,8 +51,8 @@ namespace Scumm {
#define WRLE_LESS_LARGE_RUN_SIZE 256
#define AUX_IGNORE_ZPLANE_BITS(_dst, _mask, _count) { \
- for (int _counter = 0; _counter < _count; _counter++) { \
- if (0 == (_mask >>= 1)) { \
+ for (int i = 0; i < _count; i++) { \
+ if ((_mask >>= 1) == 0) { \
_mask = 0x80; \
_dst++; \
} \
@@ -60,9 +60,9 @@ namespace Scumm {
}
#define AUX_SET_ZPLANE_BITS(_dst, _mask, _count) { \
- for (int _counter = 0; _counter < _count; _counter++) { \
+ for (int i = 0; i < _count; i++) { \
*(_dst) |= _mask; \
- if (0 == (_mask >>= 1)) { \
+ if ((_mask >>= 1) == 0) { \
_mask = 0x80; \
_dst++; \
} \
@@ -70,9 +70,9 @@ namespace Scumm {
}
#define AUX_CLEAR_ZPLANE_BITS(_dst, _mask, _count) { \
- for (int _counter = 0; _counter < _count; _counter++) { \
+ for (int i = 0; i < _count; i++) { \
*(_dst) &= ~_mask; \
- if (0 == (_mask >>= 1)) { \
+ if ((_mask >>= 1) == 0) { \
_mask = 0x80; \
_dst++; \
} \
@@ -82,6 +82,8 @@ namespace Scumm {
void Wiz::auxWRLEUncompressPixelStream(WizRawPixel *destStream, const byte *singleColorTable, const byte *streamData, int streamSize, const WizRawPixel *conversionTable) {
int value, runCount;
+ WizRawPixel8 *dest8 = (WizRawPixel8 *)destStream;
+ WizRawPixel16 *dest16 = (WizRawPixel16 *)destStream;
while (streamSize > 0) {
value = *streamData++;
@@ -91,11 +93,15 @@ void Wiz::auxWRLEUncompressPixelStream(WizRawPixel *destStream, const byte *sing
runCount = WRLE_TINY_RUN_MIN_COUNT + ((value >> 1) & 0x03);
streamSize -= runCount;
- memset8BppConversion(
- destStream, *(singleColorTable + (value >> 3)),
- runCount, conversionTable);
+ memset8BppConversion(destStream, *(singleColorTable + (value >> 3)), runCount, conversionTable);
- destStream += runCount;
+ if (!_uses16BitColor) {
+ dest8 += runCount;
+ destStream = (WizRawPixel *)dest8;
+ } else {
+ dest16 += runCount;
+ destStream = (WizRawPixel *)dest16;
+ }
} else if (!(value & 0x02)) { // xxxxxx00
// Transparent run
@@ -106,7 +112,14 @@ void Wiz::auxWRLEUncompressPixelStream(WizRawPixel *destStream, const byte *sing
}
streamSize -= runCount;
- destStream += runCount;
+
+ if (!_uses16BitColor) {
+ dest8 += runCount;
+ destStream = (WizRawPixel *)dest8;
+ } else {
+ dest16 += runCount;
+ destStream = (WizRawPixel *)dest16;
+ }
} else if (value & 0x04) { // xxxxx110 ?
// Run of some color
@@ -119,16 +132,28 @@ void Wiz::auxWRLEUncompressPixelStream(WizRawPixel *destStream, const byte *sing
streamSize -= runCount;
- memset8BppConversion(
- destStream, *((byte *)streamData),
- runCount, conversionTable);
+ memset8BppConversion(destStream, *((byte *)streamData), runCount, conversionTable);
streamData += sizeof(byte);
- destStream += runCount;
+
+ if (!_uses16BitColor) {
+ dest8 += runCount;
+ destStream = (WizRawPixel *)dest8;
+ } else {
+ dest16 += runCount;
+ destStream = (WizRawPixel *)dest16;
+ }
} else { // xxxxx010
// Single color!
- *destStream++ = convert8BppToRawPixel(*(singleColorTable + (value >> 3)), conversionTable);
+ if (!_uses16BitColor) {
+ *dest8++ = (WizRawPixel8)convert8BppToRawPixel(*(singleColorTable + (value >> 3)), conversionTable);
+ destStream = (WizRawPixel *)dest8;
+ } else {
+ *dest16++ = (WizRawPixel16)convert8BppToRawPixel(*(singleColorTable + (value >> 3)), conversionTable);
+ destStream = (WizRawPixel *)dest16;
+ }
+
streamSize--;
}
}
@@ -137,6 +162,8 @@ void Wiz::auxWRLEUncompressPixelStream(WizRawPixel *destStream, const byte *sing
void Wiz::auxWRLEUncompressAndCopyFromStreamOffset(WizRawPixel *destStream, const byte *singleColorTable, const byte *streamData, int streamSize, byte copyFromColor, int streamOffset, const WizRawPixel *conversionTable) {
int value, runCount;
byte color;
+ WizRawPixel8 *dest8 = (WizRawPixel8 *)destStream;
+ WizRawPixel16 *dest16 = (WizRawPixel16 *)destStream;
while (streamSize > 0) {
value = *streamData++;
@@ -149,15 +176,22 @@ void Wiz::auxWRLEUncompressAndCopyFromStreamOffset(WizRawPixel *destStream, cons
color = *(singleColorTable + (value >> 3));
if (copyFromColor != color) {
- memset8BppConversion(
- destStream, color, runCount, conversionTable);
+ memset8BppConversion(destStream, color, runCount, conversionTable);
} else {
- memcpy(
- destStream, destStream + streamOffset,
- (runCount * sizeof(WizRawPixel)));
+ if (!_uses16BitColor) {
+ memcpy(dest8, dest8 + streamOffset, (runCount * sizeof(WizRawPixel8)));
+ } else {
+ memcpy(dest16, dest16 + streamOffset, (runCount * sizeof(WizRawPixel16)));
+ }
}
- destStream += runCount;
+ if (!_uses16BitColor) {
+ dest8 += runCount;
+ destStream = (WizRawPixel *)dest8;
+ } else {
+ dest16 += runCount;
+ destStream = (WizRawPixel *)dest16;
+ }
} else if (!(value & 0x02)) { // xxxxxx00
// Transparent run
@@ -168,7 +202,14 @@ void Wiz::auxWRLEUncompressAndCopyFromStreamOffset(WizRawPixel *destStream, cons
}
streamSize -= runCount;
- destStream += runCount;
+
+ if (!_uses16BitColor) {
+ dest8 += runCount;
+ destStream = (WizRawPixel *)dest8;
+ } else {
+ dest16 += runCount;
+ destStream = (WizRawPixel *)dest16;
+ }
} else if (value & 0x04) { // xxxxx110 ?
// Run of some color
@@ -184,26 +225,45 @@ void Wiz::auxWRLEUncompressAndCopyFromStreamOffset(WizRawPixel *destStream, cons
color = *((byte *)streamData);
if (color != copyFromColor) {
- memset8BppConversion(
- destStream, color,
- runCount, conversionTable);
+ memset8BppConversion(destStream, color, runCount, conversionTable);
} else {
- memcpy(
- destStream, destStream + streamOffset,
- (runCount * sizeof(WizRawPixel)));
+ if (!_uses16BitColor) {
+ memcpy(dest8, dest8 + streamOffset, (runCount * sizeof(WizRawPixel8)));
+ } else {
+ memcpy(dest16, dest16 + streamOffset, (runCount * sizeof(WizRawPixel16)));
+ }
}
streamData += sizeof(byte);
- destStream += runCount;
+
+ if (!_uses16BitColor) {
+ dest8 += runCount;
+ destStream = (WizRawPixel *)dest8;
+ } else {
+ dest16 += runCount;
+ destStream = (WizRawPixel *)dest16;
+ }
} else { // xxxxx010
// Single color!
color = *(singleColorTable + (value >> 3));
- if (color != copyFromColor) {
- *destStream++ = convert8BppToRawPixel(color, conversionTable);
+ if (!_uses16BitColor) {
+ if (color != copyFromColor) {
+ *dest8++ = (WizRawPixel8)convert8BppToRawPixel(color, conversionTable);
+ } else {
+ *dest8++ = *(dest8 + streamOffset);
+ }
+
+ destStream = (WizRawPixel *)dest8;
} else {
- *destStream++ = *(destStream + streamOffset);
+ if (color != copyFromColor) {
+ *dest16++ = (WizRawPixel16)convert8BppToRawPixel(color, conversionTable);
+ } else {
+ *dest16++ = *(dest16 + streamOffset);
+ }
+
+ destStream = (WizRawPixel *)dest16;
}
streamSize--;
@@ -213,6 +273,10 @@ void Wiz::auxWRLEUncompressAndCopyFromStreamOffset(WizRawPixel *destStream, cons
void Wiz::auxDecompSRLEStream(WizRawPixel *destStream, const WizRawPixel *backgroundStream, const byte *singleColorTable, const byte *streamData, int streamSize, const WizRawPixel *conversionTable) {
int value, runCount;
+ WizRawPixel8 *dest8 = (WizRawPixel8 *)destStream;
+ WizRawPixel16 *dest16 = (WizRawPixel16 *)destStream;
+ WizRawPixel8 *background8 = (WizRawPixel8 *)backgroundStream;
+ WizRawPixel16 *background16 = (WizRawPixel16 *)backgroundStream;
while (streamSize > 0) {
value = *streamData++;
@@ -226,16 +290,41 @@ void Wiz::auxDecompSRLEStream(WizRawPixel *destStream, const WizRawPixel *backgr
}
streamSize -= runCount;
- backgroundStream += runCount;
- destStream += runCount;
+
+ if (!_uses16BitColor) {
+ background8 += runCount;
+ dest8 += runCount;
+
+ backgroundStream = (WizRawPixel *)background8;
+ destStream = (WizRawPixel *)dest8;
+ } else {
+ background16 += runCount;
+ dest16 += runCount;
+
+ backgroundStream = (WizRawPixel *)background16;
+ destStream = (WizRawPixel *)dest16;
+ }
} else if (!(value & 0x02)) { // xxxxxx00
// Background run
runCount = 1 + (value >> 2);
streamSize -= runCount;
- memcpy(destStream, backgroundStream, runCount * sizeof(WizRawPixel));
- backgroundStream += runCount;
- destStream += runCount;
+
+ if (!_uses16BitColor) {
+ memcpy(dest8, background8, runCount * sizeof(WizRawPixel8));
+ background8 += runCount;
+ dest8 += runCount;
+
+ backgroundStream = (WizRawPixel *)background8;
+ destStream = (WizRawPixel *)dest8;
+ } else {
+ memcpy(dest16, background16, runCount * sizeof(WizRawPixel16));
+ background16 += runCount;
+ dest16 += runCount;
+
+ backgroundStream = (WizRawPixel *)background16;
+ destStream = (WizRawPixel *)dest16;
+ }
} else if (value & 0x04) { // xxxxx110
// Run of some color
@@ -252,14 +341,36 @@ void Wiz::auxDecompSRLEStream(WizRawPixel *destStream, const WizRawPixel *backgr
destStream, *streamData++, runCount,
conversionTable);
- backgroundStream += runCount;
- destStream += runCount;
+ if (!_uses16BitColor) {
+ background8 += runCount;
+ dest8 += runCount;
+
+ backgroundStream = (WizRawPixel *)background8;
+ destStream = (WizRawPixel *)dest8;
+ } else {
+ background16 += runCount;
+ dest16 += runCount;
+
+ backgroundStream = (WizRawPixel *)background16;
+ destStream = (WizRawPixel *)dest16;
+ }
} else { // xxxxx010
// Single color!
+ if (!_uses16BitColor) {
+ *dest8++ = (WizRawPixel8)convert8BppToRawPixel(*(singleColorTable + (value >> 3)), conversionTable);
+ background8++;
+
+ destStream = (WizRawPixel *)dest8;
+ backgroundStream = (WizRawPixel *)background8;
+ } else {
+ *dest16++ = (WizRawPixel16)convert8BppToRawPixel(*(singleColorTable + (value >> 3)), conversionTable);
+ background16++;
+
+ destStream = (WizRawPixel *)dest16;
+ backgroundStream = (WizRawPixel *)background16;
+ }
- *destStream++ = convert8BppToRawPixel(*(singleColorTable + (value >> 3)), conversionTable);
- backgroundStream++;
streamSize--;
}
}
@@ -322,6 +433,10 @@ void Wiz::auxDecompDRLEImage(WizRawPixel *foregroundBufferPtr, WizRawPixel *back
void Wiz::auxDecompDRLEPrim(WizRawPixel *foregroundBufferPtr, WizRawPixel *backgroundBufferPtr, int bufferWidth, Common::Rect *destRect, byte *compData, Common::Rect *sourceRect, const WizRawPixel *conversionTable) {
int decompWidth, decompHeight, counter, sX1, dX1, dX2, lineSize;
+ WizRawPixel8 *foregroundBuffer8 = (WizRawPixel8 *)foregroundBufferPtr;
+ WizRawPixel16 *foregroundBuffer16 = (WizRawPixel16 *)foregroundBufferPtr;
+ WizRawPixel8 *backgroundBuffer8 = (WizRawPixel8 *)backgroundBufferPtr;
+ WizRawPixel16 *backgroundBuffer16 = (WizRawPixel16 *)backgroundBufferPtr;
// General setup...
sX1 = sourceRect->left;
@@ -331,8 +446,19 @@ void Wiz::auxDecompDRLEPrim(WizRawPixel *foregroundBufferPtr, WizRawPixel *backg
decompHeight = sourceRect->bottom - sourceRect->top + 1;
// Quickly skip down to the lines to be compressed & dest position...
- foregroundBufferPtr += bufferWidth * destRect->top + dX1;
- backgroundBufferPtr += bufferWidth * destRect->top + dX1;
+ if (!_uses16BitColor) {
+ foregroundBuffer8 += bufferWidth * destRect->top + dX1;
+ backgroundBuffer8 += bufferWidth * destRect->top + dX1;
+
+ foregroundBufferPtr = (WizRawPixel *)foregroundBuffer8;
+ backgroundBufferPtr = (WizRawPixel *)backgroundBuffer8;
+ } else {
+ foregroundBuffer16 += bufferWidth * destRect->top + dX1;
+ backgroundBuffer16 += bufferWidth * destRect->top + dX1;
+
+ foregroundBufferPtr = (WizRawPixel *)foregroundBuffer16;
+ backgroundBufferPtr = (WizRawPixel *)backgroundBuffer16;
+ }
for (counter = sourceRect->top; counter > 0; counter--) {
compData += READ_LE_UINT16(compData) + 2;
@@ -348,19 +474,28 @@ void Wiz::auxDecompDRLEPrim(WizRawPixel *foregroundBufferPtr, WizRawPixel *backg
sX1, decompWidth, conversionTable);
compData += lineSize + 2;
- foregroundBufferPtr += bufferWidth;
- backgroundBufferPtr += bufferWidth;
-
} else {
// Handle a completely transparent line!
compData += 2;
- foregroundBufferPtr += bufferWidth;
- backgroundBufferPtr += bufferWidth;
+ }
+
+ if (!_uses16BitColor) {
+ foregroundBuffer8 += bufferWidth;
+ backgroundBuffer8 += bufferWidth;
+
+ foregroundBufferPtr = (WizRawPixel *)foregroundBuffer8;
+ backgroundBufferPtr = (WizRawPixel *)backgroundBuffer8;
+ } else {
+ foregroundBuffer16 += bufferWidth;
+ backgroundBuffer16 += bufferWidth;
+
+ foregroundBufferPtr = (WizRawPixel *)foregroundBuffer16;
+ backgroundBufferPtr = (WizRawPixel *)backgroundBuffer16;
}
}
}
-void Wiz::auxDecompTRLEImage(WizRawPixel *bufferPtr, byte *compData, int bufferWidth, int bufferHeight, int x, int y, int width, int height, Common::Rect *clipRectPtr, const WizRawPixel *conversionTable) {
+void Wiz::auxDecompTRLEImage(WizRawPixel *bufferPtr, const byte *compData, int bufferWidth, int bufferHeight, int x, int y, int width, int height, Common::Rect *clipRectPtr, const WizRawPixel *conversionTable) {
Common::Rect sourceRect, destRect, clipRect, workRect;
sourceRect.left = 0;
@@ -415,8 +550,10 @@ void Wiz::auxDecompTRLEImage(WizRawPixel *bufferPtr, byte *compData, int bufferW
&sourceRect, conversionTable);
}
-void Wiz::auxDecompTRLEPrim(WizRawPixel *bufferPtr, int bufferWidth, Common::Rect *destRect, byte *compData, Common::Rect *sourceRect, const WizRawPixel *conversionTable) {
+void Wiz::auxDecompTRLEPrim(WizRawPixel *bufferPtr, int bufferWidth, Common::Rect *destRect, const byte *compData, Common::Rect *sourceRect, const WizRawPixel *conversionTable) {
int decompWidth, decompHeight, counter, sX1, dX1, dX2, lineSize;
+ WizRawPixel8 *buffer8 = (WizRawPixel8 *)bufferPtr;
+ WizRawPixel16 *buffer16 = (WizRawPixel16 *)bufferPtr;
// General setup...
sX1 = sourceRect->left;
@@ -426,7 +563,14 @@ void Wiz::auxDecompTRLEPrim(WizRawPixel *bufferPtr, int bufferWidth, Common::Rec
decompHeight = sourceRect->bottom - sourceRect->top + 1;
// Quickly skip down to the lines to be compressed & dest position...
- bufferPtr += bufferWidth * destRect->top + dX1;
+ if (!_uses16BitColor) {
+ buffer8 += bufferWidth * destRect->top + dX1;
+ bufferPtr = (WizRawPixel *)buffer8;
+ } else {
+ buffer16 += bufferWidth * destRect->top + dX1;
+ bufferPtr = (WizRawPixel *)buffer16;
+ }
+
for (counter = sourceRect->top; counter > 0; counter--) {
compData += READ_LE_UINT16(compData) + 2;
}
@@ -440,11 +584,18 @@ void Wiz::auxDecompTRLEPrim(WizRawPixel *bufferPtr, int bufferWidth, Common::Rec
bufferPtr, compData + 2, sX1, decompWidth, conversionTable);
compData += lineSize + 2;
- bufferPtr += bufferWidth;
+
} else {
// Handle a completely transparent line!
compData += 2;
- bufferPtr += bufferWidth;
+ }
+
+ if (!_uses16BitColor) {
+ buffer8 += bufferWidth;
+ bufferPtr = (WizRawPixel *)buffer8;
+ } else {
+ buffer16 += bufferWidth;
+ bufferPtr = (WizRawPixel *)buffer16;
}
}
}
@@ -534,13 +685,12 @@ void Wiz::auxDrawZplaneFromTRLEPrim(byte *zplanePtr, int zplanePixelWidth, Commo
zplanePtr, compData + 2, sX1, decompWidth, mask, transOp, solidOp);
compData += lineSize + 2;
- zplanePtr += zplaneWidth;
-
} else {
// Handle a completely transparent line!
compData += 2;
- zplanePtr += zplaneWidth;
}
+
+ zplanePtr += zplaneWidth;
}
}
@@ -602,7 +752,9 @@ void Wiz::auxDecompRemappedTRLEImage(WizRawPixel *bufferPtr, byte *compData, int
}
void Wiz::auxDecompRemappedTRLEPrim(WizRawPixel *bufferPtr, int bufferWidth, Common::Rect *destRect, byte *compData, Common::Rect *sourceRect, byte *remapTable, const WizRawPixel *conversionTable) {
- int decompWidth, decompHeight, counter, sX1, dX1, dX2, lineSize;
+ int decompWidth, decompHeight, sX1, dX1, dX2, lineSize;
+ WizRawPixel8 *buffer8 = (WizRawPixel8 *)bufferPtr;
+ WizRawPixel16 *buffer16 = (WizRawPixel16 *)bufferPtr;
// General setup...
sX1 = sourceRect->left;
@@ -612,8 +764,15 @@ void Wiz::auxDecompRemappedTRLEPrim(WizRawPixel *bufferPtr, int bufferWidth, Com
decompHeight = sourceRect->bottom - sourceRect->top + 1;
// Quickly skip down to the lines to be compressed & dest position...
- bufferPtr += bufferWidth * destRect->top + dX1;
- for (counter = sourceRect->top; counter > 0; counter--) {
+ if (!_uses16BitColor) {
+ buffer8 += bufferWidth * destRect->top + dX1;
+ bufferPtr = (WizRawPixel *)buffer8;
+ } else {
+ buffer16 += bufferWidth * destRect->top + dX1;
+ bufferPtr = (WizRawPixel *)buffer16;
+ }
+
+ for (int i = sourceRect->top; i > 0; i--) {
compData += READ_LE_UINT16(compData) + 2;
}
@@ -627,16 +786,22 @@ void Wiz::auxDecompRemappedTRLEPrim(WizRawPixel *bufferPtr, int bufferWidth, Com
remapTable, conversionTable);
compData += lineSize + 2;
- bufferPtr += bufferWidth;
} else {
// Handle a completely transparent line!
compData += 2;
- bufferPtr += bufferWidth;
+ }
+
+ if (!_uses16BitColor) {
+ buffer8 += bufferWidth;
+ bufferPtr = (WizRawPixel *)buffer8;
+ } else {
+ buffer16 += bufferWidth;
+ bufferPtr = (WizRawPixel *)buffer16;
}
}
}
-bool Wiz::auxHitTestTRLEXPos(byte *dataStream, int skipAmount) {
+bool Wiz::auxHitTestTRLEXPos(const byte *dataStream, int skipAmount) {
int runCount;
// Decompress bytes to do simple clipping...
@@ -685,16 +850,14 @@ bool Wiz::auxHitTestTRLEXPos(byte *dataStream, int skipAmount) {
}
}
-bool Wiz::auxHitTestTRLEImageRelPos(byte *compData, int x, int y, int width, int height) {
- int counter;
-
+bool Wiz::auxHitTestTRLEImageRelPos(const byte *compData, int x, int y, int width, int height) {
// Quickly reject points outside the image boundry.
if ((x < 0) || (width <= x) || (y < 0) || (height <= y)) {
return false;
}
// Quickly skip down to the lines to be compressed & dest position...
- for (counter = 0; counter < y; counter++) {
+ for (int i = 0; i < y; i++) {
compData += READ_LE_UINT16(compData) + 2;
}
@@ -756,15 +919,13 @@ bool Wiz::auxPixelHitTestTRLEXPos(byte *dataStream, int skipAmount, int transpar
}
int Wiz::auxPixelHitTestTRLEImageRelPos(byte *compData, int x, int y, int width, int height, int transparentValue) {
- int counter;
-
// Quickly reject points outside the image boundry.
if ((x < 0) || (width <= x) || (y < 0) || (height <= y)) {
return transparentValue;
}
// Quickly skip down to the lines to be compressed & dest position...
- for (counter = 0; counter < y; counter++) {
+ for (int i = 0; i < y; i++) {
compData += READ_LE_UINT16(compData) + 2;
}
@@ -833,7 +994,9 @@ void Wiz::auxDecompMixColorsTRLEImage(WizRawPixel *bufferPtr, byte *compData, in
}
void Wiz::auxDecompMixColorsTRLEPrim(WizRawPixel *bufferPtr, int bufferWidth, Common::Rect *destRect, byte *compData, Common::Rect *sourceRect, byte *coloMixTable, const WizRawPixel *conversionTable) {
- int decompWidth, decompHeight, counter, sX1, dX1, dX2, lineSize;
+ int decompWidth, decompHeight, sX1, dX1, dX2, lineSize;
+ WizRawPixel8 *buffer8 = (WizRawPixel8 *)bufferPtr;
+ WizRawPixel16 *buffer16 = (WizRawPixel16 *)bufferPtr;
// General setup...
sX1 = sourceRect->left;
@@ -843,8 +1006,15 @@ void Wiz::auxDecompMixColorsTRLEPrim(WizRawPixel *bufferPtr, int bufferWidth, Co
decompHeight = sourceRect->bottom - sourceRect->top + 1;
// Quickly skip down to the lines to be compressed & dest position...
- bufferPtr += bufferWidth * destRect->top + dX1;
- for (counter = sourceRect->top; counter > 0; counter--) {
+ if (!_uses16BitColor) {
+ buffer8 += bufferWidth * destRect->top + dX1;
+ bufferPtr = (WizRawPixel *)buffer8;
+ } else {
+ buffer16 += bufferWidth * destRect->top + dX1;
+ bufferPtr = (WizRawPixel *)buffer16;
+ }
+
+ for (int i = sourceRect->top; i > 0; i--) {
compData += READ_LE_UINT16(compData) + 2;
}
@@ -858,18 +1028,27 @@ void Wiz::auxDecompMixColorsTRLEPrim(WizRawPixel *bufferPtr, int bufferWidth, Co
conversionTable);
compData += lineSize + 2;
- bufferPtr += bufferWidth;
-
} else {
// Handle a completely transparent line!
compData += 2;
- bufferPtr += bufferWidth;
+ }
+
+ if (!_uses16BitColor) {
+ buffer8 += bufferWidth;
+ bufferPtr = (WizRawPixel *)buffer8;
+ } else {
+ buffer16 += bufferWidth;
+ bufferPtr = (WizRawPixel *)buffer16;
}
}
}
void Wiz::auxDecompDRLEStream(WizRawPixel *destPtr, byte *dataStream, WizRawPixel *backgroundPtr, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
int runCount;
+ WizRawPixel8 *dest8 = (WizRawPixel8 *)destPtr;
+ WizRawPixel16 *dest16 = (WizRawPixel16 *)destPtr;
+ WizRawPixel8 *background8 = (WizRawPixel8 *)backgroundPtr;
+ WizRawPixel16 *background16 = (WizRawPixel16 *)backgroundPtr;
// Decompress bytes to do simple clipping...
while (skipAmount > 0) {
@@ -917,8 +1096,20 @@ void Wiz::auxDecompDRLEStream(WizRawPixel *destPtr, byte *dataStream, WizRawPixe
runCount >>= 1;
DoTransparentRun:
- destPtr += runCount;
- backgroundPtr += runCount;
+ if (!_uses16BitColor) {
+ dest8 += runCount;
+ background8 += runCount;
+
+ destPtr = (WizRawPixel *)dest8;
+ backgroundPtr = (WizRawPixel *)background8;
+ } else {
+ dest16 += runCount;
+ background16 += runCount;
+
+ destPtr = (WizRawPixel *)dest16;
+ backgroundPtr = (WizRawPixel *)background16;
+ }
+
decompAmount -= runCount;
} else if (runCount & 2) {
@@ -929,8 +1120,20 @@ void Wiz::auxDecompDRLEStream(WizRawPixel *destPtr, byte *dataStream, WizRawPixe
decompAmount -= runCount;
if (decompAmount >= 0) {
memset8BppConversion(destPtr, *dataStream++, runCount, conversionTable);
- destPtr += runCount;
- backgroundPtr += runCount;
+
+ if (!_uses16BitColor) {
+ dest8 += runCount;
+ background8 += runCount;
+
+ destPtr = (WizRawPixel *)dest8;
+ backgroundPtr = (WizRawPixel *)background8;
+ } else {
+ dest16 += runCount;
+ background16 += runCount;
+
+ destPtr = (WizRawPixel *)dest16;
+ backgroundPtr = (WizRawPixel *)background16;
+ }
} else {
runCount += decompAmount;
memset8BppConversion(destPtr, *dataStream++, runCount, conversionTable);
@@ -941,21 +1144,37 @@ void Wiz::auxDecompDRLEStream(WizRawPixel *destPtr, byte *dataStream, WizRawPixe
WriteBackgroundData:
decompAmount -= runCount;
if (decompAmount >= 0) {
- memcpy(destPtr, backgroundPtr, runCount * sizeof(WizRawPixel));
+ if (!_uses16BitColor) {
+ memcpy(dest8, background8, runCount * sizeof(WizRawPixel8));
+ dest8 += runCount;
+ background8 += runCount;
+
+ destPtr = (WizRawPixel *)dest8;
+ backgroundPtr = (WizRawPixel *)background8;
+ } else {
+ memcpy(dest16, background16, runCount * sizeof(WizRawPixel16));
+ dest16 += runCount;
+ background16 += runCount;
- destPtr += runCount;
- backgroundPtr += runCount;
+ destPtr = (WizRawPixel *)dest16;
+ backgroundPtr = (WizRawPixel *)background16;
+ }
} else {
runCount += decompAmount;
- memcpy(destPtr, backgroundPtr, runCount * sizeof(WizRawPixel));
-
+ if (!_uses16BitColor) {
+ memcpy(dest8, background8, runCount * sizeof(WizRawPixel8));
+ } else {
+ memcpy(dest16, background16, runCount * sizeof(WizRawPixel16));
+ }
}
}
}
}
-void Wiz::auxDecompTRLEStream(WizRawPixel *destPtr, byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
+void Wiz::auxDecompTRLEStream(WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
int runCount;
+ WizRawPixel8 *dest8 = (WizRawPixel8 *)destPtr;
+ WizRawPixel16 *dest16 = (WizRawPixel16 *)destPtr;
// Decompress bytes to do simple clipping...
while (skipAmount > 0) {
@@ -1003,7 +1222,14 @@ void Wiz::auxDecompTRLEStream(WizRawPixel *destPtr, byte *dataStream, int skipAm
runCount >>= 1;
DoTransparentRun:
- destPtr += runCount;
+ if (!_uses16BitColor) {
+ dest8 += runCount;
+ destPtr = (WizRawPixel *)dest8;
+ } else {
+ dest16 += runCount;
+ destPtr = (WizRawPixel *)dest16;
+ }
+
decompAmount -= runCount;
} else if (runCount & 2) {
@@ -1014,7 +1240,14 @@ void Wiz::auxDecompTRLEStream(WizRawPixel *destPtr, byte *dataStream, int skipAm
decompAmount -= runCount;
if (decompAmount >= 0) {
memset8BppConversion(destPtr, *dataStream++, runCount, conversionTable);
- destPtr += runCount;
+
+ if (!_uses16BitColor) {
+ dest8 += runCount;
+ destPtr = (WizRawPixel *)dest8;
+ } else {
+ dest16 += runCount;
+ destPtr = (WizRawPixel *)dest16;
+ }
} else {
runCount += decompAmount;
memset8BppConversion(destPtr, *dataStream, runCount, conversionTable);
@@ -1029,7 +1262,14 @@ void Wiz::auxDecompTRLEStream(WizRawPixel *destPtr, byte *dataStream, int skipAm
if (decompAmount >= 0) {
memcpy8BppConversion(destPtr, dataStream, runCount, conversionTable);
dataStream += runCount;
- destPtr += runCount;
+
+ if (!_uses16BitColor) {
+ dest8 += runCount;
+ destPtr = (WizRawPixel *)dest8;
+ } else {
+ dest16 += runCount;
+ destPtr = (WizRawPixel *)dest16;
+ }
} else {
runCount += decompAmount;
memcpy8BppConversion(destPtr, dataStream, runCount, conversionTable);
@@ -1040,6 +1280,8 @@ void Wiz::auxDecompTRLEStream(WizRawPixel *destPtr, byte *dataStream, int skipAm
void Wiz::auxDecompRemappedTRLEStream(WizRawPixel *destPtr, byte *dataStream, int skipAmount, int decompAmount, byte *remapTable, const WizRawPixel *conversionTable) {
int runCount;
+ WizRawPixel8 *dest8 = (WizRawPixel8 *)destPtr;
+ WizRawPixel16 *dest16 = (WizRawPixel16 *)destPtr;
// Decompress bytes to do simple clipping...
while (skipAmount > 0) {
@@ -1086,8 +1328,14 @@ void Wiz::auxDecompRemappedTRLEStream(WizRawPixel *destPtr, byte *dataStream, in
/* xxxxxxx1 */
runCount >>= 1;
DoTransparentRun:
+ if (!_uses16BitColor) {
+ dest8 += runCount;
+ destPtr = (WizRawPixel *)dest8;
+ } else {
+ dest16 += runCount;
+ destPtr = (WizRawPixel *)dest16;
+ }
- destPtr += runCount;
decompAmount -= runCount;
} else if (runCount & 2) {
@@ -1097,14 +1345,20 @@ void Wiz::auxDecompRemappedTRLEStream(WizRawPixel *destPtr, byte *dataStream, in
decompAmount -= runCount;
if (decompAmount >= 0) {
memset8BppConversion(destPtr, *(remapTable + *dataStream++), runCount, conversionTable);
- destPtr += runCount;
+
+ if (!_uses16BitColor) {
+ dest8 += runCount;
+ destPtr = (WizRawPixel *)dest8;
+ } else {
+ dest16 += runCount;
+ destPtr = (WizRawPixel *)dest16;
+ }
} else {
runCount += decompAmount;
memset8BppConversion(destPtr, *(remapTable + *dataStream), runCount, conversionTable);
}
} else {
-
/* xxxxxx00 */
runCount = (runCount >> 2) + 1;
WriteLiteralData:
@@ -1112,7 +1366,14 @@ void Wiz::auxDecompRemappedTRLEStream(WizRawPixel *destPtr, byte *dataStream, in
if (decompAmount >= 0) {
auxRemappedMemcpy(destPtr, dataStream, runCount, remapTable, conversionTable);
dataStream += runCount;
- destPtr += runCount;
+
+ if (!_uses16BitColor) {
+ dest8 += runCount;
+ destPtr = (WizRawPixel *)dest8;
+ } else {
+ dest16 += runCount;
+ destPtr = (WizRawPixel *)dest16;
+ }
} else {
runCount += decompAmount;
auxRemappedMemcpy(destPtr, dataStream, runCount, remapTable, conversionTable);
@@ -1427,8 +1688,16 @@ void Wiz::auxHistogramTRLEPrim(int *histogramTablePtr, byte *compData, Common::R
}
void Wiz::auxRemappedMemcpy(WizRawPixel *dstPtr, byte *srcPtr, int count, byte *remapTable, const WizRawPixel *conversionTable) {
+ WizRawPixel8 *dst8 = (WizRawPixel8 *)dstPtr;
+ WizRawPixel16 *dst16 = (WizRawPixel16 *)dstPtr;
+
do {
- *dstPtr++ = convert8BppToRawPixel(*(remapTable + *srcPtr++), conversionTable);
+ if (!_uses16BitColor) {
+ *dst8++ = (WizRawPixel8)convert8BppToRawPixel(*(remapTable + *srcPtr++), conversionTable);
+ } else {
+ *dst16++ = (WizRawPixel16)convert8BppToRawPixel(*(remapTable + *srcPtr++), conversionTable);
+ }
+
} while (--count > 0);
}
diff --git a/engines/scumm/he/gfx_comp/mrle_comp.cpp b/engines/scumm/he/gfx_comp/mrle_comp.cpp
index f6b54ea3034..07812727348 100644
--- a/engines/scumm/he/gfx_comp/mrle_comp.cpp
+++ b/engines/scumm/he/gfx_comp/mrle_comp.cpp
@@ -93,10 +93,15 @@ static void MRLEFLIP_VertFlipAlignWithRect(Common::Rect *rectToAlign, const Comm
static void MRLEFLIP_AltSource_F_XBppToXBpp(Wiz *wiz,
WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream,
int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
- const WizRawPixel *srcPtr;
- int runCount;
+ const WizRawPixel *srcPtr = (const WizRawPixel *)altSourcePtr;
+
+ const WizRawPixel8 *src8 = (const WizRawPixel8 *)srcPtr;
+ const WizRawPixel16 *src16 = (const WizRawPixel16 *)srcPtr;
- srcPtr = (const WizRawPixel *)altSourcePtr;
+ WizRawPixel8 *dest8 = (WizRawPixel8 *)destPtr;
+ WizRawPixel16 *dest16 = (WizRawPixel16 *)destPtr;
+
+ int runCount;
// Decompress bytes to do simple clipping...
HANDLE_SKIP_PIXELS_MACRO();
@@ -104,13 +109,24 @@ static void MRLEFLIP_AltSource_F_XBppToXBpp(Wiz *wiz,
// Really decompress to the dest buffer...
HANDLE_RUN_DECOMPRESS_MACRO(
{
- destPtr += runCount;
- srcPtr += runCount;
+ if (!wiz->_uses16BitColor) {
+ dest8 += runCount;
+ src8 += runCount;
+ } else {
+ dest16 += runCount;
+ src16 += runCount;
+ }
},
{
- memcpy(destPtr, srcPtr, (runCount * sizeof(WizRawPixel)));
- destPtr += runCount;
- srcPtr += runCount;
+ if (!wiz->_uses16BitColor) {
+ memcpy(dest8, src8, (runCount * sizeof(WizRawPixel8)));
+ dest8 += runCount;
+ src8 += runCount;
+ } else {
+ memcpy(dest16, src16, (runCount * sizeof(WizRawPixel16)));
+ dest16 += runCount;
+ src16 += runCount;
+ }
}
);
}
@@ -118,10 +134,15 @@ static void MRLEFLIP_AltSource_F_XBppToXBpp(Wiz *wiz,
static void MRLEFLIP_AltSource_B_XBppToXBpp(Wiz *wiz,
WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream,
int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
- const WizRawPixel *srcPtr;
- int runCount;
+ const WizRawPixel *srcPtr = (const WizRawPixel *)altSourcePtr;
+
+ const WizRawPixel8 *src8 = (const WizRawPixel8 *)srcPtr;
+ const WizRawPixel16 *src16 = (const WizRawPixel16 *)srcPtr;
- srcPtr = (const WizRawPixel *)altSourcePtr;
+ WizRawPixel8 *dest8 = (WizRawPixel8 *)destPtr;
+ WizRawPixel16 *dest16 = (WizRawPixel16 *)destPtr;
+
+ int runCount;
// Decompress bytes to do simple clipping...
HANDLE_SKIP_PIXELS_MACRO();
@@ -129,13 +150,24 @@ static void MRLEFLIP_AltSource_B_XBppToXBpp(Wiz *wiz,
// Really decompress to the dest buffer...
HANDLE_RUN_DECOMPRESS_MACRO(
{
- destPtr -= runCount;
- srcPtr -= runCount;
+ if (!wiz->_uses16BitColor) {
+ dest8 -= runCount;
+ src8 -= runCount;
+ } else {
+ dest16 -= runCount;
+ src16 -= runCount;
+ }
},
{
- destPtr -= runCount;
- srcPtr -= runCount;
- memcpy(destPtr + 1, srcPtr + 1, (runCount * sizeof(WizRawPixel)));
+ if (!wiz->_uses16BitColor) {
+ dest8 -= runCount;
+ src8 -= runCount;
+ memcpy(dest8 + 1, src8 + 1, (runCount * sizeof(WizRawPixel8)));
+ } else {
+ dest16 -= runCount;
+ src16 -= runCount;
+ memcpy(dest16 + 1, src16 + 1, (runCount * sizeof(WizRawPixel16)));
+ }
}
);
}
@@ -143,10 +175,12 @@ static void MRLEFLIP_AltSource_B_XBppToXBpp(Wiz *wiz,
static void MRLEFLIP_AltSource_F_8BppToXBpp(Wiz *wiz,
WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream,
int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
- const byte *srcPtr;
- int runCount;
+ const byte *srcPtr = (const byte *)altSourcePtr;
+
+ WizRawPixel8 *dest8 = (WizRawPixel8 *)destPtr;
+ WizRawPixel16 *dest16 = (WizRawPixel16 *)destPtr;
- srcPtr = (const byte *)altSourcePtr;
+ int runCount;
// Decompress bytes to do simple clipping...
HANDLE_SKIP_PIXELS_MACRO();
@@ -154,23 +188,47 @@ static void MRLEFLIP_AltSource_F_8BppToXBpp(Wiz *wiz,
// Really decompress to the dest buffer...
HANDLE_RUN_DECOMPRESS_MACRO(
{
- destPtr += runCount;
- srcPtr += runCount;
+ if (!wiz->_uses16BitColor) {
+ dest8 += runCount;
+ srcPtr += runCount;
+ destPtr = (WizRawPixel *)dest8;
+ } else {
+ dest16 += runCount;
+ srcPtr += runCount;
+ destPtr = (WizRawPixel *)dest16;
+ }
},
{
- wiz->memcpy8BppConversion(destPtr, srcPtr, runCount, conversionTable);
- destPtr += runCount;
- srcPtr += runCount;
- });
+ if (!wiz->_uses16BitColor) {
+ wiz->memcpy8BppConversion(destPtr, srcPtr, runCount, conversionTable);
+ dest8 += runCount;
+ srcPtr += runCount;
+ destPtr = (WizRawPixel *)dest8;
+ } else {
+ wiz->memcpy8BppConversion(destPtr, srcPtr, runCount, conversionTable);
+ dest16 += runCount;
+ srcPtr += runCount;
+ destPtr = (WizRawPixel *)dest16;
+ }
+ }
+ );
}
static void MRLEFLIP_AltSource_B_8BppToXBpp(Wiz *wiz,
WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream,
int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
- const WizRawPixel *srcPtr;
- int runCount;
- srcPtr = (const WizRawPixel *)altSourcePtr;
+ // NOTE: This looks like it should be a const byte pointer, but the original
+ // says it's a WizRawPixel pointer; I'm going to follow the original for now...
+ const WizRawPixel *srcPtr = (const WizRawPixel *)altSourcePtr;
+
+ const WizRawPixel8 *src8 = (const WizRawPixel8 *)srcPtr;
+ const WizRawPixel16 *src16 = (const WizRawPixel16 *)srcPtr;
+
+ WizRawPixel8 *dest8 = (WizRawPixel8 *)destPtr;
+ WizRawPixel16 *dest16 = (WizRawPixel16 *)destPtr;
+
+ int runCount;
// Decompress bytes to do simple clipping...
HANDLE_SKIP_PIXELS_MACRO();
@@ -178,14 +236,34 @@ static void MRLEFLIP_AltSource_B_8BppToXBpp(Wiz *wiz,
// Really decompress to the dest buffer...
HANDLE_RUN_DECOMPRESS_MACRO(
{
- destPtr -= runCount;
- srcPtr -= runCount;
+ if (!wiz->_uses16BitColor) {
+ dest8 -= runCount;
+ src8 -= runCount;
+ destPtr = (WizRawPixel *)dest8;
+ srcPtr = (WizRawPixel *)src8;
+ } else {
+ dest16 -= runCount;
+ src16 -= runCount;
+ destPtr = (WizRawPixel *)dest16;
+ srcPtr = (WizRawPixel *)src16;
+ }
},
{
- destPtr -= runCount;
- srcPtr -= runCount;
- wiz->memcpy8BppConversion(destPtr + 1, srcPtr + 1, runCount, conversionTable);
- });
+ if (!wiz->_uses16BitColor) {
+ wiz->memcpy8BppConversion(destPtr + 1, srcPtr + 1, runCount, conversionTable);
+ dest8 -= runCount;
+ src8 -= runCount;
+ destPtr = (WizRawPixel *)dest8;
+ srcPtr = (WizRawPixel *)src8;
+ } else {
+ wiz->memcpy8BppConversion(destPtr + 1, srcPtr + 1, runCount, conversionTable);
+ dest16 -= runCount;
+ src16 -= runCount;
+ destPtr = (WizRawPixel *)dest16;
+ srcPtr = (WizRawPixel *)src16;
+ }
+ }
+ );
}
static void MRLEFLIP_AltSource_DecompImageHull(Wiz *wiz,
@@ -197,7 +275,10 @@ static void MRLEFLIP_AltSource_DecompImageHull(Wiz *wiz,
void (*functionPtr)(Wiz *wiz,
WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream,
int skipAmount, int decompAmount, const WizRawPixel *conversionTable)) {
+
int decompWidth, decompHeight, counter, sX1, lineSize;
+ WizRawPixel8 *buffer8 = (WizRawPixel8 *)bufferPtr;
+ WizRawPixel16 *buffer16 = (WizRawPixel16 *)bufferPtr;
// Yet more general setup...
sX1 = sourceRect->left;
@@ -206,7 +287,13 @@ static void MRLEFLIP_AltSource_DecompImageHull(Wiz *wiz,
decompHeight = sourceRect->bottom - sourceRect->top + 1;
// Quickly skip down to the lines to be compressed & dest position...
- bufferPtr += bufferWidth * destRect->top + destRect->left;
+ if (!wiz->_uses16BitColor) {
+ buffer8 += bufferWidth * destRect->top + destRect->left;
+ bufferPtr = (WizRawPixel *)buffer8;
+ } else {
+ buffer16 += bufferWidth * destRect->top + destRect->left;
+ bufferPtr = (WizRawPixel *)buffer16;
+ }
for (counter = sourceRect->top; counter > 0; counter--) {
compData += READ_LE_UINT16((byte *)compData) + 2;
@@ -231,15 +318,20 @@ static void MRLEFLIP_AltSource_DecompImageHull(Wiz *wiz,
decompWidth, conversionTable);
compData += lineSize + 2;
- bufferPtr += bufferWidth;
- altSourceBuffer += altBytesPerLine;
-
} else {
// Handle a completely transparent line!
compData += 2;
- bufferPtr += bufferWidth;
- altSourceBuffer += altBytesPerLine;
}
+
+ if (!wiz->_uses16BitColor) {
+ buffer8 += bufferWidth;
+ bufferPtr = (WizRawPixel *)buffer8;
+ } else {
+ buffer16 += bufferWidth;
+ bufferPtr = (WizRawPixel *)buffer16;
+ }
+
+ altSourceBuffer += altBytesPerLine;
}
}
@@ -350,9 +442,6 @@ void Wiz::MRLEFLIP_AltSource_DecompressImage(
int x, int y, int width, int height, Common::Rect *clipRectPtr,
int32 wizFlags, const WizRawPixel *conversionTable) {
- if (!_uses16BitColor)
- error("Wiz::MRLEFLIP_AltSource_DecompressImage(): It's used, fix it...");
-
Common::Rect srcRect, clipRect;
WizCompressedImage fakeImage;
diff --git a/engines/scumm/he/gfx_comp/trle_comp.cpp b/engines/scumm/he/gfx_comp/trle_comp.cpp
index 5984057e7cc..a770a596832 100644
--- a/engines/scumm/he/gfx_comp/trle_comp.cpp
+++ b/engines/scumm/he/gfx_comp/trle_comp.cpp
@@ -313,29 +313,19 @@ void Wiz::TRLEFLIP_DecompImageHull(
if (lineSize != 0) {
(*functionPtr)(this, bufferPtr, compData + 2, sX1, decompWidth, extraPtr, conversionTable);
compData += lineSize + 2;
-
- if (_uses16BitColor) {
- buf16 = (WizRawPixel16 *)bufferPtr;
- buf16 += bufferWidth;
- bufferPtr = (WizRawPixel *)buf16;
- } else {
- buf8 = (WizRawPixel8 *)bufferPtr;
- buf8 += bufferWidth;
- bufferPtr = (WizRawPixel *)buf8;
- }
} else {
// Handle a completely transparent line!
compData += 2;
+ }
- if (_uses16BitColor) {
- buf16 = (WizRawPixel16 *)bufferPtr;
- buf16 += bufferWidth;
- bufferPtr = (WizRawPixel *)buf16;
- } else {
- buf8 = (WizRawPixel8 *)bufferPtr;
- buf8 += bufferWidth;
- bufferPtr = (WizRawPixel *)buf8;
- }
+ if (_uses16BitColor) {
+ buf16 = (WizRawPixel16 *)bufferPtr;
+ buf16 += bufferWidth;
+ bufferPtr = (WizRawPixel *)buf16;
+ } else {
+ buf8 = (WizRawPixel8 *)bufferPtr;
+ buf8 += bufferWidth;
+ bufferPtr = (WizRawPixel *)buf8;
}
}
}
@@ -1984,34 +1974,22 @@ void Wiz::TRLEFLIP_AltSource_DecompImageHull(
decompWidth, conversionTable);
compData += lineSize + 2;
-
- if (_uses16BitColor) {
- buf16 = (WizRawPixel16 *)bufferPtr;
- buf16 += bufferWidth;
- bufferPtr = (WizRawPixel *)buf16;
- } else {
- buf8 = (WizRawPixel8 *)bufferPtr;
- buf8 += bufferWidth;
- bufferPtr = (WizRawPixel *)buf8;
- }
-
- altSourceBuffer += altBytesPerLine;
} else {
// Handle a completely transparent line!
compData += 2;
+ }
- if (_uses16BitColor) {
- buf16 = (WizRawPixel16 *)bufferPtr;
- buf16 += bufferWidth;
- bufferPtr = (WizRawPixel *)buf16;
- } else {
- buf8 = (WizRawPixel8 *)bufferPtr;
- buf8 += bufferWidth;
- bufferPtr = (WizRawPixel *)buf8;
- }
-
- altSourceBuffer += altBytesPerLine;
+ if (_uses16BitColor) {
+ buf16 = (WizRawPixel16 *)bufferPtr;
+ buf16 += bufferWidth;
+ bufferPtr = (WizRawPixel *)buf16;
+ } else {
+ buf8 = (WizRawPixel8 *)bufferPtr;
+ buf8 += bufferWidth;
+ bufferPtr = (WizRawPixel *)buf8;
}
+
+ altSourceBuffer += altBytesPerLine;
}
}
diff --git a/engines/scumm/he/intern_he.h b/engines/scumm/he/intern_he.h
index dd0e270883c..7af2da8ff3b 100644
--- a/engines/scumm/he/intern_he.h
+++ b/engines/scumm/he/intern_he.h
@@ -304,7 +304,6 @@ protected:
int getStringCharWidth(byte chr);
void appendSubstring(int dst, int src, int len2, int len);
- void adjustRect(Common::Rect &rect);
/* HE version 71 script opcodes */
void o71_kernelSetFunctions();
@@ -639,8 +638,8 @@ protected:
int32 _heObject, _heObjectNum;
int32 _hePaletteNum;
- int32 _curMaxSpriteId;
- int32 _curSpriteId;
+ int32 _maxSpriteNum = 0;
+ int32 _minSpriteNum = 0;
int32 _curSpriteGroupId;
LogicHE *_logicHE;
@@ -750,6 +749,7 @@ protected:
byte VAR_NUM_SPRITES;
byte VAR_NUM_PALETTES;
byte VAR_NUM_UNK;
+ byte VAR_SPRITE_IMAGE_CHANGE_DOES_NOT_RESET_SETTINGS;
byte VAR_U32_VERSION;
byte VAR_U32_ARRAY_UNK;
diff --git a/engines/scumm/he/moonbase/moonbase_fow.cpp b/engines/scumm/he/moonbase/moonbase_fow.cpp
index 05fcae0de37..ff1b5fe740f 100644
--- a/engines/scumm/he/moonbase/moonbase_fow.cpp
+++ b/engines/scumm/he/moonbase/moonbase_fow.cpp
@@ -137,7 +137,7 @@ bool Moonbase::setFOWImage(int image) {
_fowAnimationFrames = (nStates + FOW_ANIM_FRAME_COUNT - 1) / FOW_ANIM_FRAME_COUNT;
_vm->_wiz->getWizImageDim(_fowImage, (nStates - 1), _fowTileW, _fowTileH);
- _fowBlackMode = !_vm->_wiz->isWizPixelNonTransparent(_fowImage, nStates - 1, 0, 0, 0);
+ // TODO: _fowBlackMode = !_vm->_wiz->isWizPixelNonTransparent(_fowImage, nStates - 1, 0, 0, 0);
if (ConfMan.hasKey("EnableFOWRects"))
_fowBlackMode = (ConfMan.getInt("EnableFOWRects") == 1);
@@ -333,7 +333,7 @@ void Moonbase::renderFOWState(uint8 *destSurface, int dstPitch, int dstType, int
_vm->_wiz->getWizImageSpot(_fowImage, state, spotx, spoty);
Common::Rect r(_fowClipX1, _fowClipY1, _fowClipX2, _fowClipY2);
- _vm->_wiz->drawWizImageEx(destSurface, _fowImage, 0, dstPitch, dstType, dstw, dsth, x - spotx, y - spoty, srcw, srch, state, &r, flags, 0, 0, 16, 0, 0);
+ //_vm->_wiz->drawWizImageEx(destSurface, _fowImage, 0, dstPitch, dstType, dstw, dsth, x - spotx, y - spoty, srcw, srch, state, &r, flags, 0, 0, 16, 0, 0);
}
static void blackRect_16bpp(uint8 *destSurface, int dstPitch, int dstw, int dsth, int x1, int y1, int x2, int y2) {
diff --git a/engines/scumm/he/polygon_he.cpp b/engines/scumm/he/polygon_he.cpp
index 4599f9b6900..4e1c007b4f2 100644
--- a/engines/scumm/he/polygon_he.cpp
+++ b/engines/scumm/he/polygon_he.cpp
@@ -87,7 +87,7 @@ void Wiz::polygonStore(int id, bool localFlag, int vert1x, int vert1y, int vert2
}
void Wiz::polyRotatePoints(Common::Point *pts, int num, int angle) {
- double alpha = angle * M_PI / 180.;
+ double alpha = ((double)angle) * M_PI / 180.;
double cos_alpha = cos(alpha);
double sin_alpha = sin(alpha);
diff --git a/engines/scumm/he/script_v100he.cpp b/engines/scumm/he/script_v100he.cpp
index 968b5b4dddc..6c683693342 100644
--- a/engines/scumm/he/script_v100he.cpp
+++ b/engines/scumm/he/script_v100he.cpp
@@ -384,7 +384,6 @@ void ScummEngine_v100he::o100_actorOps() {
a->_clipOverride.right = pop();
a->_clipOverride.top = pop();
a->_clipOverride.left = pop();
- adjustRect(a->_clipOverride);
break;
case SO_CONDITION:
k = getStackList(args, ARRAYSIZE(args));
@@ -465,7 +464,6 @@ void ScummEngine_v100he::o100_actorOps() {
_actorClipOverride.right = pop();
_actorClipOverride.top = pop();
_actorClipOverride.left = pop();
- adjustRect(_actorClipOverride);
break;
case SO_ACTOR_SOUNDS:
k = getStackList(args, ARRAYSIZE(args));
@@ -948,7 +946,7 @@ void ScummEngine_v100he::o100_setSpriteGroupInfo() {
value2 = pop();
value1 = pop();
if (_curSpriteGroupId)
- _sprite->setGroupPosition(_curSpriteGroupId, value1, value2);
+ _sprite->setGroupPoint(_curSpriteGroupId, value1, value2);
break;
case SO_CLIPPED: // 18
@@ -957,7 +955,7 @@ void ScummEngine_v100he::o100_setSpriteGroupInfo() {
value2 = pop();
value1 = pop();
if (_curSpriteGroupId)
- _sprite->setGroupBounds(_curSpriteGroupId, value1, value2, value3, value4);
+ _sprite->setGroupClipRect(_curSpriteGroupId, value1, value2, value3, value4);
break;
case SO_GROUP: // 38
@@ -979,7 +977,7 @@ void ScummEngine_v100he::o100_setSpriteGroupInfo() {
case SPRGRPOP_NEW_GROUP: // 3
value1 = pop(); // newGroup
if (_curSpriteGroupId)
- _sprite->setGroupMembersGroup(_curSpriteGroupId, value1);
+ _sprite->changeGroupMembersGroup(_curSpriteGroupId, value1);
break;
case SPRGRPOP_UPDATE_TYPE: // 4
@@ -990,7 +988,7 @@ void ScummEngine_v100he::o100_setSpriteGroupInfo() {
break;
case SPRGRPOP_NEW: // 5
if (_curSpriteGroupId)
- _sprite->setGroupMembersResetSprite(_curSpriteGroupId);
+ _sprite->performNewOnGroupMembers(_curSpriteGroupId);
break;
case SPRGRPOP_ANIMATION_SPEED: // 6
@@ -1033,7 +1031,7 @@ void ScummEngine_v100he::o100_setSpriteGroupInfo() {
break;
case SO_NEW: // 53
if (_curSpriteGroupId)
- _sprite->resetGroup(_curSpriteGroupId);
+ _sprite->newGroup(_curSpriteGroupId);
break;
case SO_NEW_GENERAL_PROPERTY: // 54
@@ -1072,7 +1070,7 @@ void ScummEngine_v100he::o100_setSpriteGroupInfo() {
break;
case SO_NEVER_ZCLIP: // 89
if (_curSpriteGroupId)
- _sprite->resetGroupBounds(_curSpriteGroupId);
+ _sprite->clearGroupClipRect(_curSpriteGroupId);
break;
default:
@@ -1186,7 +1184,7 @@ void ScummEngine_v100he::o100_wizImageOps() {
switch (subOp) {
case SO_INIT: // 0
_wizImageCommand.image = pop();
- _wizImageCommand.actionMode = kWAUnknown;
+ _wizImageCommand.actionType = kWAUnknown;
_wizImageCommand.actionFlags = 0;
_wizImageCommand.remapCount = 0;
_wizImageCommand.flags = 0;
@@ -1211,13 +1209,12 @@ void ScummEngine_v100he::o100_wizImageOps() {
break;
case SO_CAPTURE: // 11
_wizImageCommand.actionFlags |= kWAFRect | kWAFCompressionType;
- _wizImageCommand.actionMode = kWACapture;
+ _wizImageCommand.actionType = kWACapture;
_wizImageCommand.box.bottom = pop();
_wizImageCommand.box.right = pop();
_wizImageCommand.box.top = pop();
_wizImageCommand.box.left = pop();
_wizImageCommand.compressionType = pop();
- adjustRect(_wizImageCommand.box);
break;
case SO_CLIPPED: // 18
_wizImageCommand.actionFlags |= kWAFRect;
@@ -1225,13 +1222,12 @@ void ScummEngine_v100he::o100_wizImageOps() {
_wizImageCommand.box.right = pop();
_wizImageCommand.box.top = pop();
_wizImageCommand.box.left = pop();
- adjustRect(_wizImageCommand.box);
break;
case SO_COLOR_LIST: // 21
b = pop();
a = pop();
_wizImageCommand.actionFlags |= kWAFRemapList;
- _wizImageCommand.actionMode = kWAModify;
+ _wizImageCommand.actionType = kWAModify;
if (_wizImageCommand.remapCount == 0) {
memset(_wizImageCommand.remapList, 0, sizeof(_wizImageCommand.remapList));
} else {
@@ -1242,7 +1238,7 @@ void ScummEngine_v100he::o100_wizImageOps() {
}
break;
case SO_DRAW: // 29
- _wizImageCommand.actionMode = kWADraw;
+ _wizImageCommand.actionType = kWADraw;
break;
case SO_GENERAL_CLIP_RECT: // 36
_wizImageCommand.box.bottom = pop();
@@ -1260,11 +1256,11 @@ void ScummEngine_v100he::o100_wizImageOps() {
break;
case SO_LOAD: // 47
_wizImageCommand.actionFlags |= kWAFFilename;
- _wizImageCommand.actionMode = kWALoad;
+ _wizImageCommand.actionType = kWALoad;
copyScriptString(_wizImageCommand.filename, sizeof(_wizImageCommand.filename));
break;
case SO_NEW: // 53
- _wizImageCommand.actionMode = kWANew;
+ _wizImageCommand.actionType = kWANew;
break;
case SO_NEW_GENERAL_PROPERTY: // 54
_wizImageCommand.actionFlags |= kWAFProperty;
@@ -1296,14 +1292,14 @@ void ScummEngine_v100he::o100_wizImageOps() {
break;
case SO_POLY_TO_POLY: // 58
_wizImageCommand.actionFlags |= kWAFPolygon2 | kWAFCompressionType | kWAFPolygon;
- _wizImageCommand.actionMode = kWAPolyCapture;
+ _wizImageCommand.actionType = kWAPolyCapture;
_wizImageCommand.polygon2 = pop();
_wizImageCommand.polygon = pop();
_wizImageCommand.compressionType = pop();
break;
case SO_SAVE: // 64
_wizImageCommand.actionFlags |= kWAFFilename;
- _wizImageCommand.actionMode = kWASave;
+ _wizImageCommand.actionType = kWASave;
copyScriptString(_wizImageCommand.filename, sizeof(_wizImageCommand.filename));
_wizImageCommand.fileType = pop();
break;
@@ -1337,7 +1333,7 @@ void ScummEngine_v100he::o100_wizImageOps() {
_wiz->processWizImageCmd(&_wizImageCommand);
break;
case SO_FONT_CREATE: // 128
- _wizImageCommand.actionMode = kWAFontCreate;
+ _wizImageCommand.actionType = kWAFontCreate;
_wizImageCommand.fontProperties.bgColor = pop();
_wizImageCommand.fontProperties.fgColor = pop();
_wizImageCommand.fontProperties.size = pop();
@@ -1345,19 +1341,19 @@ void ScummEngine_v100he::o100_wizImageOps() {
copyScriptString(_wizImageCommand.fontProperties.fontName, sizeof(_wizImageCommand.fontProperties.fontName));
break;
case SO_FONT_END: // 129
- _wizImageCommand.actionMode = kWAFontEnd;
+ _wizImageCommand.actionType = kWAFontEnd;
break;
case SO_FONT_RENDER: // 130
- _wizImageCommand.actionMode = kWAFontRender;
+ _wizImageCommand.actionType = kWAFontRender;
_wizImageCommand.fontProperties.yPos = pop();
_wizImageCommand.fontProperties.xPos = pop();
copyScriptString(_wizImageCommand.fontProperties.string, sizeof(_wizImageCommand.fontProperties.string));
break;
case SO_FONT_START: // 131
- _wizImageCommand.actionMode = kWAFontStart;
+ _wizImageCommand.actionType = kWAFontStart;
break;
case SO_RENDER_ELLIPSE: // 133
- _wizImageCommand.actionMode = kWARenderEllipse;
+ _wizImageCommand.actionType = kWARenderEllipse;
_wizImageCommand.ellipseProperties.color = pop();
_wizImageCommand.ellipseProperties.lod = pop();
_wizImageCommand.ellipseProperties.ky = pop();
@@ -1369,11 +1365,10 @@ void ScummEngine_v100he::o100_wizImageOps() {
break;
case SO_RENDER_FLOOD_FILL: // 134
_wizImageCommand.actionFlags |= kWAFColor | kWAFRenderCoords;
- _wizImageCommand.actionMode = kWARenderFloodFill;
+ _wizImageCommand.actionType = kWARenderFloodFill;
_wizImageCommand.colorValue = pop();
_wizImageCommand.renderCoords.top = _wizImageCommand.renderCoords.bottom = pop();
_wizImageCommand.renderCoords.left = _wizImageCommand.renderCoords.right = pop();
- adjustRect(_wizImageCommand.renderCoords);
break;
case SO_RENDER_INTO_IMAGE: // 135
_wizImageCommand.actionFlags |= kWAFDestImage;
@@ -1381,31 +1376,28 @@ void ScummEngine_v100he::o100_wizImageOps() {
break;
case SO_RENDER_LINE: // 136
_wizImageCommand.actionFlags |= kWAFColor | kWAFRenderCoords;
- _wizImageCommand.actionMode = kWARenderLine;
+ _wizImageCommand.actionType = kWARenderLine;
_wizImageCommand.colorValue = pop();
_wizImageCommand.renderCoords.bottom = pop();
_wizImageCommand.renderCoords.right = pop();
_wizImageCommand.renderCoords.top = pop();
_wizImageCommand.renderCoords.left = pop();
- adjustRect(_wizImageCommand.renderCoords);
break;
case SO_RENDER_PIXEL: // 137
_wizImageCommand.actionFlags |= kWAFColor | kWAFRenderCoords;
- _wizImageCommand.actionMode = kWARenderPixel;
+ _wizImageCommand.actionType = kWARenderPixel;
_wizImageCommand.colorValue = pop();
_wizImageCommand.renderCoords.top = _wizImageCommand.renderCoords.bottom = pop();
_wizImageCommand.renderCoords.left = _wizImageCommand.renderCoords.right = pop();
- adjustRect(_wizImageCommand.renderCoords);
break;
case SO_RENDER_RECTANGLE: // 138
_wizImageCommand.actionFlags |= kWAFColor | kWAFRenderCoords;
- _wizImageCommand.actionMode = kWARenderRectangle;
+ _wizImageCommand.actionType = kWARenderRectangle;
_wizImageCommand.colorValue = pop();
_wizImageCommand.renderCoords.bottom = pop();
_wizImageCommand.renderCoords.right = pop();
_wizImageCommand.renderCoords.top = pop();
_wizImageCommand.renderCoords.left = pop();
- adjustRect(_wizImageCommand.renderCoords);
break;
default:
error("o100_wizImageOps: Unknown case %d", subOp);
@@ -1809,85 +1801,85 @@ void ScummEngine_v100he::o100_setSpriteInfo() {
switch (subOp) {
case SO_INIT: // 0
- _curMaxSpriteId = pop();
- _curSpriteId = pop();
+ _maxSpriteNum = pop();
+ _minSpriteNum = pop();
- if (_curSpriteId > _curMaxSpriteId)
- SWAP(_curSpriteId, _curMaxSpriteId);
+ if (_minSpriteNum > _maxSpriteNum)
+ SWAP(_minSpriteNum, _maxSpriteNum);
break;
case SO_ANGLE: // 2
args[0] = pop();
- if (_curSpriteId > _curMaxSpriteId)
+ if (_minSpriteNum > _maxSpriteNum)
break;
- spriteId = _curSpriteId;
+ spriteId = _minSpriteNum;
if (!spriteId)
spriteId++;
- for (; spriteId <= _curMaxSpriteId; spriteId++)
+ for (; spriteId <= _maxSpriteNum; spriteId++)
_sprite->setSpriteAngle(spriteId, args[0]);
break;
case SO_ANIMATION: // 3
args[0] = pop();
- if (_curSpriteId > _curMaxSpriteId)
+ if (_minSpriteNum > _maxSpriteNum)
break;
- spriteId = _curSpriteId;
+ spriteId = _minSpriteNum;
if (!spriteId)
spriteId++;
- for (; spriteId <= _curMaxSpriteId; spriteId++)
- _sprite->setSpriteFlagAutoAnim(spriteId, args[0]);
+ for (; spriteId <= _maxSpriteNum; spriteId++)
+ _sprite->setSpriteAutoAnimFlag(spriteId, args[0]);
break;
case SO_ANIMATION_SPEED: // 4
args[0] = pop();
- if (_curSpriteId > _curMaxSpriteId)
+ if (_minSpriteNum > _maxSpriteNum)
break;
- spriteId = _curSpriteId;
+ spriteId = _minSpriteNum;
if (!spriteId)
spriteId++;
- for (; spriteId <= _curMaxSpriteId; spriteId++)
+ for (; spriteId <= _maxSpriteNum; spriteId++)
_sprite->setSpriteAnimSpeed(spriteId, args[0]);
break;
case SO_AT: // 6
args[1] = pop();
args[0] = pop();
- if (_curSpriteId > _curMaxSpriteId)
+ if (_minSpriteNum > _maxSpriteNum)
break;
- spriteId = _curSpriteId;
+ spriteId = _minSpriteNum;
if (!spriteId)
spriteId++;
- for (; spriteId <= _curMaxSpriteId; spriteId++)
+ for (; spriteId <= _maxSpriteNum; spriteId++)
_sprite->setSpritePosition(spriteId, args[0], args[1]);
break;
case SO_AT_IMAGE: // 7
args[0] = pop();
- if (_curSpriteId > _curMaxSpriteId)
+ if (_minSpriteNum > _maxSpriteNum)
break;
- spriteId = _curSpriteId;
+ spriteId = _minSpriteNum;
if (!spriteId)
spriteId++;
- for (; spriteId <= _curMaxSpriteId; spriteId++)
- _sprite->setSpriteSourceImage(spriteId, args[0]);
+ for (; spriteId <= _maxSpriteNum; spriteId++)
+ _sprite->setSourceImage(spriteId, args[0]);
break;
case SO_CLASS: // 16
n = getStackList(args, ARRAYSIZE(args));
- if (_curSpriteId != 0 && _curMaxSpriteId != 0 && n != 0) {
+ if (_minSpriteNum != 0 && _maxSpriteNum != 0 && n != 0) {
int *p = &args[n - 1];
do {
int code = *p;
if (code == 0) {
- for (int i = _curSpriteId; i <= _curMaxSpriteId; ++i) {
- _sprite->setSpriteResetClass(i);
+ for (int i = _minSpriteNum; i <= _maxSpriteNum; ++i) {
+ _sprite->clearSpriteClasses(i);
}
} else if (code & 0x80) {
- for (int i = _curSpriteId; i <= _curMaxSpriteId; ++i) {
- _sprite->setSpriteSetClass(i, code & 0x7F, 1);
+ for (int i = _minSpriteNum; i <= _maxSpriteNum; ++i) {
+ _sprite->setSpriteClass(i, code & 0x7F, 1);
}
} else {
- for (int i = _curSpriteId; i <= _curMaxSpriteId; ++i) {
- _sprite->setSpriteSetClass(i, code & 0x7F, 0);
+ for (int i = _minSpriteNum; i <= _maxSpriteNum; ++i) {
+ _sprite->setSpriteClass(i, code & 0x7F, 0);
}
}
--p;
@@ -1896,132 +1888,132 @@ void ScummEngine_v100he::o100_setSpriteInfo() {
break;
case SO_ERASE: // 32
args[0] = pop();
- if (_curSpriteId > _curMaxSpriteId)
+ if (_minSpriteNum > _maxSpriteNum)
break;
- spriteId = _curSpriteId;
+ spriteId = _minSpriteNum;
if (!spriteId)
spriteId++;
- for (; spriteId <= _curMaxSpriteId; spriteId++)
- _sprite->setSpriteFlagEraseType(spriteId, args[0]);
+ for (; spriteId <= _maxSpriteNum; spriteId++)
+ _sprite->setSpriteEraseType(spriteId, args[0]);
break;
case SO_GROUP: // 38
args[0] = pop();
- if (_curSpriteId > _curMaxSpriteId)
+ if (_minSpriteNum > _maxSpriteNum)
break;
- spriteId = _curSpriteId;
+ spriteId = _minSpriteNum;
if (!spriteId)
spriteId++;
- for (; spriteId <= _curMaxSpriteId; spriteId++)
+ for (; spriteId <= _maxSpriteNum; spriteId++)
_sprite->setSpriteGroup(spriteId, args[0]);
break;
case SO_IMAGE: // 40
args[0] = pop();
- if (_curSpriteId > _curMaxSpriteId)
+ if (_minSpriteNum > _maxSpriteNum)
break;
- spriteId = _curSpriteId;
+ spriteId = _minSpriteNum;
if (!spriteId)
spriteId++;
- for (; spriteId <= _curMaxSpriteId; spriteId++)
+ for (; spriteId <= _maxSpriteNum; spriteId++)
_sprite->setSpriteImage(spriteId, args[0]);
break;
case SO_MASK: // 48
args[0] = pop();
- if (_curSpriteId > _curMaxSpriteId)
+ if (_minSpriteNum > _maxSpriteNum)
break;
- spriteId = _curSpriteId;
+ spriteId = _minSpriteNum;
if (!spriteId)
spriteId++;
- for (; spriteId <= _curMaxSpriteId; spriteId++)
- _sprite->setSpriteMaskImage(spriteId, args[0]);
+ for (; spriteId <= _maxSpriteNum; spriteId++)
+ _sprite->setMaskImage(spriteId, args[0]);
break;
case SO_MOVE: // 49
args[1] = pop();
args[0] = pop();
- if (_curSpriteId > _curMaxSpriteId)
+ if (_minSpriteNum > _maxSpriteNum)
break;
- spriteId = _curSpriteId;
+ spriteId = _minSpriteNum;
if (!spriteId)
spriteId++;
- for (; spriteId <= _curMaxSpriteId; spriteId++)
+ for (; spriteId <= _maxSpriteNum; spriteId++)
_sprite->moveSprite(spriteId, args[0], args[1]);
break;
case SO_NAME: // 52
copyScriptString(string, sizeof(string));
break;
case SO_NEW: // 53
- if (_curSpriteId > _curMaxSpriteId)
+ if (_minSpriteNum > _maxSpriteNum)
break;
- spriteId = _curSpriteId;
+ spriteId = _minSpriteNum;
if (!spriteId)
spriteId++;
- for (; spriteId <= _curMaxSpriteId; spriteId++)
- _sprite->resetSprite(spriteId);
+ for (; spriteId <= _maxSpriteNum; spriteId++)
+ _sprite->newSprite(spriteId);
break;
case SO_NEW_GENERAL_PROPERTY: // 54
args[1] = pop();
args[0] = pop();
- if (_curSpriteId > _curMaxSpriteId)
+ if (_minSpriteNum > _maxSpriteNum)
break;
- spriteId = _curSpriteId;
+ spriteId = _minSpriteNum;
if (!spriteId)
spriteId++;
- for (; spriteId <= _curMaxSpriteId; spriteId++)
+ for (; spriteId <= _maxSpriteNum; spriteId++)
_sprite->setSpriteGeneralProperty(spriteId, args[0], args[1]);
break;
case SO_PALETTE: // 57
args[0] = pop();
- if (_curSpriteId > _curMaxSpriteId)
+ if (_minSpriteNum > _maxSpriteNum)
break;
- spriteId = _curSpriteId;
+ spriteId = _minSpriteNum;
if (!spriteId)
spriteId++;
- for (; spriteId <= _curMaxSpriteId; spriteId++)
+ for (; spriteId <= _maxSpriteNum; spriteId++)
_sprite->setSpritePalette(spriteId, args[0]);
break;
case SO_PRIORITY: // 59
args[0] = pop();
- if (_curSpriteId > _curMaxSpriteId)
+ if (_minSpriteNum > _maxSpriteNum)
break;
- spriteId = _curSpriteId;
+ spriteId = _minSpriteNum;
if (!spriteId)
spriteId++;
- for (; spriteId <= _curMaxSpriteId; spriteId++)
+ for (; spriteId <= _maxSpriteNum; spriteId++)
_sprite->setSpritePriority(spriteId, args[0]);
break;
case SO_PROPERTY: // 60
args[1] = pop();
args[0] = pop();
- if (_curSpriteId > _curMaxSpriteId)
+ if (_minSpriteNum > _maxSpriteNum)
break;
- spriteId = _curSpriteId;
+ spriteId = _minSpriteNum;
if (!spriteId)
spriteId++;
- for (; spriteId <= _curMaxSpriteId; spriteId++)
+ for (; spriteId <= _maxSpriteNum; spriteId++)
switch (args[1]) {
case SPRPROP_HFLIP: // 0
- _sprite->setSpriteFlagXFlipped(spriteId, args[0]);
+ _sprite->setSpriteHorzFlip(spriteId, args[0]);
break;
case SPRPROP_VFLIP: // 1
- _sprite->setSpriteFlagYFlipped(spriteId, args[0]);
+ _sprite->setSpriteVertFlip(spriteId, args[0]);
break;
case SPRPROP_ACTIVE: // 2
- _sprite->setSpriteFlagActive(spriteId, args[0]);
+ _sprite->setSpriteActiveFlag(spriteId, args[0]);
break;
case SPRPROP_BACKGROUND_RENDER: // 3
- _sprite->setSpriteFlagDoubleBuffered(spriteId, args[0]);
+ _sprite->setSpriteRenderToBackground(spriteId, args[0]);
break;
case SPRPROP_USE_IMAGE_REMAP_TABLE: // 4
- _sprite->setSpriteFlagRemapPalette(spriteId, args[0]);
+ _sprite->setSpriteImageRemapFlag(spriteId, args[0]);
break;
default:
warning("Unknown sprite property %d for sprite %d", args[0], spriteId);
@@ -2029,121 +2021,121 @@ void ScummEngine_v100he::o100_setSpriteInfo() {
}
break;
case SO_RESTART: // 61
- _sprite->resetTables(true);
+ _sprite->resetSpriteSystem(true);
break;
case SO_SCALE: // 65
args[0] = pop();
- if (_curSpriteId > _curMaxSpriteId)
+ if (_minSpriteNum > _maxSpriteNum)
break;
- spriteId = _curSpriteId;
+ spriteId = _minSpriteNum;
if (!spriteId)
spriteId++;
- for (; spriteId <= _curMaxSpriteId; spriteId++)
+ for (; spriteId <= _maxSpriteNum; spriteId++)
_sprite->setSpriteScale(spriteId, args[0]);
break;
case SO_SHADOW: // 70
args[0] = pop();
- if (_curSpriteId > _curMaxSpriteId)
+ if (_minSpriteNum > _maxSpriteNum)
break;
- spriteId = _curSpriteId;
+ spriteId = _minSpriteNum;
if (!spriteId)
spriteId++;
- for (; spriteId <= _curMaxSpriteId; spriteId++)
+ for (; spriteId <= _maxSpriteNum; spriteId++)
_sprite->setSpriteShadow(spriteId, args[0]);
break;
case SO_STATE: // 73
args[0] = pop();
- if (_curSpriteId > _curMaxSpriteId)
+ if (_minSpriteNum > _maxSpriteNum)
break;
- spriteId = _curSpriteId;
+ spriteId = _minSpriteNum;
if (!spriteId)
spriteId++;
- for (; spriteId <= _curMaxSpriteId; spriteId++)
+ for (; spriteId <= _maxSpriteNum; spriteId++)
_sprite->setSpriteImageState(spriteId, args[0]);
break;
case SO_STEP_DIST: // 74
args[1] = pop();
args[0] = pop();
- if (_curSpriteId > _curMaxSpriteId)
+ if (_minSpriteNum > _maxSpriteNum)
break;
- spriteId = _curSpriteId;
+ spriteId = _minSpriteNum;
if (!spriteId)
spriteId++;
- for (; spriteId <= _curMaxSpriteId; spriteId++)
- _sprite->setSpriteDist(spriteId, args[0], args[1]);
+ for (; spriteId <= _maxSpriteNum; spriteId++)
+ _sprite->setDelta(spriteId, args[0], args[1]);
break;
case SO_STEP_DIST_X: // 75
args[0] = pop();
- if (_curSpriteId > _curMaxSpriteId)
+ if (_minSpriteNum > _maxSpriteNum)
break;
- spriteId = _curSpriteId;
+ spriteId = _minSpriteNum;
if (!spriteId)
spriteId++;
- for (; spriteId <= _curMaxSpriteId; spriteId++) {
- _sprite->getSpriteDist(spriteId, tmp[0], tmp[1]);
- _sprite->setSpriteDist(spriteId, args[0], tmp[1]);
+ for (; spriteId <= _maxSpriteNum; spriteId++) {
+ _sprite->getDelta(spriteId, tmp[0], tmp[1]);
+ _sprite->setDelta(spriteId, args[0], tmp[1]);
}
break;
case SO_STEP_DIST_Y: // 76
args[0] = pop();
- if (_curSpriteId > _curMaxSpriteId)
+ if (_minSpriteNum > _maxSpriteNum)
break;
- spriteId = _curSpriteId;
+ spriteId = _minSpriteNum;
if (!spriteId)
spriteId++;
- for (; spriteId <= _curMaxSpriteId; spriteId++) {
- _sprite->getSpriteDist(spriteId, tmp[0], tmp[1]);
- _sprite->setSpriteDist(spriteId, tmp[0], args[0]);
+ for (; spriteId <= _maxSpriteNum; spriteId++) {
+ _sprite->getDelta(spriteId, tmp[0], tmp[1]);
+ _sprite->setDelta(spriteId, tmp[0], args[0]);
}
break;
case SO_UPDATE: // 82
args[0] = pop();
- if (_curSpriteId > _curMaxSpriteId)
+ if (_minSpriteNum > _maxSpriteNum)
break;
- spriteId = _curSpriteId;
+ spriteId = _minSpriteNum;
if (!spriteId)
spriteId++;
- for (; spriteId <= _curMaxSpriteId; spriteId++)
- _sprite->setSpriteFlagUpdateType(spriteId, args[0]);
+ for (; spriteId <= _maxSpriteNum; spriteId++)
+ _sprite->setSpriteUpdateType(spriteId, args[0]);
break;
case SO_VARIABLE: // 83
args[1] = pop();
args[0] = pop();
- if (_curSpriteId > _curMaxSpriteId)
+ if (_minSpriteNum > _maxSpriteNum)
break;
- spriteId = _curSpriteId;
+ spriteId = _minSpriteNum;
if (!spriteId)
spriteId++;
- for (; spriteId <= _curMaxSpriteId; spriteId++)
- _sprite->setSpriteUserValue(spriteId, args[0], args[1]);
+ for (; spriteId <= _maxSpriteNum; spriteId++)
+ _sprite->setUserValue(spriteId, args[0], args[1]);
break;
case SO_IMAGE_ZCLIP: // 88
args[0] = pop();
- if (_curSpriteId > _curMaxSpriteId)
+ if (_minSpriteNum > _maxSpriteNum)
break;
- spriteId = _curSpriteId;
+ spriteId = _minSpriteNum;
if (!spriteId)
spriteId++;
- for (; spriteId <= _curMaxSpriteId; spriteId++)
+ for (; spriteId <= _maxSpriteNum; spriteId++)
_sprite->setSpriteZBuffer(spriteId, args[0]);
break;
case SO_NEVER_ZCLIP: // 89
- if (_curSpriteId > _curMaxSpriteId)
+ if (_minSpriteNum > _maxSpriteNum)
break;
- spriteId = _curSpriteId;
+ spriteId = _minSpriteNum;
if (!spriteId)
spriteId++;
- for (; spriteId <= _curMaxSpriteId; spriteId++)
+ for (; spriteId <= _maxSpriteNum; spriteId++)
_sprite->setSpriteZBuffer(spriteId, 0);
break;
default:
@@ -2514,7 +2506,7 @@ void ScummEngine_v100he::o100_getSpriteGroupInfo() {
case SO_IMAGE:
spriteGroupId = pop();
if (spriteGroupId)
- push(_sprite->getGroupDstResNum(spriteGroupId));
+ push(_sprite->getGroupImage(spriteGroupId));
else
push(0);
break;
@@ -2559,7 +2551,7 @@ void ScummEngine_v100he::o100_getSpriteGroupInfo() {
case SO_XPOS:
spriteGroupId = pop();
if (spriteGroupId) {
- _sprite->getGroupPosition(spriteGroupId, tx, ty);
+ _sprite->getGroupPoint(spriteGroupId, tx, ty);
push(tx);
} else {
push(0);
@@ -2568,7 +2560,7 @@ void ScummEngine_v100he::o100_getSpriteGroupInfo() {
case SO_YPOS:
spriteGroupId = pop();
if (spriteGroupId) {
- _sprite->getGroupPosition(spriteGroupId, tx, ty);
+ _sprite->getGroupPoint(spriteGroupId, tx, ty);
push(ty);
} else {
push(0);
@@ -2597,7 +2589,7 @@ void ScummEngine_v100he::o100_getWizData() {
push(_wiz->pixelHitTestWiz(resId, state, x, y, 0));
break;
case SO_COUNT:
- push(_wiz->getWizImageStates(pop()));
+ push(_wiz->getWizStateCount(pop()));
break;
case SO_FIND:
y = pop();
@@ -2630,13 +2622,13 @@ void ScummEngine_v100he::o100_getWizData() {
case SO_XPOS:
state = pop();
resId = pop();
- _wiz->getWizImageSpot(resId, state, x, y);
+ _wiz->getWizSpot(resId, state, x, y);
push(x);
break;
case SO_YPOS:
state = pop();
resId = pop();
- _wiz->getWizImageSpot(resId, state, x, y);
+ _wiz->getWizSpot(resId, state, x, y);
push(y);
break;
case SO_FONT_START:
@@ -2762,7 +2754,7 @@ void ScummEngine_v100he::o100_readFile() {
void ScummEngine_v100he::o100_getSpriteInfo() {
int args[16];
- int spriteId, flags, groupId, type;
+ int spriteId, flags, groupId, quickCheck, classCount, count;
int32 x, y;
byte subOp = fetchScriptByte();
@@ -2771,7 +2763,7 @@ void ScummEngine_v100he::o100_getSpriteInfo() {
case SO_ANIMATION:
spriteId = pop();
if (spriteId)
- push(_sprite->getSpriteFlagAutoAnim(spriteId));
+ push(_sprite->getSpriteAutoAnimFlag(spriteId));
else
push(0);
break;
@@ -2785,15 +2777,19 @@ void ScummEngine_v100he::o100_getSpriteInfo() {
case SO_AT_IMAGE:
spriteId = pop();
if (spriteId)
- push(_sprite->getSpriteSourceImage(spriteId));
+ push(_sprite->getSourceImage(spriteId));
else
push(0);
break;
case SO_CLASS:
- flags = getStackList(args, ARRAYSIZE(args));
+ count = getStackList(args, ARRAYSIZE(args));
spriteId = pop();
if (spriteId) {
- push(_sprite->getSpriteClass(spriteId, flags, args));
+ if (!count) {
+ push(_sprite->getSpriteClass(spriteId, -1));
+ } else {
+ push(_sprite->checkSpriteClassAgaintClassSet(spriteId, count, args));
+ }
} else {
push(0);
}
@@ -2822,17 +2818,17 @@ void ScummEngine_v100he::o100_getSpriteInfo() {
case SO_ERASE:
spriteId = pop();
if (spriteId)
- push(_sprite->getSpriteFlagEraseType(spriteId));
+ push(_sprite->getSpriteEraseType(spriteId));
else
push(1);
break;
case SO_FIND:
- flags = getStackList(args, ARRAYSIZE(args));
- type = pop();
+ classCount = getStackList(args, ARRAYSIZE(args));
+ quickCheck = pop();
groupId = pop();
y = pop();
x = pop();
- push(_sprite->findSpriteWithClassOf(x, y, groupId, type, flags, args));
+ push(_sprite->spriteFromPoint(x, y, groupId, quickCheck, classCount, args));
break;
case SO_GROUP:
spriteId = pop();
@@ -2860,7 +2856,7 @@ void ScummEngine_v100he::o100_getSpriteInfo() {
case SO_MASK:
spriteId = pop();
if (spriteId)
- push(_sprite->getSpriteMaskImage(spriteId));
+ push(_sprite->getMaskImage(spriteId));
else
push(0);
break;
@@ -2892,19 +2888,19 @@ void ScummEngine_v100he::o100_getSpriteInfo() {
if (spriteId) {
switch (flags) {
case SPRPROP_HFLIP: // 0
- push(_sprite->getSpriteFlagXFlipped(spriteId));
+ push(_sprite->getSpriteHorzFlip(spriteId));
break;
case SPRPROP_VFLIP: // 1
- push(_sprite->getSpriteFlagYFlipped(spriteId));
+ push(_sprite->getSpriteVertFlip(spriteId));
break;
case SPRPROP_ACTIVE: // 2
- push(_sprite->getSpriteFlagActive(spriteId));
+ push(_sprite->getSpriteActiveFlag(spriteId));
break;
case SPRPROP_BACKGROUND_RENDER: // 3
- push(_sprite->getSpriteFlagDoubleBuffered(spriteId));
+ push(_sprite->getSpriteRenderToBackground(spriteId));
break;
case SPRPROP_USE_IMAGE_REMAP_TABLE: // 4
- push(_sprite->getSpriteFlagRemapPalette(spriteId));
+ push(_sprite->getSpriteImageRemapFlag(spriteId));
break;
default:
push(0);
@@ -2937,7 +2933,7 @@ void ScummEngine_v100he::o100_getSpriteInfo() {
case SO_STEP_DIST_X:
spriteId = pop();
if (spriteId) {
- _sprite->getSpriteDist(spriteId, x, y);
+ _sprite->getDelta(spriteId, x, y);
push(x);
} else {
push(0);
@@ -2946,7 +2942,7 @@ void ScummEngine_v100he::o100_getSpriteInfo() {
case SO_STEP_DIST_Y:
spriteId = pop();
if (spriteId) {
- _sprite->getSpriteDist(spriteId, x, y);
+ _sprite->getDelta(spriteId, x, y);
push(y);
} else {
push(0);
@@ -2955,7 +2951,7 @@ void ScummEngine_v100he::o100_getSpriteInfo() {
case SO_UPDATE:
spriteId = pop();
if (spriteId)
- push(_sprite->getSpriteFlagUpdateType(spriteId));
+ push(_sprite->getSpriteUpdateType(spriteId));
else
push(0);
break;
@@ -2963,7 +2959,7 @@ void ScummEngine_v100he::o100_getSpriteInfo() {
pop();
spriteId = pop();
if (spriteId)
- push(_sprite->getSpriteUserValue(spriteId));
+ push(_sprite->getUserValue(spriteId));
else
push(0);
break;
diff --git a/engines/scumm/he/script_v71he.cpp b/engines/scumm/he/script_v71he.cpp
index 2c57a61b0bf..3b99d9c435c 100644
--- a/engines/scumm/he/script_v71he.cpp
+++ b/engines/scumm/he/script_v71he.cpp
@@ -168,15 +168,6 @@ void ScummEngine_v71he::appendSubstring(int dst, int src, int srcOffs, int len)
writeArray(0, 0, dstOffs + i, 0);
}
-void ScummEngine_v71he::adjustRect(Common::Rect &rect) {
- // Scripts can set all rect positions to -1
- if (rect.right != -1)
- rect.right += 1;
-
- if (rect.bottom != -1)
- rect.bottom += 1;
-}
-
void ScummEngine_v71he::o71_kernelSetFunctions() {
int args[29];
int num;
@@ -229,7 +220,6 @@ void ScummEngine_v71he::o71_kernelSetFunctions() {
_wiz->_lWizClipRect.top = args[2];
_wiz->_lWizClipRect.right = args[3];
_wiz->_lWizClipRect.bottom = args[4];
- adjustRect(_wiz->_lWizClipRect);
break;
case 43:
_wiz->_lUseWizClipRect = false;
diff --git a/engines/scumm/he/script_v72he.cpp b/engines/scumm/he/script_v72he.cpp
index 9ee356230a9..a2fc1e03a74 100644
--- a/engines/scumm/he/script_v72he.cpp
+++ b/engines/scumm/he/script_v72he.cpp
@@ -842,7 +842,6 @@ void ScummEngine_v72he::o72_actorOps() {
_actorClipOverride.right = pop();
_actorClipOverride.top = pop();
_actorClipOverride.left = pop();
- adjustRect(_actorClipOverride);
break;
case ScummEngine_v6::SubOpType::SO_AT: // (HE 98+)
j = pop();
@@ -854,7 +853,15 @@ void ScummEngine_v72he::o72_actorOps() {
a->_clipOverride.right = pop();
a->_clipOverride.top = pop();
a->_clipOverride.left = pop();
- adjustRect(a->_clipOverride);
+
+ if (a->_clipOverride.left == -1 && a->_clipOverride.top == -1 &&
+ a->_clipOverride.right == -1 && a->_clipOverride.bottom == -1) {
+
+ a->_clipOverride.bottom = _actorClipOverride.bottom;
+ a->_clipOverride.right = _actorClipOverride.right;
+ a->_clipOverride.top = _actorClipOverride.top;
+ a->_clipOverride.left = _actorClipOverride.left;
+ }
break;
case SO_ERASE: // // (HE 90+)
k = pop();
diff --git a/engines/scumm/he/script_v90he.cpp b/engines/scumm/he/script_v90he.cpp
index 73f4037a0bb..0634faf5538 100644
--- a/engines/scumm/he/script_v90he.cpp
+++ b/engines/scumm/he/script_v90he.cpp
@@ -130,28 +130,27 @@ void ScummEngine_v90he::o90_wizImageOps() {
_wizImageCommand.box.left = pop();
break;
case SO_DRAW: // 48
- _wizImageCommand.actionMode = kWADraw;
+ _wizImageCommand.actionType = kWADraw;
break;
case SO_LOAD: // 49
_wizImageCommand.actionFlags |= kWAFFilename;
- _wizImageCommand.actionMode = kWALoad;
+ _wizImageCommand.actionType = kWALoad;
copyScriptString(_wizImageCommand.filename, sizeof(_wizImageCommand.filename));
break;
case SO_SAVE: // 50
_wizImageCommand.actionFlags |= kWAFFilename;
- _wizImageCommand.actionMode = kWASave;
+ _wizImageCommand.actionType = kWASave;
copyScriptString(_wizImageCommand.filename, sizeof(_wizImageCommand.filename));
_wizImageCommand.fileType = pop();
break;
case SO_CAPTURE: // 51
_wizImageCommand.actionFlags |= kWAFRect | kWAFCompressionType;
- _wizImageCommand.actionMode = kWACapture;
+ _wizImageCommand.actionType = kWACapture;
_wizImageCommand.box.bottom = pop();
_wizImageCommand.box.right = pop();
_wizImageCommand.box.top = pop();
_wizImageCommand.box.left = pop();
_wizImageCommand.compressionType = pop();
- adjustRect(_wizImageCommand.box);
break;
case SO_STATE: // 52
_wizImageCommand.actionFlags |= kWAFState;
@@ -183,7 +182,7 @@ void ScummEngine_v90he::o90_wizImageOps() {
break;
case SO_INIT: // 57
_wizImageCommand.image = pop();
- _wizImageCommand.actionMode = kWAUnknown;
+ _wizImageCommand.actionType = kWAUnknown;
_wizImageCommand.actionFlags = 0;
_wizImageCommand.remapCount = 0;
_wizImageCommand.flags = 0;
@@ -208,7 +207,7 @@ void ScummEngine_v90he::o90_wizImageOps() {
b = pop();
a = pop();
_wizImageCommand.actionFlags |= kWAFRemapList;
- _wizImageCommand.actionMode = kWAModify;
+ _wizImageCommand.actionType = kWAModify;
if (_wizImageCommand.remapCount == 0) {
memset(_wizImageCommand.remapList, 0, sizeof(_wizImageCommand.remapList));
}
@@ -223,7 +222,6 @@ void ScummEngine_v90he::o90_wizImageOps() {
_wizImageCommand.box.right = pop();
_wizImageCommand.box.top = pop();
_wizImageCommand.box.left = pop();
- adjustRect(_wizImageCommand.box);
break;
case SO_PALETTE: // 86, HE99+
_wizImageCommand.actionFlags |= kWAFPalette;
@@ -239,46 +237,42 @@ void ScummEngine_v90he::o90_wizImageOps() {
break;
case SO_POLY_POLYGON: // 131, HE99+
_wizImageCommand.actionFlags |= kWAFPolygon2 | kWAFCompressionType | kWAFPolygon;
- _wizImageCommand.actionMode = kWAPolyCapture;
+ _wizImageCommand.actionType = kWAPolyCapture;
_wizImageCommand.polygon2 = pop();
_wizImageCommand.polygon = pop();
_wizImageCommand.compressionType = pop();
break;
case SO_RENDER_RECTANGLE: // 133, HE99+
_wizImageCommand.actionFlags |= kWAFColor | kWAFRenderCoords;
- _wizImageCommand.actionMode = kWARenderRectangle;
+ _wizImageCommand.actionType = kWARenderRectangle;
_wizImageCommand.colorValue = pop();
_wizImageCommand.renderCoords.bottom = pop();
_wizImageCommand.renderCoords.right = pop();
_wizImageCommand.renderCoords.top = pop();
_wizImageCommand.renderCoords.left = pop();
- adjustRect(_wizImageCommand.renderCoords);
break;
case SO_RENDER_LINE: // 134, HE99+
_wizImageCommand.actionFlags |= kWAFColor | kWAFRenderCoords;
- _wizImageCommand.actionMode = kWARenderLine;
+ _wizImageCommand.actionType = kWARenderLine;
_wizImageCommand.colorValue = pop();
_wizImageCommand.renderCoords.bottom = pop();
_wizImageCommand.renderCoords.right = pop();
_wizImageCommand.renderCoords.top = pop();
_wizImageCommand.renderCoords.left = pop();
- adjustRect(_wizImageCommand.renderCoords);
break;
case SO_RENDER_PIXEL: // 135, HE99+
_wizImageCommand.actionFlags |= kWAFColor | kWAFRenderCoords;
- _wizImageCommand.actionMode = kWARenderPixel;
+ _wizImageCommand.actionType = kWARenderPixel;
_wizImageCommand.colorValue = pop();
_wizImageCommand.renderCoords.top = _wizImageCommand.renderCoords.bottom = pop();
_wizImageCommand.renderCoords.left = _wizImageCommand.renderCoords.right = pop();
- adjustRect(_wizImageCommand.renderCoords);
break;
case SO_RENDER_FLOOD_FILL: // 136, HE99+
_wizImageCommand.actionFlags |= kWAFColor | kWAFRenderCoords;
- _wizImageCommand.actionMode = kWARenderFloodFill;
+ _wizImageCommand.actionType = kWARenderFloodFill;
_wizImageCommand.colorValue = pop();
_wizImageCommand.renderCoords.top = _wizImageCommand.renderCoords.bottom = pop();
_wizImageCommand.renderCoords.left = _wizImageCommand.renderCoords.right = pop();
- adjustRect(_wizImageCommand.renderCoords);
break;
case SO_RENDER_INTO_IMAGE: // 137, HE99+
_wizImageCommand.actionFlags |= kWAFDestImage;
@@ -290,10 +284,10 @@ void ScummEngine_v90he::o90_wizImageOps() {
_wizImageCommand.propertyNumber = pop();
break;
case SO_FONT_START: // 141, HE99+
- _wizImageCommand.actionMode = kWAFontStart;
+ _wizImageCommand.actionType = kWAFontStart;
break;
case SO_FONT_CREATE: // 142, HE99+
- _wizImageCommand.actionMode = kWAFontCreate;
+ _wizImageCommand.actionType = kWAFontCreate;
_wizImageCommand.fontProperties.bgColor = pop();
_wizImageCommand.fontProperties.fgColor = pop();
_wizImageCommand.fontProperties.size = pop();
@@ -301,13 +295,13 @@ void ScummEngine_v90he::o90_wizImageOps() {
copyScriptString(_wizImageCommand.fontProperties.fontName, sizeof(_wizImageCommand.fontProperties.fontName));
break;
case SO_FONT_RENDER: // 143, HE99+
- _wizImageCommand.actionMode = kWAFontRender;
+ _wizImageCommand.actionType = kWAFontRender;
_wizImageCommand.fontProperties.yPos = pop();
_wizImageCommand.fontProperties.xPos = pop();
copyScriptString(_wizImageCommand.fontProperties.string, sizeof(_wizImageCommand.fontProperties.string));
break;
case SO_RENDER_ELLIPSE: // 189, HE99+
- _wizImageCommand.actionMode = kWARenderEllipse;
+ _wizImageCommand.actionType = kWARenderEllipse;
_wizImageCommand.ellipseProperties.color = pop();
_wizImageCommand.ellipseProperties.lod = pop();
_wizImageCommand.ellipseProperties.ky = pop();
@@ -318,10 +312,10 @@ void ScummEngine_v90he::o90_wizImageOps() {
_wizImageCommand.ellipseProperties.px = pop();
break;
case SO_FONT_END: // 196, HE99+
- _wizImageCommand.actionMode = kWAFontEnd;
+ _wizImageCommand.actionType = kWAFontEnd;
break;
case SO_NEW: // 217, HE99+
- _wizImageCommand.actionMode = kWANew;
+ _wizImageCommand.actionType = kWANew;
break;
case SO_SET_POLYGON: // 246
_wizImageCommand.actionFlags |= kWAFFlags | kWAFSpot | kWAFPolygon;
@@ -500,7 +494,7 @@ void ScummEngine_v90he::o90_getSpriteInfo() {
case SO_STEP_DIST_X: // 34
spriteId = pop();
if (spriteId) {
- _sprite->getSpriteDist(spriteId, x, y);
+ _sprite->getDelta(spriteId, x, y);
push(x);
} else {
push(0);
@@ -509,7 +503,7 @@ void ScummEngine_v90he::o90_getSpriteInfo() {
case SO_STEP_DIST_Y: // 35
spriteId = pop();
if (spriteId) {
- _sprite->getSpriteDist(spriteId, x, y);
+ _sprite->getDelta(spriteId, x, y);
push(y);
} else {
push(0);
@@ -549,19 +543,19 @@ void ScummEngine_v90he::o90_getSpriteInfo() {
if (spriteId) {
switch (flags) {
case SPRPROP_HFLIP: // 0
- push(_sprite->getSpriteFlagXFlipped(spriteId));
+ push(_sprite->getSpriteHorzFlip(spriteId));
break;
case SPRPROP_VFLIP: // 1
- push(_sprite->getSpriteFlagYFlipped(spriteId));
+ push(_sprite->getSpriteVertFlip(spriteId));
break;
case SPRPROP_ACTIVE: // 2
- push(_sprite->getSpriteFlagActive(spriteId));
+ push(_sprite->getSpriteActiveFlag(spriteId));
break;
case SPRPROP_BACKGROUND_RENDER: // 3
- push(_sprite->getSpriteFlagDoubleBuffered(spriteId));
+ push(_sprite->getSpriteRenderToBackground(spriteId));
break;
case SPRPROP_USE_IMAGE_REMAP_TABLE: // 4
- push(_sprite->getSpriteFlagRemapPalette(spriteId));
+ push(_sprite->getSpriteImageRemapFlag(spriteId));
break;
default:
push(0);
@@ -584,18 +578,18 @@ void ScummEngine_v90he::o90_getSpriteInfo() {
groupId = pop();
y = pop();
x = pop();
- push(_sprite->findSpriteWithClassOf(x, y, groupId, type, flags, args));
+ push(_sprite->spriteFromPoint(x, y, groupId, type, flags, args));
} else if (_game.heversion == 98) {
type = pop();
groupId = pop();
y = pop();
x = pop();
- push(_sprite->findSpriteWithClassOf(x, y, groupId, type, 0, 0));
+ push(_sprite->spriteFromPoint(x, y, groupId, type, 0, 0));
} else {
groupId = pop();
y = pop();
x = pop();
- push(_sprite->findSpriteWithClassOf(x, y, groupId, 0, 0, 0));
+ push(_sprite->spriteFromPoint(x, y, groupId, 0, 0, 0));
}
break;
case SO_STATE: // 52
@@ -608,7 +602,7 @@ void ScummEngine_v90he::o90_getSpriteInfo() {
case SO_AT_IMAGE: // 62
spriteId = pop();
if (spriteId)
- push(_sprite->getSpriteSourceImage(spriteId));
+ push(_sprite->getSourceImage(spriteId));
else
push(0);
break;
@@ -622,14 +616,14 @@ void ScummEngine_v90he::o90_getSpriteInfo() {
case SO_ERASE: // 68
spriteId = pop();
if (spriteId)
- push(_sprite->getSpriteFlagEraseType(spriteId));
+ push(_sprite->getSpriteEraseType(spriteId));
else
push(1);
break;
case SO_ANIMATION: // 82
spriteId = pop();
if (spriteId)
- push(_sprite->getSpriteFlagAutoAnim(spriteId));
+ push(_sprite->getSpriteAutoAnimFlag(spriteId));
else
push(0);
break;
@@ -664,7 +658,7 @@ void ScummEngine_v90he::o90_getSpriteInfo() {
case SO_UPDATE: // 124
spriteId = pop();
if (spriteId)
- push(_sprite->getSpriteFlagUpdateType(spriteId));
+ push(_sprite->getSpriteUpdateType(spriteId));
else
push(0);
break;
@@ -672,9 +666,33 @@ void ScummEngine_v90he::o90_getSpriteInfo() {
count = getStackList(args, ARRAYSIZE(args));
spriteId = pop();
- // TODO: Implement HE98-99-100 differences here
if (spriteId) {
- push(_sprite->getSpriteClass(spriteId, count, args));
+ if (!count) {
+ push(_sprite->getSpriteClass(spriteId, -1));
+ } else {
+ if (_game.heversion > 98) {
+ push(_sprite->checkSpriteClassAgaintClassSet(spriteId, count, args));
+ } else {
+ bool stillTrue = true;
+
+ while (count--) {
+ int classID = args[count];
+ int classbit = _sprite->getSpriteClass(spriteId, (classID & 0x7f));
+
+ if (((classID & 0x80) == 0x80) && (classbit == 0))
+ stillTrue = false;
+
+ if (((classID & 0x80) == 0x00) && (classbit != 0))
+ stillTrue = false;
+ }
+
+ if (!stillTrue) {
+ push(0);
+ } else {
+ push(1);
+ }
+ }
+ }
} else {
push(0);
}
@@ -690,7 +708,7 @@ void ScummEngine_v90he::o90_getSpriteInfo() {
case SO_MASK: // 140
spriteId = pop();
if (spriteId)
- push(_sprite->getSpriteMaskImage(spriteId));
+ push(_sprite->getMaskImage(spriteId));
else
push(0);
break;
@@ -698,7 +716,7 @@ void ScummEngine_v90he::o90_getSpriteInfo() {
pop();
spriteId = pop();
if (spriteId)
- push(_sprite->getSpriteUserValue(spriteId));
+ push(_sprite->getUserValue(spriteId));
else
push(0);
break;
@@ -718,66 +736,66 @@ void ScummEngine_v90he::o90_setSpriteInfo() {
switch (subOp) {
case SO_STEP_DIST_X: // 34
args[0] = pop();
- if (_curSpriteId > _curMaxSpriteId)
+ if (_minSpriteNum > _maxSpriteNum)
break;
- spriteId = _curSpriteId;
+ spriteId = _minSpriteNum;
if (!spriteId)
spriteId++;
- for (; spriteId <= _curMaxSpriteId; spriteId++) {
- _sprite->getSpriteDist(spriteId, tmp[0], tmp[1]);
- _sprite->setSpriteDist(spriteId, args[0], tmp[1]);
+ for (; spriteId <= _maxSpriteNum; spriteId++) {
+ _sprite->getDelta(spriteId, tmp[0], tmp[1]);
+ _sprite->setDelta(spriteId, args[0], tmp[1]);
}
break;
case SO_STEP_DIST_Y: // 35
args[0] = pop();
- if (_curSpriteId > _curMaxSpriteId)
+ if (_minSpriteNum > _maxSpriteNum)
break;
- spriteId = _curSpriteId;
+ spriteId = _minSpriteNum;
if (!spriteId)
spriteId++;
- for (; spriteId <= _curMaxSpriteId; spriteId++) {
- _sprite->getSpriteDist(spriteId, tmp[0], tmp[1]);
- _sprite->setSpriteDist(spriteId, tmp[0], args[0]);
+ for (; spriteId <= _maxSpriteNum; spriteId++) {
+ _sprite->getDelta(spriteId, tmp[0], tmp[1]);
+ _sprite->setDelta(spriteId, tmp[0], args[0]);
}
break;
case SO_GROUP: // 37
args[0] = pop();
- if (_curSpriteId > _curMaxSpriteId)
+ if (_minSpriteNum > _maxSpriteNum)
break;
- spriteId = _curSpriteId;
+ spriteId = _minSpriteNum;
if (!spriteId)
spriteId++;
- for (; spriteId <= _curMaxSpriteId; spriteId++)
+ for (; spriteId <= _maxSpriteNum; spriteId++)
_sprite->setSpriteGroup(spriteId, args[0]);
break;
case SO_PROPERTY: // 42
args[1] = pop();
args[0] = pop();
- if (_curSpriteId > _curMaxSpriteId)
+ if (_minSpriteNum > _maxSpriteNum)
break;
- spriteId = _curSpriteId;
+ spriteId = _minSpriteNum;
if (!spriteId)
spriteId++;
- for (; spriteId <= _curMaxSpriteId; spriteId++)
+ for (; spriteId <= _maxSpriteNum; spriteId++)
switch (args[1]) {
case SPRPROP_HFLIP: // 0
- _sprite->setSpriteFlagXFlipped(spriteId, args[0]);
+ _sprite->setSpriteHorzFlip(spriteId, args[0]);
break;
case SPRPROP_VFLIP: // 1
- _sprite->setSpriteFlagYFlipped(spriteId, args[0]);
+ _sprite->setSpriteVertFlip(spriteId, args[0]);
break;
case SPRPROP_ACTIVE: // 2
- _sprite->setSpriteFlagActive(spriteId, args[0]);
+ _sprite->setSpriteActiveFlag(spriteId, args[0]);
break;
case SPRPROP_BACKGROUND_RENDER: // 3
- _sprite->setSpriteFlagDoubleBuffered(spriteId, args[0]);
+ _sprite->setSpriteRenderToBackground(spriteId, args[0]);
break;
case SPRPROP_USE_IMAGE_REMAP_TABLE: // 4
- _sprite->setSpriteFlagRemapPalette(spriteId, args[0]);
+ _sprite->setSpriteImageRemapFlag(spriteId, args[0]);
break;
default:
break;
@@ -785,201 +803,201 @@ void ScummEngine_v90he::o90_setSpriteInfo() {
break;
case SO_PRIORITY: // 43
args[0] = pop();
- if (_curSpriteId > _curMaxSpriteId)
+ if (_minSpriteNum > _maxSpriteNum)
break;
- spriteId = _curSpriteId;
+ spriteId = _minSpriteNum;
if (!spriteId)
spriteId++;
- for (; spriteId <= _curMaxSpriteId; spriteId++)
+ for (; spriteId <= _maxSpriteNum; spriteId++)
_sprite->setSpritePriority(spriteId, args[0]);
break;
case SO_MOVE: // 44
args[1] = pop();
args[0] = pop();
- if (_curSpriteId > _curMaxSpriteId)
+ if (_minSpriteNum > _maxSpriteNum)
break;
- spriteId = _curSpriteId;
+ spriteId = _minSpriteNum;
if (!spriteId)
spriteId++;
- for (; spriteId <= _curMaxSpriteId; spriteId++)
+ for (; spriteId <= _maxSpriteNum; spriteId++)
_sprite->moveSprite(spriteId, args[0], args[1]);
break;
case SO_STATE: // 52
args[0] = pop();
- if (_curSpriteId > _curMaxSpriteId)
+ if (_minSpriteNum > _maxSpriteNum)
break;
- spriteId = _curSpriteId;
+ spriteId = _minSpriteNum;
if (!spriteId)
spriteId++;
- for (; spriteId <= _curMaxSpriteId; spriteId++)
+ for (; spriteId <= _maxSpriteNum; spriteId++)
_sprite->setSpriteImageState(spriteId, args[0]);
break;
case SO_ANGLE: // 53
args[0] = pop();
- if (_curSpriteId > _curMaxSpriteId)
+ if (_minSpriteNum > _maxSpriteNum)
break;
- spriteId = _curSpriteId;
+ spriteId = _minSpriteNum;
if (!spriteId)
spriteId++;
- for (; spriteId <= _curMaxSpriteId; spriteId++)
+ for (; spriteId <= _maxSpriteNum; spriteId++)
_sprite->setSpriteAngle(spriteId, args[0]);
break;
case SO_INIT: // 57
if (_game.features & GF_HE_985 || _game.heversion >= 99) {
- _curMaxSpriteId = pop();
- _curSpriteId = pop();
+ _maxSpriteNum = pop();
+ _minSpriteNum = pop();
- if (_curSpriteId > _curMaxSpriteId)
- SWAP(_curSpriteId, _curMaxSpriteId);
+ if (_minSpriteNum > _maxSpriteNum)
+ SWAP(_minSpriteNum, _maxSpriteNum);
} else {
- _curSpriteId = pop();
- _curMaxSpriteId = _curSpriteId; // to make all functions happy
+ _minSpriteNum = pop();
+ _maxSpriteNum = _minSpriteNum; // to make all functions happy
}
break;
case SO_AT_IMAGE: // 62, HE99+
args[0] = pop();
- if (_curSpriteId > _curMaxSpriteId)
+ if (_minSpriteNum > _maxSpriteNum)
break;
- spriteId = _curSpriteId;
+ spriteId = _minSpriteNum;
if (!spriteId)
spriteId++;
- for (; spriteId <= _curMaxSpriteId; spriteId++)
- _sprite->setSpriteSourceImage(spriteId, args[0]);
+ for (; spriteId <= _maxSpriteNum; spriteId++)
+ _sprite->setSourceImage(spriteId, args[0]);
break;
case SO_IMAGE: // 63
args[0] = pop();
- if (_curSpriteId > _curMaxSpriteId)
+ if (_minSpriteNum > _maxSpriteNum)
break;
- spriteId = _curSpriteId;
+ spriteId = _minSpriteNum;
if (!spriteId)
spriteId++;
- for (; spriteId <= _curMaxSpriteId; spriteId++)
+ for (; spriteId <= _maxSpriteNum; spriteId++)
_sprite->setSpriteImage(spriteId, args[0]);
break;
case SO_AT: // 65
args[1] = pop();
args[0] = pop();
- if (_curSpriteId > _curMaxSpriteId)
+ if (_minSpriteNum > _maxSpriteNum)
break;
- spriteId = _curSpriteId;
+ spriteId = _minSpriteNum;
if (!spriteId)
spriteId++;
- for (; spriteId <= _curMaxSpriteId; spriteId++)
+ for (; spriteId <= _maxSpriteNum; spriteId++)
_sprite->setSpritePosition(spriteId, args[0], args[1]);
break;
case SO_ERASE: // 68
args[0] = pop();
- if (_curSpriteId > _curMaxSpriteId)
+ if (_minSpriteNum > _maxSpriteNum)
break;
- spriteId = _curSpriteId;
+ spriteId = _minSpriteNum;
if (!spriteId)
spriteId++;
- for (; spriteId <= _curMaxSpriteId; spriteId++)
- _sprite->setSpriteFlagEraseType(spriteId, args[0]);
+ for (; spriteId <= _maxSpriteNum; spriteId++)
+ _sprite->setSpriteEraseType(spriteId, args[0]);
break;
case SO_STEP_DIST: // 77
args[1] = pop();
args[0] = pop();
- if (_curSpriteId > _curMaxSpriteId)
+ if (_minSpriteNum > _maxSpriteNum)
break;
- spriteId = _curSpriteId;
+ spriteId = _minSpriteNum;
if (!spriteId)
spriteId++;
- for (; spriteId <= _curMaxSpriteId; spriteId++)
- _sprite->setSpriteDist(spriteId, args[0], args[1]);
+ for (; spriteId <= _maxSpriteNum; spriteId++)
+ _sprite->setDelta(spriteId, args[0], args[1]);
break;
case SO_ANIMATION: // 82
args[0] = pop();
- if (_curSpriteId > _curMaxSpriteId)
+ if (_minSpriteNum > _maxSpriteNum)
break;
- spriteId = _curSpriteId;
+ spriteId = _minSpriteNum;
if (!spriteId)
spriteId++;
- for (; spriteId <= _curMaxSpriteId; spriteId++)
- _sprite->setSpriteFlagAutoAnim(spriteId, args[0]);
+ for (; spriteId <= _maxSpriteNum; spriteId++)
+ _sprite->setSpriteAutoAnimFlag(spriteId, args[0]);
break;
case SO_PALETTE: // 86, HE98+
args[0] = pop();
- if (_curSpriteId > _curMaxSpriteId)
+ if (_minSpriteNum > _maxSpriteNum)
break;
- spriteId = _curSpriteId;
+ spriteId = _minSpriteNum;
if (!spriteId)
spriteId++;
- for (; spriteId <= _curMaxSpriteId; spriteId++)
+ for (; spriteId <= _maxSpriteNum; spriteId++)
_sprite->setSpritePalette(spriteId, args[0]);
break;
case SO_SCALE: // 92, HE99+
args[0] = pop();
- if (_curSpriteId > _curMaxSpriteId)
+ if (_minSpriteNum > _maxSpriteNum)
break;
- spriteId = _curSpriteId;
+ spriteId = _minSpriteNum;
if (!spriteId)
spriteId++;
- for (; spriteId <= _curMaxSpriteId; spriteId++)
+ for (; spriteId <= _maxSpriteNum; spriteId++)
_sprite->setSpriteScale(spriteId, args[0]);
break;
case SO_ANIMATION_SPEED: // 97, HE98+
args[0] = pop();
- if (_curSpriteId > _curMaxSpriteId)
+ if (_minSpriteNum > _maxSpriteNum)
break;
- spriteId = _curSpriteId;
+ spriteId = _minSpriteNum;
if (!spriteId)
spriteId++;
- for (; spriteId <= _curMaxSpriteId; spriteId++)
+ for (; spriteId <= _maxSpriteNum; spriteId++)
_sprite->setSpriteAnimSpeed(spriteId, args[0]);
break;
case SO_SHADOW: // 98
args[0] = pop();
- if (_curSpriteId > _curMaxSpriteId)
+ if (_minSpriteNum > _maxSpriteNum)
break;
- spriteId = _curSpriteId;
+ spriteId = _minSpriteNum;
if (!spriteId)
spriteId++;
- for (; spriteId <= _curMaxSpriteId; spriteId++)
+ for (; spriteId <= _maxSpriteNum; spriteId++)
_sprite->setSpriteShadow(spriteId, args[0]);
break;
case SO_UPDATE: // 124
args[0] = pop();
- if (_curSpriteId > _curMaxSpriteId)
+ if (_minSpriteNum > _maxSpriteNum)
break;
- spriteId = _curSpriteId;
+ spriteId = _minSpriteNum;
if (!spriteId)
spriteId++;
- for (; spriteId <= _curMaxSpriteId; spriteId++)
- _sprite->setSpriteFlagUpdateType(spriteId, args[0]);
+ for (; spriteId <= _maxSpriteNum; spriteId++)
+ _sprite->setSpriteUpdateType(spriteId, args[0]);
break;
case SO_CLASS: // 125
n = getStackList(args, ARRAYSIZE(args));
- if (_curSpriteId != 0 && _curMaxSpriteId != 0 && n != 0) {
+ if (_minSpriteNum != 0 && _maxSpriteNum != 0 && n != 0) {
int *p = &args[n - 1];
do {
int code = *p;
if (code == 0) {
- for (int i = _curSpriteId; i <= _curMaxSpriteId; ++i) {
- _sprite->setSpriteResetClass(i);
+ for (int i = _minSpriteNum; i <= _maxSpriteNum; ++i) {
+ _sprite->clearSpriteClasses(i);
}
} else if (code & 0x80) {
- for (int i = _curSpriteId; i <= _curMaxSpriteId; ++i) {
- _sprite->setSpriteSetClass(i, code & 0x7F, 1);
+ for (int i = _minSpriteNum; i <= _maxSpriteNum; ++i) {
+ _sprite->setSpriteClass(i, code & 0x7F, 1);
}
} else {
- for (int i = _curSpriteId; i <= _curMaxSpriteId; ++i) {
- _sprite->setSpriteSetClass(i, code & 0x7F, 0);
+ for (int i = _minSpriteNum; i <= _maxSpriteNum; ++i) {
+ _sprite->setSpriteClass(i, code & 0x7F, 0);
}
}
--p;
@@ -989,50 +1007,50 @@ void ScummEngine_v90he::o90_setSpriteInfo() {
case SO_NEW_GENERAL_PROPERTY: // 139, HE99+
args[1] = pop();
args[0] = pop();
- if (_curSpriteId > _curMaxSpriteId)
+ if (_minSpriteNum > _maxSpriteNum)
break;
- spriteId = _curSpriteId;
+ spriteId = _minSpriteNum;
if (!spriteId)
spriteId++;
- for (; spriteId <= _curMaxSpriteId; spriteId++)
+ for (; spriteId <= _maxSpriteNum; spriteId++)
_sprite->setSpriteGeneralProperty(spriteId, args[0], args[1]);
break;
case SO_MASK: // 140, HE99+
args[0] = pop();
- if (_curSpriteId > _curMaxSpriteId)
+ if (_minSpriteNum > _maxSpriteNum)
break;
- spriteId = _curSpriteId;
+ spriteId = _minSpriteNum;
if (!spriteId)
spriteId++;
- for (; spriteId <= _curMaxSpriteId; spriteId++)
- _sprite->setSpriteMaskImage(spriteId, args[0]);
+ for (; spriteId <= _maxSpriteNum; spriteId++)
+ _sprite->setMaskImage(spriteId, args[0]);
break;
case SO_RESTART: // 158
- _sprite->resetTables(true);
+ _sprite->resetSpriteSystem(true);
break;
case SO_ACTOR_VARIABLE: // 198
args[1] = pop();
args[0] = pop();
- if (_curSpriteId > _curMaxSpriteId)
+ if (_minSpriteNum > _maxSpriteNum)
break;
- spriteId = _curSpriteId;
+ spriteId = _minSpriteNum;
if (!spriteId)
spriteId++;
- for (; spriteId <= _curMaxSpriteId; spriteId++)
- _sprite->setSpriteUserValue(spriteId, args[0], args[1]);
+ for (; spriteId <= _maxSpriteNum; spriteId++)
+ _sprite->setUserValue(spriteId, args[0], args[1]);
break;
case SO_NEW: // 217
- if (_curSpriteId > _curMaxSpriteId)
+ if (_minSpriteNum > _maxSpriteNum)
break;
- spriteId = _curSpriteId;
+ spriteId = _minSpriteNum;
if (!spriteId)
spriteId++;
- for (; spriteId <= _curMaxSpriteId; spriteId++)
- _sprite->resetSprite(spriteId);
+ for (; spriteId <= _maxSpriteNum; spriteId++)
+ _sprite->newSprite(spriteId);
break;
default:
error("o90_setSpriteInfo: Unknown case %d", subOp);
@@ -1056,7 +1074,7 @@ void ScummEngine_v90he::o90_getSpriteGroupInfo() {
case SO_XPOS: // 30
spriteGroupId = pop();
if (spriteGroupId) {
- _sprite->getGroupPosition(spriteGroupId, tx, ty);
+ _sprite->getGroupPoint(spriteGroupId, tx, ty);
push(tx);
} else {
push(0);
@@ -1065,7 +1083,7 @@ void ScummEngine_v90he::o90_getSpriteGroupInfo() {
case SO_YPOS: // 31
spriteGroupId = pop();
if (spriteGroupId) {
- _sprite->getGroupPosition(spriteGroupId, tx, ty);
+ _sprite->getGroupPoint(spriteGroupId, tx, ty);
push(ty);
} else {
push(0);
@@ -1105,7 +1123,7 @@ void ScummEngine_v90he::o90_getSpriteGroupInfo() {
case SO_IMAGE: // 63, HE99+
spriteGroupId = pop();
if (spriteGroupId)
- push(_sprite->getGroupDstResNum(spriteGroupId));
+ push(_sprite->getGroupImage(spriteGroupId));
else
push(0);
break;
@@ -1151,7 +1169,7 @@ void ScummEngine_v90he::o90_setSpriteGroupInfo() {
if (!_curSpriteGroupId)
break;
- _sprite->setGroupMembersGroup(_curSpriteGroupId, value1);
+ _sprite->changeGroupMembersGroup(_curSpriteGroupId, value1);
break;
case SPRGRPOP_UPDATE_TYPE: // 4
value1 = pop();
@@ -1164,7 +1182,7 @@ void ScummEngine_v90he::o90_setSpriteGroupInfo() {
if (!_curSpriteGroupId)
break;
- _sprite->setGroupMembersResetSprite(_curSpriteGroupId);
+ _sprite->performNewOnGroupMembers(_curSpriteGroupId);
break;
case SPRGRPOP_ANIMATION_SPEED: // 6
value1 = pop();
@@ -1245,7 +1263,7 @@ void ScummEngine_v90he::o90_setSpriteGroupInfo() {
if (!_curSpriteGroupId)
break;
- _sprite->setGroupPosition(_curSpriteGroupId, value1, value2);
+ _sprite->setGroupPoint(_curSpriteGroupId, value1, value2);
break;
case SO_CLIPPED: // 67
value4 = pop();
@@ -1255,19 +1273,19 @@ void ScummEngine_v90he::o90_setSpriteGroupInfo() {
if (!_curSpriteGroupId)
break;
- _sprite->setGroupBounds(_curSpriteGroupId, value1, value2, value3, value4);
+ _sprite->setGroupClipRect(_curSpriteGroupId, value1, value2, value3, value4);
break;
case SO_NEVER_ZCLIP: // 93
if (!_curSpriteGroupId)
break;
- _sprite->resetGroupBounds(_curSpriteGroupId);
+ _sprite->clearGroupClipRect(_curSpriteGroupId);
break;
case SO_NEW: // 217
if (!_curSpriteGroupId)
break;
- _sprite->resetGroup(_curSpriteGroupId);
+ _sprite->newGroup(_curSpriteGroupId);
break;
default:
error("o90_setSpriteGroupInfo: Unknown case %d", subOp);
@@ -1287,13 +1305,13 @@ void ScummEngine_v90he::o90_getWizData() {
case SO_XPOS: // 30
state = pop();
resId = pop();
- _wiz->getWizImageSpot(resId, state, x, y);
+ _wiz->getWizSpot(resId, state, x, y);
push(x);
break;
case SO_YPOS: // 31
state = pop();
resId = pop();
- _wiz->getWizImageSpot(resId, state, x, y);
+ _wiz->getWizSpot(resId, state, x, y);
push(y);
break;
case SO_WIDTH: // 32
@@ -1310,36 +1328,40 @@ void ScummEngine_v90he::o90_getWizData() {
break;
case SO_COUNT: // 36
resId = pop();
- push(_wiz->getWizImageStates(resId));
+ push(_wiz->getWizStateCount(resId));
break;
case SO_FIND: // 45
y = pop();
x = pop();
state = pop();
resId = pop();
- push(_wiz->isWizPixelNonTransparent(resId, state, x, y, 0));
+ push(_wiz->hitTestWiz(resId, state, x, y, 0));
break;
case SO_COLOR: // 66
y = pop();
x = pop();
state = pop();
resId = pop();
- push(_wiz->getWizPixelColor(resId, state, x, y));
+ push(_wiz->pixelHitTestWiz(resId, state, x, y, 0));
break;
case SO_HISTOGRAM: // 130
- h = pop();
- w = pop();
- y = pop();
- x = pop();
+ {
+ Common::Rect clipRect;
+ clipRect.bottom = pop();
+ clipRect.right = pop();
+ clipRect.top = pop();
+ clipRect.left = pop();
state = pop();
resId = pop();
- if (x == -1 && y == -1 && w == -1 && h == -1) {
+
+ if (clipRect.left == -1 && clipRect.top == -1 && clipRect.right == -1 && clipRect.bottom == -1) {
_wiz->getWizImageDim(resId, state, w, h);
- x = 0;
- y = 0;
+ _wiz->makeSizedRect(&clipRect, w, h);
}
- push(computeWizHistogram(resId, state, x, y, w, h));
+
+ push(_wiz->createHistogramArrayForImage(resId, state, &clipRect));
break;
+ }
case SO_NEW_GENERAL_PROPERTY: // 139
// TODO: Recheck, this looks different at least in HE99...
type = pop();
@@ -1687,8 +1709,8 @@ void ScummEngine_v90he::o90_getPolygonOverlap() {
case OVERLAP_SPRITE_TO_SPRITE: // 6
{
Common::Rect r1, r2;
- _sprite->getSpriteBounds(args2[0], false, r2);
- _sprite->getSpriteBounds(args1[0], false, r1);
+ _sprite->getSpriteLogicalRect(args2[0], false, r2);
+ _sprite->getSpriteLogicalRect(args1[0], false, r1);
if (r2.isValidRect() == false) {
push(0);
break;
@@ -1712,7 +1734,7 @@ void ScummEngine_v90he::o90_getPolygonOverlap() {
case OVERLAP_SPRITE_TO_RECT: // 7
{
Common::Rect r2;
- _sprite->getSpriteBounds(args2[0], false, r2);
+ _sprite->getSpriteLogicalRect(args2[0], false, r2);
Common::Rect r1(args1[0], args1[1], args1[2] + 1, args1[3] + 1);
if (r2.isValidRect() == false) {
push(0);
@@ -1733,8 +1755,8 @@ void ScummEngine_v90he::o90_getPolygonOverlap() {
// TODO: Draw sprites to buffer and compare.
{
Common::Rect r1, r2;
- _sprite->getSpriteBounds(args2[0], true, r2);
- _sprite->getSpriteBounds(args1[0], true, r1);
+ _sprite->getSpriteLogicalRect(args2[0], true, r2);
+ _sprite->getSpriteLogicalRect(args1[0], true, r1);
if (r2.isValidRect() == false) {
push(0);
break;
@@ -1758,7 +1780,7 @@ void ScummEngine_v90he::o90_getPolygonOverlap() {
case OVERLAP_DRAW_POS_SPRITE_TO_RECT: // 9
{
Common::Rect r2;
- _sprite->getSpriteBounds(args2[0], true, r2);
+ _sprite->getSpriteLogicalRect(args2[0], true, r2);
Common::Rect r1(args1[0], args1[1], args1[2] + 1, args1[3] + 1);
if (r2.isValidRect() == false) {
push(0);
@@ -2401,7 +2423,6 @@ void ScummEngine_v90he::o90_kernelSetFunctions() {
_wiz->_lWizClipRect.top = args[2];
_wiz->_lWizClipRect.right = args[3];
_wiz->_lWizClipRect.bottom = args[4];
- adjustRect(_wiz->_lWizClipRect);
break;
case 43:
_wiz->_lUseWizClipRect = false;
diff --git a/engines/scumm/he/sprite_he.cpp b/engines/scumm/he/sprite_he.cpp
index 0ec0cc74b91..68f9e3a086d 100644
--- a/engines/scumm/he/sprite_he.cpp
+++ b/engines/scumm/he/sprite_he.cpp
@@ -34,370 +34,397 @@ namespace Scumm {
Sprite::Sprite(ScummEngine_v90he *vm)
:
_vm(vm),
- _spriteGroups(0),
+ _groupTable(0),
_spriteTable(0),
- _activeSpritesTable(0),
- _numSpritesToProcess(0),
- _varNumSpriteGroups(0),
- _varNumSprites(0),
- _varMaxSprites(0) {
+ _activeSprites(0),
+ _activeSpriteCount(0),
+ _maxSpriteGroups(0),
+ _maxSprites(0),
+ _maxImageLists(0) {
}
Sprite::~Sprite() {
- free(_spriteGroups);
+ free(_groupTable);
free(_spriteTable);
- free(_activeSpritesTable);
+ free(_activeSprites);
}
void ScummEngine_v90he::allocateArrays() {
ScummEngine_v70he::allocateArrays();
- _sprite->allocTables(_numSprites, MAX(64, _numSprites / 4), 64);
+ _sprite->initializeStuff(_numSprites, MAX(64, _numSprites / 4), 64);
}
-void Sprite::getSpriteBounds(int spriteId, bool checkGroup, Common::Rect &bound) {
- assertRange(1, spriteId, _varNumSprites, "sprite");
- int32 spr_wiz_x, spr_wiz_y;
- int angle, scale, x1, y1;
- int32 w, h;
+void Sprite::getSpriteLogicalRect(int spriteId, bool checkGroup, Common::Rect &bound) {
+ assertRange(1, spriteId, _maxSprites, "sprite");
- SpriteInfo *spi = &_spriteTable[spriteId];
+ if (_vm->_game.heversion <= 98) {
+ int32 x, y, w, h;
+ Common::Point spot;
- _vm->_wiz->getWizImageSpot(spi->image, spi->state, spr_wiz_x, spr_wiz_y);
- if (checkGroup && spi->group) {
- SpriteGroup *spg = &_spriteGroups[spi->group];
+ int image = _spriteTable[spriteId].image;
+
+ if (image != 0) {
+ int state = _spriteTable[spriteId].state;
+ _vm->_wiz->getWizSpot(image, state, x, y);
+ _vm->_wiz->getWizImageDim(image, state, w, h);
+
+ spot.x = (int16)(_spriteTable[spriteId].posX - spot.x);
+ spot.y = (int16)(_spriteTable[spriteId].posY - spot.y);
+
+ bound.left = spot.x;
+ bound.top = spot.y;
+ bound.right = spot.x + (int16)w - 1,
+ bound.bottom = spot.y + (int16)h - 1;
- if (spg->scaling) {
- x1 = spi->posX * spg->scale_x_ratio_mul / spg->scale_x_ratio_div - spr_wiz_x + spg->tx;
- y1 = spi->posY * spg->scale_y_ratio_mul / spg->scale_y_ratio_div - spr_wiz_y + spg->ty;
- } else {
- x1 = spi->posX - spr_wiz_x + spg->tx;
- y1 = spi->posY - spr_wiz_y + spg->ty;
- }
- } else {
- x1 = spi->posX - spr_wiz_x;
- y1 = spi->posY - spr_wiz_y;
- }
-
- if (spi->image) {
- angle = spi->angle;
- scale = spi->scale;
- _vm->_wiz->getWizImageDim(spi->image, spi->state, w, h);
- if (spi->flags & (kSFScaleSpecified | kSFAngleSpecified)) {
- Common::Point pts[4];
- _vm->_wiz->polygonTransform(spi->image, spi->state, x1, y1, angle, scale, pts);
- _vm->_wiz->polyBuildBoundingRect(pts, 4, bound);
} else {
- bound.left = x1;
- bound.top = y1;
- bound.right = x1 + w;
- bound.bottom = y1 + h;
+ bound.left = 1234;
+ bound.top = 1234;
+ bound.right = -1234;
+ bound.bottom = -1234;
}
} else {
- bound.left = 1234;
- bound.top = 1234;
- bound.right = -1234;
- bound.bottom = -1234;
+ int32 x, y;
+ calcSpriteSpot(&_spriteTable[spriteId], false, x, y);
+
+ // Let's hope it doesn't overflow...
+ Common::Point spot((int16)x, (int16)y);
+
+ getSpriteRectPrim(&_spriteTable[spriteId], &bound, false, &spot);
}
}
//
// spriteInfoGet functions
//
-int Sprite::findSpriteWithClassOf(int x_pos, int y_pos, int spriteGroupId, int type, int num, int *args) {
- debug(7, "findSprite: x %d, y %d, spriteGroup %d, type %d, num %d", x_pos, y_pos, spriteGroupId, type, num);
- Common::Point pos[1];
- bool cond;
- int code, classId;
-
- for (int i = (_numSpritesToProcess - 1); i >= 0; i--) {
- SpriteInfo *spi = _activeSpritesTable[i];
- if (!spi->lastImage)
- continue;
+int Sprite::spriteFromPoint(int x, int y, int groupCheck, int quickCheck, int classCount, int *classCheckTable) {
+ SpriteInfo **spritePtr;
+ const Common::Rect *r;
+ int image;
- if (spriteGroupId && spi->group != spriteGroupId)
- continue;
+ if (!_activeSpriteCount)
+ return 0;
- cond = true;
- for (int j = 0; j < num; j++) {
- code = classId = args[j];
- classId &= 0x7F;
- assertRange(1, classId, 32, "class");
- if (code & 0x80) {
- if (!(spi->classFlags & (1 << (classId - 1))))
- cond = 0;
- } else {
- if ((spi->classFlags & (1 << (classId - 1))))
- cond = 0;
+ spritePtr = &_activeSprites [_activeSpriteCount - 1];
+
+ if (quickCheck != 0) {
+ for (int counter = 0; counter < _activeSpriteCount; counter++, spritePtr--) {
+ if (_vm->_game.heversion > 90 && groupCheck != 0) {
+ if (groupCheck != (*spritePtr)->group)
+ continue;
}
- }
- if (!cond)
- continue;
- if (type) {
- if (spi->lastRect.left > spi->lastRect.right)
- continue;
- if (spi->lastRect.top > spi->lastRect.bottom)
- continue;
- if (spi->lastRect.left > x_pos)
- continue;
- if (spi->lastRect.top > y_pos)
+ if (_vm->_game.heversion >= 99 && classCount != 0) {
+ if (!checkSpriteClassAgaintClassSet(((*spritePtr) - _spriteTable), classCount, classCheckTable)) {
+ continue;
+ }
+ }
+
+ r = &(*spritePtr)->lastRect;
+ image = (*spritePtr)->lastImage;
+ if ((!image) || (!_vm->_wiz->isRectValid(*r)))
continue;
- if (spi->lastRect.right < x_pos)
+
+ if ((r->left > x) || (r->top > y) || (r->right < x) || (r->bottom < y)) {
continue;
- if (spi->lastRect.bottom < y_pos)
+ }
+
+ return ((*spritePtr) - _spriteTable);
+ }
+ } else {
+ for (int counter = 0; counter < _activeSpriteCount; counter++, spritePtr--) {
+ r = &(*spritePtr)->lastRect;
+ image = (*spritePtr)->lastImage;
+
+ if ((!image))
continue;
- return spi->id;
- } else {
- int image, imageState, angle, scale;
- int32 w, h;
- image = spi->lastImage;
- if (spi->maskImage) {
- int32 x1, x2, y1, y2;
+ if (_vm->_game.heversion > 90 && groupCheck) {
+ if (groupCheck != (*spritePtr)->group)
+ continue;
+ }
+
+ if (_vm->_game.heversion >= 99 && classCount) {
+ if (!checkSpriteClassAgaintClassSet(((*spritePtr) - _spriteTable), classCount, classCheckTable)) {
+ continue;
+ }
+ }
- image = spi->maskImage;
- imageState = spi->lastState % _vm->_wiz->getWizImageStates(spi->maskImage);
+ if (_vm->_game.heversion > 99) {
+ int state = 0;
+ int32 testPointX, testPointY;
+ if ((*spritePtr)->maskImage) {
+ int32 maskSpotX, maskSpotY, imageSpotX, imageSpotY;
+ int maskStateCount;
- pos[0].x = x_pos - spi->lastSpot.x;
- pos[0].y = y_pos - spi->lastSpot.y;
+ // Change to using the the mask image instead of the display image
+ image = (*spritePtr)->maskImage;
- _vm->_wiz->getWizImageSpot(spi->lastImage, imageState, x1, y1);
- _vm->_wiz->getWizImageSpot(spi->maskImage, imageState, x2, y2);
+ // Get the state for the mask (wrap if necessary)
+ maskStateCount = _vm->_wiz->getWizStateCount(image);
+ state = ((*spritePtr)->lastState % maskStateCount);
- pos[0].x += (x2 - x1);
- pos[0].y += (y2 - y1);
- } else {
- if (spi->lastRect.left > spi->lastRect.right)
- continue;
- if (spi->lastRect.top > spi->lastRect.bottom)
- continue;
- if (spi->lastRect.left > x_pos)
- continue;
- if (spi->lastRect.top > y_pos)
+ // Convert the coords to "image" relative coords.
+ testPointX = (x - (*spritePtr)->lastSpot.x);
+ testPointY = (y - (*spritePtr)->lastSpot.y);
+
+ // Get the spot's so we can adjust the "lastSpot" to
+ // be relative to the mask's link point...
+ _vm->_wiz->getWizSpot((*spritePtr)->lastImage, state, imageSpotX, imageSpotY);
+ _vm->_wiz->getWizSpot(image, state, maskSpotX, maskSpotY);
+
+ // Convert the coords to "Mask" relative coords.
+ testPointX += (maskSpotX - imageSpotX);
+ testPointY += (maskSpotY - imageSpotY);
+ } else {
+ r = &(*spritePtr)->lastRect;
+
+ if (!_vm->_wiz->isRectValid(*r) || (r->left > x) || (r->top > y) || (r->right < x) || (r->bottom < y)) {
+ continue;
+ }
+
+ // Convert the coords to image relative coords.
+ testPointX = (x - (*spritePtr)->lastSpot.x);
+ testPointY = (y - (*spritePtr)->lastSpot.y);
+
+ // Get the last active image state
+ state = (*spritePtr)->lastState;
+ }
+
+ if (!_vm->_wiz->hitTestWiz(image, state, testPointX, testPointY, (*spritePtr)->lastRenderFlags)) {
continue;
- if (spi->lastRect.right < x_pos)
+ }
+
+ return ((*spritePtr) - _spriteTable);
+ } else {
+ if (!_vm->_wiz->isRectValid(*r))
continue;
- if (spi->lastRect.bottom < y_pos)
+
+ if ((r->left > x) || (r->top > y) || (r->right < x) || (r->bottom < y))
continue;
- pos[0].x = x_pos - spi->lastSpot.x;
- pos[0].y = y_pos - spi->lastSpot.y;
- imageState = spi->lastState;
- }
+ int32 state = _vm->_game.heversion > 80 ? (*spritePtr)->lastState : 0; // HE80 doesn't have states
- angle = spi->lastAngle;
- scale = spi->lastScale;
- if ((spi->flags & kSFScaleSpecified) || (spi->flags & kSFAngleSpecified)) {
- if (spi->flags & kSFScaleSpecified && scale) {
- pos[0].x = pos[0].x * 256 / scale;
- pos[0].y = pos[0].y * 256 / scale;
- }
- if (spi->flags & kSFAngleSpecified && angle) {
- angle = (360 - angle) % 360;
- _vm->_wiz->polyRotatePoints(pos, 1, angle);
+ if (!_vm->_wiz->hitTestWiz(image, state, (x - (*spritePtr)->lastSpot.x), (y - (*spritePtr)->lastSpot.y), 0)) {
+ continue;
}
- _vm->_wiz->getWizImageDim(image, imageState, w, h);
- pos[0].x += w / 2;
- pos[0].y += h / 2;
+ return ((*spritePtr) - _spriteTable);
}
-
- if (_vm->_wiz->isWizPixelNonTransparent(image, imageState, pos[0].x, pos[0].y, spi->lastRenderFlags))
- return spi->id;
}
}
return 0;
}
-int Sprite::getSpriteClass(int spriteId, int num, int *args) {
- assertRange(1, spriteId, _varNumSprites, "sprite");
- int code, classId;
+int Sprite::getSpriteClass(int spriteId, int classId) {
+ assertRange(1, spriteId, _maxSprites, "sprite");
- if (num == 0)
+ if (classId == -1) {
return _spriteTable[spriteId].classFlags;
+ } else {
+ assertRange(1, classId, 32, "sprite");
+ return _spriteTable[spriteId].classFlags & (1 << (classId - 1));
+ }
+}
- for (int i = 0; i < num; i++) {
- code = classId = args[i];
- classId &= 0x7F;
- assertRange(1, classId, 32, "class");
- if (code & 0x80) {
- if (!(_spriteTable[spriteId].classFlags & (1 << (classId - 1))))
- return 0;
- } else {
- if ((_spriteTable[spriteId].classFlags & (1 << (classId - 1))))
- return 0;
- }
+int Sprite::checkSpriteClassAgaintClassSet(int sprite, int classCount, int *classCheckTable) {
+ int classId, classBit;
+
+ while (classCount--) {
+ classId = classCheckTable[classCount];
+ classBit = getSpriteClass(sprite, (classId & 0x7f));
+
+ if (((classId & 0x80) == 0x80) && (classBit == 0))
+ return 0;
+
+ if (((classId & 0x80) == 0x00) && (classBit != 0))
+ return 0;
}
return 1;
}
-int Sprite::getSpriteFlagDoubleBuffered(int spriteId) {
- assertRange(1, spriteId, _varNumSprites, "sprite");
+int Sprite::getSpriteRenderToBackground(int spriteId) {
+ assertRange(1, spriteId, _maxSprites, "sprite");
return ((_spriteTable[spriteId].flags & kSFBackgroundRender) != 0) ? 1 : 0;
}
-int Sprite::getSpriteFlagYFlipped(int spriteId) {
- assertRange(1, spriteId, _varNumSprites, "sprite");
+int Sprite::getSpriteVertFlip(int spriteId) {
+ assertRange(1, spriteId, _maxSprites, "sprite");
return ((_spriteTable[spriteId].flags & kSFVFlip) != 0) ? 1 : 0;
}
-int Sprite::getSpriteFlagXFlipped(int spriteId) {
- assertRange(1, spriteId, _varNumSprites, "sprite");
+int Sprite::getSpriteHorzFlip(int spriteId) {
+ assertRange(1, spriteId, _maxSprites, "sprite");
return ((_spriteTable[spriteId].flags & kSFHFlip) != 0) ? 1 : 0;
}
-int Sprite::getSpriteFlagActive(int spriteId) {
- assertRange(1, spriteId, _varNumSprites, "sprite");
+int Sprite::getSpriteActiveFlag(int spriteId) {
+ assertRange(1, spriteId, _maxSprites, "sprite");
return ((_spriteTable[spriteId].flags & kSFActive) != 0) ? 1 : 0;
}
-int Sprite::getSpriteFlagRemapPalette(int spriteId) {
- assertRange(1, spriteId, _varNumSprites, "sprite");
+int Sprite::getSpriteImageRemapFlag(int spriteId) {
+ assertRange(1, spriteId, _maxSprites, "sprite");
return ((_spriteTable[spriteId].flags & kSFUseImageRemap) != 0) ? 1 : 0;
}
-int Sprite::getSpriteFlagAutoAnim(int spriteId) {
- assertRange(1, spriteId, _varNumSprites, "sprite");
-
- // WORKAROUND: Two scripts (room 2 script 2070/2071) compare against
- // a return value of one, but the original game returned the flag value
- // (0x200000) for true. These scripts bugs caused problems (infinite loop
- // and beans not appearing) in the Jumping Beans mini games under ScummVM.
- if (_vm->_game.id == GID_PJGAMES)
- return 0;
+int Sprite::getSpriteAutoAnimFlag(int spriteId) {
+ assertRange(1, spriteId, _maxSprites, "sprite");
- return ((_spriteTable[spriteId].flags & kSFAutoAnimate) != 0) ? 1 : 0;
+ return (_spriteTable[spriteId].flags & kSFAutoAnimate);
}
-int Sprite::getSpriteFlagUpdateType(int spriteId) {
- assertRange(1, spriteId, _varNumSprites, "sprite");
+int Sprite::getSpriteUpdateType(int spriteId) {
+ assertRange(1, spriteId, _maxSprites, "sprite");
+ if (_vm->_game.heversion > 99) {
+ if (_spriteTable[spriteId].flags & kSFSmartRender) {
+ return SPRDEF_SMART;
+ } else {
+ return (_spriteTable[spriteId].flags & kSFDontCombineErase) ? SPRDEF_SIMPLE : SPRDEF_DUMB;
+ }
+ } else {
+ return ((_spriteTable[spriteId].flags & kSFSmartRender) != 0) ? 1 : 0;
+ }
- return ((_spriteTable[spriteId].flags & kSFSmartRender) != 0) ? 1 : 0;
}
-int Sprite::getSpriteFlagEraseType(int spriteId) {
- assertRange(1, spriteId, _varNumSprites, "sprite");
+int Sprite::getSpriteEraseType(int spriteId) {
+ assertRange(1, spriteId, _maxSprites, "sprite");
- return ((_spriteTable[spriteId].flags & kSFIgnoreErase) != 0) ? 1 : 0;
+ return ((_spriteTable[spriteId].flags & kSFIgnoreErase) != 0) ? 0 : 1;
}
int Sprite::getSpriteImage(int spriteId) {
- assertRange(1, spriteId, _varNumSprites, "sprite");
+ assertRange(1, spriteId, _maxSprites, "sprite");
return _spriteTable[spriteId].image;
}
int Sprite::getSpriteImageState(int spriteId) {
- assertRange(1, spriteId, _varNumSprites, "sprite");
+ assertRange(1, spriteId, _maxSprites, "sprite");
return _spriteTable[spriteId].state;
}
int Sprite::getSpriteGroup(int spriteId) {
- assertRange(1, spriteId, _varNumSprites, "sprite");
+ assertRange(1, spriteId, _maxSprites, "sprite");
return _spriteTable[spriteId].group;
}
int Sprite::getSpritePalette(int spriteId) {
- assertRange(1, spriteId, _varNumSprites, "sprite");
+ assertRange(1, spriteId, _maxSprites, "sprite");
return _spriteTable[spriteId].palette;
}
int Sprite::getSpritePriority(int spriteId) {
- assertRange(1, spriteId, _varNumSprites, "sprite");
+ assertRange(1, spriteId, _maxSprites, "sprite");
return _spriteTable[spriteId].priority;
}
int Sprite::getSpriteDisplayX(int spriteId) {
- assertRange(1, spriteId, _varNumSprites, "sprite");
+ assertRange(1, spriteId, _maxSprites, "sprite");
if (_spriteTable[spriteId].group)
- return _spriteTable[spriteId].posX + _spriteGroups[_spriteTable[spriteId].group].tx;
+ return _spriteTable[spriteId].posX + _groupTable[_spriteTable[spriteId].group].posX;
else
return _spriteTable[spriteId].posX;
}
int Sprite::getSpriteDisplayY(int spriteId) {
- assertRange(1, spriteId, _varNumSprites, "sprite");
+ assertRange(1, spriteId, _maxSprites, "sprite");
if (_spriteTable[spriteId].group)
- return _spriteTable[spriteId].posY + _spriteGroups[_spriteTable[spriteId].group].ty;
+ return _spriteTable[spriteId].posY + _groupTable[_spriteTable[spriteId].group].posY;
else
return _spriteTable[spriteId].posY;
}
-int Sprite::getSpriteUserValue(int spriteId) {
- assertRange(1, spriteId, _varNumSprites, "sprite");
+int Sprite::getUserValue(int spriteId) {
+ assertRange(1, spriteId, _maxSprites, "sprite");
return _spriteTable[spriteId].userValue;
}
int Sprite::getSpriteShadow(int spriteId) {
- assertRange(1, spriteId, _varNumSprites, "sprite");
+ assertRange(1, spriteId, _maxSprites, "sprite");
return _spriteTable[spriteId].shadow;
}
int Sprite::getSpriteImageStateCount(int spriteId) {
- assertRange(1, spriteId, _varNumSprites, "sprite");
+ assertRange(1, spriteId, _maxSprites, "sprite");
return _spriteTable[spriteId].maxStates;
}
int Sprite::getSpriteScale(int spriteId) {
- assertRange(1, spriteId, _varNumSprites, "sprite");
+ assertRange(1, spriteId, _maxSprites, "sprite");
return _spriteTable[spriteId].scale;
}
int Sprite::getSpriteAnimSpeed(int spriteId) {
- assertRange(1, spriteId, _varNumSprites, "sprite");
+ assertRange(1, spriteId, _maxSprites, "sprite");
return _spriteTable[spriteId].animSpeed;
}
-int Sprite::getSpriteSourceImage(int spriteId) {
- assertRange(1, spriteId, _varNumSprites, "sprite");
+int Sprite::getSourceImage(int spriteId) {
+ assertRange(1, spriteId, _maxSprites, "sprite");
return _spriteTable[spriteId].sourceImage;
}
-int Sprite::getSpriteMaskImage(int spriteId) {
- assertRange(1, spriteId, _varNumSprites, "sprite");
+int Sprite::getMaskImage(int spriteId) {
+ assertRange(1, spriteId, _maxSprites, "sprite");
return _spriteTable[spriteId].maskImage;
}
int Sprite::getSpriteGeneralProperty(int spriteId, int type) {
debug(7, "getSpriteGeneralProperty: spriteId %d type 0x%x", spriteId, type);
- assertRange(1, spriteId, _varNumSprites, "sprite");
+ assertRange(1, spriteId, _maxSprites, "sprite");
- // XXX U32 related check
+ // TODO U32
switch (type) {
- case 0x7B:
+ case SPRPROP_SPECIAL_RENDER_FLAGS:
return _spriteTable[spriteId].specialRenderFlags;
- case 0x7D:
+ case SPRPROP_CONDITION_BITS:
return _spriteTable[spriteId].conditionBits;
- case 0x7E:
- return _spriteTable[spriteId].animState;
+ case SPRPROP_ANIMATION_SUB_STATE:
+ return getSpriteAnimSpeedState(spriteId);
default:
error("getSpriteGeneralProperty: Invalid type %d", type);
}
}
+int Sprite::getDestImageForSprite(const SpriteInfo *spritePtr) {
+ if (spritePtr->image) {
+ if (spritePtr->group) {
+ return _groupTable[spritePtr->group].image;
+ }
+ }
+
+ return 0;
+}
+
+int Sprite::getSpriteAnimSpeedState(int spriteId) {
+ assertRange(1, spriteId, _maxSprites, "sprite");
+ return _spriteTable[spriteId].animState;
+}
+
void Sprite::getSpriteImageDim(int spriteId, int32 &w, int32 &h) {
- assertRange(1, spriteId, _varNumSprites, "sprite");
+ assertRange(1, spriteId, _maxSprites, "sprite");
if (_spriteTable[spriteId].image) {
_vm->_wiz->getWizImageDim(_spriteTable[spriteId].image, _spriteTable[spriteId].state, w, h);
@@ -408,28 +435,159 @@ void Sprite::getSpriteImageDim(int spriteId, int32 &w, int32 &h) {
}
void Sprite::getSpritePosition(int spriteId, int32 &tx, int32 &ty) {
- assertRange(1, spriteId, _varNumSprites, "sprite");
+ assertRange(1, spriteId, _maxSprites, "sprite");
tx = _spriteTable[spriteId].posX;
ty = _spriteTable[spriteId].posY;
}
-void Sprite::getSpriteDist(int spriteId, int32 &dx, int32 &dy) {
- assertRange(1, spriteId, _varNumSprites, "sprite");
+void Sprite::getSpriteRectPrim(const SpriteInfo *spritePtr, Common::Rect *rectPtr, bool includeGroupTransform, const Common::Point *spotPtr) {
+ bool angleSpecified, scaleSpecified;
+ int state, scale, angle;
+ int32 x, y;
+ int image = spritePtr->image;
+
+ if (image != 0) {
+ Common::Point tmpPt(spotPtr->x, spotPtr->y);
+
+ if (_vm->_game.heversion < 100) {
+ calcSpriteSpot(spritePtr, includeGroupTransform, x, y);
+ tmpPt.x = x;
+ tmpPt.y = y;
+ }
+
+ state = spritePtr->state;
+ angle = spritePtr->angle;
+ scale = spritePtr->scale;
+
+ scaleSpecified = (kSFScaleSpecified & spritePtr->flags);
+ angleSpecified = (kSFAngleSpecified & spritePtr->flags);
+
+ if (angleSpecified || scaleSpecified) {
+ Common::Point listOfPoints[4];
+ int w, h;
+
+ _vm->_wiz->getWizImageDim(image, state, w, h);
+
+ listOfPoints[0].x = -w / 2;
+ listOfPoints[0].y = -h / 2;
+
+ listOfPoints[1].x = listOfPoints[0].x + w - 1;
+ listOfPoints[1].y = listOfPoints[0].y;
+
+ listOfPoints[2].x = listOfPoints[1].x;
+ listOfPoints[2].y = listOfPoints[0].y + h - 1;
+
+ listOfPoints[3].x = listOfPoints[0].x;
+ listOfPoints[3].y = listOfPoints[2].y;
+
+ if (scaleSpecified) {
+ for (int i = 0; i < 4; i++) {
+ listOfPoints[i].x = (scale * listOfPoints[i].x) / 256;
+ listOfPoints[i].y = (scale * listOfPoints[i].y) / 256;
+ }
+ }
+
+ // Rotate the points
+ if (angleSpecified) {
+ _vm->_wiz->polyRotatePoints(listOfPoints, 4, angle);
+ }
+
+ // Offset the points
+ _vm->_wiz->polyMovePolygonPoints(listOfPoints, 4, tmpPt.x, tmpPt.y);
+
+ // Finally get down the point and get the bounding rect of this
+ _vm->_wiz->polyBuildBoundingRect(listOfPoints, 4, *rectPtr);
+
+ } else {
+ int w, h;
+ _vm->_wiz->getWizImageDim(image, state, w, h);
+
+ rectPtr->left = tmpPt.x;
+ rectPtr->top = tmpPt.y;
+ rectPtr->right = tmpPt.x + w - 1;
+ rectPtr->bottom = tmpPt.y + h - 1;
+ }
+
+ } else {
+ rectPtr->left = 1234;
+ rectPtr->top = 1234;
+ rectPtr->right = -1234;
+ rectPtr->bottom = -1234;
+ }
+}
+
+void Sprite::getDelta(int spriteId, int32 &dx, int32 &dy) {
+ assertRange(1, spriteId, _maxSprites, "sprite");
dx = _spriteTable[spriteId].deltaPosX;
dy = _spriteTable[spriteId].deltaPosY;
}
+void Sprite::calcSpriteSpot(const SpriteInfo *spritePtr, bool includeGroupTransform, int32 &x, int32 &y) {
+ if (_vm->_game.heversion <= 90) {
+ if (_vm->_game.heversion == 80) {
+ _vm->_wiz->getWizSpot(spritePtr->image, x, y);
+ } else {
+ _vm->_wiz->getWizSpot(spritePtr->image, spritePtr->state, x, y);
+ }
+
+ x = spritePtr->posX - x;
+ y = spritePtr->posY - y;
+
+ if (spritePtr->group != 0) {
+ x += _groupTable[spritePtr->group].posX;
+ y += _groupTable[spritePtr->group].posY;
+ }
+
+ } else if (_vm->_game.heversion >= 98) {
+ if (_vm->_game.heversion >= 100) {
+ if (spritePtr->image == 0) {
+ if (includeGroupTransform && spritePtr->group) {
+ x = _groupTable[spritePtr->group].posX;
+ y = _groupTable[spritePtr->group].posY;
+ } else {
+ x = 0;
+ y = 0;
+ }
+
+ return;
+ }
+ }
+
+ _vm->_wiz->getWizSpot(spritePtr->image, spritePtr->state, x, y);
+
+ int group = spritePtr->group;
+
+ if ((includeGroupTransform || _vm->_game.heversion == 98) && group != 0) {
+ if (_groupTable[group].isScaled) {
+ x = (int)((float)spritePtr->posX * _groupTable[group].xScale) - x;
+ y = (int)((float)spritePtr->posY * _groupTable[group].yScale) - y;
+
+ x += _groupTable[group].posX;
+ y += _groupTable[group].posY;
+ } else {
+ x = spritePtr->posX - x;
+ y = spritePtr->posY - y;
+ x += _groupTable[group].posX;
+ y += _groupTable[group].posY;
+ }
+ } else {
+ x = spritePtr->posX - x;
+ y = spritePtr->posY - y;
+ }
+ }
+}
+
//
// spriteGroupGet functions
//
int ScummEngine_v90he::getGroupSpriteArray(int spriteGroupId) {
int i, numSprites = 0;
- assertRange(1, spriteGroupId, _sprite->_varNumSpriteGroups, "sprite group");
+ assertRange(1, spriteGroupId, _sprite->_maxSpriteGroups, "sprite group");
- for (i = (_sprite->_varNumSprites - 1); i > 0; i--) {
+ for (i = (_sprite->_maxSprites - 1); i > 0; i--) {
if (_sprite->_spriteTable[i].group == spriteGroupId)
numSprites++;
}
@@ -442,7 +600,7 @@ int ScummEngine_v90he::getGroupSpriteArray(int spriteGroupId) {
writeArray(0, 0, 0, numSprites);
numSprites = 1;
- for (i = (_sprite->_varNumSprites - 1); i > 0; i--) {
+ for (i = (_sprite->_maxSprites - 1); i > 0; i--) {
if (_sprite->_spriteTable[i].group == spriteGroupId) {
writeArray(0, 0, numSprites, i);
numSprites++;
@@ -453,53 +611,53 @@ int ScummEngine_v90he::getGroupSpriteArray(int spriteGroupId) {
}
int Sprite::getGroupPriority(int spriteGroupId) {
- assertRange(1, spriteGroupId, _varNumSpriteGroups, "sprite group");
+ assertRange(1, spriteGroupId, _maxSpriteGroups, "sprite group");
- return _spriteGroups[spriteGroupId].priority;
+ return _groupTable[spriteGroupId].priority;
}
-int Sprite::getGroupDstResNum(int spriteGroupId) {
- assertRange(1, spriteGroupId, _varNumSpriteGroups, "sprite group");
+int Sprite::getGroupImage(int spriteGroupId) {
+ assertRange(1, spriteGroupId, _maxSpriteGroups, "sprite group");
- return _spriteGroups[spriteGroupId].image;
+ return _groupTable[spriteGroupId].image;
}
int Sprite::getGroupXMul(int spriteGroupId) {
- assertRange(1, spriteGroupId, _varNumSpriteGroups, "sprite group");
+ assertRange(1, spriteGroupId, _maxSpriteGroups, "sprite group");
- return _spriteGroups[spriteGroupId].scale_x_ratio_mul;
+ return _groupTable[spriteGroupId].xMul;
}
int Sprite::getGroupXDiv(int spriteGroupId) {
- assertRange(1, spriteGroupId, _varNumSpriteGroups, "sprite group");
+ assertRange(1, spriteGroupId, _maxSpriteGroups, "sprite group");
- return _spriteGroups[spriteGroupId].scale_x_ratio_div;
+ return _groupTable[spriteGroupId].xDiv;
}
int Sprite::getGroupYMul(int spriteGroupId) {
- assertRange(1, spriteGroupId, _varNumSpriteGroups, "sprite group");
+ assertRange(1, spriteGroupId, _maxSpriteGroups, "sprite group");
- return _spriteGroups[spriteGroupId].scale_y_ratio_mul;
+ return _groupTable[spriteGroupId].yMul;
}
int Sprite::getGroupYDiv(int spriteGroupId) {
- assertRange(1, spriteGroupId, _varNumSpriteGroups, "sprite group");
+ assertRange(1, spriteGroupId, _maxSpriteGroups, "sprite group");
- return _spriteGroups[spriteGroupId].scale_y_ratio_div;
+ return _groupTable[spriteGroupId].yDiv;
}
-void Sprite::getGroupPosition(int spriteGroupId, int32 &tx, int32 &ty) {
- assertRange(1, spriteGroupId, _varNumSpriteGroups, "sprite group");
+void Sprite::getGroupPoint(int spriteGroupId, int32 &tx, int32 &ty) {
+ assertRange(1, spriteGroupId, _maxSpriteGroups, "sprite group");
- tx = _spriteGroups[spriteGroupId].tx;
- ty = _spriteGroups[spriteGroupId].ty;
+ tx = _groupTable[spriteGroupId].posX;
+ ty = _groupTable[spriteGroupId].posY;
}
//
// spriteInfoSet functions
//
void Sprite::setSpritePalette(int spriteId, int value) {
- assertRange(1, spriteId, _varNumSprites, "sprite");
+ assertRange(1, spriteId, _maxSprites, "sprite");
if (_spriteTable[spriteId].palette != value) {
_spriteTable[spriteId].palette = value;
@@ -507,8 +665,8 @@ void Sprite::setSpritePalette(int spriteId, int value) {
}
}
-void Sprite::setSpriteSourceImage(int spriteId, int value) {
- assertRange(1, spriteId, _varNumSprites, "sprite");
+void Sprite::setSourceImage(int spriteId, int value) {
+ assertRange(1, spriteId, _maxSprites, "sprite");
if (_spriteTable[spriteId].sourceImage != value) {
_spriteTable[spriteId].sourceImage = value;
@@ -516,19 +674,18 @@ void Sprite::setSpriteSourceImage(int spriteId, int value) {
}
}
-void Sprite::setSpriteMaskImage(int spriteId, int value) {
- assertRange(1, spriteId, _varNumSprites, "sprite");
+void Sprite::setMaskImage(int spriteId, int value) {
+ assertRange(1, spriteId, _maxSprites, "sprite");
_spriteTable[spriteId].maskImage = value;
}
void Sprite::setSpriteImageState(int spriteId, int state) {
- assertRange(1, spriteId, _varNumSprites, "sprite");
+ assertRange(1, spriteId, _maxSprites, "sprite");
if (_spriteTable[spriteId].image) {
int imageStateCount = _spriteTable[spriteId].maxStates - 1;
- state = MAX(0, state);
- state = MIN(state, imageStateCount);
+ state = MAX(0, MIN(state, imageStateCount));
if (_spriteTable[spriteId].state != state) {
_spriteTable[spriteId].state = state;
@@ -538,194 +695,220 @@ void Sprite::setSpriteImageState(int spriteId, int state) {
}
void Sprite::setSpritePosition(int spriteId, int tx, int ty) {
- assertRange(1, spriteId, _varNumSprites, "sprite");
+ assertRange(1, spriteId, _maxSprites, "sprite");
+
+ int32 oldX, oldY;
+ oldX = _spriteTable[spriteId].posX;
+ oldY = _spriteTable[spriteId].posY;
- if (_spriteTable[spriteId].posX != tx || _spriteTable[spriteId].posY != ty) {
- _spriteTable[spriteId].posX = tx;
- _spriteTable[spriteId].posY = ty;
+ _spriteTable[spriteId].posX = tx;
+ _spriteTable[spriteId].posY = ty;
+
+ if (oldX != tx || oldY != ty) {
_spriteTable[spriteId].flags |= kSFErase | kSFRender;
}
}
-void Sprite::setSpriteGroup(int spriteId, int value) {
- assertRange(1, spriteId, _varNumSprites, "sprite");
- assertRange(0, value, _varNumSpriteGroups, "sprite group");
+void Sprite::setSpriteGroup(int spriteId, int group) {
+ assertRange(1, spriteId, _maxSprites, "sprite");
+
+ if (group != 0)
+ assertRange(1, group, _maxSpriteGroups, "sprite group");
- _spriteTable[spriteId].group = value;
+ _spriteTable[spriteId].group = group;
_spriteTable[spriteId].flags |= kSFErase | kSFRender;
}
-void Sprite::setSpriteDist(int spriteId, int value1, int value2) {
- assertRange(1, spriteId, _varNumSprites, "sprite");
+void Sprite::setDelta(int spriteId, int dx, int dy) {
+ assertRange(1, spriteId, _maxSprites, "sprite");
- _spriteTable[spriteId].deltaPosX = value1;
- _spriteTable[spriteId].deltaPosY = value2;
+ _spriteTable[spriteId].deltaPosX = dx;
+ _spriteTable[spriteId].deltaPosY = dy;
}
-void Sprite::setSpriteShadow(int spriteId, int value) {
- assertRange(1, spriteId, _varNumSprites, "sprite");
+void Sprite::setSpriteShadow(int spriteId, int shadow) {
+ assertRange(1, spriteId, _maxSprites, "sprite");
- _spriteTable[spriteId].shadow = value;
+ _spriteTable[spriteId].shadow = shadow;
if (_spriteTable[spriteId].image)
_spriteTable[spriteId].flags |= kSFErase | kSFRender;
}
-void Sprite::setSpriteUserValue(int spriteId, int value1, int value2) {
- assertRange(1, spriteId, _varNumSprites, "sprite");
+void Sprite::setUserValue(int spriteId, int value1, int value2) {
+ assertRange(1, spriteId, _maxSprites, "sprite");
_spriteTable[spriteId].userValue = value2;
}
-void Sprite::setSpritePriority(int spriteId, int value) {
- assertRange(1, spriteId, _varNumSprites, "sprite");
+void Sprite::setSpritePriority(int spriteId, int priority) {
+ assertRange(1, spriteId, _maxSprites, "sprite");
- _spriteTable[spriteId].priority = value;
+ _spriteTable[spriteId].priority = priority;
}
-void Sprite::moveSprite(int spriteId, int value1, int value2) {
- assertRange(1, spriteId, _varNumSprites, "sprite");
+void Sprite::moveSprite(int spriteId, int dx, int dy) {
+ assertRange(1, spriteId, _maxSprites, "sprite");
- _spriteTable[spriteId].posX += value1;
- _spriteTable[spriteId].posY += value2;
+ int32 oldX, oldY;
+ oldX = _spriteTable[spriteId].posX;
+ oldY = _spriteTable[spriteId].posY;
- if (value1 || value2)
- _spriteTable[spriteId].flags |= kSFErase | kSFRender;
+ _spriteTable[spriteId].posX += dx;
+ _spriteTable[spriteId].posY += dy;
+
+ if ((oldX != _spriteTable[spriteId].posX) || (oldY != _spriteTable[spriteId].posY))
+ _spriteTable[spriteId].flags |= (kSFErase | kSFRender);
}
-void Sprite::setSpriteScale(int spriteId, int value) {
- assertRange(1, spriteId, _varNumSprites, "sprite");
+void Sprite::setSpriteScale(int spriteId, int scale) {
+ assertRange(1, spriteId, _maxSprites, "sprite");
_spriteTable[spriteId].flags |= kSFScaleSpecified;
- if (_spriteTable[spriteId].scale != value) {
- _spriteTable[spriteId].scale = value;
+ if (_spriteTable[spriteId].scale != scale) {
+ _spriteTable[spriteId].scale = scale;
if (_spriteTable[spriteId].image)
- _spriteTable[spriteId].flags |= kSFErase | kSFRender;
+ _spriteTable[spriteId].flags |= (kSFErase | kSFRender);
}
}
-void Sprite::setSpriteAngle(int spriteId, int value) {
- assertRange(1, spriteId, _varNumSprites, "sprite");
+void Sprite::setSpriteAngle(int spriteId, int angle) {
+ assertRange(1, spriteId, _maxSprites, "sprite");
_spriteTable[spriteId].flags |= kSFAngleSpecified;
- if (_spriteTable[spriteId].angle != value) {
- _spriteTable[spriteId].angle = value;
+ if (_spriteTable[spriteId].angle != angle) {
+ _spriteTable[spriteId].angle = angle;
if (_spriteTable[spriteId].image)
- _spriteTable[spriteId].flags |= kSFErase | kSFRender;
+ _spriteTable[spriteId].flags |= (kSFErase | kSFRender);
}
}
-void Sprite::setSpriteFlagDoubleBuffered(int spriteId, int value) {
- assertRange(1, spriteId, _varNumSprites, "sprite");
+void Sprite::setSpriteRenderToBackground(int spriteId, int value) {
+ assertRange(1, spriteId, _maxSprites, "sprite");
int oldFlags = _spriteTable[spriteId].flags;
- if (value)
+ if (value) {
_spriteTable[spriteId].flags |= kSFBackgroundRender;
- else
+ } else {
_spriteTable[spriteId].flags &= ~kSFBackgroundRender;
+ }
if (_spriteTable[spriteId].image && _spriteTable[spriteId].flags != oldFlags)
_spriteTable[spriteId].flags |= kSFErase | kSFRender;
}
-void Sprite::setSpriteFlagYFlipped(int spriteId, int value) {
- assertRange(1, spriteId, _varNumSprites, "sprite");
+void Sprite::setSpriteVertFlip(int spriteId, int flip) {
+ assertRange(1, spriteId, _maxSprites, "sprite");
int oldFlags = _spriteTable[spriteId].flags;
- if (value)
+ if (flip) {
_spriteTable[spriteId].flags |= kSFVFlip;
- else
+ } else {
_spriteTable[spriteId].flags &= ~kSFVFlip;
+ }
if (_spriteTable[spriteId].image && _spriteTable[spriteId].flags != oldFlags)
_spriteTable[spriteId].flags |= kSFErase | kSFRender;
}
-void Sprite::setSpriteFlagXFlipped(int spriteId, int value) {
- assertRange(1, spriteId, _varNumSprites, "sprite");
+void Sprite::setSpriteHorzFlip(int spriteId, int flip) {
+ assertRange(1, spriteId, _maxSprites, "sprite");
int oldFlags = _spriteTable[spriteId].flags;
- if (value)
+ if (flip) {
_spriteTable[spriteId].flags |= kSFHFlip;
- else
+ } else {
_spriteTable[spriteId].flags &= ~kSFHFlip;
+ }
if (_spriteTable[spriteId].image && _spriteTable[spriteId].flags != oldFlags)
_spriteTable[spriteId].flags |= kSFErase | kSFRender;
}
-void Sprite::setSpriteFlagActive(int spriteId, int value) {
- assertRange(1, spriteId, _varNumSprites, "sprite");
+void Sprite::setSpriteActiveFlag(int spriteId, int value) {
+ assertRange(1, spriteId, _maxSprites, "sprite");
- if (value)
+ if (value) {
_spriteTable[spriteId].flags |= kSFActive;
- else
+ } else {
_spriteTable[spriteId].flags &= ~kSFActive;
+ }
}
-void Sprite::setSpriteFlagRemapPalette(int spriteId, int value) {
- assertRange(1, spriteId, _varNumSprites, "sprite");
+void Sprite::setSpriteImageRemapFlag(int spriteId, int value) {
+ assertRange(1, spriteId, _maxSprites, "sprite");
int oldFlags = _spriteTable[spriteId].flags;
- if (value)
+ if (value) {
_spriteTable[spriteId].flags |= kSFUseImageRemap;
- else
+ } else {
_spriteTable[spriteId].flags &= ~kSFUseImageRemap;
+ }
if (_spriteTable[spriteId].image && _spriteTable[spriteId].flags != oldFlags)
_spriteTable[spriteId].flags |= kSFErase | kSFRender;
}
-void Sprite::setSpriteFlagAutoAnim(int spriteId, int value) {
- assertRange(1, spriteId, _varNumSprites, "sprite");
+void Sprite::setSpriteAutoAnimFlag(int spriteId, int value) {
+ assertRange(1, spriteId, _maxSprites, "sprite");
- if (value)
+ if (value) {
_spriteTable[spriteId].flags |= kSFAutoAnimate;
- else
+ } else {
_spriteTable[spriteId].flags &= ~kSFAutoAnimate;
+ }
}
-void Sprite::setSpriteFlagUpdateType(int spriteId, int value) {
- assertRange(1, spriteId, _varNumSprites, "sprite");
-
- switch (value) {
- case 2:
- _spriteTable[spriteId].flags &= ~(kSFSmartRender);
- _spriteTable[spriteId].flags |= kSFDontCombineErase;
- break;
- case 1:
- _spriteTable[spriteId].flags |= kSFSmartRender | kSFDontCombineErase;
- break;
- case 0:
- _spriteTable[spriteId].flags &= ~(kSFSmartRender | kSFDontCombineErase);
- break;
- default:
- error("setSpriteFlagUpdateType: Invalid value %d", value);
+void Sprite::setSpriteUpdateType(int spriteId, int eraseType) {
+ assertRange(1, spriteId, _maxSprites, "sprite");
+
+ if (_vm->_game.heversion > 99) {
+ switch (eraseType) {
+ default:
+ case SPRDEF_SMART:
+ _spriteTable[spriteId].flags |= kSFSmartRender | kSFDontCombineErase;
+ break;
+ case SPRDEF_DUMB:
+ _spriteTable[spriteId].flags &= ~(kSFSmartRender | kSFDontCombineErase);
+ break;
+ case SPRDEF_SIMPLE:
+ _spriteTable[spriteId].flags &= ~(kSFSmartRender);
+ _spriteTable[spriteId].flags |= kSFDontCombineErase;
+ break;
+ }
+ } else {
+ if (eraseType != 0) {
+ _spriteTable[spriteId].flags |= (kSFSmartRender | kSFDontCombineErase);
+ } else {
+ _spriteTable[spriteId].flags &= ~(kSFSmartRender | kSFDontCombineErase);
+ }
}
+
}
-void Sprite::setSpriteFlagEraseType(int spriteId, int value) {
- assertRange(1, spriteId, _varNumSprites, "sprite");
+void Sprite::setSpriteEraseType(int spriteId, int eraseType) {
+ assertRange(1, spriteId, _maxSprites, "sprite");
// Note that condition is inverted
- if (!value)
+ if (!eraseType) {
_spriteTable[spriteId].flags |= kSFIgnoreErase;
- else
+ } else {
_spriteTable[spriteId].flags &= ~kSFIgnoreErase;
+ }
}
void Sprite::setSpriteAnimSpeed(int spriteId, int value) {
- assertRange(1, spriteId, _varNumSprites, "sprite");
+ assertRange(1, spriteId, _maxSprites, "sprite");
_spriteTable[spriteId].animSpeed = value;
_spriteTable[spriteId].animState = value;
}
-void Sprite::setSpriteSetClass(int spriteId, int classId, int toggle) {
- assertRange(1, spriteId, _varNumSprites, "sprite");
+void Sprite::setSpriteClass(int spriteId, int classId, int toggle) {
+ assertRange(1, spriteId, _maxSprites, "sprite");
assertRange(1, classId, 32, "class");
if (toggle) {
@@ -735,131 +918,192 @@ void Sprite::setSpriteSetClass(int spriteId, int classId, int toggle) {
}
}
-void Sprite::setSpriteResetClass(int spriteId) {
- assertRange(1, spriteId, _varNumSprites, "sprite");
+void Sprite::clearSpriteClasses(int spriteId) {
+ assertRange(1, spriteId, _maxSprites, "sprite");
_spriteTable[spriteId].classFlags = 0;
}
void Sprite::setSpriteZBuffer(int spriteId, int value) {
- assertRange(1, spriteId, _varNumSprites, "sprite");
+ assertRange(1, spriteId, _maxSprites, "sprite");
_spriteTable[spriteId].zbufferImage = value;
}
-void Sprite::setSpriteGeneralProperty(int spriteId, int type, int value) {
- debug(7, "setSpriteGeneralProperty: spriteId %d type 0x%x value 0x%x", spriteId, type, value);
- assertRange(1, spriteId, _varNumSprites, "sprite");
- int32 delay;
+void Sprite::setSpriteAnimSpeedState(int spriteId, int animState) {
+ assertRange(1, spriteId, _maxSprites, "sprite");
+ _spriteTable[spriteId].animState = MAX(0, MIN(animState, _spriteTable[spriteId].animSpeed));
+}
- switch (type) {
- case 0x7B:
+void Sprite::setSpriteGeneralProperty(int spriteId, int property, int value) {
+ // TODO U32
+ debug(7, "setSpriteGeneralProperty: spriteId %d type 0x%x value 0x%x", spriteId, property, value);
+ assertRange(1, spriteId, _maxSprites, "sprite");
+
+ switch (property) {
+ case SPRPROP_SPECIAL_RENDER_FLAGS:
_spriteTable[spriteId].specialRenderFlags = value;
_spriteTable[spriteId].flags |= kSFErase | kSFRender;
break;
- case 0x7D:
+ case SPRPROP_CONDITION_BITS:
_spriteTable[spriteId].conditionBits = value;
_spriteTable[spriteId].flags |= kSFErase | kSFRender;
break;
- case 0x7E:
- delay = MAX(0, value);
- delay = MIN(delay, _spriteTable[spriteId].animSpeed);
-
- _spriteTable[spriteId].animState = delay;
+ case SPRPROP_ANIMATION_SUB_STATE:
+ setSpriteAnimSpeedState(spriteId, value);
break;
default:
- error("setSpriteGeneralProperty: Invalid value %d", type);
+ warning("Sprite::setSpriteGeneralProperty(): Unknown sprite property %d", property);
}
}
-void Sprite::resetSprite(int spriteId) {
- assertRange(1, spriteId, _varNumSprites, "sprite");
+void Sprite::newSprite(int sprite) {
+ assertRange(1, sprite, _maxSprites, "sprite");
- _spriteTable[spriteId].angle = 0;
- _spriteTable[spriteId].scale = 0;
+ _spriteTable[sprite].angle = 0;
+ _spriteTable[sprite].scale = 0;
- setSpriteImage(spriteId, 0);
+ setSpriteImage(sprite, 0);
+ setSpriteShadow(sprite, 0);
+ setSpritePosition(sprite, 0, 0);
+ setSpriteHorzFlip(sprite, 0);
+ setSpriteVertFlip(sprite, 0);
+ setDelta(sprite, 0, 0);
+ setUserValue(sprite, 0, 0);
+ setSpriteGroup(sprite, 0);
+ setSpriteAnimSpeed(sprite, 0);
+ clearSpriteClasses(sprite);
- _spriteTable[spriteId].shadow = 0;
- _spriteTable[spriteId].posX = 0;
- _spriteTable[spriteId].posY = 0;
+ if (_vm->_game.heversion > 98) {
+ setSpritePalette(sprite, 0);
+ setSourceImage(sprite, 0);
+ setMaskImage(sprite, 0);
+ }
- _spriteTable[spriteId].flags &= ~(kSFVFlip | kSFHFlip);
- _spriteTable[spriteId].flags |= kSFErase | kSFRender;
- _spriteTable[spriteId].deltaPosX = 0;
- _spriteTable[spriteId].deltaPosY = 0;
- _spriteTable[spriteId].userValue = 0;
- _spriteTable[spriteId].group = 0;
- _spriteTable[spriteId].animSpeed = 0;
- _spriteTable[spriteId].animState = 0;
- _spriteTable[spriteId].classFlags = 0;
- _spriteTable[spriteId].palette = 0;
- _spriteTable[spriteId].sourceImage = 0;
- _spriteTable[spriteId].maskImage = 0;
- _spriteTable[spriteId].priority = 0;
- _spriteTable[spriteId].zbufferImage = 0;
- _spriteTable[spriteId].specialRenderFlags = 0;
- _spriteTable[spriteId].conditionBits = 0;
+ if (_vm->_game.heversion > 99) {
+ setSpriteUpdateType(sprite, SPRDEF_SIMPLE);
+ setSpritePriority(sprite, 0);
+ setSpriteZBuffer(sprite, 0);
+
+ _spriteTable[sprite].flags |= kSFAutoAnimate;
+ _spriteTable[sprite].conditionBits = 0;
- if (_vm->_game.heversion >= 100) {
- _spriteTable[spriteId].flags &= ~kSFSmartRender;
- _spriteTable[spriteId].flags |= kSFAutoAnimate | kSFDontCombineErase;
+ _spriteTable[sprite].specialRenderFlags = 0;
+ // TODO U32 PU_SpriteNewHook(sprite);
}
}
-void Sprite::setSpriteImage(int spriteId, int imageNum) {
- int origResId, origResWizStates;
+void Sprite::setImageList(int sprite, int count, const int *list) {
+ SpriteImageList *imageListPtr;
+ int counter;
- assertRange(1, spriteId, _varNumSprites, "sprite");
+ assertRange(1, sprite, _maxSprites, "sprite");
- origResId = _spriteTable[spriteId].image;
- origResWizStates = _spriteTable[spriteId].maxStates;
+ // Release the last image list if one...
+ if (_spriteTable[sprite].imageList) {
+ releaseImageList(_spriteTable[sprite].imageList);
+ _spriteTable[sprite].imageList = 0;
+ }
- _spriteTable[spriteId].image = imageNum;
- _spriteTable[spriteId].animIndex = 0;
- _spriteTable[spriteId].state = 0;
+ // HE90+
+ int32 lastMaxStates = _spriteTable[sprite].maxStates;
+ int32 lastImage = _spriteTable[sprite].image;
- if (_spriteTable[spriteId].image) {
- _spriteTable[spriteId].maxStates = _vm->_wiz->getWizImageStates(_spriteTable[spriteId].image);
+ if (count == 1) {
+ _spriteTable[sprite].image = *list;
+ } else {
+ _spriteTable[sprite].imageList = getFreeImageList(count);
+ imageListPtr = getImageListPtr(_spriteTable[sprite].imageList);
+ imageListPtr->count = count;
- if (_vm->VAR(139))
- _spriteTable[spriteId].flags |= kSFActive;
- else
- _spriteTable[spriteId].flags |= kSFActive | kSFAutoAnimate | kSFSmartRender | kSFDontCombineErase;
+ for (counter = 0; counter < count; counter++) {
+ imageListPtr->list[counter] = *list++;
+ }
+
+ _spriteTable[sprite].image = imageListPtr->list[0];
+ }
+
+ _spriteTable[sprite].animIndex = 0;
+ _spriteTable[sprite].state = 0; // HE90+
+
+ if (_spriteTable[sprite].image) {
+ if (_vm->_game.heversion == 80) {
+ _spriteTable[sprite].flags |=
+ (kSFActive | kSFAutoAnimate |
+ kSFRender | kSFErase);
+ } else {
+ _spriteTable[sprite].maxStates = _vm->_wiz->getWizStateCount(_spriteTable[sprite].image);
+
+ if (_vm->_game.heversion < 100) {
+ _spriteTable[sprite].flags |= kSFDefaultFlagActive;
+ } else {
+ if (_vm->VAR(_vm->VAR_SPRITE_IMAGE_CHANGE_DOES_NOT_RESET_SETTINGS)) {
+ _spriteTable[sprite].flags |= kSFActive;
+ } else {
+ _spriteTable[sprite].flags |= kSFDefaultFlagActive;
+ }
+ }
+
+ if (_vm->_game.heversion > 80 &&
+ (lastImage != _spriteTable[sprite].image) || (_spriteTable[sprite].maxStates != lastMaxStates)) {
+ _spriteTable[sprite].flags |= (kSFRender | kSFErase);
+ }
+ }
- if (_spriteTable[spriteId].image != origResId || _spriteTable[spriteId].maxStates != origResWizStates)
- _spriteTable[spriteId].flags |= kSFErase | kSFRender;
} else {
- if (_vm->VAR(139))
- _spriteTable[spriteId].flags &= ~kSFActive;
- else if (_vm->_game.heversion >= 100 && origResId == 0)
- _spriteTable[spriteId].flags = 0;
- else if (_spriteTable[spriteId].flags & kSFIgnoreErase)
- _spriteTable[spriteId].flags = 0;
- else
- _spriteTable[spriteId].flags = kSFErase | kSFDontCombineErase;
- _spriteTable[spriteId].lastImage = 0;
- _spriteTable[spriteId].lastState = 0;
- _spriteTable[spriteId].maxStates = 0;
+ if (_vm->_game.heversion >= 95 && _vm->_game.heversion < 100) {
+ if (_spriteTable[sprite].flags & kSFIgnoreErase) {
+ _spriteTable[sprite].flags = 0;
+ } else {
+ _spriteTable[sprite].flags = kSFDefaultFlagInactive;
+ }
+ } else if (_vm->_game.heversion >= 100) {
+ if (_vm->VAR(_vm->VAR_SPRITE_IMAGE_CHANGE_DOES_NOT_RESET_SETTINGS)) {
+ _spriteTable[sprite].flags &= ~kSFActive;
+ } else {
+ if (lastImage) {
+ if (_spriteTable[sprite].flags & kSFIgnoreErase) {
+ _spriteTable[sprite].flags = 0;
+ } else {
+ _spriteTable[sprite].flags = kSFDefaultFlagInactive;
+ }
+ } else {
+ _spriteTable[sprite].flags = 0;
+ }
+ }
+ } else {
+ _spriteTable[sprite].flags = (_vm->_game.heversion == 80 ? kSFErase : kSFDefaultFlagInactive);
+ }
+
+ _spriteTable[sprite].lastImage = 0;
+
+ // HE90+
+ _spriteTable[sprite].lastState = 0;
+ _spriteTable[sprite].maxStates = 0;
}
}
+void Sprite::setSpriteImage(int sprite, int imageNum) {
+ setImageList(sprite, 1, &imageNum);
+}
//
// spriteGroupSet functions
//
-void Sprite::redrawSpriteGroup(int spriteGroupId) {
- for (int i = 0; i < _numSpritesToProcess; ++i) {
- SpriteInfo *spi = _activeSpritesTable[i];
+void Sprite::orInGroupMembersFlags(int spriteGroupId, int32 flags) {
+ assertRange(1, spriteGroupId, _maxSpriteGroups, "sprite group");
+
+ for (int i = 0; i < _activeSpriteCount; ++i) {
+ SpriteInfo *spi = _activeSprites[i];
if (spi->group == spriteGroupId) {
- spi->flags |= kSFErase | kSFRender;
+ spi->flags |= flags;
}
}
}
void Sprite::moveGroupMembers(int spriteGroupId, int value1, int value2) {
- assertRange(1, spriteGroupId, _varNumSpriteGroups, "sprite group");
+ assertRange(1, spriteGroupId, _maxSpriteGroups, "sprite group");
- for (int i = 1; i < _varNumSprites; i++) {
+ for (int i = 1; i < _maxSprites; i++) {
if (_spriteTable[i].group == spriteGroupId) {
_spriteTable[i].posX += value1;
_spriteTable[i].posY += value2;
@@ -871,18 +1115,18 @@ void Sprite::moveGroupMembers(int spriteGroupId, int value1, int value2) {
}
void Sprite::setGroupMembersPriority(int spriteGroupId, int value) {
- assertRange(1, spriteGroupId, _varNumSpriteGroups, "sprite group");
+ assertRange(1, spriteGroupId, _maxSpriteGroups, "sprite group");
- for (int i = 1; i < _varNumSprites; i++) {
+ for (int i = 1; i < _maxSprites; i++) {
if (_spriteTable[i].group == spriteGroupId)
_spriteTable[i].priority = value;
}
}
-void Sprite::setGroupMembersGroup(int spriteGroupId, int value) {
- assertRange(1, spriteGroupId, _varNumSpriteGroups, "sprite group");
+void Sprite::changeGroupMembersGroup(int spriteGroupId, int value) {
+ assertRange(1, spriteGroupId, _maxSpriteGroups, "sprite group");
- for (int i = 1; i < _varNumSprites; i++) {
+ for (int i = 1; i < _maxSprites; i++) {
if (_spriteTable[i].group == spriteGroupId) {
_spriteTable[i].group = value;
_spriteTable[i].flags |= kSFErase | kSFRender;
@@ -891,27 +1135,27 @@ void Sprite::setGroupMembersGroup(int spriteGroupId, int value) {
}
void Sprite::setGroupMembersUpdateType(int spriteGroupId, int value) {
- assertRange(1, spriteGroupId, _varNumSpriteGroups, "sprite group");
+ assertRange(1, spriteGroupId, _maxSpriteGroups, "sprite group");
- for (int i = 1; i < _varNumSprites; i++) {
+ for (int i = 1; i < _maxSprites; i++) {
if (_spriteTable[i].group == spriteGroupId)
- setSpriteFlagUpdateType(i, value);
+ setSpriteUpdateType(i, value);
}
}
-void Sprite::setGroupMembersResetSprite(int spriteGroupId) {
- assertRange(1, spriteGroupId, _varNumSpriteGroups, "sprite group");
+void Sprite::performNewOnGroupMembers(int spriteGroupId) {
+ assertRange(1, spriteGroupId, _maxSpriteGroups, "sprite group");
- for (int i = 1; i < _varNumSprites; i++) {
+ for (int i = 1; i < _maxSprites; i++) {
if (_spriteTable[i].group == spriteGroupId)
- resetSprite(i);
+ newSprite(i);
}
}
void Sprite::setGroupMembersAnimationSpeed(int spriteGroupId, int value) {
- assertRange(1, spriteGroupId, _varNumSpriteGroups, "sprite group");
+ assertRange(1, spriteGroupId, _maxSpriteGroups, "sprite group");
- for (int i = 1; i < _varNumSprites; i++) {
+ for (int i = 1; i < _maxSprites; i++) {
if (_spriteTable[i].group == spriteGroupId) {
_spriteTable[i].animSpeed = value;
_spriteTable[i].animState = value;
@@ -920,9 +1164,9 @@ void Sprite::setGroupMembersAnimationSpeed(int spriteGroupId, int value) {
}
void Sprite::setGroupMembersAutoAnimFlag(int spriteGroupId, int value) {
- assertRange(1, spriteGroupId, _varNumSpriteGroups, "sprite group");
+ assertRange(1, spriteGroupId, _maxSpriteGroups, "sprite group");
- for (int i = 1; i < _varNumSprites; i++) {
+ for (int i = 1; i < _maxSprites; i++) {
if (_spriteTable[i].group == spriteGroupId) {
if (value)
_spriteTable[i].flags |= kSFAutoAnimate;
@@ -933,9 +1177,9 @@ void Sprite::setGroupMembersAutoAnimFlag(int spriteGroupId, int value) {
}
void Sprite::setGroupMembersShadow(int spriteGroupId, int value) {
- assertRange(1, spriteGroupId, _varNumSpriteGroups, "sprite group");
+ assertRange(1, spriteGroupId, _maxSpriteGroups, "sprite group");
- for (int i = 1; i < _varNumSprites; i++) {
+ for (int i = 1; i < _maxSprites; i++) {
if (_spriteTable[i].group == spriteGroupId) {
_spriteTable[i].shadow = value;
if (_spriteTable[i].image)
@@ -944,265 +1188,417 @@ void Sprite::setGroupMembersShadow(int spriteGroupId, int value) {
}
}
-void Sprite::setGroupBounds(int spriteGroupId, int x1, int y1, int x2, int y2) {
- assertRange(1, spriteGroupId, _varNumSpriteGroups, "sprite group");
+void Sprite::setGroupClipRect(int spriteGroupId, int x1, int y1, int x2, int y2) {
+ assertRange(1, spriteGroupId, _maxSpriteGroups, "sprite group");
- _spriteGroups[spriteGroupId].flags |= kSGFUseClipRect;
- _spriteGroups[spriteGroupId].bbox.left = x1;
- _spriteGroups[spriteGroupId].bbox.top = y1;
- _spriteGroups[spriteGroupId].bbox.right = x2;
- _spriteGroups[spriteGroupId].bbox.bottom = y2;
- _vm->adjustRect(_spriteGroups[spriteGroupId].bbox);
+ _groupTable[spriteGroupId].flags |= kSGFUseClipRect;
+ _groupTable[spriteGroupId].clipRect.left = x1;
+ _groupTable[spriteGroupId].clipRect.top = y1;
+ _groupTable[spriteGroupId].clipRect.right = x2;
+ _groupTable[spriteGroupId].clipRect.bottom = y2;
- redrawSpriteGroup(spriteGroupId);
+ orInGroupMembersFlags(spriteGroupId, (kSFRender | kSFErase));
}
void Sprite::setGroupPriority(int spriteGroupId, int value) {
- assertRange(1, spriteGroupId, _varNumSpriteGroups, "sprite group");
+ assertRange(1, spriteGroupId, _maxSpriteGroups, "sprite group");
- if (_spriteGroups[spriteGroupId].priority != value) {
- _spriteGroups[spriteGroupId].priority = value;
- redrawSpriteGroup(spriteGroupId);
+ if (_groupTable[spriteGroupId].priority != value) {
+ _groupTable[spriteGroupId].priority = value;
+ orInGroupMembersFlags(spriteGroupId, (kSFRender | kSFErase));
}
}
-void Sprite::setGroupPosition(int spriteGroupId, int value1, int value2) {
- assertRange(1, spriteGroupId, _varNumSpriteGroups, "sprite group");
+void Sprite::setGroupPoint(int spriteGroupId, int x, int y) {
+ assertRange(1, spriteGroupId, _maxSpriteGroups, "sprite group");
- if (_spriteGroups[spriteGroupId].tx != value1 || _spriteGroups[spriteGroupId].ty != value2) {
- _spriteGroups[spriteGroupId].tx = value1;
- _spriteGroups[spriteGroupId].ty = value2;
- redrawSpriteGroup(spriteGroupId);
+ if (_groupTable[spriteGroupId].posX != x || _groupTable[spriteGroupId].posY != y) {
+ _groupTable[spriteGroupId].posX = x;
+ _groupTable[spriteGroupId].posY = y;
+ orInGroupMembersFlags(spriteGroupId, (kSFRender | kSFErase));
}
}
-void Sprite::moveGroup(int spriteGroupId, int value1, int value2) {
- assertRange(1, spriteGroupId, _varNumSpriteGroups, "sprite group");
+void Sprite::moveGroup(int spriteGroupId, int dx, int dy) {
+ assertRange(1, spriteGroupId, _maxSpriteGroups, "sprite group");
- if (value1 || value2) {
- _spriteGroups[spriteGroupId].tx += value1;
- _spriteGroups[spriteGroupId].ty += value2;
- redrawSpriteGroup(spriteGroupId);
+ if (dx || dy) {
+ _groupTable[spriteGroupId].posX += dx;
+ _groupTable[spriteGroupId].posY += dy;
+ orInGroupMembersFlags(spriteGroupId, (kSFRender | kSFErase));
}
}
void Sprite::setGroupImage(int spriteGroupId, int value) {
- assertRange(1, spriteGroupId, _varNumSpriteGroups, "sprite group");
+ assertRange(1, spriteGroupId, _maxSpriteGroups, "sprite group");
- if (_spriteGroups[spriteGroupId].image != value) {
- _spriteGroups[spriteGroupId].image = value;
- redrawSpriteGroup(spriteGroupId);
+ if (_groupTable[spriteGroupId].image != value) {
+ _groupTable[spriteGroupId].image = value;
+ orInGroupMembersFlags(spriteGroupId, (kSFRender | kSFErase));
}
}
void Sprite::setGroupScaling(int spriteGroupId) {
- if ((_spriteGroups[spriteGroupId].scale_x_ratio_mul != _spriteGroups[spriteGroupId].scale_x_ratio_div) || (_spriteGroups[spriteGroupId].scale_y_ratio_mul != _spriteGroups[spriteGroupId].scale_y_ratio_div))
- _spriteGroups[spriteGroupId].scaling = 1;
+ if ((_groupTable[spriteGroupId].xMul != _groupTable[spriteGroupId].xDiv) || (_groupTable[spriteGroupId].yMul != _groupTable[spriteGroupId].yDiv))
+ _groupTable[spriteGroupId].isScaled = 1;
else
- _spriteGroups[spriteGroupId].scaling = 0;
+ _groupTable[spriteGroupId].isScaled = 0;
}
void Sprite::setGroupXMul(int spriteGroupId, int value) {
- assertRange(1, spriteGroupId, _varNumSpriteGroups, "sprite group");
+ assertRange(1, spriteGroupId, _maxSpriteGroups, "sprite group");
+
+ if (_groupTable[spriteGroupId].xMul != value) {
+ _groupTable[spriteGroupId].xMul = value;
+ _groupTable[spriteGroupId].xScale = (float)_groupTable[spriteGroupId].xMul / (float)_groupTable[spriteGroupId].xDiv;
- if (_spriteGroups[spriteGroupId].scale_x_ratio_mul != value) {
- _spriteGroups[spriteGroupId].scale_x_ratio_mul = value;
setGroupScaling(spriteGroupId);
- redrawSpriteGroup(spriteGroupId);
+ orInGroupMembersFlags(spriteGroupId, (kSFRender | kSFErase));
}
}
void Sprite::setGroupXDiv(int spriteGroupId, int value) {
- assertRange(1, spriteGroupId, _varNumSpriteGroups, "sprite group");
+ assertRange(1, spriteGroupId, _maxSpriteGroups, "sprite group");
if (value == 0)
error("setGroupXDiv: Divisor must not be 0");
- if (_spriteGroups[spriteGroupId].scale_x_ratio_div != value) {
- _spriteGroups[spriteGroupId].scale_x_ratio_div = value;
+ if (_groupTable[spriteGroupId].xDiv != value) {
+ _groupTable[spriteGroupId].xDiv = value;
+ _groupTable[spriteGroupId].xScale = (float)_groupTable[spriteGroupId].xMul / (float)_groupTable[spriteGroupId].xDiv;
+
setGroupScaling(spriteGroupId);
- redrawSpriteGroup(spriteGroupId);
+ orInGroupMembersFlags(spriteGroupId, (kSFRender | kSFErase));
}
}
void Sprite::setGroupYMul(int spriteGroupId, int value) {
- assertRange(1, spriteGroupId, _varNumSpriteGroups, "sprite group");
+ assertRange(1, spriteGroupId, _maxSpriteGroups, "sprite group");
+
+ if (_groupTable[spriteGroupId].yMul != value) {
+ _groupTable[spriteGroupId].yMul = value;
+ _groupTable[spriteGroupId].yScale = (float)_groupTable[spriteGroupId].yMul / (float)_groupTable[spriteGroupId].yDiv;
- if (_spriteGroups[spriteGroupId].scale_y_ratio_mul != value) {
- _spriteGroups[spriteGroupId].scale_y_ratio_mul = value;
setGroupScaling(spriteGroupId);
- redrawSpriteGroup(spriteGroupId);
+ orInGroupMembersFlags(spriteGroupId, (kSFRender | kSFErase));
}
}
void Sprite::setGroupYDiv(int spriteGroupId, int value) {
- assertRange(1, spriteGroupId, _varNumSpriteGroups, "sprite group");
+ assertRange(1, spriteGroupId, _maxSpriteGroups, "sprite group");
if (value == 0)
error("setGroupYDiv: Divisor must not be 0");
- if (_spriteGroups[spriteGroupId].scale_y_ratio_div != value) {
- _spriteGroups[spriteGroupId].scale_y_ratio_div = value;
+ if (_groupTable[spriteGroupId].yDiv != value) {
+ _groupTable[spriteGroupId].yDiv = value;
+ _groupTable[spriteGroupId].yScale = (float)_groupTable[spriteGroupId].yMul / (float)_groupTable[spriteGroupId].yDiv;
+
setGroupScaling(spriteGroupId);
- redrawSpriteGroup(spriteGroupId);
+ orInGroupMembersFlags(spriteGroupId, (kSFRender | kSFErase));
}
}
-void Sprite::resetGroupBounds(int spriteGroupId) {
- assertRange(1, spriteGroupId, _varNumSpriteGroups, "sprite group");
+void Sprite::clearGroupClipRect(int spriteGroupId) {
+ assertRange(1, spriteGroupId, _maxSpriteGroups, "sprite group");
- _spriteGroups[spriteGroupId].flags &= ~(kSGFUseClipRect);
- redrawSpriteGroup(spriteGroupId);
+ _groupTable[spriteGroupId].flags &= ~(kSGFUseClipRect);
+ orInGroupMembersFlags(spriteGroupId, (kSFRender | kSFErase));
}
-void Sprite::allocTables(int numSprites, int numGroups, int numMaxSprites) {
- _varNumSpriteGroups = numGroups;
- _numSpritesToProcess = 0;
- _varNumSprites = numSprites;
- _varMaxSprites = numMaxSprites;
- _spriteGroups = (SpriteGroup *)malloc((_varNumSpriteGroups + 1) * sizeof(SpriteGroup));
- _spriteTable = (SpriteInfo *)malloc((_varNumSprites + 1) * sizeof(SpriteInfo));
- _activeSpritesTable = (SpriteInfo **)malloc((_varNumSprites + 1) * sizeof(SpriteInfo *));
+void Sprite::clearGroupScaleInfo(int group) {
+ assertRange(1, group, _maxSpriteGroups, "sprite group");
+
+ _groupTable[group].isScaled = 0;
+ _groupTable[group].xScale = 1.0;
+ _groupTable[group].xMul = 1;
+ _groupTable[group].xDiv = 1;
+ _groupTable[group].yScale = 1.0;
+ _groupTable[group].yMul = 1;
+ _groupTable[group].yDiv = 1;
}
-void Sprite::resetGroup(int spriteGroupId) {
- assertRange(1, spriteGroupId, _varNumSpriteGroups, "sprite group");
- SpriteGroup *spg = &_spriteGroups[spriteGroupId];
+void Sprite::initializeStuff(int spriteCount, int groupCount, int imageListCount) {
+ _activeSpriteCount = 0;
+ _maxSpriteGroups = groupCount;
+ _maxSprites = spriteCount;
+ _maxImageLists = imageListCount;
+
+ _groupTable = (SpriteGroup *)malloc((_maxSpriteGroups + 1) * sizeof(SpriteGroup));
+ _spriteTable = (SpriteInfo *)malloc((_maxSprites + 1) * sizeof(SpriteInfo));
+ _activeSprites = (SpriteInfo **)malloc((_maxSprites + 1) * sizeof(SpriteInfo *));
+ _imageLists = (SpriteImageList *)malloc((_maxImageLists + 1) * sizeof(SpriteImageList));
+ _imageListStack = (int16 *)malloc((_maxImageLists + 1) * sizeof(int16));
+
+ resetSpriteSystem(false);
+}
- spg->priority = 0;
- spg->tx = spg->ty = 0;
+void Sprite::newGroup(int group) {
+ assertRange(1, group, _maxSpriteGroups, "sprite group");
- spg->flags &= ~kSGFUseClipRect;
- redrawSpriteGroup(spriteGroupId);
+ setGroupPriority(group, 0);
+ setGroupPoint(group, 0, 0);
+ clearGroupClipRect(group);
+ setGroupImage(group, 0);
+ clearGroupScaleInfo(group);
- spg->image = 0;
- spg->scaling = 0;
- spg->scale_x_ratio_mul = 1;
- spg->scale_x_ratio_div = 1;
- spg->scale_y_ratio_mul = 1;
- spg->scale_y_ratio_div = 1;
+ // TODO U32
+ // if (_vm->_game.heversion > 99)
+ // PU_GroupNewHook(group);
}
-void Sprite::resetTables(bool refreshScreen) {
- for (int i = 0; i < _varNumSprites; i++) {
+void Sprite::resetSpriteSystem(bool refreshScreen) {
+ resetImageLists();
+
+ for (int i = 0; i < _maxSprites; i++) {
_spriteTable[i].reset();
}
- for (int i = 0; i < _varNumSpriteGroups; i++) {
- _spriteGroups[i].reset();
+
+ for (int i = 0; i < _maxSpriteGroups; i++) {
+ _groupTable[i].reset();
}
- for (int curGrp = 1; curGrp < _varNumSpriteGroups; ++curGrp)
- resetGroup(curGrp);
+ if (_vm->_game.heversion >= 98) {
+ for (int i = 1; i < _maxSpriteGroups; i++) {
+ newGroup(i);
+ }
+ }
- if (refreshScreen) {
- _vm->backgroundToForegroundBlit(Common::Rect(_vm->_screenWidth, _vm->_screenHeight));
+ if (_vm->_game.heversion > 80) {
+ if (refreshScreen) {
+ _vm->backgroundToForegroundBlit(Common::Rect(_vm->_screenWidth - 1, _vm->_screenHeight - 1));
+ }
+ } else {
+ _vm->_completeScreenRedraw = true;
+ }
+
+ _activeSpriteCount = 0;
+}
+
+void Sprite::resetImageLists() {
+ _imageListStackIndex = _maxImageLists;
+
+ for (int i = 0; i < _maxImageLists; i++) {
+ _imageListStack[i] = i;
+ }
+}
+
+SpriteImageList *Sprite::getImageListPtr(int imageList) {
+ assertRange(1, imageList, _maxImageLists, "sprite image list");
+ return &_imageLists[imageList - 1];
+}
+
+int Sprite::getFreeImageList(int imageCount) {
+ if (!_imageListStackIndex) {
+ error("Sprite::getFreeImageList(): Out of image lists");
}
- _numSpritesToProcess = 0;
+
+ if (imageCount > 32) {
+ error("Sprite::getFreeImageList(): Too many images in image list (%d)!", imageCount);
+ }
+
+ --_imageListStackIndex;
+ return (_imageListStack[_imageListStackIndex] + 1);
}
-void Sprite::resetBackground() {
- int xmin, xmax, ymin, ymax;
- xmin = ymin = 1234;
- xmax = ymax = -1234;
- bool firstLoop = true;
- bool refreshScreen = false;
+void Sprite::releaseImageList(int imageList) {
+ assertRange(1, imageList, _maxImageLists, "sprite image list");
+ _imageListStack[_imageListStackIndex++] = (imageList - 1);
+}
+
+void Sprite::eraseSprites() {
+ Common::Rect *lastRectPtr;
+ Common::Rect eraseRect;
+ SpriteInfo **spritePtr;
+ bool first, valid;
+ int32 flags;
+
+ eraseRect.left = 1234;
+ eraseRect.top = 1234;
+ eraseRect.left = -1234;
+ eraseRect.bottom = -1234;
- for (int i = 0; i < _numSpritesToProcess; ++i) {
- SpriteInfo *spi = _activeSpritesTable[i];
- if (!(spi->flags & kSFIgnoreErase) && (spi->flags & kSFErase)) {
- spi->flags &= ~kSFErase;
- if (spi->lastRect.left <= spi->lastRect.right && spi->lastRect.top <= spi->lastRect.bottom) {
- if (spi->flags & kSFDontCombineErase) {
- _vm->backgroundToForegroundBlit(spi->lastRect, USAGE_BIT_RESTORED);
- } else if (firstLoop) {
- xmin = spi->lastRect.left;
- ymin = spi->lastRect.top;
- xmax = spi->lastRect.right;
- ymax = spi->lastRect.bottom;
- firstLoop = false;
- refreshScreen = true;
+ spritePtr = _activeSprites;
+ first = true;
+ valid = false;
+
+ for (int i = 0; i < _activeSpriteCount; i++) {
+ // Get the current flags & clear the erase flag...
+ flags = spritePtr[i]->flags;
+ spritePtr[i]->flags &= ~kSFErase;
+
+ // Check to see if this sprite should erase it's last rect...
+ if (!(flags & kSFErase))
+ continue;
+
+ if (_vm->_game.heversion >= 98) {
+ if (flags & kSFIgnoreErase)
+ continue;
+ }
+
+ // Combine the rect with the erase rect...
+ lastRectPtr = &spritePtr[i]->lastRect;
+
+ if (_vm->_wiz->isRectValid(*lastRectPtr)) {
+ if (_vm->_game.heversion < 90 || !(flags & kSFDontCombineErase)) {
+ if (!first) {
+ _vm->_wiz->combineRects(&eraseRect, &eraseRect, lastRectPtr);
} else {
- if (xmin > spi->lastRect.left) {
- xmin = spi->lastRect.left;
- }
- if (ymin > spi->lastRect.top) {
- ymin = spi->lastRect.top;
- }
- if (xmax < spi->lastRect.right) {
- xmax = spi->lastRect.right;
- }
- if (ymax < spi->lastRect.bottom) {
- ymax = spi->lastRect.bottom;
+ eraseRect = *lastRectPtr;
+ first = false;
+ }
+
+ valid = true;
+ } else {
+ _vm->backgroundToForegroundBlit(*lastRectPtr, USAGE_BIT_RESTORED);
+ }
+
+ if (_vm->_game.version >= 90) {
+ if (!(flags & (kSFIgnoreErase | kSFRender))) {
+ if (spritePtr[i]->image) {
+ spritePtr[i]->flags |= kSFRender;
}
- refreshScreen = true;
}
- if (!(spi->flags & kSFRender) && spi->image)
- spi->flags |= kSFRender;
}
}
}
- if (refreshScreen) {
- _vm->backgroundToForegroundBlit(Common::Rect(xmin, ymin, xmax, ymax), USAGE_BIT_RESTORED);
+
+ // Erase the sprites as a bunch, hopefuly this will be faster
+ // Also set the bits so that any "actors" that are in the area
+ // will also be updated!
+ if (valid) {
+ _vm->backgroundToForegroundBlit(eraseRect, USAGE_BIT_RESTORED);
}
}
-void Sprite::checkForForcedRedraws(bool checkZOrder) {
+
+bool Sprite::doesRectIntersectUpdateAreas(const Common::Rect *rectPtr) {
+ int sMin, sMax, y1, y2, minValue;
VirtScreen *vs = &_vm->_virtscr[kMainVirtScreen];
- for (int i = 0; i < _numSpritesToProcess; ++i) {
- SpriteInfo *spi = _activeSpritesTable[i];
- if (!(spi->flags & kSFRender)) {
- if ((!checkZOrder || spi->priority >= 0) && (spi->flags & kSFSmartRender)) {
- int32 lp = spi->lastRect.left / 8;
- lp = MAX((int32)0, lp);
- lp = MIN(lp, _vm->_gdi->_numStrips);
- int32 rp = (spi->lastRect.right + 7) / 8;
- rp = MAX((int32)0, rp);
- rp = MIN(rp, _vm->_gdi->_numStrips);
- for (; lp < rp; lp++) {
- if (vs->tdirty[lp] < vs->h && spi->lastRect.bottom >= vs->tdirty[lp] && spi->lastRect.top <= vs->bdirty[lp]) {
- spi->flags |= kSFRender;
- break;
- }
- }
+ int strips = _vm->_gdi->_numStrips;
+ int stripsBytes = 8;
+
+ y1 = rectPtr->top;
+ y2 = rectPtr->bottom;
+
+ sMin = rectPtr->left / stripsBytes;
+ _vm->_gdi->_numStrips;
+ sMin = MAX(0, MIN(sMin, (strips - 1)));
+ sMax = (rectPtr->right + stripsBytes - 1) / stripsBytes;
+ sMax = MAX(0, MIN(sMax, (strips - 1)));
+
+ for (int i = sMin; i <= sMax; i++) {
+ minValue = vs->tdirty[i];
+ if (minValue >= vs->h)
+ continue;
+
+ if (y2 < minValue)
+ continue;
+
+ if (y1 > vs->bdirty[i])
+ continue;
+
+ return true;
+ }
+
+ return false;
+}
+
+void Sprite::checkForForcedRedraws(bool checkOnlyPositivePriority) {
+ if (_vm->_game.heversion < 90)
+ return;
+
+ SpriteInfo **spritePtr;
+ int32 flags;
+
+ spritePtr = _activeSprites;
+
+ for (int i = 0; i < _activeSpriteCount; i++) {
+ flags = spritePtr[i]->flags;
+ if (flags & (kSFRender | kSFIgnoreRender)) {
+ continue;
+ }
+
+ if (_vm->_game.heversion > 90) {
+ if (checkOnlyPositivePriority && (spritePtr[i]->priority < 0)) {
+ continue;
+ }
+ }
+
+ if (kSFSmartRender & flags) {
+ if (doesRectIntersectUpdateAreas(&spritePtr[i]->lastRect)) {
+ spritePtr[i]->flags |= kSFRender;
}
}
}
}
-void Sprite::updateImages() {
- for (int i = 0; i < _numSpritesToProcess; ++i) {
- SpriteInfo *spi = _activeSpritesTable[i];
- if (spi->deltaPosX || spi->deltaPosY) {
- int tx = spi->posX;
- int ty = spi->posY;
- spi->posX += spi->deltaPosX;
- spi->posY += spi->deltaPosY;
- if (tx != spi->posX || ty != spi->posY) {
- spi->flags |= kSFErase | kSFRender;
- }
+void Sprite::runSpriteEngines() {
+ int lastIndex, index, lastState;
+ SpriteImageList *imageListPtr;
+ SpriteInfo **spritePtr;
+ int32 flags;
+
+ spritePtr = _activeSprites;
+
+ for (int i = 0; i < _activeSpriteCount; i++) {
+ // Handle movement
+ if (spritePtr[i]->deltaPosX || spritePtr[i]->deltaPosY) {
+ moveSprite(
+ spritePtr[i] - _spriteTable,
+ spritePtr[i]->deltaPosX, spritePtr[i]->deltaPosY);
}
- if (spi->flags & kSFAutoAnimate) {
- if (spi->animSpeed) {
- --spi->animState;
- if (spi->animState)
- continue;
- spi->animState = spi->animSpeed;
+ // Handle animation...
+ if ((flags = spritePtr[i]->flags) & kSFAutoAnimate) {
+ // Check to see if the speed is set!
+ if (_vm->_game.heversion >= 95) {
+ if (spritePtr[i]->animSpeed) {
+ if (--spritePtr[i]->animState) {
+ continue;
+ }
+
+ spritePtr[i]->animState = spritePtr[i]->animSpeed;
+ }
}
- int imageState = spi->state;
- ++spi->state;
- if (spi->state >= spi->maxStates) {
- spi->state = 0;
- if (imageState == 0)
- continue;
+
+ // Handle "state" animation...
+ lastState = spritePtr[i]->state;
+ spritePtr[i]->state++;
+
+ if ((spritePtr[i]->state >= spritePtr[i]->maxStates)) {
+ spritePtr[i]->state = 0;
+ if (!spritePtr[i]->imageList) {
+ if (lastState) {
+ spritePtr[i]->flags |= (kSFRender | kSFErase);
+ }
+ } else {
+ // Handle image list animation...
+ if (!(flags & kSFDontAnimImageList)) {
+ imageListPtr = getImageListPtr(spritePtr[i]->imageList);
+ index = lastIndex = spritePtr[i]->animIndex;
+
+ if ((++index) >= imageListPtr->count) {
+ index = 0;
+ }
+
+ if (lastIndex != index) {
+ spritePtr[i]->animIndex = index;
+ spritePtr[i]->image = imageListPtr->list[index];
+ spritePtr[i]->flags |= (kSFRender | kSFErase);
+ spritePtr[i]->maxStates = _vm->_wiz->getWizStateCount(spritePtr[i]->image);
+ }
+ }
+ }
+ } else {
+ spritePtr[i]->flags |= (kSFRender | kSFErase);
}
- spi->flags |= kSFErase | kSFRender;
}
}
}
-static int compareSprTable(const void *a, const void *b) {
+static int compareSpritePriority(const void *a, const void *b) {
const SpriteInfo *spr1 = *(const SpriteInfo *const*)a;
const SpriteInfo *spr2 = *(const SpriteInfo *const*)b;
@@ -1215,181 +1611,239 @@ static int compareSprTable(const void *a, const void *b) {
return 0;
}
-void Sprite::sortActiveSprites() {
- int groupZorder;
+void Sprite::buildActiveSpriteList() {
+ SpriteInfo **spritePtr;
- _numSpritesToProcess = 0;
+ // Build the list of active sprites
+ _activeSpriteCount = 0;
+ spritePtr = _activeSprites;
- if (_varNumSprites <= 1)
- return;
-
- for (int i = 1; i < _varNumSprites; i++) {
- SpriteInfo *spi = &_spriteTable[i];
+ for (int i = 1; i < _maxSprites; i++) {
+ if (!(_spriteTable[i].flags & kSFActive))
+ continue;
- if (spi->flags & kSFActive) {
- if (!(spi->flags & kSFSmartRender)) {
- spi->flags |= kSFRender;
- if (!(spi->flags & kSFIgnoreErase))
- spi->flags |= kSFErase;
+ if (!(_spriteTable[i].flags & kSFSmartRender)) {
+ if (!(_spriteTable[i].flags & kSFIgnoreRender)) {
+ _spriteTable[i].flags |= kSFRender;
}
- if (spi->group)
- groupZorder = _spriteGroups[spi->group].priority;
- else
- groupZorder = 0;
- spi->id = i;
- spi->combinedPriority = spi->priority + groupZorder;
+ if (!(_spriteTable[i].flags & kSFIgnoreErase)) {
+ _spriteTable[i].flags |= kSFErase;
+ }
+ }
- _activeSpritesTable[_numSpritesToProcess++] = spi;
+ if (_vm->_game.heversion > 90) {
+ _spriteTable[i].combinedPriority = (_spriteTable[i].priority +
+ (((_spriteTable[i].group) ? _groupTable[_spriteTable[i].group].priority : 0)));
}
- }
- if (_numSpritesToProcess < 2)
- return;
+ *spritePtr++ = &_spriteTable[i];
+ _activeSpriteCount++;
+ }
- qsort(_activeSpritesTable, _numSpritesToProcess, sizeof(SpriteInfo *), compareSprTable);
+ // Sort the list of active sprites...
+ if (_activeSpriteCount) {
+ qsort(_activeSprites, _activeSpriteCount, sizeof(SpriteInfo *), compareSpritePriority);
+ }
}
-void Sprite::renderSprites(bool arg) {
- int spr_flags;
- int32 spr_wiz_x, spr_wiz_y;
- int image, imageState;
- Common::Rect *bboxPtr;
- int angle, scale;
- int32 w, h;
- WizImageCommand wiz;
- wiz.reset();
+void Sprite::renderSprites(bool negativeOrPositiveRender) {
+ int image, group, shadow, state, angle;
+ int sourceImage, scale, destImageNumber;
+ WizImageCommand imageRenderCmd;
+ Common::Rect clippedLastRect;
+ Common::Rect *clipRectPtr;
+ SpriteInfo **spritePtr;
+ int32 flags, renderFlags;
+ bool angleSpecified;
+ bool scaleSpecified;
+ Common::Point spot;
- for (int i = 0; i < _numSpritesToProcess; i++) {
- SpriteInfo *spi = _activeSpritesTable[i];
+ spritePtr = _activeSprites;
- if (!(spi->flags & kSFRender))
- continue;
+ for (int i = 0; i < _activeSpriteCount; i++) {
+ // Get the current flags & clear the render flag...
+ flags = spritePtr[i]->flags;
- spr_flags = spi->flags;
+ // Check to see if this sprite needs to render...
+ if (!(flags & kSFRender)) {
+ continue;
+ }
- if (arg) {
- if (spi->combinedPriority >= 0)
- return;
+ // This code is how we draw the negative priority sprites first.
+ // If it reaches a positive priority it stops, because the active list
+ // should be sorted by this point...
+ if (negativeOrPositiveRender) {
+ if (spritePtr[i]->combinedPriority >= 0) {
+ break;
+ }
} else {
- if (spi->combinedPriority < 0)
+ if (spritePtr[i]->combinedPriority < 0) {
continue;
+ }
}
- spi->flags &= ~kSFRender;
- image = spi->image;
- imageState = spi->state;
- _vm->_wiz->getWizImageSpot(spi->image, spi->state, spr_wiz_x, spr_wiz_y);
+ // Clear the sprite render flag...
+ spritePtr[i]->flags &= ~kSFRender;
- if (spi->group) {
- SpriteGroup *spg = &_spriteGroups[spi->group];
+ // Get the current image and the rect it will render to...
+ image = spritePtr[i]->image;
+ state = spritePtr[i]->state;
- if (spg->scaling) {
- wiz.xPos = spi->posX * spg->scale_x_ratio_mul / spg->scale_x_ratio_div - spr_wiz_x + spg->tx;
- wiz.yPos = spi->posY * spg->scale_y_ratio_mul / spg->scale_y_ratio_div - spr_wiz_y + spg->ty;
- } else {
- wiz.xPos = spi->posX - spr_wiz_x + spg->tx;
- wiz.yPos = spi->posY - spr_wiz_y + spg->ty;
- }
- } else {
- wiz.xPos = spi->posX - spr_wiz_x;
- wiz.yPos = spi->posY - spr_wiz_y;
+ int32 spotX, spotY;
+ calcSpriteSpot(spritePtr[i], true, spotX, spotY);
+
+ // In the hope that it never overflows...
+ spot.x = (int16)spotX;
+ spot.y = (int16)spotY;
+
+ // Setup the image render command...
+ imageRenderCmd.extendedRenderInfo.sprite = (int32)(spritePtr[i] - _spriteTable);
+ imageRenderCmd.extendedRenderInfo.group = spritePtr[i]->group;
+ imageRenderCmd.extendedRenderInfo.conditionBits = spritePtr[i]->conditionBits;
+
+ imageRenderCmd.actionFlags = kWAFSpot;
+ imageRenderCmd.xPos = spot.x;
+ imageRenderCmd.yPos = spot.y;
+
+ imageRenderCmd.actionFlags |= kWAFState;
+ imageRenderCmd.image = image;
+ imageRenderCmd.state = state;
+
+ spritePtr[i]->lastAngle = spritePtr[i]->angle;
+ spritePtr[i]->lastScale = spritePtr[i]->scale;
+ spritePtr[i]->lastImage = image;
+ spritePtr[i]->lastState = state;
+ spritePtr[i]->lastSpot = spot;
+
+ // The the potential update rect (we'll clip it later)
+ getSpriteRectPrim(spritePtr[i], &spritePtr[i]->lastRect, true, &spot);
+
+ // Setup the renderFlags
+ renderFlags = kWRFForeground;
+
+ if (flags & kSFHFlip) {
+ renderFlags |= kWRFHFlip;
}
- wiz.extendedRenderInfo.sprite = spi->id;
- wiz.extendedRenderInfo.group = spi->group;
- wiz.extendedRenderInfo.conditionBits = spi->conditionBits;
- spi->lastState = wiz.state = imageState;
- spi->lastImage = wiz.image = image;
- wiz.actionFlags = kWAFState | kWAFSpot;
- spi->lastAngle = spi->angle;
- spi->lastScale = spi->scale;
- spi->lastSpot.x = wiz.xPos;
- spi->lastSpot.y = wiz.yPos;
- bboxPtr = &spi->lastRect;
- if (image) {
- angle = spi->angle;
- scale = spi->scale;
- _vm->_wiz->getWizImageDim(image, imageState, w, h);
- if (spi->flags & (kSFScaleSpecified | kSFAngleSpecified)) {
- Common::Point pts[4];
- _vm->_wiz->polygonTransform(image, imageState, wiz.xPos, wiz.yPos, angle, scale, pts);
- _vm->_wiz->polyBuildBoundingRect(pts, 4, spi->lastRect);
- } else {
- bboxPtr->left = wiz.xPos;
- bboxPtr->top = wiz.yPos;
- bboxPtr->right = wiz.xPos + w;
- bboxPtr->bottom = wiz.yPos + h;
- }
- } else {
- bboxPtr->left = 1234;
- bboxPtr->top = 1234;
- bboxPtr->right = -1234;
- bboxPtr->bottom = -1234;
+ if (flags & kSFVFlip) {
+ renderFlags |= kWRFVFlip;
}
- wiz.flags = kWRFForeground;
- wiz.zPos = 0;
- if (spr_flags & kSFHFlip)
- wiz.flags |= kWRFHFlip;
- if (spr_flags & kSFVFlip)
- wiz.flags |= kWRFVFlip;
- if (spr_flags & kSFBackgroundRender) {
- wiz.flags &= ~kWRFForeground;
- wiz.flags |= kWRFBackground;
+ if (flags & kSFBackgroundRender) {
+ renderFlags &= ~kWRFForeground;
+ renderFlags |= kWRFBackground;
}
- if (spi->shadow) {
- wiz.flags |= kWRFUseShadow;
- wiz.actionFlags |= kWAFShadow;
- wiz.shadow = spi->shadow;
+
+ // Check to see if there is any shadow attached to this sprite...
+ shadow = spritePtr[i]->shadow;
+ if (shadow != 0) {
+ renderFlags |= kWRFUseShadow;
+ imageRenderCmd.actionFlags |= kWAFShadow;
+ imageRenderCmd.shadow = shadow;
}
- if (spr_flags & kSFUseImageRemap)
- wiz.flags |= kWRFRemap;
- if (spi->zbufferImage) {
- wiz.actionFlags |= kWAFZBufferImage;
- wiz.zbufferImage = spi->zbufferImage;
- wiz.zPos = spi->priority;
+
+ // Check to see if the sprite is supposed to remap...
+ if (flags & kSFUseImageRemap) {
+ renderFlags |= kWRFRemap;
}
- if (spi->sourceImage) {
- wiz.actionFlags |= kWAFSourceImage;
- wiz.sourceImage = spi->sourceImage;
+
+ // Handle Z-Clipping
+ if (spritePtr[i]->zbufferImage != 0) {
+ imageRenderCmd.actionFlags |= kWAFZBufferImage;
+ imageRenderCmd.zbufferImage = spritePtr[i]->zbufferImage;
+ imageRenderCmd.zPos = spritePtr[i]->priority;
}
- wiz.actionFlags |= kWAFFlags;
- wiz.flags |= spi->specialRenderFlags;
- if (spr_flags & kSFAngleSpecified) {
- wiz.actionFlags |= kWAFAngle;
- wiz.angle = spi->angle;
+ // Set the source image...
+ sourceImage = spritePtr[i]->sourceImage;
+ if (sourceImage != 0) {
+ imageRenderCmd.actionFlags |= kWAFSourceImage;
+ imageRenderCmd.sourceImage = sourceImage;
}
- if (spr_flags & kSFScaleSpecified) {
- wiz.actionFlags |= kWAFScale;
- wiz.scale = spi->scale;
+
+ renderFlags |= spritePtr[i]->specialRenderFlags;
+
+ // Finally set the image render flags
+ imageRenderCmd.actionFlags |= kWAFFlags;
+ imageRenderCmd.flags = renderFlags;
+
+ // Read the angle/scale variables
+ angle = spritePtr[i]->angle;
+ scale = spritePtr[i]->scale;
+
+ scaleSpecified = (spritePtr[i]->flags & kSFScaleSpecified);
+ angleSpecified = (spritePtr[i]->flags & kSFAngleSpecified);
+
+ // Check for "complex" image draw mode...
+ if (angleSpecified) {
+ imageRenderCmd.actionFlags |= kWAFAngle;
+ imageRenderCmd.angle = angle;
}
- spi->lastRenderFlags = wiz.flags;
-
- if (spi->group && (_spriteGroups[spi->group].flags & kSGFUseClipRect)) {
- Common::Rect &spgBbox = _spriteGroups[spi->group].bbox;
- if (spgBbox.isValidRect() && spi->lastRect.intersects(spgBbox)) {
- spi->lastRect.clip(spgBbox);
- wiz.actionFlags |= kWAFRect;
- wiz.box = spi->lastRect;
+
+ if (scaleSpecified) {
+ imageRenderCmd.actionFlags |= kWAFScale;
+ imageRenderCmd.scale = scale;
+ }
+
+ // Store off the render flags
+ spritePtr[i]->lastRenderFlags = renderFlags;
+
+ // Check to see if the group has a clipping rect.
+ group = spritePtr[i]->group;
+ if (group != 0) {
+ if (_groupTable[group].flags & kSGFUseClipRect) {
+ if (!_vm->_wiz->findRectOverlap(&spritePtr[i]->lastRect, &_groupTable[group].clipRect)) {
+ spritePtr[i]->lastRect.left = 1234;
+ spritePtr[i]->lastRect.top = 1234;
+ spritePtr[i]->lastRect.right = -1234;
+ spritePtr[i]->lastRect.bottom = -1234;
+
+ continue;
+ }
+
+ // Setup the clipping rect to the overlap rect.
+ // This will eventually be clipped down to the
+ // limits of the bitmap
+ imageRenderCmd.actionFlags |= kWAFRect;
+ imageRenderCmd.box.left= spritePtr[i]->lastRect.left;
+ imageRenderCmd.box.top = spritePtr[i]->lastRect.top;
+ imageRenderCmd.box.right = spritePtr[i]->lastRect.right;
+ imageRenderCmd.box.bottom = spritePtr[i]->lastRect.bottom;
+
+ clippedLastRect = spritePtr[i]->lastRect;
+ clipRectPtr = &clippedLastRect;
} else {
- bboxPtr->left = 1234;
- bboxPtr->top = 1234;
- bboxPtr->right = -1234;
- bboxPtr->bottom = -1234;
- continue;
+ clipRectPtr = nullptr;
}
+ } else {
+ clipRectPtr = nullptr;
+ }
+
+ // Finally get down to business and render the wiz
+ // get the palette
+ if (spritePtr[i]->palette != 0) {
+ imageRenderCmd.actionFlags |= kWAFPalette;
+ imageRenderCmd.palette = spritePtr[i]->palette;
}
- if (spi->palette) {
- wiz.actionFlags |= kWAFPalette;
- wiz.palette = spi->palette;
+
+ // get the associated dest image if any
+ destImageNumber = getDestImageForSprite(spritePtr[i]);
+
+ if (destImageNumber) {
+ imageRenderCmd.actionFlags |= kWAFDestImage;
+ imageRenderCmd.destImageNumber = destImageNumber;
}
- if (spi->image && spi->group && _spriteGroups[spi->group].image) {
- wiz.actionFlags |= kWAFDestImage;
- wiz.destImageNumber = _spriteGroups[spi->group].image;
+
+ // Finally actually do something by calling the command parser
+ // this function is the same core that renders images via the
+ // "image" draw command.
+ if (_vm->_game.heversion > 99) {
+ imageRenderCmd.actionType = kWADraw;
+ _vm->_wiz->processWizImageCmd(&imageRenderCmd);
+ } else {
+ _vm->_wiz->processWizImageDrawCmd(&imageRenderCmd);
}
- _vm->_wiz->processWizImageDrawCmd(&wiz);
}
}
@@ -1435,37 +1889,37 @@ static void syncWithSerializer(Common::Serializer &s, SpriteInfo &si) {
}
static void syncWithSerializer(Common::Serializer &s, SpriteGroup &sg) {
- s.syncAsSint32LE(sg.bbox.left, VER(48));
- s.syncAsSint32LE(sg.bbox.top, VER(48));
- s.syncAsSint32LE(sg.bbox.right, VER(48));
- s.syncAsSint32LE(sg.bbox.bottom, VER(48));
+ s.syncAsSint32LE(sg.clipRect.left, VER(48));
+ s.syncAsSint32LE(sg.clipRect.top, VER(48));
+ s.syncAsSint32LE(sg.clipRect.right, VER(48));
+ s.syncAsSint32LE(sg.clipRect.bottom, VER(48));
s.syncAsSint32LE(sg.priority, VER(48));
s.syncAsSint32LE(sg.flags, VER(48));
- s.syncAsSint32LE(sg.tx, VER(48));
- s.syncAsSint32LE(sg.ty, VER(48));
+ s.syncAsSint32LE(sg.posX, VER(48));
+ s.syncAsSint32LE(sg.posY, VER(48));
s.syncAsSint32LE(sg.image, VER(48));
- s.syncAsSint32LE(sg.scaling, VER(48));
- s.syncAsSint32LE(sg.scale_x_ratio_mul, VER(48));
- s.syncAsSint32LE(sg.scale_x_ratio_div, VER(48));
- s.syncAsSint32LE(sg.scale_y_ratio_mul, VER(48));
- s.syncAsSint32LE(sg.scale_y_ratio_div, VER(48));
+ s.syncAsSint32LE(sg.isScaled, VER(48));
+ s.syncAsSint32LE(sg.xMul, VER(48));
+ s.syncAsSint32LE(sg.xDiv, VER(48));
+ s.syncAsSint32LE(sg.yMul, VER(48));
+ s.syncAsSint32LE(sg.yDiv, VER(48));
}
void Sprite::saveLoadWithSerializer(Common::Serializer &s) {
if (s.getVersion() >= VER(64)) {
- s.syncArray(_spriteTable, _varNumSprites + 1, syncWithSerializer);
- s.syncArray(_spriteGroups, _varNumSpriteGroups + 1, syncWithSerializer);
+ s.syncArray(_spriteTable, _maxSprites + 1, syncWithSerializer);
+ s.syncArray(_groupTable, _maxSpriteGroups + 1, syncWithSerializer);
} else {
// TODO: This had been bogus, what is it really supposed to do?
-// s->saveLoadArrayOf(_activeSpritesTable, _varNumSprites, sizeof(_activeSpritesTable[0]), spriteEntries);
- s.syncArray(*_activeSpritesTable, _varNumSprites, syncWithSerializer);
- s.syncArray(_spriteTable, _varNumSprites, syncWithSerializer);
- s.syncArray(_spriteGroups, _varNumSpriteGroups, syncWithSerializer);
+// s->saveLoadArrayOf(_activeSprites, _maxSprites, sizeof(_activeSprites[0]), spriteEntries);
+ s.syncArray(*_activeSprites, _maxSprites, syncWithSerializer);
+ s.syncArray(_spriteTable, _maxSprites, syncWithSerializer);
+ s.syncArray(_groupTable, _maxSpriteGroups, syncWithSerializer);
}
// Reset active sprite table
if (s.isLoading())
- _numSpritesToProcess = 0;
+ _activeSpriteCount = 0;
}
} // End of namespace Scumm
diff --git a/engines/scumm/he/sprite_he.h b/engines/scumm/he/sprite_he.h
index 552227af55c..4befc518067 100644
--- a/engines/scumm/he/sprite_he.h
+++ b/engines/scumm/he/sprite_he.h
@@ -26,6 +26,10 @@
namespace Scumm {
+#define SPRDEF_DUMB 0
+#define SPRDEF_SMART 1
+#define SPRDEF_SIMPLE 2
+
enum SpriteFlags {
kSFErase = 0x00000001,
kSFRender = 0x00000002,
@@ -41,11 +45,15 @@ enum SpriteFlags {
kSFDontAnimImageList = 0x01000000,
kSFDontCombineErase = 0x02000000,
kSFIgnoreRender = 0x20000000,
- kSFIgnoreErase = 0x40000000
+ kSFIgnoreErase = 0x40000000,
+
+ // Defaults
+ kSFDefaultFlagInactive = (kSFErase | kSFDontCombineErase),
+ kSFDefaultFlagActive = (kSFActive | kSFAutoAnimate | kSFSmartRender | kSFDontCombineErase)
};
enum SpriteGroupFlags {
- kSGFUseClipRect = (1 << 0)
+ kSGFUseClipRect = 0x00000001
};
enum SpritePropertySubOps {
@@ -74,6 +82,13 @@ enum SpriteGroupSubOps {
SPRGRPOP_SHADOW = 8,
};
+enum SpriteProperties {
+ SPRPROP_SPECIAL_RENDER_FLAGS = 123,
+ SPRPROP_SPECIAL_BLEND_FLAGS = 124,
+ SPRPROP_CONDITION_BITS = 125,
+ SPRPROP_ANIMATION_SUB_STATE = 126
+};
+
enum PolygonOverlapSubOps {
OVERLAP_POINT_TO_RECT = 1,
OVERLAP_POINT_TO_CIRCLE = 2,
@@ -161,31 +176,40 @@ struct SpriteInfo {
}
};
+struct SpriteImageList {
+ int16 list[32];
+ int16 count;
+};
+
struct SpriteGroup {
- Common::Rect bbox;
+ Common::Rect clipRect;
int32 priority;
int32 flags;
- int32 tx;
- int32 ty;
+ int32 posX;
+ int32 posY;
int32 image;
- int32 scaling;
- int32 scale_x_ratio_mul;
- int32 scale_x_ratio_div;
- int32 scale_y_ratio_mul;
- int32 scale_y_ratio_div;
+ int32 isScaled;
+ float xScale;
+ float yScale;
+ int32 xMul;
+ int32 xDiv;
+ int32 yMul;
+ int32 yDiv;
void reset() {
- bbox.top = bbox.left = bbox.bottom = bbox.right = 0;
+ clipRect.top = clipRect.left = clipRect.bottom = clipRect.right = 0;
priority = 0;
flags = 0;
- tx = 0;
- ty = 0;
+ posX = 0;
+ posY = 0;
image = 0;
- scaling = 0;
- scale_x_ratio_mul = 0;
- scale_x_ratio_div = 0;
- scale_y_ratio_mul = 0;
- scale_y_ratio_div = 0;
+ isScaled = 0;
+ xScale = 0.0F;
+ yScale = 0.0F;
+ xMul = 0;
+ xDiv = 0;
+ yMul = 0;
+ yDiv = 0;
}
};
@@ -197,31 +221,36 @@ public:
~Sprite() override;
SpriteInfo *_spriteTable;
- SpriteGroup *_spriteGroups;
- SpriteInfo **_activeSpritesTable;
+ SpriteGroup *_groupTable;
+ SpriteInfo **_activeSprites;
+ SpriteImageList *_imageLists;
+ int16 *_imageListStack;
- int32 _numSpritesToProcess;
- int32 _varNumSpriteGroups;
- int32 _varNumSprites;
- int32 _varMaxSprites;
+ int32 _imageListStackIndex = 0;
+ int32 _activeSpriteCount;
+ int32 _maxSpriteGroups;
+ int32 _maxSprites;
+ int32 _maxImageLists;
void saveLoadWithSerializer(Common::Serializer &s) override;
- void resetBackground();
- void checkForForcedRedraws(bool checkZOrder);
- void sortActiveSprites();
+ void eraseSprites();
+ bool doesRectIntersectUpdateAreas(const Common::Rect *rectPtr);
+ void checkForForcedRedraws(bool checkOnlyPositivePriority);
+ void buildActiveSpriteList();
void renderSprites(bool arg);
- void updateImages();
-
- int findSpriteWithClassOf(int x, int y, int spriteGroupId, int d, int num, int *args);
- int getSpriteClass(int spriteId, int num, int *args);
- int getSpriteFlagDoubleBuffered(int spriteId);
- int getSpriteFlagYFlipped(int spriteId);
- int getSpriteFlagXFlipped(int spriteId);
- int getSpriteFlagActive(int spriteId);
- int getSpriteFlagRemapPalette(int spriteId);
- int getSpriteFlagAutoAnim(int spriteId);
- int getSpriteFlagUpdateType(int spriteId);
- int getSpriteFlagEraseType(int spriteId);
+ void runSpriteEngines();
+
+ int spriteFromPoint(int x, int y, int spriteGroupId, int d, int num, int *args);
+ int getSpriteClass(int spriteId, int num);
+ int checkSpriteClassAgaintClassSet(int sprite, int classCount, int *classCheckTable);
+ int getSpriteRenderToBackground(int spriteId);
+ int getSpriteVertFlip(int spriteId);
+ int getSpriteHorzFlip(int spriteId);
+ int getSpriteActiveFlag(int spriteId);
+ int getSpriteImageRemapFlag(int spriteId);
+ int getSpriteAutoAnimFlag(int spriteId);
+ int getSpriteUpdateType(int spriteId);
+ int getSpriteEraseType(int spriteId);
int getSpriteImage(int spriteId);
int getSpriteImageState(int spriteId);
int getSpriteGroup(int spriteId);
@@ -229,80 +258,94 @@ public:
int getSpritePriority(int spriteId);
int getSpriteDisplayX(int spriteId);
int getSpriteDisplayY(int spriteId);
- int getSpriteUserValue(int spriteId);
+ int getUserValue(int spriteId);
int getSpriteShadow(int spriteId);
int getSpriteImageStateCount(int spriteId);
int getSpriteScale(int spriteId);
int getSpriteAnimSpeed(int spriteId);
- int getSpriteSourceImage(int spriteId);
- int getSpriteMaskImage(int spriteId);
+ int getSourceImage(int spriteId);
+ int getMaskImage(int spriteId);
int getSpriteGeneralProperty(int spriteId, int type);
- void getSpriteBounds(int spriteId, bool checkGroup, Common::Rect &bound);
+ int getDestImageForSprite(const SpriteInfo *spritePtr);
+ int getSpriteAnimSpeedState(int sprite);
+ void getSpriteLogicalRect(int spriteId, bool checkGroup, Common::Rect &bound);
void getSpriteImageDim(int spriteId, int32 &w, int32 &h);
void getSpritePosition(int spriteId, int32 &tx, int32 &ty);
- void getSpriteDist(int spriteId, int32 &dx, int32 &dy);
+ void getSpriteRectPrim(const SpriteInfo *spritePtr, Common::Rect *rectPtr, bool includeGroupTransform, const Common::Point *spotPtr);
+ void getDelta(int spriteId, int32 &dx, int32 &dy);
+ void calcSpriteSpot(const SpriteInfo *spritePtr, bool includeGroupTransform, int32 &x, int32 &y);
int getGroupPriority(int spriteGroupId);
- int getGroupDstResNum(int spriteGroupId);
+ int getGroupImage(int spriteGroupId);
int getGroupXMul(int spriteGroupId);
int getGroupXDiv(int spriteGroupId);
int getGroupYMul(int spriteGroupId);
int getGroupYDiv(int spriteGroupId);
- void getGroupPosition(int spriteGroupId, int32 &tx, int32 &ty);
+ void getGroupPoint(int spriteGroupId, int32 &tx, int32 &ty);
void setSpritePalette(int spriteId, int value);
- void setSpriteSourceImage(int spriteId, int value);
- void setSpriteMaskImage(int spriteId, int value);
- void resetSprite(int spriteId);
+ void setSourceImage(int spriteId, int value);
+ void setMaskImage(int spriteId, int value);
+ void newSprite(int spriteId);
void setSpriteImageState(int spriteId, int value);
void setSpritePosition(int spriteId, int value1, int value2);
void setSpriteGroup(int spriteId, int value);
- void setSpriteDist(int spriteId, int value1, int value2);
+ void setDelta(int spriteId, int value1, int value2);
void setSpriteShadow(int spriteId, int value);
- void setSpriteUserValue(int spriteId, int value1, int value2);
+ void setUserValue(int spriteId, int value1, int value2);
void setSpritePriority(int spriteId, int value);
void moveSprite(int spriteId, int value1, int value2);
void setSpriteScale(int spriteId, int value);
void setSpriteAngle(int spriteId, int value);
- void setSpriteFlagDoubleBuffered(int spriteId, int value);
- void setSpriteFlagYFlipped(int spriteId, int value);
- void setSpriteFlagXFlipped(int spriteId, int value);
- void setSpriteFlagActive(int spriteId, int value);
- void setSpriteFlagRemapPalette(int spriteId, int value);
- void setSpriteFlagAutoAnim(int spriteId, int value);
- void setSpriteFlagUpdateType(int spriteId, int value);
- void setSpriteFlagEraseType(int spriteId, int value);
+ void setSpriteRenderToBackground(int spriteId, int value);
+ void setSpriteVertFlip(int spriteId, int value);
+ void setSpriteHorzFlip(int spriteId, int value);
+ void setSpriteActiveFlag(int spriteId, int value);
+ void setSpriteImageRemapFlag(int spriteId, int value);
+ void setSpriteAutoAnimFlag(int spriteId, int value);
+ void setSpriteUpdateType(int spriteId, int value);
+ void setSpriteEraseType(int spriteId, int value);
void setSpriteAnimSpeed(int spriteId, int value);
- void setSpriteSetClass(int spriteId, int classId, int toggle);
- void setSpriteResetClass(int spriteId);
+ void setSpriteClass(int spriteId, int classId, int toggle);
+ void clearSpriteClasses(int spriteId);
void setSpriteZBuffer(int spriteId, int value);
+ void setSpriteAnimSpeedState(int spriteId, int animState);
void setSpriteGeneralProperty(int spriteId, int type, int value);
+ void setImageList(int sprite, int count, const int *list);
void moveGroupMembers(int spriteGroupId, int value1, int value2);
- void redrawSpriteGroup(int spriteGroupId);
+ void orInGroupMembersFlags(int spriteGroupId, int32 flags);
void setGroupMembersPriority(int spriteGroupId, int value);
- void setGroupMembersGroup(int spriteGroupId, int value);
+ void changeGroupMembersGroup(int spriteGroupId, int value);
void setGroupMembersUpdateType(int spriteGroupId, int value);
- void setGroupMembersResetSprite(int spriteGroupId);
+ void performNewOnGroupMembers(int spriteGroupId);
void setGroupMembersAnimationSpeed(int spriteGroupId, int value);
void setGroupMembersAutoAnimFlag(int spriteGroupId, int value);
void setGroupMembersShadow(int spriteGroupId, int value);
void moveGroup(int spriteGroupId, int value1, int value2);
- void setGroupBounds(int spriteGroupId, int x1, int y1, int x2, int y2);
+ void setGroupClipRect(int spriteGroupId, int x1, int y1, int x2, int y2);
void setGroupPriority(int spriteGroupId, int value);
- void setGroupPosition(int spriteGroupId, int value1, int value2);
+ void setGroupPoint(int spriteGroupId, int value1, int value2);
void setGroupImage(int spriteGroupId, int value);
void setGroupScaling(int spriteGroupId);
void setGroupXMul(int spriteGroupId, int value);
void setGroupXDiv(int spriteGroupId, int value);
void setGroupYMul(int spriteGroupId, int value);
void setGroupYDiv(int spriteGroupId, int value);
- void resetGroupBounds(int spriteGroupId);
- void allocTables(int numSprites, int numGroups, int numMaxSprites);
- void resetGroup(int spriteGroupId);
- void resetTables(bool refreshScreen);
+ void clearGroupClipRect(int spriteGroupId);
+ void clearGroupScaleInfo(int group);
+
+ void resetImageLists();
+ SpriteImageList *getImageListPtr(int imageList);
+ int getFreeImageList(int imageCount);
+ void releaseImageList(int imageList);
+
+ void initializeStuff(int numSprites, int numGroups, int numMaxSprites);
+ void newGroup(int spriteGroupId);
+ void resetSpriteSystem(bool refreshScreen);
+
void setSpriteImage(int spriteId, int imageNum);
private:
ScummEngine_v90he *_vm;
diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp
index 11622125c5c..290ee688a13 100644
--- a/engines/scumm/he/wiz_he.cpp
+++ b/engines/scumm/he/wiz_he.cpp
@@ -47,1050 +47,6 @@ void Wiz::clearWizBuffer() {
_wizBufferIndex = 0;
}
-void Wiz::copyAuxImage(uint8 *dst1, uint8 *dst2, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, uint8 bitDepth) {
- assert(bitDepth == 1);
-
- Common::Rect dstRect(srcx, srcy, srcx + srcw, srcy + srch);
- dstRect.clip(dstw, dsth);
-
- int rw = dstRect.width();
- int rh = dstRect.height();
- if (rh <= 0 || rw <= 0)
- return;
-
- uint8 *dst1Ptr = dst1 + dstRect.top * dstw + dstRect.left;
- uint8 *dst2Ptr = dst2 + dstRect.top * dstw + dstRect.left;
- const uint8 *dataPtr = src;
-
- while (rh--) {
- uint16 off = READ_LE_UINT16(dataPtr); dataPtr += 2;
- const uint8 *dataPtrNext = off + dataPtr;
- uint8 *dst1PtrNext = dst1Ptr + dstw;
- uint8 *dst2PtrNext = dst2Ptr + dstw;
- if (off != 0) {
- int w = rw;
- while (w > 0) {
- uint8 code = *dataPtr++;
- if (code & 1) {
- code >>= 1;
- dst1Ptr += code;
- dst2Ptr += code;
- w -= code;
- } else if (code & 2) {
- code = (code >> 2) + 1;
- w -= code;
- if (w >= 0) {
- memset(dst1Ptr, *dataPtr++, code);
- dst1Ptr += code;
- dst2Ptr += code;
- } else {
- code += w;
- memset(dst1Ptr, *dataPtr, code);
- }
- } else {
- code = (code >> 2) + 1;
- w -= code;
- if (w >= 0) {
- memcpy(dst1Ptr, dst2Ptr, code);
- dst1Ptr += code;
- dst2Ptr += code;
- } else {
- code += w;
- memcpy(dst1Ptr, dst2Ptr, code);
- }
- }
- }
- }
- dataPtr = dataPtrNext;
- dst1Ptr = dst1PtrNext;
- dst2Ptr = dst2PtrNext;
- }
-}
-
-static bool calcClipRects(int dst_w, int dst_h, int src_x, int src_y, int src_w, int src_h, const Common::Rect *rect, Common::Rect &srcRect, Common::Rect &dstRect) {
- srcRect = Common::Rect(src_w, src_h);
- dstRect = Common::Rect(src_x, src_y, src_x + src_w, src_y + src_h);
- Common::Rect r3;
- int diff;
-
- if (rect) {
- r3 = *rect;
- Common::Rect r4(dst_w, dst_h);
- if (r3.intersects(r4)) {
- r3.clip(r4);
- } else {
- return false;
- }
- } else {
- r3 = Common::Rect(dst_w, dst_h);
- }
- diff = dstRect.left - r3.left;
- if (diff < 0) {
- srcRect.left -= diff;
- dstRect.left -= diff;
- }
- diff = dstRect.right - r3.right;
- if (diff > 0) {
- srcRect.right -= diff;
- dstRect.right -= diff;
- }
- diff = dstRect.top - r3.top;
- if (diff < 0) {
- srcRect.top -= diff;
- dstRect.top -= diff;
- }
- diff = dstRect.bottom - r3.bottom;
- if (diff > 0) {
- srcRect.bottom -= diff;
- dstRect.bottom -= diff;
- }
-
- return srcRect.isValidRect() && dstRect.isValidRect();
-}
-
-void Wiz::writeColor(uint8 *dstPtr, int dstType, uint16 color) {
- switch (dstType) {
- case kDstCursor:
- case kDstScreen:
- WRITE_UINT16(dstPtr, color);
- break;
- case kDstMemory:
- case kDstResource:
- WRITE_LE_UINT16(dstPtr, color);
- break;
- default:
- error("writeColor: Unknown dstType %d", dstType);
- }
-}
-
-#ifdef USE_RGB_COLOR
-void Wiz::copy16BitWizImage(uint8 *dst, const uint8 *src, int dstPitch, int dstType, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, const uint8 *xmapPtr) {
- Common::Rect r1, r2;
- if (calcClipRects(dstw, dsth, srcx, srcy, srcw, srch, rect, r1, r2)) {
- dst += r2.top * dstPitch + r2.left * 2;
- if (flags & kWRFVFlip) {
- const int dy = (srcy < 0) ? srcy : (srch - r1.height());
- r1.translate(0, dy);
- }
- if (flags & kWRFHFlip) {
- const int dx = (srcx < 0) ? srcx : (srcw - r1.width());
- r1.translate(dx, 0);
- }
- if (xmapPtr) {
- decompress16BitWizImage<kWizXMap>(dst, dstPitch, dstType, src, r1, flags, xmapPtr);
- } else {
- decompress16BitWizImage<kWizCopy>(dst, dstPitch, dstType, src, r1, flags);
- }
- }
-}
-#endif
-
-void Wiz::copyWizImage(uint8 *dst, const uint8 *src, int dstPitch, int dstType, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, const uint8 *palPtr, const uint8 *xmapPtr, uint8 bitDepth) {
- Common::Rect r1, r2;
- if (calcClipRects(dstw, dsth, srcx, srcy, srcw, srch, rect, r1, r2)) {
- dst += r2.top * dstPitch + r2.left * bitDepth;
- if (flags & kWRFVFlip) {
- const int dy = (srcy < 0) ? srcy : (srch - r1.height());
- r1.translate(0, dy);
- }
- if (flags & kWRFHFlip) {
- const int dx = (srcx < 0) ? srcx : (srcw - r1.width());
- r1.translate(dx, 0);
- }
- if (xmapPtr) {
- decompressWizImage<kWizXMap>(dst, dstPitch, dstType, src, r1, flags, palPtr, xmapPtr, bitDepth);
- } else if (palPtr) {
- decompressWizImage<kWizRMap>(dst, dstPitch, dstType, src, r1, flags, palPtr, nullptr, bitDepth);
- } else {
- decompressWizImage<kWizCopy>(dst, dstPitch, dstType, src, r1, flags, nullptr, nullptr, bitDepth);
- }
- }
-}
-
-static void decodeWizMask(uint8 *&dst, uint8 &mask, int w, int maskType) {
- switch (maskType) {
- case 0:
- while (w--) {
- mask >>= 1;
- if (mask == 0) {
- mask = 0x80;
- ++dst;
- }
- }
- break;
- case 1:
- while (w--) {
- *dst &= ~mask;
- mask >>= 1;
- if (mask == 0) {
- mask = 0x80;
- ++dst;
- }
- }
- break;
- case 2:
- while (w--) {
- *dst |= mask;
- mask >>= 1;
- if (mask == 0) {
- mask = 0x80;
- ++dst;
- }
- }
- break;
- default:
- break;
- }
-}
-
-#ifdef USE_RGB_COLOR
-void Wiz::copyMaskWizImage(uint8 *dst, const uint8 *src, const uint8 *mask, int dstPitch, int dstType, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, const uint8 *palPtr) {
- Common::Rect srcRect, dstRect;
- if (!calcClipRects(dstw, dsth, srcx, srcy, srcw, srch, rect, srcRect, dstRect)) {
- return;
- }
- dst += dstRect.top * dstPitch + dstRect.left * 2;
- if (flags & kWRFVFlip) {
- const int dy = (srcy < 0) ? srcy : (srch - srcRect.height());
- srcRect.translate(0, dy);
- }
- if (flags & kWRFHFlip) {
- const int dx = (srcx < 0) ? srcx : (srcw - srcRect.width());
- srcRect.translate(dx, 0);
- }
-
- const uint8 *dataPtr, *dataPtrNext;
- const uint8 *maskPtr, *maskPtrNext;
- uint8 code, *dstPtr, *dstPtrNext;
- int h, w, dstInc;
-
- dataPtr = src;
- dstPtr = dst;
- maskPtr = mask;
-
- // Skip over the first 'srcRect->top' lines in the data
- dataPtr += dstRect.top * dstPitch + dstRect.left * 2;
-
- h = dstRect.height();
- w = dstRect.width();
- if (h <= 0 || w <= 0)
- return;
-
- dstInc = 2;
- if (flags & kWRFHFlip) {
- dstPtr += (w - 1) * 2;
- dstInc = -2;
- }
-
- while (h--) {
- w = dstRect.width();
- uint16 lineSize = READ_LE_UINT16(maskPtr); maskPtr += 2;
- dataPtrNext = dataPtr + dstPitch;
- dstPtrNext = dstPtr + dstPitch;
- maskPtrNext = maskPtr + lineSize;
- if (lineSize != 0) {
- while (w > 0) {
- code = *maskPtr++;
- if (code & 1) {
- code >>= 1;
- dataPtr += dstInc * code;
- dstPtr += dstInc * code;
- w -= code;
- } else if (code & 2) {
- code = (code >> 2) + 1;
- w -= code;
- if (w < 0) {
- code += w;
- }
- while (code--) {
- if (*maskPtr != 5)
- write16BitColor<kWizCopy>(dstPtr, dataPtr, dstType, palPtr);
- dataPtr += 2;
- dstPtr += dstInc;
- }
- maskPtr++;
- } else {
- code = (code >> 2) + 1;
- w -= code;
- if (w < 0) {
- code += w;
- }
- while (code--) {
- if (*maskPtr != 5)
- write16BitColor<kWizCopy>(dstPtr, dataPtr, dstType, palPtr);
- dataPtr += 2;
- dstPtr += dstInc;
- maskPtr++;
- }
- }
- }
- }
- dataPtr = dataPtrNext;
- dstPtr = dstPtrNext;
- maskPtr = maskPtrNext;
- }
-}
-#endif
-
-void Wiz::copyWizImageWithMask(uint8 *dst, const uint8 *src, int dstPitch, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int maskT, int maskP) {
- Common::Rect srcRect, dstRect;
- if (!calcClipRects(dstw, dsth, srcx, srcy, srcw, srch, rect, srcRect, dstRect)) {
- return;
- }
- dstPitch /= 8;
- dst += dstRect.top * dstPitch + dstRect.left / 8;
-
- const uint8 *dataPtr, *dataPtrNext;
- uint8 code, mask, *dstPtr, *dstPtrNext;
- int h, w, xoff;
- uint16 off;
-
- dstPtr = dst;
- dataPtr = src;
-
- // Skip over the first 'srcRect->top' lines in the data
- h = srcRect.top;
- while (h--) {
- dataPtr += READ_LE_UINT16(dataPtr) + 2;
- }
- h = srcRect.height();
- w = srcRect.width();
- if (h <= 0 || w <= 0)
- return;
-
- while (h--) {
- xoff = srcRect.left;
- w = srcRect.width();
- mask = revBitMask(dstRect.left & 7);
- off = READ_LE_UINT16(dataPtr); dataPtr += 2;
- dstPtrNext = dstPtr + dstPitch;
- dataPtrNext = dataPtr + off;
- if (off != 0) {
- while (w > 0) {
- code = *dataPtr++;
- if (code & 1) {
- code >>= 1;
- if (xoff > 0) {
- xoff -= code;
- if (xoff >= 0)
- continue;
-
- code = -xoff;
- }
- decodeWizMask(dstPtr, mask, code, maskT);
- w -= code;
- } else if (code & 2) {
- code = (code >> 2) + 1;
- if (xoff > 0) {
- xoff -= code;
- ++dataPtr;
- if (xoff >= 0)
- continue;
-
- code = -xoff;
- --dataPtr;
- }
- w -= code;
- if (w < 0) {
- code += w;
- }
- decodeWizMask(dstPtr, mask, code, maskP);
- dataPtr++;
- } else {
- code = (code >> 2) + 1;
- if (xoff > 0) {
- xoff -= code;
- dataPtr += code;
- if (xoff >= 0)
- continue;
-
- code = -xoff;
- dataPtr += xoff;
- }
- w -= code;
- if (w < 0) {
- code += w;
- }
- decodeWizMask(dstPtr, mask, code, maskP);
- dataPtr += code;
- }
- }
- }
- dataPtr = dataPtrNext;
- dstPtr = dstPtrNext;
- }
-}
-
-#ifdef USE_RGB_COLOR
-void Wiz::copyRaw16BitWizImage(uint8 *dst, const uint8 *src, int dstPitch, int dstType, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, int transColor) {
- Common::Rect r1, r2;
- if (calcClipRects(dstw, dsth, srcx, srcy, srcw, srch, rect, r1, r2)) {
- if (flags & kWRFHFlip) {
- int l = r1.left;
- int r = r1.right;
- r1.left = srcw - r;
- r1.right = srcw - l;
- }
- if (flags & kWRFVFlip) {
- int t = r1.top;
- int b = r1.bottom;
- r1.top = srch - b;
- r1.bottom = srch - t;
- }
- int h = r1.height();
- int w = r1.width();
- src += (r1.top * srcw + r1.left) * 2;
- dst += r2.top * dstPitch + r2.left * 2;
- while (h--) {
- for (int i = 0; i < w; ++ i) {
- uint16 col = READ_LE_UINT16(src + 2 * i);
- if (transColor == -1 || transColor != col) {
- writeColor(dst + i * 2, dstType, col);
- }
- }
- src += srcw * 2;
- dst += dstPitch;
- }
- }
-}
-#endif
-
-void Wiz::copyRawWizImage(uint8 *dst, const uint8 *src, int dstPitch, int dstType, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, const uint8 *palPtr, int transColor, uint8 bitDepth) {
- Common::Rect r1, r2;
- if (calcClipRects(dstw, dsth, srcx, srcy, srcw, srch, rect, r1, r2)) {
- if (flags & kWRFHFlip) {
- int l = r1.left;
- int r = r1.right;
- r1.left = srcw - r;
- r1.right = srcw - l;
- }
- if (flags & kWRFVFlip) {
- int t = r1.top;
- int b = r1.bottom;
- r1.top = srch - b;
- r1.bottom = srch - t;
- }
- int h = r1.height();
- int w = r1.width();
- src += r1.top * srcw + r1.left;
- dst += r2.top * dstPitch + r2.left * bitDepth;
- if (palPtr) {
- decompressRawWizImage<kWizRMap>(dst, dstPitch, dstType, src, srcw, w, h, transColor, palPtr, bitDepth);
- } else {
- decompressRawWizImage<kWizCopy>(dst, dstPitch, dstType, src, srcw, w, h, transColor, nullptr, bitDepth);
- }
- }
-}
-
-#ifdef USE_RGB_COLOR
-template<int type>
-void Wiz::write16BitColor(uint8 *dstPtr, const uint8 *dataPtr, int dstType, const uint8 *xmapPtr) {
- uint16 col = READ_LE_UINT16(dataPtr);
- if (type == kWizXMap) {
- uint16 srcColor = (col >> 1) & 0x7DEF;
- uint16 dstColor = (READ_UINT16(dstPtr) >> 1) & 0x7DEF;
- uint16 newColor = srcColor + dstColor;
- writeColor(dstPtr, dstType, newColor);
- }
- if (type == kWizCopy) {
- writeColor(dstPtr, dstType, col);
- }
-}
-
-template<int type>
-void Wiz::decompress16BitWizImage(uint8 *dst, int dstPitch, int dstType, const uint8 *src, const Common::Rect &srcRect, int flags, const uint8 *xmapPtr) {
- const uint8 *dataPtr, *dataPtrNext;
- uint8 code;
- uint8 *dstPtr, *dstPtrNext;
- int h, w, xoff, dstInc;
-
- if (type == kWizXMap) {
- assert(xmapPtr != 0);
- }
-
- dstPtr = dst;
- dataPtr = src;
-
- // Skip over the first 'srcRect->top' lines in the data
- h = srcRect.top;
- while (h--) {
- dataPtr += READ_LE_UINT16(dataPtr) + 2;
- }
- h = srcRect.height();
- w = srcRect.width();
- if (h <= 0 || w <= 0)
- return;
-
- if (flags & kWRFVFlip) {
- dstPtr += (h - 1) * dstPitch;
- dstPitch = -dstPitch;
- }
- dstInc = 2;
- if (flags & kWRFHFlip) {
- dstPtr += (w - 1) * 2;
- dstInc = -2;
- }
-
- while (h--) {
- xoff = srcRect.left;
- w = srcRect.width();
- uint16 lineSize = READ_LE_UINT16(dataPtr); dataPtr += 2;
- dstPtrNext = dstPtr + dstPitch;
- dataPtrNext = dataPtr + lineSize;
- if (lineSize != 0) {
- while (w > 0) {
- code = *dataPtr++;
- if (code & 1) {
- code >>= 1;
- if (xoff > 0) {
- xoff -= code;
- if (xoff >= 0)
- continue;
-
- code = -xoff;
- }
- dstPtr += dstInc * code;
- w -= code;
- } else if (code & 2) {
- code = (code >> 2) + 1;
- if (xoff > 0) {
- xoff -= code;
- dataPtr += 2;
- if (xoff >= 0)
- continue;
-
- code = -xoff;
- dataPtr -= 2;
- }
- w -= code;
- if (w < 0) {
- code += w;
- }
- while (code--) {
- write16BitColor<type>(dstPtr, dataPtr, dstType, xmapPtr);
- dstPtr += dstInc;
- }
- dataPtr += 2;
- } else {
- code = (code >> 2) + 1;
- if (xoff > 0) {
- xoff -= code;
- dataPtr += code * 2;
- if (xoff >= 0)
- continue;
-
- code = -xoff;
- dataPtr += xoff * 2;
- }
- w -= code;
- if (w < 0) {
- code += w;
- }
- while (code--) {
- write16BitColor<type>(dstPtr, dataPtr, dstType, xmapPtr);
- dataPtr += 2;
- dstPtr += dstInc;
- }
- }
- }
- }
- dataPtr = dataPtrNext;
- dstPtr = dstPtrNext;
- }
-}
-#endif
-
-template<int type>
-void Wiz::write8BitColor(uint8 *dstPtr, const uint8 *dataPtr, int dstType, const uint8 *palPtr, const uint8 *xmapPtr, uint8 bitDepth) {
- if (bitDepth == 2) {
- if (type == kWizXMap) {
- uint16 color = READ_LE_UINT16(palPtr + *dataPtr * 2);
- uint16 srcColor = (color >> 1) & 0x7DEF;
- uint16 dstColor = (READ_UINT16(dstPtr) >> 1) & 0x7DEF;
- uint16 newColor = srcColor + dstColor;
- writeColor(dstPtr, dstType, newColor);
- }
- if (type == kWizRMap) {
- writeColor(dstPtr, dstType, READ_LE_UINT16(palPtr + *dataPtr * 2));
- }
- if (type == kWizCopy) {
- writeColor(dstPtr, dstType, *dataPtr);
- }
- } else {
- if (type == kWizXMap) {
- *dstPtr = xmapPtr[*dataPtr * 256 + *dstPtr];
- }
- if (type == kWizRMap) {
- *dstPtr = palPtr[*dataPtr];
- }
- if (type == kWizCopy) {
- *dstPtr = *dataPtr;
- }
- }
-}
-
-template<int type>
-void Wiz::decompressWizImage(uint8 *dst, int dstPitch, int dstType, const uint8 *src, const Common::Rect &srcRect, int flags, const uint8 *palPtr, const uint8 *xmapPtr, uint8 bitDepth) {
- const uint8 *dataPtr, *dataPtrNext;
- uint8 code, *dstPtr, *dstPtrNext;
- int h, w, xoff, dstInc;
-
- if (type == kWizXMap) {
- assert(xmapPtr != 0);
- }
- if (type == kWizRMap) {
- assert(palPtr != 0);
- }
-
- dstPtr = dst;
- dataPtr = src;
-
- // Skip over the first 'srcRect->top' lines in the data
- h = srcRect.top;
- while (h--) {
- dataPtr += READ_LE_UINT16(dataPtr) + 2;
- }
- h = srcRect.height();
- w = srcRect.width();
- if (h <= 0 || w <= 0)
- return;
-
- if (flags & kWRFVFlip) {
- dstPtr += (h - 1) * dstPitch;
- dstPitch = -dstPitch;
- }
- dstInc = bitDepth;
- if (flags & kWRFHFlip) {
- dstPtr += (w - 1) * bitDepth;
- dstInc = -bitDepth;
- }
-
- while (h--) {
- xoff = srcRect.left;
- w = srcRect.width();
- uint16 lineSize = READ_LE_UINT16(dataPtr); dataPtr += 2;
- dstPtrNext = dstPtr + dstPitch;
- dataPtrNext = dataPtr + lineSize;
- if (lineSize != 0) {
- while (w > 0) {
- code = *dataPtr++;
- if (code & 1) {
- code >>= 1;
- if (xoff > 0) {
- xoff -= code;
- if (xoff >= 0)
- continue;
-
- code = -xoff;
- }
- dstPtr += dstInc * code;
- w -= code;
- } else if (code & 2) {
- code = (code >> 2) + 1;
- if (xoff > 0) {
- xoff -= code;
- ++dataPtr;
- if (xoff >= 0)
- continue;
-
- code = -xoff;
- --dataPtr;
- }
- w -= code;
- if (w < 0) {
- code += w;
- }
- while (code--) {
- write8BitColor<type>(dstPtr, dataPtr, dstType, palPtr, xmapPtr, bitDepth);
- dstPtr += dstInc;
- }
- dataPtr++;
- } else {
- code = (code >> 2) + 1;
- if (xoff > 0) {
- xoff -= code;
- dataPtr += code;
- if (xoff >= 0)
- continue;
-
- code = -xoff;
- dataPtr += xoff;
- }
- w -= code;
- if (w < 0) {
- code += w;
- }
- while (code--) {
- write8BitColor<type>(dstPtr, dataPtr, dstType, palPtr, xmapPtr, bitDepth);
- dataPtr++;
- dstPtr += dstInc;
- }
- }
- }
- }
- dataPtr = dataPtrNext;
- dstPtr = dstPtrNext;
- }
-}
-
-// NOTE: These templates are used outside this file. We don't want the compiler to optimize them away, so we need to explicitely instantiate them.
-template void Wiz::decompressWizImage<kWizXMap>(uint8 *dst, int dstPitch, int dstType, const uint8 *src, const Common::Rect &srcRect, int flags, const uint8 *palPtr, const uint8 *xmapPtr, uint8 bitDepth);
-template void Wiz::decompressWizImage<kWizRMap>(uint8 *dst, int dstPitch, int dstType, const uint8 *src, const Common::Rect &srcRect, int flags, const uint8 *palPtr, const uint8 *xmapPtr, uint8 bitDepth);
-template void Wiz::decompressWizImage<kWizCopy>(uint8 *dst, int dstPitch, int dstType, const uint8 *src, const Common::Rect &srcRect, int flags, const uint8 *palPtr, const uint8 *xmapPtr, uint8 bitDepth);
-
-template<int type>
-void Wiz::decompressRawWizImage(uint8 *dst, int dstPitch, int dstType, const uint8 *src, int srcPitch, int w, int h, int transColor, const uint8 *palPtr, uint8 bitDepth) {
- if (type == kWizRMap) {
- assert(palPtr != 0);
- }
-
- if (w <= 0 || h <= 0) {
- return;
- }
- while (h--) {
- for (int i = 0; i < w; ++i) {
- uint8 col = src[i];
- if (transColor == -1 || transColor != col) {
- if (type == kWizRMap) {
- if (bitDepth == 2) {
- writeColor(dst + i * 2, dstType, READ_LE_UINT16(palPtr + col * 2));
- } else {
- dst[i] = palPtr[col];
- }
- }
- if (type == kWizCopy) {
- if (bitDepth == 2) {
- writeColor(dst + i * 2, dstType, col);
- } else {
- dst[i] = col;
- }
- }
- }
- }
- src += srcPitch;
- dst += dstPitch;
- }
-}
-
-int Wiz::isPixelNonTransparent(const uint8 *data, int x, int y, int w, int h, uint8 bitDepth) {
- if (x < 0 || x >= w || y < 0 || y >= h) {
- return 0;
- }
- while (y != 0) {
- data += READ_LE_UINT16(data) + 2;
- --y;
- }
- uint16 off = READ_LE_UINT16(data); data += 2;
- if (off == 0) {
- return 0;
- }
- while (x > 0) {
- uint8 code = *data++;
- if (code & 1) {
- code >>= 1;
- if (code > x) {
- return 0;
- }
- x -= code;
- } else if (code & 2) {
- code = (code >> 2) + 1;
- if (code > x) {
- return 1;
- }
- x -= code;
- data += bitDepth;
- } else {
- code = (code >> 2) + 1;
- if (code > x) {
- return 1;
- }
- x -= code;
- data += code * bitDepth;
- }
- }
-
- if (bitDepth == 2)
- return (~READ_LE_UINT16(data)) & 1;
- else
- return (~data[0]) & 1;
-}
-
-uint16 Wiz::getWizPixelColor(const uint8 *data, int x, int y, int w, int h, uint8 bitDepth, uint16 color) {
- if (x < 0 || x >= w || y < 0 || y >= h) {
- return color;
- }
- while (y != 0) {
- data += READ_LE_UINT16(data) + 2;
- --y;
- }
- uint16 off = READ_LE_UINT16(data); data += 2;
- if (off == 0) {
- return color;
- }
- while (x > 0) {
- uint8 code = *data++;
- if (code & 1) {
- code >>= 1;
- if (code > x) {
- return color;
- }
- x -= code;
- } else if (code & 2) {
- code = (code >> 2) + 1;
- if (code > x) {
- return (bitDepth == 2) ? READ_LE_UINT16(data) : data[0];
- }
- x -= code;
- data += bitDepth;
- } else {
- code = (code >> 2) + 1;
- if (code > x) {
- return (bitDepth == 2) ? READ_LE_UINT16(data + x) : data[x];
- }
- x -= code;
- data += code * bitDepth;
- }
- }
-
- if (bitDepth == 2)
- return (READ_LE_UINT16(data) & 1) ? color : READ_LE_UINT16(data + 2);
- else
- return (data[0] & 1) ? color : data[1];
-
-}
-
-uint16 Wiz::getRawWizPixelColor(const uint8 *data, int x, int y, int w, int h, uint8 bitDepth, uint16 color) {
- if (x < 0 || x >= w || y < 0 || y >= h) {
- return color;
- }
- if (bitDepth == 2)
- return READ_LE_UINT16(data + (y * w + x) * 2);
- else
- return data[y * w + x];
-}
-
-void Wiz::computeWizHistogram(uint32 *histogram, const uint8 *data, const Common::Rect &rCapt) {
- int h = rCapt.top;
- while (h--) {
- data += READ_LE_UINT16(data) + 2;
- }
-
- h = rCapt.height();
- while (h--) {
- uint16 off = READ_LE_UINT16(data); data += 2;
- if (off != 0) {
- const uint8 *p = data;
- int xoffs = rCapt.left;
- int w = rCapt.width();
- uint8 code;
- while (xoffs > 0) {
- code = *p++;
- if (code & 1) {
- code >>= 1;
- if (code > xoffs) {
- code -= xoffs;
- w -= code;
- break;
- }
- xoffs -= code;
- } else if (code & 2) {
- code = (code >> 2) + 1;
- if (code > xoffs) {
- code -= xoffs;
- goto dec_sub2;
- }
- xoffs -= code;
- p++;
- } else {
- code = (code >> 2) + 1;
- if (code > xoffs) {
- code -= xoffs;
- p += xoffs;
- goto dec_sub3;
- }
- xoffs -= code;
- p += code;
- }
- }
- while (w > 0) {
- code = *p++;
- if (code & 1) {
- code >>= 1;
- w -= code;
- } else if (code & 2) {
- code = (code >> 2) + 1;
-dec_sub2: w -= code;
- if (w < 0) {
- code += w;
- }
- histogram[*p++] += code;
- } else {
- code = (code >> 2) + 1;
-dec_sub3: w -= code;
- if (w < 0) {
- code += w;
- }
- int n = code;
- while (n--) {
- ++histogram[*p++];
- }
- }
- }
- data += off;
- }
- }
-}
-
-void Wiz::computeRawWizHistogram(uint32 *histogram, const uint8 *data, int srcPitch, const Common::Rect &rCapt) {
- data += rCapt.top * srcPitch + rCapt.left;
- int iw = rCapt.width();
- int ih = rCapt.height();
- while (ih--) {
- for (int i = 0; i < iw; ++i) {
- ++histogram[data[i]];
- }
- data += srcPitch;
- }
-}
-
-#ifdef USE_RGB_COLOR
-static int wizPackType2(uint8 *dst, const uint8 *src, int srcPitch, const Common::Rect& rCapt) {
- debug(9, "wizPackType2([%d,%d,%d,%d])", rCapt.left, rCapt.top, rCapt.right, rCapt.bottom);
- int w = rCapt.width();
- int h = rCapt.height();
- int size = w * h * 2;
- if (dst) {
- src += rCapt.top * srcPitch + rCapt.left * 2;
- while (h--) {
- for (int i = 0; i < w; i++)
- WRITE_LE_UINT16(dst + i * 2, READ_UINT16(src + i * 2));
- dst += w * 2;
- src += srcPitch;
- }
- }
- return size;
-}
-#endif
-
-static int wizPackType1(uint8 *dst, const uint8 *src, int srcPitch, const Common::Rect& rCapt, uint8 transColor) {
- debug(9, "wizPackType1(%d, [%d,%d,%d,%d])", transColor, rCapt.left, rCapt.top, rCapt.right, rCapt.bottom);
- src += rCapt.top * srcPitch + rCapt.left;
- int w = rCapt.width();
- int h = rCapt.height();
- int dataSize = 0;
- while (h--) {
- uint8 *dstLine = dst;
- if (dst) {
- dst += 2;
- }
- uint8 diffBuffer[0x40];
- int runCountSame = 0;
- int runCountDiff = 0;
- uint8 prevColor = src[0];
- for (int i = 1; i < w; ) {
- uint8 color = src[i++];
- if (i == 2) {
- if (prevColor == color) {
- runCountSame = 1;
- } else {
- diffBuffer[0] = prevColor;
- runCountDiff = 1;
- }
- }
- if (prevColor == color) {
- if (runCountDiff != 0) {
- runCountSame = 1;
- if (runCountDiff > 1) {
- --runCountDiff;
- if (dst) {
- *dst++ = ((runCountDiff - 1) << 2) | 0;
- memcpy(dst, diffBuffer, runCountDiff);
- dst += runCountDiff;
- }
- dataSize += runCountDiff + 1;
- }
- runCountDiff = 0;
- }
- ++runCountSame;
- if (prevColor == transColor) {
- if (runCountSame == 0x7F) {
- if (dst) {
- *dst++ = (runCountSame << 1) | 1;
- }
- ++dataSize;
- runCountSame = 0;
- }
- } else {
- if (runCountSame == 0x40) {
- if (dst) {
- *dst++ = ((runCountSame - 1) << 2) | 2;
- *dst++ = prevColor;
- }
- dataSize += 2;
- runCountSame = 0;
- }
- }
- } else {
- if (runCountSame != 0) {
- if (prevColor == transColor) {
- if (dst) {
- *dst++ = (runCountSame << 1) | 1;
- }
- ++dataSize;
- } else {
- if (dst) {
- *dst++ = ((runCountSame - 1) << 2) | 2;
- *dst++ = prevColor;
- }
- dataSize += 2;
- }
- runCountSame = 0;
- }
- assert(runCountDiff < ARRAYSIZE(diffBuffer));
- diffBuffer[runCountDiff++] = color;
- if (runCountDiff == 0x40) {
- if (dst) {
- *dst++ = ((runCountDiff - 1) << 2) | 0;
- memcpy(dst, diffBuffer, runCountDiff);
- dst += runCountDiff;
- }
- dataSize += runCountDiff + 1;
- runCountDiff = 0;
- }
- }
- prevColor = color;
- }
- if (runCountSame != 0) {
- if (prevColor == transColor) {
- if (dst) {
- *dst++ = (runCountSame << 1) | 1;
- }
- ++dataSize;
- } else {
- if (dst) {
- *dst++ = ((runCountSame - 1) << 2) | 2;
- *dst++ = prevColor;
- }
- dataSize += 2;
- }
- }
- if (runCountDiff != 0) {
- if (dst) {
- *dst++ = ((runCountDiff - 1) << 2) | 0;
- memcpy(dst, diffBuffer, runCountDiff);
- dst += runCountDiff;
- }
- dataSize += runCountDiff + 1;
- }
- if (dst) {
- WRITE_LE_UINT16(dstLine, dst - dstLine - 2);
- }
- dataSize += 2;
- src += srcPitch;
- }
- return dataSize;
-}
-
void Wiz::processWizImageCaptureCmd(const WizImageCommand *params) {
bool compressIt = (params->compressionType == kWCTTRLE);
bool background = (params->flags & kWRFBackground) != 0;
@@ -1230,12 +186,13 @@ void *Wiz::drawAWizPrimEx(int globNum, int state, int x, int y, int z, int shado
markUpdates = true;
remap_p = nullptr;
- // Set the optional remap table up to the default if one isn't specified
- if (!optionalColorConversionTable) {
- optionalColorConversionTable = (WizRawPixel *)_vm->getHEPaletteSlot(1);
+ if (_vm->_game.heversion > 98) {
+ // Set the optional remap table up to the default if one isn't specified
+ if (!optionalColorConversionTable) {
+ optionalColorConversionTable = (WizRawPixel *)_vm->getHEPaletteSlot(1);
+ }
}
- // If using a shadow make sure both globs are in ram!!!!
if (shadowImage) {
shadow_p = (byte *)getColorMixBlockPtrForWiz(shadowImage);
@@ -1246,17 +203,25 @@ void *Wiz::drawAWizPrimEx(int globNum, int state, int x, int y, int z, int shado
shadow_p = nullptr;
}
- // If using a z-buffer make sure both globs are in ram!!!!
- if (zbufferImage) {
- // uncompressed 16-bit z-buffers only for now
- byte *pzbHeader = (byte *)getWizStateHeaderPrim(zbufferImage, 0);
+ if (_vm->_game.heversion <= 99 && _uses16BitColor) {
+ if (shadow_p) {
+ shadow_p = nullptr;
+ }
+ }
+
+ if (_vm->_game.heversion > 99) {
+ // If using a z-buffer make sure both globs are in ram!!!!
+ if (zbufferImage) {
+ // uncompressed 16-bit z-buffers only for now
+ byte *pzbHeader = (byte *)getWizStateHeaderPrim(zbufferImage, 0);
- assert(pzbHeader);
+ assert(pzbHeader);
- int zbComp = READ_LE_UINT32(pzbHeader + _vm->_resourceHeaderSize);
+ int zbComp = READ_LE_UINT32(pzbHeader + _vm->_resourceHeaderSize);
- if (zbComp != kWCTNone16Bpp) {
- error("Wiz::drawAWizPrimEx(): 16-bit uncompressed z-buffers are the only currently supported format");
+ if (zbComp != kWCTNone16Bpp) {
+ error("Wiz::drawAWizPrimEx(): 16-bit uncompressed z-buffers are the only currently supported format");
+ }
}
}
@@ -1303,7 +268,7 @@ void *Wiz::drawAWizPrimEx(int globNum, int state, int x, int y, int z, int shado
if (!src_p)
error("Wiz::drawAWizPrimEx(): %d state %d missing palette block", globNum, state);
- _vm->remapHEPalette(src_p, remap_p + 4);
+ _vm->remapHEPalette(src_p, remap_p + _vm->_resourceHeaderSize + 4);
}
}
}
@@ -1362,7 +327,7 @@ void *Wiz::drawAWizPrimEx(int globNum, int state, int x, int y, int z, int shado
}
// Get down to business and decompress the image...
- if (zbufferImage) {
+ if (_vm->_game.heversion > 99 && zbufferImage) {
WizSimpleBitmap sbZBuffer;
sbZBuffer.bitmapHeight = 0;
sbZBuffer.bitmapWidth = 0;
@@ -1388,18 +353,35 @@ void *Wiz::drawAWizPrimEx(int globNum, int state, int x, int y, int z, int shado
}
} else if (src_c == kWCTTRLE) {
if (flags & kWRFZPlaneOn) {
- if (_vm->_gdi->_numZBuffer <= 1) {
+ if (_vm->_game.heversion > 95 && _vm->_gdi->_numZBuffer <= 1) {
error("Wiz::drawAWizPrimEx(): No zplane %d (limit 0 to %d)", 1, (_vm->_gdi->_numZBuffer - 1));
}
auxDrawZplaneFromTRLEImage(_vm->getMaskBuffer(0, 0, 1), src_d + _vm->_resourceHeaderSize, dest_w, dest_h, x, y, src_w, src_h, &clip_r, kWZOIgnore, kWZOSet);
} else if (flags & kWRFZPlaneOff) {
- if (_vm->_gdi->_numZBuffer <= 1) {
+ if (_vm->_game.heversion > 95 && _vm->_gdi->_numZBuffer <= 1) {
error("Wiz::drawAWizPrimEx(): No zplane %d (limit 0 to %d)", 1, (_vm->_gdi->_numZBuffer - 1));
}
auxDrawZplaneFromTRLEImage(_vm->getMaskBuffer(0, 0, 1), src_d + _vm->_resourceHeaderSize, dest_w, dest_h, x, y, src_w, src_h, &clip_r, kWZOIgnore, kWZOClear);
- } else {
+ } else if (_vm->_game.heversion <= 98 && !(flags & (kWRFHFlip | kWRFVFlip))) {
+ if (flags & kWRFRemap) {
+ auxDecompRemappedTRLEImage(
+ dest_p, src_d + _vm->_resourceHeaderSize, dest_w, dest_h,
+ x, y, src_w, src_h, &clip_r, remap_p + _vm->_resourceHeaderSize + 4,
+ optionalColorConversionTable);
+ } else if (!shadow_p) {
+ auxDecompTRLEImage(
+ dest_p, src_d + _vm->_resourceHeaderSize, dest_w, dest_h,
+ x, y, src_w, src_h, &clip_r,
+ optionalColorConversionTable);
+ } else {
+ auxDecompMixColorsTRLEImage(
+ dest_p, src_d + _vm->_resourceHeaderSize, dest_w, dest_h,
+ x, y, src_w, src_h, &clip_r, shadow_p,
+ optionalColorConversionTable);
+ }
+ } else if (_vm->_game.heversion >= 99) {
void *dataPtr = nullptr;
if (shadow_p)
@@ -1431,24 +413,36 @@ void *Wiz::drawAWizPrimEx(int globNum, int state, int x, int y, int z, int shado
transColorOverride = -1;
}
- if (src_c != kWCTNone16Bpp && src_c != kWCTNone16BppBigEndian) {
- if (src_c == kWCTNone) {
- pgDraw8BppFormatImage(
- dest_p, (byte *)(src_d + _vm->_resourceHeaderSize), dest_w, dest_h,
- x, y, src_w, src_h, &clip_r, flags, dataPtr, transColorOverride,
- optionalColorConversionTable);
+ if (_uses16BitColor) {
+ if (src_c != kWCTNone16Bpp && src_c != kWCTNone16BppBigEndian) {
+ if (src_c == kWCTNone) {
+ pgDraw8BppFormatImage(
+ dest_p, (byte *)(src_d + _vm->_resourceHeaderSize), dest_w, dest_h,
+ x, y, src_w, src_h, &clip_r, flags, dataPtr, transColorOverride,
+ optionalColorConversionTable);
+ } else {
+ error("Wiz::drawAWizPrimEx(): Raw data type mismatch for mode %d vs %d", src_c, kWCTNone16Bpp);
+ }
} else {
- error("Wiz::drawAWizPrimEx(): Raw data type mismatch for mode %d vs %d", src_c, kWCTNone16Bpp);
+ // Use the native transfer function
+ pgDrawRawDataFormatImage(
+ dest_p, (WizRawPixel *)(src_d + _vm->_resourceHeaderSize), dest_w, dest_h,
+ x, y, src_w, src_h, &clip_r, flags, dataPtr, transColorOverride);
}
-
} else {
- // Use the native transfer function
- if (optionalColorConversionTable &&
- ((WizRawPixel *)_vm->getHEPaletteSlot(1) != optionalColorConversionTable)) {
- flags |= kWRFRemap;
- dataPtr = (void *)optionalColorConversionTable;
+ if (_vm->_game.heversion > 99) {
+ if (optionalColorConversionTable &&
+ ((WizRawPixel *)_vm->getHEPaletteSlot(1) != optionalColorConversionTable)) {
+ flags |= kWRFRemap;
+ dataPtr = (void *)optionalColorConversionTable;
+ }
+ } else {
+ if (src_c != kWCTNone) {
+ error("Raw data type mismatch for mode %d vs %d", src_c, kWCTNone);
+ }
}
+ // Use the native transfer function
pgDrawRawDataFormatImage(
dest_p, (WizRawPixel *)(src_d + _vm->_resourceHeaderSize), dest_w, dest_h,
x, y, src_w, src_h, &clip_r, flags, dataPtr, transColorOverride);
@@ -1459,7 +453,7 @@ void *Wiz::drawAWizPrimEx(int globNum, int state, int x, int y, int z, int shado
if (flags & kWRFPrint) {
warning("Wiz::drawAWizPrimEx(): Printing not yet supported");
- if ((flags & kWRFAlloc) == 0) {
+ if (_vm->_game.heversion <= 99 || (flags & kWRFAlloc) == 0) {
free(dest_p);
dest_p = nullptr;
}
@@ -1500,7 +494,7 @@ void Wiz::buildAWiz(const WizRawPixel *bufPtr, int bufWidth, int bufHeight, cons
if (rectPtr) {
if (!findRectOverlap(&compRect, rectPtr)) {
- error("Build wiz incorrect size (%d,%d,%d,%d)", rectPtr->left, rectPtr->top, rectPtr->right, rectPtr->bottom);
+ error("Wiz::buildAWiz(): Build wiz incorrect size (%d,%d,%d,%d)", rectPtr->left, rectPtr->top, rectPtr->right, rectPtr->bottom);
}
}
@@ -1523,7 +517,7 @@ void Wiz::buildAWiz(const WizRawPixel *bufPtr, int bufWidth, int bufHeight, cons
} else if (isUncompressedFormatTypeID(compressionType)) {
dataSize = ((getRectWidth(&compRect) * getRectHeight(&compRect)) * sizeof(WizRawPixel));
} else {
- error("Unknown compression type %d", compressionType);
+ error("Wiz::buildAWiz(): Unknown compression type %d", compressionType);
}
// Make sure that the "glob" is even sized...
@@ -1578,7 +572,7 @@ void Wiz::buildAWiz(const WizRawPixel *bufPtr, int bufWidth, int bufHeight, cons
compRect.left, compRect.top, compRect.top, compRect.bottom,
(byte)transparentColor);
} else {
- error("Incorrect type %d for current pixel mode 16 bit", compressionType);
+ error("Wiz::buildAWiz(): Incorrect type %d for current pixel mode 16 bit", compressionType);
}
} else {
WizSimpleBitmap srcBitmap, dstBitmap;
@@ -1610,7 +604,7 @@ void Wiz::buildAWiz(const WizRawPixel *bufPtr, int bufWidth, int bufHeight, cons
// Error check.
dataOffset += dataSize;
if (globSize != dataOffset) {
- error("WIZ size mismatch!");
+ error("Wiz::buildAWiz(): WIZ size mismatch!");
}
}
@@ -1628,529 +622,154 @@ int Wiz::pixelHitTestWizPrim(int globNum, int state, int x, int y, int32 flags)
}
#endif
- int src_c, src_w, src_h;
- byte *src_d;
- byte *pp;
-
- // Get the header (width, height + compression)
- pp = getWizStateHeaderPrim(globNum, state);
-
- src_c = READ_LE_UINT32(pp + _vm->_resourceHeaderSize + 0);
- src_w = READ_LE_UINT32(pp + _vm->_resourceHeaderSize + 4);
- src_h = READ_LE_UINT32(pp + _vm->_resourceHeaderSize + 8);
-
- // If the compression type is TRLE...
- if (src_c == kWCTTRLE) {
- src_d = getWizStateDataPrim(globNum, state);
-
- // Where should the color lookup happen?
- int pixel = auxPixelHitTestTRLEImageRelPos(
- src_d + _vm->_resourceHeaderSize, x, y, src_w, src_h,
- _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR));
-
- int compType = getWizCompressionType(globNum, state);
-
- if (LITTLE_ENDIAN_WIZ(compType)) {
- return pixel;
- } else {
- if (WIZ_16BPP(compType)) {
- return SWAP_BYTES_16(pixel);
- } else {
- return pixel;
- }
- }
-
- } else if (isUncompressedFormatTypeID(src_c)) {
- WizSimpleBitmap srcBitmap;
-
- src_d = getWizStateDataPrim(globNum, state);
-
- srcBitmap.bufferPtr = (WizRawPixel *)(src_d + _vm->_resourceHeaderSize);
- srcBitmap.bitmapWidth = src_w;
- srcBitmap.bitmapHeight = src_h;
-
- int pixel = pgReadPixel(&srcBitmap, x, y, _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR));
- int compType = getWizCompressionType(globNum, state);
-
- if (LITTLE_ENDIAN_WIZ(compType)) {
- return pixel;
- } else {
- if (WIZ_16BPP(compType)) {
- return SWAP_BYTES_16(pixel);
- } else {
- return pixel;
- }
- }
- } else {
- return _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR);
- }
-}
-
-int Wiz::hitTestWiz(int image, int state, int x, int y, int32 flags) {
- return hitTestWizPrim(image, state, x, y, flags);
-}
-
-int Wiz::hitTestWizPrim(int globNum, int state, int x, int y, int32 flags) {
-
-#ifdef SCUMM_XTL_BRIDGE // 5/9/2000 BPT
- int outValue = 0;
-
- if (PU_OverrideImageHitTest(&outValue, globType, globNum, state, x, y, flags)) {
- return outValue;
- }
-#endif
-
- int src_c, src_w, src_h;
- byte *src_d;
- byte *pp;
-
- // Get the header (width, height + compression)
- pp = getWizStateHeaderPrim(globNum, state);
-
- src_c = READ_LE_UINT32(pp + _vm->_resourceHeaderSize + 0);
- src_w = READ_LE_UINT32(pp + _vm->_resourceHeaderSize + 4);
- src_h = READ_LE_UINT32(pp + _vm->_resourceHeaderSize + 8);
-
- if (_vm->_game.heversion > 98) {
- // Flip the test coords if needed and do simple point rejection
- // (should be faster than calling the various functions)
-
- if (flags & kWRFHFlip) {
- x = ((src_w - 1) - x);
-
- if (x < 0) {
- return 0;
- }
-
- } else if ((x >= src_w) || (x < 0)) {
- return 0;
- }
-
- if (flags & kWRFVFlip) {
- y = ((src_h - 1) - y);
-
- if (y < 0) {
- return 0;
- }
-
- } else if ((y >= src_h) || (y < 0)) {
- return 0;
- }
- }
-
- // If the compression type is TRLE...
- if (src_c == kWCTTRLE) {
- src_d = getWizStateDataPrim(globNum, state);
-
- return auxHitTestTRLEImageRelPos(src_d + _vm->_resourceHeaderSize, x, y, src_w, src_h) ? 1 : 0;
- } else if (_vm->_game.heversion > 98 && isUncompressedFormatTypeID(src_c)) {
- WizSimpleBitmap srcBitmap;
-
- src_d = getWizStateDataPrim(globNum, state);
-
- srcBitmap.bufferPtr = (WizRawPixel *)(src_d + _vm->_resourceHeaderSize);
- srcBitmap.bitmapWidth = src_w;
- srcBitmap.bitmapHeight = src_h;
-
- return (_vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR) !=
- pgReadPixel(&srcBitmap, x, y, _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR)))
- ? 1
- : 0;
- } else {
- return 0;
- }
-}
-
-uint8 *Wiz::drawWizImage(int resNum, int state, int maskNum, int maskState, int x1, int y1, int zorder, int shadow, int zbuffer, const Common::Rect *clipBox, int flags, int dstResNum, const uint8 *palPtr, uint32 conditionBits) {
- debug(7, "drawWizImage(resNum %d, state %d maskNum %d maskState %d x1 %d y1 %d flags 0x%X zorder %d shadow %d zbuffer %d dstResNum %d conditionBits: 0x%x)", resNum, state, maskNum, maskState, x1, y1, flags, zorder, shadow, zbuffer, dstResNum, conditionBits);
- uint8 *dataPtr;
- uint8 *dst = nullptr;
-
- const uint8 *xmapPtr = nullptr;
- if (shadow) {
- dataPtr = _vm->getResourceAddress(rtImage, shadow);
- assert(dataPtr);
- xmapPtr = _vm->findResourceData(MKTAG('X','M','A','P'), dataPtr);
- assert(xmapPtr);
- }
-
- dataPtr = _vm->getResourceAddress(rtImage, resNum);
- assert(dataPtr);
-
- uint8 *wizh = _vm->findWrappedBlock(MKTAG('W','I','Z','H'), dataPtr, state, 0);
- assert(wizh);
- uint32 comp = READ_LE_UINT32(wizh + 0x0);
- uint32 width = READ_LE_UINT32(wizh + 0x4);
- uint32 height = READ_LE_UINT32(wizh + 0x8);
- debug(7, "wiz_header.comp = %d wiz_header.w = %d wiz_header.h = %d", comp, width, height);
-
- uint8 *mask = NULL;
- if (maskNum) {
- uint8 *maskPtr = _vm->getResourceAddress(rtImage, maskNum);
- assert(maskPtr);
-
- wizh = _vm->findWrappedBlock(MKTAG('W','I','Z','H'), maskPtr, maskState, 0);
- assert(wizh);
- assert(comp == 2 && READ_LE_UINT32(wizh + 0x0) == 1);
- width = READ_LE_UINT32(wizh + 0x4);
- height = READ_LE_UINT32(wizh + 0x8);
-
- mask = _vm->findWrappedBlock(MKTAG('W','I','Z','D'), maskPtr, maskState, 0);
- assert(mask);
- }
-
- if (flags & kWRFUsePalette) {
- uint8 *pal = _vm->findWrappedBlock(MKTAG('R','G','B','S'), dataPtr, state, 0);
- assert(pal);
- _vm->setPaletteFromPtr(pal, 256);
- }
-
- uint8 *rmap = nullptr;
- if (flags & kWRFRemap) {
- rmap = _vm->findWrappedBlock(MKTAG('R','M','A','P'), dataPtr, state, 0);
- assert(rmap);
- if (_vm->_game.heversion <= 80 || READ_BE_UINT32(rmap) != WIZ_MAGIC_REMAP_NUMBER) {
- uint8 *rgbs = _vm->findWrappedBlock(MKTAG('R','G','B','S'), dataPtr, state, 0);
- assert(rgbs);
- _vm->remapHEPalette(rgbs, rmap + 4);
- }
- }
-
- if (flags & kWRFPrint) {
- error("WizImage printing is unimplemented");
- }
-
- int32 dstPitch, dstType, cw, ch;
- if (flags & kWRFAlloc) {
- dst = (uint8 *)malloc(width * height * _vm->_bytesPerPixel);
- int transColor = (_vm->VAR_WIZ_TRANSPARENT_COLOR != 0xFF) ? (_vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR)) : 5;
-
- if (_vm->_bytesPerPixel == 2) {
- uint8 *tmpPtr = dst;
- for (uint i = 0; i < height; i++) {
- for (uint j = 0; j < width; j++) {
- if (_cursorImage) {
- WRITE_UINT16(tmpPtr + j * 2, transColor);
- } else {
- WRITE_LE_UINT16(tmpPtr + j * 2, transColor);
- }
- }
- tmpPtr += width * 2;
- }
- } else {
- memset(dst, transColor, width * height);
- }
- cw = width;
- ch = height;
- dstPitch = cw * _vm->_bytesPerPixel;
- dstType = (_cursorImage) ? kDstCursor : kDstMemory;
- } else {
- if (dstResNum) {
- uint8 *dstPtr = _vm->getResourceAddress(rtImage, dstResNum);
- assert(dstPtr);
- dst = _vm->findWrappedBlock(MKTAG('W','I','Z','D'), dstPtr, 0, 0);
- assert(dst);
- getWizImageDim(dstResNum, 0, cw, ch);
- dstPitch = cw * _vm->_bytesPerPixel;
- dstType = kDstResource;
- } else {
- VirtScreen *pvs = &_vm->_virtscr[kMainVirtScreen];
- if (flags & kWRFForeground) {
- dst = pvs->getPixels(0, pvs->topline);
- } else {
- dst = pvs->getBackPixels(0, pvs->topline);
- }
- cw = pvs->w;
- ch = pvs->h;
- dstPitch = pvs->pitch;
- dstType = kDstScreen;
- }
- }
-
- Common::Rect rScreen(cw, ch);
- if (clipBox) {
- Common::Rect clip(clipBox->left, clipBox->top, clipBox->right, clipBox->bottom);
- if (rScreen.intersects(clip)) {
- rScreen.clip(clip);
- } else {
- if (flags & kWRFAlloc)
- free(dst);
-
- return 0;
- }
- } else if (_lUseWizClipRect) {
- if (rScreen.intersects(_lWizClipRect)) {
- rScreen.clip(_lWizClipRect);
- } else {
- if (flags & kWRFAlloc)
- free(dst);
-
- return 0;
- }
- }
-
- if (flags & kWRFRemap && _vm->_bytesPerPixel == 1) {
- palPtr = rmap + 4;
- }
-
- int transColor = -1;
- if (_vm->VAR_WIZ_TRANSPARENT_COLOR != 0xFF) {
- uint8 *trns = _vm->findWrappedBlock(MKTAG('T','R','N','S'), dataPtr, state, 0);
- transColor = (trns == nullptr) ? _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR) : -1;
- }
-
- if (_vm->_game.id == GID_MOONBASE &&
- ((ScummEngine_v100he *)_vm)->_moonbase->isFOW(resNum, state, conditionBits)) {
- ((ScummEngine_v100he *)_vm)->_moonbase->renderFOW(dst, dstPitch, dstType, cw, ch, flags);
- x1 = 0;
- y1 = 0;
- width = rScreen.width();
- height = rScreen.height();
- } else {
- drawWizImageEx(dst, dataPtr, mask, dstPitch, dstType, cw, ch, x1, y1, width, height,
- state, &rScreen, flags, palPtr, transColor, _vm->_bytesPerPixel, xmapPtr, conditionBits);
- }
-
- if (!(flags & kWRFAlloc) && dstResNum == 0) {
- Common::Rect rImage(x1, y1, x1 + width, y1 + height);
- if (rImage.intersects(rScreen)) {
- rImage.clip(rScreen);
- if (!(flags & kWRFBackground) && (flags & (kWRFBackground | kWRFForeground))) {
- ++rImage.bottom;
- _vm->markRectAsDirty(kMainVirtScreen, rImage);
- } else {
- _vm->backgroundToForegroundBlit(rImage);
- }
- }
- }
-
- return dst;
-}
-
-void Wiz::drawWizImageEx(uint8 *dst, uint8 *dataPtr, uint8 *maskPtr, int dstPitch, int dstType,
- int dstw, int dsth, int srcx, int srcy, int srcw, int srch, int state, const Common::Rect *rect,
- int flags, const uint8 *palPtr, int transColor, uint8 bitDepth, const uint8 *xmapPtr, uint32 conditionBits) {
- uint8 *wizh = _vm->findWrappedBlock(MKTAG('W','I','Z','H'), dataPtr, state, 0);
- assert(wizh);
- uint32 comp = READ_LE_UINT32(wizh + 0x0);
- uint32 width = READ_LE_UINT32(wizh + 0x4);
- uint32 height = READ_LE_UINT32(wizh + 0x8);
- debug(7, "wiz_header.comp = %d wiz_header.w = %d wiz_header.h = %d", comp, width, height);
-
- uint8 *wizd = _vm->findWrappedBlock(MKTAG('W','I','Z','D'), dataPtr, state, 0);
- assert(wizd);
-
- switch (comp) {
- case kWCTNone:
- copyRawWizImage(dst, wizd, dstPitch, dstType, dstw, dsth, srcx, srcy, srcw, srch, rect, flags, palPtr, transColor, bitDepth);
- break;
- case kWCTTRLE:
- if (flags & kWRFZPlaneOn) {
- dst = _vm->getMaskBuffer(0, 0, 1);
- dstPitch /= _vm->_bytesPerPixel;
- copyWizImageWithMask(dst, wizd, dstPitch, dstw, dsth, srcx, srcy, srcw, srch, rect, 0, 2);
- } else if (flags & kWRFZPlaneOff) {
- dst = _vm->getMaskBuffer(0, 0, 1);
- dstPitch /= _vm->_bytesPerPixel;
- copyWizImageWithMask(dst, wizd, dstPitch, dstw, dsth, srcx, srcy, srcw, srch, rect, 0, 1);
- } else {
- copyWizImage(dst, wizd, dstPitch, dstType, dstw, dsth, srcx, srcy, srcw, srch, rect, flags, palPtr, xmapPtr, bitDepth);
- }
- break;
-#ifdef USE_RGB_COLOR
- case kWCTNone16Bpp:
- if (maskPtr) {
- copyMaskWizImage(dst, wizd, maskPtr, dstPitch, dstType, dstw, dsth, srcx, srcy, srcw, srch, rect, flags, palPtr);
- } else {
- copyRaw16BitWizImage(dst, wizd, dstPitch, dstType, dstw, dsth, srcx, srcy, srcw, srch, rect, flags, transColor);
- }
- break;
- case kWCTComposite:
- copyCompositeWizImage(dst, dataPtr, wizd, maskPtr, dstPitch, dstType, dstw, dsth, srcx, srcy, srcw, srch, state, rect, flags, palPtr, transColor, bitDepth, xmapPtr, conditionBits);
- break;
- case kWCTTRLE16Bpp:
- copy16BitWizImage(dst, wizd, dstPitch, dstType, dstw, dsth, srcx, srcy, srcw, srch, rect, flags, xmapPtr);
- break;
- case kWCTDataBlockDependent:
- copy555WizImage(dst, wizd, dstPitch, dstType, dstw, dsth, srcx, srcy, rect, conditionBits);
- break;
-#endif
- default:
- error("drawWizImageEx: Unhandled wiz compression type %d", comp);
- }
-}
-
-#ifdef USE_RGB_COLOR
-
-void Wiz::copyCompositeWizImage(uint8 *dst, uint8 *wizPtr, uint8 *compositeInfoBlockPtr, uint8 *maskPtr, int dstPitch, int dstType,
- int dstw, int dsth, int srcx, int srcy, int srcw, int srch, int state, const Common::Rect *clipBox,
- int flags, const uint8 *palPtr, int transColor, uint8 bitDepth, const uint8 *xmapPtr, uint32 conditionBits) {
-
- uint8 *nestedBlockHeader = _vm->heFindResource(MKTAG('N','E','S','T'), wizPtr);
- assert(nestedBlockHeader);
-
- uint8 *nestedWizHeader = _vm->heFindResource(MKTAG('M','U','L','T'), nestedBlockHeader);
- assert(nestedWizHeader);
-
- uint16 layerCount = READ_LE_UINT16(compositeInfoBlockPtr);
- compositeInfoBlockPtr += 2;
-
- uint16 defaultSubConditionBits = (conditionBits & kWMSBReservedBits);
-
- conditionBits &= ~kWMSBReservedBits;
-
- for (uint layerCounter = 0; layerCounter < layerCount; layerCounter++) {
- int cmdSize = READ_LE_UINT16(compositeInfoBlockPtr);
- uint8 *cmdPtr = compositeInfoBlockPtr + 2;
+ int src_c, src_w, src_h;
+ byte *src_d;
+ byte *pp;
- compositeInfoBlockPtr += (cmdSize + 2);
- uint32 layerCmdDataBits = READ_LE_UINT32(cmdPtr);
- cmdPtr += 4;
+ // Get the header (width, height + compression)
+ pp = getWizStateHeaderPrim(globNum, state);
- uint32 subConditionBits;
+ src_c = READ_LE_UINT32(pp + _vm->_resourceHeaderSize + 0);
+ src_w = READ_LE_UINT32(pp + _vm->_resourceHeaderSize + 4);
+ src_h = READ_LE_UINT32(pp + _vm->_resourceHeaderSize + 8);
- if (layerCmdDataBits & kWCFConditionBits) {
- uint32 layerConditionBits = READ_LE_UINT32(cmdPtr);
- cmdPtr += 4;
+ // If the compression type is TRLE...
+ if (src_c == kWCTTRLE) {
+ src_d = getWizStateDataPrim(globNum, state);
- subConditionBits = (layerConditionBits & kWMSBReservedBits);
- layerConditionBits &= ~kWMSBReservedBits;
+ // Where should the color lookup happen?
+ int pixel = auxPixelHitTestTRLEImageRelPos(
+ src_d + _vm->_resourceHeaderSize, x, y, src_w, src_h,
+ _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR));
- if (subConditionBits == 0)
- subConditionBits = defaultSubConditionBits;
+ int compType = getWizCompressionType(globNum, state);
- uint32 conditionType = (layerConditionBits & kWSPCCTBits);
- layerConditionBits &= ~kWSPCCTBits;
+ if (LITTLE_ENDIAN_WIZ(compType)) {
+ return pixel;
+ } else {
+ if (WIZ_16BPP(compType)) {
+ return SWAP_BYTES_16(pixel);
+ } else {
+ return pixel;
+ }
+ }
- switch (conditionType) {
- case kWSPCCTAnd:
- if (layerConditionBits != (layerConditionBits & conditionBits))
- continue;
- break;
+ } else if (isUncompressedFormatTypeID(src_c)) {
+ WizSimpleBitmap srcBitmap;
- case kWSPCCTNot:
- if (layerConditionBits & conditionBits)
- continue;
- break;
+ src_d = getWizStateDataPrim(globNum, state);
- case kWSPCCTOr:
- default:
- if (!(layerConditionBits & conditionBits))
- continue;
- break;
- }
- } else {
- subConditionBits = defaultSubConditionBits;
- }
+ srcBitmap.bufferPtr = (WizRawPixel *)(src_d + _vm->_resourceHeaderSize);
+ srcBitmap.bitmapWidth = src_w;
+ srcBitmap.bitmapHeight = src_h;
- uint16 subState;
- if (layerCmdDataBits & kWCFSubState) {
- subState = READ_LE_UINT16(cmdPtr);
- cmdPtr += 2;
- } else {
- subState = 0;
- }
+ int pixel = pgReadPixel(&srcBitmap, x, y, _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR));
+ int compType = getWizCompressionType(globNum, state);
- int16 xPos;
- if (layerCmdDataBits & kWCFXDelta) {
- xPos = (int16)READ_LE_UINT16(cmdPtr);
- cmdPtr += 2;
+ if (LITTLE_ENDIAN_WIZ(compType)) {
+ return pixel;
} else {
- xPos = 0;
+ if (WIZ_16BPP(compType)) {
+ return SWAP_BYTES_16(pixel);
+ } else {
+ return pixel;
+ }
}
+ } else {
+ return _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR);
+ }
+}
- int16 yPos;
- if (layerCmdDataBits & kWCFYDelta) {
- yPos = (int16)READ_LE_UINT16(cmdPtr);
- cmdPtr += 2;
- } else {
- yPos = 0;
- }
+int Wiz::hitTestWiz(int image, int state, int x, int y, int32 flags) {
+ return hitTestWizPrim(image, state, x, y, flags);
+}
- uint32 drawFlags;
- if (layerCmdDataBits & kWCFDrawFlags) {
- drawFlags = READ_LE_UINT32(cmdPtr);
- cmdPtr += 4;
- } else {
- drawFlags = flags;
- }
+int Wiz::hitTestWizPrim(int globNum, int state, int x, int y, int32 flags) {
+ int src_c, src_w, src_h;
+ const byte *src_d;
+ const byte *pp;
+ byte *dataTmp = nullptr;
+
+ // U32 TODO
+ //int outValue = 0;
+ //
+ //if (PU_OverrideImageHitTest(&outValue, globType, globNum, state, x, y, flags)) {
+ // return outValue;
+ //}
- uint srcw1 = 0, srch1 = 0;
- if (drawFlags & (kWRFHFlip | kWRFVFlip)) {
- uint8 *wizh = _vm->findWrappedBlock(MKTAG('W','I','Z','H'), wizPtr, subState, 0);
- assert(wizh);
- srcw1 = READ_LE_UINT32(wizh + 0x4);
- srch1 = READ_LE_UINT32(wizh + 0x8);
- }
+ if (_vm->_game.heversion == 80) {
+ dataTmp = _vm->getResourceAddress(rtImage, globNum);
+ assert(dataTmp);
+ pp = _vm->findResourceData(MKTAG('W', 'I', 'Z', 'H'), dataTmp);
+ assert(pp);
+ } else {
+ pp = getWizStateHeaderPrim(globNum, state);
+ }
- if (drawFlags & kWRFHFlip)
- xPos = (srcw - (xPos + srcw1));
+ // Get the header (width, height + compression)
+ src_c = READ_LE_UINT32(pp + _vm->_resourceHeaderSize + 0);
+ src_w = READ_LE_UINT32(pp + _vm->_resourceHeaderSize + 4);
+ src_h = READ_LE_UINT32(pp + _vm->_resourceHeaderSize + 8);
- if (drawFlags & kWRFVFlip)
- yPos = (srch - (yPos + srch1));
+ if (_vm->_game.heversion == 80) {
+ if (src_c != kWCTTRLE)
+ error("Wiz::hitTestWizPrim(): resource %d has invalid compression type %d", globNum, src_c);
- if (layerCmdDataBits & kWCFSubConditionBits) {
- subConditionBits = READ_LE_UINT32(cmdPtr);
- cmdPtr += 4;
- }
+ src_d = _vm->findResourceData(MKTAG('W', 'I', 'Z', 'D'), dataTmp);
- drawWizImageEx(dst, nestedWizHeader, maskPtr, dstPitch, dstType, dstw, dsth, srcx + xPos, srcy + yPos, srcw, srch,
- subState, clipBox, drawFlags, palPtr, transColor, bitDepth, xmapPtr, subConditionBits);
+ return auxHitTestTRLEImageRelPos(src_d + _vm->_resourceHeaderSize, x, y, src_w, src_h) ? 1 : 0;
}
-}
-void Wiz::copy555WizImage(uint8 *dst, uint8 *wizd, int dstPitch, int dstType,
- int dstw, int dsth, int srcx, int srcy, const Common::Rect *clipBox, uint32 conditionBits) {
+ if (_vm->_game.heversion > 98) {
+ // Flip the test coords if needed and do simple point rejection
+ // (should be faster than calling the various functions)
- int rawROP = conditionBits & kWMSBRopMask;
- int paramROP = (conditionBits & kWMSBReservedBits) >> kWMSBRopParamRShift;
+ if (flags & kWRFHFlip) {
+ x = ((src_w - 1) - x);
- switch (rawROP) {
- default:
- case 1:
- rawROP = 1;
- // MMX_PREMUL_ALPHA_COPY
- break;
+ if (x < 0) {
+ return 0;
+ }
- case 2:
- //warning("T14: MMX_ADDITIVE");
- break;
+ } else if ((x >= src_w) || (x < 0)) {
+ return 0;
+ }
- case 3:
- warning("T14: MMX_SUBTRACTIVE");
- break;
+ if (flags & kWRFVFlip) {
+ y = ((src_h - 1) - y);
- case 4:
- warning("T14: MMX_CONSTANT_ALPHA");
- break;
+ if (y < 0) {
+ return 0;
+ }
- case 5:
- //warning("T14: MMX_CHEAP_50_50");
- break;
+ } else if ((y >= src_h) || (y < 0)) {
+ return 0;
+ }
+ }
- case 6:
- warning("T14: COPY");
- break;
+ // If the compression type is TRLE...
+ if (src_c == kWCTTRLE) {
+ src_d = getWizStateDataPrim(globNum, state);
- case 7:
- warning("T14: CHEAP_50_50");
- break;
- }
+ return auxHitTestTRLEImageRelPos(src_d + _vm->_resourceHeaderSize, x, y, src_w, src_h) ? 1 : 0;
+ } else if (_vm->_game.heversion > 98 && isUncompressedFormatTypeID(src_c)) {
+ WizSimpleBitmap srcBitmap;
+ src_d = getWizStateDataPrim(globNum, state);
- uint32 compID = READ_LE_UINT32(wizd);
+ srcBitmap.bufferPtr = (WizRawPixel *)(src_d + _vm->_resourceHeaderSize);
+ srcBitmap.bitmapWidth = src_w;
+ srcBitmap.bitmapHeight = src_h;
- if (compID == 0x12340102) {
- ((ScummEngine_v100he *)_vm)->_moonbase->blitT14WizImage(dst, dstw, dsth, dstPitch, clipBox, wizd, srcx, srcy, rawROP, paramROP);
- } else if (compID == 0x12340802) {
- ((ScummEngine_v100he *)_vm)->_moonbase->blitDistortion(dst, dstw, dsth, dstPitch, clipBox, wizd, srcx, srcy, 0);
- } else if (compID == 0x12340902) {
- error("Unsupported Distortion");
+ return (_vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR) !=
+ pgReadPixel(&srcBitmap, x, y, _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR)))
+ ? 1
+ : 0;
+ } else {
+ return 0;
}
}
-#endif
-
struct PolygonDrawData {
struct PolygonArea {
int32 xmin;
@@ -2562,242 +1181,28 @@ void Wiz::processWizImagePolyCaptureCmd(const WizImageCommand *params) {
_vm->_res->setModified(rtImage, params->image);
}
-void Wiz::drawWizComplexPolygon(int resNum, int state, int po_x, int po_y, int shadow, int angle, int scale, const Common::Rect *r, int flags, int dstResNum, int palette) {
- Common::Point pts[4];
-
- polygonTransform(resNum, state, po_x, po_y, angle, scale, pts);
- drawWizPolygonTransform(resNum, state, pts, flags, shadow, dstResNum, palette);
-}
-
-void Wiz::drawWizPolygon(int resNum, int state, int id, int flags, int shadow, int dstResNum, int palette) {
- int i;
- WizPolygon *wp = nullptr;
- for (i = 0; i < ARRAYSIZE(_polygons); ++i) {
- if (_polygons[i].id == id) {
- wp = &_polygons[i];
- break;
- }
- }
- if (!wp) {
- error("Polygon %d is not defined", id);
- }
- if (wp->numPoints != 5) {
- error("Invalid point count %d for Polygon %d", wp->numPoints, id);
- }
-
- drawWizPolygonTransform(resNum, state, wp->points, flags, shadow, dstResNum, palette);
-}
-
-void Wiz::drawWizPolygonTransform(int resNum, int state, Common::Point *wp, int flags, int shadow, int dstResNum, int palette) {
- debug(7, "drawWizPolygonTransform(resNum %d, flags 0x%X, shadow %d dstResNum %d palette %d)", resNum, flags, shadow, dstResNum, palette);
- const Common::Rect *r = nullptr;
- uint8 *srcWizBuf = nullptr;
- bool freeBuffer = true;
-
- if (_vm->_game.heversion >= 99) {
- if (getWizImageData(resNum, state, 0) != 0 || (flags & (kWRFRemap | kWRFHFlip | kWRFVFlip)) || palette != 0) {
- flags |= kWRFAlloc;
-
- if (flags & kWRFAreaSampleDuringWarp) {
- debug(7, "drawWizPolygonTransform() unhandled flag kWRFAreaSampleDuringWarp");
- }
-
- srcWizBuf = drawWizImage(resNum, state, 0, 0, 0, 0, 0, shadow, 0, r, flags, 0, _vm->getHEPaletteSlot(palette), 0);
- } else {
- assert(_vm->_bytesPerPixel == 1);
- uint8 *dataPtr = _vm->getResourceAddress(rtImage, resNum);
- assert(dataPtr);
- srcWizBuf = _vm->findWrappedBlock(MKTAG('W','I','Z','D'), dataPtr, state, 0);
- assert(srcWizBuf);
- freeBuffer = false;
- }
- } else {
- if (getWizImageData(resNum, state, 0) != 0) {
- srcWizBuf = drawWizImage(resNum, state, 0, 0, 0, 0, 0, shadow, 0, r, kWRFAlloc, 0, _vm->getHEPaletteSlot(palette), 0);
- } else {
- uint8 *dataPtr = _vm->getResourceAddress(rtImage, resNum);
- assert(dataPtr);
- srcWizBuf = _vm->findWrappedBlock(MKTAG('W','I','Z','D'), dataPtr, state, 0);
- assert(srcWizBuf);
- freeBuffer = false;
- }
- }
-
- assert(srcWizBuf);
-
- uint8 *dst;
- int32 dstw, dsth, dstpitch, dstType, wizW, wizH;
- VirtScreen *pvs = &_vm->_virtscr[kMainVirtScreen];
-
- if (dstResNum) {
- uint8 *dstPtr = _vm->getResourceAddress(rtImage, dstResNum);
- assert(dstPtr);
- dst = _vm->findWrappedBlock(MKTAG('W','I','Z','D'), dstPtr, 0, 0);
- assert(dst);
- getWizImageDim(dstResNum, 0, dstw, dsth);
- dstpitch = dstw * _vm->_bytesPerPixel;
- dstType = kDstResource;
- } else {
- if (flags & kWRFForeground) {
- dst = pvs->getPixels(0, 0);
- } else {
- dst = pvs->getBackPixels(0, 0);
- }
- dstw = pvs->w;
- dsth = pvs->h;
- dstpitch = pvs->pitch;
- dstType = kDstScreen;
- }
-
- Common::Rect bound;
- getWizImageDim(resNum, state, wizW, wizH);
- drawWizPolygonImage(dst, srcWizBuf, 0, dstpitch, dstType, dstw, dsth, wizW, wizH, bound, wp, _vm->_bytesPerPixel);
-
- if (flags & kWRFForeground) {
- ++bound.bottom;
- _vm->markRectAsDirty(kMainVirtScreen, bound);
- } else {
- _vm->backgroundToForegroundBlit(bound);
- }
-
- if (freeBuffer)
- free(srcWizBuf);
-}
+void Wiz::flushAWizBuffer() {
+ if (_wizBufferIndex == 0)
+ return;
-void Wiz::drawWizPolygonImage(uint8 *dst, const uint8 *src, const uint8 *mask, int dstpitch, int dstType, int dstw, int dsth, int wizW, int wizH, Common::Rect &bound, Common::Point *wp, uint8 bitDepth) {
- int i, transColor = (_vm->VAR_WIZ_TRANSPARENT_COLOR != 0xFF) ? _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR) : 5;
-
- Common::Point bbox[4];
- bbox[0].x = 0;
- bbox[0].y = 0;
- bbox[1].x = wizW - 1;
- bbox[1].y = 0;
- bbox[2].x = wizW - 1;
- bbox[2].y = wizH - 1;
- bbox[3].x = 0;
- bbox[3].y = wizH - 1;
-
- int16 xmin_p, xmax_p, ymin_p, ymax_p;
- xmin_p = ymin_p = (int16)0x7FFF;
- xmax_p = ymax_p = (int16)0x8000;
-
- for (i = 0; i < 4; ++i) {
- xmin_p = MIN(wp[i].x, xmin_p);
- xmax_p = MAX(wp[i].x, xmax_p);
- ymin_p = MIN(wp[i].y, ymin_p);
- ymax_p = MAX(wp[i].y, ymax_p);
- }
-
- int16 xmin_b, xmax_b, ymin_b, ymax_b;
- xmin_b = ymin_b = (int16)0x7FFF;
- xmax_b = ymax_b = (int16)0x8000;
-
- for (i = 0; i < 4; ++i) {
- xmin_b = MIN(bbox[i].x, xmin_b);
- xmax_b = MAX(bbox[i].x, xmax_b);
- ymin_b = MIN(bbox[i].y, ymin_b);
- ymax_b = MAX(bbox[i].y, ymax_b);
- }
-
- PolygonDrawData pdd(ymax_p - ymin_p + 1);
- pdd.mat[0].x = xmin_p;
- pdd.mat[0].y = ymin_p;
- pdd.mat[1].x = xmax_p;
- pdd.mat[1].y = ymax_p;
- pdd.mat[2].x = xmin_b;
- pdd.mat[2].y = ymin_b;
- pdd.mat[3].x = xmax_b;
- pdd.mat[3].y = ymax_b;
-
- // precompute the transformation which remaps 'bbox' pixels to 'wp'
- for (i = 0; i < 3; ++i) {
- pdd.transform(&wp[i], &wp[i + 1], &bbox[i], &bbox[i + 1]);
- }
- pdd.transform(&wp[3], &wp[0], &bbox[3], &bbox[0]);
-
- pdd.rAreasNum = 0;
- PolygonDrawData::ResultArea *pra = &pdd.ra[0];
- int32 yoff = pdd.mat[0].y * dstpitch;
- int16 y_start = pdd.mat[0].y;
- for (i = 0; i < pdd.pAreasNum; ++i) {
- PolygonDrawData::PolygonArea *ppa = &pdd.pa[i];
- if (y_start >= 0 && y_start < dsth) {
- int16 x1 = ppa->xmin;
- if (x1 < 0) {
- x1 = 0;
- }
- int16 x2 = ppa->xmax;
- if (x2 >= dstw) {
- x2 = dstw - 1;
- }
- int16 w = x2 - x1 + 1;
- if (w > 0) {
- int16 width = ppa->xmax - ppa->xmin + 1;
- pra->x_step = ((ppa->x2 - ppa->x1) * (1 << 16)) / width;
- pra->y_step = ((ppa->y2 - ppa->y1) * (1 << 16)) / width;
- pra->dst_offs = yoff + x1 * _vm->_bytesPerPixel;
- pra->w = w;
- pra->x_s = ppa->x1 * (1 << 16);
- pra->y_s = ppa->y1 * (1 << 16);
- int16 tmp = x1 - ppa->xmin;
- if (tmp != 0) {
- pra->x_s += pra->x_step * tmp;
- pra->y_s += pra->y_step * tmp;
- }
- ++pra;
- ++pdd.rAreasNum;
- }
- }
- ++ppa;
- yoff += dstpitch;
- ++y_start;
- }
-
- pra = &pdd.ra[0];
- for (i = 0; i < pdd.rAreasNum; ++i, ++pra) {
- uint8 *dstPtr = dst + pra->dst_offs;
- int32 w = pra->w;
- int32 x_acc = pra->x_s;
- int32 y_acc = pra->y_s;
- while (w--) {
- int32 src_offs = (y_acc / (1 << 16)) * wizW + (x_acc / (1 << 16));
- assert(src_offs < wizW * wizH);
- x_acc += pra->x_step;
- y_acc += pra->y_step;
- if (bitDepth == 2) {
- if (transColor == -1 || transColor != READ_LE_UINT16(src + src_offs * 2)) {
- writeColor(dstPtr, dstType, READ_LE_UINT16(src + src_offs * 2));
- }
- } else {
- if (transColor == -1 || transColor != src[src_offs])
- *dstPtr = src[src_offs];
- }
- dstPtr += bitDepth;
- }
+ for (int i = 0; i < _wizBufferIndex; i++) {
+ drawAWiz(
+ _wizBuffer[i].image, _wizBuffer[i].state,
+ _wizBuffer[i].x, _wizBuffer[i].y, _wizBuffer[i].z,
+ _wizBuffer[i].flags,
+ _wizBuffer[i].shadow,
+ _wizBuffer[i].zbuffer,
+ 0,
+ _wizBuffer[i].palette,
+ 0);
}
- bound.left = xmin_p;
- bound.top = ymin_p;
- bound.right = xmax_p + 1;
- bound.bottom = ymax_p + 1;
-}
-
-void Wiz::flushAWizBuffer() {
- for (int i = 0; i < _wizBufferIndex; ++i) {
- WizBufferElement *pwi = &_wizBuffer[i];
- if (pwi->flags & kWRFPolygon) {
- drawWizPolygon(pwi->image, pwi->state, pwi->x, pwi->flags, pwi->shadow, 0, pwi->palette);
- } else {
- const Common::Rect *r = nullptr;
- drawWizImage(pwi->image, pwi->state, 0, 0, pwi->x, pwi->y, pwi->z, pwi->shadow, pwi->zbuffer, r, pwi->flags, 0, _vm->getHEPaletteSlot(pwi->palette), 0);
- }
- }
_wizBufferIndex = 0;
}
void Wiz::loadWizCursor(int resId, int palette) {
int32 x, y;
- getWizImageSpot(resId, 0, x, y);
+ getWizSpot(resId, 0, x, y);
if (x < 0) {
x = 0;
} else if (x > 32) {
@@ -2812,8 +1217,7 @@ void Wiz::loadWizCursor(int resId, int palette) {
const Common::Rect *r = nullptr;
_cursorImage = true;
// TODO
- //uint8 *cursor = drawWizImage(resId, 0, 0, 0, 0, 0, 0, 0, 0, r, kWRFAlloc, 0, _vm->getHEPaletteSlot(palette), 0);
- uint8 *cursor = (uint8 *)drawAWizPrim(resId, 0, 0, 0, 0, 0, 0, 0, kWRFAlloc, 0, (WizRawPixel *)_vm->getHEPaletteSlot(palette));
+ uint8 *cursor = (uint8 *)drawAWizPrim(resId, 0, 0, 0, 0, 0, 0, r, kWRFAlloc, 0, (WizRawPixel *)_vm->getHEPaletteSlot(palette));
_cursorImage = false;
int32 cw, ch;
@@ -3235,7 +1639,7 @@ void Wiz::dwAltSourceDrawWiz(int maskImage, int maskState, int x, int y, int sou
error("Wiz::dwAltSourceDrawWiz(): Image %d missing data block", sourceImage);
}
- sourceBufferPtr += 8;
+ sourceBufferPtr += _vm->_resourceHeaderSize;
getWizImageDim(sourceImage, sourceState, srcBitmapWidth, srcBitmapHeight);
if ((destBitmapPtr->bitmapWidth != srcBitmapWidth) ||
@@ -3260,7 +1664,7 @@ void Wiz::dwAltSourceDrawWiz(int maskImage, int maskState, int x, int y, int sou
error("Wiz::dwAltSourceDrawWiz(): Image %d missing data block", maskImage);
}
- maskDataPtr += 8;
+ maskDataPtr += _vm->_resourceHeaderSize;
getWizImageDim(maskImage, maskState, maskWidth, maskHeight);
// Make sure that we have an overlap before we call the decompressor
@@ -3303,14 +1707,6 @@ void Wiz::dwAltSourceDrawWiz(int maskImage, int maskState, int x, int y, int sou
}
}
-#define SWAP_POINTS(a, b) { \
- int t; \
- t = *b; \
- *b = *a; \
- *b = t; \
-}
-
-
void Wiz::dwHandleComplexImageDraw(int image, int state, int x, int y, int shadow, int angle, int scale, const Common::Rect *clipRect, int32 flags, WizSimpleBitmap *optionalBitmapOverride, const WizRawPixel *optionalColorConversionTable) {
int w, h, correctedAngle;
Common::Point listOfPoints[4];
@@ -3318,7 +1714,7 @@ void Wiz::dwHandleComplexImageDraw(int image, int state, int x, int y, int shado
// Set the optional remap table up to the default if one isn't specified
if (!optionalColorConversionTable) {
- if (!_uses16BitColor) {
+ if (_uses16BitColor) {
optionalColorConversionTable = (WizRawPixel *)_vm->getHEPaletteSlot(1);
}
}
@@ -3340,14 +1736,14 @@ void Wiz::dwHandleComplexImageDraw(int image, int state, int x, int y, int shado
// Hflip
if (flags & kWRFHFlip) {
- SWAP_POINTS(&listOfPoints[0].x, &listOfPoints[1].x);
- SWAP_POINTS(&listOfPoints[2].x, &listOfPoints[3].x);
+ SWAP<int16>(listOfPoints[0].x, listOfPoints[1].x);
+ SWAP<int16>(listOfPoints[2].x, listOfPoints[3].x);
}
// VFlip
if (flags & kWRFVFlip) {
- SWAP_POINTS(&listOfPoints[0].y, &listOfPoints[1].y);
- SWAP_POINTS(&listOfPoints[2].y, &listOfPoints[3].y);
+ SWAP<int16>(listOfPoints[0].y, listOfPoints[1].y);
+ SWAP<int16>(listOfPoints[2].y, listOfPoints[3].y);
}
// Scale the points?
@@ -3434,8 +1830,6 @@ void Wiz::dwHandleComplexImageDraw(int image, int state, int x, int y, int shado
shadowPtr);
}
-#undef SWAP_POINTS
-
bool Wiz::dwIsMaskCompatibleCompressionType(int compressionType) {
return (kWCTTRLE == compressionType) || (kWCTMRLEWithLineSizePrefix == compressionType);
}
@@ -3791,23 +2185,23 @@ void Wiz::processWizImageRenderPixelCmd(const WizImageCommand *params) {
}
}
-void Wiz::remapImage(int image, int state, int tableCount, const uint8 *remapList, const uint8 *remapTable) {
- int tableIndex;
- uint8 *resAddr, *basePtr, *tablePtr;
+void Wiz::remapImagePrim(int image, int state, int tableCount, const uint8 *remapList, const uint8 *remapTable) {
+ int index;
+ byte *tablePtr;
+ byte *basePtr;
- resAddr = _vm->getResourceAddress(rtImage, image);
- assert(resAddr);
- basePtr = _vm->findWrappedBlock(MKTAG('R', 'M', 'A', 'P'), resAddr, state, 0);
+ // Find the table...
+ basePtr = getWizStateRemapDataPrim(rtImage, image);
assert(basePtr);
- tablePtr = basePtr + 4;
-
+ // Set the modified bit...
_vm->_res->setModified(rtImage, image);
- WRITE_BE_UINT32(basePtr, WIZ_MAGIC_REMAP_NUMBER);
+ WRITE_BE_UINT32(basePtr + _vm->_resourceHeaderSize, WIZ_MAGIC_REMAP_NUMBER);
+ tablePtr = basePtr + _vm->_resourceHeaderSize + 4;
for (int i = 0; i < tableCount; i++) {
- tableIndex = *remapList++;
- tablePtr[tableIndex] = remapTable[tableIndex];
+ index = *remapList++;
+ tablePtr[index] = remapTable[index];
}
}
@@ -3932,7 +2326,7 @@ void Wiz::processWizImageModifyCmd(const WizImageCommand *params) {
}
if (params->actionFlags & kWAFRemapList) {
- remapImage(params->image, state, params->remapCount, params->remapList, params->remapTable);
+ remapImagePrim(params->image, state, params->remapCount, params->remapList, params->remapTable);
}
}
@@ -4091,11 +2485,11 @@ void Wiz::processNewWizImageCmd(const WizImageCommand *params) {
}
int pixelDepth = (_vm->_game.features & GF_16BIT_COLOR) ? 16 : 8;
- if (propertyNumber == 1) {
+ if (propertyNumber == 1) { // Color hint property
pixelDepth = propertyValue;
if ((pixelDepth != 16) && (pixelDepth != 8)) {
- error("Wiz::processNewWizImageCmd(): Currently the only pixel depths supported for a new image are 16 and 8. You picked %d.\n", pixelDepth);
+ error("Wiz::processNewWizImageCmd(): The only pixel depths supported for a new image are 16 and 8. You picked %d.", pixelDepth);
}
}
@@ -4167,7 +2561,7 @@ void Wiz::processWizImageSaveCmd(const WizImageCommand *params) {
break;
}
default:
- error("processWizImageCmd: actionMode kWASave unhandled fileType %d", params->fileType);
+ error("processWizImageCmd: actionType kWASave unhandled fileType %d", params->fileType);
}
}
}
@@ -4177,9 +2571,9 @@ void Wiz::processWizImageCmd(const WizImageCommand *params) {
//if (PU_ProcessWizImageCmd(params)) {
// return;
//}
- debug(5, "processWizImageCmd: actionMode %d for image %d", params->actionMode, params->image);
+ //debug(5, "Wiz::processWizImageCmd(): actionType %d for image %d", params->actionType, params->image);
- switch (params->actionMode) {
+ switch (params->actionType) {
case kWAUnknown:
// Do nothing...
break;
@@ -4236,7 +2630,7 @@ void Wiz::processWizImageCmd(const WizImageCommand *params) {
processWizImageRenderEllipseCmd(params);
break;
default:
- error("Unhandled processWizImageCmd mode %d", params->actionMode);
+ error("Wiz::processWizImageCmd(): Unhandled processWizImageCmd mode %d", params->actionType);
}
}
@@ -4257,12 +2651,25 @@ void Wiz::getWizImageDim(uint8 *dataPtr, int state, int32 &w, int32 &h) {
h = READ_LE_UINT32(wizh + 0x8);
}
-void Wiz::getWizImageSpot(int resId, int state, int32 &x, int32 &y) {
+void Wiz::getWizSpot(int resId, int state, int32 &x, int32 &y) {
uint8 *dataPtr = _vm->getResourceAddress(rtImage, resId);
assert(dataPtr);
getWizImageSpot(dataPtr, state, x, y);
}
+void Wiz::getWizSpot(int resId, int32 &x, int32 &y) {
+ uint8 *dataPtr = _vm->getResourceAddress(rtImage, resId);
+ assert(dataPtr);
+ const uint8 *spotPtr = _vm->findResourceData(MKTAG('S', 'P', 'O', 'T'), dataPtr);
+
+ if (!spotPtr) {
+ x = y = 0;
+ } else {
+ x = READ_LE_UINT32(spotPtr + 0x0);
+ y = READ_LE_UINT32(spotPtr + 0x4);
+ }
+}
+
void Wiz::getWizImageSpot(uint8 *dataPtr, int state, int32 &x, int32 &y) {
uint8 *spotPtr = _vm->findWrappedBlock(MKTAG('S','P','O','T'), dataPtr, state, 0);
if (spotPtr) {
@@ -4299,7 +2706,7 @@ int Wiz::getWizImageData(int resNum, int state, int type) {
}
}
-int Wiz::getWizImageStates(int resNum) {
+int Wiz::getWizStateCount(int resNum) {
const uint8 *dataPtr = _vm->getResourceAddress(rtImage, resNum);
assert(dataPtr);
@@ -4382,155 +2789,6 @@ bool Wiz::doesStateContainBlock(int globNum, int state, uint32 blockID) {
return _vm->findWrappedBlock(blockID, data, state, false) != nullptr;
}
-int Wiz::isWizPixelNonTransparent(int resNum, int state, int x, int y, int flags) {
- uint8 *data = _vm->getResourceAddress(rtImage, resNum);
- assert(data);
-
- return isWizPixelNonTransparent(data, state, x, y, flags);
-}
-
-int Wiz::isWizPixelNonTransparent(uint8 *data, int state, int x, int y, int flags) {
- int ret = 0;
- uint8 *wizh = _vm->findWrappedBlock(MKTAG('W','I','Z','H'), data, state, 0);
- assert(wizh);
- int c = READ_LE_UINT32(wizh + 0x0);
- int w = READ_LE_UINT32(wizh + 0x4);
- int h = READ_LE_UINT32(wizh + 0x8);
-
- if (_vm->_game.id == GID_MOONBASE) {
- WizRawPixel color = 0xffff;
- drawWizImageEx((byte *)&color, data, 0, 2, kDstMemory, 1, 1, -x, -y, w, h, state, 0, 0, 0, 0, 2, 0, 0);
-
- return color != 0xffff;
- }
-
- uint8 *wizd = _vm->findWrappedBlock(MKTAG('W','I','Z','D'), data, state, 0);
- assert(wizd);
- if (x >= 0 && x < w && y >= 0 && y < h) {
- if (flags & kWRFHFlip) {
- x = w - x - 1;
- }
- if (flags & kWRFVFlip) {
- y = h - y - 1;
- }
- switch (c) {
- case 0:
- if (_vm->_game.heversion >= 99) {
- ret = getRawWizPixelColor(wizd, x, y, w, h, 1, _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR)) != _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR) ? 1 : 0;
- } else {
- ret = 0;
- }
- break;
- case 1:
- ret = isPixelNonTransparent(wizd, x, y, w, h, 1);
- break;
-#ifdef USE_RGB_COLOR
- case 2:
- ret = getRawWizPixelColor(wizd, x, y, w, h, 2, _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR)) != _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR) ? 1 : 0;
- break;
- case 4: {
- uint16 color = 0xffff;
- copyCompositeWizImage((byte *)&color, data, wizd, 0, 2, kDstMemory, 1, 1, -x, -y, w, h, state, 0, 0, 0, 0, 2, 0, 0);
- ret = color != 0xffff;
- break;
- }
- case 5:
- ret = isPixelNonTransparent(wizd, x, y, w, h, 2);
- break;
-#endif
- default:
- error("isWizPixelNonTransparent: Unhandled wiz compression type %d", c);
- break;
- }
- }
- return ret;
-}
-
-uint16 Wiz::getWizPixelColor(int resNum, int state, int x, int y) {
- uint16 color = 0;
- uint8 *data = _vm->getResourceAddress(rtImage, resNum);
- assert(data);
- uint8 *wizh = _vm->findWrappedBlock(MKTAG('W','I','Z','H'), data, state, 0);
- assert(wizh);
- int c = READ_LE_UINT32(wizh + 0x0);
- int w = READ_LE_UINT32(wizh + 0x4);
- int h = READ_LE_UINT32(wizh + 0x8);
-
- if (_vm->_game.id == GID_MOONBASE) {
- drawWizImageEx((byte *)&color, data, 0, 2, kDstMemory, 1, 1, -x, -y, w, h, state, 0, 0, 0, 0, 2, 0, 0);
-
- return color;
- }
-
- uint8 *wizd = _vm->findWrappedBlock(MKTAG('W','I','Z','D'), data, state, 0);
- assert(wizd);
- switch (c) {
- case 0:
- if (_vm->_game.heversion >= 99) {
- color = getRawWizPixelColor(wizd, x, y, w, h, 1, _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR));
- } else {
- color = _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR);
- }
- break;
- case 1:
- color = getWizPixelColor(wizd, x, y, w, h, 1, _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR));
- break;
-#ifdef USE_RGB_COLOR
- case 2:
- color = getRawWizPixelColor(wizd, x, y, w, h, 2, _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR));
- break;
- case 4:
- copyCompositeWizImage((byte *)&color, data, wizd, 0, 2, kDstMemory, 1, 1, -x, -y, w, h, state, 0, 0, 0, 0, 2, 0, 0);
- break;
- case 5:
- color = getWizPixelColor(wizd, x, y, w, h, 2, _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR));
- break;
-#endif
- default:
- error("getWizPixelColor: Unhandled wiz compression type %d", c);
- break;
- }
- return color;
-}
-
-int ScummEngine_v90he::computeWizHistogram(int resNum, int state, int x, int y, int w, int h) {
- writeVar(0, 0);
- defineArray(0, kDwordArray, 0, 0, 0, 255);
- if (readVar(0) != 0) {
- Common::Rect rCapt(x, y, w + 1, h + 1);
- uint8 *data = getResourceAddress(rtImage, resNum);
- assert(data);
- uint8 *wizh = findWrappedBlock(MKTAG('W','I','Z','H'), data, state, 0);
- assert(wizh);
- int c = READ_LE_UINT32(wizh + 0x0);
- w = READ_LE_UINT32(wizh + 0x4);
- h = READ_LE_UINT32(wizh + 0x8);
- Common::Rect rWiz(w, h);
- uint8 *wizd = findWrappedBlock(MKTAG('W','I','Z','D'), data, state, 0);
- assert(wizd);
- if (rCapt.intersects(rWiz)) {
- rCapt.clip(rWiz);
- uint32 histogram[256];
- memset(histogram, 0, sizeof(histogram));
- switch (c) {
- case 0:
- _wiz->computeRawWizHistogram(histogram, wizd, w, rCapt);
- break;
- case 1:
- _wiz->computeWizHistogram(histogram, wizd, rCapt);
- break;
- default:
- error("computeWizHistogram: Unhandled wiz compression type %d", c);
- break;
- }
- for (int i = 0; i < 256; ++i) {
- writeArray(0, 0, i, histogram[i]);
- }
- }
- }
- return readVar(0);
-}
-
} // End of namespace Scumm
#endif // ENABLE_HE
diff --git a/engines/scumm/he/wiz_he.h b/engines/scumm/he/wiz_he.h
index f91d5309669..48ad302b820 100644
--- a/engines/scumm/he/wiz_he.h
+++ b/engines/scumm/he/wiz_he.h
@@ -176,7 +176,7 @@ struct WizImageCommand {
byte filename[260];
Common::Rect box;
int actionFlags;
- int actionMode;
+ int actionType;
int params[8];
int flags;
int xPos;
@@ -213,7 +213,7 @@ struct WizImageCommand {
memset(filename, 0, sizeof(filename));
box.top = box.left = box.bottom = box.right = 0;
actionFlags = 0;
- actionMode = 0;
+ actionType = 0;
memset(params, 0, sizeof(params));
image = 0;
xPos = 0;
@@ -562,7 +562,7 @@ public:
void getWizImageDim(int resNum, int state, int32 &w, int32 &h);
void getWizImageDim(uint8 *dataPtr, int state, int32 &w, int32 &h);
- int getWizImageStates(int resnum);
+ int getWizStateCount(int resnum);
int getWizImageStates(const uint8 *ptr);
byte *getWizStateHeaderPrim(int resNum, int state);
byte *getWizStateDataPrim(int resNum, int state);
@@ -574,11 +574,6 @@ public:
const byte *getColorMixBlockPtrForWiz(int image);
void setWizCompressionType(int image, int state, int newType);
-
- int isWizPixelNonTransparent(int resnum, int state, int x, int y, int flags);
- int isWizPixelNonTransparent(uint8 *data, int state, int x, int y, int flags);
- int isPixelNonTransparent(const uint8 *data, int x, int y, int w, int h, uint8 bitdepth);
- uint16 getWizPixelColor(int resnum, int state, int x, int y);
int getWizImageData(int resNum, int state, int type);
bool isUncompressedFormatTypeID(int id);
@@ -589,12 +584,12 @@ public:
void flushAWizBuffer();
- void getWizImageSpot(int resId, int state, int32 &x, int32 &y);
+ void getWizSpot(int resId, int state, int32 &x, int32 &y);
+ void getWizSpot(int resId, int32 &x, int32 &y); // HE80
void getWizImageSpot(uint8 *data, int state, int32 &x, int32 &y);
void loadWizCursor(int resId, int palette);
void takeAWiz(int globnum, int x1, int y1, int x2, int y2, bool back, bool compress);
-
void simpleDrawAWiz(int image, int state, int x, int y, int flags);
void bufferAWiz(int image, int state, int x, int y, int z, int flags, int optionalShadowImage, int optionalZBufferImage, int whichPalette);
byte *drawAWiz(int image, int state, int x, int y, int z, int flags, int optionalShadowImage, int optionalZBufferImage,
@@ -604,54 +599,13 @@ public:
void *drawAWizPrim(int globNum, int state, int x, int y, int z, int shadowImage, int zbufferImage, const Common::Rect *optionalClipRect, int flags, WizSimpleBitmap *optionalBitmapOverride, const WizRawPixel *optionalColorConversionTable);
void *drawAWizPrimEx(int globNum, int state, int x, int y, int z, int shadowImage, int zbufferImage, const Common::Rect *optionalClipRect, int flags, WizSimpleBitmap *optionalBitmapOverride, const WizRawPixel *optionalColorConversionTable, const WizImageCommand *optionalICmdPtr);
void buildAWiz(const WizRawPixel *bufPtr, int bufWidth, int bufHeight, const byte *palettePtr, const Common::Rect *rectPtr, int compressionType, int globNum, int transparentColor);
+
int pixelHitTestWiz(int image, int state, int x, int y, int32 flags);
- int pixelHitTestWizPrim(int globNum, int state, int x, int y, int32 flags);
+ int pixelHitTestWizPrim(int image, int state, int x, int y, int32 flags);
int hitTestWiz(int image, int state, int x, int y, int32 flags);
int hitTestWizPrim(int globNum, int state, int x, int y, int32 flags);
-
- uint8 *drawWizImage(int resNum, int state, int maskNum, int maskState, int x1, int y1, int zorder, int shadow, int zbuffer, const Common::Rect *clipBox, int flags, int dstResNum, const uint8 *palPtr, uint32 conditionBits);
- void drawWizImageEx(uint8 *dst, uint8 *src, uint8 *mask, int dstPitch, int dstType, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, int state, const Common::Rect *rect, int flags, const uint8 *palPtr, int transColor, uint8 bitDepth, const uint8 *xmapPtr, uint32 conditionBits);
- void drawWizPolygon(int resNum, int state, int id, int flags, int shadow, int dstResNum, int palette);
- void drawWizComplexPolygon(int resNum, int state, int po_x, int po_y, int shadow, int angle, int zoom, const Common::Rect *r, int flags, int dstResNum, int palette);
- void drawWizPolygonTransform(int resNum, int state, Common::Point *wp, int flags, int shadow, int dstResNum, int palette);
- void drawWizPolygonImage(uint8 *dst, const uint8 *src, const uint8 *mask, int dstpitch, int dstType, int dstw, int dsth, int wizW, int wizH, Common::Rect &bound, Common::Point *wp, uint8 bitDepth);
-
-#ifdef USE_RGB_COLOR
- static void copyMaskWizImage(uint8 *dst, const uint8 *src, const uint8 *mask, int dstPitch, int dstType, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, const uint8 *palPtr);
-
- void copyCompositeWizImage(uint8 *dst, uint8 *wizPtr, uint8 *wizd, uint8 *maskPtr, int dstPitch, int dstType,
- int dstw, int dsth, int srcx, int srcy, int srcw, int srch, int state, const Common::Rect *clipBox,
- int flags, const uint8 *palPtr, int transColor, uint8 bitDepth, const uint8 *xmapPtr, uint32 conditionBits);
- void copy555WizImage(uint8 *dst, uint8 *wizd, int dstPitch, int dstType,
- int dstw, int dsth, int srcx, int srcy, const Common::Rect *clipBox, uint32 conditionBits);
-#endif
-
- static void copyAuxImage(uint8 *dst1, uint8 *dst2, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, uint8 bitdepth);
- static void copyWizImageWithMask(uint8 *dst, const uint8 *src, int dstPitch, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int maskT, int maskP);
- static void copyWizImage(uint8 *dst, const uint8 *src, int dstPitch, int dstType, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, const uint8 *palPtr, const uint8 *xmapPtr, uint8 bitdepth);
- static void copyRawWizImage(uint8 *dst, const uint8 *src, int dstPitch, int dstType, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, const uint8 *palPtr, int transColor, uint8 bitdepth);
-#ifdef USE_RGB_COLOR
- static void copy16BitWizImage(uint8 *dst, const uint8 *src, int dstPitch, int dstType, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, const uint8 *xmapPtr);
- static void copyRaw16BitWizImage(uint8 *dst, const uint8 *src, int dstPitch, int dstType, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, int transColor);
- template<int type> static void decompress16BitWizImage(uint8 *dst, int dstPitch, int dstType, const uint8 *src, const Common::Rect &srcRect, int flags, const uint8 *xmapPtr = NULL);
-#endif
- template<int type> static void decompressWizImage(uint8 *dst, int dstPitch, int dstType, const uint8 *src, const Common::Rect &srcRect, int flags, const uint8 *palPtr, const uint8 *xmapPtr, uint8 bitdepth);
- template<int type> static void decompressRawWizImage(uint8 *dst, int dstPitch, int dstType, const uint8 *src, int srcPitch, int w, int h, int transColor, const uint8 *palPtr, uint8 bitdepth);
-
-#ifdef USE_RGB_COLOR
- template<int type> static void write16BitColor(uint8 *dst, const uint8 *src, int dstType, const uint8 *xmapPtr);
-#endif
- template<int type> static void write8BitColor(uint8 *dst, const uint8 *src, int dstType, const uint8 *palPtr, const uint8 *xmapPtr, uint8 bitDepth);
- static void writeColor(uint8 *dstPtr, int dstType, WizRawPixel color);
-
- uint16 getWizPixelColor(const uint8 *data, int x, int y, int w, int h, uint8 bitDepth, WizRawPixel color);
- uint16 getRawWizPixelColor(const uint8 *data, int x, int y, int w, int h, uint8 bitDepth, WizRawPixel color);
- void computeWizHistogram(uint32 *histogram, const uint8 *data, const Common::Rect &rCapt);
- void computeRawWizHistogram(uint32 *histogram, const uint8 *data, int srcPitch, const Common::Rect &rCapt);
- void remapImage(int image, int state, int tableCount, const uint8 *remapList, const uint8 *remapTable);
-
+ void remapImagePrim(int image, int state, int tableCount, const uint8 *remapList, const uint8 *remapTable);
int createHistogramArrayForImage(int image, int state, const Common::Rect *optionalClipRect);
-
void ensureNativeFormatImageForState(int image, int state);
private:
@@ -772,9 +726,9 @@ public:
void auxDecompDRLEImage(WizRawPixel *foregroundBufferPtr, WizRawPixel *backgroundBufferPtr, byte *compData, int bufferWidth, int bufferHeight, int x, int y, int width, int height, Common::Rect *clipRectPtr, const WizRawPixel *conversionTable);
void auxDecompDRLEPrim(WizRawPixel *foregroundBufferPtr, WizRawPixel *backgroundBufferPtr, int bufferWidth, Common::Rect *destRect, byte *compData, Common::Rect *sourceRect, const WizRawPixel *conversionTable);
- void auxDecompTRLEStream(WizRawPixel *destPtr, byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable);
- void auxDecompTRLEImage(WizRawPixel *bufferPtr, byte *compData, int bufferWidth, int bufferHeight, int x, int y, int width, int height, Common::Rect *clipRectPtr, const WizRawPixel *conversionTable);
- void auxDecompTRLEPrim(WizRawPixel *bufferPtr, int bufferWidth, Common::Rect *destRect, byte *compData, Common::Rect *sourceRect, const WizRawPixel *conversionTable);
+ void auxDecompTRLEStream(WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable);
+ void auxDecompTRLEImage(WizRawPixel *bufferPtr, const byte *compData, int bufferWidth, int bufferHeight, int x, int y, int width, int height, Common::Rect *clipRectPtr, const WizRawPixel *conversionTable);
+ void auxDecompTRLEPrim(WizRawPixel *bufferPtr, int bufferWidth, Common::Rect *destRect, const byte *compData, Common::Rect *sourceRect, const WizRawPixel *conversionTable);
void auxDrawZplaneFromTRLEImage(byte *zplanePtr, byte *compData, int zplanePixelWidth, int zplanePixelHeight, int x, int y, int width, int height, Common::Rect *clipRectPtr, int transOp, int solidOp);
void auxDrawZplaneFromTRLEPrim(byte *zplanePtr, int zplanePixelWidth, Common::Rect *destRect, byte *compData, Common::Rect *sourceRect, int transOp, int solidOp);
@@ -782,8 +736,8 @@ public:
void auxDecompRemappedTRLEImage(WizRawPixel *bufferPtr, byte *compData, int bufferWidth, int bufferHeight, int x, int y, int width, int height, Common::Rect *clipRectPtr, byte *remapTable, const WizRawPixel *conversionTable);
void auxDecompRemappedTRLEPrim(WizRawPixel *bufferPtr, int bufferWidth, Common::Rect *destRect, byte *compData, Common::Rect *sourceRect, byte *remapTable, const WizRawPixel *conversionTable);
- bool auxHitTestTRLEXPos(byte *dataStream, int skipAmount);
- bool auxHitTestTRLEImageRelPos(byte *compData, int x, int y, int width, int height);
+ bool auxHitTestTRLEXPos(const byte *dataStream, int skipAmount);
+ bool auxHitTestTRLEImageRelPos(const byte *compData, int x, int y, int width, int height);
bool auxPixelHitTestTRLEXPos(byte *dataStream, int skipAmount, int transparentValue);
int auxPixelHitTestTRLEImageRelPos(byte *compData, int x, int y, int width, int height, int transparentValue);
diff --git a/engines/scumm/saveload.cpp b/engines/scumm/saveload.cpp
index e21b4b9c044..aa918f70c8b 100644
--- a/engines/scumm/saveload.cpp
+++ b/engines/scumm/saveload.cpp
@@ -2279,10 +2279,10 @@ void ScummEngine_v90he::saveLoadWithSerializer(Common::Serializer &s) {
syncWithSerializer(s, _floodFillCommand);
- s.syncAsSint32LE(_curMaxSpriteId, VER(51));
- s.syncAsSint32LE(_curSpriteId, VER(51));
+ s.syncAsSint32LE(_maxSpriteNum, VER(51));
+ s.syncAsSint32LE(_minSpriteNum, VER(51));
s.syncAsSint32LE(_curSpriteGroupId, VER(51));
- s.skip(4, VER(51), VER(63)); // _numSpritesToProcess
+ s.skip(4, VER(51), VER(63)); // _activeSpriteCount
s.syncAsSint32LE(_heObject, VER(51));
s.syncAsSint32LE(_heObjectNum, VER(51));
s.syncAsSint32LE(_hePaletteNum, VER(51));
diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
index a62fb7c0968..9752cb0a606 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -773,6 +773,7 @@ ScummEngine_v90he::ScummEngine_v90he(OSystem *syst, const DetectorResult &dr)
VAR_NUM_SPRITES = 0xFF;
VAR_NUM_PALETTES = 0xFF;
VAR_NUM_UNK = 0xFF;
+ VAR_SPRITE_IMAGE_CHANGE_DOES_NOT_RESET_SETTINGS = 0xFF;
VAR_U32_VERSION = 0xFF;
VAR_U32_ARRAY_UNK = 0xFF;
@@ -1981,7 +1982,7 @@ void ScummEngine_v90he::resetScumm() {
_heObjectNum = 0;
_hePaletteNum = 0;
- _sprite->resetTables(0);
+ _sprite->resetSpriteSystem(false);
_wizImageCommand.reset();
if (_game.heversion >= 98)
@@ -2815,7 +2816,7 @@ void ScummEngine_v90he::scummLoop(int delta) {
ScummEngine::scummLoop(delta);
- _sprite->updateImages();
+ _sprite->runSpriteEngines();
if (_game.heversion >= 98) {
_logicHE->endOfFrame();
}
@@ -3519,8 +3520,8 @@ void ScummEngine_v90he::scummLoop_handleDrawing() {
_fullRedraw = false;
if (_game.heversion >= 90) {
- _sprite->resetBackground();
- _sprite->sortActiveSprites();
+ _sprite->eraseSprites();
+ _sprite->buildActiveSpriteList();
}
}
#endif
diff --git a/engines/scumm/vars.cpp b/engines/scumm/vars.cpp
index 6c6214cfcb7..7879bcef0bc 100644
--- a/engines/scumm/vars.cpp
+++ b/engines/scumm/vars.cpp
@@ -357,6 +357,7 @@ void ScummEngine_v90he::setupScummVars() {
VAR_MAIN_SCRIPT = 127;
VAR_NUM_PALETTES = 130;
VAR_NUM_UNK = 131;
+ VAR_SPRITE_IMAGE_CHANGE_DOES_NOT_RESET_SETTINGS = 139;
}
}
Commit: 4bcfff35bdc73dad2bf2574298a6515ba64533e1
https://github.com/scummvm/scummvm/commit/4bcfff35bdc73dad2bf2574298a6515ba64533e1
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Bump save version
Changed paths:
engines/scumm/he/sprite_he.cpp
engines/scumm/saveload.cpp
diff --git a/engines/scumm/he/sprite_he.cpp b/engines/scumm/he/sprite_he.cpp
index 68f9e3a086d..fa954025c28 100644
--- a/engines/scumm/he/sprite_he.cpp
+++ b/engines/scumm/he/sprite_he.cpp
@@ -1905,10 +1905,21 @@ static void syncWithSerializer(Common::Serializer &s, SpriteGroup &sg) {
s.syncAsSint32LE(sg.yDiv, VER(48));
}
+static void syncWithSerializer(Common::Serializer &s, SpriteImageList &sil) {
+ for (int i = 0; i < ARRAYSIZE(sil.list); i++) {
+ s.syncAsSint16LE(sil.list[i], VER(119));
+ }
+
+ s.syncAsSint16LE(sil.count, VER(119));
+}
+
void Sprite::saveLoadWithSerializer(Common::Serializer &s) {
if (s.getVersion() >= VER(64)) {
s.syncArray(_spriteTable, _maxSprites + 1, syncWithSerializer);
s.syncArray(_groupTable, _maxSpriteGroups + 1, syncWithSerializer);
+ if (s.getVersion() >= VER(119)) {
+ s.syncArray(_imageLists, _maxImageLists + 1, syncWithSerializer);
+ }
} else {
// TODO: This had been bogus, what is it really supposed to do?
// s->saveLoadArrayOf(_activeSprites, _maxSprites, sizeof(_activeSprites[0]), spriteEntries);
diff --git a/engines/scumm/saveload.cpp b/engines/scumm/saveload.cpp
index aa918f70c8b..66eeadfdc4e 100644
--- a/engines/scumm/saveload.cpp
+++ b/engines/scumm/saveload.cpp
@@ -69,7 +69,7 @@ struct SaveInfoSection {
#define SaveInfoSectionSize (4+4+4 + 4+4 + 4+2)
-#define CURRENT_VER 118
+#define CURRENT_VER 119
#define INFOSECTION_VERSION 2
#pragma mark -
@@ -2269,7 +2269,7 @@ void syncWithSerializer(Common::Serializer &s, FloodFillCommand &ffc) {
s.syncAsSint32LE(ffc.y, VER(51));
s.syncAsSint32LE(ffc.flags, VER(51));
s.skip(4, VER(51), VER(62)); // color
- s.syncAsSint32LE(ffc.color, VER(114));
+ s.syncAsSint32LE(ffc.color, VER(119));
}
void ScummEngine_v90he::saveLoadWithSerializer(Common::Serializer &s) {
Commit: 483ac31ced397514e4806b3b856eb47cfcdf4ed1
https://github.com/scummvm/scummvm/commit/483ac31ced397514e4806b3b856eb47cfcdf4ed1
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Relabel Polygon functions
Changed paths:
engines/scumm/he/polygon_he.cpp
engines/scumm/he/script_v71he.cpp
engines/scumm/he/script_v72he.cpp
engines/scumm/he/script_v90he.cpp
engines/scumm/he/wiz_he.h
engines/scumm/object.cpp
diff --git a/engines/scumm/he/polygon_he.cpp b/engines/scumm/he/polygon_he.cpp
index 4e1c007b4f2..319c0d5daef 100644
--- a/engines/scumm/he/polygon_he.cpp
+++ b/engines/scumm/he/polygon_he.cpp
@@ -28,7 +28,7 @@
namespace Scumm {
-void Wiz::polygonClear() {
+void Wiz::deleteLocalPolygons() {
for (int i = 0; i < ARRAYSIZE(_polygons); i++) {
if (_polygons[i].flag == 1)
_polygons[i].reset();
@@ -56,11 +56,11 @@ void Wiz::polygonLoad(const uint8 *polData) {
vert4y = READ_LE_UINT32(polData + 36);
polData += 40;
- polygonStore(id, flag, vert1x, vert1y, vert2x, vert2y, vert3x, vert3y, vert4x, vert4y);
+ set4Polygon(id, flag, vert1x, vert1y, vert2x, vert2y, vert3x, vert3y, vert4x, vert4y);
}
}
-void Wiz::polygonStore(int id, bool localFlag, int vert1x, int vert1y, int vert2x, int vert2y, int vert3x, int vert3y, int vert4x, int vert4y) {
+void Wiz::set4Polygon(int id, bool localFlag, int vert1x, int vert1y, int vert2x, int vert2y, int vert3x, int vert3y, int vert4x, int vert4y) {
for (int i = 0; i < ARRAYSIZE(_polygons); ++i) {
if (_polygons[i].id == 0) {
_polygons[i].points[0].x = vert1x;
@@ -83,7 +83,7 @@ void Wiz::polygonStore(int id, bool localFlag, int vert1x, int vert1y, int vert2
}
}
- error("Wiz::polygonStore: out of polygon slot, max = %d", ARRAYSIZE(_polygons));
+ error("Wiz::set4Polygon: out of polygon slot, max = %d", ARRAYSIZE(_polygons));
}
void Wiz::polyRotatePoints(Common::Point *pts, int num, int angle) {
@@ -99,42 +99,6 @@ void Wiz::polyRotatePoints(Common::Point *pts, int num, int angle) {
}
}
-void Wiz::polygonTransform(int resNum, int state, int po_x, int po_y, int angle, int scale, Common::Point *pts) {
- int32 w, h;
-
- getWizImageDim(resNum, state, w, h);
-
- // set the transformation origin to the center of the image
- if (_vm->_game.heversion >= 99) {
- pts[0].x = pts[3].x = -(w / 2);
- pts[1].x = pts[2].x = w / 2 - 1;
- pts[0].y = pts[1].y = -(h / 2);
- pts[2].y = pts[3].y = h / 2 - 1;
- } else {
- pts[1].x = pts[2].x = w / 2 - 1;
- pts[0].x = pts[0].y = pts[1].y = pts[3].x = -(w / 2);
- pts[2].y = pts[3].y = h / 2 - 1;
- }
-
- // scale
- if (scale != 0 && scale != 256) {
- for (int i = 0; i < 4; ++i) {
- pts[i].x = pts[i].x * scale / 256;
- pts[i].y = pts[i].y * scale / 256;
- }
- }
-
- // rotate
- if (angle != 0)
- polyRotatePoints(pts, 4, angle);
-
- // translate
- for (int i = 0; i < 4; ++i) {
- pts[i].x += po_x;
- pts[i].y += po_y;
- }
-}
-
void Wiz::polyMovePolygonPoints(Common::Point *listOfPoints, int numverts, int deltaX, int deltaY) {
for (int i = 0; i < numverts; i++) {
listOfPoints->x += deltaX;
@@ -187,28 +151,51 @@ void Wiz::polyBuildBoundingRect(Common::Point *points, int numVerts, Common::Rec
}
}
-void Wiz::polygonErase(int fromId, int toId) {
+void Wiz::deletePolygon(int fromId, int toId) {
for (int i = 0; i < ARRAYSIZE(_polygons); i++) {
if (_polygons[i].id >= fromId && _polygons[i].id <= toId)
_polygons[i].reset();
}
}
-int Wiz::polygonTestForObjectHit(int id, int x, int y) {
+int Wiz::findPolygon(int x, int y) {
+ Common::Point checkPoint((int16)x, (int16)y);
+
for (int i = 0; i < ARRAYSIZE(_polygons); i++) {
- if ((id == 0 || _polygons[i].id == id) && _polygons[i].boundingRect.contains(x, y)) {
+ if (isPointInRect(&_polygons[i].boundingRect, &checkPoint)) {
if (polyIsPointInsidePoly(_polygons[i], x, y)) {
return _polygons[i].id;
}
}
}
+ return 0;
+}
+
+int Wiz::testForObjectPolygon(int object, int x, int y) {
+ Common::Point checkPoint((int16)x, (int16)y);
+
+ if (object == 0)
+ return 0;
+
+ for (int i = 0; i < ARRAYSIZE(_polygons); i++) {
+ if (_polygons[i].id == object) {
+ if (isPointInRect(&_polygons[i].boundingRect, &checkPoint)) {
+ if (polyIsPointInsidePoly(_polygons[i], x, y)) {
+ return 1;
+ }
+ }
+ }
+ }
return 0;
}
-bool Wiz::polygonDefined(int id) {
+bool Wiz::doesObjectHavePolygon(int object) {
+ if (object == 0)
+ return false;
+
for (int i = 0; i < ARRAYSIZE(_polygons); i++)
- if (_polygons[i].id == id)
+ if (_polygons[i].id == object)
return true;
return false;
}
diff --git a/engines/scumm/he/script_v71he.cpp b/engines/scumm/he/script_v71he.cpp
index 3b99d9c435c..850d17de80e 100644
--- a/engines/scumm/he/script_v71he.cpp
+++ b/engines/scumm/he/script_v71he.cpp
@@ -418,13 +418,13 @@ void ScummEngine_v71he::o71_polygonOps() {
vert1x = pop();
flag = (subOp == ScummEngine_v100he::SO_SET_POLYGON_LOCAL || subOp == SO_SET_POLYGON_LOCAL);
id = pop();
- _wiz->polygonStore(id, flag, vert1x, vert1y, vert2x, vert2y, vert3x, vert3y, vert4x, vert4y);
+ _wiz->set4Polygon(id, flag, vert1x, vert1y, vert2x, vert2y, vert3x, vert3y, vert4x, vert4y);
break;
case ScummEngine_v100he::SO_DELETE_POLYGON: // HE 100
case SO_DELETE_POLYGON:
toId = pop();
fromId = pop();
- _wiz->polygonErase(fromId, toId);
+ _wiz->deletePolygon(fromId, toId);
break;
default:
error("o71_polygonOps: default case %d", subOp);
@@ -434,7 +434,7 @@ void ScummEngine_v71he::o71_polygonOps() {
void ScummEngine_v71he::o71_polygonHit() {
int y = pop();
int x = pop();
- push(_wiz->polygonTestForObjectHit(0, x, y));
+ push(_wiz->findPolygon(x, y));
}
} // End of namespace Scumm
diff --git a/engines/scumm/he/script_v72he.cpp b/engines/scumm/he/script_v72he.cpp
index a2fc1e03a74..bb010eb53d6 100644
--- a/engines/scumm/he/script_v72he.cpp
+++ b/engines/scumm/he/script_v72he.cpp
@@ -417,8 +417,8 @@ int ScummEngine_v72he::findObject(int x, int y, int num, int *args) {
continue;
// Check polygon bounds
- if (_wiz->polygonDefined(_objs[i].obj_nr)) {
- if (_wiz->polygonTestForObjectHit(_objs[i].obj_nr, x, y))
+ if (_wiz->doesObjectHavePolygon(_objs[i].obj_nr)) {
+ if (_wiz->testForObjectPolygon(_objs[i].obj_nr, x, y))
result = _objs[i].obj_nr;
else if (VAR_POLYGONS_ONLY != 0xFF && VAR(VAR_POLYGONS_ONLY))
continue;
diff --git a/engines/scumm/he/script_v90he.cpp b/engines/scumm/he/script_v90he.cpp
index 0634faf5538..8572302ead0 100644
--- a/engines/scumm/he/script_v90he.cpp
+++ b/engines/scumm/he/script_v90he.cpp
@@ -1206,7 +1206,7 @@ void ScummEngine_v90he::o90_setSpriteGroupInfo() {
_sprite->setGroupMembersShadow(_curSpriteGroupId, value1);
break;
default:
- error("o90_setSpriteGroupInfo subOp 0: Unknown case %d", subOp);
+ error("o90_setSpriteGroupInfo checkType 0: Unknown case %d", subOp);
}
break;
case SO_PROPERTY: // 42
@@ -1229,7 +1229,7 @@ void ScummEngine_v90he::o90_setSpriteGroupInfo() {
_sprite->setGroupYDiv(_curSpriteGroupId, value1);
break;
default:
- error("o90_setSpriteGroupInfo subOp 5: Unknown case %d", subOp);
+ error("o90_setSpriteGroupInfo checkType 5: Unknown case %d", subOp);
}
break;
case SO_PRIORITY: // 43
@@ -1536,7 +1536,7 @@ void ScummEngine_v90he::o90_getVideoData() {
push(_moviePlay->getImageNum());
break;
case SO_NEW_GENERAL_PROPERTY: // 139
- debug(0, "o90_getVideoData: subOp 107 stub (%d, %d)", pop(), pop());
+ debug(0, "o90_getVideoData: checkType 107 stub (%d, %d)", pop(), pop());
push(0);
break;
default:
@@ -1637,71 +1637,72 @@ void ScummEngine_v90he::o90_findAllObjectsWithClassOf() {
}
void ScummEngine_v90he::o90_getPolygonOverlap() {
- int args1[32];
- int args2[32];
+ int lastList[32];
+ int firstList[32];
- int n1 = getStackList(args1, ARRAYSIZE(args1));
- int n2 = getStackList(args2, ARRAYSIZE(args2));
+ int lastCount = getStackList(lastList, ARRAYSIZE(lastList));
+ int firstCount = getStackList(firstList, ARRAYSIZE(firstList));
- int subOp = pop();
+ int checkType = pop();
- switch (subOp) {
+ switch (checkType) {
case OVERLAP_POINT_TO_RECT: // 1
{
- Common::Rect r(args1[0], args1[1], args1[2] + 1, args1[3] + 1);
- Common::Point p(args2[0], args2[1]);
- push(r.contains(p) ? 1 : 0);
+ Common::Rect r(lastList[0], lastList[1], lastList[2], lastList[3]);
+ Common::Point p(firstList[0], firstList[1]);
+
+ push(_wiz->isPointInRect(&r, &p) ? 1 : 0);
}
break;
case OVERLAP_POINT_TO_CIRCLE: // 2
{
- int dx = args2[0] - args1[0];
- int dy = args2[1] - args1[1];
+ int dx = firstList[0] - lastList[0];
+ int dy = firstList[1] - lastList[1];
int dist = dx * dx + dy * dy;
if (dist >= 2) {
dist = (int)sqrt((double)(dist + 1));
}
if (_game.heversion >= 98) {
- push((dist <= args1[2]) ? 1 : 0);
+ push((dist <= lastList[2]) ? 1 : 0);
} else {
- push((dist > args1[2]) ? 1 : 0);
+ push((dist > lastList[2]) ? 1 : 0);
}
}
break;
case OVERLAP_RECT_TO_RECT: // 3
{
- Common::Rect r1(args1[0], args1[1], args1[2] + 1, args1[3] + 1);
- Common::Rect r2(args2[0], args2[1], args2[2] + 1, args2[3] + 1);
+ Common::Rect r1(lastList[0], lastList[1], lastList[2] + 1, lastList[3] + 1);
+ Common::Rect r2(firstList[0], firstList[1], firstList[2] + 1, firstList[3] + 1);
push(r2.intersects(r1) ? 1 : 0);
}
break;
case OVERLAP_CIRCLE_TO_CIRCLE: // 4
{
- int dx = args2[0] - args1[0];
- int dy = args2[1] - args1[1];
+ int dx = firstList[0] - lastList[0];
+ int dy = firstList[1] - lastList[1];
int dist = dx * dx + dy * dy;
if (dist >= 2) {
dist = (int)sqrt((double)(dist + 1));
}
- push((dist < args1[2] && dist < args2[2]) ? 1 : 0);
+ push((dist < lastList[2] && dist < firstList[2]) ? 1 : 0);
}
break;
case OVERLAP_POINT_N_SIDED_POLYGON: // 5
{
- assert((n1 & 1) == 0);
- n1 /= 2;
- if (n1 == 0) {
+ assert((lastCount & 1) == 0);
+ lastCount /= 2;
+ if (lastCount == 0) {
push(0);
} else {
WizPolygon wp;
wp.reset();
- wp.numPoints = n1;
- assert(n1 < ARRAYSIZE(wp.points));
- for (int i = 0; i < n1; ++i) {
- wp.points[i].x = args1[i * 2 + 0];
- wp.points[i].y = args1[i * 2 + 1];
+ wp.numPoints = lastCount;
+ assert(lastCount < ARRAYSIZE(wp.points));
+ for (int i = 0; i < lastCount; ++i) {
+ wp.points[i].x = lastList[i * 2 + 0];
+ wp.points[i].y = lastList[i * 2 + 1];
}
- push(_wiz->polyIsPointInsidePoly(wp, args2[0], args2[1]) ? 1 : 0);
+ push(_wiz->polyIsPointInsidePoly(wp, firstList[0], firstList[1]) ? 1 : 0);
}
}
break;
@@ -1709,24 +1710,24 @@ void ScummEngine_v90he::o90_getPolygonOverlap() {
case OVERLAP_SPRITE_TO_SPRITE: // 6
{
Common::Rect r1, r2;
- _sprite->getSpriteLogicalRect(args2[0], false, r2);
- _sprite->getSpriteLogicalRect(args1[0], false, r1);
+ _sprite->getSpriteLogicalRect(firstList[0], false, r2);
+ _sprite->getSpriteLogicalRect(lastList[0], false, r1);
if (r2.isValidRect() == false) {
push(0);
break;
}
- if (n2 == 3) {
- r2.left += args2[1];
- r2.right += args2[1];
- r2.top += args2[2];
- r2.bottom += args2[2];
+ if (firstCount == 3) {
+ r2.left += firstList[1];
+ r2.right += firstList[1];
+ r2.top += firstList[2];
+ r2.bottom += firstList[2];
}
- if (n1 == 3) {
- r1.left += args1[1];
- r1.right += args1[1];
- r1.top += args1[2];
- r1.bottom += args1[2];
+ if (lastCount == 3) {
+ r1.left += lastList[1];
+ r1.right += lastList[1];
+ r1.top += lastList[2];
+ r1.bottom += lastList[2];
}
push(r2.intersects(r1) ? 1 : 0);
}
@@ -1734,18 +1735,18 @@ void ScummEngine_v90he::o90_getPolygonOverlap() {
case OVERLAP_SPRITE_TO_RECT: // 7
{
Common::Rect r2;
- _sprite->getSpriteLogicalRect(args2[0], false, r2);
- Common::Rect r1(args1[0], args1[1], args1[2] + 1, args1[3] + 1);
+ _sprite->getSpriteLogicalRect(firstList[0], false, r2);
+ Common::Rect r1(lastList[0], lastList[1], lastList[2] + 1, lastList[3] + 1);
if (r2.isValidRect() == false) {
push(0);
break;
}
- if (n2 == 3) {
- r2.left += args2[1];
- r2.right += args2[1];
- r2.top += args2[2];
- r2.bottom += args2[2];
+ if (firstCount == 3) {
+ r2.left += firstList[1];
+ r2.right += firstList[1];
+ r2.top += firstList[2];
+ r2.bottom += firstList[2];
}
push(r2.intersects(r1) ? 1 : 0);
}
@@ -1755,24 +1756,24 @@ void ScummEngine_v90he::o90_getPolygonOverlap() {
// TODO: Draw sprites to buffer and compare.
{
Common::Rect r1, r2;
- _sprite->getSpriteLogicalRect(args2[0], true, r2);
- _sprite->getSpriteLogicalRect(args1[0], true, r1);
+ _sprite->getSpriteLogicalRect(firstList[0], true, r2);
+ _sprite->getSpriteLogicalRect(lastList[0], true, r1);
if (r2.isValidRect() == false) {
push(0);
break;
}
- if (n2 == 3) {
- r2.left += args2[1];
- r2.right += args2[1];
- r2.top += args2[2];
- r2.bottom += args2[2];
+ if (firstCount == 3) {
+ r2.left += firstList[1];
+ r2.right += firstList[1];
+ r2.top += firstList[2];
+ r2.bottom += firstList[2];
}
- if (n1 == 3) {
- r1.left += args1[1];
- r1.right += args1[1];
- r1.top += args1[2];
- r1.bottom += args1[2];
+ if (lastCount == 3) {
+ r1.left += lastList[1];
+ r1.right += lastList[1];
+ r1.top += lastList[2];
+ r1.bottom += lastList[2];
}
push(r2.intersects(r1) ? 1 : 0);
}
@@ -1780,24 +1781,24 @@ void ScummEngine_v90he::o90_getPolygonOverlap() {
case OVERLAP_DRAW_POS_SPRITE_TO_RECT: // 9
{
Common::Rect r2;
- _sprite->getSpriteLogicalRect(args2[0], true, r2);
- Common::Rect r1(args1[0], args1[1], args1[2] + 1, args1[3] + 1);
+ _sprite->getSpriteLogicalRect(firstList[0], true, r2);
+ Common::Rect r1(lastList[0], lastList[1], lastList[2] + 1, lastList[3] + 1);
if (r2.isValidRect() == false) {
push(0);
break;
}
- if (n2 == 3) {
- r2.left += args2[1];
- r2.right += args2[1];
- r2.top += args2[2];
- r2.bottom += args2[2];
+ if (firstCount == 3) {
+ r2.left += firstList[1];
+ r2.right += firstList[1];
+ r2.top += firstList[2];
+ r2.bottom += firstList[2];
}
push(r2.intersects(r1) ? 1 : 0);
}
break;
default:
- error("o90_getPolygonOverlap: default case %d", subOp);
+ error("o90_getPolygonOverlap: default case %d", checkType);
}
}
diff --git a/engines/scumm/he/wiz_he.h b/engines/scumm/he/wiz_he.h
index 48ad302b820..a1385ab2669 100644
--- a/engines/scumm/he/wiz_he.h
+++ b/engines/scumm/he/wiz_he.h
@@ -520,16 +520,16 @@ public:
bool _uses16BitColor = false;
int _lWizActiveShadow = 0;
- void polygonClear();
+ void deleteLocalPolygons();
void polygonLoad(const uint8 *polData);
- void polygonStore(int id, bool flag, int vert1x, int vert1y, int vert2x, int vert2y, int vert3x, int vert3y, int vert4x, int vert4y);
+ void set4Polygon(int id, bool flag, int vert1x, int vert1y, int vert2x, int vert2y, int vert3x, int vert3y, int vert4x, int vert4y);
void polyBuildBoundingRect(Common::Point *vert, int numVerts, Common::Rect & bound);
- void polygonErase(int fromId, int toId);
- int polygonTestForObjectHit(int id, int x, int y);
- bool polygonDefined(int id);
+ void deletePolygon(int fromId, int toId);
+ int testForObjectPolygon(int id, int x, int y);
+ int findPolygon(int x, int y);
+ bool doesObjectHavePolygon(int id);
bool polyIsPointInsidePoly(const WizPolygon &pol, int x, int y);
void polyRotatePoints(Common::Point *pts, int num, int alpha);
- void polygonTransform(int resNum, int state, int po_x, int po_y, int angle, int zoom, Common::Point *vert);
void polyMovePolygonPoints(Common::Point *listOfPoints, int numverts, int deltaX, int deltaY);
bool polyIsRectangle(const Common::Point *points, int numverts);
diff --git a/engines/scumm/object.cpp b/engines/scumm/object.cpp
index 1d5a53e43ee..9d8b87be325 100644
--- a/engines/scumm/object.cpp
+++ b/engines/scumm/object.cpp
@@ -569,7 +569,7 @@ int ScummEngine::findObject(int x, int y) {
if (b == 0) {
#ifdef ENABLE_HE
if (_game.heversion >= 71) {
- if (((ScummEngine_v71he *)this)->_wiz->polygonTestForObjectHit(_objs[i].obj_nr, x, y))
+ if (((ScummEngine_v71he *)this)->_wiz->testForObjectPolygon(_objs[i].obj_nr, x, y))
return _objs[i].obj_nr;
}
#endif
@@ -1213,7 +1213,7 @@ void ScummEngine_v6::clearDrawQueues() {
void ScummEngine_v71he::clearDrawQueues() {
ScummEngine_v6::clearDrawQueues();
- _wiz->polygonClear();
+ _wiz->deleteLocalPolygons();
}
void ScummEngine_v80he::clearDrawQueues() {
Commit: 50d18e054d7b0af575a71524d871b9a1d5e41277
https://github.com/scummvm/scummvm/commit/50d18e054d7b0af575a71524d871b9a1d5e41277
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Implement proper sprite collision
Also introduce proper SCUMM math functions.
Changed paths:
A engines/scumm/he/math_he.cpp
engines/scumm/he/gfx_primitives_he.cpp
engines/scumm/he/intern_he.h
engines/scumm/he/polygon_he.cpp
engines/scumm/he/script_v100he.cpp
engines/scumm/he/script_v90he.cpp
engines/scumm/he/sprite_he.cpp
engines/scumm/he/sprite_he.h
engines/scumm/he/wiz_he.cpp
engines/scumm/he/wiz_he.h
engines/scumm/module.mk
diff --git a/engines/scumm/he/gfx_primitives_he.cpp b/engines/scumm/he/gfx_primitives_he.cpp
index a7933b5881f..3eb83157cc3 100644
--- a/engines/scumm/he/gfx_primitives_he.cpp
+++ b/engines/scumm/he/gfx_primitives_he.cpp
@@ -1736,6 +1736,30 @@ WizRawPixel Wiz::convert8BppToRawPixel(WizRawPixel value, const WizRawPixel *con
}
}
+bool Wiz::compareDoPixelStreamsOverlap(const WizRawPixel *a, const WizRawPixel *b, int width, WizRawPixel transparentColor) {
+ const WizRawPixel8 *a8 = (const WizRawPixel8 *)a;
+ const WizRawPixel8 *b8 = (const WizRawPixel8 *)b;
+
+ const WizRawPixel16 *a16 = (const WizRawPixel16 *)a;
+ const WizRawPixel16 *b16 = (const WizRawPixel16 *)b;
+
+ if (!_uses16BitColor) {
+ for (int i = 0; i < width; i++) {
+ if ((*a8++ != (WizRawPixel8)transparentColor) && (*b8++ != (WizRawPixel8)transparentColor)) {
+ return true;
+ }
+ }
+ } else {
+ for (int i = 0; i < width; i++) {
+ if ((*a16++ != (WizRawPixel16)transparentColor) && (*b16++ != (WizRawPixel16)transparentColor)) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
void Wiz::rawPixelExtractComponents(WizRawPixel aPixel, int &r, int &g, int &b) {
r = (aPixel & WIZRAWPIXEL_R_MASK) >> WIZRAWPIXEL_R_SHIFT;
g = (aPixel & WIZRAWPIXEL_G_MASK) >> WIZRAWPIXEL_G_SHIFT;
diff --git a/engines/scumm/he/intern_he.h b/engines/scumm/he/intern_he.h
index 7af2da8ff3b..96705c59e1c 100644
--- a/engines/scumm/he/intern_he.h
+++ b/engines/scumm/he/intern_he.h
@@ -703,6 +703,20 @@ protected:
void copyHEPalette(int dstPalSlot, int srcPalSlot);
void copyHEPaletteColor(int palSlot, uint8 dstColor, uint16 srcColor);
+ /*
+ * Math functions
+ *
+ * Please do not attempt to revert these to our standard math functions!
+ * These are accurate for the games, ours aren't :-P
+ */
+ int scummMathSin(int angle);
+ int scummMathCos(int angle);
+ int scummMathSqrt(int value);
+ int scummMathDist2D(int x1, int y1, int x2, int y2);
+ int scummMathAngleFromDelta(int dx, int dy);
+ int scummMathAngleOfLineSegment(int x1, int y1, int x2, int y2);
+
+
protected:
/* HE version 90 script opcodes */
void o90_dup_n();
@@ -711,8 +725,8 @@ protected:
void o90_sin();
void o90_cos();
void o90_sqrt();
- void o90_atan2();
- void o90_getSegmentAngle();
+ void o90_getAngleFromDelta();
+ void o90_getAngleFromLine();
void o90_getActorData();
void o90_priorityStartScript();
void o90_priorityChainScript();
@@ -731,7 +745,7 @@ protected:
void o90_shr();
void o90_xor();
void o90_findAllObjectsWithClassOf();
- void o90_getPolygonOverlap();
+ void o90_getOverlap();
void o90_cond();
void o90_dim2dim2Array();
void o90_redim2dimArray();
diff --git a/engines/scumm/he/math_he.cpp b/engines/scumm/he/math_he.cpp
new file mode 100644
index 00000000000..b923136ed51
--- /dev/null
+++ b/engines/scumm/he/math_he.cpp
@@ -0,0 +1,156 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifdef ENABLE_HE
+
+#include "scumm/he/intern_he.h"
+#include "scumm/scumm.h"
+#include "scumm/util.h"
+
+namespace Scumm {
+
+static int _scummMathSineTable[181] = {
+ 0, 1745, 3489, 5233, 6975, 8715, 10452, 12186, 13917,
+ 15643, 17364, 19080, 20791, 22495, 24192, 25881, 27563, 29237,
+ 30901, 32556, 34202, 35836, 37460, 39073, 40673, 42261, 43837,
+ 45399, 46947, 48480, 50000, 51503, 52991, 54463, 55919, 57357,
+ 58778, 60181, 61656, 62932, 64278, 65605, 66913, 68199, 69465,
+ 70710, 71933, 73135, 74314, 75470, 76604, 77714, 78801, 79863,
+ 80901, 81915, 82903, 83867, 84804, 85716, 86602, 87461, 88294,
+ 89100, 89879, 90630, 91354, 92050, 92718, 93358, 93969, 94551,
+ 95105, 95630, 96126, 96592, 97029, 97437, 97814, 98162, 98480,
+ 98768, 99026, 99254, 99452, 99619, 99756, 99862, 99939, 99984,
+ 100000, 99984, 99939, 99862, 99756, 99619, 99452, 99254, 99026,
+ 98768, 98480, 98162, 97814, 97437, 97029, 96592, 96126, 95630,
+ 95105, 94551, 93969, 93358, 92718, 92050, 91354, 90630, 89879,
+ 89100, 88294, 87461, 86602, 85716, 84804, 83867, 82903, 81915,
+ 80901, 79863, 78801, 77714, 76604, 75470, 74314, 73135, 71933,
+ 70710, 69465, 68199, 66913, 65605, 64278, 62932, 61656, 60181,
+ 58778, 57357, 55919, 54463, 52991, 51503, 50000, 48480, 46947,
+ 45399, 43837, 42261, 40673, 39073, 37460, 35836, 34202, 32556,
+ 30901, 29237, 27563, 25881, 24192, 22495, 20791, 19080, 17364,
+ 15643, 13917, 12186, 10452, 8715, 6975, 5233, 3489, 1745,
+ 0
+};
+
+int ScummEngine_v90he::scummMathSin(int angle) {
+ bool positive;
+
+ if (angle) {
+ positive = (angle > 0) ? 1 : 0;
+ angle %= 360;
+ angle = abs(angle);
+
+ if (angle > 180) {
+ positive = !positive;
+ angle -= 180;
+ }
+
+ if (positive) {
+ return _scummMathSineTable[angle];
+ } else {
+ return -(_scummMathSineTable[angle]);
+ }
+ }
+
+ return 0;
+}
+
+int ScummEngine_v90he::scummMathCos(int angle) {
+ bool positive;
+
+ if (angle += 90) {
+ positive = (angle > 0) ? 1 : 0;
+ angle %= 360;
+ angle = abs(angle);
+
+ if (angle > 180) {
+ positive = !positive;
+ angle -= 180;
+ }
+
+ if (positive) {
+ return _scummMathSineTable[angle];
+
+ } else {
+ return -(_scummMathSineTable[angle]);
+ }
+ }
+
+ return 0;
+}
+
+int ScummEngine_v90he::scummMathSqrt(int value) {
+ int32 s1, s2, x;
+
+ x = (int32)abs(value);
+ if (x < 2)
+ return x;
+
+ s1 = x;
+ s2 = 2;
+
+ do {
+ s1 >>= 1;
+ s2 <<= 1;
+ } while (s1 > s2);
+
+ do {
+ s1 = s2;
+ s2 = (x / s1 + s1) / 2;
+ } while (s1 > s2);
+
+ return s2;
+}
+
+int ScummEngine_v90he::scummMathDist2D(int x1, int y1, int x2, int y2) {
+ int dx, dy;
+
+ dx = x1 - x2;
+ dx *= dx;
+
+ dy = y1 - y2;
+ dy *= dy;
+
+ return scummMathSqrt(dx + dy);
+}
+
+
+int ScummEngine_v90he::scummMathAngleFromDelta(int dx, int dy) {
+ int angle = (int)((atan2((double)dy, (double)dx) * 180.0) / M_PI);
+
+ if (angle < 0) {
+ angle = 360 + angle;
+ }
+
+ if (angle == 360)
+ angle = 0;
+
+ return angle;
+}
+
+int ScummEngine_v90he::scummMathAngleOfLineSegment(int x1, int y1, int x2, int y2) {
+ return scummMathAngleFromDelta((x2 - x1), (y2 - y1));
+}
+
+} // End of namespace Scumm
+
+#endif // ENABLE_HE
diff --git a/engines/scumm/he/polygon_he.cpp b/engines/scumm/he/polygon_he.cpp
index 319c0d5daef..ecac2ffa5cb 100644
--- a/engines/scumm/he/polygon_he.cpp
+++ b/engines/scumm/he/polygon_he.cpp
@@ -163,7 +163,7 @@ int Wiz::findPolygon(int x, int y) {
for (int i = 0; i < ARRAYSIZE(_polygons); i++) {
if (isPointInRect(&_polygons[i].boundingRect, &checkPoint)) {
- if (polyIsPointInsidePoly(_polygons[i], x, y)) {
+ if (polyIsPointInsidePoly(_polygons[i].points, _polygons[i].numPoints, &checkPoint)) {
return _polygons[i].id;
}
}
@@ -180,7 +180,7 @@ int Wiz::testForObjectPolygon(int object, int x, int y) {
for (int i = 0; i < ARRAYSIZE(_polygons); i++) {
if (_polygons[i].id == object) {
if (isPointInRect(&_polygons[i].boundingRect, &checkPoint)) {
- if (polyIsPointInsidePoly(_polygons[i], x, y)) {
+ if (polyIsPointInsidePoly(_polygons[i].points, _polygons[i].numPoints, &checkPoint)) {
return 1;
}
}
@@ -200,64 +200,63 @@ bool Wiz::doesObjectHavePolygon(int object) {
return false;
}
-bool Wiz::polyIsPointInsidePoly(const WizPolygon &pol, int x, int y) {
- int pi = pol.numPoints - 1;
- bool diry = (y < pol.points[pi].y);
- bool curdir;
- bool r = false;
+bool Wiz::polyIsPointInsidePoly(Common::Point *listOfPoints, int numverts, Common::Point *checkPoint) {
+ int ty, tx, yflag0, yflag1;
+ bool insideFlag = false;
+ Common::Point *vtx0, *vtx1;
- for (int i = 0; i < pol.numPoints; i++) {
- curdir = (y < pol.points[i].y);
+ tx = checkPoint->x;
+ ty = checkPoint->y;
+ vtx0 = listOfPoints + (numverts - 1);
+ yflag0 = (vtx0->y >= ty);
+ vtx1 = listOfPoints;
- if (curdir != diry) {
- if (((pol.points[pi].y - pol.points[i].y) * (pol.points[i].x - x) <
- (pol.points[pi].x - pol.points[i].x) * (pol.points[i].y - y)) == diry)
- r = !r;
+ for (int j = numverts + 1; --j;) {
+ yflag1 = (vtx1->y >= ty);
+
+ if (yflag0 != yflag1) {
+ if (((vtx1->y - ty) * (vtx0->x - vtx1->x) >=
+ (vtx1->x - tx) * (vtx0->y - vtx1->y)) == yflag0) {
+ insideFlag = !insideFlag;
+ }
}
- pi = i;
- diry = curdir;
+ yflag0 = yflag1;
+ vtx0 = vtx1;
+ vtx1++;
}
+ // Special case the vert and horz edges.
if (_vm->_game.heversion >= 80) {
- int a, b;
- pi = pol.numPoints - 1;
- if (r == 0) {
- for (int i = 0; i < pol.numPoints; i++) {
- if (pol.points[i].y == y && pol.points[i].y == pol.points[pi].y) {
-
- a = pol.points[i].x;
- b = pol.points[pi].x;
-
- if (pol.points[i].x >= pol.points[pi].x)
- a = pol.points[pi].x;
-
- if (pol.points[i].x > pol.points[pi].x)
- b = pol.points[i].x;
+ if (!insideFlag) {
+ int a, b, minX, maxX, minY, maxY;
- if (x >= a && x <= b)
- return 1;
+ for (int j = 0; j < numverts; j++) {
+ a = j % numverts;
+ b = (j + 1) % numverts;
- } else if (pol.points[i].x == x && pol.points[i].x == pol.points[pi].x) {
+ if ((ty == listOfPoints[a].y) && (listOfPoints[a].y == listOfPoints[b].y)) {
- a = pol.points[i].y;
- b = pol.points[i].y;
+ minX = MIN(listOfPoints[a].x, listOfPoints[b].x);
+ maxX = MAX(listOfPoints[a].x, listOfPoints[b].x);
- if (pol.points[i].y >= pol.points[pi].y)
- a = pol.points[pi].y;
+ if ((tx >= minX) && (tx <= maxX)) {
+ return true;
+ }
- if (pol.points[i].y <= pol.points[pi].y)
- b = pol.points[pi].y;
+ } else if ((tx == listOfPoints[a].x) && (listOfPoints[a].x == listOfPoints[b].x)) {
+ minY = MIN(listOfPoints[a].y, listOfPoints[b].y);
+ maxY = MAX(listOfPoints[a].y, listOfPoints[b].y);
- if (y >= a && y <= b)
- return 1;
+ if ((ty >= minY) && (ty <= maxY)) {
+ return true;
+ }
}
- pi = i;
}
}
}
- return r;
+ return insideFlag;
}
} // End of namespace Scumm
diff --git a/engines/scumm/he/script_v100he.cpp b/engines/scumm/he/script_v100he.cpp
index 6c683693342..6bb3db1cf53 100644
--- a/engines/scumm/he/script_v100he.cpp
+++ b/engines/scumm/he/script_v100he.cpp
@@ -234,8 +234,8 @@ void ScummEngine_v100he::setupOpcodes() {
OPCODE(0x9e, o6_getObjectX);
OPCODE(0x9f, o6_getObjectY);
/* A0 */
- OPCODE(0xa0, o90_atan2);
- OPCODE(0xa1, o90_getSegmentAngle);
+ OPCODE(0xa0, o90_getAngleFromDelta);
+ OPCODE(0xa1, o90_getAngleFromLine);
OPCODE(0xa2, o90_getActorAnimProgress);
OPCODE(0xa3, o90_getDistanceBetweenPoints);
/* A4 */
@@ -279,7 +279,7 @@ void ScummEngine_v100he::setupOpcodes() {
/* C4 */
OPCODE(0xc4, o90_getObjectData);
OPCODE(0xc5, o72_openFile);
- OPCODE(0xc6, o90_getPolygonOverlap);
+ OPCODE(0xc6, o90_getOverlap);
OPCODE(0xc7, o6_getOwner);
/* C8 */
OPCODE(0xc8, o100_getPaletteData);
diff --git a/engines/scumm/he/script_v90he.cpp b/engines/scumm/he/script_v90he.cpp
index 8572302ead0..27e6c438492 100644
--- a/engines/scumm/he/script_v90he.cpp
+++ b/engines/scumm/he/script_v90he.cpp
@@ -50,8 +50,8 @@ void ScummEngine_v90he::setupOpcodes() {
/* 20 */
OPCODE(0x20, o90_cos);
OPCODE(0x21, o90_sqrt);
- OPCODE(0x22, o90_atan2);
- OPCODE(0x23, o90_getSegmentAngle);
+ OPCODE(0x22, o90_getAngleFromDelta);
+ OPCODE(0x23, o90_getAngleFromLine);
/* 24 */
OPCODE(0x24, o90_getDistanceBetweenPoints);
OPCODE(0x25, o90_getSpriteInfo);
@@ -74,7 +74,7 @@ void ScummEngine_v90he::setupOpcodes() {
OPCODE(0x33, o90_xor);
/* 34 */
OPCODE(0x34, o90_findAllObjectsWithClassOf);
- OPCODE(0x35, o90_getPolygonOverlap);
+ OPCODE(0x35, o90_getOverlap);
OPCODE(0x36, o90_cond);
OPCODE(0x37, o90_dim2dim2Array);
/* 38 */
@@ -335,76 +335,45 @@ void ScummEngine_v90he::o90_min() {
int a = pop();
int b = pop();
- if (b < a) {
- push(b);
- } else {
- push(a);
- }
+ push((a <= b) ? a : b);
}
void ScummEngine_v90he::o90_max() {
int a = pop();
int b = pop();
- if (b > a) {
- push(b);
- } else {
- push(a);
- }
+ push((a >= b) ? a : b);
}
void ScummEngine_v90he::o90_sin() {
- // TODO: the math calculation albeit more precise
- // is not accurate enough with respect to what the
- // engine expects. Implement the correct one...
- double a = pop() * M_PI / 180.;
- push((int)(sin(a) * 100000));
+ push(scummMathSin(pop()));
}
void ScummEngine_v90he::o90_cos() {
- // TODO: the math calculation albeit more precise
- // is not accurate enough with respect to what the
- // engine expects. Implement the correct one...
- double a = pop() * M_PI / 180.;
- push((int)(cos(a) * 100000));
+ push(scummMathCos(pop()));
}
void ScummEngine_v90he::o90_sqrt() {
- // TODO: the math calculation albeit more precise
- // is not accurate enough with respect to what the
- // engine expects. Implement the correct one...
- int i = pop();
- if (i < 2) {
- push(i);
- } else {
- push((int)sqrt((double)(i + 1)));
- }
+ push(scummMathSqrt(pop()));
}
-void ScummEngine_v90he::o90_atan2() {
- int y = pop();
- int x = pop();
- int a = (int)(atan2((double)y, (double)x) * 180. / M_PI);
- if (a < 0) {
- a += 360;
- }
- push(a);
+void ScummEngine_v90he::o90_getAngleFromDelta() {
+ int dy = pop();
+ int dx = pop();
+ push(scummMathAngleFromDelta(dx, dy));
}
-void ScummEngine_v90he::o90_getSegmentAngle() {
+void ScummEngine_v90he::o90_getAngleFromLine() {
+ int y2 = pop();
+ int x2 = pop();
int y1 = pop();
int x1 = pop();
- int dy = y1 - pop();
- int dx = x1 - pop();
- int a = (int)(atan2((double)dy, (double)dx) * 180. / M_PI);
- if (a < 0) {
- a += 360;
- }
- push(a);
+
+ push(scummMathAngleFromDelta((x2 - x1), (y2 - y1)));
}
void ScummEngine_v90he::o90_getDistanceBetweenPoints() {
- int x1, y1, z1, x2, y2, z2, dx, dy, dz, d;
+ int x1, y1, z1, x2, y2, z2, dx, dy, dz;
byte subOp = fetchScriptByte();
@@ -415,14 +384,9 @@ void ScummEngine_v90he::o90_getDistanceBetweenPoints() {
x2 = pop();
y1 = pop();
x1 = pop();
- dx = x2 - x1;
- dy = y2 - y1;
- d = dx * dx + dy * dy;
- if (d < 2) {
- push(d);
- } else {
- push((int)sqrt((double)(d + 1)));
- }
+ dx = (x2 - x1) * (x2 - x1);
+ dy = (y2 - y1) * (y2 - y1);
+ push(scummMathSqrt(dx + dy));
break;
case ScummEngine_v100he::SO_COORD_3D: // 24
case SO_COORD_3D: // 29
@@ -432,15 +396,10 @@ void ScummEngine_v90he::o90_getDistanceBetweenPoints() {
z1 = pop();
y1 = pop();
x1 = pop();
- dx = x2 - x1;
- dy = y2 - y1;
- dz = z2 - z1;
- d = dx * dx + dy * dy + dz * dz;
- if (d < 2) {
- push(d);
- } else {
- push((int)sqrt((double)(d + 1)));
- }
+ dx = (x2 - x1) * (x2 - x1);
+ dy = (y2 - y1) * (y2 - y1);
+ dz = (z2 - z1) * (z2 - z1);
+ push(scummMathSqrt(dx + dy + dz));
break;
default:
error("o90_getDistanceBetweenPoints: Unknown case %d", subOp);
@@ -1636,169 +1595,383 @@ void ScummEngine_v90he::o90_findAllObjectsWithClassOf() {
push(readVar(0));
}
-void ScummEngine_v90he::o90_getPolygonOverlap() {
- int lastList[32];
- int firstList[32];
+int auxRectsOverlap(const Common::Rect *destRectPtr, const Common::Rect *sourceRectPtr) {
+ if (destRectPtr->left > sourceRectPtr->right) {
+ return 0;
+ }
+
+ if (destRectPtr->top > sourceRectPtr->bottom) {
+ return 0;
+ }
- int lastCount = getStackList(lastList, ARRAYSIZE(lastList));
- int firstCount = getStackList(firstList, ARRAYSIZE(firstList));
+ if (destRectPtr->right < sourceRectPtr->left) {
+ return 0;
+ }
- int checkType = pop();
+ if (destRectPtr->bottom < sourceRectPtr->top) {
+ return 0;
+ }
+
+ return 1;
+}
+void ScummEngine_v90he::o90_getOverlap() {
+ //int lastList[32];
+ //int firstList[32];
+ //
+ //int lastCount = getStackList(lastList, ARRAYSIZE(lastList));
+ //int firstCount = getStackList(firstList, ARRAYSIZE(firstList));
+ //
+ //int checkType = pop();
+ //
+ //switch (checkType) {
+ //case OVERLAP_POINT_TO_RECT: // 1
+ // {
+ // Common::Rect r(lastList[0], lastList[1], lastList[2], lastList[3]);
+ // Common::Point p(firstList[0], firstList[1]);
+ //
+ // push(_wiz->isPointInRect(&r, &p) ? 1 : 0);
+ // }
+ // break;
+ //case OVERLAP_POINT_TO_CIRCLE: // 2
+ // {
+ // int dx = firstList[0] - lastList[0];
+ // int dy = firstList[1] - lastList[1];
+ // int dist = dx * dx + dy * dy;
+ // if (dist >= 2) {
+ // dist = (int)sqrt((double)(dist + 1));
+ // }
+ // if (_game.heversion >= 98) {
+ // push((dist <= lastList[2]) ? 1 : 0);
+ // } else {
+ // push((dist > lastList[2]) ? 1 : 0);
+ // }
+ // }
+ // break;
+ //case OVERLAP_RECT_TO_RECT: // 3
+ // {
+ // Common::Rect r1(lastList[0], lastList[1], lastList[2] + 1, lastList[3] + 1);
+ // Common::Rect r2(firstList[0], firstList[1], firstList[2] + 1, firstList[3] + 1);
+ // push(r2.intersects(r1) ? 1 : 0);
+ // }
+ // break;
+ //case OVERLAP_CIRCLE_TO_CIRCLE: // 4
+ // {
+ // int dx = firstList[0] - lastList[0];
+ // int dy = firstList[1] - lastList[1];
+ // int dist = dx * dx + dy * dy;
+ // if (dist >= 2) {
+ // dist = (int)sqrt((double)(dist + 1));
+ // }
+ // push((dist < lastList[2] && dist < firstList[2]) ? 1 : 0);
+ // }
+ // break;
+ //case OVERLAP_POINT_N_SIDED_POLYGON: // 5
+ // {
+ // assert((lastCount & 1) == 0);
+ // lastCount /= 2;
+ // if (lastCount == 0) {
+ // push(0);
+ // } else {
+ // WizPolygon wp;
+ // wp.reset();
+ // wp.numPoints = lastCount;
+ // assert(lastCount < ARRAYSIZE(wp.points));
+ // for (int i = 0; i < lastCount; ++i) {
+ // wp.points[i].x = lastList[i * 2 + 0];
+ // wp.points[i].y = lastList[i * 2 + 1];
+ // }
+ // push(_wiz->polyIsPointInsidePoly(wp, firstList[0], firstList[1]) ? 1 : 0);
+ // }
+ // }
+ // break;
+ //// HE 98+
+ //case OVERLAP_SPRITE_TO_SPRITE: // 6
+ // {
+ // Common::Rect r1, r2;
+ // _sprite->getSpriteLogicalRect(firstList[0], false, r2);
+ // _sprite->getSpriteLogicalRect(lastList[0], false, r1);
+ // if (r2.isValidRect() == false) {
+ // push(0);
+ // break;
+ // }
+ //
+ // if (firstCount == 3) {
+ // r2.left += firstList[1];
+ // r2.right += firstList[1];
+ // r2.top += firstList[2];
+ // r2.bottom += firstList[2];
+ // }
+ // if (lastCount == 3) {
+ // r1.left += lastList[1];
+ // r1.right += lastList[1];
+ // r1.top += lastList[2];
+ // r1.bottom += lastList[2];
+ // }
+ // push(r2.intersects(r1) ? 1 : 0);
+ // }
+ // break;
+ //case OVERLAP_SPRITE_TO_RECT: // 7
+ // {
+ // Common::Rect r2;
+ // _sprite->getSpriteLogicalRect(firstList[0], false, r2);
+ // Common::Rect r1(lastList[0], lastList[1], lastList[2] + 1, lastList[3] + 1);
+ // if (r2.isValidRect() == false) {
+ // push(0);
+ // break;
+ // }
+ //
+ // if (firstCount == 3) {
+ // r2.left += firstList[1];
+ // r2.right += firstList[1];
+ // r2.top += firstList[2];
+ // r2.bottom += firstList[2];
+ // }
+ // push(r2.intersects(r1) ? 1 : 0);
+ // }
+ // break;
+ //case OVERLAP_DRAW_POS_SPRITE_TO_SPRITE: // 8
+ //case OVERLAP_SPRITE_TO_SPRITE_PIXEL_PERFECT: // 10
+ //// TODO: Draw sprites to buffer and compare.
+ // {
+ // Common::Rect r1, r2;
+ // _sprite->getSpriteLogicalRect(firstList[0], true, r2);
+ // _sprite->getSpriteLogicalRect(lastList[0], true, r1);
+ // if (r2.isValidRect() == false) {
+ // push(0);
+ // break;
+ // }
+ //
+ // if (firstCount == 3) {
+ // r2.left += firstList[1];
+ // r2.right += firstList[1];
+ // r2.top += firstList[2];
+ // r2.bottom += firstList[2];
+ // }
+ // if (lastCount == 3) {
+ // r1.left += lastList[1];
+ // r1.right += lastList[1];
+ // r1.top += lastList[2];
+ // r1.bottom += lastList[2];
+ // }
+ // push(r2.intersects(r1) ? 1 : 0);
+ // }
+ // break;
+ //case OVERLAP_DRAW_POS_SPRITE_TO_RECT: // 9
+ // {
+ // Common::Rect r2;
+ // _sprite->getSpriteLogicalRect(firstList[0], true, r2);
+ // Common::Rect r1(lastList[0], lastList[1], lastList[2] + 1, lastList[3] + 1);
+ // if (r2.isValidRect() == false) {
+ // push(0);
+ // break;
+ // }
+ //
+ // if (firstCount == 3) {
+ // r2.left += firstList[1];
+ // r2.right += firstList[1];
+ // r2.top += firstList[2];
+ // r2.bottom += firstList[2];
+ // }
+ // push(r2.intersects(r1) ? 1 : 0);
+ // }
+ // break;
+ //default:
+ // error("o90_getOverlap: default case %d", checkType);
+ //}
+ int firstCount, lastCount, checkType, firstRadius, ax, ay, bx, by;
+ int nVerts, index, lastRadius, distance, counter;
+ Common::Point lastCenterPoint, firstCenterPoint;
+ Common::Rect firstRect, lastRect;
+ int firstList[32], lastList[32];
+ Common::Point polyPoints[16];
+
+ // Get the info
+ lastCount = getStackList(lastList, ARRAYSIZE(lastList));
+ firstCount = getStackList(firstList, ARRAYSIZE(firstList));
+ checkType = pop();
+
+ // Check the info
switch (checkType) {
- case OVERLAP_POINT_TO_RECT: // 1
- {
- Common::Rect r(lastList[0], lastList[1], lastList[2], lastList[3]);
- Common::Point p(firstList[0], firstList[1]);
+ default:
+ error("o90_getOverlap: Unknown overlap type %d", checkType);
+ break;
- push(_wiz->isPointInRect(&r, &p) ? 1 : 0);
+ case OVERLAP_SPRITE_TO_SPRITE_PIXEL_PERFECT:
+ // Get the adjustments...
+ if (firstCount == 3) {
+ ax = firstList[1];
+ ay = firstList[2];
+ } else {
+ ax = 0;
+ ay = 0;
}
- break;
- case OVERLAP_POINT_TO_CIRCLE: // 2
- {
- int dx = firstList[0] - lastList[0];
- int dy = firstList[1] - lastList[1];
- int dist = dx * dx + dy * dy;
- if (dist >= 2) {
- dist = (int)sqrt((double)(dist + 1));
- }
- if (_game.heversion >= 98) {
- push((dist <= lastList[2]) ? 1 : 0);
- } else {
- push((dist > lastList[2]) ? 1 : 0);
- }
+
+ if (lastCount == 3) {
+ bx = lastList[1];
+ by = lastList[2];
+ } else {
+ bx = 0;
+ by = 0;
}
+
+ // Do the command.
+ push(_sprite->pixelPerfectSpriteCollisionCheck(firstList[0], ax, ay, lastList[0], bx, by));
+
break;
- case OVERLAP_RECT_TO_RECT: // 3
- {
- Common::Rect r1(lastList[0], lastList[1], lastList[2] + 1, lastList[3] + 1);
- Common::Rect r2(firstList[0], firstList[1], firstList[2] + 1, firstList[3] + 1);
- push(r2.intersects(r1) ? 1 : 0);
+
+ case OVERLAP_SPRITE_TO_SPRITE:
+ // Get the positions and check to see if either rect is invalid...
+ _sprite->getSpriteLogicalRect(firstList[0], &firstRect);
+ _sprite->getSpriteLogicalRect(lastList[0], &lastRect);
+
+ if (!_wiz->isRectValid(firstRect) || !_wiz->isRectValid(firstRect)) {
+ push(0);
+ break;
}
+
+ if (firstCount == 3)
+ _wiz->moveRect(&firstRect, firstList[1], firstList[2]);
+
+ if (lastCount == 3)
+ _wiz->moveRect(&lastRect, lastList[1], lastList[2]);
+
+ push(auxRectsOverlap(&firstRect, &lastRect));
break;
- case OVERLAP_CIRCLE_TO_CIRCLE: // 4
- {
- int dx = firstList[0] - lastList[0];
- int dy = firstList[1] - lastList[1];
- int dist = dx * dx + dy * dy;
- if (dist >= 2) {
- dist = (int)sqrt((double)(dist + 1));
- }
- push((dist < lastList[2] && dist < firstList[2]) ? 1 : 0);
+
+ case OVERLAP_DRAW_POS_SPRITE_TO_SPRITE:
+ // Get the positions and check to see if either rect is invalid...
+ _sprite->getSpriteDrawRect(firstList[0], &firstRect);
+ _sprite->getSpriteDrawRect(lastList[0], &lastRect);
+
+ if (!_wiz->isRectValid(firstRect) || !_wiz->isRectValid(firstRect)) {
+ push(0);
+ break;
}
+
+ if (firstCount == 3)
+ _wiz->moveRect(&firstRect, firstList[1], firstList[2]);
+
+ if (lastCount == 3)
+ _wiz->moveRect(&lastRect, lastList[1], lastList[2]);
+
+ push(auxRectsOverlap(&firstRect, &lastRect));
break;
- case OVERLAP_POINT_N_SIDED_POLYGON: // 5
- {
- assert((lastCount & 1) == 0);
- lastCount /= 2;
- if (lastCount == 0) {
- push(0);
- } else {
- WizPolygon wp;
- wp.reset();
- wp.numPoints = lastCount;
- assert(lastCount < ARRAYSIZE(wp.points));
- for (int i = 0; i < lastCount; ++i) {
- wp.points[i].x = lastList[i * 2 + 0];
- wp.points[i].y = lastList[i * 2 + 1];
- }
- push(_wiz->polyIsPointInsidePoly(wp, firstList[0], firstList[1]) ? 1 : 0);
- }
+
+ case OVERLAP_SPRITE_TO_RECT:
+ // Get the positions and check to see if either rect is invalid...
+ _sprite->getSpriteLogicalRect(firstList[0], &firstRect);
+
+ lastRect.left = lastList[0];
+ lastRect.top = lastList[1];
+ lastRect.right = lastList[2];
+ lastRect.bottom = lastList[3];
+
+ if (!_wiz->isRectValid(firstRect) || _wiz->isRectValid(firstRect)) {
+ push(0);
+ break;
}
+
+ if (firstCount == 3)
+ _wiz->moveRect(&firstRect, firstList[1], firstList[2]);
+
+ push(auxRectsOverlap(&firstRect, &lastRect));
break;
- // HE 98+
- case OVERLAP_SPRITE_TO_SPRITE: // 6
- {
- Common::Rect r1, r2;
- _sprite->getSpriteLogicalRect(firstList[0], false, r2);
- _sprite->getSpriteLogicalRect(lastList[0], false, r1);
- if (r2.isValidRect() == false) {
- push(0);
- break;
- }
- if (firstCount == 3) {
- r2.left += firstList[1];
- r2.right += firstList[1];
- r2.top += firstList[2];
- r2.bottom += firstList[2];
- }
- if (lastCount == 3) {
- r1.left += lastList[1];
- r1.right += lastList[1];
- r1.top += lastList[2];
- r1.bottom += lastList[2];
- }
- push(r2.intersects(r1) ? 1 : 0);
+ case OVERLAP_DRAW_POS_SPRITE_TO_RECT:
+ // Get the positions and check to see if either rect is invalid...
+ _sprite->getSpriteDrawRect(firstList[0], &firstRect);
+
+ lastRect.left = lastList[0];
+ lastRect.top = lastList[1];
+ lastRect.right = lastList[2];
+ lastRect.bottom = lastList[3];
+
+ if (!_wiz->isRectValid(firstRect) || !_wiz->isRectValid(firstRect)) {
+ push(0);
+ break;
}
+
+ if (firstCount == 3)
+ _wiz->moveRect(&firstRect, firstList[1], firstList[2]);
+
+ push(auxRectsOverlap(&firstRect, &lastRect));
+
break;
- case OVERLAP_SPRITE_TO_RECT: // 7
- {
- Common::Rect r2;
- _sprite->getSpriteLogicalRect(firstList[0], false, r2);
- Common::Rect r1(lastList[0], lastList[1], lastList[2] + 1, lastList[3] + 1);
- if (r2.isValidRect() == false) {
- push(0);
- break;
- }
+ case OVERLAP_POINT_TO_RECT:
+ firstCenterPoint.x = firstList[0];
+ firstCenterPoint.y = firstList[1];
+ lastRect.left = lastList[0];
+ lastRect.top = lastList[1];
+ lastRect.right = lastList[2];
+ lastRect.bottom = lastList[3];
- if (firstCount == 3) {
- r2.left += firstList[1];
- r2.right += firstList[1];
- r2.top += firstList[2];
- r2.bottom += firstList[2];
- }
- push(r2.intersects(r1) ? 1 : 0);
- }
+ push(_wiz->isPointInRect(&lastRect, &firstCenterPoint));
break;
- case OVERLAP_DRAW_POS_SPRITE_TO_SPRITE: // 8
- case OVERLAP_SPRITE_TO_SPRITE_PIXEL_PERFECT: // 10
- // TODO: Draw sprites to buffer and compare.
- {
- Common::Rect r1, r2;
- _sprite->getSpriteLogicalRect(firstList[0], true, r2);
- _sprite->getSpriteLogicalRect(lastList[0], true, r1);
- if (r2.isValidRect() == false) {
- push(0);
- break;
- }
- if (firstCount == 3) {
- r2.left += firstList[1];
- r2.right += firstList[1];
- r2.top += firstList[2];
- r2.bottom += firstList[2];
- }
- if (lastCount == 3) {
- r1.left += lastList[1];
- r1.right += lastList[1];
- r1.top += lastList[2];
- r1.bottom += lastList[2];
- }
- push(r2.intersects(r1) ? 1 : 0);
- }
+ case OVERLAP_POINT_TO_CIRCLE:
+ firstCenterPoint.x = firstList[0];
+ firstCenterPoint.y = firstList[1];
+
+ lastCenterPoint.x = lastList[0];
+ lastCenterPoint.y = lastList[1];
+ lastRadius = lastList[2];
+
+ distance = scummMathDist2D(
+ firstCenterPoint.x, firstCenterPoint.y, lastCenterPoint.x, lastCenterPoint.y);
+
+ push((distance <= lastRadius));
break;
- case OVERLAP_DRAW_POS_SPRITE_TO_RECT: // 9
- {
- Common::Rect r2;
- _sprite->getSpriteLogicalRect(firstList[0], true, r2);
- Common::Rect r1(lastList[0], lastList[1], lastList[2] + 1, lastList[3] + 1);
- if (r2.isValidRect() == false) {
- push(0);
- break;
- }
- if (firstCount == 3) {
- r2.left += firstList[1];
- r2.right += firstList[1];
- r2.top += firstList[2];
- r2.bottom += firstList[2];
+ case OVERLAP_RECT_TO_RECT:
+ firstRect.left = firstList[0];
+ firstRect.top = firstList[1];
+ firstRect.right = firstList[2];
+ firstRect.bottom = firstList[3];
+
+ lastRect.left = lastList[0];
+ lastRect.top = lastList[1];
+ lastRect.right = lastList[2];
+ lastRect.bottom = lastList[3];
+
+ push(auxRectsOverlap(&firstRect, &lastRect));
+ break;
+
+ case OVERLAP_CIRCLE_TO_CIRCLE:
+ firstCenterPoint.x = firstList[0];
+ firstCenterPoint.y = firstList[1];
+ firstRadius = firstList[2];
+
+ lastCenterPoint.x = lastList[0];
+ lastCenterPoint.y = lastList[1];
+ lastRadius = lastList[2];
+
+ distance = scummMathDist2D(
+ firstCenterPoint.x, firstCenterPoint.y, lastCenterPoint.x, lastCenterPoint.y);
+
+ push(distance < (firstRadius + lastRadius));
+ break;
+
+ case OVERLAP_POINT_N_SIDED_POLYGON:
+ firstCenterPoint.x = firstList[0];
+ firstCenterPoint.y = firstList[1];
+
+ nVerts = lastCount / 2;
+
+ if (nVerts) {
+ index = 0;
+
+ for (int i = 0; i < nVerts; i++) {
+ polyPoints[i].x = lastList[index++];
+ polyPoints[i].y = lastList[index++];
}
- push(r2.intersects(r1) ? 1 : 0);
+
+ push(_wiz->polyIsPointInsidePoly(polyPoints, nVerts, &firstCenterPoint) ? 1 : 0);
+ } else {
+ push(0);
}
+
break;
- default:
- error("o90_getPolygonOverlap: default case %d", checkType);
}
}
@@ -1880,122 +2053,143 @@ void ScummEngine_v90he::o90_redim2dimArray() {
}
void ScummEngine_v90he::o90_getLinesIntersectionPoint() {
- int var_ix = fetchScriptWord();
- int var_iy = fetchScriptWord();
- int line2_y2 = pop();
- int line2_x2 = pop();
- int line2_y1 = pop();
- int line2_x1 = pop();
- int line1_y2 = pop();
- int line1_x2 = pop();
- int line1_y1 = pop();
- int line1_x1 = pop();
-
- int result = 0;
- int ix = 0;
- int iy = 0;
-
- bool isLine1Point = (line1_x1 == line1_x2 && line1_y1 == line1_y2);
- bool isLine2Point = (line2_x1 == line2_x2 && line2_y1 == line2_y2);
-
- if (isLine1Point) {
- if (isLine2Point) {
- if (line1_x1 == line2_x1 && line1_y1 == line2_y2) {
- ix = line1_x1;
- iy = line2_x1;
- result = 1;
- }
+ int x1, y1, x2, y2, x3, y3, x4, y4, returnValue, x, y;
+ int dv, xVariable, yVariable, ta, tb, tc, td, t;
+ float ua, ub, oodv, tua, tub;
+
+ bool segAIsAPoint;
+ bool segBIsAPoint;
+
+ xVariable = fetchScriptWord();
+ yVariable = fetchScriptWord();
+
+ // Get the line segment coords off the stack...
+ y4 = pop();
+ x4 = pop();
+ y3 = pop();
+ x3 = pop();
+ y2 = pop();
+ x2 = pop();
+ y1 = pop();
+ x1 = pop();
+
+ // Check to see if both segments are points...
+ segAIsAPoint = ((x1 == x2) && (y1 == y2));
+ segBIsAPoint = ((x3 == x4) && (y3 == y4));
+
+ if (segAIsAPoint && segBIsAPoint) {
+ if ((x1 == x3) && (y1 == y3) && (x2 == x4) && (y2 == y4)) {
+ // The points are the same....
+ writeVar(xVariable, x1);
+ writeVar(yVariable, y1);
+ push(1);
+ return;
} else {
- // 1 point and 1 line
- int dx2 = line2_x2 - line2_x1;
- if (dx2 != 0) {
- int dy2 = line2_y2 - line2_y1;
- float y = (float)dy2 / dx2 * (line1_x1 - line2_x1) + line2_y1 + .5f;
- if (line1_y1 == (int)y) {
- ix = line1_x1;
- iy = line1_y1;
- result = 1;
- }
- } else {
- // vertical line
- if (line1_x1 == line2_x1) {
- if (line2_y1 > line2_y2) {
- if (line1_y1 >= line2_y2 && line1_y1 <= line2_y1) {
- ix = line1_x1;
- iy = line1_y1;
- result = 1;
- }
- } else {
- if (line1_y1 >= line2_y1 && line1_y1 <= line2_y2) {
- ix = line1_x1;
- iy = line1_y1;
- result = 1;
- }
- }
- }
- }
+ // No intersection...
+ writeVar(xVariable, 0);
+ writeVar(yVariable, 0);
+ push(0);
+ return;
}
} else {
- if (isLine2Point) {
- // 1 point and 1 line
- int dx1 = line1_x2 - line1_x1;
- if (dx1 != 0) {
- int dy1 = line1_y2 - line1_y1;
- float y = (float)dy1 / dx1 * (line2_x1 - line1_x1) + line1_y1 + .5f;
- if (line2_y1 == (int)y) {
- ix = line2_x1;
- iy = line2_y1;
- result = 1;
+ // Check to see if we need to special case to point on a line...
+ if (segAIsAPoint) {
+ int dx, dy, py;
+
+ dx = (x4 - x3);
+
+ if (dx != 0) {
+ float m = (float)(y4 - y3) / (float)dx;
+ py = (((float)(x1 - x3) * m) + 0.5) + y3;
+
+ if (y1 == py) {
+ writeVar(xVariable, x1);
+ writeVar(yVariable, y1);
+ push(1);
+ return;
}
} else {
- // vertical line
- if (line2_x1 == line1_x1) {
- if (line1_y1 > line1_y2) {
- if (line2_y1 >= line1_y2 && line2_y1 <= line1_y1) {
- ix = line2_x1;
- iy = line2_y1;
- result = 1;
- }
- } else {
- if (line2_y1 >= line1_y1 && line2_y1 <= line1_y2) {
- ix = line2_x2;
- iy = line2_y1;
- result = 1;
- }
- }
+ if ((x3 == x1) && ((y3 <= y4) ? ((y1 >= y3) && (y1 <= y4)) : ((y1 >= y4) && (y1 <= y3)))) {
+ writeVar(xVariable, x1);
+ writeVar(yVariable, y1);
+ push(1);
+ return;
}
}
- } else {
- // 2 lines
- int dy1 = line1_y2 - line1_y1;
- int dx1 = line1_x2 - line1_x1;
- int dy2 = line2_y2 - line2_y1;
- int dx2 = line2_x2 - line2_x1;
- int det = dx1 * dy2 - dx2 * dy1;
- int cross_p1 = dx1 * (line1_y1 - line2_y1) - dy1 * (line1_x1 - line2_x1);
- int cross_p2 = dx2 * (line1_y1 - line2_y1) - dy2 * (line1_x1 - line2_x1);
- if (det == 0) {
- // parallel lines
- if (cross_p2 == 0) {
- ix = ABS(line2_x2 + line2_x1) / 2;
- iy = ABS(line2_y2 + line2_y1) / 2;
- result = 2;
+
+ // There was no intersection...
+ writeVar(xVariable, 0);
+ writeVar(yVariable, 0);
+ push(0);
+ return;
+ } else if (segBIsAPoint) {
+ int dx, dy, py;
+
+ dx = (x2 - x1);
+
+ if (dx != 0) {
+ float m = (float)(y2 - y1) / (float)dx;
+ py = (((float)(x3 - x1) * m) + 0.5) + y1;
+
+ if (y3 == py) {
+ writeVar(xVariable, x3);
+ writeVar(yVariable, y3);
+ push(1);
+ return;
}
} else {
- float rcp1 = (float)cross_p1 / det;
- float rcp2 = (float)cross_p2 / det;
- if (rcp1 >= 0 && rcp1 <= 1 && rcp2 >= 0 && rcp2 <= 1) {
- ix = (int)(dx1 * rcp2 + line1_x1 + .5f);
- iy = (int)(dy1 * rcp2 + line1_y1 + .5f);
- result = 1;
+ if ((x3 == x1) && ((y1 <= y2) ? ((y3 >= y1) && (y3 <= y2)) : ((y3 >= y2) && (y3 <= y1)))) {
+ writeVar(xVariable, x3);
+ writeVar(yVariable, y3);
+ push(1);
+ return;
}
}
+
+ // There was no intersection...
+ writeVar(xVariable, 0);
+ writeVar(yVariable, 0);
+ push(0);
+ return;
}
}
- writeVar(var_ix, ix);
- writeVar(var_iy, iy);
- push(result);
+ // Do the intersection test...
+ dv = (((y4 - y3) * (x2 - x1)) - ((x4 - x3) * (y2 - y1)));
+
+ ta = (y1 - y3);
+ tb = (x1 - x3);
+ tc = ((x4 - x3) * ta) - ((y4 - y3) * tb);
+ td = ((x2 - x1) * ta) - ((y2 - y1) * tb);
+
+ if (dv != 0) {
+ oodv = 1.0 / (float)dv;
+ ua = (float)tc * oodv;
+ ub = (float)td * oodv;
+
+ if ((ua >= 0) && (ub >= 0) && (ua <= 1.0) && (ub <= 1.0)) {
+ x = (int)(x1 + (0.5 + (ua * (x2 - x1))));
+ y = (int)(y1 + (0.5 + (ua * (y2 - y1))));
+
+ writeVar(xVariable, x);
+ writeVar(yVariable, y);
+ push(1);
+ return;
+ }
+ } else {
+ if (tc == 0) {
+
+ writeVar(xVariable, ((x3 + x4) / 2));
+ writeVar(yVariable, ((y3 + y4) / 2));
+ push(2);
+ return;
+ }
+ }
+
+ // No intersection...
+ writeVar(xVariable, 0);
+ writeVar(yVariable, 0);
+ push(0);
}
void ScummEngine_v90he::getArrayDim(int array, int *dim2start, int *dim2end, int *dim1start, int *dim1end) {
@@ -2360,16 +2554,22 @@ void ScummEngine_v90he::o90_kernelGetFunctions() {
switch (args[0]) {
case 1001:
- {
- double b = args[1] * M_PI / 180.;
- push((int)(sin(b) * 100000));
- }
+ push(scummMathSin(args[1]));
break;
case 1002:
- {
- double b = args[1] * M_PI / 180.;
- push((int)(cos(b) * 100000));
- }
+ push(scummMathCos(args[1]));
+ break;
+ case 1003:
+ push(scummMathSqrt(args[1]));
+ break;
+ case 1004:
+ push(scummMathDist2D(args[1], args[2], args[3], args[4]));
+ break;
+ case 1005:
+ push(scummMathAngleFromDelta(args[1], args[2]));
+ break;
+ case 1006:
+ push(scummMathAngleOfLineSegment(args[1], args[2], args[3], args[4]));
break;
case 1969:
a = derefActor(args[1], "o90_kernelGetFunctions: 1969");
diff --git a/engines/scumm/he/sprite_he.cpp b/engines/scumm/he/sprite_he.cpp
index fa954025c28..e24ac60af97 100644
--- a/engines/scumm/he/sprite_he.cpp
+++ b/engines/scumm/he/sprite_he.cpp
@@ -54,43 +54,22 @@ void ScummEngine_v90he::allocateArrays() {
_sprite->initializeStuff(_numSprites, MAX(64, _numSprites / 4), 64);
}
-void Sprite::getSpriteLogicalRect(int spriteId, bool checkGroup, Common::Rect &bound) {
- assertRange(1, spriteId, _maxSprites, "sprite");
-
- if (_vm->_game.heversion <= 98) {
- int32 x, y, w, h;
- Common::Point spot;
-
- int image = _spriteTable[spriteId].image;
-
- if (image != 0) {
- int state = _spriteTable[spriteId].state;
- _vm->_wiz->getWizSpot(image, state, x, y);
- _vm->_wiz->getWizImageDim(image, state, w, h);
-
- spot.x = (int16)(_spriteTable[spriteId].posX - spot.x);
- spot.y = (int16)(_spriteTable[spriteId].posY - spot.y);
-
- bound.left = spot.x;
- bound.top = spot.y;
- bound.right = spot.x + (int16)w - 1,
- bound.bottom = spot.y + (int16)h - 1;
+void Sprite::getSpriteDrawRect(int sprite, Common::Rect *rectPtr) {
+ assertRange(1, sprite, _maxSprites, "sprite");
- } else {
- bound.left = 1234;
- bound.top = 1234;
- bound.right = -1234;
- bound.bottom = -1234;
- }
- } else {
- int32 x, y;
- calcSpriteSpot(&_spriteTable[spriteId], false, x, y);
+ int32 x, y;
+ calcSpriteSpot(&_spriteTable[sprite], true, x, y);
+ Common::Point spot((int16)x, (int16)y);
+ getSpriteRectPrim(&_spriteTable[sprite], rectPtr, true, &spot);
+}
- // Let's hope it doesn't overflow...
- Common::Point spot((int16)x, (int16)y);
+void Sprite::getSpriteLogicalRect(int sprite, Common::Rect *rectPtr) {
+ assertRange(1, sprite, _maxSprites, "sprite");
- getSpriteRectPrim(&_spriteTable[spriteId], &bound, false, &spot);
- }
+ int32 x, y;
+ calcSpriteSpot(&_spriteTable[sprite], false, x, y);
+ Common::Point spot((int16)x, (int16)y);
+ getSpriteRectPrim(&_spriteTable[sprite], rectPtr, false, &spot);
}
//
@@ -1847,6 +1826,137 @@ void Sprite::renderSprites(bool negativeOrPositiveRender) {
}
}
+int Sprite::pixelPerfectSpriteCollisionCheck(int spriteA, int deltaAX, int deltaAY, int spriteB, int deltaBX, int deltaBY) {
+ int overlapWidth, overlapHeight;
+ int imageA, imageB, stateA, stateB;
+ int32 wizAFlags, wizBFlags, flags;
+ Common::Rect rectA, rectB, originalA, originalB;
+ int imageAType, imageBType;
+ int aWidth, aHeight;
+ int bWidth, bHeight;
+ WizRawPixel transparentColor;
+ int32 spotAX, spotAY, spotBX, spotBY;
+ const byte *imageAHeader;
+ const byte *imageAData;
+ const byte *imageBHeader;
+ const byte *imageBData;
+
+ assertRange(1, spriteA, _maxSprites, "sprite");
+ assertRange(1, spriteB, _maxSprites, "sprite");
+
+ // Get the current potential draw rect...
+ getSpriteDrawRect(spriteA, &originalA);
+ getSpriteDrawRect(spriteB, &originalB);
+
+ if (!_vm->_wiz->isRectValid(originalA) || !_vm->_wiz->isRectValid(originalB)) {
+ return 0;
+ }
+
+ _vm->_wiz->moveRect(&originalA, deltaAX, deltaAY);
+ _vm->_wiz->moveRect(&originalB, deltaBX, deltaBY);
+
+ // Find the overlap if any
+ rectA = originalA;
+
+ if (!_vm->_wiz->findRectOverlap(&rectA, &originalB)) {
+ return 0;
+ }
+
+ rectB = rectA;
+
+ // Adjust the coords to be image relative.
+ calcSpriteSpot(&_spriteTable[spriteA], true, spotAX, spotAY);
+ calcSpriteSpot(&_spriteTable[spriteB], true, spotBX, spotBY);
+ _vm->_wiz->moveRect(&rectA, -spotAX - deltaAX, -spotAY - deltaAY);
+ _vm->_wiz->moveRect(&rectB, -spotBX - deltaBX, -spotBY - deltaBY);
+
+ // Limit the compare to only the compare buffer size
+ overlapWidth = _vm->_wiz->getRectWidth(&rectA);
+
+ if (overlapWidth > 640) {
+ overlapWidth = 640;
+ }
+
+ overlapHeight = _vm->_wiz->getRectHeight(&rectA);
+ transparentColor = (WizRawPixel)_vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR);
+
+ // Get the image / state here...
+ imageA = (_spriteTable[spriteA].image);
+ stateA = (_spriteTable[spriteA].state);
+ imageB = (_spriteTable[spriteB].image);
+ stateB = (_spriteTable[spriteB].state);
+
+ // Get image A's data...
+ imageAHeader = _vm->_wiz->getWizStateHeaderPrim(imageA, stateA);
+ imageAData = _vm->_wiz->getWizStateDataPrim(imageA, stateA);
+ imageAData += _vm->_resourceHeaderSize;
+
+ // Read A's header...
+ imageAType = READ_LE_UINT32(imageAHeader + _vm->_resourceHeaderSize + 0);
+ aWidth = READ_LE_UINT32(imageAHeader + _vm->_resourceHeaderSize + 4);
+ aHeight = READ_LE_UINT32(imageAHeader + _vm->_resourceHeaderSize + 8);
+
+ if ((imageAType != kWCTNone) && (imageAType != kWCTTRLE)) {
+ error("%d has invalid compression type %d", imageA, imageAType);
+ }
+
+ // Get the render flag options...
+ flags = _spriteTable[spriteA].flags;
+ wizAFlags = 0;
+
+ if (flags & kSFHFlip) {
+ wizAFlags |= kWRFHFlip;
+ }
+
+ if (flags & kSFVFlip) {
+ wizAFlags |= kWRFVFlip;
+ }
+
+ // Get image B's data...
+ imageBHeader = _vm->_wiz->getWizStateHeaderPrim(imageB, stateB);
+ imageBData = _vm->_wiz->getWizStateDataPrim(imageB, stateB);
+
+ imageBData += _vm->_resourceHeaderSize;
+
+ // Read B's header...
+ imageBType = READ_LE_UINT32(imageBHeader + _vm->_resourceHeaderSize + 0);
+ bWidth = READ_LE_UINT32(imageBHeader + _vm->_resourceHeaderSize + 4);
+ bHeight = READ_LE_UINT32(imageBHeader + _vm->_resourceHeaderSize + 8);
+
+ if ((imageBType != kWCTNone) && (imageBType != kWCTTRLE)) {
+ error("%d has invalid compression type %d", imageB, imageBType);
+ }
+
+ // Get the render flag options...
+ flags = _spriteTable[spriteB].flags;
+ wizBFlags = 0;
+
+ if (flags & kSFHFlip) {
+ wizBFlags |= kWRFHFlip;
+ }
+
+ if (flags & kSFVFlip) {
+ wizBFlags |= kWRFVFlip;
+ }
+
+ // Get down to business :-)
+ for (int yCounter = 0; yCounter < overlapHeight; yCounter++) {
+ if (_vm->_wiz->collisionCompareImageLines(
+ imageAData, imageAType, aWidth, aHeight, wizAFlags, rectA.left, rectA.top,
+ imageBData, imageBType, bWidth, bHeight, wizBFlags, rectB.left, rectB.top,
+ overlapWidth, transparentColor)) {
+
+ return 1;
+ }
+
+ // Advance to the next line
+ ++rectA.top;
+ ++rectB.top;
+ }
+
+ return 0;
+}
+
static void syncWithSerializer(Common::Serializer &s, SpriteInfo &si) {
s.syncAsSint32LE(si.id, VER(48));
s.syncAsSint32LE(si.combinedPriority, VER(48));
diff --git a/engines/scumm/he/sprite_he.h b/engines/scumm/he/sprite_he.h
index 4befc518067..7118bc07e6b 100644
--- a/engines/scumm/he/sprite_he.h
+++ b/engines/scumm/he/sprite_he.h
@@ -268,7 +268,8 @@ public:
int getSpriteGeneralProperty(int spriteId, int type);
int getDestImageForSprite(const SpriteInfo *spritePtr);
int getSpriteAnimSpeedState(int sprite);
- void getSpriteLogicalRect(int spriteId, bool checkGroup, Common::Rect &bound);
+ void getSpriteLogicalRect(int sprite, Common::Rect *rectPtr);
+ void getSpriteDrawRect(int sprite, Common::Rect *rectPtr);
void getSpriteImageDim(int spriteId, int32 &w, int32 &h);
void getSpritePosition(int spriteId, int32 &tx, int32 &ty);
void getSpriteRectPrim(const SpriteInfo *spritePtr, Common::Rect *rectPtr, bool includeGroupTransform, const Common::Point *spotPtr);
@@ -334,6 +335,8 @@ public:
void setGroupYMul(int spriteGroupId, int value);
void setGroupYDiv(int spriteGroupId, int value);
+ int pixelPerfectSpriteCollisionCheck(int spriteA, int deltaAX, int deltaAY, int spriteB, int deltaBX, int deltaBY);
+
void clearGroupClipRect(int spriteGroupId);
void clearGroupScaleInfo(int group);
diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp
index 290ee688a13..903842e00df 100644
--- a/engines/scumm/he/wiz_he.cpp
+++ b/engines/scumm/he/wiz_he.cpp
@@ -2789,6 +2789,51 @@ bool Wiz::doesStateContainBlock(int globNum, int state, uint32 blockID) {
return _vm->findWrappedBlock(blockID, data, state, false) != nullptr;
}
+bool Wiz::collisionCompareImageLines(
+ const byte *imageAData, int aType, int aw, int ah, int32 wizAFlags, int ax, int ay,
+ const byte *imageBData, int bType, int bw, int bh, int32 wizBFlags, int bx, int by,
+ int compareWidth, WizRawPixel transparentColor) {
+
+ // Get line A's data
+ rawPixelMemset(_compareBufferA, transparentColor, compareWidth);
+
+ if (aType == kWCTTRLE) {
+ TRLEFLIP_DecompressImage(
+ _compareBufferA, imageAData, compareWidth, 1,
+ -ax, -ay, aw, ah, nullptr, wizAFlags, nullptr,
+ (WizRawPixel *)_vm->getHEPaletteSlot(1),
+ nullptr);
+ } else {
+ pgDrawRawDataFormatImage(
+ _compareBufferA, (const WizRawPixel *)imageAData, compareWidth, 1,
+ -ax, -ay, aw, ah, nullptr, wizAFlags, nullptr,
+ transparentColor);
+ }
+
+ // Get line B's data
+ rawPixelMemset(_compareBufferB, transparentColor, compareWidth);
+
+ if (bType == kWCTTRLE) {
+ TRLEFLIP_DecompressImage(
+ _compareBufferB, imageBData, compareWidth, 1,
+ -bx, -by, bw, bh, nullptr, wizBFlags, nullptr,
+ (WizRawPixel *)_vm->getHEPaletteSlot(1),
+ nullptr);
+ } else {
+ pgDrawRawDataFormatImage(
+ _compareBufferB, (const WizRawPixel *)imageBData, compareWidth, 1,
+ -bx, -by, bw, bh, nullptr, wizBFlags, nullptr,
+ transparentColor);
+ }
+
+ // Compare the lines
+ if (compareDoPixelStreamsOverlap(_compareBufferA, _compareBufferB, compareWidth, transparentColor)) {
+ return true;
+ }
+
+ return false;
+}
+
} // End of namespace Scumm
#endif // ENABLE_HE
diff --git a/engines/scumm/he/wiz_he.h b/engines/scumm/he/wiz_he.h
index a1385ab2669..dc643c4abbc 100644
--- a/engines/scumm/he/wiz_he.h
+++ b/engines/scumm/he/wiz_he.h
@@ -511,6 +511,10 @@ public:
uint16 _wizBufferIndex;
WizPolygon _polygons[NUM_POLYGONS];
+ // For collision
+ WizRawPixel _compareBufferA[640];
+ WizRawPixel _compareBufferB[640];
+
Wiz(ScummEngine_v71he *vm);
void clearWizBuffer();
@@ -528,7 +532,7 @@ public:
int testForObjectPolygon(int id, int x, int y);
int findPolygon(int x, int y);
bool doesObjectHavePolygon(int id);
- bool polyIsPointInsidePoly(const WizPolygon &pol, int x, int y);
+ bool polyIsPointInsidePoly(Common::Point *listOfPoints, int numverts, Common::Point *checkPoint);
void polyRotatePoints(Common::Point *pts, int num, int alpha);
void polyMovePolygonPoints(Common::Point *listOfPoints, int numverts, int deltaX, int deltaY);
bool polyIsRectangle(const Common::Point *points, int numverts);
@@ -608,6 +612,12 @@ public:
int createHistogramArrayForImage(int image, int state, const Common::Rect *optionalClipRect);
void ensureNativeFormatImageForState(int image, int state);
+ bool compareDoPixelStreamsOverlap(const WizRawPixel *a, const WizRawPixel *b, int width, WizRawPixel transparentColor);
+ bool collisionCompareImageLines(
+ const byte *imageAData, int aType, int aw, int ah, int32 wizAFlags, int ax, int ay,
+ const byte *imageBData, int bType, int bw, int bh, int32 wizBFlags, int bx, int by,
+ int compareWidth, WizRawPixel transparentColor);
+
private:
ScummEngine_v71he *_vm;
diff --git a/engines/scumm/module.mk b/engines/scumm/module.mk
index 7f17e752b7e..5c60945e4f5 100644
--- a/engines/scumm/module.mk
+++ b/engines/scumm/module.mk
@@ -148,6 +148,7 @@ MODULE_OBJS += \
he/gfx_comp/trle_comp.o \
he/gfx_primitives_he.o \
he/logic_he.o \
+ he/math_he.o \
he/palette_he.o \
he/polygon_he.o \
he/script_v71he.o \
Commit: 7040db13afaf55d5217aada4ec827d388c87df7d
https://github.com/scummvm/scummvm/commit/7040db13afaf55d5217aada4ec827d388c87df7d
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Clean-up pass
Changed paths:
engines/scumm/he/gfx_comp/mrle_comp.cpp
engines/scumm/he/gfx_comp/trle_comp.cpp
engines/scumm/he/intern_he.h
engines/scumm/he/script_v90he.cpp
engines/scumm/he/wiz_he.cpp
engines/scumm/he/wiz_he.h
engines/scumm/he/wizwarp_he.cpp
diff --git a/engines/scumm/he/gfx_comp/mrle_comp.cpp b/engines/scumm/he/gfx_comp/mrle_comp.cpp
index 07812727348..22626083c1c 100644
--- a/engines/scumm/he/gfx_comp/mrle_comp.cpp
+++ b/engines/scumm/he/gfx_comp/mrle_comp.cpp
@@ -335,7 +335,7 @@ static void MRLEFLIP_AltSource_DecompImageHull(Wiz *wiz,
}
}
-void Wiz::MRLEFLIP_AltSource_DecompressPrim(
+void Wiz::mrleFLIPAltSourceDecompressPrim(
WizRawPixel *destBufferPtr, int destBufferWidth, int destBufferHeight,
const void *altBufferPtr, int altBitsPerPixel,
const WizCompressedImage *imagePtr, int destX, int destY,
@@ -436,7 +436,7 @@ void Wiz::MRLEFLIP_AltSource_DecompressPrim(
conversionTable, functionPtr);
}
-void Wiz::MRLEFLIP_AltSource_DecompressImage(
+void Wiz::mrleFLIPAltSourceDecompressImage(
WizRawPixel *destBufferPtr, const byte *compData, int destBufferWidth, int destBufferHeight,
const void *altBufferPtr, int altWidth, int altHeight, int altBitsPerPixel,
int x, int y, int width, int height, Common::Rect *clipRectPtr,
@@ -466,14 +466,14 @@ void Wiz::MRLEFLIP_AltSource_DecompressImage(
// Dispatch to the next level of code. (8bpp or conversion)
if (altBitsPerPixel == 16) {
- MRLEFLIP_AltSource_DecompressPrim(
+ mrleFLIPAltSourceDecompressPrim(
destBufferPtr, destBufferWidth, destBufferHeight,
altBufferPtr, altBitsPerPixel, &fakeImage, x, y,
&srcRect, &clipRect, wizFlags, conversionTable,
MRLEFLIP_AltSource_F_XBppToXBpp,
MRLEFLIP_AltSource_B_XBppToXBpp);
} else if (altBitsPerPixel == 8) {
- MRLEFLIP_AltSource_DecompressPrim(
+ mrleFLIPAltSourceDecompressPrim(
destBufferPtr, destBufferWidth, destBufferHeight,
altBufferPtr, altBitsPerPixel, &fakeImage, x, y,
&srcRect, &clipRect, wizFlags, conversionTable,
diff --git a/engines/scumm/he/gfx_comp/trle_comp.cpp b/engines/scumm/he/gfx_comp/trle_comp.cpp
index a770a596832..db52d24bda3 100644
--- a/engines/scumm/he/gfx_comp/trle_comp.cpp
+++ b/engines/scumm/he/gfx_comp/trle_comp.cpp
@@ -205,22 +205,22 @@ namespace Scumm {
} \
++_trlePutsize; \
}
-#define trle_outdump(nn) dest = trle_putdump(dest, nn)
-#define trle_outrun(nn, cc) dest = trle_putrun(dest, nn, cc, tcolor)
+#define trle_outdump(nn) dest = trlePutDump(dest, nn)
+#define trle_outrun(nn, cc) dest = trlePutRun(dest, nn, cc, tcolor)
-void Wiz::TRLEFLIP_CheckAlphaSetup() {
- if (s_InitializelphaTable && _uses16BitColor) {
- s_InitializelphaTable = false;
+void Wiz::trleFLIPCheckAlphaSetup() {
+ if (_initializeAlphaTable && _uses16BitColor) {
+ _initializeAlphaTable = false;
// int alpha to float table
for (int i = 1; i < 255; i++) {
- s_AlphaTable[i] = (float)i / 255.0f;
+ _alphaTable[i] = (float)i / 255.0f;
}
// Force 0 & 255 values just incase the float accuracy is bad.
- s_AlphaTable[0] = 0.0f;
- s_AlphaTable[255] = 1.0f;
+ _alphaTable[0] = 0.0f;
+ _alphaTable[255] = 1.0f;
// Quantized pre-computed alpha results.
int alpha_index = 0;
@@ -234,26 +234,26 @@ void Wiz::TRLEFLIP_CheckAlphaSetup() {
for (int colorB = 0; colorB < WIZ_COLOR16_COMPONENT_COUNT; colorB++) {
int value = (int)(ca + ((float)colorB * ia));
- s_Precomputed16bppTable[alpha_index][colorA][colorB] = value;
+ _precomputed16bppTable[alpha_index][colorA][colorB] = value;
}
}
}
}
}
-WizRawPixel Wiz::TRLEFLIP_AlphaMixPrim(WizRawPixel b, WizRawPixel a, int alpha) {
+WizRawPixel Wiz::trleFLIPAlphaMixPrim(WizRawPixel b, WizRawPixel a, int alpha) {
int quantized = (alpha / WIZ_QUANTIZED_ALPHA_DIV);
return (
- ((s_Precomputed16bppTable[quantized]
+ ((_precomputed16bppTable[quantized]
[((a & WIZRAWPIXEL_R_MASK) >> WIZRAWPIXEL_R_SHIFT)]
[((b & WIZRAWPIXEL_R_MASK) >> WIZRAWPIXEL_R_SHIFT)])
<< WIZRAWPIXEL_R_SHIFT) |
- ((s_Precomputed16bppTable[quantized]
+ ((_precomputed16bppTable[quantized]
[((a & WIZRAWPIXEL_G_MASK) >> WIZRAWPIXEL_G_SHIFT)]
[((b & WIZRAWPIXEL_G_MASK) >> WIZRAWPIXEL_G_SHIFT)])
<< WIZRAWPIXEL_G_SHIFT) |
- ((s_Precomputed16bppTable[quantized]
+ ((_precomputed16bppTable[quantized]
[((a & WIZRAWPIXEL_B_MASK) >> WIZRAWPIXEL_B_SHIFT)]
[((b & WIZRAWPIXEL_B_MASK) >> WIZRAWPIXEL_B_SHIFT)])
<< WIZRAWPIXEL_B_SHIFT));
@@ -271,7 +271,7 @@ void TRLEFLIP_VertFlipAlignWithRect(Common::Rect *rectToAlign, const Common::Rec
rectToAlign->bottom += dy;
}
-void Wiz::TRLEFLIP_DecompImageHull(
+void Wiz::trleFLIPDecompImageHull(
WizRawPixel *bufferPtr, int bufferWidth, const Common::Rect *destRect,
const byte *compData, const Common::Rect *sourceRect, const void *extraPtr,
const WizRawPixel *conversionTable,
@@ -330,7 +330,7 @@ void Wiz::TRLEFLIP_DecompImageHull(
}
}
-void Wiz::TRLEFLIP_DecompressPrim(
+void Wiz::trleFLIPDecompressPrim(
WizSimpleBitmap *bitmapPtr, const COMPRESSEDIMAGE *imagePtr, int destX, int destY,
const Common::Rect *sourceCoords, const Common::Rect *clipRectPtr, const void *extraPtr,
int32 flags, const WizRawPixel *conversionTable,
@@ -425,12 +425,12 @@ void Wiz::TRLEFLIP_DecompressPrim(
}
// Call the primitive image renderer...
- TRLEFLIP_DecompImageHull(
+ trleFLIPDecompImageHull(
bitmapPtr->bufferPtr, bufferWidth, &destRect, imagePtr->data,
&sourceRect, extraPtr, conversionTable, functionPtr);
}
-void Wiz::TRLEFLIP_50_50_Mix_PixelMemset(WizRawPixel *dstPtr, WizRawPixel mixColor, int size) {
+void Wiz::trleFLIPFiftyFiftyMixPixelMemset(WizRawPixel *dstPtr, WizRawPixel mixColor, int size) {
WizRawPixel adjustedColor = WIZRAWPIXEL_50_50_PREMIX_COLOR(mixColor);
while (size-- > 0) {
@@ -439,7 +439,7 @@ void Wiz::TRLEFLIP_50_50_Mix_PixelMemset(WizRawPixel *dstPtr, WizRawPixel mixCol
}
}
-void Wiz::TRLEFLIP_50_50_Mix_ForwardPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable) {
+void Wiz::trleFLIPFiftyFiftyMixForwardPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable) {
while (size-- > 0) {
WizRawPixel srcColor = convert8BppToRawPixel(*srcPtr++, conversionTable);
*dstPtr++ = WIZRAWPIXEL_50_50_MIX(
@@ -448,7 +448,7 @@ void Wiz::TRLEFLIP_50_50_Mix_ForwardPixelCopy(WizRawPixel *dstPtr, const byte *s
}
}
-void Wiz::TRLEFLIP_50_50_Mix_BackwardsPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable) {
+void Wiz::trleFLIPFiftyFiftyMixBackwardsPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable) {
while (size-- > 0) {
WizRawPixel srcColor = convert8BppToRawPixel(*srcPtr++, conversionTable);
*dstPtr-- = WIZRAWPIXEL_50_50_MIX(
@@ -457,7 +457,7 @@ void Wiz::TRLEFLIP_50_50_Mix_BackwardsPixelCopy(WizRawPixel *dstPtr, const byte
}
}
-void Wiz::TRLEFLIP_ADDITIVE_PixelMemset(WizRawPixel *dstPtr, WizRawPixel mixColor, int size) {
+void Wiz::trleFLIPADDITIVEPixelMemset(WizRawPixel *dstPtr, WizRawPixel mixColor, int size) {
while (size-- > 0) {
WizRawPixel workColor = *dstPtr;
@@ -465,7 +465,7 @@ void Wiz::TRLEFLIP_ADDITIVE_PixelMemset(WizRawPixel *dstPtr, WizRawPixel mixColo
}
}
-void Wiz::TRLEFLIP_ADDITIVE_ForwardPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable) {
+void Wiz::trleFLIPADDITIVEForwardPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable) {
while (size-- > 0) {
WizRawPixel srcColor = convert8BppToRawPixel(*srcPtr++, conversionTable);
WizRawPixel workColor = *dstPtr;
@@ -474,7 +474,7 @@ void Wiz::TRLEFLIP_ADDITIVE_ForwardPixelCopy(WizRawPixel *dstPtr, const byte *sr
}
}
-void Wiz::TRLEFLIP_ADDITIVE_BackwardsPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable) {
+void Wiz::trleFLIPADDITIVEBackwardsPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable) {
while (size-- > 0) {
WizRawPixel srcColor = convert8BppToRawPixel(*srcPtr++, conversionTable);
WizRawPixel workColor = *dstPtr;
@@ -482,7 +482,7 @@ void Wiz::TRLEFLIP_ADDITIVE_BackwardsPixelCopy(WizRawPixel *dstPtr, const byte *
*dstPtr-- = (WizRawPixel)WIZRAWPIXEL_ADDITIVE_MIX(workColor, srcColor);
}
}
-void Wiz::TRLEFLIP_SUBTRACTIVE_PixelMemset(WizRawPixel *dstPtr, WizRawPixel mixColor, int size) {
+void Wiz::trleFLIPSUBTRACTIVEPixelMemset(WizRawPixel *dstPtr, WizRawPixel mixColor, int size) {
while (size-- > 0) {
WizRawPixel workColor = *dstPtr;
@@ -490,7 +490,7 @@ void Wiz::TRLEFLIP_SUBTRACTIVE_PixelMemset(WizRawPixel *dstPtr, WizRawPixel mixC
}
}
-void Wiz::TRLEFLIP_SUBTRACTIVE_ForwardPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable) {
+void Wiz::trleFLIPSUBTRACTIVEForwardPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable) {
while (size-- > 0) {
WizRawPixel srcColor = convert8BppToRawPixel(*srcPtr++, conversionTable);
WizRawPixel workColor = *dstPtr;
@@ -499,7 +499,7 @@ void Wiz::TRLEFLIP_SUBTRACTIVE_ForwardPixelCopy(WizRawPixel *dstPtr, const byte
}
}
-void Wiz::TRLEFLIP_SUBTRACTIVE_BackwardsPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable) {
+void Wiz::trleFLIPSUBTRACTIVEBackwardsPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable) {
while (size-- > 0) {
WizRawPixel srcColor = convert8BppToRawPixel(*srcPtr++, conversionTable);
WizRawPixel workColor = *dstPtr;
@@ -508,7 +508,7 @@ void Wiz::TRLEFLIP_SUBTRACTIVE_BackwardsPixelCopy(WizRawPixel *dstPtr, const byt
}
}
-void Wiz::TRLEFLIP_RemapDestPixels(WizRawPixel *dstPtr, int size, const byte *lookupTable) {
+void Wiz::trleFLIPRemapDestPixels(WizRawPixel *dstPtr, int size, const byte *lookupTable) {
if (!_uses16BitColor) {
while (size-- > 0) {
*dstPtr++ = *(lookupTable + *dstPtr);
@@ -516,7 +516,7 @@ void Wiz::TRLEFLIP_RemapDestPixels(WizRawPixel *dstPtr, int size, const byte *lo
}
}
-void Wiz::TRLEFLIP_ForwardPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable) {
+void Wiz::trleFLIPForwardPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable) {
WizRawPixel8 *buf8 = (WizRawPixel8 *)dstPtr;
WizRawPixel16 *buf16 = (WizRawPixel16 *)dstPtr;
@@ -537,7 +537,7 @@ void Wiz::TRLEFLIP_ForwardPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int
}
}
-void Wiz::TRLEFLIP_BackwardsPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable) {
+void Wiz::trleFLIPBackwardsPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable) {
WizRawPixel8 *buf8 = (WizRawPixel8 *)dstPtr;
WizRawPixel16 *buf16 = (WizRawPixel16 *)dstPtr;
@@ -558,7 +558,7 @@ void Wiz::TRLEFLIP_BackwardsPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, i
}
}
-void Wiz::TRLEFLIP_ForewordLookupPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const byte *lookupTable, const WizRawPixel *conversionTable) {
+void Wiz::trleFLIPForewordLookupPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const byte *lookupTable, const WizRawPixel *conversionTable) {
WizRawPixel8 *buf8 = (WizRawPixel8 *)dstPtr;
WizRawPixel16 *buf16 = (WizRawPixel16 *)dstPtr;
@@ -579,7 +579,7 @@ void Wiz::TRLEFLIP_ForewordLookupPixelCopy(WizRawPixel *dstPtr, const byte *srcP
}
}
-void Wiz::TRLEFLIP_BackwardsLookupPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const byte *lookupTable, const WizRawPixel *conversionTable) {
+void Wiz::trleFLIPBackwardsLookupPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const byte *lookupTable, const WizRawPixel *conversionTable) {
WizRawPixel8 *buf8 = (WizRawPixel8 *)dstPtr;
WizRawPixel16 *buf16 = (WizRawPixel16 *)dstPtr;
@@ -600,7 +600,7 @@ void Wiz::TRLEFLIP_BackwardsLookupPixelCopy(WizRawPixel *dstPtr, const byte *src
}
}
-void Wiz::TRLEFLIP_ForewordMixColorsPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const byte *lookupTable) {
+void Wiz::trleFLIPForewordMixColorsPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const byte *lookupTable) {
WizRawPixel8 *buf8 = (WizRawPixel8 *)dstPtr;
WizRawPixel16 *buf16 = (WizRawPixel16 *)dstPtr;
@@ -621,7 +621,7 @@ void Wiz::TRLEFLIP_ForewordMixColorsPixelCopy(WizRawPixel *dstPtr, const byte *s
}
}
-void Wiz::TRLEFLIP_BackwardsMixColorsPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const byte *lookupTable) {
+void Wiz::trleFLIPBackwardsMixColorsPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const byte *lookupTable) {
WizRawPixel8 *buf8 = (WizRawPixel8 *)dstPtr;
WizRawPixel16 *buf16 = (WizRawPixel16 *)dstPtr;
@@ -644,26 +644,26 @@ void Wiz::TRLEFLIP_BackwardsMixColorsPixelCopy(WizRawPixel *dstPtr, const byte *
static void TRLEFLIP_ADDATIVE_DecompressLineForeword(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable) {
TRLEFLIP_X_Foreward_MACRO(
- wiz->TRLEFLIP_ADDITIVE_PixelMemset,
- wiz->TRLEFLIP_ADDITIVE_ForwardPixelCopy);
+ wiz->trleFLIPADDITIVEPixelMemset,
+ wiz->trleFLIPADDITIVEForwardPixelCopy);
}
static void TRLEFLIP_ADDATIVE_DecompressLineBackward(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable) {
TRLEFLIP_X_Backward_MACRO(
- wiz->TRLEFLIP_ADDITIVE_PixelMemset,
- wiz->TRLEFLIP_ADDITIVE_BackwardsPixelCopy);
+ wiz->trleFLIPADDITIVEPixelMemset,
+ wiz->trleFLIPADDITIVEBackwardsPixelCopy);
}
static void TRLEFLIP_SUBTRACTIVE_DecompressLineForeword(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable) {
TRLEFLIP_X_Foreward_MACRO(
- wiz->TRLEFLIP_SUBTRACTIVE_PixelMemset,
- wiz->TRLEFLIP_SUBTRACTIVE_ForwardPixelCopy);
+ wiz->trleFLIPSUBTRACTIVEPixelMemset,
+ wiz->trleFLIPSUBTRACTIVEForwardPixelCopy);
}
static void TRLEFLIP_SUBTRACTIVE_DecompressLineBackward(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable) {
TRLEFLIP_X_Backward_MACRO(
- wiz->TRLEFLIP_SUBTRACTIVE_PixelMemset,
- wiz->TRLEFLIP_SUBTRACTIVE_BackwardsPixelCopy);
+ wiz->trleFLIPSUBTRACTIVEPixelMemset,
+ wiz->trleFLIPSUBTRACTIVEBackwardsPixelCopy);
}
static void TRLEFLIP_DecompressLineForeword(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable) {
@@ -696,7 +696,7 @@ static void TRLEFLIP_DecompressLineForeword(Wiz *wiz, WizRawPixel *destPtr, cons
}
},
{
- wiz->TRLEFLIP_ForwardPixelCopy(destPtr, dataStream, runCount, conversionTable);
+ wiz->trleFLIPForwardPixelCopy(destPtr, dataStream, runCount, conversionTable);
if (wiz->_uses16BitColor) {
dest16 += runCount;
destPtr = (WizRawPixel *)dest16;
@@ -737,7 +737,7 @@ static void TRLEFLIP_DecompressLineBackward(Wiz *wiz, WizRawPixel *destPtr, cons
TRLEFLIP_MEMSET(destPtr + 1, *((byte *)dataStream), runCount);
},
{
- wiz->TRLEFLIP_BackwardsPixelCopy(destPtr, dataStream, runCount, conversionTable);
+ wiz->trleFLIPBackwardsPixelCopy(destPtr, dataStream, runCount, conversionTable);
if (wiz->_uses16BitColor) {
dest16 -= runCount;
destPtr = (WizRawPixel *)dest16;
@@ -781,7 +781,7 @@ static void TRLEFLIP_LookupDecompressLineForeword(Wiz *wiz, WizRawPixel *destPtr
}
},
{
- wiz->TRLEFLIP_ForewordLookupPixelCopy(destPtr, dataStream, runCount, lookupTable, conversionTable);
+ wiz->trleFLIPForewordLookupPixelCopy(destPtr, dataStream, runCount, lookupTable, conversionTable);
if (wiz->_uses16BitColor) {
dest16 += runCount;
destPtr = (WizRawPixel *)dest16;
@@ -825,7 +825,7 @@ static void TRLEFLIP_LookupDecompressLineBackward(Wiz *wiz, WizRawPixel *destPtr
TRLEFLIP_MEMSET(destPtr + 1, *(lookupTable + *dataStream), runCount);
},
{
- wiz->TRLEFLIP_BackwardsLookupPixelCopy(destPtr, dataStream, runCount, lookupTable, conversionTable);
+ wiz->trleFLIPBackwardsLookupPixelCopy(destPtr, dataStream, runCount, lookupTable, conversionTable);
if (wiz->_uses16BitColor) {
dest16 -= runCount;
destPtr = (WizRawPixel *)dest16;
@@ -860,11 +860,11 @@ static void TRLEFLIP_MixDecompressLineForeword(Wiz *wiz, WizRawPixel *destPtr, c
},
{
if (!wiz->_uses16BitColor) {
- wiz->TRLEFLIP_RemapDestPixels(destPtr, runCount, lookupTable + (*dataStream * 256));
+ wiz->trleFLIPRemapDestPixels(destPtr, runCount, lookupTable + (*dataStream * 256));
dest8 += runCount;
destPtr = (WizRawPixel *)dest8;
} else {
- wiz->TRLEFLIP_50_50_Mix_PixelMemset(
+ wiz->trleFLIPFiftyFiftyMixPixelMemset(
destPtr, wiz->convert8BppToRawPixel(*dataStream, conversionTable), runCount);
dest16 += runCount;
@@ -873,11 +873,11 @@ static void TRLEFLIP_MixDecompressLineForeword(Wiz *wiz, WizRawPixel *destPtr, c
},
{
if (!wiz->_uses16BitColor) {
- wiz->TRLEFLIP_ForewordMixColorsPixelCopy(destPtr, dataStream, runCount, lookupTable);
+ wiz->trleFLIPForewordMixColorsPixelCopy(destPtr, dataStream, runCount, lookupTable);
dest8 += runCount;
destPtr = (WizRawPixel *)dest8;
} else {
- wiz->TRLEFLIP_50_50_Mix_ForwardPixelCopy(destPtr, dataStream, runCount, conversionTable);
+ wiz->trleFLIPFiftyFiftyMixForwardPixelCopy(destPtr, dataStream, runCount, conversionTable);
dest16 += runCount;
destPtr = (WizRawPixel *)dest16;
}
@@ -910,21 +910,21 @@ static void TRLEFLIP_MixDecompressLineBackward(Wiz *wiz, WizRawPixel *destPtr, c
if (!wiz->_uses16BitColor) {
dest8 -= runCount;
destPtr = (WizRawPixel *)dest8;
- wiz->TRLEFLIP_RemapDestPixels(destPtr + 1, runCount, lookupTable + (*dataStream * 256));
+ wiz->trleFLIPRemapDestPixels(destPtr + 1, runCount, lookupTable + (*dataStream * 256));
} else {
dest16 -= runCount;
destPtr = (WizRawPixel *)dest16;
- wiz->TRLEFLIP_50_50_Mix_PixelMemset(
+ wiz->trleFLIPFiftyFiftyMixPixelMemset(
destPtr, wiz->convert8BppToRawPixel(*dataStream, conversionTable), runCount);
}
},
{
if (!wiz->_uses16BitColor) {
- wiz->TRLEFLIP_BackwardsMixColorsPixelCopy(destPtr, dataStream, runCount, lookupTable);
+ wiz->trleFLIPBackwardsMixColorsPixelCopy(destPtr, dataStream, runCount, lookupTable);
dest8 -= runCount;
destPtr = (WizRawPixel *)dest8;
} else {
- wiz->TRLEFLIP_50_50_Mix_BackwardsPixelCopy(destPtr, dataStream, runCount, conversionTable);
+ wiz->trleFLIPFiftyFiftyMixBackwardsPixelCopy(destPtr, dataStream, runCount, conversionTable);
dest16 -= runCount;
destPtr = (WizRawPixel *)dest16;
}
@@ -1164,7 +1164,7 @@ static void TRLEFLIP_SUBTRACTIVE_ArbitraryDstStepDecompressLine(Wiz *wiz, WizRaw
TRLEFLIP_X_ArbitraryDstStep_MACRO(WIZRAWPIXEL_SUBTRACTIVE_MIX);
}
-void Wiz::TRLEFLIP_90_DegreeRotateCore(WizSimpleBitmap *dstBitmap, int x, int y, const COMPRESSEDIMAGE *imagePtr, const Common::Rect *optionalSrcRect,
+void Wiz::trleFLIP90DegreeRotateCore(WizSimpleBitmap *dstBitmap, int x, int y, const COMPRESSEDIMAGE *imagePtr, const Common::Rect *optionalSrcRect,
const Common::Rect *optionalClipRect, bool hFlip, bool vFlip, const void *userParam, const WizRawPixel *conversionTable,
void(*functionPtr)(Wiz *wiz,
WizRawPixel *destPtr, const byte *dataStream, int skipAmount,
@@ -1265,7 +1265,7 @@ void Wiz::TRLEFLIP_90_DegreeRotateCore(WizSimpleBitmap *dstBitmap, int x, int y,
}
}
-void Wiz::TRLEFLIP_DecompressImage(
+void Wiz::trleFLIPDecompressImage(
WizRawPixel *bufferPtr, const byte *compData, int bufferWidth, int bufferHeight,
int x, int y, int width, int height, Common::Rect *clipRectPtr,
int32 wizFlags, const void *extraTable, const WizRawPixel *conversionTable,
@@ -1274,7 +1274,7 @@ void Wiz::TRLEFLIP_DecompressImage(
WizSimpleBitmap fakeBitmap;
if (_uses16BitColor)
- TRLEFLIP_CheckAlphaSetup();
+ trleFLIPCheckAlphaSetup();
// General setup for the primitives
fakeBitmap.bufferPtr = bufferPtr;
@@ -1303,21 +1303,21 @@ void Wiz::TRLEFLIP_DecompressImage(
// Check for new "special" rendering modes
if (wizFlags & kWRFSpecialRenderBitMask) {
if (wizFlags & kWRFAdditiveBlend) {
- TRLEFLIP_DecompressPrim(
+ trleFLIPDecompressPrim(
&fakeBitmap, &fakeImage, x, y, nullptr, clipRectPtr, extraTable, wizFlags, conversionTable,
TRLEFLIP_ADDATIVE_DecompressLineForeword,
TRLEFLIP_ADDATIVE_DecompressLineBackward);
return;
} else if (wizFlags & kWRFSubtractiveBlend) {
- TRLEFLIP_DecompressPrim(
+ trleFLIPDecompressPrim(
&fakeBitmap, &fakeImage, x, y, nullptr, clipRectPtr, extraTable, wizFlags, conversionTable,
TRLEFLIP_SUBTRACTIVE_DecompressLineForeword,
TRLEFLIP_SUBTRACTIVE_DecompressLineBackward);
return;
} else if (wizFlags & kWRF5050Blend) {
- TRLEFLIP_DecompressPrim(
+ trleFLIPDecompressPrim(
&fakeBitmap, &fakeImage, x, y, nullptr, clipRectPtr, extraTable, wizFlags, conversionTable,
TRLEFLIP_MixDecompressLineForeword,
TRLEFLIP_MixDecompressLineBackward);
@@ -1329,22 +1329,22 @@ void Wiz::TRLEFLIP_DecompressImage(
// Find which draw primitives need to be called...
if (!extraTable) {
- TRLEFLIP_DecompressPrim(
+ trleFLIPDecompressPrim(
&fakeBitmap, &fakeImage, x, y, nullptr, clipRectPtr, extraTable, wizFlags, conversionTable,
TRLEFLIP_DecompressLineForeword, TRLEFLIP_DecompressLineBackward);
} else if (wizFlags & kWRFRemap) {
- TRLEFLIP_DecompressPrim(
+ trleFLIPDecompressPrim(
&fakeBitmap, &fakeImage, x, y, nullptr, clipRectPtr, extraTable, wizFlags, conversionTable,
TRLEFLIP_LookupDecompressLineForeword, TRLEFLIP_LookupDecompressLineBackward);
} else /* if (wizFlags & kWRFUseShadow) */ {
- TRLEFLIP_DecompressPrim(
+ trleFLIPDecompressPrim(
&fakeBitmap, &fakeImage, x, y, nullptr, clipRectPtr, extraTable, wizFlags, conversionTable,
TRLEFLIP_MixDecompressLineForeword,
TRLEFLIP_MixDecompressLineBackward);
}
}
-void Wiz::TRLEFLIP_Rotate90_DecompressImage(
+void Wiz::trleFLIPRotate90DecompressImage(
WizRawPixel *bufferPtr, const byte *compData, int bufferWidth, int bufferHeight,
int x, int y, int width, int height, const Common::Rect *clipRectPtr,
int32 wizFlags, const void *extraTable, const WizRawPixel *conversionTable,
@@ -1353,7 +1353,7 @@ void Wiz::TRLEFLIP_Rotate90_DecompressImage(
WizSimpleBitmap fakeBitmap;
if (_uses16BitColor)
- TRLEFLIP_CheckAlphaSetup();
+ trleFLIPCheckAlphaSetup();
// General setup for the primitives
fakeBitmap.bufferPtr = bufferPtr;
@@ -1382,7 +1382,7 @@ void Wiz::TRLEFLIP_Rotate90_DecompressImage(
// Check for new "special" rendering modes
if (wizFlags & kWRFSpecialRenderBitMask) {
if (wizFlags & kWRFAdditiveBlend) {
- TRLEFLIP_90_DegreeRotateCore(
+ trleFLIP90DegreeRotateCore(
&fakeBitmap, x, y, &fakeImage, nullptr, clipRectPtr,
(wizFlags & kWRFHFlip), (wizFlags & kWRFVFlip),
extraTable, conversionTable,
@@ -1390,7 +1390,7 @@ void Wiz::TRLEFLIP_Rotate90_DecompressImage(
return;
} else if (wizFlags & kWRFSubtractiveBlend) {
- TRLEFLIP_90_DegreeRotateCore(
+ trleFLIP90DegreeRotateCore(
&fakeBitmap, x, y, &fakeImage, nullptr, clipRectPtr,
(wizFlags & kWRFHFlip), (wizFlags & kWRFVFlip),
extraTable, conversionTable,
@@ -1398,7 +1398,7 @@ void Wiz::TRLEFLIP_Rotate90_DecompressImage(
return;
} else if (wizFlags & kWRF5050Blend) {
- TRLEFLIP_90_DegreeRotateCore(
+ trleFLIP90DegreeRotateCore(
&fakeBitmap, x, y, &fakeImage, nullptr, clipRectPtr,
(wizFlags & kWRFHFlip), (wizFlags & kWRFVFlip),
extraTable, conversionTable,
@@ -1411,20 +1411,20 @@ void Wiz::TRLEFLIP_Rotate90_DecompressImage(
// Find which draw primitives need to be called...
if (!extraTable) {
- TRLEFLIP_90_DegreeRotateCore(
+ trleFLIP90DegreeRotateCore(
&fakeBitmap, x, y, &fakeImage, nullptr, clipRectPtr,
(wizFlags & kWRFHFlip), (wizFlags & kWRFVFlip),
extraTable, conversionTable,
TRLEFLIP_ArbitraryDstStepDecompressLine);
} else if (wizFlags & kWRFRemap) {
- TRLEFLIP_90_DegreeRotateCore(
+ trleFLIP90DegreeRotateCore(
&fakeBitmap, x, y, &fakeImage, nullptr, clipRectPtr,
(wizFlags & kWRFHFlip), (wizFlags & kWRFVFlip),
extraTable, conversionTable,
TRLEFLIP_LookupArbitraryDstStepDecompressLine);
} else /* if (wizFlags & kWRFUseShadow) */ {
- TRLEFLIP_90_DegreeRotateCore(
+ trleFLIP90DegreeRotateCore(
&fakeBitmap, x, y, &fakeImage, nullptr, clipRectPtr,
(wizFlags & kWRFHFlip), (wizFlags & kWRFVFlip),
extraTable, conversionTable,
@@ -1541,7 +1541,7 @@ static void TRLEFLIP_X2X_ALPHA_Memset(Wiz *wiz, WizRawPixel *dstPtr, const WizRa
int alpha = ((*srcPtr++) & 255);
if (alpha) {
- *dstPtr = wiz->TRLEFLIP_AlphaMixPrim(value, *dstPtr, (255 - alpha));
+ *dstPtr = wiz->trleFLIPAlphaMixPrim(value, *dstPtr, (255 - alpha));
}
++dstPtr;
@@ -1554,7 +1554,7 @@ static void TRLEFLIP_X2X_INVALPHA_Memset(Wiz *wiz, WizRawPixel *dstPtr, const Wi
int alpha = (255 - ((*srcPtr++) & 255));
if (alpha) {
- *dstPtr = wiz->TRLEFLIP_AlphaMixPrim(value, *dstPtr, (255 - alpha));
+ *dstPtr = wiz->trleFLIPAlphaMixPrim(value, *dstPtr, (255 - alpha));
}
++dstPtr;
@@ -1567,7 +1567,7 @@ static void TRLEFLIP_X2X_ALPHA_F_Memcpy(Wiz *wiz, WizRawPixel *dstPtr, const Wiz
int alpha = ((*srcPtr++) & 255);
if (alpha) {
- *dstPtr = wiz->TRLEFLIP_AlphaMixPrim(*dstPtr, wiz->convert8BppToRawPixel(*dataPtr, conversionTable), alpha);
+ *dstPtr = wiz->trleFLIPAlphaMixPrim(*dstPtr, wiz->convert8BppToRawPixel(*dataPtr, conversionTable), alpha);
}
++dstPtr;
@@ -1581,7 +1581,7 @@ static void TRLEFLIP_X2X_ALPHA_B_Memcpy(Wiz *wiz, WizRawPixel *dstPtr, const Wiz
int alpha = ((*srcPtr--) & 255);
if (alpha) {
- *dstPtr = wiz->TRLEFLIP_AlphaMixPrim(*dstPtr, wiz->convert8BppToRawPixel(*dataPtr, conversionTable), alpha);
+ *dstPtr = wiz->trleFLIPAlphaMixPrim(*dstPtr, wiz->convert8BppToRawPixel(*dataPtr, conversionTable), alpha);
}
--dstPtr;
@@ -1595,7 +1595,7 @@ static void TRLEFLIP_X2X_INVALPHA_F_Memcpy(Wiz *wiz, WizRawPixel *dstPtr, const
int alpha = (255 - ((*srcPtr++) & 255));
if (alpha) {
- *dstPtr = wiz->TRLEFLIP_AlphaMixPrim(*dstPtr, wiz->convert8BppToRawPixel(*dataPtr, conversionTable), alpha);
+ *dstPtr = wiz->trleFLIPAlphaMixPrim(*dstPtr, wiz->convert8BppToRawPixel(*dataPtr, conversionTable), alpha);
}
++dstPtr;
@@ -1609,7 +1609,7 @@ static void TRLEFLIP_X2X_INVALPHA_B_Memcpy(Wiz *wiz, WizRawPixel *dstPtr, const
int alpha = (255 - ((*srcPtr--) & 255));
if (alpha) {
- *dstPtr = wiz->TRLEFLIP_AlphaMixPrim(
+ *dstPtr = wiz->trleFLIPAlphaMixPrim(
*dstPtr, wiz->convert8BppToRawPixel(*dataPtr, conversionTable), alpha);
}
@@ -1652,7 +1652,7 @@ static void TRLEFLIP_ATRLE_ALPHA_Memset(Wiz *wiz, WizRawPixel *dstPtr, const Wiz
if (alpha) {
while (size-- > 0) {
- *dstPtr = wiz->TRLEFLIP_AlphaMixPrim(*dstPtr, *srcPtr, alpha);
+ *dstPtr = wiz->trleFLIPAlphaMixPrim(*dstPtr, *srcPtr, alpha);
++dstPtr;
++srcPtr;
@@ -1666,7 +1666,7 @@ static void TRLEFLIP_ATRLE_INVALPHA_Memset(Wiz *wiz, WizRawPixel *dstPtr, const
if (alpha) {
while (size-- > 0) {
- *dstPtr = wiz->TRLEFLIP_AlphaMixPrim(*dstPtr, *srcPtr, alpha);
+ *dstPtr = wiz->trleFLIPAlphaMixPrim(*dstPtr, *srcPtr, alpha);
++dstPtr;
++srcPtr;
@@ -1680,7 +1680,7 @@ static void TRLEFLIP_ATRLE_ALPHA_F_Memcpy(Wiz *wiz, WizRawPixel *dstPtr, const W
int alpha = ((wiz->convert8BppToRawPixel(*dataPtr++, conversionTable)) & 255);
if (alpha) {
- *dstPtr = wiz->TRLEFLIP_AlphaMixPrim(
+ *dstPtr = wiz->trleFLIPAlphaMixPrim(
*dstPtr, *srcPtr, alpha);
}
@@ -1695,7 +1695,7 @@ static void TRLEFLIP_ATRLE_ALPHA_B_Memcpy(Wiz *wiz, WizRawPixel *dstPtr, const W
int alpha = ((wiz->convert8BppToRawPixel(*dataPtr++, conversionTable)) & 255);
if (alpha) {
- *dstPtr = wiz->TRLEFLIP_AlphaMixPrim(
+ *dstPtr = wiz->trleFLIPAlphaMixPrim(
*dstPtr, *srcPtr, alpha);
}
@@ -1710,7 +1710,7 @@ static void TRLEFLIP_ATRLE_INVALPHA_F_Memcpy(Wiz *wiz, WizRawPixel *dstPtr, cons
int alpha = (255 - ((wiz->convert8BppToRawPixel(*dataPtr++, conversionTable)) & 255));
if (alpha) {
- *dstPtr = wiz->TRLEFLIP_AlphaMixPrim(
+ *dstPtr = wiz->trleFLIPAlphaMixPrim(
*dstPtr, *srcPtr, alpha);
}
@@ -1725,7 +1725,7 @@ static void TRLEFLIP_ATRLE_INVALPHA_B_Memcpy(Wiz *wiz, WizRawPixel *dstPtr, cons
int alpha = (255 - ((wiz->convert8BppToRawPixel(*dataPtr++, conversionTable)) & 255));
if (alpha) {
- *dstPtr = wiz->TRLEFLIP_AlphaMixPrim(
+ *dstPtr = wiz->trleFLIPAlphaMixPrim(
*dstPtr, *srcPtr, alpha);
}
@@ -1922,13 +1922,13 @@ static void TRLEFLIP_AltSource_INV_B_XBppToXBpp(Wiz *wiz, WizRawPixel *destPtr,
});
}
-void Wiz::TRLEFLIP_AltSource_DecompImageHull(
+void Wiz::trleFLIPAltSourceDecompImageHull(
WizRawPixel *bufferPtr, int bufferWidth, const Common::Rect *destRect,
const byte *altSourceBuffer, int altBytesPerLine,
int altBytesPerPixel, const Common::Rect *altRect,
const byte *compData, const Common::Rect *sourceRect,
const WizRawPixel *conversionTable,
- void (*functionPtr)(Wiz *,
+ void (*functionPtr)(Wiz *wiz,
WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream,
int skipAmount, int decompAmount, const WizRawPixel *conversionTable)) {
int decompWidth, decompHeight, counter, sX1, lineSize;
@@ -1993,7 +1993,7 @@ void Wiz::TRLEFLIP_AltSource_DecompImageHull(
}
}
-void Wiz::TRLEFLIP_AltSource_DecompressPrim(
+void Wiz::trleFLIPAltSourceDecompressPrim(
WizRawPixel *destBufferPtr, int destBufferWidth, int destBufferHeight,
const void *altBufferPtr, int altBitsPerPixel,
const COMPRESSEDIMAGE *imagePtr, int destX, int destY,
@@ -2086,14 +2086,14 @@ void Wiz::TRLEFLIP_AltSource_DecompressPrim(
}
// Call the primitive image renderer...
- TRLEFLIP_AltSource_DecompImageHull(
+ trleFLIPAltSourceDecompImageHull(
destBufferPtr, destBufferWidth, &destRect,
(const byte *)altBufferPtr, ((destBufferWidth * altBitsPerPixel) / 8),
(altBitsPerPixel / 8), &destRect, imagePtr->data, &sourceRect,
conversionTable, functionPtr);
}
-bool Wiz::TRLEFLIP_AltSource_SpecialCaseDispatch(
+bool Wiz::trleFLIPAltSourceSpecialCaseDispatch(
WizRawPixel *destBufferPtr, const byte *compData, int destBufferWidth, int destBufferHeight,
const void *altBufferPtr, int altWidth, int altHeight, int altBitsPerPixel,
int x, int y, int width, int height, Common::Rect *clipRectPtr,
@@ -2126,7 +2126,7 @@ bool Wiz::TRLEFLIP_AltSource_SpecialCaseDispatch(
if (wizFlags & kWRFBooleanAlpha) {
if (wizFlags & kWRFInverseAlpha) {
// Inverse alpha
- TRLEFLIP_AltSource_DecompressPrim(
+ trleFLIPAltSourceDecompressPrim(
destBufferPtr, destBufferWidth, destBufferHeight,
altBufferPtr, altBitsPerPixel, &fakeImage, x, y,
&srcRect, &clipRect, wizFlags, conversionTable,
@@ -2136,7 +2136,7 @@ bool Wiz::TRLEFLIP_AltSource_SpecialCaseDispatch(
return true;
} else {
// Normal alpha
- TRLEFLIP_AltSource_DecompressPrim(
+ trleFLIPAltSourceDecompressPrim(
destBufferPtr, destBufferWidth, destBufferHeight,
altBufferPtr, altBitsPerPixel, &fakeImage, x, y,
&srcRect, &clipRect, wizFlags, conversionTable,
@@ -2148,7 +2148,7 @@ bool Wiz::TRLEFLIP_AltSource_SpecialCaseDispatch(
} else {
if (wizFlags & kWRFInverseAlpha) {
// Inverse alpha
- TRLEFLIP_AltSource_DecompressPrim(
+ trleFLIPAltSourceDecompressPrim(
destBufferPtr, destBufferWidth, destBufferHeight,
altBufferPtr, altBitsPerPixel, &fakeImage, x, y,
&srcRect, &clipRect, wizFlags, conversionTable,
@@ -2158,7 +2158,7 @@ bool Wiz::TRLEFLIP_AltSource_SpecialCaseDispatch(
return true;
} else {
// Normal alpha
- TRLEFLIP_AltSource_DecompressPrim(
+ trleFLIPAltSourceDecompressPrim(
destBufferPtr, destBufferWidth, destBufferHeight,
altBufferPtr, altBitsPerPixel, &fakeImage, x, y,
&srcRect, &clipRect, wizFlags, conversionTable,
@@ -2172,7 +2172,7 @@ bool Wiz::TRLEFLIP_AltSource_SpecialCaseDispatch(
if (wizFlags & kWRFBooleanAlpha) {
if (wizFlags & kWRFInverseAlpha) {
// Inverse alpha
- TRLEFLIP_AltSource_DecompressPrim(
+ trleFLIPAltSourceDecompressPrim(
destBufferPtr, destBufferWidth, destBufferHeight,
altBufferPtr, altBitsPerPixel, &fakeImage, x, y,
&srcRect, &clipRect, wizFlags, conversionTable,
@@ -2182,7 +2182,7 @@ bool Wiz::TRLEFLIP_AltSource_SpecialCaseDispatch(
return true;
} else {
// Normal alpha
- TRLEFLIP_AltSource_DecompressPrim(
+ trleFLIPAltSourceDecompressPrim(
destBufferPtr, destBufferWidth, destBufferHeight,
altBufferPtr, altBitsPerPixel, &fakeImage, x, y,
&srcRect, &clipRect, wizFlags, conversionTable,
@@ -2194,7 +2194,7 @@ bool Wiz::TRLEFLIP_AltSource_SpecialCaseDispatch(
} else {
if (wizFlags & kWRFInverseAlpha) {
// Inverse alpha
- TRLEFLIP_AltSource_DecompressPrim(
+ trleFLIPAltSourceDecompressPrim(
destBufferPtr, destBufferWidth, destBufferHeight,
altBufferPtr, altBitsPerPixel, &fakeImage, x, y,
&srcRect, &clipRect, wizFlags, conversionTable,
@@ -2204,7 +2204,7 @@ bool Wiz::TRLEFLIP_AltSource_SpecialCaseDispatch(
return true;
} else {
// Normal alpha
- TRLEFLIP_AltSource_DecompressPrim(
+ trleFLIPAltSourceDecompressPrim(
destBufferPtr, destBufferWidth, destBufferHeight,
altBufferPtr, altBitsPerPixel, &fakeImage, x, y,
&srcRect, &clipRect, wizFlags, conversionTable,
@@ -2219,7 +2219,7 @@ bool Wiz::TRLEFLIP_AltSource_SpecialCaseDispatch(
return false;
}
-void Wiz::TRLEFLIP_AltSource_DecompressImage(
+void Wiz::trleFLIPAltSourceDecompressImage(
WizRawPixel *destBufferPtr, const byte *compData, int destBufferWidth, int destBufferHeight,
const void *altBufferPtr, int altWidth, int altHeight, int altBitsPerPixel,
int x, int y, int width, int height, Common::Rect *clipRectPtr,
@@ -2230,7 +2230,7 @@ void Wiz::TRLEFLIP_AltSource_DecompressImage(
int curBpp = _uses16BitColor ? 16 : 8;
if (_uses16BitColor)
- TRLEFLIP_CheckAlphaSetup();
+ trleFLIPCheckAlphaSetup();
// General setup
fakeImage.data = (byte *)compData;
@@ -2254,7 +2254,7 @@ void Wiz::TRLEFLIP_AltSource_DecompressImage(
if (_uses16BitColor) {
// Check for new "special" rendering modes
if (wizFlags & kWRFSpecialRenderBitMask) {
- if (!TRLEFLIP_AltSource_SpecialCaseDispatch(
+ if (!trleFLIPAltSourceSpecialCaseDispatch(
destBufferPtr, compData, destBufferWidth, destBufferHeight,
altBufferPtr, altWidth, altHeight, altBitsPerPixel,
x, y, width, height, clipRectPtr, wizFlags, conversionTable,
@@ -2268,8 +2268,8 @@ void Wiz::TRLEFLIP_AltSource_DecompressImage(
// Dispatch to the next level of code. (8bpp or conversion)
if (altBitsPerPixel == curBpp) {
if (!_uses16BitColor)
- error("Wiz::TRLEFLIP_AltSource_DecompressImage(): Yeah, it's used, fix it! 1");
- TRLEFLIP_AltSource_DecompressPrim(
+ error("Wiz::trleFLIPAltSourceDecompressImage(): Yeah, it's used, fix it! 1");
+ trleFLIPAltSourceDecompressPrim(
destBufferPtr, destBufferWidth, destBufferHeight,
altBufferPtr, altBitsPerPixel, &fakeImage, x, y,
&srcRect, &clipRect, wizFlags, conversionTable,
@@ -2277,8 +2277,8 @@ void Wiz::TRLEFLIP_AltSource_DecompressImage(
TRLEFLIP_AltSource_B_XBppToXBpp);
} else if (altBitsPerPixel == 8) {
if (!_uses16BitColor)
- error("Wiz::TRLEFLIP_AltSource_DecompressImage(): Yeah, it's used, fix it! 2");
- TRLEFLIP_AltSource_DecompressPrim(
+ error("Wiz::trleFLIPAltSourceDecompressImage(): Yeah, it's used, fix it! 2");
+ trleFLIPAltSourceDecompressPrim(
destBufferPtr, destBufferWidth, destBufferHeight,
altBufferPtr, altBitsPerPixel, &fakeImage, x, y,
&srcRect, &clipRect, wizFlags, conversionTable,
@@ -2287,7 +2287,7 @@ void Wiz::TRLEFLIP_AltSource_DecompressImage(
}
}
-int Wiz::TRLE_CompressImageArea(
+int Wiz::trleCompressImageArea(
byte *destBuffer, const WizRawPixel *sourceBuffer, int sourceBufferWidth,
int x1, int y1, int x2, int y2, WizRawPixel transparentColor) {
int width, height, totalSize, lineSize;
@@ -2316,7 +2316,7 @@ int Wiz::TRLE_CompressImageArea(
}
totalSize += 2;
- lineSize = trle_rle_compression(
+ lineSize = trleRLECompression(
destBuffer, sourceBuffer, width, transparentColor);
// Refresh pointers, you never know...
@@ -2341,7 +2341,7 @@ int Wiz::TRLE_CompressImageArea(
return totalSize;
}
-byte *Wiz::trle_putdump(byte *dest, int nn) {
+byte *Wiz::trlePutDump(byte *dest, int nn) {
int i, count, index;
byte value;
@@ -2368,7 +2368,7 @@ byte *Wiz::trle_putdump(byte *dest, int nn) {
return dest;
}
-byte *Wiz::trle_putrun(byte *dest, int nn, int cc, int tColor) {
+byte *Wiz::trlePutRun(byte *dest, int nn, int cc, int tColor) {
byte value;
int count;
@@ -2411,7 +2411,7 @@ byte *Wiz::trle_putrun(byte *dest, int nn, int cc, int tColor) {
return dest;
}
-int Wiz::trle_rle_compression(byte *pdest, const WizRawPixel *psource, int rowsize, WizRawPixel tcolor) {
+int Wiz::trleRLECompression(byte *pdest, const WizRawPixel *psource, int rowsize, WizRawPixel tcolor) {
byte *dest;
WizRawPixel c;
WizRawPixel lastc = 0;
diff --git a/engines/scumm/he/intern_he.h b/engines/scumm/he/intern_he.h
index 96705c59e1c..11b4f46d366 100644
--- a/engines/scumm/he/intern_he.h
+++ b/engines/scumm/he/intern_he.h
@@ -681,7 +681,6 @@ protected:
void processActors() override;
- int computeWizHistogram(int resnum, int state, int x, int y, int w, int h);
void getArrayDim(int array, int *dim2start, int *dim2end, int *dim1start, int *dim1end);
void sortArray(int array, int dim2start, int dim2end, int dim1start, int dim1end, int sortOrder);
diff --git a/engines/scumm/he/script_v90he.cpp b/engines/scumm/he/script_v90he.cpp
index 27e6c438492..d216c313d17 100644
--- a/engines/scumm/he/script_v90he.cpp
+++ b/engines/scumm/he/script_v90he.cpp
@@ -1616,169 +1616,6 @@ int auxRectsOverlap(const Common::Rect *destRectPtr, const Common::Rect *sourceR
}
void ScummEngine_v90he::o90_getOverlap() {
- //int lastList[32];
- //int firstList[32];
- //
- //int lastCount = getStackList(lastList, ARRAYSIZE(lastList));
- //int firstCount = getStackList(firstList, ARRAYSIZE(firstList));
- //
- //int checkType = pop();
- //
- //switch (checkType) {
- //case OVERLAP_POINT_TO_RECT: // 1
- // {
- // Common::Rect r(lastList[0], lastList[1], lastList[2], lastList[3]);
- // Common::Point p(firstList[0], firstList[1]);
- //
- // push(_wiz->isPointInRect(&r, &p) ? 1 : 0);
- // }
- // break;
- //case OVERLAP_POINT_TO_CIRCLE: // 2
- // {
- // int dx = firstList[0] - lastList[0];
- // int dy = firstList[1] - lastList[1];
- // int dist = dx * dx + dy * dy;
- // if (dist >= 2) {
- // dist = (int)sqrt((double)(dist + 1));
- // }
- // if (_game.heversion >= 98) {
- // push((dist <= lastList[2]) ? 1 : 0);
- // } else {
- // push((dist > lastList[2]) ? 1 : 0);
- // }
- // }
- // break;
- //case OVERLAP_RECT_TO_RECT: // 3
- // {
- // Common::Rect r1(lastList[0], lastList[1], lastList[2] + 1, lastList[3] + 1);
- // Common::Rect r2(firstList[0], firstList[1], firstList[2] + 1, firstList[3] + 1);
- // push(r2.intersects(r1) ? 1 : 0);
- // }
- // break;
- //case OVERLAP_CIRCLE_TO_CIRCLE: // 4
- // {
- // int dx = firstList[0] - lastList[0];
- // int dy = firstList[1] - lastList[1];
- // int dist = dx * dx + dy * dy;
- // if (dist >= 2) {
- // dist = (int)sqrt((double)(dist + 1));
- // }
- // push((dist < lastList[2] && dist < firstList[2]) ? 1 : 0);
- // }
- // break;
- //case OVERLAP_POINT_N_SIDED_POLYGON: // 5
- // {
- // assert((lastCount & 1) == 0);
- // lastCount /= 2;
- // if (lastCount == 0) {
- // push(0);
- // } else {
- // WizPolygon wp;
- // wp.reset();
- // wp.numPoints = lastCount;
- // assert(lastCount < ARRAYSIZE(wp.points));
- // for (int i = 0; i < lastCount; ++i) {
- // wp.points[i].x = lastList[i * 2 + 0];
- // wp.points[i].y = lastList[i * 2 + 1];
- // }
- // push(_wiz->polyIsPointInsidePoly(wp, firstList[0], firstList[1]) ? 1 : 0);
- // }
- // }
- // break;
- //// HE 98+
- //case OVERLAP_SPRITE_TO_SPRITE: // 6
- // {
- // Common::Rect r1, r2;
- // _sprite->getSpriteLogicalRect(firstList[0], false, r2);
- // _sprite->getSpriteLogicalRect(lastList[0], false, r1);
- // if (r2.isValidRect() == false) {
- // push(0);
- // break;
- // }
- //
- // if (firstCount == 3) {
- // r2.left += firstList[1];
- // r2.right += firstList[1];
- // r2.top += firstList[2];
- // r2.bottom += firstList[2];
- // }
- // if (lastCount == 3) {
- // r1.left += lastList[1];
- // r1.right += lastList[1];
- // r1.top += lastList[2];
- // r1.bottom += lastList[2];
- // }
- // push(r2.intersects(r1) ? 1 : 0);
- // }
- // break;
- //case OVERLAP_SPRITE_TO_RECT: // 7
- // {
- // Common::Rect r2;
- // _sprite->getSpriteLogicalRect(firstList[0], false, r2);
- // Common::Rect r1(lastList[0], lastList[1], lastList[2] + 1, lastList[3] + 1);
- // if (r2.isValidRect() == false) {
- // push(0);
- // break;
- // }
- //
- // if (firstCount == 3) {
- // r2.left += firstList[1];
- // r2.right += firstList[1];
- // r2.top += firstList[2];
- // r2.bottom += firstList[2];
- // }
- // push(r2.intersects(r1) ? 1 : 0);
- // }
- // break;
- //case OVERLAP_DRAW_POS_SPRITE_TO_SPRITE: // 8
- //case OVERLAP_SPRITE_TO_SPRITE_PIXEL_PERFECT: // 10
- //// TODO: Draw sprites to buffer and compare.
- // {
- // Common::Rect r1, r2;
- // _sprite->getSpriteLogicalRect(firstList[0], true, r2);
- // _sprite->getSpriteLogicalRect(lastList[0], true, r1);
- // if (r2.isValidRect() == false) {
- // push(0);
- // break;
- // }
- //
- // if (firstCount == 3) {
- // r2.left += firstList[1];
- // r2.right += firstList[1];
- // r2.top += firstList[2];
- // r2.bottom += firstList[2];
- // }
- // if (lastCount == 3) {
- // r1.left += lastList[1];
- // r1.right += lastList[1];
- // r1.top += lastList[2];
- // r1.bottom += lastList[2];
- // }
- // push(r2.intersects(r1) ? 1 : 0);
- // }
- // break;
- //case OVERLAP_DRAW_POS_SPRITE_TO_RECT: // 9
- // {
- // Common::Rect r2;
- // _sprite->getSpriteLogicalRect(firstList[0], true, r2);
- // Common::Rect r1(lastList[0], lastList[1], lastList[2] + 1, lastList[3] + 1);
- // if (r2.isValidRect() == false) {
- // push(0);
- // break;
- // }
- //
- // if (firstCount == 3) {
- // r2.left += firstList[1];
- // r2.right += firstList[1];
- // r2.top += firstList[2];
- // r2.bottom += firstList[2];
- // }
- // push(r2.intersects(r1) ? 1 : 0);
- // }
- // break;
- //default:
- // error("o90_getOverlap: default case %d", checkType);
- //}
int firstCount, lastCount, checkType, firstRadius, ax, ay, bx, by;
int nVerts, index, lastRadius, distance, counter;
Common::Point lastCenterPoint, firstCenterPoint;
diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp
index 903842e00df..2060bd6dbcc 100644
--- a/engines/scumm/he/wiz_he.cpp
+++ b/engines/scumm/he/wiz_he.cpp
@@ -162,7 +162,7 @@ byte *Wiz::drawAWizEx(int image, int state, int x, int y, int z, int flags, int
optionalShadowImage, optionalZBufferImage, clipRectPtr,
flags, optionalBitmapOverride, colorConversionTable, optionalICmdPtr);
} else {
- WARPWIZ_DrawWiz(
+ warpDrawWiz(
image, state, x, flags, _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR),
optionalBitmapOverride, colorConversionTable, optionalShadowImage);
@@ -390,7 +390,7 @@ void *Wiz::drawAWizPrimEx(int globNum, int state, int x, int y, int z, int shado
if (flags & kWRFRemap)
dataPtr = remap_p + _vm->_resourceHeaderSize + 4;
- TRLEFLIP_DecompressImage(
+ trleFLIPDecompressImage(
dest_p, src_d + _vm->_resourceHeaderSize, dest_w, dest_h,
x, y, src_w, src_h, &clip_r, flags, dataPtr,
optionalColorConversionTable,
@@ -511,7 +511,7 @@ void Wiz::buildAWiz(const WizRawPixel *bufPtr, int bufWidth, int bufHeight, cons
}
if (compressionType == kWCTTRLE) {
- dataSize = TRLE_CompressImageArea(
+ dataSize = trleCompressImageArea(
nullptr, bufPtr, bufWidth, compRect.left, compRect.top, compRect.right, compRect.bottom,
(WizRawPixel)transparentColor);
} else if (isUncompressedFormatTypeID(compressionType)) {
@@ -567,7 +567,7 @@ void Wiz::buildAWiz(const WizRawPixel *bufPtr, int bufWidth, int bufHeight, cons
if (compressionType == kWCTTRLE) {
if (!_uses16BitColor) {
- TRLE_CompressImageArea(
+ trleCompressImageArea(
ptr + dataOffset, bufPtr, bufWidth,
compRect.left, compRect.top, compRect.top, compRect.bottom,
(byte)transparentColor);
@@ -1126,7 +1126,7 @@ void Wiz::processWizImagePolyCaptureCmd(const WizImageCommand *params) {
srcWarpPoints[i] = tmp;
}
- WARPWIZ_NPt2NPtNonClippedWarpFiltered(
+ warpNPt2NPtNonClippedWarpFiltered(
&destBitmap, polypoints, &srcBitmap, srcWarpPoints,
_polygons[polygon1].numPoints, _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR),
pXmapColorTable, bIsHintColor, (WizRawPixel)iHintColor);
@@ -1146,7 +1146,7 @@ void Wiz::processWizImagePolyCaptureCmd(const WizImageCommand *params) {
srcWarpPoints[i] = tmp;
}
- WARPWIZ_NPt2NPtNonClippedWarp(
+ warpNPt2NPtNonClippedWarp(
&destBitmap, polypoints, &srcBitmap, srcWarpPoints,
_polygons[polygon1].numPoints, _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR));
}
@@ -1680,7 +1680,7 @@ void Wiz::dwAltSourceDrawWiz(int maskImage, int maskState, int x, int y, int sou
// Finally call the primitive...
if (maskCompressionType == kWCTTRLE) {
- TRLEFLIP_AltSource_DecompressImage(
+ trleFLIPAltSourceDecompressImage(
destBitmapPtr->bufferPtr, maskDataPtr,
destBitmapPtr->bitmapWidth, destBitmapPtr->bitmapHeight,
sourceBufferPtr, srcBitmapWidth, srcBitmapHeight, srcBitsPerPixel,
@@ -1688,7 +1688,7 @@ void Wiz::dwAltSourceDrawWiz(int maskImage, int maskState, int x, int y, int sou
nullptr);
} else if (maskCompressionType == kWCTMRLEWithLineSizePrefix) {
- MRLEFLIP_AltSource_DecompressImage(
+ mrleFLIPAltSourceDecompressImage(
destBitmapPtr->bufferPtr, maskDataPtr,
destBitmapPtr->bitmapWidth, destBitmapPtr->bitmapHeight,
sourceBufferPtr, srcBitmapWidth, srcBitmapHeight, srcBitsPerPixel,
@@ -1823,7 +1823,7 @@ void Wiz::dwHandleComplexImageDraw(int image, int state, int x, int y, int shado
}
// Finally call the renderer
- WARPWIZ_DrawWizTo4Points(
+ warpDrawWizTo4Points(
image, state, listOfWarpPoints, flags,
_vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR),
clipRect, optionalBitmapOverride, optionalColorConversionTable,
@@ -1924,7 +1924,7 @@ void Wiz::handleRotate90SpecialCase(int image, int state, int x, int y, int shad
}
}
- TRLEFLIP_Rotate90_DecompressImage(
+ trleFLIPRotate90DecompressImage(
dest_p, compressedDataPtr, dest_w, dest_h, x, y, src_w, src_h,
clipRect, flags, nullptr, optionalColorConversionTable,
nullptr);
@@ -2798,7 +2798,7 @@ bool Wiz::collisionCompareImageLines(
rawPixelMemset(_compareBufferA, transparentColor, compareWidth);
if (aType == kWCTTRLE) {
- TRLEFLIP_DecompressImage(
+ trleFLIPDecompressImage(
_compareBufferA, imageAData, compareWidth, 1,
-ax, -ay, aw, ah, nullptr, wizAFlags, nullptr,
(WizRawPixel *)_vm->getHEPaletteSlot(1),
@@ -2814,7 +2814,7 @@ bool Wiz::collisionCompareImageLines(
rawPixelMemset(_compareBufferB, transparentColor, compareWidth);
if (bType == kWCTTRLE) {
- TRLEFLIP_DecompressImage(
+ trleFLIPDecompressImage(
_compareBufferB, imageBData, compareWidth, 1,
-bx, -by, bw, bh, nullptr, wizBFlags, nullptr,
(WizRawPixel *)_vm->getHEPaletteSlot(1),
diff --git a/engines/scumm/he/wiz_he.h b/engines/scumm/he/wiz_he.h
index dc643c4abbc..97009db6904 100644
--- a/engines/scumm/he/wiz_he.h
+++ b/engines/scumm/he/wiz_he.h
@@ -708,12 +708,12 @@ public:
*/
// MRLE
- void MRLEFLIP_AltSource_DecompressImage(
+ void mrleFLIPAltSourceDecompressImage(
WizRawPixel *destBufferPtr, const byte *compData, int destBufferWidth, int destBufferHeight,
const void *altBufferPtr, int altWidth, int altHeight, int altBitsPerPixel,
int x, int y, int width, int height, Common::Rect *clipRectPtr,
int32 wizFlags, const WizRawPixel *conversionTable);
- void MRLEFLIP_AltSource_DecompressPrim(
+ void mrleFLIPAltSourceDecompressPrim(
WizRawPixel *destBufferPtr, int destBufferWidth, int destBufferHeight,
const void *altBufferPtr, int altBitsPerPixel,
const WizCompressedImage *imagePtr, int destX, int destY,
@@ -773,23 +773,23 @@ public:
int _trlePutsize = 0;
byte _trleBuf[(128 * 2) * sizeof(WizRawPixel)];
- byte *trle_putdump(byte *dest, int nn);
- byte *trle_putrun(byte *dest, int nn, int cc, int tcolor);
- int trle_rle_compression(byte *pdest, const WizRawPixel *psource, int rowsize, WizRawPixel tcolor);
- int TRLE_CompressImageArea(byte *destBuffer, const WizRawPixel *sourceBuffer, int sourceBufferWidth, int x1, int y1, int x2, int y2, WizRawPixel transparentColor);
+ byte *trlePutDump(byte *dest, int nn);
+ byte *trlePutRun(byte *dest, int nn, int cc, int tcolor);
+ int trleRLECompression(byte *pdest, const WizRawPixel *psource, int rowsize, WizRawPixel tcolor);
+ int trleCompressImageArea(byte *destBuffer, const WizRawPixel *sourceBuffer, int sourceBufferWidth, int x1, int y1, int x2, int y2, WizRawPixel transparentColor);
// TRLE FLIP
- bool s_InitializelphaTable = true;
- float s_AlphaTable[256];
- int s_Precomputed16bppTable[WIZ_QUANTIZED_ALPHA_COUNT][WIZ_COLOR16_COMPONENT_COUNT][WIZ_COLOR16_COMPONENT_COUNT];
+ bool _initializeAlphaTable = true;
+ float _alphaTable[256];
+ int _precomputed16bppTable[WIZ_QUANTIZED_ALPHA_COUNT][WIZ_COLOR16_COMPONENT_COUNT][WIZ_COLOR16_COMPONENT_COUNT];
- void TRLEFLIP_DecompressImage(
+ void trleFLIPDecompressImage(
WizRawPixel *bufferPtr, const byte *compData, int bufferWidth, int bufferHeight,
int x, int y, int width, int height, Common::Rect *clipRectPtr,
int32 wizFlags, const void *extraTable, const WizRawPixel *conversionTable,
const WizImageCommand *optionalICmdPtr);
- void TRLEFLIP_DecompressPrim(
+ void trleFLIPDecompressPrim(
WizSimpleBitmap *bitmapPtr, const COMPRESSEDIMAGE *imagePtr, int destX, int destY,
const Common::Rect *sourceCoords, const Common::Rect *clipRectPtr, const void *extraPtr,
int32 flags, const WizRawPixel *conversionTable,
@@ -800,7 +800,7 @@ public:
WizRawPixel *destPtr, const byte *dataStream, int skipAmount,
int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable));
- void TRLEFLIP_DecompImageHull(
+ void trleFLIPDecompImageHull(
WizRawPixel *bufferPtr, int bufferWidth, const Common::Rect *destRect,
const byte *compData, const Common::Rect *sourceRect, const void *extraPtr,
const WizRawPixel *conversionTable,
@@ -808,14 +808,14 @@ public:
WizRawPixel *destPtr, const byte *dataStream, int skipAmount,
int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable));
- void TRLEFLIP_AltSource_DecompressImage(
+ void trleFLIPAltSourceDecompressImage(
WizRawPixel *destBufferPtr, const byte *compData, int destBufferWidth, int destBufferHeight,
const void *altBufferPtr, int altWidth, int altHeight, int altBitsPerPixel,
int x, int y, int width, int height, Common::Rect *clipRectPtr,
int32 wizFlags, const WizRawPixel *conversionTable,
WizImageCommand *optionalICmdPtr);
- void TRLEFLIP_AltSource_DecompressPrim(
+ void trleFLIPAltSourceDecompressPrim(
WizRawPixel *destBufferPtr, int destBufferWidth, int destBufferHeight,
const void *altBufferPtr, int altBitsPerPixel,
const COMPRESSEDIMAGE *imagePtr, int destX, int destY,
@@ -828,30 +828,30 @@ public:
WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream,
int skipAmount, int decompAmount, const WizRawPixel *conversionTable));
- void TRLEFLIP_AltSource_DecompImageHull(
+ void trleFLIPAltSourceDecompImageHull(
WizRawPixel *bufferPtr, int bufferWidth, const Common::Rect *destRect,
const byte *altSourceBuffer, int altBytesPerLine,
int altBytesPerPixel, const Common::Rect *altRect,
const byte *compData, const Common::Rect *sourceRect,
const WizRawPixel *conversionTable,
- void (*functionPtr)(Wiz *,
+ void (*functionPtr)(Wiz *wiz,
WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream,
int skipAmount, int decompAmount, const WizRawPixel *conversionTable));
- bool TRLEFLIP_AltSource_SpecialCaseDispatch(
+ bool trleFLIPAltSourceSpecialCaseDispatch(
WizRawPixel *destBufferPtr, const byte *compData, int destBufferWidth, int destBufferHeight,
const void *altBufferPtr, int altWidth, int altHeight, int altBitsPerPixel,
int x, int y, int width, int height, Common::Rect *clipRectPtr,
int32 wizFlags, const WizRawPixel *conversionTable,
WizImageCommand *optionalICmdPtr);
- void TRLEFLIP_Rotate90_DecompressImage(
+ void trleFLIPRotate90DecompressImage(
WizRawPixel *bufferPtr, const byte *compData, int bufferWidth, int bufferHeight,
int x, int y, int width, int height, const Common::Rect *clipRectPtr,
int32 wizFlags, const void *extraTable, const WizRawPixel *conversionTable,
WizImageCommand *optionalICmdPtr);
- void TRLEFLIP_90_DegreeRotateCore(
+ void trleFLIP90DegreeRotateCore(
WizSimpleBitmap *dstBitmap, int x, int y, const COMPRESSEDIMAGE *imagePtr, const Common::Rect *optionalSrcRect,
const Common::Rect *optionalClipRect, bool hFlip, bool vFlip, const void *userParam, const WizRawPixel *conversionTable,
void (*functionPtr)(Wiz *wiz,
@@ -859,48 +859,48 @@ public:
int decompAmount, const void *userParam, int destStepValue,
const WizRawPixel *conversionTable));
- void TRLEFLIP_CheckAlphaSetup();
- WizRawPixel TRLEFLIP_AlphaMixPrim(WizRawPixel b, WizRawPixel a, int alpha);
- void TRLEFLIP_50_50_Mix_PixelMemset(WizRawPixel *dstPtr, WizRawPixel mixColor, int size);
- void TRLEFLIP_50_50_Mix_ForwardPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable);
- void TRLEFLIP_50_50_Mix_BackwardsPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable);
- void TRLEFLIP_ADDITIVE_PixelMemset(WizRawPixel *dstPtr, WizRawPixel mixColor, int size);
- void TRLEFLIP_ADDITIVE_ForwardPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable);
- void TRLEFLIP_ADDITIVE_BackwardsPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable);
- void TRLEFLIP_SUBTRACTIVE_PixelMemset(WizRawPixel *dstPtr, WizRawPixel mixColor, int size);
- void TRLEFLIP_SUBTRACTIVE_ForwardPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable);
- void TRLEFLIP_SUBTRACTIVE_BackwardsPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable);
- void TRLEFLIP_RemapDestPixels(WizRawPixel *dstPtr, int size, const byte *lookupTable);
- void TRLEFLIP_ForwardPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable);
- void TRLEFLIP_BackwardsPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable);
- void TRLEFLIP_ForewordLookupPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const byte *lookupTable, const WizRawPixel *conversionTable);
- void TRLEFLIP_BackwardsLookupPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const byte *lookupTable, const WizRawPixel *conversionTable);
- void TRLEFLIP_ForewordMixColorsPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const byte *lookupTable);
- void TRLEFLIP_BackwardsMixColorsPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const byte *lookupTable);
+ void trleFLIPCheckAlphaSetup();
+ WizRawPixel trleFLIPAlphaMixPrim(WizRawPixel b, WizRawPixel a, int alpha);
+ void trleFLIPFiftyFiftyMixPixelMemset(WizRawPixel *dstPtr, WizRawPixel mixColor, int size);
+ void trleFLIPFiftyFiftyMixForwardPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable);
+ void trleFLIPFiftyFiftyMixBackwardsPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable);
+ void trleFLIPADDITIVEPixelMemset(WizRawPixel *dstPtr, WizRawPixel mixColor, int size);
+ void trleFLIPADDITIVEForwardPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable);
+ void trleFLIPADDITIVEBackwardsPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable);
+ void trleFLIPSUBTRACTIVEPixelMemset(WizRawPixel *dstPtr, WizRawPixel mixColor, int size);
+ void trleFLIPSUBTRACTIVEForwardPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable);
+ void trleFLIPSUBTRACTIVEBackwardsPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable);
+ void trleFLIPRemapDestPixels(WizRawPixel *dstPtr, int size, const byte *lookupTable);
+ void trleFLIPForwardPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable);
+ void trleFLIPBackwardsPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable);
+ void trleFLIPForewordLookupPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const byte *lookupTable, const WizRawPixel *conversionTable);
+ void trleFLIPBackwardsLookupPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const byte *lookupTable, const WizRawPixel *conversionTable);
+ void trleFLIPForewordMixColorsPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const byte *lookupTable);
+ void trleFLIPBackwardsMixColorsPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const byte *lookupTable);
/*
* Image Warping on Polygons Primitives
*/
- bool WARPWIZ_DrawWiz(int image, int state, int polygon, int32 flags, int transparentColor, WizSimpleBitmap *optionalDestBitmap, const WizRawPixel *optionalColorConversionTable, int shadowImage);
- bool WARPWIZ_DrawWizTo4Points(int image, int state, const WarpWizPoint *dstPoints, int32 flags, int transparentColor, const Common::Rect *optionalClipRect, WizSimpleBitmap *optionalDestBitmap, const WizRawPixel *optionalColorConversionTable, byte *colorMixTable);
- WarpWizOneSpanTable *WARPWIZ_CreateSpanTable(int spanCount);
- void WARPWIZ_DestroySpanTable(WarpWizOneSpanTable *spanTable);
- WarpWizOneSpanTable *WARPWIZ_BuildSpanTable(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizPoint *dstPts, const WarpWizPoint *srcPts, int npoints, const Common::Rect *clipRectPtr);
- void WARPWIZ_ProcessDrawSpansA(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizOneDrawSpan *drawSpans, int count);
- void WARPWIZ_ProcessDrawSpansTransparent(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizOneDrawSpan *drawSpans, int count, WizRawPixel transparentColor);
- void WARPWIZ_ProcessDrawSpansTransparentFiltered(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizOneDrawSpan *drawSpans, int count, WizRawPixel transparentColor, byte *pXmapColorTable, bool bIsHintColor, WizRawPixel hintColor);
- void WARPWIZ_ProcessDrawSpansMixColors(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizOneDrawSpan *drawSpans, int count, WizRawPixel transparentColor, byte *tablePtr);
- void WARPWIZ_FillSpanWithLine(WarpWizOneSpanTable *st, const WarpWizPoint *dstA, const WarpWizPoint *dstB, const WarpWizPoint *srcA, const WarpWizPoint *srcB);
- void WARPWIZ_ProcessDrawSpans_Sampled(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizOneDrawSpan *drawSpans, int count);
- void WARPWIZ_ProcessDrawSpansTransparent_Sampled(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap,const WarpWizOneDrawSpan *drawSpans, int count, WizRawPixel transparentColor);
- bool WARPWIZ_NPt2NPtWarp_CORE(WizSimpleBitmap *dstBitmap, const WarpWizPoint *dstpoints, const WizSimpleBitmap *srcBitmap, const WarpWizPoint *srcpoints, int npoints, int transparentColor, const Common::Rect *optionalClipRect, int32 wizFlags);
- bool WARPWIZ_NPt2NPtNonClippedWarp(WizSimpleBitmap *dstBitmap, const WarpWizPoint *dstpoints, const WizSimpleBitmap *srcBitmap, const WarpWizPoint *srcpoints, int npoints, int transparentColor);
- bool WARPWIZ_NPt2NPtClippedWarp(WizSimpleBitmap *dstBitmap, const WarpWizPoint *dstpoints, const WizSimpleBitmap *srcBitmap, const WarpWizPoint *srcpoints, int npoints, int transparentColor, const Common::Rect *optionalClipRect);
- bool WARPWIZ_NPt2NPtClippedWarpMixColors(WizSimpleBitmap *dstBitmap, const WarpWizPoint *dstpoints, const WizSimpleBitmap *srcBitmap, const WarpWizPoint *srcpoints, int npoints, int transparentColor, const Common::Rect *optionalClipRect, byte *colorMixTable);
- bool WARPWIZ_NPt2NPtNonClippedWarpFiltered(WizSimpleBitmap *dstBitmap, const WarpWizPoint *dstpoints, const WizSimpleBitmap *srcBitmap, const WarpWizPoint *srcpoints, int npoints, int transparentColor, byte *pXmapColorTable, bool bIsHintColor, WizRawPixel hintColor);
- void WARPWIZ_FindMinMaxpoints(WarpWizPoint *minPtr, WarpWizPoint *maxPtr, const WarpWizPoint *points, int npoints);
+ bool warpDrawWiz(int image, int state, int polygon, int32 flags, int transparentColor, WizSimpleBitmap *optionalDestBitmap, const WizRawPixel *optionalColorConversionTable, int shadowImage);
+ bool warpDrawWizTo4Points(int image, int state, const WarpWizPoint *dstPoints, int32 flags, int transparentColor, const Common::Rect *optionalClipRect, WizSimpleBitmap *optionalDestBitmap, const WizRawPixel *optionalColorConversionTable, byte *colorMixTable);
+ WarpWizOneSpanTable *warpCreateSpanTable(int spanCount);
+ void warpDestroySpanTable(WarpWizOneSpanTable *spanTable);
+ WarpWizOneSpanTable *warpBuildSpanTable(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizPoint *dstPts, const WarpWizPoint *srcPts, int npoints, const Common::Rect *clipRectPtr);
+ void warpProcessDrawSpansA(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizOneDrawSpan *drawSpans, int count);
+ void warpProcessDrawSpansTransparent(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizOneDrawSpan *drawSpans, int count, WizRawPixel transparentColor);
+ void warpProcessDrawSpansTransparentFiltered(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizOneDrawSpan *drawSpans, int count, WizRawPixel transparentColor, byte *pXmapColorTable, bool bIsHintColor, WizRawPixel hintColor);
+ void warpProcessDrawSpansMixColors(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizOneDrawSpan *drawSpans, int count, WizRawPixel transparentColor, byte *tablePtr);
+ void warpFillSpanWithLine(WarpWizOneSpanTable *st, const WarpWizPoint *dstA, const WarpWizPoint *dstB, const WarpWizPoint *srcA, const WarpWizPoint *srcB);
+ void warpProcessDrawSpansSampled(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizOneDrawSpan *drawSpans, int count);
+ void warpProcessDrawSpansTransparentSampled(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap,const WarpWizOneDrawSpan *drawSpans, int count, WizRawPixel transparentColor);
+ bool warpNPt2NPtWarpCORE(WizSimpleBitmap *dstBitmap, const WarpWizPoint *dstpoints, const WizSimpleBitmap *srcBitmap, const WarpWizPoint *srcpoints, int npoints, int transparentColor, const Common::Rect *optionalClipRect, int32 wizFlags);
+ bool warpNPt2NPtNonClippedWarp(WizSimpleBitmap *dstBitmap, const WarpWizPoint *dstpoints, const WizSimpleBitmap *srcBitmap, const WarpWizPoint *srcpoints, int npoints, int transparentColor);
+ bool warpNPt2NPtClippedWarp(WizSimpleBitmap *dstBitmap, const WarpWizPoint *dstpoints, const WizSimpleBitmap *srcBitmap, const WarpWizPoint *srcpoints, int npoints, int transparentColor, const Common::Rect *optionalClipRect);
+ bool warpNPt2NPtClippedWarpMixColors(WizSimpleBitmap *dstBitmap, const WarpWizPoint *dstpoints, const WizSimpleBitmap *srcBitmap, const WarpWizPoint *srcpoints, int npoints, int transparentColor, const Common::Rect *optionalClipRect, byte *colorMixTable);
+ bool warpNPt2NPtNonClippedWarpFiltered(WizSimpleBitmap *dstBitmap, const WarpWizPoint *dstpoints, const WizSimpleBitmap *srcBitmap, const WarpWizPoint *srcpoints, int npoints, int transparentColor, byte *pXmapColorTable, bool bIsHintColor, WizRawPixel hintColor);
+ void warpFindMinMaxpoints(WarpWizPoint *minPtr, WarpWizPoint *maxPtr, const WarpWizPoint *points, int npoints);
};
} // End of namespace Scumm
diff --git a/engines/scumm/he/wizwarp_he.cpp b/engines/scumm/he/wizwarp_he.cpp
index e4a939a119e..b281bf9d5b3 100644
--- a/engines/scumm/he/wizwarp_he.cpp
+++ b/engines/scumm/he/wizwarp_he.cpp
@@ -34,7 +34,7 @@ namespace Scumm {
#define WARP_TO_FRAC(_x_) ((_x_) << (WARP_FRAC_SIZE))
#define WARP_FROM_FRAC(_x_) ((_x_) >> (WARP_FRAC_SIZE))
-bool Wiz::WARPWIZ_DrawWiz(int image, int state, int polygon, int32 flags, int transparentColor, WizSimpleBitmap *optionalDestBitmap, const WizRawPixel *optionalColorConversionTable, int shadowImage) {
+bool Wiz::warpDrawWiz(int image, int state, int polygon, int32 flags, int transparentColor, WizSimpleBitmap *optionalDestBitmap, const WizRawPixel *optionalColorConversionTable, int shadowImage) {
byte *xmapColorTable;
int polyIndex;
@@ -71,12 +71,12 @@ bool Wiz::WARPWIZ_DrawWiz(int image, int state, int polygon, int32 flags, int tr
polypoints[i] = tmp;
}
- return WARPWIZ_DrawWizTo4Points(
+ return warpDrawWizTo4Points(
image, state, polypoints, flags, transparentColor,
nullptr, optionalDestBitmap, optionalColorConversionTable, xmapColorTable);
}
-bool Wiz::WARPWIZ_DrawWizTo4Points(int image, int state, const WarpWizPoint *dstPoints, int32 flags, int transparentColor, const Common::Rect *optionalClipRect, WizSimpleBitmap *optionalDestBitmap, const WizRawPixel *optionalColorConversionTable, byte *colorMixTable) {
+bool Wiz::warpDrawWizTo4Points(int image, int state, const WarpWizPoint *dstPoints, int32 flags, int transparentColor, const Common::Rect *optionalClipRect, WizSimpleBitmap *optionalDestBitmap, const WizRawPixel *optionalColorConversionTable, byte *colorMixTable) {
WizSimpleBitmap dstBitmap, srcBitmap;
bool rValue, freeBitmapBits;
Common::Rect updateRect;
@@ -173,21 +173,21 @@ bool Wiz::WARPWIZ_DrawWizTo4Points(int image, int state, const WarpWizPoint *dst
// Call the warping primitive!
if (colorMixTable) {
- rValue = WARPWIZ_NPt2NPtClippedWarpMixColors(
+ rValue = warpNPt2NPtClippedWarpMixColors(
&dstBitmap, dstPoints, &srcBitmap, srcPoints, 4, transparentColor,
optionalClipRect, colorMixTable);
} else {
if (_vm->_game.heversion >= 99) { // TODO: Recheck!! Code valid for executables from 3/14/2000 onwards
- rValue = WARPWIZ_NPt2NPtWarp_CORE(
+ rValue = warpNPt2NPtWarpCORE(
&dstBitmap, dstPoints, &srcBitmap, srcPoints,
4, transparentColor, optionalClipRect, flags);
} else {
if (optionalClipRect) {
- rValue = WARPWIZ_NPt2NPtClippedWarp(
+ rValue = warpNPt2NPtClippedWarp(
&dstBitmap, dstPoints, &srcBitmap, srcPoints, 4, transparentColor,
optionalClipRect);
} else {
- rValue = WARPWIZ_NPt2NPtNonClippedWarp(
+ rValue = warpNPt2NPtNonClippedWarp(
&dstBitmap, dstPoints, &srcBitmap, srcPoints, 4, transparentColor);
}
}
@@ -212,7 +212,7 @@ bool Wiz::WARPWIZ_DrawWizTo4Points(int image, int state, const WarpWizPoint *dst
return rValue;
}
-WarpWizOneSpanTable *Wiz::WARPWIZ_CreateSpanTable(int spanCount) {
+WarpWizOneSpanTable *Wiz::warpCreateSpanTable(int spanCount) {
WarpWizOneSpanTable *spanTable;
WarpWizOneSpan *spanPtr;
int counter;
@@ -225,7 +225,7 @@ WarpWizOneSpanTable *Wiz::WARPWIZ_CreateSpanTable(int spanCount) {
spanTable->spanCount = spanCount;
spanTable->spans = (WarpWizOneSpan *)malloc(spanCount * sizeof(WarpWizOneSpan));
if (!spanTable->spans) {
- WARPWIZ_DestroySpanTable(spanTable);
+ warpDestroySpanTable(spanTable);
return nullptr;
}
@@ -238,14 +238,14 @@ WarpWizOneSpanTable *Wiz::WARPWIZ_CreateSpanTable(int spanCount) {
spanTable->drawSpans = (WarpWizOneDrawSpan *)malloc(spanCount * sizeof(WarpWizOneDrawSpan));
if (!spanTable->drawSpans) {
- WARPWIZ_DestroySpanTable(spanTable);
+ warpDestroySpanTable(spanTable);
return nullptr;
}
return spanTable;
}
-void Wiz::WARPWIZ_DestroySpanTable(WarpWizOneSpanTable *spanTable) {
+void Wiz::warpDestroySpanTable(WarpWizOneSpanTable *spanTable) {
if (spanTable->drawSpans) {
free(spanTable->drawSpans);
spanTable->drawSpans = nullptr;
@@ -260,7 +260,7 @@ void Wiz::WARPWIZ_DestroySpanTable(WarpWizOneSpanTable *spanTable) {
spanTable = nullptr;
}
-WarpWizOneSpanTable *Wiz::WARPWIZ_BuildSpanTable(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizPoint *dstPts, const WarpWizPoint *srcPts, int npoints, const Common::Rect *clipRectPtr) {
+WarpWizOneSpanTable *Wiz::warpBuildSpanTable(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizPoint *dstPts, const WarpWizPoint *srcPts, int npoints, const Common::Rect *clipRectPtr) {
int offset, dw, sw, nonClippedWidth, maxOffset, cl, cr, cy, dl, cw;
WarpWizPoint srcPt, dstPt, dstMinPt, dstMaxPt, srcMinPt, srcMaxPt, clippedPt;
WarpWizOneDrawSpan *drawSpan;
@@ -283,10 +283,10 @@ WarpWizOneSpanTable *Wiz::WARPWIZ_BuildSpanTable(WizSimpleBitmap *dstBitmap, con
}
// Find the span table fun parts...
- WARPWIZ_FindMinMaxpoints(&dstMinPt, &dstMaxPt, dstPts, npoints);
- WARPWIZ_FindMinMaxpoints(&srcMinPt, &srcMaxPt, srcPts, npoints);
+ warpFindMinMaxpoints(&dstMinPt, &dstMaxPt, dstPts, npoints);
+ warpFindMinMaxpoints(&srcMinPt, &srcMaxPt, srcPts, npoints);
- st = WARPWIZ_CreateSpanTable((dstMaxPt.y - dstMinPt.y) + 1);
+ st = warpCreateSpanTable((dstMaxPt.y - dstMinPt.y) + 1);
if (!st) {
return nullptr;
}
@@ -301,12 +301,12 @@ WarpWizOneSpanTable *Wiz::WARPWIZ_BuildSpanTable(WizSimpleBitmap *dstBitmap, con
// Scan convert the polygon...
for (int i = 1; i < npoints; i++) {
- WARPWIZ_FillSpanWithLine(st, dstPts, dstPts + 1, srcPts, srcPts + 1);
+ warpFillSpanWithLine(st, dstPts, dstPts + 1, srcPts, srcPts + 1);
dstPts++;
srcPts++;
}
- WARPWIZ_FillSpanWithLine(st, dstPts, &dstPt, srcPts, &srcPt);
+ warpFillSpanWithLine(st, dstPts, &dstPt, srcPts, &srcPt);
// Build the draw span table!
drawSpan = st->drawSpans;
@@ -359,7 +359,7 @@ WarpWizOneSpanTable *Wiz::WARPWIZ_BuildSpanTable(WizSimpleBitmap *dstBitmap, con
return st;
}
-void Wiz::WARPWIZ_FindMinMaxpoints(WarpWizPoint *minPtr, WarpWizPoint *maxPtr, const WarpWizPoint *points, int npoints) {
+void Wiz::warpFindMinMaxpoints(WarpWizPoint *minPtr, WarpWizPoint *maxPtr, const WarpWizPoint *points, int npoints) {
WarpWizPoint minPt, maxPt, pt;
// Find the limits...
@@ -392,7 +392,7 @@ void Wiz::WARPWIZ_FindMinMaxpoints(WarpWizPoint *minPtr, WarpWizPoint *maxPtr, c
*maxPtr = maxPt;
}
-void Wiz::WARPWIZ_ProcessDrawSpansA(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizOneDrawSpan *drawSpans, int count) {
+void Wiz::warpProcessDrawSpansA(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizOneDrawSpan *drawSpans, int count) {
int xStep, yStep, sw, xOffset, yOffset;
const WizRawPixel8 *src8;
@@ -435,7 +435,7 @@ void Wiz::WARPWIZ_ProcessDrawSpansA(WizSimpleBitmap *dstBitmap, const WizSimpleB
}
}
-void Wiz::WARPWIZ_ProcessDrawSpansTransparent(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizOneDrawSpan *drawSpans, int count, WizRawPixel transparentColor) {
+void Wiz::warpProcessDrawSpansTransparent(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizOneDrawSpan *drawSpans, int count, WizRawPixel transparentColor) {
int xStep, yStep, sw, xOffset, yOffset;
const WizRawPixel8 *src8 = (WizRawPixel8 *)srcBitmap->bufferPtr;
@@ -487,7 +487,7 @@ void Wiz::WARPWIZ_ProcessDrawSpansTransparent(WizSimpleBitmap *dstBitmap, const
}
}
-void Wiz::WARPWIZ_ProcessDrawSpansTransparentFiltered(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizOneDrawSpan *drawSpans, int count, WizRawPixel transparentColor, byte *pXmapColorTable, bool bIsHintColor, WizRawPixel hintColor) {
+void Wiz::warpProcessDrawSpansTransparentFiltered(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizOneDrawSpan *drawSpans, int count, WizRawPixel transparentColor, byte *pXmapColorTable, bool bIsHintColor, WizRawPixel hintColor) {
int srcWidth = srcBitmap->bitmapWidth;
const WizRawPixel8 *src8 = (WizRawPixel8 *)srcBitmap->bufferPtr;
@@ -709,7 +709,7 @@ void Wiz::WARPWIZ_ProcessDrawSpansTransparentFiltered(WizSimpleBitmap *dstBitmap
}
}
-void Wiz::WARPWIZ_ProcessDrawSpansMixColors(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizOneDrawSpan *drawSpans, int count, WizRawPixel transparentColor, byte *tablePtr) {
+void Wiz::warpProcessDrawSpansMixColors(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizOneDrawSpan *drawSpans, int count, WizRawPixel transparentColor, byte *tablePtr) {
int xStep, yStep, sw, xOffset, yOffset;
WizRawPixel srcColor;
@@ -757,7 +757,7 @@ void Wiz::WARPWIZ_ProcessDrawSpansMixColors(WizSimpleBitmap *dstBitmap, const Wi
}
}
-void Wiz::WARPWIZ_FillSpanWithLine(WarpWizOneSpanTable *st, const WarpWizPoint *dstA, const WarpWizPoint *dstB, const WarpWizPoint *srcA, const WarpWizPoint *srcB) {
+void Wiz::warpFillSpanWithLine(WarpWizOneSpanTable *st, const WarpWizPoint *dstA, const WarpWizPoint *dstB, const WarpWizPoint *srcA, const WarpWizPoint *srcB) {
WarpWizPoint dstStep, srcStep, dstPt, srcPt, dpt, spt;
int h, lx1, ly1, lx2, ly2;
WarpWizOneSpan *spanPtr;
@@ -814,7 +814,7 @@ void Wiz::WARPWIZ_FillSpanWithLine(WarpWizOneSpanTable *st, const WarpWizPoint *
}
}
-void Wiz::WARPWIZ_ProcessDrawSpans_Sampled(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizOneDrawSpan *drawSpans, int count) {
+void Wiz::warpProcessDrawSpansSampled(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizOneDrawSpan *drawSpans, int count) {
// Setup read pointer and clipping limits for the sampling rect
const WizRawPixel8 *src8 = (WizRawPixel8 *)srcBitmap->bufferPtr;
const WizRawPixel16 *src16 = (WizRawPixel16 *)srcBitmap->bufferPtr;
@@ -927,7 +927,7 @@ void Wiz::WARPWIZ_ProcessDrawSpans_Sampled(WizSimpleBitmap *dstBitmap, const Wiz
}
}
-void Wiz::WARPWIZ_ProcessDrawSpansTransparent_Sampled(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizOneDrawSpan *drawSpans, int count, WizRawPixel transparentColor) {
+void Wiz::warpProcessDrawSpansTransparentSampled(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizOneDrawSpan *drawSpans, int count, WizRawPixel transparentColor) {
// Setup read pointer and clipping limits for the sampling rect
const WizRawPixel8 *src8 = (WizRawPixel8 *)srcBitmap->bufferPtr;
const WizRawPixel16 *src16 = (WizRawPixel16 *)srcBitmap->bufferPtr;
@@ -1081,7 +1081,7 @@ void Wiz::WARPWIZ_ProcessDrawSpansTransparent_Sampled(WizSimpleBitmap *dstBitmap
}
}
-bool Wiz::WARPWIZ_NPt2NPtWarp_CORE(WizSimpleBitmap *dstBitmap, const WarpWizPoint *dstpoints, const WizSimpleBitmap *srcBitmap, const WarpWizPoint *srcpoints, int npoints, int transparentColor, const Common::Rect *optionalClipRect, int32 wizFlags) {
+bool Wiz::warpNPt2NPtWarpCORE(WizSimpleBitmap *dstBitmap, const WarpWizPoint *dstpoints, const WizSimpleBitmap *srcBitmap, const WarpWizPoint *srcpoints, int npoints, int transparentColor, const Common::Rect *optionalClipRect, int32 wizFlags) {
WarpWizOneSpanTable *st;
if ((srcBitmap->bitmapWidth >= WARP_TEXTURE_LIMIT) || (srcBitmap->bitmapHeight >= WARP_TEXTURE_LIMIT)) {
@@ -1090,32 +1090,32 @@ bool Wiz::WARPWIZ_NPt2NPtWarp_CORE(WizSimpleBitmap *dstBitmap, const WarpWizPoin
WARP_TEXTURE_LIMIT, WARP_TEXTURE_LIMIT);
}
- st = WARPWIZ_BuildSpanTable(dstBitmap, srcBitmap, dstpoints, srcpoints, npoints, optionalClipRect);
+ st = warpBuildSpanTable(dstBitmap, srcBitmap, dstpoints, srcpoints, npoints, optionalClipRect);
if (st) {
if (st->drawSpanCount) {
if (transparentColor != -1) {
if (wizFlags & kWRFAreaSampleDuringWarp) {
- WARPWIZ_ProcessDrawSpansTransparent_Sampled(
+ warpProcessDrawSpansTransparentSampled(
dstBitmap, srcBitmap, st->drawSpans, st->drawSpanCount,
(WizRawPixel)transparentColor);
} else {
- WARPWIZ_ProcessDrawSpansTransparent(
+ warpProcessDrawSpansTransparent(
dstBitmap, srcBitmap, st->drawSpans, st->drawSpanCount,
(WizRawPixel)transparentColor);
}
} else {
if (wizFlags & kWRFAreaSampleDuringWarp) {
- WARPWIZ_ProcessDrawSpans_Sampled(
+ warpProcessDrawSpansSampled(
dstBitmap, srcBitmap, st->drawSpans, st->drawSpanCount);
} else {
- WARPWIZ_ProcessDrawSpansA(
+ warpProcessDrawSpansA(
dstBitmap, srcBitmap, st->drawSpans, st->drawSpanCount);
}
}
}
- WARPWIZ_DestroySpanTable(st);
+ warpDestroySpanTable(st);
return true;
}
@@ -1123,9 +1123,9 @@ bool Wiz::WARPWIZ_NPt2NPtWarp_CORE(WizSimpleBitmap *dstBitmap, const WarpWizPoin
return false;
}
-bool Wiz::WARPWIZ_NPt2NPtNonClippedWarp(WizSimpleBitmap *dstBitmap, const WarpWizPoint *dstpoints, const WizSimpleBitmap *srcBitmap, const WarpWizPoint *srcpoints, int npoints, int transparentColor) {
+bool Wiz::warpNPt2NPtNonClippedWarp(WizSimpleBitmap *dstBitmap, const WarpWizPoint *dstpoints, const WizSimpleBitmap *srcBitmap, const WarpWizPoint *srcpoints, int npoints, int transparentColor) {
if (_vm->_game.heversion > 99) {
- return WARPWIZ_NPt2NPtWarp_CORE(
+ return warpNPt2NPtWarpCORE(
dstBitmap, dstpoints, srcBitmap, srcpoints,
npoints, transparentColor, nullptr, 0);
} else {
@@ -1137,20 +1137,20 @@ bool Wiz::WARPWIZ_NPt2NPtNonClippedWarp(WizSimpleBitmap *dstBitmap, const WarpWi
WARP_TEXTURE_LIMIT, WARP_TEXTURE_LIMIT);
}
- st = WARPWIZ_BuildSpanTable(dstBitmap, srcBitmap, dstpoints, srcpoints, npoints, nullptr);
+ st = warpBuildSpanTable(dstBitmap, srcBitmap, dstpoints, srcpoints, npoints, nullptr);
if (st) {
if (st->drawSpanCount) {
if (transparentColor != -1) {
- WARPWIZ_ProcessDrawSpansTransparent(
+ warpProcessDrawSpansTransparent(
dstBitmap, srcBitmap, st->drawSpans, st->drawSpanCount,
(WizRawPixel)transparentColor);
} else {
- WARPWIZ_ProcessDrawSpansA(dstBitmap, srcBitmap, st->drawSpans, st->drawSpanCount);
+ warpProcessDrawSpansA(dstBitmap, srcBitmap, st->drawSpans, st->drawSpanCount);
}
}
- WARPWIZ_DestroySpanTable(st);
+ warpDestroySpanTable(st);
return true;
} else {
@@ -1160,9 +1160,9 @@ bool Wiz::WARPWIZ_NPt2NPtNonClippedWarp(WizSimpleBitmap *dstBitmap, const WarpWi
}
}
-bool Wiz::WARPWIZ_NPt2NPtClippedWarp(WizSimpleBitmap *dstBitmap, const WarpWizPoint *dstpoints, const WizSimpleBitmap *srcBitmap, const WarpWizPoint *srcpoints, int npoints, int transparentColor, const Common::Rect *optionalClipRect) {
+bool Wiz::warpNPt2NPtClippedWarp(WizSimpleBitmap *dstBitmap, const WarpWizPoint *dstpoints, const WizSimpleBitmap *srcBitmap, const WarpWizPoint *srcpoints, int npoints, int transparentColor, const Common::Rect *optionalClipRect) {
if (_vm->_game.heversion > 99) {
- return WARPWIZ_NPt2NPtWarp_CORE(
+ return warpNPt2NPtWarpCORE(
dstBitmap, dstpoints, srcBitmap, srcpoints,
npoints, transparentColor, nullptr, 0);
} else {
@@ -1174,20 +1174,20 @@ bool Wiz::WARPWIZ_NPt2NPtClippedWarp(WizSimpleBitmap *dstBitmap, const WarpWizPo
WARP_TEXTURE_LIMIT, WARP_TEXTURE_LIMIT);
}
- st = WARPWIZ_BuildSpanTable(dstBitmap, srcBitmap, dstpoints, srcpoints, npoints, optionalClipRect);
+ st = warpBuildSpanTable(dstBitmap, srcBitmap, dstpoints, srcpoints, npoints, optionalClipRect);
if (st) {
if (st->drawSpanCount) {
if (transparentColor != -1) {
- WARPWIZ_ProcessDrawSpansTransparent(
+ warpProcessDrawSpansTransparent(
dstBitmap, srcBitmap, st->drawSpans, st->drawSpanCount,
(WizRawPixel)transparentColor);
} else {
- WARPWIZ_ProcessDrawSpansA(dstBitmap, srcBitmap, st->drawSpans, st->drawSpanCount);
+ warpProcessDrawSpansA(dstBitmap, srcBitmap, st->drawSpans, st->drawSpanCount);
}
}
- WARPWIZ_DestroySpanTable(st);
+ warpDestroySpanTable(st);
return true;
} else {
warning("Unable to warp bitmap");
@@ -1196,7 +1196,7 @@ bool Wiz::WARPWIZ_NPt2NPtClippedWarp(WizSimpleBitmap *dstBitmap, const WarpWizPo
}
}
-bool Wiz::WARPWIZ_NPt2NPtClippedWarpMixColors(WizSimpleBitmap *dstBitmap, const WarpWizPoint *dstpoints, const WizSimpleBitmap *srcBitmap, const WarpWizPoint *srcpoints, int npoints, int transparentColor, const Common::Rect *optionalClipRect, byte *colorMixTable) {
+bool Wiz::warpNPt2NPtClippedWarpMixColors(WizSimpleBitmap *dstBitmap, const WarpWizPoint *dstpoints, const WizSimpleBitmap *srcBitmap, const WarpWizPoint *srcpoints, int npoints, int transparentColor, const Common::Rect *optionalClipRect, byte *colorMixTable) {
WarpWizOneSpanTable *st;
if ((srcBitmap->bitmapWidth >= WARP_TEXTURE_LIMIT) || (srcBitmap->bitmapHeight >= WARP_TEXTURE_LIMIT)) {
@@ -1205,17 +1205,17 @@ bool Wiz::WARPWIZ_NPt2NPtClippedWarpMixColors(WizSimpleBitmap *dstBitmap, const
WARP_TEXTURE_LIMIT, WARP_TEXTURE_LIMIT);
}
- st = WARPWIZ_BuildSpanTable(
+ st = warpBuildSpanTable(
dstBitmap, srcBitmap, dstpoints, srcpoints, npoints, optionalClipRect);
if (st) {
if (st->drawSpanCount) {
- WARPWIZ_ProcessDrawSpansMixColors(
+ warpProcessDrawSpansMixColors(
dstBitmap, srcBitmap, st->drawSpans, st->drawSpanCount,
transparentColor, colorMixTable);
}
- WARPWIZ_DestroySpanTable(st);
+ warpDestroySpanTable(st);
return true;
} else {
warning("Unable to warp bitmap");
@@ -1223,7 +1223,7 @@ bool Wiz::WARPWIZ_NPt2NPtClippedWarpMixColors(WizSimpleBitmap *dstBitmap, const
}
}
-bool Wiz::WARPWIZ_NPt2NPtNonClippedWarpFiltered(WizSimpleBitmap *dstBitmap, const WarpWizPoint *dstpoints, const WizSimpleBitmap *srcBitmap, const WarpWizPoint *srcpoints, int npoints, int transparentColor, byte *pXmapColorTable, bool bIsHintColor, WizRawPixel hintColor) {
+bool Wiz::warpNPt2NPtNonClippedWarpFiltered(WizSimpleBitmap *dstBitmap, const WarpWizPoint *dstpoints, const WizSimpleBitmap *srcBitmap, const WarpWizPoint *srcpoints, int npoints, int transparentColor, byte *pXmapColorTable, bool bIsHintColor, WizRawPixel hintColor) {
WarpWizOneSpanTable *st;
if ((srcBitmap->bitmapWidth >= WARP_TEXTURE_LIMIT) || (srcBitmap->bitmapHeight >= WARP_TEXTURE_LIMIT)) {
@@ -1232,15 +1232,15 @@ bool Wiz::WARPWIZ_NPt2NPtNonClippedWarpFiltered(WizSimpleBitmap *dstBitmap, cons
WARP_TEXTURE_LIMIT, WARP_TEXTURE_LIMIT);
}
- st = WARPWIZ_BuildSpanTable(dstBitmap, srcBitmap, dstpoints, srcpoints, npoints, 0);
+ st = warpBuildSpanTable(dstBitmap, srcBitmap, dstpoints, srcpoints, npoints, 0);
if (st) {
if (st->drawSpanCount) {
- WARPWIZ_ProcessDrawSpansTransparentFiltered(dstBitmap, srcBitmap, st->drawSpans,
+ warpProcessDrawSpansTransparentFiltered(dstBitmap, srcBitmap, st->drawSpans,
st->drawSpanCount,(WizRawPixel)transparentColor, pXmapColorTable, bIsHintColor, hintColor);
}
- WARPWIZ_DestroySpanTable(st);
+ warpDestroySpanTable(st);
return true;
} else {
Commit: c4cac1f14829d23a8708929b54bf67f8f909be41
https://github.com/scummvm/scummvm/commit/c4cac1f14829d23a8708929b54bf67f8f909be41
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Fix some transparency issues
Changed paths:
engines/scumm/he/sprite_he.cpp
engines/scumm/he/sprite_he.h
engines/scumm/he/wiz_he.cpp
diff --git a/engines/scumm/he/sprite_he.cpp b/engines/scumm/he/sprite_he.cpp
index e24ac60af97..4e921de6d2a 100644
--- a/engines/scumm/he/sprite_he.cpp
+++ b/engines/scumm/he/sprite_he.cpp
@@ -1638,6 +1638,8 @@ void Sprite::renderSprites(bool negativeOrPositiveRender) {
bool scaleSpecified;
Common::Point spot;
+ imageRenderCmd.reset();
+
spritePtr = _activeSprites;
for (int i = 0; i < _activeSpriteCount; i++) {
diff --git a/engines/scumm/he/sprite_he.h b/engines/scumm/he/sprite_he.h
index 7118bc07e6b..edf7d425651 100644
--- a/engines/scumm/he/sprite_he.h
+++ b/engines/scumm/he/sprite_he.h
@@ -237,7 +237,7 @@ public:
bool doesRectIntersectUpdateAreas(const Common::Rect *rectPtr);
void checkForForcedRedraws(bool checkOnlyPositivePriority);
void buildActiveSpriteList();
- void renderSprites(bool arg);
+ void renderSprites(bool negativeOrPositiveRender);
void runSpriteEngines();
int spriteFromPoint(int x, int y, int spriteGroupId, int d, int num, int *args);
diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp
index 2060bd6dbcc..fa2c461680b 100644
--- a/engines/scumm/he/wiz_he.cpp
+++ b/engines/scumm/he/wiz_he.cpp
@@ -770,89 +770,6 @@ int Wiz::hitTestWizPrim(int globNum, int state, int x, int y, int32 flags) {
}
}
-struct PolygonDrawData {
- struct PolygonArea {
- int32 xmin;
- int32 xmax;
- int32 x1;
- int32 y1;
- int32 x2;
- int32 y2;
- };
- struct ResultArea {
- int32 dst_offs;
- int32 x_step;
- int32 y_step;
- int32 x_s;
- int32 y_s;
- int32 w;
- };
- Common::Point mat[4];
- PolygonArea *pa;
- ResultArea *ra;
- int rAreasNum;
- int pAreasNum;
-
- PolygonDrawData(int n) {
- for (uint i = 0; i < ARRAYSIZE(mat); i++) {
- mat[i] = Common::Point();
- }
- pa = new PolygonArea[n];
- for (int i = 0; i < n; ++i) {
- pa[i].xmin = 0x7FFFFFFF;
- pa[i].xmax = 0x80000000;
- }
- ra = new ResultArea[n];
- rAreasNum = 0;
- pAreasNum = n;
- }
-
- ~PolygonDrawData() {
- delete[] pa;
- delete[] ra;
- }
-
- void transform(const Common::Point *tp1, const Common::Point *tp2, const Common::Point *sp1, const Common::Point *sp2) {
- int32 tx_acc = tp1->x * (1 << 16);
- int32 sx_acc = sp1->x * (1 << 16);
- int32 sy_acc = sp1->y * (1 << 16);
- uint16 dy = ABS(tp2->y - tp1->y) + 1;
- int32 tx_step = ((tp2->x - tp1->x) * (1 << 16)) / dy;
- int32 sx_step = ((sp2->x - sp1->x) * (1 << 16)) / dy;
- int32 sy_step = ((sp2->y - sp1->y) * (1 << 16)) / dy;
-
- int y = tp1->y - mat[0].y;
- while (dy--) {
- assert(y >= 0 && y < pAreasNum);
- PolygonArea *ppa = &pa[y];
- int32 ttx = tx_acc / (1 << 16);
- int32 tsx = sx_acc / (1 << 16);
- int32 tsy = sy_acc / (1 << 16);
-
- if (ppa->xmin > ttx) {
- ppa->xmin = ttx;
- ppa->x1 = tsx;
- ppa->y1 = tsy;
- }
- if (ppa->xmax < ttx) {
- ppa->xmax = ttx;
- ppa->x2 = tsx;
- ppa->y2 = tsy;
- }
-
- tx_acc += tx_step;
- sx_acc += sx_step;
- sy_acc += sy_step;
-
- if (tp2->y <= tp1->y) {
- --y;
- } else {
- ++y;
- }
- }
- }
-};
-
void Wiz::processWizImagePolyCaptureCmd(const WizImageCommand *params) {
int polygon1, polygon2, compressionType, srcImage = 0, shadow = 0, state = 0;
bool bIsHintColor = false;
@@ -1847,19 +1764,19 @@ int Wiz::dwGetImageGeneralProperty(int image, int state, int property) {
break;
case kWIPPaletteBlockPresent:
- return doesStateContainBlock(image, state, MKTAG('R', 'G', 'B', 'S'));
+ return doesStateContainBlock(image, state, MKTAG('R', 'G', 'B', 'S')) ? 1 : 0;
break;
case kWIPRemapBlockPresent:
- return doesStateContainBlock(image, state, MKTAG('R', 'M', 'A', 'P'));
+ return doesStateContainBlock(image, state, MKTAG('R', 'M', 'A', 'P')) ? 1 : 0;
break;
case kWIPOpaqueBlockPresent:
- return doesRawWizStateHaveTransparency(image, state);
+ return doesRawWizStateHaveTransparency(image, state) ? 1 : 0;
break;
case kWIPXMAPBlockPresent:
- return doesStateContainBlock(image, state, MKTAG('X', 'M', 'A', 'P'));
+ return doesStateContainBlock(image, state, MKTAG('X', 'M', 'A', 'P')) ? 1 : 0;
break;
default:
@@ -2779,7 +2696,8 @@ bool Wiz::doesRawWizStateHaveTransparency(int globNum, int state) {
byte *data = _vm->getResourceAddress(rtImage, globNum);
assert(data);
- return _vm->findWrappedBlock(MKTAG('T', 'R', 'N', 'S'), data, state, false) != nullptr;
+ // Yes, this has to return "true" if the block is not available :-)
+ return _vm->findWrappedBlock(MKTAG('T', 'R', 'N', 'S'), data, state, false) == nullptr;
}
bool Wiz::doesStateContainBlock(int globNum, int state, uint32 blockID) {
Commit: 0ae4143e6f81cd2fbf8f7cc8b6b561150333bd5c
https://github.com/scummvm/scummvm/commit/0ae4143e6f81cd2fbf8f7cc8b6b561150333bd5c
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Fix more 8-bit vs 16-bit discrepancies
Changed paths:
engines/scumm/he/gfx_primitives_he.cpp
engines/scumm/he/wiz_he.cpp
diff --git a/engines/scumm/he/gfx_primitives_he.cpp b/engines/scumm/he/gfx_primitives_he.cpp
index 3eb83157cc3..805ae32d30c 100644
--- a/engines/scumm/he/gfx_primitives_he.cpp
+++ b/engines/scumm/he/gfx_primitives_he.cpp
@@ -601,15 +601,20 @@ void Wiz::pgDrawRawDataFormatImage(WizRawPixel *bufferPtr, const WizRawPixel *ra
void Wiz::pgSimpleBlit(WizSimpleBitmap *destBM, Common::Rect *destRect, WizSimpleBitmap *sourceBM, Common::Rect *sourceRect) {
int cw, dw, sw, ch, cSize;
- WizRawPixel *s, *d;
+ WizRawPixel8 *s8, *d8;
+ WizRawPixel16 *s16, *d16;
// Common calcs...
dw = destBM->bitmapWidth;
sw = sourceBM->bitmapWidth;
cw = abs(sourceRect->right - sourceRect->left) + 1;
ch = abs(sourceRect->bottom - sourceRect->top) + 1;
- d = destBM->bufferPtr + destRect->top * dw + destRect->left;
- s = sourceBM->bufferPtr + sourceRect->top * sw + sourceRect->left;
+
+ d8 = ((WizRawPixel8 *)destBM->bufferPtr) + destRect->top * dw + destRect->left;
+ s8 = ((WizRawPixel8 *)sourceBM->bufferPtr) + sourceRect->top * sw + sourceRect->left;
+ d16 = ((WizRawPixel16 *)destBM->bufferPtr) + destRect->top * dw + destRect->left;
+ s16 = ((WizRawPixel16 *)sourceBM->bufferPtr) + sourceRect->top * sw + sourceRect->left;
+
// Going up or down?
if (sourceRect->top > sourceRect->bottom) {
@@ -621,22 +626,38 @@ void Wiz::pgSimpleBlit(WizSimpleBitmap *destBM, Common::Rect *destRect, WizSimpl
cSize = (cw * sizeof(WizRawPixel));
while (--ch >= 0) {
- memcpy(d, s, cSize); // TODO
+ if (!_uses16BitColor) {
+ memcpy(d8, s8, cSize);
- d += dw;
- s += sw;
+ d8 += dw;
+ s8 += sw;
+ } else {
+ memcpy(d16, s16, cSize);
+
+ d16 += dw;
+ s16 += sw;
+ }
}
} else {
dw -= cw;
sw += cw;
while (--ch >= 0) {
- for (int i = cw; --i >= 0;) {
- *d++ = *s--;
- }
+ if (!_uses16BitColor) {
+ for (int i = cw; --i >= 0;) {
+ *d8++ = *s8--;
+ }
- d += dw;
- s += sw;
+ d8 += dw;
+ s8 += sw;
+ } else {
+ for (int i = cw; --i >= 0;) {
+ *d16++ = *s16--;
+ }
+
+ d16 += dw;
+ s16 += sw;
+ }
}
}
}
@@ -795,15 +816,19 @@ void Wiz::pgSimpleBlitTransparentMixColors(WizSimpleBitmap *destBM, Common::Rect
void Wiz::pgTransparentSimpleBlit(WizSimpleBitmap *destBM, Common::Rect *destRect, WizSimpleBitmap *sourceBM, Common::Rect *sourceRect, WizRawPixel transparentColor) {
int value, cw, dw, sw, ch, soff, doff, tColor;
- WizRawPixel *s, *d;
+ WizRawPixel8 *s8, *d8;
+ WizRawPixel16 *s16, *d16;
// Common calcs...
dw = destBM->bitmapWidth;
sw = sourceBM->bitmapWidth;
cw = abs(sourceRect->right - sourceRect->left) + 1;
ch = abs(sourceRect->bottom - sourceRect->top) + 1;
- d = destBM->bufferPtr + destRect->top * dw + destRect->left;
- s = sourceBM->bufferPtr + sourceRect->top * sw + sourceRect->left;
+
+ d8 = ((WizRawPixel8 *)destBM->bufferPtr) + destRect->top * dw + destRect->left;
+ s8 = ((WizRawPixel8 *)sourceBM->bufferPtr) + sourceRect->top * sw + sourceRect->left;
+ d16 = ((WizRawPixel16 *)destBM->bufferPtr) + destRect->top * dw + destRect->left;
+ s16 = ((WizRawPixel16 *)sourceBM->bufferPtr) + sourceRect->top * sw + sourceRect->left;
tColor = (int)transparentColor;
@@ -818,18 +843,34 @@ void Wiz::pgTransparentSimpleBlit(WizSimpleBitmap *destBM, Common::Rect *destRec
doff = dw - cw;
while (--ch >= 0) {
- for (int x = cw; --x >= 0;) {
- value = *s++;
+ if (!_uses16BitColor) {
+ for (int x = cw; --x >= 0;) {
+ value = *s8++;
+
+ if (value != tColor) {
+ *d8++ = (WizRawPixel8)value;
+ } else {
+ d8++;
+ }
+ }
- if (value != tColor) {
- *d++ = value;
- } else {
- d++;
+ s8 += soff;
+ d8 += doff;
+ } else {
+ for (int x = cw; --x >= 0;) {
+ value = *s16++;
+
+ if (value != tColor) {
+ *d16++ = (WizRawPixel16)value;
+ } else {
+ d16++;
+ }
}
+
+ s16 += soff;
+ d16 += doff;
}
- s += soff;
- d += doff;
}
} else {
@@ -837,18 +878,33 @@ void Wiz::pgTransparentSimpleBlit(WizSimpleBitmap *destBM, Common::Rect *destRec
doff = dw - cw;
while (--ch >= 0) {
- for (int x = cw; --x >= 0;) {
- value = *s--;
+ if (!_uses16BitColor) {
+ for (int x = cw; --x >= 0;) {
+ value = *s8--;
+
+ if (value != tColor) {
+ *d8++ = (WizRawPixel8)value;
+ } else {
+ d8++;
+ }
+ }
- if (value != tColor) {
- *d++ = value;
- } else {
- d++;
+ s8 += soff;
+ d8 += doff;
+ } else {
+ for (int x = cw; --x >= 0;) {
+ value = *s16--;
+
+ if (value != tColor) {
+ *d16++ = (WizRawPixel16)value;
+ } else {
+ d16++;
+ }
}
- }
- s += soff;
- d += doff;
+ s16 += soff;
+ d16 += doff;
+ }
}
}
}
diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp
index fa2c461680b..939525d3472 100644
--- a/engines/scumm/he/wiz_he.cpp
+++ b/engines/scumm/he/wiz_he.cpp
@@ -413,8 +413,7 @@ void *Wiz::drawAWizPrimEx(int globNum, int state, int x, int y, int z, int shado
transColorOverride = -1;
}
- if (_uses16BitColor) {
- if (src_c != kWCTNone16Bpp && src_c != kWCTNone16BppBigEndian) {
+ if (_uses16BitColor && src_c != kWCTNone16Bpp && src_c != kWCTNone16BppBigEndian) {
if (src_c == kWCTNone) {
pgDraw8BppFormatImage(
dest_p, (byte *)(src_d + _vm->_resourceHeaderSize), dest_w, dest_h,
@@ -423,12 +422,6 @@ void *Wiz::drawAWizPrimEx(int globNum, int state, int x, int y, int z, int shado
} else {
error("Wiz::drawAWizPrimEx(): Raw data type mismatch for mode %d vs %d", src_c, kWCTNone16Bpp);
}
- } else {
- // Use the native transfer function
- pgDrawRawDataFormatImage(
- dest_p, (WizRawPixel *)(src_d + _vm->_resourceHeaderSize), dest_w, dest_h,
- x, y, src_w, src_h, &clip_r, flags, dataPtr, transColorOverride);
- }
} else {
if (_vm->_game.heversion > 99) {
if (optionalColorConversionTable &&
@@ -437,8 +430,8 @@ void *Wiz::drawAWizPrimEx(int globNum, int state, int x, int y, int z, int shado
dataPtr = (void *)optionalColorConversionTable;
}
} else {
- if (src_c != kWCTNone) {
- error("Raw data type mismatch for mode %d vs %d", src_c, kWCTNone);
+ if (!_uses16BitColor && src_c != kWCTNone) {
+ error("Wiz::drawAWizPrimEx(): Raw data type mismatch for mode %d vs %d", src_c, kWCTNone);
}
}
Commit: 9dd2ea4e43de1d8fc2171590a12b19d5074907d2
https://github.com/scummvm/scummvm/commit/9dd2ea4e43de1d8fc2171590a12b19d5074907d2
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Re-implement WIZ text and Aux images
Changed paths:
engines/scumm/actor.cpp
engines/scumm/actor.h
engines/scumm/actor_he.h
engines/scumm/akos.cpp
engines/scumm/akos.h
engines/scumm/charset.cpp
engines/scumm/gfx.cpp
engines/scumm/he/gfx_comp/aux_comp.cpp
engines/scumm/he/gfx_primitives_he.cpp
engines/scumm/he/intern_he.h
engines/scumm/he/resource_he.cpp
engines/scumm/he/script_v100he.cpp
engines/scumm/he/script_v71he.cpp
engines/scumm/he/script_v72he.cpp
engines/scumm/he/script_v90he.cpp
engines/scumm/he/sprite_he.cpp
engines/scumm/he/wiz_he.cpp
engines/scumm/he/wiz_he.h
engines/scumm/scumm.cpp
diff --git a/engines/scumm/actor.cpp b/engines/scumm/actor.cpp
index bb7887b7fcc..9dcc4121304 100644
--- a/engines/scumm/actor.cpp
+++ b/engines/scumm/actor.cpp
@@ -107,7 +107,7 @@ static const byte v0WalkboxSlantedModifier[0x16] = {
Actor::Actor(ScummEngine *scumm, int id) :
_vm(scumm), _number(id), _visible(false), _shadowMode(0), _flip(false), _frame(0), _walkbox(0), _talkPosX(0), _talkPosY(0),
_talkScript(0), _walkScript(0), _ignoreTurns(false), _drawToBackBuf(false), _layer(0), _heOffsX(0), _heOffsY(0), _heSkipLimbs(false),
- _heCondMask(0), _hePaletteNum(0), _heXmapNum(0), _elevation(0), _facing(0), _targetFacing(0), _speedx(0), _speedy(0),
+ _heCondMask(0), _hePaletteNum(0), _heShadow(0), _elevation(0), _facing(0), _targetFacing(0), _speedx(0), _speedy(0),
_animProgress(0), _animSpeed(0), _costumeNeedsInit(false) {
assert(_vm != nullptr);
}
@@ -130,7 +130,7 @@ void ActorHE::initActor(int mode) {
_heSkipLimbs = false;
}
- _heXmapNum = 0;
+ _heShadow = 0;
_hePaletteNum = 0;
_heFlags = 0;
_heTalking = false;
@@ -140,7 +140,11 @@ void ActorHE::initActor(int mode) {
_clipOverride = ((ScummEngine_v60he *)_vm)->_actorClipOverride;
- _auxBlock.reset();
+ _auxActor = 0;
+ _auxEraseX1 = 0;
+ _auxEraseY1 = 0;
+ _auxEraseX2 = -1;
+ _auxEraseY2 = -1;
}
void Actor::initActor(int mode) {
@@ -1682,7 +1686,7 @@ void Actor::putActor(int dstX, int dstY, int newRoom) {
} else {
#ifdef ENABLE_HE
if (_vm->_game.heversion >= 71)
- ((ScummEngine_v71he *)_vm)->queueAuxBlock((ActorHE *)this);
+ ((ScummEngine_v71he *)_vm)->heQueueEraseAuxActor((ActorHE *)this);
#endif
hideActor();
}
@@ -2091,7 +2095,11 @@ void Actor::hideActor() {
void ActorHE::hideActor() {
Actor::hideActor();
- _auxBlock.reset();
+ _auxActor = 0;
+ _auxEraseX1 = 0;
+ _auxEraseY1 = 0;
+ _auxEraseX2 = -1;
+ _auxEraseY2 = -1;
}
void Actor::showActor() {
@@ -2355,7 +2363,7 @@ void ScummEngine_v6::processActors() {
void ScummEngine_v71he::processActors() {
heFlushAuxEraseQueue();
- if (!_skipProcessActors)
+ if (!_disableActorDrawingFlag)
ScummEngine_v6::processActors();
_fullRedraw = false;
@@ -2369,7 +2377,7 @@ void ScummEngine_v90he::processActors() {
_sprite->checkForForcedRedraws(false);
_sprite->renderSprites(true);
- if (!_skipProcessActors)
+ if (!_disableActorDrawingFlag)
ScummEngine_v6::processActors();
_fullRedraw = false;
@@ -2441,7 +2449,7 @@ void Actor::prepareDrawActorCostume(BaseCostumeRenderer *bcr) {
bcr->_shadowTable = _vm->_shadowPalette;
}
- bcr->setCostume(_costume, (_vm->_game.heversion == 0) ? 0 : _heXmapNum);
+ bcr->setCostume(_costume, (_vm->_game.heversion == 0) ? 0 : _heShadow);
bcr->setPalette(_palette);
bcr->setFacing(this);
@@ -2592,7 +2600,11 @@ void Actor::startAnimActor(int f) {
if (_vm->_game.version >= 3 && f == _initFrame) {
_cost.reset();
if (_vm->_game.heversion != 0) {
- ((ActorHE *)this)->_auxBlock.reset();
+ ((ActorHE *)this)->_auxActor = 0;
+ ((ActorHE *)this)->_auxEraseX1 = 0;
+ ((ActorHE *)this)->_auxEraseY1 = 0;
+ ((ActorHE *)this)->_auxEraseX2 = -1;
+ ((ActorHE *)this)->_auxEraseY2 = -1;
}
}
_vm->_costumeLoader->costumeDecodeData(this, f, (uint) - 1);
@@ -2835,7 +2847,7 @@ void ScummEngine::setActorRedrawFlags() {
} else {
if (_game.heversion >= 72) {
for (j = 1; j < _numActors; j++) {
- if (_actors[j]->_costume && _actors[j]->_heXmapNum)
+ if (_actors[j]->_costume && _actors[j]->_heShadow)
_actors[j]->_needRedraw = true;
}
}
@@ -3194,9 +3206,14 @@ void ActorHE::setActorCostume(int c) {
if (_vm->_game.features & GF_NEW_COSTUMES) {
#ifdef ENABLE_HE
if (_vm->_game.heversion >= 71)
- ((ScummEngine_v71he *)_vm)->queueAuxBlock(this);
+ ((ScummEngine_v71he *)_vm)->heQueueEraseAuxActor(this);
#endif
- _auxBlock.reset();
+ _auxActor = 0;
+ _auxEraseX1 = 0;
+ _auxEraseY1 = 0;
+ _auxEraseX2 = -1;
+ _auxEraseY2 = -1;
+
if (_visible) {
if (_vm->_game.heversion >= 60)
_needRedraw = true;
@@ -3511,104 +3528,437 @@ bool ActorHE::isTalkConditionSet(int slot) const {
#ifdef ENABLE_HE
void ScummEngine_v71he::heFlushAuxEraseQueue() {
- if (!_skipProcessActors) {
- for (int i = 0; i < _auxBlocksNum; ++i) {
- AuxBlock *ab = &_auxBlocks[i];
- if (ab->r.top <= ab->r.bottom) {
- backgroundToForegroundBlit(ab->r);
- }
+ if (_disableActorDrawingFlag) {
+ _heAuxEraseActorIndex = 0;
+ return;
+ }
+
+ // Erase any AUX frames that were marked to be erased...
+ for (int i = 0; i < _heAuxEraseActorIndex; i++) {
+ if (_heAuxEraseActorTable[i].y1 <= _heAuxEraseActorTable[i].y2) {
+ Common::Rect blitRect(
+ _heAuxEraseActorTable[i].x1, _heAuxEraseActorTable[i].y1,
+ _heAuxEraseActorTable[i].x2, _heAuxEraseActorTable[i].y2);
+ backgroundToForegroundBlit(blitRect);
}
}
- _auxBlocksNum = 0;
+
+ _heAuxEraseActorIndex = 0;
}
void ScummEngine_v71he::heFlushAuxQueues() {
- if (!_skipProcessActors) {
- for (int i = 0; i < _auxEntriesNum; ++i) {
- AuxEntry *ae = &_auxEntries[i];
- if (ae->actorNum != -1) {
- ActorHE *a = (ActorHE *)derefActor(ae->actorNum, "postProcessAuxQueue");
- const uint8 *cost = getResourceAddress(rtCostume, a->_costume);
- int dy = a->_heOffsY + a->getPos().y;
- int dx = a->_heOffsX + a->getPos().x;
-
- if (_game.heversion >= 72)
- dy -= a->getElevation();
-
- const uint8 *akax = findResource(MKTAG('A','K','A','X'), cost);
- assert(akax);
- const uint8 *auxd = findPalInPals(akax, ae->subIndex) - _resourceHeaderSize;
- assert(auxd);
- const uint8 *frel = findResourceData(MKTAG('F','R','E','L'), auxd);
- if (frel) {
- error("unhandled FREL block");
- }
- const uint8 *disp = findResourceData(MKTAG('D','I','S','P'), auxd);
- if (disp) {
- error("unhandled DISP block");
- }
- const uint8 *axfd = findResourceData(MKTAG('A','X','F','D'), auxd);
- assert(axfd);
-
- uint16 comp = READ_LE_UINT16(axfd);
- if (comp != 0) {
- int x = (int16)READ_LE_UINT16(axfd + 2) + dx;
- int y = (int16)READ_LE_UINT16(axfd + 4) + dy;
- int w = (int16)READ_LE_UINT16(axfd + 6);
- int h = (int16)READ_LE_UINT16(axfd + 8);
- VirtScreen *pvs = &_virtscr[kMainVirtScreen];
- uint8 *dst1 = pvs->getPixels(0, pvs->topline);
- uint8 *dst2 = pvs->getBackPixels(0, pvs->topline);
- switch (comp) {
- case 1:
- // TODO: Wiz::copyAuxImage(dst1, dst2, axfd + 10, pvs->pitch, pvs->h, x, y, w, h, _bytesPerPixel);
- break;
- default:
- error("unimplemented compression type %d", comp);
- }
+ int x, y, w, h, type, whichActor;
+ int updateRects, xOffset, yOffset;
+ byte *costumeAddress;
+ const byte *auxDataBlockPtr;
+ const byte *auxDataPtr;
+ const byte *auxFrameDataPtr;
+ const byte *auxUpdateRectPtr;
+ byte *foregroundBufferPtr;
+ byte *backgroundBufferPtr;
+ const byte *auxEraseRectPtr;
+ bool drewSomething;
+ VirtScreen *pvs = &_virtscr[kMainVirtScreen];
+
+ if (_disableActorDrawingFlag) {
+ _heAuxAnimTableIndex = 0;
+ return;
+ }
+
+ // Render queued animations...
+ for (int i = 0; i < _heAuxAnimTableIndex; i++) {
+ whichActor = _heAuxAnimTable[i].actor;
+ if (whichActor == -1)
+ continue;
+
+ ActorHE *a = (ActorHE *)derefActor(whichActor, "heFlushAuxQueues");
+ costumeAddress = getResourceAddress(rtCostume, a->_costume);
+
+ xOffset = a->_heOffsX + a->getPos().x - pvs->xstart;
+ yOffset = a->_heOffsY + a->getPos().y;
+
+ if (_game.heversion >= 72) {
+ yOffset -= a->getElevation();
+ }
+
+ auxDataBlockPtr = findResourceData(MKTAG('A', 'K', 'A', 'X'), costumeAddress);
+ if (!auxDataBlockPtr) {
+ error("heFlushAuxQueue(): NO AKAX block actor %d!", whichActor);
+ }
+
+ auxDataPtr = findPalInPals(auxDataBlockPtr, _heAuxAnimTable[i].auxIndex);
+ if (!auxDataPtr) {
+ error("heFlushAuxQueue(): NO AUXD block actor %d!", whichActor);
+ }
+
+ // Check the type of the AUXD block...
+ auxFrameDataPtr = findResourceData(MKTAG('A', 'X', 'F', 'D'), auxDataPtr);
+ if (!auxFrameDataPtr) {
+ warning("heFlushAuxQueue(): NO AXFD block actor %d; ignoring...", whichActor);
+ continue;
+ }
+
+ auxFrameDataPtr += _resourceHeaderSize;
+ type = READ_LE_UINT16(auxFrameDataPtr);
+
+ drewSomething = false;
+
+ if ((type == AKOS_AUXD_TYPE_DRLE_FRAME) || (type == AKOS_AUXD_TYPE_SRLE_FRAME)) {
+ x = xOffset + (int16)READ_LE_UINT16(auxFrameDataPtr + 2);
+ y = yOffset + (int16)READ_LE_UINT16(auxFrameDataPtr + 4);
+ w = READ_LE_UINT16(auxFrameDataPtr + 6);
+ h = READ_LE_UINT16(auxFrameDataPtr + 8);
+
+ auxFrameDataPtr += 10;
+
+ // Call the render function to go to the main buffer...
+ foregroundBufferPtr = pvs->getPixels(0, pvs->topline);
+ backgroundBufferPtr = pvs->getBackPixels(0, pvs->topline);
+
+ if (type == AKOS_AUXD_TYPE_SRLE_FRAME) {
+ error("Unimplemented compression type actor %d!", whichActor);
+ } else if (type == AKOS_AUXD_TYPE_DRLE_FRAME) {
+ _wiz->auxDecompDRLEImage(
+ (WizRawPixel *)foregroundBufferPtr, (WizRawPixel *)backgroundBufferPtr, auxFrameDataPtr,
+ pvs->w, pvs->h, x, y, w, h, nullptr, nullptr);
+ } else {
+ error("Unimplemented compression type actor %d!", whichActor);
+ }
+
+ drewSomething = true;
+ }
+
+ // Add any update rects to the list for the final blit(s)
+ auxUpdateRectPtr = findResourceData(MKTAG('A', 'X', 'U', 'R'), auxDataPtr);
+ if (!auxUpdateRectPtr) {
+ continue;
+ }
+
+ auxUpdateRectPtr += _resourceHeaderSize;
+ updateRects = READ_LE_UINT16(auxUpdateRectPtr);
+ auxUpdateRectPtr += 2;
+
+ for (int rectCounter = 0; rectCounter < updateRects; rectCounter++) {
+ markRectAsDirty(
+ kMainVirtScreen,
+ xOffset + (int16)READ_LE_UINT16(auxUpdateRectPtr + 0),
+ xOffset + (int16)READ_LE_UINT16(auxUpdateRectPtr + 4),
+ yOffset + (int16)READ_LE_UINT16(auxUpdateRectPtr + 2),
+ yOffset + (int16)READ_LE_UINT16(auxUpdateRectPtr + 6));
+
+ auxUpdateRectPtr += 8;
+ }
+
+ // Set the actors erase info...
+ auxEraseRectPtr = findResourceData(MKTAG('A', 'X', 'E', 'R'), auxDataPtr);
+ if (!auxEraseRectPtr) {
+ continue;
+ }
+
+ auxEraseRectPtr += _resourceHeaderSize;
+ a->_auxActor = 1;
+ a->_auxEraseX1 = xOffset + (int16)READ_LE_UINT16(auxEraseRectPtr + 0);
+ a->_auxEraseY1 = yOffset + (int16)READ_LE_UINT16(auxEraseRectPtr + 2);
+ a->_auxEraseX2 = xOffset + (int16)READ_LE_UINT16(auxEraseRectPtr + 4);
+ a->_auxEraseY2 = yOffset + (int16)READ_LE_UINT16(auxEraseRectPtr + 6);
+
+ }
+
+ _heAuxAnimTableIndex = 0;
+}
+
+void ScummEngine_v90he::heFlushAuxQueues() {
+ // TODO: VERIFY HE95
+ if (_game.heversion < 98) {
+ ScummEngine_v71he::heFlushAuxQueues();
+ return;
+ }
+
+ int x, y, w, h, type, whichActor;
+ int updateRects, xOffset, yOffset;
+ byte *costumeAddress;
+ const byte *auxDataPtr;
+ const byte *auxFrameDataPtr;
+ const byte *auxUpdateRectPtr;
+ WizRawPixel *foregroundBufferPtr;
+ WizRawPixel *backgroundBufferPtr;
+ const byte *auxEraseRectPtr;
+ const byte *colorTablePtr;
+ bool drewSomething;
+ HEAnimAuxData auxInfo;
+ int actorBits;
+ const WizRawPixel *conversionTablePtr;
+ VirtScreen *pvs = &_virtscr[kMainVirtScreen];
+
+ if (_disableActorDrawingFlag) {
+ _heAuxAnimTableIndex = 0;
+ return;
+ }
+
+ // Render queued animations...
+ for (int i = 0; i < _heAuxAnimTableIndex; i++, heAuxReleaseAuxDataInfo(&auxInfo)) {
+ actorBits = 0;
+
+ whichActor = _heAuxAnimTable[i].actor;
+ if (whichActor == -1)
+ continue;
+
+ ActorHE *a = (ActorHE *)derefActor(whichActor, "heFlushAuxQueues");
+
+ if (_game.heversion > 99 && a->_hePaletteNum) {
+ conversionTablePtr = (WizRawPixel *)getHEPaletteSlot(a->_hePaletteNum);
+ } else {
+ conversionTablePtr = (WizRawPixel *)getHEPaletteSlot(1);
+ }
+
+ costumeAddress = getResourceAddress(rtCostume, a->_costume);
+
+ xOffset = a->_heOffsX + a->getPos().x - pvs->xstart;
+ yOffset = a->_heOffsY + a->getPos().y;
+
+ if (_game.heversion >= 72) {
+ yOffset -= a->getElevation();
+ }
+
+ // Get the frame data ptr
+ heAuxGetAuxDataInfo(&auxInfo, whichActor, _heAuxAnimTable[i].auxIndex);
+
+ // Check the type of the AUXD block...
+ auxFrameDataPtr = heAuxFindBlock(&auxInfo, MKTAG('A', 'X', 'F', 'D'));
+ if (!auxFrameDataPtr) {
+ warning("heFlushAuxQueue(): NO AXFD block actor %d; ignoring...", whichActor);
+ continue;
+ }
+
+ auxFrameDataPtr += _resourceHeaderSize;
+ type = READ_LE_UINT16(auxFrameDataPtr);
+
+ drewSomething = false;
+
+ if ((type == AKOS_AUXD_TYPE_DRLE_FRAME) ||
+ (type == AKOS_AUXD_TYPE_SRLE_FRAME) ||
+ (type == AKOS_AUXD_TYPE_WRLE_FRAME)) {
+ x = xOffset + (int16)READ_LE_UINT16(auxFrameDataPtr + 2);
+ y = yOffset + (int16)READ_LE_UINT16(auxFrameDataPtr + 4);
+ w = READ_LE_UINT16(auxFrameDataPtr + 6);
+ h = READ_LE_UINT16(auxFrameDataPtr + 8);
+
+ auxFrameDataPtr += 10;
+
+ // Call the render function to go to the main buffer...
+ foregroundBufferPtr = (WizRawPixel *)pvs->getPixels(0, pvs->topline);
+ backgroundBufferPtr = (WizRawPixel *)pvs->getBackPixels(0, pvs->topline);
+
+ if (type == AKOS_AUXD_TYPE_SRLE_FRAME) {
+ colorTablePtr = heAuxFindBlock(&auxInfo, MKTAG('C', 'L', 'R', 'S'));
+ if (!colorTablePtr) {
+ error("heFlushAuxQueue(): NO CLRS block actor %d!", whichActor);
}
- const uint8 *axur = findResourceData(MKTAG('A','X','U','R'), auxd);
- if (axur) {
- uint16 n = READ_LE_UINT16(axur); axur += 2;
- while (n--) {
- int x1 = (int16)READ_LE_UINT16(axur + 0) + dx;
- int y1 = (int16)READ_LE_UINT16(axur + 2) + dy;
- int x2 = (int16)READ_LE_UINT16(axur + 4) + dx;
- int y2 = (int16)READ_LE_UINT16(axur + 6) + dy;
- markRectAsDirty(kMainVirtScreen, x1, x2, y1, y2 + 1);
- axur += 8;
- }
+
+ colorTablePtr += _resourceHeaderSize;
+
+ if ((x != 0) || (y != 0) || (w != 640) || (h != 480)) {
+ error("heFlushAuxQueue(): Actor %d invalid (%d,%d)[%d,%d]", whichActor, x, y, w, h);
}
- const uint8 *axer = findResourceData(MKTAG('A','X','E','R'), auxd);
- if (axer) {
- a->_auxBlock.visible = true;
- a->_auxBlock.r.left = (int16)READ_LE_UINT16(axer + 0) + dx;
- a->_auxBlock.r.top = (int16)READ_LE_UINT16(axer + 2) + dy;
- a->_auxBlock.r.right = (int16)READ_LE_UINT16(axer + 4) + dx;
- a->_auxBlock.r.bottom = (int16)READ_LE_UINT16(axer + 6) + dy;
+
+ _wiz->auxDecompSRLEStream(
+ foregroundBufferPtr, backgroundBufferPtr, colorTablePtr,
+ auxFrameDataPtr, w * h,
+ conversionTablePtr);
+ } else if (type == AKOS_AUXD_TYPE_DRLE_FRAME) {
+ _wiz->auxDecompDRLEImage(
+ (WizRawPixel *)foregroundBufferPtr, (WizRawPixel *)backgroundBufferPtr, auxFrameDataPtr,
+ pvs->w, pvs->h, x, y, w, h, nullptr, conversionTablePtr);
+ } else if (AKOS_AUXD_TYPE_WRLE_FRAME == type) {
+ // Where is the color table?
+ if ((x != 0) || (w != 640)) {
+ error("heFlushAuxQueue(): Actor %d invalid (%d,%d)[%d,%d]", whichActor, x, y, w, h);
}
+
+ // Where is the color table?
+ colorTablePtr = auxFrameDataPtr;
+ auxFrameDataPtr += 32;
+
+ // Handle the uncompress
+ _wiz->auxWRLEUncompressPixelStream(
+ foregroundBufferPtr + (y * 640),
+ colorTablePtr, auxFrameDataPtr, (w * h),
+ conversionTablePtr);
+
+ actorBits = a->_number;
+ a->_needRedraw = true;
+
+ } else {
+ error("heFlushAuxQueue(): Unimplemented compression type actor %d!", whichActor);
}
+
+ drewSomething = true;
+ }
+
+ // Add any update rects to the list for the final blit(s)
+ auxUpdateRectPtr = heAuxFindBlock(&auxInfo, MKTAG('A', 'X', 'U', 'R'));
+ if (!auxUpdateRectPtr) {
+ continue;
}
+
+ auxUpdateRectPtr += _resourceHeaderSize;
+ updateRects = READ_LE_UINT16(auxUpdateRectPtr);
+ auxUpdateRectPtr += 2;
+
+ for (int rectCounter = 0; rectCounter < updateRects; rectCounter++) {
+ markRectAsDirty(
+ kMainVirtScreen,
+ xOffset + (int16)READ_LE_UINT16(auxUpdateRectPtr + 0),
+ xOffset + (int16)READ_LE_UINT16(auxUpdateRectPtr + 4),
+ yOffset + (int16)READ_LE_UINT16(auxUpdateRectPtr + 2),
+ yOffset + (int16)READ_LE_UINT16(auxUpdateRectPtr + 6),
+ actorBits);
+
+ // TODO: Is this really needed?
+ //setActorUpdateArea(
+ // whichActor,
+ // xOffset + (int16)READ_LE_UINT16(auxUpdateRectPtr + 0),
+ // yOffset + (int16)READ_LE_UINT16(auxUpdateRectPtr + 2),
+ // xOffset + (int16)READ_LE_UINT16(auxUpdateRectPtr + 4),
+ // yOffset + (int16)READ_LE_UINT16(auxUpdateRectPtr + 6));
+
+ auxUpdateRectPtr += 8;
+ }
+
+ // Set the actors erase info...
+ auxEraseRectPtr = heAuxFindBlock(&auxInfo, MKTAG('A', 'X', 'E', 'R'));
+ if (!auxEraseRectPtr) {
+ continue;
+ }
+
+ auxEraseRectPtr += _resourceHeaderSize;
+ a->_auxActor = 1;
+ a->_auxEraseX1 = xOffset + (int16)READ_LE_UINT16(auxEraseRectPtr + 0);
+ a->_auxEraseY1 = yOffset + (int16)READ_LE_UINT16(auxEraseRectPtr + 2);
+ a->_auxEraseX2 = xOffset + (int16)READ_LE_UINT16(auxEraseRectPtr + 4);
+ a->_auxEraseY2 = yOffset + (int16)READ_LE_UINT16(auxEraseRectPtr + 6);
}
- _auxEntriesNum = 0;
+
+ _heAuxAnimTableIndex = 0;
}
-void ScummEngine_v71he::queueAuxBlock(ActorHE *a) {
- if (!a->_auxBlock.visible)
+const byte *ScummEngine_v90he::heAuxFindBlock(HEAnimAuxData *auxInfoPtr, int32 id) {
+ const byte *resultPtr;
+
+ // Search the external block thing
+ if (auxInfoPtr->externalDataPtr) {
+ resultPtr = findResourceData(id, auxInfoPtr->externalDataPtr);
+ if (resultPtr)
+ return resultPtr;
+ }
+
+ // Search the current block first
+ resultPtr = findResourceData(id, auxInfoPtr->auxDataBlock);
+ if (resultPtr)
+ return resultPtr;
+
+ // If the alt search isn't the same search there...
+ if (auxInfoPtr->auxDataBlock == auxInfoPtr->auxDefaultSearchBlock) {
+ return resultPtr;
+ }
+
+ // Search the default block
+ return findResourceData(id, auxInfoPtr->auxDefaultSearchBlock);
+}
+
+void ScummEngine_v90he::heAuxReleaseAuxDataInfo(HEAnimAuxData *auxInfoPtr) {
+ auxInfoPtr->auxDefaultSearchBlock = nullptr;
+ auxInfoPtr->auxDataBlock = nullptr;
+
+ if (auxInfoPtr->externalDataPtr) {
+ free(auxInfoPtr->externalDataPtr);
+ auxInfoPtr->externalDataPtr = nullptr;
+ }
+}
+
+bool ScummEngine_v90he::heAuxProcessFileRelativeBlock(HEAnimAuxData *auxInfoPtr, const byte *dataBlockPtr) {
+ error("heAuxProcessFileRelativeBlock(): This looks like a development path! If you end up here, please report it in our bug tracker!");
+}
+
+bool ScummEngine_v90he::heAuxProcessDisplacedBlock(HEAnimAuxData *auxInfoPtr, const byte *displacedBlockPtr) {
+ error("heAuxProcessDisplacedBlock(): This looks like a development path! If you end up here, please report it in our bug tracker!");
+}
+
+void ScummEngine_v90he::heAuxGetAuxDataInfo(HEAnimAuxData *auxInfoPtr, int whichActor, int auxIndex) {
+ const byte *fileRelativeDataBlockPtr;
+ const byte *displacedBlockPtr;
+ const byte *auxDataBlockPtr;
+ const byte *auxDataPtr;
+ byte *costumeAddress;
+
+ // Store off some of the passed in info
+ auxInfoPtr->externalDataPtr = nullptr;
+ auxInfoPtr->actor = whichActor;
+
+ // Get the interesting data
+ ActorHE *a = (ActorHE *)derefActor(whichActor, "heAuxGetAuxDataInfo");
+ costumeAddress = getResourceAddress(rtCostume, a->_costume);
+
+ auxDataBlockPtr = findResourceData(MKTAG('A', 'K', 'A', 'X'), costumeAddress);
+ if (!auxDataBlockPtr) {
+ error("heAuxGetAuxDataInfo(): NO AKAX block actor %d!", whichActor);
+ }
+
+ auxDataPtr = findPalInPals(auxDataBlockPtr, auxIndex);
+ if (!auxDataPtr) {
+ error("heAuxGetAuxDataInfo():NO AUXD block actor %d!", whichActor);
+ }
+
+ // Check for other outside block types
+ fileRelativeDataBlockPtr = findResourceData(MKTAG('F', 'R', 'E', 'L'), auxDataPtr);
+
+ if (fileRelativeDataBlockPtr) {
+ if (!heAuxProcessFileRelativeBlock(auxInfoPtr, fileRelativeDataBlockPtr)) {
+ error("heAuxGetAuxDataInfo(): Actor %d aux %d failed", whichActor, auxIndex);
+ }
+ }
+
+ // This is where the DISP block will be processed!
+ displacedBlockPtr = findResourceData(MKTAG('D', 'I', 'S', 'P'), auxDataPtr);
+
+ if (displacedBlockPtr) {
+ if (!heAuxProcessDisplacedBlock(auxInfoPtr, displacedBlockPtr)) {
+ error("heAuxGetAuxDataInfo(): Actor %d aux %d failed", whichActor, auxIndex);
+ }
+ }
+
+ // Fill in the data result
+ auxInfoPtr->auxDefaultSearchBlock = costumeAddress;
+ auxInfoPtr->auxDataBlock = auxDataPtr;
+}
+
+void ScummEngine_v71he::heQueueEraseAuxActor(ActorHE *a) {
+ if (_heAuxEraseActorIndex >= ARRAYSIZE(_heAuxEraseActorTable)) {
+ warning("heQueueEraseAuxActor(): Queue full, ignoring...");
return;
+ }
- assert(_auxBlocksNum < ARRAYSIZE(_auxBlocks));
- _auxBlocks[_auxBlocksNum] = a->_auxBlock;
- ++_auxBlocksNum;
+ if (a->_auxActor) {
+ _heAuxEraseActorTable[_heAuxEraseActorIndex].actor = a->_number;
+ _heAuxEraseActorTable[_heAuxEraseActorIndex].x1 = a->_auxEraseX1;
+ _heAuxEraseActorTable[_heAuxEraseActorIndex].y1 = a->_auxEraseY1;
+ _heAuxEraseActorTable[_heAuxEraseActorIndex].x2 = a->_auxEraseX2;
+ _heAuxEraseActorTable[_heAuxEraseActorIndex].y2 = a->_auxEraseY2;
+ _heAuxEraseActorIndex++;
+ }
}
-void ScummEngine_v71he::queueAuxEntry(int actorNum, int subIndex) {
- assert(_auxEntriesNum < ARRAYSIZE(_auxEntries));
- AuxEntry *ae = &_auxEntries[_auxEntriesNum];
- ae->actorNum = actorNum;
- ae->subIndex = subIndex;
- ++_auxEntriesNum;
+void ScummEngine_v71he::heQueueAnimAuxFrame(int actor, int auxIndex) {
+ if (_heAuxAnimTableIndex >= ARRAYSIZE(_heAuxAnimTable)) {
+ warning("HEQueueAnimAuxFrame(): Queue full, ignoring...");
+ return;
+ }
+
+ _heAuxAnimTable[_heAuxAnimTableIndex].actor = actor;
+ _heAuxAnimTable[_heAuxAnimTableIndex].auxIndex = auxIndex;
+ _heAuxAnimTableIndex++;
}
+
#endif
void Actor_v0::animateActor(int anim) {
@@ -3847,7 +4197,7 @@ void Actor::saveLoadWithSerializer(Common::Serializer &s) {
s.syncAsByte(_costumeNeedsInit, VER(8));
s.syncAsUint32LE(_heCondMask, VER(38));
s.syncAsUint32LE(_hePaletteNum, VER(59));
- s.syncAsUint32LE(_heXmapNum, VER(59));
+ s.syncAsUint32LE(_heShadow, VER(59));
s.syncAsSint16LE(_talkPosY, VER(8));
s.syncAsSint16LE(_talkPosX, VER(8));
diff --git a/engines/scumm/actor.h b/engines/scumm/actor.h
index 214f9d9a1bd..9e663c41ce4 100644
--- a/engines/scumm/actor.h
+++ b/engines/scumm/actor.h
@@ -142,7 +142,7 @@ public:
bool _heSkipLimbs;
uint32 _heCondMask;
uint32 _hePaletteNum;
- uint32 _heXmapNum;
+ uint32 _heShadow;
protected:
struct ActorWalkData {
diff --git a/engines/scumm/actor_he.h b/engines/scumm/actor_he.h
index 0f3c5666503..81a985befc5 100644
--- a/engines/scumm/actor_he.h
+++ b/engines/scumm/actor_he.h
@@ -27,26 +27,29 @@
namespace Scumm {
-struct AuxBlock {
- bool visible;
- Common::Rect r;
-
- void reset() {
- visible = false;
- r.left = r.top = 0;
- r.right = r.bottom = -1;
- }
-
- void clear() {
- reset();
- r.right = 0;
- r.bottom = 0;
- }
+ struct HEEraseAuxEntry {
+ int actor;
+ int32 x1, y1, x2, y2;
};
-struct AuxEntry {
- int actorNum;
- int subIndex;
+struct HEAnimAuxEntry {
+ int actor;
+ int auxIndex;
+};
+
+struct HEAnimAuxData {
+ byte *auxDefaultSearchBlock;
+ byte *externalDataPtr;
+ const byte *auxDataBlock;
+ int actor;
+};
+
+struct HEAuxFileRelInfo {
+ int globFileOffset;
+ Common::File fileHandle;
+ int globType;
+ int globNum;
+ int roomNum;
};
class ActorHE : public Actor {
@@ -78,7 +81,8 @@ public:
bool _heTalking;
byte _heFlags;
- AuxBlock _auxBlock;
+ int _auxActor;
+ int32 _auxEraseX1, _auxEraseY1, _auxEraseX2, _auxEraseY2;
struct {
int16 posX;
diff --git a/engines/scumm/akos.cpp b/engines/scumm/akos.cpp
index be4829bcc07..59ce1706d7d 100644
--- a/engines/scumm/akos.cpp
+++ b/engines/scumm/akos.cpp
@@ -1365,7 +1365,7 @@ bool ScummEngine_v6::akos_increaseAnim(Actor *a, int limb, const byte *aksq, con
curState += aksq[curState + 2];
break;
case AKC_DisplayAuxFrame:
- akos_queCommand(7, a, GW(2), 0);
+ akos_queCommand(AKQC_DisplayAuxFrame, a, GW(2), 0);
curState += 4;
break;
default:
@@ -1681,7 +1681,7 @@ void ScummEngine_v6::akos_processQueue() {
case AKQC_DisplayAuxFrame:
#ifdef ENABLE_HE
assert(_game.heversion >= 71);
- ((ScummEngine_v71he *)this)->queueAuxEntry(a->_number, param1);
+ ((ScummEngine_v71he *)this)->heQueueAnimAuxFrame(a->_number, param1);
#endif
break;
case AKQC_StartTalkie:
diff --git a/engines/scumm/akos.h b/engines/scumm/akos.h
index e17d922791c..2c5c0b238f1 100644
--- a/engines/scumm/akos.h
+++ b/engines/scumm/akos.h
@@ -31,6 +31,11 @@ namespace Scumm {
#define AKOS_RUN_MAJMIN_CODEC 16
#define AKOS_TRLE_CODEC 32
+#define AKOS_AUXD_TYPE_EMPTY_FRAME 0x0000
+#define AKOS_AUXD_TYPE_DRLE_FRAME 0x0001
+#define AKOS_AUXD_TYPE_SRLE_FRAME 0x0010
+#define AKOS_AUXD_TYPE_WRLE_FRAME 0x0020
+
struct CostumeData;
struct AkosHeader;
struct AkosOffset;
diff --git a/engines/scumm/charset.cpp b/engines/scumm/charset.cpp
index 73ca577e556..a9623b584fe 100644
--- a/engines/scumm/charset.cpp
+++ b/engines/scumm/charset.cpp
@@ -1204,6 +1204,7 @@ void CharsetRendererClassic::printCharIntern(bool is2byte, const byte *charPtr,
if ((_vm->_game.heversion >= 71 && _bitsPerPixel >= 8) || (_vm->_game.heversion >= 90 && _bitsPerPixel == 0)) {
#ifdef ENABLE_HE
+ // TODO: FIX ZPLANE
if (ignoreCharsetMask || !vs->hasTwoBuffers) {
dstPtr = vs->getPixels(0, 0);
} else {
@@ -1214,20 +1215,48 @@ void CharsetRendererClassic::printCharIntern(bool is2byte, const byte *charPtr,
dstPtr = vs->getBackPixels(0, 0);
}
- Common::Rect rScreen(vs->w, vs->h);
- if (_bitsPerPixel >= 8) {
- byte imagePalette[256];
- memset(imagePalette, 0, sizeof(imagePalette));
- memcpy(imagePalette, _vm->_charsetColorMap, 4);
- // TODO: Wiz::copyWizImage(dstPtr, charPtr, vs->pitch, kDstScreen, vs->w, vs->h, _left, _top, origWidth, origHeight, &rScreen, 0, imagePalette, NULL, _vm->_bytesPerPixel);
+ byte *colorLookupTable;
+ byte generalColorLookupTable[256];
+ int black = _vm->VAR_COLOR_BLACK != 0xFF ? _vm->VAR(_vm->VAR_COLOR_BLACK) : 0;
+
+ memset(generalColorLookupTable, black, sizeof(generalColorLookupTable));
+ for (int i = 0; i < 4; i++) {
+ generalColorLookupTable[i] = _vm->_charsetColorMap[i];
+ }
+ generalColorLookupTable[1] = _color;
+
+ if (_bitsPerPixel || _vm->_game.heversion < 90) {
+ colorLookupTable = generalColorLookupTable;
} else {
- // TODO: Wiz::copyWizImage(dstPtr, charPtr, vs->pitch, kDstScreen, vs->w, vs->h, _left, _top, origWidth, origHeight, &rScreen, 0, NULL, NULL, _vm->_bytesPerPixel);
+ colorLookupTable = nullptr;
}
- if (_blitAlso && vs->hasTwoBuffers) {
- Common::Rect dst(_left, _top, _left + origWidth, _top + origHeight);
- ((ScummEngine_v71he *)_vm)->backgroundToForegroundBlit(dst);
+ if (ignoreCharsetMask && vs->hasTwoBuffers) {
+ ((ScummEngine_v71he *)_vm)->_wiz->pgDrawWarpDrawLetter(
+ (WizRawPixel *)dstPtr,
+ vs->w, vs->h,
+ charPtr, _left, drawTop, origWidth, origHeight,
+ colorLookupTable);
+
+ Common::Rect blitRect(_left, drawTop, _left + origWidth - 1, drawTop + origHeight);
+ ((ScummEngine_v71he *)_vm)->backgroundToForegroundBlit(blitRect);
+ } else {
+ ((ScummEngine_v71he *)_vm)->_wiz->pgDrawWarpDrawLetter((WizRawPixel *)dstPtr,
+ vs->w, vs->h,
+ charPtr, _left, drawTop, origWidth, origHeight,
+ colorLookupTable);
}
+
+ if (_vm->_game.heversion >= 80) {
+ if ((vs->number == kMainVirtScreen && !_blitAlso) || _vm->_game.heversion <= 90) {
+ ((ScummEngine_v71he *)_vm)->_wiz->auxDrawZplaneFromTRLEImage(
+ dstPtr, charPtr,
+ _vm->_textSurface.w, _vm->_textSurface.h,
+ _left, drawTop, origWidth, origHeight,
+ nullptr, kWZOIgnore, kWZOSet);
+ }
+ }
+
#endif
} else {
Graphics::Surface dstSurface;
diff --git a/engines/scumm/gfx.cpp b/engines/scumm/gfx.cpp
index 672772ee35e..66f50f762e5 100644
--- a/engines/scumm/gfx.cpp
+++ b/engines/scumm/gfx.cpp
@@ -2559,7 +2559,7 @@ void Gdi::drawBMAPObject(const byte *ptr, VirtScreen *vs, int obj, int x, int y,
// TODO: Wiz::copyWizImage(dst, bmap_ptr, vs->pitch, kDstScreen, vs->w, vs->h, x - scrX, y, w, h, &rScreen, 0, 0, 0, _vm->_bytesPerPixel);
((ScummEngine_v71he *)_vm)->_wiz->auxDecompTRLEImage(
dst, bmap_ptr, vs->w, vs->h,
- x, y, w, h, &rScreen,
+ x - scrX, y, w, h, &rScreen,
nullptr);
}
diff --git a/engines/scumm/he/gfx_comp/aux_comp.cpp b/engines/scumm/he/gfx_comp/aux_comp.cpp
index 55e819590ce..f13fa9b8614 100644
--- a/engines/scumm/he/gfx_comp/aux_comp.cpp
+++ b/engines/scumm/he/gfx_comp/aux_comp.cpp
@@ -376,7 +376,7 @@ void Wiz::auxDecompSRLEStream(WizRawPixel *destStream, const WizRawPixel *backgr
}
}
-void Wiz::auxDecompDRLEImage(WizRawPixel *foregroundBufferPtr, WizRawPixel *backgroundBufferPtr, byte *compData, int bufferWidth, int bufferHeight, int x, int y, int width, int height, Common::Rect *clipRectPtr, const WizRawPixel *conversionTable) {
+void Wiz::auxDecompDRLEImage(WizRawPixel *foregroundBufferPtr, WizRawPixel *backgroundBufferPtr, const byte *compData, int bufferWidth, int bufferHeight, int x, int y, int width, int height, Common::Rect *clipRectPtr, const WizRawPixel *conversionTable) {
Common::Rect sourceRect, destRect, clipRect, workRect;
sourceRect.left = 0;
@@ -390,7 +390,7 @@ void Wiz::auxDecompDRLEImage(WizRawPixel *foregroundBufferPtr, WizRawPixel *back
destRect.bottom = y + height - 1;
// Custom clip rect...
- if (!clipRectPtr) {
+ if (clipRectPtr) {
clipRect = *clipRectPtr;
workRect.left = 0;
workRect.top = 0;
@@ -431,7 +431,7 @@ void Wiz::auxDecompDRLEImage(WizRawPixel *foregroundBufferPtr, WizRawPixel *back
&destRect, compData, &sourceRect, conversionTable);
}
-void Wiz::auxDecompDRLEPrim(WizRawPixel *foregroundBufferPtr, WizRawPixel *backgroundBufferPtr, int bufferWidth, Common::Rect *destRect, byte *compData, Common::Rect *sourceRect, const WizRawPixel *conversionTable) {
+void Wiz::auxDecompDRLEPrim(WizRawPixel *foregroundBufferPtr, WizRawPixel *backgroundBufferPtr, int bufferWidth, Common::Rect *destRect, const byte *compData, Common::Rect *sourceRect, const WizRawPixel *conversionTable) {
int decompWidth, decompHeight, counter, sX1, dX1, dX2, lineSize;
WizRawPixel8 *foregroundBuffer8 = (WizRawPixel8 *)foregroundBufferPtr;
WizRawPixel16 *foregroundBuffer16 = (WizRawPixel16 *)foregroundBufferPtr;
@@ -509,7 +509,7 @@ void Wiz::auxDecompTRLEImage(WizRawPixel *bufferPtr, const byte *compData, int b
destRect.bottom = y + height - 1;
// Custom clip rect...
- if (!clipRectPtr) {
+ if (clipRectPtr) {
clipRect = *clipRectPtr;
workRect.left = 0;
workRect.top = 0;
@@ -601,7 +601,7 @@ void Wiz::auxDecompTRLEPrim(WizRawPixel *bufferPtr, int bufferWidth, Common::Rec
}
-void Wiz::auxDrawZplaneFromTRLEImage(byte *zplanePtr, byte *compData, int zplanePixelWidth, int zplanePixelHeight, int x, int y, int width, int height, Common::Rect *clipRectPtr, int transOp, int solidOp) {
+void Wiz::auxDrawZplaneFromTRLEImage(byte *zplanePtr, const byte *compData, int zplanePixelWidth, int zplanePixelHeight, int x, int y, int width, int height, Common::Rect *clipRectPtr, int transOp, int solidOp) {
Common::Rect sourceRect, destRect, clipRect, workRect;
sourceRect.left = 0;
@@ -615,7 +615,7 @@ void Wiz::auxDrawZplaneFromTRLEImage(byte *zplanePtr, byte *compData, int zplane
destRect.bottom = y + height - 1;
// Custom clip rect...
- if (!clipRectPtr) {
+ if (clipRectPtr) {
clipRect = *clipRectPtr;
workRect.left = 0;
@@ -657,7 +657,7 @@ void Wiz::auxDrawZplaneFromTRLEImage(byte *zplanePtr, byte *compData, int zplane
zplanePtr, zplanePixelWidth, &destRect, compData, &sourceRect, transOp, solidOp);
}
-void Wiz::auxDrawZplaneFromTRLEPrim(byte *zplanePtr, int zplanePixelWidth, Common::Rect *destRect, byte *compData, Common::Rect *sourceRect, int transOp, int solidOp) {
+void Wiz::auxDrawZplaneFromTRLEPrim(byte *zplanePtr, int zplanePixelWidth, Common::Rect *destRect, const byte *compData, Common::Rect *sourceRect, int transOp, int solidOp) {
int decompWidth, decompHeight, counter, sX1, dX1, dX2, lineSize, mask, zplaneWidth;
// General setup...
@@ -694,7 +694,7 @@ void Wiz::auxDrawZplaneFromTRLEPrim(byte *zplanePtr, int zplanePixelWidth, Commo
}
}
-void Wiz::auxDecompRemappedTRLEImage(WizRawPixel *bufferPtr, byte *compData, int bufferWidth, int bufferHeight, int x, int y, int width, int height, Common::Rect *clipRectPtr, byte *remapTable, const WizRawPixel *conversionTable) {
+void Wiz::auxDecompRemappedTRLEImage(WizRawPixel *bufferPtr, const byte *compData, int bufferWidth, int bufferHeight, int x, int y, int width, int height, Common::Rect *clipRectPtr, byte *remapTable, const WizRawPixel *conversionTable) {
Common::Rect sourceRect, destRect, clipRect, workRect;
sourceRect.left = 0;
@@ -708,7 +708,7 @@ void Wiz::auxDecompRemappedTRLEImage(WizRawPixel *bufferPtr, byte *compData, int
destRect.bottom = y + height - 1;
// Custom clip rect...
- if (!clipRectPtr) {
+ if (clipRectPtr) {
clipRect = *clipRectPtr;
workRect.left = 0;
@@ -751,7 +751,7 @@ void Wiz::auxDecompRemappedTRLEImage(WizRawPixel *bufferPtr, byte *compData, int
conversionTable);
}
-void Wiz::auxDecompRemappedTRLEPrim(WizRawPixel *bufferPtr, int bufferWidth, Common::Rect *destRect, byte *compData, Common::Rect *sourceRect, byte *remapTable, const WizRawPixel *conversionTable) {
+void Wiz::auxDecompRemappedTRLEPrim(WizRawPixel *bufferPtr, int bufferWidth, Common::Rect *destRect, const byte *compData, Common::Rect *sourceRect, byte *remapTable, const WizRawPixel *conversionTable) {
int decompWidth, decompHeight, sX1, dX1, dX2, lineSize;
WizRawPixel8 *buffer8 = (WizRawPixel8 *)bufferPtr;
WizRawPixel16 *buffer16 = (WizRawPixel16 *)bufferPtr;
@@ -950,7 +950,7 @@ void Wiz::auxDecompMixColorsTRLEImage(WizRawPixel *bufferPtr, byte *compData, in
destRect.bottom = y + height - 1;
// Custom clip rect...
- if (!clipRectPtr) {
+ if (clipRectPtr) {
clipRect = *clipRectPtr;
workRect.left = 0;
@@ -1043,7 +1043,7 @@ void Wiz::auxDecompMixColorsTRLEPrim(WizRawPixel *bufferPtr, int bufferWidth, Co
}
}
-void Wiz::auxDecompDRLEStream(WizRawPixel *destPtr, byte *dataStream, WizRawPixel *backgroundPtr, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
+void Wiz::auxDecompDRLEStream(WizRawPixel *destPtr, const byte *dataStream, WizRawPixel *backgroundPtr, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
int runCount;
WizRawPixel8 *dest8 = (WizRawPixel8 *)destPtr;
WizRawPixel16 *dest16 = (WizRawPixel16 *)destPtr;
@@ -1278,7 +1278,7 @@ void Wiz::auxDecompTRLEStream(WizRawPixel *destPtr, const byte *dataStream, int
}
}
-void Wiz::auxDecompRemappedTRLEStream(WizRawPixel *destPtr, byte *dataStream, int skipAmount, int decompAmount, byte *remapTable, const WizRawPixel *conversionTable) {
+void Wiz::auxDecompRemappedTRLEStream(WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, byte *remapTable, const WizRawPixel *conversionTable) {
int runCount;
WizRawPixel8 *dest8 = (WizRawPixel8 *)destPtr;
WizRawPixel16 *dest16 = (WizRawPixel16 *)destPtr;
@@ -1383,7 +1383,7 @@ void Wiz::auxDecompRemappedTRLEStream(WizRawPixel *destPtr, byte *dataStream, in
}
-void Wiz::auxZplaneFromTRLEStream(byte *destPtr, byte *dataStream, int skipAmount, int decompAmount, int mask, int transOp, int solidOp) {
+void Wiz::auxZplaneFromTRLEStream(byte *destPtr, const byte *dataStream, int skipAmount, int decompAmount, int mask, int transOp, int solidOp) {
int runCount;
// Decompress bytes to do simple clipping...
@@ -1687,7 +1687,7 @@ void Wiz::auxHistogramTRLEPrim(int *histogramTablePtr, byte *compData, Common::R
}
}
-void Wiz::auxRemappedMemcpy(WizRawPixel *dstPtr, byte *srcPtr, int count, byte *remapTable, const WizRawPixel *conversionTable) {
+void Wiz::auxRemappedMemcpy(WizRawPixel *dstPtr, const byte *srcPtr, int count, byte *remapTable, const WizRawPixel *conversionTable) {
WizRawPixel8 *dst8 = (WizRawPixel8 *)dstPtr;
WizRawPixel16 *dst16 = (WizRawPixel16 *)dstPtr;
diff --git a/engines/scumm/he/gfx_primitives_he.cpp b/engines/scumm/he/gfx_primitives_he.cpp
index 805ae32d30c..d383763d703 100644
--- a/engines/scumm/he/gfx_primitives_he.cpp
+++ b/engines/scumm/he/gfx_primitives_he.cpp
@@ -615,7 +615,6 @@ void Wiz::pgSimpleBlit(WizSimpleBitmap *destBM, Common::Rect *destRect, WizSimpl
d16 = ((WizRawPixel16 *)destBM->bufferPtr) + destRect->top * dw + destRect->left;
s16 = ((WizRawPixel16 *)sourceBM->bufferPtr) + sourceRect->top * sw + sourceRect->left;
-
// Going up or down?
if (sourceRect->top > sourceRect->bottom) {
sw = -sw;
@@ -909,6 +908,23 @@ void Wiz::pgTransparentSimpleBlit(WizSimpleBitmap *destBM, Common::Rect *destRec
}
}
+void Wiz::pgDrawWarpDrawLetter(WizRawPixel *bitmapBuffer, int bitmapWidth, int bitmapHeight, const byte *charData, int x1, int y1, int width, int height, byte *colorLookupTable) {
+ WizRawPixel *remapTable = (_vm->_game.heversion <= 90) ? nullptr : (WizRawPixel *)_vm->getHEPaletteSlot(1);
+
+ if (colorLookupTable) {
+ auxDecompRemappedTRLEImage(
+ bitmapBuffer, charData, bitmapWidth, bitmapHeight, x1, y1, width, height, nullptr,
+ colorLookupTable,
+ remapTable
+ );
+ } else {
+ auxDecompTRLEImage(
+ bitmapBuffer, charData, bitmapWidth, bitmapHeight, x1, y1, width, height, nullptr,
+ remapTable
+ );
+ }
+}
+
void Wiz::pgDraw8BppFormatImage(WizRawPixel *bufferPtr, const byte *rawData, int bufferWidth, int bufferHeight, int x, int y, int width, int height, Common::Rect *clipRectPtr, int32 wizFlags, const void *extraTable, int transparentColor, const WizRawPixel *conversionTable) {
Common::Rect srcRect, dstRect, clipRect;
WizSimpleBitmap srcBitmap, dstBitmap;
@@ -991,16 +1007,17 @@ void Wiz::pgDraw8BppFormatImage(WizRawPixel *bufferPtr, const byte *rawData, int
void Wiz::pgDraw8BppSimpleBlit(WizSimpleBitmap *destBM, Common::Rect *destRect, WizSimpleBitmap *sourceBM, Common::Rect *sourceRect, const WizRawPixel *conversionTable) {
int x, cw, dw, sw, ch;
- const byte *s;
- WizRawPixel *d;
+ const WizRawPixel8 *s8; // Source is always 8-bit
+ WizRawPixel16 *d16; // Dest is always 16-bit
// Common calcs...
dw = destBM->bitmapWidth;
sw = sourceBM->bitmapWidth;
cw = abs(sourceRect->right - sourceRect->left) + 1;
ch = abs(sourceRect->bottom - sourceRect->top) + 1;
- d = destBM->bufferPtr + destRect->top * dw + destRect->left;
- s = ((const byte *)sourceBM->bufferPtr) + sourceRect->top * sw + sourceRect->left;
+
+ d16 = ((WizRawPixel16 *)destBM->bufferPtr) + destRect->top * dw + destRect->left;
+ s8 = ((const WizRawPixel8 *)sourceBM->bufferPtr) + sourceRect->top * sw + sourceRect->left;
// Going up or down?
if (sourceRect->top > sourceRect->bottom) {
@@ -1010,10 +1027,10 @@ void Wiz::pgDraw8BppSimpleBlit(WizSimpleBitmap *destBM, Common::Rect *destRect,
// Left or right?
if (sourceRect->left <= sourceRect->right) {
while (--ch >= 0) {
- memcpy8BppConversion(d, s, cw, conversionTable);
+ memcpy8BppConversion(d16, s8, cw, conversionTable);
- d += dw;
- s += sw;
+ d16 += dw;
+ s8 += sw;
}
} else {
dw -= cw;
@@ -1021,27 +1038,29 @@ void Wiz::pgDraw8BppSimpleBlit(WizSimpleBitmap *destBM, Common::Rect *destRect,
while (--ch >= 0) {
for (x = cw; --x >= 0;) {
- *d++ = convert8BppToRawPixel(*s--, conversionTable);
+ *d16 = (WizRawPixel16)convert8BppToRawPixel((WizRawPixel)*s8, conversionTable);
+ d16++;
+ s8--;
}
- d += dw;
- s += sw;
+ d16 += dw;
+ s8 += sw;
}
}
}
void Wiz::pgDraw8BppTransparentSimpleBlit(WizSimpleBitmap *destBM, Common::Rect *destRect, WizSimpleBitmap *sourceBM, Common::Rect *sourceRect, int transparentColor, const WizRawPixel *conversionTable) {
int cw, dw, sw, ch, soff, doff, value;
- const byte *s;
- WizRawPixel *d;
+ const WizRawPixel8 *s8; // Source is always 8-bit
+ WizRawPixel16 *d16; // Dest is always 16-bit
// Common calcs...
dw = destBM->bitmapWidth;
sw = sourceBM->bitmapWidth;
cw = abs(sourceRect->right - sourceRect->left) + 1;
ch = abs(sourceRect->bottom - sourceRect->top) + 1;
- d = destBM->bufferPtr + destRect->top * dw + destRect->left;
- s = ((const byte *)sourceBM->bufferPtr) + sourceRect->top * sw + sourceRect->left;
+ d16 = ((WizRawPixel16 *)destBM->bufferPtr) + destRect->top * dw + destRect->left;
+ s8 = ((const WizRawPixel8 *)sourceBM->bufferPtr) + sourceRect->top * sw + sourceRect->left;
// Going up or down?
if (sourceRect->top > sourceRect->bottom) {
@@ -1055,17 +1074,17 @@ void Wiz::pgDraw8BppTransparentSimpleBlit(WizSimpleBitmap *destBM, Common::Rect
while (--ch >= 0) {
for (int x = cw; --x >= 0;) {
- value = *s++;
+ value = *s8++;
if (value != transparentColor) {
- *d++ = convert8BppToRawPixel(value, conversionTable);
+ *d16++ = (WizRawPixel16)convert8BppToRawPixel((WizRawPixel)value, conversionTable);
} else {
- d++;
+ d16++;
}
}
- s += soff;
- d += doff;
+ s8 += soff;
+ d16 += doff;
}
} else {
soff = sw + cw;
@@ -1073,22 +1092,25 @@ void Wiz::pgDraw8BppTransparentSimpleBlit(WizSimpleBitmap *destBM, Common::Rect
while (--ch >= 0) {
for (int x = cw; --x >= 0;) {
- value = *s--;
+ value = *s8--;
if (value != transparentColor) {
- *d++ = convert8BppToRawPixel(value, conversionTable);
+ *d16++ = (WizRawPixel16)convert8BppToRawPixel((WizRawPixel)value, conversionTable);
} else {
- d++;
+ d16++;
}
}
- s += soff;
- d += doff;
+ s8 += soff;
+ d16 += doff;
}
}
}
void Wiz::pgDrawImageWith16BitZBuffer(WizSimpleBitmap *psbDst, const WizSimpleBitmap *psbZBuffer, const byte *imgData, int x, int y, int z, int width, int height, Common::Rect *prcClip) {
- // validate parameters
+ // This is available only on HE100+, which hopefully means it should only be called for 16-bit games
+ assert(_uses16BitColor);
+
+ // Validate parameters
assert(psbDst && psbZBuffer && imgData && prcClip);
// z-buffer and destination buffer must have the same dimensions
@@ -1120,14 +1142,13 @@ void Wiz::pgDrawImageWith16BitZBuffer(WizSimpleBitmap *psbDst, const WizSimpleBi
// perform the drawing
int dstWidth = psbDst->bitmapWidth; // same for destination and Z buffer
+ const int drawWidth = (prcClip->right - prcClip->left + 1);
+ const int drawHeight = (prcClip->bottom - prcClip->top + 1);
WizRawPixel *pSrc = (WizRawPixel *)imgData + (prcClip->top - y) * width + (prcClip->left - x);
WizRawPixel *pDst = (WizRawPixel *)psbDst->bufferPtr + prcClip->top * dstWidth + prcClip->left;
WizRawPixel *pZB = (WizRawPixel *)psbZBuffer->bufferPtr + prcClip->top * dstWidth + prcClip->left;
- const int drawWidth = (prcClip->right - prcClip->left + 1);
- const int drawHeight = (prcClip->bottom - prcClip->top + 1);
-
for (int row = 0; row < drawHeight; ++row) {
for (int col = 0; col < drawWidth; ++col, ++pZB, ++pDst, ++pSrc) {
// left hand rule - don't draw unless we're closer than the z-buffer value
@@ -1145,41 +1166,53 @@ void Wiz::pgDrawImageWith16BitZBuffer(WizSimpleBitmap *psbDst, const WizSimpleBi
void Wiz::pgForewordRemapPixelCopy(WizRawPixel *dstPtr, const WizRawPixel *srcPtr, int size, const byte *lookupTable) {
if (!_uses16BitColor) {
+ WizRawPixel8 *dst8 = (WizRawPixel8 *)dstPtr;
+ const WizRawPixel8 *src8 = (const WizRawPixel8 *)srcPtr;
+
while (size-- > 0) {
- *dstPtr++ = *(lookupTable + *srcPtr++);
+ *dst8++ = *(lookupTable + *src8++);
}
} else {
+ WizRawPixel16 *dst16 = (WizRawPixel16 *)dstPtr;
+ const WizRawPixel16 *src16 = (const WizRawPixel16 *)srcPtr;
+
while (size-- > 0) {
- *dstPtr++ = *srcPtr++;
+ *dst16++ = *src16++;
}
}
}
void Wiz::pgTransparentForewordRemapPixelCopy(WizRawPixel *dstPtr, const WizRawPixel *srcPtr, int size, WizRawPixel transparentColor, const byte *lookupTable) {
if (!_uses16BitColor) {
+ WizRawPixel8 *dst8 = (WizRawPixel8 *)dstPtr;
+ const WizRawPixel8 *src8 = (const WizRawPixel8 *)srcPtr;
+
while (size-- > 0) {
- WizRawPixel srcColor = *srcPtr++;
+ WizRawPixel8 srcColor = *src8++;
if (transparentColor != srcColor) {
- WizRawPixel remappedColor = *(lookupTable + srcColor);
+ WizRawPixel8 remappedColor = *(lookupTable + srcColor);
if (transparentColor != remappedColor) {
- *dstPtr++ = remappedColor;
+ *dst8++ = remappedColor;
} else {
- ++dstPtr;
+ ++dst8;
}
} else {
- ++dstPtr;
+ ++dst8;
}
}
} else {
+ WizRawPixel16 *dst16 = (WizRawPixel16 *)dstPtr;
+ const WizRawPixel16 *src16 = (const WizRawPixel16 *)srcPtr;
+
while (size-- > 0) {
- WizRawPixel srcColor = *srcPtr++;
+ WizRawPixel16 srcColor = *src16++;
if (transparentColor != srcColor) {
- *dstPtr++ = srcColor;
+ *dst16++ = srcColor;
} else {
- ++dstPtr;
+ ++dst16;
}
}
}
@@ -1187,29 +1220,35 @@ void Wiz::pgTransparentForewordRemapPixelCopy(WizRawPixel *dstPtr, const WizRawP
void Wiz::pgTransparentBackwardsRemapPixelCopy(WizRawPixel *dstPtr, const WizRawPixel *srcPtr, int size, WizRawPixel transparentColor, const byte *lookupTable) {
if (!_uses16BitColor) {
+ WizRawPixel8 *dst8 = (WizRawPixel8 *)dstPtr;
+ const WizRawPixel8 *src8 = (const WizRawPixel8 *)srcPtr;
+
while (size-- > 0) {
- WizRawPixel srcColor = *srcPtr++;
+ WizRawPixel srcColor = *src8++;
if (transparentColor != srcColor) {
- WizRawPixel remappedColor = *(lookupTable + srcColor);
+ WizRawPixel8 remappedColor = *(lookupTable + srcColor);
if (transparentColor != remappedColor) {
- *dstPtr-- = remappedColor;
+ *dst8-- = remappedColor;
} else {
- --dstPtr;
+ --dst8;
}
} else {
- --dstPtr;
+ --dst8;
}
}
} else {
+ WizRawPixel16 *dst16 = (WizRawPixel16 *)dstPtr;
+ const WizRawPixel16 *src16 = (const WizRawPixel16 *)srcPtr;
+
while (size-- > 0) {
- WizRawPixel srcColor = *srcPtr++;
+ WizRawPixel16 srcColor = *src16++;
if (transparentColor != srcColor) {
- *dstPtr-- = srcColor;
+ *dst16-- = srcColor;
} else {
- --dstPtr;
+ --dst16;
}
}
}
@@ -1217,32 +1256,44 @@ void Wiz::pgTransparentBackwardsRemapPixelCopy(WizRawPixel *dstPtr, const WizRaw
void Wiz::pgBackwardsRemapPixelCopy(WizRawPixel *dstPtr, const WizRawPixel *srcPtr, int size, const byte *lookupTable) {
if (!_uses16BitColor) {
+ WizRawPixel8 *dst8 = (WizRawPixel8 *)dstPtr;
+ const WizRawPixel8 *src8 = (const WizRawPixel8 *)srcPtr;
+
while (size-- > 0) {
- *dstPtr-- = *(lookupTable + *srcPtr++);
+ *dst8-- = *(lookupTable + *src8++);
}
} else {
+ WizRawPixel16 *dst16 = (WizRawPixel16 *)dstPtr;
+ const WizRawPixel16 *src16 = (const WizRawPixel16 *)srcPtr;
+
while (size-- > 0) {
- *dstPtr-- = *srcPtr++;
+ *dst16-- = *src16++;
}
}
}
void Wiz::pgForewordMixColorsPixelCopy(WizRawPixel *dstPtr, const WizRawPixel *srcPtr, int size, const byte *lookupTable) {
if (!_uses16BitColor) {
+ WizRawPixel8 *dst8 = (WizRawPixel8 *)dstPtr;
+ const WizRawPixel8 *src8 = (const WizRawPixel8 *)srcPtr;
+
while (size-- > 0) {
- *dstPtr++ = *(lookupTable + ((*srcPtr++) * 256) + *dstPtr);
+ *dst8++ = *(lookupTable + ((*src8++) * 256) + *dst8);
}
} else {
+ WizRawPixel16 *dst16 = (WizRawPixel16 *)dstPtr;
+ const WizRawPixel16 *src16 = (const WizRawPixel16 *)srcPtr;
+
while (size-- > 0) {
if (_vm->_game.heversion > 99) {
- WizRawPixel srcColor = *srcPtr++;
- WizRawPixel dstColor = *dstPtr;
+ WizRawPixel16 srcColor = *src16++;
+ WizRawPixel16 dstColor = *dst16;
- *dstPtr++ = WIZRAWPIXEL_50_50_MIX(
+ *dst16++ = WIZRAWPIXEL_50_50_MIX(
WIZRAWPIXEL_50_50_PREMIX_COLOR(srcColor),
WIZRAWPIXEL_50_50_PREMIX_COLOR(dstColor));
} else {
- *dstPtr++ = (*srcPtr++);
+ *dst16++ = (*src16++);
}
}
}
@@ -1250,20 +1301,26 @@ void Wiz::pgForewordMixColorsPixelCopy(WizRawPixel *dstPtr, const WizRawPixel *s
void Wiz::pgBackwardsMixColorsPixelCopy(WizRawPixel *dstPtr, const WizRawPixel *srcPtr, int size, const byte *lookupTable) {
if (!_uses16BitColor) {
+ WizRawPixel8 *dst8 = (WizRawPixel8 *)dstPtr;
+ const WizRawPixel8 *src8 = (const WizRawPixel8 *)srcPtr;
+
while (size-- > 0) {
- *dstPtr-- = *(lookupTable + ((*srcPtr++) * 256) + *dstPtr);
+ *dst8-- = *(lookupTable + ((*src8++) * 256) + *dst8);
}
} else {
+ WizRawPixel16 *dst16 = (WizRawPixel16 *)dstPtr;
+ const WizRawPixel16 *src16 = (const WizRawPixel16 *)srcPtr;
+
while (size-- > 0) {
if (_vm->_game.heversion > 99) {
- WizRawPixel srcColor = *srcPtr++;
- WizRawPixel dstColor = *dstPtr;
+ WizRawPixel16 srcColor = *src16++;
+ WizRawPixel16 dstColor = *dst16;
- *dstPtr-- = WIZRAWPIXEL_50_50_MIX(
+ *dst16-- = WIZRAWPIXEL_50_50_MIX(
WIZRAWPIXEL_50_50_PREMIX_COLOR(srcColor),
WIZRAWPIXEL_50_50_PREMIX_COLOR(dstColor));
} else {
- *dstPtr-- = (*srcPtr++);
+ *dst16-- = (*src16++);
}
}
}
@@ -1271,33 +1328,39 @@ void Wiz::pgBackwardsMixColorsPixelCopy(WizRawPixel *dstPtr, const WizRawPixel *
void Wiz::pgTransparentForewordMixColorsPixelCopy(WizRawPixel *dstPtr, const WizRawPixel *srcPtr, int size, WizRawPixel transparentColor, const byte *lookupTable) {
if (!_uses16BitColor) {
+ WizRawPixel8 *dst8 = (WizRawPixel8 *)dstPtr;
+ const WizRawPixel8 *src8 = (const WizRawPixel8 *)srcPtr;
+
while (size-- > 0) {
- WizRawPixel srcColor = *srcPtr++;
+ WizRawPixel8 srcColor = *src8++;
if (transparentColor != srcColor) {
- WizRawPixel resultColor = *(lookupTable + (srcColor * 256) + *dstPtr);
+ WizRawPixel8 resultColor = *(lookupTable + (srcColor * 256) + *dst8);
if (transparentColor != resultColor) {
- *dstPtr++ = resultColor;
+ *dst8++ = resultColor;
} else {
- ++dstPtr;
+ ++dst8;
}
} else {
- ++dstPtr;
+ ++dst8;
}
}
} else {
+ WizRawPixel16 *dst16 = (WizRawPixel16 *)dstPtr;
+ const WizRawPixel16 *src16 = (const WizRawPixel16 *)srcPtr;
+
while (size-- > 0) {
- WizRawPixel srcColor = *srcPtr++;
+ WizRawPixel16 srcColor = *src16++;
if (transparentColor != srcColor) {
- WizRawPixel dstColor = *dstPtr;
+ WizRawPixel16 dstColor = *dst16;
- *dstPtr++ = WIZRAWPIXEL_50_50_MIX(
+ *dst16++ = WIZRAWPIXEL_50_50_MIX(
WIZRAWPIXEL_50_50_PREMIX_COLOR(srcColor),
WIZRAWPIXEL_50_50_PREMIX_COLOR(dstColor));
} else {
- ++dstPtr;
+ ++dst16;
}
}
}
@@ -1305,57 +1368,97 @@ void Wiz::pgTransparentForewordMixColorsPixelCopy(WizRawPixel *dstPtr, const Wiz
void Wiz::pgTransparentBackwardsMixColorsPixelCopy(WizRawPixel *dstPtr, const WizRawPixel *srcPtr, int size, WizRawPixel transparentColor, const byte *lookupTable) {
if (!_uses16BitColor) {
+ WizRawPixel8 *dst8 = (WizRawPixel8 *)dstPtr;
+ const WizRawPixel8 *src8 = (const WizRawPixel8 *)srcPtr;
+
while (size-- > 0) {
- WizRawPixel srcColor = *srcPtr++;
+ WizRawPixel8 srcColor = *src8++;
if (transparentColor != srcColor) {
- WizRawPixel resultColor = *(lookupTable + (srcColor * 256) + *dstPtr);
+ WizRawPixel8 resultColor = *(lookupTable + (srcColor * 256) + *dst8);
if (transparentColor != resultColor) {
- *dstPtr-- = resultColor;
+ *dst8-- = resultColor;
} else {
- --dstPtr;
+ --dst8;
}
} else {
- --dstPtr;
+ --dst8;
}
}
} else {
+ WizRawPixel16 *dst16 = (WizRawPixel16 *)dstPtr;
+ const WizRawPixel16 *src16 = (const WizRawPixel16 *)srcPtr;
+
while (size-- > 0) {
- WizRawPixel srcColor = *srcPtr++;
+ WizRawPixel16 srcColor = *src16++;
if (transparentColor != srcColor) {
- WizRawPixel dstColor = *dstPtr;
+ WizRawPixel16 dstColor = *dst16;
- *dstPtr-- = WIZRAWPIXEL_50_50_MIX(
+ *dst16-- = WIZRAWPIXEL_50_50_MIX(
WIZRAWPIXEL_50_50_PREMIX_COLOR(srcColor),
WIZRAWPIXEL_50_50_PREMIX_COLOR(dstColor));
} else {
- --dstPtr;
+ --dst16;
}
}
}
}
static void pgBlitForwardSrcArbitraryDstPixelTransfer(Wiz *wiz, WizRawPixel *dstPtr, int dstStep, const WizRawPixel *srcPtr, int count, const void *userParam, const void *userParam2) {
- for (int i = 0; i < count; i++) {
- *dstPtr = *srcPtr++;
- dstPtr += dstStep;
+ if (!wiz->_uses16BitColor) {
+ WizRawPixel8 *dst8 = (WizRawPixel8 *)dstPtr;
+ const WizRawPixel8 *src8 = (const WizRawPixel8 *)srcPtr;
+
+ for (int i = 0; i < count; i++) {
+ *dst8 = *src8++;
+ dst8 += dstStep;
+ }
+ } else {
+ WizRawPixel16 *dst16 = (WizRawPixel16 *)dstPtr;
+ const WizRawPixel16 *src16 = (const WizRawPixel16 *)srcPtr;
+
+ for (int i = 0; i < count; i++) {
+ *dst16 = *src16++;
+ dst16 += dstStep;
+ }
}
}
static void pgBlitForwardSrcArbitraryDstTransparentPixelTransfer(Wiz *wiz, WizRawPixel *dstPtr, int dstStep, const WizRawPixel *srcPtr, int count, const void *userParam, const void *userParam2) {
- WizRawPixel transparentColor, color;
- transparentColor = *((const WizRawPixel *)userParam);
+ if (!wiz->_uses16BitColor) {
+ WizRawPixel8 *dst8 = (WizRawPixel8 *)dstPtr;
+ const WizRawPixel8 *src8 = (const WizRawPixel8 *)srcPtr;
- for (int i = 0; i < count; i++) {
- color = *srcPtr++;
+ WizRawPixel8 transparentColor, color;
+ transparentColor = *((const WizRawPixel8 *)userParam);
+
+ for (int i = 0; i < count; i++) {
+ color = *src8++;
+
+ if (transparentColor != color) {
+ *dst8 = color;
+ }
- if (transparentColor != color) {
- *dstPtr = color;
+ dst8 += dstStep;
}
+ } else {
+ WizRawPixel16 *dst16 = (WizRawPixel16 *)dstPtr;
+ const WizRawPixel16 *src16 = (const WizRawPixel16 *)srcPtr;
+
+ WizRawPixel16 transparentColor, color;
+ transparentColor = *((const WizRawPixel16 *)userParam);
- dstPtr += dstStep;
+ for (int i = 0; i < count; i++) {
+ color = *src16++;
+
+ if (transparentColor != color) {
+ *dst16 = color;
+ }
+
+ dst16 += dstStep;
+ }
}
}
@@ -1377,8 +1480,11 @@ void Wiz::pgBlit90DegreeRotateCore(WizSimpleBitmap *dstBitmap, int x, int y, con
Common::Rect dstRect, srcRect, clipRect, clippedDstRect, clippedSrcRect;
int dstOffset, dstStep, w, h, srcOffset, dstX, dstY;
- const WizRawPixel *srcPtr;
- WizRawPixel *dstPtr;
+
+ const WizRawPixel8 *src8;
+ WizRawPixel8 *dst8;
+ const WizRawPixel16 *src16;
+ WizRawPixel16 *dst16;
// Do as much pre-clipping as possible
makeSizedRect(&clipRect, dstBitmap->bitmapWidth, dstBitmap->bitmapHeight);
@@ -1433,19 +1539,30 @@ void Wiz::pgBlit90DegreeRotateCore(WizSimpleBitmap *dstBitmap, int x, int y, con
}
// Finally get down to business and do the blit!
- dstPtr = dstBitmap->bufferPtr + dstX + (dstY * dstBitmap->bitmapWidth);
- srcPtr = srcBitmap->bufferPtr + clippedSrcRect.left + (clippedSrcRect.top * srcBitmap->bitmapWidth);
-
w = getRectWidth(&clippedSrcRect);
h = getRectHeight(&clippedSrcRect);
// Transfer the src line to the dest line using the passed transfer prim.
srcOffset = srcBitmap->bitmapWidth;
- while (--h >= 0) {
- (*srcTransferFP)(this, dstPtr, dstStep, srcPtr, w, userParam, userParam2);
- dstPtr += dstOffset;
- srcPtr += srcOffset;
+ if (!_uses16BitColor) {
+ dst8 = ((WizRawPixel8 *)dstBitmap->bufferPtr) + dstX + (dstY * dstBitmap->bitmapWidth);
+ src8 = ((WizRawPixel8 *)srcBitmap->bufferPtr) + clippedSrcRect.left + (clippedSrcRect.top * srcBitmap->bitmapWidth);
+
+ while (--h >= 0) {
+ (*srcTransferFP)(this, (WizRawPixel *)dst8, dstStep, (WizRawPixel *)src8, w, userParam, userParam2);
+ dst8 += dstOffset;
+ src8 += srcOffset;
+ }
+ } else {
+ dst16 = ((WizRawPixel16 *)dstBitmap->bufferPtr) + dstX + (dstY * dstBitmap->bitmapWidth);
+ src16 = ((WizRawPixel16 *)srcBitmap->bufferPtr) + clippedSrcRect.left + (clippedSrcRect.top * srcBitmap->bitmapWidth);
+
+ while (--h >= 0) {
+ (*srcTransferFP)(this, (WizRawPixel *)dst16, dstStep, (WizRawPixel *)src16, w, userParam, userParam2);
+ dst16 += dstOffset;
+ src16 += srcOffset;
+ }
}
}
diff --git a/engines/scumm/he/intern_he.h b/engines/scumm/he/intern_he.h
index 11b4f46d366..7427bb150a6 100644
--- a/engines/scumm/he/intern_he.h
+++ b/engines/scumm/he/intern_he.h
@@ -26,7 +26,7 @@
#ifdef ENABLE_HE
#include "scumm/he/wiz_he.h"
#endif
-#include "scumm/actor_he.h" // For AuxBlock & AuxEntry
+#include "scumm/actor_he.h" // For HEEraseAuxEntry & HEAnimAuxEntry
namespace Common {
class SeekableReadStream;
@@ -275,7 +275,7 @@ protected:
SO_SET_POLYGON_LOCAL = 248,
};
- bool _skipProcessActors;
+ bool _disableActorDrawingFlag;
public:
ScummEngine_v71he(OSystem *syst, const DetectorResult &dr);
@@ -298,7 +298,7 @@ protected:
void processActors() override;
void heFlushAuxEraseQueue();
- void heFlushAuxQueues();
+ virtual void heFlushAuxQueues();
void clearDrawQueues() override;
@@ -321,13 +321,13 @@ protected:
byte VAR_WIZ_TRANSPARENT_COLOR;
public:
/* Actor AuxQueue stuff (HE) */
- AuxBlock _auxBlocks[16];
- uint16 _auxBlocksNum;
- AuxEntry _auxEntries[16];
- uint16 _auxEntriesNum;
+ HEEraseAuxEntry _heAuxEraseActorTable[16];
+ int _heAuxEraseActorIndex = 0;
+ HEAnimAuxEntry _heAuxAnimTable[16];
+ int _heAuxAnimTableIndex = 0;
- void queueAuxBlock(ActorHE *a);
- void queueAuxEntry(int actorNum, int subIndex);
+ void heQueueEraseAuxActor(ActorHE *a);
+ void heQueueAnimAuxFrame(int actorNum, int subIndex);
void remapHEPalette(const uint8 *src, uint8 *dst);
};
@@ -680,6 +680,12 @@ protected:
void setResourceOffHeap(int typeId, int resId, int val);
void processActors() override;
+ void heFlushAuxQueues() override;
+ const byte *heAuxFindBlock(HEAnimAuxData *auxInfoPtr, int32 id);
+ void heAuxReleaseAuxDataInfo(HEAnimAuxData *auxInfoPtr);
+ void heAuxGetAuxDataInfo(HEAnimAuxData *auxInfoPtr, int whichActor, int auxIndex);
+ bool heAuxProcessFileRelativeBlock(HEAnimAuxData *auxInfoPtr, const byte *dataBlockPtr);
+ bool heAuxProcessDisplacedBlock(HEAnimAuxData *auxInfoPtr, const byte *displacedBlockPtr);
void getArrayDim(int array, int *dim2start, int *dim2end, int *dim1start, int *dim1end);
void sortArray(int array, int dim2start, int dim2end, int dim1start, int dim1end, int sortOrder);
diff --git a/engines/scumm/he/resource_he.cpp b/engines/scumm/he/resource_he.cpp
index 123c7423dae..07d8d47d61c 100644
--- a/engines/scumm/he/resource_he.cpp
+++ b/engines/scumm/he/resource_he.cpp
@@ -313,6 +313,11 @@ void ScummEngine_v90he::readMAXS(int blockSize) {
_numSprites = _fileHandle->readUint16LE();
_numLocalScripts = _fileHandle->readUint16LE();
_HEHeapSize = _fileHandle->readUint16LE();
+
+ // In the original, this is hardcoded as well...
+ if (_game.heversion > 90)
+ _numPalettes = 16;
+
_numNewNames = 10;
_objectRoomTable = (byte *)calloc(_numGlobalObjects, 1);
diff --git a/engines/scumm/he/script_v100he.cpp b/engines/scumm/he/script_v100he.cpp
index 6bb3db1cf53..620ac19b201 100644
--- a/engines/scumm/he/script_v100he.cpp
+++ b/engines/scumm/he/script_v100he.cpp
@@ -428,7 +428,7 @@ void ScummEngine_v100he::o100_actorOps() {
a->setScale(i, i);
break;
case SO_SHADOW:
- a->_heXmapNum = pop();
+ a->_heShadow = pop();
a->_needRedraw = true;
break;
case SO_STEP_DIST:
diff --git a/engines/scumm/he/script_v71he.cpp b/engines/scumm/he/script_v71he.cpp
index 850d17de80e..ef351cb306d 100644
--- a/engines/scumm/he/script_v71he.cpp
+++ b/engines/scumm/he/script_v71he.cpp
@@ -183,7 +183,7 @@ void ScummEngine_v71he::o71_kernelSetFunctions() {
break;
case 20: // HE72+
a = (ActorHE *)derefActor(args[1], "o71_kernelSetFunctions: 20");
- queueAuxBlock(a);
+ heQueueEraseAuxActor(a);
break;
case 21:
_skipDrawObject = 1;
@@ -196,33 +196,33 @@ void ScummEngine_v71he::o71_kernelSetFunctions() {
_fullRedraw = true;
break;
case 24:
- _skipProcessActors = 1;
+ _disableActorDrawingFlag = 1;
redrawAllActors();
break;
case 25:
- _skipProcessActors = 0;
+ _disableActorDrawingFlag = 0;
redrawAllActors();
break;
case 26:
a = (ActorHE *)derefActor(args[1], "o71_kernelSetFunctions: 26");
- a->_auxBlock.r.left = 0;
- a->_auxBlock.r.right = -1;
- a->_auxBlock.r.top = 0;
- a->_auxBlock.r.bottom = -2;
+ a->_auxEraseX1 = 0;
+ a->_auxEraseY1 = -1;
+ a->_auxEraseX2 = 0;
+ a->_auxEraseY2 = -2;
break;
case 30:
a = (ActorHE *)derefActor(args[1], "o71_kernelSetFunctions: 30");
a->_clipOverride.bottom = args[2];
break;
case 42:
- _wiz->_lUseWizClipRect = true;
- _wiz->_lWizClipRect.left = args[1];
- _wiz->_lWizClipRect.top = args[2];
- _wiz->_lWizClipRect.right = args[3];
- _wiz->_lWizClipRect.bottom = args[4];
+ _wiz->_useWizClipRect = true;
+ _wiz->_wizClipRect.left = args[1];
+ _wiz->_wizClipRect.top = args[2];
+ _wiz->_wizClipRect.right = args[3];
+ _wiz->_wizClipRect.bottom = args[4];
break;
case 43:
- _wiz->_lUseWizClipRect = false;
+ _wiz->_useWizClipRect = false;
break;
default:
error("o71_kernelSetFunctions: default case %d (param count %d)", args[0], num);
diff --git a/engines/scumm/he/script_v72he.cpp b/engines/scumm/he/script_v72he.cpp
index bb010eb53d6..1a57b36b763 100644
--- a/engines/scumm/he/script_v72he.cpp
+++ b/engines/scumm/he/script_v72he.cpp
@@ -959,7 +959,7 @@ void ScummEngine_v72he::o72_actorOps() {
a->setAnimSpeed(pop());
break;
case SO_SHADOW:
- a->_heXmapNum = pop();
+ a->_heShadow = pop();
a->_needRedraw = true;
break;
case SO_TEXT_OFFSET:
diff --git a/engines/scumm/he/script_v90he.cpp b/engines/scumm/he/script_v90he.cpp
index d216c313d17..9805893102a 100644
--- a/engines/scumm/he/script_v90he.cpp
+++ b/engines/scumm/he/script_v90he.cpp
@@ -1617,7 +1617,7 @@ int auxRectsOverlap(const Common::Rect *destRectPtr, const Common::Rect *sourceR
void ScummEngine_v90he::o90_getOverlap() {
int firstCount, lastCount, checkType, firstRadius, ax, ay, bx, by;
- int nVerts, index, lastRadius, distance, counter;
+ int nVerts, index, lastRadius, distance;
Common::Point lastCenterPoint, firstCenterPoint;
Common::Rect firstRect, lastRect;
int firstList[32], lastList[32];
@@ -1890,9 +1890,9 @@ void ScummEngine_v90he::o90_redim2dimArray() {
}
void ScummEngine_v90he::o90_getLinesIntersectionPoint() {
- int x1, y1, x2, y2, x3, y3, x4, y4, returnValue, x, y;
- int dv, xVariable, yVariable, ta, tb, tc, td, t;
- float ua, ub, oodv, tua, tub;
+ int x1, y1, x2, y2, x3, y3, x4, y4, x, y;
+ int dv, xVariable, yVariable, ta, tb, tc, td;
+ float ua, ub, oodv;
bool segAIsAPoint;
bool segBIsAPoint;
@@ -1931,7 +1931,7 @@ void ScummEngine_v90he::o90_getLinesIntersectionPoint() {
} else {
// Check to see if we need to special case to point on a line...
if (segAIsAPoint) {
- int dx, dy, py;
+ int dx, py;
dx = (x4 - x3);
@@ -2432,7 +2432,7 @@ void ScummEngine_v90he::o90_kernelSetFunctions() {
switch (args[0]) {
case 20:
a = (ActorHE *)derefActor(args[1], "o90_kernelSetFunctions: 20");
- queueAuxBlock(a); // TODO: Shouldn't this be HEQueueEraseAuxActor?
+ heQueueEraseAuxActor(a);
break;
case 21:
_skipDrawObject = 1;
@@ -2445,25 +2445,25 @@ void ScummEngine_v90he::o90_kernelSetFunctions() {
_fullRedraw = true;
break;
case 24:
- _skipProcessActors = 1;
+ _disableActorDrawingFlag = 1;
redrawAllActors();
break;
case 25:
- _skipProcessActors = 0;
+ _disableActorDrawingFlag = 0;
redrawAllActors();
break;
case 27:
// Used in readdemo
break;
case 42:
- _wiz->_lUseWizClipRect = true;
- _wiz->_lWizClipRect.left = args[1];
- _wiz->_lWizClipRect.top = args[2];
- _wiz->_lWizClipRect.right = args[3];
- _wiz->_lWizClipRect.bottom = args[4];
+ _wiz->_useWizClipRect = true;
+ _wiz->_wizClipRect.left = args[1];
+ _wiz->_wizClipRect.top = args[2];
+ _wiz->_wizClipRect.right = args[3];
+ _wiz->_wizClipRect.bottom = args[4];
break;
case 43:
- _wiz->_lUseWizClipRect = false;
+ _wiz->_useWizClipRect = false;
break;
case 714:
setResourceOffHeap(args[1], args[2], args[3]);
diff --git a/engines/scumm/he/sprite_he.cpp b/engines/scumm/he/sprite_he.cpp
index 4e921de6d2a..0b402e7ca5f 100644
--- a/engines/scumm/he/sprite_he.cpp
+++ b/engines/scumm/he/sprite_he.cpp
@@ -1339,6 +1339,10 @@ void Sprite::resetSpriteSystem(bool refreshScreen) {
}
if (_vm->_game.heversion >= 98) {
+ for (int i = 1; i < _maxSprites; i++) {
+ newSprite(i);
+ }
+
for (int i = 1; i < _maxSpriteGroups; i++) {
newGroup(i);
}
diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp
index 939525d3472..e06d799bbc5 100644
--- a/engines/scumm/he/wiz_he.cpp
+++ b/engines/scumm/he/wiz_he.cpp
@@ -39,7 +39,7 @@ Wiz::Wiz(ScummEngine_v71he *vm) : _vm(vm) {
memset(&_wizBuffer, 0, sizeof(_wizBuffer));
memset(&_polygons, 0, sizeof(_polygons));
_cursorImage = false;
- _lUseWizClipRect = false;
+ _useWizClipRect = false;
_uses16BitColor = (_vm->_game.features & GF_16BIT_COLOR);
}
@@ -140,16 +140,16 @@ byte *Wiz::drawAWizEx(int image, int state, int x, int y, int z, int flags, int
// Get the "shadow"...
if (!optionalShadowImage) {
- if (_lWizActiveShadow && (flags & kWRFUseShadow)) {
- optionalShadowImage = _lWizActiveShadow;
+ if (_wizActiveShadow && (flags & kWRFUseShadow)) {
+ optionalShadowImage = _wizActiveShadow;
}
}
if (!(flags & kWRFPolygon)) {
// Get the clipping rect if any...
if (!optionalClipRect) {
- if (_lUseWizClipRect && !(flags & (kWRFPrint | kWRFAlloc))) {
- clipRectPtr = &_lWizClipRect;
+ if (_useWizClipRect && !(flags & (kWRFPrint | kWRFAlloc))) {
+ clipRectPtr = &_wizClipRect;
} else {
clipRectPtr = nullptr;
}
@@ -606,14 +606,13 @@ int Wiz::pixelHitTestWiz(int image, int state, int x, int y, int32 flags) {
}
int Wiz::pixelHitTestWizPrim(int globNum, int state, int x, int y, int32 flags) {
+ // U32 TODO
+ //int outValue = 0;
+ //
+ //if (PU_OverrideImagePixelHitTest(&outValue, globType, globNum, state, x, y, flags)) {
+ // return outValue;
+ //}
-#ifdef SCUMM_XTL_BRIDGE // 5/9/2000 BPT
- int outValue = 0;
-
- if (PU_OverrideImagePixelHitTest(&outValue, globType, globNum, state, x, y, flags)) {
- return outValue;
- }
-#endif
int src_c, src_w, src_h;
byte *src_d;
diff --git a/engines/scumm/he/wiz_he.h b/engines/scumm/he/wiz_he.h
index 97009db6904..df32ae2d691 100644
--- a/engines/scumm/he/wiz_he.h
+++ b/engines/scumm/he/wiz_he.h
@@ -518,11 +518,11 @@ public:
Wiz(ScummEngine_v71he *vm);
void clearWizBuffer();
- Common::Rect _lWizClipRect;
+ Common::Rect _wizClipRect;
bool _cursorImage;
- bool _lUseWizClipRect = false;
+ bool _useWizClipRect = false;
bool _uses16BitColor = false;
- int _lWizActiveShadow = 0;
+ int _wizActiveShadow = 0;
void deleteLocalPolygons();
void polygonLoad(const uint8 *polData);
@@ -652,6 +652,7 @@ public:
void pgSimpleBlitTransparentMixColors(WizSimpleBitmap *destBM, Common::Rect *destRect, WizSimpleBitmap *sourceBM, Common::Rect *sourceRect, WizRawPixel transparentColor, const byte *mixColorTable);
void pgTransparentSimpleBlit(WizSimpleBitmap *destBM, Common::Rect *destRect, WizSimpleBitmap *sourceBM, Common::Rect *sourceRect, WizRawPixel transparentColor);
+ void pgDrawWarpDrawLetter(WizRawPixel *bitmapBuffer, int bitmapWidth, int bitmapHeight, const byte *charData, int x1, int y1, int width, int height, byte *colorLookupTable);
void pgDraw8BppFormatImage(WizRawPixel *bufferPtr, const byte *rawData, int bufferWidth, int bufferHeight, int x, int y, int width, int height, Common::Rect *clipRectPtr, int32 wizFlags, const void *extraTable, int transparentColor, const WizRawPixel *conversionTable);
void pgDraw8BppSimpleBlit(WizSimpleBitmap *destBM, Common::Rect *destRect, WizSimpleBitmap *sourceBM, Common::Rect *sourceRect, const WizRawPixel *conversionTable);
void pgDraw8BppTransparentSimpleBlit(WizSimpleBitmap *destBM, Common::Rect *destRect, WizSimpleBitmap *sourceBM, Common::Rect *sourceRect, int transparentColor, const WizRawPixel *conversionTable);
@@ -732,19 +733,19 @@ public:
void auxDecompSRLEStream(WizRawPixel *destStream, const WizRawPixel *backgroundStream, const byte *singleColorTable, const byte *streamData, int streamSize, const WizRawPixel *conversionTable);
- void auxDecompDRLEStream(WizRawPixel *destPtr, byte *dataStream, WizRawPixel *backgroundPtr, int skipAmount, int decompAmount, const WizRawPixel *conversionTable);
- void auxDecompDRLEImage(WizRawPixel *foregroundBufferPtr, WizRawPixel *backgroundBufferPtr, byte *compData, int bufferWidth, int bufferHeight, int x, int y, int width, int height, Common::Rect *clipRectPtr, const WizRawPixel *conversionTable);
- void auxDecompDRLEPrim(WizRawPixel *foregroundBufferPtr, WizRawPixel *backgroundBufferPtr, int bufferWidth, Common::Rect *destRect, byte *compData, Common::Rect *sourceRect, const WizRawPixel *conversionTable);
+ void auxDecompDRLEStream(WizRawPixel *destPtr, const byte *dataStream, WizRawPixel *backgroundPtr, int skipAmount, int decompAmount, const WizRawPixel *conversionTable);
+ void auxDecompDRLEImage(WizRawPixel *foregroundBufferPtr, WizRawPixel *backgroundBufferPtr, const byte *compData, int bufferWidth, int bufferHeight, int x, int y, int width, int height, Common::Rect *clipRectPtr, const WizRawPixel *conversionTable);
+ void auxDecompDRLEPrim(WizRawPixel *foregroundBufferPtr, WizRawPixel *backgroundBufferPtr, int bufferWidth, Common::Rect *destRect, const byte *compData, Common::Rect *sourceRect, const WizRawPixel *conversionTable);
void auxDecompTRLEStream(WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable);
void auxDecompTRLEImage(WizRawPixel *bufferPtr, const byte *compData, int bufferWidth, int bufferHeight, int x, int y, int width, int height, Common::Rect *clipRectPtr, const WizRawPixel *conversionTable);
void auxDecompTRLEPrim(WizRawPixel *bufferPtr, int bufferWidth, Common::Rect *destRect, const byte *compData, Common::Rect *sourceRect, const WizRawPixel *conversionTable);
- void auxDrawZplaneFromTRLEImage(byte *zplanePtr, byte *compData, int zplanePixelWidth, int zplanePixelHeight, int x, int y, int width, int height, Common::Rect *clipRectPtr, int transOp, int solidOp);
- void auxDrawZplaneFromTRLEPrim(byte *zplanePtr, int zplanePixelWidth, Common::Rect *destRect, byte *compData, Common::Rect *sourceRect, int transOp, int solidOp);
+ void auxDrawZplaneFromTRLEImage(byte *zplanePtr, const byte *compData, int zplanePixelWidth, int zplanePixelHeight, int x, int y, int width, int height, Common::Rect *clipRectPtr, int transOp, int solidOp);
+ void auxDrawZplaneFromTRLEPrim(byte *zplanePtr, int zplanePixelWidth, Common::Rect *destRect, const byte *compData, Common::Rect *sourceRect, int transOp, int solidOp);
- void auxDecompRemappedTRLEStream(WizRawPixel *destPtr, byte *dataStream, int skipAmount, int decompAmount, byte *remapTable, const WizRawPixel *conversionTable);
- void auxDecompRemappedTRLEImage(WizRawPixel *bufferPtr, byte *compData, int bufferWidth, int bufferHeight, int x, int y, int width, int height, Common::Rect *clipRectPtr, byte *remapTable, const WizRawPixel *conversionTable);
- void auxDecompRemappedTRLEPrim(WizRawPixel *bufferPtr, int bufferWidth, Common::Rect *destRect, byte *compData, Common::Rect *sourceRect, byte *remapTable, const WizRawPixel *conversionTable);
+ void auxDecompRemappedTRLEStream(WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, byte *remapTable, const WizRawPixel *conversionTable);
+ void auxDecompRemappedTRLEImage(WizRawPixel *bufferPtr, const byte *compData, int bufferWidth, int bufferHeight, int x, int y, int width, int height, Common::Rect *clipRectPtr, byte *remapTable, const WizRawPixel *conversionTable);
+ void auxDecompRemappedTRLEPrim(WizRawPixel *bufferPtr, int bufferWidth, Common::Rect *destRect, const byte *compData, Common::Rect *sourceRect, byte *remapTable, const WizRawPixel *conversionTable);
bool auxHitTestTRLEXPos(const byte *dataStream, int skipAmount);
bool auxHitTestTRLEImageRelPos(const byte *compData, int x, int y, int width, int height);
@@ -759,11 +760,11 @@ public:
const WizRawPixel *conversionTable);
void auxRemappedMemcpy(
- WizRawPixel *dstPtr, byte *srcPtr, int count, byte *remapTable,
+ WizRawPixel *dstPtr, const byte *srcPtr, int count, byte *remapTable,
const WizRawPixel *conversionTable);
void auxZplaneFromTRLEStream(
- byte *destPtr, byte *dataStream, int skipAmount, int decompAmount,
+ byte *destPtr, const byte *dataStream, int skipAmount, int decompAmount,
int mask, int transOp, int solidOp);
void auxHistogramTRLELine(int *tablePtr, const byte *dataStream, int skipAmount, int decompAmount);
diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
index 9752cb0a606..14ed7c292ca 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -703,16 +703,14 @@ ScummEngine_v70he::~ScummEngine_v70he() {
#ifdef ENABLE_HE
ScummEngine_v71he::ScummEngine_v71he(OSystem *syst, const DetectorResult &dr)
: ScummEngine_v70he(syst, dr) {
- _auxBlocksNum = 0;
- for (uint i = 0; i < ARRAYSIZE(_auxBlocks); i++) {
- _auxBlocks[i].clear();
- }
- _auxEntriesNum = 0;
- memset(_auxEntries, 0, sizeof(_auxEntries));
+ _heAuxEraseActorIndex = 0;
+ memset(_heAuxEraseActorTable, 0, sizeof(_heAuxEraseActorTable));
+ _heAuxAnimTableIndex = 0;
+ memset(_heAuxAnimTable, 0, sizeof(_heAuxAnimTable));
_wiz = new Wiz(this);
- _skipProcessActors = 0;
+ _disableActorDrawingFlag = 0;
VAR_WIZ_TRANSPARENT_COLOR = 0xFF;
}
Commit: 2da460850642c6e4c9a802f0ec9cd1b83152e35d
https://github.com/scummvm/scummvm/commit/2da460850642c6e4c9a802f0ec9cd1b83152e35d
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Re-implement BMAP routines
Changed paths:
engines/scumm/gfx.cpp
diff --git a/engines/scumm/gfx.cpp b/engines/scumm/gfx.cpp
index 66f50f762e5..b1d128b12ea 100644
--- a/engines/scumm/gfx.cpp
+++ b/engines/scumm/gfx.cpp
@@ -2461,20 +2461,16 @@ void GdiV2::decodeMask(int x, int y, const int width, const int height,
* the generic Gdi::drawBitmap() method.
*/
void Gdi::drawBMAPBg(const byte *ptr, VirtScreen *vs) {
- const byte *z_plane_ptr;
- byte *mask_ptr;
- const byte *zplane_list[9];
+ const byte *zPlanePtr;
+ byte *maskPtr;
+ const byte *zPlaneList[9];
- const byte *bmap_ptr = _vm->findResourceData(MKTAG('B','M','A','P'), ptr);
- assert(bmap_ptr);
+ const byte *bmapPtr = _vm->findResourceData(MKTAG('B','M','A','P'), ptr);
+ assert(bmapPtr);
- byte code = *bmap_ptr++;
+ byte code = *bmapPtr++;
byte *dst = vs->getBackPixels(0, 0);
- // The following few lines more or less duplicate decompressBitmap(), only
- // for an area spanning multiple strips. In particular, the codecs 13 & 14
- // in decompressBitmap call drawStripHE()
-
switch (code) {
case BMCOMP_NMAJMIN_H4:
case BMCOMP_NMAJMIN_H5:
@@ -2483,7 +2479,7 @@ void Gdi::drawBMAPBg(const byte *ptr, VirtScreen *vs) {
case BMCOMP_NMAJMIN_H8:
_decomp_shr = code - BMCOMP_NMAJMIN_H0; // Bits per pixel
_decomp_mask = bitMasks[_decomp_shr];
- drawStripHE(dst, vs->pitch, bmap_ptr, vs->w, vs->h, false);
+ drawStripHE(dst, vs->pitch, bmapPtr, vs->w, vs->h, false);
break;
case BMCOMP_NMAJMIN_HT4:
case BMCOMP_NMAJMIN_HT5:
@@ -2492,11 +2488,24 @@ void Gdi::drawBMAPBg(const byte *ptr, VirtScreen *vs) {
case BMCOMP_NMAJMIN_HT8:
_decomp_shr = code - BMCOMP_NMAJMIN_HT0; // Bits per pixel
_decomp_mask = bitMasks[_decomp_shr];
- drawStripHE(dst, vs->pitch, bmap_ptr, vs->w, vs->h, false);
+ drawStripHE(dst, vs->pitch, bmapPtr, vs->w, vs->h, false);
break;
case BMCOMP_SOLID_COLOR_FILL:
- fill(dst, vs->pitch, *bmap_ptr, vs->w, vs->h, vs->format.bytesPerPixel);
+ {
+ WizRawPixel color = ((ScummEngine_v71he *)_vm)->_wiz->convert8BppToRawPixel(*bmapPtr, (WizRawPixel *)_vm->getHEPaletteSlot(1));
+
+ if (_vm->_game.heversion > 99 && _vm->VAR_COLOR_BLACK != 0xFF && _vm->VAR(_vm->VAR_COLOR_BLACK) == color)
+ break;
+
+ WizSimpleBitmap dstBitmap;
+ dstBitmap.bufferPtr = (WizRawPixel *)dst;
+ dstBitmap.bitmapWidth = vs->w;
+ dstBitmap.bitmapHeight = vs->h;
+ Common::Rect fillRect(0, 0, (dstBitmap.bitmapWidth - 1), (dstBitmap.bitmapHeight - 1));
+
+ ((ScummEngine_v71he *)_vm)->_wiz->pgDrawSolidRect(&dstBitmap, &fillRect, color);
break;
+ }
default:
// Alternative russian freddi3 uses badly formatted bitmaps
debug(0, "Gdi::drawBMAPBg: default case %d", code);
@@ -2504,22 +2513,22 @@ void Gdi::drawBMAPBg(const byte *ptr, VirtScreen *vs) {
((ScummEngine_v71he *)_vm)->backgroundToForegroundBlit(Common::Rect(vs->w, vs->h));
- int numzbuf = getZPlanes(ptr, zplane_list, true);
+ int numzbuf = getZPlanes(ptr, zPlaneList, true);
if (numzbuf <= 1)
return;
uint32 offs;
for (int stripnr = 0; stripnr < _numStrips; stripnr++) {
for (int i = 1; i < numzbuf; i++) {
- if (!zplane_list[i])
+ if (!zPlaneList[i])
continue;
- offs = READ_LE_UINT16(zplane_list[i] + stripnr * 2 + 8);
- mask_ptr = getMaskBuffer(stripnr, 0, i);
+ offs = READ_LE_UINT16(zPlaneList[i] + stripnr * 2 + 8);
+ maskPtr = getMaskBuffer(stripnr, 0, i);
if (offs) {
- z_plane_ptr = zplane_list[i] + offs;
- decompressMaskImg(mask_ptr, z_plane_ptr, vs->h);
+ zPlanePtr = zPlaneList[i] + offs;
+ decompressMaskImg(maskPtr, zPlanePtr, vs->h);
}
}
@@ -2547,20 +2556,39 @@ void Gdi::drawBMAPBg(const byte *ptr, VirtScreen *vs) {
}
void Gdi::drawBMAPObject(const byte *ptr, VirtScreen *vs, int obj, int x, int y, int w, int h) {
- const byte *bmap_ptr = _vm->findResourceData(MKTAG('B','M','A','P'), ptr);
- assert(bmap_ptr);
+ const byte *bmapPtr = _vm->findResourceData(MKTAG('B','M','A','P'), ptr);
+ assert(bmapPtr);
- byte code = *bmap_ptr++;
+ byte code = *bmapPtr++;
int scrX = _vm->_screenStartStrip * 8 * _vm->_bytesPerPixel;
+ WizRawPixel *dst = (WizRawPixel *)(_vm->_virtscr[kMainVirtScreen].backBuf + scrX);
- if (code == BMCOMP_RLE8BIT || code == BMCOMP_TRLE8BIT) {
+ switch (code) {
+ case BMCOMP_RLE8BIT:
+ case BMCOMP_TRLE8BIT:
+ {
Common::Rect rScreen(0, 0, vs->w, vs->h);
- WizRawPixel *dst = (WizRawPixel *)(_vm->_virtscr[kMainVirtScreen].backBuf + scrX);
- // TODO: Wiz::copyWizImage(dst, bmap_ptr, vs->pitch, kDstScreen, vs->w, vs->h, x - scrX, y, w, h, &rScreen, 0, 0, 0, _vm->_bytesPerPixel);
- ((ScummEngine_v71he *)_vm)->_wiz->auxDecompTRLEImage(
- dst, bmap_ptr, vs->w, vs->h,
- x - scrX, y, w, h, &rScreen,
- nullptr);
+ ((ScummEngine_v71he *)_vm)->_wiz->auxDecompTRLEImage(dst, bmapPtr, vs->w, vs->h, x + scrX, y, w, h, &rScreen, nullptr);
+ break;
+ }
+ case BMCOMP_SOLID_COLOR_FILL:
+ {
+ WizRawPixel color = ((ScummEngine_v71he *)_vm)->_wiz->convert8BppToRawPixel(*bmapPtr, (WizRawPixel *)_vm->getHEPaletteSlot(1));
+
+ if (_vm->_game.heversion > 99 && _vm->VAR_COLOR_BLACK != 0xFF && _vm->VAR(_vm->VAR_COLOR_BLACK) == color)
+ break;
+
+ WizSimpleBitmap dstBitmap;
+ dstBitmap.bufferPtr = (WizRawPixel *)dst;
+ dstBitmap.bitmapWidth = w;
+ dstBitmap.bitmapHeight = h;
+ Common::Rect fillRect(x + scrX, y, x + scrX + w - 1, y + h - 1);
+
+ ((ScummEngine_v71he *)_vm)->_wiz->pgDrawSolidRect(&dstBitmap, &fillRect, color);
+ break;
+ }
+ default:
+ error("Gdi::drawBMAPObject(): Unhandled code %d", code);
}
Common::Rect renderArea, clipArea;
Commit: 86b9af993a1f5720a671a1d6bf966e18292a8d8a
https://github.com/scummvm/scummvm/commit/86b9af993a1f5720a671a1d6bf966e18292a8d8a
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Re-implement AKOS TRLE drawing
Changed paths:
engines/scumm/akos.cpp
engines/scumm/akos.h
engines/scumm/he/gfx_comp/aux_comp.cpp
engines/scumm/he/wiz_he.h
diff --git a/engines/scumm/akos.cpp b/engines/scumm/akos.cpp
index 59ce1706d7d..b76c3ccb841 100644
--- a/engines/scumm/akos.cpp
+++ b/engines/scumm/akos.cpp
@@ -315,13 +315,13 @@ byte AkosRenderer::drawLimb(const Actor *a, int limb) {
uint i, extra;
byte result = 0;
int xMoveCur, yMoveCur;
- uint32 heCondMaskIndex[32];
- bool useCondMask;
+ uint32 sequenceLayerIndirection[32];
+ bool useConditionalTable = false;
int lastDx, lastDy;
lastDx = lastDy = 0;
for (i = 0; i < 32; ++i) {
- heCondMaskIndex[i] = i;
+ sequenceLayerIndirection[i] = i;
}
if (_skipLimbs)
@@ -333,7 +333,6 @@ byte AkosRenderer::drawLimb(const Actor *a, int limb) {
if (cost.animType[limb] == AKAT_Empty || cost.stopped & (1 << limb))
return 0;
- useCondMask = false;
p = _aksq + cost.curpos[limb];
code = p[0];
@@ -348,11 +347,11 @@ byte AkosRenderer::drawLimb(const Actor *a, int limb) {
uint j = 0;
extra = p[3];
uint8 n = extra;
- assert(n <= ARRAYSIZE(heCondMaskIndex));
+ assert(n <= ARRAYSIZE(sequenceLayerIndirection));
while (n--) {
- heCondMaskIndex[j++] = _aksq[s++];
+ sequenceLayerIndirection[j++] = _aksq[s++];
}
- useCondMask = true;
+ useConditionalTable = true;
p += extra + 2;
code = (code == AKC_CondDrawMany) ? AKC_DrawMany : AKC_RelativeOffsetDrawMany;
}
@@ -398,7 +397,7 @@ byte AkosRenderer::drawLimb(const Actor *a, int limb) {
extra = p[2];
p += 3;
- uint32 decFlag = heCondMaskIndex[0];
+ uint32 decFlag = sequenceLayerIndirection[0];
for (i = 0; i != extra; i++) {
code = p[4];
@@ -428,10 +427,10 @@ byte AkosRenderer::drawLimb(const Actor *a, int limb) {
uint16 shadowMask = 0;
- if (!useCondMask || !_akct) {
+ if (!useConditionalTable || !_akct) {
decFlag = 1;
} else {
- uint32 cond = READ_LE_UINT32(_akct + cost.heCondMaskTable[limb] + heCondMaskIndex[i] * 4);
+ uint32 cond = READ_LE_UINT32(_akct + cost.heCondMaskTable[limb] + sequenceLayerIndirection[i] * 4);
if (cond == 0) {
decFlag = 1;
} else {
@@ -476,7 +475,7 @@ byte AkosRenderer::drawLimb(const Actor *a, int limb) {
result |= paintCelMajMin(xMoveCur, yMoveCur);
break;
case AKOS_TRLE_CODEC:
- result |= paintCelTRLE(xMoveCur, yMoveCur);
+ result |= paintCelTRLE(a->_number, a->_drawToBackBuf, xMoveCur, yMoveCur, _width, _height, _akpl[0], _xmap, 0);
break;
default:
error("akos_drawLimb: invalid _codec %d", _codec);
@@ -1153,7 +1152,149 @@ byte AkosRenderer::paintCelMajMin(int xMoveCur, int yMoveCur) {
return 0;
}
-byte AkosRenderer::paintCelTRLE(int xMoveCur, int yMoveCur) {
+#ifdef ENABLE_HE
+byte AkosRenderer::hePaintCel(int actor, int drawToBack, int celX, int celY, int celWidth, int celHeight, byte tcolor, bool allowFlip, const byte *shadowTablePtr,
+ void (*drawPtr)(ScummEngine *vm, Wiz *wiz, WizRawPixel *, int, int, Common::Rect *, const byte *, int, int, Common::Rect *, byte, const byte *shadowTablePtr, const WizRawPixel *conversionTable, int32 specialRenderFlags),
+ const WizRawPixel *conversionTable, int32 specialRenderFlags) {
+
+ int plotX, plotY;
+ bool xFlipFlag, yFlipFlag;
+ int newWidth, newHeight;
+ int topSkipAmount, rightSkipAmount, destSkipAmount, xdx;
+ Common::Rect destRect;
+ Common::Rect sourceRect;
+ Common::Rect clipRect;
+ int destBufferWidth, destBufferHeight;
+ int zClipFlag, textClipFlag;
+ WizRawPixel *destBuffer;
+ Wiz *wiz = ((ScummEngine_v71he *)_vm)->_wiz;
+ Actor *a = _vm->derefActor(actor, "hePaintCel");
+
+ if (allowFlip) {
+ yFlipFlag = false;
+ xFlipFlag = _mirror;
+ } else {
+ xFlipFlag = yFlipFlag = false;
+ }
+
+ // Find cel's "plot" position with flipping etc...
+ plotY = (int32)_actorY + (int32)celY;
+ plotX = (xFlipFlag) ? (_actorX - celX - celWidth + 1) : (_actorX + celX);
+
+ // Find which buffer to plot into. back or forground (STAMP ACTOR)...
+ VirtScreen *pvs = &_vm->_virtscr[kMainVirtScreen];
+ destBufferWidth = pvs->w;
+ destBufferHeight = pvs->h;
+
+ if (drawToBack) {
+ destBuffer = (WizRawPixel *)pvs->getBackPixels(0, 0);
+ } else {
+ destBuffer = (WizRawPixel *)pvs->getPixels(0, 0);
+ }
+
+ // Setup clipping rectangle(s)...
+ wiz->makeSizedRect(&sourceRect, celWidth, celHeight);
+ wiz->makeSizedRect(&clipRect, destBufferWidth, destBufferHeight);
+ wiz->makeSizedRectAt(&destRect, plotX, plotY, celWidth, celHeight);
+
+ // Check to see if the actor has a clipping rect...
+ if ((((ActorHE *)a)->_clipOverride.left < ((ActorHE *)a)->_clipOverride.right) &&
+ (((ActorHE *)a)->_clipOverride.top < ((ActorHE *)a)->_clipOverride.bottom)) {
+ if (destBufferHeight > ((ActorHE *)a)->_clipOverride.bottom) {
+ clipRect.left = ((ActorHE *)a)->_clipOverride.left;
+ clipRect.right = ((ActorHE *)a)->_clipOverride.right;
+ clipRect.top = ((ActorHE *)a)->_clipOverride.top;
+ clipRect.bottom = ((ActorHE *)a)->_clipOverride.bottom;
+ } else {
+ warning(
+ "Actor %d invalid clipping rect (%-3d,%3d,%-3d,%3d)", a->_number,
+ ((ActorHE *)a)->_clipOverride.left, ((ActorHE *)a)->_clipOverride.top,
+ ((ActorHE *)a)->_clipOverride.right, ((ActorHE *)a)->_clipOverride.bottom);
+ }
+ }
+
+ // Clip the coords...
+ wiz->clipRectCoords(&sourceRect, &destRect, &clipRect);
+
+ if (wiz->isRectValid(destRect)) {
+ // Mark the dest area as the changed section...
+ _vm->markRectAsDirty(kMainVirtScreen, destRect, actor);
+
+ if (destRect.top < a->_top)
+ a->_top = destRect.top;
+ if (destRect.bottom > a->_bottom)
+ a->_bottom = destRect.bottom + 1;
+
+ //SetActorUpdateArea(actor, destRect.x1, destRect.y1, destRect.x2, destRect.y2);
+
+ // Get final plot point and flip source coords if necessary.
+ if (yFlipFlag) {
+ wiz->swapRectY(&sourceRect);
+ sourceRect.top = (celHeight - 1) - sourceRect.top;
+ sourceRect.bottom = (celHeight - 1) - sourceRect.bottom;
+ }
+ if (xFlipFlag) {
+ wiz->swapRectX(&sourceRect);
+ sourceRect.left = (celWidth - 1) - sourceRect.left;
+ sourceRect.right = (celWidth - 1) - sourceRect.right;
+ }
+
+ // Call the decompression routine...
+ if (drawPtr) {
+ (*drawPtr)(_vm, wiz,
+ destBuffer, destBufferWidth, destBufferHeight, &destRect,
+ _srcPtr, celWidth, celHeight, &sourceRect, tcolor,
+ shadowTablePtr, conversionTable, specialRenderFlags);
+ }
+
+ return 2;
+ }
+
+ return 0;
+}
+
+static void heTRLEPaintPrim(ScummEngine *vm, Wiz *wiz, WizRawPixel *dstDataPtr, int dstWid, int dstHei, Common::Rect *dstRect, const byte *srcDataPtr, int srcWid, int srcHei, Common::Rect *srcRect, byte tColor, const byte *shadowTablePtr, const WizRawPixel *conversionTable, int32 specialRenderFlags) {
+ if (vm->_game.heversion > 99) {
+ int plotX, plotY;
+
+ // Convert incoming src rect to flags and adjust dest position for sub rect
+ int32 additionalRenderFlags = 0;
+
+ if (srcRect->left < srcRect->right) {
+ plotX = dstRect->left - srcRect->left;
+ } else {
+ plotX = dstRect->left - srcRect->right;
+ additionalRenderFlags |= kWRFHFlip;
+ }
+
+ if (srcRect->top < srcRect->bottom) {
+ plotY = dstRect->top - srcRect->top;
+ } else {
+ plotY = dstRect->top - srcRect->bottom;
+ additionalRenderFlags |= kWRFVFlip;
+ }
+
+ // Finally call the drawing primitive
+ wiz->trleFLIPDecompressImage(
+ dstDataPtr, srcDataPtr, dstWid, dstHei,
+ plotX, plotY, srcWid, srcHei, dstRect,
+ (specialRenderFlags & kWRFSpecialRenderBitMask) | additionalRenderFlags,
+ nullptr, conversionTable, nullptr);
+
+ } else {
+ wiz->auxDecompTRLEPrim(
+ dstDataPtr, dstWid, dstRect, srcDataPtr, srcRect, conversionTable);
+ }
+}
+
+static void heTRLEPaintPrimShadow(ScummEngine *vm, Wiz *wiz, WizRawPixel *dstDataPtr, int dstWid, int dstHei, Common::Rect *dstRect, const byte *srcDataPtr, int srcWid, int srcHei, Common::Rect *srcRect, byte tColor, const byte *shadowTablePtr, const WizRawPixel *conversionTable, int32 specialRenderFlags) {
+ wiz->auxDecompMixColorsTRLEPrim(
+ dstDataPtr, dstWid, dstRect, srcDataPtr, srcRect, shadowTablePtr,
+ conversionTable);
+}
+#endif
+
+byte AkosRenderer::paintCelTRLE(int actor, int drawToBack, int celX, int celY, int celWidth, int celHeight, byte tcolor, const byte *shadowTablePtr, int32 specialRenderFlags) {
#ifdef ENABLE_HE
/*
Common::Rect src, dst;
@@ -1230,7 +1371,33 @@ byte AkosRenderer::paintCelTRLE(int xMoveCur, int yMoveCur) {
}
*/
+ const uint8 *palPtr = nullptr;
+ if (_vm->_game.features & GF_16BIT_COLOR) {
+ palPtr = _vm->_hePalettes + _vm->_hePaletteSlot + 768;
+ if (_paletteNum) {
+ palPtr = _vm->_hePalettes + _paletteNum * _vm->_hePaletteSlot + 768;
+ } else if (_rgbs) {
+ for (uint i = 0; i < 256; i++)
+ WRITE_LE_UINT16(_palette + i, _vm->get16BitColor(_rgbs[i * 3 + 0], _rgbs[i * 3 + 1], _rgbs[i * 3 + 2]));
+ palPtr = (uint8 *)_palette;
+ }
+ } else if (_vm->_game.heversion >= 99) {
+ palPtr = _vm->_hePalettes + _vm->_hePaletteSlot + 768;
+ }
+ if (!shadowTablePtr) {
+ return hePaintCel(
+ actor, drawToBack, celX, celY, celWidth, celHeight, tcolor, false, nullptr,
+ heTRLEPaintPrim,
+ (WizRawPixel *)palPtr,
+ specialRenderFlags);
+ } else {
+ return hePaintCel(
+ actor, drawToBack, celX, celY, celWidth, celHeight, tcolor, false, shadowTablePtr,
+ heTRLEPaintPrimShadow,
+ (WizRawPixel *)palPtr,
+ specialRenderFlags);
+ }
#endif
return 0;
}
diff --git a/engines/scumm/akos.h b/engines/scumm/akos.h
index 2c5c0b238f1..4820ec2d761 100644
--- a/engines/scumm/akos.h
+++ b/engines/scumm/akos.h
@@ -23,6 +23,7 @@
#define SCUMM_AKOS_H
#include "scumm/base-costume.h"
+#include "scumm/he/wiz_he.h"
namespace Scumm {
@@ -125,7 +126,13 @@ protected:
void byleRLEDecode(ByleRLEData &v1);
byte paintCelCDATRLE(int xMoveCur, int yMoveCur);
byte paintCelMajMin(int xMoveCur, int yMoveCur);
- byte paintCelTRLE(int xMoveCur, int yMoveCur);
+ byte paintCelTRLE(int actor, int drawToBack, int celX, int celY, int celWidth, int celHeight, byte tcolor, const byte *shadowTablePtr, int32 specialRenderFlags);
+ byte hePaintCel(
+ int actor, int drawToBack, int celX, int celY, int celWidth, int celHeight, byte tcolor, bool allowFlip, const byte *shadowTablePtr,
+ void (*drawPtr)(ScummEngine *vm, Wiz *wiz, WizRawPixel *, int, int, Common::Rect *, const byte *, int, int, Common::Rect *, byte, const byte *shadowTablePtr, const WizRawPixel *conversionTable, int32 specialRenderFlags),
+ const WizRawPixel *conversionTable,
+ int32 specialRenderFlags);
+
void majMinCodecDecompress(byte *dest, int32 pitch, const byte *src, int32 t_width, int32 t_height, int32 dir, int32 numSkipBefore, int32 numSkipAfter, byte transparency, int maskLeft, int maskTop, int zBuf);
void markRectAsDirty(Common::Rect rect);
diff --git a/engines/scumm/he/gfx_comp/aux_comp.cpp b/engines/scumm/he/gfx_comp/aux_comp.cpp
index f13fa9b8614..9ea9975effe 100644
--- a/engines/scumm/he/gfx_comp/aux_comp.cpp
+++ b/engines/scumm/he/gfx_comp/aux_comp.cpp
@@ -993,7 +993,7 @@ void Wiz::auxDecompMixColorsTRLEImage(WizRawPixel *bufferPtr, byte *compData, in
conversionTable);
}
-void Wiz::auxDecompMixColorsTRLEPrim(WizRawPixel *bufferPtr, int bufferWidth, Common::Rect *destRect, byte *compData, Common::Rect *sourceRect, byte *coloMixTable, const WizRawPixel *conversionTable) {
+void Wiz::auxDecompMixColorsTRLEPrim(WizRawPixel *bufferPtr, int bufferWidth, Common::Rect *destRect, const byte *compData, Common::Rect *sourceRect, const byte *coloMixTable, const WizRawPixel *conversionTable) {
int decompWidth, decompHeight, sX1, dX1, dX2, lineSize;
WizRawPixel8 *buffer8 = (WizRawPixel8 *)bufferPtr;
WizRawPixel16 *buffer16 = (WizRawPixel16 *)bufferPtr;
@@ -1499,6 +1499,7 @@ void Wiz::auxColorMixDecompressLine(WizRawPixel *destPtr, const byte *dataStream
if (_uses16BitColor)
return;
+ WizRawPixel8 *dest8 = (WizRawPixel8 *)destPtr;
const byte *remapTable;
int runCount;
@@ -1546,7 +1547,7 @@ void Wiz::auxColorMixDecompressLine(WizRawPixel *destPtr, const byte *dataStream
/* xxxxxxx1 */
runCount >>= 1;
DoTransparentRun:
- destPtr += runCount;
+ dest8 += runCount;
decompAmount -= runCount;
} else if (runCount & 2) {
@@ -1560,7 +1561,7 @@ void Wiz::auxColorMixDecompressLine(WizRawPixel *destPtr, const byte *dataStream
remapTable = colorMixTable + ((*((const byte *)dataStream)) << 8);
dataStream++;
while (--runCount >= 0) {
- *destPtr++ = *(remapTable + *destPtr);
+ *dest8++ = *(remapTable + *dest8);
}
} else {
@@ -1572,7 +1573,7 @@ void Wiz::auxColorMixDecompressLine(WizRawPixel *destPtr, const byte *dataStream
runCount += decompAmount;
}
while (--runCount >= 0) {
- *destPtr++ = *(colorMixTable + ((*((const byte *)dataStream)) << 8) + *destPtr);
+ *dest8++ = *(colorMixTable + ((*((const byte *)dataStream)) << 8) + *dest8);
dataStream++;
}
}
diff --git a/engines/scumm/he/wiz_he.h b/engines/scumm/he/wiz_he.h
index df32ae2d691..c7f45535ead 100644
--- a/engines/scumm/he/wiz_he.h
+++ b/engines/scumm/he/wiz_he.h
@@ -753,7 +753,7 @@ public:
int auxPixelHitTestTRLEImageRelPos(byte *compData, int x, int y, int width, int height, int transparentValue);
void auxDecompMixColorsTRLEImage(WizRawPixel *bufferPtr, byte *compData, int bufferWidth, int bufferHeight, int x, int y, int width, int height, Common::Rect *clipRectPtr, byte *coloMixTable, const WizRawPixel *conversionTable);
- void auxDecompMixColorsTRLEPrim(WizRawPixel *bufferPtr, int bufferWidth, Common::Rect *destRect, byte *compData, Common::Rect *sourceRect, byte *coloMixTable, const WizRawPixel *conversionTable);
+ void auxDecompMixColorsTRLEPrim(WizRawPixel *bufferPtr, int bufferWidth, Common::Rect *destRect, const byte *compData, Common::Rect *sourceRect, const byte *coloMixTable, const WizRawPixel *conversionTable);
void auxColorMixDecompressLine(
WizRawPixel *destPtr, const byte *dataStream, int skipAmount,
int decompAmount, const byte *colorMixTable,
Commit: 9d1ebb0cba308841628e95dc02c5722cff1db2f7
https://github.com/scummvm/scummvm/commit/9d1ebb0cba308841628e95dc02c5722cff1db2f7
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Fix TRLE AKOS cels not being erased
Changed paths:
engines/scumm/actor.cpp
engines/scumm/akos.cpp
engines/scumm/he/intern_he.h
engines/scumm/he/script_v100he.cpp
engines/scumm/he/script_v60he.cpp
engines/scumm/he/script_v72he.cpp
engines/scumm/he/script_v90he.cpp
engines/scumm/scumm.cpp
diff --git a/engines/scumm/actor.cpp b/engines/scumm/actor.cpp
index 9dcc4121304..f10bcf77e2f 100644
--- a/engines/scumm/actor.cpp
+++ b/engines/scumm/actor.cpp
@@ -138,7 +138,7 @@ void ActorHE::initActor(int mode) {
if (_vm->_game.heversion >= 61)
_flip = 0;
- _clipOverride = ((ScummEngine_v60he *)_vm)->_actorClipOverride;
+ ((ScummEngine_v60he *)_vm)->setActorClippingRect(_number, -1, -1, -1, -1);
_auxActor = 0;
_auxEraseX1 = 0;
@@ -3677,7 +3677,6 @@ void ScummEngine_v90he::heFlushAuxQueues() {
int x, y, w, h, type, whichActor;
int updateRects, xOffset, yOffset;
byte *costumeAddress;
- const byte *auxDataPtr;
const byte *auxFrameDataPtr;
const byte *auxUpdateRectPtr;
WizRawPixel *foregroundBufferPtr;
@@ -4070,6 +4069,28 @@ void Actor_v0::actorSetWalkTo() {
}
}
+void ScummEngine_v60he::setActorClippingRect(int actor, int x1, int y1, int x2, int y2) {
+ if (actor == -1) {
+ _defaultActorClipping.left = x1;
+ _defaultActorClipping.top = y1;
+ _defaultActorClipping.right = x2;
+ _defaultActorClipping.bottom = y2;
+ } else {
+ ActorHE *a = (ActorHE *)derefActor(actor, "setActorClippingRect");
+ if (x1 == -1 && y1 == -1 && x2 == -1 && y2 == -1) {
+ a->_clipOverride.left = _defaultActorClipping.left;
+ a->_clipOverride.top = _defaultActorClipping.top;
+ a->_clipOverride.right = _defaultActorClipping.right;
+ a->_clipOverride.bottom = _defaultActorClipping.bottom;
+ } else {
+ a->_clipOverride.left = x1;
+ a->_clipOverride.top = y1;
+ a->_clipOverride.right = x2;
+ a->_clipOverride.bottom = y2;
+ }
+ }
+}
+
void Actor_v0::saveLoadWithSerializer(Common::Serializer &s) {
Actor::saveLoadWithSerializer(s);
diff --git a/engines/scumm/akos.cpp b/engines/scumm/akos.cpp
index b76c3ccb841..511be6d2c25 100644
--- a/engines/scumm/akos.cpp
+++ b/engines/scumm/akos.cpp
@@ -1159,13 +1159,10 @@ byte AkosRenderer::hePaintCel(int actor, int drawToBack, int celX, int celY, int
int plotX, plotY;
bool xFlipFlag, yFlipFlag;
- int newWidth, newHeight;
- int topSkipAmount, rightSkipAmount, destSkipAmount, xdx;
Common::Rect destRect;
Common::Rect sourceRect;
Common::Rect clipRect;
int destBufferWidth, destBufferHeight;
- int zClipFlag, textClipFlag;
WizRawPixel *destBuffer;
Wiz *wiz = ((ScummEngine_v71he *)_vm)->_wiz;
Actor *a = _vm->derefActor(actor, "hePaintCel");
@@ -1225,6 +1222,9 @@ byte AkosRenderer::hePaintCel(int actor, int drawToBack, int celX, int celY, int
if (destRect.bottom > a->_bottom)
a->_bottom = destRect.bottom + 1;
+ _drawTop = a->_top;
+ _drawBottom = a->_bottom;
+
//SetActorUpdateArea(actor, destRect.x1, destRect.y1, destRect.x2, destRect.y2);
// Get final plot point and flip source coords if necessary.
diff --git a/engines/scumm/he/intern_he.h b/engines/scumm/he/intern_he.h
index 7427bb150a6..c81c16677b4 100644
--- a/engines/scumm/he/intern_he.h
+++ b/engines/scumm/he/intern_he.h
@@ -65,7 +65,7 @@ public:
Common::SeekableReadStream *_hInFileTable[17];
Common::SeekableWriteStream *_hOutFileTable[17];
- Common::Rect _actorClipOverride; // HE specific
+ Common::Rect _defaultActorClipping; // HE specific
int _heTimers[16];
uint32 _pauseStartTime = 0;
@@ -79,6 +79,7 @@ public:
~ScummEngine_v60he() override;
Common::Path generateFilename(const int room) const override;
+ void setActorClippingRect(int actor, int x1, int y1, int x2, int y2);
void resetScumm() override;
diff --git a/engines/scumm/he/script_v100he.cpp b/engines/scumm/he/script_v100he.cpp
index 620ac19b201..65bd95160c0 100644
--- a/engines/scumm/he/script_v100he.cpp
+++ b/engines/scumm/he/script_v100he.cpp
@@ -380,11 +380,17 @@ void ScummEngine_v100he::o100_actorOps() {
a->_charset = pop();
break;
case SO_CLIPPED:
- a->_clipOverride.bottom = pop();
- a->_clipOverride.right = pop();
- a->_clipOverride.top = pop();
- a->_clipOverride.left = pop();
+ {
+ int x1, y1, x2, y2;
+ y2 = pop();
+ x2 = pop();
+ y1 = pop();
+ x1 = pop();
+ if (_curActor) {
+ setActorClippingRect(_curActor, x1, y1, x2, y2);
+ }
break;
+ }
case SO_CONDITION:
k = getStackList(args, ARRAYSIZE(args));
for (i = 0; i < k; ++i) {
@@ -460,11 +466,15 @@ void ScummEngine_v100he::o100_actorOps() {
a->_forceClip = 0;
break;
case SO_ACTOR_DEFAULT_CLIPPED:
- _actorClipOverride.bottom = pop();
- _actorClipOverride.right = pop();
- _actorClipOverride.top = pop();
- _actorClipOverride.left = pop();
+ {
+ int x1, y1, x2, y2;
+ y2 = pop();
+ x2 = pop();
+ y1 = pop();
+ x1 = pop();
+ setActorClippingRect(-1, x1, y1, x2, y2);
break;
+ }
case SO_ACTOR_SOUNDS:
k = getStackList(args, ARRAYSIZE(args));
for (i = 0; i < k; i++)
diff --git a/engines/scumm/he/script_v60he.cpp b/engines/scumm/he/script_v60he.cpp
index 41e1a696a7a..ccbdae4dcdd 100644
--- a/engines/scumm/he/script_v60he.cpp
+++ b/engines/scumm/he/script_v60he.cpp
@@ -508,11 +508,15 @@ void ScummEngine_v60he::o60_actorOps() {
switch (subOp) {
case SO_ACTOR_DEFAULT_CLIPPED:
// _game.heversion >= 70
- _actorClipOverride.bottom = pop();
- _actorClipOverride.right = pop();
- _actorClipOverride.top = pop();
- _actorClipOverride.left = pop();
- break;
+ {
+ int x1, y1, x2, y2;
+ y2 = pop();
+ x2 = pop();
+ y1 = pop();
+ x1 = pop();
+ setActorClippingRect(-1, x1, y1, x2, y2);
+ break;
+ }
case SO_COSTUME:
a->setActorCostume(pop());
break;
diff --git a/engines/scumm/he/script_v72he.cpp b/engines/scumm/he/script_v72he.cpp
index 1a57b36b763..03b5afc6c35 100644
--- a/engines/scumm/he/script_v72he.cpp
+++ b/engines/scumm/he/script_v72he.cpp
@@ -838,31 +838,32 @@ void ScummEngine_v72he::o72_actorOps() {
a->_needRedraw = true;
break;
case SO_ACTOR_DEFAULT_CLIPPED:
- _actorClipOverride.bottom = pop();
- _actorClipOverride.right = pop();
- _actorClipOverride.top = pop();
- _actorClipOverride.left = pop();
+ {
+ int x1, y1, x2, y2;
+ y2 = pop();
+ x2 = pop();
+ y1 = pop();
+ x1 = pop();
+ setActorClippingRect(-1, x1, y1, x2, y2);
break;
+ }
case ScummEngine_v6::SubOpType::SO_AT: // (HE 98+)
j = pop();
i = pop();
a->putActor(i, j);
break;
case SO_CLIPPED: // (HE 99+)
- a->_clipOverride.bottom = pop();
- a->_clipOverride.right = pop();
- a->_clipOverride.top = pop();
- a->_clipOverride.left = pop();
-
- if (a->_clipOverride.left == -1 && a->_clipOverride.top == -1 &&
- a->_clipOverride.right == -1 && a->_clipOverride.bottom == -1) {
-
- a->_clipOverride.bottom = _actorClipOverride.bottom;
- a->_clipOverride.right = _actorClipOverride.right;
- a->_clipOverride.top = _actorClipOverride.top;
- a->_clipOverride.left = _actorClipOverride.left;
+ {
+ int x1, y1, x2, y2;
+ y2 = pop();
+ x2 = pop();
+ y1 = pop();
+ x1 = pop();
+ if (_curActor) {
+ setActorClippingRect(_curActor, x1, y1, x2, y2);
}
break;
+ }
case SO_ERASE: // // (HE 90+)
k = pop();
a->setHEFlag(1, k);
diff --git a/engines/scumm/he/script_v90he.cpp b/engines/scumm/he/script_v90he.cpp
index 9805893102a..106a8aa6870 100644
--- a/engines/scumm/he/script_v90he.cpp
+++ b/engines/scumm/he/script_v90he.cpp
@@ -1960,7 +1960,7 @@ void ScummEngine_v90he::o90_getLinesIntersectionPoint() {
push(0);
return;
} else if (segBIsAPoint) {
- int dx, dy, py;
+ int dx, py;
dx = (x2 - x1);
diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
index 14ed7c292ca..4178648adcb 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -647,10 +647,7 @@ ScummEngine_v60he::ScummEngine_v60he(OSystem *syst, const DetectorResult &dr)
memset(_hInFileTable, 0, sizeof(_hInFileTable));
memset(_hOutFileTable, 0, sizeof(_hOutFileTable));
- _actorClipOverride.top = 0;
- _actorClipOverride.bottom = 480;
- _actorClipOverride.left = 0;
- _actorClipOverride.right = 640;
+ setActorClippingRect(-1, 0, 0, 640 - 1, 480 - 1);
memset(_heTimers, 0, sizeof(_heTimers));
Commit: a6ebc81784423d9c0e9824d34535bff774127c7b
https://github.com/scummvm/scummvm/commit/a6ebc81784423d9c0e9824d34535bff774127c7b
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Fix several sprite rendering issues
Changed paths:
engines/scumm/he/script_v90he.cpp
engines/scumm/he/sprite_he.cpp
engines/scumm/he/sprite_he.h
diff --git a/engines/scumm/he/script_v90he.cpp b/engines/scumm/he/script_v90he.cpp
index 106a8aa6870..387e18aac66 100644
--- a/engines/scumm/he/script_v90he.cpp
+++ b/engines/scumm/he/script_v90he.cpp
@@ -201,8 +201,7 @@ void ScummEngine_v90he::o90_wizImageOps() {
_wizImageCommand.yPos = pop();
_wizImageCommand.xPos = pop();
break;
- case SO_COLOR: // 66
- // TODO: I haven't found SO_COLOR in any executable, recheck later...
+ case SO_COLOR: // 66, HE95
case SO_COLOR_LIST: // 249, HE98+
b = pop();
a = pop();
@@ -806,13 +805,13 @@ void ScummEngine_v90he::o90_setSpriteInfo() {
_sprite->setSpriteAngle(spriteId, args[0]);
break;
case SO_INIT: // 57
- if (_game.features & GF_HE_985 || _game.heversion >= 99) {
+ if (_game.features & GF_HE_985 || _game.heversion >= 98) {
_maxSpriteNum = pop();
_minSpriteNum = pop();
if (_minSpriteNum > _maxSpriteNum)
SWAP(_minSpriteNum, _maxSpriteNum);
- } else {
+ } else { // HE95
_minSpriteNum = pop();
_maxSpriteNum = _minSpriteNum; // to make all functions happy
}
diff --git a/engines/scumm/he/sprite_he.cpp b/engines/scumm/he/sprite_he.cpp
index 0b402e7ca5f..4589ee4a582 100644
--- a/engines/scumm/he/sprite_he.cpp
+++ b/engines/scumm/he/sprite_he.cpp
@@ -128,7 +128,7 @@ int Sprite::spriteFromPoint(int x, int y, int groupCheck, int quickCheck, int cl
}
}
- if (_vm->_game.heversion > 99) {
+ if (_vm->_game.heversion >= 99) {
int state = 0;
int32 testPointX, testPointY;
if ((*spritePtr)->maskImage) {
@@ -348,6 +348,9 @@ int Sprite::getSpriteImageStateCount(int spriteId) {
int Sprite::getSpriteScale(int spriteId) {
assertRange(1, spriteId, _maxSprites, "sprite");
+ if (_vm->_game.heversion == 95)
+ return 0;
+
return _spriteTable[spriteId].scale;
}
@@ -519,6 +522,14 @@ void Sprite::calcSpriteSpot(const SpriteInfo *spritePtr, bool includeGroupTransf
y += _groupTable[spritePtr->group].posY;
}
+ } else if (_vm->_game.heversion == 95) {
+ _vm->_wiz->getWizSpot(spritePtr->image, spritePtr->state, x, y);
+ x = spritePtr->posX - x;
+ y = spritePtr->posY - y;
+ if (spritePtr->group != 0) {
+ x += _groupTable[spritePtr->group].posX;
+ y += _groupTable[spritePtr->group].posY;
+ }
} else if (_vm->_game.heversion >= 98) {
if (_vm->_game.heversion >= 100) {
if (spritePtr->image == 0) {
@@ -538,7 +549,7 @@ void Sprite::calcSpriteSpot(const SpriteInfo *spritePtr, bool includeGroupTransf
int group = spritePtr->group;
- if ((includeGroupTransform || _vm->_game.heversion == 98) && group != 0) {
+ if ((includeGroupTransform || _vm->_game.heversion <= 98) && group != 0) {
if (_groupTable[group].isScaled) {
x = (int)((float)spritePtr->posX * _groupTable[group].xScale) - x;
y = (int)((float)spritePtr->posY * _groupTable[group].yScale) - y;
@@ -844,7 +855,7 @@ void Sprite::setSpriteAutoAnimFlag(int spriteId, int value) {
void Sprite::setSpriteUpdateType(int spriteId, int eraseType) {
assertRange(1, spriteId, _maxSprites, "sprite");
- if (_vm->_game.heversion > 99) {
+ if (_vm->_game.heversion >= 99) {
switch (eraseType) {
default:
case SPRDEF_SMART:
@@ -957,9 +968,7 @@ void Sprite::newSprite(int sprite) {
setSpritePalette(sprite, 0);
setSourceImage(sprite, 0);
setMaskImage(sprite, 0);
- }
- if (_vm->_game.heversion > 99) {
setSpriteUpdateType(sprite, SPRDEF_SIMPLE);
setSpritePriority(sprite, 0);
setSpriteZBuffer(sprite, 0);
@@ -1323,7 +1332,7 @@ void Sprite::newGroup(int group) {
clearGroupScaleInfo(group);
// TODO U32
- // if (_vm->_game.heversion > 99)
+ // if (_vm->_game.heversion >= 99)
// PU_GroupNewHook(group);
}
@@ -1630,6 +1639,21 @@ void Sprite::buildActiveSpriteList() {
}
}
+WizSimpleBitmap *Sprite::getSimpleBitmapForSprite(const SpriteInfo *spritePtr) {
+ WizSimpleBitmap *simpleBitmap = nullptr;
+ int image = spritePtr->image;
+ int group = spritePtr->group;
+ int groupImage = _groupTable[group].image;
+
+ if (image != 0 && group != 0 && groupImage != 0) {
+ if (_vm->_wiz->dwSetSimpleBitmapStructFromImage(groupImage, 0, simpleBitmap)) {
+ return simpleBitmap;
+ }
+ }
+
+ return nullptr;
+}
+
void Sprite::renderSprites(bool negativeOrPositiveRender) {
int image, group, shadow, state, angle;
int sourceImage, scale, destImageNumber;
@@ -1641,6 +1665,7 @@ void Sprite::renderSprites(bool negativeOrPositiveRender) {
bool angleSpecified;
bool scaleSpecified;
Common::Point spot;
+ bool simpleDraw = false;
imageRenderCmd.reset();
@@ -1675,34 +1700,48 @@ void Sprite::renderSprites(bool negativeOrPositiveRender) {
image = spritePtr[i]->image;
state = spritePtr[i]->state;
- int32 spotX, spotY;
+ int32 spotX = 0, spotY = 0;
calcSpriteSpot(spritePtr[i], true, spotX, spotY);
// In the hope that it never overflows...
spot.x = (int16)spotX;
spot.y = (int16)spotY;
- // Setup the image render command...
- imageRenderCmd.extendedRenderInfo.sprite = (int32)(spritePtr[i] - _spriteTable);
- imageRenderCmd.extendedRenderInfo.group = spritePtr[i]->group;
- imageRenderCmd.extendedRenderInfo.conditionBits = spritePtr[i]->conditionBits;
+ if (_vm->_game.heversion > 98) {
+ // Setup the image render command...
+ imageRenderCmd.extendedRenderInfo.sprite = (int32)(spritePtr[i] - _spriteTable);
+ imageRenderCmd.extendedRenderInfo.group = spritePtr[i]->group;
+ imageRenderCmd.extendedRenderInfo.conditionBits = spritePtr[i]->conditionBits;
- imageRenderCmd.actionFlags = kWAFSpot;
- imageRenderCmd.xPos = spot.x;
- imageRenderCmd.yPos = spot.y;
+ imageRenderCmd.actionFlags = kWAFSpot;
+ imageRenderCmd.xPos = spot.x;
+ imageRenderCmd.yPos = spot.y;
- imageRenderCmd.actionFlags |= kWAFState;
- imageRenderCmd.image = image;
- imageRenderCmd.state = state;
+ imageRenderCmd.actionFlags |= kWAFState;
+ imageRenderCmd.image = image;
+ imageRenderCmd.state = state;
- spritePtr[i]->lastAngle = spritePtr[i]->angle;
- spritePtr[i]->lastScale = spritePtr[i]->scale;
- spritePtr[i]->lastImage = image;
- spritePtr[i]->lastState = state;
- spritePtr[i]->lastSpot = spot;
+ spritePtr[i]->lastAngle = spritePtr[i]->angle;
+ spritePtr[i]->lastScale = spritePtr[i]->scale;
+ spritePtr[i]->lastImage = image;
+ spritePtr[i]->lastState = state;
+ spritePtr[i]->lastSpot = spot;
+
+ // The the potential update rect (we'll clip it later)
+ getSpriteRectPrim(spritePtr[i], &spritePtr[i]->lastRect, true, &spot);
+ } else {
+ spritePtr[i]->lastImage = image;
+ spritePtr[i]->lastState = state;
+ spritePtr[i]->lastSpot = spot;
+
+ int w, h;
+ _vm->_wiz->getWizImageDim(image, state, w, h);
- // The the potential update rect (we'll clip it later)
- getSpriteRectPrim(spritePtr[i], &spritePtr[i]->lastRect, true, &spot);
+ spritePtr[i]->lastRect.left = spot.x;
+ spritePtr[i]->lastRect.top = spot.y;
+ spritePtr[i]->lastRect.right = spot.x + w - 1;
+ spritePtr[i]->lastRect.bottom = spot.y + h - 1;
+ }
// Setup the renderFlags
renderFlags = kWRFForeground;
@@ -1720,12 +1759,14 @@ void Sprite::renderSprites(bool negativeOrPositiveRender) {
renderFlags |= kWRFBackground;
}
- // Check to see if there is any shadow attached to this sprite...
- shadow = spritePtr[i]->shadow;
- if (shadow != 0) {
- renderFlags |= kWRFUseShadow;
- imageRenderCmd.actionFlags |= kWAFShadow;
- imageRenderCmd.shadow = shadow;
+ if (_vm->_game.heversion > 98) {
+ // Check to see if there is any shadow attached to this sprite...
+ shadow = spritePtr[i]->shadow;
+ if (shadow != 0) {
+ renderFlags |= kWRFUseShadow;
+ imageRenderCmd.actionFlags |= kWAFShadow;
+ imageRenderCmd.shadow = shadow;
+ }
}
// Check to see if the sprite is supposed to remap...
@@ -1733,71 +1774,101 @@ void Sprite::renderSprites(bool negativeOrPositiveRender) {
renderFlags |= kWRFRemap;
}
- // Handle Z-Clipping
- if (spritePtr[i]->zbufferImage != 0) {
- imageRenderCmd.actionFlags |= kWAFZBufferImage;
- imageRenderCmd.zbufferImage = spritePtr[i]->zbufferImage;
- imageRenderCmd.zPos = spritePtr[i]->priority;
- }
+ if (_vm->_game.heversion > 98) {
+ // Handle Z-Clipping
+ if (spritePtr[i]->zbufferImage != 0) {
+ imageRenderCmd.actionFlags |= kWAFZBufferImage;
+ imageRenderCmd.zbufferImage = spritePtr[i]->zbufferImage;
+ imageRenderCmd.zPos = spritePtr[i]->priority;
+ }
- // Set the source image...
- sourceImage = spritePtr[i]->sourceImage;
- if (sourceImage != 0) {
- imageRenderCmd.actionFlags |= kWAFSourceImage;
- imageRenderCmd.sourceImage = sourceImage;
- }
+ // Set the source image...
+ sourceImage = spritePtr[i]->sourceImage;
+ if (sourceImage != 0) {
+ imageRenderCmd.actionFlags |= kWAFSourceImage;
+ imageRenderCmd.sourceImage = sourceImage;
+ }
- renderFlags |= spritePtr[i]->specialRenderFlags;
+ renderFlags |= spritePtr[i]->specialRenderFlags;
- // Finally set the image render flags
- imageRenderCmd.actionFlags |= kWAFFlags;
- imageRenderCmd.flags = renderFlags;
+ // Finally set the image render flags
+ imageRenderCmd.actionFlags |= kWAFFlags;
+ imageRenderCmd.flags = renderFlags;
- // Read the angle/scale variables
- angle = spritePtr[i]->angle;
- scale = spritePtr[i]->scale;
+ // Read the angle/scale variables
+ angle = spritePtr[i]->angle;
+ scale = spritePtr[i]->scale;
- scaleSpecified = (spritePtr[i]->flags & kSFScaleSpecified);
- angleSpecified = (spritePtr[i]->flags & kSFAngleSpecified);
+ scaleSpecified = (spritePtr[i]->flags & kSFScaleSpecified);
+ angleSpecified = (spritePtr[i]->flags & kSFAngleSpecified);
- // Check for "complex" image draw mode...
- if (angleSpecified) {
- imageRenderCmd.actionFlags |= kWAFAngle;
- imageRenderCmd.angle = angle;
- }
+ // Check for "complex" image draw mode...
+ if (angleSpecified) {
+ imageRenderCmd.actionFlags |= kWAFAngle;
+ imageRenderCmd.angle = angle;
+ }
+
+ if (scaleSpecified) {
+ imageRenderCmd.actionFlags |= kWAFScale;
+ imageRenderCmd.scale = scale;
+ }
+
+ // Store off the render flags
+ spritePtr[i]->lastRenderFlags = renderFlags;
+ } else {
+ // Check for complex image draw mode...
+ simpleDraw = true;
+
+ if (angle = spritePtr[i]->angle) {
+ simpleDraw = false;
+ }
- if (scaleSpecified) {
- imageRenderCmd.actionFlags |= kWAFScale;
- imageRenderCmd.scale = scale;
+ if (scale = spritePtr[i]->scale) {
+ simpleDraw = false;
+ }
}
- // Store off the render flags
- spritePtr[i]->lastRenderFlags = renderFlags;
+ simpleDraw = _vm->_game.heversion == 95 ? true : simpleDraw;
// Check to see if the group has a clipping rect.
group = spritePtr[i]->group;
if (group != 0) {
if (_groupTable[group].flags & kSGFUseClipRect) {
- if (!_vm->_wiz->findRectOverlap(&spritePtr[i]->lastRect, &_groupTable[group].clipRect)) {
- spritePtr[i]->lastRect.left = 1234;
- spritePtr[i]->lastRect.top = 1234;
- spritePtr[i]->lastRect.right = -1234;
- spritePtr[i]->lastRect.bottom = -1234;
+ if (_vm->_game.heversion > 98) {
+ if (!_vm->_wiz->findRectOverlap(&spritePtr[i]->lastRect, &_groupTable[group].clipRect)) {
+ spritePtr[i]->lastRect.left = 1234;
+ spritePtr[i]->lastRect.top = 1234;
+ spritePtr[i]->lastRect.right = -1234;
+ spritePtr[i]->lastRect.bottom = -1234;
- continue;
- }
+ continue;
+ }
- // Setup the clipping rect to the overlap rect.
- // This will eventually be clipped down to the
- // limits of the bitmap
- imageRenderCmd.actionFlags |= kWAFRect;
- imageRenderCmd.box.left= spritePtr[i]->lastRect.left;
- imageRenderCmd.box.top = spritePtr[i]->lastRect.top;
- imageRenderCmd.box.right = spritePtr[i]->lastRect.right;
- imageRenderCmd.box.bottom = spritePtr[i]->lastRect.bottom;
-
- clippedLastRect = spritePtr[i]->lastRect;
- clipRectPtr = &clippedLastRect;
+ // Setup the clipping rect to the overlap rect.
+ // This will eventually be clipped down to the
+ // limits of the bitmap
+ imageRenderCmd.actionFlags |= kWAFRect;
+ imageRenderCmd.box.left = spritePtr[i]->lastRect.left;
+ imageRenderCmd.box.top = spritePtr[i]->lastRect.top;
+ imageRenderCmd.box.right = spritePtr[i]->lastRect.right;
+ imageRenderCmd.box.bottom = spritePtr[i]->lastRect.bottom;
+
+ clippedLastRect = spritePtr[i]->lastRect;
+ clipRectPtr = &clippedLastRect;
+ } else {
+ if (simpleDraw) {
+ if (!_vm->_wiz->findRectOverlap(&spritePtr[i]->lastRect, &_groupTable[group].clipRect)) {
+ spritePtr[i]->lastRect.left = 1234;
+ spritePtr[i]->lastRect.top = 1234;
+ spritePtr[i]->lastRect.right = -1234;
+ spritePtr[i]->lastRect.bottom = -1234;
+
+ continue;
+ }
+ }
+
+ clipRectPtr = &_groupTable[group].clipRect;
+ }
} else {
clipRectPtr = nullptr;
}
@@ -1805,29 +1876,47 @@ void Sprite::renderSprites(bool negativeOrPositiveRender) {
clipRectPtr = nullptr;
}
- // Finally get down to business and render the wiz
- // get the palette
- if (spritePtr[i]->palette != 0) {
- imageRenderCmd.actionFlags |= kWAFPalette;
- imageRenderCmd.palette = spritePtr[i]->palette;
- }
+ if (_vm->_game.heversion > 98) {
+ // Finally get down to business and render the wiz
+ // get the palette
+ if (spritePtr[i]->palette != 0) {
+ imageRenderCmd.actionFlags |= kWAFPalette;
+ imageRenderCmd.palette = spritePtr[i]->palette;
+ }
- // get the associated dest image if any
- destImageNumber = getDestImageForSprite(spritePtr[i]);
+ // get the associated dest image if any
+ destImageNumber = getDestImageForSprite(spritePtr[i]);
- if (destImageNumber) {
- imageRenderCmd.actionFlags |= kWAFDestImage;
- imageRenderCmd.destImageNumber = destImageNumber;
- }
+ if (destImageNumber) {
+ imageRenderCmd.actionFlags |= kWAFDestImage;
+ imageRenderCmd.destImageNumber = destImageNumber;
+ }
- // Finally actually do something by calling the command parser
- // this function is the same core that renders images via the
- // "image" draw command.
- if (_vm->_game.heversion > 99) {
- imageRenderCmd.actionType = kWADraw;
- _vm->_wiz->processWizImageCmd(&imageRenderCmd);
+ // Finally actually do something by calling the command parser
+ // this function is the same core that renders images via the
+ // "image" draw command.
+ if (_vm->_game.heversion > 99) {
+ imageRenderCmd.actionType = kWADraw;
+ _vm->_wiz->processWizImageCmd(&imageRenderCmd);
+ } else {
+ _vm->_wiz->processWizImageDrawCmd(&imageRenderCmd);
+ }
} else {
- _vm->_wiz->processWizImageDrawCmd(&imageRenderCmd);
+ // Check to see if there is a shadow attached to this sprite
+ shadow = spritePtr[i]->shadow;
+ if (shadow != 0) {
+ renderFlags |= kWRFUseShadow;
+ }
+
+ WizSimpleBitmap *bitmapPtr = getSimpleBitmapForSprite(spritePtr[i]);
+
+ if (simpleDraw) {
+ _vm->_wiz->drawAWizPrim(image, state, spot.x, spot.y, 0, shadow, 0, clipRectPtr, renderFlags, bitmapPtr, nullptr);
+ } else {
+ _vm->_wiz->dwHandleComplexImageDraw(
+ image, state, spot.x, spot.y, shadow,
+ angle, scale, clipRectPtr, renderFlags, nullptr, nullptr);
+ }
}
}
}
diff --git a/engines/scumm/he/sprite_he.h b/engines/scumm/he/sprite_he.h
index edf7d425651..61ebc925560 100644
--- a/engines/scumm/he/sprite_he.h
+++ b/engines/scumm/he/sprite_he.h
@@ -237,6 +237,7 @@ public:
bool doesRectIntersectUpdateAreas(const Common::Rect *rectPtr);
void checkForForcedRedraws(bool checkOnlyPositivePriority);
void buildActiveSpriteList();
+ WizSimpleBitmap *getSimpleBitmapForSprite(const SpriteInfo *spritePtr);
void renderSprites(bool negativeOrPositiveRender);
void runSpriteEngines();
Commit: 0f91f728afc9c9eff05bb2f9dcc196bb1ef60de9
https://github.com/scummvm/scummvm/commit/0f91f728afc9c9eff05bb2f9dcc196bb1ef60de9
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: More HE95 changes
Changed paths:
engines/scumm/he/sprite_he.cpp
diff --git a/engines/scumm/he/sprite_he.cpp b/engines/scumm/he/sprite_he.cpp
index 4589ee4a582..2d07c221a86 100644
--- a/engines/scumm/he/sprite_he.cpp
+++ b/engines/scumm/he/sprite_he.cpp
@@ -276,7 +276,7 @@ int Sprite::getSpriteUpdateType(int spriteId) {
int Sprite::getSpriteEraseType(int spriteId) {
assertRange(1, spriteId, _maxSprites, "sprite");
- return ((_spriteTable[spriteId].flags & kSFIgnoreErase) != 0) ? 0 : 1;
+ return ((_spriteTable[spriteId].flags & kSFIgnoreErase) == 0) ? 1 : 0;
}
int Sprite::getSpriteImage(int spriteId) {
@@ -1039,7 +1039,7 @@ void Sprite::setImageList(int sprite, int count, const int *list) {
}
} else {
- if (_vm->_game.heversion >= 95 && _vm->_game.heversion < 100) {
+ if (_vm->_game.heversion >= 98 && _vm->_game.heversion < 100) {
if (_spriteTable[sprite].flags & kSFIgnoreErase) {
_spriteTable[sprite].flags = 0;
} else {
@@ -1336,7 +1336,7 @@ void Sprite::newGroup(int group) {
// PU_GroupNewHook(group);
}
-void Sprite::resetSpriteSystem(bool refreshScreen) {
+void Sprite::resetSpriteSystem(bool eraseScreen) {
resetImageLists();
for (int i = 0; i < _maxSprites; i++) {
@@ -1358,7 +1358,7 @@ void Sprite::resetSpriteSystem(bool refreshScreen) {
}
if (_vm->_game.heversion > 80) {
- if (refreshScreen) {
+ if (eraseScreen) {
_vm->backgroundToForegroundBlit(Common::Rect(_vm->_screenWidth - 1, _vm->_screenHeight - 1));
}
} else {
Commit: 7f004920a438c08ea1f2759542623e5d0c4518f6
https://github.com/scummvm/scummvm/commit/7f004920a438c08ea1f2759542623e5d0c4518f6
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Fix Aux Images rendering
Changed paths:
engines/scumm/actor.cpp
engines/scumm/he/wizwarp_he.cpp
diff --git a/engines/scumm/actor.cpp b/engines/scumm/actor.cpp
index f10bcf77e2f..c0b0e41d924 100644
--- a/engines/scumm/actor.cpp
+++ b/engines/scumm/actor.cpp
@@ -3581,18 +3581,18 @@ void ScummEngine_v71he::heFlushAuxQueues() {
yOffset -= a->getElevation();
}
- auxDataBlockPtr = findResourceData(MKTAG('A', 'K', 'A', 'X'), costumeAddress);
+ auxDataBlockPtr = findResourceData(MKTAG('A', 'K', 'A', 'X'), costumeAddress) - _resourceHeaderSize;
if (!auxDataBlockPtr) {
error("heFlushAuxQueue(): NO AKAX block actor %d!", whichActor);
}
- auxDataPtr = findPalInPals(auxDataBlockPtr, _heAuxAnimTable[i].auxIndex);
+ auxDataPtr = findPalInPals(auxDataBlockPtr, _heAuxAnimTable[i].auxIndex) - _resourceHeaderSize;
if (!auxDataPtr) {
error("heFlushAuxQueue(): NO AUXD block actor %d!", whichActor);
}
// Check the type of the AUXD block...
- auxFrameDataPtr = findResourceData(MKTAG('A', 'X', 'F', 'D'), auxDataPtr);
+ auxFrameDataPtr = findResourceData(MKTAG('A', 'X', 'F', 'D'), auxDataPtr) - _resourceHeaderSize;
if (!auxFrameDataPtr) {
warning("heFlushAuxQueue(): NO AXFD block actor %d; ignoring...", whichActor);
continue;
diff --git a/engines/scumm/he/wizwarp_he.cpp b/engines/scumm/he/wizwarp_he.cpp
index b281bf9d5b3..248346f781c 100644
--- a/engines/scumm/he/wizwarp_he.cpp
+++ b/engines/scumm/he/wizwarp_he.cpp
@@ -177,7 +177,7 @@ bool Wiz::warpDrawWizTo4Points(int image, int state, const WarpWizPoint *dstPoin
&dstBitmap, dstPoints, &srcBitmap, srcPoints, 4, transparentColor,
optionalClipRect, colorMixTable);
} else {
- if (_vm->_game.heversion >= 99) { // TODO: Recheck!! Code valid for executables from 3/14/2000 onwards
+ if (_vm->_game.heversion >= 99) { // This shouldn't be a HE99 branch, but some later HE99 executables do this...
rValue = warpNPt2NPtWarpCORE(
&dstBitmap, dstPoints, &srcBitmap, srcPoints,
4, transparentColor, optionalClipRect, flags);
Commit: 5ac8ea75a0fa32112409fecad04d719fc62954ce
https://github.com/scummvm/scummvm/commit/5ac8ea75a0fa32112409fecad04d719fc62954ce
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Fix sub HE95 games not starting
Changed paths:
engines/scumm/akos.cpp
engines/scumm/he/gfx_comp/trle_comp.cpp
engines/scumm/he/intern_he.h
engines/scumm/he/script_v72he.cpp
engines/scumm/he/script_v80he.cpp
engines/scumm/he/sprite_he.cpp
engines/scumm/he/wiz_he.cpp
engines/scumm/he/wizwarp_he.cpp
engines/scumm/scumm.cpp
diff --git a/engines/scumm/akos.cpp b/engines/scumm/akos.cpp
index 511be6d2c25..18a17ad6d3c 100644
--- a/engines/scumm/akos.cpp
+++ b/engines/scumm/akos.cpp
@@ -1197,14 +1197,16 @@ byte AkosRenderer::hePaintCel(int actor, int drawToBack, int celX, int celY, int
// Check to see if the actor has a clipping rect...
if ((((ActorHE *)a)->_clipOverride.left < ((ActorHE *)a)->_clipOverride.right) &&
(((ActorHE *)a)->_clipOverride.top < ((ActorHE *)a)->_clipOverride.bottom)) {
- if (destBufferHeight > ((ActorHE *)a)->_clipOverride.bottom) {
+ // The original evaluates this as '>', but for some reason we need actor clipping
+ // rectangles to max out at 640x480, instead of 639x479; this *should* not be an issue...
+ if (destBufferHeight >= ((ActorHE *)a)->_clipOverride.bottom) {
clipRect.left = ((ActorHE *)a)->_clipOverride.left;
clipRect.right = ((ActorHE *)a)->_clipOverride.right;
clipRect.top = ((ActorHE *)a)->_clipOverride.top;
clipRect.bottom = ((ActorHE *)a)->_clipOverride.bottom;
} else {
warning(
- "Actor %d invalid clipping rect (%-3d,%3d,%-3d,%3d)", a->_number,
+ "AkosRenderer::hePaintCel(): Actor %d invalid clipping rect (%-3d,%3d,%-3d,%3d)", a->_number,
((ActorHE *)a)->_clipOverride.left, ((ActorHE *)a)->_clipOverride.top,
((ActorHE *)a)->_clipOverride.right, ((ActorHE *)a)->_clipOverride.bottom);
}
@@ -1296,81 +1298,6 @@ static void heTRLEPaintPrimShadow(ScummEngine *vm, Wiz *wiz, WizRawPixel *dstDat
byte AkosRenderer::paintCelTRLE(int actor, int drawToBack, int celX, int celY, int celWidth, int celHeight, byte tcolor, const byte *shadowTablePtr, int32 specialRenderFlags) {
#ifdef ENABLE_HE
- /*
- Common::Rect src, dst;
-
- if (!_mirror) {
- dst.left = (_actorX - xMoveCur - _width) + 1;
- } else {
- dst.left = _actorX + xMoveCur;
- }
-
- src.top = src.left = 0;
- src.right = _width;
- src.bottom = _height;
-
- dst.top = _actorY + yMoveCur;
- dst.right = dst.left + _width;
- dst.bottom = dst.top + _height;
-
- int diff;
- diff = dst.left - _clipOverride.left;
- if (diff < 0) {
- src.left -= diff;
- dst.left -= diff;
- }
- diff = dst.right - _clipOverride.right;
- if (diff > 0) {
- src.right -= diff;
- dst.right -= diff;
- }
- diff = dst.top - _clipOverride.top;
- if (diff < 0) {
- src.top -= diff;
- dst.top -= diff;
- }
- diff = dst.bottom - _clipOverride.bottom;
- if (diff > 0) {
- src.bottom -= diff;
- dst.bottom -= diff;
- }
-
- if (dst.isValidRect() == false)
- return 0;
-
- markRectAsDirty(dst);
-
- if (_drawTop > dst.top)
- _drawTop = dst.top;
- if (_drawBottom < dst.bottom)
- _drawBottom = dst.bottom;
-
- const uint8 *palPtr = NULL;
- if (_vm->_game.features & GF_16BIT_COLOR) {
- palPtr = _vm->_hePalettes + _vm->_hePaletteSlot + 768;
- if (_paletteNum) {
- palPtr = _vm->_hePalettes + _paletteNum * _vm->_hePaletteSlot + 768;
- } else if (_rgbs) {
- for (uint i = 0; i < 256; i++)
- WRITE_LE_UINT16(_palette + i, _vm->get16BitColor(_rgbs[i * 3 + 0], _rgbs[i * 3 + 1], _rgbs[i * 3 + 2]));
- palPtr = (uint8 *)_palette;
- }
- } else if (_vm->_game.heversion >= 99) {
- palPtr = _vm->_hePalettes + _vm->_hePaletteSlot + 768;
- }
-
- byte *dstPtr = (byte *)_out.getBasePtr(dst.left, dst.top);
- if (_shadowMode == 3) {
- Wiz::decompressWizImage<kWizXMap>(dstPtr, _out.pitch, kDstScreen, _srcPtr, src, 0, palPtr, _xmap, _vm->_bytesPerPixel);
- } else {
- if (palPtr != NULL) {
- Wiz::decompressWizImage<kWizRMap>(dstPtr, _out.pitch, kDstScreen, _srcPtr, src, 0, palPtr, NULL, _vm->_bytesPerPixel);
- } else {
- Wiz::decompressWizImage<kWizCopy>(dstPtr, _out.pitch, kDstScreen, _srcPtr, src, 0, NULL, NULL, _vm->_bytesPerPixel);
- }
- }
- */
-
const uint8 *palPtr = nullptr;
if (_vm->_game.features & GF_16BIT_COLOR) {
palPtr = _vm->_hePalettes + _vm->_hePaletteSlot + 768;
diff --git a/engines/scumm/he/gfx_comp/trle_comp.cpp b/engines/scumm/he/gfx_comp/trle_comp.cpp
index db52d24bda3..90ca86032ce 100644
--- a/engines/scumm/he/gfx_comp/trle_comp.cpp
+++ b/engines/scumm/he/gfx_comp/trle_comp.cpp
@@ -1378,7 +1378,7 @@ void Wiz::trleFLIPRotate90DecompressImage(
}
}
- if (_vm->_game.heversion > 99 && _uses16BitColor) {
+ if (_vm->_game.heversion >= 99 && _uses16BitColor) {
// Check for new "special" rendering modes
if (wizFlags & kWRFSpecialRenderBitMask) {
if (wizFlags & kWRFAdditiveBlend) {
diff --git a/engines/scumm/he/intern_he.h b/engines/scumm/he/intern_he.h
index c81c16677b4..3a1e14924af 100644
--- a/engines/scumm/he/intern_he.h
+++ b/engines/scumm/he/intern_he.h
@@ -509,6 +509,12 @@ protected:
SO_BUTTON = 60,
};
+ enum LineType {
+ kLTColor = 1,
+ kLTActor = 2,
+ kLTImage = 3
+ };
+
public:
ScummEngine_v80he(OSystem *syst, const DetectorResult &dr);
diff --git a/engines/scumm/he/script_v72he.cpp b/engines/scumm/he/script_v72he.cpp
index 03b5afc6c35..aeb9b7fc6fa 100644
--- a/engines/scumm/he/script_v72he.cpp
+++ b/engines/scumm/he/script_v72he.cpp
@@ -536,7 +536,7 @@ void ScummEngine_v72he::o72_captureWizImage() {
_wiz->takeAWiz(image, x1, y1, x2, y2, false, true);
- if (_game.heversion > 99) {
+ if (_game.heversion >= 99) {
_res->setModified(rtImage, image);
}
}
@@ -641,13 +641,9 @@ void ScummEngine_v72he::o72_drawObject() {
}
void ScummEngine_v72he::o72_printWizImage() {
- WizBufferElement wi;
- wi.image = pop();
- wi.x = wi.y = 0;
- wi.state = 0;
- wi.flags = kWRFPrint;
+ int image = pop();
- _wiz->simpleDrawAWiz(wi.image, wi.state, wi.x, wi.y, wi.flags);
+ _wiz->simpleDrawAWiz(image, 0, 0, 0, kWRFPrint);
}
void ScummEngine_v72he::o72_getArrayDimSize() {
diff --git a/engines/scumm/he/script_v80he.cpp b/engines/scumm/he/script_v80he.cpp
index d57deb20e75..4e52ff22cfd 100644
--- a/engines/scumm/he/script_v80he.cpp
+++ b/engines/scumm/he/script_v80he.cpp
@@ -327,12 +327,10 @@ void ScummEngine_v80he::o80_setState() {
}
void ScummEngine_v80he::o80_drawWizPolygon() {
- WizBufferElement wi;
- wi.x = wi.y = pop();
- wi.image = pop();
- wi.state = 0;
- wi.flags = kWRFPolygon;
- _wiz->simpleDrawAWiz(wi.image, wi.state, wi.x, wi.y, wi.flags);
+ int polygon = pop();
+ int image = pop();
+
+ _wiz->simpleDrawAWiz(image, 0, polygon, polygon, kWRFPolygon);
}
/**
@@ -345,12 +343,14 @@ void ScummEngine_v80he::o80_drawWizPolygon() {
* @param step the step size used to render the line, only ever 'step'th point is drawn
* @param type the line type -- points are rendered by drawing actors (type == 2),
* wiz images (type == 3), or pixels (any other type)
- * @param id the id of an actor, wizimage or color (low bit) & flag (high bit)
+ * @param color the id of an actor, wizimage or color (low bit) & flag (high bit)
*/
-void ScummEngine_v80he::drawLine(int x1, int y1, int x, int y, int step, int type, int id) {
+void ScummEngine_v80he::drawLine(int x1, int y1, int x, int y, int step, int type, int color) {
+ // TODO
if (step < 0) {
step = -step;
}
+
if (step == 0) {
step = 1;
}
@@ -366,20 +366,13 @@ void ScummEngine_v80he::drawLine(int x1, int y1, int x, int y, int step, int typ
y = y1;
x = x1;
-
- if (type == 2) {
- ActorHE *a = (ActorHE *)derefActor(id, "drawLine");
+ if (type == kLTActor) {
+ ActorHE *a = (ActorHE *)derefActor(color, "drawLine");
a->drawActorToBackBuf(x, y);
- } else if (type == 3) {
- WizBufferElement wi;
- wi.flags = 0;
- wi.y = y;
- wi.x = x;
- wi.image = id;
- wi.state = 0;
- _wiz->simpleDrawAWiz(wi.image, wi.state, wi.x, wi.y, wi.flags);
+ } else if (type == kLTImage) {
+ _wiz->drawAWiz(color, 0, x, y, 0, 0, 0, 0, nullptr, 0, nullptr);
} else {
- drawPixel(x, y, id);
+ drawPixel(x, y, color);
}
int stepCount = 0;
@@ -418,24 +411,19 @@ void ScummEngine_v80he::drawLine(int x1, int y1, int x, int y, int step, int typ
if ((stepCount++ % step) != 0 && maxDist != i)
continue;
- if (type == 2) {
- ActorHE *a = (ActorHE *)derefActor(id, "drawLine");
+ if (type == kLTActor) {
+ ActorHE *a = (ActorHE *)derefActor(color, "drawLine");
a->drawActorToBackBuf(x, y);
- } else if (type == 3) {
- WizBufferElement wi;
- wi.flags = 0;
- wi.y = y;
- wi.x = x;
- wi.image = id;
- wi.state = 0;
- _wiz->simpleDrawAWiz(wi.image, wi.state, wi.x, wi.y, wi.flags);
+ } else if (type == kLTImage) {
+ _wiz->drawAWiz(color, 0, x, y, 0, 0, 0, 0, nullptr, 0, nullptr);
} else {
- drawPixel(x, y, id);
+ drawPixel(x, y, color);
}
}
}
void ScummEngine_v80he::drawPixel(int x, int y, int flags) {
+ // TODO: RECHECK
byte *src, *dst;
VirtScreen *vs;
@@ -445,7 +433,7 @@ void ScummEngine_v80he::drawPixel(int x, int y, int flags) {
if (y < 0)
return;
- if ((vs = findVirtScreen(y)) == NULL)
+ if ((vs = findVirtScreen(y)) == nullptr)
return;
markRectAsDirty(vs->number, x, y, x, y + 1);
@@ -471,12 +459,13 @@ void ScummEngine_v80he::drawPixel(int x, int y, int flags) {
}
void ScummEngine_v80he::o80_drawLine() {
- int id, step, x, y, x1, y1;
+ int id, step, x2, y2, x1, y1, type;
+ type = kLTColor;
step = pop();
id = pop();
- y = pop();
- x = pop();
+ y2 = pop();
+ x2 = pop();
y1 = pop();
x1 = pop();
@@ -484,18 +473,17 @@ void ScummEngine_v80he::o80_drawLine() {
switch (subOp) {
case SO_ACTOR:
- drawLine(x1, y1, x, y, step, 2, id);
+ type = kLTActor;
break;
case SO_IMAGE:
- drawLine(x1, y1, x, y, step, 3, id);
+ type = kLTImage;
break;
case SO_COLOR:
- drawLine(x1, y1, x, y, step, 1, id);
+ type = kLTColor;
break;
- default:
- error("o80_drawLine: default case %d", subOp);
}
+ drawLine(x1, y1, x2, y2, step, type, id);
}
void ScummEngine_v80he::o80_pickVarRandom() {
diff --git a/engines/scumm/he/sprite_he.cpp b/engines/scumm/he/sprite_he.cpp
index 2d07c221a86..f9044295af8 100644
--- a/engines/scumm/he/sprite_he.cpp
+++ b/engines/scumm/he/sprite_he.cpp
@@ -261,7 +261,7 @@ int Sprite::getSpriteAutoAnimFlag(int spriteId) {
int Sprite::getSpriteUpdateType(int spriteId) {
assertRange(1, spriteId, _maxSprites, "sprite");
- if (_vm->_game.heversion > 99) {
+ if (_vm->_game.heversion >= 99) {
if (_spriteTable[spriteId].flags & kSFSmartRender) {
return SPRDEF_SMART;
} else {
@@ -1895,7 +1895,7 @@ void Sprite::renderSprites(bool negativeOrPositiveRender) {
// Finally actually do something by calling the command parser
// this function is the same core that renders images via the
// "image" draw command.
- if (_vm->_game.heversion > 99) {
+ if (_vm->_game.heversion >= 99) {
imageRenderCmd.actionType = kWADraw;
_vm->_wiz->processWizImageCmd(&imageRenderCmd);
} else {
diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp
index e06d799bbc5..5567fc96d7b 100644
--- a/engines/scumm/he/wiz_he.cpp
+++ b/engines/scumm/he/wiz_he.cpp
@@ -96,7 +96,7 @@ void Wiz::takeAWiz(int globnum, int x1, int y1, int x2, int y2, bool back, bool
srcPtr, bufferWidth, bufferHeight,
palPtr, &rect,
(compress) ? kWCTTRLE : kWCTNone,
- globnum, _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR));
+ globnum, _vm->_game.heversion <= 90 ? 0x05 : _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR));
}
void Wiz::simpleDrawAWiz(int image, int state, int x, int y, int flags) {
@@ -163,7 +163,7 @@ byte *Wiz::drawAWizEx(int image, int state, int x, int y, int z, int flags, int
flags, optionalBitmapOverride, colorConversionTable, optionalICmdPtr);
} else {
warpDrawWiz(
- image, state, x, flags, _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR),
+ image, state, x, flags, _vm->_game.heversion <= 90 ? 0x05 : _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR),
optionalBitmapOverride, colorConversionTable, optionalShadowImage);
return nullptr;
@@ -203,13 +203,13 @@ void *Wiz::drawAWizPrimEx(int globNum, int state, int x, int y, int z, int shado
shadow_p = nullptr;
}
- if (_vm->_game.heversion <= 99 && _uses16BitColor) {
+ if (_vm->_game.heversion < 99 && _uses16BitColor) {
if (shadow_p) {
shadow_p = nullptr;
}
}
- if (_vm->_game.heversion > 99) {
+ if (_vm->_game.heversion >= 99) {
// If using a z-buffer make sure both globs are in ram!!!!
if (zbufferImage) {
// uncompressed 16-bit z-buffers only for now
@@ -289,7 +289,7 @@ void *Wiz::drawAWizPrimEx(int globNum, int state, int x, int y, int z, int shado
} else if (flags & kWRFAlloc) {
memset8BppConversion(
dest_p,
- _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR),
+ _vm->_game.heversion < 95 ? 0x05 : _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR),
dest_w * dest_h,
optionalColorConversionTable);
}
@@ -327,7 +327,7 @@ void *Wiz::drawAWizPrimEx(int globNum, int state, int x, int y, int z, int shado
}
// Get down to business and decompress the image...
- if (_vm->_game.heversion > 99 && zbufferImage) {
+ if (_vm->_game.heversion >= 99 && zbufferImage) {
WizSimpleBitmap sbZBuffer;
sbZBuffer.bitmapHeight = 0;
sbZBuffer.bitmapWidth = 0;
@@ -381,7 +381,7 @@ void *Wiz::drawAWizPrimEx(int globNum, int state, int x, int y, int z, int shado
x, y, src_w, src_h, &clip_r, shadow_p,
optionalColorConversionTable);
}
- } else if (_vm->_game.heversion >= 99) {
+ } else {
void *dataPtr = nullptr;
if (shadow_p)
@@ -407,7 +407,7 @@ void *Wiz::drawAWizPrimEx(int globNum, int state, int x, int y, int z, int shado
if (flags & kWRFRemap)
dataPtr = remap_p + _vm->_resourceHeaderSize + 4;
- if (doesRawWizStateHaveTransparency(globNum, state)) {
+ if (_vm->_game.heversion >= 95 && doesRawWizStateHaveTransparency(globNum, state)) {
transColorOverride = _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR);
} else {
transColorOverride = -1;
@@ -423,7 +423,7 @@ void *Wiz::drawAWizPrimEx(int globNum, int state, int x, int y, int z, int shado
error("Wiz::drawAWizPrimEx(): Raw data type mismatch for mode %d vs %d", src_c, kWCTNone16Bpp);
}
} else {
- if (_vm->_game.heversion > 99) {
+ if (_vm->_game.heversion >= 99) {
if (optionalColorConversionTable &&
((WizRawPixel *)_vm->getHEPaletteSlot(1) != optionalColorConversionTable)) {
flags |= kWRFRemap;
@@ -513,9 +513,11 @@ void Wiz::buildAWiz(const WizRawPixel *bufPtr, int bufWidth, int bufHeight, cons
error("Wiz::buildAWiz(): Unknown compression type %d", compressionType);
}
- // Make sure that the "glob" is even sized...
- if (dataSize & 1) {
- dataSize++;
+ if (_vm->_game.heversion > 90) {
+ // Make sure that the "glob" is even sized...
+ if (dataSize & 1) {
+ dataSize++;
+ }
}
// Finalize the glob size!
@@ -613,7 +615,6 @@ int Wiz::pixelHitTestWizPrim(int globNum, int state, int x, int y, int32 flags)
// return outValue;
//}
-
int src_c, src_w, src_h;
byte *src_d;
byte *pp;
@@ -1111,12 +1112,15 @@ void Wiz::flushAWizBuffer() {
void Wiz::loadWizCursor(int resId, int palette) {
int32 x, y;
+
getWizSpot(resId, 0, x, y);
+
if (x < 0) {
x = 0;
} else if (x > 32) {
x = 32;
}
+
if (y < 0) {
y = 0;
} else if (y > 32) {
@@ -2121,7 +2125,6 @@ int Wiz::createHistogramArrayForImage(int image, int state, const Common::Rect *
byte *src_d;
byte *pp;
- // This only makes sense in 8 bit color!!!!
globNum = image;
_vm->writeVar(0, 0);
@@ -2174,7 +2177,7 @@ int Wiz::createHistogramArrayForImage(int image, int state, const Common::Rect *
}
}
- return _vm->readVar(0); // Too much fun!!!!
+ return _vm->readVar(0);
}
void Wiz::ensureNativeFormatImageForState(int image, int state) {
@@ -2356,7 +2359,7 @@ void Wiz::processWizImageRenderFloodFillCmd(const WizImageCommand *params) {
if (isPointInRect(&clipRect, &pt)) {
floodSimpleFill(&renderBitmap, pt.x, pt.y, whatColor, &clipRect, &renderRect);
- if (_vm->_game.heversion > 99) {
+ if (_vm->_game.heversion >= 99) {
_vm->_res->setModified(rtImage, params->image);
}
}
diff --git a/engines/scumm/he/wizwarp_he.cpp b/engines/scumm/he/wizwarp_he.cpp
index 248346f781c..53a410d478f 100644
--- a/engines/scumm/he/wizwarp_he.cpp
+++ b/engines/scumm/he/wizwarp_he.cpp
@@ -172,7 +172,7 @@ bool Wiz::warpDrawWizTo4Points(int image, int state, const WarpWizPoint *dstPoin
srcPoints[3].y = srcBitmap.bitmapHeight - 1;
// Call the warping primitive!
- if (colorMixTable) {
+ if (_vm->_game.heversion >= 95 && colorMixTable) {
rValue = warpNPt2NPtClippedWarpMixColors(
&dstBitmap, dstPoints, &srcBitmap, srcPoints, 4, transparentColor,
optionalClipRect, colorMixTable);
diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
index 4178648adcb..8fd7da5918f 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -647,7 +647,7 @@ ScummEngine_v60he::ScummEngine_v60he(OSystem *syst, const DetectorResult &dr)
memset(_hInFileTable, 0, sizeof(_hInFileTable));
memset(_hOutFileTable, 0, sizeof(_hOutFileTable));
- setActorClippingRect(-1, 0, 0, 640 - 1, 480 - 1);
+ setActorClippingRect(-1, 0, 0, 640, 480);
memset(_heTimers, 0, sizeof(_heTimers));
Commit: ce193359e10a37d980ceffb4350727ad2f299690
https://github.com/scummvm/scummvm/commit/ce193359e10a37d980ceffb4350727ad2f299690
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Fix more 8-bit vs 16-bit issues
Changed paths:
engines/scumm/he/gfx_primitives_he.cpp
diff --git a/engines/scumm/he/gfx_primitives_he.cpp b/engines/scumm/he/gfx_primitives_he.cpp
index d383763d703..4bcb00f7552 100644
--- a/engines/scumm/he/gfx_primitives_he.cpp
+++ b/engines/scumm/he/gfx_primitives_he.cpp
@@ -663,15 +663,19 @@ void Wiz::pgSimpleBlit(WizSimpleBitmap *destBM, Common::Rect *destRect, WizSimpl
void Wiz::pgSimpleBlitRemapColors(WizSimpleBitmap *destBM, Common::Rect *destRect, WizSimpleBitmap *sourceBM, Common::Rect *sourceRect, const byte *remapColorTable) {
int cw, dw, sw, ch;
- WizRawPixel *s, *d;
+ WizRawPixel8 *s8, *d8;
+ WizRawPixel16 *s16, *d16;
// Common calcs...
dw = destBM->bitmapWidth;
sw = sourceBM->bitmapWidth;
cw = abs(sourceRect->right - sourceRect->left) + 1;
ch = abs(sourceRect->bottom - sourceRect->top) + 1;
- d = destBM->bufferPtr + destRect->top * dw + destRect->left;
- s = sourceBM->bufferPtr + sourceRect->top * sw + sourceRect->left;
+
+ d8 = ((WizRawPixel8 *)destBM->bufferPtr) + destRect->top * dw + destRect->left;
+ s8 = ((WizRawPixel8 *)sourceBM->bufferPtr) + sourceRect->top * sw + sourceRect->left;
+ d16 = ((WizRawPixel16 *)destBM->bufferPtr) + destRect->top * dw + destRect->left;
+ s16 = ((WizRawPixel16 *)sourceBM->bufferPtr) + sourceRect->top * sw + sourceRect->left;
// Going up or down?
if (sourceRect->top > sourceRect->bottom) {
@@ -680,36 +684,61 @@ void Wiz::pgSimpleBlitRemapColors(WizSimpleBitmap *destBM, Common::Rect *destRec
// Left or right?
if (sourceRect->left <= sourceRect->right) {
- while (--ch >= 0) {
- pgForewordRemapPixelCopy(d, s, cw, remapColorTable);
+ if (!_uses16BitColor) {
+ while (--ch >= 0) {
+ pgForewordRemapPixelCopy((WizRawPixel *)d8, (WizRawPixel *)s8, cw, remapColorTable);
+
+ d8 += dw;
+ s8 += sw;
+ }
+ } else {
+ while (--ch >= 0) {
+ pgForewordRemapPixelCopy((WizRawPixel *)d16, (WizRawPixel *)s16, cw, remapColorTable);
- d += dw;
- s += sw;
+ d16 += dw;
+ s16 += sw;
+ }
}
} else {
- d += (cw - 1);
- s -= (cw - 1);
+ if (!_uses16BitColor) {
+ d8 += (cw - 1);
+ s8 -= (cw - 1);
- while (--ch >= 0) {
- pgBackwardsRemapPixelCopy(d, s, cw, remapColorTable);
+ while (--ch >= 0) {
+ pgBackwardsRemapPixelCopy((WizRawPixel *)d8, (WizRawPixel *)s8, cw, remapColorTable);
- d += dw;
- s += sw;
+ d8 += dw;
+ s8 += sw;
+ }
+ } else {
+ d16 += (cw - 1);
+ s16 -= (cw - 1);
+
+ while (--ch >= 0) {
+ pgBackwardsRemapPixelCopy((WizRawPixel *)d16, (WizRawPixel *)s16, cw, remapColorTable);
+
+ d16 += dw;
+ s16 += sw;
+ }
}
}
}
void Wiz::pgSimpleBlitTransparentRemapColors(WizSimpleBitmap *destBM, Common::Rect *destRect, WizSimpleBitmap *sourceBM, Common::Rect *sourceRect, WizRawPixel transparentColor, const byte *remapColorTable) {
int cw, dw, sw, ch;
- WizRawPixel *s, *d;
+ WizRawPixel8 *s8, *d8;
+ WizRawPixel16 *s16, *d16;
// Common calcs...
dw = destBM->bitmapWidth;
sw = sourceBM->bitmapWidth;
cw = abs(sourceRect->right - sourceRect->left) + 1;
ch = abs(sourceRect->bottom - sourceRect->top) + 1;
- d = destBM->bufferPtr + destRect->top * dw + destRect->left;
- s = sourceBM->bufferPtr + sourceRect->top * sw + sourceRect->left;
+
+ d8 = ((WizRawPixel8 *)destBM->bufferPtr) + destRect->top * dw + destRect->left;
+ s8 = ((WizRawPixel8 *)sourceBM->bufferPtr) + sourceRect->top * sw + sourceRect->left;
+ d16 = ((WizRawPixel16 *)destBM->bufferPtr) + destRect->top * dw + destRect->left;
+ s16 = ((WizRawPixel16 *)sourceBM->bufferPtr) + sourceRect->top * sw + sourceRect->left;
// Going up or down?
if (sourceRect->top > sourceRect->bottom) {
@@ -718,36 +747,61 @@ void Wiz::pgSimpleBlitTransparentRemapColors(WizSimpleBitmap *destBM, Common::Re
// Left or right?
if (sourceRect->left <= sourceRect->right) {
- while (--ch >= 0) {
- pgTransparentForewordRemapPixelCopy(d, s, cw, transparentColor, remapColorTable);
+ if (!_uses16BitColor) {
+ while (--ch >= 0) {
+ pgTransparentForewordRemapPixelCopy((WizRawPixel *)d8, (WizRawPixel *)s8, cw, transparentColor, remapColorTable);
+
+ d8 += dw;
+ s8 += sw;
+ }
+ } else {
+ while (--ch >= 0) {
+ pgTransparentForewordRemapPixelCopy((WizRawPixel *)d16, (WizRawPixel *)s16, cw, transparentColor, remapColorTable);
- d += dw;
- s += sw;
+ d16 += dw;
+ s16 += sw;
+ }
}
} else {
- d += (cw - 1);
- s -= (cw - 1);
+ if (!_uses16BitColor) {
+ d8 += (cw - 1);
+ s8 -= (cw - 1);
- while (--ch >= 0) {
- pgTransparentBackwardsRemapPixelCopy(d, s, cw, transparentColor, remapColorTable);
+ while (--ch >= 0) {
+ pgTransparentBackwardsRemapPixelCopy((WizRawPixel *)d8, (WizRawPixel *)s8, cw, transparentColor, remapColorTable);
- d += dw;
- s += sw;
+ d8 += dw;
+ s8 += sw;
+ }
+ } else {
+ d16 += (cw - 1);
+ s16 -= (cw - 1);
+
+ while (--ch >= 0) {
+ pgTransparentBackwardsRemapPixelCopy((WizRawPixel *)d16, (WizRawPixel *)s16, cw, transparentColor, remapColorTable);
+
+ d16 += dw;
+ s16 += sw;
+ }
}
}
}
void Wiz::pgSimpleBlitMixColors(WizSimpleBitmap *destBM, Common::Rect *destRect, WizSimpleBitmap *sourceBM, Common::Rect *sourceRect, const byte *mixColorTable) {
int cw, dw, sw, ch;
- WizRawPixel *s, *d;
+ WizRawPixel8 *s8, *d8;
+ WizRawPixel16 *s16, *d16;
// Common calcs...
dw = destBM->bitmapWidth;
sw = sourceBM->bitmapWidth;
cw = abs(sourceRect->right - sourceRect->left) + 1;
ch = abs(sourceRect->bottom - sourceRect->top) + 1;
- d = destBM->bufferPtr + destRect->top * dw + destRect->left;
- s = sourceBM->bufferPtr + sourceRect->top * sw + sourceRect->left;
+
+ d8 = ((WizRawPixel8 *)destBM->bufferPtr) + destRect->top * dw + destRect->left;
+ s8 = ((WizRawPixel8 *)sourceBM->bufferPtr) + sourceRect->top * sw + sourceRect->left;
+ d16 = ((WizRawPixel16 *)destBM->bufferPtr) + destRect->top * dw + destRect->left;
+ s16 = ((WizRawPixel16 *)sourceBM->bufferPtr) + sourceRect->top * sw + sourceRect->left;
// Going up or down?
if (sourceRect->top > sourceRect->bottom) {
@@ -756,36 +810,61 @@ void Wiz::pgSimpleBlitMixColors(WizSimpleBitmap *destBM, Common::Rect *destRect,
// Left or right?
if (sourceRect->left <= sourceRect->right) {
- while (--ch >= 0) {
- pgForewordMixColorsPixelCopy(d, s, cw, mixColorTable);
+ if (!_uses16BitColor) {
+ while (--ch >= 0) {
+ pgForewordMixColorsPixelCopy((WizRawPixel *)d8, (WizRawPixel *)s8, cw, mixColorTable);
+
+ d8 += dw;
+ s8 += sw;
+ }
+ } else {
+ while (--ch >= 0) {
+ pgForewordMixColorsPixelCopy((WizRawPixel *)d16, (WizRawPixel *)s16, cw, mixColorTable);
- d += dw;
- s += sw;
+ d16 += dw;
+ s16 += sw;
+ }
}
} else {
- d += (cw - 1);
- s -= (cw - 1);
+ if (!_uses16BitColor) {
+ d8 += (cw - 1);
+ s8 -= (cw - 1);
- while (--ch >= 0) {
- pgBackwardsMixColorsPixelCopy(d, s, cw, mixColorTable);
+ while (--ch >= 0) {
+ pgBackwardsMixColorsPixelCopy((WizRawPixel *)d8, (WizRawPixel *)s8, cw, mixColorTable);
- d += dw;
- s += sw;
+ d8 += dw;
+ s8 += sw;
+ }
+ } else {
+ d16 += (cw - 1);
+ s16 -= (cw - 1);
+
+ while (--ch >= 0) {
+ pgBackwardsMixColorsPixelCopy((WizRawPixel *)d16, (WizRawPixel *)s16, cw, mixColorTable);
+
+ d16 += dw;
+ s16 += sw;
+ }
}
}
}
void Wiz::pgSimpleBlitTransparentMixColors(WizSimpleBitmap *destBM, Common::Rect *destRect, WizSimpleBitmap *sourceBM, Common::Rect *sourceRect, WizRawPixel transparentColor, const byte *mixColorTable) {
int cw, dw, sw, ch;
- WizRawPixel *s, *d;
+ WizRawPixel8 *s8, *d8;
+ WizRawPixel16 *s16, *d16;
// Common calcs...
dw = destBM->bitmapWidth;
sw = sourceBM->bitmapWidth;
cw = abs(sourceRect->right - sourceRect->left) + 1;
ch = abs(sourceRect->bottom - sourceRect->top) + 1;
- d = destBM->bufferPtr + destRect->top * dw + destRect->left;
- s = sourceBM->bufferPtr + sourceRect->top * sw + sourceRect->left;
+
+ d8 = ((WizRawPixel8 *)destBM->bufferPtr) + destRect->top * dw + destRect->left;
+ s8 = ((WizRawPixel8 *)sourceBM->bufferPtr) + sourceRect->top * sw + sourceRect->left;
+ d16 = ((WizRawPixel16 *)destBM->bufferPtr) + destRect->top * dw + destRect->left;
+ s16 = ((WizRawPixel16 *)sourceBM->bufferPtr) + sourceRect->top * sw + sourceRect->left;
// Going up or down?
if (sourceRect->top > sourceRect->bottom) {
@@ -794,21 +873,42 @@ void Wiz::pgSimpleBlitTransparentMixColors(WizSimpleBitmap *destBM, Common::Rect
// Left or right?
if (sourceRect->left <= sourceRect->right) {
- while (--ch >= 0) {
- pgTransparentForewordMixColorsPixelCopy(d, s, cw, transparentColor, mixColorTable);
+ if (!_uses16BitColor) {
+ while (--ch >= 0) {
+ pgTransparentForewordMixColorsPixelCopy((WizRawPixel *)d8, (WizRawPixel *)s8, cw, transparentColor, mixColorTable);
+
+ d8 += dw;
+ s8 += sw;
+ }
+ } else {
+ while (--ch >= 0) {
+ pgTransparentForewordMixColorsPixelCopy((WizRawPixel *)d16, (WizRawPixel *)s16, cw, transparentColor, mixColorTable);
- d += dw;
- s += sw;
+ d16 += dw;
+ s16 += sw;
+ }
}
} else {
- d += (cw - 1);
- s -= (cw - 1);
+ if (!_uses16BitColor) {
+ d8 += (cw - 1);
+ s8 -= (cw - 1);
- while (--ch >= 0) {
- pgTransparentBackwardsMixColorsPixelCopy(d, s, cw, transparentColor, mixColorTable);
+ while (--ch >= 0) {
+ pgTransparentBackwardsMixColorsPixelCopy((WizRawPixel *)d8, (WizRawPixel *)s8, cw, transparentColor, mixColorTable);
- d += dw;
- s += sw;
+ d8 += dw;
+ s8 += sw;
+ }
+ } else {
+ d16 += (cw - 1);
+ s16 -= (cw - 1);
+
+ while (--ch >= 0) {
+ pgTransparentBackwardsMixColorsPixelCopy((WizRawPixel *)d16, (WizRawPixel *)s16, cw, transparentColor, mixColorTable);
+
+ d16 += dw;
+ s16 += sw;
+ }
}
}
}
Commit: 8d416fbbc77b39d63bc4a5f5c667e4ae1b89f7fc
https://github.com/scummvm/scummvm/commit/8d416fbbc77b39d63bc4a5f5c667e4ae1b89f7fc
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Fix remap call
Changed paths:
engines/scumm/he/wiz_he.cpp
diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp
index 5567fc96d7b..5a4f5cc2b70 100644
--- a/engines/scumm/he/wiz_he.cpp
+++ b/engines/scumm/he/wiz_he.cpp
@@ -2104,7 +2104,7 @@ void Wiz::remapImagePrim(int image, int state, int tableCount, const uint8 *rema
byte *basePtr;
// Find the table...
- basePtr = getWizStateRemapDataPrim(rtImage, image);
+ basePtr = getWizStateRemapDataPrim(image, state);
assert(basePtr);
// Set the modified bit...
Commit: bb509c68f0cca25c69cbfc8ecb2fe0c9998b3703
https://github.com/scummvm/scummvm/commit/bb509c68f0cca25c69cbfc8ecb2fe0c9998b3703
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: More fixes
Changed paths:
engines/scumm/he/gfx_primitives_he.cpp
diff --git a/engines/scumm/he/gfx_primitives_he.cpp b/engines/scumm/he/gfx_primitives_he.cpp
index 4bcb00f7552..28151d720ef 100644
--- a/engines/scumm/he/gfx_primitives_he.cpp
+++ b/engines/scumm/he/gfx_primitives_he.cpp
@@ -577,15 +577,15 @@ void Wiz::pgDrawRawDataFormatImage(WizRawPixel *bufferPtr, const WizRawPixel *ra
if (extraTable) {
if (wizFlags & kWRFRemap) {
if (transparentColor == -1) {
- pgSimpleBlitRemapColors(&dstBitmap, &dstRect, &srcBitmap, &srcRect, (byte *)extraTable);
+ pgSimpleBlitRemapColors(&dstBitmap, &dstRect, &srcBitmap, &srcRect, (const byte *)extraTable);
} else {
- pgSimpleBlitTransparentRemapColors(&dstBitmap, &dstRect, &srcBitmap, &srcRect, (WizRawPixel)transparentColor, (byte *)extraTable);
+ pgSimpleBlitTransparentRemapColors(&dstBitmap, &dstRect, &srcBitmap, &srcRect, (WizRawPixel)transparentColor, (const byte *)extraTable);
}
} else {
if (transparentColor == -1) {
- pgSimpleBlitMixColors(&dstBitmap, &dstRect, &srcBitmap, &srcRect, (byte *)extraTable);
+ pgSimpleBlitMixColors(&dstBitmap, &dstRect, &srcBitmap, &srcRect, (const byte *)extraTable);
} else {
- pgSimpleBlitTransparentMixColors(&dstBitmap, &dstRect, &srcBitmap, &srcRect, (WizRawPixel)transparentColor, (byte *)extraTable);
+ pgSimpleBlitTransparentMixColors(&dstBitmap, &dstRect, &srcBitmap, &srcRect, (WizRawPixel)transparentColor, (const byte *)extraTable);
}
}
} else {
@@ -622,7 +622,7 @@ void Wiz::pgSimpleBlit(WizSimpleBitmap *destBM, Common::Rect *destRect, WizSimpl
// Left or right?
if (sourceRect->left <= sourceRect->right) {
- cSize = (cw * sizeof(WizRawPixel));
+ cSize = _uses16BitColor ? (cw * sizeof(WizRawPixel16)) : (cw * sizeof(WizRawPixel8));
while (--ch >= 0) {
if (!_uses16BitColor) {
Commit: 7d46b01e40ed9efd463613d004734448d04d6e57
https://github.com/scummvm/scummvm/commit/7d46b01e40ed9efd463613d004734448d04d6e57
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: More 8-bit vs 16-bit fixes
Changed paths:
engines/scumm/he/gfx_comp/trle_comp.cpp
engines/scumm/he/wiz_he.h
diff --git a/engines/scumm/he/gfx_comp/trle_comp.cpp b/engines/scumm/he/gfx_comp/trle_comp.cpp
index 90ca86032ce..f42e6d075dd 100644
--- a/engines/scumm/he/gfx_comp/trle_comp.cpp
+++ b/engines/scumm/he/gfx_comp/trle_comp.cpp
@@ -259,13 +259,13 @@ WizRawPixel Wiz::trleFLIPAlphaMixPrim(WizRawPixel b, WizRawPixel a, int alpha) {
<< WIZRAWPIXEL_B_SHIFT));
}
-void TRLEFLIP_HorzFlipAlignWithRect(Common::Rect *rectToAlign, const Common::Rect *baseRect) {
+void trleFLIPHorzFlipAlignWithRect(Common::Rect *rectToAlign, const Common::Rect *baseRect) {
int dx = (baseRect->right - rectToAlign->right) - (rectToAlign->left - baseRect->left);
rectToAlign->left += dx;
rectToAlign->right += dx;
}
-void TRLEFLIP_VertFlipAlignWithRect(Common::Rect *rectToAlign, const Common::Rect *baseRect) {
+void trleFLIPVertFlipAlignWithRect(Common::Rect *rectToAlign, const Common::Rect *baseRect) {
int dy = (baseRect->bottom - rectToAlign->bottom) - (rectToAlign->top - baseRect->top);
rectToAlign->top += dy;
rectToAlign->bottom += dy;
@@ -413,14 +413,14 @@ void Wiz::trleFLIPDecompressPrim(
// Handle the flip coords source adjustment...
if (flags & kWRFHFlip) {
functionPtr = backwardFunctionPtr;
- TRLEFLIP_HorzFlipAlignWithRect(&sourceRect, &inSourceRect);
+ trleFLIPHorzFlipAlignWithRect(&sourceRect, &inSourceRect);
swapRectX(&destRect);
} else {
functionPtr = forewordFunctionPtr;
}
if (flags & kWRFVFlip) {
- TRLEFLIP_VertFlipAlignWithRect(&sourceRect, &inSourceRect);
+ trleFLIPVertFlipAlignWithRect(&sourceRect, &inSourceRect);
swapRectY(&destRect);
}
@@ -432,86 +432,169 @@ void Wiz::trleFLIPDecompressPrim(
void Wiz::trleFLIPFiftyFiftyMixPixelMemset(WizRawPixel *dstPtr, WizRawPixel mixColor, int size) {
WizRawPixel adjustedColor = WIZRAWPIXEL_50_50_PREMIX_COLOR(mixColor);
+ WizRawPixel8 *dst8 = (WizRawPixel8 *)dstPtr;
+ WizRawPixel16 *dst16 = (WizRawPixel16 *)dstPtr;
while (size-- > 0) {
- *dstPtr++ = WIZRAWPIXEL_50_50_MIX(
- adjustedColor, WIZRAWPIXEL_50_50_PREMIX_COLOR(*dstPtr));
+ if (!_uses16BitColor) {
+ *dst8++ = WIZRAWPIXEL_50_50_MIX(
+ adjustedColor, WIZRAWPIXEL_50_50_PREMIX_COLOR(*dst8));
+ } else {
+ *dst16++ = WIZRAWPIXEL_50_50_MIX(
+ adjustedColor, WIZRAWPIXEL_50_50_PREMIX_COLOR(*dst16));
+ }
}
}
void Wiz::trleFLIPFiftyFiftyMixForwardPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable) {
+ WizRawPixel8 *dst8 = (WizRawPixel8 *)dstPtr;
+ WizRawPixel16 *dst16 = (WizRawPixel16 *)dstPtr;
+
while (size-- > 0) {
- WizRawPixel srcColor = convert8BppToRawPixel(*srcPtr++, conversionTable);
- *dstPtr++ = WIZRAWPIXEL_50_50_MIX(
- WIZRAWPIXEL_50_50_PREMIX_COLOR(srcColor),
- WIZRAWPIXEL_50_50_PREMIX_COLOR(*dstPtr));
+ if (!_uses16BitColor) {
+ WizRawPixel srcColor = convert8BppToRawPixel(*srcPtr++, conversionTable);
+ *dst8++ = WIZRAWPIXEL_50_50_MIX(
+ WIZRAWPIXEL_50_50_PREMIX_COLOR(srcColor),
+ WIZRAWPIXEL_50_50_PREMIX_COLOR(*dst8));
+ } else {
+ WizRawPixel srcColor = convert8BppToRawPixel(*srcPtr++, conversionTable);
+ *dst16++ = WIZRAWPIXEL_50_50_MIX(
+ WIZRAWPIXEL_50_50_PREMIX_COLOR(srcColor),
+ WIZRAWPIXEL_50_50_PREMIX_COLOR(*dst16));
+ }
}
}
void Wiz::trleFLIPFiftyFiftyMixBackwardsPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable) {
+ WizRawPixel8 *dst8 = (WizRawPixel8 *)dstPtr;
+ WizRawPixel16 *dst16 = (WizRawPixel16 *)dstPtr;
+
while (size-- > 0) {
- WizRawPixel srcColor = convert8BppToRawPixel(*srcPtr++, conversionTable);
- *dstPtr-- = WIZRAWPIXEL_50_50_MIX(
- WIZRAWPIXEL_50_50_PREMIX_COLOR(srcColor),
- WIZRAWPIXEL_50_50_PREMIX_COLOR(*dstPtr));
+ if (!_uses16BitColor) {
+ WizRawPixel srcColor = convert8BppToRawPixel(*srcPtr++, conversionTable);
+ *dst8-- = WIZRAWPIXEL_50_50_MIX(
+ WIZRAWPIXEL_50_50_PREMIX_COLOR(srcColor),
+ WIZRAWPIXEL_50_50_PREMIX_COLOR(*dst8));
+ } else {
+ WizRawPixel srcColor = convert8BppToRawPixel(*srcPtr++, conversionTable);
+ *dst16-- = WIZRAWPIXEL_50_50_MIX(
+ WIZRAWPIXEL_50_50_PREMIX_COLOR(srcColor),
+ WIZRAWPIXEL_50_50_PREMIX_COLOR(*dst16));
+ }
}
}
-void Wiz::trleFLIPADDITIVEPixelMemset(WizRawPixel *dstPtr, WizRawPixel mixColor, int size) {
- while (size-- > 0) {
- WizRawPixel workColor = *dstPtr;
+void Wiz::trleFLIPAdditivePixelMemset(WizRawPixel *dstPtr, WizRawPixel mixColor, int size) {
+ WizRawPixel8 *dst8 = (WizRawPixel8 *)dstPtr;
+ WizRawPixel16 *dst16 = (WizRawPixel16 *)dstPtr;
- *dstPtr++ = (WizRawPixel)WIZRAWPIXEL_ADDITIVE_MIX(workColor, mixColor);
+ while (size-- > 0) {
+ if (!_uses16BitColor) {
+ WizRawPixel workColor = *dst8;
+ *dst8++ = (WizRawPixel8)WIZRAWPIXEL_ADDITIVE_MIX(workColor, mixColor);
+ } else {
+ WizRawPixel workColor = *dst16;
+ *dst16++ = (WizRawPixel16)WIZRAWPIXEL_ADDITIVE_MIX(workColor, mixColor);
+ }
}
}
-void Wiz::trleFLIPADDITIVEForwardPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable) {
+void Wiz::trleFLIPAdditiveForwardPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable) {
+ WizRawPixel8 *dst8 = (WizRawPixel8 *)dstPtr;
+ WizRawPixel16 *dst16 = (WizRawPixel16 *)dstPtr;
+
while (size-- > 0) {
- WizRawPixel srcColor = convert8BppToRawPixel(*srcPtr++, conversionTable);
- WizRawPixel workColor = *dstPtr;
+ if (!_uses16BitColor) {
+ WizRawPixel srcColor = convert8BppToRawPixel(*srcPtr++, conversionTable);
+ WizRawPixel workColor = *dst8;
- *dstPtr++ = (WizRawPixel)WIZRAWPIXEL_ADDITIVE_MIX(workColor, srcColor);
+ *dst8++ = (WizRawPixel8)WIZRAWPIXEL_ADDITIVE_MIX(workColor, srcColor);
+ } else {
+ WizRawPixel srcColor = convert8BppToRawPixel(*srcPtr++, conversionTable);
+ WizRawPixel workColor = *dst16;
+
+ *dst16++ = (WizRawPixel16)WIZRAWPIXEL_ADDITIVE_MIX(workColor, srcColor);
+ }
}
}
-void Wiz::trleFLIPADDITIVEBackwardsPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable) {
+void Wiz::trleFLIPAdditiveBackwardsPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable) {
+ WizRawPixel8 *dst8 = (WizRawPixel8 *)dstPtr;
+ WizRawPixel16 *dst16 = (WizRawPixel16 *)dstPtr;
+
while (size-- > 0) {
- WizRawPixel srcColor = convert8BppToRawPixel(*srcPtr++, conversionTable);
- WizRawPixel workColor = *dstPtr;
+ if (!_uses16BitColor) {
+ WizRawPixel srcColor = convert8BppToRawPixel(*srcPtr++, conversionTable);
+ WizRawPixel workColor = *dst8;
- *dstPtr-- = (WizRawPixel)WIZRAWPIXEL_ADDITIVE_MIX(workColor, srcColor);
+ *dst8-- = (WizRawPixel8)WIZRAWPIXEL_ADDITIVE_MIX(workColor, srcColor);
+ } else {
+ WizRawPixel srcColor = convert8BppToRawPixel(*srcPtr++, conversionTable);
+ WizRawPixel workColor = *dst16;
+
+ *dst16-- = (WizRawPixel16)WIZRAWPIXEL_ADDITIVE_MIX(workColor, srcColor);
+ }
}
}
-void Wiz::trleFLIPSUBTRACTIVEPixelMemset(WizRawPixel *dstPtr, WizRawPixel mixColor, int size) {
- while (size-- > 0) {
- WizRawPixel workColor = *dstPtr;
+void Wiz::trleFLIPSubtractivePixelMemset(WizRawPixel *dstPtr, WizRawPixel mixColor, int size) {
+ WizRawPixel8 *dst8 = (WizRawPixel8 *)dstPtr;
+ WizRawPixel16 *dst16 = (WizRawPixel16 *)dstPtr;
- *dstPtr++ = (WizRawPixel)WIZRAWPIXEL_SUBTRACTIVE_MIX(workColor, mixColor);
+ while (size-- > 0) {
+ if (!_uses16BitColor) {
+ WizRawPixel workColor = *dst8;
+ *dst8++ = (WizRawPixel8)WIZRAWPIXEL_SUBTRACTIVE_MIX(workColor, mixColor);
+ } else {
+ WizRawPixel workColor = *dst16;
+ *dst16++ = (WizRawPixel16)WIZRAWPIXEL_SUBTRACTIVE_MIX(workColor, mixColor);
+ }
}
}
-void Wiz::trleFLIPSUBTRACTIVEForwardPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable) {
+void Wiz::trleFLIPSubtractiveForwardPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable) {
+ WizRawPixel8 *dst8 = (WizRawPixel8 *)dstPtr;
+ WizRawPixel16 *dst16 = (WizRawPixel16 *)dstPtr;
+
while (size-- > 0) {
- WizRawPixel srcColor = convert8BppToRawPixel(*srcPtr++, conversionTable);
- WizRawPixel workColor = *dstPtr;
+ if (!_uses16BitColor) {
+ WizRawPixel srcColor = convert8BppToRawPixel(*srcPtr++, conversionTable);
+ WizRawPixel workColor = *dst8;
+
+ *dst8++ = (WizRawPixel8)WIZRAWPIXEL_SUBTRACTIVE_MIX(workColor, srcColor);
+ } else {
+ WizRawPixel srcColor = convert8BppToRawPixel(*srcPtr++, conversionTable);
+ WizRawPixel workColor = *dst16;
- *dstPtr++ = (WizRawPixel)WIZRAWPIXEL_SUBTRACTIVE_MIX(workColor, srcColor);
+ *dst16++ = (WizRawPixel16)WIZRAWPIXEL_SUBTRACTIVE_MIX(workColor, srcColor);
+ }
}
}
-void Wiz::trleFLIPSUBTRACTIVEBackwardsPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable) {
+void Wiz::trleFLIPSubtractiveBackwardsPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable) {
+ WizRawPixel8 *dst8 = (WizRawPixel8 *)dstPtr;
+ WizRawPixel16 *dst16 = (WizRawPixel16 *)dstPtr;
+
while (size-- > 0) {
- WizRawPixel srcColor = convert8BppToRawPixel(*srcPtr++, conversionTable);
- WizRawPixel workColor = *dstPtr;
+ if (!_uses16BitColor) {
+ WizRawPixel srcColor = convert8BppToRawPixel(*srcPtr++, conversionTable);
+ WizRawPixel workColor = *dst8;
- *dstPtr-- = (WizRawPixel)WIZRAWPIXEL_SUBTRACTIVE_MIX(workColor, srcColor);
+ *dst8-- = (WizRawPixel8)WIZRAWPIXEL_SUBTRACTIVE_MIX(workColor, srcColor);
+ } else {
+ WizRawPixel srcColor = convert8BppToRawPixel(*srcPtr++, conversionTable);
+ WizRawPixel workColor = *dst16;
+
+ *dst16-- = (WizRawPixel16)WIZRAWPIXEL_SUBTRACTIVE_MIX(workColor, srcColor);
+ }
}
}
void Wiz::trleFLIPRemapDestPixels(WizRawPixel *dstPtr, int size, const byte *lookupTable) {
if (!_uses16BitColor) {
+ WizRawPixel8 *dst8 = (WizRawPixel8 *)dstPtr;
+
while (size-- > 0) {
- *dstPtr++ = *(lookupTable + *dstPtr);
+ *dst8++ = *(lookupTable + *dst8);
}
}
}
@@ -526,8 +609,6 @@ void Wiz::trleFLIPForwardPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int
} else {
*buf8++ = (WizRawPixel8)convert8BppToRawPixel(*srcPtr++, conversionTable);
}
-
- //*dstPtr++ = convert8BppToRawPixel(*srcPtr++, conversionTable);
}
if (_uses16BitColor) {
@@ -547,8 +628,6 @@ void Wiz::trleFLIPBackwardsPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, in
} else {
*buf8-- = (WizRawPixel8)convert8BppToRawPixel(*srcPtr++, conversionTable);
}
-
- //*dstPtr-- = convert8BppToRawPixel(*srcPtr++, conversionTable);
}
if (_uses16BitColor) {
@@ -568,8 +647,6 @@ void Wiz::trleFLIPForewordLookupPixelCopy(WizRawPixel *dstPtr, const byte *srcPt
} else {
*buf8++ = (WizRawPixel8)convert8BppToRawPixel(*(lookupTable + *srcPtr++), conversionTable);
}
-
- //*dstPtr++ = convert8BppToRawPixel(*(lookupTable + *srcPtr++), conversionTable);
}
if (_uses16BitColor) {
@@ -589,8 +666,6 @@ void Wiz::trleFLIPBackwardsLookupPixelCopy(WizRawPixel *dstPtr, const byte *srcP
} else {
*buf8-- = (WizRawPixel8)convert8BppToRawPixel(*(lookupTable + *srcPtr++), conversionTable);
}
-
- //*dstPtr-- = convert8BppToRawPixel(*(lookupTable + *srcPtr++), conversionTable);
}
if (_uses16BitColor) {
@@ -607,10 +682,8 @@ void Wiz::trleFLIPForewordMixColorsPixelCopy(WizRawPixel *dstPtr, const byte *sr
while (size-- > 0) {
if (!_uses16BitColor) {
*buf8++ = *(lookupTable + ((*srcPtr++) * 256) + *buf8);
- //*dstPtr++ = *(lookupTable + ((*srcPtr++) * 256) + *dstPtr);
} else {
*buf16++ = *srcPtr++;
- //*dstPtr++ = *srcPtr++;
}
}
@@ -628,10 +701,8 @@ void Wiz::trleFLIPBackwardsMixColorsPixelCopy(WizRawPixel *dstPtr, const byte *s
while (size-- > 0) {
if (!_uses16BitColor) {
*buf8-- = *(lookupTable + ((*srcPtr++) * 256) + *buf8);
- //*dstPtr-- = *(lookupTable + ((*srcPtr++) * 256) + *dstPtr);
} else {
*buf16-- = *srcPtr++;
- //*dstPtr-- = *srcPtr++;
}
}
@@ -642,28 +713,28 @@ void Wiz::trleFLIPBackwardsMixColorsPixelCopy(WizRawPixel *dstPtr, const byte *s
}
}
-static void TRLEFLIP_ADDATIVE_DecompressLineForeword(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable) {
+static void trleFLIPAdditiveDecompressLineForeword(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable) {
TRLEFLIP_X_Foreward_MACRO(
- wiz->trleFLIPADDITIVEPixelMemset,
- wiz->trleFLIPADDITIVEForwardPixelCopy);
+ wiz->trleFLIPAdditivePixelMemset,
+ wiz->trleFLIPAdditiveForwardPixelCopy);
}
-static void TRLEFLIP_ADDATIVE_DecompressLineBackward(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable) {
+static void trleFLIPAdditiveDecompressLineBackward(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable) {
TRLEFLIP_X_Backward_MACRO(
- wiz->trleFLIPADDITIVEPixelMemset,
- wiz->trleFLIPADDITIVEBackwardsPixelCopy);
+ wiz->trleFLIPAdditivePixelMemset,
+ wiz->trleFLIPAdditiveBackwardsPixelCopy);
}
-static void TRLEFLIP_SUBTRACTIVE_DecompressLineForeword(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable) {
+static void trleFLIPSubtractiveDecompressLineForeword(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable) {
TRLEFLIP_X_Foreward_MACRO(
- wiz->trleFLIPSUBTRACTIVEPixelMemset,
- wiz->trleFLIPSUBTRACTIVEForwardPixelCopy);
+ wiz->trleFLIPSubtractivePixelMemset,
+ wiz->trleFLIPSubtractiveForwardPixelCopy);
}
-static void TRLEFLIP_SUBTRACTIVE_DecompressLineBackward(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable) {
+static void trleFLIPSubtractiveDecompressLineBackward(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable) {
TRLEFLIP_X_Backward_MACRO(
- wiz->trleFLIPSUBTRACTIVEPixelMemset,
- wiz->trleFLIPSUBTRACTIVEBackwardsPixelCopy);
+ wiz->trleFLIPSubtractivePixelMemset,
+ wiz->trleFLIPSubtractiveBackwardsPixelCopy);
}
static void TRLEFLIP_DecompressLineForeword(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable) {
@@ -707,7 +778,7 @@ static void TRLEFLIP_DecompressLineForeword(Wiz *wiz, WizRawPixel *destPtr, cons
});
}
-static void TRLEFLIP_DecompressLineBackward(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable) {
+static void trleFLIPDecompressLineBackward(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable) {
int runCount;
WizRawPixel8 *dest8 = (WizRawPixel8 *)destPtr;
WizRawPixel16 *dest16 = (WizRawPixel16 *)destPtr;
@@ -748,7 +819,7 @@ static void TRLEFLIP_DecompressLineBackward(Wiz *wiz, WizRawPixel *destPtr, cons
});
}
-static void TRLEFLIP_LookupDecompressLineForeword(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable) {
+static void trleFLIPLookupDecompressLineForeword(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable) {
const byte *lookupTable;
int runCount;
WizRawPixel8 *dest8 = (WizRawPixel8 *)destPtr;
@@ -792,7 +863,7 @@ static void TRLEFLIP_LookupDecompressLineForeword(Wiz *wiz, WizRawPixel *destPtr
});
}
-static void TRLEFLIP_LookupDecompressLineBackward(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable) {
+static void trleFLIPLookupDecompressLineBackward(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable) {
const byte *lookupTable;
int runCount;
WizRawPixel8 *dest8 = (WizRawPixel8 *)destPtr;
@@ -836,7 +907,7 @@ static void TRLEFLIP_LookupDecompressLineBackward(Wiz *wiz, WizRawPixel *destPtr
});
}
-static void TRLEFLIP_MixDecompressLineForeword(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable) {
+static void trleFLIPMixDecompressLineForeword(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable) {
const byte *lookupTable;
int runCount;
WizRawPixel8 *dest8 = (WizRawPixel8 *)destPtr;
@@ -884,7 +955,7 @@ static void TRLEFLIP_MixDecompressLineForeword(Wiz *wiz, WizRawPixel *destPtr, c
});
}
-static void TRLEFLIP_MixDecompressLineBackward(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable) {
+static void trleFLIPMixDecompressLineBackward(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable) {
const byte *lookupTable;
int runCount;
WizRawPixel8 *dest8 = (WizRawPixel8 *)destPtr;
@@ -931,7 +1002,7 @@ static void TRLEFLIP_MixDecompressLineBackward(Wiz *wiz, WizRawPixel *destPtr, c
});
}
-static void TRLEFLIP_ArbitraryDstStepDecompressLine(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *userParam, int destStepValue, const WizRawPixel *conversionTable) {
+static void trleFLIPArbitraryDstStepDecompressLine(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *userParam, int destStepValue, const WizRawPixel *conversionTable) {
int runCount;
WizRawPixel8 *dest8 = (WizRawPixel8 *)destPtr;
WizRawPixel16 *dest16 = (WizRawPixel16 *)destPtr;
@@ -999,7 +1070,7 @@ static void TRLEFLIP_ArbitraryDstStepDecompressLine(Wiz *wiz, WizRawPixel *destP
);
}
-static void TRLEFLIP_LookupArbitraryDstStepDecompressLine(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *userParam, int destStepValue, const WizRawPixel *conversionTable) {
+static void trleFLIPLookupArbitraryDstStepDecompressLine(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *userParam, int destStepValue, const WizRawPixel *conversionTable) {
const byte *lookupTable;
int runCount;
WizRawPixel8 *dest8 = (WizRawPixel8 *)destPtr;
@@ -1069,7 +1140,7 @@ static void TRLEFLIP_LookupArbitraryDstStepDecompressLine(Wiz *wiz, WizRawPixel
);
}
-static void TRLEFLIP_MixArbitraryDstStepDecompressLine(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *userParam, int destStepValue, const WizRawPixel *conversionTable) {
+static void trleFLIPMixArbitraryDstStepDecompressLine(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *userParam, int destStepValue, const WizRawPixel *conversionTable) {
bool _uses16BitColor = wiz->_uses16BitColor;
const byte *mixColorTable;
const byte *lookupTable;
@@ -1154,12 +1225,12 @@ static void TRLEFLIP_MixArbitraryDstStepDecompressLine(Wiz *wiz, WizRawPixel *de
);
}
-static void TRLEFLIP_ADDITIVE_ArbitraryDstStepDecompressLine(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *userParam, int destStepValue, const WizRawPixel *conversionTable) {
+static void trleFLIPAdditiveArbitraryDstStepDecompressLine(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *userParam, int destStepValue, const WizRawPixel *conversionTable) {
bool _uses16BitColor = wiz->_uses16BitColor;
TRLEFLIP_X_ArbitraryDstStep_MACRO(WIZRAWPIXEL_ADDITIVE_MIX);
}
-static void TRLEFLIP_SUBTRACTIVE_ArbitraryDstStepDecompressLine(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *userParam, int destStepValue, const WizRawPixel *conversionTable) {
+static void trleFLIPSubtractiveArbitraryDstStepDecompressLine(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *userParam, int destStepValue, const WizRawPixel *conversionTable) {
bool _uses16BitColor = wiz->_uses16BitColor;
TRLEFLIP_X_ArbitraryDstStep_MACRO(WIZRAWPIXEL_SUBTRACTIVE_MIX);
}
@@ -1305,22 +1376,22 @@ void Wiz::trleFLIPDecompressImage(
if (wizFlags & kWRFAdditiveBlend) {
trleFLIPDecompressPrim(
&fakeBitmap, &fakeImage, x, y, nullptr, clipRectPtr, extraTable, wizFlags, conversionTable,
- TRLEFLIP_ADDATIVE_DecompressLineForeword,
- TRLEFLIP_ADDATIVE_DecompressLineBackward);
+ trleFLIPAdditiveDecompressLineForeword,
+ trleFLIPAdditiveDecompressLineBackward);
return;
} else if (wizFlags & kWRFSubtractiveBlend) {
trleFLIPDecompressPrim(
&fakeBitmap, &fakeImage, x, y, nullptr, clipRectPtr, extraTable, wizFlags, conversionTable,
- TRLEFLIP_SUBTRACTIVE_DecompressLineForeword,
- TRLEFLIP_SUBTRACTIVE_DecompressLineBackward);
+ trleFLIPSubtractiveDecompressLineForeword,
+ trleFLIPSubtractiveDecompressLineBackward);
return;
} else if (wizFlags & kWRF5050Blend) {
trleFLIPDecompressPrim(
&fakeBitmap, &fakeImage, x, y, nullptr, clipRectPtr, extraTable, wizFlags, conversionTable,
- TRLEFLIP_MixDecompressLineForeword,
- TRLEFLIP_MixDecompressLineBackward);
+ trleFLIPMixDecompressLineForeword,
+ trleFLIPMixDecompressLineBackward);
return;
}
@@ -1331,16 +1402,16 @@ void Wiz::trleFLIPDecompressImage(
if (!extraTable) {
trleFLIPDecompressPrim(
&fakeBitmap, &fakeImage, x, y, nullptr, clipRectPtr, extraTable, wizFlags, conversionTable,
- TRLEFLIP_DecompressLineForeword, TRLEFLIP_DecompressLineBackward);
+ TRLEFLIP_DecompressLineForeword, trleFLIPDecompressLineBackward);
} else if (wizFlags & kWRFRemap) {
trleFLIPDecompressPrim(
&fakeBitmap, &fakeImage, x, y, nullptr, clipRectPtr, extraTable, wizFlags, conversionTable,
- TRLEFLIP_LookupDecompressLineForeword, TRLEFLIP_LookupDecompressLineBackward);
+ trleFLIPLookupDecompressLineForeword, trleFLIPLookupDecompressLineBackward);
} else /* if (wizFlags & kWRFUseShadow) */ {
trleFLIPDecompressPrim(
&fakeBitmap, &fakeImage, x, y, nullptr, clipRectPtr, extraTable, wizFlags, conversionTable,
- TRLEFLIP_MixDecompressLineForeword,
- TRLEFLIP_MixDecompressLineBackward);
+ trleFLIPMixDecompressLineForeword,
+ trleFLIPMixDecompressLineBackward);
}
}
@@ -1386,7 +1457,7 @@ void Wiz::trleFLIPRotate90DecompressImage(
&fakeBitmap, x, y, &fakeImage, nullptr, clipRectPtr,
(wizFlags & kWRFHFlip), (wizFlags & kWRFVFlip),
extraTable, conversionTable,
- TRLEFLIP_ADDITIVE_ArbitraryDstStepDecompressLine);
+ trleFLIPAdditiveArbitraryDstStepDecompressLine);
return;
} else if (wizFlags & kWRFSubtractiveBlend) {
@@ -1394,7 +1465,7 @@ void Wiz::trleFLIPRotate90DecompressImage(
&fakeBitmap, x, y, &fakeImage, nullptr, clipRectPtr,
(wizFlags & kWRFHFlip), (wizFlags & kWRFVFlip),
extraTable, conversionTable,
- TRLEFLIP_SUBTRACTIVE_ArbitraryDstStepDecompressLine);
+ trleFLIPSubtractiveArbitraryDstStepDecompressLine);
return;
} else if (wizFlags & kWRF5050Blend) {
@@ -1402,7 +1473,7 @@ void Wiz::trleFLIPRotate90DecompressImage(
&fakeBitmap, x, y, &fakeImage, nullptr, clipRectPtr,
(wizFlags & kWRFHFlip), (wizFlags & kWRFVFlip),
extraTable, conversionTable,
- TRLEFLIP_MixArbitraryDstStepDecompressLine);
+ trleFLIPMixArbitraryDstStepDecompressLine);
return;
}
@@ -1415,20 +1486,20 @@ void Wiz::trleFLIPRotate90DecompressImage(
&fakeBitmap, x, y, &fakeImage, nullptr, clipRectPtr,
(wizFlags & kWRFHFlip), (wizFlags & kWRFVFlip),
extraTable, conversionTable,
- TRLEFLIP_ArbitraryDstStepDecompressLine);
+ trleFLIPArbitraryDstStepDecompressLine);
} else if (wizFlags & kWRFRemap) {
trleFLIP90DegreeRotateCore(
&fakeBitmap, x, y, &fakeImage, nullptr, clipRectPtr,
(wizFlags & kWRFHFlip), (wizFlags & kWRFVFlip),
extraTable, conversionTable,
- TRLEFLIP_LookupArbitraryDstStepDecompressLine);
+ trleFLIPLookupArbitraryDstStepDecompressLine);
} else /* if (wizFlags & kWRFUseShadow) */ {
trleFLIP90DegreeRotateCore(
&fakeBitmap, x, y, &fakeImage, nullptr, clipRectPtr,
(wizFlags & kWRFHFlip), (wizFlags & kWRFVFlip),
extraTable, conversionTable,
- TRLEFLIP_MixArbitraryDstStepDecompressLine);
+ trleFLIPMixArbitraryDstStepDecompressLine);
}
}
@@ -2074,14 +2145,14 @@ void Wiz::trleFLIPAltSourceDecompressPrim(
// Handle the flip coords source adjustment...
if (flags & kWRFHFlip) {
functionPtr = backwardFunctionPtr;
- TRLEFLIP_HorzFlipAlignWithRect(&sourceRect, &inSourceRect);
+ trleFLIPHorzFlipAlignWithRect(&sourceRect, &inSourceRect);
swapRectX(&destRect);
} else {
functionPtr = forewordFunctionPtr;
}
if (flags & kWRFVFlip) {
- TRLEFLIP_VertFlipAlignWithRect(&sourceRect, &inSourceRect);
+ trleFLIPVertFlipAlignWithRect(&sourceRect, &inSourceRect);
swapRectY(&destRect);
}
diff --git a/engines/scumm/he/wiz_he.h b/engines/scumm/he/wiz_he.h
index c7f45535ead..fce709c07eb 100644
--- a/engines/scumm/he/wiz_he.h
+++ b/engines/scumm/he/wiz_he.h
@@ -865,12 +865,12 @@ public:
void trleFLIPFiftyFiftyMixPixelMemset(WizRawPixel *dstPtr, WizRawPixel mixColor, int size);
void trleFLIPFiftyFiftyMixForwardPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable);
void trleFLIPFiftyFiftyMixBackwardsPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable);
- void trleFLIPADDITIVEPixelMemset(WizRawPixel *dstPtr, WizRawPixel mixColor, int size);
- void trleFLIPADDITIVEForwardPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable);
- void trleFLIPADDITIVEBackwardsPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable);
- void trleFLIPSUBTRACTIVEPixelMemset(WizRawPixel *dstPtr, WizRawPixel mixColor, int size);
- void trleFLIPSUBTRACTIVEForwardPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable);
- void trleFLIPSUBTRACTIVEBackwardsPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable);
+ void trleFLIPAdditivePixelMemset(WizRawPixel *dstPtr, WizRawPixel mixColor, int size);
+ void trleFLIPAdditiveForwardPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable);
+ void trleFLIPAdditiveBackwardsPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable);
+ void trleFLIPSubtractivePixelMemset(WizRawPixel *dstPtr, WizRawPixel mixColor, int size);
+ void trleFLIPSubtractiveForwardPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable);
+ void trleFLIPSubtractiveBackwardsPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable);
void trleFLIPRemapDestPixels(WizRawPixel *dstPtr, int size, const byte *lookupTable);
void trleFLIPForwardPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable);
void trleFLIPBackwardsPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable);
Commit: 8b69b3eccdd2782a4506ceea696af86604a70e40
https://github.com/scummvm/scummvm/commit/8b69b3eccdd2782a4506ceea696af86604a70e40
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Compression function names cleanup
Changed paths:
engines/scumm/he/gfx_comp/mrle_comp.cpp
engines/scumm/he/gfx_comp/trle_comp.cpp
engines/scumm/he/wiz_he.cpp
diff --git a/engines/scumm/he/gfx_comp/mrle_comp.cpp b/engines/scumm/he/gfx_comp/mrle_comp.cpp
index 22626083c1c..a3fe800f33f 100644
--- a/engines/scumm/he/gfx_comp/mrle_comp.cpp
+++ b/engines/scumm/he/gfx_comp/mrle_comp.cpp
@@ -28,13 +28,13 @@
namespace Scumm {
-static void MRLEFLIP_HorzFlipAlignWithRect(Common::Rect *rectToAlign, const Common::Rect *baseRect) {
+static void mrleFLIPHorzFlipAlignWithRect(Common::Rect *rectToAlign, const Common::Rect *baseRect) {
int dx = (baseRect->right - rectToAlign->right) - (rectToAlign->left - baseRect->left);
rectToAlign->left += dx;
rectToAlign->right += dx;
}
-static void MRLEFLIP_VertFlipAlignWithRect(Common::Rect *rectToAlign, const Common::Rect *baseRect) {
+static void mrleFLIPVertFlipAlignWithRect(Common::Rect *rectToAlign, const Common::Rect *baseRect) {
int dy = (baseRect->bottom - rectToAlign->bottom) - (rectToAlign->top - baseRect->top);
rectToAlign->top += dy;
rectToAlign->bottom += dy;
@@ -90,7 +90,7 @@ static void MRLEFLIP_VertFlipAlignWithRect(Common::Rect *rectToAlign, const Comm
} \
}
-static void MRLEFLIP_AltSource_F_XBppToXBpp(Wiz *wiz,
+static void mrleFLIPAltSourceForwardXBppToXBpp(Wiz *wiz,
WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream,
int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
const WizRawPixel *srcPtr = (const WizRawPixel *)altSourcePtr;
@@ -131,7 +131,7 @@ static void MRLEFLIP_AltSource_F_XBppToXBpp(Wiz *wiz,
);
}
-static void MRLEFLIP_AltSource_B_XBppToXBpp(Wiz *wiz,
+static void mrleFLIPAltSourceBackwardXBppToXBpp(Wiz *wiz,
WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream,
int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
const WizRawPixel *srcPtr = (const WizRawPixel *)altSourcePtr;
@@ -172,7 +172,7 @@ static void MRLEFLIP_AltSource_B_XBppToXBpp(Wiz *wiz,
);
}
-static void MRLEFLIP_AltSource_F_8BppToXBpp(Wiz *wiz,
+static void mrleFLIPAltSourceForward8BppToXBpp(Wiz *wiz,
WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream,
int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
const byte *srcPtr = (const byte *)altSourcePtr;
@@ -214,7 +214,7 @@ static void MRLEFLIP_AltSource_F_8BppToXBpp(Wiz *wiz,
);
}
-static void MRLEFLIP_AltSource_B_8BppToXBpp(Wiz *wiz,
+static void mrleFLIPAltSourceBackward8BppToXBpp(Wiz *wiz,
WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream,
int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
@@ -266,7 +266,7 @@ static void MRLEFLIP_AltSource_B_8BppToXBpp(Wiz *wiz,
);
}
-static void MRLEFLIP_AltSource_DecompImageHull(Wiz *wiz,
+static void mrleFLIPAltSourceDecompImageHull(Wiz *wiz,
WizRawPixel *bufferPtr, int bufferWidth, const Common::Rect *destRect,
const byte *altSourceBuffer, int altBytesPerLine,
int altBytesPerPixel, const Common::Rect *altRect,
@@ -417,19 +417,19 @@ void Wiz::mrleFLIPAltSourceDecompressPrim(
// Handle the flip coords source adjustment...
if (flags & kWRFHFlip) {
functionPtr = backwardFunctionPtr;
- MRLEFLIP_HorzFlipAlignWithRect(&sourceRect, &inSourceRect);
+ mrleFLIPHorzFlipAlignWithRect(&sourceRect, &inSourceRect);
SWAP<int16>(destRect.left, destRect.right);
} else {
functionPtr = forewordFunctionPtr;
}
if (flags & kWRFVFlip) {
- MRLEFLIP_VertFlipAlignWithRect(&sourceRect, &inSourceRect);
+ mrleFLIPVertFlipAlignWithRect(&sourceRect, &inSourceRect);
SWAP<int16>(destRect.top, destRect.bottom);
}
// Call the primitive image renderer...
- MRLEFLIP_AltSource_DecompImageHull(this,
+ mrleFLIPAltSourceDecompImageHull(this,
destBufferPtr, destBufferWidth, &destRect,
(const byte *)altBufferPtr, ((destBufferWidth * altBitsPerPixel) / 8),
(altBitsPerPixel / 8), &destRect, imagePtr->data, &sourceRect,
@@ -470,15 +470,15 @@ void Wiz::mrleFLIPAltSourceDecompressImage(
destBufferPtr, destBufferWidth, destBufferHeight,
altBufferPtr, altBitsPerPixel, &fakeImage, x, y,
&srcRect, &clipRect, wizFlags, conversionTable,
- MRLEFLIP_AltSource_F_XBppToXBpp,
- MRLEFLIP_AltSource_B_XBppToXBpp);
+ mrleFLIPAltSourceForwardXBppToXBpp,
+ mrleFLIPAltSourceBackwardXBppToXBpp);
} else if (altBitsPerPixel == 8) {
mrleFLIPAltSourceDecompressPrim(
destBufferPtr, destBufferWidth, destBufferHeight,
altBufferPtr, altBitsPerPixel, &fakeImage, x, y,
&srcRect, &clipRect, wizFlags, conversionTable,
- MRLEFLIP_AltSource_F_8BppToXBpp,
- MRLEFLIP_AltSource_B_8BppToXBpp);
+ mrleFLIPAltSourceForward8BppToXBpp,
+ mrleFLIPAltSourceBackward8BppToXBpp);
}
}
diff --git a/engines/scumm/he/gfx_comp/trle_comp.cpp b/engines/scumm/he/gfx_comp/trle_comp.cpp
index f42e6d075dd..2db4f2d0af9 100644
--- a/engines/scumm/he/gfx_comp/trle_comp.cpp
+++ b/engines/scumm/he/gfx_comp/trle_comp.cpp
@@ -737,7 +737,7 @@ static void trleFLIPSubtractiveDecompressLineBackward(Wiz *wiz, WizRawPixel *des
wiz->trleFLIPSubtractiveBackwardsPixelCopy);
}
-static void TRLEFLIP_DecompressLineForeword(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable) {
+static void trleFLIPDecompressLineForeword(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable) {
int runCount;
WizRawPixel8 *dest8 = (WizRawPixel8 *)destPtr;
WizRawPixel16 *dest16 = (WizRawPixel16 *)destPtr;
@@ -1402,7 +1402,7 @@ void Wiz::trleFLIPDecompressImage(
if (!extraTable) {
trleFLIPDecompressPrim(
&fakeBitmap, &fakeImage, x, y, nullptr, clipRectPtr, extraTable, wizFlags, conversionTable,
- TRLEFLIP_DecompressLineForeword, trleFLIPDecompressLineBackward);
+ trleFLIPDecompressLineForeword, trleFLIPDecompressLineBackward);
} else if (wizFlags & kWRFRemap) {
trleFLIPDecompressPrim(
&fakeBitmap, &fakeImage, x, y, nullptr, clipRectPtr, extraTable, wizFlags, conversionTable,
@@ -1503,7 +1503,7 @@ void Wiz::trleFLIPRotate90DecompressImage(
}
}
-static void TRLEFLIP_X2X_BOOL_ALPHA_Memset(Wiz *wiz, WizRawPixel *dstPtr, const WizRawPixel *srcPtr, const WizRawPixel value, int size) {
+static void trleFLIPX2XBoolAlphaMemset(Wiz *wiz, WizRawPixel *dstPtr, const WizRawPixel *srcPtr, const WizRawPixel value, int size) {
// 16-bit only
while (size-- > 0) {
if (*srcPtr++) {
@@ -1514,7 +1514,7 @@ static void TRLEFLIP_X2X_BOOL_ALPHA_Memset(Wiz *wiz, WizRawPixel *dstPtr, const
}
}
-static void TRLEFLIP_X2X_BOOL_INVALPHA_Memset(Wiz *wiz, WizRawPixel *dstPtr, const WizRawPixel *srcPtr, const WizRawPixel value, int size) {
+static void trleFLIPX2XBoolInvAlphaMemset(Wiz *wiz, WizRawPixel *dstPtr, const WizRawPixel *srcPtr, const WizRawPixel value, int size) {
// 16-bit only
while (size-- > 0) {
if (*srcPtr++) {
@@ -1525,7 +1525,7 @@ static void TRLEFLIP_X2X_BOOL_INVALPHA_Memset(Wiz *wiz, WizRawPixel *dstPtr, con
}
}
-static void TRLEFLIP_X2X_BOOL_ALPHA_F_Memcpy(Wiz *wiz, WizRawPixel *dstPtr, const WizRawPixel *srcPtr, const byte *dataPtr,
+static void trleFLIPX2XBoolAlphaForwardMemcpy(Wiz *wiz, WizRawPixel *dstPtr, const WizRawPixel *srcPtr, const byte *dataPtr,
// 16-bit only
int size, const WizRawPixel *conversionTable) {
while (size-- > 0) {
@@ -1539,7 +1539,7 @@ static void TRLEFLIP_X2X_BOOL_ALPHA_F_Memcpy(Wiz *wiz, WizRawPixel *dstPtr, cons
}
}
-static void TRLEFLIP_X2X_BOOL_ALPHA_B_Memcpy(Wiz *wiz, WizRawPixel *dstPtr, const WizRawPixel *srcPtr, const byte *dataPtr, int size, const WizRawPixel *conversionTable) {
+static void trleFLIPX2XBoolAlphaBackwardMemcpy(Wiz *wiz, WizRawPixel *dstPtr, const WizRawPixel *srcPtr, const byte *dataPtr, int size, const WizRawPixel *conversionTable) {
// 16-bit only
while (size-- > 0) {
if ((*srcPtr)) {
@@ -1552,7 +1552,7 @@ static void TRLEFLIP_X2X_BOOL_ALPHA_B_Memcpy(Wiz *wiz, WizRawPixel *dstPtr, cons
}
}
-static void TRLEFLIP_X2X_BOOL_INVALPHA_F_Memcpy(Wiz *wiz, WizRawPixel *dstPtr, const WizRawPixel *srcPtr, const byte *dataPtr, int size, const WizRawPixel *conversionTable) {
+static void trleFLIPX2XBoolInvAlphaForwardMemcpy(Wiz *wiz, WizRawPixel *dstPtr, const WizRawPixel *srcPtr, const byte *dataPtr, int size, const WizRawPixel *conversionTable) {
// 16-bit only
while (size-- > 0) {
if (!(*srcPtr)) {
@@ -1565,7 +1565,7 @@ static void TRLEFLIP_X2X_BOOL_INVALPHA_F_Memcpy(Wiz *wiz, WizRawPixel *dstPtr, c
}
}
-static void TRLEFLIP_X2X_BOOL_INVALPHA_B_Memcpy(Wiz *wiz, WizRawPixel *dstPtr, const WizRawPixel *srcPtr, const byte *dataPtr, int size, const WizRawPixel *conversionTable) {
+static void trleFLIPX2XBoolInvAlphaBackwardMemcpy(Wiz *wiz, WizRawPixel *dstPtr, const WizRawPixel *srcPtr, const byte *dataPtr, int size, const WizRawPixel *conversionTable) {
// 16-bit only
while (size-- > 0) {
if (!(*srcPtr)) {
@@ -1578,35 +1578,35 @@ static void TRLEFLIP_X2X_BOOL_INVALPHA_B_Memcpy(Wiz *wiz, WizRawPixel *dstPtr, c
}
}
-static void TRLEFLIP_AltSource_F_BOOL_ALPHA_X2X(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
+static void trleFLIPAltSourceForwardBoolAlphaX2X(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
// 16-bit only
TRLEFLIP_ALTX_Foreward_MACRO(
- TRLEFLIP_X2X_BOOL_ALPHA_Memset,
- TRLEFLIP_X2X_BOOL_ALPHA_F_Memcpy);
+ trleFLIPX2XBoolAlphaMemset,
+ trleFLIPX2XBoolAlphaForwardMemcpy);
}
-static void TRLEFLIP_AltSource_B_BOOL_ALPHA_X2X(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
+static void trleFLIPAltSourceBackwardBoolAlphaX2X(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
// 16-bit only
TRLEFLIP_ALTX_Backward_MACRO(
- TRLEFLIP_X2X_BOOL_ALPHA_Memset,
- TRLEFLIP_X2X_BOOL_ALPHA_B_Memcpy);
+ trleFLIPX2XBoolAlphaMemset,
+ trleFLIPX2XBoolAlphaBackwardMemcpy);
}
-static void TRLEFLIP_AltSource_F_BOOL_INVALPHA_X2X(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
+static void trleFLIPAltSourceForwardBoolInvAlphaX2X(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
// 16-bit only
TRLEFLIP_ALTX_Foreward_MACRO(
- TRLEFLIP_X2X_BOOL_INVALPHA_Memset,
- TRLEFLIP_X2X_BOOL_INVALPHA_F_Memcpy);
+ trleFLIPX2XBoolInvAlphaMemset,
+ trleFLIPX2XBoolInvAlphaForwardMemcpy);
}
-static void TRLEFLIP_AltSource_B_BOOL_INVALPHA_X2X(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
+static void trleFLIPAltSourceBackwardBoolInvAlphaX2X(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
// 16-bit only
TRLEFLIP_ALTX_Backward_MACRO(
- TRLEFLIP_X2X_BOOL_INVALPHA_Memset,
- TRLEFLIP_X2X_BOOL_INVALPHA_B_Memcpy);
+ trleFLIPX2XBoolInvAlphaMemset,
+ trleFLIPX2XBoolInvAlphaBackwardMemcpy);
}
-static void TRLEFLIP_X2X_ALPHA_Memset(Wiz *wiz, WizRawPixel *dstPtr, const WizRawPixel *srcPtr, const WizRawPixel value, int size) {
+static void trleFLIPX2XAlphaMemset(Wiz *wiz, WizRawPixel *dstPtr, const WizRawPixel *srcPtr, const WizRawPixel value, int size) {
// 16-bit only
while (size-- > 0) {
int alpha = ((*srcPtr++) & 255);
@@ -1619,7 +1619,7 @@ static void TRLEFLIP_X2X_ALPHA_Memset(Wiz *wiz, WizRawPixel *dstPtr, const WizRa
}
}
-static void TRLEFLIP_X2X_INVALPHA_Memset(Wiz *wiz, WizRawPixel *dstPtr, const WizRawPixel *srcPtr, const WizRawPixel value, int size) {
+static void trleFLIPX2XInvAlphaMemset(Wiz *wiz, WizRawPixel *dstPtr, const WizRawPixel *srcPtr, const WizRawPixel value, int size) {
// 16-bit only
while (size-- > 0) {
int alpha = (255 - ((*srcPtr++) & 255));
@@ -1632,7 +1632,7 @@ static void TRLEFLIP_X2X_INVALPHA_Memset(Wiz *wiz, WizRawPixel *dstPtr, const Wi
}
}
-static void TRLEFLIP_X2X_ALPHA_F_Memcpy(Wiz *wiz, WizRawPixel *dstPtr, const WizRawPixel *srcPtr, const byte *dataPtr, int size, const WizRawPixel *conversionTable) {
+static void trleFLIPX2XAlphaForwardMemcpy(Wiz *wiz, WizRawPixel *dstPtr, const WizRawPixel *srcPtr, const byte *dataPtr, int size, const WizRawPixel *conversionTable) {
// 16-bit only
while (size-- > 0) {
int alpha = ((*srcPtr++) & 255);
@@ -1646,7 +1646,7 @@ static void TRLEFLIP_X2X_ALPHA_F_Memcpy(Wiz *wiz, WizRawPixel *dstPtr, const Wiz
}
}
-static void TRLEFLIP_X2X_ALPHA_B_Memcpy(Wiz *wiz, WizRawPixel *dstPtr, const WizRawPixel *srcPtr, const byte *dataPtr, int size, const WizRawPixel *conversionTable) {
+static void trleFLIPX2XAlphaBackwardMemcpy(Wiz *wiz, WizRawPixel *dstPtr, const WizRawPixel *srcPtr, const byte *dataPtr, int size, const WizRawPixel *conversionTable) {
// 16-bit only
while (size-- > 0) {
int alpha = ((*srcPtr--) & 255);
@@ -1660,7 +1660,7 @@ static void TRLEFLIP_X2X_ALPHA_B_Memcpy(Wiz *wiz, WizRawPixel *dstPtr, const Wiz
}
}
-static void TRLEFLIP_X2X_INVALPHA_F_Memcpy(Wiz *wiz, WizRawPixel *dstPtr, const WizRawPixel *srcPtr, const byte *dataPtr, int size, const WizRawPixel *conversionTable) {
+static void trleFLIPX2XInvAlphaForwardMemcpy(Wiz *wiz, WizRawPixel *dstPtr, const WizRawPixel *srcPtr, const byte *dataPtr, int size, const WizRawPixel *conversionTable) {
// 16-bit only
while (size-- > 0) {
int alpha = (255 - ((*srcPtr++) & 255));
@@ -1674,7 +1674,7 @@ static void TRLEFLIP_X2X_INVALPHA_F_Memcpy(Wiz *wiz, WizRawPixel *dstPtr, const
}
}
-static void TRLEFLIP_X2X_INVALPHA_B_Memcpy(Wiz *wiz, WizRawPixel *dstPtr, const WizRawPixel *srcPtr, const byte *dataPtr, int size, const WizRawPixel *conversionTable) {
+static void trleFLIPX2XInvAlphaBackwardMemcpy(Wiz *wiz, WizRawPixel *dstPtr, const WizRawPixel *srcPtr, const byte *dataPtr, int size, const WizRawPixel *conversionTable) {
// 16-bit only
while (size-- > 0) {
int alpha = (255 - ((*srcPtr--) & 255));
@@ -1689,35 +1689,35 @@ static void TRLEFLIP_X2X_INVALPHA_B_Memcpy(Wiz *wiz, WizRawPixel *dstPtr, const
}
}
-static void TRLEFLIP_AltSource_F_ALPHA_X2X(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
+static void trleFLIPAltSourceForwardAlphaX2X(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
// 16-bit only
TRLEFLIP_ALTX_Foreward_MACRO(
- TRLEFLIP_X2X_ALPHA_Memset,
- TRLEFLIP_X2X_ALPHA_F_Memcpy);
+ trleFLIPX2XAlphaMemset,
+ trleFLIPX2XAlphaForwardMemcpy);
}
-static void TRLEFLIP_AltSource_B_ALPHA_X2X(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
+static void trleFLIPAltSourceBackwardAlphaX2X(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
// 16-bit only
TRLEFLIP_ALTX_Backward_MACRO(
- TRLEFLIP_X2X_ALPHA_Memset,
- TRLEFLIP_X2X_ALPHA_B_Memcpy);
+ trleFLIPX2XAlphaMemset,
+ trleFLIPX2XAlphaBackwardMemcpy);
}
-static void TRLEFLIP_AltSource_F_INVALPHA_X2X(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
+static void trleFLIPAltSourceForwardInvAlphaX2X(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
// 16-bit only
TRLEFLIP_ALTX_Foreward_MACRO(
- TRLEFLIP_X2X_INVALPHA_Memset,
- TRLEFLIP_X2X_INVALPHA_F_Memcpy);
+ trleFLIPX2XInvAlphaMemset,
+ trleFLIPX2XInvAlphaForwardMemcpy);
}
-static void TRLEFLIP_AltSource_B_INVALPHA_X2X(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
+static void trleFLIPAltSourceBackwardInvAlphaX2X(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
// 16-bit only
TRLEFLIP_ALTX_Backward_MACRO(
- TRLEFLIP_X2X_INVALPHA_Memset,
- TRLEFLIP_X2X_INVALPHA_B_Memcpy);
+ trleFLIPX2XInvAlphaMemset,
+ trleFLIPX2XInvAlphaBackwardMemcpy);
}
-static void TRLEFLIP_ATRLE_ALPHA_Memset(Wiz *wiz, WizRawPixel *dstPtr, const WizRawPixel *srcPtr, const WizRawPixel value, int size) {
+static void trleFLIPATRLEAlphaMemset(Wiz *wiz, WizRawPixel *dstPtr, const WizRawPixel *srcPtr, const WizRawPixel value, int size) {
// 16-bit only
int alpha = (value & 255);
@@ -1731,7 +1731,7 @@ static void TRLEFLIP_ATRLE_ALPHA_Memset(Wiz *wiz, WizRawPixel *dstPtr, const Wiz
}
}
-static void TRLEFLIP_ATRLE_INVALPHA_Memset(Wiz *wiz, WizRawPixel *dstPtr, const WizRawPixel *srcPtr, const WizRawPixel value, int size) {
+static void trleFLIPATRLEInvAlphaMemset(Wiz *wiz, WizRawPixel *dstPtr, const WizRawPixel *srcPtr, const WizRawPixel value, int size) {
// 16-bit only
int alpha = (255 - (value & 255));
@@ -1745,7 +1745,7 @@ static void TRLEFLIP_ATRLE_INVALPHA_Memset(Wiz *wiz, WizRawPixel *dstPtr, const
}
}
-static void TRLEFLIP_ATRLE_ALPHA_F_Memcpy(Wiz *wiz, WizRawPixel *dstPtr, const WizRawPixel *srcPtr, const byte *dataPtr, int size, const WizRawPixel *conversionTable) {
+static void trleFLIPATRLEAlphaForwardMemcpy(Wiz *wiz, WizRawPixel *dstPtr, const WizRawPixel *srcPtr, const byte *dataPtr, int size, const WizRawPixel *conversionTable) {
// 16-bit only
while (size-- > 0) {
int alpha = ((wiz->convert8BppToRawPixel(*dataPtr++, conversionTable)) & 255);
@@ -1760,7 +1760,7 @@ static void TRLEFLIP_ATRLE_ALPHA_F_Memcpy(Wiz *wiz, WizRawPixel *dstPtr, const W
}
}
-static void TRLEFLIP_ATRLE_ALPHA_B_Memcpy(Wiz *wiz, WizRawPixel *dstPtr, const WizRawPixel *srcPtr, const byte *dataPtr, int size, const WizRawPixel *conversionTable) {
+static void trleFLIPATRLEAlphaBackwardMemcpy(Wiz *wiz, WizRawPixel *dstPtr, const WizRawPixel *srcPtr, const byte *dataPtr, int size, const WizRawPixel *conversionTable) {
// 16-bit only
while (size-- > 0) {
int alpha = ((wiz->convert8BppToRawPixel(*dataPtr++, conversionTable)) & 255);
@@ -1775,7 +1775,7 @@ static void TRLEFLIP_ATRLE_ALPHA_B_Memcpy(Wiz *wiz, WizRawPixel *dstPtr, const W
}
}
-static void TRLEFLIP_ATRLE_INVALPHA_F_Memcpy(Wiz *wiz, WizRawPixel *dstPtr, const WizRawPixel *srcPtr, const byte *dataPtr, int size, const WizRawPixel *conversionTable) {
+static void trleFLIPATRLEInvAlphaForwardMemcpy(Wiz *wiz, WizRawPixel *dstPtr, const WizRawPixel *srcPtr, const byte *dataPtr, int size, const WizRawPixel *conversionTable) {
// 16-bit only
while (size-- > 0) {
int alpha = (255 - ((wiz->convert8BppToRawPixel(*dataPtr++, conversionTable)) & 255));
@@ -1790,7 +1790,7 @@ static void TRLEFLIP_ATRLE_INVALPHA_F_Memcpy(Wiz *wiz, WizRawPixel *dstPtr, cons
}
}
-static void TRLEFLIP_ATRLE_INVALPHA_B_Memcpy(Wiz *wiz, WizRawPixel *dstPtr, const WizRawPixel *srcPtr, const byte *dataPtr, int size, const WizRawPixel *conversionTable) {
+static void trleFLIPATRLEInvAlphaBackwardMemcpy(Wiz *wiz, WizRawPixel *dstPtr, const WizRawPixel *srcPtr, const byte *dataPtr, int size, const WizRawPixel *conversionTable) {
// 16-bit only
while (size-- > 0) {
int alpha = (255 - ((wiz->convert8BppToRawPixel(*dataPtr++, conversionTable)) & 255));
@@ -1805,35 +1805,35 @@ static void TRLEFLIP_ATRLE_INVALPHA_B_Memcpy(Wiz *wiz, WizRawPixel *dstPtr, cons
}
}
-static void TRLEFLIP_AltSource_F_ALPHA_ATRLE(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
+static void trleFLIPAltSourceForwardAlphaATRLE(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
// 16-bit only
TRLEFLIP_ALTX_Foreward_MACRO(
- TRLEFLIP_ATRLE_ALPHA_Memset,
- TRLEFLIP_ATRLE_ALPHA_F_Memcpy);
+ trleFLIPATRLEAlphaMemset,
+ trleFLIPATRLEAlphaForwardMemcpy);
}
-static void TRLEFLIP_AltSource_B_ALPHA_ATRLE(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
+static void trleFLIPAltSourceBackwardAlphaATRLE(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
// 16-bit only
TRLEFLIP_ALTX_Backward_MACRO(
- TRLEFLIP_ATRLE_ALPHA_Memset,
- TRLEFLIP_ATRLE_ALPHA_B_Memcpy);
+ trleFLIPATRLEAlphaMemset,
+ trleFLIPATRLEAlphaBackwardMemcpy);
}
-static void TRLEFLIP_AltSource_F_INVALPHA_ATRLE(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
+static void trleFLIPAltSourceForwardInvAlphaATRLE(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
// 16-bit only
TRLEFLIP_ALTX_Foreward_MACRO(
- TRLEFLIP_ATRLE_INVALPHA_Memset,
- TRLEFLIP_ATRLE_INVALPHA_F_Memcpy);
+ trleFLIPATRLEInvAlphaMemset,
+ trleFLIPATRLEInvAlphaForwardMemcpy);
}
-static void TRLEFLIP_AltSource_B_INVALPHA_ATRLE(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
+static void trleFLIPAltSourceBackwardInvAlphaATRLE(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
// 16-bit only
TRLEFLIP_ALTX_Backward_MACRO(
- TRLEFLIP_ATRLE_INVALPHA_Memset,
- TRLEFLIP_ATRLE_INVALPHA_B_Memcpy);
+ trleFLIPATRLEInvAlphaMemset,
+ trleFLIPATRLEInvAlphaBackwardMemcpy);
}
-static void TRLEFLIP_AltSource_F_XBppToXBpp(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
+static void trleFLIPAltSourceForwardXBppToXBpp(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
const WizRawPixel *srcPtr;
int runCount;
@@ -1860,7 +1860,7 @@ static void TRLEFLIP_AltSource_F_XBppToXBpp(Wiz *wiz, WizRawPixel *destPtr, cons
});
}
-static void TRLEFLIP_AltSource_B_XBppToXBpp(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
+static void trleFLIPAltSourceBackwardXBppToXBpp(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
const WizRawPixel *srcPtr;
int runCount;
@@ -1887,7 +1887,7 @@ static void TRLEFLIP_AltSource_B_XBppToXBpp(Wiz *wiz, WizRawPixel *destPtr, cons
});
}
-static void TRLEFLIP_AltSource_F_8BppToXBpp(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
+static void trleFLIPAltSourceForward8BppToXBpp(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
const byte *srcPtr;
int runCount;
@@ -1914,7 +1914,7 @@ static void TRLEFLIP_AltSource_F_8BppToXBpp(Wiz *wiz, WizRawPixel *destPtr, cons
});
}
-static void TRLEFLIP_AltSource_B_8BppToXBpp(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
+static void trleFLIPAltSourceBackward8BppToXBpp(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
const WizRawPixel *srcPtr;
int runCount;
@@ -1941,7 +1941,7 @@ static void TRLEFLIP_AltSource_B_8BppToXBpp(Wiz *wiz, WizRawPixel *destPtr, cons
});
}
-static void TRLEFLIP_AltSource_INV_F_XBppToXBpp(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
+static void trleFLIPAltSourceInvForwardXBppToXBpp(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
const WizRawPixel *srcPtr;
int runCount;
@@ -1967,7 +1967,7 @@ static void TRLEFLIP_AltSource_INV_F_XBppToXBpp(Wiz *wiz, WizRawPixel *destPtr,
});
}
-static void TRLEFLIP_AltSource_INV_B_XBppToXBpp(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
+static void trleFLIPAltSourceInvBackwardXBppToXBpp(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
const WizRawPixel *srcPtr;
int runCount;
@@ -2201,8 +2201,8 @@ bool Wiz::trleFLIPAltSourceSpecialCaseDispatch(
destBufferPtr, destBufferWidth, destBufferHeight,
altBufferPtr, altBitsPerPixel, &fakeImage, x, y,
&srcRect, &clipRect, wizFlags, conversionTable,
- TRLEFLIP_AltSource_INV_F_XBppToXBpp,
- TRLEFLIP_AltSource_INV_B_XBppToXBpp);
+ trleFLIPAltSourceInvForwardXBppToXBpp,
+ trleFLIPAltSourceInvBackwardXBppToXBpp);
return true;
} else {
@@ -2211,8 +2211,8 @@ bool Wiz::trleFLIPAltSourceSpecialCaseDispatch(
destBufferPtr, destBufferWidth, destBufferHeight,
altBufferPtr, altBitsPerPixel, &fakeImage, x, y,
&srcRect, &clipRect, wizFlags, conversionTable,
- TRLEFLIP_AltSource_F_XBppToXBpp,
- TRLEFLIP_AltSource_B_XBppToXBpp);
+ trleFLIPAltSourceForwardXBppToXBpp,
+ trleFLIPAltSourceBackwardXBppToXBpp);
return true;
}
@@ -2223,8 +2223,8 @@ bool Wiz::trleFLIPAltSourceSpecialCaseDispatch(
destBufferPtr, destBufferWidth, destBufferHeight,
altBufferPtr, altBitsPerPixel, &fakeImage, x, y,
&srcRect, &clipRect, wizFlags, conversionTable,
- TRLEFLIP_AltSource_F_INVALPHA_ATRLE,
- TRLEFLIP_AltSource_B_INVALPHA_ATRLE);
+ trleFLIPAltSourceForwardInvAlphaATRLE,
+ trleFLIPAltSourceBackwardInvAlphaATRLE);
return true;
} else {
@@ -2233,8 +2233,8 @@ bool Wiz::trleFLIPAltSourceSpecialCaseDispatch(
destBufferPtr, destBufferWidth, destBufferHeight,
altBufferPtr, altBitsPerPixel, &fakeImage, x, y,
&srcRect, &clipRect, wizFlags, conversionTable,
- TRLEFLIP_AltSource_F_ALPHA_ATRLE,
- TRLEFLIP_AltSource_B_ALPHA_ATRLE);
+ trleFLIPAltSourceForwardAlphaATRLE,
+ trleFLIPAltSourceBackwardAlphaATRLE);
return true;
}
@@ -2247,8 +2247,8 @@ bool Wiz::trleFLIPAltSourceSpecialCaseDispatch(
destBufferPtr, destBufferWidth, destBufferHeight,
altBufferPtr, altBitsPerPixel, &fakeImage, x, y,
&srcRect, &clipRect, wizFlags, conversionTable,
- TRLEFLIP_AltSource_F_BOOL_INVALPHA_X2X,
- TRLEFLIP_AltSource_B_BOOL_INVALPHA_X2X);
+ trleFLIPAltSourceForwardBoolInvAlphaX2X,
+ trleFLIPAltSourceBackwardBoolInvAlphaX2X);
return true;
} else {
@@ -2257,8 +2257,8 @@ bool Wiz::trleFLIPAltSourceSpecialCaseDispatch(
destBufferPtr, destBufferWidth, destBufferHeight,
altBufferPtr, altBitsPerPixel, &fakeImage, x, y,
&srcRect, &clipRect, wizFlags, conversionTable,
- TRLEFLIP_AltSource_F_BOOL_ALPHA_X2X,
- TRLEFLIP_AltSource_B_BOOL_ALPHA_X2X);
+ trleFLIPAltSourceForwardBoolAlphaX2X,
+ trleFLIPAltSourceBackwardBoolAlphaX2X);
return true;
}
@@ -2269,8 +2269,8 @@ bool Wiz::trleFLIPAltSourceSpecialCaseDispatch(
destBufferPtr, destBufferWidth, destBufferHeight,
altBufferPtr, altBitsPerPixel, &fakeImage, x, y,
&srcRect, &clipRect, wizFlags, conversionTable,
- TRLEFLIP_AltSource_F_INVALPHA_X2X,
- TRLEFLIP_AltSource_B_INVALPHA_X2X);
+ trleFLIPAltSourceForwardInvAlphaX2X,
+ trleFLIPAltSourceBackwardInvAlphaX2X);
return true;
} else {
@@ -2279,8 +2279,8 @@ bool Wiz::trleFLIPAltSourceSpecialCaseDispatch(
destBufferPtr, destBufferWidth, destBufferHeight,
altBufferPtr, altBitsPerPixel, &fakeImage, x, y,
&srcRect, &clipRect, wizFlags, conversionTable,
- TRLEFLIP_AltSource_F_ALPHA_X2X,
- TRLEFLIP_AltSource_B_ALPHA_X2X);
+ trleFLIPAltSourceForwardAlphaX2X,
+ trleFLIPAltSourceBackwardAlphaX2X);
return true;
}
@@ -2344,8 +2344,8 @@ void Wiz::trleFLIPAltSourceDecompressImage(
destBufferPtr, destBufferWidth, destBufferHeight,
altBufferPtr, altBitsPerPixel, &fakeImage, x, y,
&srcRect, &clipRect, wizFlags, conversionTable,
- TRLEFLIP_AltSource_F_XBppToXBpp,
- TRLEFLIP_AltSource_B_XBppToXBpp);
+ trleFLIPAltSourceForwardXBppToXBpp,
+ trleFLIPAltSourceBackwardXBppToXBpp);
} else if (altBitsPerPixel == 8) {
if (!_uses16BitColor)
error("Wiz::trleFLIPAltSourceDecompressImage(): Yeah, it's used, fix it! 2");
@@ -2353,14 +2353,12 @@ void Wiz::trleFLIPAltSourceDecompressImage(
destBufferPtr, destBufferWidth, destBufferHeight,
altBufferPtr, altBitsPerPixel, &fakeImage, x, y,
&srcRect, &clipRect, wizFlags, conversionTable,
- TRLEFLIP_AltSource_F_8BppToXBpp,
- TRLEFLIP_AltSource_B_8BppToXBpp);
+ trleFLIPAltSourceForward8BppToXBpp,
+ trleFLIPAltSourceBackward8BppToXBpp);
}
}
-int Wiz::trleCompressImageArea(
- byte *destBuffer, const WizRawPixel *sourceBuffer, int sourceBufferWidth,
- int x1, int y1, int x2, int y2, WizRawPixel transparentColor) {
+int Wiz::trleCompressImageArea(byte *destBuffer, const WizRawPixel *sourceBuffer, int sourceBufferWidth, int x1, int y1, int x2, int y2, WizRawPixel transparentColor) {
int width, height, totalSize, lineSize;
byte *sizeWordPtr = nullptr;
@@ -2413,24 +2411,24 @@ int Wiz::trleCompressImageArea(
}
byte *Wiz::trlePutDump(byte *dest, int nn) {
- int i, count, index;
+ int count, index;
byte value;
index = 0;
do {
-
count = nn;
if (count > 64) {
count = 64;
}
+
nn -= count;
value = count - 1;
value <<= 2;
trle_putbyte(value);
- for (i = 0; i < count; i++) {
+ for (int i = 0; i < count; i++) {
trle_putbyte(_trleBuf[index++]);
}
@@ -2444,38 +2442,35 @@ byte *Wiz::trlePutRun(byte *dest, int nn, int cc, int tColor) {
int count;
if (cc == tColor) {
-
do {
-
count = nn;
if (count > 127) {
count = 127;
}
+
nn -= count;
value = count;
value <<= 1;
value |= 1;
- trle_putbyte(value);
+ trle_putbyte(value);
} while (nn > 0);
-
} else {
-
do {
-
count = nn;
if (count > 64) {
count = 64;
}
+
nn -= count;
value = count - 1;
value <<= 2;
value |= 2;
+
trle_putbyte(value);
trle_putbyte(cc);
-
} while (nn > 0);
}
@@ -2491,7 +2486,6 @@ int Wiz::trleRLECompression(byte *pdest, const WizRawPixel *psource, int rowsize
int rstart = 0;
int counter;
- const WizRawPixel *source = psource;
const WizRawPixel8 *source8 = (WizRawPixel8 *)psource;
const WizRawPixel16 *source16 = (WizRawPixel16 *)psource;
@@ -2518,11 +2512,9 @@ int Wiz::trleRLECompression(byte *pdest, const WizRawPixel *psource, int rowsize
if (_uses16BitColor) {
_trleBuf[0] = lastc = c = (*source16++);
_trleBuf[0] = (byte)c;
- source = (WizRawPixel *)source16;
} else {
_trleBuf[0] = lastc = c = (*source8++);
_trleBuf[0] = (byte)c;
- source = (WizRawPixel *)source8;
}
nbuf = 1;
@@ -2533,11 +2525,9 @@ int Wiz::trleRLECompression(byte *pdest, const WizRawPixel *psource, int rowsize
if (_uses16BitColor) {
c = (*source16++);
_trleBuf[nbuf++] = (byte)c;
- source = (WizRawPixel *)source16;
} else {
c = (*source8++);
_trleBuf[nbuf++] = (byte)c;
- source = (WizRawPixel *)source8;
}
switch (mode) {
diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp
index 5a4f5cc2b70..ce71a21d804 100644
--- a/engines/scumm/he/wiz_he.cpp
+++ b/engines/scumm/he/wiz_he.cpp
@@ -508,7 +508,7 @@ void Wiz::buildAWiz(const WizRawPixel *bufPtr, int bufWidth, int bufHeight, cons
nullptr, bufPtr, bufWidth, compRect.left, compRect.top, compRect.right, compRect.bottom,
(WizRawPixel)transparentColor);
} else if (isUncompressedFormatTypeID(compressionType)) {
- dataSize = ((getRectWidth(&compRect) * getRectHeight(&compRect)) * sizeof(WizRawPixel));
+ dataSize = ((getRectWidth(&compRect) * getRectHeight(&compRect)) * sizeof(WizRawPixel));
} else {
error("Wiz::buildAWiz(): Unknown compression type %d", compressionType);
}
Commit: 6bb2a93a0ef74a83ef500e20719c42e1596e1099
https://github.com/scummvm/scummvm/commit/6bb2a93a0ef74a83ef500e20719c42e1596e1099
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Fix WARPWIZ issue
Changed paths:
engines/scumm/he/wizwarp_he.cpp
diff --git a/engines/scumm/he/wizwarp_he.cpp b/engines/scumm/he/wizwarp_he.cpp
index 53a410d478f..7916287ebd2 100644
--- a/engines/scumm/he/wizwarp_he.cpp
+++ b/engines/scumm/he/wizwarp_he.cpp
@@ -151,8 +151,8 @@ bool Wiz::warpDrawWizTo4Points(int image, int state, const WarpWizPoint *dstPoin
y = dstPoints[i].y;
updateRect.left = MIN<int16>(updateRect.left, x);
updateRect.top = MIN<int16>(updateRect.top, y);
- updateRect.right = MIN<int16>(updateRect.right, x);
- updateRect.bottom = MIN<int16>(updateRect.bottom, y);
+ updateRect.right = MAX<int16>(updateRect.right, x);
+ updateRect.bottom = MAX<int16>(updateRect.bottom, y);
}
updateRect.left = MAX<int16>(0, MIN<int16>((dstBitmap.bitmapWidth - 1), updateRect.left));
Commit: 9f460f6cf50aad9f4909ca3c811d0726f577d5b1
https://github.com/scummvm/scummvm/commit/9f460f6cf50aad9f4909ca3c811d0726f577d5b1
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: More cleanup and changes
Changed paths:
engines/scumm/he/gfx_comp/trle_comp.cpp
engines/scumm/he/gfx_primitives_he.cpp
engines/scumm/he/script_v90he.cpp
engines/scumm/he/wiz_he.cpp
engines/scumm/he/wiz_he.h
diff --git a/engines/scumm/he/gfx_comp/trle_comp.cpp b/engines/scumm/he/gfx_comp/trle_comp.cpp
index 2db4f2d0af9..e684afd6bab 100644
--- a/engines/scumm/he/gfx_comp/trle_comp.cpp
+++ b/engines/scumm/he/gfx_comp/trle_comp.cpp
@@ -203,11 +203,8 @@ namespace Scumm {
if (dest) { \
*dest++ = (c); \
} \
- ++_trlePutsize; \
+ ++_trlePutSize; \
}
-#define trle_outdump(nn) dest = trlePutDump(dest, nn)
-#define trle_outrun(nn, cc) dest = trlePutRun(dest, nn, cc, tcolor)
-
void Wiz::trleFLIPCheckAlphaSetup() {
if (_initializeAlphaTable && _uses16BitColor) {
@@ -2507,7 +2504,7 @@ int Wiz::trleRLECompression(byte *pdest, const WizRawPixel *psource, int rowsize
}
dest = pdest;
- _trlePutsize = 0;
+ _trlePutSize = 0;
if (_uses16BitColor) {
_trleBuf[0] = lastc = c = (*source16++);
@@ -2534,7 +2531,7 @@ int Wiz::trleRLECompression(byte *pdest, const WizRawPixel *psource, int rowsize
case TRLE_DUMP:
// Don't allow transparent colors in a literal run!
if (c == tcolor) {
- trle_outdump(nbuf - 1);
+ dest = trlePutDump(dest, nbuf - 1);
_trleBuf[0] = c;
nbuf = 1;
rstart = 0;
@@ -2544,7 +2541,7 @@ int Wiz::trleRLECompression(byte *pdest, const WizRawPixel *psource, int rowsize
// check to see if too literal run too big if so dump it
if (nbuf > TRLE_MAXDAT) {
- trle_outdump(nbuf - 1);
+ dest = trlePutDump(dest, nbuf - 1);
_trleBuf[0] = c;
nbuf = 1;
rstart = 0;
@@ -2555,7 +2552,7 @@ int Wiz::trleRLECompression(byte *pdest, const WizRawPixel *psource, int rowsize
if (c == lastc) {
if (nbuf - rstart >= TRLE_MINRUN) {
if (rstart > 0) {
- trle_outdump(rstart);
+ dest = trlePutDump(dest, rstart);
}
mode = TRLE_RUN;
} else {
@@ -2563,6 +2560,8 @@ int Wiz::trleRLECompression(byte *pdest, const WizRawPixel *psource, int rowsize
mode = TRLE_RUN;
}
}
+
+ // Note, in this case we HAVE to fall through!
} else {
rstart = nbuf - 1;
break;
@@ -2571,7 +2570,7 @@ int Wiz::trleRLECompression(byte *pdest, const WizRawPixel *psource, int rowsize
case TRLE_RUN:
// Check run to see if still going...
if ((c != lastc) || (nbuf - rstart > TRLE_MAXRUN)) {
- trle_outrun(nbuf - 1 - rstart, lastc);
+ dest = trlePutRun(dest, nbuf - 1 - rstart, lastc, tcolor);
_trleBuf[0] = c;
nbuf = 1;
rstart = 0;
@@ -2586,14 +2585,14 @@ int Wiz::trleRLECompression(byte *pdest, const WizRawPixel *psource, int rowsize
switch (mode) {
case TRLE_DUMP:
- trle_outdump(nbuf);
+ dest = trlePutDump(dest, nbuf);
break;
case TRLE_RUN:
- trle_outrun(nbuf - rstart, lastc);
+ dest = trlePutRun(dest, nbuf - rstart, lastc, tcolor);
break;
}
- return _trlePutsize;
+ return _trlePutSize;
}
} // End of namespace Scumm
diff --git a/engines/scumm/he/gfx_primitives_he.cpp b/engines/scumm/he/gfx_primitives_he.cpp
index 28151d720ef..4266c0bd0e7 100644
--- a/engines/scumm/he/gfx_primitives_he.cpp
+++ b/engines/scumm/he/gfx_primitives_he.cpp
@@ -1385,7 +1385,7 @@ void Wiz::pgForewordMixColorsPixelCopy(WizRawPixel *dstPtr, const WizRawPixel *s
const WizRawPixel16 *src16 = (const WizRawPixel16 *)srcPtr;
while (size-- > 0) {
- if (_vm->_game.heversion > 99) {
+ if (_vm->_game.heversion >= 99) {
WizRawPixel16 srcColor = *src16++;
WizRawPixel16 dstColor = *dst16;
@@ -1412,7 +1412,7 @@ void Wiz::pgBackwardsMixColorsPixelCopy(WizRawPixel *dstPtr, const WizRawPixel *
const WizRawPixel16 *src16 = (const WizRawPixel16 *)srcPtr;
while (size-- > 0) {
- if (_vm->_game.heversion > 99) {
+ if (_vm->_game.heversion >= 99) {
WizRawPixel16 srcColor = *src16++;
WizRawPixel16 dstColor = *dst16;
diff --git a/engines/scumm/he/script_v90he.cpp b/engines/scumm/he/script_v90he.cpp
index 387e18aac66..f758f6d9c62 100644
--- a/engines/scumm/he/script_v90he.cpp
+++ b/engines/scumm/he/script_v90he.cpp
@@ -1321,11 +1321,15 @@ void ScummEngine_v90he::o90_getWizData() {
break;
}
case SO_NEW_GENERAL_PROPERTY: // 139
- // TODO: Recheck, this looks different at least in HE99...
- type = pop();
+ if (_game.heversion > 99 || (_game.heversion == 99 && _wiz->_uses16BitColor)) {
+ type = pop();
+ } else {
+ type = 0;
+ }
+
state = pop();
resId = pop();
- push(_wiz->getWizImageData(resId, state, type));
+ push(_wiz->dwGetImageGeneralProperty(resId, state, type));
break;
case SO_FONT_START: // 141
// TODO: Implement...
@@ -1353,7 +1357,7 @@ void ScummEngine_v90he::o90_getWizData() {
push(0);
}
- debug(0, "o90_getWizData() case 111 unhandled");
+ debug(0, "o90_getWizData() case SO_FONT_START unhandled");
break;
default:
error("o90_getWizData: Unknown case %d", subOp);
diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp
index ce71a21d804..cffaaff33c4 100644
--- a/engines/scumm/he/wiz_he.cpp
+++ b/engines/scumm/he/wiz_he.cpp
@@ -765,8 +765,8 @@ int Wiz::hitTestWizPrim(int globNum, int state, int x, int y, int32 flags) {
void Wiz::processWizImagePolyCaptureCmd(const WizImageCommand *params) {
int polygon1, polygon2, compressionType, srcImage = 0, shadow = 0, state = 0;
- bool bIsHintColor = false;
- int iHintColor = 0;
+ bool isHintColor = false;
+ int hintColor = 0;
// Get all the options...
if (params->actionFlags & kWAFPolygon) {
@@ -809,40 +809,40 @@ void Wiz::processWizImagePolyCaptureCmd(const WizImageCommand *params) {
debug(7, "ProcessWizImagePolyCaptureCmd: color hint does nothing for an unfiltered scale.");
}
- bIsHintColor = true;
- iHintColor = params->propertyValue;
+ isHintColor = true;
+ hintColor = params->propertyValue;
}
}
// validate the parameters
- bool bPoly1Found = false;
- bool bPoly2Found = false;
+ bool poly1Found = false;
+ bool poly2Found = false;
for (int polyIndex = 0; polyIndex < ARRAYSIZE(_polygons); ++polyIndex) {
if (polygon1 == _polygons[polyIndex].id) {
- bPoly1Found = true;
+ poly1Found = true;
polygon1 = polyIndex;
if (_polygons[polyIndex].numPoints != 5)
error("Invalid point count");
}
if (polygon2 == _polygons[polyIndex].id) {
- bPoly2Found = true;
+ poly2Found = true;
polygon2 = polyIndex;
if (_polygons[polyIndex].numPoints != 5)
error("Invalid point count");
}
- if (bPoly1Found && bPoly2Found) {
+ if (poly1Found && poly2Found) {
break;
}
}
- if (!bPoly1Found) {
+ if (!poly1Found) {
error("Image capture poly: Polygon %d not defined", polygon1);
}
- if (!bPoly2Found) {
+ if (!poly2Found) {
error("Image capture poly: Polygon %d not defined", polygon2);
}
@@ -870,7 +870,7 @@ void Wiz::processWizImagePolyCaptureCmd(const WizImageCommand *params) {
destBitmap.bitmapHeight = getRectHeight(&destPolyRect);
destBitmap.bufferPtr = (WizRawPixel *)malloc(destBitmap.bitmapWidth * destBitmap.bitmapHeight * sizeof(WizRawPixel));
- if (destBitmap.bufferPtr == 0) {
+ if (!destBitmap.bufferPtr) {
error("Image capture poly: Could not allocate destination buffer");
}
@@ -885,28 +885,28 @@ void Wiz::processWizImagePolyCaptureCmd(const WizImageCommand *params) {
// we need to get the points so that they can be offset to the correct position in
// the source buffer in the case of a screen capture (since the whole screen may not
// be captured, and the polygon may be offset into it, so we only create a buffer of the size needed
- int iPointCt;
+ int pointCt;
Common::Point srcPoints[5];
- for (iPointCt = 0; iPointCt < 5; ++iPointCt) {
- srcPoints[iPointCt].x = _polygons[polygon1].points[iPointCt].x;
- srcPoints[iPointCt].y = _polygons[polygon1].points[iPointCt].y;
+ for (pointCt = 0; pointCt < 5; ++pointCt) {
+ srcPoints[pointCt].x = _polygons[polygon1].points[pointCt].x;
+ srcPoints[pointCt].y = _polygons[polygon1].points[pointCt].y;
}
// check for one to one rectangle, which will set up for an image copy later
- bool bOneToOneRect = false;
+ bool oneToOneRect = false;
// see if they are both rectangles, passing in 4 because it turns out you can only create a 4 vertex polygon in scumm
// according to set4Polygon
if (polyIsRectangle(_polygons[polygon1].points, 4) && polyIsRectangle(_polygons[polygon2].points, 4)) {
// check if the points are all the same
- for (iPointCt = 0; iPointCt < 4; ++iPointCt) {
- if ((_polygons[polygon1].points[iPointCt].x != _polygons[polygon2].points[iPointCt].x) ||
- (_polygons[polygon1].points[iPointCt].y != _polygons[polygon2].points[iPointCt].y)) {
+ for (pointCt = 0; pointCt < 4; ++pointCt) {
+ if ((_polygons[polygon1].points[pointCt].x != _polygons[polygon2].points[pointCt].x) ||
+ (_polygons[polygon1].points[pointCt].y != _polygons[polygon2].points[pointCt].y)) {
break;
}
}
- if (iPointCt == 4) {
- bOneToOneRect = true;
+ if (pointCt == 4) {
+ oneToOneRect = true;
}
}
@@ -959,15 +959,15 @@ void Wiz::processWizImagePolyCaptureCmd(const WizImageCommand *params) {
// get the window size
VirtScreen *pvs = &_vm->_virtscr[kMainVirtScreen];
- int iWindowWidth = pvs->w;
- int iWindowHeight = pvs->h;
+ int windowWidth = pvs->w;
+ int windowHeight = pvs->h;
// intersect the bound rect and the window rect
Common::Rect clipRect;
clipRect.left = 0;
clipRect.top = 0;
- clipRect.right = iWindowWidth - 1;
- clipRect.bottom = iWindowHeight - 1;
+ clipRect.right = windowWidth - 1;
+ clipRect.bottom = windowHeight - 1;
if (!findRectOverlap(&srcPolyRect, &clipRect)) {
error("Image capture poly: Specified polygon doesn't intersect screen.");
@@ -997,32 +997,46 @@ void Wiz::processWizImagePolyCaptureCmd(const WizImageCommand *params) {
destPtr = srcBitmap.bufferPtr;
- int iScreenRowLen = 640 * sizeof(WizRawPixel);
- int iDestRowLen = srcBitmap.bitmapWidth * sizeof(WizRawPixel);
+ int screenRowLen = 640;
+ int destRowLen = srcBitmap.bitmapWidth;
- for (int iRow = 0; iRow < srcBitmap.bitmapHeight; ++iRow) {
- memcpy(destPtr, screenPtr, iDestRowLen);
- screenPtr += iScreenRowLen;
- destPtr += iDestRowLen;
+ if (_uses16BitColor) {
+ WizRawPixel16 *screen16 = (WizRawPixel16 *)screenPtr;
+ WizRawPixel16 *dest16 = (WizRawPixel16 *)destPtr;
+
+ for (int i = 0; i < srcBitmap.bitmapHeight; ++i) {
+ memcpy(dest16, screen16, destRowLen);
+ screen16 += screenRowLen;
+ dest16 += destRowLen;
+ }
+ } else {
+ WizRawPixel8 *screen8 = (WizRawPixel8 *)screenPtr;
+ WizRawPixel8 *dest8 = (WizRawPixel8 *)destPtr;
+
+ for (int i = 0; i < srcBitmap.bitmapHeight; ++i) {
+ memcpy(dest8, screen8, destRowLen);
+ screen8 += screenRowLen;
+ dest8 += destRowLen;
+ }
}
// translate the polygon so it is in the correct place in the buffer
- int iDX = 0, iDY = 0;
- iDX = 0 - srcPolyRect.left;
- iDY = 0 - srcPolyRect.top;
- polyMovePolygonPoints(srcPoints, _polygons[polygon1].numPoints, iDX, iDY);
+ int dx = 0, dy = 0;
+ dx = 0 - srcPolyRect.left;
+ dy = 0 - srcPolyRect.top;
+ polyMovePolygonPoints(srcPoints, _polygons[polygon1].numPoints, dx, dy);
}
// if there is an xmap, do filtered warp
if (shadow) {
// get the color map, bypass the header information
- byte *pXmapColorTable = (byte *)getColorMixBlockPtrForWiz(shadow);
+ byte *xmapColorTable = (byte *)getColorMixBlockPtrForWiz(shadow);
- if (!pXmapColorTable) {
+ if (!xmapColorTable) {
error("Image capture poly: Shadow specified but not present in image.");
}
- pXmapColorTable += _vm->_resourceHeaderSize;
+ xmapColorTable += _vm->_resourceHeaderSize;
WarpWizPoint polypoints[5];
for (int i = 0; i < 5; i++) {
@@ -1039,9 +1053,9 @@ void Wiz::processWizImagePolyCaptureCmd(const WizImageCommand *params) {
warpNPt2NPtNonClippedWarpFiltered(
&destBitmap, polypoints, &srcBitmap, srcWarpPoints,
_polygons[polygon1].numPoints, _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR),
- pXmapColorTable, bIsHintColor, (WizRawPixel)iHintColor);
+ xmapColorTable, isHintColor, (WizRawPixel)hintColor);
- } else if (bOneToOneRect) { // if a one to one copy is performed, just copy this bits
+ } else if (oneToOneRect) { // if a one to one copy is performed, just copy this bits
memcpy(destBitmap.bufferPtr, srcBitmap.bufferPtr, destBitmap.bitmapHeight * destBitmap.bitmapWidth);
} else { // otherwise do "old" warp
WarpWizPoint polypoints[5];
@@ -1264,8 +1278,10 @@ void Wiz::processWizImageDrawCmd(const WizImageCommand *params) {
}
// See if the images are in their native format and twiddle if need be.
- for (int i = 0; i < requiredImageCount; i++) {
- ensureNativeFormatImageForState(requiredImages[i], state);
+ if (_vm->_game.heversion > 99 || (_vm->_game.heversion == 99 && _uses16BitColor)) {
+ for (int i = 0; i < requiredImageCount; i++) {
+ ensureNativeFormatImageForState(requiredImages[i], state);
+ }
}
}
@@ -1754,6 +1770,9 @@ bool Wiz::dwIsUncompressedFormatTypeID(int id) {
}
int Wiz::dwGetImageGeneralProperty(int image, int state, int property) {
+ if (_vm->_game.heversion == 99 && !_uses16BitColor)
+ return 0;
+
switch (property) {
case kWIPCompressionType:
return getWizCompressionType(image, state);
@@ -1974,7 +1993,7 @@ void Wiz::processWizImageRenderLineCmd(const WizImageCommand *params) {
int whichState, w, h, whichImage;
WizSimpleBitmap renderBitmap;
WizRawPixel whatColor;
- int iPropertyNumber = 0, iPropertyValue = 0;
+ int propertyNumber = 0, propertyValue = 0;
if (!(params->actionFlags & kWAFRenderCoords)) {
return;
@@ -1987,8 +2006,8 @@ void Wiz::processWizImageRenderLineCmd(const WizImageCommand *params) {
}
if (params->actionFlags & kWAFProperty) {
- iPropertyNumber = params->propertyNumber;
- iPropertyValue = params->propertyValue;
+ propertyNumber = params->propertyNumber;
+ propertyValue = params->propertyValue;
}
whichImage = params->image;
@@ -2021,7 +2040,7 @@ void Wiz::processWizImageRenderLineCmd(const WizImageCommand *params) {
}
// If we're here we must be able to render into the image (clipped)...
- switch (iPropertyNumber) {
+ switch (propertyNumber) {
case 0:
pgClippedLineDraw(
&renderBitmap,
@@ -2036,7 +2055,7 @@ void Wiz::processWizImageRenderLineCmd(const WizImageCommand *params) {
params->renderCoords.left, params->renderCoords.top,
params->renderCoords.right, params->renderCoords.bottom,
&clipRect,
- iPropertyValue,
+ propertyValue,
whatColor);
break;
@@ -2243,32 +2262,32 @@ void Wiz::processWizImageModifyCmd(const WizImageCommand *params) {
}
void Wiz::processWizImageRenderEllipseCmd(const WizImageCommand *params) {
- int iWhichState = 0, iPropertyNumber = 0, iPropertyValue = 0;
- int iWidth = 0, iHeight = 0;
+ int whichState = 0, propertyNumber = 0, propertyValue = 0;
+ int width = 0, height = 0;
if (params->actionFlags & kWAFProperty) {
- iPropertyNumber = params->propertyNumber;
- iPropertyValue = params->propertyValue;
+ propertyNumber = params->propertyNumber;
+ propertyValue = params->propertyValue;
}
// What state is going to rendered into?
if (params->actionFlags & kWAFState) {
- iWhichState = params->state;
+ whichState = params->state;
}
- int iWhichImage = params->image;
+ int whichImage = params->image;
// Make the clipping rect for this image / state
- getWizImageDim(iWhichImage, iWhichState, iWidth, iHeight);
+ getWizImageDim(whichImage, whichState, width, height);
Common::Rect clipRect;
- makeSizedRectAt(&clipRect, 0, 0, iWidth, iHeight);
+ makeSizedRectAt(&clipRect, 0, 0, width, height);
// Get the simple bitmap
WizSimpleBitmap renderBitmap;
- if (!dwSetSimpleBitmapStructFromImage(iWhichImage, iWhichState, &renderBitmap)) {
- error("Wiz::processWizImageRenderEllipseCmd(): Image %d state %d invalid for rendering.", iWhichImage, iWhichState);
+ if (!dwSetSimpleBitmapStructFromImage(whichImage, whichState, &renderBitmap)) {
+ error("Wiz::processWizImageRenderEllipseCmd(): Image %d state %d invalid for rendering.", whichImage, whichState);
}
pgDrawClippedEllipse(&renderBitmap,
@@ -2277,7 +2296,7 @@ void Wiz::processWizImageRenderEllipseCmd(const WizImageCommand *params) {
params->ellipseProperties.kx, params->ellipseProperties.ky,
params->ellipseProperties.lod,
&clipRect,
- iPropertyValue,
+ propertyValue,
params->ellipseProperties.color);
_vm->_res->setModified(rtImage, params->image);
@@ -2593,31 +2612,6 @@ void Wiz::getWizImageSpot(uint8 *dataPtr, int state, int32 &x, int32 &y) {
}
}
-int Wiz::getWizImageData(int resNum, int state, int type) {
- // TODO: Fix
- uint8 *dataPtr, *wizh;
-
- dataPtr = _vm->getResourceAddress(rtImage, resNum);
- assert(dataPtr);
-
- switch (type) {
- case 0:
- wizh = _vm->findWrappedBlock(MKTAG('W','I','Z','H'), dataPtr, state, 0);
- assert(wizh);
- return READ_LE_UINT32(wizh + 0x0);
- case 1:
- return (_vm->findWrappedBlock(MKTAG('R','G','B','S'), dataPtr, state, 0) != nullptr) ? 1 : 0;
- case 2:
- return (_vm->findWrappedBlock(MKTAG('R','M','A','P'), dataPtr, state, 0) != nullptr) ? 1 : 0;
- case 3:
- return (_vm->findWrappedBlock(MKTAG('T','R','N','S'), dataPtr, state, 0) != nullptr) ? 1 : 0;
- case 4:
- return (_vm->findWrappedBlock(MKTAG('X','M','A','P'), dataPtr, state, 0) != nullptr) ? 1 : 0;
- default:
- error("getWizImageData: Unknown type %d", type);
- }
-}
-
int Wiz::getWizStateCount(int resNum) {
const uint8 *dataPtr = _vm->getResourceAddress(rtImage, resNum);
assert(dataPtr);
diff --git a/engines/scumm/he/wiz_he.h b/engines/scumm/he/wiz_he.h
index fce709c07eb..a0d65751778 100644
--- a/engines/scumm/he/wiz_he.h
+++ b/engines/scumm/he/wiz_he.h
@@ -578,7 +578,6 @@ public:
const byte *getColorMixBlockPtrForWiz(int image);
void setWizCompressionType(int image, int state, int newType);
- int getWizImageData(int resNum, int state, int type);
bool isUncompressedFormatTypeID(int id);
void handleRotate0SpecialCase(int image, int state, int x, int y, int shadow, int angle, int scale, const Common::Rect *clipRect, int32 flags, WizSimpleBitmap *optionalBitmapOverride, const WizRawPixel *optionalColorConversionTable);
@@ -771,7 +770,7 @@ public:
void auxHistogramTRLEPrim(int *histogramTablePtr, byte *compData, Common::Rect *sourceRect);
// TRLE
- int _trlePutsize = 0;
+ int _trlePutSize = 0;
byte _trleBuf[(128 * 2) * sizeof(WizRawPixel)];
byte *trlePutDump(byte *dest, int nn);
Commit: 1f493dec1af6db215c5b5b80a52c6ca54b8ba1e5
https://github.com/scummvm/scummvm/commit/1f493dec1af6db215c5b5b80a52c6ca54b8ba1e5
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Add new HE variant (99.5) as game feature flag
Changed paths:
engines/scumm/detection.h
engines/scumm/detection_tables.h
engines/scumm/he/script_v90he.cpp
engines/scumm/he/sprite_he.cpp
engines/scumm/he/wiz_he.cpp
engines/scumm/scumm.cpp
engines/scumm/scumm.h
diff --git a/engines/scumm/detection.h b/engines/scumm/detection.h
index 40f300bd59c..4e4a5ecb3da 100644
--- a/engines/scumm/detection.h
+++ b/engines/scumm/detection.h
@@ -348,7 +348,13 @@ enum GameFeatures {
* The "Ultimate Talkie" versions of Monkey Island, which have been
* patched so that most workarounds/bugfixes no longer apply to them.
*/
- GF_ULTIMATE_TALKIE = 1 << 18
+ GF_ULTIMATE_TALKIE = 1 << 18,
+
+ /**
+ * HE99 games which were ported to a C++ codebase with HE99 opcodes
+ * and several HE100 GFX/Wiz features.
+ */
+ GF_HE_995 = 1 << 19
};
enum ScummGameId {
diff --git a/engines/scumm/detection_tables.h b/engines/scumm/detection_tables.h
index 9fb2080b474..18b5bbcd741 100644
--- a/engines/scumm/detection_tables.h
+++ b/engines/scumm/detection_tables.h
@@ -329,22 +329,22 @@ static const GameSettings gameVariantsTable[] = {
{"mustard", 0, 0, GID_HEGAME, 6, 99, MDT_NONE, GF_USE_KEY | GF_HE_LOCALIZED, UNK, GUIO4(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT, GUIO_AUDIO_OVERRIDE)},
// Added the use of fonts
- {"FreddisFunShop", 0, 0, GID_FUNSHOP, 6, 99, MDT_NONE, GF_USE_KEY | GF_HE_LOCALIZED, UNK, GUIO4(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT, GUIO_AUDIO_OVERRIDE)},
- {"SamsFunShop", 0, 0, GID_FUNSHOP, 6, 99, MDT_NONE, GF_USE_KEY | GF_HE_LOCALIZED, UNK, GUIO4(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT, GUIO_AUDIO_OVERRIDE)},
- {"PuttsFunShop", 0, 0, GID_FUNSHOP, 6, 99, MDT_NONE, GF_USE_KEY | GF_HE_LOCALIZED, UNK, GUIO4(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT, GUIO_AUDIO_OVERRIDE)},
+ {"FreddisFunShop", 0, 0, GID_FUNSHOP, 6, 99, MDT_NONE, GF_USE_KEY | GF_HE_LOCALIZED | GF_HE_995, UNK, GUIO4(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT, GUIO_AUDIO_OVERRIDE)},
+ {"SamsFunShop", 0, 0, GID_FUNSHOP, 6, 99, MDT_NONE, GF_USE_KEY | GF_HE_LOCALIZED | GF_HE_995, UNK, GUIO4(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT, GUIO_AUDIO_OVERRIDE)},
+ {"PuttsFunShop", 0, 0, GID_FUNSHOP, 6, 99, MDT_NONE, GF_USE_KEY | GF_HE_LOCALIZED | GF_HE_995, UNK, GUIO4(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT, GUIO_AUDIO_OVERRIDE)},
// Added the use of smacker videos
- {"BluesTreasureHunt", 0, 0, GID_TREASUREHUNT, 6, 99, MDT_NONE, GF_HE_LOCALIZED | GF_USE_KEY, UNK, GUIO4(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT, GUIO_AUDIO_OVERRIDE)},
+ {"BluesTreasureHunt", 0, 0, GID_TREASUREHUNT, 6, 99, MDT_NONE, GF_HE_LOCALIZED | GF_USE_KEY | GF_HE_995 | GF_HE_995, UNK, GUIO4(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT, GUIO_AUDIO_OVERRIDE)},
// Added 16bit color
- {"arttime", 0, 0, GID_HEGAME, 6, 99, MDT_NONE, GF_USE_KEY | GF_HE_LOCALIZED | GF_16BIT_COLOR, UNK, GUIO4(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT, GUIO_AUDIO_OVERRIDE)},
- {"baseball2001", 0, 0, GID_BASEBALL2001, 6, 99, MDT_NONE, GF_USE_KEY | GF_16BIT_COLOR, UNK, GUIO5(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT, GUIO_AUDIO_OVERRIDE, GUIO_NETWORK)},
- {"readtime", 0, 0, GID_HEGAME, 6, 99, MDT_NONE, GF_USE_KEY | GF_HE_LOCALIZED | GF_16BIT_COLOR, UNK, GUIO4(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT, GUIO_AUDIO_OVERRIDE)},
- {"SoccerMLS", 0, 0, GID_SOCCERMLS, 6, 99, MDT_NONE, GF_USE_KEY | GF_HE_LOCALIZED | GF_16BIT_COLOR, UNK, GUIO4(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT, GUIO_AUDIO_OVERRIDE)},
- {"spyozon", 0, 0, GID_HEGAME, 6, 99, MDT_NONE, GF_USE_KEY | GF_HE_LOCALIZED | GF_16BIT_COLOR, UNK, GUIO4(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT, GUIO_AUDIO_OVERRIDE)},
-
- {"freddicove", "", 0, GID_HEGAME, 6, 99, MDT_NONE, GF_USE_KEY | GF_HE_LOCALIZED | GF_16BIT_COLOR, UNK, GUIO4(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT, GUIO_AUDIO_OVERRIDE)},
- {"freddicove", "unenc", 0, GID_HEGAME, 6, 99, MDT_NONE, GF_HE_LOCALIZED | GF_16BIT_COLOR, UNK, GUIO4(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT, GUIO_AUDIO_OVERRIDE)},
+ {"arttime", 0, 0, GID_HEGAME, 6, 99, MDT_NONE, GF_USE_KEY | GF_HE_LOCALIZED | GF_16BIT_COLOR | GF_HE_995, UNK, GUIO4(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT, GUIO_AUDIO_OVERRIDE)},
+ {"baseball2001", 0, 0, GID_BASEBALL2001, 6, 99, MDT_NONE, GF_USE_KEY | GF_16BIT_COLOR | GF_HE_995, UNK, GUIO5(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT, GUIO_AUDIO_OVERRIDE, GUIO_NETWORK)},
+ {"readtime", 0, 0, GID_HEGAME, 6, 99, MDT_NONE, GF_USE_KEY | GF_HE_LOCALIZED | GF_16BIT_COLOR | GF_HE_995, UNK, GUIO4(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT, GUIO_AUDIO_OVERRIDE)},
+ {"SoccerMLS", 0, 0, GID_SOCCERMLS, 6, 99, MDT_NONE, GF_USE_KEY | GF_HE_LOCALIZED | GF_16BIT_COLOR | GF_HE_995, UNK, GUIO4(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT, GUIO_AUDIO_OVERRIDE)},
+ {"spyozon", 0, 0, GID_HEGAME, 6, 99, MDT_NONE, GF_USE_KEY | GF_HE_LOCALIZED | GF_16BIT_COLOR | GF_HE_995, UNK, GUIO4(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT, GUIO_AUDIO_OVERRIDE)},
+
+ {"freddicove", "", 0, GID_HEGAME, 6, 99, MDT_NONE, GF_USE_KEY | GF_HE_LOCALIZED | GF_16BIT_COLOR | GF_HE_995, UNK, GUIO4(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT, GUIO_AUDIO_OVERRIDE)},
+ {"freddicove", "unenc", 0, GID_HEGAME, 6, 99, MDT_NONE, GF_HE_LOCALIZED | GF_16BIT_COLOR | GF_HE_995, UNK, GUIO4(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT, GUIO_AUDIO_OVERRIDE)},
{"freddicove", "HE 100", 0, GID_HEGAME, 6, 100, MDT_NONE, GF_USE_KEY | GF_HE_LOCALIZED | GF_16BIT_COLOR, UNK, GUIO4(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT, GUIO_AUDIO_OVERRIDE)},
// Restructured the Scumm engine
@@ -377,6 +377,7 @@ static const GameSettings gameVariantsTable[] = {
{"", "HE 98", 0, GID_HEGAME, 6, 98, MDT_NONE, GF_USE_KEY, UNK, GUIO4(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT, GUIO_AUDIO_OVERRIDE)},
{"", "HE 98.5", 0, GID_HEGAME, 6, 98, MDT_NONE, GF_USE_KEY | GF_HE_985, UNK, GUIO4(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT, GUIO_AUDIO_OVERRIDE)},
{"", "HE 99", 0, GID_HEGAME, 6, 99, MDT_NONE, GF_USE_KEY, UNK, GUIO4(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT, GUIO_AUDIO_OVERRIDE)},
+ {"", "HE 99.5", 0, GID_HEGAME, 6, 99, MDT_NONE, GF_USE_KEY | GF_HE_995, UNK, GUIO4(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT, GUIO_AUDIO_OVERRIDE)},
{"", "HE 100", 0, GID_HEGAME, 6, 100, MDT_NONE, GF_USE_KEY, UNK, GUIO4(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT, GUIO_AUDIO_OVERRIDE)},
{"", "HE 101", 0, GID_HEGAME, 6, 100, MDT_NONE, GF_USE_KEY, UNK, GUIO4(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT, GUIO_AUDIO_OVERRIDE)},
diff --git a/engines/scumm/he/script_v90he.cpp b/engines/scumm/he/script_v90he.cpp
index f758f6d9c62..1cb6d868d66 100644
--- a/engines/scumm/he/script_v90he.cpp
+++ b/engines/scumm/he/script_v90he.cpp
@@ -1321,7 +1321,7 @@ void ScummEngine_v90he::o90_getWizData() {
break;
}
case SO_NEW_GENERAL_PROPERTY: // 139
- if (_game.heversion > 99 || (_game.heversion == 99 && _wiz->_uses16BitColor)) {
+ if (_game.heversion > 99 || _isHE995) {
type = pop();
} else {
type = 0;
diff --git a/engines/scumm/he/sprite_he.cpp b/engines/scumm/he/sprite_he.cpp
index f9044295af8..326aa7b881c 100644
--- a/engines/scumm/he/sprite_he.cpp
+++ b/engines/scumm/he/sprite_he.cpp
@@ -261,7 +261,7 @@ int Sprite::getSpriteAutoAnimFlag(int spriteId) {
int Sprite::getSpriteUpdateType(int spriteId) {
assertRange(1, spriteId, _maxSprites, "sprite");
- if (_vm->_game.heversion >= 99) {
+ if (_vm->_game.heversion > 99 || _vm->_isHE995) {
if (_spriteTable[spriteId].flags & kSFSmartRender) {
return SPRDEF_SMART;
} else {
@@ -432,7 +432,7 @@ void Sprite::getSpriteRectPrim(const SpriteInfo *spritePtr, Common::Rect *rectPt
if (image != 0) {
Common::Point tmpPt(spotPtr->x, spotPtr->y);
- if (_vm->_game.heversion < 100) {
+ if (_vm->_game.heversion < 100 && !_vm->_isHE995) {
calcSpriteSpot(spritePtr, includeGroupTransform, x, y);
tmpPt.x = x;
tmpPt.y = y;
@@ -531,7 +531,7 @@ void Sprite::calcSpriteSpot(const SpriteInfo *spritePtr, bool includeGroupTransf
y += _groupTable[spritePtr->group].posY;
}
} else if (_vm->_game.heversion >= 98) {
- if (_vm->_game.heversion >= 100) {
+ if (_vm->_game.heversion > 99 || _vm->_isHE995) {
if (spritePtr->image == 0) {
if (includeGroupTransform && spritePtr->group) {
x = _groupTable[spritePtr->group].posX;
@@ -855,7 +855,7 @@ void Sprite::setSpriteAutoAnimFlag(int spriteId, int value) {
void Sprite::setSpriteUpdateType(int spriteId, int eraseType) {
assertRange(1, spriteId, _maxSprites, "sprite");
- if (_vm->_game.heversion >= 99) {
+ if (_vm->_game.heversion > 99 || _vm->_isHE995) {
switch (eraseType) {
default:
case SPRDEF_SMART:
@@ -969,15 +969,17 @@ void Sprite::newSprite(int sprite) {
setSourceImage(sprite, 0);
setMaskImage(sprite, 0);
- setSpriteUpdateType(sprite, SPRDEF_SIMPLE);
- setSpritePriority(sprite, 0);
- setSpriteZBuffer(sprite, 0);
+ if (_vm->_game.heversion > 99 || _vm->_isHE995) {
+ setSpriteUpdateType(sprite, SPRDEF_SIMPLE);
+ setSpritePriority(sprite, 0);
+ setSpriteZBuffer(sprite, 0);
- _spriteTable[sprite].flags |= kSFAutoAnimate;
- _spriteTable[sprite].conditionBits = 0;
+ _spriteTable[sprite].flags |= kSFAutoAnimate;
+ _spriteTable[sprite].conditionBits = 0;
- _spriteTable[sprite].specialRenderFlags = 0;
- // TODO U32 PU_SpriteNewHook(sprite);
+ _spriteTable[sprite].specialRenderFlags = 0;
+ // TODO U32 PU_SpriteNewHook(sprite);
+ }
}
}
@@ -1022,14 +1024,14 @@ void Sprite::setImageList(int sprite, int count, const int *list) {
} else {
_spriteTable[sprite].maxStates = _vm->_wiz->getWizStateCount(_spriteTable[sprite].image);
- if (_vm->_game.heversion < 100) {
- _spriteTable[sprite].flags |= kSFDefaultFlagActive;
- } else {
+ if (_vm->_game.heversion > 99 || _vm->_isHE995) {
if (_vm->VAR(_vm->VAR_SPRITE_IMAGE_CHANGE_DOES_NOT_RESET_SETTINGS)) {
_spriteTable[sprite].flags |= kSFActive;
} else {
_spriteTable[sprite].flags |= kSFDefaultFlagActive;
}
+ } else {
+ _spriteTable[sprite].flags |= kSFDefaultFlagActive;
}
if (_vm->_game.heversion > 80 &&
@@ -1045,7 +1047,7 @@ void Sprite::setImageList(int sprite, int count, const int *list) {
} else {
_spriteTable[sprite].flags = kSFDefaultFlagInactive;
}
- } else if (_vm->_game.heversion >= 100) {
+ } else if (_vm->_game.heversion > 99 || _vm->_isHE995) {
if (_vm->VAR(_vm->VAR_SPRITE_IMAGE_CHANGE_DOES_NOT_RESET_SETTINGS)) {
_spriteTable[sprite].flags &= ~kSFActive;
} else {
@@ -1332,8 +1334,9 @@ void Sprite::newGroup(int group) {
clearGroupScaleInfo(group);
// TODO U32
- // if (_vm->_game.heversion >= 99)
- // PU_GroupNewHook(group);
+ // if (_vm->_game.heversion > 99 || _vm->_isHE995) {
+ // PU_GroupNewHook(group);
+ // }
}
void Sprite::resetSpriteSystem(bool eraseScreen) {
@@ -1709,9 +1712,11 @@ void Sprite::renderSprites(bool negativeOrPositiveRender) {
if (_vm->_game.heversion > 98) {
// Setup the image render command...
- imageRenderCmd.extendedRenderInfo.sprite = (int32)(spritePtr[i] - _spriteTable);
- imageRenderCmd.extendedRenderInfo.group = spritePtr[i]->group;
- imageRenderCmd.extendedRenderInfo.conditionBits = spritePtr[i]->conditionBits;
+ if (_vm->_game.heversion > 99 || _vm->_isHE995) {
+ imageRenderCmd.extendedRenderInfo.sprite = (int32)(spritePtr[i] - _spriteTable);
+ imageRenderCmd.extendedRenderInfo.group = spritePtr[i]->group;
+ imageRenderCmd.extendedRenderInfo.conditionBits = spritePtr[i]->conditionBits;
+ }
imageRenderCmd.actionFlags = kWAFSpot;
imageRenderCmd.xPos = spot.x;
@@ -1775,11 +1780,13 @@ void Sprite::renderSprites(bool negativeOrPositiveRender) {
}
if (_vm->_game.heversion > 98) {
- // Handle Z-Clipping
- if (spritePtr[i]->zbufferImage != 0) {
- imageRenderCmd.actionFlags |= kWAFZBufferImage;
- imageRenderCmd.zbufferImage = spritePtr[i]->zbufferImage;
- imageRenderCmd.zPos = spritePtr[i]->priority;
+ if (_vm->_game.heversion > 99 || _vm->_isHE995) {
+ // Handle Z-Clipping
+ if (spritePtr[i]->zbufferImage != 0) {
+ imageRenderCmd.actionFlags |= kWAFZBufferImage;
+ imageRenderCmd.zbufferImage = spritePtr[i]->zbufferImage;
+ imageRenderCmd.zPos = spritePtr[i]->priority;
+ }
}
// Set the source image...
@@ -1789,7 +1796,9 @@ void Sprite::renderSprites(bool negativeOrPositiveRender) {
imageRenderCmd.sourceImage = sourceImage;
}
- renderFlags |= spritePtr[i]->specialRenderFlags;
+ if (_vm->_game.heversion > 99 || _vm->_isHE995) {
+ renderFlags |= spritePtr[i]->specialRenderFlags;
+ }
// Finally set the image render flags
imageRenderCmd.actionFlags |= kWAFFlags;
@@ -1836,10 +1845,12 @@ void Sprite::renderSprites(bool negativeOrPositiveRender) {
if (_groupTable[group].flags & kSGFUseClipRect) {
if (_vm->_game.heversion > 98) {
if (!_vm->_wiz->findRectOverlap(&spritePtr[i]->lastRect, &_groupTable[group].clipRect)) {
- spritePtr[i]->lastRect.left = 1234;
- spritePtr[i]->lastRect.top = 1234;
- spritePtr[i]->lastRect.right = -1234;
- spritePtr[i]->lastRect.bottom = -1234;
+ if (_vm->_game.heversion > 99 || _vm->_isHE995) {
+ spritePtr[i]->lastRect.left = 1234;
+ spritePtr[i]->lastRect.top = 1234;
+ spritePtr[i]->lastRect.right = -1234;
+ spritePtr[i]->lastRect.bottom = -1234;
+ }
continue;
}
@@ -1895,7 +1906,7 @@ void Sprite::renderSprites(bool negativeOrPositiveRender) {
// Finally actually do something by calling the command parser
// this function is the same core that renders images via the
// "image" draw command.
- if (_vm->_game.heversion >= 99) {
+ if (_vm->_game.heversion > 99 || _vm->_isHE995) {
imageRenderCmd.actionType = kWADraw;
_vm->_wiz->processWizImageCmd(&imageRenderCmd);
} else {
diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp
index cffaaff33c4..c9a759f59f6 100644
--- a/engines/scumm/he/wiz_he.cpp
+++ b/engines/scumm/he/wiz_he.cpp
@@ -209,7 +209,7 @@ void *Wiz::drawAWizPrimEx(int globNum, int state, int x, int y, int z, int shado
}
}
- if (_vm->_game.heversion >= 99) {
+ if (_vm->_game.heversion > 99 || _vm->_isHE995) {
// If using a z-buffer make sure both globs are in ram!!!!
if (zbufferImage) {
// uncompressed 16-bit z-buffers only for now
@@ -327,7 +327,7 @@ void *Wiz::drawAWizPrimEx(int globNum, int state, int x, int y, int z, int shado
}
// Get down to business and decompress the image...
- if (_vm->_game.heversion >= 99 && zbufferImage) {
+ if ((_vm->_game.heversion > 99 || _vm->_isHE995) && zbufferImage) {
WizSimpleBitmap sbZBuffer;
sbZBuffer.bitmapHeight = 0;
sbZBuffer.bitmapWidth = 0;
@@ -423,7 +423,7 @@ void *Wiz::drawAWizPrimEx(int globNum, int state, int x, int y, int z, int shado
error("Wiz::drawAWizPrimEx(): Raw data type mismatch for mode %d vs %d", src_c, kWCTNone16Bpp);
}
} else {
- if (_vm->_game.heversion >= 99) {
+ if (_vm->_game.heversion > 99 || _vm->_isHE995) {
if (optionalColorConversionTable &&
((WizRawPixel *)_vm->getHEPaletteSlot(1) != optionalColorConversionTable)) {
flags |= kWRFRemap;
@@ -635,6 +635,10 @@ int Wiz::pixelHitTestWizPrim(int globNum, int state, int x, int y, int32 flags)
src_d + _vm->_resourceHeaderSize, x, y, src_w, src_h,
_vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR));
+ if (!(_vm->_game.heversion > 99 || _vm->_isHE995)) {
+ return pixel;
+ }
+
int compType = getWizCompressionType(globNum, state);
if (LITTLE_ENDIAN_WIZ(compType)) {
@@ -657,6 +661,11 @@ int Wiz::pixelHitTestWizPrim(int globNum, int state, int x, int y, int32 flags)
srcBitmap.bitmapHeight = src_h;
int pixel = pgReadPixel(&srcBitmap, x, y, _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR));
+
+ if (!(_vm->_game.heversion > 99 || _vm->_isHE995)) {
+ return pixel;
+ }
+
int compType = getWizCompressionType(globNum, state);
if (LITTLE_ENDIAN_WIZ(compType)) {
@@ -784,7 +793,12 @@ void Wiz::processWizImagePolyCaptureCmd(const WizImageCommand *params) {
if (params->actionFlags & kWAFCompressionType) {
compressionType = params->compressionType;
} else {
- compressionType = kWCTNone;
+ compressionType = (_vm->_game.heversion > 99 || _vm->_isHE995) ? kWCTTRLE : kWCTNone;
+ }
+
+ if (!(_vm->_game.heversion > 99 || _vm->_isHE995)) {
+ _vm->_res->setModified(rtImage, params->image);
+ return;
}
if (params->actionFlags & kWAFShadow) {
@@ -1234,9 +1248,11 @@ void Wiz::processWizImageDrawCmd(const WizImageCommand *params) {
shadowImage = 0;
}
- if (params->actionFlags & kWAFZBufferImage) {
- zbufferImage = params->zbufferImage;
- ADD_REQUIRED_IMAGE(zbufferImage);
+ if (_vm->_game.heversion > 99 || _vm->_isHE995) {
+ if (params->actionFlags & kWAFZBufferImage) {
+ zbufferImage = params->zbufferImage;
+ ADD_REQUIRED_IMAGE(zbufferImage);
+ }
}
if (params->actionFlags & kWAFRect) {
@@ -1278,7 +1294,7 @@ void Wiz::processWizImageDrawCmd(const WizImageCommand *params) {
}
// See if the images are in their native format and twiddle if need be.
- if (_vm->_game.heversion > 99 || (_vm->_game.heversion == 99 && _uses16BitColor)) {
+ if (_vm->_game.heversion > 99 || _vm->_isHE995) {
for (int i = 0; i < requiredImageCount; i++) {
ensureNativeFormatImageForState(requiredImages[i], state);
}
@@ -1296,7 +1312,7 @@ void Wiz::processWizImageDrawCmd(const WizImageCommand *params) {
destBitmap = nullptr;
}
- if (_vm->_game.heversion >= 99 && (params->actionFlags & kWAFRemapList)) {
+ if ((_vm->_game.heversion > 99 || _vm->_isHE995) && (params->actionFlags & kWAFRemapList)) {
processWizImageModifyCmd(params);
flags |= kWRFRemap;
}
@@ -1708,7 +1724,7 @@ void Wiz::dwHandleComplexImageDraw(int image, int state, int x, int y, int shado
y = boundingRect.top;
// Special case renderers don't use shadows...
- if (!shadow) {
+ if (!shadow || (_vm->_game.heversion <= 99 && !_vm->_isHE995)) {
switch (correctedAngle) {
case 0:
handleRotate0SpecialCase(
@@ -1740,7 +1756,10 @@ void Wiz::dwHandleComplexImageDraw(int image, int state, int x, int y, int shado
// If there is a shadow get it's address
if (shadow) {
shadowPtr = (byte *)getColorMixBlockPtrForWiz(shadow);
- shadowPtr += _vm->_resourceHeaderSize;
+
+ // Let's replicate whichever bug they had in the interpreter...
+ if (_vm->_game.heversion > 99 || _vm->_isHE995)
+ shadowPtr += _vm->_resourceHeaderSize;
} else {
shadowPtr = nullptr;
}
@@ -1770,7 +1789,7 @@ bool Wiz::dwIsUncompressedFormatTypeID(int id) {
}
int Wiz::dwGetImageGeneralProperty(int image, int state, int property) {
- if (_vm->_game.heversion == 99 && !_uses16BitColor)
+ if (_vm->_isHE995)
return 0;
switch (property) {
@@ -1984,7 +2003,10 @@ void Wiz::processWizImageRenderRectCmd(const WizImageCommand *params) {
// If we're here we must be able to render into the image (clipped)...
if (findRectOverlap(&renderRect, &clipRect)) {
pgDrawSolidRect(&renderBitmap, &renderRect, whatColor);
- _vm->_res->setModified(rtImage, params->image);
+
+ if (_vm->_game.heversion > 99 || _vm->_isHE995) {
+ _vm->_res->setModified(rtImage, params->image);
+ }
}
}
@@ -2005,9 +2027,11 @@ void Wiz::processWizImageRenderLineCmd(const WizImageCommand *params) {
whichState = 0;
}
- if (params->actionFlags & kWAFProperty) {
- propertyNumber = params->propertyNumber;
- propertyValue = params->propertyValue;
+ if (_vm->_game.heversion > 99 || _vm->_isHE995) {
+ if (params->actionFlags & kWAFProperty) {
+ propertyNumber = params->propertyNumber;
+ propertyValue = params->propertyValue;
+ }
}
whichImage = params->image;
@@ -2040,28 +2064,36 @@ void Wiz::processWizImageRenderLineCmd(const WizImageCommand *params) {
}
// If we're here we must be able to render into the image (clipped)...
- switch (propertyNumber) {
- case 0:
+ if (_vm->_game.heversion > 99 || _vm->_isHE995) {
+ switch (propertyNumber) {
+ case 0:
+ pgClippedLineDraw(
+ &renderBitmap,
+ params->renderCoords.left, params->renderCoords.top,
+ params->renderCoords.right, params->renderCoords.bottom,
+ &clipRect, whatColor);
+
+ break;
+ case 1:
+ pgClippedThickLineDraw(
+ &renderBitmap,
+ params->renderCoords.left, params->renderCoords.top,
+ params->renderCoords.right, params->renderCoords.bottom,
+ &clipRect,
+ propertyValue,
+ whatColor);
+
+ break;
+ }
+
+ _vm->_res->setModified(rtImage, params->image);
+ } else {
pgClippedLineDraw(
&renderBitmap,
params->renderCoords.left, params->renderCoords.top,
params->renderCoords.right, params->renderCoords.bottom,
&clipRect, whatColor);
-
- break;
- case 1:
- pgClippedThickLineDraw(
- &renderBitmap,
- params->renderCoords.left, params->renderCoords.top,
- params->renderCoords.right, params->renderCoords.bottom,
- &clipRect,
- propertyValue,
- whatColor);
-
- break;
}
-
- _vm->_res->setModified(rtImage, params->image);
}
void Wiz::processWizImageRenderPixelCmd(const WizImageCommand *params) {
@@ -2113,7 +2145,9 @@ void Wiz::processWizImageRenderPixelCmd(const WizImageCommand *params) {
if (isPointInRect(&clipRect,&pt)) {
pgWritePixel(&renderBitmap, pt.x, pt.y, whatColor);
- _vm->_res->setModified(rtImage, params->image);
+ if (_vm->_game.heversion > 99 || _vm->_isHE995) {
+ _vm->_res->setModified(rtImage, params->image);
+ }
}
}
@@ -2378,7 +2412,7 @@ void Wiz::processWizImageRenderFloodFillCmd(const WizImageCommand *params) {
if (isPointInRect(&clipRect, &pt)) {
floodSimpleFill(&renderBitmap, pt.x, pt.y, whatColor, &clipRect, &renderRect);
- if (_vm->_game.heversion >= 99) {
+ if (_vm->_game.heversion > 99 || _vm->_isHE995) {
_vm->_res->setModified(rtImage, params->image);
}
}
@@ -2409,24 +2443,29 @@ void Wiz::processNewWizImageCmd(const WizImageCommand *params) {
hotspotY = 0;
}
- // Determine pixel depth...
- if (params->actionFlags & kWAFProperty) {
- propertyNumber = params->propertyNumber;
- propertyValue = params->propertyValue;
- }
int pixelDepth = (_vm->_game.features & GF_16BIT_COLOR) ? 16 : 8;
- if (propertyNumber == 1) { // Color hint property
- pixelDepth = propertyValue;
+ if (_vm->_game.heversion > 99 || _vm->_isHE995) {
+ // Determine pixel depth...
+ if (params->actionFlags & kWAFProperty) {
+ propertyNumber = params->propertyNumber;
+ propertyValue = params->propertyValue;
+ }
- if ((pixelDepth != 16) && (pixelDepth != 8)) {
- error("Wiz::processNewWizImageCmd(): The only pixel depths supported for a new image are 16 and 8. You picked %d.", pixelDepth);
+ if (propertyNumber == 1) { // Color hint property
+ pixelDepth = propertyValue;
+
+ if ((pixelDepth != 16) && (pixelDepth != 8)) {
+ error("Wiz::processNewWizImageCmd(): The only pixel depths supported for a new image are 16 and 8. You picked %d.", pixelDepth);
+ }
}
}
dwCreateRawWiz(params->image, width, height, kCWFDefault, pixelDepth, hotspotX, hotspotY);
- _vm->_res->setModified(rtImage, params->image);
+ if (_vm->_game.heversion > 99 || _vm->_isHE995) {
+ _vm->_res->setModified(rtImage, params->image);
+ }
}
void Wiz::processWizImageLoadCmd(const WizImageCommand *params) {
@@ -2460,39 +2499,69 @@ void Wiz::processWizImageLoadCmd(const WizImageCommand *params) {
void Wiz::processWizImageSaveCmd(const WizImageCommand *params) {
if (params->actionFlags & kWAFFilename) {
- switch (params->fileType) {
- case DW_SAVE_RAW_FORMAT:
- // Ignore on purpose...
- _vm->VAR(_vm->VAR_OPERATION_FAILURE) = DW_SAVE_NOT_TYPE;
- break;
- case DW_SAVE_PCX_FORMAT:
- // TODO Write image to file
- break;
- case DW_SAVE_WIZ_FORMAT: {
+ if (_vm->_game.heversion <= 99 && !_vm->_isHE995) {
+ // Validate the type
+ if (params->fileType != DW_SAVE_WIZ_FORMAT) {
+ _vm->VAR(_vm->VAR_OPERATION_FAILURE) = DW_SAVE_NOT_TYPE;
+ return;
+ }
+
+ // Open the file
Common::WriteStream *f = _vm->openSaveFileForWriting(params->filename);
if (!f) {
debug(0, "Unable to open for write '%s'", params->filename);
_vm->VAR(_vm->VAR_OPERATION_FAILURE) = DW_SAVE_CREATE_FAILURE;
+ return;
+ }
+
+ // Get the data size and save out the glob.
+ byte *p = _vm->getResourceAddress(rtImage, params->image);
+ uint32 dataSize = READ_BE_UINT32(p + 4);
+
+ if (f->write(p, dataSize) == dataSize) {
+ _vm->VAR(_vm->VAR_OPERATION_FAILURE) = DW_SAVE_SUCCESS;
} else {
- byte *p = _vm->getResourceAddress(rtImage, params->image);
- uint32 size = READ_BE_UINT32(p + 4);
+ _vm->VAR(_vm->VAR_OPERATION_FAILURE) = DW_SAVE_WRITE_FAILURE;
+ }
- if (f->write(p, size) != size) {
- error("i/o error when writing '%s'", params->filename);
- _vm->VAR(_vm->VAR_OPERATION_FAILURE) = DW_SAVE_WRITE_FAILURE;
+ f->finalize();
+ delete f;
+ } else {
+ switch (params->fileType) {
+ case DW_SAVE_RAW_FORMAT:
+ // Ignore on purpose...
+ _vm->VAR(_vm->VAR_OPERATION_FAILURE) = DW_SAVE_NOT_TYPE;
+ break;
+ case DW_SAVE_PCX_FORMAT:
+ // TODO Write image to file
+ break;
+ case DW_SAVE_WIZ_FORMAT: {
+ Common::WriteStream *f = _vm->openSaveFileForWriting(params->filename);
+
+ if (!f) {
+ debug(0, "Unable to open for write '%s'", params->filename);
+ _vm->VAR(_vm->VAR_OPERATION_FAILURE) = DW_SAVE_CREATE_FAILURE;
} else {
- _vm->VAR(_vm->VAR_OPERATION_FAILURE) = DW_SAVE_SUCCESS;
+ byte *p = _vm->getResourceAddress(rtImage, params->image);
+ uint32 size = READ_BE_UINT32(p + 4);
+
+ if (f->write(p, size) != size) {
+ error("i/o error when writing '%s'", params->filename);
+ _vm->VAR(_vm->VAR_OPERATION_FAILURE) = DW_SAVE_WRITE_FAILURE;
+ } else {
+ _vm->VAR(_vm->VAR_OPERATION_FAILURE) = DW_SAVE_SUCCESS;
+ }
+
+ f->finalize();
+ delete f;
}
- f->finalize();
- delete f;
+ break;
+ }
+ default:
+ error("processWizImageCmd: actionType kWASave unhandled fileType %d", params->fileType);
}
-
- break;
- }
- default:
- error("processWizImageCmd: actionType kWASave unhandled fileType %d", params->fileType);
}
}
}
diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
index 8fd7da5918f..ca7cbb87ed9 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -1994,6 +1994,7 @@ void ScummEngine_v99he::resetScumm() {
_hePaletteSlot = (_game.features & GF_16BIT_COLOR) ? 1280 : 1024;
_hePalettes = (uint8 *)malloc((_numPalettes + 1) * _hePaletteSlot);
memset(_hePalettes, 0, (_numPalettes + 1) * _hePaletteSlot);
+ _isHE995 = (_game.features & GF_HE_995);
// Array 129 is set to base name
len = strlen(_filenamePattern.pattern);
diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h
index 714c4651769..09e08937a19 100644
--- a/engines/scumm/scumm.h
+++ b/engines/scumm/scumm.h
@@ -558,6 +558,7 @@ public:
bool _enableCOMISong = false;
bool _isAmigaPALSystem = false;
bool _quitFromScriptCmd = false;
+ bool _isHE995 = false;
Common::Keymap *_insaneKeymap;
Commit: 055d0f1ff11c979ea75cf40b7808ff974dc518af
https://github.com/scummvm/scummvm/commit/055d0f1ff11c979ea75cf40b7808ff974dc518af
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Fix TRLE compression rect
Changed paths:
engines/scumm/he/wiz_he.cpp
diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp
index c9a759f59f6..34ffc7ee9d8 100644
--- a/engines/scumm/he/wiz_he.cpp
+++ b/engines/scumm/he/wiz_he.cpp
@@ -564,7 +564,7 @@ void Wiz::buildAWiz(const WizRawPixel *bufPtr, int bufWidth, int bufHeight, cons
if (!_uses16BitColor) {
trleCompressImageArea(
ptr + dataOffset, bufPtr, bufWidth,
- compRect.left, compRect.top, compRect.top, compRect.bottom,
+ compRect.left, compRect.top, compRect.right, compRect.bottom,
(byte)transparentColor);
} else {
error("Wiz::buildAWiz(): Incorrect type %d for current pixel mode 16 bit", compressionType);
@@ -959,7 +959,7 @@ void Wiz::processWizImagePolyCaptureCmd(const WizImageCommand *params) {
// create the bitmap
srcBitmap.bufferPtr = (WizRawPixel *)malloc(srcBitmap.bitmapWidth * srcBitmap.bitmapHeight * sizeof(WizRawPixel));
- if (srcBitmap.bufferPtr == 0) {
+ if (!srcBitmap.bufferPtr) {
error("Image capture poly: Could not allocate source buffer");
}
Commit: d4d2ce6fb406f4371f81ba3bd5325747461079d9
https://github.com/scummvm/scummvm/commit/d4d2ce6fb406f4371f81ba3bd5325747461079d9
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Fix crash in Backyard Football
Changed paths:
engines/scumm/he/wiz_he.cpp
diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp
index 34ffc7ee9d8..d5683160706 100644
--- a/engines/scumm/he/wiz_he.cpp
+++ b/engines/scumm/he/wiz_he.cpp
@@ -793,12 +793,7 @@ void Wiz::processWizImagePolyCaptureCmd(const WizImageCommand *params) {
if (params->actionFlags & kWAFCompressionType) {
compressionType = params->compressionType;
} else {
- compressionType = (_vm->_game.heversion > 99 || _vm->_isHE995) ? kWCTTRLE : kWCTNone;
- }
-
- if (!(_vm->_game.heversion > 99 || _vm->_isHE995)) {
- _vm->_res->setModified(rtImage, params->image);
- return;
+ compressionType = kWCTNone;
}
if (params->actionFlags & kWAFShadow) {
@@ -1095,12 +1090,7 @@ void Wiz::processWizImagePolyCaptureCmd(const WizImageCommand *params) {
srcBitmap.bufferPtr = nullptr;
}
- uint8 *palPtr = nullptr;
- if (_vm->_game.heversion >= 99) {
- palPtr = _vm->_hePalettes + _vm->_hePaletteSlot;
- } else {
- palPtr = _vm->_currentPalette;
- }
+ uint8 *palPtr = _vm->getHEPaletteSlot(1);
buildAWiz(destBitmap.bufferPtr,
destBitmap.bitmapWidth,
@@ -1409,12 +1399,7 @@ void Wiz::dwCreateRawWiz(int imageNum, int w, int h, int flags, int bitsPerPixel
WRITE_LE_UINT32(writePtr, h); writePtr += 4;
if (flags & kCWFPalette) {
- const uint8 *palPtr;
- if (_vm->_game.heversion >= 99) {
- palPtr = _vm->_hePalettes + _vm->_hePaletteSlot;
- } else {
- palPtr = _vm->_currentPalette;
- }
+ const uint8 *palPtr = _vm->getHEPaletteSlot(1);
WRITE_BE_UINT32(writePtr, 'RGBS'); writePtr += 4;
WRITE_BE_UINT32(writePtr, WIZBLOCK_RGBS_SIZE); writePtr += 4;
@@ -2003,10 +1988,7 @@ void Wiz::processWizImageRenderRectCmd(const WizImageCommand *params) {
// If we're here we must be able to render into the image (clipped)...
if (findRectOverlap(&renderRect, &clipRect)) {
pgDrawSolidRect(&renderBitmap, &renderRect, whatColor);
-
- if (_vm->_game.heversion > 99 || _vm->_isHE995) {
- _vm->_res->setModified(rtImage, params->image);
- }
+ _vm->_res->setModified(rtImage, params->image);
}
}
@@ -2145,9 +2127,7 @@ void Wiz::processWizImageRenderPixelCmd(const WizImageCommand *params) {
if (isPointInRect(&clipRect,&pt)) {
pgWritePixel(&renderBitmap, pt.x, pt.y, whatColor);
- if (_vm->_game.heversion > 99 || _vm->_isHE995) {
- _vm->_res->setModified(rtImage, params->image);
- }
+ _vm->_res->setModified(rtImage, params->image);
}
}
@@ -2411,10 +2391,7 @@ void Wiz::processWizImageRenderFloodFillCmd(const WizImageCommand *params) {
// If we're here we must be able to render into the image (clipped)...
if (isPointInRect(&clipRect, &pt)) {
floodSimpleFill(&renderBitmap, pt.x, pt.y, whatColor, &clipRect, &renderRect);
-
- if (_vm->_game.heversion > 99 || _vm->_isHE995) {
- _vm->_res->setModified(rtImage, params->image);
- }
+ _vm->_res->setModified(rtImage, params->image);
}
}
@@ -2462,10 +2439,7 @@ void Wiz::processNewWizImageCmd(const WizImageCommand *params) {
}
dwCreateRawWiz(params->image, width, height, kCWFDefault, pixelDepth, hotspotX, hotspotY);
-
- if (_vm->_game.heversion > 99 || _vm->_isHE995) {
- _vm->_res->setModified(rtImage, params->image);
- }
+ _vm->_res->setModified(rtImage, params->image);
}
void Wiz::processWizImageLoadCmd(const WizImageCommand *params) {
Commit: 92fd7a6a5c35ee3e6660f96e1ebb25ce72554486
https://github.com/scummvm/scummvm/commit/92fd7a6a5c35ee3e6660f96e1ebb25ce72554486
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Fix some games crashing at startup
Changed paths:
engines/scumm/he/script_v90he.cpp
engines/scumm/he/wiz_he.cpp
diff --git a/engines/scumm/he/script_v90he.cpp b/engines/scumm/he/script_v90he.cpp
index 1cb6d868d66..db4cccfca5c 100644
--- a/engines/scumm/he/script_v90he.cpp
+++ b/engines/scumm/he/script_v90he.cpp
@@ -805,7 +805,7 @@ void ScummEngine_v90he::o90_setSpriteInfo() {
_sprite->setSpriteAngle(spriteId, args[0]);
break;
case SO_INIT: // 57
- if (_game.features & GF_HE_985 || _game.heversion >= 98) {
+ if (_game.features & GF_HE_985 || _game.heversion >= 99) {
_maxSpriteNum = pop();
_minSpriteNum = pop();
diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp
index d5683160706..b776c92c68d 100644
--- a/engines/scumm/he/wiz_he.cpp
+++ b/engines/scumm/he/wiz_he.cpp
@@ -1090,7 +1090,12 @@ void Wiz::processWizImagePolyCaptureCmd(const WizImageCommand *params) {
srcBitmap.bufferPtr = nullptr;
}
- uint8 *palPtr = _vm->getHEPaletteSlot(1);
+ uint8 *palPtr = nullptr;
+ if (_vm->_game.heversion >= 99) {
+ palPtr = _vm->_hePalettes + _vm->_hePaletteSlot;
+ } else {
+ palPtr = _vm->_currentPalette;
+ }
buildAWiz(destBitmap.bufferPtr,
destBitmap.bitmapWidth,
@@ -1399,7 +1404,12 @@ void Wiz::dwCreateRawWiz(int imageNum, int w, int h, int flags, int bitsPerPixel
WRITE_LE_UINT32(writePtr, h); writePtr += 4;
if (flags & kCWFPalette) {
- const uint8 *palPtr = _vm->getHEPaletteSlot(1);
+ const uint8 *palPtr;
+ if (_vm->_game.heversion >= 99) {
+ palPtr = _vm->_hePalettes + _vm->_hePaletteSlot;
+ } else {
+ palPtr = _vm->_currentPalette;
+ }
WRITE_BE_UINT32(writePtr, 'RGBS'); writePtr += 4;
WRITE_BE_UINT32(writePtr, WIZBLOCK_RGBS_SIZE); writePtr += 4;
Commit: a3e147ca3d13bfd102af53ed86412be17159d40f
https://github.com/scummvm/scummvm/commit/a3e147ca3d13bfd102af53ed86412be17159d40f
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Mark actual HE99.5 games in detection table
Changed paths:
engines/scumm/detection_tables.h
diff --git a/engines/scumm/detection_tables.h b/engines/scumm/detection_tables.h
index 18b5bbcd741..f44696753af 100644
--- a/engines/scumm/detection_tables.h
+++ b/engines/scumm/detection_tables.h
@@ -329,18 +329,18 @@ static const GameSettings gameVariantsTable[] = {
{"mustard", 0, 0, GID_HEGAME, 6, 99, MDT_NONE, GF_USE_KEY | GF_HE_LOCALIZED, UNK, GUIO4(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT, GUIO_AUDIO_OVERRIDE)},
// Added the use of fonts
- {"FreddisFunShop", 0, 0, GID_FUNSHOP, 6, 99, MDT_NONE, GF_USE_KEY | GF_HE_LOCALIZED | GF_HE_995, UNK, GUIO4(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT, GUIO_AUDIO_OVERRIDE)},
- {"SamsFunShop", 0, 0, GID_FUNSHOP, 6, 99, MDT_NONE, GF_USE_KEY | GF_HE_LOCALIZED | GF_HE_995, UNK, GUIO4(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT, GUIO_AUDIO_OVERRIDE)},
- {"PuttsFunShop", 0, 0, GID_FUNSHOP, 6, 99, MDT_NONE, GF_USE_KEY | GF_HE_LOCALIZED | GF_HE_995, UNK, GUIO4(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT, GUIO_AUDIO_OVERRIDE)},
+ {"FreddisFunShop", 0, 0, GID_FUNSHOP, 6, 99, MDT_NONE, GF_USE_KEY | GF_HE_LOCALIZED, UNK, GUIO4(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT, GUIO_AUDIO_OVERRIDE)},
+ {"SamsFunShop", 0, 0, GID_FUNSHOP, 6, 99, MDT_NONE, GF_USE_KEY | GF_HE_LOCALIZED, UNK, GUIO4(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT, GUIO_AUDIO_OVERRIDE)},
+ {"PuttsFunShop", 0, 0, GID_FUNSHOP, 6, 99, MDT_NONE, GF_USE_KEY | GF_HE_LOCALIZED, UNK, GUIO4(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT, GUIO_AUDIO_OVERRIDE)},
// Added the use of smacker videos
- {"BluesTreasureHunt", 0, 0, GID_TREASUREHUNT, 6, 99, MDT_NONE, GF_HE_LOCALIZED | GF_USE_KEY | GF_HE_995 | GF_HE_995, UNK, GUIO4(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT, GUIO_AUDIO_OVERRIDE)},
+ {"BluesTreasureHunt", 0, 0, GID_TREASUREHUNT, 6, 99, MDT_NONE, GF_HE_LOCALIZED | GF_USE_KEY, UNK, GUIO4(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT, GUIO_AUDIO_OVERRIDE)},
// Added 16bit color
- {"arttime", 0, 0, GID_HEGAME, 6, 99, MDT_NONE, GF_USE_KEY | GF_HE_LOCALIZED | GF_16BIT_COLOR | GF_HE_995, UNK, GUIO4(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT, GUIO_AUDIO_OVERRIDE)},
- {"baseball2001", 0, 0, GID_BASEBALL2001, 6, 99, MDT_NONE, GF_USE_KEY | GF_16BIT_COLOR | GF_HE_995, UNK, GUIO5(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT, GUIO_AUDIO_OVERRIDE, GUIO_NETWORK)},
- {"readtime", 0, 0, GID_HEGAME, 6, 99, MDT_NONE, GF_USE_KEY | GF_HE_LOCALIZED | GF_16BIT_COLOR | GF_HE_995, UNK, GUIO4(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT, GUIO_AUDIO_OVERRIDE)},
- {"SoccerMLS", 0, 0, GID_SOCCERMLS, 6, 99, MDT_NONE, GF_USE_KEY | GF_HE_LOCALIZED | GF_16BIT_COLOR | GF_HE_995, UNK, GUIO4(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT, GUIO_AUDIO_OVERRIDE)},
+ {"arttime", 0, 0, GID_HEGAME, 6, 99, MDT_NONE, GF_USE_KEY | GF_HE_LOCALIZED | GF_16BIT_COLOR, UNK, GUIO4(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT, GUIO_AUDIO_OVERRIDE)},
+ {"baseball2001", 0, 0, GID_BASEBALL2001, 6, 99, MDT_NONE, GF_USE_KEY | GF_16BIT_COLOR, UNK, GUIO5(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT, GUIO_AUDIO_OVERRIDE, GUIO_NETWORK)},
+ {"readtime", 0, 0, GID_HEGAME, 6, 99, MDT_NONE, GF_USE_KEY | GF_HE_LOCALIZED | GF_16BIT_COLOR, UNK, GUIO4(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT, GUIO_AUDIO_OVERRIDE)},
+ {"SoccerMLS", 0, 0, GID_SOCCERMLS, 6, 99, MDT_NONE, GF_USE_KEY | GF_HE_LOCALIZED | GF_16BIT_COLOR, UNK, GUIO4(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT, GUIO_AUDIO_OVERRIDE)},
{"spyozon", 0, 0, GID_HEGAME, 6, 99, MDT_NONE, GF_USE_KEY | GF_HE_LOCALIZED | GF_16BIT_COLOR | GF_HE_995, UNK, GUIO4(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT, GUIO_AUDIO_OVERRIDE)},
{"freddicove", "", 0, GID_HEGAME, 6, 99, MDT_NONE, GF_USE_KEY | GF_HE_LOCALIZED | GF_16BIT_COLOR | GF_HE_995, UNK, GUIO4(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT, GUIO_AUDIO_OVERRIDE)},
Commit: 1b7836e6fa535cad766cc585e22fba700ccfa71d
https://github.com/scummvm/scummvm/commit/1b7836e6fa535cad766cc585e22fba700ccfa71d
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Fix palette remapping issues
Changed paths:
engines/scumm/he/intern_he.h
engines/scumm/he/palette_he.cpp
engines/scumm/he/sprite_he.cpp
engines/scumm/he/wiz_he.cpp
diff --git a/engines/scumm/he/intern_he.h b/engines/scumm/he/intern_he.h
index 3a1e14924af..35fc9a0d2b9 100644
--- a/engines/scumm/he/intern_he.h
+++ b/engines/scumm/he/intern_he.h
@@ -330,7 +330,7 @@ public:
void heQueueEraseAuxActor(ActorHE *a);
void heQueueAnimAuxFrame(int actorNum, int subIndex);
- void remapHEPalette(const uint8 *src, uint8 *dst);
+ void buildRemapTable(byte *remapTablePtr, const byte *palDPtr, const byte *palSPtr);
};
class ScummEngine_v72he : public ScummEngine_v71he {
diff --git a/engines/scumm/he/palette_he.cpp b/engines/scumm/he/palette_he.cpp
index b940a3b20dd..0b5abdedf31 100644
--- a/engines/scumm/he/palette_he.cpp
+++ b/engines/scumm/he/palette_he.cpp
@@ -30,42 +30,34 @@
namespace Scumm {
-void ScummEngine_v71he::remapHEPalette(const uint8 *src, uint8 *dst) {
- int r, g, b, sum, bestitem, bestsum;
- int ar, ag, ab;
- uint8 *palPtr;
- src += 30;
-
- if (_game.heversion >= 99) {
- palPtr = _hePalettes + _hePaletteSlot + 30;
- } else {
- palPtr = _currentPalette + 30;
- }
+void ScummEngine_v71he::buildRemapTable(byte *remapTablePtr, const byte *palDPtr, const byte *palSPtr) {
+ int closestIndex;
+ int32 closestDistance, distance;
- for (int j = 10; j < 246; j++) {
- bestitem = 0xFFFF;
- bestsum = 0xFFFF;
+ for (int outer = 10; outer < 246; outer++) {
+ remapTablePtr[outer] = outer;
- r = *src++;
- g = *src++;
- b = *src++;
-
- uint8 *curPal = palPtr;
+ closestIndex = -1;
+ closestDistance = ~0;
- for (int k = 10; k < 246; k++) {
- ar = r - *curPal++;
- ag = g - *curPal++;
- ab = b - *curPal++;
+ for (int inner = 10; inner < 246; inner++) {
+ const byte *clutSrcEntry = &palSPtr[outer * 3];
+ const byte *clutDstEntry = &palSPtr[inner * 3];
- sum = (ar * ar) + (ag * ag) + (ab * ab);
+ distance = (
+ (int32)((clutSrcEntry[0] - clutDstEntry[0]) * (clutSrcEntry[0] - clutDstEntry[0])) +
+ (int32)((clutSrcEntry[1] - clutDstEntry[1]) * (clutSrcEntry[1] - clutDstEntry[1])) +
+ (int32)((clutSrcEntry[2] - clutDstEntry[2]) * (clutSrcEntry[2] - clutDstEntry[2])));
- if (bestitem == 0xFFFF || sum <= bestsum) {
- bestitem = k;
- bestsum = sum;
+ if ((closestIndex == -1) || (distance <= closestDistance)) {
+ closestIndex = inner;
+ closestDistance = distance;
}
}
- dst[j] = bestitem;
+ if (closestIndex != -1) {
+ remapTablePtr[outer] = closestIndex;
+ }
}
}
diff --git a/engines/scumm/he/sprite_he.cpp b/engines/scumm/he/sprite_he.cpp
index 326aa7b881c..139ddb3d462 100644
--- a/engines/scumm/he/sprite_he.cpp
+++ b/engines/scumm/he/sprite_he.cpp
@@ -1546,7 +1546,8 @@ void Sprite::runSpriteEngines() {
}
// Handle animation...
- if ((flags = spritePtr[i]->flags) & kSFAutoAnimate) {
+ flags = spritePtr[i]->flags;
+ if (flags & kSFAutoAnimate) {
// Check to see if the speed is set!
if (_vm->_game.heversion >= 95) {
if (spritePtr[i]->animSpeed) {
diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp
index b776c92c68d..255c2c832b7 100644
--- a/engines/scumm/he/wiz_he.cpp
+++ b/engines/scumm/he/wiz_he.cpp
@@ -268,7 +268,14 @@ void *Wiz::drawAWizPrimEx(int globNum, int state, int x, int y, int z, int shado
if (!src_p)
error("Wiz::drawAWizPrimEx(): %d state %d missing palette block", globNum, state);
- _vm->remapHEPalette(src_p, remap_p + _vm->_resourceHeaderSize + 4);
+ const byte *palPtr = nullptr;
+ if (_vm->_game.heversion >= 99) {
+ palPtr = _vm->_hePalettes + _vm->_hePaletteSlot;
+ } else {
+ palPtr = _vm->_currentPalette;
+ }
+
+ _vm->buildRemapTable(remap_p + _vm->_resourceHeaderSize + 4, palPtr, src_p + _vm->_resourceHeaderSize);
}
}
}
Commit: f5714eaefdc9b70f3920c74166732eb4d9456cf6
https://github.com/scummvm/scummvm/commit/f5714eaefdc9b70f3920c74166732eb4d9456cf6
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Fix cursor wrong colors
Changed paths:
engines/scumm/he/script_v100he.cpp
engines/scumm/he/script_v80he.cpp
engines/scumm/he/wiz_he.cpp
engines/scumm/he/wiz_he.h
diff --git a/engines/scumm/he/script_v100he.cpp b/engines/scumm/he/script_v100he.cpp
index 65bd95160c0..b285a761815 100644
--- a/engines/scumm/he/script_v100he.cpp
+++ b/engines/scumm/he/script_v100he.cpp
@@ -2221,14 +2221,17 @@ void ScummEngine_v100he::o100_cursorCommand() {
_charsetColorMap[i] = _charsetData[_string[1]._default.charset][i] = (unsigned char)args[i];
break;
case SO_CURSOR_IMAGE:
+ a = pop();
+ _wiz->loadWizCursor(a, 0, false);
+ break;
case SO_CURSOR_COLOR_IMAGE:
a = pop();
- _wiz->loadWizCursor(a, 0);
+ _wiz->loadWizCursor(a, 0, true);
break;
case SO_CURSOR_COLOR_PAL_IMAGE:
b = pop();
a = pop();
- _wiz->loadWizCursor(a, b);
+ _wiz->loadWizCursor(a, b, true);
break;
case SO_CURSOR_ON: // Turn cursor on
_cursor.state = 1;
diff --git a/engines/scumm/he/script_v80he.cpp b/engines/scumm/he/script_v80he.cpp
index 4e52ff22cfd..b7fde47d14c 100644
--- a/engines/scumm/he/script_v80he.cpp
+++ b/engines/scumm/he/script_v80he.cpp
@@ -266,14 +266,17 @@ void ScummEngine_v80he::o80_cursorCommand() {
switch (subOp) {
case SO_CURSOR_IMAGE:
+ a = pop();
+ _wiz->loadWizCursor(a, 0, false);
+ break;
case SO_CURSOR_COLOR_IMAGE:
a = pop();
- _wiz->loadWizCursor(a, 0);
+ _wiz->loadWizCursor(a, 0, true);
break;
case SO_BUTTON:
b = pop();
a = pop();
- _wiz->loadWizCursor(a, b);
+ _wiz->loadWizCursor(a, b, true);
break;
case SO_CURSOR_ON: // Turn cursor on
_cursor.state = 1;
diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp
index 255c2c832b7..37c58405c1b 100644
--- a/engines/scumm/he/wiz_he.cpp
+++ b/engines/scumm/he/wiz_he.cpp
@@ -38,7 +38,6 @@ Wiz::Wiz(ScummEngine_v71he *vm) : _vm(vm) {
_wizBufferIndex = 0;
memset(&_wizBuffer, 0, sizeof(_wizBuffer));
memset(&_polygons, 0, sizeof(_polygons));
- _cursorImage = false;
_useWizClipRect = false;
_uses16BitColor = (_vm->_game.features & GF_16BIT_COLOR);
}
@@ -1140,7 +1139,7 @@ void Wiz::flushAWizBuffer() {
_wizBufferIndex = 0;
}
-void Wiz::loadWizCursor(int resId, int palette) {
+void Wiz::loadWizCursor(int resId, int palette, bool useColor) {
int32 x, y;
getWizSpot(resId, 0, x, y);
@@ -1157,14 +1156,27 @@ void Wiz::loadWizCursor(int resId, int palette) {
y = 32;
}
- const Common::Rect *r = nullptr;
- _cursorImage = true;
- // TODO
- uint8 *cursor = (uint8 *)drawAWizPrim(resId, 0, 0, 0, 0, 0, 0, r, kWRFAlloc, 0, (WizRawPixel *)_vm->getHEPaletteSlot(palette));
- _cursorImage = false;
+ WizRawPixel *colorConversionTable = nullptr;
+
+ if (palette != 0)
+ colorConversionTable = (WizRawPixel *) _vm->getHEPaletteSlot(palette);
+
+ byte *cursor = (byte *)drawAWizPrim(resId, 0, 0, 0, 0, 0, 0, nullptr, kWRFAlloc, nullptr, colorConversionTable);
int32 cw, ch;
getWizImageDim(resId, 0, cw, ch);
+
+ // Hello! This is a hack :-D
+ // In the original code, when useColor is false, the engine
+ // instructs the OS to set the cursor to black and white only.
+ // We obtain the same effect doing it like this...
+ if (!useColor && _vm->_bytesPerPixel == 1) {
+ for (int i = 0; i < ch * cw; i++) {
+ if (cursor[i] != 0 && cursor[i] != 5)
+ cursor[i] = 15;
+ }
+ }
+
_vm->setCursorHotspot(x, y);
_vm->setCursorFromBuffer(cursor, cw, ch, cw * _vm->_bytesPerPixel);
diff --git a/engines/scumm/he/wiz_he.h b/engines/scumm/he/wiz_he.h
index a0d65751778..27a3a19f1d0 100644
--- a/engines/scumm/he/wiz_he.h
+++ b/engines/scumm/he/wiz_he.h
@@ -519,7 +519,6 @@ public:
void clearWizBuffer();
Common::Rect _wizClipRect;
- bool _cursorImage;
bool _useWizClipRect = false;
bool _uses16BitColor = false;
int _wizActiveShadow = 0;
@@ -590,7 +589,7 @@ public:
void getWizSpot(int resId, int state, int32 &x, int32 &y);
void getWizSpot(int resId, int32 &x, int32 &y); // HE80
void getWizImageSpot(uint8 *data, int state, int32 &x, int32 &y);
- void loadWizCursor(int resId, int palette);
+ void loadWizCursor(int resId, int palette, bool useColor);
void takeAWiz(int globnum, int x1, int y1, int x2, int y2, bool back, bool compress);
void simpleDrawAWiz(int image, int state, int x, int y, int flags);
Commit: 65e391dceffb79d4239858fd139e9dc98d4e1dc8
https://github.com/scummvm/scummvm/commit/65e391dceffb79d4239858fd139e9dc98d4e1dc8
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Remove useless casts
Changed paths:
engines/scumm/he/wiz_he.cpp
diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp
index 37c58405c1b..cee834308cd 100644
--- a/engines/scumm/he/wiz_he.cpp
+++ b/engines/scumm/he/wiz_he.cpp
@@ -238,13 +238,13 @@ void *Wiz::drawAWizPrimEx(int globNum, int state, int x, int y, int z, int shado
}
// Get the data block for this "state"
- src_d = (byte *)getWizStateDataPrim(globNum, state);
+ src_d = getWizStateDataPrim(globNum, state);
if (!src_d)
error("Wiz::drawAWizPrimEx(): %d state %d missing data block", globNum, state);
// Copy the palette from this "state"?
if (flags & kWRFUsePalette) {
- src_p = (byte *)getWizStatePaletteDataPrim(globNum, state);
+ src_p = getWizStatePaletteDataPrim(globNum, state);
if (!src_p)
error("Wiz::drawAWizPrimEx(): %d state %d missing palette block", globNum, state);
@@ -253,7 +253,7 @@ void *Wiz::drawAWizPrimEx(int globNum, int state, int x, int y, int z, int shado
// Remap this wiz "state"?
if (flags & kWRFRemap) {
- remap_p = (byte *)getWizStateRemapDataPrim(globNum, state);
+ remap_p = getWizStateRemapDataPrim(globNum, state);
if (!remap_p)
error("Wiz::drawAWizPrimEx(): %d state %d is missing a remap palette block", globNum, state);
@@ -263,7 +263,7 @@ void *Wiz::drawAWizPrimEx(int globNum, int state, int x, int y, int z, int shado
if (remapID != _vm->_paletteChangedCounter) {
WRITE_LE_UINT32(remap_p + _vm->_resourceHeaderSize, _vm->_paletteChangedCounter);
- src_p = (byte *)getWizStatePaletteDataPrim(globNum, state);
+ src_p = getWizStatePaletteDataPrim(globNum, state);
if (!src_p)
error("Wiz::drawAWizPrimEx(): %d state %d missing palette block", globNum, state);
Commit: a136275a92e5d92d2dfa080925298357dc60d2af
https://github.com/scummvm/scummvm/commit/a136275a92e5d92d2dfa080925298357dc60d2af
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Fix some Spy Fox 1 (HE90) issues
Changed paths:
engines/scumm/charset.cpp
engines/scumm/gfx.cpp
engines/scumm/he/script_v100he.cpp
engines/scumm/he/sprite_he.cpp
diff --git a/engines/scumm/charset.cpp b/engines/scumm/charset.cpp
index a9623b584fe..a432210f2ab 100644
--- a/engines/scumm/charset.cpp
+++ b/engines/scumm/charset.cpp
@@ -1198,13 +1198,12 @@ void CharsetRendererClassic::printChar(int chr, bool ignoreCharsetMask) {
}
void CharsetRendererClassic::printCharIntern(bool is2byte, const byte *charPtr, int origWidth, int origHeight, int width, int height, VirtScreen *vs, bool ignoreCharsetMask) {
- byte *dstPtr;
+ byte *dstPtr = nullptr;
byte *back = nullptr;
int drawTop = _top - vs->topline;
if ((_vm->_game.heversion >= 71 && _bitsPerPixel >= 8) || (_vm->_game.heversion >= 90 && _bitsPerPixel == 0)) {
#ifdef ENABLE_HE
- // TODO: FIX ZPLANE
if (ignoreCharsetMask || !vs->hasTwoBuffers) {
dstPtr = vs->getPixels(0, 0);
} else {
@@ -1246,17 +1245,6 @@ void CharsetRendererClassic::printCharIntern(bool is2byte, const byte *charPtr,
charPtr, _left, drawTop, origWidth, origHeight,
colorLookupTable);
}
-
- if (_vm->_game.heversion >= 80) {
- if ((vs->number == kMainVirtScreen && !_blitAlso) || _vm->_game.heversion <= 90) {
- ((ScummEngine_v71he *)_vm)->_wiz->auxDrawZplaneFromTRLEImage(
- dstPtr, charPtr,
- _vm->_textSurface.w, _vm->_textSurface.h,
- _left, drawTop, origWidth, origHeight,
- nullptr, kWZOIgnore, kWZOSet);
- }
- }
-
#endif
} else {
Graphics::Surface dstSurface;
diff --git a/engines/scumm/gfx.cpp b/engines/scumm/gfx.cpp
index b1d128b12ea..016bf2bf1cd 100644
--- a/engines/scumm/gfx.cpp
+++ b/engines/scumm/gfx.cpp
@@ -2492,7 +2492,10 @@ void Gdi::drawBMAPBg(const byte *ptr, VirtScreen *vs) {
break;
case BMCOMP_SOLID_COLOR_FILL:
{
- WizRawPixel color = ((ScummEngine_v71he *)_vm)->_wiz->convert8BppToRawPixel(*bmapPtr, (WizRawPixel *)_vm->getHEPaletteSlot(1));
+ WizRawPixel color = (WizRawPixel)(*bmapPtr);
+
+ if (_vm->_game.heversion > 90)
+ color = ((ScummEngine_v71he *)_vm)->_wiz->convert8BppToRawPixel(*bmapPtr, (WizRawPixel *)_vm->getHEPaletteSlot(1));
if (_vm->_game.heversion > 99 && _vm->VAR_COLOR_BLACK != 0xFF && _vm->VAR(_vm->VAR_COLOR_BLACK) == color)
break;
diff --git a/engines/scumm/he/script_v100he.cpp b/engines/scumm/he/script_v100he.cpp
index b285a761815..3bbcedc58d5 100644
--- a/engines/scumm/he/script_v100he.cpp
+++ b/engines/scumm/he/script_v100he.cpp
@@ -2506,8 +2506,6 @@ void ScummEngine_v100he::o100_getSpriteGroupInfo() {
byte subOp = fetchScriptByte();
- warning("o100_getSpriteGroupInfo, subop %d", subOp);
-
switch (subOp) {
case SO_ARRAY:
spriteGroupId = pop();
diff --git a/engines/scumm/he/sprite_he.cpp b/engines/scumm/he/sprite_he.cpp
index 139ddb3d462..e5dfc236234 100644
--- a/engines/scumm/he/sprite_he.cpp
+++ b/engines/scumm/he/sprite_he.cpp
@@ -1594,17 +1594,18 @@ void Sprite::runSpriteEngines() {
}
}
-static int compareSpritePriority(const void *a, const void *b) {
+static int compareSpriteCombinedPriority(const void *a, const void *b) {
const SpriteInfo *spr1 = *(const SpriteInfo *const*)a;
const SpriteInfo *spr2 = *(const SpriteInfo *const*)b;
- if (spr1->combinedPriority > spr2->combinedPriority)
- return 1;
+ return spr1->combinedPriority - spr2->combinedPriority;
+}
- if (spr1->combinedPriority < spr2->combinedPriority)
- return -1;
+static int compareSpritePriority(const void *a, const void *b) {
+ const SpriteInfo *spr1 = *(const SpriteInfo *const *)a;
+ const SpriteInfo *spr2 = *(const SpriteInfo *const *)b;
- return 0;
+ return spr1->priority - spr2->priority;
}
void Sprite::buildActiveSpriteList() {
@@ -1639,7 +1640,11 @@ void Sprite::buildActiveSpriteList() {
// Sort the list of active sprites...
if (_activeSpriteCount) {
- qsort(_activeSprites, _activeSpriteCount, sizeof(SpriteInfo *), compareSpritePriority);
+ if (_vm->_game.heversion >= 95) {
+ qsort(_activeSprites, _activeSpriteCount, sizeof(SpriteInfo *), compareSpriteCombinedPriority);
+ } else {
+ qsort(_activeSprites, _activeSpriteCount, sizeof(SpriteInfo *), compareSpritePriority);
+ }
}
}
@@ -1760,9 +1765,11 @@ void Sprite::renderSprites(bool negativeOrPositiveRender) {
renderFlags |= kWRFVFlip;
}
- if (flags & kSFBackgroundRender) {
- renderFlags &= ~kWRFForeground;
- renderFlags |= kWRFBackground;
+ if (_vm->_game.heversion >= 95) {
+ if (flags & kSFBackgroundRender) {
+ renderFlags &= ~kWRFForeground;
+ renderFlags |= kWRFBackground;
+ }
}
if (_vm->_game.heversion > 98) {
@@ -1775,9 +1782,11 @@ void Sprite::renderSprites(bool negativeOrPositiveRender) {
}
}
- // Check to see if the sprite is supposed to remap...
- if (flags & kSFUseImageRemap) {
- renderFlags |= kWRFRemap;
+ if (_vm->_game.heversion >= 95) {
+ // Check to see if the sprite is supposed to remap...
+ if (flags & kSFUseImageRemap) {
+ renderFlags |= kWRFRemap;
+ }
}
if (_vm->_game.heversion > 98) {
@@ -1829,16 +1838,19 @@ void Sprite::renderSprites(bool negativeOrPositiveRender) {
// Check for complex image draw mode...
simpleDraw = true;
- if (angle = spritePtr[i]->angle) {
+ angle = spritePtr[i]->angle;
+ scale = spritePtr[i]->scale;
+
+ if (angle != 0) {
simpleDraw = false;
}
- if (scale = spritePtr[i]->scale) {
+ if (scale != 0) {
simpleDraw = false;
}
}
- simpleDraw = _vm->_game.heversion == 95 ? true : simpleDraw;
+ simpleDraw = _vm->_game.heversion <= 95 ? true : simpleDraw;
// Check to see if the group has a clipping rect.
group = spritePtr[i]->group;
@@ -1920,7 +1932,11 @@ void Sprite::renderSprites(bool negativeOrPositiveRender) {
renderFlags |= kWRFUseShadow;
}
- WizSimpleBitmap *bitmapPtr = getSimpleBitmapForSprite(spritePtr[i]);
+ WizSimpleBitmap *bitmapPtr = nullptr;
+
+ if (_vm->_game.heversion >= 95) {
+ bitmapPtr = getSimpleBitmapForSprite(spritePtr[i]);
+ }
if (simpleDraw) {
_vm->_wiz->drawAWizPrim(image, state, spot.x, spot.y, 0, shadow, 0, clipRectPtr, renderFlags, bitmapPtr, nullptr);
Commit: d632a18996d2cc68f0c57aafcb61127726e9928d
https://github.com/scummvm/scummvm/commit/d632a18996d2cc68f0c57aafcb61127726e9928d
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Fix some mem leaks
Changed paths:
engines/scumm/he/sprite_he.cpp
diff --git a/engines/scumm/he/sprite_he.cpp b/engines/scumm/he/sprite_he.cpp
index e5dfc236234..799c5777430 100644
--- a/engines/scumm/he/sprite_he.cpp
+++ b/engines/scumm/he/sprite_he.cpp
@@ -47,6 +47,8 @@ Sprite::~Sprite() {
free(_groupTable);
free(_spriteTable);
free(_activeSprites);
+ free(_imageLists);
+ free(_imageListStack);
}
void ScummEngine_v90he::allocateArrays() {
Commit: 35939dd19df5f392527e9f0611319dfc29752dce
https://github.com/scummvm/scummvm/commit/35939dd19df5f392527e9f0611319dfc29752dce
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Fix warnings
Changed paths:
engines/scumm/actor.cpp
engines/scumm/akos.cpp
engines/scumm/he/gfx_comp/aux_comp.cpp
engines/scumm/he/gfx_comp/mrle_comp.cpp
engines/scumm/he/gfx_comp/trle_comp.cpp
engines/scumm/he/gfx_primitives_he.cpp
engines/scumm/he/script_v100he.cpp
engines/scumm/he/sprite_he.cpp
engines/scumm/he/wiz_he.cpp
engines/scumm/he/wiz_he.h
engines/scumm/he/wizwarp_he.cpp
diff --git a/engines/scumm/actor.cpp b/engines/scumm/actor.cpp
index c0b0e41d924..c5c60c2255f 100644
--- a/engines/scumm/actor.cpp
+++ b/engines/scumm/actor.cpp
@@ -3557,7 +3557,6 @@ void ScummEngine_v71he::heFlushAuxQueues() {
byte *foregroundBufferPtr;
byte *backgroundBufferPtr;
const byte *auxEraseRectPtr;
- bool drewSomething;
VirtScreen *pvs = &_virtscr[kMainVirtScreen];
if (_disableActorDrawingFlag) {
@@ -3601,8 +3600,6 @@ void ScummEngine_v71he::heFlushAuxQueues() {
auxFrameDataPtr += _resourceHeaderSize;
type = READ_LE_UINT16(auxFrameDataPtr);
- drewSomething = false;
-
if ((type == AKOS_AUXD_TYPE_DRLE_FRAME) || (type == AKOS_AUXD_TYPE_SRLE_FRAME)) {
x = xOffset + (int16)READ_LE_UINT16(auxFrameDataPtr + 2);
y = yOffset + (int16)READ_LE_UINT16(auxFrameDataPtr + 4);
@@ -3624,8 +3621,6 @@ void ScummEngine_v71he::heFlushAuxQueues() {
} else {
error("Unimplemented compression type actor %d!", whichActor);
}
-
- drewSomething = true;
}
// Add any update rects to the list for the final blit(s)
@@ -3676,14 +3671,12 @@ void ScummEngine_v90he::heFlushAuxQueues() {
int x, y, w, h, type, whichActor;
int updateRects, xOffset, yOffset;
- byte *costumeAddress;
const byte *auxFrameDataPtr;
const byte *auxUpdateRectPtr;
WizRawPixel *foregroundBufferPtr;
WizRawPixel *backgroundBufferPtr;
const byte *auxEraseRectPtr;
const byte *colorTablePtr;
- bool drewSomething;
HEAnimAuxData auxInfo;
int actorBits;
const WizRawPixel *conversionTablePtr;
@@ -3710,8 +3703,6 @@ void ScummEngine_v90he::heFlushAuxQueues() {
conversionTablePtr = (WizRawPixel *)getHEPaletteSlot(1);
}
- costumeAddress = getResourceAddress(rtCostume, a->_costume);
-
xOffset = a->_heOffsX + a->getPos().x - pvs->xstart;
yOffset = a->_heOffsY + a->getPos().y;
@@ -3732,8 +3723,6 @@ void ScummEngine_v90he::heFlushAuxQueues() {
auxFrameDataPtr += _resourceHeaderSize;
type = READ_LE_UINT16(auxFrameDataPtr);
- drewSomething = false;
-
if ((type == AKOS_AUXD_TYPE_DRLE_FRAME) ||
(type == AKOS_AUXD_TYPE_SRLE_FRAME) ||
(type == AKOS_AUXD_TYPE_WRLE_FRAME)) {
@@ -3790,8 +3779,6 @@ void ScummEngine_v90he::heFlushAuxQueues() {
} else {
error("heFlushAuxQueue(): Unimplemented compression type actor %d!", whichActor);
}
-
- drewSomething = true;
}
// Add any update rects to the list for the final blit(s)
@@ -3813,14 +3800,6 @@ void ScummEngine_v90he::heFlushAuxQueues() {
yOffset + (int16)READ_LE_UINT16(auxUpdateRectPtr + 6),
actorBits);
- // TODO: Is this really needed?
- //setActorUpdateArea(
- // whichActor,
- // xOffset + (int16)READ_LE_UINT16(auxUpdateRectPtr + 0),
- // yOffset + (int16)READ_LE_UINT16(auxUpdateRectPtr + 2),
- // xOffset + (int16)READ_LE_UINT16(auxUpdateRectPtr + 4),
- // yOffset + (int16)READ_LE_UINT16(auxUpdateRectPtr + 6));
-
auxUpdateRectPtr += 8;
}
diff --git a/engines/scumm/akos.cpp b/engines/scumm/akos.cpp
index 18a17ad6d3c..9e2f4e93fb7 100644
--- a/engines/scumm/akos.cpp
+++ b/engines/scumm/akos.cpp
@@ -1316,13 +1316,13 @@ byte AkosRenderer::paintCelTRLE(int actor, int drawToBack, int celX, int celY, i
return hePaintCel(
actor, drawToBack, celX, celY, celWidth, celHeight, tcolor, false, nullptr,
heTRLEPaintPrim,
- (WizRawPixel *)palPtr,
+ (const WizRawPixel *)palPtr,
specialRenderFlags);
} else {
return hePaintCel(
actor, drawToBack, celX, celY, celWidth, celHeight, tcolor, false, shadowTablePtr,
heTRLEPaintPrimShadow,
- (WizRawPixel *)palPtr,
+ (const WizRawPixel *)palPtr,
specialRenderFlags);
}
#endif
diff --git a/engines/scumm/he/gfx_comp/aux_comp.cpp b/engines/scumm/he/gfx_comp/aux_comp.cpp
index 9ea9975effe..987fed92ff8 100644
--- a/engines/scumm/he/gfx_comp/aux_comp.cpp
+++ b/engines/scumm/he/gfx_comp/aux_comp.cpp
@@ -132,7 +132,7 @@ void Wiz::auxWRLEUncompressPixelStream(WizRawPixel *destStream, const byte *sing
streamSize -= runCount;
- memset8BppConversion(destStream, *((byte *)streamData), runCount, conversionTable);
+ memset8BppConversion(destStream, *streamData, runCount, conversionTable);
streamData += sizeof(byte);
@@ -222,7 +222,7 @@ void Wiz::auxWRLEUncompressAndCopyFromStreamOffset(WizRawPixel *destStream, cons
streamSize -= runCount;
- color = *((byte *)streamData);
+ color = *streamData;
if (color != copyFromColor) {
memset8BppConversion(destStream, color, runCount, conversionTable);
@@ -252,7 +252,8 @@ void Wiz::auxWRLEUncompressAndCopyFromStreamOffset(WizRawPixel *destStream, cons
if (color != copyFromColor) {
*dest8++ = (WizRawPixel8)convert8BppToRawPixel(color, conversionTable);
} else {
- *dest8++ = *(dest8 + streamOffset);
+ *dest8 = *(dest8 + streamOffset);
+ dest8++;
}
destStream = (WizRawPixel *)dest8;
@@ -260,7 +261,8 @@ void Wiz::auxWRLEUncompressAndCopyFromStreamOffset(WizRawPixel *destStream, cons
if (color != copyFromColor) {
*dest16++ = (WizRawPixel16)convert8BppToRawPixel(color, conversionTable);
} else {
- *dest16++ = *(dest16 + streamOffset);
+ *dest16 = *(dest16 + streamOffset);
+ dest16++;
}
destStream = (WizRawPixel *)dest16;
@@ -275,8 +277,8 @@ void Wiz::auxDecompSRLEStream(WizRawPixel *destStream, const WizRawPixel *backgr
int value, runCount;
WizRawPixel8 *dest8 = (WizRawPixel8 *)destStream;
WizRawPixel16 *dest16 = (WizRawPixel16 *)destStream;
- WizRawPixel8 *background8 = (WizRawPixel8 *)backgroundStream;
- WizRawPixel16 *background16 = (WizRawPixel16 *)backgroundStream;
+ const WizRawPixel8 *background8 = (const WizRawPixel8 *)backgroundStream;
+ const WizRawPixel16 *background16 = (const WizRawPixel16 *)backgroundStream;
while (streamSize > 0) {
value = *streamData++;
@@ -295,13 +297,13 @@ void Wiz::auxDecompSRLEStream(WizRawPixel *destStream, const WizRawPixel *backgr
background8 += runCount;
dest8 += runCount;
- backgroundStream = (WizRawPixel *)background8;
+ backgroundStream = (const WizRawPixel *)background8;
destStream = (WizRawPixel *)dest8;
} else {
background16 += runCount;
dest16 += runCount;
- backgroundStream = (WizRawPixel *)background16;
+ backgroundStream = (const WizRawPixel *)background16;
destStream = (WizRawPixel *)dest16;
}
@@ -315,14 +317,14 @@ void Wiz::auxDecompSRLEStream(WizRawPixel *destStream, const WizRawPixel *backgr
background8 += runCount;
dest8 += runCount;
- backgroundStream = (WizRawPixel *)background8;
+ backgroundStream = (const WizRawPixel *)background8;
destStream = (WizRawPixel *)dest8;
} else {
memcpy(dest16, background16, runCount * sizeof(WizRawPixel16));
background16 += runCount;
dest16 += runCount;
- backgroundStream = (WizRawPixel *)background16;
+ backgroundStream = (const WizRawPixel *)background16;
destStream = (WizRawPixel *)dest16;
}
@@ -345,13 +347,13 @@ void Wiz::auxDecompSRLEStream(WizRawPixel *destStream, const WizRawPixel *backgr
background8 += runCount;
dest8 += runCount;
- backgroundStream = (WizRawPixel *)background8;
+ backgroundStream = (const WizRawPixel *)background8;
destStream = (WizRawPixel *)dest8;
} else {
background16 += runCount;
dest16 += runCount;
- backgroundStream = (WizRawPixel *)background16;
+ backgroundStream = (const WizRawPixel *)background16;
destStream = (WizRawPixel *)dest16;
}
@@ -362,13 +364,13 @@ void Wiz::auxDecompSRLEStream(WizRawPixel *destStream, const WizRawPixel *backgr
background8++;
destStream = (WizRawPixel *)dest8;
- backgroundStream = (WizRawPixel *)background8;
+ backgroundStream = (const WizRawPixel *)background8;
} else {
*dest16++ = (WizRawPixel16)convert8BppToRawPixel(*(singleColorTable + (value >> 3)), conversionTable);
background16++;
destStream = (WizRawPixel *)dest16;
- backgroundStream = (WizRawPixel *)background16;
+ backgroundStream = (const WizRawPixel *)background16;
}
streamSize--;
@@ -432,7 +434,7 @@ void Wiz::auxDecompDRLEImage(WizRawPixel *foregroundBufferPtr, WizRawPixel *back
}
void Wiz::auxDecompDRLEPrim(WizRawPixel *foregroundBufferPtr, WizRawPixel *backgroundBufferPtr, int bufferWidth, Common::Rect *destRect, const byte *compData, Common::Rect *sourceRect, const WizRawPixel *conversionTable) {
- int decompWidth, decompHeight, counter, sX1, dX1, dX2, lineSize;
+ int decompWidth, decompHeight, counter, sX1, dX1, lineSize;
WizRawPixel8 *foregroundBuffer8 = (WizRawPixel8 *)foregroundBufferPtr;
WizRawPixel16 *foregroundBuffer16 = (WizRawPixel16 *)foregroundBufferPtr;
WizRawPixel8 *backgroundBuffer8 = (WizRawPixel8 *)backgroundBufferPtr;
@@ -441,7 +443,7 @@ void Wiz::auxDecompDRLEPrim(WizRawPixel *foregroundBufferPtr, WizRawPixel *backg
// General setup...
sX1 = sourceRect->left;
dX1 = destRect->left;
- dX2 = destRect->right;
+
decompWidth = sourceRect->right - sourceRect->left + 1;
decompHeight = sourceRect->bottom - sourceRect->top + 1;
@@ -551,14 +553,14 @@ void Wiz::auxDecompTRLEImage(WizRawPixel *bufferPtr, const byte *compData, int b
}
void Wiz::auxDecompTRLEPrim(WizRawPixel *bufferPtr, int bufferWidth, Common::Rect *destRect, const byte *compData, Common::Rect *sourceRect, const WizRawPixel *conversionTable) {
- int decompWidth, decompHeight, counter, sX1, dX1, dX2, lineSize;
+ int decompWidth, decompHeight, counter, sX1, dX1, lineSize;
WizRawPixel8 *buffer8 = (WizRawPixel8 *)bufferPtr;
WizRawPixel16 *buffer16 = (WizRawPixel16 *)bufferPtr;
// General setup...
sX1 = sourceRect->left;
dX1 = destRect->left;
- dX2 = destRect->right;
+
decompWidth = sourceRect->right - sourceRect->left + 1;
decompHeight = sourceRect->bottom - sourceRect->top + 1;
@@ -658,12 +660,12 @@ void Wiz::auxDrawZplaneFromTRLEImage(byte *zplanePtr, const byte *compData, int
}
void Wiz::auxDrawZplaneFromTRLEPrim(byte *zplanePtr, int zplanePixelWidth, Common::Rect *destRect, const byte *compData, Common::Rect *sourceRect, int transOp, int solidOp) {
- int decompWidth, decompHeight, counter, sX1, dX1, dX2, lineSize, mask, zplaneWidth;
+ int decompWidth, decompHeight, counter, sX1, dX1, lineSize, mask, zplaneWidth;
// General setup...
sX1 = sourceRect->left;
dX1 = destRect->left;
- dX2 = destRect->right;
+
decompWidth = sourceRect->right - sourceRect->left + 1;
decompHeight = sourceRect->bottom - sourceRect->top + 1;
@@ -752,14 +754,14 @@ void Wiz::auxDecompRemappedTRLEImage(WizRawPixel *bufferPtr, const byte *compDat
}
void Wiz::auxDecompRemappedTRLEPrim(WizRawPixel *bufferPtr, int bufferWidth, Common::Rect *destRect, const byte *compData, Common::Rect *sourceRect, byte *remapTable, const WizRawPixel *conversionTable) {
- int decompWidth, decompHeight, sX1, dX1, dX2, lineSize;
+ int decompWidth, decompHeight, sX1, dX1, lineSize;
WizRawPixel8 *buffer8 = (WizRawPixel8 *)bufferPtr;
WizRawPixel16 *buffer16 = (WizRawPixel16 *)bufferPtr;
// General setup...
sX1 = sourceRect->left;
dX1 = destRect->left;
- dX2 = destRect->right;
+
decompWidth = sourceRect->right - sourceRect->left + 1;
decompHeight = sourceRect->bottom - sourceRect->top + 1;
@@ -936,7 +938,7 @@ int Wiz::auxPixelHitTestTRLEImageRelPos(byte *compData, int x, int y, int width,
}
}
-void Wiz::auxDecompMixColorsTRLEImage(WizRawPixel *bufferPtr, byte *compData, int bufferWidth, int bufferHeight, int x, int y, int width, int height, Common::Rect *clipRectPtr, byte *coloMixTable, const WizRawPixel *conversionTable) {
+void Wiz::auxDecompMixColorsTRLEImage(WizRawPixel *bufferPtr, byte *compData, int bufferWidth, int bufferHeight, int x, int y, int width, int height, Common::Rect *clipRectPtr, const byte *colorMixTable, const WizRawPixel *conversionTable) {
Common::Rect sourceRect, destRect, clipRect, workRect;
sourceRect.left = 0;
@@ -989,19 +991,19 @@ void Wiz::auxDecompMixColorsTRLEImage(WizRawPixel *bufferPtr, byte *compData, in
// Call the primitive image renderer...
auxDecompMixColorsTRLEPrim(
- bufferPtr, bufferWidth, &destRect, compData, &sourceRect, coloMixTable,
+ bufferPtr, bufferWidth, &destRect, compData, &sourceRect, colorMixTable,
conversionTable);
}
void Wiz::auxDecompMixColorsTRLEPrim(WizRawPixel *bufferPtr, int bufferWidth, Common::Rect *destRect, const byte *compData, Common::Rect *sourceRect, const byte *coloMixTable, const WizRawPixel *conversionTable) {
- int decompWidth, decompHeight, sX1, dX1, dX2, lineSize;
+ int decompWidth, decompHeight, sX1, dX1, lineSize;
WizRawPixel8 *buffer8 = (WizRawPixel8 *)bufferPtr;
WizRawPixel16 *buffer16 = (WizRawPixel16 *)bufferPtr;
// General setup...
sX1 = sourceRect->left;
dX1 = destRect->left;
- dX2 = destRect->right;
+
decompWidth = sourceRect->right - sourceRect->left + 1;
decompHeight = sourceRect->bottom - sourceRect->top + 1;
@@ -1561,7 +1563,8 @@ void Wiz::auxColorMixDecompressLine(WizRawPixel *destPtr, const byte *dataStream
remapTable = colorMixTable + ((*((const byte *)dataStream)) << 8);
dataStream++;
while (--runCount >= 0) {
- *dest8++ = *(remapTable + *dest8);
+ *dest8 = *(remapTable + *dest8);
+ dest8++;
}
} else {
@@ -1573,7 +1576,8 @@ void Wiz::auxColorMixDecompressLine(WizRawPixel *destPtr, const byte *dataStream
runCount += decompAmount;
}
while (--runCount >= 0) {
- *dest8++ = *(colorMixTable + ((*((const byte *)dataStream)) << 8) + *dest8);
+ *dest8 = *(colorMixTable + ((*((const byte *)dataStream)) << 8) + *dest8);
+ dest8++;
dataStream++;
}
}
diff --git a/engines/scumm/he/gfx_comp/mrle_comp.cpp b/engines/scumm/he/gfx_comp/mrle_comp.cpp
index a3fe800f33f..2f2681818aa 100644
--- a/engines/scumm/he/gfx_comp/mrle_comp.cpp
+++ b/engines/scumm/he/gfx_comp/mrle_comp.cpp
@@ -240,12 +240,12 @@ static void mrleFLIPAltSourceBackward8BppToXBpp(Wiz *wiz,
dest8 -= runCount;
src8 -= runCount;
destPtr = (WizRawPixel *)dest8;
- srcPtr = (WizRawPixel *)src8;
+ srcPtr = (const WizRawPixel *)src8;
} else {
dest16 -= runCount;
src16 -= runCount;
destPtr = (WizRawPixel *)dest16;
- srcPtr = (WizRawPixel *)src16;
+ srcPtr = (const WizRawPixel *)src16;
}
},
{
@@ -254,13 +254,13 @@ static void mrleFLIPAltSourceBackward8BppToXBpp(Wiz *wiz,
dest8 -= runCount;
src8 -= runCount;
destPtr = (WizRawPixel *)dest8;
- srcPtr = (WizRawPixel *)src8;
+ srcPtr = (const WizRawPixel *)src8;
} else {
wiz->memcpy8BppConversion(destPtr + 1, srcPtr + 1, runCount, conversionTable);
dest16 -= runCount;
src16 -= runCount;
destPtr = (WizRawPixel *)dest16;
- srcPtr = (WizRawPixel *)src16;
+ srcPtr = (const WizRawPixel *)src16;
}
}
);
@@ -296,7 +296,7 @@ static void mrleFLIPAltSourceDecompImageHull(Wiz *wiz,
}
for (counter = sourceRect->top; counter > 0; counter--) {
- compData += READ_LE_UINT16((byte *)compData) + 2;
+ compData += READ_LE_UINT16(compData) + 2;
}
// Calc the ALT buffer location
@@ -310,7 +310,7 @@ static void mrleFLIPAltSourceDecompImageHull(Wiz *wiz,
// Decompress all the lines that are visible!!!!
while (decompHeight-- > 0) {
- lineSize = READ_LE_UINT16((byte *)compData);
+ lineSize = READ_LE_UINT16(compData);
if (lineSize != 0) {
(*functionPtr)(wiz,
@@ -446,7 +446,7 @@ void Wiz::mrleFLIPAltSourceDecompressImage(
WizCompressedImage fakeImage;
// General setup
- fakeImage.data = (byte *)compData;
+ fakeImage.data = compData;
fakeImage.width = width;
fakeImage.height = height;
diff --git a/engines/scumm/he/gfx_comp/trle_comp.cpp b/engines/scumm/he/gfx_comp/trle_comp.cpp
index e684afd6bab..5236a0d5749 100644
--- a/engines/scumm/he/gfx_comp/trle_comp.cpp
+++ b/engines/scumm/he/gfx_comp/trle_comp.cpp
@@ -270,11 +270,11 @@ void trleFLIPVertFlipAlignWithRect(Common::Rect *rectToAlign, const Common::Rect
void Wiz::trleFLIPDecompImageHull(
WizRawPixel *bufferPtr, int bufferWidth, const Common::Rect *destRect,
- const byte *compData, const Common::Rect *sourceRect, const void *extraPtr,
+ const byte *compData, const Common::Rect *sourceRect, const byte *extraPtr,
const WizRawPixel *conversionTable,
void (*functionPtr)(Wiz *wiz,
WizRawPixel *destPtr, const byte *dataStream, int skipAmount,
- int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable)) {
+ int decompAmount, const byte *extraPtr, const WizRawPixel *conversionTable)) {
int decompWidth, decompHeight, counter, sX1, lineSize;
// General setup...
@@ -295,7 +295,7 @@ void Wiz::trleFLIPDecompImageHull(
}
for (counter = sourceRect->top; counter > 0; counter--) {
- compData += READ_LE_UINT16((byte *)compData) + 2;
+ compData += READ_LE_UINT16(compData) + 2;
}
// Flip the dest offset if vertical flipping...
@@ -305,7 +305,7 @@ void Wiz::trleFLIPDecompImageHull(
// Decompress all the lines that are visible!!!!
while (decompHeight-- > 0) {
- lineSize = READ_LE_UINT16((byte *)compData);
+ lineSize = READ_LE_UINT16(compData);
if (lineSize != 0) {
(*functionPtr)(this, bufferPtr, compData + 2, sX1, decompWidth, extraPtr, conversionTable);
@@ -328,22 +328,22 @@ void Wiz::trleFLIPDecompImageHull(
}
void Wiz::trleFLIPDecompressPrim(
- WizSimpleBitmap *bitmapPtr, const COMPRESSEDIMAGE *imagePtr, int destX, int destY,
- const Common::Rect *sourceCoords, const Common::Rect *clipRectPtr, const void *extraPtr,
+ WizSimpleBitmap *bitmapPtr, const WizCompressedImage *imagePtr, int destX, int destY,
+ const Common::Rect *sourceCoords, const Common::Rect *clipRectPtr, const byte *extraPtr,
int32 flags, const WizRawPixel *conversionTable,
void (*forewordFunctionPtr)(Wiz *wiz,
WizRawPixel *destPtr, const byte *dataStream, int skipAmount,
- int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable),
+ int decompAmount, const byte *extraPtr, const WizRawPixel *conversionTable),
void (*backwardFunctionPtr)(Wiz *wiz,
WizRawPixel *destPtr, const byte *dataStream, int skipAmount,
- int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable)) {
+ int decompAmount, const byte *extraPtr, const WizRawPixel *conversionTable)) {
Common::Rect sourceRect, destRect, clipRect, workRect, inSourceRect;
int width, height, bufferWidth, bufferHeight;
void (*functionPtr)(Wiz *wiz,
WizRawPixel * destPtr, const byte *dataStream, int skipAmount,
- int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable);
+ int decompAmount, const byte *extraPtr, const WizRawPixel *conversionTable);
bufferWidth = bitmapPtr->bitmapWidth;
bufferHeight = bitmapPtr->bitmapHeight;
@@ -434,11 +434,13 @@ void Wiz::trleFLIPFiftyFiftyMixPixelMemset(WizRawPixel *dstPtr, WizRawPixel mixC
while (size-- > 0) {
if (!_uses16BitColor) {
- *dst8++ = WIZRAWPIXEL_50_50_MIX(
+ *dst8 = WIZRAWPIXEL_50_50_MIX(
adjustedColor, WIZRAWPIXEL_50_50_PREMIX_COLOR(*dst8));
+ dst8++;
} else {
- *dst16++ = WIZRAWPIXEL_50_50_MIX(
+ *dst16 = WIZRAWPIXEL_50_50_MIX(
adjustedColor, WIZRAWPIXEL_50_50_PREMIX_COLOR(*dst16));
+ dst16++;
}
}
}
@@ -450,14 +452,16 @@ void Wiz::trleFLIPFiftyFiftyMixForwardPixelCopy(WizRawPixel *dstPtr, const byte
while (size-- > 0) {
if (!_uses16BitColor) {
WizRawPixel srcColor = convert8BppToRawPixel(*srcPtr++, conversionTable);
- *dst8++ = WIZRAWPIXEL_50_50_MIX(
+ *dst8 = WIZRAWPIXEL_50_50_MIX(
WIZRAWPIXEL_50_50_PREMIX_COLOR(srcColor),
WIZRAWPIXEL_50_50_PREMIX_COLOR(*dst8));
+ dst8++;
} else {
WizRawPixel srcColor = convert8BppToRawPixel(*srcPtr++, conversionTable);
- *dst16++ = WIZRAWPIXEL_50_50_MIX(
+ *dst16 = WIZRAWPIXEL_50_50_MIX(
WIZRAWPIXEL_50_50_PREMIX_COLOR(srcColor),
WIZRAWPIXEL_50_50_PREMIX_COLOR(*dst16));
+ dst16++;
}
}
}
@@ -469,14 +473,16 @@ void Wiz::trleFLIPFiftyFiftyMixBackwardsPixelCopy(WizRawPixel *dstPtr, const byt
while (size-- > 0) {
if (!_uses16BitColor) {
WizRawPixel srcColor = convert8BppToRawPixel(*srcPtr++, conversionTable);
- *dst8-- = WIZRAWPIXEL_50_50_MIX(
+ *dst8 = WIZRAWPIXEL_50_50_MIX(
WIZRAWPIXEL_50_50_PREMIX_COLOR(srcColor),
WIZRAWPIXEL_50_50_PREMIX_COLOR(*dst8));
+ dst8--;
} else {
WizRawPixel srcColor = convert8BppToRawPixel(*srcPtr++, conversionTable);
- *dst16-- = WIZRAWPIXEL_50_50_MIX(
+ *dst16 = WIZRAWPIXEL_50_50_MIX(
WIZRAWPIXEL_50_50_PREMIX_COLOR(srcColor),
WIZRAWPIXEL_50_50_PREMIX_COLOR(*dst16));
+ dst16--;
}
}
}
@@ -591,7 +597,8 @@ void Wiz::trleFLIPRemapDestPixels(WizRawPixel *dstPtr, int size, const byte *loo
WizRawPixel8 *dst8 = (WizRawPixel8 *)dstPtr;
while (size-- > 0) {
- *dst8++ = *(lookupTable + *dst8);
+ *dst8 = *(lookupTable + *dst8);
+ dst8++;
}
}
}
@@ -678,7 +685,8 @@ void Wiz::trleFLIPForewordMixColorsPixelCopy(WizRawPixel *dstPtr, const byte *sr
while (size-- > 0) {
if (!_uses16BitColor) {
- *buf8++ = *(lookupTable + ((*srcPtr++) * 256) + *buf8);
+ *buf8 = *(lookupTable + ((*srcPtr++) * 256) + *buf8);
+ buf8++;
} else {
*buf16++ = *srcPtr++;
}
@@ -697,7 +705,8 @@ void Wiz::trleFLIPBackwardsMixColorsPixelCopy(WizRawPixel *dstPtr, const byte *s
while (size-- > 0) {
if (!_uses16BitColor) {
- *buf8-- = *(lookupTable + ((*srcPtr++) * 256) + *buf8);
+ *buf8 = *(lookupTable + ((*srcPtr++) * 256) + *buf8);
+ buf8--;
} else {
*buf16-- = *srcPtr++;
}
@@ -710,31 +719,31 @@ void Wiz::trleFLIPBackwardsMixColorsPixelCopy(WizRawPixel *dstPtr, const byte *s
}
}
-static void trleFLIPAdditiveDecompressLineForeword(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable) {
+static void trleFLIPAdditiveDecompressLineForeword(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const byte *extraPtr, const WizRawPixel *conversionTable) {
TRLEFLIP_X_Foreward_MACRO(
wiz->trleFLIPAdditivePixelMemset,
wiz->trleFLIPAdditiveForwardPixelCopy);
}
-static void trleFLIPAdditiveDecompressLineBackward(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable) {
+static void trleFLIPAdditiveDecompressLineBackward(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const byte *extraPtr, const WizRawPixel *conversionTable) {
TRLEFLIP_X_Backward_MACRO(
wiz->trleFLIPAdditivePixelMemset,
wiz->trleFLIPAdditiveBackwardsPixelCopy);
}
-static void trleFLIPSubtractiveDecompressLineForeword(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable) {
+static void trleFLIPSubtractiveDecompressLineForeword(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const byte *extraPtr, const WizRawPixel *conversionTable) {
TRLEFLIP_X_Foreward_MACRO(
wiz->trleFLIPSubtractivePixelMemset,
wiz->trleFLIPSubtractiveForwardPixelCopy);
}
-static void trleFLIPSubtractiveDecompressLineBackward(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable) {
+static void trleFLIPSubtractiveDecompressLineBackward(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const byte *extraPtr, const WizRawPixel *conversionTable) {
TRLEFLIP_X_Backward_MACRO(
wiz->trleFLIPSubtractivePixelMemset,
wiz->trleFLIPSubtractiveBackwardsPixelCopy);
}
-static void trleFLIPDecompressLineForeword(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable) {
+static void trleFLIPDecompressLineForeword(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const byte *extraPtr, const WizRawPixel *conversionTable) {
int runCount;
WizRawPixel8 *dest8 = (WizRawPixel8 *)destPtr;
WizRawPixel16 *dest16 = (WizRawPixel16 *)destPtr;
@@ -754,7 +763,7 @@ static void trleFLIPDecompressLineForeword(Wiz *wiz, WizRawPixel *destPtr, const
}
},
{
- TRLEFLIP_MEMSET(destPtr, *((byte *)dataStream), runCount);
+ TRLEFLIP_MEMSET(destPtr, *dataStream, runCount);
if (wiz->_uses16BitColor) {
dest16 += runCount;
destPtr = (WizRawPixel *)dest16;
@@ -775,7 +784,7 @@ static void trleFLIPDecompressLineForeword(Wiz *wiz, WizRawPixel *destPtr, const
});
}
-static void trleFLIPDecompressLineBackward(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable) {
+static void trleFLIPDecompressLineBackward(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const byte *extraPtr, const WizRawPixel *conversionTable) {
int runCount;
WizRawPixel8 *dest8 = (WizRawPixel8 *)destPtr;
WizRawPixel16 *dest16 = (WizRawPixel16 *)destPtr;
@@ -802,7 +811,7 @@ static void trleFLIPDecompressLineBackward(Wiz *wiz, WizRawPixel *destPtr, const
dest8 -= runCount;
destPtr = (WizRawPixel *)dest8;
}
- TRLEFLIP_MEMSET(destPtr + 1, *((byte *)dataStream), runCount);
+ TRLEFLIP_MEMSET(destPtr + 1, *dataStream, runCount);
},
{
wiz->trleFLIPBackwardsPixelCopy(destPtr, dataStream, runCount, conversionTable);
@@ -816,13 +825,13 @@ static void trleFLIPDecompressLineBackward(Wiz *wiz, WizRawPixel *destPtr, const
});
}
-static void trleFLIPLookupDecompressLineForeword(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable) {
+static void trleFLIPLookupDecompressLineForeword(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const byte *extraPtr, const WizRawPixel *conversionTable) {
const byte *lookupTable;
int runCount;
WizRawPixel8 *dest8 = (WizRawPixel8 *)destPtr;
WizRawPixel16 *dest16 = (WizRawPixel16 *)destPtr;
- lookupTable = (byte *)extraPtr;
+ lookupTable = extraPtr;
// Decompress bytes to do simple clipping...
HANDLE_SKIP_PIXELS_MACRO();
@@ -860,13 +869,13 @@ static void trleFLIPLookupDecompressLineForeword(Wiz *wiz, WizRawPixel *destPtr,
});
}
-static void trleFLIPLookupDecompressLineBackward(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable) {
+static void trleFLIPLookupDecompressLineBackward(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const byte *extraPtr, const WizRawPixel *conversionTable) {
const byte *lookupTable;
int runCount;
WizRawPixel8 *dest8 = (WizRawPixel8 *)destPtr;
WizRawPixel16 *dest16 = (WizRawPixel16 *)destPtr;
- lookupTable = (byte *)extraPtr;
+ lookupTable = extraPtr;
// Decompress bytes to do simple clipping...
HANDLE_SKIP_PIXELS_MACRO();
@@ -904,13 +913,13 @@ static void trleFLIPLookupDecompressLineBackward(Wiz *wiz, WizRawPixel *destPtr,
});
}
-static void trleFLIPMixDecompressLineForeword(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable) {
+static void trleFLIPMixDecompressLineForeword(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const byte *extraPtr, const WizRawPixel *conversionTable) {
const byte *lookupTable;
int runCount;
WizRawPixel8 *dest8 = (WizRawPixel8 *)destPtr;
WizRawPixel16 *dest16 = (WizRawPixel16 *)destPtr;
- lookupTable = (byte *)extraPtr;
+ lookupTable = extraPtr;
// Decompress bytes to do simple clipping...
HANDLE_SKIP_PIXELS_MACRO();
@@ -952,13 +961,13 @@ static void trleFLIPMixDecompressLineForeword(Wiz *wiz, WizRawPixel *destPtr, co
});
}
-static void trleFLIPMixDecompressLineBackward(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable) {
+static void trleFLIPMixDecompressLineBackward(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const byte *extraPtr, const WizRawPixel *conversionTable) {
const byte *lookupTable;
int runCount;
WizRawPixel8 *dest8 = (WizRawPixel8 *)destPtr;
WizRawPixel16 *dest16 = (WizRawPixel16 *)destPtr;
- lookupTable = (byte *)extraPtr;
+ lookupTable = extraPtr;
// Decompress bytes to do simple clipping...
HANDLE_SKIP_PIXELS_MACRO();
@@ -1232,7 +1241,7 @@ static void trleFLIPSubtractiveArbitraryDstStepDecompressLine(Wiz *wiz, WizRawPi
TRLEFLIP_X_ArbitraryDstStep_MACRO(WIZRAWPIXEL_SUBTRACTIVE_MIX);
}
-void Wiz::trleFLIP90DegreeRotateCore(WizSimpleBitmap *dstBitmap, int x, int y, const COMPRESSEDIMAGE *imagePtr, const Common::Rect *optionalSrcRect,
+void Wiz::trleFLIP90DegreeRotateCore(WizSimpleBitmap *dstBitmap, int x, int y, const WizCompressedImage *imagePtr, const Common::Rect *optionalSrcRect,
const Common::Rect *optionalClipRect, bool hFlip, bool vFlip, const void *userParam, const WizRawPixel *conversionTable,
void(*functionPtr)(Wiz *wiz,
WizRawPixel *destPtr, const byte *dataStream, int skipAmount,
@@ -1242,7 +1251,7 @@ void Wiz::trleFLIP90DegreeRotateCore(WizSimpleBitmap *dstBitmap, int x, int y, c
Common::Rect dstRect, srcRect, clipRect, clippedDstRect, clippedSrcRect;
int dstOffset, dstStep, w, h, srcOffset, dstX, dstY, skipAmount, c;
WizRawPixel *dstPtr;
- byte *compData;
+ const byte *compData;
// Do as much pre-clipping as possible
makeSizedRect(&clipRect, dstBitmap->bitmapWidth, dstBitmap->bitmapHeight);
@@ -1336,9 +1345,9 @@ void Wiz::trleFLIP90DegreeRotateCore(WizSimpleBitmap *dstBitmap, int x, int y, c
void Wiz::trleFLIPDecompressImage(
WizRawPixel *bufferPtr, const byte *compData, int bufferWidth, int bufferHeight,
int x, int y, int width, int height, Common::Rect *clipRectPtr,
- int32 wizFlags, const void *extraTable, const WizRawPixel *conversionTable,
+ int32 wizFlags, const byte *extraTable, const WizRawPixel *conversionTable,
const WizImageCommand *optionalICmdPtr) {
- COMPRESSEDIMAGE fakeImage;
+ WizCompressedImage fakeImage;
WizSimpleBitmap fakeBitmap;
if (_uses16BitColor)
@@ -1349,14 +1358,14 @@ void Wiz::trleFLIPDecompressImage(
fakeBitmap.bitmapWidth = bufferWidth;
fakeBitmap.bitmapHeight = bufferHeight;
- fakeImage.data = (byte *)compData;
+ fakeImage.data = compData;
fakeImage.width = width;
fakeImage.height = height;
if (!_uses16BitColor) {
// Check to see if there is a remap to be performed on the TRLE data...
if (conversionTable && (conversionTable != (WizRawPixel *)_vm->getHEPaletteSlot(1))) {
- extraTable = (const void *)conversionTable;
+ extraTable = (const byte *)conversionTable;
wizFlags &= ~kWRFUseShadow;
wizFlags |= kWRFRemap;
}
@@ -1417,7 +1426,7 @@ void Wiz::trleFLIPRotate90DecompressImage(
int x, int y, int width, int height, const Common::Rect *clipRectPtr,
int32 wizFlags, const void *extraTable, const WizRawPixel *conversionTable,
WizImageCommand *optionalICmdPtr) {
- COMPRESSEDIMAGE fakeImage;
+ WizCompressedImage fakeImage;
WizSimpleBitmap fakeBitmap;
if (_uses16BitColor)
@@ -1428,7 +1437,7 @@ void Wiz::trleFLIPRotate90DecompressImage(
fakeBitmap.bitmapWidth = bufferWidth;
fakeBitmap.bitmapHeight = bufferHeight;
- fakeImage.data = (byte *)compData;
+ fakeImage.data = compData;
fakeImage.width = width;
fakeImage.height = height;
@@ -2020,7 +2029,7 @@ void Wiz::trleFLIPAltSourceDecompImageHull(
}
for (counter = sourceRect->top; counter > 0; counter--) {
- compData += READ_LE_UINT16((byte *)compData) + 2;
+ compData += READ_LE_UINT16(compData) + 2;
}
// Calc the ALT buffer location
@@ -2034,7 +2043,7 @@ void Wiz::trleFLIPAltSourceDecompImageHull(
// Decompress all the lines that are visible!!!!
while (decompHeight-- > 0) {
- lineSize = READ_LE_UINT16((byte *)compData);
+ lineSize = READ_LE_UINT16(compData);
if (lineSize != 0) {
(*functionPtr)(this,
@@ -2064,7 +2073,7 @@ void Wiz::trleFLIPAltSourceDecompImageHull(
void Wiz::trleFLIPAltSourceDecompressPrim(
WizRawPixel *destBufferPtr, int destBufferWidth, int destBufferHeight,
const void *altBufferPtr, int altBitsPerPixel,
- const COMPRESSEDIMAGE *imagePtr, int destX, int destY,
+ const WizCompressedImage *imagePtr, int destX, int destY,
const Common::Rect *sourceCoords, const Common::Rect *clipRectPtr,
int32 flags, const WizRawPixel *conversionTable,
void (*forewordFunctionPtr)(Wiz *wiz,
@@ -2174,9 +2183,9 @@ bool Wiz::trleFLIPAltSourceSpecialCaseDispatch(
// General setup
Common::Rect srcRect, clipRect;
- COMPRESSEDIMAGE fakeImage;
+ WizCompressedImage fakeImage;
- fakeImage.data = (byte *)compData;
+ fakeImage.data = compData;
fakeImage.width = width;
fakeImage.height = height;
@@ -2294,14 +2303,14 @@ void Wiz::trleFLIPAltSourceDecompressImage(
int32 wizFlags, const WizRawPixel *conversionTable,
WizImageCommand *optionalICmdPtr) {
Common::Rect srcRect, clipRect;
- COMPRESSEDIMAGE fakeImage;
+ WizCompressedImage fakeImage;
int curBpp = _uses16BitColor ? 16 : 8;
if (_uses16BitColor)
trleFLIPCheckAlphaSetup();
// General setup
- fakeImage.data = (byte *)compData;
+ fakeImage.data = compData;
fakeImage.width = width;
fakeImage.height = height;
@@ -2362,15 +2371,15 @@ int Wiz::trleCompressImageArea(byte *destBuffer, const WizRawPixel *sourceBuffer
width = x2 - x1 + 1;
height = y2 - y1 + 1;
- WizRawPixel8 *buf8 = (WizRawPixel8 *)sourceBuffer;
- WizRawPixel16 *buf16 = (WizRawPixel16 *)sourceBuffer;
+ const WizRawPixel8 *buf8 = (const WizRawPixel8 *)sourceBuffer;
+ const WizRawPixel16 *buf16 = (const WizRawPixel16 *)sourceBuffer;
if (_uses16BitColor) {
buf16 += sourceBufferWidth * y1 + x1;
- sourceBuffer = (WizRawPixel *)buf16;
+ sourceBuffer = (const WizRawPixel *)buf16;
} else {
buf8 += sourceBufferWidth * y1 + x1;
- sourceBuffer = (WizRawPixel *)buf8;
+ sourceBuffer = (const WizRawPixel *)buf8;
}
totalSize = 0;
@@ -2386,15 +2395,15 @@ int Wiz::trleCompressImageArea(byte *destBuffer, const WizRawPixel *sourceBuffer
destBuffer, sourceBuffer, width, transparentColor);
// Refresh pointers, you never know...
- buf8 = (WizRawPixel8 *)sourceBuffer;
- buf16 = (WizRawPixel16 *)sourceBuffer;
+ buf8 = (const WizRawPixel8 *)sourceBuffer;
+ buf16 = (const WizRawPixel16 *)sourceBuffer;
if (_uses16BitColor) {
buf16 += sourceBufferWidth;
- sourceBuffer = (WizRawPixel *)buf16;
+ sourceBuffer = (const WizRawPixel *)buf16;
} else {
buf8 += sourceBufferWidth;
- sourceBuffer = (WizRawPixel *)buf8;
+ sourceBuffer = (const WizRawPixel *)buf8;
}
totalSize += lineSize;
@@ -2483,8 +2492,8 @@ int Wiz::trleRLECompression(byte *pdest, const WizRawPixel *psource, int rowsize
int rstart = 0;
int counter;
- const WizRawPixel8 *source8 = (WizRawPixel8 *)psource;
- const WizRawPixel16 *source16 = (WizRawPixel16 *)psource;
+ const WizRawPixel8 *source8 = (const WizRawPixel8 *)psource;
+ const WizRawPixel16 *source16 = (const WizRawPixel16 *)psource;
// Check for completely transparent
for (counter = 0; counter < rowsize; counter++) {
@@ -2561,7 +2570,20 @@ int Wiz::trleRLECompression(byte *pdest, const WizRawPixel *psource, int rowsize
}
}
- // Note, in this case we HAVE to fall through!
+ // Note, in this case the original falls through!
+ // Let's replicate that in a way which doesn't trigger warnings...
+ //
+ // case TRLE_RUN:
+ // Check run to see if still going...
+ if ((c != lastc) || (nbuf - rstart > TRLE_MAXRUN)) {
+ dest = trlePutRun(dest, nbuf - 1 - rstart, lastc, tcolor);
+ _trleBuf[0] = c;
+ nbuf = 1;
+ rstart = 0;
+ // Don't allow transparent colors in a literal run!
+ mode = ((c == tcolor) ? TRLE_RUN : TRLE_DUMP);
+ }
+ break;
} else {
rstart = nbuf - 1;
break;
diff --git a/engines/scumm/he/gfx_primitives_he.cpp b/engines/scumm/he/gfx_primitives_he.cpp
index 4266c0bd0e7..a74b03196c8 100644
--- a/engines/scumm/he/gfx_primitives_he.cpp
+++ b/engines/scumm/he/gfx_primitives_he.cpp
@@ -216,8 +216,6 @@ void Wiz::pgClippedThickLineDraw(WizSimpleBitmap *destBM, int asx, int asy, int
int *xPoints = new int[4];
int *yPoints = new int[4];
- int aLeftNeighborTable[4] = {1, 2, 3, 0};
- int aRightNeighborTable[4] = {3, 2, 1, 0};
xPoints[aSortOrder[0]] = asx - iCompDX;
yPoints[aSortOrder[0]] = asy - iCompDY;
@@ -497,7 +495,7 @@ void Wiz::pgSimpleBitmapFromDrawBuffer(WizSimpleBitmap *bitmapPtr, bool backgrou
}
}
-void Wiz::pgDrawRawDataFormatImage(WizRawPixel *bufferPtr, const WizRawPixel *rawData, int bufferWidth, int bufferHeight, int x, int y, int width, int height, Common::Rect *clipRectPtr, int32 wizFlags, const void *extraTable, int transparentColor) {
+void Wiz::pgDrawRawDataFormatImage(WizRawPixel *bufferPtr, const WizRawPixel *rawData, int bufferWidth, int bufferHeight, int x, int y, int width, int height, Common::Rect *clipRectPtr, int32 wizFlags, const byte *extraTable, int transparentColor) {
Common::Rect srcRect, dstRect, clipRect;
WizSimpleBitmap srcBitmap, dstBitmap;
int off, t;
@@ -566,7 +564,7 @@ void Wiz::pgDrawRawDataFormatImage(WizRawPixel *bufferPtr, const WizRawPixel *ra
dstBitmap.bitmapWidth = bufferWidth;
dstBitmap.bitmapHeight = bufferHeight;
- srcBitmap.bufferPtr = (WizRawPixel *)rawData;
+ srcBitmap.bufferPtr = const_cast<WizRawPixel *>(rawData);
srcBitmap.bitmapWidth = width;
srcBitmap.bitmapHeight = height;
@@ -577,15 +575,15 @@ void Wiz::pgDrawRawDataFormatImage(WizRawPixel *bufferPtr, const WizRawPixel *ra
if (extraTable) {
if (wizFlags & kWRFRemap) {
if (transparentColor == -1) {
- pgSimpleBlitRemapColors(&dstBitmap, &dstRect, &srcBitmap, &srcRect, (const byte *)extraTable);
+ pgSimpleBlitRemapColors(&dstBitmap, &dstRect, &srcBitmap, &srcRect, extraTable);
} else {
- pgSimpleBlitTransparentRemapColors(&dstBitmap, &dstRect, &srcBitmap, &srcRect, (WizRawPixel)transparentColor, (const byte *)extraTable);
+ pgSimpleBlitTransparentRemapColors(&dstBitmap, &dstRect, &srcBitmap, &srcRect, (WizRawPixel)transparentColor, extraTable);
}
} else {
if (transparentColor == -1) {
- pgSimpleBlitMixColors(&dstBitmap, &dstRect, &srcBitmap, &srcRect, (const byte *)extraTable);
+ pgSimpleBlitMixColors(&dstBitmap, &dstRect, &srcBitmap, &srcRect, extraTable);
} else {
- pgSimpleBlitTransparentMixColors(&dstBitmap, &dstRect, &srcBitmap, &srcRect, (WizRawPixel)transparentColor, (const byte *)extraTable);
+ pgSimpleBlitTransparentMixColors(&dstBitmap, &dstRect, &srcBitmap, &srcRect, (WizRawPixel)transparentColor, extraTable);
}
}
} else {
@@ -1025,7 +1023,7 @@ void Wiz::pgDrawWarpDrawLetter(WizRawPixel *bitmapBuffer, int bitmapWidth, int b
}
}
-void Wiz::pgDraw8BppFormatImage(WizRawPixel *bufferPtr, const byte *rawData, int bufferWidth, int bufferHeight, int x, int y, int width, int height, Common::Rect *clipRectPtr, int32 wizFlags, const void *extraTable, int transparentColor, const WizRawPixel *conversionTable) {
+void Wiz::pgDraw8BppFormatImage(WizRawPixel *bufferPtr, const byte *rawData, int bufferWidth, int bufferHeight, int x, int y, int width, int height, Common::Rect *clipRectPtr, int32 wizFlags, const byte *extraTable, int transparentColor, const WizRawPixel *conversionTable) {
Common::Rect srcRect, dstRect, clipRect;
WizSimpleBitmap srcBitmap, dstBitmap;
@@ -1093,7 +1091,7 @@ void Wiz::pgDraw8BppFormatImage(WizRawPixel *bufferPtr, const byte *rawData, int
dstBitmap.bitmapWidth = bufferWidth;
dstBitmap.bitmapHeight = bufferHeight;
- srcBitmap.bufferPtr = (WizRawPixel *)rawData;
+ srcBitmap.bufferPtr = (WizRawPixel *)const_cast<byte *>(rawData);
srcBitmap.bitmapWidth = width;
srcBitmap.bitmapHeight = height;
@@ -1245,7 +1243,7 @@ void Wiz::pgDrawImageWith16BitZBuffer(WizSimpleBitmap *psbDst, const WizSimpleBi
const int drawWidth = (prcClip->right - prcClip->left + 1);
const int drawHeight = (prcClip->bottom - prcClip->top + 1);
- WizRawPixel *pSrc = (WizRawPixel *)imgData + (prcClip->top - y) * width + (prcClip->left - x);
+ WizRawPixel *pSrc = (WizRawPixel *)const_cast<byte *>(imgData) + (prcClip->top - y) * width + (prcClip->left - x);
WizRawPixel *pDst = (WizRawPixel *)psbDst->bufferPtr + prcClip->top * dstWidth + prcClip->left;
WizRawPixel *pZB = (WizRawPixel *)psbZBuffer->bufferPtr + prcClip->top * dstWidth + prcClip->left;
@@ -1378,7 +1376,8 @@ void Wiz::pgForewordMixColorsPixelCopy(WizRawPixel *dstPtr, const WizRawPixel *s
const WizRawPixel8 *src8 = (const WizRawPixel8 *)srcPtr;
while (size-- > 0) {
- *dst8++ = *(lookupTable + ((*src8++) * 256) + *dst8);
+ *dst8 = *(lookupTable + ((*src8++) * 256) + *dst8);
+ dst8++;
}
} else {
WizRawPixel16 *dst16 = (WizRawPixel16 *)dstPtr;
@@ -1405,7 +1404,8 @@ void Wiz::pgBackwardsMixColorsPixelCopy(WizRawPixel *dstPtr, const WizRawPixel *
const WizRawPixel8 *src8 = (const WizRawPixel8 *)srcPtr;
while (size-- > 0) {
- *dst8-- = *(lookupTable + ((*src8++) * 256) + *dst8);
+ *dst8 = *(lookupTable + ((*src8++) * 256) + *dst8);
+ dst8--;
}
} else {
WizRawPixel16 *dst16 = (WizRawPixel16 *)dstPtr;
@@ -1650,7 +1650,7 @@ void Wiz::pgBlit90DegreeRotateCore(WizSimpleBitmap *dstBitmap, int x, int y, con
src8 = ((WizRawPixel8 *)srcBitmap->bufferPtr) + clippedSrcRect.left + (clippedSrcRect.top * srcBitmap->bitmapWidth);
while (--h >= 0) {
- (*srcTransferFP)(this, (WizRawPixel *)dst8, dstStep, (WizRawPixel *)src8, w, userParam, userParam2);
+ (*srcTransferFP)(this, (WizRawPixel *)dst8, dstStep, (const WizRawPixel *)src8, w, userParam, userParam2);
dst8 += dstOffset;
src8 += srcOffset;
}
@@ -1659,7 +1659,7 @@ void Wiz::pgBlit90DegreeRotateCore(WizSimpleBitmap *dstBitmap, int x, int y, con
src16 = ((WizRawPixel16 *)srcBitmap->bufferPtr) + clippedSrcRect.left + (clippedSrcRect.top * srcBitmap->bitmapWidth);
while (--h >= 0) {
- (*srcTransferFP)(this, (WizRawPixel *)dst16, dstStep, (WizRawPixel *)src16, w, userParam, userParam2);
+ (*srcTransferFP)(this, (WizRawPixel *)dst16, dstStep, (const WizRawPixel *)src16, w, userParam, userParam2);
dst16 += dstOffset;
src16 += srcOffset;
}
@@ -1993,7 +1993,7 @@ void Wiz::memcpy8BppConversion(void *dstPtr, const void *srcPtr, size_t count, c
void Wiz::rawPixelMemset(void *dstPtr, int value, size_t count) {
if (_uses16BitColor) {
WizRawPixel16 *dst16Bit = (WizRawPixel16 *)dstPtr;
- for (int i = 0; i < count; i++)
+ for (size_t i = 0; i < count; i++)
WRITE_LE_UINT16(&dst16Bit[i], value);
} else {
WizRawPixel8 *dst8Bit = (WizRawPixel8 *)dstPtr;
@@ -2003,7 +2003,7 @@ void Wiz::rawPixelMemset(void *dstPtr, int value, size_t count) {
WizRawPixel Wiz::convert8BppToRawPixel(WizRawPixel value, const WizRawPixel *conversionTable) {
if (_uses16BitColor) {
- return *(((WizRawPixel16 *)conversionTable) + value);
+ return *(((const WizRawPixel16 *)conversionTable) + value);
} else {
return value;
}
diff --git a/engines/scumm/he/script_v100he.cpp b/engines/scumm/he/script_v100he.cpp
index 3bbcedc58d5..fd62ccc03a4 100644
--- a/engines/scumm/he/script_v100he.cpp
+++ b/engines/scumm/he/script_v100he.cpp
@@ -2618,7 +2618,8 @@ void ScummEngine_v100he::o100_getWizData() {
case SO_NEW_GENERAL_PROPERTY:
type = pop();
state = pop();
- if (resId = pop()) {
+ resId = pop();
+ if (resId != 0) {
push(_wiz->dwGetImageGeneralProperty(resId, state, type));
} else {
push(0);
diff --git a/engines/scumm/he/sprite_he.cpp b/engines/scumm/he/sprite_he.cpp
index 799c5777430..15326ccba62 100644
--- a/engines/scumm/he/sprite_he.cpp
+++ b/engines/scumm/he/sprite_he.cpp
@@ -1037,7 +1037,7 @@ void Sprite::setImageList(int sprite, int count, const int *list) {
}
if (_vm->_game.heversion > 80 &&
- (lastImage != _spriteTable[sprite].image) || (_spriteTable[sprite].maxStates != lastMaxStates)) {
+ ((lastImage != _spriteTable[sprite].image) || (_spriteTable[sprite].maxStates != lastMaxStates))) {
_spriteTable[sprite].flags |= (kSFRender | kSFErase);
}
}
@@ -1480,7 +1480,7 @@ bool Sprite::doesRectIntersectUpdateAreas(const Common::Rect *rectPtr) {
y2 = rectPtr->bottom;
sMin = rectPtr->left / stripsBytes;
- _vm->_gdi->_numStrips;
+
sMin = MAX(0, MIN(sMin, (strips - 1)));
sMax = (rectPtr->right + stripsBytes - 1) / stripsBytes;
sMax = MAX(0, MIN(sMax, (strips - 1)));
diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp
index cee834308cd..c48b7eb0841 100644
--- a/engines/scumm/he/wiz_he.cpp
+++ b/engines/scumm/he/wiz_he.cpp
@@ -177,7 +177,8 @@ void *Wiz::drawAWizPrim(int globNum, int state, int x, int y, int z, int shadowI
void *Wiz::drawAWizPrimEx(int globNum, int state, int x, int y, int z, int shadowImage, int zbufferImage, const Common::Rect *optionalClipRect, int flags, WizSimpleBitmap *optionalBitmapOverride, const WizRawPixel *optionalColorConversionTable, const WizImageCommand *optionalICmdPtr) {
int dest_w, dest_h, src_w, src_h, src_c, remapID;
- byte *src_d, *src_p, *pp, *remap_p, *shadow_p;
+ byte *src_d, *src_p, *pp, *remap_p;
+ const byte *shadow_p;
Common::Rect dest_r, clip_r;
bool markUpdates;
WizRawPixel *dest_p;
@@ -193,7 +194,7 @@ void *Wiz::drawAWizPrimEx(int globNum, int state, int x, int y, int z, int shado
}
if (shadowImage) {
- shadow_p = (byte *)getColorMixBlockPtrForWiz(shadowImage);
+ shadow_p = getColorMixBlockPtrForWiz(shadowImage);
if (shadow_p) {
shadow_p += _vm->_resourceHeaderSize;
@@ -212,7 +213,7 @@ void *Wiz::drawAWizPrimEx(int globNum, int state, int x, int y, int z, int shado
// If using a z-buffer make sure both globs are in ram!!!!
if (zbufferImage) {
// uncompressed 16-bit z-buffers only for now
- byte *pzbHeader = (byte *)getWizStateHeaderPrim(zbufferImage, 0);
+ byte *pzbHeader = getWizStateHeaderPrim(zbufferImage, 0);
assert(pzbHeader);
@@ -388,7 +389,7 @@ void *Wiz::drawAWizPrimEx(int globNum, int state, int x, int y, int z, int shado
optionalColorConversionTable);
}
} else {
- void *dataPtr = nullptr;
+ const byte *dataPtr = nullptr;
if (shadow_p)
dataPtr = shadow_p;
@@ -405,7 +406,7 @@ void *Wiz::drawAWizPrimEx(int globNum, int state, int x, int y, int z, int shado
} else {
int transColorOverride;
- void *dataPtr = nullptr;
+ const byte *dataPtr = nullptr;
if (shadow_p)
dataPtr = shadow_p;
@@ -433,7 +434,7 @@ void *Wiz::drawAWizPrimEx(int globNum, int state, int x, int y, int z, int shado
if (optionalColorConversionTable &&
((WizRawPixel *)_vm->getHEPaletteSlot(1) != optionalColorConversionTable)) {
flags |= kWRFRemap;
- dataPtr = (void *)optionalColorConversionTable;
+ dataPtr = (const byte *)optionalColorConversionTable;
}
} else {
if (!_uses16BitColor && src_c != kWCTNone) {
@@ -580,7 +581,7 @@ void Wiz::buildAWiz(const WizRawPixel *bufPtr, int bufWidth, int bufHeight, cons
Common::Rect dstRect;
// Src setup
- srcBitmap.bufferPtr = (WizRawPixel *)bufPtr;
+ srcBitmap.bufferPtr = const_cast<WizRawPixel *>(bufPtr);
srcBitmap.bitmapWidth = bufWidth;
srcBitmap.bitmapHeight = bufHeight;
@@ -763,9 +764,9 @@ int Wiz::hitTestWizPrim(int globNum, int state, int x, int y, int32 flags) {
} else if (_vm->_game.heversion > 98 && isUncompressedFormatTypeID(src_c)) {
WizSimpleBitmap srcBitmap;
- src_d = getWizStateDataPrim(globNum, state);
+ src_d = getWizStateDataPrim(globNum, state) + _vm->_resourceHeaderSize;
- srcBitmap.bufferPtr = (WizRawPixel *)(src_d + _vm->_resourceHeaderSize);
+ srcBitmap.bufferPtr = (WizRawPixel *)const_cast<byte *>(src_d);
srcBitmap.bitmapWidth = src_w;
srcBitmap.bitmapHeight = src_h;
@@ -1045,7 +1046,7 @@ void Wiz::processWizImagePolyCaptureCmd(const WizImageCommand *params) {
// if there is an xmap, do filtered warp
if (shadow) {
// get the color map, bypass the header information
- byte *xmapColorTable = (byte *)getColorMixBlockPtrForWiz(shadow);
+ const byte *xmapColorTable = getColorMixBlockPtrForWiz(shadow);
if (!xmapColorTable) {
error("Image capture poly: Shadow specified but not present in image.");
@@ -1669,7 +1670,7 @@ void Wiz::dwAltSourceDrawWiz(int maskImage, int maskState, int x, int y, int sou
void Wiz::dwHandleComplexImageDraw(int image, int state, int x, int y, int shadow, int angle, int scale, const Common::Rect *clipRect, int32 flags, WizSimpleBitmap *optionalBitmapOverride, const WizRawPixel *optionalColorConversionTable) {
int w, h, correctedAngle;
Common::Point listOfPoints[4];
- byte *shadowPtr;
+ const byte *shadowPtr;
// Set the optional remap table up to the default if one isn't specified
if (!optionalColorConversionTable) {
@@ -1769,7 +1770,7 @@ void Wiz::dwHandleComplexImageDraw(int image, int state, int x, int y, int shado
// If there is a shadow get it's address
if (shadow) {
- shadowPtr = (byte *)getColorMixBlockPtrForWiz(shadow);
+ shadowPtr = getColorMixBlockPtrForWiz(shadow);
// Let's replicate whichever bug they had in the interpreter...
if (_vm->_game.heversion > 99 || _vm->_isHE995)
@@ -2305,11 +2306,10 @@ void Wiz::processWizImageModifyCmd(const WizImageCommand *params) {
}
void Wiz::processWizImageRenderEllipseCmd(const WizImageCommand *params) {
- int whichState = 0, propertyNumber = 0, propertyValue = 0;
+ int whichState = 0, propertyValue = 0;
int width = 0, height = 0;
if (params->actionFlags & kWAFProperty) {
- propertyNumber = params->propertyNumber;
propertyValue = params->propertyValue;
}
diff --git a/engines/scumm/he/wiz_he.h b/engines/scumm/he/wiz_he.h
index 27a3a19f1d0..08d789970d1 100644
--- a/engines/scumm/he/wiz_he.h
+++ b/engines/scumm/he/wiz_he.h
@@ -288,7 +288,7 @@ struct WizFloodState {
};
struct WizCompressedImage {
- byte *data;
+ const byte *data;
int width;
int height;
};
@@ -334,12 +334,6 @@ struct WarpWizOneSpanTable {
int spanCount;
};
-struct COMPRESSEDIMAGE {
- byte *data;
- int width;
- int height;
-};
-
enum WizRenderingFlags {
// Standard rendering flags
kWRFUsePalette = 0x00000001,
@@ -642,7 +636,7 @@ public:
void pgHistogramBitmapSubRect(int *tablePtr, const WizSimpleBitmap *bitmapPtr, const Common::Rect *sourceRect);
void pgSimpleBitmapFromDrawBuffer(WizSimpleBitmap *bitmapPtr, bool background);
- void pgDrawRawDataFormatImage(WizRawPixel *bufferPtr, const WizRawPixel *rawData, int bufferWidth, int bufferHeight, int x, int y, int width, int height, Common::Rect *clipRectPtr, int32 wizFlags, const void *extraTable, int transparentColor);
+ void pgDrawRawDataFormatImage(WizRawPixel *bufferPtr, const WizRawPixel *rawData, int bufferWidth, int bufferHeight, int x, int y, int width, int height, Common::Rect *clipRectPtr, int32 wizFlags, const byte *extraTable, int transparentColor);
void pgSimpleBlit(WizSimpleBitmap *destBM, Common::Rect *destRect, WizSimpleBitmap *sourceBM, Common::Rect *sourceRect);
void pgSimpleBlitRemapColors(WizSimpleBitmap *destBM, Common::Rect *destRect, WizSimpleBitmap *sourceBM, Common::Rect *sourceRect, const byte *remapColorTable);
void pgSimpleBlitTransparentRemapColors(WizSimpleBitmap *destBM, Common::Rect *destRect, WizSimpleBitmap *sourceBM, Common::Rect *sourceRect, WizRawPixel transparentColor, const byte *remapColorTable);
@@ -651,7 +645,7 @@ public:
void pgTransparentSimpleBlit(WizSimpleBitmap *destBM, Common::Rect *destRect, WizSimpleBitmap *sourceBM, Common::Rect *sourceRect, WizRawPixel transparentColor);
void pgDrawWarpDrawLetter(WizRawPixel *bitmapBuffer, int bitmapWidth, int bitmapHeight, const byte *charData, int x1, int y1, int width, int height, byte *colorLookupTable);
- void pgDraw8BppFormatImage(WizRawPixel *bufferPtr, const byte *rawData, int bufferWidth, int bufferHeight, int x, int y, int width, int height, Common::Rect *clipRectPtr, int32 wizFlags, const void *extraTable, int transparentColor, const WizRawPixel *conversionTable);
+ void pgDraw8BppFormatImage(WizRawPixel *bufferPtr, const byte *rawData, int bufferWidth, int bufferHeight, int x, int y, int width, int height, Common::Rect *clipRectPtr, int32 wizFlags, const byte *extraTable, int transparentColor, const WizRawPixel *conversionTable);
void pgDraw8BppSimpleBlit(WizSimpleBitmap *destBM, Common::Rect *destRect, WizSimpleBitmap *sourceBM, Common::Rect *sourceRect, const WizRawPixel *conversionTable);
void pgDraw8BppTransparentSimpleBlit(WizSimpleBitmap *destBM, Common::Rect *destRect, WizSimpleBitmap *sourceBM, Common::Rect *sourceRect, int transparentColor, const WizRawPixel *conversionTable);
void pgDrawImageWith16BitZBuffer(WizSimpleBitmap *psbDst, const WizSimpleBitmap *psbZBuffer, const byte *imgData, int x, int y, int z, int width, int height, Common::Rect *prcClip);
@@ -750,7 +744,7 @@ public:
bool auxPixelHitTestTRLEXPos(byte *dataStream, int skipAmount, int transparentValue);
int auxPixelHitTestTRLEImageRelPos(byte *compData, int x, int y, int width, int height, int transparentValue);
- void auxDecompMixColorsTRLEImage(WizRawPixel *bufferPtr, byte *compData, int bufferWidth, int bufferHeight, int x, int y, int width, int height, Common::Rect *clipRectPtr, byte *coloMixTable, const WizRawPixel *conversionTable);
+ void auxDecompMixColorsTRLEImage(WizRawPixel *bufferPtr, byte *compData, int bufferWidth, int bufferHeight, int x, int y, int width, int height, Common::Rect *clipRectPtr, const byte *colorMixTable, const WizRawPixel *conversionTable);
void auxDecompMixColorsTRLEPrim(WizRawPixel *bufferPtr, int bufferWidth, Common::Rect *destRect, const byte *compData, Common::Rect *sourceRect, const byte *coloMixTable, const WizRawPixel *conversionTable);
void auxColorMixDecompressLine(
WizRawPixel *destPtr, const byte *dataStream, int skipAmount,
@@ -785,27 +779,27 @@ public:
void trleFLIPDecompressImage(
WizRawPixel *bufferPtr, const byte *compData, int bufferWidth, int bufferHeight,
int x, int y, int width, int height, Common::Rect *clipRectPtr,
- int32 wizFlags, const void *extraTable, const WizRawPixel *conversionTable,
+ int32 wizFlags, const byte *extraTable, const WizRawPixel *conversionTable,
const WizImageCommand *optionalICmdPtr);
void trleFLIPDecompressPrim(
- WizSimpleBitmap *bitmapPtr, const COMPRESSEDIMAGE *imagePtr, int destX, int destY,
- const Common::Rect *sourceCoords, const Common::Rect *clipRectPtr, const void *extraPtr,
+ WizSimpleBitmap *bitmapPtr, const WizCompressedImage *imagePtr, int destX, int destY,
+ const Common::Rect *sourceCoords, const Common::Rect *clipRectPtr, const byte *extraPtr,
int32 flags, const WizRawPixel *conversionTable,
void (*forewordFunctionPtr)(Wiz *wiz,
WizRawPixel *destPtr, const byte *dataStream, int skipAmount,
- int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable),
+ int decompAmount, const byte *extraPtr, const WizRawPixel *conversionTable),
void (*backwardFunctionPtr)(Wiz *wiz,
WizRawPixel *destPtr, const byte *dataStream, int skipAmount,
- int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable));
+ int decompAmount, const byte *extraPtr, const WizRawPixel *conversionTable));
void trleFLIPDecompImageHull(
WizRawPixel *bufferPtr, int bufferWidth, const Common::Rect *destRect,
- const byte *compData, const Common::Rect *sourceRect, const void *extraPtr,
+ const byte *compData, const Common::Rect *sourceRect, const byte *extraPtr,
const WizRawPixel *conversionTable,
void (*functionPtr)(Wiz *wiz,
WizRawPixel *destPtr, const byte *dataStream, int skipAmount,
- int decompAmount, const void *extraPtr, const WizRawPixel *conversionTable));
+ int decompAmount, const byte *extraPtr, const WizRawPixel *conversionTable));
void trleFLIPAltSourceDecompressImage(
WizRawPixel *destBufferPtr, const byte *compData, int destBufferWidth, int destBufferHeight,
@@ -817,7 +811,7 @@ public:
void trleFLIPAltSourceDecompressPrim(
WizRawPixel *destBufferPtr, int destBufferWidth, int destBufferHeight,
const void *altBufferPtr, int altBitsPerPixel,
- const COMPRESSEDIMAGE *imagePtr, int destX, int destY,
+ const WizCompressedImage *imagePtr, int destX, int destY,
const Common::Rect *sourceCoords, const Common::Rect *clipRectPtr,
int32 flags, const WizRawPixel *conversionTable,
void (*forewordFunctionPtr)(Wiz *wiz,
@@ -851,7 +845,7 @@ public:
WizImageCommand *optionalICmdPtr);
void trleFLIP90DegreeRotateCore(
- WizSimpleBitmap *dstBitmap, int x, int y, const COMPRESSEDIMAGE *imagePtr, const Common::Rect *optionalSrcRect,
+ WizSimpleBitmap *dstBitmap, int x, int y, const WizCompressedImage *imagePtr, const Common::Rect *optionalSrcRect,
const Common::Rect *optionalClipRect, bool hFlip, bool vFlip, const void *userParam, const WizRawPixel *conversionTable,
void (*functionPtr)(Wiz *wiz,
WizRawPixel *destPtr, const byte *dataStream, int skipAmount,
@@ -883,22 +877,22 @@ public:
*/
bool warpDrawWiz(int image, int state, int polygon, int32 flags, int transparentColor, WizSimpleBitmap *optionalDestBitmap, const WizRawPixel *optionalColorConversionTable, int shadowImage);
- bool warpDrawWizTo4Points(int image, int state, const WarpWizPoint *dstPoints, int32 flags, int transparentColor, const Common::Rect *optionalClipRect, WizSimpleBitmap *optionalDestBitmap, const WizRawPixel *optionalColorConversionTable, byte *colorMixTable);
+ bool warpDrawWizTo4Points(int image, int state, const WarpWizPoint *dstPoints, int32 flags, int transparentColor, const Common::Rect *optionalClipRect, WizSimpleBitmap *optionalDestBitmap, const WizRawPixel *optionalColorConversionTable, const byte *colorMixTable);
WarpWizOneSpanTable *warpCreateSpanTable(int spanCount);
void warpDestroySpanTable(WarpWizOneSpanTable *spanTable);
WarpWizOneSpanTable *warpBuildSpanTable(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizPoint *dstPts, const WarpWizPoint *srcPts, int npoints, const Common::Rect *clipRectPtr);
void warpProcessDrawSpansA(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizOneDrawSpan *drawSpans, int count);
void warpProcessDrawSpansTransparent(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizOneDrawSpan *drawSpans, int count, WizRawPixel transparentColor);
- void warpProcessDrawSpansTransparentFiltered(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizOneDrawSpan *drawSpans, int count, WizRawPixel transparentColor, byte *pXmapColorTable, bool bIsHintColor, WizRawPixel hintColor);
- void warpProcessDrawSpansMixColors(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizOneDrawSpan *drawSpans, int count, WizRawPixel transparentColor, byte *tablePtr);
+ void warpProcessDrawSpansTransparentFiltered(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizOneDrawSpan *drawSpans, int count, WizRawPixel transparentColor, const byte *pXmapColorTable, bool bIsHintColor, WizRawPixel hintColor);
+ void warpProcessDrawSpansMixColors(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizOneDrawSpan *drawSpans, int count, WizRawPixel transparentColor, const byte *tablePtr);
void warpFillSpanWithLine(WarpWizOneSpanTable *st, const WarpWizPoint *dstA, const WarpWizPoint *dstB, const WarpWizPoint *srcA, const WarpWizPoint *srcB);
void warpProcessDrawSpansSampled(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizOneDrawSpan *drawSpans, int count);
void warpProcessDrawSpansTransparentSampled(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap,const WarpWizOneDrawSpan *drawSpans, int count, WizRawPixel transparentColor);
bool warpNPt2NPtWarpCORE(WizSimpleBitmap *dstBitmap, const WarpWizPoint *dstpoints, const WizSimpleBitmap *srcBitmap, const WarpWizPoint *srcpoints, int npoints, int transparentColor, const Common::Rect *optionalClipRect, int32 wizFlags);
bool warpNPt2NPtNonClippedWarp(WizSimpleBitmap *dstBitmap, const WarpWizPoint *dstpoints, const WizSimpleBitmap *srcBitmap, const WarpWizPoint *srcpoints, int npoints, int transparentColor);
bool warpNPt2NPtClippedWarp(WizSimpleBitmap *dstBitmap, const WarpWizPoint *dstpoints, const WizSimpleBitmap *srcBitmap, const WarpWizPoint *srcpoints, int npoints, int transparentColor, const Common::Rect *optionalClipRect);
- bool warpNPt2NPtClippedWarpMixColors(WizSimpleBitmap *dstBitmap, const WarpWizPoint *dstpoints, const WizSimpleBitmap *srcBitmap, const WarpWizPoint *srcpoints, int npoints, int transparentColor, const Common::Rect *optionalClipRect, byte *colorMixTable);
- bool warpNPt2NPtNonClippedWarpFiltered(WizSimpleBitmap *dstBitmap, const WarpWizPoint *dstpoints, const WizSimpleBitmap *srcBitmap, const WarpWizPoint *srcpoints, int npoints, int transparentColor, byte *pXmapColorTable, bool bIsHintColor, WizRawPixel hintColor);
+ bool warpNPt2NPtClippedWarpMixColors(WizSimpleBitmap *dstBitmap, const WarpWizPoint *dstpoints, const WizSimpleBitmap *srcBitmap, const WarpWizPoint *srcpoints, int npoints, int transparentColor, const Common::Rect *optionalClipRect, const byte *colorMixTable);
+ bool warpNPt2NPtNonClippedWarpFiltered(WizSimpleBitmap *dstBitmap, const WarpWizPoint *dstpoints, const WizSimpleBitmap *srcBitmap, const WarpWizPoint *srcpoints, int npoints, int transparentColor, const byte *pXmapColorTable, bool bIsHintColor, WizRawPixel hintColor);
void warpFindMinMaxpoints(WarpWizPoint *minPtr, WarpWizPoint *maxPtr, const WarpWizPoint *points, int npoints);
};
diff --git a/engines/scumm/he/wizwarp_he.cpp b/engines/scumm/he/wizwarp_he.cpp
index 7916287ebd2..d437a7a6ea6 100644
--- a/engines/scumm/he/wizwarp_he.cpp
+++ b/engines/scumm/he/wizwarp_he.cpp
@@ -35,7 +35,7 @@ namespace Scumm {
#define WARP_FROM_FRAC(_x_) ((_x_) >> (WARP_FRAC_SIZE))
bool Wiz::warpDrawWiz(int image, int state, int polygon, int32 flags, int transparentColor, WizSimpleBitmap *optionalDestBitmap, const WizRawPixel *optionalColorConversionTable, int shadowImage) {
- byte *xmapColorTable;
+ const byte *xmapColorTable;
int polyIndex;
// Error check the params.
@@ -46,16 +46,16 @@ bool Wiz::warpDrawWiz(int image, int state, int polygon, int32 flags, int transp
}
if (ARRAYSIZE(_polygons) <= polyIndex) {
- error("Polygon %d not defined", polygon);
+ error("Wiz::warpDrawWiz(): Polygon %d not defined", polygon);
}
if (_polygons[polyIndex].numPoints != 5) {
- error("Invalid point count");
+ error("Wiz::warpDrawWiz(): Invalid point count");
}
// How to lock this bad boy down?
if (shadowImage) {
- xmapColorTable = (byte *)getColorMixBlockPtrForWiz(shadowImage);
+ xmapColorTable = getColorMixBlockPtrForWiz(shadowImage);
if (xmapColorTable) {
xmapColorTable += _vm->_resourceHeaderSize;
}
@@ -76,7 +76,7 @@ bool Wiz::warpDrawWiz(int image, int state, int polygon, int32 flags, int transp
nullptr, optionalDestBitmap, optionalColorConversionTable, xmapColorTable);
}
-bool Wiz::warpDrawWizTo4Points(int image, int state, const WarpWizPoint *dstPoints, int32 flags, int transparentColor, const Common::Rect *optionalClipRect, WizSimpleBitmap *optionalDestBitmap, const WizRawPixel *optionalColorConversionTable, byte *colorMixTable) {
+bool Wiz::warpDrawWizTo4Points(int image, int state, const WarpWizPoint *dstPoints, int32 flags, int transparentColor, const Common::Rect *optionalClipRect, WizSimpleBitmap *optionalDestBitmap, const WizRawPixel *optionalColorConversionTable, const byte *colorMixTable) {
WizSimpleBitmap dstBitmap, srcBitmap;
bool rValue, freeBitmapBits;
Common::Rect updateRect;
@@ -104,7 +104,7 @@ bool Wiz::warpDrawWizTo4Points(int image, int state, const WarpWizPoint *dstPoin
// Get a pointer to the bits!
ptr = (byte *)getWizStateDataPrim(image, state);
if (!ptr)
- error("Image %d missing data", image);
+ error("Wiz::warpDrawWizTo4Points(): Image %d missing data", image);
// Map the srcBitmap bits to the wiz data...
srcBitmap.bufferPtr = (WizRawPixel *)(ptr + _vm->_resourceHeaderSize);
@@ -126,7 +126,7 @@ bool Wiz::warpDrawWizTo4Points(int image, int state, const WarpWizPoint *dstPoin
}
if (!dstBitmap.bufferPtr) {
- error("Missing drawing buffer?");
+ error("Wiz::warpDrawWizTo4Points(): Missing drawing buffer?");
}
if (_uses16BitColor) {
@@ -261,7 +261,7 @@ void Wiz::warpDestroySpanTable(WarpWizOneSpanTable *spanTable) {
}
WarpWizOneSpanTable *Wiz::warpBuildSpanTable(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizPoint *dstPts, const WarpWizPoint *srcPts, int npoints, const Common::Rect *clipRectPtr) {
- int offset, dw, sw, nonClippedWidth, maxOffset, cl, cr, cy, dl, cw;
+ int offset, dw, nonClippedWidth, cl, cr, cy, dl, cw;
WarpWizPoint srcPt, dstPt, dstMinPt, dstMaxPt, srcMinPt, srcMaxPt, clippedPt;
WarpWizOneDrawSpan *drawSpan;
Common::Rect clippingRect;
@@ -311,10 +311,8 @@ WarpWizOneSpanTable *Wiz::warpBuildSpanTable(WizSimpleBitmap *dstBitmap, const W
// Build the draw span table!
drawSpan = st->drawSpans;
dw = dstBitmap->bitmapWidth;
- sw = srcBitmap->bitmapWidth;
span = st->spans;
offset = st->dstMinPt.y * dw;
- maxOffset = (dw * (dstBitmap->bitmapHeight - 1));
st->drawSpanCount = 0;
cy = st->dstMinPt.y;
@@ -487,7 +485,7 @@ void Wiz::warpProcessDrawSpansTransparent(WizSimpleBitmap *dstBitmap, const WizS
}
}
-void Wiz::warpProcessDrawSpansTransparentFiltered(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizOneDrawSpan *drawSpans, int count, WizRawPixel transparentColor, byte *pXmapColorTable, bool bIsHintColor, WizRawPixel hintColor) {
+void Wiz::warpProcessDrawSpansTransparentFiltered(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizOneDrawSpan *drawSpans, int count, WizRawPixel transparentColor, const byte *pXmapColorTable, bool bIsHintColor, WizRawPixel hintColor) {
int srcWidth = srcBitmap->bitmapWidth;
const WizRawPixel8 *src8 = (WizRawPixel8 *)srcBitmap->bufferPtr;
@@ -709,7 +707,7 @@ void Wiz::warpProcessDrawSpansTransparentFiltered(WizSimpleBitmap *dstBitmap, co
}
}
-void Wiz::warpProcessDrawSpansMixColors(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizOneDrawSpan *drawSpans, int count, WizRawPixel transparentColor, byte *tablePtr) {
+void Wiz::warpProcessDrawSpansMixColors(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizOneDrawSpan *drawSpans, int count, WizRawPixel transparentColor, const byte *tablePtr) {
int xStep, yStep, sw, xOffset, yOffset;
WizRawPixel srcColor;
@@ -739,14 +737,16 @@ void Wiz::warpProcessDrawSpansMixColors(WizSimpleBitmap *dstBitmap, const WizSim
if (!_uses16BitColor) {
srcColor = (*(src8 + (sw * WARP_FROM_FRAC(yOffset)) + WARP_FROM_FRAC(xOffset)));
if (srcColor != transparentColor) {
- *dst8++ = *(tablePtr + (srcColor * 256) + (*dst8));
+ *dst8 = *(tablePtr + (srcColor * 256) + (*dst8));
+ dst8++;
} else {
dst8++;
}
} else {
srcColor = *(src16 + (sw * WARP_FROM_FRAC(yOffset)) + WARP_FROM_FRAC(xOffset));
- *dst16++ = WIZRAWPIXEL_50_50_MIX(WIZRAWPIXEL_50_50_PREMIX_COLOR(srcColor), WIZRAWPIXEL_50_50_PREMIX_COLOR(*dst16));
+ *dst16 = WIZRAWPIXEL_50_50_MIX(WIZRAWPIXEL_50_50_PREMIX_COLOR(srcColor), WIZRAWPIXEL_50_50_PREMIX_COLOR(*dst16));
+ dst16++;
}
xOffset += xStep;
@@ -1085,7 +1085,7 @@ bool Wiz::warpNPt2NPtWarpCORE(WizSimpleBitmap *dstBitmap, const WarpWizPoint *ds
WarpWizOneSpanTable *st;
if ((srcBitmap->bitmapWidth >= WARP_TEXTURE_LIMIT) || (srcBitmap->bitmapHeight >= WARP_TEXTURE_LIMIT)) {
- error("Source bitmap (%d,%d) too big limit (%d,%d)",
+ error("Wiz::warpNPt2NPtWarpCORE(): Source bitmap (%d,%d) too big limit (%d,%d)",
srcBitmap->bitmapWidth, srcBitmap->bitmapHeight,
WARP_TEXTURE_LIMIT, WARP_TEXTURE_LIMIT);
}
@@ -1119,7 +1119,7 @@ bool Wiz::warpNPt2NPtWarpCORE(WizSimpleBitmap *dstBitmap, const WarpWizPoint *ds
return true;
}
- warning("Unable to warp bitmap");
+ warning("Wiz::warpNPt2NPtWarpCORE(): Unable to warp bitmap");
return false;
}
@@ -1132,7 +1132,7 @@ bool Wiz::warpNPt2NPtNonClippedWarp(WizSimpleBitmap *dstBitmap, const WarpWizPoi
WarpWizOneSpanTable *st;
if ((srcBitmap->bitmapWidth >= WARP_TEXTURE_LIMIT) || (srcBitmap->bitmapHeight >= WARP_TEXTURE_LIMIT)) {
- error("Source bitmap (%d,%d) too big limit (%d,%d)",
+ error("Wiz::warpNPt2NPtNonClippedWarp(): Source bitmap (%d,%d) too big limit (%d,%d)",
srcBitmap->bitmapWidth, srcBitmap->bitmapHeight,
WARP_TEXTURE_LIMIT, WARP_TEXTURE_LIMIT);
}
@@ -1154,7 +1154,7 @@ bool Wiz::warpNPt2NPtNonClippedWarp(WizSimpleBitmap *dstBitmap, const WarpWizPoi
return true;
} else {
- warning("Unable to warp bitmap");
+ warning("Wiz::warpNPt2NPtNonClippedWarp(): Unable to warp bitmap");
return false;
}
}
@@ -1169,7 +1169,7 @@ bool Wiz::warpNPt2NPtClippedWarp(WizSimpleBitmap *dstBitmap, const WarpWizPoint
WarpWizOneSpanTable *st;
if ((srcBitmap->bitmapWidth >= WARP_TEXTURE_LIMIT) || (srcBitmap->bitmapHeight >= WARP_TEXTURE_LIMIT)) {
- error("Source bitmap (%d,%d) too big limit (%d,%d)",
+ error("Wiz::warpNPt2NPtClippedWarp(): Source bitmap (%d,%d) too big limit (%d,%d)",
srcBitmap->bitmapWidth, srcBitmap->bitmapHeight,
WARP_TEXTURE_LIMIT, WARP_TEXTURE_LIMIT);
}
@@ -1190,17 +1190,17 @@ bool Wiz::warpNPt2NPtClippedWarp(WizSimpleBitmap *dstBitmap, const WarpWizPoint
warpDestroySpanTable(st);
return true;
} else {
- warning("Unable to warp bitmap");
+ warning("Wiz::warpNPt2NPtClippedWarp(): Unable to warp bitmap");
return false;
}
}
}
-bool Wiz::warpNPt2NPtClippedWarpMixColors(WizSimpleBitmap *dstBitmap, const WarpWizPoint *dstpoints, const WizSimpleBitmap *srcBitmap, const WarpWizPoint *srcpoints, int npoints, int transparentColor, const Common::Rect *optionalClipRect, byte *colorMixTable) {
+bool Wiz::warpNPt2NPtClippedWarpMixColors(WizSimpleBitmap *dstBitmap, const WarpWizPoint *dstpoints, const WizSimpleBitmap *srcBitmap, const WarpWizPoint *srcpoints, int npoints, int transparentColor, const Common::Rect *optionalClipRect, const byte *colorMixTable) {
WarpWizOneSpanTable *st;
if ((srcBitmap->bitmapWidth >= WARP_TEXTURE_LIMIT) || (srcBitmap->bitmapHeight >= WARP_TEXTURE_LIMIT)) {
- error("Source bitmap (%d,%d) too big limit (%d,%d)",
+ error("Wiz::warpNPt2NPtClippedWarpMixColors(): Source bitmap (%d,%d) too big limit (%d,%d)",
srcBitmap->bitmapWidth, srcBitmap->bitmapHeight,
WARP_TEXTURE_LIMIT, WARP_TEXTURE_LIMIT);
}
@@ -1218,16 +1218,16 @@ bool Wiz::warpNPt2NPtClippedWarpMixColors(WizSimpleBitmap *dstBitmap, const Warp
warpDestroySpanTable(st);
return true;
} else {
- warning("Unable to warp bitmap");
+ warning("Wiz::warpNPt2NPtClippedWarpMixColors(): Unable to warp bitmap");
return false;
}
}
-bool Wiz::warpNPt2NPtNonClippedWarpFiltered(WizSimpleBitmap *dstBitmap, const WarpWizPoint *dstpoints, const WizSimpleBitmap *srcBitmap, const WarpWizPoint *srcpoints, int npoints, int transparentColor, byte *pXmapColorTable, bool bIsHintColor, WizRawPixel hintColor) {
+bool Wiz::warpNPt2NPtNonClippedWarpFiltered(WizSimpleBitmap *dstBitmap, const WarpWizPoint *dstpoints, const WizSimpleBitmap *srcBitmap, const WarpWizPoint *srcpoints, int npoints, int transparentColor, const byte *pXmapColorTable, bool bIsHintColor, WizRawPixel hintColor) {
WarpWizOneSpanTable *st;
if ((srcBitmap->bitmapWidth >= WARP_TEXTURE_LIMIT) || (srcBitmap->bitmapHeight >= WARP_TEXTURE_LIMIT)) {
- error("Source bitmap (%d,%d) too big limit (%d,%d)",
+ error("Wiz::warpNPt2NPtNonClippedWarpFiltered(): Source bitmap (%d,%d) too big limit (%d,%d)",
srcBitmap->bitmapWidth, srcBitmap->bitmapHeight,
WARP_TEXTURE_LIMIT, WARP_TEXTURE_LIMIT);
}
@@ -1244,7 +1244,7 @@ bool Wiz::warpNPt2NPtNonClippedWarpFiltered(WizSimpleBitmap *dstBitmap, const Wa
return true;
} else {
- warning("Unable to warp bitmap");
+ warning("Wiz::warpNPt2NPtNonClippedWarpFiltered(): Unable to warp bitmap");
return false;
}
}
Commit: e70935815dc128c13b8fda4f744a2e8b3a2cd673
https://github.com/scummvm/scummvm/commit/e70935815dc128c13b8fda4f744a2e8b3a2cd673
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Fix AUX animations
Changed paths:
engines/scumm/actor.cpp
diff --git a/engines/scumm/actor.cpp b/engines/scumm/actor.cpp
index c5c60c2255f..5a500dcddf6 100644
--- a/engines/scumm/actor.cpp
+++ b/engines/scumm/actor.cpp
@@ -3580,24 +3580,27 @@ void ScummEngine_v71he::heFlushAuxQueues() {
yOffset -= a->getElevation();
}
- auxDataBlockPtr = findResourceData(MKTAG('A', 'K', 'A', 'X'), costumeAddress) - _resourceHeaderSize;
+ auxDataBlockPtr = findResourceData(MKTAG('A', 'K', 'A', 'X'), costumeAddress);
if (!auxDataBlockPtr) {
error("heFlushAuxQueue(): NO AKAX block actor %d!", whichActor);
+ } else {
+ auxDataBlockPtr -= _resourceHeaderSize;
}
- auxDataPtr = findPalInPals(auxDataBlockPtr, _heAuxAnimTable[i].auxIndex) - _resourceHeaderSize;
+ auxDataPtr = findPalInPals(auxDataBlockPtr, _heAuxAnimTable[i].auxIndex);
if (!auxDataPtr) {
error("heFlushAuxQueue(): NO AUXD block actor %d!", whichActor);
+ } else {
+ auxDataPtr -= _resourceHeaderSize;
}
// Check the type of the AUXD block...
- auxFrameDataPtr = findResourceData(MKTAG('A', 'X', 'F', 'D'), auxDataPtr) - _resourceHeaderSize;
+ auxFrameDataPtr = findResourceData(MKTAG('A', 'X', 'F', 'D'), auxDataPtr);
if (!auxFrameDataPtr) {
warning("heFlushAuxQueue(): NO AXFD block actor %d; ignoring...", whichActor);
continue;
}
- auxFrameDataPtr += _resourceHeaderSize;
type = READ_LE_UINT16(auxFrameDataPtr);
if ((type == AKOS_AUXD_TYPE_DRLE_FRAME) || (type == AKOS_AUXD_TYPE_SRLE_FRAME)) {
@@ -3629,7 +3632,6 @@ void ScummEngine_v71he::heFlushAuxQueues() {
continue;
}
- auxUpdateRectPtr += _resourceHeaderSize;
updateRects = READ_LE_UINT16(auxUpdateRectPtr);
auxUpdateRectPtr += 2;
@@ -3650,7 +3652,6 @@ void ScummEngine_v71he::heFlushAuxQueues() {
continue;
}
- auxEraseRectPtr += _resourceHeaderSize;
a->_auxActor = 1;
a->_auxEraseX1 = xOffset + (int16)READ_LE_UINT16(auxEraseRectPtr + 0);
a->_auxEraseY1 = yOffset + (int16)READ_LE_UINT16(auxEraseRectPtr + 2);
@@ -3720,7 +3721,6 @@ void ScummEngine_v90he::heFlushAuxQueues() {
continue;
}
- auxFrameDataPtr += _resourceHeaderSize;
type = READ_LE_UINT16(auxFrameDataPtr);
if ((type == AKOS_AUXD_TYPE_DRLE_FRAME) ||
@@ -3787,7 +3787,6 @@ void ScummEngine_v90he::heFlushAuxQueues() {
continue;
}
- auxUpdateRectPtr += _resourceHeaderSize;
updateRects = READ_LE_UINT16(auxUpdateRectPtr);
auxUpdateRectPtr += 2;
@@ -3809,7 +3808,6 @@ void ScummEngine_v90he::heFlushAuxQueues() {
continue;
}
- auxEraseRectPtr += _resourceHeaderSize;
a->_auxActor = 1;
a->_auxEraseX1 = xOffset + (int16)READ_LE_UINT16(auxEraseRectPtr + 0);
a->_auxEraseY1 = yOffset + (int16)READ_LE_UINT16(auxEraseRectPtr + 2);
@@ -3880,26 +3878,32 @@ void ScummEngine_v90he::heAuxGetAuxDataInfo(HEAnimAuxData *auxInfoPtr, int which
auxDataBlockPtr = findResourceData(MKTAG('A', 'K', 'A', 'X'), costumeAddress);
if (!auxDataBlockPtr) {
error("heAuxGetAuxDataInfo(): NO AKAX block actor %d!", whichActor);
+ } else {
+ auxDataBlockPtr -= _resourceHeaderSize;
}
auxDataPtr = findPalInPals(auxDataBlockPtr, auxIndex);
if (!auxDataPtr) {
- error("heAuxGetAuxDataInfo():NO AUXD block actor %d!", whichActor);
+ error("heAuxGetAuxDataInfo(): NO AUXD block actor %d!", whichActor);
+ } else {
+ auxDataPtr -= _resourceHeaderSize;
}
// Check for other outside block types
fileRelativeDataBlockPtr = findResourceData(MKTAG('F', 'R', 'E', 'L'), auxDataPtr);
if (fileRelativeDataBlockPtr) {
+ fileRelativeDataBlockPtr -= _resourceHeaderSize;
if (!heAuxProcessFileRelativeBlock(auxInfoPtr, fileRelativeDataBlockPtr)) {
error("heAuxGetAuxDataInfo(): Actor %d aux %d failed", whichActor, auxIndex);
}
}
// This is where the DISP block will be processed!
- displacedBlockPtr = findResourceData(MKTAG('D', 'I', 'S', 'P'), auxDataPtr);
+ displacedBlockPtr = findResourceData(MKTAG('D', 'I', 'S', 'P'), auxDataPtr) ;
if (displacedBlockPtr) {
+ displacedBlockPtr -= _resourceHeaderSize;
if (!heAuxProcessDisplacedBlock(auxInfoPtr, displacedBlockPtr)) {
error("heAuxGetAuxDataInfo(): Actor %d aux %d failed", whichActor, auxIndex);
}
Commit: c65097c05515414920affe991bd5e0a0b4ef4713
https://github.com/scummvm/scummvm/commit/c65097c05515414920affe991bd5e0a0b4ef4713
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Hopefully fix palette remapping for good
Changed paths:
engines/scumm/he/wiz_he.cpp
diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp
index c48b7eb0841..1701104f691 100644
--- a/engines/scumm/he/wiz_he.cpp
+++ b/engines/scumm/he/wiz_he.cpp
@@ -258,9 +258,9 @@ void *Wiz::drawAWizPrimEx(int globNum, int state, int x, int y, int z, int shado
if (!remap_p)
error("Wiz::drawAWizPrimEx(): %d state %d is missing a remap palette block", globNum, state);
- remapID = READ_LE_UINT32(remap_p + _vm->_resourceHeaderSize);
+ remapID = READ_BE_UINT32(remap_p + _vm->_resourceHeaderSize);
- if (remapID != WIZ_MAGIC_REMAP_NUMBER) {
+ if (_vm->_game.heversion <= 80 || remapID != WIZ_MAGIC_REMAP_NUMBER) {
if (remapID != _vm->_paletteChangedCounter) {
WRITE_LE_UINT32(remap_p + _vm->_resourceHeaderSize, _vm->_paletteChangedCounter);
Commit: e4b9e601d4b15a80caeecc2bd45ce117a82600ce
https://github.com/scummvm/scummvm/commit/e4b9e601d4b15a80caeecc2bd45ce117a82600ce
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Fix sprite ordering for HE95
Changed paths:
engines/scumm/he/sprite_he.cpp
diff --git a/engines/scumm/he/sprite_he.cpp b/engines/scumm/he/sprite_he.cpp
index 15326ccba62..18de2a2e131 100644
--- a/engines/scumm/he/sprite_he.cpp
+++ b/engines/scumm/he/sprite_he.cpp
@@ -1642,7 +1642,7 @@ void Sprite::buildActiveSpriteList() {
// Sort the list of active sprites...
if (_activeSpriteCount) {
- if (_vm->_game.heversion >= 95) {
+ if (_vm->_game.heversion > 95) {
qsort(_activeSprites, _activeSpriteCount, sizeof(SpriteInfo *), compareSpriteCombinedPriority);
} else {
qsort(_activeSprites, _activeSpriteCount, sizeof(SpriteInfo *), compareSpritePriority);
Commit: 25855773e7a2eb92bdc49363fc76e2b75767dc0e
https://github.com/scummvm/scummvm/commit/25855773e7a2eb92bdc49363fc76e2b75767dc0e
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Fix pixel color retrieval
Changed paths:
engines/scumm/he/gfx_comp/aux_comp.cpp
engines/scumm/he/wiz_he.cpp
engines/scumm/he/wiz_he.h
diff --git a/engines/scumm/he/gfx_comp/aux_comp.cpp b/engines/scumm/he/gfx_comp/aux_comp.cpp
index 987fed92ff8..0a2f43897d6 100644
--- a/engines/scumm/he/gfx_comp/aux_comp.cpp
+++ b/engines/scumm/he/gfx_comp/aux_comp.cpp
@@ -803,7 +803,7 @@ void Wiz::auxDecompRemappedTRLEPrim(WizRawPixel *bufferPtr, int bufferWidth, Com
}
}
-bool Wiz::auxHitTestTRLEXPos(const byte *dataStream, int skipAmount) {
+int Wiz::auxHitTestTRLEXPos(const byte *dataStream, int skipAmount) {
int runCount;
// Decompress bytes to do simple clipping...
@@ -814,7 +814,7 @@ bool Wiz::auxHitTestTRLEXPos(const byte *dataStream, int skipAmount) {
// Handle the transparent color...
runCount >>= 1;
if (runCount > skipAmount) {
- return false;
+ return 0;
} else {
skipAmount -= runCount;
}
@@ -824,7 +824,7 @@ bool Wiz::auxHitTestTRLEXPos(const byte *dataStream, int skipAmount) {
// Handle a run of color...
runCount = (runCount >> 2) + 1;
if (runCount > skipAmount) {
- return true;
+ return 1;
} else {
skipAmount -= runCount;
dataStream++;
@@ -834,7 +834,7 @@ bool Wiz::auxHitTestTRLEXPos(const byte *dataStream, int skipAmount) {
// Handle a literal run of pixels...
runCount = (runCount >> 2) + 1;
if (runCount > skipAmount) {
- return true;
+ return 1;
} else {
skipAmount -= runCount;
dataStream += runCount;
@@ -846,16 +846,16 @@ bool Wiz::auxHitTestTRLEXPos(const byte *dataStream, int skipAmount) {
runCount = *dataStream++;
if (runCount & 1) {
- return false;
+ return 0;
} else {
- return true;
+ return 1;
}
}
-bool Wiz::auxHitTestTRLEImageRelPos(const byte *compData, int x, int y, int width, int height) {
+int Wiz::auxHitTestTRLEImageRelPos(const byte *compData, int x, int y, int width, int height) {
// Quickly reject points outside the image boundry.
if ((x < 0) || (width <= x) || (y < 0) || (height <= y)) {
- return false;
+ return 0;
}
// Quickly skip down to the lines to be compressed & dest position...
@@ -866,11 +866,11 @@ bool Wiz::auxHitTestTRLEImageRelPos(const byte *compData, int x, int y, int widt
if (READ_LE_UINT16(compData) != 0) {
return auxHitTestTRLEXPos(compData + 2, x);
} else {
- return false;
+ return 0;
}
}
-bool Wiz::auxPixelHitTestTRLEXPos(byte *dataStream, int skipAmount, int transparentValue) {
+int Wiz::auxPixelHitTestTRLEXPos(byte *dataStream, int skipAmount, int transparentValue) {
int runCount;
// Decompress bytes to do simple clipping...
diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp
index 1701104f691..af3ef280602 100644
--- a/engines/scumm/he/wiz_he.cpp
+++ b/engines/scumm/he/wiz_he.cpp
@@ -726,7 +726,7 @@ int Wiz::hitTestWizPrim(int globNum, int state, int x, int y, int32 flags) {
src_d = _vm->findResourceData(MKTAG('W', 'I', 'Z', 'D'), dataTmp);
- return auxHitTestTRLEImageRelPos(src_d + _vm->_resourceHeaderSize, x, y, src_w, src_h) ? 1 : 0;
+ return auxHitTestTRLEImageRelPos(src_d + _vm->_resourceHeaderSize, x, y, src_w, src_h);
}
if (_vm->_game.heversion > 98) {
@@ -760,7 +760,7 @@ int Wiz::hitTestWizPrim(int globNum, int state, int x, int y, int32 flags) {
if (src_c == kWCTTRLE) {
src_d = getWizStateDataPrim(globNum, state);
- return auxHitTestTRLEImageRelPos(src_d + _vm->_resourceHeaderSize, x, y, src_w, src_h) ? 1 : 0;
+ return auxHitTestTRLEImageRelPos(src_d + _vm->_resourceHeaderSize, x, y, src_w, src_h);
} else if (_vm->_game.heversion > 98 && isUncompressedFormatTypeID(src_c)) {
WizSimpleBitmap srcBitmap;
diff --git a/engines/scumm/he/wiz_he.h b/engines/scumm/he/wiz_he.h
index 08d789970d1..d562989bed0 100644
--- a/engines/scumm/he/wiz_he.h
+++ b/engines/scumm/he/wiz_he.h
@@ -739,10 +739,10 @@ public:
void auxDecompRemappedTRLEImage(WizRawPixel *bufferPtr, const byte *compData, int bufferWidth, int bufferHeight, int x, int y, int width, int height, Common::Rect *clipRectPtr, byte *remapTable, const WizRawPixel *conversionTable);
void auxDecompRemappedTRLEPrim(WizRawPixel *bufferPtr, int bufferWidth, Common::Rect *destRect, const byte *compData, Common::Rect *sourceRect, byte *remapTable, const WizRawPixel *conversionTable);
- bool auxHitTestTRLEXPos(const byte *dataStream, int skipAmount);
- bool auxHitTestTRLEImageRelPos(const byte *compData, int x, int y, int width, int height);
- bool auxPixelHitTestTRLEXPos(byte *dataStream, int skipAmount, int transparentValue);
- int auxPixelHitTestTRLEImageRelPos(byte *compData, int x, int y, int width, int height, int transparentValue);
+ int auxHitTestTRLEXPos(const byte *dataStream, int skipAmount);
+ int auxHitTestTRLEImageRelPos(const byte *compData, int x, int y, int width, int height);
+ int auxPixelHitTestTRLEXPos(byte *dataStream, int skipAmount, int transparentValue);
+ int auxPixelHitTestTRLEImageRelPos(byte *compData, int x, int y, int width, int height, int transparentValue);
void auxDecompMixColorsTRLEImage(WizRawPixel *bufferPtr, byte *compData, int bufferWidth, int bufferHeight, int x, int y, int width, int height, Common::Rect *clipRectPtr, const byte *colorMixTable, const WizRawPixel *conversionTable);
void auxDecompMixColorsTRLEPrim(WizRawPixel *bufferPtr, int bufferWidth, Common::Rect *destRect, const byte *compData, Common::Rect *sourceRect, const byte *coloMixTable, const WizRawPixel *conversionTable);
Commit: 9cd1e63b53d26f6e2e3976b45fec6f1038e15257
https://github.com/scummvm/scummvm/commit/9cd1e63b53d26f6e2e3976b45fec6f1038e15257
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Fix Backyard games sprite ordering issues
Changed paths:
engines/scumm/detection_tables.h
engines/scumm/he/wiz_he.cpp
diff --git a/engines/scumm/detection_tables.h b/engines/scumm/detection_tables.h
index f44696753af..775e0edc0b0 100644
--- a/engines/scumm/detection_tables.h
+++ b/engines/scumm/detection_tables.h
@@ -338,9 +338,9 @@ static const GameSettings gameVariantsTable[] = {
// Added 16bit color
{"arttime", 0, 0, GID_HEGAME, 6, 99, MDT_NONE, GF_USE_KEY | GF_HE_LOCALIZED | GF_16BIT_COLOR, UNK, GUIO4(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT, GUIO_AUDIO_OVERRIDE)},
- {"baseball2001", 0, 0, GID_BASEBALL2001, 6, 99, MDT_NONE, GF_USE_KEY | GF_16BIT_COLOR, UNK, GUIO5(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT, GUIO_AUDIO_OVERRIDE, GUIO_NETWORK)},
+ {"baseball2001", 0, 0, GID_BASEBALL2001, 6, 99, MDT_NONE, GF_USE_KEY | GF_16BIT_COLOR | GF_HE_995, UNK, GUIO5(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT, GUIO_AUDIO_OVERRIDE, GUIO_NETWORK)},
{"readtime", 0, 0, GID_HEGAME, 6, 99, MDT_NONE, GF_USE_KEY | GF_HE_LOCALIZED | GF_16BIT_COLOR, UNK, GUIO4(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT, GUIO_AUDIO_OVERRIDE)},
- {"SoccerMLS", 0, 0, GID_SOCCERMLS, 6, 99, MDT_NONE, GF_USE_KEY | GF_HE_LOCALIZED | GF_16BIT_COLOR, UNK, GUIO4(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT, GUIO_AUDIO_OVERRIDE)},
+ {"SoccerMLS", 0, 0, GID_SOCCERMLS, 6, 99, MDT_NONE, GF_USE_KEY | GF_HE_LOCALIZED | GF_16BIT_COLOR | GF_HE_995, UNK, GUIO4(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT, GUIO_AUDIO_OVERRIDE)},
{"spyozon", 0, 0, GID_HEGAME, 6, 99, MDT_NONE, GF_USE_KEY | GF_HE_LOCALIZED | GF_16BIT_COLOR | GF_HE_995, UNK, GUIO4(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT, GUIO_AUDIO_OVERRIDE)},
{"freddicove", "", 0, GID_HEGAME, 6, 99, MDT_NONE, GF_USE_KEY | GF_HE_LOCALIZED | GF_16BIT_COLOR | GF_HE_995, UNK, GUIO4(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT, GUIO_AUDIO_OVERRIDE)},
diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp
index af3ef280602..bf7a71b71ff 100644
--- a/engines/scumm/he/wiz_he.cpp
+++ b/engines/scumm/he/wiz_he.cpp
@@ -1309,7 +1309,7 @@ void Wiz::processWizImageDrawCmd(const WizImageCommand *params) {
}
// See if the images are in their native format and twiddle if need be.
- if (_vm->_game.heversion > 99 || _vm->_isHE995) {
+ if (_vm->_game.heversion > 99) {
for (int i = 0; i < requiredImageCount; i++) {
ensureNativeFormatImageForState(requiredImages[i], state);
}
Commit: 30760ad7160784d8d11b0dfa4a5a791aa6ee63cd
https://github.com/scummvm/scummvm/commit/30760ad7160784d8d11b0dfa4a5a791aa6ee63cd
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Swap some tags with MKTAG macros
Changed paths:
engines/scumm/he/wiz_he.cpp
diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp
index bf7a71b71ff..1fe499a6793 100644
--- a/engines/scumm/he/wiz_he.cpp
+++ b/engines/scumm/he/wiz_he.cpp
@@ -1415,9 +1415,9 @@ void Wiz::dwCreateRawWiz(int imageNum, int w, int h, int flags, int bitsPerPixel
break;
}
- WRITE_BE_UINT32(writePtr, 'AWIZ'); writePtr += 4;
+ WRITE_BE_UINT32(writePtr, MKTAG('A', 'W', 'I', 'Z')); writePtr += 4;
WRITE_BE_UINT32(writePtr, globSize); writePtr += 4;
- WRITE_BE_UINT32(writePtr, 'WIZH'); writePtr += 4;
+ WRITE_BE_UINT32(writePtr, MKTAG('W', 'I', 'Z', 'H')); writePtr += 4;
WRITE_BE_UINT32(writePtr, WIZBLOCK_WIZH_SIZE); writePtr += 4;
WRITE_LE_UINT32(writePtr, compressionType); writePtr += 4;
WRITE_LE_UINT32(writePtr, w); writePtr += 4;
@@ -1431,7 +1431,7 @@ void Wiz::dwCreateRawWiz(int imageNum, int w, int h, int flags, int bitsPerPixel
palPtr = _vm->_currentPalette;
}
- WRITE_BE_UINT32(writePtr, 'RGBS'); writePtr += 4;
+ WRITE_BE_UINT32(writePtr, MKTAG('R', 'G', 'B', 'S')); writePtr += 4;
WRITE_BE_UINT32(writePtr, WIZBLOCK_RGBS_SIZE); writePtr += 4;
memcpy(writePtr, palPtr, WIZBLOCK_RGBS_DATA_SIZE);
@@ -1439,7 +1439,7 @@ void Wiz::dwCreateRawWiz(int imageNum, int w, int h, int flags, int bitsPerPixel
}
if (flags & kCWFSpot) {
- WRITE_BE_UINT32(writePtr, 'SPOT'); writePtr += 4;
+ WRITE_BE_UINT32(writePtr, MKTAG('S', 'P', 'O', 'T')); writePtr += 4;
WRITE_BE_UINT32(writePtr, WIZBLOCK_SPOT_SIZE); writePtr += 4;
WRITE_BE_UINT32(writePtr + 0, optionalSpotX);
WRITE_BE_UINT32(writePtr + 4, optionalSpotY);
@@ -1448,7 +1448,7 @@ void Wiz::dwCreateRawWiz(int imageNum, int w, int h, int flags, int bitsPerPixel
}
if (flags & kCWFRemapTable) {
- WRITE_BE_UINT32(writePtr, 'RMAP'); writePtr += 4;
+ WRITE_BE_UINT32(writePtr, MKTAG('R', 'M', 'A', 'P')); writePtr += 4;
WRITE_BE_UINT32(writePtr, WIZBLOCK_RMAP_SIZE); writePtr += 4;
WRITE_BE_UINT32(writePtr, 0); writePtr += 4;
@@ -1457,7 +1457,7 @@ void Wiz::dwCreateRawWiz(int imageNum, int w, int h, int flags, int bitsPerPixel
}
}
- WRITE_BE_UINT32(writePtr, 'WIZD'); writePtr += 4;
+ WRITE_BE_UINT32(writePtr, MKTAG('W','I', 'Z', 'D')); writePtr += 4;
WRITE_BE_UINT32(writePtr, 8 + wizdSize); writePtr += 4;
}
Commit: 12f511928a0b9a366ce0cf9bbd517eefbcbc5865
https://github.com/scummvm/scummvm/commit/12f511928a0b9a366ce0cf9bbd517eefbcbc5865
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Cleanup
Changed paths:
engines/scumm/actor.cpp
engines/scumm/he/sprite_he.cpp
engines/scumm/he/sprite_he.h
diff --git a/engines/scumm/actor.cpp b/engines/scumm/actor.cpp
index 5a500dcddf6..9b9f1713873 100644
--- a/engines/scumm/actor.cpp
+++ b/engines/scumm/actor.cpp
@@ -3616,13 +3616,13 @@ void ScummEngine_v71he::heFlushAuxQueues() {
backgroundBufferPtr = pvs->getBackPixels(0, pvs->topline);
if (type == AKOS_AUXD_TYPE_SRLE_FRAME) {
- error("Unimplemented compression type actor %d!", whichActor);
+ error("heFlushAuxQueue(): Unimplemented compression type actor %d!", whichActor);
} else if (type == AKOS_AUXD_TYPE_DRLE_FRAME) {
_wiz->auxDecompDRLEImage(
(WizRawPixel *)foregroundBufferPtr, (WizRawPixel *)backgroundBufferPtr, auxFrameDataPtr,
pvs->w, pvs->h, x, y, w, h, nullptr, nullptr);
} else {
- error("Unimplemented compression type actor %d!", whichActor);
+ error("heFlushAuxQueue(): Unimplemented compression type actor %d!", whichActor);
}
}
diff --git a/engines/scumm/he/sprite_he.cpp b/engines/scumm/he/sprite_he.cpp
index 18de2a2e131..f3decbcedd2 100644
--- a/engines/scumm/he/sprite_he.cpp
+++ b/engines/scumm/he/sprite_he.cpp
@@ -1461,9 +1461,7 @@ void Sprite::eraseSprites() {
}
}
- // Erase the sprites as a bunch, hopefuly this will be faster
- // Also set the bits so that any "actors" that are in the area
- // will also be updated!
+ // Erase the cumulative sprites rectangle
if (valid) {
_vm->backgroundToForegroundBlit(eraseRect, USAGE_BIT_RESTORED);
}
diff --git a/engines/scumm/he/sprite_he.h b/engines/scumm/he/sprite_he.h
index 61ebc925560..8ec4ef325bb 100644
--- a/engines/scumm/he/sprite_he.h
+++ b/engines/scumm/he/sprite_he.h
@@ -227,10 +227,10 @@ public:
int16 *_imageListStack;
int32 _imageListStackIndex = 0;
- int32 _activeSpriteCount;
- int32 _maxSpriteGroups;
- int32 _maxSprites;
- int32 _maxImageLists;
+ int32 _activeSpriteCount = 0;
+ int32 _maxSpriteGroups = 0;
+ int32 _maxSprites = 0;
+ int32 _maxImageLists = 0;
void saveLoadWithSerializer(Common::Serializer &s) override;
void eraseSprites();
Commit: 6c5949d8de3f74529a938e5b872ac813a2df4699
https://github.com/scummvm/scummvm/commit/6c5949d8de3f74529a938e5b872ac813a2df4699
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Fix glitched bottom left score table on BASEBALL97
Changed paths:
engines/scumm/he/sprite_he.cpp
engines/scumm/he/wiz_he.cpp
diff --git a/engines/scumm/he/sprite_he.cpp b/engines/scumm/he/sprite_he.cpp
index f3decbcedd2..9e2d6fa0fec 100644
--- a/engines/scumm/he/sprite_he.cpp
+++ b/engines/scumm/he/sprite_he.cpp
@@ -1515,11 +1515,12 @@ void Sprite::checkForForcedRedraws(bool checkOnlyPositivePriority) {
continue;
}
- if (_vm->_game.heversion > 90) {
+ // NOTE: Apparently some HE90 games still have this in their code...
+ //if (_vm->_game.heversion > 90) {
if (checkOnlyPositivePriority && (spritePtr[i]->priority < 0)) {
continue;
}
- }
+ //}
if (kSFSmartRender & flags) {
if (doesRectIntersectUpdateAreas(&spritePtr[i]->lastRect)) {
diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp
index 1fe499a6793..8f4dfa64887 100644
--- a/engines/scumm/he/wiz_he.cpp
+++ b/engines/scumm/he/wiz_he.cpp
@@ -65,9 +65,9 @@ void Wiz::takeAWiz(int globnum, int x1, int y1, int x2, int y2, bool back, bool
bufferHeight = pvs->h;
if (back) {
- srcPtr = (WizRawPixel *)pvs->getPixels(0, 0);
- } else {
srcPtr = (WizRawPixel *)pvs->getBackPixels(0, 0);
+ } else {
+ srcPtr = (WizRawPixel *)pvs->getPixels(0, 0);
}
rect.left = x1;
Commit: ee2bf64267bc643ce2d1bccc96a2c655b82b7c40
https://github.com/scummvm/scummvm/commit/ee2bf64267bc643ce2d1bccc96a2c655b82b7c40
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Fix typo in palette remapping function
Changed paths:
engines/scumm/he/palette_he.cpp
diff --git a/engines/scumm/he/palette_he.cpp b/engines/scumm/he/palette_he.cpp
index 0b5abdedf31..5cf7f592019 100644
--- a/engines/scumm/he/palette_he.cpp
+++ b/engines/scumm/he/palette_he.cpp
@@ -42,7 +42,7 @@ void ScummEngine_v71he::buildRemapTable(byte *remapTablePtr, const byte *palDPtr
for (int inner = 10; inner < 246; inner++) {
const byte *clutSrcEntry = &palSPtr[outer * 3];
- const byte *clutDstEntry = &palSPtr[inner * 3];
+ const byte *clutDstEntry = &palDPtr[inner * 3];
distance = (
(int32)((clutSrcEntry[0] - clutDstEntry[0]) * (clutSrcEntry[0] - clutDstEntry[0])) +
Commit: 8f4b909f38531c2fb21c44eefa731cdf1b744782
https://github.com/scummvm/scummvm/commit/8f4b909f38531c2fb21c44eefa731cdf1b744782
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Comments and styling clean-up
Changed paths:
engines/scumm/he/gfx_comp/aux_comp.cpp
engines/scumm/he/gfx_comp/mrle_comp.cpp
engines/scumm/he/gfx_comp/trle_comp.cpp
engines/scumm/he/gfx_primitives_he.cpp
engines/scumm/he/sprite_he.cpp
engines/scumm/he/wiz_he.cpp
engines/scumm/he/wizwarp_he.cpp
diff --git a/engines/scumm/he/gfx_comp/aux_comp.cpp b/engines/scumm/he/gfx_comp/aux_comp.cpp
index 0a2f43897d6..e4fb5c4ce75 100644
--- a/engines/scumm/he/gfx_comp/aux_comp.cpp
+++ b/engines/scumm/he/gfx_comp/aux_comp.cpp
@@ -466,7 +466,7 @@ void Wiz::auxDecompDRLEPrim(WizRawPixel *foregroundBufferPtr, WizRawPixel *backg
compData += READ_LE_UINT16(compData) + 2;
}
- // Decompress all the lines that are visible!!!!
+ // Decompress all the lines that are visible...
while (decompHeight-- > 0) {
lineSize = READ_LE_UINT16(compData);
@@ -577,7 +577,7 @@ void Wiz::auxDecompTRLEPrim(WizRawPixel *bufferPtr, int bufferWidth, Common::Rec
compData += READ_LE_UINT16(compData) + 2;
}
- // Decompress all the lines that are visible!!!!
+ // Decompress all the lines that are visible...
while (decompHeight-- > 0) {
lineSize = READ_LE_UINT16(compData);
@@ -678,7 +678,7 @@ void Wiz::auxDrawZplaneFromTRLEPrim(byte *zplanePtr, int zplanePixelWidth, Commo
compData += READ_LE_UINT16(compData) + 2;
}
- // Decompress all the lines that are visible!!!!
+ // Decompress all the lines that are visible...
while (decompHeight-- > 0) {
lineSize = READ_LE_UINT16(compData);
@@ -778,7 +778,7 @@ void Wiz::auxDecompRemappedTRLEPrim(WizRawPixel *bufferPtr, int bufferWidth, Com
compData += READ_LE_UINT16(compData) + 2;
}
- // Decompress all the lines that are visible!!!!
+ // Decompress all the lines that are visible...
while (decompHeight-- > 0) {
lineSize = READ_LE_UINT16(compData);
@@ -1020,7 +1020,7 @@ void Wiz::auxDecompMixColorsTRLEPrim(WizRawPixel *bufferPtr, int bufferWidth, Co
compData += READ_LE_UINT16(compData) + 2;
}
- // Decompress all the lines that are visible!!!!
+ // Decompress all the lines that are visible...
while (decompHeight-- > 0) {
lineSize = READ_LE_UINT16(compData);
@@ -1678,7 +1678,7 @@ void Wiz::auxHistogramTRLEPrim(int *histogramTablePtr, byte *compData, Common::R
compData += READ_LE_UINT16(compData) + 2;
}
- // Decompress all the lines that are visible!!!!
+ // Decompress all the lines that are visible...
while (decompHeight-- > 0) {
lineSize = READ_LE_UINT16(compData);
diff --git a/engines/scumm/he/gfx_comp/mrle_comp.cpp b/engines/scumm/he/gfx_comp/mrle_comp.cpp
index 2f2681818aa..9991d4d7801 100644
--- a/engines/scumm/he/gfx_comp/mrle_comp.cpp
+++ b/engines/scumm/he/gfx_comp/mrle_comp.cpp
@@ -299,7 +299,7 @@ static void mrleFLIPAltSourceDecompImageHull(Wiz *wiz,
compData += READ_LE_UINT16(compData) + 2;
}
- // Calc the ALT buffer location
+ // Calc the ALT buffer location...
altSourceBuffer += (altBytesPerLine * altRect->top) + (altRect->left * altBytesPerPixel);
// Flip the dest offset if vertical flipping...
@@ -308,7 +308,7 @@ static void mrleFLIPAltSourceDecompImageHull(Wiz *wiz,
altBytesPerLine = -altBytesPerLine;
}
- // Decompress all the lines that are visible!!!!
+ // Decompress all the lines that are visible...
while (decompHeight-- > 0) {
lineSize = READ_LE_UINT16(compData);
diff --git a/engines/scumm/he/gfx_comp/trle_comp.cpp b/engines/scumm/he/gfx_comp/trle_comp.cpp
index 5236a0d5749..81b05496d3d 100644
--- a/engines/scumm/he/gfx_comp/trle_comp.cpp
+++ b/engines/scumm/he/gfx_comp/trle_comp.cpp
@@ -210,16 +210,16 @@ void Wiz::trleFLIPCheckAlphaSetup() {
if (_initializeAlphaTable && _uses16BitColor) {
_initializeAlphaTable = false;
- // int alpha to float table
+ // Create the int alpha to float table...
for (int i = 1; i < 255; i++) {
_alphaTable[i] = (float)i / 255.0f;
}
- // Force 0 & 255 values just incase the float accuracy is bad.
+ // Force 0 & 255 values just in case the float accuracy is bad...
_alphaTable[0] = 0.0f;
_alphaTable[255] = 1.0f;
- // Quantized pre-computed alpha results.
+ // Quantized pre-computed alpha results...
int alpha_index = 0;
for (int alpha = 0; alpha < 256; alpha += WIZ_QUANTIZED_ALPHA_DIV, alpha_index++) {
@@ -303,7 +303,7 @@ void Wiz::trleFLIPDecompImageHull(
bufferWidth = -bufferWidth;
}
- // Decompress all the lines that are visible!!!!
+ // Decompress all the lines that are visible...
while (decompHeight-- > 0) {
lineSize = READ_LE_UINT16(compData);
@@ -1413,7 +1413,7 @@ void Wiz::trleFLIPDecompressImage(
trleFLIPDecompressPrim(
&fakeBitmap, &fakeImage, x, y, nullptr, clipRectPtr, extraTable, wizFlags, conversionTable,
trleFLIPLookupDecompressLineForeword, trleFLIPLookupDecompressLineBackward);
- } else /* if (wizFlags & kWRFUseShadow) */ {
+ } else if ((wizFlags & kWRFUseShadow) != 0 || _vm->_game.heversion > 98) {
trleFLIPDecompressPrim(
&fakeBitmap, &fakeImage, x, y, nullptr, clipRectPtr, extraTable, wizFlags, conversionTable,
trleFLIPMixDecompressLineForeword,
@@ -1500,7 +1500,7 @@ void Wiz::trleFLIPRotate90DecompressImage(
(wizFlags & kWRFHFlip), (wizFlags & kWRFVFlip),
extraTable, conversionTable,
trleFLIPLookupArbitraryDstStepDecompressLine);
- } else /* if (wizFlags & kWRFUseShadow) */ {
+ } else if ((wizFlags & kWRFUseShadow) != 0 || _vm->_game.heversion > 98) {
trleFLIP90DegreeRotateCore(
&fakeBitmap, x, y, &fakeImage, nullptr, clipRectPtr,
(wizFlags & kWRFHFlip), (wizFlags & kWRFVFlip),
@@ -2032,7 +2032,7 @@ void Wiz::trleFLIPAltSourceDecompImageHull(
compData += READ_LE_UINT16(compData) + 2;
}
- // Calc the ALT buffer location
+ // Calc the ALT buffer location...
altSourceBuffer += (altBytesPerLine * altRect->top) + (altRect->left * altBytesPerPixel);
// Flip the dest offset if vertical flipping...
@@ -2041,7 +2041,7 @@ void Wiz::trleFLIPAltSourceDecompImageHull(
altBytesPerLine = -altBytesPerLine;
}
- // Decompress all the lines that are visible!!!!
+ // Decompress all the lines that are visible...
while (decompHeight-- > 0) {
lineSize = READ_LE_UINT16(compData);
@@ -2181,7 +2181,7 @@ bool Wiz::trleFLIPAltSourceSpecialCaseDispatch(
return false;
}
- // General setup
+ // General setup...
Common::Rect srcRect, clipRect;
WizCompressedImage fakeImage;
@@ -2548,7 +2548,7 @@ int Wiz::trleRLECompression(byte *pdest, const WizRawPixel *psource, int rowsize
break;
}
- // check to see if too literal run too big if so dump it
+ // Check to see if too literal run too big if so dump it...
if (nbuf > TRLE_MAXDAT) {
dest = trlePutDump(dest, nbuf - 1);
_trleBuf[0] = c;
diff --git a/engines/scumm/he/gfx_primitives_he.cpp b/engines/scumm/he/gfx_primitives_he.cpp
index a74b03196c8..6b7cf9042fc 100644
--- a/engines/scumm/he/gfx_primitives_he.cpp
+++ b/engines/scumm/he/gfx_primitives_he.cpp
@@ -123,16 +123,16 @@ int scanEdge(WizScanLine *aScanLines, int iScanLineStart, bool bLeftSide, int iX
int iDX, iDY;
double fInverseSlope;
- // Get deltas
+ // Get deltas...
iDX = iX2 - iX1;
iDY = iY2 - iY1;
- // Protect against horizontal lines
+ // Protect against horizontal lines...
if (iDY <= 0) {
return 0;
}
- // Calculate inverse slope
+ // Calculate inverse slope...
fInverseSlope = (double)iDX / (double)iDY;
for (int iY = iY1; iY < iY2; ++iY) {
@@ -153,7 +153,7 @@ void Wiz::pgClippedThickLineDraw(WizSimpleBitmap *destBM, int asx, int asy, int
int iDY = aey - asy;
double fDistance = sqrt((iDX * iDX) + (iDY * iDY));
- // if distance is 0, don't draw
+ // If distance is 0, don't draw...
if (fDistance == 0) {
return;
}
@@ -165,7 +165,7 @@ void Wiz::pgClippedThickLineDraw(WizSimpleBitmap *destBM, int asx, int asy, int
float fDDX = -fScale * (float)iDY;
float fDDY = fScale * (float)iDX;
- if (fDDX > 0) { // round off
+ if (fDDX > 0) { // Round off
fDDX += 0.5;
} else {
fDDX -= 0.5;
@@ -182,8 +182,8 @@ void Wiz::pgClippedThickLineDraw(WizSimpleBitmap *destBM, int asx, int asy, int
int aSortOrder[4] = { 0, 0, 0, 0 };
- // determine point order of polygons based on line orientation
- // topmost (and topleft in case of x or y = 0)
+ // Determine point order of polygons based on line orientation
+ // topmost (and topleft in case of x or y = 0)...
if ((iDX >= 0) && (iDY < 0)) {
aSortOrder[0] = 1;
aSortOrder[1] = 2;
@@ -229,21 +229,21 @@ void Wiz::pgClippedThickLineDraw(WizSimpleBitmap *destBM, int asx, int asy, int
xPoints[aSortOrder[3]] = aex + iCompDX;
yPoints[aSortOrder[3]] = aey + iCompDY;
- // determine how tall (how many scan lines) the polygon is
+ // Determine how tall (how many scan lines) the polygon is...
int iNumScanLines = yPoints[2] - yPoints[0];
- // create scan line list
+ // Create scan line list...
WizScanLine *aScanLines = new WizScanLine[iNumScanLines];
- // scan left side
+ // Scan left side...
int iNextScanLine = scanEdge(aScanLines, 0, true, xPoints[0], yPoints[0], xPoints[1], yPoints[1]);
scanEdge(aScanLines, iNextScanLine, true, xPoints[1], yPoints[1], xPoints[2], yPoints[2]);
- // scan right side
+ // Scan right side...
iNextScanLine = scanEdge(aScanLines, 0, false, xPoints[0], yPoints[0], xPoints[3], yPoints[3]);
scanEdge(aScanLines, iNextScanLine, false, xPoints[3], yPoints[3], xPoints[2], yPoints[2]);
- // draw polygon
+ // Draw polygon...
int iCurX, iCurY;
for (int iWhichScanLine = 0; iWhichScanLine < iNumScanLines; ++iWhichScanLine) {
iCurY = iWhichScanLine + yPoints[0];
@@ -262,12 +262,12 @@ int convertFromFixed(int iFixedNumber) {
}
void Wiz::pgDrawClippedEllipse(WizSimpleBitmap *pDestBitmap, int iPX, int iPY, int iQX, int iQY, int iKX, int iKY, int iLOD, const Common::Rect *pClipRectPtr, int iThickness, WizRawPixel aColor) {
- // since this is fixed point, limit the LOD to 14 bits precision
+ // Since this is fixed point, limit the LOD to 14 bits precision...
if (iLOD > kWECFixedSize - 2) {
iLOD = kWECFixedSize - 2;
}
- // determine the rest of the rectangle verts using the midpoint formula
+ // Determine the rest of the rectangle verts using the midpoint formula...
int iKX1 = (2 * iQX) - iKX;
int iKY1 = (2 * iQY) - iKY;
int iKX3 = (2 * iPX) - iKX;
@@ -283,11 +283,11 @@ void Wiz::pgDrawClippedEllipse(WizSimpleBitmap *pDestBitmap, int iPX, int iPY, i
bool bFirstPass = true;
int x1 = 0, y1 = 0, x2 = 0, y2 = 0, iFirstX = 0, iFirstY = 0;
- // Loop through each quadrant
+ // Loop through each quadrant...
for (int iSide = 0; iSide < 4; ++iSide) {
int xP = 0, yP = 0, xQ = 0, yQ = 0, xK = 0, yK = 0;
- // Determine quadrant and convert input to fixed point
+ // Determine quadrant and convert input to fixed point...
switch (iSide) {
case 0:
xP = convertToFixed(iPX);
@@ -325,21 +325,21 @@ void Wiz::pgDrawClippedEllipse(WizSimpleBitmap *pDestBitmap, int iPX, int iPY, i
int vx, ux, vy, uy, w, xJ, yJ;
- vx = xK - xQ; // Displacements from center
+ vx = xK - xQ; // Displacements from center...
ux = xK - xP;
vy = yK - yQ;
uy = yK - yP;
- xJ = xP - vx + kWECHalf; // Center of ellipse J
+ xJ = xP - vx + kWECHalf; // Center of ellipse J...
yJ = yP - vy + kWECHalf;
- ux -= (w = ux >> (2 * iLOD + 3)); // Cancel 2nd-order error
- ux -= (w >>= (2 * iLOD + 4)); // Cancel 4th-order error
- ux -= w >> (2 * iLOD + 3); // Cancel 6th-order error
- ux += vx >> (iLOD + 1); // Cancel 1st-order error
- uy -= (w = uy >> (2 * iLOD + 3)); // Cancel 2nd-order error
- uy -= (w >>= (2 * iLOD + 4)); // Cancel 4th-order error
- uy -= w >> (2 * iLOD + 3); // Cancel 6th-order error
- uy += vy >> (iLOD + 1); // Cancel 1st-order error
+ ux -= (w = ux >> (2 * iLOD + 3)); // Cancel 2nd-order error...
+ ux -= (w >>= (2 * iLOD + 4)); // Cancel 4th-order error...
+ ux -= w >> (2 * iLOD + 3); // Cancel 6th-order error...
+ ux += vx >> (iLOD + 1); // Cancel 1st-order error...
+ uy -= (w = uy >> (2 * iLOD + 3)); // Cancel 2nd-order error...
+ uy -= (w >>= (2 * iLOD + 4)); // Cancel 4th-order error...
+ uy -= w >> (2 * iLOD + 3); // Cancel 6th-order error...
+ uy += vy >> (iLOD + 1); // Cancel 1st-order error...
for (int i = (kWECPiOver2 << iLOD) >> 16; i >= 0; --i) {
x2 = (xJ + vx) >> 16;
@@ -355,7 +355,7 @@ void Wiz::pgDrawClippedEllipse(WizSimpleBitmap *pDestBitmap, int iPX, int iPY, i
if (iThickness > 0) {
pgClippedThickLineDraw(pDestBitmap, x1, y1, x2, y2, pClipRectPtr, 5, aColor);
} else {
- // specific to print pack, should be moved to a thick pixel
+ // Specific to print pack, should be moved to a thick pixel...
pgClippedWritePixel(pDestBitmap, x2, y2, pClipRectPtr, aColor);
pgClippedWritePixel(pDestBitmap, x2 + 1, y2, pClipRectPtr, aColor);
pgClippedWritePixel(pDestBitmap, x2 - 1, y2, pClipRectPtr, aColor);
@@ -434,7 +434,7 @@ void Wiz::pgFloodFillCmd(int x, int y, int color, const Common::Rect *optionalCl
// Strip the color info down...
colorToWrite = getRawPixel(color);
- // Call the primitive
+ // Call the primitive...
updateRect.left = updateRect.top = 12345;
updateRect.right = updateRect.bottom = -12345;
@@ -500,8 +500,6 @@ void Wiz::pgDrawRawDataFormatImage(WizRawPixel *bufferPtr, const WizRawPixel *ra
WizSimpleBitmap srcBitmap, dstBitmap;
int off, t;
- // Build the dest bitmap clipping rect and clip the "CLIP"
- // rect passed in to it.
clipRect.left = 0;
clipRect.top = 0;
clipRect.right = bufferWidth - 1;
@@ -513,7 +511,7 @@ void Wiz::pgDrawRawDataFormatImage(WizRawPixel *bufferPtr, const WizRawPixel *ra
}
}
- // Build the src and dest rects based on the passed in coords
+ // Build the src and dest rects based on the passed in coords...
srcRect.left = 0;
srcRect.top = 0;
srcRect.right = (width - 1);
@@ -524,7 +522,7 @@ void Wiz::pgDrawRawDataFormatImage(WizRawPixel *bufferPtr, const WizRawPixel *ra
dstRect.right = (x + width - 1);
dstRect.bottom = (y + height - 1);
- // Clip the src & dst coords to the clipping rect
+ // Clip the src & dst coords to the clipping rect...
clipRectCoords(&srcRect, &dstRect, &clipRect);
if (dstRect.right < dstRect.left) {
@@ -1027,8 +1025,6 @@ void Wiz::pgDraw8BppFormatImage(WizRawPixel *bufferPtr, const byte *rawData, int
Common::Rect srcRect, dstRect, clipRect;
WizSimpleBitmap srcBitmap, dstBitmap;
- // Build the dest bitmap clipping rect and clip the "CLIP"
- // rect passed in to it.
clipRect.left = 0;
clipRect.top = 0;
clipRect.right = bufferWidth - 1;
@@ -1040,7 +1036,7 @@ void Wiz::pgDraw8BppFormatImage(WizRawPixel *bufferPtr, const byte *rawData, int
}
}
- // Build the src and dest rects based on the passed in coords
+ // Build the src and dest rects based on the passed in coords...
srcRect.left = 0;
srcRect.top = 0;
srcRect.right = (width - 1);
@@ -1051,7 +1047,7 @@ void Wiz::pgDraw8BppFormatImage(WizRawPixel *bufferPtr, const byte *rawData, int
dstRect.right = (x + width - 1);
dstRect.bottom = (y + height - 1);
- // Clip the src & dst coords to the clipping rect
+ // Clip the src & dst coords to the clipping rect...
clipRectCoords(&srcRect, &dstRect, &clipRect);
if (dstRect.right < dstRect.left) {
@@ -1205,27 +1201,27 @@ void Wiz::pgDraw8BppTransparentSimpleBlit(WizSimpleBitmap *destBM, Common::Rect
}
void Wiz::pgDrawImageWith16BitZBuffer(WizSimpleBitmap *psbDst, const WizSimpleBitmap *psbZBuffer, const byte *imgData, int x, int y, int z, int width, int height, Common::Rect *prcClip) {
- // This is available only on HE100+, which hopefully means it should only be called for 16-bit games
+ // This is available only on HE100+, which hopefully means it should only be called for 16-bit games!
assert(_uses16BitColor);
- // Validate parameters
+ // Validate parameters...
assert(psbDst && psbZBuffer && imgData && prcClip);
- // z-buffer and destination buffer must have the same dimensions
+ // Z-Buffer and destination buffer must have the same dimensions...
assert(psbDst->bitmapWidth == psbZBuffer->bitmapWidth);
assert(psbDst->bitmapHeight == psbZBuffer->bitmapHeight);
- // make sure that clip rect is clipped to destination buffer
+ // Make sure that clip rect is clipped to destination buffer...
Common::Rect dstRect;
makeSizedRect(&dstRect, psbDst->bitmapWidth, psbDst->bitmapHeight);
if (!findRectOverlap(prcClip, &dstRect)) {
- // rectangles don't intersect - no drawing necessary
+ // Rectangles don't intersect - no drawing necessary...
return;
}
- // make sure that clip rect is clipped to source image
+ // Make sure that clip rect is clipped to source image...
Common::Rect srcRect;
srcRect.left = x;
@@ -1234,12 +1230,12 @@ void Wiz::pgDrawImageWith16BitZBuffer(WizSimpleBitmap *psbDst, const WizSimpleBi
srcRect.bottom = y + (height - 1);
if (!findRectOverlap(prcClip, &srcRect)) {
- // rectangles don't intersect - no drawing necessary
+ // Rectangles don't intersect - no drawing necessary...
return;
}
- // perform the drawing
- int dstWidth = psbDst->bitmapWidth; // same for destination and Z buffer
+ // Perform the drawing...
+ int dstWidth = psbDst->bitmapWidth; // Same for destination and Z-Buffer...
const int drawWidth = (prcClip->right - prcClip->left + 1);
const int drawHeight = (prcClip->bottom - prcClip->top + 1);
@@ -1249,13 +1245,13 @@ void Wiz::pgDrawImageWith16BitZBuffer(WizSimpleBitmap *psbDst, const WizSimpleBi
for (int row = 0; row < drawHeight; ++row) {
for (int col = 0; col < drawWidth; ++col, ++pZB, ++pDst, ++pSrc) {
- // left hand rule - don't draw unless we're closer than the z-buffer value
+ // Left hand rule - don't draw unless we're closer than the Z-Buffer value...
if (*pZB > z) {
*pDst = *pSrc;
}
}
- // move to the next line
+ // Move to the next line...
pSrc += width - drawWidth;
pDst += dstWidth - drawWidth;
pZB += dstWidth - drawWidth;
@@ -1586,7 +1582,7 @@ void Wiz::pgBlit90DegreeRotateCore(WizSimpleBitmap *dstBitmap, int x, int y, con
const WizRawPixel16 *src16;
WizRawPixel16 *dst16;
- // Do as much pre-clipping as possible
+ // Do as much pre-clipping as possible...
makeSizedRect(&clipRect, dstBitmap->bitmapWidth, dstBitmap->bitmapHeight);
if (optionalClipRect) {
@@ -1595,7 +1591,7 @@ void Wiz::pgBlit90DegreeRotateCore(WizSimpleBitmap *dstBitmap, int x, int y, con
}
}
- // Clip the source rect against the actual src bitmap limits
+ // Clip the source rect against the actual src bitmap limits...
makeSizedRect(&srcRect, srcBitmap->bitmapWidth, srcBitmap->bitmapHeight);
if (optionalSrcRect) {
@@ -1604,7 +1600,7 @@ void Wiz::pgBlit90DegreeRotateCore(WizSimpleBitmap *dstBitmap, int x, int y, con
}
}
- // Make the "dest" rect then clip it against the clip rect
+ // Make the dest rect, then clip it against the clip rect...
makeSizedRectAt(&dstRect, x, y, getRectHeight(&srcRect), getRectWidth(&srcRect));
clippedDstRect = dstRect;
@@ -1613,13 +1609,13 @@ void Wiz::pgBlit90DegreeRotateCore(WizSimpleBitmap *dstBitmap, int x, int y, con
return;
}
- // Make the clipped src rect adjusted for the 90 degree rotation.
+ // Make the clipped src rect adjusted for the 90 degree rotation...
clippedSrcRect.left = srcRect.left + (clippedDstRect.top - dstRect.top);
clippedSrcRect.top = srcRect.top + (dstRect.right - clippedDstRect.right);
clippedSrcRect.right = srcRect.right - (dstRect.bottom - clippedDstRect.bottom);
clippedSrcRect.bottom = srcRect.bottom - (clippedDstRect.left - dstRect.left);
- // Perform any flipping of the coords and setup the step variables
+ // Perform any flipping of the coords and setup the step variables...
if (hFlip) {
horzFlipAlignWithRect(&clippedSrcRect, &srcRect);
dstY = clippedDstRect.bottom;
@@ -1638,11 +1634,11 @@ void Wiz::pgBlit90DegreeRotateCore(WizSimpleBitmap *dstBitmap, int x, int y, con
dstOffset = -1;
}
- // Finally get down to business and do the blit!
+ // Finally get down to business and do the blit...
w = getRectWidth(&clippedSrcRect);
h = getRectHeight(&clippedSrcRect);
- // Transfer the src line to the dest line using the passed transfer prim.
+ // Transfer the src line to the dest line using the passed transfer prim...
srcOffset = srcBitmap->bitmapWidth;
if (!_uses16BitColor) {
@@ -1673,7 +1669,7 @@ bool Wiz::findRectOverlap(Common::Rect *destRectPtr, const Common::Rect *sourceR
return false;
}
- // Perform the actual clipping
+ // Perform the actual clipping...
if (destRectPtr->left < sourceRectPtr->left) {
destRectPtr->left = sourceRectPtr->left;
}
diff --git a/engines/scumm/he/sprite_he.cpp b/engines/scumm/he/sprite_he.cpp
index 9e2d6fa0fec..cab242ff62e 100644
--- a/engines/scumm/he/sprite_he.cpp
+++ b/engines/scumm/he/sprite_he.cpp
@@ -137,14 +137,14 @@ int Sprite::spriteFromPoint(int x, int y, int groupCheck, int quickCheck, int cl
int32 maskSpotX, maskSpotY, imageSpotX, imageSpotY;
int maskStateCount;
- // Change to using the the mask image instead of the display image
+ // Change to using the the mask image instead of the display image...
image = (*spritePtr)->maskImage;
- // Get the state for the mask (wrap if necessary)
+ // Get the state for the mask (wrap if necessary)...
maskStateCount = _vm->_wiz->getWizStateCount(image);
state = ((*spritePtr)->lastState % maskStateCount);
- // Convert the coords to "image" relative coords.
+ // Convert the coords to image relative coords...
testPointX = (x - (*spritePtr)->lastSpot.x);
testPointY = (y - (*spritePtr)->lastSpot.y);
@@ -153,7 +153,7 @@ int Sprite::spriteFromPoint(int x, int y, int groupCheck, int quickCheck, int cl
_vm->_wiz->getWizSpot((*spritePtr)->lastImage, state, imageSpotX, imageSpotY);
_vm->_wiz->getWizSpot(image, state, maskSpotX, maskSpotY);
- // Convert the coords to "Mask" relative coords.
+ // Convert the coords to "Mask" relative coords...
testPointX += (maskSpotX - imageSpotX);
testPointY += (maskSpotY - imageSpotY);
} else {
@@ -163,11 +163,11 @@ int Sprite::spriteFromPoint(int x, int y, int groupCheck, int quickCheck, int cl
continue;
}
- // Convert the coords to image relative coords.
+ // Convert the coords to image relative coords...
testPointX = (x - (*spritePtr)->lastSpot.x);
testPointY = (y - (*spritePtr)->lastSpot.y);
- // Get the last active image state
+ // Get the last active image state...
state = (*spritePtr)->lastState;
}
@@ -472,15 +472,15 @@ void Sprite::getSpriteRectPrim(const SpriteInfo *spritePtr, Common::Rect *rectPt
}
}
- // Rotate the points
+ // Rotate the points...
if (angleSpecified) {
_vm->_wiz->polyRotatePoints(listOfPoints, 4, angle);
}
- // Offset the points
+ // Offset the points...
_vm->_wiz->polyMovePolygonPoints(listOfPoints, 4, tmpPt.x, tmpPt.y);
- // Finally get down the point and get the bounding rect of this
+ // Finally get down the point and get the bounding rect...
_vm->_wiz->polyBuildBoundingRect(listOfPoints, 4, *rectPtr);
} else {
@@ -884,7 +884,7 @@ void Sprite::setSpriteUpdateType(int spriteId, int eraseType) {
void Sprite::setSpriteEraseType(int spriteId, int eraseType) {
assertRange(1, spriteId, _maxSprites, "sprite");
- // Note that condition is inverted
+ // Note that condition is inverted!
if (!eraseType) {
_spriteTable[spriteId].flags |= kSFIgnoreErase;
} else {
@@ -929,6 +929,9 @@ void Sprite::setSpriteAnimSpeedState(int spriteId, int animState) {
void Sprite::setSpriteGeneralProperty(int spriteId, int property, int value) {
// TODO U32
+ //if (PU_SetSpriteProperty(spriteId, property, value)) {
+ // return;
+ //}
debug(7, "setSpriteGeneralProperty: spriteId %d type 0x%x value 0x%x", spriteId, property, value);
assertRange(1, spriteId, _maxSprites, "sprite");
@@ -1461,7 +1464,7 @@ void Sprite::eraseSprites() {
}
}
- // Erase the cumulative sprites rectangle
+ // Erase the cumulative sprites rectangle...
if (valid) {
_vm->backgroundToForegroundBlit(eraseRect, USAGE_BIT_RESTORED);
}
@@ -1539,7 +1542,7 @@ void Sprite::runSpriteEngines() {
spritePtr = _activeSprites;
for (int i = 0; i < _activeSpriteCount; i++) {
- // Handle movement
+ // Handle movement...
if (spritePtr[i]->deltaPosX || spritePtr[i]->deltaPosY) {
moveSprite(
spritePtr[i] - _spriteTable,
@@ -1612,7 +1615,7 @@ static int compareSpritePriority(const void *a, const void *b) {
void Sprite::buildActiveSpriteList() {
SpriteInfo **spritePtr;
- // Build the list of active sprites
+ // Build the list of active sprites...
_activeSpriteCount = 0;
spritePtr = _activeSprites;
@@ -1755,7 +1758,7 @@ void Sprite::renderSprites(bool negativeOrPositiveRender) {
spritePtr[i]->lastRect.bottom = spot.y + h - 1;
}
- // Setup the renderFlags
+ // Setup the renderFlags...
renderFlags = kWRFForeground;
if (flags & kSFHFlip) {
@@ -1792,7 +1795,7 @@ void Sprite::renderSprites(bool negativeOrPositiveRender) {
if (_vm->_game.heversion > 98) {
if (_vm->_game.heversion > 99 || _vm->_isHE995) {
- // Handle Z-Clipping
+ // Handle Z-Clipping...
if (spritePtr[i]->zbufferImage != 0) {
imageRenderCmd.actionFlags |= kWAFZBufferImage;
imageRenderCmd.zbufferImage = spritePtr[i]->zbufferImage;
@@ -1811,11 +1814,11 @@ void Sprite::renderSprites(bool negativeOrPositiveRender) {
renderFlags |= spritePtr[i]->specialRenderFlags;
}
- // Finally set the image render flags
+ // Finally set the image render flags...
imageRenderCmd.actionFlags |= kWAFFlags;
imageRenderCmd.flags = renderFlags;
- // Read the angle/scale variables
+ // Read the angle/scale variables...
angle = spritePtr[i]->angle;
scale = spritePtr[i]->scale;
@@ -1833,7 +1836,7 @@ void Sprite::renderSprites(bool negativeOrPositiveRender) {
imageRenderCmd.scale = scale;
}
- // Store off the render flags
+ // Store off the render flags...
spritePtr[i]->lastRenderFlags = renderFlags;
} else {
// Check for complex image draw mode...
@@ -1853,7 +1856,7 @@ void Sprite::renderSprites(bool negativeOrPositiveRender) {
simpleDraw = _vm->_game.heversion <= 95 ? true : simpleDraw;
- // Check to see if the group has a clipping rect.
+ // Check to see if the group has a clipping rect...
group = spritePtr[i]->group;
if (group != 0) {
if (_groupTable[group].flags & kSGFUseClipRect) {
@@ -1869,9 +1872,8 @@ void Sprite::renderSprites(bool negativeOrPositiveRender) {
continue;
}
- // Setup the clipping rect to the overlap rect.
- // This will eventually be clipped down to the
- // limits of the bitmap
+ // Setup the clipping rect to the overlap rect...
+ // This will eventually be clipped down to the limits of the bitmap!
imageRenderCmd.actionFlags |= kWAFRect;
imageRenderCmd.box.left = spritePtr[i]->lastRect.left;
imageRenderCmd.box.top = spritePtr[i]->lastRect.top;
@@ -1902,14 +1904,13 @@ void Sprite::renderSprites(bool negativeOrPositiveRender) {
}
if (_vm->_game.heversion > 98) {
- // Finally get down to business and render the wiz
- // get the palette
+ // Get the palette...
if (spritePtr[i]->palette != 0) {
imageRenderCmd.actionFlags |= kWAFPalette;
imageRenderCmd.palette = spritePtr[i]->palette;
}
- // get the associated dest image if any
+ // Get the associated dest image if any...
destImageNumber = getDestImageForSprite(spritePtr[i]);
if (destImageNumber) {
@@ -1917,9 +1918,7 @@ void Sprite::renderSprites(bool negativeOrPositiveRender) {
imageRenderCmd.destImageNumber = destImageNumber;
}
- // Finally actually do something by calling the command parser
- // this function is the same core that renders images via the
- // "image" draw command.
+ // Finally actually do something by calling the command parser...
if (_vm->_game.heversion > 99 || _vm->_isHE995) {
imageRenderCmd.actionType = kWADraw;
_vm->_wiz->processWizImageCmd(&imageRenderCmd);
@@ -1927,7 +1926,7 @@ void Sprite::renderSprites(bool negativeOrPositiveRender) {
_vm->_wiz->processWizImageDrawCmd(&imageRenderCmd);
}
} else {
- // Check to see if there is a shadow attached to this sprite
+ // Check to see if there is a shadow attached to this sprite...
shadow = spritePtr[i]->shadow;
if (shadow != 0) {
renderFlags |= kWRFUseShadow;
@@ -1979,7 +1978,7 @@ int Sprite::pixelPerfectSpriteCollisionCheck(int spriteA, int deltaAX, int delta
_vm->_wiz->moveRect(&originalA, deltaAX, deltaAY);
_vm->_wiz->moveRect(&originalB, deltaBX, deltaBY);
- // Find the overlap if any
+ // Find the overlap if any...
rectA = originalA;
if (!_vm->_wiz->findRectOverlap(&rectA, &originalB)) {
@@ -1988,13 +1987,13 @@ int Sprite::pixelPerfectSpriteCollisionCheck(int spriteA, int deltaAX, int delta
rectB = rectA;
- // Adjust the coords to be image relative.
+ // Adjust the coords to be image relative...
calcSpriteSpot(&_spriteTable[spriteA], true, spotAX, spotAY);
calcSpriteSpot(&_spriteTable[spriteB], true, spotBX, spotBY);
_vm->_wiz->moveRect(&rectA, -spotAX - deltaAX, -spotAY - deltaAY);
_vm->_wiz->moveRect(&rectB, -spotBX - deltaBX, -spotBY - deltaBY);
- // Limit the compare to only the compare buffer size
+ // Limit the compare to only the compare buffer size...
overlapWidth = _vm->_wiz->getRectWidth(&rectA);
if (overlapWidth > 640) {
@@ -2073,7 +2072,7 @@ int Sprite::pixelPerfectSpriteCollisionCheck(int spriteA, int deltaAX, int delta
return 1;
}
- // Advance to the next line
+ // Advance to the next line...
++rectA.top;
++rectB.top;
}
diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp
index 8f4dfa64887..1a8d0935e98 100644
--- a/engines/scumm/he/wiz_he.cpp
+++ b/engines/scumm/he/wiz_he.cpp
@@ -137,7 +137,7 @@ byte *Wiz::drawAWizEx(int image, int state, int x, int y, int z, int flags, int
colorConversionTable = nullptr;
}
- // Get the "shadow"...
+ // Get the shadow...
if (!optionalShadowImage) {
if (_wizActiveShadow && (flags & kWRFUseShadow)) {
optionalShadowImage = _wizActiveShadow;
@@ -176,15 +176,15 @@ void *Wiz::drawAWizPrim(int globNum, int state, int x, int y, int z, int shadowI
}
void *Wiz::drawAWizPrimEx(int globNum, int state, int x, int y, int z, int shadowImage, int zbufferImage, const Common::Rect *optionalClipRect, int flags, WizSimpleBitmap *optionalBitmapOverride, const WizRawPixel *optionalColorConversionTable, const WizImageCommand *optionalICmdPtr) {
- int dest_w, dest_h, src_w, src_h, src_c, remapID;
- byte *src_d, *src_p, *pp, *remap_p;
- const byte *shadow_p;
- Common::Rect dest_r, clip_r;
+ int destWidth, destHeight, srcWidth, srcHeight, srcComp, remapId;
+ byte *srcData, *srcPtr, *stateHeader, *remapPtr;
+ const byte *shadowPtr;
+ Common::Rect destRect, clipRect;
bool markUpdates;
- WizRawPixel *dest_p;
+ WizRawPixel *destPtr;
markUpdates = true;
- remap_p = nullptr;
+ remapPtr = nullptr;
if (_vm->_game.heversion > 98) {
// Set the optional remap table up to the default if one isn't specified
@@ -194,25 +194,24 @@ void *Wiz::drawAWizPrimEx(int globNum, int state, int x, int y, int z, int shado
}
if (shadowImage) {
- shadow_p = getColorMixBlockPtrForWiz(shadowImage);
+ shadowPtr = getColorMixBlockPtrForWiz(shadowImage);
- if (shadow_p) {
- shadow_p += _vm->_resourceHeaderSize;
+ if (shadowPtr) {
+ shadowPtr += _vm->_resourceHeaderSize;
}
} else {
- shadow_p = nullptr;
+ shadowPtr = nullptr;
}
if (_vm->_game.heversion < 99 && _uses16BitColor) {
- if (shadow_p) {
- shadow_p = nullptr;
+ if (shadowPtr) {
+ shadowPtr = nullptr;
}
}
if (_vm->_game.heversion > 99 || _vm->_isHE995) {
- // If using a z-buffer make sure both globs are in ram!!!!
+ // Z-Buffer image... (only format supported: uncompressed 16-bit)
if (zbufferImage) {
- // uncompressed 16-bit z-buffers only for now
byte *pzbHeader = getWizStateHeaderPrim(zbufferImage, 0);
assert(pzbHeader);
@@ -225,47 +224,47 @@ void *Wiz::drawAWizPrimEx(int globNum, int state, int x, int y, int z, int shado
}
}
- // Get the header for this "state"
- pp = getWizStateHeaderPrim(globNum, state);
- if (!pp)
+ // Get the header for this state...
+ stateHeader = getWizStateHeaderPrim(globNum, state);
+ if (!stateHeader)
error("Wiz::drawAWizPrimEx(): %d state %d missing header", globNum, state);
- src_c = READ_LE_UINT32(pp + _vm->_resourceHeaderSize + 0);
- src_w = READ_LE_UINT32(pp + _vm->_resourceHeaderSize + 4);
- src_h = READ_LE_UINT32(pp + _vm->_resourceHeaderSize + 8);
+ srcComp = READ_LE_UINT32(stateHeader + _vm->_resourceHeaderSize + 0);
+ srcWidth = READ_LE_UINT32(stateHeader + _vm->_resourceHeaderSize + 4);
+ srcHeight = READ_LE_UINT32(stateHeader + _vm->_resourceHeaderSize + 8);
- if ((!isUncompressedFormatTypeID(src_c)) && (src_c != kWCTTRLE)) {
- error("Wiz::drawAWizPrimEx(): %d has invalid compression type %d", globNum, src_c);
+ if ((!isUncompressedFormatTypeID(srcComp)) && (srcComp != kWCTTRLE)) {
+ error("Wiz::drawAWizPrimEx(): %d has invalid compression type %d", globNum, srcComp);
}
- // Get the data block for this "state"
- src_d = getWizStateDataPrim(globNum, state);
- if (!src_d)
+ // Get the data block for this state...
+ srcData = getWizStateDataPrim(globNum, state);
+ if (!srcData)
error("Wiz::drawAWizPrimEx(): %d state %d missing data block", globNum, state);
- // Copy the palette from this "state"?
+ // Copy the palette from this state...
if (flags & kWRFUsePalette) {
- src_p = getWizStatePaletteDataPrim(globNum, state);
- if (!src_p)
+ srcPtr = getWizStatePaletteDataPrim(globNum, state);
+ if (!srcPtr)
error("Wiz::drawAWizPrimEx(): %d state %d missing palette block", globNum, state);
- _vm->setPaletteFromPtr(src_p + _vm->_resourceHeaderSize, 256);
+ _vm->setPaletteFromPtr(srcPtr + _vm->_resourceHeaderSize, 256);
}
- // Remap this wiz "state"?
+ // Remap this wiz state...
if (flags & kWRFRemap) {
- remap_p = getWizStateRemapDataPrim(globNum, state);
- if (!remap_p)
+ remapPtr = getWizStateRemapDataPrim(globNum, state);
+ if (!remapPtr)
error("Wiz::drawAWizPrimEx(): %d state %d is missing a remap palette block", globNum, state);
- remapID = READ_BE_UINT32(remap_p + _vm->_resourceHeaderSize);
+ remapId = READ_BE_UINT32(remapPtr + _vm->_resourceHeaderSize);
- if (_vm->_game.heversion <= 80 || remapID != WIZ_MAGIC_REMAP_NUMBER) {
- if (remapID != _vm->_paletteChangedCounter) {
- WRITE_LE_UINT32(remap_p + _vm->_resourceHeaderSize, _vm->_paletteChangedCounter);
+ if (_vm->_game.heversion <= 80 || remapId != WIZ_MAGIC_REMAP_NUMBER) {
+ if (remapId != _vm->_paletteChangedCounter) {
+ WRITE_LE_UINT32(remapPtr + _vm->_resourceHeaderSize, _vm->_paletteChangedCounter);
- src_p = getWizStatePaletteDataPrim(globNum, state);
- if (!src_p)
+ srcPtr = getWizStatePaletteDataPrim(globNum, state);
+ if (!srcPtr)
error("Wiz::drawAWizPrimEx(): %d state %d missing palette block", globNum, state);
const byte *palPtr = nullptr;
@@ -275,65 +274,65 @@ void *Wiz::drawAWizPrimEx(int globNum, int state, int x, int y, int z, int shado
palPtr = _vm->_currentPalette;
}
- _vm->buildRemapTable(remap_p + _vm->_resourceHeaderSize + 4, palPtr, src_p + _vm->_resourceHeaderSize);
+ _vm->buildRemapTable(remapPtr + _vm->_resourceHeaderSize + 4, palPtr, srcPtr + _vm->_resourceHeaderSize);
}
}
}
// Get the dest pointer...
if (flags & (kWRFPrint | kWRFAlloc)) {
- dest_w = src_w;
- dest_h = src_h;
+ destWidth = srcWidth;
+ destHeight = srcHeight;
if (_uses16BitColor) {
- dest_p = (WizRawPixel *)malloc(dest_w * dest_h * sizeof(WizRawPixel16));
+ destPtr = (WizRawPixel *)malloc(destWidth * destHeight * sizeof(WizRawPixel16));
} else {
- dest_p = (WizRawPixel *)malloc(dest_w * dest_h * sizeof(WizRawPixel8));
+ destPtr = (WizRawPixel *)malloc(destWidth * destHeight * sizeof(WizRawPixel8));
}
- if (!dest_p) {
+ if (!destPtr) {
warning("Wiz::drawAWizPrimEx(): Not enough memory for image operation (print / other)");
return nullptr;
} else if (flags & kWRFAlloc) {
memset8BppConversion(
- dest_p,
+ destPtr,
_vm->_game.heversion < 95 ? 0x05 : _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR),
- dest_w * dest_h,
+ destWidth * destHeight,
optionalColorConversionTable);
}
} else {
if (optionalBitmapOverride) {
- dest_w = optionalBitmapOverride->bitmapWidth;
- dest_h = optionalBitmapOverride->bitmapHeight;
- dest_p = optionalBitmapOverride->bufferPtr;
+ destWidth = optionalBitmapOverride->bitmapWidth;
+ destHeight = optionalBitmapOverride->bitmapHeight;
+ destPtr = optionalBitmapOverride->bufferPtr;
markUpdates = false;
} else {
VirtScreen *pvs = &_vm->_virtscr[kMainVirtScreen];
- dest_w = pvs->w;
- dest_h = pvs->h;
+ destWidth = pvs->w;
+ destHeight = pvs->h;
if (flags & kWRFForeground) {
- dest_p = (WizRawPixel *)pvs->getPixels(0, pvs->topline);
+ destPtr = (WizRawPixel *)pvs->getPixels(0, pvs->topline);
} else {
- dest_p = (WizRawPixel *)pvs->getBackPixels(0, pvs->topline);
+ destPtr = (WizRawPixel *)pvs->getBackPixels(0, pvs->topline);
}
}
}
- // Make the clipping rect equal to the limits of the draw buffer
- clip_r.left = 0;
- clip_r.top = 0;
- clip_r.right = dest_w - 1;
- clip_r.bottom = dest_h - 1;
+ // Make the clipping rect equal to the limits of the draw buffer...
+ clipRect.left = 0;
+ clipRect.top = 0;
+ clipRect.right = destWidth - 1;
+ clipRect.bottom = destHeight - 1;
if (optionalClipRect && (!(flags & (kWRFPrint | kWRFAlloc)))) {
- if (!findRectOverlap(&clip_r, optionalClipRect)) {
+ if (!findRectOverlap(&clipRect, optionalClipRect)) {
return nullptr;
}
}
- // Get down to business and decompress the image...
+ // Decompress the image...
if ((_vm->_game.heversion > 99 || _vm->_isHE995) && zbufferImage) {
WizSimpleBitmap sbZBuffer;
sbZBuffer.bitmapHeight = 0;
@@ -342,64 +341,64 @@ void *Wiz::drawAWizPrimEx(int globNum, int state, int x, int y, int z, int shado
dwSetSimpleBitmapStructFromImage(zbufferImage, 0, &sbZBuffer);
- // Validate destination for z-buffer
- if ((dest_w != sbZBuffer.bitmapWidth) ||
- (dest_h != sbZBuffer.bitmapHeight)) {
+ // Validate destination for z-buffer...
+ if ((destWidth != sbZBuffer.bitmapWidth) ||
+ (destHeight != sbZBuffer.bitmapHeight)) {
error("Wiz::drawAWizPrimEx(): destination size must match z-buffer size d:%dx%d z:%dx%d",
- dest_w, dest_h, sbZBuffer.bitmapWidth, sbZBuffer.bitmapHeight);
+ destWidth, destHeight, sbZBuffer.bitmapWidth, sbZBuffer.bitmapHeight);
}
WizSimpleBitmap sbDst;
- sbDst.bufferPtr = dest_p;
- sbDst.bitmapWidth = dest_w;
- sbDst.bitmapHeight = dest_h;
+ sbDst.bufferPtr = destPtr;
+ sbDst.bitmapWidth = destWidth;
+ sbDst.bitmapHeight = destHeight;
- if (src_c != kWCTTRLE) {
- pgDrawImageWith16BitZBuffer(&sbDst, &sbZBuffer, src_d + _vm->_resourceHeaderSize, x, y, z, src_w, src_h, &clip_r);
+ if (srcComp != kWCTTRLE) {
+ pgDrawImageWith16BitZBuffer(&sbDst, &sbZBuffer, srcData + _vm->_resourceHeaderSize, x, y, z, srcWidth, srcHeight, &clipRect);
}
- } else if (src_c == kWCTTRLE) {
+ } else if (srcComp == kWCTTRLE) {
if (flags & kWRFZPlaneOn) {
if (_vm->_game.heversion > 95 && _vm->_gdi->_numZBuffer <= 1) {
error("Wiz::drawAWizPrimEx(): No zplane %d (limit 0 to %d)", 1, (_vm->_gdi->_numZBuffer - 1));
}
- auxDrawZplaneFromTRLEImage(_vm->getMaskBuffer(0, 0, 1), src_d + _vm->_resourceHeaderSize, dest_w, dest_h, x, y, src_w, src_h, &clip_r, kWZOIgnore, kWZOSet);
+ auxDrawZplaneFromTRLEImage(_vm->getMaskBuffer(0, 0, 1), srcData + _vm->_resourceHeaderSize, destWidth, destHeight, x, y, srcWidth, srcHeight, &clipRect, kWZOIgnore, kWZOSet);
} else if (flags & kWRFZPlaneOff) {
if (_vm->_game.heversion > 95 && _vm->_gdi->_numZBuffer <= 1) {
error("Wiz::drawAWizPrimEx(): No zplane %d (limit 0 to %d)", 1, (_vm->_gdi->_numZBuffer - 1));
}
- auxDrawZplaneFromTRLEImage(_vm->getMaskBuffer(0, 0, 1), src_d + _vm->_resourceHeaderSize, dest_w, dest_h, x, y, src_w, src_h, &clip_r, kWZOIgnore, kWZOClear);
+ auxDrawZplaneFromTRLEImage(_vm->getMaskBuffer(0, 0, 1), srcData + _vm->_resourceHeaderSize, destWidth, destHeight, x, y, srcWidth, srcHeight, &clipRect, kWZOIgnore, kWZOClear);
} else if (_vm->_game.heversion <= 98 && !(flags & (kWRFHFlip | kWRFVFlip))) {
if (flags & kWRFRemap) {
auxDecompRemappedTRLEImage(
- dest_p, src_d + _vm->_resourceHeaderSize, dest_w, dest_h,
- x, y, src_w, src_h, &clip_r, remap_p + _vm->_resourceHeaderSize + 4,
+ destPtr, srcData + _vm->_resourceHeaderSize, destWidth, destHeight,
+ x, y, srcWidth, srcHeight, &clipRect, remapPtr + _vm->_resourceHeaderSize + 4,
optionalColorConversionTable);
- } else if (!shadow_p) {
+ } else if (!shadowPtr) {
auxDecompTRLEImage(
- dest_p, src_d + _vm->_resourceHeaderSize, dest_w, dest_h,
- x, y, src_w, src_h, &clip_r,
+ destPtr, srcData + _vm->_resourceHeaderSize, destWidth, destHeight,
+ x, y, srcWidth, srcHeight, &clipRect,
optionalColorConversionTable);
} else {
auxDecompMixColorsTRLEImage(
- dest_p, src_d + _vm->_resourceHeaderSize, dest_w, dest_h,
- x, y, src_w, src_h, &clip_r, shadow_p,
+ destPtr, srcData + _vm->_resourceHeaderSize, destWidth, destHeight,
+ x, y, srcWidth, srcHeight, &clipRect, shadowPtr,
optionalColorConversionTable);
}
} else {
const byte *dataPtr = nullptr;
- if (shadow_p)
- dataPtr = shadow_p;
+ if (shadowPtr)
+ dataPtr = shadowPtr;
if (flags & kWRFRemap)
- dataPtr = remap_p + _vm->_resourceHeaderSize + 4;
+ dataPtr = remapPtr + _vm->_resourceHeaderSize + 4;
trleFLIPDecompressImage(
- dest_p, src_d + _vm->_resourceHeaderSize, dest_w, dest_h,
- x, y, src_w, src_h, &clip_r, flags, dataPtr,
+ destPtr, srcData + _vm->_resourceHeaderSize, destWidth, destHeight,
+ x, y, srcWidth, srcHeight, &clipRect, flags, dataPtr,
optionalColorConversionTable,
optionalICmdPtr);
}
@@ -408,11 +407,11 @@ void *Wiz::drawAWizPrimEx(int globNum, int state, int x, int y, int z, int shado
int transColorOverride;
const byte *dataPtr = nullptr;
- if (shadow_p)
- dataPtr = shadow_p;
+ if (shadowPtr)
+ dataPtr = shadowPtr;
if (flags & kWRFRemap)
- dataPtr = remap_p + _vm->_resourceHeaderSize + 4;
+ dataPtr = remapPtr + _vm->_resourceHeaderSize + 4;
if (_vm->_game.heversion >= 95 && doesRawWizStateHaveTransparency(globNum, state)) {
transColorOverride = _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR);
@@ -420,14 +419,14 @@ void *Wiz::drawAWizPrimEx(int globNum, int state, int x, int y, int z, int shado
transColorOverride = -1;
}
- if (_uses16BitColor && src_c != kWCTNone16Bpp && src_c != kWCTNone16BppBigEndian) {
- if (src_c == kWCTNone) {
+ if (_uses16BitColor && srcComp != kWCTNone16Bpp && srcComp != kWCTNone16BppBigEndian) {
+ if (srcComp == kWCTNone) {
pgDraw8BppFormatImage(
- dest_p, (byte *)(src_d + _vm->_resourceHeaderSize), dest_w, dest_h,
- x, y, src_w, src_h, &clip_r, flags, dataPtr, transColorOverride,
+ destPtr, (byte *)(srcData + _vm->_resourceHeaderSize), destWidth, destHeight,
+ x, y, srcWidth, srcHeight, &clipRect, flags, dataPtr, transColorOverride,
optionalColorConversionTable);
} else {
- error("Wiz::drawAWizPrimEx(): Raw data type mismatch for mode %d vs %d", src_c, kWCTNone16Bpp);
+ error("Wiz::drawAWizPrimEx(): Raw data type mismatch for mode %d vs %d", srcComp, kWCTNone16Bpp);
}
} else {
if (_vm->_game.heversion > 99 || _vm->_isHE995) {
@@ -437,46 +436,46 @@ void *Wiz::drawAWizPrimEx(int globNum, int state, int x, int y, int z, int shado
dataPtr = (const byte *)optionalColorConversionTable;
}
} else {
- if (!_uses16BitColor && src_c != kWCTNone) {
- error("Wiz::drawAWizPrimEx(): Raw data type mismatch for mode %d vs %d", src_c, kWCTNone);
+ if (!_uses16BitColor && srcComp != kWCTNone) {
+ error("Wiz::drawAWizPrimEx(): Raw data type mismatch for mode %d vs %d", srcComp, kWCTNone);
}
}
- // Use the native transfer function
+ // Use the native transfer function...
pgDrawRawDataFormatImage(
- dest_p, (WizRawPixel *)(src_d + _vm->_resourceHeaderSize), dest_w, dest_h,
- x, y, src_w, src_h, &clip_r, flags, dataPtr, transColorOverride);
+ destPtr, (WizRawPixel *)(srcData + _vm->_resourceHeaderSize), destWidth, destHeight,
+ x, y, srcWidth, srcHeight, &clipRect, flags, dataPtr, transColorOverride);
}
}
- // Is this a print operation?
+ // Verify if it's a printing operation...
if (flags & kWRFPrint) {
warning("Wiz::drawAWizPrimEx(): Printing not yet supported");
if (_vm->_game.heversion <= 99 || (flags & kWRFAlloc) == 0) {
- free(dest_p);
- dest_p = nullptr;
+ free(destPtr);
+ destPtr = nullptr;
}
} else {
if (!(flags & kWRFAlloc) && markUpdates) {
- dest_r.left = x;
- dest_r.top = y;
- dest_r.right = x + src_w - 1;
- dest_r.bottom = y + src_h - 1;
+ destRect.left = x;
+ destRect.top = y;
+ destRect.right = x + srcWidth - 1;
+ destRect.bottom = y + srcHeight - 1;
- if (findRectOverlap(&dest_r, &clip_r)) {
+ if (findRectOverlap(&destRect, &clipRect)) {
// If neither foreground or background, copy to both
if ((flags & kWRFBackground) || ((flags & (kWRFBackground | kWRFForeground)) == 0)) {
- _vm->backgroundToForegroundBlit(dest_r);
+ _vm->backgroundToForegroundBlit(destRect);
} else {
- ++dest_r.bottom;
- _vm->markRectAsDirty(kMainVirtScreen, dest_r);
+ ++destRect.bottom;
+ _vm->markRectAsDirty(kMainVirtScreen, destRect);
}
}
}
}
- return dest_p;
+ return destPtr;
}
void Wiz::buildAWiz(const WizRawPixel *bufPtr, int bufWidth, int bufHeight, const byte *palettePtr, const Common::Rect *rectPtr, int compressionType, int globNum, int transparentColor) {
@@ -484,7 +483,6 @@ void Wiz::buildAWiz(const WizRawPixel *bufPtr, int bufWidth, int bufHeight, cons
Common::Rect compRect;
byte *ptr;
- // Make sure that the coords passed in make sense.
compRect.left = 0;
compRect.top = 0;
compRect.right = bufWidth - 1;
@@ -498,15 +496,15 @@ void Wiz::buildAWiz(const WizRawPixel *bufPtr, int bufWidth, int bufHeight, cons
}
}
- // Force the compression type if in hi-color mode.
+ // Force the compression type if in hi-color mode...
if (_uses16BitColor) {
compressionType = kWCTNone16Bpp;
}
- // Estimate the size of the wiz.
+ // Estimate the size of the wiz...
globSize = (_vm->_resourceHeaderSize * 3) + 12; // AWIZ, WIZH + data (12), WIZD
- if (!palettePtr) {
+ if (palettePtr) {
globSize += (_vm->_resourceHeaderSize * 2) + 768 + 256 + 4; // RGBS + 768, RMAP + 256 + 4
}
@@ -521,16 +519,16 @@ void Wiz::buildAWiz(const WizRawPixel *bufPtr, int bufWidth, int bufHeight, cons
}
if (_vm->_game.heversion > 90) {
- // Make sure that the "glob" is even sized...
+ // Make sure that the resource is even sized...
if (dataSize & 1) {
dataSize++;
}
}
- // Finalize the glob size!
+ // Finalize the resource size...
globSize += dataSize;
- // Actually build the wiz!
+ // Finally build the wiz...
ptr = (byte *)_vm->_res->createResource(rtImage, globNum, globSize);
dataOffset = 0;
@@ -546,7 +544,7 @@ void Wiz::buildAWiz(const WizRawPixel *bufPtr, int bufWidth, int bufHeight, cons
WRITE_LE_UINT32(ptr + dataOffset, getRectWidth(&compRect)); dataOffset += 4; // WIDTH
WRITE_LE_UINT32(ptr + dataOffset, getRectHeight(&compRect)); dataOffset += 4; // HEIGHT
- if (!palettePtr) {
+ if (palettePtr) {
// RGBS
WRITE_BE_UINT32(ptr + dataOffset + 0, MKTAG('R', 'G', 'B', 'S'));
WRITE_BE_UINT32(ptr + dataOffset + 4, (768 + _vm->_resourceHeaderSize)); dataOffset += _vm->_resourceHeaderSize;
@@ -598,12 +596,10 @@ void Wiz::buildAWiz(const WizRawPixel *bufPtr, int bufWidth, int bufHeight, cons
dstRect.right = width - 1;
dstRect.bottom = height - 1;
- // Call the blit primitive. There should be a rendering
- // pipeline. That would allow things to happen much smoother.
+ // Call the blit primitive...
pgSimpleBlit(&dstBitmap, &dstRect, &srcBitmap, &compRect);
}
- // Error check.
dataOffset += dataSize;
if (globSize != dataOffset) {
error("Wiz::buildAWiz(): WIZ size mismatch!");
@@ -622,24 +618,24 @@ int Wiz::pixelHitTestWizPrim(int globNum, int state, int x, int y, int32 flags)
// return outValue;
//}
- int src_c, src_w, src_h;
- byte *src_d;
- byte *pp;
+ int srcComp, srcWidth, srcHeight;
+ byte *srcData;
+ byte *headerPtr;
- // Get the header (width, height + compression)
- pp = getWizStateHeaderPrim(globNum, state);
+ // Get the header (width, height + compression)...
+ headerPtr = getWizStateHeaderPrim(globNum, state);
- src_c = READ_LE_UINT32(pp + _vm->_resourceHeaderSize + 0);
- src_w = READ_LE_UINT32(pp + _vm->_resourceHeaderSize + 4);
- src_h = READ_LE_UINT32(pp + _vm->_resourceHeaderSize + 8);
+ srcComp = READ_LE_UINT32(headerPtr + _vm->_resourceHeaderSize + 0);
+ srcWidth = READ_LE_UINT32(headerPtr + _vm->_resourceHeaderSize + 4);
+ srcHeight = READ_LE_UINT32(headerPtr + _vm->_resourceHeaderSize + 8);
// If the compression type is TRLE...
- if (src_c == kWCTTRLE) {
- src_d = getWizStateDataPrim(globNum, state);
+ if (srcComp == kWCTTRLE) {
+ srcData = getWizStateDataPrim(globNum, state);
- // Where should the color lookup happen?
+ // Execute the color lookup...
int pixel = auxPixelHitTestTRLEImageRelPos(
- src_d + _vm->_resourceHeaderSize, x, y, src_w, src_h,
+ srcData + _vm->_resourceHeaderSize, x, y, srcWidth, srcHeight,
_vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR));
if (!(_vm->_game.heversion > 99 || _vm->_isHE995)) {
@@ -658,14 +654,14 @@ int Wiz::pixelHitTestWizPrim(int globNum, int state, int x, int y, int32 flags)
}
}
- } else if (isUncompressedFormatTypeID(src_c)) {
+ } else if (isUncompressedFormatTypeID(srcComp)) {
WizSimpleBitmap srcBitmap;
- src_d = getWizStateDataPrim(globNum, state);
+ srcData = getWizStateDataPrim(globNum, state);
- srcBitmap.bufferPtr = (WizRawPixel *)(src_d + _vm->_resourceHeaderSize);
- srcBitmap.bitmapWidth = src_w;
- srcBitmap.bitmapHeight = src_h;
+ srcBitmap.bufferPtr = (WizRawPixel *)(srcData + _vm->_resourceHeaderSize);
+ srcBitmap.bitmapWidth = srcWidth;
+ srcBitmap.bitmapHeight = srcHeight;
int pixel = pgReadPixel(&srcBitmap, x, y, _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR));
@@ -694,9 +690,9 @@ int Wiz::hitTestWiz(int image, int state, int x, int y, int32 flags) {
}
int Wiz::hitTestWizPrim(int globNum, int state, int x, int y, int32 flags) {
- int src_c, src_w, src_h;
- const byte *src_d;
- const byte *pp;
+ int srcComp, srcWidth, srcHeight;
+ const byte *srcData;
+ const byte *headerPtr;
byte *dataTmp = nullptr;
// U32 TODO
@@ -709,71 +705,67 @@ int Wiz::hitTestWizPrim(int globNum, int state, int x, int y, int32 flags) {
if (_vm->_game.heversion == 80) {
dataTmp = _vm->getResourceAddress(rtImage, globNum);
assert(dataTmp);
- pp = _vm->findResourceData(MKTAG('W', 'I', 'Z', 'H'), dataTmp);
- assert(pp);
+ headerPtr = _vm->findResourceData(MKTAG('W', 'I', 'Z', 'H'), dataTmp);
+ assert(headerPtr);
} else {
- pp = getWizStateHeaderPrim(globNum, state);
+ headerPtr = getWizStateHeaderPrim(globNum, state);
}
- // Get the header (width, height + compression)
- src_c = READ_LE_UINT32(pp + _vm->_resourceHeaderSize + 0);
- src_w = READ_LE_UINT32(pp + _vm->_resourceHeaderSize + 4);
- src_h = READ_LE_UINT32(pp + _vm->_resourceHeaderSize + 8);
+ // Get the header (width, height + compression)...
+ srcComp = READ_LE_UINT32(headerPtr + _vm->_resourceHeaderSize + 0);
+ srcWidth = READ_LE_UINT32(headerPtr + _vm->_resourceHeaderSize + 4);
+ srcHeight = READ_LE_UINT32(headerPtr + _vm->_resourceHeaderSize + 8);
if (_vm->_game.heversion == 80) {
- if (src_c != kWCTTRLE)
- error("Wiz::hitTestWizPrim(): resource %d has invalid compression type %d", globNum, src_c);
+ if (srcComp != kWCTTRLE)
+ error("Wiz::hitTestWizPrim(): resource %d has invalid compression type %d", globNum, srcComp);
- src_d = _vm->findResourceData(MKTAG('W', 'I', 'Z', 'D'), dataTmp);
+ srcData = _vm->findResourceData(MKTAG('W', 'I', 'Z', 'D'), dataTmp);
- return auxHitTestTRLEImageRelPos(src_d + _vm->_resourceHeaderSize, x, y, src_w, src_h);
+ return auxHitTestTRLEImageRelPos(srcData + _vm->_resourceHeaderSize, x, y, srcWidth, srcHeight);
}
if (_vm->_game.heversion > 98) {
- // Flip the test coords if needed and do simple point rejection
- // (should be faster than calling the various functions)
-
+ // Flip the test coords if needed and do simple point rejection...
if (flags & kWRFHFlip) {
- x = ((src_w - 1) - x);
+ x = ((srcWidth - 1) - x);
if (x < 0) {
return 0;
}
- } else if ((x >= src_w) || (x < 0)) {
+ } else if ((x >= srcWidth) || (x < 0)) {
return 0;
}
if (flags & kWRFVFlip) {
- y = ((src_h - 1) - y);
+ y = ((srcHeight - 1) - y);
if (y < 0) {
return 0;
}
- } else if ((y >= src_h) || (y < 0)) {
+ } else if ((y >= srcHeight) || (y < 0)) {
return 0;
}
}
// If the compression type is TRLE...
- if (src_c == kWCTTRLE) {
- src_d = getWizStateDataPrim(globNum, state);
+ if (srcComp == kWCTTRLE) {
+ srcData = getWizStateDataPrim(globNum, state);
- return auxHitTestTRLEImageRelPos(src_d + _vm->_resourceHeaderSize, x, y, src_w, src_h);
- } else if (_vm->_game.heversion > 98 && isUncompressedFormatTypeID(src_c)) {
+ return auxHitTestTRLEImageRelPos(srcData + _vm->_resourceHeaderSize, x, y, srcWidth, srcHeight);
+ } else if (_vm->_game.heversion > 98 && isUncompressedFormatTypeID(srcComp)) {
WizSimpleBitmap srcBitmap;
- src_d = getWizStateDataPrim(globNum, state) + _vm->_resourceHeaderSize;
+ srcData = getWizStateDataPrim(globNum, state) + _vm->_resourceHeaderSize;
- srcBitmap.bufferPtr = (WizRawPixel *)const_cast<byte *>(src_d);
- srcBitmap.bitmapWidth = src_w;
- srcBitmap.bitmapHeight = src_h;
+ srcBitmap.bufferPtr = (WizRawPixel *)const_cast<byte *>(srcData);
+ srcBitmap.bitmapWidth = srcWidth;
+ srcBitmap.bitmapHeight = srcHeight;
return (_vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR) !=
- pgReadPixel(&srcBitmap, x, y, _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR)))
- ? 1
- : 0;
+ pgReadPixel(&srcBitmap, x, y, _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR))) ? 1 : 0;
} else {
return 0;
}
@@ -788,7 +780,7 @@ void Wiz::processWizImagePolyCaptureCmd(const WizImageCommand *params) {
if (params->actionFlags & kWAFPolygon) {
polygon1 = params->polygon;
} else {
- error("Image capture poly: no polygon 1 specified.");
+ error("Wiz::processWizImagePolyCaptureCmd(): Image capture poly: no polygon 1 specified.");
}
if (params->actionFlags & kWAFPolygon2) {
@@ -808,7 +800,7 @@ void Wiz::processWizImagePolyCaptureCmd(const WizImageCommand *params) {
}
if (params->actionFlags & kWAFDestImage) {
- error("Image capture poly: destination 'image' not supported, use 'source image'");
+ error("Wiz::processWizImagePolyCaptureCmd(): destination 'image' not supported, use 'source image'");
}
if (params->actionFlags & kWAFSourceImage) {
@@ -822,7 +814,7 @@ void Wiz::processWizImagePolyCaptureCmd(const WizImageCommand *params) {
if (params->actionFlags & kWAFProperty) {
if (params->propertyNumber == 1) { // Color hint property
if (!shadow) {
- debug(7, "ProcessWizImagePolyCaptureCmd: color hint does nothing for an unfiltered scale.");
+ debug(7, "Wiz::processWizImagePolyCaptureCmd(): color hint does nothing for an unfiltered scale.");
}
isHintColor = true;
@@ -830,7 +822,7 @@ void Wiz::processWizImagePolyCaptureCmd(const WizImageCommand *params) {
}
}
- // validate the parameters
+ // Validate the parameters...
bool poly1Found = false;
bool poly2Found = false;
@@ -839,14 +831,14 @@ void Wiz::processWizImagePolyCaptureCmd(const WizImageCommand *params) {
poly1Found = true;
polygon1 = polyIndex;
if (_polygons[polyIndex].numPoints != 5)
- error("Invalid point count");
+ error("Wiz::processWizImagePolyCaptureCmd(): Invalid point count");
}
if (polygon2 == _polygons[polyIndex].id) {
poly2Found = true;
polygon2 = polyIndex;
if (_polygons[polyIndex].numPoints != 5)
- error("Invalid point count");
+ error("Wiz::processWizImagePolyCaptureCmd(): Invalid point count");
}
if (poly1Found && poly2Found) {
@@ -855,29 +847,23 @@ void Wiz::processWizImagePolyCaptureCmd(const WizImageCommand *params) {
}
if (!poly1Found) {
- error("Image capture poly: Polygon %d not defined", polygon1);
+ error("Wiz::processWizImagePolyCaptureCmd(): Polygon %d not defined", polygon1);
}
if (!poly2Found) {
- error("Image capture poly: Polygon %d not defined", polygon2);
+ error("Wiz::processWizImagePolyCaptureCmd(): Polygon %d not defined", polygon2);
}
if (_polygons[polygon1].numPoints != _polygons[polygon2].numPoints) {
- error("Image capture poly: Polygons MUST have same number of points.");
+ error("Wiz::processWizImagePolyCaptureCmd(): Polygons MUST have same number of points.");
}
- // create the buffers to hold the source and dest image bits
- // since a lot of drawing commands will be called, and we can't gurantee
- // that the source image will stick around, we make a buffer big enough
- // to contain it and then copy the bits in.
-
+ // Create the buffers to hold the source and destination image bitmaps...
WizSimpleBitmap srcBitmap, destBitmap;
srcBitmap.bufferPtr = nullptr;
destBitmap.bufferPtr = nullptr;
- // we need to get the poly points
-
- // build a bounding rect for the polys and set the appropriate sizes in the bitmaps
+ // Build a bounding rect for the polys and set the appropriate sizes in the bitmaps...
Common::Rect destPolyRect;
Common::Rect srcPolyRect;
@@ -887,20 +873,20 @@ void Wiz::processWizImagePolyCaptureCmd(const WizImageCommand *params) {
destBitmap.bufferPtr = (WizRawPixel *)malloc(destBitmap.bitmapWidth * destBitmap.bitmapHeight * sizeof(WizRawPixel));
if (!destBitmap.bufferPtr) {
- error("Image capture poly: Could not allocate destination buffer");
+ error("Wiz::processWizImagePolyCaptureCmd(): Could not allocate destination buffer");
}
- // fill with transparent color
+ // Fill with transparent color...
rawPixelMemset(destBitmap.bufferPtr,
_vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR),
destBitmap.bitmapWidth * destBitmap.bitmapHeight);
- // get the bound rect for the poly
+ // Get the bound rect for the poly...
polyBuildBoundingRect(_polygons[polygon1].points, _polygons[polygon1].numPoints, srcPolyRect);
- // we need to get the points so that they can be offset to the correct position in
- // the source buffer in the case of a screen capture (since the whole screen may not
- // be captured, and the polygon may be offset into it, so we only create a buffer of the size needed
+ // We need to save the current points so that they can be offset to the correct position in
+ // the source buffer in the case of a screen capture (since the whole screen may not be captured,
+ // and the polygon may be offset into it)...
int pointCt;
Common::Point srcPoints[5];
for (pointCt = 0; pointCt < 5; ++pointCt) {
@@ -908,12 +894,12 @@ void Wiz::processWizImagePolyCaptureCmd(const WizImageCommand *params) {
srcPoints[pointCt].y = _polygons[polygon1].points[pointCt].y;
}
- // check for one to one rectangle, which will set up for an image copy later
+ // Check for one to one rectangle, which will set up for an image copy later...
bool oneToOneRect = false;
- // see if they are both rectangles, passing in 4 because it turns out you can only create a 4 vertex polygon in scumm
- // according to set4Polygon
+
+ // See if they are both rectangles; the '4' notes the maximum amount of vertexes we can have...
if (polyIsRectangle(_polygons[polygon1].points, 4) && polyIsRectangle(_polygons[polygon2].points, 4)) {
- // check if the points are all the same
+ // Check if the points are all the same, and bail if so...
for (pointCt = 0; pointCt < 4; ++pointCt) {
if ((_polygons[polygon1].points[pointCt].x != _polygons[polygon2].points[pointCt].x) ||
(_polygons[polygon1].points[pointCt].y != _polygons[polygon2].points[pointCt].y)) {
@@ -926,7 +912,7 @@ void Wiz::processWizImagePolyCaptureCmd(const WizImageCommand *params) {
}
}
- // if there is a source image, get its bits, otherwise capture from the screen
+ // If there is a source image, get it, otherwise capture from the screen...
if (srcImage) {
// get the wiz size
Common::Rect clipRect;
@@ -938,47 +924,46 @@ void Wiz::processWizImagePolyCaptureCmd(const WizImageCommand *params) {
clipRect.right = w;
clipRect.bottom = h;
- // make sure capture area isn't outside or bigger than the source image
+ // Make sure the capture area isn't outside or bigger than the source image...
Common::Rect testRect;
combineRects(&testRect, &srcPolyRect, &clipRect);
if ((getRectWidth(&testRect) * getRectHeight(&testRect)) >
(getRectWidth(&clipRect) * getRectHeight(&clipRect))) {
- error("Image capture poly: Specified polygon captures points outside bounds of source image");
+ error("Wiz::processWizImagePolyCaptureCmd(): Specified polygon captures points outside bounds of source image");
}
- // clip poly to image and verify it's within the image
+ // Clip poly to image and verify it's within the image...
if (!findRectOverlap(&srcPolyRect, &clipRect)) {
- error("Image capture poly: Specified polygon doesn't intersect source image.");
+ error("Wiz::processWizImagePolyCaptureCmd(): Specified polygon doesn't intersect source image.");
}
srcBitmap.bitmapWidth = getRectWidth(&srcPolyRect);
srcBitmap.bitmapHeight = getRectHeight(&srcPolyRect);
if ((srcBitmap.bitmapWidth == 0) || (srcBitmap.bitmapHeight == 0)) {
- error("Image capture poly: Poly or source image invalid");
+ error("Wiz::processWizImagePolyCaptureCmd(): Poly or source image invalid");
}
- // create the bitmap
+ // Create the bitmap...
srcBitmap.bufferPtr = (WizRawPixel *)malloc(srcBitmap.bitmapWidth * srcBitmap.bitmapHeight * sizeof(WizRawPixel));
if (!srcBitmap.bufferPtr) {
- error("Image capture poly: Could not allocate source buffer");
+ error("Wiz::processWizImagePolyCaptureCmd(): Could not allocate source buffer");
}
- // clear to transparent
+ // Set it all to transparent...
rawPixelMemset(srcBitmap.bufferPtr,
_vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR),
srcBitmap.bitmapWidth * srcBitmap.bitmapHeight);
drawAWiz(srcImage, state, 0, 0, 0, 0, 0, 0, &srcPolyRect, 0, &srcBitmap);
- } else { // we must be capturing from screen
-
- // get the window size
+ } else {
+ // If we're here, we are handling a screen capture...
VirtScreen *pvs = &_vm->_virtscr[kMainVirtScreen];
int windowWidth = pvs->w;
int windowHeight = pvs->h;
- // intersect the bound rect and the window rect
+ // Intersect the bound rect and the VirtScreen rect...
Common::Rect clipRect;
clipRect.left = 0;
clipRect.top = 0;
@@ -986,28 +971,28 @@ void Wiz::processWizImagePolyCaptureCmd(const WizImageCommand *params) {
clipRect.bottom = windowHeight - 1;
if (!findRectOverlap(&srcPolyRect, &clipRect)) {
- error("Image capture poly: Specified polygon doesn't intersect screen.");
+ error("Wiz::processWizImagePolyCaptureCmd(): Specified polygon doesn't intersect screen.");
}
srcBitmap.bitmapWidth = getRectWidth(&srcPolyRect);
srcBitmap.bitmapHeight = getRectHeight(&srcPolyRect);
if ((srcBitmap.bitmapWidth == 0) || (srcBitmap.bitmapHeight == 0)) {
- error("Image capture poly: Specified screen rectangle invalid.");
+ error("Wiz::processWizImagePolyCaptureCmd(): Specified screen rectangle invalid.");
}
- // create the bitmap
+ // Create the bitmap...
srcBitmap.bufferPtr = (WizRawPixel *)malloc(srcBitmap.bitmapWidth * srcBitmap.bitmapHeight * sizeof(WizRawPixel));
if (!srcBitmap.bufferPtr) {
- error("Image capture poly: Could not allocate source buffer");
+ error("Wiz::processWizImagePolyCaptureCmd(): Could not allocate source buffer");
}
- // clear to transparent
+ // Set it all to transparent...
rawPixelMemset(srcBitmap.bufferPtr,
_vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR),
srcBitmap.bitmapWidth * srcBitmap.bitmapHeight);
- // fill it with screen data
+ // Fill it with screen data...
WizRawPixel *screenPtr = (WizRawPixel *)pvs->getPixels(srcPolyRect.left, srcPolyRect.top);
WizRawPixel *destPtr;
@@ -1036,20 +1021,20 @@ void Wiz::processWizImagePolyCaptureCmd(const WizImageCommand *params) {
}
}
- // translate the polygon so it is in the correct place in the buffer
+ // Translate the polygon so it is in the correct place in the buffer...
int dx = 0, dy = 0;
dx = 0 - srcPolyRect.left;
dy = 0 - srcPolyRect.top;
polyMovePolygonPoints(srcPoints, _polygons[polygon1].numPoints, dx, dy);
}
- // if there is an xmap, do filtered warp
+ // If there is an xmap shadow, perform a filtered warp...
if (shadow) {
- // get the color map, bypass the header information
+ // Het the color map, bypass the header information...
const byte *xmapColorTable = getColorMixBlockPtrForWiz(shadow);
if (!xmapColorTable) {
- error("Image capture poly: Shadow specified but not present in image.");
+ error("Wiz::processWizImagePolyCaptureCmd(): Shadow specified but not present in image.");
}
xmapColorTable += _vm->_resourceHeaderSize;
@@ -1071,9 +1056,9 @@ void Wiz::processWizImagePolyCaptureCmd(const WizImageCommand *params) {
_polygons[polygon1].numPoints, _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR),
xmapColorTable, isHintColor, (WizRawPixel)hintColor);
- } else if (oneToOneRect) { // if a one to one copy is performed, just copy this bits
+ } else if (oneToOneRect) { // If a one to one copy is performed, just copy this bitmap...
memcpy(destBitmap.bufferPtr, srcBitmap.bufferPtr, destBitmap.bitmapHeight * destBitmap.bitmapWidth);
- } else { // otherwise do "old" warp
+ } else { // Otherwise fallback to regular warping...
WarpWizPoint polypoints[5];
for (int i = 0; i < 5; i++) {
WarpWizPoint tmp(_polygons[polygon2].points[i]);
@@ -1091,7 +1076,7 @@ void Wiz::processWizImagePolyCaptureCmd(const WizImageCommand *params) {
_polygons[polygon1].numPoints, _vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR));
}
- // now build a wiz with the destination bitmap and throw the bitmaps away
+ // Now build a Wiz with the destination bitmap and throw the bitmaps away...
if (srcBitmap.bufferPtr) {
free(srcBitmap.bufferPtr);
srcBitmap.bufferPtr = nullptr;
@@ -1181,7 +1166,7 @@ void Wiz::loadWizCursor(int resId, int palette, bool useColor) {
_vm->setCursorHotspot(x, y);
_vm->setCursorFromBuffer(cursor, cw, ch, cw * _vm->_bytesPerPixel);
- // Since we set up cursor palette for default cursor, disable it now
+ // Since we set up cursor palette for default cursor, disable it now...
CursorMan.disableCursorPalette(true);
free(cursor);
@@ -1285,30 +1270,29 @@ void Wiz::processWizImageDrawCmd(const WizImageCommand *params) {
}
if (requiredImageCount > 0) {
- // Mark the all the image globs as stuck
+ // Mark the all the image resources as stuck...
for (int i = 0; i < requiredImageCount; i++) {
_vm->_res->lock(rtImage, requiredImages[i]);
}
- // Make sure that the globs are in RAM by requesting their address
- // Do this twice to hopefully ensure that there will be no heap movement
+ // Make sure that the resources are in RAM by requesting their address...
for (int i = 0; i < requiredImageCount; i++) {
_vm->ensureResourceLoaded(rtImage, requiredImages[i]);
}
- // Mark the all the image globs as NOT stuck
+ // Mark the all the image resources as NOT stuck...
for (int i = 0; i < requiredImageCount; i++) {
_vm->_res->unlock(rtImage, requiredImages[i]);
}
- // Validate that all of the images are on the heap!
+ // Validate that all of the images are now on the heap!
for (int i = 0; i < requiredImageCount; i++) {
if (!_vm->getResourceAddress(rtImage, requiredImages[i])) {
error("Wiz::processWizImageDrawCmd(): Image %d missing for image operation", requiredImages[i]);
}
}
- // See if the images are in their native format and twiddle if need be.
+ // Check if the images are in their native format and swap them if needed...
if (_vm->_game.heversion > 99) {
for (int i = 0; i < requiredImageCount; i++) {
ensureNativeFormatImageForState(requiredImages[i], state);
@@ -1317,7 +1301,7 @@ void Wiz::processWizImageDrawCmd(const WizImageCommand *params) {
}
if (params->actionFlags & kWAFDestImage) {
- // Get the rendering surface for this image
+ // Get the rendering surface for this image...
if (!dwSetSimpleBitmapStructFromImage(params->destImageNumber, 0, &fakeBitmap)) {
error("Wiz::processWizImageDrawCmd(): Image %d is invalid for rendering into", params->destImageNumber);
}
@@ -1466,14 +1450,14 @@ bool Wiz::dwSetSimpleBitmapStructFromImage(int imageNum, int imageState, WizSimp
byte *wizHeader;
byte *dataPtr;
- // Get the image header
+ // Get the image header...
wizHeader = (byte *)getWizStateHeaderPrim(imageNum, imageState);
if (!wizHeader) {
return false;
}
- // Double check the image header compression type
+ // Double check the image header compression type...
compType = READ_LE_UINT32(wizHeader + _vm->_resourceHeaderSize);
if (!isUncompressedFormatTypeID(compType)) {
@@ -1483,14 +1467,14 @@ bool Wiz::dwSetSimpleBitmapStructFromImage(int imageNum, int imageState, WizSimp
imageWidth = READ_LE_UINT32(wizHeader + _vm->_resourceHeaderSize + 4);
imageHeight = READ_LE_UINT32(wizHeader + _vm->_resourceHeaderSize + 8);
- // Do some fun stuff
+ // Fetch the data...
dataPtr = (byte *)getWizStateDataPrim(imageNum, imageState);
if (!dataPtr) {
return false;
}
- // Hook up the image info to the simple bitmap info
+ // Hook up the image info to the simple bitmap info...
destBM->bufferPtr = (WizRawPixel *)(dataPtr + _vm->_resourceHeaderSize);
destBM->bitmapWidth = imageWidth;
destBM->bitmapHeight = imageHeight;
@@ -1534,18 +1518,18 @@ void Wiz::dwAltSourceDrawWiz(int maskImage, int maskState, int x, int y, int sou
byte *maskDataPtr;
bool markUpdates;
- // Get the conversion table if any
+ // Get the conversion table if any...
if (paletteNumber) {
conversionTable = (WizRawPixel *)_vm->getHEPaletteSlot(paletteNumber);
} else {
if (_uses16BitColor) {
- conversionTable = (WizRawPixel *)_vm->getHEPaletteSlot(1); // Generic conversion table
+ conversionTable = (WizRawPixel *)_vm->getHEPaletteSlot(1); // Generic conversion table...
} else {
conversionTable = nullptr;
}
}
- // Get the dest bitmap ptr
+ // Get the destination bitmap...
if (!destBitmapPtr) {
markUpdates = true;
@@ -1560,7 +1544,7 @@ void Wiz::dwAltSourceDrawWiz(int maskImage, int maskState, int x, int y, int sou
markUpdates = false;
}
- // Check for overlap with the optional clip rectangle, if any
+ // Check for overlap with the optional clip rectangle, if any...
clipRect.left = 0;
clipRect.top = 0;
clipRect.right = destBitmapPtr->bitmapWidth - 1;
@@ -1568,15 +1552,15 @@ void Wiz::dwAltSourceDrawWiz(int maskImage, int maskState, int x, int y, int sou
if (optionalClipRect) {
if (!findRectOverlap(&clipRect, optionalClipRect)) {
- return; // We're done there is no update region.
+ return; // We're done, there is no update region.
}
}
- // Get the source (alt) bitmap ptr & general info
+ // Get the source (alt) bitmap pointer, and general info...
sourceCompressionType = getWizCompressionType(sourceImage, sourceState);
if (!dwIsUncompressedFormatTypeID(sourceCompressionType)) {
- error("Wiz::dwAltSourceDrawWiz(): Source image %d must be uncompressed.", sourceImage);
+ error("Wiz::dwAltSourceDrawWiz(): Source image %d must be uncompressed", sourceImage);
}
switch (sourceCompressionType) {
@@ -1592,7 +1576,7 @@ void Wiz::dwAltSourceDrawWiz(int maskImage, int maskState, int x, int y, int sou
break;
}
- // Get the source wiz data pointer.
+ // Get the source wiz data pointer...
sourceBufferPtr = (byte *)getWizStateDataPrim(sourceImage, sourceState);
if (!sourceBufferPtr) {
@@ -1611,11 +1595,11 @@ void Wiz::dwAltSourceDrawWiz(int maskImage, int maskState, int x, int y, int sou
destBitmapPtr->bitmapWidth, destBitmapPtr->bitmapHeight);
}
- // Finally get the compressed data pointer
+ // Finally get the compressed data pointer...
maskCompressionType = getWizCompressionType(maskImage, maskState);
if (!dwIsMaskCompatibleCompressionType(maskCompressionType)) {
- error("Wiz::dwAltSourceDrawWiz(): Mask image %d must be a maskable compression type.", maskImage);
+ error("Wiz::dwAltSourceDrawWiz(): Mask image %d must be a maskable compression type", maskImage);
}
maskDataPtr = (byte *)getWizStateDataPrim(maskImage, maskState);
@@ -1627,7 +1611,7 @@ void Wiz::dwAltSourceDrawWiz(int maskImage, int maskState, int x, int y, int sou
maskDataPtr += _vm->_resourceHeaderSize;
getWizImageDim(maskImage, maskState, maskWidth, maskHeight);
- // Make sure that we have an overlap before we call the decompressor
+ // Make sure that we have an overlap before we call the decompressor...
destRect.left = x;
destRect.top = y;
destRect.right = x + maskWidth - 1;
@@ -1672,7 +1656,7 @@ void Wiz::dwHandleComplexImageDraw(int image, int state, int x, int y, int shado
Common::Point listOfPoints[4];
const byte *shadowPtr;
- // Set the optional remap table up to the default if one isn't specified
+ // Set the optional remap table up to the default if one isn't specified...
if (!optionalColorConversionTable) {
if (_uses16BitColor) {
optionalColorConversionTable = (WizRawPixel *)_vm->getHEPaletteSlot(1);
@@ -1694,13 +1678,13 @@ void Wiz::dwHandleComplexImageDraw(int image, int state, int x, int y, int shado
listOfPoints[3].x = listOfPoints[0].x;
listOfPoints[3].y = listOfPoints[2].y;
- // Hflip
+ // Hflip?
if (flags & kWRFHFlip) {
SWAP<int16>(listOfPoints[0].x, listOfPoints[1].x);
SWAP<int16>(listOfPoints[2].x, listOfPoints[3].x);
}
- // VFlip
+ // VFlip?
if (flags & kWRFVFlip) {
SWAP<int16>(listOfPoints[0].y, listOfPoints[1].y);
SWAP<int16>(listOfPoints[2].y, listOfPoints[3].y);
@@ -1714,15 +1698,15 @@ void Wiz::dwHandleComplexImageDraw(int image, int state, int x, int y, int shado
}
}
- // Rotate the points
+ // Rotate the points?
if (angle) {
polyRotatePoints(listOfPoints, 4, angle);
}
- // Offset the points
+ // Offset the points...
polyMovePolygonPoints(listOfPoints, 4, x, y);
- // Special case rotate 0,90,180,270 degree special cases
+ // Special case rotate 0,90,180,270 degree special cases...
if (scale == 256) {
Common::Rect boundingRect;
@@ -1732,8 +1716,8 @@ void Wiz::dwHandleComplexImageDraw(int image, int state, int x, int y, int shado
correctedAngle = (360 - correctedAngle);
}
- // Get the upper left point so that our blit matches in position
- // the normal warp drawing function.
+ // Get the upper left point so that our blit matches
+ // in position the normal warp drawing function...
polyBuildBoundingRect(listOfPoints, 4, boundingRect);
x = boundingRect.left;
y = boundingRect.top;
@@ -1768,7 +1752,7 @@ void Wiz::dwHandleComplexImageDraw(int image, int state, int x, int y, int shado
}
}
- // If there is a shadow get it's address
+ // If there is a shadow get it's address...
if (shadow) {
shadowPtr = getColorMixBlockPtrForWiz(shadow);
@@ -1785,7 +1769,7 @@ void Wiz::dwHandleComplexImageDraw(int image, int state, int x, int y, int shado
listOfWarpPoints[i] = tmp;
}
- // Finally call the renderer
+ // Finally call the renderer...
warpDrawWizTo4Points(
image, state, listOfWarpPoints, flags,
_vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR),
@@ -1845,7 +1829,7 @@ void Wiz::handleRotate90SpecialCase(int image, int state, int x, int y, int shad
Common::Rect updateRect;
int compressionType;
- // Make the update rect and check it against the clip rect if one
+ // Make the update rect and check it against the clip rect if one...
int w, h;
getWizImageDim(image, state, w, h);
makeSizedRectAt(&updateRect, x, y, h, w); // We are swapping height and width on purpose!
@@ -1864,11 +1848,11 @@ void Wiz::handleRotate90SpecialCase(int image, int state, int x, int y, int shad
const byte *compressedDataPtr;
WizRawPixel *dest_p;
- // Get the size of the compressed image
+ // Get the size of the compressed image...
src_w = w;
src_h = h;
- // Get the compressed data ptr!
+ // Get the compressed data pointer...
compressedDataPtr = (byte *)getWizStateDataPrim(image, state);
compressedDataPtr += _vm->_resourceHeaderSize;
@@ -1935,7 +1919,7 @@ void Wiz::handleRotate90SpecialCase(int image, int state, int x, int y, int shad
(WizRawPixel)_vm->VAR(_vm->VAR_WIZ_TRANSPARENT_COLOR));
}
- // Free up working bitmap from
+ // Free up the temporary pointer...
free(srcBitmap.bufferPtr);
srcBitmap.bufferPtr = nullptr;
@@ -1980,7 +1964,7 @@ void Wiz::processWizImageRenderRectCmd(const WizImageCommand *params) {
whichImage = params->image;
- // Make the clipping rect for this image / state
+ // Make the clipping rect for this image / state...
getWizImageDim(whichImage, whichState, w, h);
makeSizedRectAt(&clipRect, 0, 0, w, h);
@@ -1990,27 +1974,27 @@ void Wiz::processWizImageRenderRectCmd(const WizImageCommand *params) {
workClipRect.right = params->box.right;
workClipRect.bottom = params->box.bottom;
- // Bail out if there isn't overlap between the clipping rects
+ // Bail out if there isn't overlap between the clipping rects...
if (!findRectOverlap(&clipRect, &workClipRect)) {
return;
}
}
- // Get the rendering coords or assume the entire
+ // Get the rendering coords or assume the entire...
if (params->actionFlags & kWAFRenderCoords) {
renderRect = params->renderCoords;
} else {
renderRect = clipRect;
}
- // What is the rendering color
+ // What is the rendering color?
if (params->actionFlags & kWAFColor) {
whatColor = params->colorValue;
} else {
whatColor = _vm->VAR(_vm->VAR_COLOR_BLACK);
}
- // Get the simple bitmap
+ // Get the simple bitmap...
if (!dwSetSimpleBitmapStructFromImage(whichImage, whichState, &renderBitmap)) {
error("Wiz::processWizImageRenderRectCmd(): Image %d state %d invalid for rendering", whichImage, whichState);
}
@@ -2057,20 +2041,20 @@ void Wiz::processWizImageRenderLineCmd(const WizImageCommand *params) {
workClipRect.right = params->box.right;
workClipRect.bottom = params->box.bottom;
- // Bail out if there isn't overlap between the clipping rects
+ // Bail out if there isn't overlap between the clipping rects...
if (!findRectOverlap(&clipRect, &workClipRect)) {
return;
}
}
- // What is the rendering color
+ // What is the rendering color?
if (params->actionFlags & kWAFColor) {
whatColor = params->colorValue;
} else {
whatColor = _vm->VAR(_vm->VAR_COLOR_BLACK);
}
- // Get the simple bitmap
+ // Get the simple bitmap...
if (!dwSetSimpleBitmapStructFromImage(whichImage, whichState, &renderBitmap)) {
error("Wiz::processWizImageRenderLineCmd(): Image %d state %d invalid for rendering", whichImage, whichState);
}
@@ -2139,7 +2123,7 @@ void Wiz::processWizImageRenderPixelCmd(const WizImageCommand *params) {
workClipRect.right = params->box.right;
workClipRect.bottom = params->box.bottom;
- // Bail out if there isn't overlap between the clipping rects
+ // Bail out if there isn't overlap between the clipping rects...
if (!findRectOverlap(&clipRect, &workClipRect)) {
return;
}
@@ -2194,14 +2178,14 @@ int Wiz::createHistogramArrayForImage(int image, int state, const Common::Rect *
((ScummEngine_v72he *)_vm)->defineArray(0, _vm->kDwordArray, 0, 0, 0, 255);
if (_vm->readVar(0) != 0) {
- // Get the header (width, height + compression)
+ // Get the header (width, height + compression)...
pp = getWizStateHeaderPrim(globNum, state);
src_c = READ_LE_UINT32(pp + _vm->_resourceHeaderSize + 0);
src_w = READ_LE_UINT32(pp + _vm->_resourceHeaderSize + 4);
src_h = READ_LE_UINT32(pp + _vm->_resourceHeaderSize + 8);
- // Clip the passed in coords to the real dimensions of the image
+ // Clip the passed in coords to the real dimensions of the image...
makeSizedRect(&realClippedRect, src_w, src_h);
if (optionalClipRect) {
@@ -2210,7 +2194,7 @@ int Wiz::createHistogramArrayForImage(int image, int state, const Common::Rect *
}
}
- // Get the data pointer
+ // Get the data pointer...
src_d = getWizStateDataPrim(globNum, state);
// Start with a clean array...
@@ -2244,7 +2228,7 @@ int Wiz::createHistogramArrayForImage(int image, int state, const Common::Rect *
}
void Wiz::ensureNativeFormatImageForState(int image, int state) {
- // If AWIZ block is an XMAP, we don't want to do anything with it
+ // If AWIZ block is an XMAP, we don't want to do anything with it...
if (dwGetImageGeneralProperty(image, state, kWIPXMAPBlockPresent)) {
return;
}
@@ -2286,7 +2270,7 @@ void Wiz::ensureNativeFormatImageForState(int image, int state) {
break;
}
- // Reset the compression type
+ // Reset the compression type...
setWizCompressionType(image, state, newCompType);
}
}
@@ -2319,14 +2303,14 @@ void Wiz::processWizImageRenderEllipseCmd(const WizImageCommand *params) {
}
int whichImage = params->image;
-
- // Make the clipping rect for this image / state
+
+ // Make the clipping rect for this image / state...
getWizImageDim(whichImage, whichState, width, height);
Common::Rect clipRect;
makeSizedRectAt(&clipRect, 0, 0, width, height);
- // Get the simple bitmap
+ // Get the simple bitmap...
WizSimpleBitmap renderBitmap;
if (!dwSetSimpleBitmapStructFromImage(whichImage, whichState, &renderBitmap)) {
@@ -2389,7 +2373,7 @@ void Wiz::processWizImageRenderFloodFillCmd(const WizImageCommand *params) {
whichImage = params->image;
- // Make the clipping rect for this image / state
+ // Make the clipping rect for this image / state...
getWizImageDim(whichImage, whichState, w, h);
makeSizedRectAt(&clipRect, 0, 0, w, h);
@@ -2399,20 +2383,20 @@ void Wiz::processWizImageRenderFloodFillCmd(const WizImageCommand *params) {
workClipRect.right = params->box.right;
workClipRect.bottom = params->box.bottom;
- // Bail out if there isn't overlap between the clipping rects
+ // Bail out if there isn't overlap between the clipping rects...
if (!findRectOverlap(&clipRect, &workClipRect)) {
return;
}
}
- // What is the rendering color
+ // What is the rendering color?
if (params->actionFlags & kWAFColor) {
whatColor = params->colorValue;
} else {
whatColor = _vm->VAR(_vm->VAR_COLOR_BLACK);
}
- // Get the simple bitmap
+ // Get the simple bitmap...
if (!dwSetSimpleBitmapStructFromImage(whichImage, whichState, &renderBitmap)) {
error("Image %d state %d invalid for rendering.", whichImage, whichState);
}
@@ -2773,7 +2757,7 @@ bool Wiz::collisionCompareImageLines(
const byte *imageBData, int bType, int bw, int bh, int32 wizBFlags, int bx, int by,
int compareWidth, WizRawPixel transparentColor) {
- // Get line A's data
+ // Get line A's data...
rawPixelMemset(_compareBufferA, transparentColor, compareWidth);
if (aType == kWCTTRLE) {
@@ -2789,7 +2773,7 @@ bool Wiz::collisionCompareImageLines(
transparentColor);
}
- // Get line B's data
+ // Get line B's data...
rawPixelMemset(_compareBufferB, transparentColor, compareWidth);
if (bType == kWCTTRLE) {
@@ -2805,7 +2789,7 @@ bool Wiz::collisionCompareImageLines(
transparentColor);
}
- // Compare the lines
+ // Finally compare the lines...
if (compareDoPixelStreamsOverlap(_compareBufferA, _compareBufferB, compareWidth, transparentColor)) {
return true;
}
diff --git a/engines/scumm/he/wizwarp_he.cpp b/engines/scumm/he/wizwarp_he.cpp
index d437a7a6ea6..5b825690d6c 100644
--- a/engines/scumm/he/wizwarp_he.cpp
+++ b/engines/scumm/he/wizwarp_he.cpp
@@ -38,7 +38,7 @@ bool Wiz::warpDrawWiz(int image, int state, int polygon, int32 flags, int transp
const byte *xmapColorTable;
int polyIndex;
- // Error check the params.
+ // Parameters check...
for (polyIndex = 0; polyIndex < ARRAYSIZE(_polygons); polyIndex++) {
if (_polygons[polyIndex].id == polygon) {
break;
@@ -53,7 +53,6 @@ bool Wiz::warpDrawWiz(int image, int state, int polygon, int32 flags, int transp
error("Wiz::warpDrawWiz(): Invalid point count");
}
- // How to lock this bad boy down?
if (shadowImage) {
xmapColorTable = getColorMixBlockPtrForWiz(shadowImage);
if (xmapColorTable) {
@@ -64,7 +63,7 @@ bool Wiz::warpDrawWiz(int image, int state, int polygon, int32 flags, int transp
xmapColorTable = nullptr;
}
- // Call the actual warping primitive
+ // Call the actual warping primitive...
WarpWizPoint polypoints[5];
for (int i = 0; i < 5; i++) {
WarpWizPoint tmp(_polygons[polyIndex].points[i]);
@@ -84,12 +83,12 @@ bool Wiz::warpDrawWizTo4Points(int image, int state, const WarpWizPoint *dstPoin
WarpWizPoint srcPoints[4];
byte *ptr;
- // Set the optional remap table up to the default if one isn't specified
+ // Set the optional remap table up to the default if one isn't specified...
if (!optionalColorConversionTable && _uses16BitColor) {
optionalColorConversionTable = (WizRawPixel *)_vm->getHEPaletteSlot(1);
}
- // Decompress the wiz into a WizSimpleBitmap... (Always if using a remap table)
+ // Decompress the wiz into a WizSimpleBitmap... (Always, if using a remap table)...
if ((getWizCompressionType(image, state) != kWCTNone) ||
(optionalColorConversionTable != nullptr) || (flags & (kWRFHFlip | kWRFVFlip | kWRFRemap))) {
@@ -101,17 +100,16 @@ bool Wiz::warpDrawWizTo4Points(int image, int state, const WarpWizPoint *dstPoin
freeBitmapBits = true;
} else {
- // Get a pointer to the bits!
ptr = (byte *)getWizStateDataPrim(image, state);
if (!ptr)
error("Wiz::warpDrawWizTo4Points(): Image %d missing data", image);
- // Map the srcBitmap bits to the wiz data...
+ // Map the srcBitmap to the Wiz data...
srcBitmap.bufferPtr = (WizRawPixel *)(ptr + _vm->_resourceHeaderSize);
freeBitmapBits = false;
}
- // Fill in the dest bitmap structure.
+ // Fill in the dest bitmap structure...
if (optionalDestBitmap) {
dstBitmap = *optionalDestBitmap;
} else {
@@ -140,7 +138,7 @@ bool Wiz::warpDrawWizTo4Points(int image, int state, const WarpWizPoint *dstPoin
}
}
- // Find the bounding rect and double check the coords.
+ // Find the bounding rect and double check the coords...
updateRect.left = 12345;
updateRect.top = 12345;
updateRect.right = -12345;
@@ -171,7 +169,7 @@ bool Wiz::warpDrawWizTo4Points(int image, int state, const WarpWizPoint *dstPoin
srcPoints[3].x = 0;
srcPoints[3].y = srcBitmap.bitmapHeight - 1;
- // Call the warping primitive!
+ // Call the warping primitive...
if (_vm->_game.heversion >= 95 && colorMixTable) {
rValue = warpNPt2NPtClippedWarpMixColors(
&dstBitmap, dstPoints, &srcBitmap, srcPoints, 4, transparentColor,
@@ -203,7 +201,7 @@ bool Wiz::warpDrawWizTo4Points(int image, int state, const WarpWizPoint *dstPoin
}
}
- // Cleanup!
+ // Clean up...
if (freeBitmapBits) {
free(srcBitmap.bufferPtr);
srcBitmap.bufferPtr = nullptr;
@@ -308,7 +306,7 @@ WarpWizOneSpanTable *Wiz::warpBuildSpanTable(WizSimpleBitmap *dstBitmap, const W
warpFillSpanWithLine(st, dstPts, &dstPt, srcPts, &srcPt);
- // Build the draw span table!
+ // Build the draw span table...
drawSpan = st->drawSpans;
dw = dstBitmap->bitmapWidth;
span = st->spans;
@@ -321,12 +319,12 @@ WarpWizOneSpanTable *Wiz::warpBuildSpanTable(WizSimpleBitmap *dstBitmap, const W
}
for (int i = st->spanCount; --i >= 0; ++cy, ++span, offset += dw) {
- // Clip vertical or all ?
+ // Clip vertical?
if ((cy < clippingRect.top) || (cy > clippingRect.bottom)) {
continue;
}
- // Clip horizontal
+ // Clip horizontal?
cl = MAX<int>(clippingRect.left, span->dstLeft);
cr = MIN<int>(clippingRect.right, span->dstRight);
@@ -334,7 +332,7 @@ WarpWizOneSpanTable *Wiz::warpBuildSpanTable(WizSimpleBitmap *dstBitmap, const W
continue;
}
- // Calc the step values
+ // Calc the step values...
nonClippedWidth = (span->dstRight) - (span->dstLeft) + 1;
drawSpan->xSrcStep = WARP_TO_FRAC((span->srcRight.x - span->srcLeft.x)) / nonClippedWidth;
drawSpan->ySrcStep = WARP_TO_FRAC((span->srcRight.y - span->srcLeft.y)) / nonClippedWidth;
@@ -500,9 +498,9 @@ void Wiz::warpProcessDrawSpansTransparentFiltered(WizSimpleBitmap *dstBitmap, co
WizRawPixel8 *dst8 = (WizRawPixel8 *)dstBitmap->bufferPtr;
WizRawPixel16 *dst16 = (WizRawPixel16 *)dstBitmap->bufferPtr;
- // set up a rect for clipping if needed
- Common::Rect aSrcRect; // the source rectangle for clipping
- Common::Rect aScanRect; // the dest rectangle for clipping
+ // Set up a rect for clipping if needed
+ Common::Rect aSrcRect; // Source rectangle for clipping...
+ Common::Rect aScanRect; // Dest rectangle for clipping...
aSrcRect.left = 0;
aSrcRect.top = 0;
aSrcRect.right = srcWidth;
@@ -522,13 +520,13 @@ void Wiz::warpProcessDrawSpansTransparentFiltered(WizSimpleBitmap *dstBitmap, co
yOffset = drawSpans->ySrcOffset;
xStep = drawSpans->xSrcStep;
yStep = drawSpans->ySrcStep;
- iXScan = WARP_FROM_FRAC(xStep); // the width of the search should be the x step size
+ iXScan = WARP_FROM_FRAC(xStep); // The width of the search should be the x step size...
for (int xCounter = drawSpans->dstWidth; --xCounter >= 0;) {
iCurrentX = WARP_FROM_FRAC(xOffset);
iCurrentY = WARP_FROM_FRAC(yOffset);
- // get the current color and the surrounding colors
+ // Get the current color and the surrounding colors...
if (!_uses16BitColor) {
srcColor = *(src8 + (srcWidth * iCurrentY) + iCurrentX);
} else {
@@ -537,14 +535,14 @@ void Wiz::warpProcessDrawSpansTransparentFiltered(WizSimpleBitmap *dstBitmap, co
bSkipFilter = false;
if (bIsHintColor) {
- // check if we need to clip our scan rectangle
+ // Check if we need to clip our scan rectangle...
aScanRect.left = iCurrentX - iXScan;
aScanRect.top = iCurrentY - iYScan;
aScanRect.right = iCurrentX + iXScan;
aScanRect.bottom = iCurrentY + iYScan;
findRectOverlap(&aScanRect, &aSrcRect);
- // scan through rect looking for hint color
+ // Scan through rect looking for hint color...
for (int yScan = aScanRect.top; yScan < aScanRect.bottom; ++yScan) {
for (int xScan = aScanRect.left; xScan < aScanRect.right; ++xScan) {
if (!_uses16BitColor) {
@@ -569,7 +567,7 @@ void Wiz::warpProcessDrawSpansTransparentFiltered(WizSimpleBitmap *dstBitmap, co
}
if ((srcColor != transparentColor) && !bSkipFilter) {
- // check if top
+ // Check if top...
if (iCurrentY != 0) {
if (!_uses16BitColor) {
srcColorN = *(src8 + (srcWidth * (iCurrentY - 1)) + iCurrentX);
@@ -580,7 +578,7 @@ void Wiz::warpProcessDrawSpansTransparentFiltered(WizSimpleBitmap *dstBitmap, co
srcColorN = transparentColor;
}
- // check if bottom
+ // Check if bottom...
if (iCurrentY != aSrcRect.bottom) {
if (!_uses16BitColor) {
srcColorS = *(src8 + (srcWidth * (iCurrentY + 1)) + iCurrentX);
@@ -591,7 +589,7 @@ void Wiz::warpProcessDrawSpansTransparentFiltered(WizSimpleBitmap *dstBitmap, co
srcColorS = transparentColor;
}
- // check for left edge
+ // Check for left edge...
if (iCurrentX != 0) {
if (!_uses16BitColor) {
srcColorW = *(src8 + (srcWidth * iCurrentY) + (iCurrentX - 1));
@@ -602,7 +600,7 @@ void Wiz::warpProcessDrawSpansTransparentFiltered(WizSimpleBitmap *dstBitmap, co
srcColorW = transparentColor;
}
- // check for right edge
+ // Check for right edge...
if (iCurrentX != aSrcRect.right) {
if (!_uses16BitColor) {
srcColorE = *(src8 + (srcWidth * iCurrentY) + (iCurrentX + 1));
@@ -613,7 +611,7 @@ void Wiz::warpProcessDrawSpansTransparentFiltered(WizSimpleBitmap *dstBitmap, co
srcColorE = transparentColor;
}
- // make transparent color black
+ // Make transparent color black...
if (srcColorN == transparentColor) {
srcColorN = srcColor;
}
@@ -631,9 +629,8 @@ void Wiz::warpProcessDrawSpansTransparentFiltered(WizSimpleBitmap *dstBitmap, co
}
if (!_uses16BitColor) {
- // in 8 bit mode go around the pixel adding in colors from the xmap color table
- // ignores transparent pixels
- // trying 1/8 of the surrounding colors
+ // In 8 bit mode go around the pixel adding in colors (1/8 of the surrounding colors)
+ // from the xmap color table; this ignores transparent pixels...
srcColor = *(pXmapColorTable + (srcColorN * 256) + srcColor);
srcColor = *(pXmapColorTable + (srcColorS * 256) + srcColor);
srcColor = *(pXmapColorTable + (srcColorE * 256) + srcColor);
@@ -643,7 +640,7 @@ void Wiz::warpProcessDrawSpansTransparentFiltered(WizSimpleBitmap *dstBitmap, co
int rs = 0, gs = 0, bs = 0;
float rd = 0, gd = 0, bd = 0;
- // get 1/4 of each surrounding pixel and add into source pixel
+ // Get 1/4 of each surrounding pixel and add into source pixel...
rawPixelExtractComponents(srcColorN, rs, gs, bs);
rd += rs;
gd += gs;
@@ -664,23 +661,23 @@ void Wiz::warpProcessDrawSpansTransparentFiltered(WizSimpleBitmap *dstBitmap, co
gd += gs;
bd += bs;
- // average pixels
+ // Average pixels...
rd /= 4.0f;
gd /= 4.0f;
bd /= 4.0f;
- // get source pixel colors
+ // Get source pixel colors...
rawPixelExtractComponents(srcColor, rs, gs, bs);
rd += rs;
gd += gs;
bd += bs;
- // now average the two
+ // Now average the two...
rd /= 2.0f;
gd /= 2.0f;
bd /= 2.0f;
-
- // pack the pixel back up
+
+ // Pack the pixel back up...
rawPixelPackComponents(srcColor, (int)rd, (int)gd, (int)bd);
}
}
@@ -815,7 +812,7 @@ void Wiz::warpFillSpanWithLine(WarpWizOneSpanTable *st, const WarpWizPoint *dstA
}
void Wiz::warpProcessDrawSpansSampled(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizOneDrawSpan *drawSpans, int count) {
- // Setup read pointer and clipping limits for the sampling rect
+ // Setup read pointer and clipping limits for the sampling rect...
const WizRawPixel8 *src8 = (WizRawPixel8 *)srcBitmap->bufferPtr;
const WizRawPixel16 *src16 = (WizRawPixel16 *)srcBitmap->bufferPtr;
WizRawPixel8 *dst8 = (WizRawPixel8 *)dstBitmap->bufferPtr;
@@ -825,7 +822,7 @@ void Wiz::warpProcessDrawSpansSampled(WizSimpleBitmap *dstBitmap, const WizSimpl
int src_x_limit = (srcBitmap->bitmapWidth - 1);
int src_y_limit = (srcBitmap->bitmapHeight - 1);
- // Process all of the spans in this span collection.
+ // Process all of the spans in this span collection...
for (int yCounter = count; --yCounter >= 0;) {
if (!_uses16BitColor) {
dst8 = (WizRawPixel8 *)dstBitmap->bufferPtr;
@@ -840,7 +837,7 @@ void Wiz::warpProcessDrawSpansSampled(WizSimpleBitmap *dstBitmap, const WizSimpl
int xStep = drawSpans->xSrcStep;
int yStep = drawSpans->ySrcStep;
- // Figure out the sample rect for this "slope"
+ // Figure out the sample rect for this "slope"...
int sample_cx = (WARP_FROM_FRAC(xStep));
int sample_cy = (WARP_FROM_FRAC(yStep));
@@ -852,7 +849,7 @@ void Wiz::warpProcessDrawSpansSampled(WizSimpleBitmap *dstBitmap, const WizSimpl
sample_cy = -sample_cy;
}
- // Make the sampling area square using the largest delta
+ // Make the sampling area square using the largest delta...
if (sample_cx > sample_cy) {
sample_cy = sample_cx;
} else {
@@ -862,12 +859,12 @@ void Wiz::warpProcessDrawSpansSampled(WizSimpleBitmap *dstBitmap, const WizSimpl
int sample_x_offset = sample_cx;
int sample_y_offset = sample_cy;
- // Process all pixels covered by this "span"
+ // Process all pixels covered by this "span"...
for (int xCounter = drawSpans->dstWidth; --xCounter >= 0;) {
if (!_uses16BitColor) {
*dst8++ = (*(src8 + (sw * WARP_FROM_FRAC(yOffset)) + WARP_FROM_FRAC(xOffset)));
} else {
- // Do a really lame sampling of the potential source pixels
+ // Do a really lame sampling of the potential source pixels...
int sx = WARP_FROM_FRAC(xOffset);
int sy = WARP_FROM_FRAC(yOffset);
@@ -877,18 +874,18 @@ void Wiz::warpProcessDrawSpansSampled(WizSimpleBitmap *dstBitmap, const WizSimpl
int sx2 = sx + sample_x_offset;
int sy2 = sy + sample_y_offset;
- // Clip the source sample coords to the bitmap limits
+ // Clip the source sample coords to the bitmap limits...
sx1 = MAX<int>(0, MIN<int>(src_x_limit, sx1));
sy1 = MAX<int>(0, MIN<int>(src_y_limit, sy1));
sx2 = MAX<int>(0, MIN<int>(src_x_limit, sx2));
sy2 = MAX<int>(0, MIN<int>(src_y_limit, sy2));
- // Now that the clipping is done figure out the sampling area
+ // Now that the clipping is done figure out the sampling area...
int sxc = ((sx2 - sx1) + 1);
int syc = ((sy2 - sy1) + 1);
int total = (sxc * syc);
- // Sample pixels from the source potential sampling area
+ // Sample pixels from the source potential sampling area...
if (total > 1) {
int total_R, total_G, total_B;
const WizRawPixel *samplePtr = (const WizRawPixel *)(src16 + ((sw * sy1) + sx1));
@@ -928,7 +925,7 @@ void Wiz::warpProcessDrawSpansSampled(WizSimpleBitmap *dstBitmap, const WizSimpl
}
void Wiz::warpProcessDrawSpansTransparentSampled(WizSimpleBitmap *dstBitmap, const WizSimpleBitmap *srcBitmap, const WarpWizOneDrawSpan *drawSpans, int count, WizRawPixel transparentColor) {
- // Setup read pointer and clipping limits for the sampling rect
+ // Setup read pointer and clipping limits for the sampling rect...
const WizRawPixel8 *src8 = (WizRawPixel8 *)srcBitmap->bufferPtr;
const WizRawPixel16 *src16 = (WizRawPixel16 *)srcBitmap->bufferPtr;
WizRawPixel8 *dst8 = (WizRawPixel8 *)dstBitmap->bufferPtr;
@@ -937,8 +934,8 @@ void Wiz::warpProcessDrawSpansTransparentSampled(WizSimpleBitmap *dstBitmap, con
int sw = srcBitmap->bitmapWidth;
int src_x_limit = (srcBitmap->bitmapWidth - 1);
int src_y_limit = (srcBitmap->bitmapHeight - 1);
-
- // Process all of the spans in this span collection.
+
+ // Process all of the spans in this span collection...
for (int yCounter = count; --yCounter >= 0;) {
if (!_uses16BitColor) {
dst8 = (WizRawPixel8 *)dstBitmap->bufferPtr;
@@ -953,7 +950,7 @@ void Wiz::warpProcessDrawSpansTransparentSampled(WizSimpleBitmap *dstBitmap, con
int xStep = drawSpans->xSrcStep;
int yStep = drawSpans->ySrcStep;
- // Figure out the sample rect for this "slope"
+ // Figure out the sample rect for this "slope"...
int sample_cx = (WARP_FROM_FRAC(xStep));
int sample_cy = (WARP_FROM_FRAC(yStep));
@@ -965,7 +962,7 @@ void Wiz::warpProcessDrawSpansTransparentSampled(WizSimpleBitmap *dstBitmap, con
sample_cy = -sample_cy;
}
- // Make the sampling area square using the largest delta
+ // Make the sampling area square using the largest delta...
if (sample_cx > sample_cy) {
sample_cy = sample_cx;
} else {
@@ -975,7 +972,7 @@ void Wiz::warpProcessDrawSpansTransparentSampled(WizSimpleBitmap *dstBitmap, con
int sample_x_offset = sample_cx;
int sample_y_offset = sample_cy;
- // Process all pixels covered by this "span"
+ // Process all pixels covered by this "span"...
for (int xCounter = drawSpans->dstWidth; --xCounter >= 0;) {
if (!_uses16BitColor) {
WizRawPixel src_color = (*(src8 + (sw * WARP_FROM_FRAC(yOffset)) + WARP_FROM_FRAC(xOffset)));
@@ -987,7 +984,7 @@ void Wiz::warpProcessDrawSpansTransparentSampled(WizSimpleBitmap *dstBitmap, con
}
} else {
- // Do a really lame sampling of the potential source pixels
+ // Do a really lame sampling of the potential source pixels...
int sx = WARP_FROM_FRAC(xOffset);
int sy = WARP_FROM_FRAC(yOffset);
@@ -997,20 +994,18 @@ void Wiz::warpProcessDrawSpansTransparentSampled(WizSimpleBitmap *dstBitmap, con
int sx2 = sx + sample_x_offset;
int sy2 = sy + sample_y_offset;
- // Clip the source sample coords to the bitmap limits, this could
- // be moved outside the loop if efficiency was important!
+ // Clip the source sample coords to the bitmap limits...
sx1 = MAX<int>(0, MIN<int>(src_x_limit, sx1));
sy1 = MAX<int>(0, MIN<int>(src_y_limit, sy1));
sx2 = MAX<int>(0, MIN<int>(src_x_limit, sx2));
sy2 = MAX<int>(0, MIN<int>(src_y_limit, sy2));
- // Now that the clipping is done figure out the sampling area
+ // Now that the clipping is done figure out the sampling area...
int sxc = ((sx2 - sx1) + 1);
int syc = ((sy2 - sy1) + 1);
int total = (sxc * syc);
- // Sample pixels from the source potential sampling area
- // For non-linear transformations this could be fairly incorrect!
+ // Sample pixels from the source potential sampling area...
if (total > 1) {
int total_R, total_G, total_B;
Commit: 1ddcbf1d6f26d48a19ca5017de2feb033055f911
https://github.com/scummvm/scummvm/commit/1ddcbf1d6f26d48a19ca5017de2feb033055f911
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Begin implementing Moonbase Commander graphics hooks
Changed paths:
A engines/scumm/he/moonbase/moonbase_gfx.cpp
engines/scumm/he/gfx_comp/mrle_comp.cpp
engines/scumm/he/gfx_comp/trle_comp.cpp
engines/scumm/he/gfx_primitives_he.cpp
engines/scumm/he/intern_he.h
engines/scumm/he/logic/moonbase_logic.cpp
engines/scumm/he/logic_he.h
engines/scumm/he/moonbase/moonbase.h
engines/scumm/he/moonbase/moonbase_fow.cpp
engines/scumm/he/wiz_he.cpp
engines/scumm/he/wiz_he.h
engines/scumm/module.mk
diff --git a/engines/scumm/he/gfx_comp/mrle_comp.cpp b/engines/scumm/he/gfx_comp/mrle_comp.cpp
index 9991d4d7801..402a125dcab 100644
--- a/engines/scumm/he/gfx_comp/mrle_comp.cpp
+++ b/engines/scumm/he/gfx_comp/mrle_comp.cpp
@@ -40,7 +40,7 @@ static void mrleFLIPVertFlipAlignWithRect(Common::Rect *rectToAlign, const Commo
rectToAlign->bottom += dy;
}
-#define HANDLE_SKIP_PIXELS_MACRO() { \
+#define MRLE_HANDLE_SKIP_PIXELS_STEP() { \
/* Decompress bytes to do simple clipping... */ \
while (skipAmount > 0) { \
if ((runCount = *dataStream++) & 1) { \
@@ -67,27 +67,27 @@ static void mrleFLIPVertFlipAlignWithRect(Common::Rect *rectToAlign, const Commo
} \
}
-#define HANDLE_RUN_DECOMPRESS_MACRO(_TransparentCode_, _RunCode_) { \
- while (decompAmount > 0) { \
- runCount = *dataStream++; \
- \
- if (runCount & 1) { /* xxxxxxx1 */ \
- runCount >>= 1; \
- DoTransparentRun: \
- decompAmount -= runCount; \
- _TransparentCode_ \
- \
- } else { /* xxxxxxx0 */ \
- \
- runCount >>= 1; \
- WriteRunData: \
- decompAmount -= runCount; \
- if (decompAmount < 0) { \
- runCount += decompAmount; \
- } \
- _RunCode_ \
- } \
- } \
+#define MRLE_HANDLE_RUN_DECOMPRESS_STEP(_TransparentCode_, _RunCode_) { \
+ while (decompAmount > 0) { \
+ runCount = *dataStream++; \
+ \
+ if (runCount & 1) { /* xxxxxxx1 */ \
+ runCount >>= 1; \
+ DoTransparentRun: \
+ decompAmount -= runCount; \
+ _TransparentCode_ \
+ \
+ } else { /* xxxxxxx0 */ \
+ \
+ runCount >>= 1; \
+ WriteRunData: \
+ decompAmount -= runCount; \
+ if (decompAmount < 0) { \
+ runCount += decompAmount; \
+ } \
+ _RunCode_ \
+ } \
+ } \
}
static void mrleFLIPAltSourceForwardXBppToXBpp(Wiz *wiz,
@@ -104,10 +104,10 @@ static void mrleFLIPAltSourceForwardXBppToXBpp(Wiz *wiz,
int runCount;
// Decompress bytes to do simple clipping...
- HANDLE_SKIP_PIXELS_MACRO();
+ MRLE_HANDLE_SKIP_PIXELS_STEP();
// Really decompress to the dest buffer...
- HANDLE_RUN_DECOMPRESS_MACRO(
+ MRLE_HANDLE_RUN_DECOMPRESS_STEP(
{
if (!wiz->_uses16BitColor) {
dest8 += runCount;
@@ -145,10 +145,10 @@ static void mrleFLIPAltSourceBackwardXBppToXBpp(Wiz *wiz,
int runCount;
// Decompress bytes to do simple clipping...
- HANDLE_SKIP_PIXELS_MACRO();
+ MRLE_HANDLE_SKIP_PIXELS_STEP();
// Really decompress to the dest buffer...
- HANDLE_RUN_DECOMPRESS_MACRO(
+ MRLE_HANDLE_RUN_DECOMPRESS_STEP(
{
if (!wiz->_uses16BitColor) {
dest8 -= runCount;
@@ -183,10 +183,10 @@ static void mrleFLIPAltSourceForward8BppToXBpp(Wiz *wiz,
int runCount;
// Decompress bytes to do simple clipping...
- HANDLE_SKIP_PIXELS_MACRO();
+ MRLE_HANDLE_SKIP_PIXELS_STEP();
// Really decompress to the dest buffer...
- HANDLE_RUN_DECOMPRESS_MACRO(
+ MRLE_HANDLE_RUN_DECOMPRESS_STEP(
{
if (!wiz->_uses16BitColor) {
dest8 += runCount;
@@ -231,10 +231,10 @@ static void mrleFLIPAltSourceBackward8BppToXBpp(Wiz *wiz,
int runCount;
// Decompress bytes to do simple clipping...
- HANDLE_SKIP_PIXELS_MACRO();
+ MRLE_HANDLE_SKIP_PIXELS_STEP();
// Really decompress to the dest buffer...
- HANDLE_RUN_DECOMPRESS_MACRO(
+ MRLE_HANDLE_RUN_DECOMPRESS_STEP(
{
if (!wiz->_uses16BitColor) {
dest8 -= runCount;
@@ -341,7 +341,7 @@ void Wiz::mrleFLIPAltSourceDecompressPrim(
const WizCompressedImage *imagePtr, int destX, int destY,
const Common::Rect *sourceCoords, const Common::Rect *clipRectPtr,
int32 flags, const WizRawPixel *conversionTable,
- void (*forewordFunctionPtr)(Wiz *wiz,
+ void (*forwardFunctionPtr)(Wiz *wiz,
WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream,
int skipAmount, int decompAmount, const WizRawPixel *conversionTable),
void (*backwardFunctionPtr)(Wiz *wiz,
@@ -420,7 +420,7 @@ void Wiz::mrleFLIPAltSourceDecompressPrim(
mrleFLIPHorzFlipAlignWithRect(&sourceRect, &inSourceRect);
SWAP<int16>(destRect.left, destRect.right);
} else {
- functionPtr = forewordFunctionPtr;
+ functionPtr = forwardFunctionPtr;
}
if (flags & kWRFVFlip) {
diff --git a/engines/scumm/he/gfx_comp/trle_comp.cpp b/engines/scumm/he/gfx_comp/trle_comp.cpp
index 81b05496d3d..77a519ede58 100644
--- a/engines/scumm/he/gfx_comp/trle_comp.cpp
+++ b/engines/scumm/he/gfx_comp/trle_comp.cpp
@@ -31,7 +31,7 @@ namespace Scumm {
#define TRLEFLIP_MEMSET(_dPt, _Pv, _rC) \
wiz->rawPixelMemset((_dPt), wiz->convert8BppToRawPixel(_Pv, conversionTable), (_rC))
-#define HANDLE_SKIP_PIXELS_MACRO() { \
+#define TRLE_HANDLE_SKIP_PIXELS_STEP() { \
/* Decompress bytes to do simple clipping... */ \
while (skipAmount > 0) { \
if ((runCount = *dataStream++) & 1) { \
@@ -68,41 +68,41 @@ namespace Scumm {
} \
}
-#define HANDLE_RUN_DECOMPRESS_MACRO(_TransparentCode_, _RunCode_, _LiteralCode_) { \
- while (decompAmount > 0) { \
- runCount = *dataStream++; \
- \
- if (runCount & 1) { /* xxxxxxx1 */ \
- runCount >>= 1; \
- DoTransparentRun: \
- decompAmount -= runCount; \
- _TransparentCode_ \
- } else if (runCount & 2) { /* xxxxxx10 */ \
- runCount = (runCount >> 2) + 1; \
- WriteRunData: \
- decompAmount -= runCount; \
- if (decompAmount < 0) { \
- runCount += decompAmount; \
- } \
- _RunCode_ \
- dataStream++; \
- } else { /* xxxxxx00 */ \
- runCount = (runCount >> 2) + 1; \
- WriteLiteralData: \
- decompAmount -= runCount; \
- if (decompAmount < 0) { \
- runCount += decompAmount; \
- } \
- _LiteralCode_ \
- dataStream += runCount; \
- } \
- } \
- }
-
-#define TRLEFLIP_X_Foreward_MACRO(MEMSET_PARAM, MEMCPY_PARAM) { \
+#define TRLE_HANDLE_RUN_DECOMPRESS_STEP(_TransparentCode_, _RunCode_, _LiteralCode_) { \
+ while (decompAmount > 0) { \
+ runCount = *dataStream++; \
+ \
+ if (runCount & 1) { /* xxxxxxx1 */ \
+ runCount >>= 1; \
+ DoTransparentRun: \
+ decompAmount -= runCount; \
+ _TransparentCode_ \
+ } else if (runCount & 2) { /* xxxxxx10 */ \
+ runCount = (runCount >> 2) + 1; \
+ WriteRunData: \
+ decompAmount -= runCount; \
+ if (decompAmount < 0) { \
+ runCount += decompAmount; \
+ } \
+ _RunCode_ \
+ dataStream++; \
+ } else { /* xxxxxx00 */ \
+ runCount = (runCount >> 2) + 1; \
+ WriteLiteralData: \
+ decompAmount -= runCount; \
+ if (decompAmount < 0) { \
+ runCount += decompAmount; \
+ } \
+ _LiteralCode_ \
+ dataStream += runCount; \
+ } \
+ } \
+ }
+
+#define TRLEFLIP_X_FORWARD_PASS(MEMSET_PARAM, MEMCPY_PARAM) { \
int runCount; \
- HANDLE_SKIP_PIXELS_MACRO(); \
- HANDLE_RUN_DECOMPRESS_MACRO( \
+ TRLE_HANDLE_SKIP_PIXELS_STEP(); \
+ TRLE_HANDLE_RUN_DECOMPRESS_STEP( \
{ destPtr += runCount; }, \
{ \
(MEMSET_PARAM)( \
@@ -115,10 +115,10 @@ namespace Scumm {
}); \
}
-#define TRLEFLIP_X_Backward_MACRO(MEMSET_PARAM, MEMCPY_PARAM) { \
+#define TRLEFLIP_X_BACKWARD_PASS(MEMSET_PARAM, MEMCPY_PARAM) { \
int runCount; \
- HANDLE_SKIP_PIXELS_MACRO(); \
- HANDLE_RUN_DECOMPRESS_MACRO( \
+ TRLE_HANDLE_SKIP_PIXELS_STEP(); \
+ TRLE_HANDLE_RUN_DECOMPRESS_STEP( \
{ destPtr -= runCount; }, \
{ \
destPtr -= runCount; \
@@ -131,10 +131,10 @@ namespace Scumm {
}); \
}
-#define TRLEFLIP_X_ArbitraryDstStep_MACRO(COLOROPERATION) { \
+#define TRLEFLIP_X_ARBITRARY_DST_STEP(COLOROPERATION) { \
int runCount; \
- HANDLE_SKIP_PIXELS_MACRO(); \
- HANDLE_RUN_DECOMPRESS_MACRO( \
+ TRLE_HANDLE_SKIP_PIXELS_STEP(); \
+ TRLE_HANDLE_RUN_DECOMPRESS_STEP( \
{ destPtr += (destStepValue * runCount); }, \
{ \
WizRawPixel adjustedRunColor = wiz->convert8BppToRawPixel(*dataStream, conversionTable); \
@@ -155,11 +155,11 @@ namespace Scumm {
}); \
}
-#define TRLEFLIP_ALTX_Foreward_MACRO(X_MEMSET_PARAM, X_MEMCPY_PARAM) { \
+#define TRLEFLIP_ALTX_FORWARD_PASS(X_MEMSET_PARAM, X_MEMCPY_PARAM) { \
const WizRawPixel *srcPtr = (const WizRawPixel *)altSourcePtr; \
int runCount; \
- HANDLE_SKIP_PIXELS_MACRO(); \
- HANDLE_RUN_DECOMPRESS_MACRO( \
+ TRLE_HANDLE_SKIP_PIXELS_STEP(); \
+ TRLE_HANDLE_RUN_DECOMPRESS_STEP( \
{ destPtr += runCount; srcPtr += runCount; }, \
{ \
X_MEMSET_PARAM(wiz, \
@@ -174,11 +174,11 @@ namespace Scumm {
}); \
}
-#define TRLEFLIP_ALTX_Backward_MACRO(X_MEMSET_PARAM, X_MEMCPY_PARAM) { \
+#define TRLEFLIP_ALTX_BACKWARD_PASS(X_MEMSET_PARAM, X_MEMCPY_PARAM) { \
const WizRawPixel *srcPtr = (const WizRawPixel *)altSourcePtr; \
int runCount; \
- HANDLE_SKIP_PIXELS_MACRO(); \
- HANDLE_RUN_DECOMPRESS_MACRO( \
+ TRLE_HANDLE_SKIP_PIXELS_STEP(); \
+ TRLE_HANDLE_RUN_DECOMPRESS_STEP( \
{destPtr -= runCount; srcPtr -= runCount; }, \
{ \
destPtr -= runCount; \
@@ -331,7 +331,7 @@ void Wiz::trleFLIPDecompressPrim(
WizSimpleBitmap *bitmapPtr, const WizCompressedImage *imagePtr, int destX, int destY,
const Common::Rect *sourceCoords, const Common::Rect *clipRectPtr, const byte *extraPtr,
int32 flags, const WizRawPixel *conversionTable,
- void (*forewordFunctionPtr)(Wiz *wiz,
+ void (*forwardFunctionPtr)(Wiz *wiz,
WizRawPixel *destPtr, const byte *dataStream, int skipAmount,
int decompAmount, const byte *extraPtr, const WizRawPixel *conversionTable),
void (*backwardFunctionPtr)(Wiz *wiz,
@@ -352,10 +352,7 @@ void Wiz::trleFLIPDecompressPrim(
width = imagePtr->width;
height = imagePtr->height;
- sourceRect.left = 0;
- sourceRect.top = 0;
- sourceRect.right = width - 1;
- sourceRect.bottom = height - 1;
+ makeSizedRect(&sourceRect, width, height);
} else {
width = sourceCoords->right - sourceCoords->left + 1;
height = sourceCoords->bottom - sourceCoords->top + 1;
@@ -413,7 +410,7 @@ void Wiz::trleFLIPDecompressPrim(
trleFLIPHorzFlipAlignWithRect(&sourceRect, &inSourceRect);
swapRectX(&destRect);
} else {
- functionPtr = forewordFunctionPtr;
+ functionPtr = forwardFunctionPtr;
}
if (flags & kWRFVFlip) {
@@ -641,7 +638,7 @@ void Wiz::trleFLIPBackwardsPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, in
}
}
-void Wiz::trleFLIPForewordLookupPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const byte *lookupTable, const WizRawPixel *conversionTable) {
+void Wiz::trleFLIPForwardLookupPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const byte *lookupTable, const WizRawPixel *conversionTable) {
WizRawPixel8 *buf8 = (WizRawPixel8 *)dstPtr;
WizRawPixel16 *buf16 = (WizRawPixel16 *)dstPtr;
@@ -679,7 +676,7 @@ void Wiz::trleFLIPBackwardsLookupPixelCopy(WizRawPixel *dstPtr, const byte *srcP
}
}
-void Wiz::trleFLIPForewordMixColorsPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const byte *lookupTable) {
+void Wiz::trleFLIPForwardMixColorsPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const byte *lookupTable) {
WizRawPixel8 *buf8 = (WizRawPixel8 *)dstPtr;
WizRawPixel16 *buf16 = (WizRawPixel16 *)dstPtr;
@@ -719,40 +716,40 @@ void Wiz::trleFLIPBackwardsMixColorsPixelCopy(WizRawPixel *dstPtr, const byte *s
}
}
-static void trleFLIPAdditiveDecompressLineForeword(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const byte *extraPtr, const WizRawPixel *conversionTable) {
- TRLEFLIP_X_Foreward_MACRO(
+static void trleFLIPAdditiveDecompressLineForward(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const byte *extraPtr, const WizRawPixel *conversionTable) {
+ TRLEFLIP_X_FORWARD_PASS(
wiz->trleFLIPAdditivePixelMemset,
wiz->trleFLIPAdditiveForwardPixelCopy);
}
static void trleFLIPAdditiveDecompressLineBackward(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const byte *extraPtr, const WizRawPixel *conversionTable) {
- TRLEFLIP_X_Backward_MACRO(
+ TRLEFLIP_X_BACKWARD_PASS(
wiz->trleFLIPAdditivePixelMemset,
wiz->trleFLIPAdditiveBackwardsPixelCopy);
}
-static void trleFLIPSubtractiveDecompressLineForeword(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const byte *extraPtr, const WizRawPixel *conversionTable) {
- TRLEFLIP_X_Foreward_MACRO(
+static void trleFLIPSubtractiveDecompressLineForward(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const byte *extraPtr, const WizRawPixel *conversionTable) {
+ TRLEFLIP_X_FORWARD_PASS(
wiz->trleFLIPSubtractivePixelMemset,
wiz->trleFLIPSubtractiveForwardPixelCopy);
}
static void trleFLIPSubtractiveDecompressLineBackward(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const byte *extraPtr, const WizRawPixel *conversionTable) {
- TRLEFLIP_X_Backward_MACRO(
+ TRLEFLIP_X_BACKWARD_PASS(
wiz->trleFLIPSubtractivePixelMemset,
wiz->trleFLIPSubtractiveBackwardsPixelCopy);
}
-static void trleFLIPDecompressLineForeword(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const byte *extraPtr, const WizRawPixel *conversionTable) {
+static void trleFLIPDecompressLineForward(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const byte *extraPtr, const WizRawPixel *conversionTable) {
int runCount;
WizRawPixel8 *dest8 = (WizRawPixel8 *)destPtr;
WizRawPixel16 *dest16 = (WizRawPixel16 *)destPtr;
// Decompress bytes to do simple clipping...
- HANDLE_SKIP_PIXELS_MACRO();
+ TRLE_HANDLE_SKIP_PIXELS_STEP();
// Really decompress to the dest buffer...
- HANDLE_RUN_DECOMPRESS_MACRO(
+ TRLE_HANDLE_RUN_DECOMPRESS_STEP(
{
if (wiz->_uses16BitColor) {
dest16 += runCount;
@@ -790,10 +787,10 @@ static void trleFLIPDecompressLineBackward(Wiz *wiz, WizRawPixel *destPtr, const
WizRawPixel16 *dest16 = (WizRawPixel16 *)destPtr;
// Decompress bytes to do simple clipping...
- HANDLE_SKIP_PIXELS_MACRO();
+ TRLE_HANDLE_SKIP_PIXELS_STEP();
// Really decompress to the dest buffer...
- HANDLE_RUN_DECOMPRESS_MACRO(
+ TRLE_HANDLE_RUN_DECOMPRESS_STEP(
{
if (wiz->_uses16BitColor) {
dest16 -= runCount;
@@ -825,7 +822,7 @@ static void trleFLIPDecompressLineBackward(Wiz *wiz, WizRawPixel *destPtr, const
});
}
-static void trleFLIPLookupDecompressLineForeword(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const byte *extraPtr, const WizRawPixel *conversionTable) {
+static void trleFLIPLookupDecompressLineForward(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const byte *extraPtr, const WizRawPixel *conversionTable) {
const byte *lookupTable;
int runCount;
WizRawPixel8 *dest8 = (WizRawPixel8 *)destPtr;
@@ -834,10 +831,10 @@ static void trleFLIPLookupDecompressLineForeword(Wiz *wiz, WizRawPixel *destPtr,
lookupTable = extraPtr;
// Decompress bytes to do simple clipping...
- HANDLE_SKIP_PIXELS_MACRO();
+ TRLE_HANDLE_SKIP_PIXELS_STEP();
// Really decompress to the dest buffer...
- HANDLE_RUN_DECOMPRESS_MACRO(
+ TRLE_HANDLE_RUN_DECOMPRESS_STEP(
{
if (wiz->_uses16BitColor) {
dest16 += runCount;
@@ -858,7 +855,7 @@ static void trleFLIPLookupDecompressLineForeword(Wiz *wiz, WizRawPixel *destPtr,
}
},
{
- wiz->trleFLIPForewordLookupPixelCopy(destPtr, dataStream, runCount, lookupTable, conversionTable);
+ wiz->trleFLIPForwardLookupPixelCopy(destPtr, dataStream, runCount, lookupTable, conversionTable);
if (wiz->_uses16BitColor) {
dest16 += runCount;
destPtr = (WizRawPixel *)dest16;
@@ -878,10 +875,10 @@ static void trleFLIPLookupDecompressLineBackward(Wiz *wiz, WizRawPixel *destPtr,
lookupTable = extraPtr;
// Decompress bytes to do simple clipping...
- HANDLE_SKIP_PIXELS_MACRO();
+ TRLE_HANDLE_SKIP_PIXELS_STEP();
// Really decompress to the dest buffer...
- HANDLE_RUN_DECOMPRESS_MACRO(
+ TRLE_HANDLE_RUN_DECOMPRESS_STEP(
{
if (wiz->_uses16BitColor) {
dest16 -= runCount;
@@ -913,7 +910,7 @@ static void trleFLIPLookupDecompressLineBackward(Wiz *wiz, WizRawPixel *destPtr,
});
}
-static void trleFLIPMixDecompressLineForeword(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const byte *extraPtr, const WizRawPixel *conversionTable) {
+static void trleFLIPMixDecompressLineForward(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const byte *extraPtr, const WizRawPixel *conversionTable) {
const byte *lookupTable;
int runCount;
WizRawPixel8 *dest8 = (WizRawPixel8 *)destPtr;
@@ -922,10 +919,10 @@ static void trleFLIPMixDecompressLineForeword(Wiz *wiz, WizRawPixel *destPtr, co
lookupTable = extraPtr;
// Decompress bytes to do simple clipping...
- HANDLE_SKIP_PIXELS_MACRO();
+ TRLE_HANDLE_SKIP_PIXELS_STEP();
// Really decompress to the dest buffer...
- HANDLE_RUN_DECOMPRESS_MACRO(
+ TRLE_HANDLE_RUN_DECOMPRESS_STEP(
{
if (wiz->_uses16BitColor) {
dest16 += runCount;
@@ -950,7 +947,7 @@ static void trleFLIPMixDecompressLineForeword(Wiz *wiz, WizRawPixel *destPtr, co
},
{
if (!wiz->_uses16BitColor) {
- wiz->trleFLIPForewordMixColorsPixelCopy(destPtr, dataStream, runCount, lookupTable);
+ wiz->trleFLIPForwardMixColorsPixelCopy(destPtr, dataStream, runCount, lookupTable);
dest8 += runCount;
destPtr = (WizRawPixel *)dest8;
} else {
@@ -970,10 +967,10 @@ static void trleFLIPMixDecompressLineBackward(Wiz *wiz, WizRawPixel *destPtr, co
lookupTable = extraPtr;
// Decompress bytes to do simple clipping...
- HANDLE_SKIP_PIXELS_MACRO();
+ TRLE_HANDLE_SKIP_PIXELS_STEP();
// Really decompress to the dest buffer...
- HANDLE_RUN_DECOMPRESS_MACRO(
+ TRLE_HANDLE_RUN_DECOMPRESS_STEP(
{
if (wiz->_uses16BitColor) {
dest16 -= runCount;
@@ -1014,10 +1011,10 @@ static void trleFLIPArbitraryDstStepDecompressLine(Wiz *wiz, WizRawPixel *destPt
WizRawPixel16 *dest16 = (WizRawPixel16 *)destPtr;
// Decompress bytes to do simple clipping...
- HANDLE_SKIP_PIXELS_MACRO();
+ TRLE_HANDLE_SKIP_PIXELS_STEP();
// Really decompress to the dest buffer...
- HANDLE_RUN_DECOMPRESS_MACRO(
+ TRLE_HANDLE_RUN_DECOMPRESS_STEP(
{
if (!wiz->_uses16BitColor) {
while (--runCount >= 0) {
@@ -1085,10 +1082,10 @@ static void trleFLIPLookupArbitraryDstStepDecompressLine(Wiz *wiz, WizRawPixel *
lookupTable = (const byte *)userParam;
// Decompress bytes to do simple clipping...
- HANDLE_SKIP_PIXELS_MACRO();
+ TRLE_HANDLE_SKIP_PIXELS_STEP();
// Really decompress to the dest buffer...
- HANDLE_RUN_DECOMPRESS_MACRO(
+ TRLE_HANDLE_RUN_DECOMPRESS_STEP(
{
if (!wiz->_uses16BitColor) {
while (--runCount >= 0) {
@@ -1157,10 +1154,10 @@ static void trleFLIPMixArbitraryDstStepDecompressLine(Wiz *wiz, WizRawPixel *des
mixColorTable = (const byte *)userParam;
// Decompress bytes to do simple clipping...
- HANDLE_SKIP_PIXELS_MACRO();
+ TRLE_HANDLE_SKIP_PIXELS_STEP();
// Really decompress to the dest buffer...
- HANDLE_RUN_DECOMPRESS_MACRO(
+ TRLE_HANDLE_RUN_DECOMPRESS_STEP(
{
if (!wiz->_uses16BitColor) {
while (--runCount >= 0) {
@@ -1233,12 +1230,12 @@ static void trleFLIPMixArbitraryDstStepDecompressLine(Wiz *wiz, WizRawPixel *des
static void trleFLIPAdditiveArbitraryDstStepDecompressLine(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *userParam, int destStepValue, const WizRawPixel *conversionTable) {
bool _uses16BitColor = wiz->_uses16BitColor;
- TRLEFLIP_X_ArbitraryDstStep_MACRO(WIZRAWPIXEL_ADDITIVE_MIX);
+ TRLEFLIP_X_ARBITRARY_DST_STEP(WIZRAWPIXEL_ADDITIVE_MIX);
}
static void trleFLIPSubtractiveArbitraryDstStepDecompressLine(Wiz *wiz, WizRawPixel *destPtr, const byte *dataStream, int skipAmount, int decompAmount, const void *userParam, int destStepValue, const WizRawPixel *conversionTable) {
bool _uses16BitColor = wiz->_uses16BitColor;
- TRLEFLIP_X_ArbitraryDstStep_MACRO(WIZRAWPIXEL_SUBTRACTIVE_MIX);
+ TRLEFLIP_X_ARBITRARY_DST_STEP(WIZRAWPIXEL_SUBTRACTIVE_MIX);
}
void Wiz::trleFLIP90DegreeRotateCore(WizSimpleBitmap *dstBitmap, int x, int y, const WizCompressedImage *imagePtr, const Common::Rect *optionalSrcRect,
@@ -1382,21 +1379,21 @@ void Wiz::trleFLIPDecompressImage(
if (wizFlags & kWRFAdditiveBlend) {
trleFLIPDecompressPrim(
&fakeBitmap, &fakeImage, x, y, nullptr, clipRectPtr, extraTable, wizFlags, conversionTable,
- trleFLIPAdditiveDecompressLineForeword,
+ trleFLIPAdditiveDecompressLineForward,
trleFLIPAdditiveDecompressLineBackward);
return;
} else if (wizFlags & kWRFSubtractiveBlend) {
trleFLIPDecompressPrim(
&fakeBitmap, &fakeImage, x, y, nullptr, clipRectPtr, extraTable, wizFlags, conversionTable,
- trleFLIPSubtractiveDecompressLineForeword,
+ trleFLIPSubtractiveDecompressLineForward,
trleFLIPSubtractiveDecompressLineBackward);
return;
} else if (wizFlags & kWRF5050Blend) {
trleFLIPDecompressPrim(
&fakeBitmap, &fakeImage, x, y, nullptr, clipRectPtr, extraTable, wizFlags, conversionTable,
- trleFLIPMixDecompressLineForeword,
+ trleFLIPMixDecompressLineForward,
trleFLIPMixDecompressLineBackward);
return;
@@ -1408,15 +1405,15 @@ void Wiz::trleFLIPDecompressImage(
if (!extraTable) {
trleFLIPDecompressPrim(
&fakeBitmap, &fakeImage, x, y, nullptr, clipRectPtr, extraTable, wizFlags, conversionTable,
- trleFLIPDecompressLineForeword, trleFLIPDecompressLineBackward);
+ trleFLIPDecompressLineForward, trleFLIPDecompressLineBackward);
} else if (wizFlags & kWRFRemap) {
trleFLIPDecompressPrim(
&fakeBitmap, &fakeImage, x, y, nullptr, clipRectPtr, extraTable, wizFlags, conversionTable,
- trleFLIPLookupDecompressLineForeword, trleFLIPLookupDecompressLineBackward);
+ trleFLIPLookupDecompressLineForward, trleFLIPLookupDecompressLineBackward);
} else if ((wizFlags & kWRFUseShadow) != 0 || _vm->_game.heversion > 98) {
trleFLIPDecompressPrim(
&fakeBitmap, &fakeImage, x, y, nullptr, clipRectPtr, extraTable, wizFlags, conversionTable,
- trleFLIPMixDecompressLineForeword,
+ trleFLIPMixDecompressLineForward,
trleFLIPMixDecompressLineBackward);
}
}
@@ -1586,28 +1583,28 @@ static void trleFLIPX2XBoolInvAlphaBackwardMemcpy(Wiz *wiz, WizRawPixel *dstPtr,
static void trleFLIPAltSourceForwardBoolAlphaX2X(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
// 16-bit only
- TRLEFLIP_ALTX_Foreward_MACRO(
+ TRLEFLIP_ALTX_FORWARD_PASS(
trleFLIPX2XBoolAlphaMemset,
trleFLIPX2XBoolAlphaForwardMemcpy);
}
static void trleFLIPAltSourceBackwardBoolAlphaX2X(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
// 16-bit only
- TRLEFLIP_ALTX_Backward_MACRO(
+ TRLEFLIP_ALTX_BACKWARD_PASS(
trleFLIPX2XBoolAlphaMemset,
trleFLIPX2XBoolAlphaBackwardMemcpy);
}
static void trleFLIPAltSourceForwardBoolInvAlphaX2X(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
// 16-bit only
- TRLEFLIP_ALTX_Foreward_MACRO(
+ TRLEFLIP_ALTX_FORWARD_PASS(
trleFLIPX2XBoolInvAlphaMemset,
trleFLIPX2XBoolInvAlphaForwardMemcpy);
}
static void trleFLIPAltSourceBackwardBoolInvAlphaX2X(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
// 16-bit only
- TRLEFLIP_ALTX_Backward_MACRO(
+ TRLEFLIP_ALTX_BACKWARD_PASS(
trleFLIPX2XBoolInvAlphaMemset,
trleFLIPX2XBoolInvAlphaBackwardMemcpy);
}
@@ -1697,28 +1694,28 @@ static void trleFLIPX2XInvAlphaBackwardMemcpy(Wiz *wiz, WizRawPixel *dstPtr, con
static void trleFLIPAltSourceForwardAlphaX2X(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
// 16-bit only
- TRLEFLIP_ALTX_Foreward_MACRO(
+ TRLEFLIP_ALTX_FORWARD_PASS(
trleFLIPX2XAlphaMemset,
trleFLIPX2XAlphaForwardMemcpy);
}
static void trleFLIPAltSourceBackwardAlphaX2X(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
// 16-bit only
- TRLEFLIP_ALTX_Backward_MACRO(
+ TRLEFLIP_ALTX_BACKWARD_PASS(
trleFLIPX2XAlphaMemset,
trleFLIPX2XAlphaBackwardMemcpy);
}
static void trleFLIPAltSourceForwardInvAlphaX2X(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
// 16-bit only
- TRLEFLIP_ALTX_Foreward_MACRO(
+ TRLEFLIP_ALTX_FORWARD_PASS(
trleFLIPX2XInvAlphaMemset,
trleFLIPX2XInvAlphaForwardMemcpy);
}
static void trleFLIPAltSourceBackwardInvAlphaX2X(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
// 16-bit only
- TRLEFLIP_ALTX_Backward_MACRO(
+ TRLEFLIP_ALTX_BACKWARD_PASS(
trleFLIPX2XInvAlphaMemset,
trleFLIPX2XInvAlphaBackwardMemcpy);
}
@@ -1813,28 +1810,28 @@ static void trleFLIPATRLEInvAlphaBackwardMemcpy(Wiz *wiz, WizRawPixel *dstPtr, c
static void trleFLIPAltSourceForwardAlphaATRLE(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
// 16-bit only
- TRLEFLIP_ALTX_Foreward_MACRO(
+ TRLEFLIP_ALTX_FORWARD_PASS(
trleFLIPATRLEAlphaMemset,
trleFLIPATRLEAlphaForwardMemcpy);
}
static void trleFLIPAltSourceBackwardAlphaATRLE(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
// 16-bit only
- TRLEFLIP_ALTX_Backward_MACRO(
+ TRLEFLIP_ALTX_BACKWARD_PASS(
trleFLIPATRLEAlphaMemset,
trleFLIPATRLEAlphaBackwardMemcpy);
}
static void trleFLIPAltSourceForwardInvAlphaATRLE(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
// 16-bit only
- TRLEFLIP_ALTX_Foreward_MACRO(
+ TRLEFLIP_ALTX_FORWARD_PASS(
trleFLIPATRLEInvAlphaMemset,
trleFLIPATRLEInvAlphaForwardMemcpy);
}
static void trleFLIPAltSourceBackwardInvAlphaATRLE(Wiz *wiz, WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream, int skipAmount, int decompAmount, const WizRawPixel *conversionTable) {
// 16-bit only
- TRLEFLIP_ALTX_Backward_MACRO(
+ TRLEFLIP_ALTX_BACKWARD_PASS(
trleFLIPATRLEInvAlphaMemset,
trleFLIPATRLEInvAlphaBackwardMemcpy);
}
@@ -1846,10 +1843,10 @@ static void trleFLIPAltSourceForwardXBppToXBpp(Wiz *wiz, WizRawPixel *destPtr, c
srcPtr = (const WizRawPixel *)altSourcePtr;
// Decompress bytes to do simple clipping...
- HANDLE_SKIP_PIXELS_MACRO();
+ TRLE_HANDLE_SKIP_PIXELS_STEP();
// Really decompress to the dest buffer...
- HANDLE_RUN_DECOMPRESS_MACRO(
+ TRLE_HANDLE_RUN_DECOMPRESS_STEP(
{
destPtr += runCount;
srcPtr += runCount;
@@ -1873,10 +1870,10 @@ static void trleFLIPAltSourceBackwardXBppToXBpp(Wiz *wiz, WizRawPixel *destPtr,
srcPtr = (const WizRawPixel *)altSourcePtr;
// Decompress bytes to do simple clipping...
- HANDLE_SKIP_PIXELS_MACRO();
+ TRLE_HANDLE_SKIP_PIXELS_STEP();
// Really decompress to the dest buffer...
- HANDLE_RUN_DECOMPRESS_MACRO(
+ TRLE_HANDLE_RUN_DECOMPRESS_STEP(
{
destPtr -= runCount;
srcPtr -= runCount;
@@ -1900,10 +1897,10 @@ static void trleFLIPAltSourceForward8BppToXBpp(Wiz *wiz, WizRawPixel *destPtr, c
srcPtr = (const byte *)altSourcePtr;
// Decompress bytes to do simple clipping...
- HANDLE_SKIP_PIXELS_MACRO();
+ TRLE_HANDLE_SKIP_PIXELS_STEP();
// Really decompress to the dest buffer...
- HANDLE_RUN_DECOMPRESS_MACRO(
+ TRLE_HANDLE_RUN_DECOMPRESS_STEP(
{
destPtr += runCount;
srcPtr += runCount;
@@ -1927,10 +1924,10 @@ static void trleFLIPAltSourceBackward8BppToXBpp(Wiz *wiz, WizRawPixel *destPtr,
srcPtr = (const WizRawPixel *)altSourcePtr;
// Decompress bytes to do simple clipping...
- HANDLE_SKIP_PIXELS_MACRO();
+ TRLE_HANDLE_SKIP_PIXELS_STEP();
// Really decompress to the dest buffer...
- HANDLE_RUN_DECOMPRESS_MACRO(
+ TRLE_HANDLE_RUN_DECOMPRESS_STEP(
{
destPtr -= runCount;
srcPtr -= runCount;
@@ -1954,10 +1951,10 @@ static void trleFLIPAltSourceInvForwardXBppToXBpp(Wiz *wiz, WizRawPixel *destPtr
srcPtr = (const WizRawPixel *)altSourcePtr;
// Decompress bytes to do simple clipping...
- HANDLE_SKIP_PIXELS_MACRO();
+ TRLE_HANDLE_SKIP_PIXELS_STEP();
// Really decompress to the dest buffer...
- HANDLE_RUN_DECOMPRESS_MACRO(
+ TRLE_HANDLE_RUN_DECOMPRESS_STEP(
{
memcpy(destPtr, srcPtr, (runCount * sizeof(WizRawPixel)));
destPtr += runCount;
@@ -1980,10 +1977,10 @@ static void trleFLIPAltSourceInvBackwardXBppToXBpp(Wiz *wiz, WizRawPixel *destPt
srcPtr = (const WizRawPixel *)altSourcePtr;
// Decompress bytes to do simple clipping...
- HANDLE_SKIP_PIXELS_MACRO();
+ TRLE_HANDLE_SKIP_PIXELS_STEP();
// Really decompress to the dest buffer...
- HANDLE_RUN_DECOMPRESS_MACRO(
+ TRLE_HANDLE_RUN_DECOMPRESS_STEP(
{
destPtr -= runCount;
srcPtr -= runCount;
@@ -2076,7 +2073,7 @@ void Wiz::trleFLIPAltSourceDecompressPrim(
const WizCompressedImage *imagePtr, int destX, int destY,
const Common::Rect *sourceCoords, const Common::Rect *clipRectPtr,
int32 flags, const WizRawPixel *conversionTable,
- void (*forewordFunctionPtr)(Wiz *wiz,
+ void (*forwardFunctionPtr)(Wiz *wiz,
WizRawPixel *destPtr, const void *altSourcePtr, const byte *dataStream,
int skipAmount, int decompAmount, const WizRawPixel *conversionTable),
void (*backwardFunctionPtr)(Wiz *wiz,
@@ -2154,7 +2151,7 @@ void Wiz::trleFLIPAltSourceDecompressPrim(
trleFLIPHorzFlipAlignWithRect(&sourceRect, &inSourceRect);
swapRectX(&destRect);
} else {
- functionPtr = forewordFunctionPtr;
+ functionPtr = forwardFunctionPtr;
}
if (flags & kWRFVFlip) {
diff --git a/engines/scumm/he/gfx_primitives_he.cpp b/engines/scumm/he/gfx_primitives_he.cpp
index 6b7cf9042fc..0f06458728e 100644
--- a/engines/scumm/he/gfx_primitives_he.cpp
+++ b/engines/scumm/he/gfx_primitives_he.cpp
@@ -495,6 +495,25 @@ void Wiz::pgSimpleBitmapFromDrawBuffer(WizSimpleBitmap *bitmapPtr, bool backgrou
}
}
+bool Wiz::pgGetMultiTypeBitmapFromDrawBuffer(WizMultiTypeBitmap *multiBM, bool background) {
+ VirtScreen *vs = &_vm->_virtscr[kMainVirtScreen];
+ int pixelSize = _uses16BitColor ? sizeof(WizRawPixel16) : sizeof(WizRawPixel8);
+
+ multiBM->width = vs->w;
+ multiBM->height = vs->h;
+ multiBM->stride = (multiBM->width * pixelSize);
+ multiBM->format = _uses16BitColor ? 555 : 8;
+ multiBM->bpp = (pixelSize * 8);
+
+ if (background) {
+ multiBM->data = (byte *)vs->getBackPixels(0, vs->topline);
+ } else {
+ multiBM->data = (byte *)vs->getPixels(0, vs->topline);
+ }
+
+ return true;
+}
+
void Wiz::pgDrawRawDataFormatImage(WizRawPixel *bufferPtr, const WizRawPixel *rawData, int bufferWidth, int bufferHeight, int x, int y, int width, int height, Common::Rect *clipRectPtr, int32 wizFlags, const byte *extraTable, int transparentColor) {
Common::Rect srcRect, dstRect, clipRect;
WizSimpleBitmap srcBitmap, dstBitmap;
@@ -682,14 +701,14 @@ void Wiz::pgSimpleBlitRemapColors(WizSimpleBitmap *destBM, Common::Rect *destRec
if (sourceRect->left <= sourceRect->right) {
if (!_uses16BitColor) {
while (--ch >= 0) {
- pgForewordRemapPixelCopy((WizRawPixel *)d8, (WizRawPixel *)s8, cw, remapColorTable);
+ pgForwardRemapPixelCopy((WizRawPixel *)d8, (WizRawPixel *)s8, cw, remapColorTable);
d8 += dw;
s8 += sw;
}
} else {
while (--ch >= 0) {
- pgForewordRemapPixelCopy((WizRawPixel *)d16, (WizRawPixel *)s16, cw, remapColorTable);
+ pgForwardRemapPixelCopy((WizRawPixel *)d16, (WizRawPixel *)s16, cw, remapColorTable);
d16 += dw;
s16 += sw;
@@ -745,14 +764,14 @@ void Wiz::pgSimpleBlitTransparentRemapColors(WizSimpleBitmap *destBM, Common::Re
if (sourceRect->left <= sourceRect->right) {
if (!_uses16BitColor) {
while (--ch >= 0) {
- pgTransparentForewordRemapPixelCopy((WizRawPixel *)d8, (WizRawPixel *)s8, cw, transparentColor, remapColorTable);
+ pgTransparentForwardRemapPixelCopy((WizRawPixel *)d8, (WizRawPixel *)s8, cw, transparentColor, remapColorTable);
d8 += dw;
s8 += sw;
}
} else {
while (--ch >= 0) {
- pgTransparentForewordRemapPixelCopy((WizRawPixel *)d16, (WizRawPixel *)s16, cw, transparentColor, remapColorTable);
+ pgTransparentForwardRemapPixelCopy((WizRawPixel *)d16, (WizRawPixel *)s16, cw, transparentColor, remapColorTable);
d16 += dw;
s16 += sw;
@@ -808,14 +827,14 @@ void Wiz::pgSimpleBlitMixColors(WizSimpleBitmap *destBM, Common::Rect *destRect,
if (sourceRect->left <= sourceRect->right) {
if (!_uses16BitColor) {
while (--ch >= 0) {
- pgForewordMixColorsPixelCopy((WizRawPixel *)d8, (WizRawPixel *)s8, cw, mixColorTable);
+ pgForwardMixColorsPixelCopy((WizRawPixel *)d8, (WizRawPixel *)s8, cw, mixColorTable);
d8 += dw;
s8 += sw;
}
} else {
while (--ch >= 0) {
- pgForewordMixColorsPixelCopy((WizRawPixel *)d16, (WizRawPixel *)s16, cw, mixColorTable);
+ pgForwardMixColorsPixelCopy((WizRawPixel *)d16, (WizRawPixel *)s16, cw, mixColorTable);
d16 += dw;
s16 += sw;
@@ -871,14 +890,14 @@ void Wiz::pgSimpleBlitTransparentMixColors(WizSimpleBitmap *destBM, Common::Rect
if (sourceRect->left <= sourceRect->right) {
if (!_uses16BitColor) {
while (--ch >= 0) {
- pgTransparentForewordMixColorsPixelCopy((WizRawPixel *)d8, (WizRawPixel *)s8, cw, transparentColor, mixColorTable);
+ pgTransparentForwardMixColorsPixelCopy((WizRawPixel *)d8, (WizRawPixel *)s8, cw, transparentColor, mixColorTable);
d8 += dw;
s8 += sw;
}
} else {
while (--ch >= 0) {
- pgTransparentForewordMixColorsPixelCopy((WizRawPixel *)d16, (WizRawPixel *)s16, cw, transparentColor, mixColorTable);
+ pgTransparentForwardMixColorsPixelCopy((WizRawPixel *)d16, (WizRawPixel *)s16, cw, transparentColor, mixColorTable);
d16 += dw;
s16 += sw;
@@ -1258,7 +1277,7 @@ void Wiz::pgDrawImageWith16BitZBuffer(WizSimpleBitmap *psbDst, const WizSimpleBi
}
}
-void Wiz::pgForewordRemapPixelCopy(WizRawPixel *dstPtr, const WizRawPixel *srcPtr, int size, const byte *lookupTable) {
+void Wiz::pgForwardRemapPixelCopy(WizRawPixel *dstPtr, const WizRawPixel *srcPtr, int size, const byte *lookupTable) {
if (!_uses16BitColor) {
WizRawPixel8 *dst8 = (WizRawPixel8 *)dstPtr;
const WizRawPixel8 *src8 = (const WizRawPixel8 *)srcPtr;
@@ -1276,7 +1295,7 @@ void Wiz::pgForewordRemapPixelCopy(WizRawPixel *dstPtr, const WizRawPixel *srcPt
}
}
-void Wiz::pgTransparentForewordRemapPixelCopy(WizRawPixel *dstPtr, const WizRawPixel *srcPtr, int size, WizRawPixel transparentColor, const byte *lookupTable) {
+void Wiz::pgTransparentForwardRemapPixelCopy(WizRawPixel *dstPtr, const WizRawPixel *srcPtr, int size, WizRawPixel transparentColor, const byte *lookupTable) {
if (!_uses16BitColor) {
WizRawPixel8 *dst8 = (WizRawPixel8 *)dstPtr;
const WizRawPixel8 *src8 = (const WizRawPixel8 *)srcPtr;
@@ -1366,7 +1385,7 @@ void Wiz::pgBackwardsRemapPixelCopy(WizRawPixel *dstPtr, const WizRawPixel *srcP
}
}
-void Wiz::pgForewordMixColorsPixelCopy(WizRawPixel *dstPtr, const WizRawPixel *srcPtr, int size, const byte *lookupTable) {
+void Wiz::pgForwardMixColorsPixelCopy(WizRawPixel *dstPtr, const WizRawPixel *srcPtr, int size, const byte *lookupTable) {
if (!_uses16BitColor) {
WizRawPixel8 *dst8 = (WizRawPixel8 *)dstPtr;
const WizRawPixel8 *src8 = (const WizRawPixel8 *)srcPtr;
@@ -1422,7 +1441,7 @@ void Wiz::pgBackwardsMixColorsPixelCopy(WizRawPixel *dstPtr, const WizRawPixel *
}
}
-void Wiz::pgTransparentForewordMixColorsPixelCopy(WizRawPixel *dstPtr, const WizRawPixel *srcPtr, int size, WizRawPixel transparentColor, const byte *lookupTable) {
+void Wiz::pgTransparentForwardMixColorsPixelCopy(WizRawPixel *dstPtr, const WizRawPixel *srcPtr, int size, WizRawPixel transparentColor, const byte *lookupTable) {
if (!_uses16BitColor) {
WizRawPixel8 *dst8 = (WizRawPixel8 *)dstPtr;
const WizRawPixel8 *src8 = (const WizRawPixel8 *)srcPtr;
diff --git a/engines/scumm/he/intern_he.h b/engines/scumm/he/intern_he.h
index 35fc9a0d2b9..82a4da4fd60 100644
--- a/engines/scumm/he/intern_he.h
+++ b/engines/scumm/he/intern_he.h
@@ -567,6 +567,7 @@ class ScummEngine_v90he : public ScummEngine_v80he {
friend class Moonbase;
friend class MoviePlayer;
friend class Sprite;
+ friend class Wiz;
protected:
enum SubOpType {
diff --git a/engines/scumm/he/logic/moonbase_logic.cpp b/engines/scumm/he/logic/moonbase_logic.cpp
index 623dfeed45f..ecd46d87ffc 100644
--- a/engines/scumm/he/logic/moonbase_logic.cpp
+++ b/engines/scumm/he/logic/moonbase_logic.cpp
@@ -43,15 +43,16 @@ public:
int startOfFrame() override;
int32 dispatch(int op, int numArgs, int32 *args) override;
+ bool userCodeProcessWizImageCmd(const WizImageCommand *icmdPtr) override;
private:
- void op_create_multi_state_wiz(int op, int numArgs, int32 *args);
- void op_load_multi_channel_wiz(int op, int numArgs, int32 *args);
- void op_wiz_from_multi_channel_wiz(int op, int numArgs, int32 *args);
+ int op_create_multi_state_wiz(int op, int numArgs, int32 *args);
+ int op_load_multi_channel_wiz(int op, int numArgs, int32 *args);
+ int op_wiz_from_multi_channel_wiz(int op, int numArgs, int32 *args);
void op_dos_command(int op, int numArgs, int32 *args);
void op_set_fow_sentinel(int32 *args);
void op_set_fow_information(int op, int numArgs, int32 *args);
- int op_set_fow_image(int op, int numArgs, int32 *args);
+ int op_set_fow_image(int op, int numArgs, int32 *args);
void op_ai_test_kludge(int op, int numArgs, int32 *args);
int op_ai_master_control_program(int op, int numArgs, int32 *args);
@@ -174,14 +175,11 @@ int LogicHEmoonbase::startOfFrame() {
int32 LogicHEmoonbase::dispatch(int op, int numArgs, int32 *args) {
switch (op) {
case OP_CREATE_MULTI_STATE_WIZ:
- op_create_multi_state_wiz(op, numArgs, args);
- break;
+ return op_create_multi_state_wiz(op, numArgs, args);
case OP_LOAD_MULTI_CHANNEL_WIZ:
- op_load_multi_channel_wiz(op, numArgs, args);
- break;
+ return op_load_multi_channel_wiz(op, numArgs, args);
case OP_WIZ_FROM_MULTI_CHANNEL_WIZ:
- op_wiz_from_multi_channel_wiz(op, numArgs, args);
- break;
+ return op_wiz_from_multi_channel_wiz(op, numArgs, args);
case OP_DOS_COMMAND:
op_dos_command(op, numArgs, args);
break;
@@ -296,24 +294,215 @@ int32 LogicHEmoonbase::dispatch(int op, int numArgs, int32 *args) {
return 0;
}
-void LogicHEmoonbase::op_create_multi_state_wiz(int op, int numArgs, int32 *args) {
- warning("STUB: op_create_multi_state_wiz()");
- LogicHE::dispatch(op, numArgs, args);
+bool LogicHEmoonbase::userCodeProcessWizImageCmd(const WizImageCommand *params) {
+ // Make sure there is a imgcmd struct and it's a render operation
+ if (!params) {
+ return false;
+ }
+
+ if (params->actionType != kWADraw) {
+ return false;
+ }
+
+ // If there are special rendering bits bail
+ if (params->flags & kWRFSpecialRenderBitMask) {
+ return false;
+ }
+
+ // Check to see if the caller wants to use a source buffer
+ int sourceBufferImage = 0;
+
+ if (params->actionFlags & kWAFSourceImage) {
+ sourceBufferImage = params->sourceImage;
+ }
+
+ // Check to see if the caller wants to render into another image.
+ int destImage = 0;
+
+ if (params->actionFlags & kWAFDestImage) {
+ destImage = params->destImageNumber;
+ }
+
+ // Get the glob address and state number
+ byte *globPtr = _vm->getResourceAddress(rtImage, params->image);
+
+ if (!globPtr) {
+ error("LogicHEmoonbase::userCodeProcessWizImageCmd(): Image %d not on heap?", params->image);
+ return false;
+ }
+
+ int state = (params->actionFlags & kWAFState) ? params->state : 0;
+
+ // Make sure the dest buffer is one we can handle (Background or foreground)
+ WizMultiTypeBitmap mappedMultiBM;
+
+ bool drawIntoBackground = ((params->flags & kWRFBackground) == kWRFBackground);
+
+ if (destImage) {
+ if (!_vm->_wiz->dwGetMultiTypeBitmapFromImageState(destImage, 0, &mappedMultiBM)) {
+ return false;
+ }
+ } else {
+ if (!_vm->_wiz->pgGetMultiTypeBitmapFromDrawBuffer(&mappedMultiBM, drawIntoBackground)) {
+ return false;
+ }
+ }
+
+ Common::Rect clipRect, bitmapLimitsRect;
+
+ bitmapLimitsRect.left = 0;
+ bitmapLimitsRect.top = 0;
+ bitmapLimitsRect.right = (mappedMultiBM.width - 1);
+ bitmapLimitsRect.bottom = (mappedMultiBM.height - 1);
+
+ if (params->actionFlags & kWAFRect) {
+ clipRect.left = params->box.left;
+ clipRect.top = params->box.top;
+ clipRect.right = params->box.right;
+ clipRect.bottom = params->box.bottom;
+
+ if (!_vm->_wiz->findRectOverlap(&clipRect, &bitmapLimitsRect)) {
+ return true;
+ }
+ } else {
+ clipRect = bitmapLimitsRect;
+ }
+
+ // Validate source image if requested
+ byte *altSourceData = nullptr;
+
+ if (sourceBufferImage) {
+ WizMultiTypeBitmap sourceMultiBM;
+
+ if (!_vm->_wiz->dwGetMultiTypeBitmapFromImageState(sourceBufferImage, 0, &sourceMultiBM)) {
+ return false;
+ }
+
+ if ((sourceMultiBM.width != mappedMultiBM.width) ||
+ (sourceMultiBM.height != mappedMultiBM.height) ||
+ (sourceMultiBM.stride != mappedMultiBM.stride) ||
+ (sourceMultiBM.format != mappedMultiBM.format) ||
+ (sourceMultiBM.bpp != mappedMultiBM.bpp)) {
+ return false;
+ }
+
+ altSourceData = sourceMultiBM.data;
+ }
+
+ // Convert the icmd struct to useful info for the renderer
+ int32 locationX, locationY;
+
+ if (params->actionFlags & kWAFSpot) {
+ locationX = params->xPos;
+ locationY = params->yPos;
+ } else {
+ locationX = 0;
+ locationY = 0;
+ }
+
+ int32 wizDrawFlags;
+
+ if (params->actionFlags & kWAFFlags) {
+ wizDrawFlags = params->flags;
+ } else {
+ wizDrawFlags = 0;
+ }
+
+ // Get any palette specified
+ byte *paletteData;
+
+ if (params->actionFlags & kWAFPalette) {
+ paletteData = _vm->getHEPaletteSlot(params->palette);
+ } else {
+ paletteData = _vm->getHEPaletteSlot(1);
+ }
+
+ // Finally call the renderer (returns false if not handled or error)
+ if ((_vm1->_moonbase->_fowSentinelImage != params->image) ||
+ (_vm1->_moonbase->_fowSentinelState != state) ||
+ (_vm1->_moonbase->_fowSentinelConditionBits != (uint32)params->extendedRenderInfo.conditionBits)) {
+
+ if (!_vm->_wiz->drawLayeredWiz(
+ mappedMultiBM.data,
+ mappedMultiBM.width, mappedMultiBM.height,
+ mappedMultiBM.stride, mappedMultiBM.format, mappedMultiBM.bpp,
+ globPtr, locationX, locationY, state,
+ clipRect.left, clipRect.top, clipRect.right, clipRect.bottom,
+ wizDrawFlags, params->extendedRenderInfo.conditionBits,
+ paletteData, altSourceData)) {
+
+ return false;
+ }
+ } else {
+ _vm1->_moonbase->renderFOW(&mappedMultiBM);
+ }
+
+ if (destImage) {
+ _vm->_res->setModified(rtImage, destImage);
+ } else {
+ Common::Rect updateRectangle = clipRect;
+
+ if (drawIntoBackground) {
+ _vm->backgroundToForegroundBlit(updateRectangle);
+ } else {
+ _vm->markRectAsDirty(kMainVirtScreen, updateRectangle);
+ }
+ }
+
+ return true;
}
-void LogicHEmoonbase::op_load_multi_channel_wiz(int op, int numArgs, int32 *args) {
- warning("STUB: op_load_multi_channel_wiz()");
- LogicHE::dispatch(op, numArgs, args);
+int LogicHEmoonbase::op_create_multi_state_wiz(int op, int numArgs, int32 *params) {
+ //return MULTIWIZ::CreateUncompressedMultiStateWiz(
+ // params[0], // image
+ // params[1], // width
+ // params[2], // height
+ // params[3], // nStates
+ // params[4], // bpp
+ // params[5], // link-point-x
+ // params[6] // link-point-y
+ // ) ? 1 : 0;
+ return 0;
}
-void LogicHEmoonbase::op_wiz_from_multi_channel_wiz(int op, int numArgs, int32 *args) {
- warning("STUB: op_wiz_from_multi_channel_wiz()");
- LogicHE::dispatch(op, numArgs, args);
+int LogicHEmoonbase::op_load_multi_channel_wiz(int op, int numArgs, int32 *params) {
+ char filename[260];
+
+ _vm1->getStringFromArray(params[1], filename, sizeof(filename));
+
+ bool maskedImage = (params[3] != 0);
+
+ //return MULTIWIZ::LoadMultiChannelWiz(
+ // params[0] , // image
+ // filename , // filename
+ // params[2] , // bpp
+ // maskedImage, // masked image
+ // params[4] , // link-point-x
+ // params[5] , // link-point-y
+ // params[6] // extra channels
+ //) ? 1 : 0;
+ return 0;
}
-void LogicHEmoonbase::op_dos_command(int op, int numArgs, int32 *args) {
- warning("STUB: op_dos_command()");
- LogicHE::dispatch(op, numArgs, args);
+int LogicHEmoonbase::op_wiz_from_multi_channel_wiz(int op, int numArgs, int32 *params) {
+ //return MULTIWIZ::WizFromMultiChannelWiz(
+ // params[0] , // dst image
+ // params[1] , // dst state
+ // params[2] , // src image
+ // (0 != params[3]), // dither?
+ // params[4] // r-channel-chromakey
+ // ) ? 1 : 0;
+ return 0;
+}
+
+void LogicHEmoonbase::op_dos_command(int op, int numArgs, int32 *params) {
+ // Function which passed a command to the OS command line, unused
+ char theCommand[4096];
+
+ _vm1->getStringFromArray(params[0], theCommand, sizeof(theCommand));
+
+ debug("LogicHEmoonbase::op_dos_command(): Unused command: op_dos_command() called with command %s", theCommand);
+ LogicHE::dispatch(op, numArgs, params);
}
void LogicHEmoonbase::op_set_fow_sentinel(int32 *args) {
diff --git a/engines/scumm/he/logic_he.h b/engines/scumm/he/logic_he.h
index 83b1dcf4714..b6ee70aa1d4 100644
--- a/engines/scumm/he/logic_he.h
+++ b/engines/scumm/he/logic_he.h
@@ -22,9 +22,15 @@
#if !defined(SCUMM_HE_LOGIC_HE_H) && defined(ENABLE_HE)
#define SCUMM_HE_LOGIC_HE_H
+#include "scumm/resource.h"
+#include "scumm/scumm.h"
+#include "scumm/he/wiz_he.h"
+
namespace Scumm {
class ScummEngine_v90he;
+class ScummEngine_v100he;
+class ResourceManager;
class LogicHE {
public:
@@ -40,6 +46,7 @@ public:
virtual int versionID();
virtual int32 dispatch(int op, int numArgs, int32 *args);
+ virtual bool userCodeProcessWizImageCmd(const WizImageCommand *icmdPtr) { return false; }
protected:
// Only to be used from makeLogicHE()
diff --git a/engines/scumm/he/moonbase/moonbase.h b/engines/scumm/he/moonbase/moonbase.h
index c5748edc721..6792a3e7069 100644
--- a/engines/scumm/he/moonbase/moonbase.h
+++ b/engines/scumm/he/moonbase/moonbase.h
@@ -61,11 +61,11 @@ public:
int clipY1, int clipX2, int clipY2, int technique, int nFrame);
- void renderFOW(uint8 *destSurface, int dstPitch, int dstType, int dstw, int dsth, int flags);
+ void renderFOW(WizMultiTypeBitmap *destSurface);
private:
int readFOWVisibilityArray(int array, int y, int x);
- void renderFOWState(uint8 *destSurface, int dstPitch, int dstType, int dstw, int dsth, int x, int y, int srcw, int srch, int state, int flags);
+ void renderFOWState(WizMultiTypeBitmap *destSurface, int x, int y, int state);
public:
int _fowSentinelImage;
diff --git a/engines/scumm/he/moonbase/moonbase_fow.cpp b/engines/scumm/he/moonbase/moonbase_fow.cpp
index ff1b5fe740f..ecc3e4f0ae6 100644
--- a/engines/scumm/he/moonbase/moonbase_fow.cpp
+++ b/engines/scumm/he/moonbase/moonbase_fow.cpp
@@ -65,7 +65,7 @@ void Moonbase::initFOW() {
void Moonbase::releaseFOWResources() {
if (_fowImage) {
free(_fowImage);
- _fowImage = 0;
+ _fowImage = nullptr;
}
}
@@ -327,27 +327,32 @@ void Moonbase::setFOWInfo(int fowInfoArray, int downDim, int acrossDim, int view
_fowFrameBaseNumber = (_fowCurrentFOWFrame * FOW_ANIM_FRAME_COUNT);
}
-void Moonbase::renderFOWState(uint8 *destSurface, int dstPitch, int dstType, int dstw, int dsth, int x, int y, int srcw, int srch, int state, int flags) {
+void Moonbase::renderFOWState(WizMultiTypeBitmap *destSurface,int x, int y, int state) {
int32 spotx, spoty;
_vm->_wiz->getWizImageSpot(_fowImage, state, spotx, spoty);
- Common::Rect r(_fowClipX1, _fowClipY1, _fowClipX2, _fowClipY2);
- //_vm->_wiz->drawWizImageEx(destSurface, _fowImage, 0, dstPitch, dstType, dstw, dsth, x - spotx, y - spoty, srcw, srch, state, &r, flags, 0, 0, 16, 0, 0);
+ _vm->_wiz->drawLayeredWiz(
+ destSurface->data,
+ destSurface->width, destSurface->height,
+ destSurface->stride, destSurface->format, destSurface->bpp,
+ _fowImage, x - spotx, y - spoty, state,
+ _fowClipX1, _fowClipY1, _fowClipX2, _fowClipY2,
+ 0, 0, nullptr, nullptr);
}
-static void blackRect_16bpp(uint8 *destSurface, int dstPitch, int dstw, int dsth, int x1, int y1, int x2, int y2) {
- byte *dst = destSurface + dstPitch * y1 + x1 * 2;
- int h = y2 - y1;
- int w = ((x2 - x1) + 1) * 2;
+static void blackRect_16bpp(WizMultiTypeBitmap *destSurface, int x1, int y1, int x2, int y2) {
+ byte *dst = destSurface->data + (destSurface->stride * y1) + (x1 * sizeof(WizRawPixel16));
+ int h = (y2 - y1) + 1;
+ int writeBytes = ((x2 - x1) + 1) * sizeof(WizRawPixel16);
while (--h >= 0) {
- memset(dst, 0, w);
- dst += dstPitch;
+ memset(dst, 0, writeBytes);
+ dst += destSurface->stride;
}
}
-void Moonbase::renderFOW(uint8 *destSurface, int dstPitch, int dstType, int dstw, int dsth, int flags) {
+void Moonbase::renderFOW(WizMultiTypeBitmap *destSurface) {
if (!_fowImage)
return;
@@ -356,66 +361,68 @@ void Moonbase::renderFOW(uint8 *destSurface, int dstPitch, int dstType, int dstw
int yPos = ((_fowVty1 * _fowTileH) - _fowMvy) + _fowDrawY;
int dataOffset = _fowVw * 3;
int halfTileHeight = _fowTileH / 2;
- int cx2 = MIN(_fowClipX2, (dstw - 1));
- int cy2 = MIN(_fowClipY2, (dsth - 1));
-
+ int cx2 = MIN(_fowClipX2, (destSurface->width - 1));
+ int cy2 = MIN(_fowClipY2, (destSurface->height - 1));
+
for (int ry = 0; ry < _fowVh; ry++) {
int real_yPos = yPos;
-
+
for (int i = 0; i < 2; i++) {
const int32 *pRenderTable = pOutterRenderTable;
pOutterRenderTable += dataOffset;
-
+
int xPos = ixPos;
-
+
for (int rx = 0; rx < _fowVw; rx++) {
int nState = *pRenderTable++;
-
+
if (nState != 0) {
if (nState == 2) {
int countLeft = (_fowVw - rx);
int count = 0;
-
+
for (; count < countLeft; count++) {
if (*(pRenderTable + count) != 2)
break;
-
+
pRenderTable++;
rx++;
}
count++;
-
+
int x1 = xPos;
int y1 = real_yPos;
-
+
xPos += _fowTileW * count;
int x2 = (xPos - 1);
int y2 = ((y1 + halfTileHeight) - 1);
-
+
x1 = MAX(0, x1);
y1 = MAX(0, y1);
x2 = MIN(x2, cx2);
y2 = MIN(y2, cy2);
-
+
if ((x2 >= x1) && (y2 >= y1) && (x1 <= _fowClipX2) && (y1 <= _fowClipY2))
- blackRect_16bpp(destSurface, dstPitch, dstw, dsth, x1, y1, x2, y2);
+ blackRect_16bpp(destSurface, x1, y1, x2, y2);
} else {
int subState;
-
+
if ((subState = *pRenderTable++) != 0)
- renderFOWState(destSurface, dstPitch, dstType, dstw, dsth, xPos, yPos, _fowTileW, _fowTileH, (subState + _fowFrameBaseNumber), flags);
-
+ renderFOWState(destSurface, xPos, yPos, (subState + _fowFrameBaseNumber));
+
if ((subState = *pRenderTable++) != 0)
- renderFOWState(destSurface, dstPitch, dstType, dstw, dsth, xPos, yPos, _fowTileW, _fowTileH, (subState + _fowFrameBaseNumber), flags);
-
+ renderFOWState(destSurface, xPos, yPos, (subState + _fowFrameBaseNumber));
+
xPos += _fowTileW;
}
} else {
xPos += _fowTileW;
}
}
+
real_yPos += halfTileHeight;
}
+
yPos += _fowTileH;
}
}
diff --git a/engines/scumm/he/moonbase/moonbase_gfx.cpp b/engines/scumm/he/moonbase/moonbase_gfx.cpp
new file mode 100644
index 00000000000..c03c0266ccf
--- /dev/null
+++ b/engines/scumm/he/moonbase/moonbase_gfx.cpp
@@ -0,0 +1,573 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "scumm/he/intern_he.h"
+#include "scumm/he/wiz_he.h"
+#include "scumm/he/moonbase/moonbase.h"
+
+namespace Scumm {
+
+#define MOONBASE_HANDLE_SKIP_PIXELS_STEP() { \
+ /* Decompress bytes to do simple clipping... */ \
+ while (skipAmount > 0) { \
+ if ((runCount = *dataStream++) & 1) { \
+ /* Handle the transparent color... */ \
+ runCount >>= 1; \
+ if (runCount > skipAmount) { \
+ runCount -= skipAmount; \
+ goto DoTransparentRun; \
+ } else { \
+ skipAmount -= runCount; \
+ } \
+ } else if (runCount & 2) { \
+ /* Handle a run of color... */ \
+ runCount = (runCount >> 2) + 1; \
+ if (runCount > skipAmount) { \
+ runCount -= skipAmount; \
+ goto WriteRunData; \
+ } else { \
+ skipAmount -= runCount; \
+ dataStream += sizeof(WizRawPixel16); \
+ } \
+ } else { \
+ /* Handle a literal run of pixels... */ \
+ runCount = (runCount >> 2) + 1; \
+ if (runCount > skipAmount) { \
+ runCount -= skipAmount; \
+ dataStream += (skipAmount * sizeof(WizRawPixel16)); \
+ goto WriteLiteralData; \
+ } else { \
+ skipAmount -= runCount; \
+ dataStream += (runCount * sizeof(WizRawPixel16)); \
+ } \
+ } \
+ } \
+ }
+
+#define MOONBASE_HANDLE_RUN_DECOMPRESS_STEP(_TransparentCode_, _RunCode_, _LiteralCode_) { \
+ while (decompAmount > 0) { \
+ runCount = *dataStream++; \
+ if (runCount & 1) { /* xxxxxxx1 */ \
+ runCount >>= 1; \
+ DoTransparentRun: \
+ decompAmount -= runCount; \
+ _TransparentCode_ \
+ } else if (runCount & 2) { /* xxxxxx10 */ \
+ runCount = (runCount >> 2) + 1; \
+ WriteRunData: \
+ decompAmount -= runCount; \
+ if (decompAmount < 0) { \
+ runCount += decompAmount; \
+ } \
+ _RunCode_ \
+ dataStream += sizeof(WizRawPixel16); \
+ } else { /* xxxxxx00 */ \
+ runCount = (runCount >> 2) + 1; \
+ WriteLiteralData: \
+ decompAmount -= runCount; \
+ if (decompAmount < 0) { \
+ runCount += decompAmount; \
+ } \
+ _LiteralCode_ \
+ dataStream += (runCount * sizeof(WizRawPixel16)); \
+ } \
+ } \
+ }
+
+static bool canMoonbaseDrawWizType(int compressionType) {
+ return (kWCTTRLE16Bpp == compressionType) ||
+ (kWCTComposite == compressionType) ||
+ (kWCTDataBlockDependent == compressionType);
+}
+
+static bool getMoonbaseWizSizeAndType(ScummEngine_v71he *vm, WizImage *wizPtr, int state, int32 &sizeX, int32 &sizeY, int32 &compType) {
+ byte *workPtr = vm->findWrappedBlock(MKTAG('W', 'I', 'Z', 'H'), wizPtr->data, state, false);
+
+ if (!workPtr) {
+ sizeX = 0;
+ sizeX = 0;
+ compType = 0;
+
+ return false;
+ }
+
+ compType = READ_LE_UINT32(workPtr + 0);
+ sizeX = READ_LE_UINT32(workPtr + 4);
+ sizeY = READ_LE_UINT32(workPtr + 8);
+
+ return true;
+}
+
+bool Wiz::drawLayeredWiz(
+ byte *pDstBitmapData, int nDstWidth, int nDstHeight, int nDstPitch,
+ int nDstFormat, int nDstBpp, byte *pWizImageData,
+ int x, const int y, int state, int clip_x1, int clip_y1, int clip_x2, int clip_y2,
+ uint32 dwFlags, uint32 dwConditionBits, byte *p8BppToXBppClut, byte *pAltSourceBuffer) {
+
+ // Build a header to use with the WTOOLKIT functions
+ WizImage wiz;
+
+ wiz.data = pWizImageData;
+ wiz.dataSize = READ_BE_UINT32(wiz.data + 4);
+
+ // Check to see if this is a compression type we like
+ byte *data = _vm->findWrappedBlock(MKTAG('W', 'I', 'Z', 'H'), wiz.data, state, false);
+ assert(data);
+
+ int stateCompressionType = READ_LE_UINT32(data);
+
+ if (!canMoonbaseDrawWizType(stateCompressionType)) {
+ return false;
+ }
+
+ // Make sure we can map the multitype bitmap to a rawbitmap...
+ WizRawBitmap mappedRawbitmap;
+
+ mappedRawbitmap.data = (WizRawPixel16 *)pDstBitmapData;
+ mappedRawbitmap.width = nDstWidth;
+ mappedRawbitmap.height = nDstHeight;
+ mappedRawbitmap.dataSize = (mappedRawbitmap.width * sizeof(WizRawPixel16)) * mappedRawbitmap.height;
+
+ if (nDstPitch != (mappedRawbitmap.width * sizeof(WizRawPixel16))) {
+ return false;
+ }
+
+ Common::Rect clipRect(clip_x1, clip_y1, clip_x2, clip_y2);
+
+ // Dispatch to the WToolkit image renderer
+ drawImageEx(&mappedRawbitmap, &wiz, x, y, state, &clipRect, dwFlags, nullptr, dwConditionBits, (WizRawPixel16 *)p8BppToXBppClut, pAltSourceBuffer);
+
+ // Assume if we're here that we did something
+ return true;
+}
+
+void Wiz::drawImageEx(
+ WizRawBitmap *bitmapPtr, WizImage *wizPtr, int x, int y, int state,
+ Common::Rect *clipRectPtr, int32 flags, Common::Rect *optionalSrcRect,
+ int32 conditionBits, WizRawPixel16 *p8BppToXBppClut, byte *pAltSourceBuffer) {
+ WizMoonbaseCompressedImage fakedHeader;
+ int nStateCompressionType;
+ WizRawBitmap fakedBitmap;
+ Common::Rect src, dstRect;
+ int32 sizeX, sizeY;
+
+ if (getMoonbaseWizSizeAndType(((ScummEngine_v71he *)_vm), wizPtr, state, sizeX, sizeY, nStateCompressionType)) {
+
+ if (nStateCompressionType == kWCTDataBlockDependent) {
+ // Find the data block
+ byte *pCompressedDataPtr = _vm->findWrappedBlock(MKTAG('W', 'I', 'Z', 'H'), wizPtr->data, state, false);
+
+ // If we have data (assume it's T14 for now...)
+ if (pCompressedDataPtr) {
+ // Massage the data to be 'U32' friendly
+ pCompressedDataPtr += _vm->_resourceHeaderSize;
+
+ Common::Rect clippingRect;
+ Common::Rect *pClippingRect;
+
+ if (clipRectPtr) {
+ clippingRect.left = clipRectPtr->left;
+ clippingRect.top = clipRectPtr->top;
+ clippingRect.right = (clipRectPtr->right + 1);
+ clippingRect.bottom = (clipRectPtr->bottom + 1);
+
+ pClippingRect = &clippingRect;
+ } else {
+ pClippingRect = nullptr;
+ }
+
+ // Convert incoming condition bits to ROP's and params
+ int rawROP = (conditionBits & kWMSBRopMask);
+
+ int nROPParam = ((conditionBits & kWMSBReservedBits) >> kWMSBRopParamRShift);
+
+ conditionBits &= ~kWMSBReservedBits;
+
+ int nROP;
+
+ switch (rawROP) {
+
+ default:
+ case 1: // MMX copy
+ nROP = T14_MMX_PREMUL_ALPHA_COPY;
+ break;
+
+ case 2: // additive
+ nROP = T14_MMX_ADDITIVE;
+ break;
+
+ case 3: // subtractive
+ nROP = T14_MMX_SUBTRACTIVE;
+ break;
+
+ case 4: // over all alpha
+ nROP = T14_MMX_CONSTANT_ALPHA;
+ break;
+
+ case 5: // MMX cheap 50:50 copy
+ nROP = T14_MMX_CHEAP_50_50;
+ break;
+
+ case 6: // NON MMX copy
+ nROP = T14_COPY;
+ break;
+
+ case 7: // NON MMX copy
+ nROP = T14_CHEAP_50_50;
+ break;
+ }
+
+ // Finally dispatch to the T14 handler
+ //DISPATCH_Blit_RGB555(bitmapPtr->data, bitmapPtr->width, bitmapPtr->height,
+ // (bitmapPtr->width * sizeof(WizRawPixel16)), pClippingRect,
+ // pCompressedDataPtr, x, y, nROP, nROPParam, pAltSourceBuffer);
+ }
+ } else {
+ byte *wizdBlockPtr = _vm->findWrappedBlock(MKTAG('W', 'I', 'Z', 'D'), wizPtr->data, state, false) - _vm->_resourceHeaderSize;
+
+ if (wizdBlockPtr) {
+ // Fake up the compressed image header
+ fakedHeader.data = wizdBlockPtr + _vm->_resourceHeaderSize;
+ fakedHeader.transparentColor = 5;
+ fakedHeader.width = sizeX;
+ fakedHeader.height = sizeY;
+ fakedHeader.size = READ_BE_UINT32(wizdBlockPtr + 4);
+ fakedHeader.type = 0x100; // COMPRESSION_TYPE_SRLE
+
+ // Clip the rects passed in...
+ makeSizedRect(&src, sizeX, sizeY);
+
+ if (optionalSrcRect) {
+ if (!findRectOverlap(&src, optionalSrcRect)) {
+ return;
+ }
+ }
+
+ // Get down to business and draw this image :-)
+ switch (nStateCompressionType) {
+ case kWCTNone:
+ break; // Explicitly unhandled
+
+ case kWCTTRLE:
+ if (p8BppToXBppClut) {
+ error("Hey! This is actually used, implement it!");
+ //TRLEFLIP_Decompress8BppToXBpp(
+ // bitmapPtr, &fakedHeader, x, y, &src, clipRectPtr, flags,
+ // p8BppToXBppClut);
+ }
+
+ break;
+ case kWCTNone16Bpp:
+ if (getRawBitmapInfoForState(&fakedBitmap, wizPtr, state)) {
+ makeSizedRectAt(&dstRect, x, y, getRectWidth(&src), getRectHeight(&src));
+
+ if (flags & kWRFHFlip) {
+ swapRectX(&dstRect);
+ }
+
+ if (flags & kWRFVFlip) {
+ swapRectY(&dstRect);
+ }
+
+ // How should transparency be managed?
+ rawBitmapBlit(bitmapPtr, &dstRect, &fakedBitmap, &src);
+ }
+ break;
+
+ case kWCTComposite:
+ //_HandleCompositeDrawImage(
+ // bitmapPtr, wizPtr, wizdBlockPtr,
+ // x, y, &src, clipRectPtr, flags,
+ // conditionBits, &size,
+ // p8BppToXBppClut,
+ // pAltSourceBuffer);
+ break;
+
+ case kWCTTRLE16Bpp:
+ trleFLIPDecompressMoonbaseImage(bitmapPtr, &fakedHeader, x, y, &src, clipRectPtr, flags);
+ break;
+
+ default:
+ break;
+ }
+ }
+ }
+ }
+}
+
+bool Wiz::getRawBitmapInfoForState(WizRawBitmap *bitmapPtr, WizImage *wizPtr, int state) {
+ byte *workPtr;
+ int32 sizeX, sizeY, compType;
+
+ bool wizValid = getMoonbaseWizSizeAndType(_vm, wizPtr, state, sizeX, sizeY, compType);
+
+ // Make sure the compression type is RAW
+ if (compType != kWCTNone16Bpp) {
+ return false;
+ }
+
+ // Make sure that the wiz has size
+ if (!wizValid) {
+ return false;
+ }
+
+ // Get the data block for the state
+ workPtr = _vm->findWrappedBlock(MKTAG('W', 'I', 'Z', 'H'), wizPtr->data, state, false);
+
+ if (!workPtr) {
+ return false;
+ }
+
+ // Build the bitmap struct for this state.
+ bitmapPtr->data = (WizRawPixel16 *)workPtr;
+ bitmapPtr->dataSize = sizeX * sizeY;
+ bitmapPtr->width = sizeX;
+ bitmapPtr->height = sizeY;
+
+ return true;
+}
+
+void Wiz::rawBitmapBlit(WizRawBitmap *dstBitmap, Common::Rect *dstRectPtr, WizRawBitmap *srcBitmap, Common::Rect *srcRectPtr) {
+ Common::Rect clipRect, dstRect, srcRect;
+ int x, cw, dw, sw, ch, dxm, dym, ca;
+ WizRawPixel16 *s;
+ WizRawPixel16 *d;
+
+ dstRect = *dstRectPtr;
+ srcRect = *srcRectPtr;
+ makeSizedRect(&clipRect, dstBitmap->width, dstBitmap->height);
+
+ if (findRectOverlap(&dstRect, &clipRect)) {
+ // Adjust the source coords to the clipped dest coords...
+ dxm = (srcRect.left <= srcRect.right) ? 1 : -1;
+ dym = (srcRect.top <= srcRect.bottom) ? 1 : -1;
+ moveRect(&srcRect, (dstRect.left - dstRectPtr->left) * dxm, (dstRect.top - dstRectPtr->top) * dym);
+
+ // Common calcs...
+ dw = dstBitmap->width;
+ sw = srcBitmap->width;
+ cw = getRectWidth(&dstRect);
+ ch = getRectHeight(&dstRect);
+ d = dstBitmap->data + (((dstBitmap)->width * (dstRect.top) + (dstRect.left)));
+ s = srcBitmap->data + (((srcBitmap)->width * (srcRect.top) + (srcRect.left)));
+ ca = cw * sizeof(WizRawPixel16);
+
+ // Going up or down?
+ if (srcRect.top > srcRect.bottom) {
+ sw = -sw;
+ }
+
+ // Left or right?
+ if (srcRect.left <= srcRect.right) {
+ while (--ch >= 0) {
+ memcpy(d, s, ca);
+
+ d += dw;
+ s += sw;
+ }
+
+ } else {
+ dw -= cw;
+ sw += cw;
+
+ while (--ch >= 0) {
+ for (x = cw; --x >= 0;) {
+ *d++ = *s--;
+ }
+
+ d += dw;
+ s += sw;
+ }
+ }
+ }
+}
+
+static void trleFLIPMoonbaseBackwardsPixelCopy(WizRawPixel16 *dstPtr, WizRawPixel16 *srcPtr, int size) {
+ while (size-- > 0) {
+ *dstPtr-- = *srcPtr++;
+ }
+}
+
+static void trleFLIPDecompressMoonbaseLineForward(Wiz *wiz, WizRawPixel16 *destPtr, byte *dataStream, int skipAmount, int decompAmount, byte *extraPtr) {
+ int runCount;
+
+ // Decompress bytes to do simple clipping...
+ MOONBASE_HANDLE_SKIP_PIXELS_STEP();
+
+ // Really decompress to the dest buffer...
+ MOONBASE_HANDLE_RUN_DECOMPRESS_STEP(
+ {
+ destPtr += runCount;
+ },
+ {
+ wiz->rawPixelMemset(destPtr, READ_LE_UINT16(dataStream), runCount);
+ destPtr += runCount;
+ },
+ {
+ memcpy(destPtr, dataStream, runCount * sizeof(WizRawPixel16));
+ destPtr += runCount;
+ }
+ );
+}
+
+static void trleFLIPDecompressMoonbaseLineBackward(Wiz *wiz, WizRawPixel16 *destPtr, byte *dataStream, int skipAmount, int decompAmount, byte *extraPtr) {
+ int runCount;
+
+ // Decompress bytes to do simple clipping...
+ MOONBASE_HANDLE_SKIP_PIXELS_STEP();
+
+ // Really decompress to the dest buffer...
+ MOONBASE_HANDLE_RUN_DECOMPRESS_STEP(
+ {
+ destPtr -= runCount;
+ },
+ {
+ destPtr -= runCount;
+ wiz->rawPixelMemset(destPtr + 1, READ_LE_UINT16(dataStream), runCount);
+ },
+ {
+ trleFLIPMoonbaseBackwardsPixelCopy(destPtr, (WizRawPixel16 *)dataStream, runCount);
+ destPtr -= runCount;
+ }
+ );
+}
+
+void Wiz::trleFLIPDecompressMoonbaseImage(
+ WizRawBitmap *bitmapPtr, WizMoonbaseCompressedImage *imagePtr, int destX, int destY,
+ Common::Rect *sourceCoords, Common::Rect *clipRectPtr, int32 flags) {
+
+ Common::Rect sourceRect, destRect, clipRect, workRect, inSourceRect;
+ int width, height, bufferWidth, bufferHeight;
+
+ // Lame ass general setup...
+ bufferWidth = bitmapPtr->width;
+ bufferHeight = bitmapPtr->height;
+
+ if (!sourceCoords) {
+ width = imagePtr->width;
+ height = imagePtr->height;
+ makeSizedRect(&sourceRect, width, height);
+ } else {
+ width = getRectWidth(sourceCoords);
+ height = getRectHeight(sourceCoords);
+ sourceRect = *sourceCoords;
+ }
+
+ inSourceRect = sourceRect;
+ makeSizedRectAt(&destRect, destX, destY, width, height);
+
+ // Custom clip rect...
+ if (clipRectPtr) {
+ clipRect = *clipRectPtr;
+ makeSizedRect(&workRect, bufferWidth, bufferHeight);
+
+ if (!findRectOverlap(&clipRect, &workRect)) {
+ return;
+ }
+ } else {
+ makeSizedRect(&clipRect, bufferWidth, bufferHeight);
+ }
+
+ // Clip the source & dest coords to the clipping rectangle...
+ clipRectCoords(&sourceRect, &destRect, &clipRect);
+
+ if (destRect.right < destRect.left) {
+ return;
+ }
+
+ if (destRect.bottom < destRect.top) {
+ return;
+ }
+
+ if (sourceRect.right < sourceRect.left) {
+ return;
+ }
+
+ if (sourceRect.bottom < sourceRect.top) {
+ return;
+ }
+
+ // Handle the flip coords source adjustment...
+ bool useForwardFunction = true;
+
+ if (flags & kWRFHFlip) {
+ useForwardFunction = false;
+ horzFlipAlignWithRect(&sourceRect, &inSourceRect);
+ swapRectX(&destRect);
+ }
+
+ if (flags & kWRFVFlip) {
+ vertFlipAlignWithRect(&sourceRect, &inSourceRect);
+ swapRectY(&destRect);
+ }
+
+ // Call the primitive image renderer...
+ if (useForwardFunction) {
+ trleFLIPDecompMoonbaseImageHull(
+ bitmapPtr->data, bufferWidth, &destRect, imagePtr->data,
+ &sourceRect, nullptr, trleFLIPDecompressMoonbaseLineForward);
+ } else {
+ trleFLIPDecompMoonbaseImageHull(
+ bitmapPtr->data, bufferWidth, &destRect, imagePtr->data,
+ &sourceRect, nullptr, trleFLIPDecompressMoonbaseLineBackward);
+ }
+}
+
+void Wiz::trleFLIPDecompMoonbaseImageHull(
+ WizRawPixel16 *bufferPtr, int bufferWidth, Common::Rect *destRect, byte *compData, Common::Rect *sourceRect, byte *extraPtr,
+ void (*functionPtr)(Wiz *wiz, WizRawPixel *destPtr, byte *dataStream, int skipAmount, int decompAmount, byte *extraPtr)) {
+
+ int decompWidth, decompHeight, counter, x1, lineSize;
+
+ // General setup...
+ x1 = sourceRect->left;
+ decompWidth = sourceRect->right - sourceRect->left + 1;
+ decompHeight = sourceRect->bottom - sourceRect->top + 1;
+
+ // Quickly skip down to the lines to be compressed & dest position...
+ bufferPtr += bufferWidth * destRect->top + destRect->left;
+
+ for (counter = sourceRect->top; counter > 0; counter--) {
+ compData += READ_LE_UINT16(compData) + 2;
+ }
+
+ // Flip the dest offset if vertical flipping...
+ if (destRect->top > destRect->bottom) {
+ bufferWidth = -bufferWidth;
+ }
+
+ // Decompress all the lines that are visible...
+ while (decompHeight-- > 0) {
+ lineSize = READ_LE_UINT16(compData);
+
+ if (lineSize != 0) {
+ (*functionPtr)(this, bufferPtr, compData + 2, x1, decompWidth, extraPtr);
+ compData += lineSize + 2;
+ bufferPtr += bufferWidth;
+ } else {
+ // Handle a completely transparent line!
+ compData += 2;
+ bufferPtr += bufferWidth;
+ }
+ }
+}
+
+} // End of namespace Scumm
diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp
index 1a8d0935e98..4c0e08d16cf 100644
--- a/engines/scumm/he/wiz_he.cpp
+++ b/engines/scumm/he/wiz_he.cpp
@@ -25,6 +25,7 @@
#include "common/system.h"
#include "graphics/cursorman.h"
#include "graphics/primitives.h"
+#include "scumm/he/logic_he.h"
#include "scumm/he/intern_he.h"
#include "scumm/resource.h"
#include "scumm/scumm.h"
@@ -1445,6 +1446,63 @@ void Wiz::dwCreateRawWiz(int imageNum, int w, int h, int flags, int bitsPerPixel
WRITE_BE_UINT32(writePtr, 8 + wizdSize); writePtr += 4;
}
+bool Wiz::dwGetMultiTypeBitmapFromImageState(int imageNum, int imageState, WizMultiTypeBitmap *multiBM) {
+ int compType, imageWidth, imageHeight;
+ byte *wizHeader;
+ byte *dataPtr;
+
+ // Get the image header...
+ wizHeader = getWizStateHeaderPrim(imageNum, imageState);
+
+ if (!wizHeader) {
+ memset(multiBM, 0, sizeof(WizMultiTypeBitmap));
+ return false;
+ }
+
+ // Double check the image header compression type...
+ compType = READ_LE_UINT32(wizHeader + _vm->_resourceHeaderSize);
+
+ if (!isUncompressedFormatTypeID(compType)) {
+ memset(multiBM, 0, sizeof(WizMultiTypeBitmap));
+ return false;
+ }
+
+ imageWidth = READ_LE_UINT32(wizHeader + _vm->_resourceHeaderSize + 4);
+ imageHeight = READ_LE_UINT32(wizHeader + _vm->_resourceHeaderSize + 8);
+
+ dataPtr = getWizStateDataPrim(imageNum, imageState);
+
+ if (!dataPtr) {
+ memset(multiBM, 0, sizeof(WizMultiTypeBitmap));
+ return false;
+ }
+
+ // Hook up the image info to the simple bitmap info...
+ multiBM->data = (dataPtr + _vm->_resourceHeaderSize);
+ multiBM->width = imageWidth;
+ multiBM->height = imageHeight;
+
+ switch (compType) {
+ case kWCTNone:
+ multiBM->bpp = 8;
+ multiBM->format = 8;
+ break;
+ case kWCTNone16Bpp:
+ case kWCTNone16BppBigEndian:
+ multiBM->bpp = 16;
+ multiBM->format = 555;
+ break;
+ default:
+ memset(multiBM, 0, sizeof(WizMultiTypeBitmap));
+ return false;
+ break;
+ }
+
+ multiBM->stride = (multiBM->width * multiBM->bpp) / 8;
+
+ return true;
+}
+
bool Wiz::dwSetSimpleBitmapStructFromImage(int imageNum, int imageState, WizSimpleBitmap *destBM) {
int compType, imageWidth, imageHeight;
byte *wizHeader;
@@ -2555,9 +2613,9 @@ void Wiz::processWizImageSaveCmd(const WizImageCommand *params) {
void Wiz::processWizImageCmd(const WizImageCommand *params) {
// TODO
- //if (PU_ProcessWizImageCmd(params)) {
- // return;
- //}
+ if (((ScummEngine_v90he *)_vm)->_logicHE->userCodeProcessWizImageCmd(params)) {
+ return;
+ }
//debug(5, "Wiz::processWizImageCmd(): actionType %d for image %d", params->actionType, params->image);
switch (params->actionType) {
diff --git a/engines/scumm/he/wiz_he.h b/engines/scumm/he/wiz_he.h
index d562989bed0..6933ac59f1c 100644
--- a/engines/scumm/he/wiz_he.h
+++ b/engines/scumm/he/wiz_he.h
@@ -64,7 +64,7 @@ namespace Scumm {
(wizComp) == kWCTTRLE16Bpp
#define NATIVE_WIZ_TYPE(wizComp) \
- (wizComp) == NATIVE_WIZ_COMP_NONE_16BPP || \
+ (wizComp) == NATIVE_WIZ_COMP_NONE_16BPP || \
(wizComp) == NATIVE_WIZ_COMP_TRLE_16BPP \
#define WIZ_16BPP(wizComp) \
@@ -98,15 +98,32 @@ namespace Scumm {
#define WIZRAWPIXEL_50_50_PREMIX_COLOR(__rawColor__) (((__rawColor__) & WIZRAWPIXEL_HI_BITS) >> 1)
#define WIZRAWPIXEL_50_50_MIX(__colorA__, __colorB__) ((__colorA__) + (__colorB__))
-#define WIZRAWPIXEL_ADDITIVE_MIX(__colorA__, __colorB__) \
- (MIN<int>(WIZRAWPIXEL_R_MASK, (((__colorA__) & WIZRAWPIXEL_R_MASK) + ((__colorB__) & WIZRAWPIXEL_R_MASK))) | \
- MIN<int>(WIZRAWPIXEL_G_MASK, (((__colorA__) & WIZRAWPIXEL_G_MASK) + ((__colorB__) & WIZRAWPIXEL_G_MASK))) | \
- MIN<int>(WIZRAWPIXEL_B_MASK, (((__colorA__) & WIZRAWPIXEL_B_MASK) + ((__colorB__) & WIZRAWPIXEL_B_MASK))))
+#define WIZRAWPIXEL_ADDITIVE_MIX(__colorA__, __colorB__) \
+ (MIN<int>(WIZRAWPIXEL_R_MASK, (((__colorA__) & WIZRAWPIXEL_R_MASK) + ((__colorB__) & WIZRAWPIXEL_R_MASK))) | \
+ MIN<int>(WIZRAWPIXEL_G_MASK, (((__colorA__) & WIZRAWPIXEL_G_MASK) + ((__colorB__) & WIZRAWPIXEL_G_MASK))) | \
+ MIN<int>(WIZRAWPIXEL_B_MASK, (((__colorA__) & WIZRAWPIXEL_B_MASK) + ((__colorB__) & WIZRAWPIXEL_B_MASK))))
+
+#define WIZRAWPIXEL_SUBTRACTIVE_MIX(__colorA__, __colorB__) \
+ (MAX<int>(WIZRAWPIXEL_LO_R_BIT, (((__colorA__) & WIZRAWPIXEL_R_MASK) - ((__colorB__) & WIZRAWPIXEL_R_MASK))) | \
+ MAX<int>(WIZRAWPIXEL_LO_G_BIT, (((__colorA__) & WIZRAWPIXEL_G_MASK) - ((__colorB__) & WIZRAWPIXEL_G_MASK))) | \
+ MAX<int>(WIZRAWPIXEL_LO_B_BIT, (((__colorA__) & WIZRAWPIXEL_B_MASK) - ((__colorB__) & WIZRAWPIXEL_B_MASK))))
+
+
+#define T14_MMX_REQUIRED 0x8000
+#define T14_NOP (0x0000)
+#define T14_COPY (0x0001)
+#define T14_CHEAP_50_50 (0x0002)
+#define T14_PREMULTIPLIED_5050 (0x0003)
+#define T14_MMX_COPY (0x0004 | T14_MMX_REQUIRED)
+#define T14_MMX_CHEAP_50_50 (0x0005 | T14_MMX_REQUIRED)
+#define T14_MMX_PREMULTIPLIED_5050 (0x0006 | T14_MMX_REQUIRED)
+#define T14_MMX_ADDITIVE (0x0007 | T14_MMX_REQUIRED)
+#define T14_MMX_SUBTRACTIVE (0x0008 | T14_MMX_REQUIRED)
+#define T14_MMX_CONSTANT_ALPHA (0x0009 | T14_MMX_REQUIRED)
+#define T14_MMX_SILHOUETTE_DARKEN (0x000a | T14_MMX_REQUIRED)
+#define T14_MMX_SILHOUETTE_BRIGHTEN (0x000b | T14_MMX_REQUIRED)
+#define T14_MMX_PREMUL_ALPHA_COPY (0x000c | T14_MMX_REQUIRED)
-#define WIZRAWPIXEL_SUBTRACTIVE_MIX(__colorA__, __colorB__) \
- (MAX<int>(WIZRAWPIXEL_LO_R_BIT, (((__colorA__) & WIZRAWPIXEL_R_MASK) - ((__colorB__) & WIZRAWPIXEL_R_MASK))) | \
- MAX<int>(WIZRAWPIXEL_LO_G_BIT, (((__colorA__) & WIZRAWPIXEL_G_MASK) - ((__colorB__) & WIZRAWPIXEL_G_MASK))) | \
- MAX<int>(WIZRAWPIXEL_LO_B_BIT, (((__colorA__) & WIZRAWPIXEL_B_MASK) - ((__colorB__) & WIZRAWPIXEL_B_MASK))))
typedef uint16 WizRawPixel;
typedef uint8 WizRawPixel8;
@@ -244,7 +261,6 @@ struct WizImageCommand {
memset(&ellipseProperties, 0, sizeof(WizEllipseProperties));
renderCoords.left = renderCoords.top = renderCoords.bottom = renderCoords.right = 0;
memset(&extendedRenderInfo, 0, sizeof(WizExtendedRenderInfo));
-
}
};
@@ -270,6 +286,27 @@ struct WizSimpleBitmap {
int bitmapHeight;
};
+struct WizMultiTypeBitmap {
+ byte *data;
+ int width;
+ int height;
+ int stride;
+ int format;
+ int bpp;
+};
+
+struct WizRawBitmap {
+ int width;
+ int height;
+ int dataSize;
+ WizRawPixel16 *data;
+};
+
+struct WizImage {
+ int dataSize;
+ byte *data;
+};
+
struct WizFloodSegment {
int y, xl, xr, dy;
};
@@ -293,6 +330,12 @@ struct WizCompressedImage {
int height;
};
+struct WizMoonbaseCompressedImage {
+ int type, size, width, height;
+ WizRawPixel16 transparentColor;
+ byte *data;
+};
+
// Our Common::Point has int16 coordinates.
// This is not enough for polygon warping...
struct WarpWizPoint {
@@ -454,16 +497,16 @@ enum WizImgProps {
};
enum WizSpcConditionTypes : uint {
- kWSPCCTBits = 0xc0000000,
+ kWSPCCTBits = 0xC0000000,
kWSPCCTOr = 0x00000000,
kWSPCCTAnd = 0x40000000,
kWSPCCTNot = 0x80000000
};
enum WizMoonSystemBits {
- kWMSBRopMask = 0xff,
- kWMSBRopParamMask = 0xff00,
- kWMSBReservedBits = (kWMSBRopMask | kWMSBRopParamMask),
+ kWMSBRopMask = 0x000000FF,
+ kWMSBRopParamMask = 0x0000FF00,
+ kWMSBReservedBits = (kWMSBRopMask | kWMSBRopParamMask),
kWMSBRopParamRShift = 8
};
@@ -475,21 +518,15 @@ enum WizEllipseConstants {
enum WizZPlaneOps {
kWZOIgnore = 0,
- kWZOClear = 1,
- kWZOSet = 2
-};
-
-enum {
- kWizXMap = 0,
- kWizRMap,
- kWizCopy
+ kWZOClear = 1,
+ kWZOSet = 2
};
enum DstSurface {
kDstScreen = 0,
kDstMemory = 1,
kDstResource = 2,
- kDstCursor = 3
+ kDstCursor = 3
};
class ScummEngine_v71he;
@@ -531,6 +568,7 @@ public:
bool polyIsRectangle(const Common::Point *points, int numverts);
void dwCreateRawWiz(int imageNum, int w, int h, int flags, int bitsPerPixel, int optionalSpotX, int optionalSpotY);
+ bool dwGetMultiTypeBitmapFromImageState(int imageNum, int imageState, WizMultiTypeBitmap *multiBM);
bool dwSetSimpleBitmapStructFromImage(int imageNum, int imageState, WizSimpleBitmap *destBM);
int dwTryToLoadWiz(Common::SeekableReadStream *inFile, const WizImageCommand *params);
void dwAltSourceDrawWiz(int maskImage, int maskState, int x, int y, int sourceImage, int sourceState, int32 flags, int paletteNumber, const Common::Rect *optionalClipRect, const WizSimpleBitmap *destBitmapPtr);
@@ -610,6 +648,33 @@ public:
const byte *imageBData, int bType, int bw, int bh, int32 wizBFlags, int bx, int by,
int compareWidth, WizRawPixel transparentColor);
+ /*
+ * Moonbase Commander custom Wiz operations
+ *
+ * These are defined in moonbase/moonbase_layered_wiz.cpp
+ */
+
+ bool drawLayeredWiz(
+ byte *pDstBitmapData, int nDstWidth, int nDstHeight, int nDstPitch,
+ int nDstFormat, int nDstBpp, byte *pWizImageData,
+ int x, const int y, int state, int clip_x1, int clip_y1, int clip_x2, int clip_y2,
+ uint32 dwFlags, uint32 dwConditionBits, byte *p8BppToXBppClut, byte *pAltSourceBuffer);
+
+ void drawImageEx(
+ WizRawBitmap *bitmapPtr, WizImage *wizPtr, int x, int y, int state,
+ Common::Rect *clipRectPtr, int32 flags, Common::Rect *optionalSrcRect,
+ int32 conditionBits, WizRawPixel16 *p8BppToXBppClut, byte *pAltSourceBuffer);
+
+ bool getRawBitmapInfoForState(WizRawBitmap *bitmapPtr, WizImage *wizPtr, int state);
+ void rawBitmapBlit(WizRawBitmap *dstBitmap, Common::Rect *dstRectPtr, WizRawBitmap *srcBitmap, Common::Rect *srcRectPtr);
+
+ void trleFLIPDecompressMoonbaseImage(
+ WizRawBitmap *bitmapPtr, WizMoonbaseCompressedImage *imagePtr, int destX, int destY,
+ Common::Rect *sourceCoords, Common::Rect *clipRectPtr, int32 flags);
+ void trleFLIPDecompMoonbaseImageHull(
+ WizRawPixel16 *bufferPtr, int bufferWidth, Common::Rect *destRect, byte *compData, Common::Rect *sourceRect, byte *extraPtr,
+ void (*functionPtr)(Wiz *wiz, WizRawPixel *destPtr, byte *dataStream, int skipAmount, int decompAmount, byte *extraPtr));
+
private:
ScummEngine_v71he *_vm;
@@ -636,6 +701,7 @@ public:
void pgHistogramBitmapSubRect(int *tablePtr, const WizSimpleBitmap *bitmapPtr, const Common::Rect *sourceRect);
void pgSimpleBitmapFromDrawBuffer(WizSimpleBitmap *bitmapPtr, bool background);
+ bool pgGetMultiTypeBitmapFromDrawBuffer(WizMultiTypeBitmap *multiBM, bool background);
void pgDrawRawDataFormatImage(WizRawPixel *bufferPtr, const WizRawPixel *rawData, int bufferWidth, int bufferHeight, int x, int y, int width, int height, Common::Rect *clipRectPtr, int32 wizFlags, const byte *extraTable, int transparentColor);
void pgSimpleBlit(WizSimpleBitmap *destBM, Common::Rect *destRect, WizSimpleBitmap *sourceBM, Common::Rect *sourceRect);
void pgSimpleBlitRemapColors(WizSimpleBitmap *destBM, Common::Rect *destRect, WizSimpleBitmap *sourceBM, Common::Rect *sourceRect, const byte *remapColorTable);
@@ -649,13 +715,13 @@ public:
void pgDraw8BppSimpleBlit(WizSimpleBitmap *destBM, Common::Rect *destRect, WizSimpleBitmap *sourceBM, Common::Rect *sourceRect, const WizRawPixel *conversionTable);
void pgDraw8BppTransparentSimpleBlit(WizSimpleBitmap *destBM, Common::Rect *destRect, WizSimpleBitmap *sourceBM, Common::Rect *sourceRect, int transparentColor, const WizRawPixel *conversionTable);
void pgDrawImageWith16BitZBuffer(WizSimpleBitmap *psbDst, const WizSimpleBitmap *psbZBuffer, const byte *imgData, int x, int y, int z, int width, int height, Common::Rect *prcClip);
- void pgForewordRemapPixelCopy(WizRawPixel *dstPtr, const WizRawPixel *srcPtr, int size, const byte *lookupTable);
+ void pgForwardRemapPixelCopy(WizRawPixel *dstPtr, const WizRawPixel *srcPtr, int size, const byte *lookupTable);
void pgBackwardsRemapPixelCopy(WizRawPixel *dstPtr, const WizRawPixel *srcPtr, int size, const byte *lookupTable);
- void pgTransparentForewordRemapPixelCopy(WizRawPixel *dstPtr, const WizRawPixel *srcPtr, int size, WizRawPixel transparentColor, const byte *lookupTable);
+ void pgTransparentForwardRemapPixelCopy(WizRawPixel *dstPtr, const WizRawPixel *srcPtr, int size, WizRawPixel transparentColor, const byte *lookupTable);
void pgTransparentBackwardsRemapPixelCopy(WizRawPixel *dstPtr, const WizRawPixel *srcPtr, int size, WizRawPixel transparentColor, const byte *lookupTable);
- void pgForewordMixColorsPixelCopy(WizRawPixel *dstPtr, const WizRawPixel *srcPtr, int size, const byte *lookupTable);
+ void pgForwardMixColorsPixelCopy(WizRawPixel *dstPtr, const WizRawPixel *srcPtr, int size, const byte *lookupTable);
void pgBackwardsMixColorsPixelCopy(WizRawPixel *dstPtr, const WizRawPixel *srcPtr, int size, const byte *lookupTable);
- void pgTransparentForewordMixColorsPixelCopy(WizRawPixel *dstPtr, const WizRawPixel *srcPtr, int size, WizRawPixel transparentColor, const byte *lookupTable);
+ void pgTransparentForwardMixColorsPixelCopy(WizRawPixel *dstPtr, const WizRawPixel *srcPtr, int size, WizRawPixel transparentColor, const byte *lookupTable);
void pgTransparentBackwardsMixColorsPixelCopy(WizRawPixel *dstPtr, const WizRawPixel *srcPtr, int size, WizRawPixel transparentColor, const byte *lookupTable);
void pgBlit90DegreeRotate(WizSimpleBitmap *dstBitmap, int x, int y, const WizSimpleBitmap *srcBitmap, const Common::Rect *optionalSrcRect, const Common::Rect *optionalClipRect, bool hFlip, bool vFlip);
void pgBlit90DegreeRotateTransparent(WizSimpleBitmap *dstBitmap, int x, int y, const WizSimpleBitmap *srcBitmap, const Common::Rect *optionalSrcRect, const Common::Rect *optionalClipRect, bool hFlip, bool vFlip, WizRawPixel transparentColor);
@@ -866,9 +932,9 @@ public:
void trleFLIPRemapDestPixels(WizRawPixel *dstPtr, int size, const byte *lookupTable);
void trleFLIPForwardPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable);
void trleFLIPBackwardsPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const WizRawPixel *conversionTable);
- void trleFLIPForewordLookupPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const byte *lookupTable, const WizRawPixel *conversionTable);
+ void trleFLIPForwardLookupPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const byte *lookupTable, const WizRawPixel *conversionTable);
void trleFLIPBackwardsLookupPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const byte *lookupTable, const WizRawPixel *conversionTable);
- void trleFLIPForewordMixColorsPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const byte *lookupTable);
+ void trleFLIPForwardMixColorsPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const byte *lookupTable);
void trleFLIPBackwardsMixColorsPixelCopy(WizRawPixel *dstPtr, const byte *srcPtr, int size, const byte *lookupTable);
diff --git a/engines/scumm/module.mk b/engines/scumm/module.mk
index 5c60945e4f5..7ec4b06bbba 100644
--- a/engines/scumm/module.mk
+++ b/engines/scumm/module.mk
@@ -177,7 +177,8 @@ MODULE_OBJS += \
he/moonbase/ai_weapon.o \
he/moonbase/distortion.o \
he/moonbase/moonbase.o \
- he/moonbase/moonbase_fow.o
+ he/moonbase/moonbase_fow.o \
+ he/moonbase/moonbase_gfx.o
ifdef USE_ENET
MODULE_OBJS += \
Commit: 1d1b7172fd8618a70c7a4252a3a26c91b200197c
https://github.com/scummvm/scummvm/commit/1d1b7172fd8618a70c7a4252a3a26c91b200197c
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Fix null pointer access
Changed paths:
engines/scumm/he/gfx_comp/mrle_comp.cpp
engines/scumm/he/gfx_comp/trle_comp.cpp
diff --git a/engines/scumm/he/gfx_comp/mrle_comp.cpp b/engines/scumm/he/gfx_comp/mrle_comp.cpp
index 402a125dcab..0f1e738f573 100644
--- a/engines/scumm/he/gfx_comp/mrle_comp.cpp
+++ b/engines/scumm/he/gfx_comp/mrle_comp.cpp
@@ -377,7 +377,7 @@ void Wiz::mrleFLIPAltSourceDecompressPrim(
destRect.bottom = destY + height - 1;
// Custom clip rect...
- if (!clipRectPtr) {
+ if (clipRectPtr) {
clipRect = *clipRectPtr;
workRect.left = 0;
diff --git a/engines/scumm/he/gfx_comp/trle_comp.cpp b/engines/scumm/he/gfx_comp/trle_comp.cpp
index 77a519ede58..d5bcc915e98 100644
--- a/engines/scumm/he/gfx_comp/trle_comp.cpp
+++ b/engines/scumm/he/gfx_comp/trle_comp.cpp
@@ -1269,8 +1269,7 @@ void Wiz::trleFLIP90DegreeRotateCore(WizSimpleBitmap *dstBitmap, int x, int y, c
}
// Make the "dest" rect then clip it against the clip rect
- makeSizedRectAt(
- &dstRect, x, y, getRectHeight(&srcRect), getRectWidth(&srcRect));
+ makeSizedRectAt(&dstRect, x, y, getRectHeight(&srcRect), getRectWidth(&srcRect));
clippedDstRect = dstRect;
Commit: 6b5c87039761c44db680bd0bbcfcd82c37864a20
https://github.com/scummvm/scummvm/commit/6b5c87039761c44db680bd0bbcfcd82c37864a20
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Implement more Moonbase graphics
Changed paths:
engines/scumm/he/intern_he.h
engines/scumm/he/logic/moonbase_logic.cpp
engines/scumm/he/logic_he.h
engines/scumm/he/moonbase/moonbase_gfx.cpp
engines/scumm/he/wiz_he.cpp
engines/scumm/he/wiz_he.h
diff --git a/engines/scumm/he/intern_he.h b/engines/scumm/he/intern_he.h
index 82a4da4fd60..b3980b435f4 100644
--- a/engines/scumm/he/intern_he.h
+++ b/engines/scumm/he/intern_he.h
@@ -650,7 +650,7 @@ protected:
int32 _minSpriteNum = 0;
int32 _curSpriteGroupId;
- LogicHE *_logicHE;
+ LogicHE *_logicHE = nullptr;
MoviePlayer *_moviePlay;
Sprite *_sprite;
diff --git a/engines/scumm/he/logic/moonbase_logic.cpp b/engines/scumm/he/logic/moonbase_logic.cpp
index ecd46d87ffc..a98cd548d4a 100644
--- a/engines/scumm/he/logic/moonbase_logic.cpp
+++ b/engines/scumm/he/logic/moonbase_logic.cpp
@@ -44,6 +44,8 @@ public:
int32 dispatch(int op, int numArgs, int32 *args) override;
bool userCodeProcessWizImageCmd(const WizImageCommand *icmdPtr) override;
+ bool overrideImageHitTest(int *outValue, int globNum, int state, int x, int y, int32 flags) override;
+ bool overrideImagePixelHitTest(int *outValue, int globNum, int state, int x, int y, int32 flags) override;
private:
int op_create_multi_state_wiz(int op, int numArgs, int32 *args);
@@ -452,6 +454,43 @@ bool LogicHEmoonbase::userCodeProcessWizImageCmd(const WizImageCommand *params)
return true;
}
+bool LogicHEmoonbase::overrideImageHitTest(int *outValue, int globNum, int state, int x, int y, int32 flags) {
+ // Make sure this is a hit-test operation is a type we can handle
+ byte *globPtr = _vm->getResourceAddress(rtImage, globNum);
+
+ if (!globPtr) {
+ warning("LogicHEmoonbase::overrideImageHitTest(): Image %d not on heap", globNum);
+ return false;
+ }
+
+ if (!_vm->_wiz->layeredWizHitTest(outValue, 0, globPtr, state, x, y, flags, 0)) {
+ return false;
+ }
+
+ return true;
+}
+
+bool LogicHEmoonbase::overrideImagePixelHitTest(int *outValue, int globNum, int state, int x, int y, int32 flags) {
+ // Make sure this is a hit-test operation is a type we can handle
+ byte *globPtr = _vm->getResourceAddress(rtImage, globNum);
+
+ if (!globPtr) {
+ warning("LogicHEmoonbase::overrideImagePixelHitTest(): Image %d not on heap", globNum);
+ return false;
+ }
+
+ uint32 actualValue = ~0;
+ int32 eatValue = 0;
+
+ if (!_vm->_wiz->layeredWizHitTest(&eatValue, &actualValue, globPtr, state, x, y, flags, 0)) {
+ return false;
+ }
+
+ *outValue = (int)actualValue;
+
+ return true;
+}
+
int LogicHEmoonbase::op_create_multi_state_wiz(int op, int numArgs, int32 *params) {
//return MULTIWIZ::CreateUncompressedMultiStateWiz(
// params[0], // image
diff --git a/engines/scumm/he/logic_he.h b/engines/scumm/he/logic_he.h
index b6ee70aa1d4..6508ec20fa2 100644
--- a/engines/scumm/he/logic_he.h
+++ b/engines/scumm/he/logic_he.h
@@ -47,6 +47,8 @@ public:
virtual int versionID();
virtual int32 dispatch(int op, int numArgs, int32 *args);
virtual bool userCodeProcessWizImageCmd(const WizImageCommand *icmdPtr) { return false; }
+ virtual bool overrideImageHitTest(int *outValue, int globNum, int state, int x, int y, int32 flags) { return false; }
+ virtual bool overrideImagePixelHitTest(int *outValue, int globNum, int state, int x, int y, int32 flags) { return false; }
protected:
// Only to be used from makeLogicHE()
diff --git a/engines/scumm/he/moonbase/moonbase_gfx.cpp b/engines/scumm/he/moonbase/moonbase_gfx.cpp
index c03c0266ccf..284521ddc13 100644
--- a/engines/scumm/he/moonbase/moonbase_gfx.cpp
+++ b/engines/scumm/he/moonbase/moonbase_gfx.cpp
@@ -150,7 +150,14 @@ bool Wiz::drawLayeredWiz(
return false;
}
- Common::Rect clipRect(clip_x1, clip_y1, clip_x2, clip_y2);
+ Common::Rect clipRect;
+ // We are not directly assigning the rectangle values
+ // in the constructor: the game can (and will!) assign
+ // values which will trigger the "invalid rectangle" assertion...
+ clipRect.left = clip_x1;
+ clipRect.top = clip_y1;
+ clipRect.right = clip_x2;
+ clipRect.bottom = clip_y2;
// Dispatch to the WToolkit image renderer
drawImageEx(&mappedRawbitmap, &wiz, x, y, state, &clipRect, dwFlags, nullptr, dwConditionBits, (WizRawPixel16 *)p8BppToXBppClut, pAltSourceBuffer);
@@ -162,26 +169,23 @@ bool Wiz::drawLayeredWiz(
void Wiz::drawImageEx(
WizRawBitmap *bitmapPtr, WizImage *wizPtr, int x, int y, int state,
Common::Rect *clipRectPtr, int32 flags, Common::Rect *optionalSrcRect,
- int32 conditionBits, WizRawPixel16 *p8BppToXBppClut, byte *pAltSourceBuffer) {
+ int32 conditionBits, WizRawPixel16 *ptr8BppToXBppClut, byte *altSourceBuffer) {
WizMoonbaseCompressedImage fakedHeader;
- int nStateCompressionType;
+ int stateCompressionType;
WizRawBitmap fakedBitmap;
Common::Rect src, dstRect;
int32 sizeX, sizeY;
- if (getMoonbaseWizSizeAndType(((ScummEngine_v71he *)_vm), wizPtr, state, sizeX, sizeY, nStateCompressionType)) {
+ if (getMoonbaseWizSizeAndType(((ScummEngine_v71he *)_vm), wizPtr, state, sizeX, sizeY, stateCompressionType)) {
- if (nStateCompressionType == kWCTDataBlockDependent) {
+ if (stateCompressionType == kWCTDataBlockDependent) {
// Find the data block
- byte *pCompressedDataPtr = _vm->findWrappedBlock(MKTAG('W', 'I', 'Z', 'H'), wizPtr->data, state, false);
+ byte *compressedDataPtr = _vm->findWrappedBlock(MKTAG('W', 'I', 'Z', 'H'), wizPtr->data, state, false);
// If we have data (assume it's T14 for now...)
- if (pCompressedDataPtr) {
- // Massage the data to be 'U32' friendly
- pCompressedDataPtr += _vm->_resourceHeaderSize;
-
+ if (compressedDataPtr) {
Common::Rect clippingRect;
- Common::Rect *pClippingRect;
+ Common::Rect *targetClippingRect;
if (clipRectPtr) {
clippingRect.left = clipRectPtr->left;
@@ -189,19 +193,17 @@ void Wiz::drawImageEx(
clippingRect.right = (clipRectPtr->right + 1);
clippingRect.bottom = (clipRectPtr->bottom + 1);
- pClippingRect = &clippingRect;
+ targetClippingRect = &clippingRect;
} else {
- pClippingRect = nullptr;
+ targetClippingRect = nullptr;
}
// Convert incoming condition bits to ROP's and params
int rawROP = (conditionBits & kWMSBRopMask);
-
int nROPParam = ((conditionBits & kWMSBReservedBits) >> kWMSBRopParamRShift);
-
conditionBits &= ~kWMSBReservedBits;
- int nROP;
+ int nROP = T14_NOP;
switch (rawROP) {
@@ -237,8 +239,8 @@ void Wiz::drawImageEx(
// Finally dispatch to the T14 handler
//DISPATCH_Blit_RGB555(bitmapPtr->data, bitmapPtr->width, bitmapPtr->height,
- // (bitmapPtr->width * sizeof(WizRawPixel16)), pClippingRect,
- // pCompressedDataPtr, x, y, nROP, nROPParam, pAltSourceBuffer);
+ // (bitmapPtr->width * sizeof(WizRawPixel16)), targetClippingRect,
+ // pCompressedDataPtr, x, y, nROP, nROPParam, altSourceBuffer);
}
} else {
byte *wizdBlockPtr = _vm->findWrappedBlock(MKTAG('W', 'I', 'Z', 'D'), wizPtr->data, state, false) - _vm->_resourceHeaderSize;
@@ -262,12 +264,12 @@ void Wiz::drawImageEx(
}
// Get down to business and draw this image :-)
- switch (nStateCompressionType) {
+ switch (stateCompressionType) {
case kWCTNone:
break; // Explicitly unhandled
case kWCTTRLE:
- if (p8BppToXBppClut) {
+ if (ptr8BppToXBppClut) {
error("Hey! This is actually used, implement it!");
//TRLEFLIP_Decompress8BppToXBpp(
// bitmapPtr, &fakedHeader, x, y, &src, clipRectPtr, flags,
@@ -293,12 +295,10 @@ void Wiz::drawImageEx(
break;
case kWCTComposite:
- //_HandleCompositeDrawImage(
- // bitmapPtr, wizPtr, wizdBlockPtr,
- // x, y, &src, clipRectPtr, flags,
- // conditionBits, &size,
- // p8BppToXBppClut,
- // pAltSourceBuffer);
+ handleCompositeDrawImage(
+ bitmapPtr, wizPtr, wizdBlockPtr, x, y, &src, clipRectPtr, flags,
+ conditionBits, sizeX, sizeY, ptr8BppToXBppClut, altSourceBuffer);
+
break;
case kWCTTRLE16Bpp:
@@ -570,4 +570,209 @@ void Wiz::trleFLIPDecompMoonbaseImageHull(
}
}
+bool Wiz::layeredWizHitTest(int32 *outValue, uint32 *pOptionalOutActualValue, byte *globPtr, int state, int x, int y, int32 flags, int32 dwConditionBits) {
+ WizImage wiz;
+
+ wiz.data = globPtr;
+ wiz.dataSize = READ_BE_UINT32(wiz.data + 4);
+
+ // Check to see if this is a compression type we like
+ byte *data = _vm->findWrappedBlock(MKTAG('W', 'I', 'Z', 'H'), wiz.data, state, false);
+ assert(data);
+
+ int stateCompressionType = READ_LE_UINT32(data);
+
+ if (!canMoonbaseDrawWizType(stateCompressionType)) {
+ return false;
+ }
+
+ // Use the layered renderer to do hit-tests, so that all compression
+ // types supported by the U32 are supported...
+ WizRawPixel16 chroma = ~0;
+
+ WizRawPixel16 pixel = chroma;
+
+ drawLayeredWiz((byte *)&pixel, 1, 1, sizeof(WizRawPixel16), 555, 16,
+ globPtr, -x, -y, state, 0, 0, 0, 0, flags, dwConditionBits, 0, 0);
+
+ if (chroma != pixel) {
+ *outValue = 1;
+ } else {
+ *outValue = 0;
+ }
+
+ if (pOptionalOutActualValue) {
+ *pOptionalOutActualValue = pixel;
+ }
+
+ return true;
+}
+
+void Wiz::handleCompositeDrawImage(
+ WizRawBitmap *bitmapPtr, WizImage *wizPtr, byte *compositeInfoBlockPtr,
+ int x, int y, Common::Rect *srcRect, Common::Rect *clipRect,
+ int32 flags, int32 conditionBits, int32 outerSizeX, int32 outerSizeY,
+ WizRawPixel16 *p8BppToXBppClut, byte *pAltSourceBuffer) {
+
+ int layerCount, xPos, yPos, subState, cmdSize;
+ int32 layerConditionBits, layerCmdDataBits;
+ int32 subConditionBits, drawFlags;
+ WizImage nestedMultiStateWiz;
+ byte *nestedBlockHeader;
+ byte *nestedWizHeader;
+ byte *cmdPtr;
+ int32 conditionType;
+ int32 stateSizeX = 0, stateSizeY = 0;
+
+ // Get the nested block...
+
+ nestedBlockHeader = _vm->heFindResource(MKTAG('N', 'E', 'S', 'T'), wizPtr->data);
+
+ if (!nestedBlockHeader) {
+ return;
+ }
+
+ // Get the real nested wiz...
+ nestedWizHeader = _vm->heFindResource(MKTAG('M', 'U', 'L', 'T'), nestedBlockHeader);
+
+ if (!nestedWizHeader) {
+ return;
+ }
+
+ // Build a fake wiz header...
+ nestedMultiStateWiz.data = nestedWizHeader;
+ nestedMultiStateWiz.dataSize = READ_BE_UINT32(nestedWizHeader + 4);
+
+ // Process the composite command block...
+ compositeInfoBlockPtr += _vm->_resourceHeaderSize;
+
+ // Get the number of layers in this command block...
+ layerCount = READ_LE_UINT16(compositeInfoBlockPtr);
+ compositeInfoBlockPtr += 2;
+
+
+ // Deal with the moonbase 'system' bits...
+ int32 defaultSubConditionBits = (conditionBits & kWMSBReservedBits);
+ conditionBits &= ~kWMSBReservedBits;
+
+ // Process each layer...
+ for (int layerCounter = 0; layerCounter < layerCount; layerCounter++) {
+ // Get the command and move down by the cmd size
+ cmdSize = READ_LE_UINT16(compositeInfoBlockPtr);
+ cmdPtr = compositeInfoBlockPtr + 2;
+ compositeInfoBlockPtr += (cmdSize + 2);
+
+ // Get the cmd flags
+ layerCmdDataBits = READ_LE_UINT32(cmdPtr);
+ cmdPtr += 4;
+
+ // Check for condition bits
+ if (layerCmdDataBits & kWCFConditionBits) {
+ layerConditionBits = READ_LE_UINT32(cmdPtr);
+ cmdPtr += 4;
+
+ // Check to see if the layer overrides the default system bits
+ subConditionBits = (layerConditionBits & kWMSBReservedBits);
+ layerConditionBits &= ~kWMSBReservedBits;
+
+ if (subConditionBits == 0) {
+ subConditionBits = defaultSubConditionBits;
+ }
+
+ // Get the condition bits and strip them from the bits...
+ conditionType = (layerConditionBits & kWSPCCTBits);
+ layerConditionBits &= ~kWSPCCTBits;
+
+ // Perform the actual compare for the bits...
+ switch (conditionType) {
+
+ default:
+ case kWSPCCTOr:
+ if (!(layerConditionBits & conditionBits)) {
+ continue;
+ }
+
+ break;
+
+ case kWSPCCTAnd:
+ if (layerConditionBits != (layerConditionBits & conditionBits)) {
+ continue;
+ }
+
+ break;
+
+ case kWSPCCTNot:
+ if (layerConditionBits & conditionBits) {
+ continue;
+ }
+
+ break;
+ }
+ } else {
+ subConditionBits = defaultSubConditionBits;
+ }
+
+ // Get the sub state
+ if (layerCmdDataBits & kWCFSubState) {
+ subState = READ_LE_UINT16(cmdPtr);
+ cmdPtr += 2;
+ } else {
+ subState = 0;
+ }
+
+ // Get the X delta
+ if (layerCmdDataBits & kWCFXDelta) {
+ xPos = (int16)READ_LE_UINT16(cmdPtr);
+ cmdPtr += 2;
+ } else {
+ xPos = 0;
+ }
+
+ // Get the Y delta
+ if (layerCmdDataBits & kWCFYDelta) {
+ yPos = (int16)READ_LE_UINT16(cmdPtr);
+ cmdPtr += 2;
+ } else {
+ yPos = 0;
+ }
+
+ // Get the drawing flags
+ if (layerCmdDataBits & kWCFDrawFlags) {
+ drawFlags = READ_LE_UINT32(cmdPtr);
+ cmdPtr += 4;
+ } else {
+ drawFlags = flags;
+ }
+
+ // Based on the drawing flags adjust the blit position
+ if (drawFlags & (kWRFHFlip | kWRFVFlip)) {
+ int32 compressionType = 0;
+ if (!getMoonbaseWizSizeAndType(_vm, &nestedMultiStateWiz, subState, stateSizeX, stateSizeY, compressionType)) {
+ return;
+ }
+ }
+
+ if (drawFlags & kWRFHFlip) {
+ xPos = (outerSizeX - (xPos + stateSizeX));
+ }
+
+ if (drawFlags & kWRFVFlip) {
+ yPos = (outerSizeY - (yPos + stateSizeY));
+ }
+
+ // Are there any sub condition bits?
+ if (layerCmdDataBits & kWCFSubConditionBits) {
+ subConditionBits = READ_LE_UINT32(cmdPtr);
+ cmdPtr += 4;
+ } else {
+ subConditionBits = 0;
+ }
+
+ // Finally do the actual command...
+ drawImageEx(
+ bitmapPtr, &nestedMultiStateWiz, (x + xPos), (y + yPos), subState, clipRect,
+ drawFlags, nullptr, subConditionBits, p8BppToXBppClut, pAltSourceBuffer);
+ }
+}
+
} // End of namespace Scumm
diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp
index 4c0e08d16cf..c8c10824171 100644
--- a/engines/scumm/he/wiz_he.cpp
+++ b/engines/scumm/he/wiz_he.cpp
@@ -612,12 +612,11 @@ int Wiz::pixelHitTestWiz(int image, int state, int x, int y, int32 flags) {
}
int Wiz::pixelHitTestWizPrim(int globNum, int state, int x, int y, int32 flags) {
- // U32 TODO
- //int outValue = 0;
- //
- //if (PU_OverrideImagePixelHitTest(&outValue, globType, globNum, state, x, y, flags)) {
- // return outValue;
- //}
+ int outValue = 0;
+
+ if (((ScummEngine_v90he *)_vm)->_logicHE && ((ScummEngine_v90he *)_vm)->_logicHE->overrideImagePixelHitTest(&outValue, globNum, state, x, y, flags)) {
+ return outValue;
+ }
int srcComp, srcWidth, srcHeight;
byte *srcData;
@@ -696,12 +695,11 @@ int Wiz::hitTestWizPrim(int globNum, int state, int x, int y, int32 flags) {
const byte *headerPtr;
byte *dataTmp = nullptr;
- // U32 TODO
- //int outValue = 0;
- //
- //if (PU_OverrideImageHitTest(&outValue, globType, globNum, state, x, y, flags)) {
- // return outValue;
- //}
+ int outValue = 0;
+
+ if (((ScummEngine_v90he *)_vm)->_logicHE && ((ScummEngine_v90he *)_vm)->_logicHE->overrideImageHitTest(&outValue, globNum, state, x, y, flags)) {
+ return outValue;
+ }
if (_vm->_game.heversion == 80) {
dataTmp = _vm->getResourceAddress(rtImage, globNum);
@@ -2612,11 +2610,9 @@ void Wiz::processWizImageSaveCmd(const WizImageCommand *params) {
}
void Wiz::processWizImageCmd(const WizImageCommand *params) {
- // TODO
- if (((ScummEngine_v90he *)_vm)->_logicHE->userCodeProcessWizImageCmd(params)) {
+ if (((ScummEngine_v90he *)_vm)->_logicHE && ((ScummEngine_v90he *)_vm)->_logicHE->userCodeProcessWizImageCmd(params)) {
return;
}
- //debug(5, "Wiz::processWizImageCmd(): actionType %d for image %d", params->actionType, params->image);
switch (params->actionType) {
case kWAUnknown:
diff --git a/engines/scumm/he/wiz_he.h b/engines/scumm/he/wiz_he.h
index 6933ac59f1c..fcdb65e39e3 100644
--- a/engines/scumm/he/wiz_he.h
+++ b/engines/scumm/he/wiz_he.h
@@ -660,6 +660,12 @@ public:
int x, const int y, int state, int clip_x1, int clip_y1, int clip_x2, int clip_y2,
uint32 dwFlags, uint32 dwConditionBits, byte *p8BppToXBppClut, byte *pAltSourceBuffer);
+ void handleCompositeDrawImage(
+ WizRawBitmap *bitmapPtr, WizImage *wizPtr, byte *compositeInfoBlockPtr,
+ int x, int y, Common::Rect *srcRect, Common::Rect *clipRect,
+ int32 flags, int32 conditionBits, int32 outerSizeX, int32 outerSizeY,
+ WizRawPixel16 *p8BppToXBppClut, byte *pAltSourceBuffer);
+
void drawImageEx(
WizRawBitmap *bitmapPtr, WizImage *wizPtr, int x, int y, int state,
Common::Rect *clipRectPtr, int32 flags, Common::Rect *optionalSrcRect,
@@ -675,6 +681,8 @@ public:
WizRawPixel16 *bufferPtr, int bufferWidth, Common::Rect *destRect, byte *compData, Common::Rect *sourceRect, byte *extraPtr,
void (*functionPtr)(Wiz *wiz, WizRawPixel *destPtr, byte *dataStream, int skipAmount, int decompAmount, byte *extraPtr));
+ bool layeredWizHitTest(int32 *outValue, uint32 *pOptionalOutActualValue, byte *globPtr, int state, int x, int y, int32 flags, int32 dwConditionBits);
+
private:
ScummEngine_v71he *_vm;
Commit: ea66c16d3c653bd15325507bdf8643d9704c2750
https://github.com/scummvm/scummvm/commit/ea66c16d3c653bd15325507bdf8643d9704c2750
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Clean up and finish hooking up external U32 prototypes
Changed paths:
engines/scumm/he/logic/moonbase_logic.cpp
engines/scumm/he/logic_he.h
engines/scumm/he/moonbase/moonbase_fow.cpp
engines/scumm/he/moonbase/moonbase_gfx.cpp
engines/scumm/he/script_v100he.cpp
engines/scumm/he/sprite_he.cpp
engines/scumm/he/sprite_he.h
engines/scumm/he/wiz_he.h
diff --git a/engines/scumm/he/logic/moonbase_logic.cpp b/engines/scumm/he/logic/moonbase_logic.cpp
index a98cd548d4a..cc223488b4a 100644
--- a/engines/scumm/he/logic/moonbase_logic.cpp
+++ b/engines/scumm/he/logic/moonbase_logic.cpp
@@ -424,7 +424,7 @@ bool LogicHEmoonbase::userCodeProcessWizImageCmd(const WizImageCommand *params)
(_vm1->_moonbase->_fowSentinelState != state) ||
(_vm1->_moonbase->_fowSentinelConditionBits != (uint32)params->extendedRenderInfo.conditionBits)) {
- if (!_vm->_wiz->drawLayeredWiz(
+ if (!_vm->_wiz->drawMoonbaseLayeredWiz(
mappedMultiBM.data,
mappedMultiBM.width, mappedMultiBM.height,
mappedMultiBM.stride, mappedMultiBM.format, mappedMultiBM.bpp,
@@ -463,7 +463,7 @@ bool LogicHEmoonbase::overrideImageHitTest(int *outValue, int globNum, int state
return false;
}
- if (!_vm->_wiz->layeredWizHitTest(outValue, 0, globPtr, state, x, y, flags, 0)) {
+ if (!_vm->_wiz->moonbaseLayeredWizHitTest(outValue, 0, globPtr, state, x, y, flags, 0)) {
return false;
}
@@ -479,10 +479,10 @@ bool LogicHEmoonbase::overrideImagePixelHitTest(int *outValue, int globNum, int
return false;
}
- uint32 actualValue = ~0;
+ int32 actualValue = ~0;
int32 eatValue = 0;
- if (!_vm->_wiz->layeredWizHitTest(&eatValue, &actualValue, globPtr, state, x, y, flags, 0)) {
+ if (!_vm->_wiz->moonbaseLayeredWizHitTest(&eatValue, &actualValue, globPtr, state, x, y, flags, 0)) {
return false;
}
diff --git a/engines/scumm/he/logic_he.h b/engines/scumm/he/logic_he.h
index 6508ec20fa2..abadd87ee6a 100644
--- a/engines/scumm/he/logic_he.h
+++ b/engines/scumm/he/logic_he.h
@@ -49,6 +49,12 @@ public:
virtual bool userCodeProcessWizImageCmd(const WizImageCommand *icmdPtr) { return false; }
virtual bool overrideImageHitTest(int *outValue, int globNum, int state, int x, int y, int32 flags) { return false; }
virtual bool overrideImagePixelHitTest(int *outValue, int globNum, int state, int x, int y, int32 flags) { return false; }
+ virtual bool getSpriteProperty(int sprite, int property, int *outValue) { return false; }
+ virtual bool setSpriteProperty(int sprite, int property, int value) { return false; }
+ virtual bool getGroupProperty(int group, int property, int *outValue) { return false; }
+ virtual void spriteNewHook(int sprite) {}
+ virtual void groupNewHook(int group) {}
+
protected:
// Only to be used from makeLogicHE()
diff --git a/engines/scumm/he/moonbase/moonbase_fow.cpp b/engines/scumm/he/moonbase/moonbase_fow.cpp
index ecc3e4f0ae6..d0f8e541594 100644
--- a/engines/scumm/he/moonbase/moonbase_fow.cpp
+++ b/engines/scumm/he/moonbase/moonbase_fow.cpp
@@ -332,7 +332,7 @@ void Moonbase::renderFOWState(WizMultiTypeBitmap *destSurface,int x, int y, int
_vm->_wiz->getWizImageSpot(_fowImage, state, spotx, spoty);
- _vm->_wiz->drawLayeredWiz(
+ _vm->_wiz->drawMoonbaseLayeredWiz(
destSurface->data,
destSurface->width, destSurface->height,
destSurface->stride, destSurface->format, destSurface->bpp,
diff --git a/engines/scumm/he/moonbase/moonbase_gfx.cpp b/engines/scumm/he/moonbase/moonbase_gfx.cpp
index 284521ddc13..3676f1f5ddb 100644
--- a/engines/scumm/he/moonbase/moonbase_gfx.cpp
+++ b/engines/scumm/he/moonbase/moonbase_gfx.cpp
@@ -93,8 +93,8 @@ namespace Scumm {
}
static bool canMoonbaseDrawWizType(int compressionType) {
- return (kWCTTRLE16Bpp == compressionType) ||
- (kWCTComposite == compressionType) ||
+ return (kWCTTRLE16Bpp == compressionType) ||
+ (kWCTComposite == compressionType) ||
(kWCTDataBlockDependent == compressionType);
}
@@ -116,19 +116,18 @@ static bool getMoonbaseWizSizeAndType(ScummEngine_v71he *vm, WizImage *wizPtr, i
return true;
}
-bool Wiz::drawLayeredWiz(
- byte *pDstBitmapData, int nDstWidth, int nDstHeight, int nDstPitch,
- int nDstFormat, int nDstBpp, byte *pWizImageData,
- int x, const int y, int state, int clip_x1, int clip_y1, int clip_x2, int clip_y2,
- uint32 dwFlags, uint32 dwConditionBits, byte *p8BppToXBppClut, byte *pAltSourceBuffer) {
+bool Wiz::drawMoonbaseLayeredWiz(
+ byte *dstBitmapData, int dstWidth, int dstHeight, int dstPitch,
+ int dstFormat, int dstBpp, byte *wizImageData,
+ int x, const int y, int state, int clipX1, int clipY1, int clipX2, int clipY2,
+ uint32 flags, uint32 conditionBits, byte *ptr8BppToXBppClut, byte *altSourceBuffer) {
- // Build a header to use with the WTOOLKIT functions
WizImage wiz;
- wiz.data = pWizImageData;
+ wiz.data = wizImageData;
wiz.dataSize = READ_BE_UINT32(wiz.data + 4);
- // Check to see if this is a compression type we like
+ // Check to see if this is a valid compression type...
byte *data = _vm->findWrappedBlock(MKTAG('W', 'I', 'Z', 'H'), wiz.data, state, false);
assert(data);
@@ -141,12 +140,12 @@ bool Wiz::drawLayeredWiz(
// Make sure we can map the multitype bitmap to a rawbitmap...
WizRawBitmap mappedRawbitmap;
- mappedRawbitmap.data = (WizRawPixel16 *)pDstBitmapData;
- mappedRawbitmap.width = nDstWidth;
- mappedRawbitmap.height = nDstHeight;
+ mappedRawbitmap.data = (WizRawPixel16 *)dstBitmapData;
+ mappedRawbitmap.width = dstWidth;
+ mappedRawbitmap.height = dstHeight;
mappedRawbitmap.dataSize = (mappedRawbitmap.width * sizeof(WizRawPixel16)) * mappedRawbitmap.height;
- if (nDstPitch != (mappedRawbitmap.width * sizeof(WizRawPixel16))) {
+ if (dstPitch != (mappedRawbitmap.width * sizeof(WizRawPixel16))) {
return false;
}
@@ -154,19 +153,19 @@ bool Wiz::drawLayeredWiz(
// We are not directly assigning the rectangle values
// in the constructor: the game can (and will!) assign
// values which will trigger the "invalid rectangle" assertion...
- clipRect.left = clip_x1;
- clipRect.top = clip_y1;
- clipRect.right = clip_x2;
- clipRect.bottom = clip_y2;
+ clipRect.left = clipX1;
+ clipRect.top = clipY1;
+ clipRect.right = clipX2;
+ clipRect.bottom = clipY2;
- // Dispatch to the WToolkit image renderer
- drawImageEx(&mappedRawbitmap, &wiz, x, y, state, &clipRect, dwFlags, nullptr, dwConditionBits, (WizRawPixel16 *)p8BppToXBppClut, pAltSourceBuffer);
+ // Dispatch to the image renderer...
+ drawMoonbaseImageEx(&mappedRawbitmap, &wiz, x, y, state, &clipRect, flags, nullptr, conditionBits, (WizRawPixel16 *)ptr8BppToXBppClut, altSourceBuffer);
- // Assume if we're here that we did something
+ // Assume if we're here that we did something...
return true;
}
-void Wiz::drawImageEx(
+void Wiz::drawMoonbaseImageEx(
WizRawBitmap *bitmapPtr, WizImage *wizPtr, int x, int y, int state,
Common::Rect *clipRectPtr, int32 flags, Common::Rect *optionalSrcRect,
int32 conditionBits, WizRawPixel16 *ptr8BppToXBppClut, byte *altSourceBuffer) {
@@ -240,7 +239,7 @@ void Wiz::drawImageEx(
// Finally dispatch to the T14 handler
//DISPATCH_Blit_RGB555(bitmapPtr->data, bitmapPtr->width, bitmapPtr->height,
// (bitmapPtr->width * sizeof(WizRawPixel16)), targetClippingRect,
- // pCompressedDataPtr, x, y, nROP, nROPParam, altSourceBuffer);
+ // compressedDataPtr, x, y, nROP, nROPParam, altSourceBuffer);
}
} else {
byte *wizdBlockPtr = _vm->findWrappedBlock(MKTAG('W', 'I', 'Z', 'D'), wizPtr->data, state, false) - _vm->_resourceHeaderSize;
@@ -263,22 +262,19 @@ void Wiz::drawImageEx(
}
}
- // Get down to business and draw this image :-)
+ // Get down to business and draw the image...
switch (stateCompressionType) {
case kWCTNone:
break; // Explicitly unhandled
case kWCTTRLE:
if (ptr8BppToXBppClut) {
- error("Hey! This is actually used, implement it!");
- //TRLEFLIP_Decompress8BppToXBpp(
- // bitmapPtr, &fakedHeader, x, y, &src, clipRectPtr, flags,
- // p8BppToXBppClut);
+ error("Wiz::drawMoonbaseImageEx(): unimplemented development path trleFLIPDecompress8BppToXBpp()!");
}
break;
case kWCTNone16Bpp:
- if (getRawBitmapInfoForState(&fakedBitmap, wizPtr, state)) {
+ if (getRawMoonbaseBitmapInfoForState(&fakedBitmap, wizPtr, state)) {
makeSizedRectAt(&dstRect, x, y, getRectWidth(&src), getRectHeight(&src));
if (flags & kWRFHFlip) {
@@ -290,12 +286,12 @@ void Wiz::drawImageEx(
}
// How should transparency be managed?
- rawBitmapBlit(bitmapPtr, &dstRect, &fakedBitmap, &src);
+ rawMoonbaseBitmapBlit(bitmapPtr, &dstRect, &fakedBitmap, &src);
}
break;
case kWCTComposite:
- handleCompositeDrawImage(
+ handleCompositeDrawMoonbaseImage(
bitmapPtr, wizPtr, wizdBlockPtr, x, y, &src, clipRectPtr, flags,
conditionBits, sizeX, sizeY, ptr8BppToXBppClut, altSourceBuffer);
@@ -313,30 +309,30 @@ void Wiz::drawImageEx(
}
}
-bool Wiz::getRawBitmapInfoForState(WizRawBitmap *bitmapPtr, WizImage *wizPtr, int state) {
+bool Wiz::getRawMoonbaseBitmapInfoForState(WizRawBitmap *bitmapPtr, WizImage *wizPtr, int state) {
byte *workPtr;
int32 sizeX, sizeY, compType;
bool wizValid = getMoonbaseWizSizeAndType(_vm, wizPtr, state, sizeX, sizeY, compType);
- // Make sure the compression type is RAW
+ // Make sure this is a raw image...
if (compType != kWCTNone16Bpp) {
return false;
}
- // Make sure that the wiz has size
+ // Make sure that the Wiz is valid...
if (!wizValid) {
return false;
}
- // Get the data block for the state
+ // Get the data block for the state...
workPtr = _vm->findWrappedBlock(MKTAG('W', 'I', 'Z', 'H'), wizPtr->data, state, false);
if (!workPtr) {
return false;
}
- // Build the bitmap struct for this state.
+ // Build the bitmap struct for this state...
bitmapPtr->data = (WizRawPixel16 *)workPtr;
bitmapPtr->dataSize = sizeX * sizeY;
bitmapPtr->width = sizeX;
@@ -345,7 +341,7 @@ bool Wiz::getRawBitmapInfoForState(WizRawBitmap *bitmapPtr, WizImage *wizPtr, in
return true;
}
-void Wiz::rawBitmapBlit(WizRawBitmap *dstBitmap, Common::Rect *dstRectPtr, WizRawBitmap *srcBitmap, Common::Rect *srcRectPtr) {
+void Wiz::rawMoonbaseBitmapBlit(WizRawBitmap *dstBitmap, Common::Rect *dstRectPtr, WizRawBitmap *srcBitmap, Common::Rect *srcRectPtr) {
Common::Rect clipRect, dstRect, srcRect;
int x, cw, dw, sw, ch, dxm, dym, ca;
WizRawPixel16 *s;
@@ -570,7 +566,7 @@ void Wiz::trleFLIPDecompMoonbaseImageHull(
}
}
-bool Wiz::layeredWizHitTest(int32 *outValue, uint32 *pOptionalOutActualValue, byte *globPtr, int state, int x, int y, int32 flags, int32 dwConditionBits) {
+bool Wiz::moonbaseLayeredWizHitTest(int32 *outValue, int32 *optionalOutActualValue, byte *globPtr, int state, int x, int y, int32 flags, int32 conditionBits) {
WizImage wiz;
wiz.data = globPtr;
@@ -592,8 +588,8 @@ bool Wiz::layeredWizHitTest(int32 *outValue, uint32 *pOptionalOutActualValue, by
WizRawPixel16 pixel = chroma;
- drawLayeredWiz((byte *)&pixel, 1, 1, sizeof(WizRawPixel16), 555, 16,
- globPtr, -x, -y, state, 0, 0, 0, 0, flags, dwConditionBits, 0, 0);
+ drawMoonbaseLayeredWiz((byte *)&pixel, 1, 1, sizeof(WizRawPixel16), 555, 16,
+ globPtr, -x, -y, state, 0, 0, 0, 0, flags, conditionBits, 0, 0);
if (chroma != pixel) {
*outValue = 1;
@@ -601,18 +597,18 @@ bool Wiz::layeredWizHitTest(int32 *outValue, uint32 *pOptionalOutActualValue, by
*outValue = 0;
}
- if (pOptionalOutActualValue) {
- *pOptionalOutActualValue = pixel;
+ if (optionalOutActualValue) {
+ *optionalOutActualValue = pixel;
}
return true;
}
-void Wiz::handleCompositeDrawImage(
+void Wiz::handleCompositeDrawMoonbaseImage(
WizRawBitmap *bitmapPtr, WizImage *wizPtr, byte *compositeInfoBlockPtr,
int x, int y, Common::Rect *srcRect, Common::Rect *clipRect,
int32 flags, int32 conditionBits, int32 outerSizeX, int32 outerSizeY,
- WizRawPixel16 *p8BppToXBppClut, byte *pAltSourceBuffer) {
+ WizRawPixel16 *ptr8BppToXBppClut, byte *altSourceBuffer) {
int layerCount, xPos, yPos, subState, cmdSize;
int32 layerConditionBits, layerCmdDataBits;
@@ -769,9 +765,9 @@ void Wiz::handleCompositeDrawImage(
}
// Finally do the actual command...
- drawImageEx(
+ drawMoonbaseImageEx(
bitmapPtr, &nestedMultiStateWiz, (x + xPos), (y + yPos), subState, clipRect,
- drawFlags, nullptr, subConditionBits, p8BppToXBppClut, pAltSourceBuffer);
+ drawFlags, nullptr, subConditionBits, ptr8BppToXBppClut, altSourceBuffer);
}
}
diff --git a/engines/scumm/he/script_v100he.cpp b/engines/scumm/he/script_v100he.cpp
index fd62ccc03a4..2b75a491dcf 100644
--- a/engines/scumm/he/script_v100he.cpp
+++ b/engines/scumm/he/script_v100he.cpp
@@ -2522,11 +2522,11 @@ void ScummEngine_v100he::o100_getSpriteGroupInfo() {
push(0);
break;
case SO_NEW_GENERAL_PROPERTY:
- // TODO: U32 related
- pop();
- pop();
- push(0);
- warning("STUB: o100_getSpriteGroupInfo, subop 54");
+ type = pop();
+ if (spriteGroupId = pop())
+ push(_sprite->getGroupGeneralProperty(spriteGroupId, type));
+ else
+ push(0);
break;
case SO_PRIORITY:
spriteGroupId = pop();
diff --git a/engines/scumm/he/sprite_he.cpp b/engines/scumm/he/sprite_he.cpp
index cab242ff62e..76dec28880a 100644
--- a/engines/scumm/he/sprite_he.cpp
+++ b/engines/scumm/he/sprite_he.cpp
@@ -21,6 +21,7 @@
#ifdef ENABLE_HE
+#include "scumm/he/logic_he.h"
#include "scumm/he/intern_he.h"
#include "scumm/resource.h"
#include "scumm/scumm.h"
@@ -378,7 +379,11 @@ int Sprite::getSpriteGeneralProperty(int spriteId, int type) {
debug(7, "getSpriteGeneralProperty: spriteId %d type 0x%x", spriteId, type);
assertRange(1, spriteId, _maxSprites, "sprite");
- // TODO U32
+ int outValue = 0;
+
+ if (((ScummEngine_v90he *)_vm)->_logicHE && ((ScummEngine_v90he *)_vm)->_logicHE->getSpriteProperty(spriteId, type, &outValue)) {
+ return outValue;
+ }
switch (type) {
case SPRPROP_SPECIAL_RENDER_FLAGS:
@@ -645,6 +650,18 @@ void Sprite::getGroupPoint(int spriteGroupId, int32 &tx, int32 &ty) {
ty = _groupTable[spriteGroupId].posY;
}
+int Sprite::getGroupGeneralProperty(int spriteGroupId, int property) {
+ assertRange(1, spriteGroupId, _maxSpriteGroups, "sprite group");
+
+ int outValue = 0;
+
+ if (((ScummEngine_v90he *)_vm)->_logicHE && ((ScummEngine_v90he *)_vm)->_logicHE->getGroupProperty(spriteGroupId, property, &outValue)) {
+ return outValue;
+ }
+
+ return 0;
+}
+
//
// spriteInfoSet functions
//
@@ -928,10 +945,10 @@ void Sprite::setSpriteAnimSpeedState(int spriteId, int animState) {
}
void Sprite::setSpriteGeneralProperty(int spriteId, int property, int value) {
- // TODO U32
- //if (PU_SetSpriteProperty(spriteId, property, value)) {
- // return;
- //}
+ if (((ScummEngine_v90he *)_vm)->_logicHE && ((ScummEngine_v90he *)_vm)->_logicHE->setSpriteProperty(spriteId, property, value)) {
+ return;
+ }
+
debug(7, "setSpriteGeneralProperty: spriteId %d type 0x%x value 0x%x", spriteId, property, value);
assertRange(1, spriteId, _maxSprites, "sprite");
@@ -983,7 +1000,9 @@ void Sprite::newSprite(int sprite) {
_spriteTable[sprite].conditionBits = 0;
_spriteTable[sprite].specialRenderFlags = 0;
- // TODO U32 PU_SpriteNewHook(sprite);
+
+ if (((ScummEngine_v90he *)_vm)->_logicHE)
+ ((ScummEngine_v90he *)_vm)->_logicHE->spriteNewHook(sprite);
}
}
}
@@ -1338,10 +1357,10 @@ void Sprite::newGroup(int group) {
setGroupImage(group, 0);
clearGroupScaleInfo(group);
- // TODO U32
- // if (_vm->_game.heversion > 99 || _vm->_isHE995) {
- // PU_GroupNewHook(group);
- // }
+
+ if (((ScummEngine_v90he *)_vm)->_logicHE) {
+ ((ScummEngine_v90he *)_vm)->_logicHE->groupNewHook(group);
+ }
}
void Sprite::resetSpriteSystem(bool eraseScreen) {
diff --git a/engines/scumm/he/sprite_he.h b/engines/scumm/he/sprite_he.h
index 8ec4ef325bb..e8983ebfab9 100644
--- a/engines/scumm/he/sprite_he.h
+++ b/engines/scumm/he/sprite_he.h
@@ -284,6 +284,7 @@ public:
int getGroupYMul(int spriteGroupId);
int getGroupYDiv(int spriteGroupId);
void getGroupPoint(int spriteGroupId, int32 &tx, int32 &ty);
+ int getGroupGeneralProperty(int group, int property);
void setSpritePalette(int spriteId, int value);
void setSourceImage(int spriteId, int value);
diff --git a/engines/scumm/he/wiz_he.h b/engines/scumm/he/wiz_he.h
index fcdb65e39e3..1ba729a6f78 100644
--- a/engines/scumm/he/wiz_he.h
+++ b/engines/scumm/he/wiz_he.h
@@ -654,25 +654,25 @@ public:
* These are defined in moonbase/moonbase_layered_wiz.cpp
*/
- bool drawLayeredWiz(
+ bool drawMoonbaseLayeredWiz(
byte *pDstBitmapData, int nDstWidth, int nDstHeight, int nDstPitch,
int nDstFormat, int nDstBpp, byte *pWizImageData,
int x, const int y, int state, int clip_x1, int clip_y1, int clip_x2, int clip_y2,
uint32 dwFlags, uint32 dwConditionBits, byte *p8BppToXBppClut, byte *pAltSourceBuffer);
- void handleCompositeDrawImage(
+ void handleCompositeDrawMoonbaseImage(
WizRawBitmap *bitmapPtr, WizImage *wizPtr, byte *compositeInfoBlockPtr,
int x, int y, Common::Rect *srcRect, Common::Rect *clipRect,
int32 flags, int32 conditionBits, int32 outerSizeX, int32 outerSizeY,
WizRawPixel16 *p8BppToXBppClut, byte *pAltSourceBuffer);
- void drawImageEx(
+ void drawMoonbaseImageEx(
WizRawBitmap *bitmapPtr, WizImage *wizPtr, int x, int y, int state,
Common::Rect *clipRectPtr, int32 flags, Common::Rect *optionalSrcRect,
int32 conditionBits, WizRawPixel16 *p8BppToXBppClut, byte *pAltSourceBuffer);
- bool getRawBitmapInfoForState(WizRawBitmap *bitmapPtr, WizImage *wizPtr, int state);
- void rawBitmapBlit(WizRawBitmap *dstBitmap, Common::Rect *dstRectPtr, WizRawBitmap *srcBitmap, Common::Rect *srcRectPtr);
+ bool getRawMoonbaseBitmapInfoForState(WizRawBitmap *bitmapPtr, WizImage *wizPtr, int state);
+ void rawMoonbaseBitmapBlit(WizRawBitmap *dstBitmap, Common::Rect *dstRectPtr, WizRawBitmap *srcBitmap, Common::Rect *srcRectPtr);
void trleFLIPDecompressMoonbaseImage(
WizRawBitmap *bitmapPtr, WizMoonbaseCompressedImage *imagePtr, int destX, int destY,
@@ -681,7 +681,7 @@ public:
WizRawPixel16 *bufferPtr, int bufferWidth, Common::Rect *destRect, byte *compData, Common::Rect *sourceRect, byte *extraPtr,
void (*functionPtr)(Wiz *wiz, WizRawPixel *destPtr, byte *dataStream, int skipAmount, int decompAmount, byte *extraPtr));
- bool layeredWizHitTest(int32 *outValue, uint32 *pOptionalOutActualValue, byte *globPtr, int state, int x, int y, int32 flags, int32 dwConditionBits);
+ bool moonbaseLayeredWizHitTest(int32 *outValue, int32 *pOptionalOutActualValue, byte *globPtr, int state, int x, int y, int32 flags, int32 dwConditionBits);
private:
ScummEngine_v71he *_vm;
Commit: bdc1608f8799baa7cd9a098cd06dd62a04207c65
https://github.com/scummvm/scummvm/commit/bdc1608f8799baa7cd9a098cd06dd62a04207c65
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Clean-up and removal of development functions
These functions are called within a room called "lab", which is part of
some kind of internal development editor used to test several types of
textures and their blending. This room was not compiled into the final game.
Changed paths:
engines/scumm/he/logic/moonbase_logic.cpp
diff --git a/engines/scumm/he/logic/moonbase_logic.cpp b/engines/scumm/he/logic/moonbase_logic.cpp
index cc223488b4a..17402dd6429 100644
--- a/engines/scumm/he/logic/moonbase_logic.cpp
+++ b/engines/scumm/he/logic/moonbase_logic.cpp
@@ -176,6 +176,8 @@ int LogicHEmoonbase::startOfFrame() {
int32 LogicHEmoonbase::dispatch(int op, int numArgs, int32 *args) {
switch (op) {
+ // Development kludge commands which are called within a room
+ // which is not compiled into the final game files
case OP_CREATE_MULTI_STATE_WIZ:
return op_create_multi_state_wiz(op, numArgs, args);
case OP_LOAD_MULTI_CHANNEL_WIZ:
@@ -185,6 +187,8 @@ int32 LogicHEmoonbase::dispatch(int op, int numArgs, int32 *args) {
case OP_DOS_COMMAND:
op_dos_command(op, numArgs, args);
break;
+
+ // "Fog of war" commands
case OP_SET_FOW_SENTINEL:
op_set_fow_sentinel(args);
break;
@@ -194,6 +198,7 @@ int32 LogicHEmoonbase::dispatch(int op, int numArgs, int32 *args) {
case OP_SET_FOW_IMAGE:
return op_set_fow_image(op, numArgs, args);
+ // AI commands
case OP_AI_TEST_KLUDGE:
op_ai_test_kludge(op, numArgs, args);
break;
@@ -210,6 +215,7 @@ int32 LogicHEmoonbase::dispatch(int op, int numArgs, int32 *args) {
break;
#ifdef USE_ENET
+ // Network commands
case OP_NET_REMOTE_START_SCRIPT:
op_net_remote_start_script(op, numArgs, args);
break;
@@ -248,12 +254,10 @@ int32 LogicHEmoonbase::dispatch(int op, int numArgs, int32 *args) {
return op_net_get_session_player_count(op, numArgs, args);
case OP_NET_DESTROY_PLAYER:
return op_net_destroy_player(op, numArgs, args);
-#if 1 // 12/2/99 BPT
case OP_NET_GET_PLAYER_LONG_NAME:
return op_net_get_player_long_name(op, numArgs, args);
case OP_NET_GET_PLAYER_SHORT_NAME:
return op_net_get_player_short_name(op, numArgs, args);
-#endif
case OP_NET_CREATE_SESSION:
return op_net_create_session(op, numArgs, args);
case OP_NET_JOIN_SESSION:
@@ -492,55 +496,28 @@ bool LogicHEmoonbase::overrideImagePixelHitTest(int *outValue, int globNum, int
}
int LogicHEmoonbase::op_create_multi_state_wiz(int op, int numArgs, int32 *params) {
- //return MULTIWIZ::CreateUncompressedMultiStateWiz(
- // params[0], // image
- // params[1], // width
- // params[2], // height
- // params[3], // nStates
- // params[4], // bpp
- // params[5], // link-point-x
- // params[6] // link-point-y
- // ) ? 1 : 0;
- return 0;
+ debug("LogicHEmoonbase::op_create_multi_state_wiz(): Unused development command called by a script non compiled in the final game files, ignoring");
+ LogicHE::dispatch(op, numArgs, params);
+
+ return 1;
}
int LogicHEmoonbase::op_load_multi_channel_wiz(int op, int numArgs, int32 *params) {
- char filename[260];
-
- _vm1->getStringFromArray(params[1], filename, sizeof(filename));
-
- bool maskedImage = (params[3] != 0);
-
- //return MULTIWIZ::LoadMultiChannelWiz(
- // params[0] , // image
- // filename , // filename
- // params[2] , // bpp
- // maskedImage, // masked image
- // params[4] , // link-point-x
- // params[5] , // link-point-y
- // params[6] // extra channels
- //) ? 1 : 0;
- return 0;
+ debug("LogicHEmoonbase::op_load_multi_channel_wiz(): Unused development command called by a script non compiled in the final game files, ignoring");
+ LogicHE::dispatch(op, numArgs, params);
+
+ return 1;
}
int LogicHEmoonbase::op_wiz_from_multi_channel_wiz(int op, int numArgs, int32 *params) {
- //return MULTIWIZ::WizFromMultiChannelWiz(
- // params[0] , // dst image
- // params[1] , // dst state
- // params[2] , // src image
- // (0 != params[3]), // dither?
- // params[4] // r-channel-chromakey
- // ) ? 1 : 0;
- return 0;
+ debug("LogicHEmoonbase::op_wiz_from_multi_channel_wiz(): Unused development command called by a script non compiled in the final game files, ignoring");
+ LogicHE::dispatch(op, numArgs, params);
+
+ return 1;
}
void LogicHEmoonbase::op_dos_command(int op, int numArgs, int32 *params) {
- // Function which passed a command to the OS command line, unused
- char theCommand[4096];
-
- _vm1->getStringFromArray(params[0], theCommand, sizeof(theCommand));
-
- debug("LogicHEmoonbase::op_dos_command(): Unused command: op_dos_command() called with command %s", theCommand);
+ debug("LogicHEmoonbase::op_dos_command(): Unused development command called by a script non compiled in the final game files, ignoring");
LogicHE::dispatch(op, numArgs, params);
}
@@ -564,17 +541,17 @@ void LogicHEmoonbase::op_set_fow_information(int op, int numArgs, int32 *args) {
debug(2, "%s", str.c_str());
_vm1->_moonbase->setFOWInfo(
- args[0], // array
- args[1], // array down dimension
- args[2], // array across dimension
- args[3], // logical view X coordinate
- args[4], // logical view Y coordinate
- args[5], // screen draw clip rect x1
- args[6], // screen draw clip rect y1
- args[7], // screen draw clip rect x2
- args[8], // screen draw clip rect y2
- args[9], // techinque
- args[10] // frame
+ args[0], // array
+ args[1], // array down dimension
+ args[2], // array across dimension
+ args[3], // logical view X coordinate
+ args[4], // logical view Y coordinate
+ args[5], // screen draw clip rect x1
+ args[6], // screen draw clip rect y1
+ args[7], // screen draw clip rect x2
+ args[8], // screen draw clip rect y2
+ args[9], // techinque
+ args[10] // frame
);
}
Commit: 3cddf27f99abecff0927e1c99b3e43ede9188d1d
https://github.com/scummvm/scummvm/commit/3cddf27f99abecff0927e1c99b3e43ede9188d1d
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Reimplement Moonbase gfx T14 routine
Changed paths:
engines/scumm/he/moonbase/moonbase.cpp
engines/scumm/he/moonbase/moonbase.h
engines/scumm/he/moonbase/moonbase_gfx.cpp
engines/scumm/he/wiz_he.h
diff --git a/engines/scumm/he/moonbase/moonbase.cpp b/engines/scumm/he/moonbase/moonbase.cpp
index ad63cc09cd5..d58e313dee3 100644
--- a/engines/scumm/he/moonbase/moonbase.cpp
+++ b/engines/scumm/he/moonbase/moonbase.cpp
@@ -79,153 +79,4 @@ int Moonbase::callScummFunction(int scriptNumber, int paramCount,...) {
return _vm->pop();
}
-
-void Moonbase::blitT14WizImage(uint8 *dst, int dstw, int dsth, int dstPitch, const Common::Rect *clipBox,
- uint8 *wizd, int x, int y, int rawROP, int paramROP) {
- bool premulAlpa = false;
-
- if (rawROP == 1)
- premulAlpa = true;
-
- Common::Rect clippedDstRect(dstw, dsth);
- if (clipBox) {
- Common::Rect clip(clipBox->left, clipBox->top, clipBox->right, clipBox->bottom);
- if (clippedDstRect.intersects(clip)) {
- clippedDstRect.clip(clip);
- } else {
- return;
- }
- }
-
- int width = READ_LE_UINT16(wizd + 0x8 + 0);
- int height = READ_LE_UINT16(wizd + 0x8 + 2);
-
- Common::Rect srcLimitsRect(width, height);
- Common::Rect dstOperation(x, y, x + width, y + height);
- if (!clippedDstRect.intersects(dstOperation))
- return;
- Common::Rect clippedRect = clippedDstRect.findIntersectingRect(dstOperation);
-
- int cx = clippedRect.right - clippedRect.left;
- int cy = clippedRect.bottom - clippedRect.top;
-
- int sx = ((clippedRect.left - x) + srcLimitsRect.left);
- int sy = ((clippedRect.top - y) + srcLimitsRect.top);
-
- dst += clippedRect.top * dstPitch + clippedRect.left * 2;
-
- int headerSize = READ_LE_UINT32(wizd + 0x4);
- uint8 *dataPointer = wizd + 0x8 + headerSize;
-
- for (int i = 0; i < sy; i++) {
- uint16 lineSize = READ_LE_UINT16(dataPointer + 0);
-
- dataPointer += lineSize;
- }
-
- for (int i = 0; i < cy; i++) {
- uint16 lineSize = READ_LE_UINT16(dataPointer + 0);
- uint8 *singlesOffset = READ_LE_UINT16(dataPointer + 2) + dataPointer;
- uint8 *quadsOffset = READ_LE_UINT16(dataPointer + 4) + dataPointer;
-
- int pixels = 0;
- byte *dst1 = dst;
- byte *codes = dataPointer + 6;
-
- while (1) {
- int code = *codes - 2;
- codes++;
-
- if (code <= 0) { // quad or single
- uint8 *src;
- int cnt;
- if (code == 0) { // quad
- src = quadsOffset;
- quadsOffset += 8;
- cnt = 4; // 4 pixels
- } else { // single
- src = singlesOffset;
- singlesOffset += 2;
- cnt = 1;
- }
-
- for (int c = 0; c < cnt; c++) {
- if (pixels >= sx) {
- if (rawROP == 1) { // MMX_PREMUL_ALPHA_COPY
- WRITE_LE_UINT16(dst1, READ_LE_UINT16(src));
- } else if (rawROP == 2) { // MMX_ADDITIVE
- uint16 color = READ_LE_UINT16(src);
- uint16 orig = READ_LE_UINT16(dst1);
-
- uint32 r = MIN<uint32>(0x7c00, (orig & 0x7c00) + (color & 0x7c00));
- uint32 g = MIN<uint32>(0x03e0, (orig & 0x03e0) + (color & 0x03e0));
- uint32 b = MIN<uint32>(0x001f, (orig & 0x001f) + (color & 0x001f));
- WRITE_LE_UINT16(dst1, (r | g | b));
- } else if (rawROP == 5) { // MMX_CHEAP_50_50
- uint16 color = (READ_LE_UINT16(src) >> 1) & 0x3DEF;
- uint16 orig = (READ_LE_UINT16(dst1) >> 1) & 0x3DEF;
- WRITE_LE_UINT16(dst1, (color + orig));
- }
- dst1 += 2;
- }
- src += 2;
- pixels++;
- if (pixels >= cx + sx)
- break;
- }
- } else { // skip
- if ((code & 1) == 0) {
- code >>= 1;
-
- for (int j = 0; j < code; j++) {
- if (pixels >= sx)
- dst1 += 2;
- pixels++;
- if (pixels >= cx + sx)
- break;
- }
- } else { // special case
- if (pixels >= sx) {
- int alpha = code >> 1;
- uint16 color = READ_LE_UINT16(singlesOffset);
- uint32 orig = READ_LE_UINT16(dst1);
-
- if (!premulAlpa) {
- WRITE_LE_UINT16(dst1, color); // ENABLE_PREMUL_ALPHA = 0
- } else {
- if (alpha > 32) {
- alpha -= 32;
-
- uint32 oR = orig & 0x7c00;
- uint32 oG = orig & 0x03e0;
- uint32 oB = orig & 0x1f;
- uint32 dR = ((((color & 0x7c00) - oR) * alpha) >> 5) + oR;
- uint32 dG = ((((color & 0x3e0) - oG) * alpha) >> 5) + oG;
- uint32 dB = ((((color & 0x1f) - oB) * alpha) >> 5) + oB;
-
- WRITE_LE_UINT16(dst1, (dR & 0x7c00) | (dG & 0x3e0) | (dB & 0x1f));
- } else {
- uint32 pix = ((orig << 16) | orig) & 0x3e07c1f;
- pix = (((pix * alpha) & 0xffffffff) >> 5) & 0x3e07c1f;
- pix = ((pix >> 16) + pix + color) & 0xffff;
- WRITE_LE_UINT16(dst1, pix);
- }
- }
-
- dst1 += 2;
- }
- singlesOffset += 2;
- pixels++;
- }
- }
-
- if (pixels >= cx + sx)
- break;
- }
-
- dataPointer += lineSize;
- dst += dstPitch;
- }
-}
-
} // End of namespace Scumm
diff --git a/engines/scumm/he/moonbase/moonbase.h b/engines/scumm/he/moonbase/moonbase.h
index 6792a3e7069..0186b8d62a5 100644
--- a/engines/scumm/he/moonbase/moonbase.h
+++ b/engines/scumm/he/moonbase/moonbase.h
@@ -42,8 +42,6 @@ public:
void deallocateArray(int array);
int callScummFunction(int scriptNumber, int paramCount,...);
- void blitT14WizImage(uint8 *dst, int dstw, int dsth, int dstPitch, const Common::Rect *clipBox,
- uint8 *wizd, int srcx, int srcy, int rawROP, int paramROP);
void blitDistortion(byte *bufferData, const int bufferWidth, const int bufferHeight, const int bufferPitch,
const Common::Rect *optionalClippingRect, byte *dataStream, const int x, const int y, byte *altSourceBuffer);
diff --git a/engines/scumm/he/moonbase/moonbase_gfx.cpp b/engines/scumm/he/moonbase/moonbase_gfx.cpp
index 3676f1f5ddb..57b2f02e4bb 100644
--- a/engines/scumm/he/moonbase/moonbase_gfx.cpp
+++ b/engines/scumm/he/moonbase/moonbase_gfx.cpp
@@ -25,6 +25,14 @@
namespace Scumm {
+#define SIZE_OF_BPTLLC_VALIDATION_HEADER 8
+#define BPTLLC_CURRENT_DATA_REVISION 2
+#define BPTLLC_CURRENT_REVISION_MASK 0x000000FF
+
+#define BPTLLC_ID_T14_TYPE (uint32)(0x12340100 | (BPTLLC_CURRENT_DATA_REVISION))
+#define BPTLLC_ID_RAW_555_DISTORT_TYPE (uint32)(0x12340800 | (BPTLLC_CURRENT_DATA_REVISION))
+#define BPTLLC_ID_TRLE_555_DISTORT_TYPE (uint32)(0x12340900 | (BPTLLC_CURRENT_DATA_REVISION))
+
#define MOONBASE_HANDLE_SKIP_PIXELS_STEP() { \
/* Decompress bytes to do simple clipping... */ \
while (skipAmount > 0) { \
@@ -176,10 +184,9 @@ void Wiz::drawMoonbaseImageEx(
int32 sizeX, sizeY;
if (getMoonbaseWizSizeAndType(((ScummEngine_v71he *)_vm), wizPtr, state, sizeX, sizeY, stateCompressionType)) {
-
if (stateCompressionType == kWCTDataBlockDependent) {
// Find the data block
- byte *compressedDataPtr = _vm->findWrappedBlock(MKTAG('W', 'I', 'Z', 'H'), wizPtr->data, state, false);
+ byte *compressedDataPtr = _vm->findWrappedBlock(MKTAG('W', 'I', 'Z', 'D'), wizPtr->data, state, false);
// If we have data (assume it's T14 for now...)
if (compressedDataPtr) {
@@ -205,7 +212,6 @@ void Wiz::drawMoonbaseImageEx(
int nROP = T14_NOP;
switch (rawROP) {
-
default:
case 1: // MMX copy
nROP = T14_MMX_PREMUL_ALPHA_COPY;
@@ -237,14 +243,16 @@ void Wiz::drawMoonbaseImageEx(
}
// Finally dispatch to the T14 handler
- //DISPATCH_Blit_RGB555(bitmapPtr->data, bitmapPtr->width, bitmapPtr->height,
- // (bitmapPtr->width * sizeof(WizRawPixel16)), targetClippingRect,
- // compressedDataPtr, x, y, nROP, nROPParam, altSourceBuffer);
+ dispatchBlitRGB555((byte *)bitmapPtr->data, bitmapPtr->width, bitmapPtr->height,
+ (bitmapPtr->width * sizeof(WizRawPixel16)), targetClippingRect,
+ compressedDataPtr, x, y, nROP, nROPParam, altSourceBuffer);
}
} else {
- byte *wizdBlockPtr = _vm->findWrappedBlock(MKTAG('W', 'I', 'Z', 'D'), wizPtr->data, state, false) - _vm->_resourceHeaderSize;
+ byte *wizdBlockPtr = _vm->findWrappedBlock(MKTAG('W', 'I', 'Z', 'D'), wizPtr->data, state, false);
if (wizdBlockPtr) {
+ wizdBlockPtr -= _vm->_resourceHeaderSize;
+
// Fake up the compressed image header
fakedHeader.data = wizdBlockPtr + _vm->_resourceHeaderSize;
fakedHeader.transparentColor = 5;
@@ -584,9 +592,9 @@ bool Wiz::moonbaseLayeredWizHitTest(int32 *outValue, int32 *optionalOutActualVal
// Use the layered renderer to do hit-tests, so that all compression
// types supported by the U32 are supported...
- WizRawPixel16 chroma = ~0;
+ int32 chroma = ~0;
- WizRawPixel16 pixel = chroma;
+ int32 pixel = chroma;
drawMoonbaseLayeredWiz((byte *)&pixel, 1, 1, sizeof(WizRawPixel16), 555, 16,
globPtr, -x, -y, state, 0, 0, 0, 0, flags, conditionBits, 0, 0);
@@ -760,14 +768,181 @@ void Wiz::handleCompositeDrawMoonbaseImage(
if (layerCmdDataBits & kWCFSubConditionBits) {
subConditionBits = READ_LE_UINT32(cmdPtr);
cmdPtr += 4;
- } else {
- subConditionBits = 0;
}
// Finally do the actual command...
drawMoonbaseImageEx(
bitmapPtr, &nestedMultiStateWiz, (x + xPos), (y + yPos), subState, clipRect,
drawFlags, nullptr, subConditionBits, ptr8BppToXBppClut, altSourceBuffer);
+
+ }
+}
+
+void Wiz::dispatchBlitRGB555(
+ byte *bufferData, int bufferWidth, int bufferHeight, int bufferPitch,
+ Common::Rect *optionalClippingRect, byte *compressedDataStream,
+ int x, int y, int nROP, int nROPParam, byte *altSourceBuffer) {
+
+ if (compressedDataStream) {
+ uint32 id = READ_LE_UINT32(compressedDataStream);
+
+ if (id == BPTLLC_ID_T14_TYPE) {
+ blitT14CodecImage(
+ bufferData, bufferWidth, bufferHeight, bufferPitch, optionalClippingRect, compressedDataStream, x, y, nROP, nROPParam);
+ } else if (id == BPTLLC_ID_RAW_555_DISTORT_TYPE) {
+ //DISTORTION_CODEC::Blit_Uncompressed_X1R5G5B5(
+ // bufferData, bufferWidth, bufferHeight, bufferPitch, optionalClippingRect, compressedDataStream, x, y, altSourceBuffer);
+ } else if (id == BPTLLC_ID_TRLE_555_DISTORT_TYPE) {
+ error("Unimplemented development path!");
+ }
+ }
+}
+
+void Wiz::blitT14CodecImage(byte *dst, int dstw, int dsth, int dstPitch, const Common::Rect *clipBox, byte *wizd, int x, int y, int rawROP, int paramROP) {
+ bool premulAlpha = false;
+
+ if (rawROP == T14_MMX_PREMUL_ALPHA_COPY)
+ premulAlpha = true;
+
+ Common::Rect clippedDstRect(dstw, dsth);
+ if (clipBox) {
+ Common::Rect clip(clipBox->left, clipBox->top, clipBox->right, clipBox->bottom);
+ if (clippedDstRect.intersects(clip)) {
+ clippedDstRect.clip(clip);
+ } else {
+ return;
+ }
+ }
+
+ int width = READ_LE_UINT16(wizd + 0x8 + 0);
+ int height = READ_LE_UINT16(wizd + 0x8 + 2);
+
+ Common::Rect srcLimitsRect(width, height);
+ Common::Rect dstOperation(x, y, x + width, y + height);
+ if (!clippedDstRect.intersects(dstOperation))
+ return;
+ Common::Rect clippedRect = clippedDstRect.findIntersectingRect(dstOperation);
+
+ int cx = clippedRect.right - clippedRect.left;
+ int cy = clippedRect.bottom - clippedRect.top;
+
+ int sx = ((clippedRect.left - x) + srcLimitsRect.left);
+ int sy = ((clippedRect.top - y) + srcLimitsRect.top);
+
+ dst += clippedRect.top * dstPitch + clippedRect.left * 2;
+
+ int headerSize = READ_LE_UINT32(wizd + 0x4);
+ uint8 *dataPointer = wizd + 0x8 + headerSize;
+
+ for (int i = 0; i < sy; i++) {
+ uint16 lineSize = READ_LE_UINT16(dataPointer + 0);
+
+ dataPointer += lineSize;
+ }
+
+ for (int i = 0; i < cy; i++) {
+ uint16 lineSize = READ_LE_UINT16(dataPointer + 0);
+ uint8 *singlesOffset = READ_LE_UINT16(dataPointer + 2) + dataPointer;
+ uint8 *quadsOffset = READ_LE_UINT16(dataPointer + 4) + dataPointer;
+
+ int pixels = 0;
+ byte *dst1 = dst;
+ byte *codes = dataPointer + 6;
+
+ while (1) {
+ int code = *codes - 2;
+ codes++;
+
+ if (code <= 0) { // quad or single
+ uint8 *src;
+ int cnt;
+ if (code == 0) { // quad
+ src = quadsOffset;
+ quadsOffset += 8;
+ cnt = 4; // 4 pixels
+ } else { // single
+ src = singlesOffset;
+ singlesOffset += 2;
+ cnt = 1;
+ }
+
+ for (int c = 0; c < cnt; c++) {
+ if (pixels >= sx) {
+ if (rawROP == T14_MMX_PREMUL_ALPHA_COPY) { // MMX_PREMUL_ALPHA_COPY
+ WRITE_LE_UINT16(dst1, READ_LE_UINT16(src));
+ } else if (rawROP == T14_MMX_ADDITIVE) { // MMX_ADDITIVE
+ uint16 color = READ_LE_UINT16(src);
+ uint16 orig = READ_LE_UINT16(dst1);
+
+ uint32 r = MIN<uint32>(0x7c00, (orig & 0x7c00) + (color & 0x7c00));
+ uint32 g = MIN<uint32>(0x03e0, (orig & 0x03e0) + (color & 0x03e0));
+ uint32 b = MIN<uint32>(0x001f, (orig & 0x001f) + (color & 0x001f));
+ WRITE_LE_UINT16(dst1, (r | g | b));
+ } else if (rawROP == T14_MMX_CHEAP_50_50) { // MMX_CHEAP_50_50
+ uint16 color = (READ_LE_UINT16(src) >> 1) & 0x3DEF;
+ uint16 orig = (READ_LE_UINT16(dst1) >> 1) & 0x3DEF;
+ WRITE_LE_UINT16(dst1, (color + orig));
+ }
+ dst1 += 2;
+ }
+ src += 2;
+ pixels++;
+ if (pixels >= cx + sx)
+ break;
+ }
+ } else { // skip
+ if ((code & 1) == 0) {
+ code >>= 1;
+
+ for (int j = 0; j < code; j++) {
+ if (pixels >= sx)
+ dst1 += 2;
+ pixels++;
+ if (pixels >= cx + sx)
+ break;
+ }
+ } else { // special case
+ if (pixels >= sx) {
+ int alpha = code >> 1;
+ uint16 color = READ_LE_UINT16(singlesOffset);
+ uint32 orig = READ_LE_UINT16(dst1);
+
+ if (!premulAlpha) {
+ WRITE_LE_UINT16(dst1, color); // ENABLE_PREMUL_ALPHA = 0
+ } else {
+ if (alpha > 32) {
+ alpha -= 32;
+
+ uint32 oR = orig & 0x7c00;
+ uint32 oG = orig & 0x03e0;
+ uint32 oB = orig & 0x1f;
+ uint32 dR = ((((color & 0x7c00) - oR) * alpha) >> 5) + oR;
+ uint32 dG = ((((color & 0x3e0) - oG) * alpha) >> 5) + oG;
+ uint32 dB = ((((color & 0x1f) - oB) * alpha) >> 5) + oB;
+
+ WRITE_LE_UINT16(dst1, (dR & 0x7c00) | (dG & 0x3e0) | (dB & 0x1f));
+ } else {
+ uint32 pix = ((orig << 16) | orig) & 0x3e07c1f;
+ pix = (((pix * alpha) & 0xffffffff) >> 5) & 0x3e07c1f;
+ pix = ((pix >> 16) + pix + color) & 0xffff;
+ WRITE_LE_UINT16(dst1, pix);
+ }
+ }
+
+ dst1 += 2;
+ }
+
+ singlesOffset += 2;
+ pixels++;
+ }
+ }
+
+ if (pixels >= cx + sx)
+ break;
+ }
+
+ dataPointer += lineSize;
+ dst += dstPitch;
}
}
diff --git a/engines/scumm/he/wiz_he.h b/engines/scumm/he/wiz_he.h
index 1ba729a6f78..3f396ee98d9 100644
--- a/engines/scumm/he/wiz_he.h
+++ b/engines/scumm/he/wiz_he.h
@@ -394,7 +394,7 @@ enum WizRenderingFlags {
kWRFRotate90 = 0x00001000,
// Special rendering flags
- kWRFSpecialRenderBitMask = 0xfff00000,
+ kWRFSpecialRenderBitMask = 0xFFF00000,
kWRFAdditiveBlend = 0x00100000,
kWRFSubtractiveBlend = 0x00200000,
kWRF5050Blend = 0x00400000,
@@ -683,6 +683,15 @@ public:
bool moonbaseLayeredWizHitTest(int32 *outValue, int32 *pOptionalOutActualValue, byte *globPtr, int state, int x, int y, int32 flags, int32 dwConditionBits);
+ void dispatchBlitRGB555(
+ byte *bufferData, int bufferWidth, int bufferHeight, int bufferPitch,
+ Common::Rect *optionalClippingRect, byte *compressedDataStream,
+ int x, int y, int nROP, int nROPParam, byte *altSourceBuffer);
+
+ void blitT14CodecImage(byte *dst, int dstw, int dsth, int dstPitch, const Common::Rect *clipBox,
+ byte *wizd, int srcx, int srcy, int rawROP, int paramROP);
+
+
private:
ScummEngine_v71he *_vm;
Commit: 184cd608f896f5c9dce3eebbce6ef051a0fc0e33
https://github.com/scummvm/scummvm/commit/184cd608f896f5c9dce3eebbce6ef051a0fc0e33
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Reimplement Moonbase distortion routines
Changed paths:
R engines/scumm/he/moonbase/distortion.cpp
engines/scumm/he/moonbase/moonbase_gfx.cpp
engines/scumm/he/wiz_he.h
engines/scumm/module.mk
diff --git a/engines/scumm/he/moonbase/distortion.cpp b/engines/scumm/he/moonbase/distortion.cpp
deleted file mode 100644
index 8c0d1e997d0..00000000000
--- a/engines/scumm/he/moonbase/distortion.cpp
+++ /dev/null
@@ -1,217 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "scumm/he/intern_he.h"
-#include "engines/scumm/he/moonbase/moonbase.h"
-
-namespace Scumm {
-
-enum {
- kBptHeaderSize = 8,
-
- kReflectionClipped = 0,
- kNotClipped = 1,
- kSpecializedNotClipped = 2
-};
-
-static void blitDistortionCore(
- Graphics::Surface *dstBitmap,
- const int x, const int y,
- const Graphics::Surface *distortionBitmap,
- const Common::Rect *optionalclipRectPtr,
- int transferOp,
- const Graphics::Surface *srcBitmap,
- Common::Rect *srcClipRect
-) {
- Common::Rect clipRect(dstBitmap->w, dstBitmap->h);
-
- if (optionalclipRectPtr) {
- if (!clipRect.intersects(*optionalclipRectPtr))
- return;
-
- clipRect.clip(*optionalclipRectPtr);
- }
-
- Common::Rect distortionRect(distortionBitmap->w, distortionBitmap->h);
- Common::Rect dstRect(x, y, x + distortionRect.width(), y + distortionRect.height());
-
- if (!dstRect.intersects(clipRect))
- return;
-
- dstRect.clip(clipRect);
-
- distortionRect.moveTo(dstRect.left - x, dstRect.top - y);
-
- const byte *distortionPtr = (const byte *)distortionBitmap->getBasePtr(distortionRect.left, distortionRect.top);
- byte *dstPtr = (byte *)dstBitmap->getBasePtr(dstRect.left, dstRect.top);
- int cw = dstRect.width();
- int ch = dstRect.height();
- int idx = dstRect.left;
- int dy = dstRect.top;
-
- int baseX, baseY;
-
- switch (transferOp) {
- case kReflectionClipped:
- case kNotClipped:
- baseX = -(0x1f / 2); // Half range
- baseY = -(0x1f / 2);
- break;
-
- case kSpecializedNotClipped:
- default:
- baseX = 0;
- baseY = 0;
- }
-
- while (--ch >= 0) {
- uint16 *d = (uint16 *)dstPtr;
- const uint16 *is = (const uint16 *)distortionPtr;
- int dx = idx;
-
- for (int i = cw; --i >= 0;) {
- uint16 p = READ_BE_UINT16(is);
-
- int sx = baseX + dx + ((p >> 5) & 0x1f); // G color
- int sy = baseY + dy + (p & 0x1f); // B color;
-
- if (transferOp == kReflectionClipped) {
- if (sx < srcClipRect->left)
- sx += (srcClipRect->left - sx);
-
- if (sx > srcClipRect->right)
- sx -= (sx - srcClipRect->right);
-
- sx = MAX<int>(srcClipRect->left, MIN<int>(sx, srcClipRect->right));
-
- if (sy < srcClipRect->top)
- sy += (srcClipRect->top - sy);
-
- if (sy > srcClipRect->bottom)
- sy -= (sy - srcClipRect->bottom);
-
- sy = MAX<int>(srcClipRect->top, MIN<int>(sy, srcClipRect->bottom));
- }
-
- *d = *((const uint16 *)srcBitmap->getBasePtr(sx, sy));
-
- ++d;
- ++is;
- ++dx;
- }
-
- dstPtr += dstBitmap->pitch;
- distortionPtr += distortionBitmap->pitch;
-
- ++dy;
- }
-}
-
-void Moonbase::blitDistortion(byte *bufferData, const int bufferWidth, const int bufferHeight, const int bufferPitch,
- const Common::Rect *optionalClippingRect, byte *dataStream, const int x, const int y, byte *altSourceBuffer) {
- byte *sourcePixels = (altSourceBuffer) ? altSourceBuffer : bufferData;
- Common::Rect dstLimitsRect(bufferWidth, bufferHeight);
- Common::Rect clippedDstRect = dstLimitsRect;
-
- if (optionalClippingRect) {
- if (!dstLimitsRect.intersects(*optionalClippingRect))
- return;
- dstLimitsRect.clip(*optionalClippingRect);
- } else {
- clippedDstRect = dstLimitsRect;
- }
-
- int w = READ_LE_UINT16(dataStream + kBptHeaderSize + 0);
- int h = READ_LE_UINT16(dataStream + kBptHeaderSize + 2);
- Common::Rect srcLimitsRect(w, h);
- Common::Rect clippedSrcRect = srcLimitsRect;
- Common::Rect dstOperation(x, y, x + clippedSrcRect.width(), y + clippedSrcRect.height());
-
- if (!clippedDstRect.intersects(dstOperation))
- return;
-
- clippedDstRect.clip(dstOperation);
-
- int subBlockCount = READ_LE_UINT16(dataStream + kBptHeaderSize + 4);
- byte *subBlockStream = dataStream + kBptHeaderSize + READ_LE_UINT32(dataStream + 4);
- int cx1 = clippedDstRect.left;
- int cy1 = clippedDstRect.top;
- int cx2 = clippedDstRect.right - 1;
- int cy2 = clippedDstRect.bottom - 1;
-
- for (int i = 0; i < subBlockCount; i++) {
- byte *blockData = subBlockStream;
- uint32 blockSize = READ_LE_UINT32(blockData); blockData += 4;
- subBlockStream += blockSize;
- int xOffset = READ_LE_UINT16(blockData); blockData += 2;
- int yOffset = READ_LE_UINT16(blockData); blockData += 2;
- int width = READ_LE_UINT16(blockData); blockData += 2;
- int height = READ_LE_UINT16(blockData); blockData += 2;
- int l_reach = READ_LE_UINT16(blockData); blockData += 2;
- int r_reach = READ_LE_UINT16(blockData); blockData += 2;
- int t_reach = READ_LE_UINT16(blockData); blockData += 2;
- int b_reach = READ_LE_UINT16(blockData); blockData += 2;
- int distortionPitch = width * 2; // 2 for 555
-
- if (width == 0 && height == 0)
- continue;
-
- Graphics::Surface dstBitmap;
- dstBitmap.init(bufferWidth, bufferHeight, bufferPitch, bufferData, Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0));
-
- Graphics::Surface srcBitmap;
- srcBitmap.init(bufferWidth, bufferHeight, bufferPitch, sourcePixels, Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0));
-
- Graphics::Surface distortionBitmap;
- distortionBitmap.init(width, height, distortionPitch, blockData, Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0));
-
- Common::Rect srcClipRect(cx1, cy1, cx2, cy2);
- Common::Rect dstClipRect(cx1, cy1, cx2, cy2);
-
- int src_x = (x + xOffset);
- int src_y = (y + yOffset);
-
- Common::Rect srcReach((src_x - l_reach), (src_y - t_reach), (src_x + r_reach), (src_y + b_reach));
- Common::Rect srcLimits(srcBitmap.w, srcBitmap.h);
-
- if (!srcLimits.intersects(srcClipRect))
- return;
-
- srcLimits.clip(srcClipRect);
-
- if (!srcReach.intersects(srcLimits))
- return;
-
- srcReach.clip(srcLimits);
-
- if (srcLimits.contains(srcReach)) {
- if (srcBitmap.pitch == 1280) {
- blitDistortionCore(&dstBitmap, src_x, src_y, &distortionBitmap, &dstClipRect, kSpecializedNotClipped, &srcBitmap, 0);
- } else {
- blitDistortionCore(&dstBitmap, src_x, src_y, &distortionBitmap, &dstClipRect, kNotClipped, &srcBitmap, 0);
- }
- } else {
- blitDistortionCore(&dstBitmap, src_x, src_y, &distortionBitmap, &dstClipRect, kReflectionClipped, &srcBitmap, &srcLimits);
- }
- }
-}
-
-}
diff --git a/engines/scumm/he/moonbase/moonbase_gfx.cpp b/engines/scumm/he/moonbase/moonbase_gfx.cpp
index 57b2f02e4bb..0106d16684e 100644
--- a/engines/scumm/he/moonbase/moonbase_gfx.cpp
+++ b/engines/scumm/he/moonbase/moonbase_gfx.cpp
@@ -25,6 +25,27 @@
namespace Scumm {
+enum MoonbaseDistortionTypes {
+ kMDTEdgeReflectionClipped = 0,
+ kMDTNotClipped = 1,
+ kMDTSpecializedNotClipped = 2
+};
+
+#define T14_MMX_REQUIRED (0x8000)
+#define T14_NOP (0x0000)
+#define T14_COPY (0x0001)
+#define T14_CHEAP_50_50 (0x0002)
+#define T14_PREMULTIPLIED_5050 (0x0003)
+#define T14_MMX_COPY (0x0004 | T14_MMX_REQUIRED)
+#define T14_MMX_CHEAP_50_50 (0x0005 | T14_MMX_REQUIRED)
+#define T14_MMX_PREMULTIPLIED_5050 (0x0006 | T14_MMX_REQUIRED)
+#define T14_MMX_ADDITIVE (0x0007 | T14_MMX_REQUIRED)
+#define T14_MMX_SUBTRACTIVE (0x0008 | T14_MMX_REQUIRED)
+#define T14_MMX_CONSTANT_ALPHA (0x0009 | T14_MMX_REQUIRED)
+#define T14_MMX_SILHOUETTE_DARKEN (0x000A | T14_MMX_REQUIRED)
+#define T14_MMX_SILHOUETTE_BRIGHTEN (0x000B | T14_MMX_REQUIRED)
+#define T14_MMX_PREMUL_ALPHA_COPY (0x000C | T14_MMX_REQUIRED)
+
#define SIZE_OF_BPTLLC_VALIDATION_HEADER 8
#define BPTLLC_CURRENT_DATA_REVISION 2
#define BPTLLC_CURRENT_REVISION_MASK 0x000000FF
@@ -628,8 +649,7 @@ void Wiz::handleCompositeDrawMoonbaseImage(
int32 conditionType;
int32 stateSizeX = 0, stateSizeY = 0;
- // Get the nested block...
-
+ // Get the nested block...
nestedBlockHeader = _vm->heFindResource(MKTAG('N', 'E', 'S', 'T'), wizPtr->data);
if (!nestedBlockHeader) {
@@ -790,8 +810,8 @@ void Wiz::dispatchBlitRGB555(
blitT14CodecImage(
bufferData, bufferWidth, bufferHeight, bufferPitch, optionalClippingRect, compressedDataStream, x, y, nROP, nROPParam);
} else if (id == BPTLLC_ID_RAW_555_DISTORT_TYPE) {
- //DISTORTION_CODEC::Blit_Uncompressed_X1R5G5B5(
- // bufferData, bufferWidth, bufferHeight, bufferPitch, optionalClippingRect, compressedDataStream, x, y, altSourceBuffer);
+ blitDistortion(
+ bufferData, bufferWidth, bufferHeight, bufferPitch, optionalClippingRect, compressedDataStream, x, y, altSourceBuffer);
} else if (id == BPTLLC_ID_TRLE_555_DISTORT_TYPE) {
error("Unimplemented development path!");
}
@@ -946,4 +966,316 @@ void Wiz::blitT14CodecImage(byte *dst, int dstw, int dsth, int dstPitch, const C
}
}
+void Wiz::blitDistortion(
+ byte *bufferData, int bufferWidth, int bufferHeight, int bufferPitch,
+ Common::Rect *optionalClippingRect, byte *compressedDataStream,
+ int x, int y, byte *altSourceBuffer) {
+
+ int format = 555;
+ int bpp = 16;
+ int distortionFormat = 555;
+ int distortionBpp = 16;
+
+ // Setup the source pointer...
+ byte *sourcePixels = (altSourceBuffer) ? altSourceBuffer : bufferData;
+
+ // Clip the optional clipping rect to the dest bitmap limits...
+ Common::Rect dstLimitsRect(0, 0, bufferWidth, bufferHeight);
+
+ Common::Rect clippedDstRect;
+
+ if (optionalClippingRect) {
+ if (!dstLimitsRect.intersects(*optionalClippingRect)) {
+ return;
+ }
+
+ clippedDstRect = dstLimitsRect;
+ clippedDstRect.clip(*optionalClippingRect);
+ } else {
+ clippedDstRect = dstLimitsRect;
+ }
+
+ // Get the source operation size...
+ int w = READ_LE_UINT16(compressedDataStream + SIZE_OF_BPTLLC_VALIDATION_HEADER + 0);
+ int h = READ_LE_UINT16(compressedDataStream + SIZE_OF_BPTLLC_VALIDATION_HEADER + 2);
+
+ Common::Rect srcLimitsRect(0, 0, w, h);
+ Common::Rect clippedSrcRect = srcLimitsRect;
+
+ // Perform a simple clipping operation to detect if we have to bail out early...
+ Common::Rect dstOperation(x, y,
+ x + (clippedSrcRect.right - clippedSrcRect.left),
+ y + (clippedSrcRect.bottom - clippedSrcRect.top));
+
+ Common::Rect clippedRect;
+
+ if (!clippedDstRect.intersects(dstOperation)) {
+ return;
+ }
+
+ clippedRect = clippedDstRect;
+ clippedRect.clip(dstOperation);
+
+ // Get the important header information...
+ int subBlockCount = READ_LE_UINT16(compressedDataStream + SIZE_OF_BPTLLC_VALIDATION_HEADER + 4);
+ byte *subBlockStream = compressedDataStream + SIZE_OF_BPTLLC_VALIDATION_HEADER + READ_LE_UINT32(compressedDataStream + 4);
+
+ // Get our clip rect information...
+ int cx1 = clippedDstRect.left;
+ int cy1 = clippedDstRect.top;
+ int cx2 = clippedDstRect.right - 1;
+ int cy2 = clippedDstRect.bottom - 1;
+
+ // Process each sub-block...
+ for (int i = 0; i < subBlockCount; i++) {
+ // Read the sub-block header...
+ byte *blockData = subBlockStream;
+
+ uint32 blockSize = READ_LE_UINT32(blockData); blockData += 4;
+ subBlockStream += blockSize;
+
+ int xOffset = READ_LE_UINT16(blockData); blockData += 2;
+ int yOffset = READ_LE_UINT16(blockData); blockData += 2;
+ int width = READ_LE_UINT16(blockData); blockData += 2;
+ int height = READ_LE_UINT16(blockData); blockData += 2;
+ int lReach = READ_LE_UINT16(blockData); blockData += 2;
+ int rReach = READ_LE_UINT16(blockData); blockData += 2;
+ int tReach = READ_LE_UINT16(blockData); blockData += 2;
+ int bReach = READ_LE_UINT16(blockData); blockData += 2;
+ int distortionPitch = ((width * distortionBpp + 7) / 8);
+
+ // Check for special case...
+ if ((width == 0) && (height == 0)) {
+ continue;
+ }
+
+ // Call the blitter for the sub block...
+ blitUncompressedDistortionBitmap(
+ bufferData, bufferWidth, bufferHeight, bufferPitch, format, bpp,
+ sourcePixels, bufferWidth, bufferHeight, bufferPitch, format, bpp,
+ blockData, width, height, distortionPitch, distortionFormat, distortionBpp,
+ (x + xOffset), (y + yOffset), (x + xOffset), (y + yOffset),
+ lReach, rReach, tReach, bReach,
+ cx1, cy1, cx2, cy2, cx1, cy1, cx2, cy2
+ );
+ }
+}
+
+void Wiz::blitUncompressedDistortionBitmap(
+ byte *dstBitmapData, int dstWidth, int dstHeight, int dstPitch, int dstFormat, int dstBpp,
+ byte *srcBitmapData, int srcWidth, int srcHeight, int srcPitch, int srcFormat, int srcBpp,
+ byte *distortionBitmapData, int distortionWidth, int distortionHeight, int distortionPitch, int distortionFormat, int distortionBpp,
+ int dstX, int dstY, int srcX, int srcY, int lReach, int rReach, int tReach, int bReach,
+ int srcClipX1, int srcClipY1, int srcClipX2, int srcClipY2,
+ int dstClipX1, int dstClipY1, int dstClipX2, int dstClipY2) {
+
+ MoonbaseDistortionInfo distInfo;
+
+ int gMax = ((1 << 5) - 1);
+ int bMax = ((1 << 5) - 1);
+
+ int xSignedAdjust = -(gMax / 2);
+ int ySignedAdjust = -(bMax / 2);
+
+ Graphics::Surface mappedDstBitmap;
+ mappedDstBitmap.init(dstWidth, dstHeight, dstPitch, dstBitmapData, Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0));
+
+ Graphics::Surface mappedSrcBitmap;
+ mappedSrcBitmap.init(srcWidth, srcHeight, srcPitch, srcBitmapData, Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0));
+
+ Graphics::Surface mappedDistortionBitmap;
+ mappedDistortionBitmap.init(distortionWidth, distortionHeight, distortionPitch, distortionBitmapData, Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0));
+
+ Common::Rect srcClipRect(srcClipX1, srcClipY1, srcClipX2, srcClipY2);
+ Common::Rect dstClipRect(dstClipX1, dstClipY1, dstClipX2, dstClipY2);
+ Common::Rect srcReach((srcX - lReach), (srcY - tReach), (srcX + rReach), (srcY + bReach));
+
+ Common::Rect srcLimits(mappedSrcBitmap.w, mappedSrcBitmap.h);
+
+ if (!findRectOverlap(&srcLimits, &srcClipRect)) {
+ return;
+ }
+
+ if (!srcReach.intersects(srcLimits)) {
+ return;
+ }
+
+ if (srcReach.contains(srcLimits)) {
+ if (mappedSrcBitmap.pitch == 1280) {
+ distInfo.baseX = 0;
+ distInfo.baseY = 0;
+ distInfo.srcPitch = mappedSrcBitmap.pitch;
+ distInfo.clipRect = nullptr;
+ distInfo.srcData = (byte *)mappedSrcBitmap.getBasePtr(
+ (dstX - srcX) + xSignedAdjust, (dstY - srcY) + ySignedAdjust);
+
+ distortionBlitCore(&mappedDstBitmap, dstX, dstY, &mappedDistortionBitmap, 0, &dstClipRect, kMDTSpecializedNotClipped, &distInfo);
+ } else {
+ distInfo.baseX = (dstX - srcX) + xSignedAdjust;
+ distInfo.baseY = (dstY - srcY) + ySignedAdjust;
+ distInfo.srcPitch = mappedSrcBitmap.pitch;
+ distInfo.clipRect = nullptr;
+ distInfo.srcData = (byte *)mappedSrcBitmap.getBasePtr(0, 0);
+
+ distortionBlitCore(&mappedDstBitmap, dstX, dstY, &mappedDistortionBitmap, 0, &dstClipRect, kMDTNotClipped, &distInfo);
+ }
+ } else {
+ distInfo.baseX = (dstX - srcX) + xSignedAdjust;
+ distInfo.baseY = (dstY - srcY) + ySignedAdjust;
+ distInfo.srcPitch = mappedSrcBitmap.pitch;
+ distInfo.clipRect = &srcLimits;
+ distInfo.srcData = (byte *)mappedSrcBitmap.getBasePtr(0, 0);
+
+ distortionBlitCore(&mappedDstBitmap, dstX, dstY, &mappedDistortionBitmap, 0, &dstClipRect, kMDTEdgeReflectionClipped, &distInfo);
+ }
+}
+
+static void distortionGetCoordinates(int s, int &x, int &y) {
+ int G_Mask = (((1 << 5) - 1) << 5);
+ int B_Mask = (((1 << 5) - 1) << 0);
+ int G_LShift = 5;
+ int B_LShift = 0;
+
+ x = (s & G_Mask) >> G_LShift;
+ y = (s & B_Mask) >> B_LShift;
+}
+
+static void distortionTransferOp(int transferOp, MoonbaseDistortionInfo *mdi, uint16 *d, uint16 *s, int dx, int dy) {
+ int xx, yy, sx, sy;
+ switch (transferOp) {
+ case kMDTEdgeReflectionClipped:
+ // Get the 'coordinates' from the color channels...
+ distortionGetCoordinates(READ_BE_UINT16(s), xx, yy);
+
+ // Find the read X location
+ sx = mdi->baseX + dx + xx;
+
+ if (sx < mdi->clipRect->left) {
+ sx -= (mdi->clipRect->left - sx);
+ }
+
+ if (sx > mdi->clipRect->right) {
+ sx -= (sx - mdi->clipRect->right);
+ }
+
+ // Cap the coordinates just incase it's a really tight src clip...
+ sx = MAX<int>(mdi->clipRect->left, MIN<int>(sx, mdi->clipRect->right));
+
+ // Find the read Y location...
+ sy = mdi->baseY + dy + yy;
+
+ if (sy < mdi->clipRect->top) {
+ sy -= (mdi->clipRect->top - sy);
+ }
+
+ if (sy > mdi->clipRect->bottom) {
+ sy -= (sy - mdi->clipRect->bottom);
+ }
+
+ // Cap the coordinates just in case it's a really tight src clip...
+ sy = MAX<int>(mdi->clipRect->top, MIN<int>(sy, mdi->clipRect->bottom));
+
+ // Transfer the pixel...
+ *d = *((uint16 *)(mdi->srcData + sy * mdi->srcPitch + sx * sizeof(uint16)));
+
+ break;
+ case kMDTNotClipped:
+ // Get the 'coordinates' from the color channels...
+ distortionGetCoordinates(READ_BE_UINT16(s), xx, yy);
+
+ // Find the read X location...
+ sx = mdi->baseX + dx + xx;
+
+ // Find the read Y location...
+ sy = mdi->baseY + dy + yy;
+
+ // Transfer the pixel...
+ *d = *((uint16 *)(mdi->srcData + sy * mdi->srcPitch + sx * sizeof(uint16)));
+ break;
+ case kMDTSpecializedNotClipped:
+ // Get the 'coordinates' from the color channels...
+ distortionGetCoordinates(READ_BE_UINT16(s), xx, yy);
+
+ // Transfer the source pixel...
+ *d = *((uint16 *)(mdi->srcData + ((dy + yy) * 640 * sizeof(uint16)) + ((dx + xx) * sizeof(uint16))));
+
+ break;
+ default:
+ error("distortionTransferOp(): Invalid transfer operation %d", transferOp);
+ }
+
+}
+
+void Wiz::distortionBlitCore(
+ Graphics::Surface *dstBitmap, int x, int y, Graphics::Surface *srcBitmap,
+ Common::Rect *optionalSrcRectPtr, Common::Rect *optionalclipRectPtr, int transferOp, MoonbaseDistortionInfo *mdi) {
+
+ // Clip the clip rect if one with the dest bitmap limits...
+ Common::Rect clipRect;
+ makeSizedRect(&clipRect, dstBitmap->w, dstBitmap->h);
+
+ if (optionalclipRectPtr) {
+ if (!findRectOverlap(&clipRect, optionalclipRectPtr))
+ return;
+ }
+
+ // Clip the source coords to the source bitmap limits...
+ Common::Rect srcRect;
+ makeSizedRect(&srcRect, srcBitmap->w, srcBitmap->h);
+
+ if (optionalSrcRectPtr) {
+ if (!findRectOverlap(&srcRect, optionalSrcRectPtr))
+ return;
+ }
+
+ // Build/clip the dest rect...
+ Common::Rect dstRect;
+ makeSizedRectAt(&dstRect, x, y, getRectWidth(&srcRect), getRectHeight(&srcRect));
+
+ if (!findRectOverlap(&dstRect, &clipRect))
+ return;
+
+ // Adjust the source coords to the clipped dest coords...
+ moveRect(&srcRect, (dstRect.left - x), (dstRect.top - y));
+
+ // Calc the source pointer/get the source stride...
+ byte *srcPtr = (byte *)srcBitmap->getBasePtr(srcRect.left, srcRect.top);
+ int sStride = srcBitmap->pitch;
+
+ // Calc the destination pointer / get the destination stride...
+ byte *dstPtr = (byte *)dstBitmap->getBasePtr(dstRect.left, dstRect.top);
+ int dStride = dstBitmap->pitch;
+
+ // Setup operation amounts...
+ int cw = getRectWidth(&dstRect);
+ int ch = getRectHeight(&dstRect);
+
+ // Left or right?
+ int idx = dstRect.left;
+ int dy = dstRect.top;
+
+ while (--ch >= 0) {
+ // Get the working pointers and step the line pointers...
+ uint16 *d = (uint16 *)dstPtr;
+ uint16 *s = (uint16 *)srcPtr;
+
+ // Transfer the pixels...
+ int dx = idx;
+
+ for (int i = cw; --i >= 0;) {
+ distortionTransferOp(transferOp, mdi, d, s, dx, dy);
+
+ ++d;
+ ++s;
+ ++dx;
+ }
+
+ // Move the line pointers...
+ dstPtr += dStride;
+ srcPtr += sStride;
+
+ ++dy;
+ }
+}
+
} // End of namespace Scumm
diff --git a/engines/scumm/he/wiz_he.h b/engines/scumm/he/wiz_he.h
index 3f396ee98d9..5db2823f170 100644
--- a/engines/scumm/he/wiz_he.h
+++ b/engines/scumm/he/wiz_he.h
@@ -109,22 +109,6 @@ namespace Scumm {
MAX<int>(WIZRAWPIXEL_LO_B_BIT, (((__colorA__) & WIZRAWPIXEL_B_MASK) - ((__colorB__) & WIZRAWPIXEL_B_MASK))))
-#define T14_MMX_REQUIRED 0x8000
-#define T14_NOP (0x0000)
-#define T14_COPY (0x0001)
-#define T14_CHEAP_50_50 (0x0002)
-#define T14_PREMULTIPLIED_5050 (0x0003)
-#define T14_MMX_COPY (0x0004 | T14_MMX_REQUIRED)
-#define T14_MMX_CHEAP_50_50 (0x0005 | T14_MMX_REQUIRED)
-#define T14_MMX_PREMULTIPLIED_5050 (0x0006 | T14_MMX_REQUIRED)
-#define T14_MMX_ADDITIVE (0x0007 | T14_MMX_REQUIRED)
-#define T14_MMX_SUBTRACTIVE (0x0008 | T14_MMX_REQUIRED)
-#define T14_MMX_CONSTANT_ALPHA (0x0009 | T14_MMX_REQUIRED)
-#define T14_MMX_SILHOUETTE_DARKEN (0x000a | T14_MMX_REQUIRED)
-#define T14_MMX_SILHOUETTE_BRIGHTEN (0x000b | T14_MMX_REQUIRED)
-#define T14_MMX_PREMUL_ALPHA_COPY (0x000c | T14_MMX_REQUIRED)
-
-
typedef uint16 WizRawPixel;
typedef uint8 WizRawPixel8;
typedef uint16 WizRawPixel16;
@@ -336,6 +320,14 @@ struct WizMoonbaseCompressedImage {
byte *data;
};
+struct MoonbaseDistortionInfo {
+ byte *srcData;
+ int baseX;
+ int baseY;
+ int srcPitch;
+ Common::Rect *clipRect;
+};
+
// Our Common::Point has int16 coordinates.
// This is not enough for polygon warping...
struct WarpWizPoint {
@@ -652,6 +644,11 @@ public:
* Moonbase Commander custom Wiz operations
*
* These are defined in moonbase/moonbase_layered_wiz.cpp
+ * Beware: some of these functions are using both the custom WIZ
+ * Rect functions and our own. This is *by design*, and emulates
+ * what the original code does (using both the WIZ functions and
+ * the Windows Rect primitives). Do not attempt to change this!
+ *
*/
bool drawMoonbaseLayeredWiz(
@@ -688,8 +685,26 @@ public:
Common::Rect *optionalClippingRect, byte *compressedDataStream,
int x, int y, int nROP, int nROPParam, byte *altSourceBuffer);
- void blitT14CodecImage(byte *dst, int dstw, int dsth, int dstPitch, const Common::Rect *clipBox,
- byte *wizd, int srcx, int srcy, int rawROP, int paramROP);
+ void blitT14CodecImage(
+ byte *dst, int dstw, int dsth, int dstPitch, const Common::Rect *clipBox,
+ byte *wizd, int srcx, int srcy, int rawROP, int paramROP);
+
+ void blitDistortion(
+ byte *bufferData, int bufferWidth, int bufferHeight, int bufferPitch,
+ Common::Rect *optionalClippingRect, byte *compressedDataStream,
+ int x, int y, byte *altSourceBuffer);
+
+ void blitUncompressedDistortionBitmap(
+ byte *dstBitmapData, int dstWidth, int dstHeight, int dstPitch, int dstFormat, int dstBpp,
+ byte *srcBitmapData, int srcWidth, int srcHeight, int srcPitch, int srcFormat, int srcBpp,
+ byte *distortionBitmapData, int distortionWidth, int distortionHeight, int distortionPitch, int distortionFormat, int distortionBpp,
+ int dstX, int dstY, int srcX, int srcY, int lReach, int rReach, int tReach, int bReach,
+ int srcClipX1, int srcClipY1, int srcClipX2, int srcClipY2,
+ int dstClipX1, int dstClipY1, int dstClipX2, int dstClipY2);
+
+ void distortionBlitCore(
+ Graphics::Surface *dstBitmap, int x, int y, Graphics::Surface *srcBitmap,
+ Common::Rect *optionalSrcRectPtr, Common::Rect *optionalclipRectPtr, int transferOp, MoonbaseDistortionInfo *mdi);
private:
diff --git a/engines/scumm/module.mk b/engines/scumm/module.mk
index 7ec4b06bbba..97d59993f8f 100644
--- a/engines/scumm/module.mk
+++ b/engines/scumm/module.mk
@@ -175,7 +175,6 @@ MODULE_OBJS += \
he/moonbase/ai_tree.o \
he/moonbase/ai_types.o \
he/moonbase/ai_weapon.o \
- he/moonbase/distortion.o \
he/moonbase/moonbase.o \
he/moonbase/moonbase_fow.o \
he/moonbase/moonbase_gfx.o
Commit: ec61ee97d8f87a822435fb9136feba3585802707
https://github.com/scummvm/scummvm/commit/ec61ee97d8f87a822435fb9136feba3585802707
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Fix build when ENABLE_HE is not defined
Changed paths:
engines/scumm/akos.h
diff --git a/engines/scumm/akos.h b/engines/scumm/akos.h
index 4820ec2d761..be130fb0dd6 100644
--- a/engines/scumm/akos.h
+++ b/engines/scumm/akos.h
@@ -127,11 +127,14 @@ protected:
byte paintCelCDATRLE(int xMoveCur, int yMoveCur);
byte paintCelMajMin(int xMoveCur, int yMoveCur);
byte paintCelTRLE(int actor, int drawToBack, int celX, int celY, int celWidth, int celHeight, byte tcolor, const byte *shadowTablePtr, int32 specialRenderFlags);
+
+#if defined(ENABLE_HE)
byte hePaintCel(
int actor, int drawToBack, int celX, int celY, int celWidth, int celHeight, byte tcolor, bool allowFlip, const byte *shadowTablePtr,
void (*drawPtr)(ScummEngine *vm, Wiz *wiz, WizRawPixel *, int, int, Common::Rect *, const byte *, int, int, Common::Rect *, byte, const byte *shadowTablePtr, const WizRawPixel *conversionTable, int32 specialRenderFlags),
const WizRawPixel *conversionTable,
int32 specialRenderFlags);
+#endif
void majMinCodecDecompress(byte *dest, int32 pitch, const byte *src, int32 t_width, int32 t_height, int32 dir, int32 numSkipBefore, int32 numSkipAfter, byte transparency, int maskLeft, int maskTop, int zBuf);
Commit: 6192dfe5c06481a627c8c0ccd08c1c741794418f
https://github.com/scummvm/scummvm/commit/6192dfe5c06481a627c8c0ccd08c1c741794418f
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Fix build and warnings
Changed paths:
engines/scumm/he/logic/moonbase_logic.cpp
engines/scumm/he/moonbase/moonbase_gfx.cpp
engines/scumm/he/script_v100he.cpp
engines/scumm/he/wiz_he.h
diff --git a/engines/scumm/he/logic/moonbase_logic.cpp b/engines/scumm/he/logic/moonbase_logic.cpp
index 17402dd6429..049f1d72f6c 100644
--- a/engines/scumm/he/logic/moonbase_logic.cpp
+++ b/engines/scumm/he/logic/moonbase_logic.cpp
@@ -467,10 +467,15 @@ bool LogicHEmoonbase::overrideImageHitTest(int *outValue, int globNum, int state
return false;
}
- if (!_vm->_wiz->moonbaseLayeredWizHitTest(outValue, 0, globPtr, state, x, y, flags, 0)) {
+ int32 actualValue = 0;
+ int32 eatValue = 0;
+
+ if (!_vm->_wiz->moonbaseLayeredWizHitTest(&eatValue, &actualValue, globPtr, state, x, y, flags, (uint32)0)) {
return false;
}
+ *outValue = (int)eatValue;
+
return true;
}
@@ -486,7 +491,7 @@ bool LogicHEmoonbase::overrideImagePixelHitTest(int *outValue, int globNum, int
int32 actualValue = ~0;
int32 eatValue = 0;
- if (!_vm->_wiz->moonbaseLayeredWizHitTest(&eatValue, &actualValue, globPtr, state, x, y, flags, 0)) {
+ if (!_vm->_wiz->moonbaseLayeredWizHitTest(&eatValue, &actualValue, globPtr, state, x, y, flags, (uint32)0)) {
return false;
}
diff --git a/engines/scumm/he/moonbase/moonbase_gfx.cpp b/engines/scumm/he/moonbase/moonbase_gfx.cpp
index 0106d16684e..63c14592a52 100644
--- a/engines/scumm/he/moonbase/moonbase_gfx.cpp
+++ b/engines/scumm/he/moonbase/moonbase_gfx.cpp
@@ -174,7 +174,7 @@ bool Wiz::drawMoonbaseLayeredWiz(
mappedRawbitmap.height = dstHeight;
mappedRawbitmap.dataSize = (mappedRawbitmap.width * sizeof(WizRawPixel16)) * mappedRawbitmap.height;
- if (dstPitch != (mappedRawbitmap.width * sizeof(WizRawPixel16))) {
+ if (dstPitch != (int)(mappedRawbitmap.width * sizeof(WizRawPixel16))) {
return false;
}
@@ -197,9 +197,9 @@ bool Wiz::drawMoonbaseLayeredWiz(
void Wiz::drawMoonbaseImageEx(
WizRawBitmap *bitmapPtr, WizImage *wizPtr, int x, int y, int state,
Common::Rect *clipRectPtr, int32 flags, Common::Rect *optionalSrcRect,
- int32 conditionBits, WizRawPixel16 *ptr8BppToXBppClut, byte *altSourceBuffer) {
+ uint32 conditionBits, WizRawPixel16 *ptr8BppToXBppClut, byte *altSourceBuffer) {
WizMoonbaseCompressedImage fakedHeader;
- int stateCompressionType;
+ int32 stateCompressionType;
WizRawBitmap fakedBitmap;
Common::Rect src, dstRect;
int32 sizeX, sizeY;
@@ -595,7 +595,7 @@ void Wiz::trleFLIPDecompMoonbaseImageHull(
}
}
-bool Wiz::moonbaseLayeredWizHitTest(int32 *outValue, int32 *optionalOutActualValue, byte *globPtr, int state, int x, int y, int32 flags, int32 conditionBits) {
+bool Wiz::moonbaseLayeredWizHitTest(int32 *outValue, int32 *optionalOutActualValue, byte *globPtr, int state, int x, int y, int32 flags, uint32 conditionBits) {
WizImage wiz;
wiz.data = globPtr;
@@ -636,17 +636,17 @@ bool Wiz::moonbaseLayeredWizHitTest(int32 *outValue, int32 *optionalOutActualVal
void Wiz::handleCompositeDrawMoonbaseImage(
WizRawBitmap *bitmapPtr, WizImage *wizPtr, byte *compositeInfoBlockPtr,
int x, int y, Common::Rect *srcRect, Common::Rect *clipRect,
- int32 flags, int32 conditionBits, int32 outerSizeX, int32 outerSizeY,
+ int32 flags, uint32 conditionBits, int32 outerSizeX, int32 outerSizeY,
WizRawPixel16 *ptr8BppToXBppClut, byte *altSourceBuffer) {
int layerCount, xPos, yPos, subState, cmdSize;
- int32 layerConditionBits, layerCmdDataBits;
- int32 subConditionBits, drawFlags;
+ uint32 layerConditionBits, layerCmdDataBits;
+ uint32 subConditionBits, drawFlags;
WizImage nestedMultiStateWiz;
byte *nestedBlockHeader;
byte *nestedWizHeader;
byte *cmdPtr;
- int32 conditionType;
+ uint32 conditionType;
int32 stateSizeX = 0, stateSizeY = 0;
// Get the nested block...
diff --git a/engines/scumm/he/script_v100he.cpp b/engines/scumm/he/script_v100he.cpp
index 2b75a491dcf..5df1e25ef31 100644
--- a/engines/scumm/he/script_v100he.cpp
+++ b/engines/scumm/he/script_v100he.cpp
@@ -2523,7 +2523,8 @@ void ScummEngine_v100he::o100_getSpriteGroupInfo() {
break;
case SO_NEW_GENERAL_PROPERTY:
type = pop();
- if (spriteGroupId = pop())
+ spriteGroupId = pop();
+ if (spriteGroupId)
push(_sprite->getGroupGeneralProperty(spriteGroupId, type));
else
push(0);
diff --git a/engines/scumm/he/wiz_he.h b/engines/scumm/he/wiz_he.h
index 5db2823f170..0f52c7796e4 100644
--- a/engines/scumm/he/wiz_he.h
+++ b/engines/scumm/he/wiz_he.h
@@ -660,13 +660,13 @@ public:
void handleCompositeDrawMoonbaseImage(
WizRawBitmap *bitmapPtr, WizImage *wizPtr, byte *compositeInfoBlockPtr,
int x, int y, Common::Rect *srcRect, Common::Rect *clipRect,
- int32 flags, int32 conditionBits, int32 outerSizeX, int32 outerSizeY,
+ int32 flags, uint32 conditionBits, int32 outerSizeX, int32 outerSizeY,
WizRawPixel16 *p8BppToXBppClut, byte *pAltSourceBuffer);
void drawMoonbaseImageEx(
WizRawBitmap *bitmapPtr, WizImage *wizPtr, int x, int y, int state,
Common::Rect *clipRectPtr, int32 flags, Common::Rect *optionalSrcRect,
- int32 conditionBits, WizRawPixel16 *p8BppToXBppClut, byte *pAltSourceBuffer);
+ uint32 conditionBits, WizRawPixel16 *p8BppToXBppClut, byte *pAltSourceBuffer);
bool getRawMoonbaseBitmapInfoForState(WizRawBitmap *bitmapPtr, WizImage *wizPtr, int state);
void rawMoonbaseBitmapBlit(WizRawBitmap *dstBitmap, Common::Rect *dstRectPtr, WizRawBitmap *srcBitmap, Common::Rect *srcRectPtr);
@@ -678,7 +678,7 @@ public:
WizRawPixel16 *bufferPtr, int bufferWidth, Common::Rect *destRect, byte *compData, Common::Rect *sourceRect, byte *extraPtr,
void (*functionPtr)(Wiz *wiz, WizRawPixel *destPtr, byte *dataStream, int skipAmount, int decompAmount, byte *extraPtr));
- bool moonbaseLayeredWizHitTest(int32 *outValue, int32 *pOptionalOutActualValue, byte *globPtr, int state, int x, int y, int32 flags, int32 dwConditionBits);
+ bool moonbaseLayeredWizHitTest(int32 *outValue, int32 *optionalOutActualValue, byte *globPtr, int state, int x, int y, int32 flags, uint32 conditionBits);
void dispatchBlitRGB555(
byte *bufferData, int bufferWidth, int bufferHeight, int bufferPitch,
Commit: 6f5878aed546e89ee85ed58e17355c5f675cdf44
https://github.com/scummvm/scummvm/commit/6f5878aed546e89ee85ed58e17355c5f675cdf44
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Hopefully fix MSVC win32 errors
Changed paths:
engines/scumm/he/sprite_he.cpp
engines/scumm/he/wiz_he.cpp
engines/scumm/he/wiz_he.h
diff --git a/engines/scumm/he/sprite_he.cpp b/engines/scumm/he/sprite_he.cpp
index 76dec28880a..47a89ca9754 100644
--- a/engines/scumm/he/sprite_he.cpp
+++ b/engines/scumm/he/sprite_he.cpp
@@ -454,7 +454,7 @@ void Sprite::getSpriteRectPrim(const SpriteInfo *spritePtr, Common::Rect *rectPt
if (angleSpecified || scaleSpecified) {
Common::Point listOfPoints[4];
- int w, h;
+ int32 w, h;
_vm->_wiz->getWizImageDim(image, state, w, h);
@@ -489,7 +489,7 @@ void Sprite::getSpriteRectPrim(const SpriteInfo *spritePtr, Common::Rect *rectPt
_vm->_wiz->polyBuildBoundingRect(listOfPoints, 4, *rectPtr);
} else {
- int w, h;
+ int32 w, h;
_vm->_wiz->getWizImageDim(image, state, w, h);
rectPtr->left = tmpPt.x;
@@ -941,7 +941,7 @@ void Sprite::setSpriteZBuffer(int spriteId, int value) {
void Sprite::setSpriteAnimSpeedState(int spriteId, int animState) {
assertRange(1, spriteId, _maxSprites, "sprite");
- _spriteTable[spriteId].animState = MAX(0, MIN(animState, _spriteTable[spriteId].animSpeed));
+ _spriteTable[spriteId].animState = MAX<int32>(0, MIN<int32>(animState, _spriteTable[spriteId].animSpeed));
}
void Sprite::setSpriteGeneralProperty(int spriteId, int property, int value) {
@@ -1768,7 +1768,7 @@ void Sprite::renderSprites(bool negativeOrPositiveRender) {
spritePtr[i]->lastState = state;
spritePtr[i]->lastSpot = spot;
- int w, h;
+ int32 w, h;
_vm->_wiz->getWizImageDim(image, state, w, h);
spritePtr[i]->lastRect.left = spot.x;
diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp
index c8c10824171..6e737d73e23 100644
--- a/engines/scumm/he/wiz_he.cpp
+++ b/engines/scumm/he/wiz_he.cpp
@@ -915,7 +915,7 @@ void Wiz::processWizImagePolyCaptureCmd(const WizImageCommand *params) {
if (srcImage) {
// get the wiz size
Common::Rect clipRect;
- int w, h;
+ int32 w, h;
getWizImageDim(srcImage, state, w, h);
clipRect.left = 0;
@@ -1566,7 +1566,7 @@ int Wiz::dwTryToLoadWiz(Common::SeekableReadStream *inFile, const WizImageComman
void Wiz::dwAltSourceDrawWiz(int maskImage, int maskState, int x, int y, int sourceImage, int sourceState, int32 flags, int paletteNumber, const Common::Rect *optionalClipRect, const WizSimpleBitmap *destBitmapPtr) {
int srcBitsPerPixel, sourceCompressionType, maskCompressionType;
- int srcBitmapWidth, srcBitmapHeight, maskWidth, maskHeight;
+ int32 srcBitmapWidth, srcBitmapHeight, maskWidth, maskHeight;
Common::Rect clipRect, destRect;
WizSimpleBitmap drawBufferBitmap;
WizRawPixel *conversionTable;
@@ -1708,7 +1708,8 @@ void Wiz::dwAltSourceDrawWiz(int maskImage, int maskState, int x, int y, int sou
}
void Wiz::dwHandleComplexImageDraw(int image, int state, int x, int y, int shadow, int angle, int scale, const Common::Rect *clipRect, int32 flags, WizSimpleBitmap *optionalBitmapOverride, const WizRawPixel *optionalColorConversionTable) {
- int w, h, correctedAngle;
+ int32 w, h;
+ int correctedAngle;
Common::Point listOfPoints[4];
const byte *shadowPtr;
@@ -1886,7 +1887,7 @@ void Wiz::handleRotate90SpecialCase(int image, int state, int x, int y, int shad
int compressionType;
// Make the update rect and check it against the clip rect if one...
- int w, h;
+ int32 w, h;
getWizImageDim(image, state, w, h);
makeSizedRectAt(&updateRect, x, y, h, w); // We are swapping height and width on purpose!
@@ -2007,7 +2008,8 @@ void Wiz::handleRotate270SpecialCase(int image, int state, int x, int y, int sha
void Wiz::processWizImageRenderRectCmd(const WizImageCommand *params) {
Common::Rect renderRect, clipRect, workClipRect;
- int whichState, w, h, whichImage;
+ int whichState, whichImage;
+ int32 w, h;
WizSimpleBitmap renderBitmap;
WizRawPixel whatColor;
@@ -2064,7 +2066,8 @@ void Wiz::processWizImageRenderRectCmd(const WizImageCommand *params) {
void Wiz::processWizImageRenderLineCmd(const WizImageCommand *params) {
Common::Rect clipRect, workClipRect;
- int whichState, w, h, whichImage;
+ int whichState, whichImage;
+ int32 w, h;
WizSimpleBitmap renderBitmap;
WizRawPixel whatColor;
int propertyNumber = 0, propertyValue = 0;
@@ -2150,7 +2153,8 @@ void Wiz::processWizImageRenderLineCmd(const WizImageCommand *params) {
void Wiz::processWizImageRenderPixelCmd(const WizImageCommand *params) {
Common::Rect clipRect, workClipRect;
- int whichState, w, h, whichImage;
+ int whichState, whichImage;
+ int32 w, h;
WizSimpleBitmap renderBitmap;
WizRawPixel whatColor;
Common::Point pt;
@@ -2296,7 +2300,7 @@ void Wiz::ensureNativeFormatImageForState(int image, int state) {
if (wiz16bpp && !native) {
uint16 *ptr = (uint16 *)getWizStateDataPrim(image, state);
- int w, h;
+ int32 w, h;
getWizImageDim(image, state, w, h);
int32 pixelCount = w * h; // Number of pixels to twiddle
@@ -2347,7 +2351,7 @@ void Wiz::processWizImageModifyCmd(const WizImageCommand *params) {
void Wiz::processWizImageRenderEllipseCmd(const WizImageCommand *params) {
int whichState = 0, propertyValue = 0;
- int width = 0, height = 0;
+ int32 width = 0, height = 0;
if (params->actionFlags & kWAFProperty) {
propertyValue = params->propertyValue;
diff --git a/engines/scumm/he/wiz_he.h b/engines/scumm/he/wiz_he.h
index 0f52c7796e4..44778265588 100644
--- a/engines/scumm/he/wiz_he.h
+++ b/engines/scumm/he/wiz_he.h
@@ -266,23 +266,23 @@ struct FloodFillCommand {
struct WizSimpleBitmap {
WizRawPixel *bufferPtr;
- int bitmapWidth;
- int bitmapHeight;
+ int32 bitmapWidth;
+ int32 bitmapHeight;
};
struct WizMultiTypeBitmap {
byte *data;
- int width;
- int height;
- int stride;
- int format;
- int bpp;
+ int32 width;
+ int32 height;
+ int32 stride;
+ int32 format;
+ int32 bpp;
};
struct WizRawBitmap {
- int width;
- int height;
- int dataSize;
+ int32 width;
+ int32 height;
+ int32 dataSize;
WizRawPixel16 *data;
};
Commit: e338e0912a65e79ccfdb86e482d8afdd0e809479
https://github.com/scummvm/scummvm/commit/e338e0912a65e79ccfdb86e482d8afdd0e809479
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Fix formatting
Changed paths:
engines/scumm/he/moonbase/moonbase_fow.cpp
diff --git a/engines/scumm/he/moonbase/moonbase_fow.cpp b/engines/scumm/he/moonbase/moonbase_fow.cpp
index d0f8e541594..f16877156f5 100644
--- a/engines/scumm/he/moonbase/moonbase_fow.cpp
+++ b/engines/scumm/he/moonbase/moonbase_fow.cpp
@@ -356,42 +356,42 @@ void Moonbase::renderFOW(WizMultiTypeBitmap *destSurface) {
if (!_fowImage)
return;
- const int32 *pOutterRenderTable = _fowRenderTable;
+ const int32 *outerRenderTable = _fowRenderTable;
int ixPos = ((_fowVtx1 * _fowTileW) - _fowMvx) + _fowDrawX;
int yPos = ((_fowVty1 * _fowTileH) - _fowMvy) + _fowDrawY;
int dataOffset = _fowVw * 3;
int halfTileHeight = _fowTileH / 2;
- int cx2 = MIN(_fowClipX2, (destSurface->width - 1));
- int cy2 = MIN(_fowClipY2, (destSurface->height - 1));
+ int cx2 = MIN<int>(_fowClipX2, (int)(destSurface->width - 1));
+ int cy2 = MIN<int>(_fowClipY2, (int)(destSurface->height - 1));
for (int ry = 0; ry < _fowVh; ry++) {
- int real_yPos = yPos;
+ int realYPos = yPos;
for (int i = 0; i < 2; i++) {
- const int32 *pRenderTable = pOutterRenderTable;
- pOutterRenderTable += dataOffset;
+ const int32 *renderTable = outerRenderTable;
+ outerRenderTable += dataOffset;
int xPos = ixPos;
for (int rx = 0; rx < _fowVw; rx++) {
- int nState = *pRenderTable++;
+ int state = *renderTable++;
- if (nState != 0) {
- if (nState == 2) {
+ if (state != 0) {
+ if (state == 2) {
int countLeft = (_fowVw - rx);
int count = 0;
for (; count < countLeft; count++) {
- if (*(pRenderTable + count) != 2)
+ if (*(renderTable + count) != 2)
break;
- pRenderTable++;
+ renderTable++;
rx++;
}
count++;
int x1 = xPos;
- int y1 = real_yPos;
+ int y1 = realYPos;
xPos += _fowTileW * count;
int x2 = (xPos - 1);
@@ -407,10 +407,10 @@ void Moonbase::renderFOW(WizMultiTypeBitmap *destSurface) {
} else {
int subState;
- if ((subState = *pRenderTable++) != 0)
+ if ((subState = *renderTable++) != 0)
renderFOWState(destSurface, xPos, yPos, (subState + _fowFrameBaseNumber));
- if ((subState = *pRenderTable++) != 0)
+ if ((subState = *renderTable++) != 0)
renderFOWState(destSurface, xPos, yPos, (subState + _fowFrameBaseNumber));
xPos += _fowTileW;
@@ -420,7 +420,7 @@ void Moonbase::renderFOW(WizMultiTypeBitmap *destSurface) {
}
}
- real_yPos += halfTileHeight;
+ realYPos += halfTileHeight;
}
yPos += _fowTileH;
Commit: f48a0ac1c1ac8214dfb2b88134787ebb8dbf4c17
https://github.com/scummvm/scummvm/commit/f48a0ac1c1ac8214dfb2b88134787ebb8dbf4c17
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-04-26T23:21:29+02:00
Commit Message:
SCUMM: HE: Fix another win32 build error
Changed paths:
engines/scumm/he/wiz_he.cpp
diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp
index 6e737d73e23..bd2a67b441c 100644
--- a/engines/scumm/he/wiz_he.cpp
+++ b/engines/scumm/he/wiz_he.cpp
@@ -2411,7 +2411,8 @@ void Wiz::processWizImageFontRenderCmd(const WizImageCommand *params) {
void Wiz::processWizImageRenderFloodFillCmd(const WizImageCommand *params) {
Common::Rect renderRect, clipRect, workClipRect;
- int whichState, w, h, whichImage;
+ int whichState, whichImage;
+ int32 w, h;
WizSimpleBitmap renderBitmap;
WizRawPixel whatColor;
Common::Point pt;
More information about the Scummvm-git-logs
mailing list