diff -ur ScummVM-cvs20020917/scummvm/scumm/gfx.cpp ScummVM-cvs20020917+hack/scummvm/scumm/gfx.cpp
old
|
new
|
|
3068 | 3068 | |
3069 | 3069 | static byte blend(byte *pal, byte method, int dest_color) |
3070 | 3070 | { |
3071 | | double val = 1.0; |
| 3071 | int val = 0; |
3072 | 3072 | int cache = 0; |
3073 | 3073 | |
| 3074 | // FIXME: Check if this gives the correct blending for the Dig |
| 3075 | // inventory box and conversation menus. For now, I have deliberately |
| 3076 | // selected them so that the subsequent multiplication and shift could |
| 3077 | // be replaced by just a shift. |
| 3078 | |
3074 | 3079 | switch (method) { |
3075 | 3080 | case 1: |
3076 | 3081 | cache = 0; |
3077 | | val = 0.5; |
| 3082 | val = 128; |
3078 | 3083 | break; |
3079 | 3084 | |
3080 | 3085 | case 2: |
3081 | 3086 | cache = 1; |
3082 | | val = 0.4; |
| 3087 | val = 64; |
3083 | 3088 | break; |
3084 | 3089 | |
3085 | 3090 | case 3: |
3086 | 3091 | cache = 2; |
3087 | | val = 1.1; |
| 3092 | val = 256; |
3088 | 3093 | break; |
3089 | 3094 | |
3090 | 3095 | case 255: |
… |
… |
|
3099 | 3104 | byte g = *(pal + 3 * dest_color + 1); |
3100 | 3105 | byte b = *(pal + 3 * dest_color + 2); |
3101 | 3106 | |
3102 | | int new_r = (int) (val * r + 0.5); |
3103 | | int new_g = (int) (val * g + 0.5); |
3104 | | int new_b = (int) (val * b + 0.5); |
| 3107 | int new_r = (val * r) >> 8; |
| 3108 | int new_g = (val * g) >> 8; |
| 3109 | int new_b = (val * b) >> 8; |
3105 | 3110 | |
3106 | 3111 | if (new_r > 255) |
3107 | 3112 | new_r = 255; |
… |
… |
|
3117 | 3122 | } |
3118 | 3123 | |
3119 | 3124 | // param3= clipping |
3120 | | |
3121 | 3125 | // param2= mirror |
3122 | | |
3123 | 3126 | // param1= never used ? |
| 3127 | |
3124 | 3128 | void Scumm::drawBomp(BompDrawData *bd, int param1, byte *dataPtr, int param2, int param3) |
3125 | 3129 | { |
3126 | 3130 | byte *scale_rows = NULL; |
… |
… |
|
3142 | 3146 | } |
3143 | 3147 | } |
3144 | 3148 | |
3145 | | if (bd->scale_y != 255) { |
| 3149 | if (bd->scale_y != 255) { |
3146 | 3150 | scale_cols = (byte *) calloc(bd->srcwidth, 1); |
3147 | 3151 | if (scale_cols == NULL) { |
3148 | 3152 | warning("drawBomp: out of memory"); |
| 3153 | if (scale_rows) |
| 3154 | free(scale_rows); |
3149 | 3155 | return; |
3150 | 3156 | } |
3151 | 3157 | } |
… |
… |
|
3166 | 3172 | scale_rows[(i * 255) / bd->scale_y] = 1; |
3167 | 3173 | } |
3168 | 3174 | |
| 3175 | // FIXME: Be more intelligent about clearing the blend cache. It |
| 3176 | // should be possible to clear it only for the parts of the palette |
| 3177 | // that have changed since the last time. |
| 3178 | |
3169 | 3179 | clear_blend_cache(); |
3170 | 3180 | |
3171 | 3181 | dest += bd->x; |
3172 | 3182 | src = bd->dataptr; |
| 3183 | |
3173 | 3184 | for (src_y = 0, dst_y = bd->y; src_y < bd->srcheight; src_y++) { |
3174 | 3185 | byte code, color; |
3175 | 3186 | uint len, num; |
3176 | 3187 | byte *d = dest; |
3177 | 3188 | |
3178 | | if (dst_y < 0 || dst_y >= bd->outheight) { |
| 3189 | if (dst_y < 0 || dst_y >= bd->outheight || (bd->scale_y != 255 && !scale_rows[src_y])) { |
3179 | 3190 | src += READ_LE_UINT16(src) + 2; |
3180 | 3191 | continue; |
3181 | 3192 | } |
… |
… |
|
3193 | 3204 | len -= num; |
3194 | 3205 | if (code & 1) { |
3195 | 3206 | color = *src++; |
3196 | | if (bd->scale_y == 255 || scale_rows[src_y]) { |
3197 | | do { |
3198 | | if (dst_x >= 0 && dst_x < bd->outwidth && (bd->scale_x || scale_cols[src_x])) |
| 3207 | for (i = 0; i < num; i++) { |
| 3208 | if (bd->scale_x == 255 || scale_cols[src_x]) { |
| 3209 | if (dst_x >= 0 && dst_x < bd->outwidth) |
3199 | 3210 | *d = blend(_currentPalette, color, *d); |
3200 | | if (bd->scale_x == 255 || scale_cols[src_x]) { |
3201 | | d++; |
3202 | | dst_x++; |
3203 | | } |
3204 | | src_x++; |
3205 | | } while (--num); |
3206 | | } else { |
3207 | | src_x += num; |
3208 | | dst_x += num; |
| 3211 | d++; |
| 3212 | dst_x++; |
| 3213 | } |
| 3214 | src_x++; |
3209 | 3215 | } |
3210 | 3216 | } else { |
3211 | | if (bd->scale_y == 255 || scale_rows[src_y]) { |
3212 | | for (i = 0; i < num; i++) { |
3213 | | if (dst_x >= 0 && dst_x < bd->outwidth && (bd->scale_x || scale_cols[src_x])) |
| 3217 | for (i = 0; i < num; i++) { |
| 3218 | if (bd->scale_x == 255 || scale_cols[src_x]) { |
| 3219 | if (dst_x >= 0 && dst_x < bd->outwidth) |
3214 | 3220 | *d = blend(_currentPalette, src[i], *d); |
3215 | | if (bd->scale_x == 255 || scale_cols[src_x]) { |
3216 | | d++; |
3217 | | dst_x++; |
3218 | | } |
3219 | | src_x++; |
| 3221 | d++; |
| 3222 | dst_x++; |
3220 | 3223 | } |
3221 | | } else { |
3222 | | dst_x += num; |
3223 | | src_x += num; |
| 3224 | src_x++; |
3224 | 3225 | } |
3225 | 3226 | src += num; |
3226 | 3227 | } |
3227 | 3228 | } |
3228 | | if (bd->scale_y == 255 || scale_rows[src_y]) { |
3229 | | dest += bd->outwidth; |
3230 | | dst_y++; |
3231 | | } |
| 3229 | dest += bd->outwidth; |
| 3230 | dst_y++; |
3232 | 3231 | } |
3233 | 3232 | |
3234 | 3233 | if (scale_rows) |