stratagus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Stratagus-CVS] stratagus/src clone/mainloop.c editor/editloop....


From: address@hidden
Subject: [Stratagus-CVS] stratagus/src clone/mainloop.c editor/editloop....
Date: 14 Dec 2003 03:14:51 +1100

CVSROOT:        /home/strat
Module name:    stratagus
Changes by:      <address@hidden>       03/12/14 03:14:49

Modified files:
        src/clone      : mainloop.c 
        src/editor     : editloop.c 
        src/game       : intro.c 
        src/include    : menus.h missile.h video.h 
        src/missile    : ccl_missile.c missile.c 
        src/ui         : ccl_ui.c menu_proc.c menus.c 
        src/video      : sprite.c 

Log message:
        Added support for transparent missiles and menus for 16 and 32 bpp only

Patches:
Index: stratagus/src/clone/mainloop.c
diff -u stratagus/src/clone/mainloop.c:1.167 
stratagus/src/clone/mainloop.c:1.168
--- stratagus/src/clone/mainloop.c:1.167        Tue Dec  2 15:00:12 2003
+++ stratagus/src/clone/mainloop.c      Sun Dec 14 03:14:43 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: mainloop.c,v 1.167 2003/12/02 04:00:12 nehalmistry Exp $
+//     $Id: mainloop.c,v 1.168 2003/12/13 16:14:43 mohydine Exp $
 
 //@{
 
@@ -274,30 +274,33 @@
            TheUI.MenuPanelX, TheUI.MenuPanelY);
     }
     if (NetworkFildes == (Socket)-1) {
+               //FIX ME: Transparent flag, 3rd param, has been hardcoded.
        if (TheUI.MenuButton.X != -1) {
            DrawMenuButton(TheUI.MenuButton.Button,
                (ButtonAreaUnderCursor == ButtonAreaMenu
                    && ButtonUnderCursor == ButtonUnderMenu ? MenuButtonActive 
: 0) |
-               (GameMenuButtonClicked ? MenuButtonClicked : 0),
+               (GameMenuButtonClicked ? MenuButtonClicked : 0), 0, 
                TheUI.MenuButton.Width, TheUI.MenuButton.Height,
                TheUI.MenuButton.X, TheUI.MenuButton.Y,
                GameFont, TheUI.MenuButton.Text, NULL, NULL);
        }
     } else {
        if (TheUI.NetworkMenuButton.X != -1) {
+               //FIX ME: Transparent flag, 3rd param, has been hardcoded.
            DrawMenuButton(TheUI.NetworkMenuButton.Button,
                (ButtonAreaUnderCursor == ButtonAreaMenu
                    && ButtonUnderCursor == ButtonUnderNetworkMenu ? 
MenuButtonActive : 0) |
-               (GameMenuButtonClicked ? MenuButtonClicked : 0),
+               (GameMenuButtonClicked ? MenuButtonClicked : 0),/*Transparent*/ 
0,
                TheUI.NetworkMenuButton.Width, TheUI.NetworkMenuButton.Height,
                TheUI.NetworkMenuButton.X, TheUI.NetworkMenuButton.Y,
                GameFont, TheUI.NetworkMenuButton.Text, NULL, NULL);
        }
        if (TheUI.NetworkDiplomacyButton.X != -1) {
+               //FIX ME: Transparent flag, 3rd param, has been hardcoded.
            DrawMenuButton(TheUI.NetworkDiplomacyButton.Button,
                (ButtonAreaUnderCursor == ButtonAreaMenu
                    && ButtonUnderCursor == ButtonUnderNetworkDiplomacy ? 
MenuButtonActive : 0) |
-               (GameDiplomacyButtonClicked ? MenuButtonClicked : 0),
+               (GameDiplomacyButtonClicked ? MenuButtonClicked : 
0),/*Transparent*/ 0,
                TheUI.NetworkDiplomacyButton.Width, 
TheUI.NetworkDiplomacyButton.Height,
                TheUI.NetworkDiplomacyButton.X, TheUI.NetworkDiplomacyButton.Y,
                GameFont, TheUI.NetworkDiplomacyButton.Text, NULL, NULL);
@@ -417,6 +420,9 @@
        //
        nunits = FindAndSortUnits(vp, table);
        nmissiles = FindAndSortMissiles(vp, missiletable);
+/*     if (Units[170]) {
+           DebugLevel0Fn("Unit 170: %s ref %d\n" _C_ Units[170]->Type->Name 
_C_ Units[170]->Refs);
+       }*/
 
        i = 0;
        j = 0;
@@ -519,7 +525,7 @@
     //
     for (vp = TheUI.Viewports; vp < evp; ++vp) {
 #ifdef USE_SDL_SURFACE
-       Uint32 color;
+       SDL_Color color;
 #else
        VMemType color;
 #endif
@@ -832,8 +838,6 @@
                    CclGarbageCollect(1);
                    break;
                case 1:
-                   HandleCloak();
-                   break;
                case 2:
                    break;
                case 3:                         // minimap update
Index: stratagus/src/editor/editloop.c
diff -u stratagus/src/editor/editloop.c:1.147 
stratagus/src/editor/editloop.c:1.148
--- stratagus/src/editor/editloop.c:1.147       Tue Dec  2 15:00:12 2003
+++ stratagus/src/editor/editloop.c     Sun Dec 14 03:14:43 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: editloop.c,v 1.147 2003/12/02 04:00:12 nehalmistry Exp $
+//     $Id: editloop.c,v 1.148 2003/12/13 16:14:43 mohydine Exp $
 
 //@{
 
@@ -936,7 +936,7 @@
     DrawMenuButton(TheUI.MenuButton.Button,
        (ButtonAreaUnderCursor == ButtonAreaMenu
            && ButtonUnderCursor == ButtonUnderMenu ? MenuButtonActive : 0) |
-       (GameMenuButtonClicked ? MenuButtonClicked : 0),
+       (GameMenuButtonClicked ? MenuButtonClicked : 0), 0,
        TheUI.MenuButton.Width, TheUI.MenuButton.Height,
        TheUI.MenuButton.X,TheUI.MenuButton.Y,
        GameFont,TheUI.MenuButton.Text, NULL, NULL);
Index: stratagus/src/game/intro.c
diff -u stratagus/src/game/intro.c:1.112 stratagus/src/game/intro.c:1.113
--- stratagus/src/game/intro.c:1.112    Fri Dec 12 08:44:41 2003
+++ stratagus/src/game/intro.c  Sun Dec 14 03:14:44 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: intro.c,v 1.112 2003/12/11 21:44:41 jsalmon3 Exp $
+//     $Id: intro.c,v 1.113 2003/12/13 16:14:44 mohydine Exp $
 
 //@{
 
@@ -207,7 +207,7 @@
 */
 local void DrawContinueButton(void)
 {
-    DrawMenuButton(MBUTTON_GM_HALF, ContinueButtonFlags,
+    DrawMenuButton(MBUTTON_GM_HALF, ContinueButtonFlags,0,
        106, 27,
        ContinueButtonX, ContinueButtonY,
        LargeFont, "~!Continue", NULL, NULL);
Index: stratagus/src/include/menus.h
diff -u stratagus/src/include/menus.h:1.114 stratagus/src/include/menus.h:1.115
--- stratagus/src/include/menus.h:1.114 Sat Nov  8 09:41:28 2003
+++ stratagus/src/include/menus.h       Sun Dec 14 03:14:45 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: menus.h,v 1.114 2003/11/07 22:41:28 jsalmon3 Exp $
+//     $Id: menus.h,v 1.115 2003/12/13 16:14:45 mohydine Exp $
 
 #ifndef __MENUS_H__
 #define __MENUS_H__
@@ -222,6 +222,7 @@
     int yofs;
     unsigned flags;
     int font;
+       int transparent;                        /// Add the transparent flag to 
draw a transparent flag
     void (*initfunc)(struct _menuitem_ *);     /// constructor
     void (*exitfunc)(struct _menuitem_ *);     /// destructor
     struct _menus_ *menu;                      /// backpointer for speedups
@@ -347,7 +348,7 @@
     /// Draw menu
 extern void DrawMenu(Menu *menu);
     /// Draw menu button
-extern void DrawMenuButton(MenuButtonId button,unsigned flags,int w,int h,
+extern void DrawMenuButton(MenuButtonId button,unsigned flags,int 
transparent,int w,int h,
                           int x,int y,const int font,const unsigned char *text,
                           char *normalcolor, char *reversecolor);
     /// Set menu backgound and draw it
Index: stratagus/src/include/missile.h
diff -u stratagus/src/include/missile.h:1.72 
stratagus/src/include/missile.h:1.73
--- stratagus/src/include/missile.h:1.72        Thu Dec 11 17:37:55 2003
+++ stratagus/src/include/missile.h     Sun Dec 14 03:14:45 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: missile.h,v 1.72 2003/12/11 06:37:55 wizzard Exp $
+//     $Id: missile.h,v 1.73 2003/12/13 16:14:45 mohydine Exp $
 
 #ifndef __MISSILE_H__
 #define __MISSILE_H__
@@ -162,12 +162,9 @@
 **             field where the missile hits.  A value of 2  would mean that
 **             the damage for that particular missile would be dealt for a 
range
 **             of 1 around the impact spot. All fields that aren't the center
-**             get only 1/SpashFactor of the damage. Fields 2 away get
-**             1/(SplashFactor*2), and following...
-**
-**     MissileType::SplashFactor
-**
-**             Determines The Splash damage divisor, see Range
+**             get only 50% of the damage.
+**             @note Can this value be higher? 3 (3x3 area with 25%),
+**             4 (4x4 area with 12.5%)! Yes, but is currently not written.
 **
 **     MissileType::ImpactName
 **
@@ -397,6 +394,7 @@
     char*      Ident;                  /// missile name
     char*      File;                   /// missile sprite file
 
+       int             Transparency;   /// Missile transparency possible value 
is 50 (later 25 and 75)
     int                Width;                  /// missile width in pixels
     int                Height;                 /// missile height in pixels
     int                DrawLevel;              /// Level to draw missile at
@@ -417,7 +415,6 @@
     int                Speed;                  /// missile speed
 
     int                Range;                  /// missile damage range
-    int                SplashFactor;           /// missile splash divisor
     char*      ImpactName;             /// impact missile-type name
     MissileType*ImpactMissile;         /// missile produces an impact
     char*      SmokeName;              /// impact missile-type name
Index: stratagus/src/include/video.h
diff -u stratagus/src/include/video.h:1.101 stratagus/src/include/video.h:1.102
--- stratagus/src/include/video.h:1.101 Tue Dec  2 15:00:14 2003
+++ stratagus/src/include/video.h       Sun Dec 14 03:14:45 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: video.h,v 1.101 2003/12/02 04:00:14 nehalmistry Exp $
+//     $Id: video.h,v 1.102 2003/12/13 16:14:45 mohydine Exp $
 
 #ifndef __VIDEO_H__
 #define __VIDEO_H__
@@ -107,6 +107,16 @@
        ///     Draw the object clipped and flipped in X direction.
     void (*DrawClipX)(const Graphic* o, unsigned f, int x, int y);
        ///     Draw the shadow object clipped to the current clipping.
+///50% Transparent functions
+       void (*DrawTrans50)(const Graphic* o, unsigned f, int x, int y);
+       ///     Draw the object unclipped and flipped in X direction.
+    void (*DrawXTrans50)(const Graphic* o, unsigned f, int x, int y);
+       ///     Draw the object clipped to the current clipping.
+    void (*DrawClipTrans50)(const Graphic* o, unsigned f, int x, int y);
+       ///     Draw the object clipped and flipped in X direction.
+    void (*DrawClipXTrans50)(const Graphic* o, unsigned f, int x, int y);
+       ///     Draw the shadow object clipped to the current clipping.
+
     void (*DrawShadowClip)(const Graphic* o, unsigned f, int x, int y);
        ///     Draw the shadow object clipped and flipped in X direction.
     void (*DrawShadowClipX)(const Graphic* o, unsigned f, int x, int y);
@@ -333,15 +343,18 @@
 extern EventCallback GameCallbacks;    /// Game callbacks
 extern EventCallback MenuCallbacks;    /// Menu callbacks
 
-extern Uint32 ColorBlack;
-extern Uint32 ColorDarkGreen;
-extern Uint32 ColorBlue;
-extern Uint32 ColorOrange;
-extern Uint32 ColorWhite;
-extern Uint32 ColorGray;
-extern Uint32 ColorRed;
-extern Uint32 ColorGreen;
-extern Uint32 ColorYellow;
+    ///        Maps RGB to a hardware dependent pixel.
+extern SDL_Color VideoMapRGB(int r, int g, int b);
+
+extern SDL_Color ColorBlack;
+extern SDL_Color ColorDarkGreen;
+extern SDL_Color ColorBlue;
+extern SDL_Color ColorOrange;
+extern SDL_Color ColorWhite;
+extern SDL_Color ColorGray;
+extern SDL_Color ColorRed;
+extern SDL_Color ColorGreen;
+extern SDL_Color ColorYellow;
 
 extern int ColorWaterCycleStart;       /// color # start for color cycling
 extern int ColorWaterCycleEnd;         /// color # end   for color cycling
@@ -353,81 +366,80 @@
 // FIXME: check these out, clean up if we can
 // FIXME: check these out, clean up if we can
 // FIXME: check these out, clean up if we can
-
     ///        Draw pixel unclipped.
-extern void (*VideoDrawPixel)(Uint32 color, int x, int y);
+extern void VideoDrawPixel(SDL_Color color, int x, int y);
 
     ///        Draw translucent pixel unclipped.
-extern void (*VideoDrawTransPixel)(Uint32 color, int x, int y,
+extern void VideoDrawTransPixel(SDL_Color color, int x, int y,
     unsigned char alpha);
 
     ///        Draw pixel clipped to current clip setting.
-extern void VideoDrawPixelClip(Uint32 color, int x, int y);
+extern void VideoDrawPixelClip(SDL_Color color, int x, int y);
 
     ///        Draw translucent pixel clipped to current clip setting.
-extern void VideoDrawTransPixelClip(Uint32 color, int x, int y,
+extern void VideoDrawTransPixelClip(SDL_Color color, int x, int y,
     unsigned char alpha);
 
     ///        Draw vertical line unclipped.
-extern void VideoDrawVLine(Uint32 color, int x, int y,
+extern void VideoDrawVLine(SDL_Color color, int x, int y,
     int height);
 
     ///        Draw translucent vertical line unclipped.
-extern void VideoDrawTransVLine(Uint32 color, int x, int y,
+extern void VideoDrawTransVLine(SDL_Color color, int x, int y,
     int height, unsigned char alpha);
 
     ///        Draw vertical line clipped to current clip setting
-extern void VideoDrawVLineClip(Uint32 color, int x, int y,
+extern void VideoDrawVLineClip(SDL_Color color, int x, int y,
     int height);
 
     ///        Draw translucent vertical line clipped to current clip setting
-extern void VideoDrawTransVLineClip(Uint32 color, int x, int y,
+extern void VideoDrawTransVLineClip(SDL_Color color, int x, int y,
     int height, unsigned char alpha);
 
     ///        Draw horizontal line unclipped.
-extern void VideoDrawHLine(Uint32 color, int x, int y,
+extern void VideoDrawHLine(SDL_Color color, int x, int y,
     int width);
 
     ///        Draw translucent horizontal line unclipped.
-extern void VideoDrawTransHLine(Uint32 color, int x, int y,
+extern void VideoDrawTransHLine(SDL_Color color, int x, int y,
     int width, unsigned char alpha);
 
     ///        Draw horizontal line clipped to current clip setting
-extern void VideoDrawHLineClip(Uint32 color, int x, int y,
+extern void VideoDrawHLineClip(SDL_Color color, int x, int y,
     int width);
 
     ///        Draw translucent horizontal line clipped to current clip setting
-extern void VideoDrawTransHLineClip(Uint32 color, int x, int y,
+extern void VideoDrawTransHLineClip(SDL_Color color, int x, int y,
     int width, unsigned char alpha);
 
     ///        Draw line unclipped.
-extern void VideoDrawLine(Uint32 color, int sx, int sy, int dx, int dy);
+extern void VideoDrawLine(SDL_Color color, int sx, int sy, int dx, int dy);
 
     ///        Draw translucent line unclipped.
-extern void VideoDrawTransLine(Uint32 color, int sx, int sy, int dx, int dy,
+extern void VideoDrawTransLine(SDL_Color color, int sx, int sy, int dx, int dy,
     unsigned char alpha);
 
     ///        Draw line clipped to current clip setting
-extern void VideoDrawLineClip(Uint32 color, int sx, int sy, int dx, int dy);
+extern void VideoDrawLineClip(SDL_Color color, int sx, int sy, int dx, int dy);
 
     ///        Draw translucent line clipped to current clip setting
-extern void VideoDrawTransLineClip(Uint32 color, int sx, int sy,
+extern void VideoDrawTransLineClip(SDL_Color color, int sx, int sy,
     int dx, int dy, unsigned char alpha);
 
     ///        Draw rectangle.
-extern void VideoDrawRectangle(Uint32 color, int x, int y,
+extern void VideoDrawRectangle(SDL_Color color, int x, int y,
     int w, int h);
 
     ///        Draw translucent rectangle.
-extern void VideoDrawTransRectangle(Uint32 color, int x, int y,
+extern void VideoDrawTransRectangle(SDL_Color color, int x, int y,
     int w, int h, unsigned char alpha);
 
     ///        Draw rectangle clipped.
-extern void VideoDrawRectangleClip(Uint32 color, int x, int y,
+extern void VideoDrawRectangleClip(SDL_Color color, int x, int y,
     int w, int h);
 
     ///        Draw translucent rectangle clipped.
-extern void VideoDrawTransRectangleClip(Uint32 color, int x, int y,
+extern void VideoDrawTransRectangleClip(SDL_Color color, int x, int y,
     int w, int h, unsigned char alpha);
 
     ///        Draw 8bit raw graphic data clipped, using given pixel pallette
@@ -441,47 +453,47 @@
     int w, int h, int x, int y, unsigned char fade);
 
     ///        Draw circle.
-extern void VideoDrawCircle(Uint32 color, int x, int y, int r);
+extern void VideoDrawCircle(SDL_Color color, int x, int y, int r);
 
     ///        Draw translucent circle.
-extern void VideoDrawTransCircle(Uint32 color, int x, int y, int r,
+extern void VideoDrawTransCircle(SDL_Color color, int x, int y, int r,
     unsigned char alpha);
 
     ///        Draw circle clipped.
-extern void VideoDrawCircleClip(Uint32 color, int x, int y, int r);
+extern void VideoDrawCircleClip(SDL_Color color, int x, int y, int r);
 
     ///        Draw translucent circle clipped.
-extern void VideoDrawTransCircleClip(Uint32 color, int x, int y, int r,
+extern void VideoDrawTransCircleClip(SDL_Color color, int x, int y, int r,
     unsigned char alpha);
 
     ///        Fill rectangle.
-extern void VideoFillRectangle(Uint32 color, int x, int y,
+extern void VideoFillRectangle(SDL_Color color, int x, int y,
     int w, int h);
 
     ///        Fill translucent rectangle.
-extern void VideoFillTransRectangle(Uint32 color, int x, int y,
+extern void VideoFillTransRectangle(SDL_Color color, int x, int y,
     int w, int h, unsigned char alpha);
 
     ///        Fill rectangle clipped.
-extern void VideoFillRectangleClip(Uint32 color, int x, int y,
+extern void VideoFillRectangleClip(SDL_Color color, int x, int y,
     int w, int h);
 
     ///        Fill translucent rectangle clipped.
-extern void VideoFillTransRectangleClip(Uint32 color, int x, int y,
+extern void VideoFillTransRectangleClip(SDL_Color color, int x, int y,
     int w, int h, unsigned char alpha);
 
     ///        Fill circle.
-extern void VideoFillCircle(Uint32 color, int x, int y, int r);
+extern void VideoFillCircle(SDL_Color color, int x, int y, int r);
 
     ///        Fill translucent circle.
-extern void VideoFillTransCircle(Uint32 color, int x, int y, int r,
+extern void VideoFillTransCircle(SDL_Color color, int x, int y, int r,
     unsigned char alpha);
 
     ///        Fill circle clipped.
-extern void VideoFillCircleClip(Uint32 color, int x, int y, int r);
+extern void VideoFillCircleClip(SDL_Color color, int x, int y, int r);
 
     ///        Fill translucent circle clipped.
-extern void VideoFillTransCircleClip(Uint32 color, int x, int y, int r,
+extern void VideoFillTransCircleClip(SDL_Color color, int x, int y, int r,
     unsigned char alpha);
 
     ///        Draw a graphic object unclipped.
@@ -503,28 +515,42 @@
     ///        Draw a graphic object clipped and flipped in X direction.
 extern void VideoDrawClipX(const Graphic*, unsigned frame, int x, int y);
 
-    ///        Draw a shadow graphic object clipped to the current clipping.
-extern void VideoDrawShadowClip(const Graphic*, unsigned frame,
-    int x, int y);
-    ///        Draw a shadow graphic object clipped and flipped in X direction.
-extern void VideoDrawShadowClipX(const Graphic*, unsigned frame,
-    int x, int y);
-
 // FIXME FIXME FIXME: need to implement all of this
+    ///        Draw a graphic object unclipped.
+//#define VideoDraw(o, f, x, y)        //((o)->Type->Draw)((o), (f), (x), (y))
     ///        Free a graphic object.
 #define VideoFree(o)   //((o)->Type->Free)((o))
     ///        Save (NULL) free a graphic object.
 #define VideoSaveFree(o) // do { if ((o)) ((o)->Type->Free)((o)); } while(0)
+//#define VideoDrawSub(a,b,c,d,e,f,g)
+    ///        Draw a graphic object clipped to the current clipping.
+//#define VideoDrawSubClip(o, ix, iy, w, h, x, y)
+    ///        Draw a shadow graphic object clipped to the current clipping.
+#define VideoDrawShadowClip(o, f, x, y)        
//((o)->Type->DrawShadowClip)((o),(f),(x),(y))
+    ///        Draw a shadow graphic object clipped and flipped in X direction.
+#define VideoDrawShadowClipX(o, f, x, y)    
//((o)->Type->DrawShadowClipX)((o),(f),(x),(y))
 
     /// Get the width of a single frame of a graphic object
 #define VideoGraphicWidth(o)   ((o)->Width)
     /// Get the height of a single frame of a graphic object
 #define VideoGraphicHeight(o)  ((o)->Height)
 #define VideoGraphicFrames(o) ((o)->NumFrames)
+//    ((o)->Type->DrawSubClip)((o), (ix), (iy), (w), (h), (x), (y))
+
 
     /// MACRO defines speed of colorcycling FIXME: should be made configurable
 #define COLOR_CYCLE_SPEED      (CYCLES_PER_SECOND/4)
 
+extern SDL_Surface* MainSurface;
+
+/*
+#define VideoMemory8   (&VideoMemory->D8)      /// video memory  8bpp
+#define VideoMemory16  (&VideoMemory->D16)     /// video memory 16bpp
+#define VideoMemory24  (&VideoMemory->D24)     /// video memory 24bpp
+#define VideoMemory32  (&VideoMemory->D32)     /// video memory 32bpp
+*/
+
+
 #else
 
 // OOOOOOOOOLLLLLLLLDDDDDDDD VIDEO MODE *********************************
@@ -676,6 +702,16 @@
     void (*DrawClip)(const Graphic* o, unsigned f, int x, int y);
        ///     Draw the object clipped and flipped in X direction.
     void (*DrawClipX)(const Graphic* o, unsigned f, int x, int y);
+///50% Transparent functions
+       ///     Draw the object unclipped.
+    void (*DrawTrans50)(const Graphic* o, unsigned f, int x, int y);
+       ///     Draw the object unclipped and flipped in X direction.
+    void (*DrawXTrans50)(const Graphic* o, unsigned f, int x, int y);
+       ///     Draw the object clipped to the current clipping.
+    void (*DrawClipTrans50)(const Graphic* o, unsigned f, int x, int y);
+       ///     Draw the object clipped and flipped in X direction.
+    void (*DrawClipXTrans50)(const Graphic* o, unsigned f, int x, int y);
+
        ///     Draw the shadow object clipped to the current clipping.
     void (*DrawShadowClip)(const Graphic* o, unsigned f, int x, int y);
        ///     Draw the shadow object clipped and flipped in X direction.
@@ -1117,6 +1153,18 @@
     ///        Draw a graphic object clipped and flipped in X direction.
 #define VideoDrawClipX(o, f, x, y)     ((o)->Type->DrawClipX)((o), (f), (x), 
(y))
     ///        Draw a shadow graphic object clipped to the current clipping.
+///Transparent Functions
+   /// Draw a graphic object unclipped.
+#define VideoDrawTrans50(o, f, x, y)   ((o)->Type->DrawTrans50)((o), (f), (x), 
(y))
+    ///        Draw a graphic object unclipped and flipped in X direction.
+#define VideoDrawXTrans50(o, f, x, y)  ((o)->Type->DrawXTrans50)((o), (f), 
(x), (y))
+    ///        Draw a graphic object clipped to the current clipping.
+#define VideoDrawClipTrans50(o, f, x, y)       
((o)->Type->DrawClipTrans50)((o), (f), (x), (y))
+    ///        Draw a graphic object clipped and flipped in X direction.
+#define VideoDrawClipXTrans50(o, f, x, y)      
((o)->Type->DrawClipXTrans50)((o), (f), (x), (y))
+    ///        Draw a shadow graphic object clipped to the current clipping.
+///Shadows
+
 #define VideoDrawShadowClip(o, f, x, y)        
((o)->Type->DrawShadowClip)((o),(f),(x),(y))
     ///        Draw a shadow graphic object clipped and flipped in X direction.
 #define VideoDrawShadowClipX(o, f, x, y)    
((o)->Type->DrawShadowClipX)((o),(f),(x),(y))
Index: stratagus/src/missile/ccl_missile.c
diff -u stratagus/src/missile/ccl_missile.c:1.45 
stratagus/src/missile/ccl_missile.c:1.46
--- stratagus/src/missile/ccl_missile.c:1.45    Fri Dec 12 08:41:39 2003
+++ stratagus/src/missile/ccl_missile.c Sun Dec 14 03:14:46 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: ccl_missile.c,v 1.45 2003/12/11 21:41:39 jsalmon3 Exp $
+//     $Id: ccl_missile.c,v 1.46 2003/12/13 16:14:46 mohydine Exp $
 
 //@{
 
@@ -36,7 +36,6 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 
 #include "stratagus.h"
 #include "video.h"
@@ -91,8 +90,6 @@
     }
 
     mtype->NumDirections = 1;
-    // Ensure we don't divide by zero.
-    mtype->SplashFactor = 100;
     //
     // Parse the arguments, already the new tagged format.
     //
@@ -111,6 +108,8 @@
            mtype->SpriteFrames = gh_scm2int(gh_car(list));
        } else if (gh_eq_p(value, gh_symbol2scm("num-directions"))) {
            mtype->NumDirections = gh_scm2int(gh_car(list));
+       } else if (gh_eq_p(value, gh_symbol2scm("transparency"))) {
+           mtype->Transparency = gh_scm2int(gh_car(list));
        } else if (gh_eq_p(value, gh_symbol2scm("fired-sound"))) {
            free(mtype->FiredSound.Name);
            mtype->FiredSound.Name = gh_scm2newstr(gh_car(list), NULL);
@@ -118,13 +117,10 @@
            free(mtype->ImpactSound.Name);
            mtype->ImpactSound.Name = gh_scm2newstr(gh_car(list), NULL);
        } else if (gh_eq_p(value, gh_symbol2scm("class"))) {
-           const char* name;
-
            value = gh_car(list);
-           name = get_c_string(value);
            for (i = 0; MissileClassNames[i]; ++i) {
-               if (!strcmp(name, MissileClassNames[i])) {
-                   mtype->Class = i;
+               if (gh_eq_p(value, gh_symbol2scm((char*)MissileClassNames[i]))) 
{
+                   mtype->Class=i;
                    break;
                }
            }
@@ -136,13 +132,13 @@
            mtype->NumBounces = gh_scm2int(gh_car(list));
        } else if (gh_eq_p(value, gh_symbol2scm("delay"))) {
            mtype->StartDelay = gh_scm2int(gh_car(list));
-       } else if (gh_eq_p(value, gh_symbol2scm("sleep"))) {
+       } else if (gh_eq_p(value, gh_symbol2scm("sleep")) ) {
            mtype->Sleep = gh_scm2int(gh_car(list));
-       } else if (gh_eq_p(value, gh_symbol2scm("speed"))) {
+       } else if (gh_eq_p(value, gh_symbol2scm("speed")) ) {
            mtype->Speed = gh_scm2int(gh_car(list));
-       } else if (gh_eq_p(value, gh_symbol2scm("draw-level"))) {
+       } else if (gh_eq_p(value, gh_symbol2scm("draw-level")) ) {
            mtype->DrawLevel = gh_scm2int(gh_car(list));
-       } else if (gh_eq_p(value, gh_symbol2scm("range"))) {
+       } else if (gh_eq_p(value, gh_symbol2scm("range")) ) {
            mtype->Range = gh_scm2int(gh_car(list));
        } else if (gh_eq_p(value, gh_symbol2scm("impact-missile"))) {
            free(mtype->ImpactName);
@@ -151,11 +147,9 @@
            free(mtype->ImpactName);
            mtype->SmokeName = gh_scm2newstr(gh_car(list), NULL);
        } else if (gh_eq_p(value, gh_symbol2scm("can-hit-owner"))) {
-           mtype->CanHitOwner = 1;
+           mtype->CanHitOwner = gh_scm2bool(gh_car(list));
        } else if (gh_eq_p(value, gh_symbol2scm("friendly-fire"))) {
-           mtype->FriendlyFire = 1;
-       } else if (gh_eq_p(value, gh_symbol2scm("splash-factor"))) {
-           mtype->SplashFactor = gh_scm2int(gh_car(list));;
+           mtype->FriendlyFire = gh_scm2bool(gh_car(list));
        } else {
            // FIXME: this leaves a half initialized missile-type
            errl("Unsupported tag", value);
@@ -166,116 +160,6 @@
     return SCM_UNSPECIFIED;
 }
 #elif defined(USE_LUA)
-local int CclDefineMissileType(lua_State* l)
-{
-    const char* value;
-    char* str;
-    MissileType* mtype;
-    unsigned i;
-    int args;
-    int j;
-
-    args = lua_gettop(l);
-    j = 0;
-
-    // Slot identifier
-
-    str = strdup(LuaToString(l, j + 1));
-    ++j;
-#ifdef DEBUG
-    i = NoWarningMissileType;
-    NoWarningMissileType = 1;
-#endif
-    mtype = MissileTypeByIdent(str);
-#ifdef DEBUG
-    NoWarningMissileType = i;
-#endif
-    if (mtype) {
-       DebugLevel0Fn("Redefining missile-type `%s'\n" _C_ str);
-       free(str);
-    } else {
-       mtype = NewMissileTypeSlot(str);        // str consumed!
-    }
-
-    mtype->NumDirections = 1;
-    // Ensure we don't divide by zero.
-    mtype->SplashFactor = 100;
-    //
-    // Parse the arguments, already the new tagged format.
-    //
-    for (; j < args; ++j) {
-       value = LuaToString(l, j + 1);
-       ++j;
-       if (!strcmp(value, "file")) {
-           free(mtype->File);
-           mtype->File = strdup(LuaToString(l, j + 1));
-       } else if (!strcmp(value, "size")) {
-           if (!lua_istable(l, j + 1)) {
-               lua_pushstring(l, "incorrect argument");
-               lua_error(l);
-           }
-           lua_rawgeti(l, j + 1, 1);
-           mtype->Width = LuaToNumber(l, -1);
-           lua_pop(l, 1);
-           lua_rawgeti(l, j + 1, 2);
-           mtype->Height = LuaToNumber(l, -1);
-           lua_pop(l, 1);
-       } else if (!strcmp(value,"frames")) {
-           mtype->SpriteFrames = LuaToNumber(l, j + 1);
-       } else if (!strcmp(value, "num-directions")) {
-           mtype->NumDirections = LuaToNumber(l, j + 1);
-       } else if (!strcmp(value, "fired-sound")) {
-           free(mtype->FiredSound.Name);
-           mtype->FiredSound.Name = strdup(LuaToString(l, j + 1));
-       } else if (!strcmp(value, "impact-sound")) {
-           free(mtype->ImpactSound.Name);
-           mtype->ImpactSound.Name = strdup(LuaToString(l, j + 1));
-       } else if (!strcmp(value, "class")) {
-           value = LuaToString(l, j + 1);
-           for (i = 0; MissileClassNames[i]; ++i) {
-               if (!strcmp(value, MissileClassNames[i])) {
-                   mtype->Class = i;
-                   break;
-               }
-           }
-           if (!MissileClassNames[i]) {
-               // FIXME: this leaves a half initialized missile-type
-               lua_pushfstring(l, "Unsupported class: %s", value);
-               lua_error(l);
-           }
-       } else if (!strcmp(value, "num-bounces")) {
-           mtype->NumBounces = LuaToNumber(l, j + 1);
-       } else if (!strcmp(value, "delay")) {
-           mtype->StartDelay = LuaToNumber(l, j + 1);
-       } else if (!strcmp(value, "sleep")) {
-           mtype->Sleep = LuaToNumber(l, j + 1);
-       } else if (!strcmp(value, "speed")) {
-           mtype->Speed = LuaToNumber(l, j + 1);
-       } else if (!strcmp(value, "draw-level")) {
-           mtype->DrawLevel = LuaToNumber(l, j + 1);
-       } else if (!strcmp(value, "range")) {
-           mtype->Range = LuaToNumber(l, j + 1);
-       } else if (!strcmp(value, "impact-missile")) {
-           free(mtype->ImpactName);
-           mtype->ImpactName = strdup(LuaToString(l, j + 1));
-       } else if (!strcmp(value, "smoke-missile")) {
-           free(mtype->ImpactName);
-           mtype->SmokeName = strdup(LuaToString(l, j + 1));
-       } else if (!strcmp(value, "can-hit-owner")) {
-           mtype->CanHitOwner = 1;
-       } else if (!strcmp(value, "friendly-fire")) {
-           mtype->FriendlyFire = 1;
-       } else if (!strcmp(value, "splash-factor")) {
-           mtype->SplashFactor = LuaToNumber(l, j + 1);
-       } else {
-           // FIXME: this leaves a half initialized missile-type
-           lua_pushfstring(l, "Unsupported tag: %s", value);
-           lua_error(l);
-       }
-    }
-
-    return 0;
-}
 #endif
 
 /**
@@ -483,10 +367,6 @@
     return SCM_UNSPECIFIED;
 }
 #elif defined(USE_LUA)
-local int CclMissile(lua_State* l)
-{
-    return 0;
-}
 #endif
 
 /**
@@ -540,56 +420,6 @@
     return SCM_UNSPECIFIED;
 }
 #elif defined(USE_LUA)
-local int CclDefineBurningBuilding(lua_State* l)
-{
-    const char* value;
-    BurningBuildingFrame** frame;
-    BurningBuildingFrame* ptr;
-    BurningBuildingFrame* next;
-    int args;
-    int j;
-    int subargs;
-    int k;
-
-    ptr = BurningBuildingFrames;
-    while (ptr) {
-       next = ptr->Next;
-       free(ptr);
-       ptr = next;
-    }
-    BurningBuildingFrames = NULL;
-
-    frame = &BurningBuildingFrames;
-
-    args = lua_gettop(l);
-    for (j = 0; j < args; ++j) {
-       if (!lua_istable(l, j + 1)) {
-           lua_pushstring(l, "incorrect argument");
-           lua_error(l);
-       }
-
-       *frame = calloc(1, sizeof(BurningBuildingFrame));
-       subargs = luaL_getn(l, j + 1);
-       for (k = 0; k < subargs; ++k) {
-           lua_rawgeti(l, j + 1, k + 1);
-           value = LuaToString(l, -1);
-           lua_pop(l, 1);
-           ++k;
-
-           if (!strcmp(value, "percent")) {
-               lua_rawgeti(l, j + 1, k + 1);
-               (*frame)->Percent = LuaToNumber(l, -1);
-               lua_pop(l, 1);
-           } else if (!strcmp(value, "missile")) {
-               lua_rawgeti(l, j + 1, k + 1);
-               (*frame)->Missile = MissileTypeByIdent(LuaToString(l, -1));
-               lua_pop(l, 1);
-           }
-       }
-       frame = &((*frame)->Next);
-    }
-    return 0;
-}
 #endif
 
 /**
@@ -606,9 +436,9 @@
 #elif defined(USE_LUA)
     lua_register(Lua, "DefineMissileTypeWcNames",
        CclDefineMissileTypeWcNames);
-    lua_register(Lua, "DefineMissileType", CclDefineMissileType);
-    lua_register(Lua, "Missile", CclMissile);
-    lua_register(Lua, "DefineBurningBuilding", CclDefineBurningBuilding);
+//    lua_register("DefineMissileType", CclDefineMissileType);
+//    lua_register("Missile", CclMissile);
+//    lua_register("DefineBurningBuilding", CclDefineBurningBuilding);
 #endif
 }
 
Index: stratagus/src/missile/missile.c
diff -u stratagus/src/missile/missile.c:1.113 
stratagus/src/missile/missile.c:1.114
--- stratagus/src/missile/missile.c:1.113       Fri Dec 12 08:42:32 2003
+++ stratagus/src/missile/missile.c     Sun Dec 14 03:14:46 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: missile.c,v 1.113 2003/12/11 21:42:32 jsalmon3 Exp $
+//     $Id: missile.c,v 1.114 2003/12/13 16:14:46 mohydine Exp $
 
 //@{
 
@@ -161,10 +161,7 @@
            file = strcat(strcpy(buf, "graphics/"), file);
            ShowLoadProgress("Missile %s", file);
            MissileTypes[i].Sprite = LoadSprite(
-               file, MissileTypes[i].Width, MissileTypes[i].Height);
-#ifdef USE_SDL_SURFACE
-           FlipGraphic(MissileTypes[i].Sprite);
-#endif
+                   file, MissileTypes[i].Width, MissileTypes[i].Height);
 
            // Correct the number of frames in graphic
            DebugCheck(MissileTypes[i].Sprite->NumFrames < 
MissileTypes[i].SpriteFrames);
@@ -612,7 +609,6 @@
 local void GetMissileMapArea(const Missile* missile, int* sx, int* sy,
     int* ex, int* ey)
 {
-#define Bound(x, y) (x) < 0 ? 0 : ((x) > (y) ? (y) : (x))
     DebugCheck(missile == NULL);
     DebugCheck(sx == NULL);
     DebugCheck(sy == NULL);
@@ -621,11 +617,10 @@
     DebugCheck(TileSizeX <= 0);
     DebugCheck(TileSizeY <= 0);
     DebugCheck(missile->Type == NULL);
-    *sx = Bound(missile->X / TileSizeX, TheMap.Width - 1);
-    *sy = Bound(missile->Y / TileSizeY, TheMap.Height - 1);
-    *ex = Bound((missile->X + missile->Type->Width) / TileSizeX, TheMap.Width 
- 1);
-    *ey = Bound((missile->Y + missile->Type->Height) / TileSizeY, 
TheMap.Height - 1);
-#undef Bound
+    *sx = missile->X / TileSizeX;
+    *sy = missile->Y / TileSizeY;
+    *ex = (missile->X + missile->Type->Width) / TileSizeX;
+    *ey = (missile->Y + missile->Type->Height) / TileSizeY;
 }
 
 /**
@@ -642,8 +637,6 @@
     int max_x;
     int min_y;
     int max_y;
-    int x;
-    int y;
 
     DebugCheck(vp == NULL);
     DebugCheck(missile == NULL);
@@ -653,15 +646,11 @@
     }
     DebugLevel3Fn("Missile bounding box %d %d %d %d\n" _C_ min_x _C_ max_x _C_
        min_y _C_ max_y);
-
-    for (x = min_x; x <= max_x; ++x) {
-       for ( y = min_y; y <= max_y; ++y) {
-           if (ReplayRevealMap || IsMapFieldVisible(ThisPlayer, x, y)) {
-               return 1;
-           }
-       }
+    if (!IsMapFieldVisible(ThisPlayer, (missile->X - TileSizeX / 2) / 
TileSizeX,
+           (missile->Y - TileSizeY / 2) / TileSizeY) && !ReplayRevealMap) {
+       return 0;
     }
-    return 0;
+    return 1;
 }
 
 /**
@@ -694,11 +683,19 @@
 {
     DebugCheck(mtype == NULL);
     // FIXME: This is a hack for mirrored sprites
-    if (frame < 0) {
-       VideoDrawClipX(mtype->Sprite, -frame, x, y);
-    } else {
-       VideoDrawClip(mtype->Sprite, frame, x, y);
-    }
+       if (mtype->Transparency==50) {
+               if (frame < 0) {
+                       VideoDrawClipXTrans50(mtype->Sprite, -frame, x, y);
+               } else {
+                       VideoDrawClipTrans50(mtype->Sprite, frame, x, y);
+               }
+       } else {
+               if (frame < 0) {
+                       VideoDrawClipX(mtype->Sprite, -frame, x, y);
+               } else {
+                       VideoDrawClip(mtype->Sprite, frame, x, y);
+               }
+       }
 }
 
 /**
@@ -1010,7 +1007,6 @@
     Unit* table[UnitMax];
     int n;
     int i;
-    int splash;
 
     DebugCheck(missile == NULL);
     DebugCheck(missile->Type == NULL);
@@ -1088,13 +1084,14 @@
        //      NOTE: perhaps this should be come a property of the missile.
        //
        if (CanTarget(missile->SourceUnit->Type, goal->Type)) {
-           splash = MapDistanceToUnit(x, y, goal);
-           if (splash) {
-               splash *= missile->Type->SplashFactor;
+           // We are attacking the nearest field of the unit
+           if (x < goal->X || y < goal->Y ||
+                   x >= goal->X + goal->Type->TileWidth ||
+                   y >= goal->Y + goal->Type->TileHeight) {
+               MissileHitsGoal(missile, goal, 2);
            } else {
-               splash = 1;
+               MissileHitsGoal(missile, goal, 1);
            }
-           MissileHitsGoal(missile, goal, splash);
        }
     }
     //
@@ -1109,8 +1106,7 @@
                if (i == 0 && n == 0) {
                    MissileHitsWall(missile, x + i, y + n, 1);
                } else {
-                   MissileHitsWall(missile, x + i, y + n, 
-                       MapDistance(x, y, i, n) * missile->Type->SplashFactor);
+                   MissileHitsWall(missile, x + i, y + n, 2);
                }
            }
        }
@@ -1339,7 +1335,7 @@
 
     DebugCheck(file == NULL);
     CLprintf(file, "\n;;; -----------------------------------------\n");
-    CLprintf(file, ";;; MODULE: missile-types $Id: missile.c,v 1.113 
2003/12/11 21:42:32 jsalmon3 Exp $\n\n");
+    CLprintf(file, ";;; MODULE: missile-types $Id: missile.c,v 1.114 
2003/12/13 16:14:46 mohydine Exp $\n\n");
 
     //
     // Original number to internal missile-type name.
@@ -1388,20 +1384,18 @@
        CLprintf(file, " 'sleep %d", mtype->Sleep);
        CLprintf(file, " 'speed %d", mtype->Speed);
        CLprintf(file, " 'range %d", mtype->Range);
-       CLprintf(file, " 'splash-factor", mtype->SplashFactor);
        if (mtype->ImpactMissile) {
            CLprintf(file, "\n  'impact-missile '%s", 
mtype->ImpactMissile->Ident);
        }
        if (mtype->SmokeMissile) {
            CLprintf(file, "\n  'smoke-missile '%s", 
mtype->SmokeMissile->Ident);
        }
-       CLprintf(file, "\n ");
-       if (mtype->CanHitOwner) {
-           CLprintf(file, " 'can-hit-owner ");
-       }
-       if (mtype->FriendlyFire) {
-           CLprintf(file, " 'friendly-fire");
+       if (mtype->Transparency) {
+       CLprintf(file, "\n 'transparency %d", mtype->Transparency);
        }
+       CLprintf(file, "\n ");
+       CLprintf(file, " 'can-hit-owner #%c", mtype->CanHitOwner ? 't' : 'f');
+       CLprintf(file, " 'friendly-fire #%c", mtype->FriendlyFire ? 't' : 'f');
        CLprintf(file, ")\n");
     }
 }
@@ -1422,7 +1416,7 @@
     CLprintf(file, " '%s", missile->Local ? "local" : "global");
     CLprintf(file, "\n  'frame %d 'state %d 'wait %d 'delay %d\n ",
        missile->SpriteFrame, missile->State, missile->Wait, missile->Delay);
-
+       
     if (missile->SourceUnit) {
        CLprintf(file, " 'source '%s", s1 = UnitReference(missile->SourceUnit));
        free(s1);
@@ -1453,7 +1447,7 @@
 
     DebugCheck(file == NULL);
     CLprintf(file,"\n;;; -----------------------------------------\n");
-    CLprintf(file,";;; MODULE: missiles $Id: missile.c,v 1.113 2003/12/11 
21:42:32 jsalmon3 Exp $\n\n");
+    CLprintf(file,";;; MODULE: missiles $Id: missile.c,v 1.114 2003/12/13 
16:14:46 mohydine Exp $\n\n");
 
     for (missiles = GlobalMissiles; *missiles; ++missiles) {
        SaveMissile(*missiles, file);
Index: stratagus/src/ui/ccl_ui.c
diff -u stratagus/src/ui/ccl_ui.c:1.166 stratagus/src/ui/ccl_ui.c:1.167
--- stratagus/src/ui/ccl_ui.c:1.166     Wed Dec  3 15:07:00 2003
+++ stratagus/src/ui/ccl_ui.c   Sun Dec 14 03:14:47 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: ccl_ui.c,v 1.166 2003/12/03 04:07:00 jsalmon3 Exp $
+//     $Id: ccl_ui.c,v 1.167 2003/12/13 16:14:47 mohydine Exp $
 
 //@{
 
@@ -323,11 +323,7 @@
        lua_error(l);
     }
     TheUI.Contrast = i;
-#ifdef USE_SDL_SURFACE
-    // FIXME
-#else
     VideoCreatePalette(GlobalPalette); // rebuild palette
-#endif
     MustRedraw = RedrawEverything;
 
     lua_pushnumber(l, old);
@@ -381,11 +377,7 @@
        lua_error(l);
     }
     TheUI.Brightness = i;
-#ifdef USE_SDL_SURFACE
-    // FIXME:
-#else
     VideoCreatePalette(GlobalPalette); // rebuild palette
-#endif
     MustRedraw = RedrawEverything;
 
     lua_pushnumber(l, old);
@@ -439,11 +431,7 @@
        lua_error(l);
     }
     TheUI.Saturation = i;
-#ifdef USE_SDL_SURFACE
-    // FIXME:
-#else
     VideoCreatePalette(GlobalPalette); // rebuild palette
-#endif
     MustRedraw = RedrawEverything;
 
     lua_pushnumber(l, old);
@@ -495,7 +483,7 @@
 **     @return                 Old fullscreen mode
 */
 #if defined(USE_GUILE) || defined(USE_SIOD)
-local SCM CclSetVideoFullScreen(SCM fullscreen)
+local SCM CclSetVideoFullscreen(SCM fullscreen)
 {
     SCM old;
 
@@ -506,7 +494,7 @@
     return old;
 }
 #elif defined(USE_LUA)
-local int CclSetVideoFullScreen(lua_State* l)
+local int CclSetVideoFullscreen(lua_State* l)
 {
     int old;
 
@@ -3034,25 +3022,13 @@
                                lua_error(l);
                            }
                            lua_rawgeti(l, -1, 1);
-#ifdef USE_SDL_SURFACE
-                           ui->CompletedBarColorRGB.r = LuaToNumber(l, -1);
-#else
                            ui->CompletedBarColorRGB.D24.a = LuaToNumber(l, -1);
-#endif
                            lua_pop(l, 1);
                            lua_rawgeti(l, -1, 2);
-#ifdef USE_SDL_SURFACE
-                           ui->CompletedBarColorRGB.g = LuaToNumber(l, -1);
-#else
                            ui->CompletedBarColorRGB.D24.b = LuaToNumber(l, -1);
-#endif
                            lua_pop(l, 1);
                            lua_rawgeti(l, -1, 3);
-#ifdef USE_SDL_SURFACE
-                           ui->CompletedBarColorRGB.b = LuaToNumber(l, -1);
-#else
                            ui->CompletedBarColorRGB.D24.c = LuaToNumber(l, -1);
-#endif
                            lua_pop(l, 1);
                            lua_pop(l, 1);
                        } else if (!strcmp(value, "pos")) {
@@ -3064,7 +3040,7 @@
                            lua_rawgeti(l, -1, 1);
                            ui->CompletedBarX = LuaToNumber(l, -1);
                            lua_pop(l, 1);
-                           lua_rawgeti(l, -1, 2);
+                           lua_rawgeti(l, -1, 1);
                            ui->CompletedBarY = LuaToNumber(l, -1);
                            lua_pop(l, 1);
                            lua_pop(l, 1);
@@ -3077,7 +3053,7 @@
                            lua_rawgeti(l, -1, 1);
                            ui->CompletedBarW = LuaToNumber(l, -1);
                            lua_pop(l, 1);
-                           lua_rawgeti(l, -1, 2);
+                           lua_rawgeti(l, -1, 1);
                            ui->CompletedBarH = LuaToNumber(l, -1);
                            lua_pop(l, 1);
                            lua_pop(l, 1);
@@ -3819,12 +3795,12 @@
 #elif defined(USE_LUA)
 local int CclSetGrabMouse(lua_State* l)
 {
-    if (lua_gettop(l) != 1 || !lua_isboolean(l, 1)) {
+    if (lua_gettop(l) != 1 || (!lua_isboolean(l, 1) && !lua_isnumber(l, 1))) {
        lua_pushstring(l, "incorrect argument");
        lua_error(l);
     }
-    if (lua_toboolean(l, 1)) {
-       ToggleGrabMouse(1);
+    if (lua_isboolean(l, 1)) {
+       ToggleGrabMouse(lua_toboolean(l, 1));
     } else {
        ToggleGrabMouse(-1);
     }
@@ -4494,7 +4470,6 @@
     } else {
        lua_pushfstring(l, "Unsupported style: %s", value);
        lua_error(l);
-       return 0;
     }
     return id;
 }
@@ -4530,7 +4505,9 @@
            item->xofs = gh_scm2int(gh_car(value));
            value = gh_cdr(value);
            item->yofs = gh_scm2int(gh_car(value));
-
+               // Addition of the transparent flag
+       } else if (gh_eq_p(value, gh_symbol2scm("transparent"))) {
+               item->transparent = 1; 
        } else if (gh_eq_p(value, gh_symbol2scm("menu"))) {
            value = gh_car(list);
            list = gh_cdr(list);
@@ -6366,7 +6343,7 @@
     char buf[64];
     const char* value;
     char* s1;
-    const char* s2;
+    char* s2;
     ButtonAction ba;
     int args;
     int j;
@@ -6439,7 +6416,7 @@
                lua_error(l);
            }
            if (lua_isnumber(l, j + 1)) {
-               sprintf(buf, "%ld", (long int)lua_tonumber(l, j + 1));
+               sprintf(buf, "%ld", lua_tonumber(l, j + 1));
                s1 = strdup(buf);
            } else {
                s1 = strdup(lua_tostring(l, j + 1));
@@ -6489,11 +6466,14 @@
            subargs = luaL_getn(l, j + 1);
            for (k = 0; k < subargs; ++k) {
                lua_rawgeti(l, j + 1, k + 1);
-               s2 = LuaToString(l, -1);
+               s2 = strdup(LuaToString(l, -1));
                lua_pop(l, 1);
                s1 = realloc(s1, strlen(s1) + strlen(s2) + 2);
                strcat(s1, s2);
-               strcat(s1, ",");
+               free(s2);
+               if (k == subargs) {
+                   strcat(s1, ",");
+               }
            }
            ba.AllowStr = s1;
        } else if (!strcmp(value, "key")) {
@@ -6513,10 +6493,11 @@
            subargs = luaL_getn(l, j + 1);
            for (k = 0; k < subargs; ++k) {
                lua_rawgeti(l, j + 1, k + 1);
-               s2 = LuaToString(l, -1);
+               s2 = strdup(LuaToString(l, -1));
                s1 = realloc(s1, strlen(s1) + strlen(s2) + 2);
                strcat(s1, s2);
                strcat(s1, ",");
+               free(s2);
            }
            ba.UnitMask = s1;
            if (!strncmp(ba.UnitMask, ",*,", 3)) {
@@ -7237,7 +7218,7 @@
     gh_new_procedure1_0("set-saturation!", CclSetSaturation);
 
     gh_new_procedure2_0("set-video-resolution!", CclSetVideoResolution);
-    gh_new_procedure1_0("set-video-fullscreen!", CclSetVideoFullScreen);
+    gh_new_procedure1_0("set-video-fullscreen!", CclSetVideoFullscreen);
 
     gh_new_procedureN("set-title-screens!", CclSetTitleScreens);
     gh_new_procedure1_0("set-menu-background!", CclSetMenuBackground);
@@ -7317,7 +7298,7 @@
     lua_register(Lua, "SetSaturation", CclSetSaturation);
 
     lua_register(Lua, "SetVideoResolution", CclSetVideoResolution);
-    lua_register(Lua, "SetVideoFullScreen", CclSetVideoFullScreen);
+    lua_register(Lua, "SetVideoFullscreen", CclSetVideoFullscreen);
 
     lua_register(Lua, "SetTitleScreens", CclSetTitleScreens);
     lua_register(Lua, "SetMenuBackground", CclSetMenuBackground);
Index: stratagus/src/ui/menu_proc.c
diff -u stratagus/src/ui/menu_proc.c:1.112 stratagus/src/ui/menu_proc.c:1.113
--- stratagus/src/ui/menu_proc.c:1.112  Tue Nov 18 11:48:16 2003
+++ stratagus/src/ui/menu_proc.c        Sun Dec 14 03:14:47 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: menu_proc.c,v 1.112 2003/11/18 00:48:16 nehalmistry Exp $
+//     $Id: menu_proc.c,v 1.113 2003/12/13 16:14:47 mohydine Exp $
 
 //@{
 
@@ -207,6 +207,7 @@
 **
 **     @param button   Button identifier
 **     @param flags    State of Button (clicked, mouse over...)
+**     @param transparent      State of button transparency: 0=No, 1=Yes
 **     @param w        Button width (for border)
 **     @param h        Button height (for border)
 **     @param x        X display position
@@ -216,7 +217,7 @@
 **     @param normalcolor
 **     @param reversecolor
 */
-global void DrawMenuButton(MenuButtonId button, unsigned flags, int w, int h,
+global void DrawMenuButton(MenuButtonId button, unsigned flags, int 
transparent, int w, int h,
     int x, int y, const int font, const unsigned char* text,
     char* normalcolor, char* reversecolor)
 {
@@ -284,7 +285,13 @@
            }
        }
        if (rb < MenuButtonGfx.Sprite->NumFrames) {
-           VideoDrawClip(MenuButtonGfx.Sprite, rb, x, y);
+               // Add 
here//*******************************************************************
+               if (transparent) {
+           VideoDrawClipTrans50(MenuButtonGfx.Sprite, rb, x, y);
+               } else {
+               VideoDrawClip(MenuButtonGfx.Sprite, rb, x, y);
+               }
+
        } else {
            if (rb < button) {
                VideoDrawRectangleClip(ColorGray, x + 1, y + 1, w - 2, h - 2);
@@ -504,7 +511,11 @@
            while (i--) {
                PushClipping();
                SetClipping(0, 0, x + w, VideoHeight - 1);
+               if (mi->transparent) {
+               VideoDrawClipTrans50(MenuButtonGfx.Sprite, rb, x - 1, y - 1 + 
oh * i);
+               } else {
                VideoDrawClip(MenuButtonGfx.Sprite, rb, x - 1, y - 1 + oh * i);
+               }
                PopClipping();
                text = mi->d.pulldown.options[i];
                if (text) {
@@ -536,7 +547,11 @@
            } else {
                SetClipping(0, 0, x + w - 1, VideoHeight - 1);
            }
-           VideoDrawClip(MenuButtonGfx.Sprite, rb, x - 1, y - 1);
+               if (mi->transparent) {
+           VideoDrawClipTrans50(MenuButtonGfx.Sprite, rb, x - 1, y - 1);
+               } else {
+               VideoDrawClip(MenuButtonGfx.Sprite, rb, x - 1, y - 1);
+               }
            PopClipping();
            if (!(mi->d.pulldown.state & MI_PSTATE_PASSIVE)) {
                VideoDraw(MenuButtonGfx.Sprite, MBUTTON_DOWN_ARROW + rb - 
MBUTTON_PULLDOWN,
@@ -606,7 +621,11 @@
     while (i--) {
        PushClipping();
        SetClipping(0, 0, x + w, VideoHeight - 1);
+       if (mi->transparent) {
+       VideoDrawClipTrans50(MenuButtonGfx.Sprite, rb, x - 1, y - 1 + 18 * i);
+       } else {
        VideoDrawClip(MenuButtonGfx.Sprite, rb, x - 1, y - 1 + 18 * i);
+       }
        PopClipping();
        if (!(flags & MenuButtonDisabled)) {
            if (i < mi->d.listbox.noptions) {
@@ -692,16 +711,26 @@
        if (flags & MenuButtonDisabled) {
            PushClipping();
            SetClipping(0, 0, VideoWidth - 1, y + h - 20);
-           VideoDrawClip(MenuButtonGfx.Sprite, MBUTTON_S_VCONT - 1, x, y - 2);
+               if (mi->transparent) {
+           VideoDrawClipTrans50(MenuButtonGfx.Sprite, MBUTTON_S_VCONT - 1, x, 
y - 2);
+           VideoDrawClipTrans50(MenuButtonGfx.Sprite, MBUTTON_S_VCONT - 1, x, 
y + h / 2);
+               } else {
+               VideoDrawClip(MenuButtonGfx.Sprite, MBUTTON_S_VCONT - 1, x, y - 
2);
            VideoDrawClip(MenuButtonGfx.Sprite, MBUTTON_S_VCONT - 1, x, y + h / 
2);
+               }
            PopClipping();
            VideoDraw(MenuButtonGfx.Sprite, MBUTTON_UP_ARROW - 1, x, y - 2);
            VideoDraw(MenuButtonGfx.Sprite, MBUTTON_DOWN_ARROW - 1, x, y + h - 
20);
        } else {
            PushClipping();
            SetClipping(0, 0, VideoWidth - 1, y + h - 20);
-           VideoDrawClip(MenuButtonGfx.Sprite, MBUTTON_S_VCONT, x, y - 2);
+               if (mi->transparent) {
+           VideoDrawClipTrans50(MenuButtonGfx.Sprite, MBUTTON_S_VCONT, x, y - 
2);
+           VideoDrawClipTrans50(MenuButtonGfx.Sprite, MBUTTON_S_VCONT, x, y + 
h / 2);
+               } else {
+               VideoDrawClip(MenuButtonGfx.Sprite, MBUTTON_S_VCONT, x, y - 2);
            VideoDrawClip(MenuButtonGfx.Sprite, MBUTTON_S_VCONT, x, y + h / 2);
+               }
            PopClipping();
            if (mi->d.vslider.cflags & MI_CFLAGS_UP) {
                VideoDraw(MenuButtonGfx.Sprite, MBUTTON_UP_ARROW + 1, x, y - 2);
@@ -785,16 +814,26 @@
        if (flags & MenuButtonDisabled) {
            PushClipping();
            SetClipping(0, 0, x + w - 20, VideoHeight - 1);
-           VideoDrawClip(MenuButtonGfx.Sprite, MBUTTON_S_HCONT - 1, x - 2, y);
+               if (mi->transparent) {
+           VideoDrawClipTrans50(MenuButtonGfx.Sprite, MBUTTON_S_HCONT - 1, x - 
2, y);
+           VideoDrawClipTrans50(MenuButtonGfx.Sprite, MBUTTON_S_HCONT - 1, x + 
w / 2, y);
+               } else {
+               VideoDrawClip(MenuButtonGfx.Sprite, MBUTTON_S_HCONT - 1, x - 2, 
y);
            VideoDrawClip(MenuButtonGfx.Sprite, MBUTTON_S_HCONT - 1, x + w / 2, 
y);
+               }
            PopClipping();
            VideoDraw(MenuButtonGfx.Sprite, MBUTTON_LEFT_ARROW - 1, x - 2, y);
            VideoDraw(MenuButtonGfx.Sprite, MBUTTON_RIGHT_ARROW - 1, x + w - 
20, y);
        } else {
            PushClipping();
            SetClipping(0, 0, x + w - 20, VideoHeight - 1);
-           VideoDrawClip(MenuButtonGfx.Sprite, MBUTTON_S_HCONT, x - 2, y);
+               if (mi->transparent) {
+           VideoDrawClipTrans50(MenuButtonGfx.Sprite, MBUTTON_S_HCONT, x - 2, 
y);
+           VideoDrawClipTrans50(MenuButtonGfx.Sprite, MBUTTON_S_HCONT, x + w / 
2, y);
+               } else {
+               VideoDrawClip(MenuButtonGfx.Sprite, MBUTTON_S_HCONT, x - 2, y);
            VideoDrawClip(MenuButtonGfx.Sprite, MBUTTON_S_HCONT, x + w / 2, y);
+               }
            PopClipping();
            if (mi->d.hslider.cflags & MI_CFLAGS_LEFT) {
                VideoDraw(MenuButtonGfx.Sprite, MBUTTON_LEFT_ARROW + 1, x - 2, 
y);
@@ -939,7 +978,11 @@
 
        PushClipping();
        SetClipping(0, 0, x + w, VideoHeight - 1);
+       if (mi->transparent) {
+       VideoDrawClipTrans50(MenuButtonGfx.Sprite, rb, x - 1, y - 1);
+       } else {
        VideoDrawClip(MenuButtonGfx.Sprite, rb, x - 1, y - 1);
+       }
        PopClipping();
        text = mi->d.input.buffer;
        if (text) {
@@ -1068,7 +1111,7 @@
                SetDefaultTextColors(oldnc, oldrc);
                break;
            case MI_TYPE_BUTTON:
-               DrawMenuButton(mi->d.button.button, mi->flags,
+               DrawMenuButton(mi->d.button.button, mi->flags, mi->transparent,
                    mi->d.button.xsize, mi->d.button.ysize,
                    menu->X + mi->xofs, menu->Y + mi->yofs,
                    mi->font, mi->d.button.text,
Index: stratagus/src/ui/menus.c
diff -u stratagus/src/ui/menus.c:1.595 stratagus/src/ui/menus.c:1.596
--- stratagus/src/ui/menus.c:1.595      Sat Nov 29 09:34:48 2003
+++ stratagus/src/ui/menus.c    Sun Dec 14 03:14:47 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: menus.c,v 1.595 2003/11/28 22:34:48 nehalmistry Exp $
+//     $Id: menus.c,v 1.596 2003/12/13 16:14:47 mohydine Exp $
 
 //@{
 
@@ -451,8 +451,8 @@
 **     Help-items for the Net Multiplayer Setup and Client Menus
 */
 local Menuitem NetMultiButtonStorage[] = {
-    { MI_TYPE_PULLDOWN, 40, 32, 0, GameFont, NULL, NULL, NULL, {{NULL,0}} },
-    { MI_TYPE_DRAWFUNC, 40, 32, 0, GameFont, NULL, NULL, NULL, {{NULL,0}} },
+    { MI_TYPE_PULLDOWN, 40, 32, 0, GameFont, 0, NULL, NULL, NULL, {{NULL,0}} },
+    { MI_TYPE_DRAWFUNC, 40, 32, 0, GameFont, 0, NULL, NULL, NULL, {{NULL,0}} },
 };
 local void InitNetMultiButtonStorage() {
     MenuitemPulldown i0 = { mgptsoptions, 172, 20, MBUTTON_PULLDOWN, 
MultiGamePTSAction, 3, -1, 0, 0, 0};
@@ -3021,7 +3021,7 @@
     Menu *menu;
 
 #ifdef USE_SDL_SURFACE
-    MenusSetBackground();
+    VideoUnlockScreen();
     Invalidate();
 #else
     VideoLockScreen();
@@ -7178,6 +7178,7 @@
     char* reply;
     Menu* menu;
     char* port;
+
 
     
     SendMetaCommand("NumberOfGames", "");
Index: stratagus/src/video/sprite.c
diff -u stratagus/src/video/sprite.c:1.53 stratagus/src/video/sprite.c:1.54
--- stratagus/src/video/sprite.c:1.53   Mon Dec  1 12:36:02 2003
+++ stratagus/src/video/sprite.c        Sun Dec 14 03:14:48 2003
@@ -27,7 +27,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: sprite.c,v 1.53 2003/12/01 01:36:02 jsalmon3 Exp $
+//     $Id: sprite.c,v 1.54 2003/12/13 16:14:48 mohydine Exp $
 
 //@{
 
@@ -72,7 +72,7 @@
 ----------------------------------------------------------------------------*/
 
 #ifdef USE_SDL_SURFACE
-global void VideoDraw(const Graphic* sprite, unsigned frame, int x, int y)
+local void VideoDraw(const Graphic* sprite, unsigned frame, int x, int y)
 {
     SDL_Rect srect;
     SDL_Rect drect;
@@ -112,29 +112,12 @@
     SDL_BlitSurface(sprite->Surface, &srect, TheScreen, &drect);
 }
 
-global void VideoDrawX(const Graphic* sprite, unsigned frame, int x, int y)
+local void VideoDrawX(const Graphic* sprite, unsigned frame, int x, int y)
 {
     SDL_Rect srect;
     SDL_Rect drect;
 
-    srect.x = (sprite->SurfaceFlip->w - (frame % (sprite->SurfaceFlip->w / 
-           sprite->Width)) * sprite->Width) - sprite->Width;
-    srect.y = (frame / (sprite->SurfaceFlip->w / sprite->Width)) * 
sprite->Height;
-    srect.w = sprite->Width;
-    srect.h = sprite->Height;
-
-    drect.x = x;
-    drect.y = y;
-
-    SDL_BlitSurface(sprite->SurfaceFlip, &srect, TheScreen, &drect);
-}
-
-global void VideoDrawClipX(const Graphic* sprite, unsigned frame, int x, int y)
-{
-    SDL_Rect srect;
-    SDL_Rect drect;
-    int oldx;
-    int oldy;
+    DebugCheck(!sprite->SurfaceFlip);
 
     srect.x = (sprite->SurfaceFlip->w - (frame % (sprite->SurfaceFlip->w / 
            sprite->Width)) * sprite->Width) - sprite->Width;
@@ -142,55 +125,18 @@
     srect.w = sprite->Width;
     srect.h = sprite->Height;
 
-    oldx = x;
-    oldy = y;
-    CLIP_RECTANGLE(x, y, srect.w, srect.h);
-    srect.x += x - oldx;
-    srect.y += y - oldy;
-
     drect.x = x;
     drect.y = y;
 
     SDL_BlitSurface(sprite->SurfaceFlip, &srect, TheScreen, &drect);
 }
 
-global void VideoDrawShadowClip(const Graphic* sprite, unsigned frame,
-    int x, int y)
-{
-    SDL_Rect srect;
-    SDL_Rect drect;
-    int oldx;
-    int oldy;
-    unsigned char alpha;
-
-    srect.x = (frame % (sprite->Surface->w / sprite->Width)) * sprite->Width;
-    srect.y = (frame / (sprite->Surface->w / sprite->Width)) * sprite->Height;
-    srect.w = sprite->Width;
-    srect.h = sprite->Height;
-
-    oldx = x;
-    oldy = y;
-    CLIP_RECTANGLE(x, y, srect.w, srect.h);
-    srect.x += x - oldx;
-    srect.y += y - oldy;
-
-    drect.x = x;
-    drect.y = y;
-
-    alpha = sprite->Surface->format->alpha;
-    SDL_SetAlpha(sprite->Surface, SDL_SRCALPHA | SDL_RLEACCEL, 128);
-    SDL_BlitSurface(sprite->Surface, &srect, TheScreen, &drect);
-    SDL_SetAlpha(sprite->Surface, SDL_SRCALPHA | SDL_RLEACCEL, alpha);
-}
-
-global void VideoDrawShadowClipX(const Graphic* sprite, unsigned frame,
-    int x, int y)
+local void VideoDrawClipX(const Graphic* sprite, unsigned frame, int x, int y)
 {
     SDL_Rect srect;
     SDL_Rect drect;
     int oldx;
     int oldy;
-    unsigned char alpha;
 
     srect.x = (sprite->SurfaceFlip->w - (frame % (sprite->SurfaceFlip->w / 
            sprite->Width)) * sprite->Width) - sprite->Width;
@@ -207,10 +153,7 @@
     drect.x = x;
     drect.y = y;
 
-    alpha = sprite->Surface->format->alpha;
-    SDL_SetAlpha(sprite->Surface, SDL_SRCALPHA | SDL_RLEACCEL, 128);
     SDL_BlitSurface(sprite->SurfaceFlip, &srect, TheScreen, &drect);
-    SDL_SetAlpha(sprite->Surface, SDL_SRCALPHA | SDL_RLEACCEL, alpha);
 }
 #else
 //
@@ -784,6 +727,7 @@
                }
                if (dp <= pp) {
                    *dp++ = pixels[*sp++];
+
                }
            } while (dp < lp);
            dp += da;
@@ -3396,76 +3340,1392 @@
 #endif
 #endif
 }
+/// 
*******************************************************************************************
+/// Begining of 50% Transparent functions
+/// 
*******************************************************************************************
+/**
+**     Draw 8bit graphic object unclipped and flipped in X direction
+**     into 8 bit framebuffer.
+**
+**     @param sprite   pointer to object
+**     @param frame    number of frame (object index)
+**     @param x        x coordinate on the screen
+**     @param y        y coordinate on the screen
+*/
+local void VideoDraw8to8XTrans50(const Graphic* sprite, unsigned frame, int x, 
int y)
+{
+    const unsigned char* sp;
+    unsigned w;
+    VMemType8* dp;
+    const VMemType8* lp;
+    const VMemType8* ep;
+    const VMemType8* pp;
+    const VMemType8* pixels;
+    unsigned da;
+
+    pixels = (VMemType8*)sprite->Pixels;
+    sp = ((unsigned char**)sprite->Frames)[frame];
+    w = sprite->Width;
+    dp = VideoMemory8 + x + y * VideoWidth + w - 1;
+    da = VideoWidth + w;
+    ep = dp + VideoWidth * sprite->Height;
+    do {
+       lp = dp - w;
+       do {                            // 1 line
+           dp -= *sp++;                        // transparent
+           pp = dp + 1 - *sp++;                // opaque
+           while (dp > pp) {           // unrolled
+               *dp-- = pixels[*sp++];
+               *dp-- = pixels[*sp++];
+           }
+           if (dp >= pp) {
+               *dp-- = pixels[*sp++];
+           }
+       } while (dp > lp);
+       dp += da;
+    } while (dp < ep);                 // all lines
+}
 
 /**
-**     Init sprite
+**     Draw 8bit graphic object unclipped and flipped in X direction
+**     into 16 bit framebuffer.
+**
+**     @param sprite   pointer to object
+**     @param frame    number of frame (object index)
+**     @param x        x coordinate on the screen
+**     @param y        y coordinate on the screen
 */
-global void InitSprite(void)
+local void VideoDraw8to16XTrans50(const Graphic* sprite, unsigned frame, int 
x, int y)
 {
-#ifdef USE_SDL_SURFACE
+    const unsigned char* sp;
+    unsigned w;
+    VMemType16* dp;
+    const VMemType16* lp;
+    const VMemType16* ep;
+    const VMemType16* pp;
+    const VMemType16* pixels;
+    unsigned da;
 
-#else
+    pixels = (VMemType16*)sprite->Pixels;
+    sp = ((unsigned char**)sprite->Frames)[frame];
+    w = sprite->Width;
+    dp = VideoMemory16 + x + y * VideoWidth + w - 1;
+    da = VideoWidth + w;
+    ep = dp + VideoWidth * sprite->Height;
 
-#ifdef USE_OPENGL
-    GraphicSprite8Type.Draw = VideoDrawOpenGL;
-    GraphicSprite8Type.DrawClip = VideoDrawClipOpenGL;
-    GraphicSprite8Type.DrawShadowClip = VideoDraw8to32ShadowClip;
-    GraphicSprite8Type.DrawX = VideoDrawXOpenGL;
-    GraphicSprite8Type.DrawClipX = VideoDrawClipXOpenGL;
-    GraphicSprite8Type.DrawShadowClipX = VideoDraw8to32ShadowClipX;
-    VideoDrawRawClip = VideoDrawRaw32Clip;
-#else
+    do {
+       lp = dp - w;
+       do {                            // 1 line
+           dp -= *sp++;                        // transparent
+           pp = dp + 1 - *sp++;                // opaque
+           while (dp > pp) {           // unrolled
+               *dp-- = pixels[*sp++];
+               *dp-- = pixels[*sp++];
+           }
+           if (dp >= pp) {
+               *dp-- = pixels[*sp++];
+           }
+       } while (dp > lp);
+       dp += da;
+    } while (dp < ep);                 // all lines
+}
 
-    switch (VideoBpp) {
-       case 8:
-           GraphicSprite8Type.Draw = VideoDraw8to8;
-           GraphicSprite8Type.DrawClip = VideoDraw8to8Clip;
-           GraphicSprite8Type.DrawShadowClip = VideoDraw8to8ShadowClip;
-           GraphicSprite8Type.DrawX = VideoDraw8to8X;
-           GraphicSprite8Type.DrawClipX = VideoDraw8to8ClipX;
-           GraphicSprite8Type.DrawShadowClipX = VideoDraw8to8ShadowClipX;
-            VideoDrawRawClip = VideoDrawRaw8Clip;
-           break;
+/**
+**     Draw 8bit graphic object unclipped and flipped in X direction
+**     into 24 bit framebuffer.
+**
+**     @param sprite   pointer to object
+**     @param frame    number of frame (object index)
+**     @param x        x coordinate on the screen
+**     @param y        y coordinate on the screen
+*/
+local void VideoDraw8to24XTrans50(const Graphic* sprite, unsigned frame, int 
x, int y)
+{
+    const unsigned char* sp;
+    unsigned w;
+    VMemType24* dp;
+    const VMemType24* lp;
+    const VMemType24* ep;
+    const VMemType24* pp;
+    const VMemType24* pixels;
+    unsigned da;
 
-       case 15:
-       case 16:
-           GraphicSprite8Type.Draw = VideoDraw8to16;
-           GraphicSprite8Type.DrawClip = VideoDraw8to16Clip;
-           GraphicSprite8Type.DrawShadowClip = VideoDraw8to16ShadowClip;
-           GraphicSprite8Type.DrawX = VideoDraw8to16X;
-           GraphicSprite8Type.DrawClipX = VideoDraw8to16ClipX;
-           GraphicSprite8Type.DrawShadowClipX = VideoDraw8to16ShadowClipX;
-            VideoDrawRawClip = VideoDrawRaw16Clip;
-           break;
+    pixels = (VMemType24*)sprite->Pixels;
+    sp = ((unsigned char**)sprite->Frames)[frame];
+    w = sprite->Width;
+    dp = VideoMemory24 + x + y * VideoWidth + w - 1;
+    da = VideoWidth + w;
+    ep = dp + VideoWidth * sprite->Height;
 
-       case 24:
-           GraphicSprite8Type.Draw = VideoDraw8to24;
-           GraphicSprite8Type.DrawClip = VideoDraw8to24Clip;
-           GraphicSprite8Type.DrawShadowClip = VideoDraw8to24ShadowClip;
-           GraphicSprite8Type.DrawX = VideoDraw8to24X;
-           GraphicSprite8Type.DrawClipX = VideoDraw8to24ClipX;
-           GraphicSprite8Type.DrawShadowClipX = VideoDraw8to24ShadowClipX;
-            VideoDrawRawClip = VideoDrawRaw24Clip;
-           break;
+    do {
+       lp = dp - w;
+       do {                            // 1 line
+           dp -= *sp++;                        // transparent
+           pp = dp + 1 - *sp++;                // opaque
+           while (dp > pp) {           // unrolled
+               *dp-- = pixels[*sp++];
+               *dp-- = pixels[*sp++];
+           }
+           if (dp >= pp) {
+               *dp-- = pixels[*sp++];
+           }
+       } while (dp > lp);
+       dp += da;
+    } while (dp < ep);                 // all lines
+}
+
+/**
+**     Draw 8bit graphic object unclipped and flipped in X direction
+**     into 32 bit framebuffer.
+**
+**     @param sprite   pointer to object
+**     @param frame    number of frame (object index)
+**     @param x        x coordinate on the screen
+**     @param y        y coordinate on the screen
+*/
+local void VideoDraw8to32XTrans50(const Graphic* sprite, unsigned frame, int 
x, int y)
+{
+    const unsigned char* sp;
+    unsigned w;
+    VMemType32* dp;
+    const VMemType32* lp;
+    const VMemType32* ep;
+    const VMemType32* pp;
+    const VMemType32* pixels;
+    unsigned da;
+
+    pixels = (VMemType32*)sprite->Pixels;
+    sp = ((unsigned char**)sprite->Frames)[frame];
+    w = sprite->Width;
+    dp = VideoMemory32 + x + y * VideoWidth + w - 1;
+    da = VideoWidth + w;
+    ep = dp + VideoWidth * sprite->Height;
+
+    do {
+       lp = dp - w;
+       do {                            // 1 line
+           dp -= *sp++;                        // transparent
+           pp = dp + 1 - *sp++;                // opaque
+           while (dp > pp) {           // unrolled
+               *dp-- = pixels[*sp++];
+               *dp-- = pixels[*sp++];
+           }
+           if (dp >= pp) {
+               *dp-- = pixels[*sp++];
+           }
+       } while (dp > lp);
+       dp += da;
+    } while (dp < ep);                 // all lines
+}
+
+
+/**
+**     Draw 8bit graphic object clipped into 8 bit framebuffer.
+**
+**     @param sprite   pointer to object
+**     @param frame    number of frame (object index)
+**     @param x        x coordinate on the screen
+**     @param y        y coordinate on the screen
+*/
+local void VideoDraw8to8ClipTrans50(const Graphic* sprite, unsigned frame, int 
x, int y)
+{
+    int ox;
+    int ex;
+    int oy;
+    int w;
+    int h;
+    const unsigned char* sp;
+    int sw;
+    VMemType8* dp;
+    const VMemType8* lp;
+    const VMemType8* ep;
+    VMemType8* pp;
+    const VMemType8* pixels;
+    int da;
+
+
+    //
+    // reduce to visible range
+    //
+    sw = w = sprite->Width;
+    h = sprite->Height;
+    CLIP_RECTANGLE_OFS(x, y, w, h, ox, oy, ex);
+
+    //
+    // Draw the clipped sprite
+    //
+    pixels = (VMemType8*)sprite->Pixels;
+    sp = ((unsigned char**)sprite->Frames)[frame];
+
+    //
+    // Skip top lines, if needed.
+    //
+    while (oy--) {
+       da = 0;
+       do {
+           da += *sp++;                        // transparent
+           da += *sp;                  // opaque
+           sp += *sp + 1;
+       } while (da < sw);
+    }
+
+    da = VideoWidth - sw;
+    dp = VideoMemory8 + x + y * VideoWidth;
+    ep = dp + VideoWidth * h;
+
+    if (w == sw) {                     // Unclipped horizontal
+
+       do {
+           lp = dp + sw;
+           do {                        // 1 line
+               dp += *sp++;            // transparent
+               pp = dp - 1 + *sp++;            // opaque
+               while (dp < pp) {       // unroll
+                   *dp++ = pixels[*sp++];
+                   *dp++ = pixels[*sp++];
+               }
+               if (dp <= pp) {
+                   *dp++ = pixels[*sp++];
+               }
+           } while (dp < lp);
+           dp += da;
+       } while (dp < ep);              // all lines
+
+    } else {                           // Clip horizontal
+
+       da += ox;
+       do {
+           lp = dp + w;
+           //
+           //  Clip left
+           //
+           pp = dp - ox;
+           for (;;) {
+               pp += *sp++;            // transparent
+               if (pp >= dp) {
+                   dp = pp;
+                   goto middle_trans;
+               }
+               pp += *sp;              // opaque
+               if (pp >= dp) {
+                   sp += *sp - (pp - dp) + 1;
+                   goto middle_pixel;
+               }
+               sp += *sp + 1;
+           }
+
+           //
+           //  Draw middle
+           //
+           for (;;) {
+               dp += *sp++;            // transparent
+middle_trans:
+               if (dp >= lp) {
+                   lp += sw - w - ox;
+                   goto right_trans;
+               }
+               pp = dp + *sp++;                // opaque
+middle_pixel:
+               if (pp < lp) {
+                   while (dp < pp) {
+                       *dp++ = pixels[*sp++];
+                   }
+                   continue;
+               }
+               while (dp < lp) {
+                   *dp++ = pixels[*sp++];
+               }
+               sp += pp - dp;
+               dp = pp;
+               break;
+           }
+
+           //
+           //  Clip right
+           //
+           lp += sw - w - ox;
+           while (dp < lp) {
+               dp += *sp++;            // transparent
+right_trans:
+               dp += *sp;              // opaque
+               sp += *sp + 1;
+           }
+           dp += da;
+       } while (dp < ep);              // all lines
+
+    }
+}
+
+/**
+**     Draw 8bit graphic object clipped into 16 bit framebuffer.
+**
+**     @param sprite   pointer to object
+**     @param frame    number of frame (object index)
+**     @param x        x coordinate on the screen
+**     @param y        y coordinate on the screen
+*/
+local void VideoDraw8to16ClipTrans50(const Graphic* sprite, unsigned frame, 
int x, int y)
+{
+    int ox;
+    int ex;
+    int oy;
+    int w;
+    int h;
+    const unsigned char* sp;
+    int sw;
+    VMemType16* dp;
+    const VMemType16* lp;
+    const VMemType16* ep;
+    VMemType16* pp;
+    const VMemType16* pixels;
+    int da;
+    
+//Added by Mohydine
+
+    VMemType16* p;
+    p = VideoMemory16 + y * VideoWidth + x;
+
+//Added by Mohydine
+    //
+    // reduce to visible range
+    //
+    sw = w = sprite->Width;
+    h = sprite->Height;
+    CLIP_RECTANGLE_OFS(x, y, w, h, ox, oy, ex);
+
+    
+    //
+    // Draw the clipped sprite
+    //
+    pixels = (VMemType16*)sprite->Pixels;
+    sp = ((unsigned char**)sprite->Frames)[frame];
+
+    //
+    // Skip top lines, if needed.
+    //
+    while (oy--) {
+       da = 0;
+       do {
+           da += *sp++;                        // transparent
+           da += *sp;                  // opaque
+           sp += *sp + 1;
+       } while (da < sw);
+    }
+
+    da = VideoWidth - sw;
+    dp = VideoMemory16 + x + y * VideoWidth;
+    ep = dp + VideoWidth * h;
+
+    if (w == sw) {                     // Unclipped horizontal
+
+       do {
+           lp = dp + sw;
+           do {                        // 1 line
+               dp += *sp++;            // transparent
+               pp = dp - 1 + *sp++;            // opaque
+               while (dp < pp) {       // unroll
+                   *dp++ =  ((*dp >> 1) & 0x7BEF)  +((pixels[*sp++] >> 1) & 
0x7BEF);
+                   *dp++ =  ((*dp >> 1) & 0x7BEF)  +((pixels[*sp++] >> 1) & 
0x7BEF);
+                       //*dp++ =  ((*dp >> 2) & 0x79E7) + ((pixels[*sp] >> 2) 
& 0x79E7) +((pixels[*sp++] >> 1) & 0x7BEF);
+                   //*dp++ =  ((*dp >> 2) & 0x79E7) + ((pixels[*sp] >> 2) & 
0x79E7) +((pixels[*sp++] >> 1) & 0x7BEF);
+               }
+               if (dp <= pp) {
+                   *dp++ =  ((*dp >> 1) & 0x7BEF) + ((pixels[*sp++] >> 1) & 
0x7BEF);
+               }
+           } while (dp < lp);
+           dp += da;
+       } while (dp < ep);              // all lines
+
+    } else {                           // Clip horizontal
+
+       da += ox;
+       do {
+           lp = dp + w;
+           //
+           //  Clip left
+           //
+           pp = dp - ox;
+           for (;;) {
+               pp += *sp++;            // transparent
+               if (pp >= dp) {
+                   dp = pp;
+                   goto middle_trans;
+               }
+               pp += *sp;              // opaque
+               if (pp >= dp) {
+                   sp += *sp - (pp - dp) + 1;
+                   goto middle_pixel;
+               }
+               sp += *sp + 1;
+           }
+
+           //
+           //  Draw middle
+           //
+           for (;;) {
+               dp += *sp++;            // transparent
+middle_trans:
+               if (dp >= lp) {
+                   lp += sw - w - ox;
+                   goto right_trans;
+               }
+               pp = dp + *sp++;                // opaque
+middle_pixel:
+               if (pp < lp) {
+                   while (dp < pp) {
+                       *dp++ =  ((*dp >> 1) & 0x7BEF) + ((pixels[*sp++] >> 1) 
& 0x7BEF);
+                   }
+                   continue;
+               }
+               while (dp < lp) {
+                   *dp++ =  ((*dp >> 1) & 0x7BEF) + ((pixels[*sp++] >> 1) & 
0x7BEF);
+               }
+               sp += pp - dp;
+               dp = pp;
+               break;
+           }
+
+           //
+           //  Clip right
+           //
+           lp += sw - w - ox;
+           while (dp < lp) {
+               dp += *sp++;            // transparent
+right_trans:
+               dp += *sp;              // opaque
+               sp += *sp + 1;
+           }
+           dp += da;
+       } while (dp < ep);              // all lines
+
+    }
+}
+
+/**
+**     Draw 8bit graphic object clipped into 24 bit framebuffer.
+**
+**     @param sprite   pointer to object
+**     @param frame    number of frame (object index)
+**     @param x        x coordinate on the screen
+**     @param y        y coordinate on the screen
+*/
+local void VideoDraw8to24ClipTrans50(const Graphic* sprite, unsigned frame, 
int x, int y)
+{
+    int ox;
+    int ex;
+    int oy;
+    int w;
+    int h;
+    const unsigned char* sp;
+    int sw;
+    VMemType24* dp;
+    const VMemType24* lp;
+    const VMemType24* ep;
+    VMemType24* pp;
+    const VMemType24* pixels;
+    int da;
+
+    //
+    // reduce to visible range
+    //
+    sw = w = sprite->Width;
+    h = sprite->Height;
+    CLIP_RECTANGLE_OFS(x, y, w, h, ox, oy, ex);
+
+    //
+    // Draw the clipped sprite
+    //
+    pixels = (VMemType24*)sprite->Pixels;
+    sp = ((unsigned char**)sprite->Frames)[frame];
+
+    //
+    // Skip top lines, if needed.
+    //
+    while (oy--) {
+       da = 0;
+       do {
+           da += *sp++;                        // transparent
+           da += *sp;                  // opaque
+           sp += *sp + 1;
+       } while (da < sw);
+    }
+
+    da = VideoWidth - sw;
+    dp = VideoMemory24 + x + y * VideoWidth;
+    ep = dp + VideoWidth * h;
+
+    if (w == sw) {                     // Unclipped horizontal
+
+       do {
+           lp = dp + sw;
+           do {                        // 1 line
+               dp += *sp++;            // transparent
+               pp = dp - 1 + *sp++;            // opaque
+               while (dp < pp) {       // unroll
+                   *dp++ = pixels[*sp++];
+                   *dp++ = pixels[*sp++];
+               }
+               if (dp <= pp) {
+                   *dp++ = pixels[*sp++];
+               }
+           } while (dp < lp);
+           dp += da;
+       } while (dp < ep);              // all lines
+
+    } else {                           // Clip horizontal
+
+       da += ox;
+       do {
+           lp = dp + w;
+           //
+           //  Clip left
+           //
+           pp = dp - ox;
+           for (;;) {
+               pp += *sp++;            // transparent
+               if (pp >= dp) {
+                   dp = pp;
+                   goto middle_trans;
+               }
+               pp += *sp;              // opaque
+               if (pp >= dp) {
+                   sp += *sp - (pp - dp) + 1;
+                   goto middle_pixel;
+               }
+               sp += *sp + 1;
+           }
+
+           //
+           //  Draw middle
+           //
+           for (;;) {
+               dp += *sp++;            // transparent
+middle_trans:
+               if (dp >= lp) {
+                   lp += sw - w - ox;
+                   goto right_trans;
+               }
+               pp = dp + *sp++;                // opaque
+middle_pixel:
+               if (pp < lp) {
+                   while (dp < pp) {
+                       *dp++ = pixels[*sp++];
+                   }
+                   continue;
+               }
+               while (dp < lp) {
+                   *dp++ = pixels[*sp++];
+               }
+               sp += pp - dp;
+               dp = pp;
+               break;
+           }
+
+           //
+           //  Clip right
+           //
+           lp += sw - w - ox;
+           while (dp < lp) {
+               dp += *sp++;            // transparent
+right_trans:
+               dp += *sp;              // opaque
+               sp += *sp + 1;
+           }
+           dp += da;
+       } while (dp < ep);              // all lines
+
+    }
+}
+
+/**
+**     Draw 8bit graphic object clipped into 32 bit framebuffer.
+**
+**     @param sprite   pointer to object
+**     @param frame    number of frame (object index)
+**     @param x        x coordinate on the screen
+**     @param y        y coordinate on the screen
+*/
+local void VideoDraw8to32ClipTrans50(const Graphic* sprite, unsigned frame, 
int x, int y)
+{
+    int ox;
+    int ex;
+    int oy;
+    int w;
+    int h;
+    const unsigned char* sp;
+    int sw;
+    VMemType32* dp;
+    const VMemType32* lp;
+    const VMemType32* ep;
+    VMemType32* pp;
+    const VMemType32* pixels;
+    int da;
+
+    //
+    // reduce to visible range
+    //
+    sw = w = sprite->Width;
+    h = sprite->Height;
+    CLIP_RECTANGLE_OFS(x, y, w, h, ox, oy, ex);
+
+    //
+    // Draw the clipped sprite
+    //
+    pixels = (VMemType32*)sprite->Pixels;
+    sp = ((unsigned char**)sprite->Frames)[frame];
+
+    //
+    // Skip top lines, if needed.
+    //
+    while (oy--) {
+       da = 0;
+       do {
+           da += *sp++;                        // transparent
+           da += *sp;                  // opaque
+           sp += *sp + 1;
+       } while (da < sw);
+    }
+
+    da = VideoWidth - sw;
+    dp = VideoMemory32 + x + y * VideoWidth;
+    ep = dp + VideoWidth * h;
+
+    if (w == sw) {                     // Unclipped horizontal
+
+       do {
+           lp = dp + sw;
+           do {                        // 1 line
+               dp += *sp++;            // transparent
+               pp = dp - 1 + *sp++;            // opaque
+               while (dp < pp) {       // unroll
+                   *dp++ =  ((*dp >> 1) & 0x7F7F7F7F) + ((pixels[*sp++] >> 1) 
& 0x7F7F7F7F) ;
+                   *dp++ =  ((*dp >> 1) & 0x7F7F7F7F) + ((pixels[*sp++] >> 1) 
& 0x7F7F7F7F) ;
+               }
+               if (dp <= pp) {
+                   *dp++ = ((*dp >> 1) & 0x7F7F7F7F) + ((pixels[*sp++] >> 1) & 
0x7F7F7F7F);
+               }
+           } while (dp < lp);
+           dp += da;
+       } while (dp < ep);              // all lines
+
+    } else {                           // Clip horizontal
+
+       da += ox;
+       do {
+           lp = dp + w;
+           //
+           //  Clip left
+           //
+           pp = dp - ox;
+           for (;;) {
+               pp += *sp++;            // transparent
+               if (pp >= dp) {
+                   dp = pp;
+                   goto middle_trans;
+               }
+               pp += *sp;              // opaque
+               if (pp >= dp) {
+                   sp += *sp - (pp - dp) + 1;
+                   goto middle_pixel;
+               }
+               sp += *sp + 1;
+           }
+
+           //
+           //  Draw middle
+           //
+           for (;;) {
+               dp += *sp++;            // transparent
+middle_trans:
+               if (dp >= lp) {
+                   lp += sw - w - ox;
+                   goto right_trans;
+               }
+               pp = dp + *sp++;                // opaque
+middle_pixel:
+               if (pp < lp) {
+                   while (dp < pp) {
+                       *dp++ = ((*dp >> 1) & 0x7F7F7F7F) + ((pixels[*sp++] >> 
1) & 0x7F7F7F7F);
+                   }
+                   continue;
+               }
+               while (dp < lp) {
+                   *dp++ = ((*dp >> 1) & 0x7F7F7F7F) + ((pixels[*sp++] >> 1) & 
0x7F7F7F7F);
+               }
+               sp += pp - dp;
+               dp = pp;
+               break;
+           }
+
+           //
+           //  Clip right
+           //
+           lp += sw - w - ox;
+           while (dp < lp) {
+               dp += *sp++;            // transparent
+right_trans:
+               dp += *sp;              // opaque
+               sp += *sp + 1;
+           }
+           dp += da;
+       } while (dp < ep);              // all lines
+
+    }
+}
+
+/**
+**     Draw 8bit graphic object clipped and flipped in X direction
+**     into 8 bit framebuffer.
+**
+**     @param sprite   pointer to object
+**     @param frame    number of frame (object index)
+**     @param x        x coordinate on the screen
+**     @param y        y coordinate on the screen
+*/
+local void VideoDraw8to8ClipXTrans50(const Graphic* sprite, unsigned frame, 
int x, int y)
+{
+    int ox;
+    int ex;
+    int oy;
+    int w;
+    int h;
+    const unsigned char* sp;
+    int sw;
+    VMemType8* dp;
+    const VMemType8* lp;
+    const VMemType8* ep;
+    VMemType8* pp;
+    const VMemType8* pixels;
+    int da;
+
+    //
+    // reduce to visible range
+    //
+    sw = w = sprite->Width;
+    h = sprite->Height;
+    CLIP_RECTANGLE_OFS(x, y, w, h, ox, oy, ex);
+
+    //
+    // Draw the clipped sprite
+    //
+    pixels = (VMemType8*)sprite->Pixels;
+    sp = ((unsigned char**)sprite->Frames)[frame];
+
+    //
+    // Skip top lines
+    //
+    while (oy--) {
+       da = 0;
+       do {
+           da += *sp++;                        // transparent
+           da += *sp;                  // opaque
+           sp += *sp + 1;
+       } while (da < sw);
+    }
+
+    da = VideoWidth + sw;
+    dp = VideoMemory8 + x + y * VideoWidth + w - 1;
+    ep = dp + VideoWidth * h;
+
+    if (w == sw) {                     // Unclipped horizontal
+
+       while (dp < ep) {               // all lines
+           lp = dp - w;
+           do {                        // 1 line
+               dp -= *sp++;            // transparent
+               pp = dp + 1 - *sp++;            // opaque
+               while (dp > pp) {
+                   *dp-- = pixels[*sp++];
+                   *dp-- = pixels[*sp++];
+               }
+               if (dp >= pp) {
+                   *dp-- = pixels[*sp++];
+               }
+           } while (dp > lp);
+           dp += da;
+       }
+
+    } else {                           // Clip horizontal
+
+       da -= sw - w - ox;
+       while (dp < ep) {               // all lines
+           lp = dp - w;
+           //
+           //  Clip right side
+           //
+           pp = dp + sw - w - ox;
+           for (;;) {
+               pp -= *sp++;            // transparent
+               if (pp <= dp) {
+                   dp = pp;
+                   goto middle_trans;
+               }
+               pp -= *sp;              // opaque
+               if (pp <= dp) {
+                   sp += *sp - (dp - pp) + 1;
+                   goto middle_pixel;
+               }
+               sp += *sp + 1;
+           }
+
+           //
+           //  Draw middle
+           //
+           for (;;) {
+               dp -= *sp++;            // transparent
+middle_trans:
+               if (dp <= lp) {
+                   lp -= ox;
+                   goto right_trans;
+               }
+               pp = dp - *sp++;                // opaque
+middle_pixel:
+               if (pp > lp) {
+                   while (dp > pp) {
+                       *dp-- = pixels[*sp++];
+                   }
+                   continue;
+               }
+               while (dp > lp) {
+                   *dp-- = pixels[*sp++];
+               }
+               sp += dp - pp;
+               dp = pp;
+               break;
+           }
+
+           //
+           //  Clip left side
+           //
+           lp -= ox;
+           while (dp > lp) {
+               dp -= *sp++;            // transparent
+right_trans:
+               dp -= *sp;              // opaque
+               sp += *sp + 1;
+           }
+           dp += da;
+
+       }
+    }
+}
+
+/**
+**     Draw 8bit graphic object clipped and flipped in X direction
+**     into 16 bit framebuffer.
+**
+**     @param sprite   pointer to object
+**     @param frame    number of frame (object index)
+**     @param x        x coordinate on the screen
+**     @param y        y coordinate on the screen
+*/
+local void VideoDraw8to16ClipXTrans50(const Graphic* sprite, unsigned frame,
+    int x, int y)
+{
+    int ox;
+    int ex;
+    int oy;
+    int w;
+    int h;
+    const unsigned char* sp;
+    int sw;
+    VMemType16* dp;
+    const VMemType16* lp;
+    const VMemType16* ep;
+    VMemType16* pp;
+    const VMemType16* pixels;
+    int da;
+
+
+    //
+    // reduce to visible range
+    //
+    sw = w = sprite->Width;
+    h = sprite->Height;
+    CLIP_RECTANGLE_OFS(x, y, w, h, ox, oy, ex);
+
+    //
+    // Draw the clipped sprite
+    //
+    pixels = (VMemType16*)sprite->Pixels;
+    sp = ((unsigned char**)sprite->Frames)[frame];
+
+    //
+    // Skip top lines
+    //
+    while (oy--) {
+       da = 0;
+       do {
+           da += *sp++;                        // transparent
+           da += *sp;                  // opaque
+           sp += *sp + 1;
+       } while (da < sw);
+    }
+
+    da = VideoWidth + sw;
+    dp = VideoMemory16 + x + y * VideoWidth + w - 1;
+    ep = dp + VideoWidth * h;
+
+    if (w == sw) {                     // Unclipped horizontal
+
+       while (dp < ep) {               // all lines
+           lp = dp - w;
+           do {                        // 1 line
+               dp -= *sp++;            // transparent
+               pp = dp + 1 - *sp++;            // opaque
+               while (dp > pp) {
+                   *dp-- = ((*dp >> 1) & 0x7BEF) + ((pixels[*sp++] >> 1) & 
0x7BEF);
+                   *dp-- = ((*dp >> 1) & 0x7BEF) + ((pixels[*sp++] >> 1) & 
0x7BEF);
+               }
+               if (dp >= pp) {
+                   *dp-- = ((*dp >> 1) & 0x7BEF) + ((pixels[*sp++] >> 1) & 
0x7BEF);
+               }
+           } while (dp > lp);
+           dp += da;
+       }
+
+    } else {                           // Clip horizontal
+
+       da -= sw - w - ox;
+       while (dp < ep) {               // all lines
+           lp = dp - w;
+           //
+           //  Clip right side
+           //
+           pp = dp + sw - w - ox;
+           for (;;) {
+               pp -= *sp++;            // transparent
+               if (pp <= dp) {
+                   dp = pp;
+                   goto middle_trans;
+               }
+               pp -= *sp;              // opaque
+               if (pp <= dp) {
+                   sp += *sp - (dp - pp) + 1;
+                   goto middle_pixel;
+               }
+               sp += *sp + 1;
+           }
+
+           //
+           //  Draw middle
+           //
+           for (;;) {
+               dp -= *sp++;            // transparent
+middle_trans:
+               if (dp <= lp) {
+                   lp -= ox;
+                   goto right_trans;
+               }
+               pp = dp - *sp++;                // opaque
+middle_pixel:
+               if (pp > lp) {
+                   while (dp > pp) {
+                       *dp-- = pixels[*sp++];
+                   }
+                   continue;
+               }
+               while (dp > lp) {
+                   *dp-- = pixels[*sp++];
+               }
+               sp += dp - pp;
+               dp = pp;
+               break;
+           }
+
+           //
+           //  Clip left side
+           //
+           lp -= ox;
+           while (dp > lp) {
+               dp -= *sp++;            // transparent
+right_trans:
+               dp -= *sp;              // opaque
+               sp += *sp + 1;
+           }
+           dp += da;
+
+       }
+    }
+}
+
+/**
+**     Draw 8bit graphic object clipped and flipped in X direction
+**     into 24bit framebuffer.
+**
+**     @param sprite   pointer to object
+**     @param frame    number of frame (object index)
+**     @param x        x coordinate on the screen
+**     @param y        y coordinate on the screen
+*/
+local void VideoDraw8to24ClipXTrans50(const Graphic* sprite, unsigned frame,
+    int x, int y)
+{
+    int ox;
+    int ex;
+    int oy;
+    int w;
+    int h;
+    const unsigned char* sp;
+    int sw;
+    VMemType24* dp;
+    const VMemType24* lp;
+    const VMemType24* ep;
+    VMemType24* pp;
+    const VMemType24* pixels;
+    int da;
+
+    //
+    // reduce to visible range
+    //
+    sw = w = sprite->Width;
+    h = sprite->Height;
+    CLIP_RECTANGLE_OFS(x, y, w, h, ox, oy, ex);
+
+    //
+    // Draw the clipped sprite
+    //
+    pixels = (VMemType24*)sprite->Pixels;
+    sp = ((unsigned char**)sprite->Frames)[frame];
+
+    //
+    // Skip top lines
+    //
+    while (oy--) {
+       da = 0;
+       do {
+           da += *sp++;                        // transparent
+           da += *sp;                  // opaque
+           sp += *sp + 1;
+       } while (da < sw);
+    }
+
+    da = VideoWidth + sw;
+    dp = VideoMemory24 + x + y * VideoWidth + w - 1;
+    ep = dp + VideoWidth * h;
+
+    if (w == sw) {                     // Unclipped horizontal
+
+       while (dp < ep) {               // all lines
+           lp = dp - w;
+           do {                        // 1 line
+               dp -= *sp++;            // transparent
+               pp = dp + 1 - *sp++;            // opaque
+               while (dp > pp) {
+                   *dp-- = pixels[*sp++];
+                   *dp-- = pixels[*sp++];
+               }
+               if (dp >= pp) {
+                   *dp-- = pixels[*sp++];
+               }
+           } while (dp > lp);
+           dp += da;
+       }
+
+    } else {                           // Clip horizontal
+
+       da -= sw - w - ox;
+       while (dp < ep) {               // all lines
+           lp = dp - w;
+           //
+           //  Clip right side
+           //
+           pp = dp + sw - w - ox;
+           for (;;) {
+               pp -= *sp++;            // transparent
+               if (pp <= dp) {
+                   dp = pp;
+                   goto middle_trans;
+               }
+               pp -= *sp;              // opaque
+               if (pp <= dp) {
+                   sp += *sp - (dp - pp) + 1;
+                   goto middle_pixel;
+               }
+               sp += *sp + 1;
+           }
+
+           //
+           //  Draw middle
+           //
+           for (;;) {
+               dp -= *sp++;            // transparent
+middle_trans:
+               if (dp <= lp) {
+                   lp -= ox;
+                   goto right_trans;
+               }
+               pp = dp - *sp++;                // opaque
+middle_pixel:
+               if (pp > lp) {
+                   while (dp > pp) {
+                       *dp-- = pixels[*sp++];
+                   }
+                   continue;
+               }
+               while (dp > lp) {
+                   *dp-- = pixels[*sp++];
+               }
+               sp += dp - pp;
+               dp = pp;
+               break;
+           }
+
+           //
+           //  Clip left side
+           //
+           lp -= ox;
+           while (dp > lp) {
+               dp -= *sp++;            // transparent
+right_trans:
+               dp -= *sp;              // opaque
+               sp += *sp + 1;
+           }
+           dp += da;
+
+       }
+    }
+}
+
+/**
+**     Draw 8bit graphic object clipped and flipped in X direction
+**     into 32bit framebuffer.
+**
+**     @param sprite   pointer to object
+**     @param frame    number of frame (object index)
+**     @param x        x coordinate on the screen
+**     @param y        y coordinate on the screen
+*/
+local void VideoDraw8to32ClipXTrans50(const Graphic* sprite, unsigned frame
+       , int x, int y)
+{
+    int ex;
+    int ox;
+    int oy;
+    int w;
+    int h;
+    const unsigned char* sp;
+    int sw;
+    VMemType32* dp;
+    const VMemType32* lp;
+    const VMemType32* ep;
+    VMemType32* pp;
+    const VMemType32* pixels;
+    int da;
+
+    //
+    // reduce to visible range
+    //
+    sw = w = sprite->Width;
+    h = sprite->Height;
+    CLIP_RECTANGLE_OFS(x, y, w, h, ox, oy, ex);
+
+    //
+    // Draw the clipped sprite
+    //
+    pixels = (VMemType32*)sprite->Pixels;
+    sp = ((unsigned char**)sprite->Frames)[frame];
+
+    //
+    // Skip top lines
+    //
+    while (oy--) {
+       da = 0;
+       do {
+           da += *sp++;                        // transparent
+           da += *sp;                  // opaque
+           sp += *sp + 1;
+       } while (da < sw);
+    }
+
+    da = VideoWidth + sw;
+    dp = VideoMemory32 + x + y * VideoWidth + w - 1;
+    ep = dp + VideoWidth * h;
+
+    if (w == sw) {                     // Unclipped horizontal
+
+       while (dp < ep) {               // all lines
+           lp = dp - w;
+           do {                        // 1 line
+               dp -= *sp++;            // transparent
+               pp = dp + 1 - *sp++;            // opaque
+               while (dp > pp) {
+                   *dp-- = ((*dp >> 1) & 0x7F7F7F7F) + ((pixels[*sp++] >> 1) & 
0x7F7F7F7F);
+                   *dp-- = ((*dp >> 1) & 0x7F7F7F7F) + ((pixels[*sp++] >> 1) & 
0x7F7F7F7F);
+               }
+               if (dp >= pp) {
+                   *dp-- = pixels[*sp++];
+               }
+           } while (dp > lp);
+           dp += da;
+       }
+
+    } else {                           // Clip horizontal
+
+       da -= ex;
+       while (dp < ep) {               // all lines
+           lp = dp - w;
+           //
+           //  Clip right side
+           //
+           pp = dp + ex;
+           for (;;) {
+               pp -= *sp++;            // transparent
+               if (pp <= dp) {
+                   dp = pp;
+                   goto middle_trans;
+               }
+               pp -= *sp;              // opaque
+               if (pp <= dp) {
+                   sp += *sp - (dp - pp) + 1;
+                   goto middle_pixel;
+               }
+               sp += *sp + 1;
+           }
+
+           //
+           //  Draw middle
+           //
+           for (;;) {
+               dp -= *sp++;            // transparent
+middle_trans:
+               if (dp <= lp) {
+                   lp -= ox;
+                   goto right_trans;
+               }
+               pp = dp - *sp++;                // opaque
+middle_pixel:
+               if (pp > lp) {
+                   while (dp > pp) {
+                       *dp-- = ((*dp >> 1) & 0x7F7F7F7F) + ((pixels[*sp++] >> 
1) & 0x7F7F7F7F);
+                   }
+                   continue;
+               }
+               while (dp > lp) {
+                   *dp-- = ((*dp >> 1) & 0x7F7F7F7F) + ((pixels[*sp++] >> 1) & 
0x7F7F7F7F);
+               }
+               sp += dp - pp;
+               dp = pp;
+               break;
+           }
+
+           //
+           //  Clip left side
+           //
+           lp -= ox;
+           while (dp > lp) {
+               dp -= *sp++;            // transparent
+right_trans:
+               dp -= *sp;              // opaque
+               sp += *sp + 1;
+           }
+           dp += da;
+
+       }
+    }
+}
+// End Of 50% Transparent functions
+
+/**
+**     Init sprite
+*/
+global void InitSprite(void)
+{
+#ifdef USE_SDL_SURFACE
+
+#else
+
+#ifdef USE_OPENGL
+    GraphicSprite8Type.Draw = VideoDrawOpenGL;
+    GraphicSprite8Type.DrawClip = VideoDrawClipOpenGL;
+    GraphicSprite8Type.DrawShadowClip = VideoDraw8to32ShadowClip;
+    GraphicSprite8Type.DrawX = VideoDrawXOpenGL;
+    GraphicSprite8Type.DrawClipX = VideoDrawClipXOpenGL;
+    GraphicSprite8Type.DrawShadowClipX = VideoDraw8to32ShadowClipX;
+    VideoDrawRawClip = VideoDrawRaw32Clip;
+#else
+
+    switch (VideoBpp) {
+       case 8:
+           GraphicSprite8Type.Draw = VideoDraw8to8;
+           GraphicSprite8Type.DrawClip = VideoDraw8to8Clip;
+           GraphicSprite8Type.DrawShadowClip = VideoDraw8to8ShadowClip;
+           GraphicSprite8Type.DrawX = VideoDraw8to8X;
+           GraphicSprite8Type.DrawClipX = VideoDraw8to8ClipX;
+//50% Transparent functions
+               //GraphicSprite8Type.DrawTrans50 = VideoDraw8to8Trans50;
+           GraphicSprite8Type.DrawClipTrans50 = VideoDraw8to8ClipTrans50;
+           GraphicSprite8Type.DrawXTrans50 = VideoDraw8to8XTrans50;
+           GraphicSprite8Type.DrawClipXTrans50 = VideoDraw8to8ClipXTrans50;
+
+               GraphicSprite8Type.DrawShadowClip = VideoDraw8to8ShadowClip;
+           GraphicSprite8Type.DrawShadowClipX = VideoDraw8to8ShadowClipX;
+            VideoDrawRawClip = VideoDrawRaw8Clip;
+           break;
+
+       case 15:
+       case 16:
+           GraphicSprite8Type.Draw = VideoDraw8to16;
+           GraphicSprite8Type.DrawClip = VideoDraw8to16Clip;
+           GraphicSprite8Type.DrawShadowClip = VideoDraw8to16ShadowClip;
+           GraphicSprite8Type.DrawX = VideoDraw8to16X;
+           GraphicSprite8Type.DrawClipX = VideoDraw8to16ClipX;
+//50% Transparent functions            
+               //GraphicSprite8Type.DrawTrans50 = VideoDraw8to16Trans50;
+           GraphicSprite8Type.DrawClipTrans50 = VideoDraw8to16ClipTrans50;
+           GraphicSprite8Type.DrawXTrans50 = VideoDraw8to16XTrans50;
+           GraphicSprite8Type.DrawClipXTrans50 = VideoDraw8to16ClipXTrans50;
+
+               GraphicSprite8Type.DrawShadowClip = VideoDraw8to16ShadowClip;
+           GraphicSprite8Type.DrawShadowClipX = VideoDraw8to16ShadowClipX;
+            VideoDrawRawClip = VideoDrawRaw16Clip;
+           break;
+
+       case 24:
+           GraphicSprite8Type.Draw = VideoDraw8to24;
+           GraphicSprite8Type.DrawClip = VideoDraw8to24Clip;
+           GraphicSprite8Type.DrawShadowClip = VideoDraw8to24ShadowClip;
+           GraphicSprite8Type.DrawX = VideoDraw8to24X;
+           GraphicSprite8Type.DrawClipX = VideoDraw8to24ClipX;
+       //50% Transparent functions             
+               //GraphicSprite8Type.DrawTrans50 = VideoDraw8to24Trans50;
+           GraphicSprite8Type.DrawClipTrans50 = VideoDraw8to24ClipTrans50;
+           GraphicSprite8Type.DrawXTrans50 = VideoDraw8to24XTrans50;
+           GraphicSprite8Type.DrawClipXTrans50 = VideoDraw8to24ClipXTrans50;
+           
+               GraphicSprite8Type.DrawShadowClip = VideoDraw8to24ShadowClip;
+           GraphicSprite8Type.DrawShadowClipX = VideoDraw8to24ShadowClipX;
+            VideoDrawRawClip = VideoDrawRaw24Clip;
+           break;
+
+       case 32:
+           GraphicSprite8Type.Draw = VideoDraw8to32;
+           GraphicSprite8Type.DrawClip = VideoDraw8to32Clip;
+           GraphicSprite8Type.DrawShadowClip = VideoDraw8to32ShadowClip;
+           GraphicSprite8Type.DrawX = VideoDraw8to32X;
+           GraphicSprite8Type.DrawClipX = VideoDraw8to32ClipX;
+       //50% Transparent functions             
+               //GraphicSprite8Type.DrawTrans50 = VideoDraw8to32Trans50;
+           GraphicSprite8Type.DrawClipTrans50 = VideoDraw8to32ClipTrans50;
+           GraphicSprite8Type.DrawXTrans50 = VideoDraw8to32XTrans50;
+           GraphicSprite8Type.DrawClipXTrans50 = VideoDraw8to32ClipXTrans50;
+
+           GraphicSprite8Type.DrawShadowClipX = VideoDraw8to32ShadowClip;
+               GraphicSprite8Type.DrawShadowClipX = VideoDraw8to32ShadowClipX;
+            VideoDrawRawClip = VideoDrawRaw32Clip;
+           break;
+
+       default:
+           DebugLevel0Fn("Unsupported %d bpp\n" _C_ VideoBpp);
+           abort();
+    }
+#endif
+
+    GraphicSprite8Type.Free = FreeSprite8;
+#endif
+}
 
-       case 32:
-           GraphicSprite8Type.Draw = VideoDraw8to32;
-           GraphicSprite8Type.DrawClip = VideoDraw8to32Clip;
-           GraphicSprite8Type.DrawShadowClip = VideoDraw8to32ShadowClip;
-           GraphicSprite8Type.DrawX = VideoDraw8to32X;
-           GraphicSprite8Type.DrawClipX = VideoDraw8to32ClipX;
-           GraphicSprite8Type.DrawShadowClipX = VideoDraw8to32ShadowClipX;
-            VideoDrawRawClip = VideoDrawRaw32Clip;
-           break;
 
-       default:
-           DebugLevel0Fn("Unsupported %d bpp\n" _C_ VideoBpp);
-           abort();
-    }
-#endif
 
-    GraphicSprite8Type.Free = FreeSprite8;
-#endif
-}
 
 //@}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]