Skip to content

Commit

Permalink
Engine: fixed inventory cursor hotspot drawing over 32-bit ARGB sprites
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-mogilko committed Dec 19, 2024
1 parent f47f70a commit 5628477
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 16 deletions.
10 changes: 3 additions & 7 deletions Engine/ac/draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1280,13 +1280,9 @@ void draw_game_screen_callback()
construct_game_screen_overlay(false);
}

void putpixel_compensate (Bitmap *ds, int xx,int yy, int col) {
if ((ds->GetColorDepth() == 32) && (col != 0)) {
// ensure the alpha channel is preserved if it has one
int alphaval = geta32(ds->GetPixel(xx, yy));
col = makeacol32(getr32(col), getg32(col), getb32(col), alphaval);
}
ds->FillRect(Rect(xx, yy, xx + get_fixed_pixel_size(1) - 1, yy + get_fixed_pixel_size(1) - 1), col);
void putpixel_scaled(Bitmap *ds, int x, int y, int col)
{
ds->FillRect(Rect(x, y, x + get_fixed_pixel_size(1) - 1, y + get_fixed_pixel_size(1) - 1), col);
}

void draw_sprite_support_alpha(Bitmap *ds, bool ds_has_alpha, int xpos, int ypos, Bitmap *image, bool src_has_alpha,
Expand Down
4 changes: 3 additions & 1 deletion Engine/ac/draw.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,16 @@ void draw_gui_sprite(Common::Bitmap *ds, int pic, int x, int y, bool use_alpha,
void draw_gui_sprite_v330(Common::Bitmap *ds, int pic, int x, int y, bool use_alpha = true, Common::BlendMode blend_mode = Common::kBlendMode_Alpha);
void draw_gui_sprite(Common::Bitmap *ds, bool use_alpha, int xpos, int ypos,
Common::Bitmap *image, bool src_has_alpha, Common::BlendMode blend_mode = Common::kBlendMode_Alpha, int alpha = 0xFF);
// Puts a pixel of certain color, scales it if running in upscaled resolution (legacy feature)
void putpixel_scaled(Common::Bitmap *ds, int x, int y, int col);

// Render game on screen
void render_to_screen();
// Callbacks for the graphics driver
void draw_game_screen_callback();
void GfxDriverOnInitCallback(void *data);
bool GfxDriverSpriteEvtCallback(int evt, int data);
void putpixel_compensate (Common::Bitmap *g, int xx,int yy, int col);

// Create the actsps[objid] image with the object drawn correctly.
// Returns true if nothing at all has changed and actsps is still
// intact from last time; false otherwise.
Expand Down
14 changes: 6 additions & 8 deletions Engine/ac/mouse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,16 +165,14 @@ void set_mouse_cursor(int newcurs, bool force_update)
}
else
{
putpixel_compensate(gen_cursor.get(), hotspotx, hotspoty, MakeColor(game.hotdot));

putpixel_scaled(gen_cursor.get(), hotspotx, hotspoty, MakeColor(game.hotdot));
if (game.hotdotouter > 0)
{
int outercol = MakeColor(game.hotdotouter);

putpixel_compensate(gen_cursor.get(), hotspotx + get_fixed_pixel_size(1), hotspoty, outercol);
putpixel_compensate(gen_cursor.get(), hotspotx, hotspoty + get_fixed_pixel_size(1), outercol);
putpixel_compensate(gen_cursor.get(), hotspotx - get_fixed_pixel_size(1), hotspoty, outercol);
putpixel_compensate(gen_cursor.get(), hotspotx, hotspoty - get_fixed_pixel_size(1), outercol);
const int outercol = MakeColor(game.hotdotouter);
putpixel_scaled(gen_cursor.get(), hotspotx + get_fixed_pixel_size(1), hotspoty, outercol);
putpixel_scaled(gen_cursor.get(), hotspotx, hotspoty + get_fixed_pixel_size(1), outercol);
putpixel_scaled(gen_cursor.get(), hotspotx - get_fixed_pixel_size(1), hotspoty, outercol);
putpixel_scaled(gen_cursor.get(), hotspotx, hotspoty - get_fixed_pixel_size(1), outercol);
}
}

Expand Down

0 comments on commit 5628477

Please sign in to comment.