Allegro.cc - Online Community

Allegro.cc Forums » Allegro Development » draw_sprite and system bitmap subbitmap failure code and images

This thread is locked; no one can reply to it. rss feed Print
 1   2 
draw_sprite and system bitmap subbitmap failure code and images
Thomas Harte
Member #33
April 2000
avatar

Quote:

with the power of AXL

Don't forget the firepower of Billy!

Richard Phipps
Member #1,632
November 2001
avatar

Neil Walker
Member #210
April 2000
avatar

I created a fullscreen bitmap (video/memory/system) and did set_clip_rect(page1,50,50,250,300);

I then did some blit, draw_sprite and masked_blit of both subbitmaps and normal bitmaps over the screen. The only thing to show was the stuff in the clipping rectangle.

All was well. Hope that helps.

Neil.
MAME Cabinet Blog / AXL LIBRARY (a games framework) / AXL Documentation and Tutorial

wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie

Evert
Member #794
November 2000
avatar

And if you remove teh clipping code from ddraw_draw_sprite()?

Neil Walker
Member #210
April 2000
avatar

ok, I added a clipping region to my back buffer (as above) and then modified wdaccel.c to be:

1static void ddraw_draw_sprite(BITMAP * bmp, BITMAP * sprite, int x, int y)
2{
3 int sx, sy, w, h;
4 
5 if (is_video_bitmap(sprite) || is_system_bitmap(sprite)) {
6 sx = 0;
7 sy = 0;
8 w = sprite->w;
9 h = sprite->h;
10/*
11 if (bmp->clip) {
12 if (x < bmp->cl) {
13 sx += bmp->cl - x;
14 w -= bmp->cl - x;
15 x = bmp->cl;
16 }
17
18 if (y < bmp->ct) {
19 sy += bmp->ct - y;
20 h -= bmp->ct - y;
21 y = bmp->ct;
22 }
23
24 if (x + w > bmp->cr)
25 w = bmp->cr - x;
26
27 if (w <= 0)
28 return;
29
30 if (y + h > bmp->cb)
31 h = bmp->cb - y;
32
33 if (h <= 0)
34 return;
35 }
36*/
37 ddraw_masked_blit(sprite, bmp, sx, sy, x, y, w, h);
38 }
39 else {
40 /* have to use the original software version */
41 _orig_draw_sprite(bmp, sprite, x, y);
42 }
43}

And something quite strange happened. If sprite was a video/system bitmap, i.e. it follows the ddraw_masked_blit route (but no clipping code is now there) and the destination (bmp) was a memory bitmap, it honoured the clip that we set in our code for bmp. All well with the removal of the code then...

However, if bmp is a system or video bitmap (i.e. we are drawing a system or video bitmap onto a video or system bitmap), then the clipping region is ignored for draw_sprite (masked_blit is still ok).

So it appears to me that removing the clipping code should be fine, but something odd is going on in the video bitmap code, not related to draw_sprite?

Neil.
MAME Cabinet Blog / AXL LIBRARY (a games framework) / AXL Documentation and Tutorial

wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie

Evert
Member #794
November 2000
avatar

Quote:

What do you think of this patch? (untested)

Looks ok to me. Did anyone test it?

Quote:

So it appears to me that removing the clipping code should be fine, but something odd is going on in the video bitmap code, not related to draw_sprite?

And if you leave the clipping code in?
It stands to reason that it's there because someone figured it was nescesary, so maybe this is why.

Neil Walker
Member #210
April 2000
avatar

Possibly it is there for that reason, but when I had a quick look at the masked_blit function it didn't do any clipping checks. But I guess thinking about it I might have been looking at the wrong function as there are a few different blitting functions for each one (e.g. original, ddraw_, etc).

I'll check again tomorrow, unless someone else does it for me beforehand.

Neil.
MAME Cabinet Blog / AXL LIBRARY (a games framework) / AXL Documentation and Tutorial

wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie

 1   2 


Go to: