[80] | 1 | /********************************************************************** <BR>
|
---|
| 2 | This file is part of Crack dot Com's free source code release of
|
---|
| 3 | Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
|
---|
| 4 | information about compiling & licensing issues visit this URL</a>
|
---|
| 5 | <PRE> If that doesn't help, contact Jonathan Clark at
|
---|
| 6 | golgotha_source@usa.net (Subject should have "GOLG" in it)
|
---|
| 7 | ***********************************************************************/
|
---|
| 8 |
|
---|
| 9 | #include "video/win32/dx5_util.hh"
|
---|
| 10 | #include "video/win32/dx5_mouse.hh"
|
---|
| 11 | #include "image/context.hh"
|
---|
| 12 | #include "video/win32/dx5_error.hh"
|
---|
| 13 |
|
---|
| 14 | #include <ddraw.h>
|
---|
| 15 |
|
---|
| 16 | dx5_mouse_class::dx5_mouse_class(i4_bool page_flipped)
|
---|
| 17 | : page_flipped(page_flipped)
|
---|
| 18 | {
|
---|
| 19 | cursor.pict=0;
|
---|
| 20 | }
|
---|
| 21 |
|
---|
| 22 | void dx5_mouse_class::set_cursor(i4_cursor_class *c)
|
---|
| 23 | {
|
---|
| 24 | if (cursor.pict)
|
---|
| 25 | {
|
---|
| 26 | delete cursor.pict;
|
---|
| 27 | cursor.pict=0;
|
---|
| 28 | }
|
---|
| 29 |
|
---|
| 30 | if (c && c->pict)
|
---|
| 31 | {
|
---|
| 32 | int cw=c->pict->width(), ch=c->pict->height();
|
---|
| 33 |
|
---|
| 34 | i4_draw_context_class context(0,0, cw-1, ch-1);
|
---|
| 35 |
|
---|
| 36 | i4_dx5_image_class *dx5_image = new i4_dx5_image_class(cw, ch, DX5_VRAM | DX5_CLEAR);
|
---|
| 37 |
|
---|
| 38 | //setup the color-key value for the mouse (black)
|
---|
| 39 | DDCOLORKEY colorkey;
|
---|
| 40 | memset(&colorkey,0,sizeof(DDCOLORKEY));
|
---|
| 41 |
|
---|
| 42 | //i4_color converted_transparent = c->pict->pal.pal->convert(c->trans,&dx5_common.i4_fmt_565);
|
---|
| 43 |
|
---|
| 44 | colorkey.dwColorSpaceLowValue = 0;//converted_transparent;
|
---|
| 45 | colorkey.dwColorSpaceHighValue = 0;//converted_transparent;
|
---|
| 46 |
|
---|
| 47 | dx5_image->surface->SetColorKey(DDCKEY_SRCBLT,&colorkey);
|
---|
| 48 |
|
---|
| 49 | cursor = *c;
|
---|
| 50 | cursor.pict = dx5_image;
|
---|
| 51 |
|
---|
| 52 | dx5_image->lock();
|
---|
| 53 | c->pict->put_image_trans(cursor.pict, 0,0, c->trans, context);
|
---|
| 54 | dx5_image->unlock();
|
---|
| 55 | }
|
---|
| 56 | }
|
---|
| 57 |
|
---|
| 58 | dx5_mouse_class::~dx5_mouse_class()
|
---|
| 59 | {
|
---|
| 60 | if (cursor.pict)
|
---|
| 61 | {
|
---|
| 62 | delete cursor.pict;
|
---|
| 63 | cursor.pict=0;
|
---|
| 64 | }
|
---|
| 65 | }
|
---|
| 66 |
|
---|
| 67 |
|
---|
| 68 | void dx5_mouse_class::save_and_draw(int x, int y)
|
---|
| 69 | {
|
---|
| 70 | if (!cursor.pict) return ;
|
---|
| 71 |
|
---|
| 72 | if (!current.save_buffer ||
|
---|
| 73 | current.save_buffer->width() != cursor.pict->width() ||
|
---|
| 74 | current.save_buffer->height() != cursor.pict->height())
|
---|
| 75 | {
|
---|
| 76 | if (current.save_buffer)
|
---|
| 77 | delete current.save_buffer;
|
---|
| 78 |
|
---|
| 79 | current.save_buffer=new i4_dx5_image_class(cursor.pict->width(), cursor.pict->height(),
|
---|
| 80 | DX5_VRAM);
|
---|
| 81 | }
|
---|
| 82 |
|
---|
| 83 | current.x=x - cursor.hot_x; current.y=y - cursor.hot_y;
|
---|
| 84 | if (current.x<0) current.x=0;
|
---|
| 85 | if (current.y<0) current.y=0;
|
---|
| 86 |
|
---|
| 87 |
|
---|
| 88 | RECT src;
|
---|
| 89 | src.left = current.x;
|
---|
| 90 | src.right = current.x + cursor.pict->width();
|
---|
| 91 | src.top = current.y;
|
---|
| 92 | src.bottom = current.y + cursor.pict->height();
|
---|
| 93 |
|
---|
| 94 | i4_dx5_check(current.save_buffer->surface->BltFast(0,0, dx5_common.back_surface, &src,DDBLTFAST_NOCOLORKEY));
|
---|
| 95 |
|
---|
| 96 |
|
---|
| 97 | i4_dx5_check(dx5_common.back_surface->BltFast(current.x, current.y,
|
---|
| 98 | ((i4_dx5_image_class *)cursor.pict)->surface,0 ,
|
---|
| 99 | DDBLTFAST_SRCCOLORKEY));
|
---|
| 100 |
|
---|
| 101 | if (page_flipped)
|
---|
| 102 | {
|
---|
| 103 | save_struct tmp=current;
|
---|
| 104 | current=last;
|
---|
| 105 | last=tmp;
|
---|
| 106 | tmp.save_buffer=0;
|
---|
| 107 | }
|
---|
| 108 |
|
---|
| 109 | }
|
---|
| 110 |
|
---|
| 111 |
|
---|
| 112 | void dx5_mouse_class::restore()
|
---|
| 113 | {
|
---|
| 114 |
|
---|
| 115 | if (current.save_buffer)
|
---|
| 116 | {
|
---|
| 117 | RECT src;
|
---|
| 118 | src.left = 0;
|
---|
| 119 | src.right = cursor.pict->width();
|
---|
| 120 | src.top = 0;
|
---|
| 121 | src.bottom = cursor.pict->height();
|
---|
| 122 |
|
---|
| 123 | dx5_common.back_surface->BltFast(current.x, current.y, current.save_buffer->surface, &src,
|
---|
| 124 | DDBLTFAST_NOCOLORKEY);
|
---|
| 125 | }
|
---|
| 126 | }
|
---|